"use client";
import { removeClassNamesFromElement as ee, addClassNamesToElement as te, mergeRegister as re, $findMatchingParent as ne, $getNearestNodeOfType as ue, calculateZoomLevel as ge } from "../utils/LexicalUtils.prod.js";
import { ElementNode as se, isHTMLElement as S, $createTextNode as de, $isElementNode as v, $createParagraphNode as M, $isParagraphNode as he, $isRangeSelection as L, $applyNodeReplacement as ie, createCommand as D, TextNode as fe, $isTextNode as pe, $getSelection as P, INSERT_PARAGRAPH_COMMAND as me, COMMAND_PRIORITY_LOW as C, KEY_ARROW_LEFT_COMMAND as _e, KEY_SPACE_COMMAND as Ce, $getNearestNodeFromDOMNode as W, KEY_ESCAPE_COMMAND as ye, KEY_ARROW_UP_COMMAND as Te, KEY_ARROW_DOWN_COMMAND as Ne, $isRootOrShadowRoot as A, $isLeafNode as oe, $setPointFromCaret as B, $normalizeCaret as U, $getChildCaret as V, getNearestEditorFromDOMNode as Se } from "../../lexical/Lexical.prod.js";
import { getStyleObjectFromCSS as z } from "../selection/LexicalSelection.prod.js";
function y(n, ...e) {
  const t = new URL("https://lexical.dev/docs/error"), r = new URLSearchParams();
  r.append("code", n);
  for (const s of e) r.append("v", s);
  throw t.search = r.toString(), Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
}
function R(n) {
  let e = 1, t = n.getParent();
  for (; t != null; ) {
    if (g(t)) {
      const r = t.getParent();
      if (u(r)) {
        e++, t = r.getParent();
        continue;
      }
      y(40);
    }
    return e;
  }
  return e;
}
function w(n) {
  let e = n.getParent();
  u(e) || y(40);
  let t = e;
  for (; t !== null; ) t = t.getParent(), u(t) && (e = t);
  return e;
}
function le(n) {
  let e = [];
  const t = n.getChildren().filter(g);
  for (let r = 0; r < t.length; r++) {
    const s = t[r], i = s.getFirstChild();
    u(i) ? e = e.concat(le(i)) : e.push(s);
  }
  return e;
}
function T(n) {
  return g(n) && u(n.getFirstChild());
}
function Y(n) {
  return m().append(n);
}
function ae(n, e) {
  return g(n) && (e.length === 0 || e.length === 1 && n.is(e[0]) && n.getChildrenSize() === 0);
}
function $(n) {
  const e = P();
  if (e !== null) {
    let t = e.getNodes();
    if (L(e)) {
      const s = e.getStartEndPoints();
      s === null && y(143);
      const [i] = s, o = i.getNode(), a = o.getParent();
      if (A(o)) {
        const l = o.getFirstChild();
        if (l) t = l.selectStart().getNodes();
        else {
          const c = M();
          o.append(c), t = c.select().getNodes();
        }
      } else if (ae(o, t)) {
        const l = p(n);
        if (A(a)) {
          o.replace(l);
          const c = m();
          v(o) && (c.setFormat(o.getFormatType()), c.setIndent(o.getIndent())), l.append(c);
        } else if (g(o)) {
          const c = o.getParentOrThrow();
          N(l, c.getChildren()), c.replace(l);
        }
        return;
      }
    }
    const r = /* @__PURE__ */ new Set();
    for (let s = 0; s < t.length; s++) {
      const i = t[s];
      if (v(i) && i.isEmpty() && !g(i) && !r.has(i.getKey())) {
        H(i, n);
        continue;
      }
      let o = oe(i) ? i.getParent() : g(i) && i.isEmpty() ? i : null;
      for (; o != null; ) {
        const a = o.getKey();
        if (u(o)) {
          if (!r.has(a)) {
            const l = p(n);
            N(l, o.getChildren()), o.replace(l), r.add(a);
          }
          break;
        }
        {
          const l = o.getParent();
          if (A(l) && !r.has(a)) {
            r.add(a), H(o, n);
            break;
          }
          o = l;
        }
      }
    }
  }
}
function N(n, e) {
  n.splice(n.getChildrenSize(), 0, e);
}
function H(n, e) {
  if (u(n)) return n;
  const t = n.getPreviousSibling(), r = n.getNextSibling(), s = m();
  let i;
  if (N(s, n.getChildren()), u(t) && e === t.getListType()) t.append(s), u(r) && e === r.getListType() && (N(t, r.getChildren()), r.remove()), i = t;
  else if (u(r) && e === r.getListType()) r.getFirstChildOrThrow().insertBefore(s), i = r;
  else {
    const o = p(e);
    o.append(s), n.replace(o), i = o;
  }
  return s.setFormat(n.getFormatType()), s.setIndent(n.getIndent()), n.remove(), i;
}
function J(n, e) {
  const t = n.getLastChild(), r = e.getFirstChild();
  t && r && T(t) && T(r) && (J(t.getFirstChild(), r.getFirstChild()), r.remove());
  const s = e.getChildren();
  s.length > 0 && n.append(...s), e.remove();
}
function ve() {
  const n = P();
  if (L(n)) {
    const e = /* @__PURE__ */ new Set(), t = n.getNodes(), r = n.anchor.getNode();
    if (ae(r, t)) e.add(w(r));
    else for (let s = 0; s < t.length; s++) {
      const i = t[s];
      if (oe(i)) {
        const o = ue(i, O);
        o != null && e.add(w(o));
      }
    }
    for (const s of e) {
      let i = s;
      const o = le(s);
      for (const a of o) {
        const l = M().setTextStyle(n.style).setTextFormat(n.format);
        N(l, a.getChildren()), i.insertAfter(l), i = l, a.__key === n.anchor.key && B(n.anchor, U(V(l, "next"))), a.__key === n.focus.key && B(n.focus, U(V(l, "next"))), a.remove();
      }
      s.remove();
    }
  }
}
function Le(n) {
  const e = /* @__PURE__ */ new Set();
  if (T(n) || e.has(n.getKey())) return;
  const t = n.getParent(), r = n.getNextSibling(), s = n.getPreviousSibling();
  if (T(r) && T(s)) {
    const i = s.getFirstChild();
    if (u(i)) {
      i.append(n);
      const o = r.getFirstChild();
      u(o) && (N(i, o.getChildren()), r.remove(), e.add(r.getKey()));
    }
  } else if (T(r)) {
    const i = r.getFirstChild();
    if (u(i)) {
      const o = i.getFirstChild();
      o !== null && o.insertBefore(n);
    }
  } else if (T(s)) {
    const i = s.getFirstChild();
    u(i) && i.append(n);
  } else if (u(t)) {
    const i = m().setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle()), o = p(t.getListType()).setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle());
    i.append(o), o.append(n), s ? s.insertAfter(i) : r ? r.insertBefore(i) : t.append(i);
  }
}
function Oe(n) {
  if (T(n)) return;
  const e = n.getParent(), t = e ? e.getParent() : void 0;
  if (u(t ? t.getParent() : void 0) && g(t) && u(e)) {
    const r = e ? e.getFirstChild() : void 0, s = e ? e.getLastChild() : void 0;
    if (n.is(r)) t.insertBefore(n), e.isEmpty() && t.remove();
    else if (n.is(s)) t.insertAfter(n), e.isEmpty() && t.remove();
    else {
      const i = e.getListType(), o = m(), a = p(i);
      o.append(a), n.getPreviousSiblings().forEach(((d) => a.append(d)));
      const l = m(), c = p(i);
      l.append(c), N(c, n.getNextSiblings()), t.insertBefore(o), t.insertAfter(l), t.replace(n);
    }
  }
}
function xe() {
  const n = P();
  if (!L(n) || !n.isCollapsed()) return !1;
  const e = n.anchor.getNode();
  if (!g(e) || e.getChildrenSize() !== 0) return !1;
  const t = w(e), r = e.getParent();
  u(r) || y(40);
  const s = r.getParent();
  let i;
  if (A(s)) i = M(), t.insertAfter(i);
  else {
    if (!g(s)) return !1;
    i = m(), s.insertAfter(i);
  }
  i.setTextStyle(n.style).setTextFormat(n.format).select();
  const o = e.getNextSiblings();
  if (o.length > 0) {
    const a = p(r.getListType());
    if (g(i)) {
      const l = m();
      l.append(a), i.insertAfter(l);
    } else i.insertAfter(a);
    a.append(...o);
  }
  return (function(a) {
    let l = a;
    for (; l.getNextSibling() == null && l.getPreviousSibling() == null; ) {
      const c = l.getParent();
      if (c == null || !g(c) && !u(c)) break;
      l = c;
    }
    l.remove();
  })(e), !0;
}
function F(...n) {
  const e = [];
  for (const t of n) if (t && typeof t == "string") for (const [r] of t.matchAll(/\S+/g)) e.push(r);
  return e;
}
class O extends se {
  static getType() {
    return "listitem";
  }
  static clone(e) {
    return new O(e.__value, e.__checked, e.__key);
  }
  constructor(e, t, r) {
    super(r), this.__value = e === void 0 ? 1 : e, this.__checked = t;
  }
  createDOM(e) {
    const t = document.createElement("li");
    return this.updateListItemDOM(null, t, e), t;
  }
  updateListItemDOM(e, t, r) {
    const s = this.getParent();
    u(s) && s.getListType() === "check" && (function(a, l, c, d) {
      u(l.getFirstChild()) ? (a.removeAttribute("role"), a.removeAttribute("tabIndex"), a.removeAttribute("aria-checked")) : (a.setAttribute("role", "checkbox"), a.setAttribute("tabIndex", "-1"), c && l.__checked === c.__checked || a.setAttribute("aria-checked", l.getChecked() ? "true" : "false"));
    })(t, this, e), t.value = this.__value, (function(a, l, c) {
      const d = [], h = [], f = l.list, x = f ? f.listitem : void 0;
      let _;
      if (f && f.nested && (_ = f.nested.listitem), x !== void 0 && d.push(...F(x)), f) {
        const k = c.getParent(), b = u(k) && k.getListType() === "check", I = c.getChecked();
        b && !I || h.push(f.listitemUnchecked), b && I || h.push(f.listitemChecked), b && d.push(I ? f.listitemChecked : f.listitemUnchecked);
      }
      if (_ !== void 0) {
        const k = F(_);
        c.getChildren().some(((b) => u(b))) ? d.push(...k) : h.push(...k);
      }
      h.length > 0 && ee(a, ...h), d.length > 0 && te(a, ...d);
    })(t, r.theme, this);
    const i = e ? e.__style : "", o = this.__style;
    i !== o && (o === "" ? t.removeAttribute("style") : t.style.cssText = o), (function(a, l, c) {
      const d = z(l.__textStyle);
      for (const h in d) a.style.setProperty(`--listitem-marker-${h}`, d[h]);
      if (c) for (const h in z(c.__textStyle)) h in d || a.style.removeProperty(`--listitem-marker-${h}`);
    })(t, this, e);
  }
  updateDOM(e, t, r) {
    const s = t;
    return this.updateListItemDOM(e, s, r), !1;
  }
  static transform() {
    return (e) => {
      if (g(e) || y(144), e.__checked == null) return;
      const t = e.getParent();
      u(t) && t.getListType() !== "check" && e.getChecked() != null && e.setChecked(void 0);
    };
  }
  static importDOM() {
    return { li: () => ({ conversion: ke, priority: 0 }) };
  }
  static importJSON(e) {
    return m().updateFromJSON(e);
  }
  updateFromJSON(e) {
    return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked);
  }
  exportDOM(e) {
    const t = this.createDOM(e._config), r = this.getFormatType();
    r && (t.style.textAlign = r);
    const s = this.getDirection();
    return s && (t.dir = s), { element: t };
  }
  exportJSON() {
    return { ...super.exportJSON(), checked: this.getChecked(), value: this.getValue() };
  }
  append(...e) {
    for (let t = 0; t < e.length; t++) {
      const r = e[t];
      if (v(r) && this.canMergeWith(r)) {
        const s = r.getChildren();
        this.append(...s), r.remove();
      } else super.append(r);
    }
    return this;
  }
  replace(e, t) {
    if (g(e)) return super.replace(e);
    this.setIndent(0);
    const r = this.getParentOrThrow();
    if (!u(r)) return e;
    if (r.__first === this.getKey()) r.insertBefore(e);
    else if (r.__last === this.getKey()) r.insertAfter(e);
    else {
      const s = p(r.getListType());
      let i = this.getNextSibling();
      for (; i; ) {
        const o = i;
        i = i.getNextSibling(), s.append(o);
      }
      r.insertAfter(e), e.insertAfter(s);
    }
    return t && (v(e) || y(139), this.getChildren().forEach(((s) => {
      e.append(s);
    }))), this.remove(), r.getChildrenSize() === 0 && r.remove(), e;
  }
  insertAfter(e, t = !0) {
    const r = this.getParentOrThrow();
    if (u(r) || y(39), g(e)) return super.insertAfter(e, t);
    const s = this.getNextSiblings();
    if (r.insertAfter(e, t), s.length !== 0) {
      const i = p(r.getListType());
      s.forEach(((o) => i.append(o))), e.insertAfter(i, t);
    }
    return e;
  }
  remove(e) {
    const t = this.getPreviousSibling(), r = this.getNextSibling();
    super.remove(e), t && r && T(t) && T(r) && (J(t.getFirstChild(), r.getFirstChild()), r.remove());
  }
  insertNewAfter(e, t = !0) {
    const r = m().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked() && void 0);
    return this.insertAfter(r, t), r;
  }
  collapseAtStart(e) {
    const t = M();
    this.getChildren().forEach(((o) => t.append(o)));
    const r = this.getParentOrThrow(), s = r.getParentOrThrow(), i = g(s);
    if (r.getChildrenSize() === 1) if (i) r.remove(), s.select();
    else {
      r.insertBefore(t), r.remove();
      const o = e.anchor, a = e.focus, l = t.getKey();
      o.type === "element" && o.getNode().is(this) && o.set(l, o.offset, "element"), a.type === "element" && a.getNode().is(this) && a.set(l, a.offset, "element");
    }
    else r.insertBefore(t), this.remove();
    return !0;
  }
  getValue() {
    return this.getLatest().__value;
  }
  setValue(e) {
    const t = this.getWritable();
    return t.__value = e, t;
  }
  getChecked() {
    const e = this.getLatest();
    let t;
    const r = this.getParent();
    return u(r) && (t = r.getListType()), t === "check" ? !!e.__checked : void 0;
  }
  setChecked(e) {
    const t = this.getWritable();
    return t.__checked = e, t;
  }
  toggleChecked() {
    const e = this.getWritable();
    return e.setChecked(!e.__checked);
  }
  getIndent() {
    const e = this.getParent();
    if (e === null || !this.isAttached()) return this.getLatest().__indent;
    let t = e.getParentOrThrow(), r = 0;
    for (; g(t); ) t = t.getParentOrThrow().getParentOrThrow(), r++;
    return r;
  }
  setIndent(e) {
    typeof e != "number" && y(117), (e = Math.floor(e)) >= 0 || y(199);
    let t = this.getIndent();
    for (; t !== e; ) t < e ? (Le(this), t++) : (Oe(this), t--);
    return this;
  }
  canInsertAfter(e) {
    return g(e);
  }
  canReplaceWith(e) {
    return g(e);
  }
  canMergeWith(e) {
    return g(e) || he(e);
  }
  extractWithChild(e, t) {
    if (!L(t)) return !1;
    const r = t.anchor.getNode(), s = t.focus.getNode();
    return this.isParentOf(r) && this.isParentOf(s) && this.getTextContent().length === t.getTextContent().length;
  }
  isParentRequired() {
    return !0;
  }
  createParentElementNode() {
    return p("bullet");
  }
  canMergeWhenEmpty() {
    return !0;
  }
}
function ke(n) {
  if (n.classList.contains("task-list-item")) {
    for (const t of n.children) if (t.tagName === "INPUT") return be(t);
  }
  const e = n.getAttribute("aria-checked");
  return { node: m(e === "true" || e !== "false" && void 0) };
}
function be(n) {
  return n.getAttribute("type") !== "checkbox" ? { node: null } : { node: m(n.hasAttribute("checked")) };
}
function m(n) {
  return ie(new O(void 0, n));
}
function g(n) {
  return n instanceof O;
}
class E extends se {
  static getType() {
    return "list";
  }
  static clone(e) {
    const t = e.__listType || j[e.__tag];
    return new E(t, e.__start, e.__key);
  }
  constructor(e = "number", t = 1, r) {
    super(r);
    const s = j[e] || e;
    this.__listType = s, this.__tag = s === "number" ? "ol" : "ul", this.__start = t;
  }
  getTag() {
    return this.__tag;
  }
  setListType(e) {
    const t = this.getWritable();
    return t.__listType = e, t.__tag = e === "number" ? "ol" : "ul", t;
  }
  getListType() {
    return this.__listType;
  }
  getStart() {
    return this.__start;
  }
  setStart(e) {
    const t = this.getWritable();
    return t.__start = e, t;
  }
  createDOM(e, t) {
    const r = this.__tag, s = document.createElement(r);
    return this.__start !== 1 && s.setAttribute("start", String(this.__start)), s.__lexicalListType = this.__listType, G(s, e.theme, this), s;
  }
  updateDOM(e, t, r) {
    return e.__tag !== this.__tag || (G(t, r.theme, this), !1);
  }
  static transform() {
    return (e) => {
      u(e) || y(163), (function(t) {
        const r = t.getNextSibling();
        u(r) && t.getListType() === r.getListType() && J(t, r);
      })(e), (function(t) {
        const r = t.getListType() !== "check";
        let s = t.getStart();
        for (const i of t.getChildren()) g(i) && (i.getValue() !== s && i.setValue(s), r && i.getLatest().__checked != null && i.setChecked(void 0), u(i.getFirstChild()) || s++);
      })(e);
    };
  }
  static importDOM() {
    return { ol: () => ({ conversion: X, priority: 0 }), ul: () => ({ conversion: X, priority: 0 }) };
  }
  static importJSON(e) {
    return p().updateFromJSON(e);
  }
  updateFromJSON(e) {
    return super.updateFromJSON(e).setListType(e.listType).setStart(e.start);
  }
  exportDOM(e) {
    const t = this.createDOM(e._config, e);
    return S(t) && (this.__start !== 1 && t.setAttribute("start", String(this.__start)), this.__listType === "check" && t.setAttribute("__lexicalListType", "check")), { element: t };
  }
  exportJSON() {
    return { ...super.exportJSON(), listType: this.getListType(), start: this.getStart(), tag: this.getTag() };
  }
  canBeEmpty() {
    return !1;
  }
  canIndent() {
    return !1;
  }
  splice(e, t, r) {
    let s = r;
    for (let i = 0; i < r.length; i++) {
      const o = r[i];
      g(o) || (s === r && (s = [...r]), s[i] = m().append(!v(o) || u(o) || o.isInline() ? o : de(o.getTextContent())));
    }
    return super.splice(e, t, s);
  }
  extractWithChild(e) {
    return g(e);
  }
}
function G(n, e, t) {
  const r = [], s = [], i = e.list;
  if (i !== void 0) {
    const o = i[`${t.__tag}Depth`] || [], a = R(t) - 1, l = a % o.length, c = o[l], d = i[t.__tag];
    let h;
    const f = i.nested, x = i.checklist;
    if (f !== void 0 && f.list && (h = f.list), d !== void 0 && r.push(d), x !== void 0 && t.__listType === "check" && r.push(x), c !== void 0) {
      r.push(...F(c));
      for (let _ = 0; _ < o.length; _++) _ !== l && s.push(t.__tag + _);
    }
    if (h !== void 0) {
      const _ = F(h);
      a > 1 ? r.push(..._) : s.push(..._);
    }
  }
  s.length > 0 && ee(n, ...s), r.length > 0 && te(n, ...r);
}
function Pe(n) {
  const e = [];
  for (let t = 0; t < n.length; t++) {
    const r = n[t];
    if (g(r)) {
      e.push(r);
      const s = r.getChildren();
      s.length > 1 && s.forEach(((i) => {
        u(i) && e.push(Y(i));
      }));
    } else e.push(Y(r));
  }
  return e;
}
function X(n) {
  const e = n.nodeName.toLowerCase();
  let t = null;
  return e === "ol" ? t = p("number", n.start) : e === "ul" && (t = (function(r) {
    if (r.getAttribute("__lexicallisttype") === "check" || r.classList.contains("contains-task-list")) return !0;
    for (const s of r.childNodes) if (S(s) && s.hasAttribute("aria-checked")) return !0;
    return !1;
  })(n) ? p("check") : p("bullet")), { after: Pe, node: t };
}
const j = { ol: "number", ul: "bullet" };
function p(n = "number", e = 1) {
  return ie(new E(n, e));
}
function u(n) {
  return n instanceof E;
}
const Ee = D("INSERT_CHECK_LIST_COMMAND");
function we(n) {
  return re(n.registerCommand(Ee, (() => ($("check"), !0)), C), n.registerCommand(Ne, ((e) => Z(e, n, !1)), C), n.registerCommand(Te, ((e) => Z(e, n, !0)), C), n.registerCommand(ye, (() => {
    if (K() != null) {
      const e = n.getRootElement();
      return e?.focus(), !0;
    }
    return !1;
  }), C), n.registerCommand(Ce, ((e) => {
    const t = K();
    return !(t == null || !n.isEditable()) && (n.update((() => {
      const r = W(t);
      g(r) && (e.preventDefault(), r.toggleChecked());
    })), !0);
  }), C), n.registerCommand(_e, ((e) => n.getEditorState().read((() => {
    const t = P();
    if (L(t) && t.isCollapsed()) {
      const { anchor: r } = t, s = r.type === "element";
      if (s || r.offset === 0) {
        const i = r.getNode(), o = ne(i, ((a) => v(a) && !a.isInline()));
        if (g(o)) {
          const a = o.getParent();
          if (u(a) && a.getListType() === "check" && (s || o.getFirstDescendant() === i)) {
            const l = n.getElementByKey(o.__key);
            if (l != null && document.activeElement !== l) return l.focus(), e.preventDefault(), !0;
          }
        }
      }
    }
    return !1;
  }))), C), n.registerRootListener(((e, t) => {
    e !== null && (e.addEventListener("click", q), e.addEventListener("pointerdown", Q)), t !== null && (t.removeEventListener("click", q), t.removeEventListener("pointerdown", Q));
  })));
}
function ce(n, e) {
  const t = n.target;
  if (!S(t)) return;
  const r = t.firstChild;
  if (S(r) && (r.tagName === "UL" || r.tagName === "OL")) return;
  const s = t.parentNode;
  if (!s || s.__lexicalListType !== "check") return;
  const i = t.getBoundingClientRect(), o = n.pageX / ge(t), a = window.getComputedStyle ? window.getComputedStyle(t, "::before") : { width: "0px" }, l = parseFloat(a.width);
  (t.dir === "rtl" ? o < i.right && o > i.right - l : o > i.left && o < i.left + l) && e();
}
function q(n) {
  ce(n, (() => {
    if (S(n.target)) {
      const e = n.target, t = Se(e);
      t != null && t.isEditable() && t.update((() => {
        const r = W(e);
        g(r) && (e.focus(), r.toggleChecked());
      }));
    }
  }));
}
function Q(n) {
  ce(n, (() => {
    n.preventDefault();
  }));
}
function K() {
  const n = document.activeElement;
  return S(n) && n.tagName === "LI" && n.parentNode != null && n.parentNode.__lexicalListType === "check" ? n : null;
}
function Z(n, e, t) {
  const r = K();
  return r != null && e.update((() => {
    const s = W(r);
    if (!g(s)) return;
    const i = (function(o, a) {
      let l = a ? o.getPreviousSibling() : o.getNextSibling(), c = o;
      for (; l == null && g(c); ) c = c.getParentOrThrow().getParent(), c != null && (l = a ? c.getPreviousSibling() : c.getNextSibling());
      for (; g(l); ) {
        const d = a ? l.getLastChild() : l.getFirstChild();
        if (!u(d)) return l;
        l = a ? d.getLastChild() : d.getFirstChild();
      }
      return null;
    })(s, t);
    if (i != null) {
      i.selectStart();
      const o = e.getElementByKey(i.__key);
      o != null && (n.preventDefault(), setTimeout((() => {
        o.focus();
      }), 0));
    }
  })), !1;
}
const Ae = D("INSERT_UNORDERED_LIST_COMMAND"), Fe = D("INSERT_ORDERED_LIST_COMMAND"), Me = D("REMOVE_LIST_COMMAND");
function $e(n) {
  return re(n.registerCommand(Fe, (() => ($("number"), !0)), C), n.registerCommand(Ae, (() => ($("bullet"), !0)), C), n.registerCommand(Me, (() => (ve(), !0)), C), n.registerCommand(me, (() => xe()), C), n.registerNodeTransform(O, ((e) => {
    const t = e.getFirstChild();
    if (t) {
      if (pe(t)) {
        const r = t.getStyle(), s = t.getFormat();
        e.getTextStyle() !== r && e.setTextStyle(r), e.getTextFormat() !== s && e.setTextFormat(s);
      }
    } else {
      const r = P();
      L(r) && (r.style !== e.getTextStyle() || r.format !== e.getTextFormat()) && r.isCollapsed() && e.is(r.anchor.getNode()) && e.setTextStyle(r.style).setTextFormat(r.format);
    }
  })), n.registerNodeTransform(fe, ((e) => {
    const t = e.getParent();
    if (g(t) && e.is(t.getFirstChild())) {
      const r = e.getStyle(), s = e.getFormat();
      r === t.getTextStyle() && s === t.getTextFormat() || t.setTextStyle(r).setTextFormat(s);
    }
  })));
}
function Ke(n) {
  const e = (t) => {
    const r = t.getParent();
    if (u(t.getFirstChild()) || !u(r)) return;
    const s = ne(t, ((i) => g(i) && u(i.getParent()) && g(i.getPreviousSibling())));
    if (s === null && t.getIndent() > 0) t.setIndent(0);
    else if (g(s)) {
      const i = s.getPreviousSibling();
      if (g(i)) {
        const o = (function(l) {
          let c = l, d = c.getFirstChild();
          for (; u(d); ) {
            const h = d.getLastChild();
            if (!g(h)) break;
            c = h, d = c.getFirstChild();
          }
          return c;
        })(i), a = o.getParent();
        if (u(a)) {
          const l = R(a);
          l + 1 < R(r) && t.setIndent(l);
        }
      }
    }
  };
  return n.registerNodeTransform(E, ((t) => {
    const r = [t];
    for (; r.length > 0; ) {
      const s = r.shift();
      if (u(s)) {
        for (const i of s.getChildren()) if (g(i)) {
          e(i);
          const o = i.getFirstChild();
          u(o) && r.push(o);
        }
      }
    }
  }));
}
export {
  m as $createListItemNode,
  p as $createListNode,
  R as $getListDepth,
  xe as $handleListInsertParagraph,
  $ as $insertList,
  g as $isListItemNode,
  u as $isListNode,
  ve as $removeList,
  Ee as INSERT_CHECK_LIST_COMMAND,
  Fe as INSERT_ORDERED_LIST_COMMAND,
  Ae as INSERT_UNORDERED_LIST_COMMAND,
  O as ListItemNode,
  E as ListNode,
  Me as REMOVE_LIST_COMMAND,
  we as registerCheckList,
  $e as registerList,
  Ke as registerListStrictIndentTransform
};
