Liferay.Loader.define("commerce-bom-admin-web@4.0.30/js/components/utilities/HighlightedText.es", ['module', 'exports', 'require', 'frontend-js-react-web$react'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = HighlightedText;

    var _react = _interopRequireDefault(require("frontend-js-react-web$react"));

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

    function _slicedToArray(arr, i) {
      return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
    }

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
          _arr.push(_s.value);if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;_e = err;
      } finally {
        try {
          if (!_n && _i["return"] != null) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }return _arr;
    }

    function _arrayWithHoles(arr) {
      if (Array.isArray(arr)) return arr;
    }

    function processQuery(query) {
      var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
      var regex = new RegExp("(.*?)(".concat(query || '', ")(.*)"), 'gmi');
      var results = regex.exec(text);
      return results ? Array(3).fill('').map(function (_, i) {
        return results[i + 1].toString();
      }) : [text, '', ''];
    }

    function HighlightedText(props) {
      var _processQuery = processQuery(props.query, props.text),
          _processQuery2 = _slicedToArray(_processQuery, 3),
          firstPart = _processQuery2[0],
          highlightedPart = _processQuery2[1],
          thirdPart = _processQuery2[2];

      return (/*#__PURE__*/_react.default.createElement("span", {
          className: "autocomplete-item"
        }, props.inverted ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, firstPart, highlightedPart && /*#__PURE__*/_react.default.createElement("strong", null, highlightedPart), thirdPart) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("strong", null, firstPart), highlightedPart, /*#__PURE__*/_react.default.createElement("strong", null, thirdPart)))
      );
    }
    //# sourceMappingURL=HighlightedText.es.js.map
  }
});
//# sourceMappingURL=HighlightedText.es.js.map