UNPKG

@uva-glass/component-library

Version:

React components UvA

1,279 lines 59.5 kB
import { w as N, r as Y, i as se, _ as mt, j as kt, N as $t, T as pt, S as Mt, L as zt } from "./LexicalUtils.prod-DVr8VsHc.js"; import { d as Pe, r as fe, H as We, $ as Lt, Y as ce, M as et, w as j, X as De, m as Ht, f as Ct, s as V, g as Pt, E as Oe, i as _t, c as z, o as Wt, j as de, h as P, a as L, k as ke, l as ye, p as Dt, q as Bt, v as It, x as Jt, A as Ae, y as Yt, z as Xt, D as St, F as qt, L as I, G as Ut, I as jt, K as Vt, O as Zt, R as Gt, S as Qt, T as en, V as tn, W as re, u as q, Z as Te, _ as nn, b as wt, a0 as on, N as bt, a1 as rn, U as ln, a2 as Ne, a3 as sn, a4 as an, a5 as tt, a6 as cn, a7 as nt, B as un, a8 as ot, e as rt, t as _e, a9 as hn, C as dn, aa as fn, ab as gn } from "./Lexical.prod-CniF7zEE.js"; import { _ as mn, M as pn } from "./LexicalClipboard.prod-BXVNkwwS.js"; const Be = /^(\d+(?:\.\d+)?)px$/, B = { BOTH: 3, COLUMN: 2, NO_STATUS: 0, ROW: 1 }; class ee extends Pe { static getType() { return "tablecell"; } static clone(e) { return new ee(e.__headerState, e.__colSpan, e.__width, e.__key); } afterCloneFrom(e) { super.afterCloneFrom(e), this.__rowSpan = e.__rowSpan, this.__backgroundColor = e.__backgroundColor, this.__verticalAlign = e.__verticalAlign; } static importDOM() { return { td: (e) => ({ conversion: lt, priority: 0 }), th: (e) => ({ conversion: lt, priority: 0 }) }; } static importJSON(e) { return me().updateFromJSON(e); } updateFromJSON(e) { return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan || 1).setRowSpan(e.rowSpan || 1).setWidth(e.width || void 0).setBackgroundColor(e.backgroundColor || null).setVerticalAlign(e.verticalAlign || void 0); } constructor(e = B.NO_STATUS, t = 1, o, l) { super(l), this.__colSpan = t, this.__rowSpan = 1, this.__headerState = e, this.__width = o, this.__backgroundColor = null, this.__verticalAlign = void 0; } createDOM(e) { const t = document.createElement(this.getTag()); return this.__width && (t.style.width = `${this.__width}px`), this.__colSpan > 1 && (t.colSpan = this.__colSpan), this.__rowSpan > 1 && (t.rowSpan = this.__rowSpan), this.__backgroundColor !== null && (t.style.backgroundColor = this.__backgroundColor), $e(this.__verticalAlign) && (t.style.verticalAlign = this.__verticalAlign), Y(t, e.theme.tableCell, this.hasHeader() && e.theme.tableCellHeader), t; } exportDOM(e) { const t = super.exportDOM(e); if (fe(t.element)) { const o = t.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 t; } exportJSON() { return { ...super.exportJSON(), ...$e(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(e) { const t = this.getWritable(); return t.__colSpan = e, t; } getRowSpan() { return this.getLatest().__rowSpan; } setRowSpan(e) { const t = this.getWritable(); return t.__rowSpan = e, t; } getTag() { return this.hasHeader() ? "th" : "td"; } setHeaderStyles(e, t = B.BOTH) { const o = this.getWritable(); return o.__headerState = e & t | o.__headerState & ~t, o; } getHeaderStyles() { return this.getLatest().__headerState; } setWidth(e) { const t = this.getWritable(); return t.__width = e, t; } getWidth() { return this.getLatest().__width; } getBackgroundColor() { return this.getLatest().__backgroundColor; } setBackgroundColor(e) { const t = this.getWritable(); return t.__backgroundColor = e, t; } getVerticalAlign() { return this.getLatest().__verticalAlign; } setVerticalAlign(e) { const t = this.getWritable(); return t.__verticalAlign = e || void 0, t; } toggleHeaderStyle(e) { const t = this.getWritable(); return (t.__headerState & e) === e ? t.__headerState -= e : t.__headerState += e, t; } hasHeaderState(e) { return (this.getHeaderStyles() & e) === e; } hasHeader() { return this.getLatest().__headerState !== B.NO_STATUS; } updateDOM(e) { return e.__headerState !== this.__headerState || e.__width !== this.__width || e.__colSpan !== this.__colSpan || e.__rowSpan !== this.__rowSpan || e.__backgroundColor !== this.__backgroundColor || e.__verticalAlign !== this.__verticalAlign; } isShadowRoot() { return !0; } collapseAtStart() { return !0; } canBeEmpty() { return !1; } canIndent() { return !1; } } function $e(n) { return n === "middle" || n === "bottom"; } function lt(n) { const e = n, t = n.nodeName.toLowerCase(); let o; Be.test(e.style.width) && (o = parseFloat(e.style.width)); const l = me(t === "th" ? B.ROW : B.NO_STATUS, e.colSpan, o); l.__rowSpan = e.rowSpan; const s = e.style.backgroundColor; s !== "" && (l.__backgroundColor = s); const r = e.style.verticalAlign; $e(r) && (l.__verticalAlign = r); const i = e.style, c = (i && i.textDecoration || "").split(" "), f = i.fontWeight === "700" || i.fontWeight === "bold", h = c.includes("line-through"), p = i.fontStyle === "italic", C = c.includes("underline"); return { after: (a) => { const u = []; let g = null; const d = () => { if (g) { const m = g.getFirstChild(); et(m) && g.getChildrenSize() === 1 && m.remove(); } }; for (const m of a) Lt(m) || ce(m) || et(m) ? (ce(m) && (f && m.toggleFormat("bold"), h && m.toggleFormat("strikethrough"), p && m.toggleFormat("italic"), C && m.toggleFormat("underline")), g ? g.append(m) : (g = j().append(m), u.push(g))) : (u.push(m), d(), g = null); return d(), u.length === 0 && u.push(j()), u; }, node: l }; } function me(n = B.NO_STATUS, e = 1, t) { return We(new ee(n, e, t)); } function S(n) { return n instanceof ee; } const Cn = Wt(); function w(n, ...e) { const t = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams(); o.append("code", n); for (const l of e) o.append("v", l); throw t.search = o.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.`); } class pe extends Pe { static getType() { return "tablerow"; } static clone(e) { return new pe(e.__height, e.__key); } static importDOM() { return { tr: (e) => ({ conversion: _n, priority: 0 }) }; } static importJSON(e) { return Ie().updateFromJSON(e); } updateFromJSON(e) { return super.updateFromJSON(e).setHeight(e.height); } constructor(e, t) { super(t), this.__height = e; } exportJSON() { const e = this.getHeight(); return { ...super.exportJSON(), ...e === void 0 ? void 0 : { height: e } }; } createDOM(e) { const t = document.createElement("tr"); return this.__height && (t.style.height = `${this.__height}px`), Y(t, e.theme.tableRow), t; } extractWithChild(e, t, o) { return o === "html"; } isShadowRoot() { return !0; } setHeight(e) { const t = this.getWritable(); return t.__height = e, t; } getHeight() { return this.getLatest().__height; } updateDOM(e) { return e.__height !== this.__height; } canBeEmpty() { return !1; } canIndent() { return !1; } } function _n(n) { const e = n; let t; return Be.test(e.style.height) && (t = parseFloat(e.style.height)), { after: (o) => mt(o, S), node: Ie(t) }; } function Ie(n) { return We(new pe(n)); } function k(n) { return n instanceof pe; } const Je = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, Sn = Je && "documentMode" in document ? document.documentMode : null, st = Je && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent); function wn(n, e, t = !0) { const o = Ue(); for (let l = 0; l < n; l++) { const s = Ie(); for (let r = 0; r < e; r++) { let i = B.NO_STATUS; typeof t == "object" ? (l === 0 && t.rows && (i |= B.ROW), r === 0 && t.columns && (i |= B.COLUMN)) : t && (l === 0 && (i |= B.ROW), r === 0 && (i |= B.COLUMN)); const c = me(i), f = j(); f.append(De()), c.append(f), s.append(c); } o.append(s); } return o; } function In(n) { const e = N(n, (t) => S(t)); return S(e) ? e : null; } function yt(n) { const e = N(n, (t) => k(t)); if (k(e)) return e; throw new Error("Expected table cell to be inside of table row."); } function bn(n) { const e = N(n, (t) => O(t)); if (O(e)) return e; throw new Error("Expected table cell to be inside of table."); } function Jn(n) { const e = yt(n); return bn(e).getChildren().findIndex((t) => t.is(e)); } function Yn(n) { return yt(n).getChildren().findIndex((e) => e.is(n)); } Je && "InputEvent" in window && !Sn && new window.InputEvent("input"); function Xn(n, e) { const t = n.getChildren(); for (let o = 0; o < t.length; o++) { const l = t[o]; if (k(l)) { const s = l.getChildren(); if (e >= s.length || e < 0) throw new Error("Table column target index out of range"); s[e].remove(); } } return n; } function U(n, e, t) { const [o, l, s] = Ye(n, e, t); return l === null && w(207), s === null && w(208), [o, l, s]; } function Ye(n, e, t) { const o = []; let l = null, s = null; function r(c) { let f = o[c]; return f === void 0 && (o[c] = f = []), f; } const i = n.getChildren(); for (let c = 0; c < i.length; c++) { const f = i[c]; k(f) || w(209); const h = r(c); for (let p = f.getFirstChild(), C = 0; p != null; p = p.getNextSibling()) { for (S(p) || w(147); h[C] !== void 0; ) C++; const a = { cell: p, startColumn: C, startRow: c }, { __rowSpan: u, __colSpan: g } = p; for (let d = 0; d < u && !(c + d >= i.length); d++) { const m = r(c + d); for (let _ = 0; _ < g; _++) m[C + _] = a; } e !== null && l === null && e.is(p) && (l = a), t !== null && s === null && t.is(p) && (s = a); } } return [o, l, s]; } function le(n) { let e; if (n instanceof ee) e = n; else if ("__type" in n) { const l = N(n, S); S(l) || w(148), e = l; } else { const l = N(n.getNode(), S); S(l) || w(148), e = l; } const t = e.getParent(); k(t) || w(149); const o = t.getParent(); return O(o) || w(210), [e, t, o]; } function Me(n, e, t) { let o, l = Math.min(e.startColumn, t.startColumn), s = Math.min(e.startRow, t.startRow), r = Math.max(e.startColumn + e.cell.__colSpan - 1, t.startColumn + t.cell.__colSpan - 1), i = Math.max(e.startRow + e.cell.__rowSpan - 1, t.startRow + t.cell.__rowSpan - 1); do { o = !1; for (let c = 0; c < n.length; c++) for (let f = 0; f < n[0].length; f++) { const h = n[c][f]; if (!h) continue; const p = h.startColumn + h.cell.__colSpan - 1, C = h.startRow + h.cell.__rowSpan - 1, a = h.startColumn <= r && p >= l, u = h.startRow <= i && C >= s; if (a && u) { const g = Math.min(l, h.startColumn), d = Math.max(r, p), m = Math.min(s, h.startRow), _ = Math.max(i, C); g === l && d === r && m === s && _ === i || (l = g, r = d, s = m, i = _, o = !0); } } } while (o); return { maxColumn: r, maxRow: i, minColumn: l, minRow: s }; } function it(n) { const [e, , t] = le(n), o = t.getChildren(), l = o.length, s = o[0].getChildren().length, r = new Array(l); for (let i = 0; i < l; i++) r[i] = new Array(s); for (let i = 0; i < l; i++) { const c = o[i].getChildren(); let f = 0; for (let h = 0; h < c.length; h++) { for (; r[i][f]; ) f++; const p = c[h], C = p.__rowSpan || 1, a = p.__colSpan || 1; for (let u = 0; u < C; u++) for (let g = 0; g < a; g++) r[i + u][f + g] = p; if (e === p) return { colSpan: a, columnIndex: f, rowIndex: i, rowSpan: C }; f += a; } } return null; } function at(n) { const [[e, t, o, l], [s, r, i, c]] = ["anchor", "focus"].map((f) => { const h = n[f].getNode(), p = N(h, S); S(p) || w(238, f, h.getKey(), h.getType()); const C = p.getParent(); k(C) || w(239, f); const a = C.getParent(); return O(a) || w(240, f), [h, p, C, a]; }); return l.is(c) || w(241), { anchorCell: t, anchorNode: e, anchorRow: o, anchorTable: l, focusCell: r, focusNode: s, focusRow: i, focusTable: c }; } class Fe { constructor(e, t, o) { this.anchor = t, this.focus = o, t._selection = this, o._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = e; } 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(e) { this._cachedNodes = e; } is(e) { return R(e) && this.tableKey === e.tableKey && this.anchor.is(e.anchor) && this.focus.is(e.focus); } set(e, t, o) { this.dirty = this.dirty || e !== this.tableKey || t !== this.anchor.key || o !== this.focus.key, this.tableKey = e, this.anchor.key = t, this.focus.key = o, this._cachedNodes = null; } clone() { return new Fe(this.tableKey, Ne(this.anchor.key, this.anchor.offset, this.anchor.type), Ne(this.focus.key, this.focus.offset, this.focus.type)); } isCollapsed() { return !1; } extract() { return this.getNodes(); } insertRawText(e) { } insertText() { } hasFormat(e) { let t = 0; this.getNodes().filter(S).forEach((l) => { const s = l.getFirstChild(); bt(s) && (t |= s.getTextFormat()); }); const o = gn[e]; return !!(t & o); } insertNodes(e) { const t = this.focus.getNode(); P(t) || w(151), dn(t.select(0, t.getChildrenSize())).insertNodes(e); } getShape() { const { anchorCell: e, focusCell: t } = at(this), o = it(e); o === null && w(153); const l = it(t); l === null && w(155); const s = Math.min(o.columnIndex, l.columnIndex), r = Math.max(o.columnIndex + o.colSpan - 1, l.columnIndex + l.colSpan - 1), i = Math.min(o.rowIndex, l.rowIndex), c = Math.max(o.rowIndex + o.rowSpan - 1, l.rowIndex + l.rowSpan - 1); return { fromX: Math.min(s, r), fromY: Math.min(i, c), toX: Math.max(s, r), toY: Math.max(i, c) }; } getNodes() { if (!this.isValid()) return []; const e = this._cachedNodes; if (e !== null) return e; const { anchorTable: t, anchorCell: o, focusCell: l } = at(this), s = l.getParents()[1]; if (s !== t) { if (t.isParentOf(l)) { const d = s.getParent(); d == null && w(159), this.set(this.tableKey, l.getKey(), d.getKey()); } else { const d = t.getParent(); d == null && w(158), this.set(this.tableKey, d.getKey(), l.getKey()); } return this.getNodes(); } const [r, i, c] = U(t, o, l), { minColumn: f, maxColumn: h, minRow: p, maxRow: C } = Me(r, i, c), a = /* @__PURE__ */ new Map([[t.getKey(), t]]); let u = null; for (let d = p; d <= C; d++) for (let m = f; m <= h; m++) { const { cell: _ } = r[d][m], b = _.getParent(); k(b) || w(160), b !== u && (a.set(b.getKey(), b), u = b), a.has(_.getKey()) || Nn(_, (y) => { a.set(y.getKey(), y); }); } const g = Array.from(a.values()); return fn() || (this._cachedNodes = g), g; } getTextContent() { const e = this.getNodes().filter((o) => S(o)); let t = ""; for (let o = 0; o < e.length; o++) { const l = e[o], s = l.__parent, r = (e[o + 1] || {}).__parent; t += l.getTextContent() + (r !== s ? ` ` : " "); } return t; } } function R(n) { return n instanceof Fe; } function Nt() { const n = Ne("root", 0, "element"), e = Ne("root", 0, "element"); return new Fe("root", n, e); } function yn(n, e, t) { n.getKey(), e.getKey(), t.getKey(); const o = L(), l = R(o) ? o.clone() : Nt(); return l.set(n.getKey(), e.getKey(), t.getKey()), l; } function Nn(n, e) { const t = [[n]]; for (let o = t.at(-1); o !== void 0 && t.length > 0; o = t.at(-1)) { const l = o.pop(); l === void 0 ? t.pop() : e(l) !== !1 && P(l) && t.push(l.getChildren()); } } function xt(n, e = Ct()) { const t = ye(n); O(t) || w(231, n); const o = G(t, e.getElementByKey(n)); return o === null && w(232, n), { tableElement: o, tableNode: t }; } class xn { constructor(e, t) { this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.listenersToRemove = /* @__PURE__ */ new Set(), this.tableNodeKey = t, this.editor = e, this.table = { columns: 0, domRows: [], rows: 0 }, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.isSelecting = !1, this.pointerType = null, this.shouldCheckSelection = !1, this.abortController = new AbortController(), this.listenerOptions = { signal: this.abortController.signal }, this.nextFocus = null, this.trackTable(); } getTable() { return this.table; } removeListeners() { this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach((e) => e()), this.listenersToRemove.clear(); } $lookup() { return xt(this.tableNodeKey, this.editor); } trackTable() { const e = new MutationObserver((t) => { this.editor.getEditorState().read(() => { let o = !1; for (let r = 0; r < t.length; r++) { const i = t[r].target.nodeName; if (i === "TABLE" || i === "TBODY" || i === "THEAD" || i === "TR") { o = !0; break; } } if (!o) return; const { tableNode: l, tableElement: s } = this.$lookup(); this.table = ie(l, s); }, { editor: this.editor }); }); this.editor.getEditorState().read(() => { const { tableNode: t, tableElement: o } = this.$lookup(); this.table = ie(t, o), e.observe(o, { attributes: !0, childList: !0, subtree: !0 }); }, { editor: this.editor }); } $clearHighlight() { const e = this.editor; this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.$enableHighlightStyle(); const { tableNode: t, tableElement: o } = this.$lookup(); Se(e, ie(t, o), null), L() !== null && (q(null), e.dispatchCommand(re, void 0)); } $enableHighlightStyle() { const e = this.editor, { tableElement: t } = this.$lookup(); se(t, e._config.theme.tableSelection), t.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1; } $disableHighlightStyle() { const { tableElement: e } = this.$lookup(); Y(e, this.editor._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0; } $updateTableTableSelection(e) { if (e !== null) { e.tableKey !== this.tableNodeKey && w(233, e.tableKey, this.tableNodeKey); const t = this.editor; this.tableSelection = e, this.isHighlightingCells = !0, this.$disableHighlightStyle(), this.updateDOMSelection(), Se(t, this.table, this.tableSelection); } else this.$clearHighlight(); } setShouldCheckSelection() { this.shouldCheckSelection = !0; } getAndClearShouldCheckSelection() { return !!this.shouldCheckSelection && (this.shouldCheckSelection = !1, !0); } setNextFocus(e) { this.nextFocus = e; } getAndClearNextFocus() { const { nextFocus: e } = this; return e !== null && (this.nextFocus = null), e; } updateDOMSelection() { if (this.anchorCell !== null && this.focusCell !== null) { const e = Te(this.editor._window); e && e.rangeCount > 0 && e.removeAllRanges(); } } $setFocusCellForSelection(e, t = !1) { const o = this.editor, { tableNode: l } = this.$lookup(), s = e.x, r = e.y; if (this.focusCell = e, this.isHighlightingCells || this.anchorX === s && this.anchorY === r && !t) { if (s === this.focusX && r === this.focusY) return !1; } else this.isHighlightingCells = !0, this.$disableHighlightStyle(); if (this.focusX = s, this.focusY = r, this.isHighlightingCells) { const i = Le(l, e.elem); if (this.tableSelection != null && this.anchorCellNodeKey != null && i !== null) return this.focusCellNodeKey = i.getKey(), this.tableSelection = yn(l, this.$getAnchorTableCellOrThrow(), i), q(this.tableSelection), o.dispatchCommand(re, void 0), Se(o, this.table, this.tableSelection), !0; } return !1; } $getAnchorTableCell() { return this.anchorCellNodeKey ? ye(this.anchorCellNodeKey) : null; } $getAnchorTableCellOrThrow() { const e = this.$getAnchorTableCell(); return e === null && w(234), e; } $getFocusTableCell() { return this.focusCellNodeKey ? ye(this.focusCellNodeKey) : null; } $getFocusTableCellOrThrow() { const e = this.$getFocusTableCell(); return e === null && w(235), e; } $setAnchorCellForSelection(e) { this.isHighlightingCells = !1, this.anchorCell = e, this.anchorX = e.x, this.anchorY = e.y; const { tableNode: t } = this.$lookup(), o = Le(t, e.elem); if (o !== null) { const l = o.getKey(); this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : Nt(), this.anchorCellNodeKey = l; } } $formatCells(e) { const t = L(); R(t) || w(236); const o = on(), l = o.anchor, s = o.focus, r = t.getNodes().filter(S); r.length > 0 || w(237); const i = r[0].getFirstChild(), c = bt(i) ? i.getFormatFlags(e, null) : null; r.forEach((f) => { l.set(f.getKey(), 0, "element"), s.set(f.getKey(), f.getChildrenSize(), "element"), o.formatText(e, c); }), q(t), this.editor.dispatchCommand(re, void 0); } $clearText() { const { editor: e } = this, t = ye(this.tableNodeKey); if (!O(t)) throw new Error("Expected TableNode."); const o = L(); R(o) || w(253); const l = o.getNodes().filter(S); if (l.length === this.table.columns * this.table.rows) { t.selectPrevious(); const s = t.getParent(); return t.remove(), void (rn(s) && s.isEmpty() && e.dispatchCommand(wt, void 0)); } l.forEach((s) => { if (P(s)) { const r = j(), i = De(); r.append(i), s.append(r), s.getChildren().forEach((c) => { c !== r && c.remove(); }); } }), Se(e, this.table, null), q(null), e.dispatchCommand(re, void 0); } } const ze = "__lexicalTableSelection", Tn = (n) => !(1 & ~n.buttons); function oe(n) { return fe(n) && n.nodeName === "TABLE"; } function G(n, e) { if (!e) return e; const t = oe(e) ? e : n.getDOMSlot(e).element; return t.nodeName !== "TABLE" && w(245, e.nodeName), t; } function Xe(n) { return n._window; } function ge(n, e) { for (let t = e, o = null; t !== null; t = t.getParent()) { if (n.is(t)) return o; S(t) && (o = t); } return null; } const Fn = [[Dt, "down"], [Bt, "up"], [It, "backward"], [Jt, "forward"]], vn = [Xt, St, qt], Rn = [Ut, jt]; function Kn(n, e, t, o) { const l = t.getRootElement(), s = Xe(t); l !== null && s !== null || w(246); const r = new xn(t, n.getKey()), i = G(n, e); (function(a, u) { ct(a) !== null && w(205), a[ze] = u; })(i, r), r.listenersToRemove.add(() => function(a, u) { ct(a) === u && delete a[ze]; }(i, r)); const c = (a) => { if (r.pointerType = a.pointerType, a.button !== 0 || !de(a.target) || !s) return; const u = xe(a.target); u !== null && t.update(() => { const g = ke(); if (st && a.shiftKey && J(g, n) && (z(g) || R(g))) { const d = g.anchor.getNode(), m = ge(n, g.anchor.getNode()); m ? (r.$setAnchorCellForSelection(Z(r, m)), r.$setFocusCellForSelection(u), X(a)) : (n.isBefore(d) ? n.selectStart() : n.selectEnd()).anchor.set(g.anchor.key, g.anchor.offset, g.anchor.type); } else r.$setAnchorCellForSelection(u); }), (() => { if (r.isSelecting) return; const g = () => { r.isSelecting = !1, s.removeEventListener("pointerup", g), s.removeEventListener("pointermove", d); }, d = (m) => { if (!Tn(m) && r.isSelecting) return r.isSelecting = !1, s.removeEventListener("pointerup", g), void s.removeEventListener("pointermove", d); if (!de(m.target)) return; let _ = null; const b = !(st || i.contains(m.target)); if (b) _ = ut(i, m.target); else for (const y of document.elementsFromPoint(m.clientX, m.clientY)) if (_ = ut(i, y), _) break; !_ || r.focusCell !== null && _.elem === r.focusCell.elem || (r.setNextFocus({ focusCell: _, override: b }), t.dispatchCommand(re, void 0)); }; r.isSelecting = !0, s.addEventListener("pointerup", g, r.listenerOptions), s.addEventListener("pointermove", d, r.listenerOptions); })(); }; i.addEventListener("pointerdown", c, r.listenerOptions), r.listenersToRemove.add(() => { i.removeEventListener("pointerdown", c); }); const f = (a) => { a.detail >= 3 && de(a.target) && xe(a.target) !== null && a.preventDefault(); }; i.addEventListener("mousedown", f, r.listenerOptions), r.listenersToRemove.add(() => { i.removeEventListener("mousedown", f); }); const h = (a) => { const u = a.target; a.button === 0 && de(u) && t.update(() => { const g = L(); R(g) && g.tableKey === r.tableNodeKey && l.contains(u) && r.$clearHighlight(); }); }; s.addEventListener("pointerdown", h, r.listenerOptions), r.listenersToRemove.add(() => { s.removeEventListener("pointerdown", h); }); for (const [a, u] of Fn) r.listenersToRemove.add(t.registerCommand(a, (g) => vt(t, g, u, n, r), Ae)); r.listenersToRemove.add(t.registerCommand(Yt, (a) => { const u = L(); if (R(u)) { const g = ge(n, u.focus.getNode()); if (g !== null) return X(a), g.selectEnd(), !0; } return !1; }, Ae)); const p = (a) => () => { const u = L(); if (!J(u, n)) return !1; if (R(u)) return r.$clearText(), !0; if (z(u)) { if (!S(ge(n, u.anchor.getNode()))) return !1; const g = u.anchor.getNode(), d = u.focus.getNode(), m = n.isParentOf(g), _ = n.isParentOf(d); if (m && !_ || _ && !m) return r.$clearText(), !0; const b = N(u.anchor.getNode(), (x) => P(x)), y = b && N(b, (x) => P(x) && S(x.getParent())); if (!P(y) || !P(b)) return !1; if (a === St && y.getPreviousSibling() === null) return !0; } return !1; }; for (const a of vn) r.listenersToRemove.add(t.registerCommand(a, p(a), I)); const C = (a) => { const u = L(); if (!R(u) && !z(u)) return !1; const g = n.isParentOf(u.anchor.getNode()); if (g !== n.isParentOf(u.focus.getNode())) { const d = g ? "anchor" : "focus", m = g ? "focus" : "anchor", { key: _, offset: b, type: y } = u[m]; return n[u[d].isBefore(u[m]) ? "selectPrevious" : "selectNext"]()[m].set(_, b, y), !1; } return !!J(u, n) && !!R(u) && (a && (a.preventDefault(), a.stopPropagation()), r.$clearText(), !0); }; for (const a of Rn) r.listenersToRemove.add(t.registerCommand(a, C, I)); return r.listenersToRemove.add(t.registerCommand(Vt, (a) => { const u = L(); if (u) { if (!R(u) && !z(u)) return !1; mn(t, zt(a, ClipboardEvent) ? a : null, pn(u)); const g = C(a); return z(u) ? (u.removeText(), !0) : g; } return !1; }, I)), r.listenersToRemove.add(t.registerCommand(Zt, (a) => { const u = L(); if (!J(u, n)) return !1; if (R(u)) return r.$formatCells(a), !0; if (z(u)) { const g = N(u.anchor.getNode(), (d) => S(d)); if (!S(g)) return !1; } return !1; }, I)), r.listenersToRemove.add(t.registerCommand(Gt, (a) => { const u = L(); if (!R(u) || !J(u, n)) return !1; const g = u.anchor.getNode(), d = u.focus.getNode(); if (!S(g) || !S(d)) return !1; if (function(T, A) { if (R(T)) { const F = T.anchor.getNode(), K = T.focus.getNode(); if (A && F && K) { const [M] = U(A, F, K); return F.getKey() === M[0][0].cell.getKey() && K.getKey() === M[M.length - 1].at(-1).cell.getKey(); } } return !1; }(u, n)) return n.setFormat(a), !0; const [m, _, b] = U(n, g, d), y = Math.max(_.startRow + _.cell.__rowSpan - 1, b.startRow + b.cell.__rowSpan - 1), x = Math.max(_.startColumn + _.cell.__colSpan - 1, b.startColumn + b.cell.__colSpan - 1), v = Math.min(_.startRow, b.startRow), $ = Math.min(_.startColumn, b.startColumn), E = /* @__PURE__ */ new Set(); for (let T = v; T <= y; T++) for (let A = $; A <= x; A++) { const F = m[T][A].cell; if (E.has(F)) continue; E.add(F), F.setFormat(a); const K = F.getChildren(); for (let M = 0; M < K.length; M++) { const H = K[M]; P(H) && !H.isInline() && H.setFormat(a); } } return !0; }, I)), r.listenersToRemove.add(t.registerCommand(Qt, (a) => { const u = L(); if (!J(u, n)) return !1; if (R(u)) return r.$clearHighlight(), !1; if (z(u)) { const g = N(u.anchor.getNode(), (d) => S(d)); if (!S(g)) return !1; if (typeof a == "string") { const d = ft(t, u, n); if (d) return dt(d, n, [De(a)]), !0; } } return !1; }, I)), o && r.listenersToRemove.add(t.registerCommand(en, (a) => { const u = L(); if (!z(u) || !u.isCollapsed() || !J(u, n)) return !1; const g = he(u.anchor.getNode()); return !(g === null || !n.is(ae(g))) && (X(a), function(d, m) { const _ = m === "next" ? "getNextSibling" : "getPreviousSibling", b = m === "next" ? "getFirstChild" : "getLastChild", y = d[_](); if (P(y)) return y.selectEnd(); const x = N(d, k); x === null && w(247); for (let $ = x[_](); k($); $ = $[_]()) { const E = $[b](); if (P(E)) return E.selectEnd(); } const v = N(x, O); v === null && w(248), m === "next" ? v.selectNext() : v.selectPrevious(); }(g, a.shiftKey ? "previous" : "next"), !0); }, I)), r.listenersToRemove.add(t.registerCommand(tn, (a) => n.isSelected(), Ae)), r.listenersToRemove.add(t.registerCommand(_t, (a) => { const { nodes: u, selection: g } = a, d = g.getStartEndPoints(), m = R(g), _ = z(g) && N(g.anchor.getNode(), (W) => S(W)) !== null && N(g.focus.getNode(), (W) => S(W)) !== null || m; if (u.length !== 1 || !O(u[0]) || !_ || d === null) return !1; const [b] = d, y = u[0], x = y.getChildren(), v = y.getFirstChildOrThrow().getChildrenSize(), $ = y.getChildrenSize(), E = N(b.getNode(), (W) => S(W)), T = E && N(E, (W) => k(W)), A = T && N(T, (W) => O(W)); if (!S(E) || !k(T) || !O(A)) return !1; const F = T.getIndexWithinParent(), K = Math.min(A.getChildrenSize() - 1, F + $ - 1), M = E.getIndexWithinParent(), H = Math.min(T.getChildrenSize() - 1, M + v - 1), ue = Math.min(M, H), ve = Math.min(F, K), Re = Math.max(M, H), D = Math.max(F, K), Kt = A.getChildren(); let je = 0; for (let W = ve; W <= D; W++) { const Ve = Kt[W]; if (!k(Ve)) return !1; const Ze = x[je]; if (!k(Ze)) return !1; const Ot = Ve.getChildren(), At = Ze.getChildren(); let Ge = 0; for (let Ke = ue; Ke <= Re; Ke++) { const Ce = Ot[Ke]; if (!S(Ce)) return !1; const Qe = At[Ge]; if (!S(Qe)) return !1; const Et = Ce.getChildren(); Qe.getChildren().forEach((te) => { ce(te) && j().append(te), Ce.append(te); }), Et.forEach((te) => te.remove()), Ge++; } je++; } return !0; }, I)), r.listenersToRemove.add(t.registerCommand(re, () => { const a = L(), u = ke(), g = r.getAndClearNextFocus(); if (g !== null) { const { focusCell: d } = g; if (R(a) && a.tableKey === r.tableNodeKey) return (d.x !== r.focusX || d.y !== r.focusY) && (r.$setFocusCellForSelection(d), !0); if (d !== r.anchorCell && J(a, n)) return r.$setFocusCellForSelection(d), !0; } if (r.getAndClearShouldCheckSelection() && z(u) && z(a) && a.isCollapsed()) { const d = a.anchor.getNode(), m = n.getFirstChild(), _ = he(d); if (_ !== null && k(m)) { const b = m.getFirstChild(); if (S(b) && n.is(N(_, (y) => y.is(n) || y.is(b)))) return b.selectStart(), !0; } } if (z(a)) { const { anchor: d, focus: m } = a, _ = d.getNode(), b = m.getNode(), y = he(_), x = he(b), v = !(!y || !n.is(ae(y))), $ = !(!x || !n.is(ae(x))), E = v !== $, T = v && $, A = a.isBackward(); if (E) { const F = a.clone(); if ($) { const [K] = U(n, x, x), M = K[0][0].cell, H = K[K.length - 1].at(-1).cell; F.focus.set(A ? M.getKey() : H.getKey(), A ? M.getChildrenSize() : H.getChildrenSize(), "element"); } else if (v) { const [K] = U(n, y, y), M = K[0][0].cell, H = K[K.length - 1].at(-1).cell; F.anchor.set(A ? H.getKey() : M.getKey(), A ? H.getChildrenSize() : 0, "element"); } q(F), ht(t, r); } else if (T && (y.is(x) || (r.$setAnchorCellForSelection(Z(r, y)), r.$setFocusCellForSelection(Z(r, x), !0)), r.pointerType === "touch" && a.isCollapsed() && z(u) && u.isCollapsed())) { const F = he(u.anchor.getNode()); F && !F.is(x) && (r.$setAnchorCellForSelection(Z(r, F)), r.$setFocusCellForSelection(Z(r, x), !0), r.pointerType = null); } } else if (a && R(a) && a.is(u) && a.tableKey === n.getKey()) { const d = Te(s); if (d && d.anchorNode && d.focusNode) { const m = V(d.focusNode), _ = m && !n.isParentOf(m), b = V(d.anchorNode), y = b && n.isParentOf(b); if (_ && y && d.rangeCount > 0) { const x = nn(d, t); x && (x.anchor.set(n.getKey(), a.isBackward() ? n.getChildrenSize() : 0, "element"), d.removeAllRanges(), q(x)); } } } return a && !a.is(u) && (R(a) || R(u)) && r.tableSelection && !r.tableSelection.is(u) ? (R(a) && a.tableKey === r.tableNodeKey ? r.$updateTableTableSelection(a) : !R(a) && R(u) && u.tableKey === r.tableNodeKey && r.$updateTableTableSelection(null), !1) : (r.hasHijackedSelectionStyles && !n.isSelected() ? function(d, m) { m.$enableHighlightStyle(), qe(m.table, (_) => { const b = _.elem; _.highlighted = !1, Ft(d, _), b.getAttribute("style") || b.removeAttribute("style"); }); }(t, r) : !r.hasHijackedSelectionStyles && n.isSelected() && ht(t, r), !1); }, I)), r.listenersToRemove.add(t.registerCommand(wt, () => { const a = L(); if (!z(a) || !a.isCollapsed() || !J(a, n)) return !1; const u = ft(t, a, n); return !!u && (dt(u, n), !0); }, I)), r; } function ct(n) { return n[ze] || null; } function xe(n) { let e = n; for (; e != null; ) { const t = e.nodeName; if (t === "TD" || t === "TH") { const o = e._cell; return o === void 0 ? null : o; } e = e.parentNode; } return null; } function ut(n, e) { if (!n.contains(e)) return null; let t = null; for (let o = e; o != null; o = o.parentNode) { if (o === n) return t; const l = o.nodeName; l !== "TD" && l !== "TH" || (t = o._cell || null); } return null; } function ie(n, e) { const t = [], o = { columns: 0, domRows: t, rows: 0 }; let l = G(n, e).querySelector("tr"), s = 0, r = 0; for (t.length = 0; l != null; ) { const i = l.nodeName; if (i === "TD" || i === "TH") { const h = { elem: l, hasBackgroundColor: l.style.backgroundColor !== "", highlighted: !1, x: s, y: r }; l._cell = h; let p = t[r]; p === void 0 && (p = t[r] = []), p[s] = h; } else { const h = l.firstChild; if (h != null) { l = h; continue; } } const c = l.nextSibling; if (c != null) { s++, l = c; continue; } const f = l.parentNode; if (f != null) { const h = f.nextSibling; if (h == null) break; r++, s = 0, l = h; } } return o.columns = s + 1, o.rows = r + 1, o; } function Se(n, e, t) { const o = new Set(t ? t.getNodes() : []); qe(e, (l, s) => { const r = l.elem; o.has(s) ? (l.highlighted = !0, Tt(n, l)) : (l.highlighted = !1, Ft(n, l), r.getAttribute("style") || r.removeAttribute("style")); }); } function qe(n, e) { const { domRows: t } = n; for (let o = 0; o < t.length; o++) { const l = t[o]; if (l) for (let s = 0; s < l.length; s++) { const r = l[s]; if (!r) continue; const i = V(r.elem); i !== null && e(r, i, { x: s, y: o }); } } } function ht(n, e) { e.$disableHighlightStyle(), qe(e.table, (t) => { t.highlighted = !0, Tt(n, t); }); } const On = (n, e, t, o, l) => { const s = l === "forward"; switch (l) { case "backward": case "forward": return t !== (s ? n.table.columns - 1 : 0) ? be(e.getCellNodeFromCordsOrThrow(t + (s ? 1 : -1), o, n.table), s) : o !== (s ? n.table.rows - 1 : 0) ? be(e.getCellNodeFromCordsOrThrow(s ? 0 : n.table.columns - 1, o + (s ? 1 : -1), n.table), s) : s ? e.selectNext() : e.selectPrevious(), !0; case "up": return o !== 0 ? be(e.getCellNodeFromCordsOrThrow(t, o - 1, n.table), !1) : e.selectPrevious(), !0; case "down": return o !== n.table.rows - 1 ? be(e.getCellNodeFromCordsOrThrow(t, o + 1, n.table), !0) : e.selectNext(), !0; default: return !1; } }; function Ee(n, e) { let t, o; if (e.startColumn === n.minColumn) t = "minColumn"; else { if (e.startColumn + e.cell.__colSpan - 1 !== n.maxColumn) return null; t = "maxColumn"; } if (e.startRow === n.minRow) o = "minRow"; else { if (e.startRow + e.cell.__rowSpan - 1 !== n.maxRow) return null; o = "maxRow"; } return [t, o]; } function we([n, e]) { return [n === "minColumn" ? "maxColumn" : "minColumn", e === "minRow" ? "maxRow" : "minRow"]; } function ne(n, e, [t, o]) { const l = e[o], s = n[l]; s === void 0 && w(250, o, String(l)); const r = e[t], i = s[r]; return i === void 0 && w(250, t, String(r)), i; } function An(n, e, t, o, l) { const s = Me(e, t, o), r = function(v, $) { const { minColumn: E, maxColumn: T, minRow: A, maxRow: F } = $; let K = 1, M = 1, H = 1, ue = 1; const ve = v[A], Re = v[F]; for (let D = E; D <= T; D++) K = Math.max(K, ve[D].cell.__rowSpan), ue = Math.max(ue, Re[D].cell.__rowSpan); for (let D = A; D <= F; D++) M = Math.max(M, v[D][E].cell.__colSpan), H = Math.max(H, v[D][T].cell.__colSpan); return { bottomSpan: ue, leftSpan: M, rightSpan: H, topSpan: K }; }(e, s), { topSpan: i, leftSpan: c, bottomSpan: f, rightSpan: h } = r, p = function(v, $) { const E = Ee(v, $); return E === null && w(249, $.cell.getKey()), E; }(s, t), [C, a] = we(p); let u = s[C], g = s[a]; l === "forward" ? u += C === "maxColumn" ? 1 : c : l === "backward" ? u -= C === "minColumn" ? 1 : h : l === "down" ? g += a === "maxRow" ? 1 : i : l === "up" && (g -= a === "minRow" ? 1 : f); const d = e[g]; if (d === void 0) return !1; const m = d[u]; if (m === void 0) return !1; const [_, b] = function(v, $, E) { const T = Me(v, $, E), A = Ee(T, $); if (A) return [ne(v, T, A), ne(v, T, we(A))]; const F = Ee(T, E); if (F) return [ne(v, T, we(F)), ne(v, T, F)]; const K = ["minColumn", "minRow"]; return [ne(v, T, K), ne(v, T, we(K))]; }(e, t, m), y = Z(n, _.cell), x = Z(n, b.cell); return n.$setAnchorCellForSelection(y), n.$setFocusCellForSelection(x, !0), !0; } function J(n, e) { if (z(n) || R(n)) { const t = e.isParentOf(n.anchor.getNode()), o = e.isParentOf(n.focus.getNode()); return t && o; } return !1; } function be(n, e) { e ? n.selectStart() : n.selectEnd(); } function Tt(n, e) { const t = e.elem, o = n._config.theme; S(V(t)) || w(131), Y(t, o.tableCellSelected); } function Ft(n, e) { const t = e.elem; S(V(t)) || w(131); const o = n._config.theme; se(t, o.tableCellSelected); } function he(n) { const e = N(n, S); return S(e) ? e : null; } function ae(n) { const e = N(n, O); return O(e) ? e : null; } function En(n, e, t, o, l, s, r) { const i = sn(t.focus, l ? "previous" : "next"); if (an(i)) return !1; let c = i; for (const d of tt(i).iterNodeCarets("shadowRoot")) { if (!cn(d) || !P(d.origin)) return !1; c = d; } const f = c.getParentAtCaret(); if (!S(f)) return !1; const h = f, p = function(d) { for (const m of tt(d).iterNodeCarets("root")) { const { origin: _ } = m; if (S(_)) { if (nt(m)) return un(_, d.direction); } else if (!k(_)) break; } return null; }(ot(h, c.direction)), C = N(h, O); if (!C || !C.is(s)) return !1; const a = n.getElementByKey(h.getKey()), u = xe(a); if (!a || !u) return !1; const g = kn(n, C); if (r.table = g, p) if (o === "extend") { const d = xe(n.getElementByKey(p.origin.getKey())); if (!d) return !1; r.$setAnchorCellForSelection(u), r.$setFocusCellForSelection(d, !0); } else { const d = rt(p); _e(t.anchor, d), _e(t.focus, d); } else if (o === "extend") r.$setAnchorCellForSelection(u), r.$setFocusCellForSelection(u, !0); else { const d = function(m) { const _ = hn(m); return nt(_) ? rt(_) : m; }(ot(C, i.direction)); _e(t.anchor, d), _e(t.focus, d); } return X(e), !0; } function vt(n, e, t, o, l) { if ((t === "up" || t === "down") && function(r) { const i = r.getRootElement(); return i ? i.hasAttribute("aria-controls") && i.getAttribute("aria-controls") === "typeahead-menu" : !1; }(n)) return !1; const s = L(); if (!J(s, o)) { if (z(s)) { if (t === "backward") { if (s.focus.offset > 0) return !1; const r = function(c) { for (let f = c, h = c; h !== null; f = h, h = h.getParent()) if (P(h)) { if (h !== f && h.getFirstChild() !== f) return null; if (!h.isInline()) return h; } return null; }(s.focus.getNode()); if (!r) return !1; const i = r.getPreviousSibling(); return !!O(i) && (X(e), e.shiftKey ? s.focus.set(i.getParentOrThrow().getKey(), i.getIndexWithinParent(), "element") : i.selectEnd(), !0); } if (e.shiftKey && (t === "up" || t === "down")) { const r = s.focus.getNode(); if (!s.isCollapsed() && (t === "up" && !s.isBackward() || t === "down" && s.isBackward())) { let i = N(r, (C) => O(C)); if (S(i) && (i = N(i, O)), i !== o || !i) return !1; const c = t === "down" ? i.getNextSibling() : i.getPreviousSibling(); if (!c) return !1; let f = 0; t === "up" && P(c) && (f = c.getChildrenSize()); let h = c; t === "up" && P(c) && (h = c.getLastChild() || c, f = ce(h) ? h.getTextContentSize() : 0); const p = s.clone(); return p.focus.set(h.getKey(), f, ce(h) ? "text" : "element"), q(p), X(e), !0; } if (ln(r)) { const i = t === "up" ? s.getNodes()[s.getNodes().length - 1] : s.getNodes()[0]; if (i && ge(o, i) !== null) { const c = o.getFirstDescendant(), f = o.getLastDescendant(); if (!c || !f) return !1; const [h] = le(c), [p] = le(f), C = o.getCordsFromCellNode(h, l.table), a = o.getCordsFromCellNode(p, l.table), u = o.getDOMCellFromCordsOrThrow(C.x, C.y, l.table), g = o.getDOMCellFromCordsOrThrow(a.x, a.y, l.table); return l.$setAnchorCellForSelection(u), l.$setFocusCellForSelection(g, !0), !0; } return !1; } { let i = N(r, (f) => P(f) && !f.isInline()); if (S(i) && (i = N(i, O)), !i) return !1; const c = t === "down" ? i.getNextSibling() : i.getPreviousSibling(); if (O(c) && l.tableNodeKey === c.getKey()) { const f = c.getFirstDescendant(), h = c.getLastDescendant(); if (!f || !h) return !1; const [p] = le(f), [C] = le(h), a = s.clone(); return a.focus.set((t === "up" ? p : C).getKey(), t === "up" ? 0 : C.getChildrenSize(), "element"), X(e), q(a), !0; } } } } return t === "down" && Rt(n) && l.setShouldCheckSelection(), !1; } if (z(s)) { if (t === "backward" || t === "forward") return En(n, e, s, e.shiftKey ? "extend" : "move", t === "backward", o, l); if (s.isCollapsed()) { const { anchor: r, focus: i } = s, c = N(r.getNode(), S), f = N(i.getNode(), S); if (!S(c) || !c.is(f)) return !1; const h = ae(c); if (h !== o && h != null) { const m = G(h, n.getElementByKey(h.getKey())); if (m != null) return l.table = ie(h, m), vt(n, e, t, h, l); } const p = n.getElementByKey(c.__key), C = n.getElementByKey(r.key); if (C == null || p == null) return !1; let a; if (r.type === "element") a = C.getBoundingClientRect(); else { const m = Te(Xe(n)); if (m === null || m.rangeCount === 0) return !1; a = m.getRangeAt(0).getBoundingClientRect(); } const u = t === "up" ? c.getFirstChild() : c.getLastChild(); if (u == null) return !1; const g = n.getElementByKey(u.__key); if (g == null) return !1; const d = g.getBoundingClientRect(); if (t === "up" ? d.top > a.top - a.height : a.bottom + a.height > d.bottom) { X(e); const m = o.getCordsFromCellNode(c, l.table); if (!e.shiftKey) return On(l, o, m.x, m.y, t); { const _ = o.getDOMCellFromCordsOrThrow(m.x, m.y, l.table); l.$setAnchorCellForSelection(_), l.$setFocusCellForSelection(_, !0); } return !0; } } } else if (R(s)) { const { anchor: r, focus: i } = s, c = N(r.getNode(), S), f = N(i.getNode(), S), [h] = s.getNodes(); O(h) || w(251); const p = G(h, n.getElementByKey(h.getKey())); if (!S(c) || !S(f) || !O(h) || p == null) return !1; l.$updateTableTableSelection(s); const C = ie(h, p), a = o.getCordsFromCellNode(c, C), u = o.getDOMCellFromCordsOrThrow(a.x, a.y, C); if (l.$setAnchorCellForSelection(u), X(e), e.shiftKey) { const [g, d, m] = U(o, c, f); return An(l, g, d, m, t); } return f.selectEnd(), !0; } return !1; } function X(n) { n.preventDefault(), n.stopImmediatePropagation(), n.stopPropagation(); } function dt(n, e, t) { const o = j(); n === "first" ? e.insertBefore(o) : e.insertAfter(o), o.append(...t || []), o.selectEnd(); } function ft(n, e, t) { const o = t.getParent(); if (!o) return; const l = Te(Xe(n)); if (!l) return; const s = l.anchorNode, r = n.getElementByKey(o.getKey()), i = G(t, n.getElementByKey(t.getKey())); if (!s || !r || !i || !r.contains(s) || i.contains(s)) return; const c = N(e.anchor.getNode(), (_) => S(_)); if (!c) return; const f = N(c, (_) => O(_)); if (!O(f) || !f.is(t)) return; const [h, p] = U(t, c, c), C = h[0][0], a = h[h.length - 1][h[0].length - 1], { startRow: u, startColumn: g } = p, d = u === C.startRow && g === C.startColumn, m = u === a.startRow && g === a.startColumn; return d ? "first" : m ? "last" : void 0; } function Z(n, e) { const { tableNode: t } = n.$lookup(), o = t.getCordsFromCellNode(e, n.table); return t.getDOMCellFromCordsOrThrow(o.x, o.y, n.table); } function Le(n, e, t) { return ge(n, V(e, t)); } function gt(n, e, t) { if (!e.theme.tableAlignment) return; const o = [], l = []; for (const s of ["center", "right"]) { const r = e.theme.tableAlignment[s]; r && (s === t ? l : o).push(r); } se(n, ...o), Y(n, ...l); } const He = /* @__PURE__ */ new WeakSet(); function Rt(n = Ct()) { return He.has(n); } function qn(n, e) { e ? He.add(n) : He.delete(n); } class Q extends Pe { static getType() { return "table"; } getColWidths() { return this.getLatest().__colWidths; } setColWidths(e) { const t = this.getWritable(); return t.__colWidths = e, t; } static clone(e) { return new Q(e.__key); } afterCloneFrom(e) { super.afterCloneFrom(e), this.__colWidths = e.__colWidths, this.__rowStriping = e.__rowStriping, this.__frozenColumnCount = e.__frozenColumnCount, this.__frozenRowCount = e.__frozenRowCount; } static importDOM() { return { table: (e) => ({ conversion: $n, priority: 1 }) }; } static importJSON(e) { return Ue().updateFromJSON(e); } updateFromJSON(e) { return super.updateFromJSON(e).setRowStriping(e.rowStriping || !1).setFrozenColumns(e.frozenColumnCount || 0).setFrozenRows(e.frozenRowCount || 0).setColWidths(e.colWidths); } constructor(e) { super(e), 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(e, t, o) { return o === "html"; } getDOMSlot(e) { const t = oe(e) ? e : e.querySelector("table"); return oe(t) || w(229), super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup")); } createDOM(e, t) { const o = docume