import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import "core-js/modules/es.error.to-string.js";
import "core-js/modules/es.array.join.js";
import "core-js/modules/es.array.slice.js";
import "core-js/modules/es.date.to-string.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.parse-int.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.regexp.test.js";
import "core-js/modules/es.regexp.to-string.js";
import toUpper from 'lodash/toUpper';
var nameColorPalette = ['#4262FF', '#0081A7', '#F07167', '#6FCFA3', '#758BFD', '#B388EB', '#ACA885', '#70A9A1'];
export var getNameColor = function getNameColor(userName) {
  if (!userName) return nameColorPalette[0];
  var arr = [];
  for (var i = 0; i < userName.length; i++) {
    arr[i] = userName.charCodeAt(i).toString(16).slice(-4);
  }
  var arrSlice = arr.join('').slice(0, 8);
  return nameColorPalette[parseInt(arrSlice, 16) % nameColorPalette.length];
};
export var splitName = function splitName() {
  var userName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var names = userName.split(' ');
  var _names = _slicedToArray(names, 1),
    firstWord = _names[0];
  var lastWord = names[names.length - 1];
  var firstLetter = firstWord.split('')[0];
  var secondLetter = names.length > 1 ? lastWord.split('')[0] : lastWord.length > 1 ? lastWord.split('')[1] : '';
  return filterChineseWord([toUpper(firstLetter), toUpper(secondLetter)]);
};
var filterChineseWord = function filterChineseWord(word) {
  var reg = /[\u4e00-\u9fa5]/;
  if (reg.test(word[1])) {
    return [word[0], ''];
  }
  return word;
};