"use strict";

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

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

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

var highlightHTML = (pattern, content) => {
  var highlightedContent;

  if (!pattern) {
    highlightedContent = content;
  } else {
    try {
      var target = new RegExp("(".concat(pattern, ")"), 'gi');
      var contentArray = content.split(target);
      highlightedContent = contentArray.map((str, index) => {
        if (target.test(str)) {
          return _react.default.createElement("span", {
            key: index,
            className: 'hi'
          }, str);
        }

        return str;
      });
    } catch (e) {
      highlightedContent = content;
    }
  }

  return highlightedContent;
};

exports.highlightHTML = highlightHTML;
//# sourceMappingURL=highlight.js.map