"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.findHighlightedSearch = void 0;
var findHighlightedSearch = exports.findHighlightedSearch = function findHighlightedSearch(searchValue, target) {
  if (searchValue && target) {
    var purifiedTarget = target === null || target === void 0 ? void 0 : target.replace(/<script.*?>.*?<\/script>/gi, "");
    var parser = new DOMParser();
    var doc = parser.parseFromString(purifiedTarget, "text/html");
    var text = doc.body.textContent || "";
    var checkValidSearchChars = searchValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
    var regex = new RegExp("(".concat(checkValidSearchChars, ")"), "gi");
    return text.replace(regex, "<mark>$1</mark>");
  }
  return "";
};
//# sourceMappingURL=findHighlightedSearch.js.map