import { jsx as t } from "react/jsx-runtime";
import d, { useRef as S, useMemo as m } from "react";
import h, { SEARCH_HIGHLIGHT_CLASS as x } from "../../hooks/useSearchHighlight.js";
const H = (r) => r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), w = (r) => {
  const { text: c, query: o, caseSensitive: a = !1, highlightClassName: p = x, classNames: i = "" } = r, n = S(null), e = m(() => o.trim(), [o]), g = m(() => h.supported(), []);
  if (h({ ref: n, query: e, highlightClassName: p, caseSensitive: a }), !g && e) {
    const u = new RegExp(`(${H(e)})`, a ? "g" : "gi"), f = c.split(u);
    return /* @__PURE__ */ t("span", { className: i, children: f.map((s, l) => (a ? s === e : s.toLowerCase() === e.toLowerCase()) ? /* @__PURE__ */ t("mark", { children: s }, l) : /* @__PURE__ */ t(d.Fragment, { children: s }, l)) });
  }
  return /* @__PURE__ */ t("span", { ref: n, className: i, children: c });
};
export {
  w as default
};
//# sourceMappingURL=SearchHighlightText.js.map
