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