const c = (e, n) => {
  const t = n.childNodes[0], s = t.textContent?.toLowerCase();
  if (!s) return [];
  const o = [];
  return [...s.matchAll(e)].forEach((r) => {
    o.push({
      s: r.index,
      e: r.index + r[0].length
    });
  }), o.map((r) => {
    const g = new Range();
    return g.setStart(t, r.s), g.setEnd(t, r.e), g;
  });
}, h = (e, n, t, s) => CSS.highlights.set(`${e}-${s}`, new Highlight(...c(n.regex, t))), a = (e, n, t) => `::highlight(${e}-${t}) { color: var(${n.css}); }`, i = (e, n, t) => Object.entries(e).map(([s, o]) => ({
  apply: () => h(s, o, n, t),
  css: a(s, o, t)
}));
export {
  i as n
};
