"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _openData = require("../../utils/open-data");

var _react = _interopRequireDefault(require("react"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var SearchKeyHandle = function SearchKeyHandle(_ref) {
  var _ref$str = _ref.str,
      str = _ref$str === void 0 ? '' : _ref$str,
      _ref$keyWord = _ref.keyWord,
      keyWord = _ref$keyWord === void 0 ? '' : _ref$keyWord,
      _ref$color = _ref.color,
      color = _ref$color === void 0 ? '#F05E5E' : _ref$color;
  if (!str || !keyWord) return /*#__PURE__*/_react["default"].createElement("span", null, (0, _openData.parseString)(str));
  var result = str.split(keyWord);
  return /*#__PURE__*/_react["default"].createElement("span", null, result.map(function (item, index) {
    if (index !== result.length - 1) {
      return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (0, _openData.parseString)(item), /*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: color
        }
      }, (0, _openData.parseString)(keyWord)));
    }

    return (0, _openData.parseString)(item);
  }));
};

SearchKeyHandle.defaultProps = {
  str: '',
  keyWord: '',
  color: ''
};
var _default = SearchKeyHandle;
exports["default"] = _default;