"use client";
import { $findMatchingParent as M, addClassNamesToElement as b, removeClassNamesFromElement as A, $descendantsMatching as V } from "../utils/LexicalUtils.prod.js";
import { $createPoint as K, $isParagraphNode as ot, $isElementNode as X, $normalizeSelection__EXPERIMENTAL as rt, isCurrentlyReadOnlyMode as nt, TEXT_TYPE_TO_FORMAT as lt, ElementNode as k, isHTMLElement as T, $isInlineElementOrDecoratorNode as st, $isTextNode as L, $isLineBreakNode as H, $createParagraphNode as P, $applyNodeReplacement as W, setDOMUnmanaged as it, $getEditor as at, $getNearestNodeFromDOMNode as Y } from "../../lexical/Lexical.prod.js";
const E = /^(\d+(?:\.\d+)?)px$/, y = { BOTH: 3, NO_STATUS: 0, ROW: 1 };
class R extends k {
  static getType() {
    return "tablecell";
  }
  static clone(t) {
    return new R(t.__headerState, t.__colSpan, t.__width, t.__key);
  }
  afterCloneFrom(t) {
    super.afterCloneFrom(t), this.__rowSpan = t.__rowSpan, this.__backgroundColor = t.__backgroundColor, this.__verticalAlign = t.__verticalAlign;
  }
  static importDOM() {
    return { td: (t) => ({ conversion: I, priority: 0 }), th: (t) => ({ conversion: I, priority: 0 }) };
  }
  static importJSON(t) {
    return j().updateFromJSON(t);
  }
  updateFromJSON(t) {
    return super.updateFromJSON(t).setHeaderStyles(t.headerState).setColSpan(t.colSpan || 1).setRowSpan(t.rowSpan || 1).setWidth(t.width || void 0).setBackgroundColor(t.backgroundColor || null).setVerticalAlign(t.verticalAlign || void 0);
  }
  constructor(t = y.NO_STATUS, e = 1, o, r) {
    super(r), this.__colSpan = e, this.__rowSpan = 1, this.__headerState = t, this.__width = o, this.__backgroundColor = null, this.__verticalAlign = void 0;
  }
  createDOM(t) {
    const e = document.createElement(this.getTag());
    return this.__width && (e.style.width = `${this.__width}px`), this.__colSpan > 1 && (e.colSpan = this.__colSpan), this.__rowSpan > 1 && (e.rowSpan = this.__rowSpan), this.__backgroundColor !== null && (e.style.backgroundColor = this.__backgroundColor), z(this.__verticalAlign) && (e.style.verticalAlign = this.__verticalAlign), b(e, t.theme.tableCell, this.hasHeader() && t.theme.tableCellHeader), e;
  }
  exportDOM(t) {
    const e = super.exportDOM(t);
    if (T(e.element)) {
      const o = e.element;
      o.setAttribute("data-temporary-table-cell-lexical-key", this.getKey()), o.style.border = "1px solid black", this.__colSpan > 1 && (o.colSpan = this.__colSpan), this.__rowSpan > 1 && (o.rowSpan = this.__rowSpan), o.style.width = `${this.getWidth() || 75}px`, o.style.verticalAlign = this.getVerticalAlign() || "top", o.style.textAlign = "start", this.__backgroundColor === null && this.hasHeader() && (o.style.backgroundColor = "#f2f3f5");
    }
    return e;
  }
  exportJSON() {
    return { ...super.exportJSON(), ...z(this.__verticalAlign) && { verticalAlign: this.__verticalAlign }, backgroundColor: this.getBackgroundColor(), colSpan: this.__colSpan, headerState: this.__headerState, rowSpan: this.__rowSpan, width: this.getWidth() };
  }
  getColSpan() {
    return this.getLatest().__colSpan;
  }
  setColSpan(t) {
    const e = this.getWritable();
    return e.__colSpan = t, e;
  }
  getRowSpan() {
    return this.getLatest().__rowSpan;
  }
  setRowSpan(t) {
    const e = this.getWritable();
    return e.__rowSpan = t, e;
  }
  getTag() {
    return this.hasHeader() ? "th" : "td";
  }
  setHeaderStyles(t, e = y.BOTH) {
    const o = this.getWritable();
    return o.__headerState = t & e | o.__headerState & ~e, o;
  }
  getHeaderStyles() {
    return this.getLatest().__headerState;
  }
  setWidth(t) {
    const e = this.getWritable();
    return e.__width = t, e;
  }
  getWidth() {
    return this.getLatest().__width;
  }
  getBackgroundColor() {
    return this.getLatest().__backgroundColor;
  }
  setBackgroundColor(t) {
    const e = this.getWritable();
    return e.__backgroundColor = t, e;
  }
  getVerticalAlign() {
    return this.getLatest().__verticalAlign;
  }
  setVerticalAlign(t) {
    const e = this.getWritable();
    return e.__verticalAlign = t || void 0, e;
  }
  toggleHeaderStyle(t) {
    const e = this.getWritable();
    return (e.__headerState & t) === t ? e.__headerState -= t : e.__headerState += t, e;
  }
  hasHeaderState(t) {
    return (this.getHeaderStyles() & t) === t;
  }
  hasHeader() {
    return this.getLatest().__headerState !== y.NO_STATUS;
  }
  updateDOM(t) {
    return t.__headerState !== this.__headerState || t.__width !== this.__width || t.__colSpan !== this.__colSpan || t.__rowSpan !== this.__rowSpan || t.__backgroundColor !== this.__backgroundColor || t.__verticalAlign !== this.__verticalAlign;
  }
  isShadowRoot() {
    return !0;
  }
  collapseAtStart() {
    return !0;
  }
  canBeEmpty() {
    return !1;
  }
  canIndent() {
    return !1;
  }
}
function z(l) {
  return l === "middle" || l === "bottom";
}
function I(l) {
  const t = l, e = l.nodeName.toLowerCase();
  let o;
  E.test(t.style.width) && (o = parseFloat(t.style.width));
  const r = j(e === "th" ? y.ROW : y.NO_STATUS, t.colSpan, o);
  r.__rowSpan = t.rowSpan;
  const n = t.style.backgroundColor;
  n !== "" && (r.__backgroundColor = n);
  const s = t.style.verticalAlign;
  z(s) && (r.__verticalAlign = s);
  const i = t.style, a = (i && i.textDecoration || "").split(" "), h = i.fontWeight === "700" || i.fontWeight === "bold", c = a.includes("line-through"), u = i.fontStyle === "italic", d = a.includes("underline");
  return { after: (_) => {
    const w = [];
    let p = null;
    const f = () => {
      if (p) {
        const g = p.getFirstChild();
        H(g) && p.getChildrenSize() === 1 && g.remove();
      }
    };
    for (const g of _) st(g) || L(g) || H(g) ? (L(g) && (h && g.toggleFormat("bold"), c && g.toggleFormat("strikethrough"), u && g.toggleFormat("italic"), d && g.toggleFormat("underline")), p ? p.append(g) : (p = P().append(g), w.push(p))) : (w.push(g), f(), p = null);
    return f(), w.length === 0 && w.push(P()), w;
  }, node: r };
}
function j(l = y.NO_STATUS, t = 1, e) {
  return W(new R(l, t, e));
}
function S(l) {
  return l instanceof R;
}
function m(l, ...t) {
  const e = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams();
  o.append("code", l);
  for (const r of t) o.append("v", r);
  throw e.search = o.toString(), Error(`Minified Lexical error #${l}; visit ${e.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
}
class O extends k {
  static getType() {
    return "tablerow";
  }
  static clone(t) {
    return new O(t.__height, t.__key);
  }
  static importDOM() {
    return { tr: (t) => ({ conversion: ct, priority: 0 }) };
  }
  static importJSON(t) {
    return Q().updateFromJSON(t);
  }
  updateFromJSON(t) {
    return super.updateFromJSON(t).setHeight(t.height);
  }
  constructor(t, e) {
    super(e), this.__height = t;
  }
  exportJSON() {
    const t = this.getHeight();
    return { ...super.exportJSON(), ...t === void 0 ? void 0 : { height: t } };
  }
  createDOM(t) {
    const e = document.createElement("tr");
    return this.__height && (e.style.height = `${this.__height}px`), b(e, t.theme.tableRow), e;
  }
  extractWithChild(t, e, o) {
    return o === "html";
  }
  isShadowRoot() {
    return !0;
  }
  setHeight(t) {
    const e = this.getWritable();
    return e.__height = t, e;
  }
  getHeight() {
    return this.getLatest().__height;
  }
  updateDOM(t) {
    return t.__height !== this.__height;
  }
  canBeEmpty() {
    return !1;
  }
  canIndent() {
    return !1;
  }
}
function ct(l) {
  const t = l;
  let e;
  return E.test(t.style.height) && (e = parseFloat(t.style.height)), { after: (o) => V(o, S), node: Q(e) };
}
function Q(l) {
  return W(new O(l));
}
function v(l) {
  return l instanceof O;
}
const G = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, ut = G && "documentMode" in document ? document.documentMode : null;
G && "InputEvent" in window && !ut && new window.InputEvent("input");
function ht(l, t, e) {
  const [o, r, n] = Z(l, t, e);
  return r === null && m(207), n === null && m(208), [o, r, n];
}
function Z(l, t, e) {
  const o = [];
  let r = null, n = null;
  function s(a) {
    let h = o[a];
    return h === void 0 && (o[a] = h = []), h;
  }
  const i = l.getChildren();
  for (let a = 0; a < i.length; a++) {
    const h = i[a];
    v(h) || m(209);
    const c = s(a);
    for (let u = h.getFirstChild(), d = 0; u != null; u = u.getNextSibling()) {
      for (S(u) || m(147); c[d] !== void 0; ) d++;
      const _ = { cell: u, startColumn: d, startRow: a }, { __rowSpan: w, __colSpan: p } = u;
      for (let f = 0; f < w && !(a + f >= i.length); f++) {
        const g = s(a + f);
        for (let C = 0; C < p; C++) g[d + C] = _;
      }
      t !== null && r === null && t.is(u) && (r = _), e !== null && n === null && e.is(u) && (n = _);
    }
  }
  return [o, r, n];
}
function dt(l) {
  let t;
  if (l instanceof R) t = l;
  else if ("__type" in l) {
    const r = M(l, S);
    S(r) || m(148), t = r;
  } else {
    const r = M(l.getNode(), S);
    S(r) || m(148), t = r;
  }
  const e = t.getParent();
  v(e) || m(149);
  const o = e.getParent();
  return et(o) || m(210), [t, e, o];
}
function _t(l, t, e) {
  let o, r = Math.min(t.startColumn, e.startColumn), n = Math.min(t.startRow, e.startRow), s = Math.max(t.startColumn + t.cell.__colSpan - 1, e.startColumn + e.cell.__colSpan - 1), i = Math.max(t.startRow + t.cell.__rowSpan - 1, e.startRow + e.cell.__rowSpan - 1);
  do {
    o = !1;
    for (let a = 0; a < l.length; a++) for (let h = 0; h < l[0].length; h++) {
      const c = l[a][h];
      if (!c) continue;
      const u = c.startColumn + c.cell.__colSpan - 1, d = c.startRow + c.cell.__rowSpan - 1, _ = c.startColumn <= s && u >= r, w = c.startRow <= i && d >= n;
      if (_ && w) {
        const p = Math.min(r, c.startColumn), f = Math.max(s, u), g = Math.min(n, c.startRow), C = Math.max(i, d);
        p === r && f === s && g === n && C === i || (r = p, s = f, n = g, i = C, o = !0);
      }
    }
  } while (o);
  return { maxColumn: s, maxRow: i, minColumn: r, minRow: n };
}
function J(l) {
  const [t, , e] = dt(l), o = e.getChildren(), r = o.length, n = o[0].getChildren().length, s = new Array(r);
  for (let i = 0; i < r; i++) s[i] = new Array(n);
  for (let i = 0; i < r; i++) {
    const a = o[i].getChildren();
    let h = 0;
    for (let c = 0; c < a.length; c++) {
      for (; s[i][h]; ) h++;
      const u = a[c], d = u.__rowSpan || 1, _ = u.__colSpan || 1;
      for (let w = 0; w < d; w++) for (let p = 0; p < _; p++) s[i + w][h + p] = u;
      if (t === u) return { colSpan: _, columnIndex: h, rowIndex: i, rowSpan: d };
      h += _;
    }
  }
  return null;
}
function B(l) {
  const [[t, e, o, r], [n, s, i, a]] = ["anchor", "focus"].map(((h) => {
    const c = l[h].getNode(), u = M(c, S);
    S(u) || m(238, h, c.getKey(), c.getType());
    const d = u.getParent();
    v(d) || m(239, h);
    const _ = d.getParent();
    return et(_) || m(240, h), [c, u, d, _];
  }));
  return r.is(a) || m(241), { anchorCell: e, anchorNode: t, anchorRow: o, anchorTable: r, focusCell: s, focusNode: n, focusRow: i, focusTable: a };
}
class $ {
  constructor(t, e, o) {
    this.anchor = e, this.focus = o, e._selection = this, o._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = t;
  }
  getStartEndPoints() {
    return [this.anchor, this.focus];
  }
  isValid() {
    return this.tableKey !== "root" && this.anchor.key !== "root" && this.anchor.type === "element" && this.focus.key !== "root" && this.focus.type === "element";
  }
  isBackward() {
    return this.focus.isBefore(this.anchor);
  }
  getCachedNodes() {
    return this._cachedNodes;
  }
  setCachedNodes(t) {
    this._cachedNodes = t;
  }
  is(t) {
    return gt(t) && this.tableKey === t.tableKey && this.anchor.is(t.anchor) && this.focus.is(t.focus);
  }
  set(t, e, o) {
    this.dirty = this.dirty || t !== this.tableKey || e !== this.anchor.key || o !== this.focus.key, this.tableKey = t, this.anchor.key = e, this.focus.key = o, this._cachedNodes = null;
  }
  clone() {
    return new $(this.tableKey, K(this.anchor.key, this.anchor.offset, this.anchor.type), K(this.focus.key, this.focus.offset, this.focus.type));
  }
  isCollapsed() {
    return !1;
  }
  extract() {
    return this.getNodes();
  }
  insertRawText(t) {
  }
  insertText() {
  }
  hasFormat(t) {
    let e = 0;
    this.getNodes().filter(S).forEach(((r) => {
      const n = r.getFirstChild();
      ot(n) && (e |= n.getTextFormat());
    }));
    const o = lt[t];
    return !!(e & o);
  }
  insertNodes(t) {
    const e = this.focus.getNode();
    X(e) || m(151), rt(e.select(0, e.getChildrenSize())).insertNodes(t);
  }
  getShape() {
    const { anchorCell: t, focusCell: e } = B(this), o = J(t);
    o === null && m(153);
    const r = J(e);
    r === null && m(155);
    const n = Math.min(o.columnIndex, r.columnIndex), s = Math.max(o.columnIndex + o.colSpan - 1, r.columnIndex + r.colSpan - 1), i = Math.min(o.rowIndex, r.rowIndex), a = Math.max(o.rowIndex + o.rowSpan - 1, r.rowIndex + r.rowSpan - 1);
    return { fromX: Math.min(n, s), fromY: Math.min(i, a), toX: Math.max(n, s), toY: Math.max(i, a) };
  }
  getNodes() {
    if (!this.isValid()) return [];
    const t = this._cachedNodes;
    if (t !== null) return t;
    const { anchorTable: e, anchorCell: o, focusCell: r } = B(this), n = r.getParents()[1];
    if (n !== e) {
      if (e.isParentOf(r)) {
        const f = n.getParent();
        f == null && m(159), this.set(this.tableKey, r.getKey(), f.getKey());
      } else {
        const f = e.getParent();
        f == null && m(158), this.set(this.tableKey, f.getKey(), r.getKey());
      }
      return this.getNodes();
    }
    const [s, i, a] = ht(e, o, r), { minColumn: h, maxColumn: c, minRow: u, maxRow: d } = _t(s, i, a), _ = /* @__PURE__ */ new Map([[e.getKey(), e]]);
    let w = null;
    for (let f = u; f <= d; f++) for (let g = h; g <= c; g++) {
      const { cell: C } = s[f][g], N = C.getParent();
      v(N) || m(160), N !== w && (_.set(N.getKey(), N), w = N), _.has(C.getKey()) || pt(C, ((D) => {
        _.set(D.getKey(), D);
      }));
    }
    const p = Array.from(_.values());
    return nt() || (this._cachedNodes = p), p;
  }
  getTextContent() {
    const t = this.getNodes().filter(((o) => S(o)));
    let e = "";
    for (let o = 0; o < t.length; o++) {
      const r = t[o], n = r.__parent, s = (t[o + 1] || {}).__parent;
      e += r.getTextContent() + (s !== n ? `
` : "	");
    }
    return e;
  }
}
function gt(l) {
  return l instanceof $;
}
function pt(l, t) {
  const e = [[l]];
  for (let o = e.at(-1); o !== void 0 && e.length > 0; o = e.at(-1)) {
    const r = o.pop();
    r === void 0 ? e.pop() : t(r) !== !1 && X(r) && e.push(r.getChildren());
  }
}
function x(l) {
  return T(l) && l.nodeName === "TABLE";
}
function ft(l, t) {
  for (let e = t, o = null; e !== null; e = e.getParent()) {
    if (l.is(e)) return o;
    S(e) && (o = e);
  }
  return null;
}
function mt(l, t, e) {
  return ft(l, Y(t, e));
}
function q(l, t, e) {
  if (!t.theme.tableAlignment) return;
  const o = [], r = [];
  for (const n of ["center", "right"]) {
    const s = t.theme.tableAlignment[n];
    s && (n === e ? r : o).push(s);
  }
  A(l, ...o), b(l, ...r);
}
const wt = /* @__PURE__ */ new WeakSet();
function U(l = at()) {
  return wt.has(l);
}
class F extends k {
  static getType() {
    return "table";
  }
  getColWidths() {
    return this.getLatest().__colWidths;
  }
  setColWidths(t) {
    const e = this.getWritable();
    return e.__colWidths = t, e;
  }
  static clone(t) {
    return new F(t.__key);
  }
  afterCloneFrom(t) {
    super.afterCloneFrom(t), this.__colWidths = t.__colWidths, this.__rowStriping = t.__rowStriping, this.__frozenColumnCount = t.__frozenColumnCount, this.__frozenRowCount = t.__frozenRowCount;
  }
  static importDOM() {
    return { table: (t) => ({ conversion: St, priority: 1 }) };
  }
  static importJSON(t) {
    return tt().updateFromJSON(t);
  }
  updateFromJSON(t) {
    return super.updateFromJSON(t).setRowStriping(t.rowStriping || !1).setFrozenColumns(t.frozenColumnCount || 0).setFrozenRows(t.frozenRowCount || 0).setColWidths(t.colWidths);
  }
  constructor(t) {
    super(t), this.__rowStriping = !1, this.__frozenColumnCount = 0, this.__frozenRowCount = 0;
  }
  exportJSON() {
    return { ...super.exportJSON(), colWidths: this.getColWidths(), frozenColumnCount: this.__frozenColumnCount ? this.__frozenColumnCount : void 0, frozenRowCount: this.__frozenRowCount ? this.__frozenRowCount : void 0, rowStriping: this.__rowStriping ? this.__rowStriping : void 0 };
  }
  extractWithChild(t, e, o) {
    return o === "html";
  }
  getDOMSlot(t) {
    const e = x(t) ? t : t.querySelector("table");
    return x(e) || m(229), super.getDOMSlot(t).withElement(e).withAfter(e.querySelector("colgroup"));
  }
  createDOM(t, e) {
    const o = document.createElement("table");
    this.__style && (o.style.cssText = this.__style);
    const r = document.createElement("colgroup");
    if (o.appendChild(r), it(r), b(o, t.theme.table), this.updateTableElement(null, o, t), U(e)) {
      const n = document.createElement("div"), s = t.theme.tableScrollableWrapper;
      return s ? b(n, s) : n.style.cssText = "overflow-x: auto;", n.appendChild(o), this.updateTableWrapper(null, n, o, t), n;
    }
    return o;
  }
  updateTableWrapper(t, e, o, r) {
    this.__frozenColumnCount !== (t ? t.__frozenColumnCount : 0) && (function(n, s, i, a) {
      a > 0 ? (b(n, i.theme.tableFrozenColumn), s.setAttribute("data-lexical-frozen-column", "true")) : (A(n, i.theme.tableFrozenColumn), s.removeAttribute("data-lexical-frozen-column"));
    })(e, o, r, this.__frozenColumnCount), this.__frozenRowCount !== (t ? t.__frozenRowCount : 0) && (function(n, s, i, a) {
      a > 0 ? (b(n, i.theme.tableFrozenRow), s.setAttribute("data-lexical-frozen-row", "true")) : (A(n, i.theme.tableFrozenRow), s.removeAttribute("data-lexical-frozen-row"));
    })(e, o, r, this.__frozenRowCount);
  }
  updateTableElement(t, e, o) {
    this.__style !== (t ? t.__style : "") && (e.style.cssText = this.__style), this.__rowStriping !== (!!t && t.__rowStriping) && (function(r, n, s) {
      s ? (b(r, n.theme.tableRowStriping), r.setAttribute("data-lexical-row-striping", "true")) : (A(r, n.theme.tableRowStriping), r.removeAttribute("data-lexical-row-striping"));
    })(e, o, this.__rowStriping), (function(r, n, s, i) {
      const a = r.querySelector("colgroup");
      if (!a) return;
      const h = [];
      for (let c = 0; c < s; c++) {
        const u = document.createElement("col"), d = i && i[c];
        d && (u.style.width = `${d}px`), h.push(u);
      }
      a.replaceChildren(...h);
    })(e, 0, this.getColumnCount(), this.getColWidths()), q(e, o, this.getFormatType());
  }
  updateDOM(t, e, o) {
    const r = this.getDOMSlot(e).element;
    return e === r === U() || (T(n = e) && n.nodeName === "DIV" && this.updateTableWrapper(t, e, r, o), this.updateTableElement(t, r, o), !1);
    var n;
  }
  exportDOM(t) {
    const e = super.exportDOM(t), { element: o } = e;
    return { after: (r) => {
      if (e.after && (r = e.after(r)), !x(r) && T(r) && (r = r.querySelector("table")), !x(r)) return null;
      q(r, t._config, this.getFormatType());
      const [n] = Z(this, null, null), s = /* @__PURE__ */ new Map();
      for (const c of n) for (const u of c) {
        const d = u.cell.getKey();
        s.has(d) || s.set(d, { colSpan: u.cell.getColSpan(), startColumn: u.startColumn });
      }
      const i = /* @__PURE__ */ new Set();
      for (const c of r.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")) {
        const u = c.getAttribute("data-temporary-table-cell-lexical-key");
        if (u) {
          const d = s.get(u);
          if (c.removeAttribute("data-temporary-table-cell-lexical-key"), d) {
            s.delete(u);
            for (let _ = 0; _ < d.colSpan; _++) i.add(_ + d.startColumn);
          }
        }
      }
      const a = r.querySelector(":scope > colgroup");
      if (a) {
        const c = Array.from(r.querySelectorAll(":scope > colgroup > col")).filter(((u, d) => i.has(d)));
        a.replaceChildren(...c);
      }
      const h = r.querySelectorAll(":scope > tr");
      if (h.length > 0) {
        const c = document.createElement("tbody");
        for (const u of h) c.appendChild(u);
        r.append(c);
      }
      return r;
    }, element: !x(o) && T(o) ? o.querySelector("table") : o };
  }
  canBeEmpty() {
    return !1;
  }
  isShadowRoot() {
    return !0;
  }
  getCordsFromCellNode(t, e) {
    const { rows: o, domRows: r } = e;
    for (let n = 0; n < o; n++) {
      const s = r[n];
      if (s != null) for (let i = 0; i < s.length; i++) {
        const a = s[i];
        if (a == null) continue;
        const { elem: h } = a, c = mt(this, h);
        if (c !== null && t.is(c)) return { x: i, y: n };
      }
    }
    throw new Error("Cell not found in table.");
  }
  getDOMCellFromCords(t, e, o) {
    const { domRows: r } = o, n = r[e];
    if (n == null) return null;
    const s = n[t < n.length ? t : n.length - 1];
    return s ?? null;
  }
  getDOMCellFromCordsOrThrow(t, e, o) {
    const r = this.getDOMCellFromCords(t, e, o);
    if (!r) throw new Error("Cell not found at cords.");
    return r;
  }
  getCellNodeFromCords(t, e, o) {
    const r = this.getDOMCellFromCords(t, e, o);
    if (r == null) return null;
    const n = Y(r.elem);
    return S(n) ? n : null;
  }
  getCellNodeFromCordsOrThrow(t, e, o) {
    const r = this.getCellNodeFromCords(t, e, o);
    if (!r) throw new Error("Node at cords not TableCellNode.");
    return r;
  }
  getRowStriping() {
    return !!this.getLatest().__rowStriping;
  }
  setRowStriping(t) {
    const e = this.getWritable();
    return e.__rowStriping = t, e;
  }
  setFrozenColumns(t) {
    const e = this.getWritable();
    return e.__frozenColumnCount = t, e;
  }
  getFrozenColumns() {
    return this.getLatest().__frozenColumnCount;
  }
  setFrozenRows(t) {
    const e = this.getWritable();
    return e.__frozenRowCount = t, e;
  }
  getFrozenRows() {
    return this.getLatest().__frozenRowCount;
  }
  canSelectBefore() {
    return !0;
  }
  canIndent() {
    return !1;
  }
  getColumnCount() {
    const t = this.getFirstChild();
    if (!t) return 0;
    let e = 0;
    return t.getChildren().forEach(((o) => {
      S(o) && (e += o.getColSpan());
    })), e;
  }
}
function St(l) {
  const t = tt();
  l.hasAttribute("data-lexical-row-striping") && t.setRowStriping(!0), l.hasAttribute("data-lexical-frozen-column") && t.setFrozenColumns(1), l.hasAttribute("data-lexical-frozen-row") && t.setFrozenRows(1);
  const e = l.querySelector(":scope > colgroup");
  if (e) {
    let o = [];
    for (const r of e.querySelectorAll(":scope > col")) {
      let n = r.style.width || "";
      if (!E.test(n) && (n = r.getAttribute("width") || "", !/^\d+$/.test(n))) {
        o = void 0;
        break;
      }
      o.push(parseFloat(n));
    }
    o && t.setColWidths(o);
  }
  return { after: (o) => V(o, v), node: t };
}
function tt() {
  return W(new F());
}
function et(l) {
  return l instanceof F;
}
export {
  ht as $computeTableMap,
  Z as $computeTableMapSkipCellCheck,
  j as $createTableCellNode,
  tt as $createTableNode,
  Q as $createTableRowNode,
  dt as $getNodeTriplet,
  J as $getTableCellNodeRect,
  U as $isScrollableTablesActive,
  S as $isTableCellNode,
  et as $isTableNode,
  v as $isTableRowNode,
  gt as $isTableSelection,
  y as TableCellHeaderStates,
  R as TableCellNode,
  F as TableNode,
  O as TableRowNode
};
