import { __exports as r } from "./index-_virtual29.js";
import { __require as p } from "./index-LexicalComposerContext2.js";
import { __require as h } from "./index-useLexicalTextEntity.js";
import P from "react";
import { __require as q } from "./index-KeywordNode.js";
var f;
function T() {
  if (f) return r;
  f = 1, Object.defineProperty(r, "__esModule", { value: !0 }), r.KeywordPlugin = void 0;
  const x = p(), y = h(), o = P, n = q();
  function g(i) {
    const e = i.join("|");
    return new RegExp(`(\\b|^|$)(${e})(\\b|^|$)`, "igu");
  }
  function w(i) {
    const { regex: e, phrases: s } = i, [d] = (0, x.useLexicalComposerContext)();
    (0, o.useEffect)(() => {
      if (!d.hasNodes([n.KeywordNode]))
        throw new Error("KeywordsPlugin: KeywordNode not registered on editor");
    }, [d]);
    const _ = (0, o.useCallback)((u) => (0, n.$createKeywordNode)(u.getTextContent()), []), m = (0, o.useCallback)((u) => {
      const a = (c) => {
        const t = c.exec(u);
        if (t === null)
          return null;
        const K = t[2].length, l = t.index + t[1].length;
        return {
          end: l + K,
          start: l
        };
      };
      if (e)
        return a(e);
      if (s) {
        const c = g(s);
        return a(c);
      }
      return null;
    }, [e, s]);
    return (0, y.useLexicalTextEntity)(m, n.KeywordNode, _), null;
  }
  return r.KeywordPlugin = w, r;
}
export {
  T as __require
};
