import { __exports as i } from "./index-LexicalTabIndentationPlugin.prod2.js";
import { __require as _ } from "./index-LexicalComposerContext2.js";
import { __require as f } from "./index-LexicalUtils.js";
import { __require as m } from "./index-Lexical.js";
import d from "react";
var l;
function E() {
  if (l) return i;
  l = 1;
  var u = _(), o = f(), n = m(), c = d;
  function s(r) {
    var e = r.getNodes();
    if (0 < o.$filter(e, (t) => n.$isBlockElementNode(t) && t.canIndent() ? t : null).length) return !0;
    if (e = r.anchor, r = r.focus, r = r.isBefore(e) ? r : e, e = r.getNode(), e = o.$getNearestBlockElementAncestorOrThrow(e), e.canIndent()) {
      e = e.getKey();
      let t = n.$createRangeSelection();
      if (t.anchor.set(e, 0, "element"), t.focus.set(e, 0, "element"), t = n.$normalizeSelection__EXPERIMENTAL(t), t.anchor.is(r)) return !0;
    }
    return !1;
  }
  function a(r) {
    return r.registerCommand(n.KEY_TAB_COMMAND, (e) => {
      let t = n.$getSelection();
      return n.$isRangeSelection(t) ? (e.preventDefault(), e = s(t) ? e.shiftKey ? n.OUTDENT_CONTENT_COMMAND : n.INDENT_CONTENT_COMMAND : n.INSERT_TAB_COMMAND, r.dispatchCommand(e, void 0)) : !1;
    }, n.COMMAND_PRIORITY_EDITOR);
  }
  return i.TabIndentationPlugin = function() {
    let [r] = u.useLexicalComposerContext();
    return c.useEffect(() => a(r)), null;
  }, i.registerTabIndentation = a, i;
}
export {
  E as __require
};
