import { __exports as s } from "./index-useLexicalNodeSelection.dev2.js";
import { __require as _ } from "./index-LexicalComposerContext2.js";
import { __require as p } from "./index-Lexical.js";
import m from "react";
var a;
function q() {
  if (a) return s;
  a = 1;
  var d = _(), t = p(), c = m;
  function n(o, e) {
    return o.getEditorState().read(() => {
      const l = t.$getNodeByKey(e);
      return l === null ? !1 : l.isSelected();
    });
  }
  function u(o) {
    const [e] = d.useLexicalComposerContext(), [l, S] = c.useState(() => n(e, o));
    c.useEffect(() => {
      let r = !0;
      const i = e.registerUpdateListener(() => {
        r && S(n(e, o));
      });
      return () => {
        r = !1, i();
      };
    }, [e, o]);
    const f = c.useCallback((r) => {
      e.update(() => {
        let i = t.$getSelection();
        t.$isNodeSelection(i) || (i = t.$createNodeSelection(), t.$setSelection(i)), t.$isNodeSelection(i) && (r ? i.add(o) : i.delete(o));
      });
    }, [e, o]), x = c.useCallback(() => {
      e.update(() => {
        const r = t.$getSelection();
        t.$isNodeSelection(r) && r.clear();
      });
    }, [e]);
    return [l, f, x];
  }
  return s.useLexicalNodeSelection = u, s;
}
export {
  q as __require
};
