import { defineComponent as v, computed as c, openBlock as n, createElementBlock as o, normalizeClass as p, unref as i, Fragment as u, renderList as C, renderSlot as d, createTextVNode as m, toDisplayString as y } from "vue";
import "../config-provider/index.mjs";
import S from "./style/index.mjs";
import { useNamespace as $ } from "../config-provider/hooks/use-namespace.mjs";
const B = { key: 1 }, N = /* @__PURE__ */ v({
  name: "Highlight",
  __name: "index",
  props: {
    content: {},
    keywords: {},
    ignoreCase: { type: Boolean }
  },
  setup(g) {
    const s = g, { b: h, e: k } = $("highlight"), f = S("highlight"), l = c(() => {
      const e = s.keywords;
      if (!e)
        return null;
      let t = Array.isArray(e) ? e : [e];
      return t = t.sort((r, a) => a.length - r.length), new RegExp(
        `(${t.join("|")})`,
        `${s.ignoreCase ? "i" : ""}g`
      );
    }), w = c(() => {
      const e = s.content;
      return !l.value || !e ? [{ keywords: !1, text: e }] : e.split(l.value).map((t) => ({ keywords: l.value.test(t), text: t }));
    });
    return (e, t) => (n(), o("div", {
      class: p([i(h)(), i(f)])
    }, [
      (n(!0), o(u, null, C(w.value, ({ text: r, keywords: a }, _) => (n(), o(u, { key: _ }, [
        a ? (n(), o("span", {
          key: 0,
          class: p(i(k)("keywords"))
        }, [
          d(e.$slots, "keywords", { text: r }, () => [
            m(y(r), 1)
          ])
        ], 2)) : (n(), o("span", B, [
          d(e.$slots, "default", { text: r }, () => [
            m(y(r), 1)
          ])
        ]))
      ], 64))), 128))
    ], 2));
  }
});
export {
  N as default
};
