import { __exports as i } from "./index-LexicalHorizontalRuleNode.dev2.js";
import { __require as L } from "./index-LexicalComposerContext2.js";
import { __require as M } from "./index-useLexicalNodeSelection.js";
import { __require as x } from "./index-LexicalUtils.js";
import { __require as D } from "./index-Lexical.js";
import A from "react";
var d;
function T() {
  if (d) return i;
  d = 1;
  var R = L(), f = M(), O = x(), e = D(), a = A;
  const C = e.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");
  function p({
    nodeKey: t
  }) {
    const [r] = R.useLexicalComposerContext(), [n, _, N] = f.useLexicalNodeSelection(t), s = a.useCallback((o) => {
      if (n && e.$isNodeSelection(e.$getSelection())) {
        o.preventDefault();
        const u = e.$getNodeByKey(t);
        m(u) && u.remove();
      }
      return !1;
    }, [n, t]);
    return a.useEffect(() => O.mergeRegister(r.registerCommand(e.CLICK_COMMAND, (o) => {
      const u = r.getElementByKey(t);
      return o.target === u ? (o.shiftKey || N(), _(!n), !0) : !1;
    }, e.COMMAND_PRIORITY_LOW), r.registerCommand(e.KEY_DELETE_COMMAND, s, e.COMMAND_PRIORITY_LOW), r.registerCommand(e.KEY_BACKSPACE_COMMAND, s, e.COMMAND_PRIORITY_LOW)), [N, r, n, t, s, _]), a.useEffect(() => {
      const o = r.getElementByKey(t);
      o !== null && (o.className = n ? "selected" : "");
    }, [r, n, t]), null;
  }
  class l extends e.DecoratorNode {
    static getType() {
      return "horizontalrule";
    }
    static clone(r) {
      return new l(r.__key);
    }
    static importJSON(r) {
      return c();
    }
    static importDOM() {
      return {
        hr: () => ({
          conversion: E,
          priority: 0
        })
      };
    }
    exportJSON() {
      return {
        type: "horizontalrule",
        version: 1
      };
    }
    exportDOM() {
      return {
        element: document.createElement("hr")
      };
    }
    createDOM() {
      return document.createElement("hr");
    }
    getTextContent() {
      return `
`;
    }
    isInline() {
      return !1;
    }
    updateDOM() {
      return !1;
    }
    decorate() {
      return /* @__PURE__ */ a.createElement(p, {
        nodeKey: this.__key
      });
    }
  }
  function E() {
    return {
      node: c()
    };
  }
  function c() {
    return e.$applyNodeReplacement(new l());
  }
  function m(t) {
    return t instanceof l;
  }
  return i.$createHorizontalRuleNode = c, i.$isHorizontalRuleNode = m, i.HorizontalRuleNode = l, i.INSERT_HORIZONTAL_RULE_COMMAND = C, i;
}
export {
  T as __require
};
