@uva-glass/component-library 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/{Lexical.prod-LIa6Q94i.js → Lexical.prod-Bu-Iw9VX.js} +1390 -1361
  2. package/dist/Lexical.prod-Bu-Iw9VX.js.map +1 -0
  3. package/dist/{LexicalClipboard.prod-LIoPcoQF.js → LexicalClipboard.prod-C5dHfEke.js} +18 -18
  4. package/dist/{LexicalClipboard.prod-LIoPcoQF.js.map → LexicalClipboard.prod-C5dHfEke.js.map} +1 -1
  5. package/dist/{LexicalLink.prod-N0i4wDOR.js → LexicalLink.prod-DdERpPPj.js} +14 -14
  6. package/dist/{LexicalLink.prod-N0i4wDOR.js.map → LexicalLink.prod-DdERpPPj.js.map} +1 -1
  7. package/dist/{LexicalList.prod-BKa7Tljk.js → LexicalList.prod-CzJqqstH.js} +91 -95
  8. package/dist/LexicalList.prod-CzJqqstH.js.map +1 -0
  9. package/dist/LexicalSelection.prod-CkM-3E0b.js +90 -0
  10. package/dist/{LexicalSelection.prod-Cid08b3Z.js.map → LexicalSelection.prod-CkM-3E0b.js.map} +1 -1
  11. package/dist/LexicalTable.prod-BsmIydKv.js +1550 -0
  12. package/dist/LexicalTable.prod-BsmIydKv.js.map +1 -0
  13. package/dist/LexicalUtils.prod-BVZbsLIa.js +107 -0
  14. package/dist/LexicalUtils.prod-BVZbsLIa.js.map +1 -0
  15. package/dist/{TablePlugin-DlTujN8R.js → TablePlugin-DKzssVbg.js} +41 -41
  16. package/dist/{TablePlugin-DlTujN8R.js.map → TablePlugin-DKzssVbg.js.map} +1 -1
  17. package/dist/assets/FeedbackBar.css +1 -1
  18. package/dist/assets/StatusBage.css +1 -0
  19. package/dist/components/CheckboxButton/CheckboxButton.test.js.map +1 -1
  20. package/dist/components/CheckboxButtonBar/CheckboxButtonBar.test.js.map +1 -1
  21. package/dist/components/CheckboxTree/CheckboxTree.js +1 -1
  22. package/dist/components/FeedbackBar/FeedbackBar.js +17 -17
  23. package/dist/components/FormInput/FormInput.js +1 -1
  24. package/dist/components/InputField/InputField.stories.js +1 -1
  25. package/dist/components/MultiSelect/MultiSelect.js +1 -1
  26. package/dist/components/MultiSelect/MultiSelect.stories.js +1 -1
  27. package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -1
  28. package/dist/components/MultiSelect/index.js +1 -1
  29. package/dist/components/OverlayStepBar/OverlayStepBar.js +1 -1
  30. package/dist/components/PeriodSelector/PeriodSelector.js +1 -1
  31. package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +1 -1
  32. package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -1
  33. package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +5 -5
  34. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +2 -2
  35. package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +2 -2
  36. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +1 -1
  37. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +4 -4
  38. package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
  39. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +25 -25
  40. package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +8 -8
  41. package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js.map +1 -1
  42. package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +1 -1
  43. package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +3 -3
  44. package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +18 -18
  45. package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
  46. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +14 -14
  47. package/dist/components/RteEditor/Plugins/index.js +1 -1
  48. package/dist/components/RteEditor/RteEditor.js +132 -130
  49. package/dist/components/RteEditor/RteEditor.js.map +1 -1
  50. package/dist/components/RteEditor/helpers.js +11 -11
  51. package/dist/components/StatusBadge/StatusBadge.stories.d.ts +5 -0
  52. package/dist/components/StatusBadge/StatusBadge.stories.js +21 -0
  53. package/dist/components/StatusBadge/StatusBadge.stories.js.map +1 -0
  54. package/dist/components/StatusBadge/StatusBadge.test.d.ts +0 -0
  55. package/dist/components/StatusBadge/StatusBadge.test.js +12 -0
  56. package/dist/components/StatusBadge/StatusBadge.test.js.map +1 -0
  57. package/dist/components/StatusBadge/StatusBage.d.ts +7 -0
  58. package/dist/components/StatusBadge/StatusBage.js +10 -0
  59. package/dist/components/StatusBadge/StatusBage.js.map +1 -0
  60. package/dist/components/StatusBadge/index.d.ts +1 -0
  61. package/dist/components/StatusBadge/index.js +5 -0
  62. package/dist/components/StatusBadge/index.js.map +1 -0
  63. package/dist/components/Timeline/Timeline.test.js +1 -1
  64. package/dist/components/index.d.ts +1 -0
  65. package/dist/components/index.js +21 -19
  66. package/dist/components/index.js.map +1 -1
  67. package/dist/{helpers-BFkCPTTp.js → helpers-D13uK95u.js} +19 -19
  68. package/dist/{helpers-BFkCPTTp.js.map → helpers-D13uK95u.js.map} +1 -1
  69. package/dist/index.js +21 -19
  70. package/dist/index.js.map +1 -1
  71. package/package.json +11 -11
  72. package/dist/Lexical.prod-LIa6Q94i.js.map +0 -1
  73. package/dist/LexicalList.prod-BKa7Tljk.js.map +0 -1
  74. package/dist/LexicalSelection.prod-Cid08b3Z.js +0 -85
  75. package/dist/LexicalTable.prod-B1mw85mv.js +0 -1545
  76. package/dist/LexicalTable.prod-B1mw85mv.js.map +0 -1
  77. package/dist/LexicalUtils.prod-DstvN5hc.js +0 -109
  78. package/dist/LexicalUtils.prod-DstvN5hc.js.map +0 -1
@@ -0,0 +1,1550 @@
1
+ import { w as N, r as X, i as se, _ as mt, j as Et, N as $t, T as pt, S as Mt, L as zt } from "./LexicalUtils.prod-BVZbsLIa.js";
2
+ import { f as Pe, e as ye, U as He, J as Lt, X as ce, O as Ze, T as j, Q as We, _ as Pt, h as Ct, r as V, i as Ht, N as Oe, j as _t, l as z, o as Wt, n as de, d as H, a as L, k as be, m as Bt, p as Dt, q as It, s as Jt, F as Ae, A as Xt, u as Yt, v as St, x as qt, y as I, z as Ut, L as jt, B as Vt, G as Qt, I as Gt, M as Zt, P as en, R as tn, S as re, V as et, g as q, W as Te, Z as nn, b as wt, a0 as on, w as bt, a1 as rn, $ as ln, a2 as Ne, a3 as sn, a4 as an, a5 as tt, a6 as cn, a7 as nt, D as un, a8 as ot, c as rt, Y as Ce, a9 as hn, C as dn, aa as fn, ab as gn } from "./Lexical.prod-Bu-Iw9VX.js";
3
+ import { _ as mn, M as pn } from "./LexicalClipboard.prod-C5dHfEke.js";
4
+ const Be = /^(\d+(?:\.\d+)?)px$/, D = { BOTH: 3, COLUMN: 2, NO_STATUS: 0, ROW: 1 };
5
+ class ee extends Pe {
6
+ static getType() {
7
+ return "tablecell";
8
+ }
9
+ static clone(e) {
10
+ return new ee(e.__headerState, e.__colSpan, e.__width, e.__key);
11
+ }
12
+ afterCloneFrom(e) {
13
+ super.afterCloneFrom(e), this.__rowSpan = e.__rowSpan, this.__backgroundColor = e.__backgroundColor, this.__verticalAlign = e.__verticalAlign;
14
+ }
15
+ static importDOM() {
16
+ return { td: (e) => ({ conversion: lt, priority: 0 }), th: (e) => ({ conversion: lt, priority: 0 }) };
17
+ }
18
+ static importJSON(e) {
19
+ return ge().updateFromJSON(e);
20
+ }
21
+ updateFromJSON(e) {
22
+ 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);
23
+ }
24
+ constructor(e = D.NO_STATUS, t = 1, o, r) {
25
+ super(r), this.__colSpan = t, this.__rowSpan = 1, this.__headerState = e, this.__width = o, this.__backgroundColor = null, this.__verticalAlign = void 0;
26
+ }
27
+ createDOM(e) {
28
+ const t = document.createElement(this.getTag());
29
+ 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), Ee(this.__verticalAlign) && (t.style.verticalAlign = this.__verticalAlign), X(t, e.theme.tableCell, this.hasHeader() && e.theme.tableCellHeader), t;
30
+ }
31
+ exportDOM(e) {
32
+ const t = super.exportDOM(e);
33
+ if (ye(t.element)) {
34
+ const o = t.element;
35
+ 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");
36
+ }
37
+ return t;
38
+ }
39
+ exportJSON() {
40
+ return { ...super.exportJSON(), ...Ee(this.__verticalAlign) && { verticalAlign: this.__verticalAlign }, backgroundColor: this.getBackgroundColor(), colSpan: this.__colSpan, headerState: this.__headerState, rowSpan: this.__rowSpan, width: this.getWidth() };
41
+ }
42
+ getColSpan() {
43
+ return this.getLatest().__colSpan;
44
+ }
45
+ setColSpan(e) {
46
+ const t = this.getWritable();
47
+ return t.__colSpan = e, t;
48
+ }
49
+ getRowSpan() {
50
+ return this.getLatest().__rowSpan;
51
+ }
52
+ setRowSpan(e) {
53
+ const t = this.getWritable();
54
+ return t.__rowSpan = e, t;
55
+ }
56
+ getTag() {
57
+ return this.hasHeader() ? "th" : "td";
58
+ }
59
+ setHeaderStyles(e, t = D.BOTH) {
60
+ const o = this.getWritable();
61
+ return o.__headerState = e & t | o.__headerState & ~t, o;
62
+ }
63
+ getHeaderStyles() {
64
+ return this.getLatest().__headerState;
65
+ }
66
+ setWidth(e) {
67
+ const t = this.getWritable();
68
+ return t.__width = e, t;
69
+ }
70
+ getWidth() {
71
+ return this.getLatest().__width;
72
+ }
73
+ getBackgroundColor() {
74
+ return this.getLatest().__backgroundColor;
75
+ }
76
+ setBackgroundColor(e) {
77
+ const t = this.getWritable();
78
+ return t.__backgroundColor = e, t;
79
+ }
80
+ getVerticalAlign() {
81
+ return this.getLatest().__verticalAlign;
82
+ }
83
+ setVerticalAlign(e) {
84
+ const t = this.getWritable();
85
+ return t.__verticalAlign = e || void 0, t;
86
+ }
87
+ toggleHeaderStyle(e) {
88
+ const t = this.getWritable();
89
+ return (t.__headerState & e) === e ? t.__headerState -= e : t.__headerState += e, t;
90
+ }
91
+ hasHeaderState(e) {
92
+ return (this.getHeaderStyles() & e) === e;
93
+ }
94
+ hasHeader() {
95
+ return this.getLatest().__headerState !== D.NO_STATUS;
96
+ }
97
+ updateDOM(e) {
98
+ 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;
99
+ }
100
+ isShadowRoot() {
101
+ return !0;
102
+ }
103
+ collapseAtStart() {
104
+ return !0;
105
+ }
106
+ canBeEmpty() {
107
+ return !1;
108
+ }
109
+ canIndent() {
110
+ return !1;
111
+ }
112
+ }
113
+ function Ee(n) {
114
+ return n === "middle" || n === "bottom";
115
+ }
116
+ function lt(n) {
117
+ const e = n, t = n.nodeName.toLowerCase();
118
+ let o;
119
+ Be.test(e.style.width) && (o = parseFloat(e.style.width));
120
+ const r = ge(t === "th" ? D.ROW : D.NO_STATUS, e.colSpan, o);
121
+ r.__rowSpan = e.rowSpan;
122
+ const s = e.style.backgroundColor;
123
+ s !== "" && (r.__backgroundColor = s);
124
+ const l = e.style.verticalAlign;
125
+ Ee(l) && (r.__verticalAlign = l);
126
+ 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");
127
+ return { after: (a) => {
128
+ const u = [];
129
+ let g = null;
130
+ const d = () => {
131
+ if (g) {
132
+ const m = g.getFirstChild();
133
+ Ze(m) && g.getChildrenSize() === 1 && m.remove();
134
+ }
135
+ };
136
+ for (const m of a) Lt(m) || ce(m) || Ze(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);
137
+ return d(), u.length === 0 && u.push(j()), u;
138
+ }, node: r };
139
+ }
140
+ function ge(n = D.NO_STATUS, e = 1, t) {
141
+ return He(new ee(n, e, t));
142
+ }
143
+ function S(n) {
144
+ return n instanceof ee;
145
+ }
146
+ const Cn = Wt();
147
+ function w(n, ...e) {
148
+ const t = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams();
149
+ o.append("code", n);
150
+ for (const r of e) o.append("v", r);
151
+ 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.`);
152
+ }
153
+ class me extends Pe {
154
+ static getType() {
155
+ return "tablerow";
156
+ }
157
+ static clone(e) {
158
+ return new me(e.__height, e.__key);
159
+ }
160
+ static importDOM() {
161
+ return { tr: (e) => ({ conversion: _n, priority: 0 }) };
162
+ }
163
+ static importJSON(e) {
164
+ return De().updateFromJSON(e);
165
+ }
166
+ updateFromJSON(e) {
167
+ return super.updateFromJSON(e).setHeight(e.height);
168
+ }
169
+ constructor(e, t) {
170
+ super(t), this.__height = e;
171
+ }
172
+ exportJSON() {
173
+ const e = this.getHeight();
174
+ return { ...super.exportJSON(), ...e === void 0 ? void 0 : { height: e } };
175
+ }
176
+ createDOM(e) {
177
+ const t = document.createElement("tr");
178
+ return this.__height && (t.style.height = `${this.__height}px`), X(t, e.theme.tableRow), t;
179
+ }
180
+ extractWithChild(e, t, o) {
181
+ return o === "html";
182
+ }
183
+ isShadowRoot() {
184
+ return !0;
185
+ }
186
+ setHeight(e) {
187
+ const t = this.getWritable();
188
+ return t.__height = e, t;
189
+ }
190
+ getHeight() {
191
+ return this.getLatest().__height;
192
+ }
193
+ updateDOM(e) {
194
+ return e.__height !== this.__height;
195
+ }
196
+ canBeEmpty() {
197
+ return !1;
198
+ }
199
+ canIndent() {
200
+ return !1;
201
+ }
202
+ }
203
+ function _n(n) {
204
+ const e = n;
205
+ let t;
206
+ return Be.test(e.style.height) && (t = parseFloat(e.style.height)), { after: (o) => mt(o, S), node: De(t) };
207
+ }
208
+ function De(n) {
209
+ return He(new me(n));
210
+ }
211
+ function E(n) {
212
+ return n instanceof me;
213
+ }
214
+ const Ie = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, Sn = Ie && "documentMode" in document ? document.documentMode : null, st = Ie && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
215
+ function wn(n, e, t = !0) {
216
+ const o = qe();
217
+ for (let r = 0; r < n; r++) {
218
+ const s = De();
219
+ for (let l = 0; l < e; l++) {
220
+ let i = D.NO_STATUS;
221
+ typeof t == "object" ? (r === 0 && t.rows && (i |= D.ROW), l === 0 && t.columns && (i |= D.COLUMN)) : t && (r === 0 && (i |= D.ROW), l === 0 && (i |= D.COLUMN));
222
+ const c = ge(i), f = j();
223
+ f.append(We()), c.append(f), s.append(c);
224
+ }
225
+ o.append(s);
226
+ }
227
+ return o;
228
+ }
229
+ function In(n) {
230
+ const e = N(n, (t) => S(t));
231
+ return S(e) ? e : null;
232
+ }
233
+ function yt(n) {
234
+ const e = N(n, (t) => E(t));
235
+ if (E(e)) return e;
236
+ throw new Error("Expected table cell to be inside of table row.");
237
+ }
238
+ function bn(n) {
239
+ const e = N(n, (t) => O(t));
240
+ if (O(e)) return e;
241
+ throw new Error("Expected table cell to be inside of table.");
242
+ }
243
+ function Jn(n) {
244
+ const e = yt(n);
245
+ return bn(e).getChildren().findIndex((t) => t.is(e));
246
+ }
247
+ function Xn(n) {
248
+ return yt(n).getChildren().findIndex((e) => e.is(n));
249
+ }
250
+ Ie && "InputEvent" in window && !Sn && new window.InputEvent("input");
251
+ function Yn(n, e) {
252
+ const t = n.getChildren();
253
+ for (let o = 0; o < t.length; o++) {
254
+ const r = t[o];
255
+ if (E(r)) {
256
+ const s = r.getChildren();
257
+ if (e >= s.length || e < 0) throw new Error("Table column target index out of range");
258
+ s[e].remove();
259
+ }
260
+ }
261
+ return n;
262
+ }
263
+ function U(n, e, t) {
264
+ const [o, r, s] = Je(n, e, t);
265
+ return r === null && w(207), s === null && w(208), [o, r, s];
266
+ }
267
+ function Je(n, e, t) {
268
+ const o = [];
269
+ let r = null, s = null;
270
+ function l(c) {
271
+ let f = o[c];
272
+ return f === void 0 && (o[c] = f = []), f;
273
+ }
274
+ const i = n.getChildren();
275
+ for (let c = 0; c < i.length; c++) {
276
+ const f = i[c];
277
+ E(f) || w(209);
278
+ const h = l(c);
279
+ for (let p = f.getFirstChild(), C = 0; p != null; p = p.getNextSibling()) {
280
+ for (S(p) || w(147); h[C] !== void 0; ) C++;
281
+ const a = { cell: p, startColumn: C, startRow: c }, { __rowSpan: u, __colSpan: g } = p;
282
+ for (let d = 0; d < u && !(c + d >= i.length); d++) {
283
+ const m = l(c + d);
284
+ for (let _ = 0; _ < g; _++) m[C + _] = a;
285
+ }
286
+ e !== null && r === null && e.is(p) && (r = a), t !== null && s === null && t.is(p) && (s = a);
287
+ }
288
+ }
289
+ return [o, r, s];
290
+ }
291
+ function le(n) {
292
+ let e;
293
+ if (n instanceof ee) e = n;
294
+ else if ("__type" in n) {
295
+ const r = N(n, S);
296
+ S(r) || w(148), e = r;
297
+ } else {
298
+ const r = N(n.getNode(), S);
299
+ S(r) || w(148), e = r;
300
+ }
301
+ const t = e.getParent();
302
+ E(t) || w(149);
303
+ const o = t.getParent();
304
+ return O(o) || w(210), [e, t, o];
305
+ }
306
+ function $e(n, e, t) {
307
+ let o, r = Math.min(e.startColumn, t.startColumn), s = Math.min(e.startRow, t.startRow), l = 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);
308
+ do {
309
+ o = !1;
310
+ for (let c = 0; c < n.length; c++) for (let f = 0; f < n[0].length; f++) {
311
+ const h = n[c][f];
312
+ if (!h) continue;
313
+ const p = h.startColumn + h.cell.__colSpan - 1, C = h.startRow + h.cell.__rowSpan - 1, a = h.startColumn <= l && p >= r, u = h.startRow <= i && C >= s;
314
+ if (a && u) {
315
+ const g = Math.min(r, h.startColumn), d = Math.max(l, p), m = Math.min(s, h.startRow), _ = Math.max(i, C);
316
+ g === r && d === l && m === s && _ === i || (r = g, l = d, s = m, i = _, o = !0);
317
+ }
318
+ }
319
+ } while (o);
320
+ return { maxColumn: l, maxRow: i, minColumn: r, minRow: s };
321
+ }
322
+ function it(n) {
323
+ const [e, , t] = le(n), o = t.getChildren(), r = o.length, s = o[0].getChildren().length, l = new Array(r);
324
+ for (let i = 0; i < r; i++) l[i] = new Array(s);
325
+ for (let i = 0; i < r; i++) {
326
+ const c = o[i].getChildren();
327
+ let f = 0;
328
+ for (let h = 0; h < c.length; h++) {
329
+ for (; l[i][f]; ) f++;
330
+ const p = c[h], C = p.__rowSpan || 1, a = p.__colSpan || 1;
331
+ for (let u = 0; u < C; u++) for (let g = 0; g < a; g++) l[i + u][f + g] = p;
332
+ if (e === p) return { colSpan: a, columnIndex: f, rowIndex: i, rowSpan: C };
333
+ f += a;
334
+ }
335
+ }
336
+ return null;
337
+ }
338
+ function at(n) {
339
+ const [[e, t, o, r], [s, l, i, c]] = ["anchor", "focus"].map((f) => {
340
+ const h = n[f].getNode(), p = N(h, S);
341
+ S(p) || w(238, f, h.getKey(), h.getType());
342
+ const C = p.getParent();
343
+ E(C) || w(239, f);
344
+ const a = C.getParent();
345
+ return O(a) || w(240, f), [h, p, C, a];
346
+ });
347
+ return r.is(c) || w(241), { anchorCell: t, anchorNode: e, anchorRow: o, anchorTable: r, focusCell: l, focusNode: s, focusRow: i, focusTable: c };
348
+ }
349
+ class Fe {
350
+ constructor(e, t, o) {
351
+ this.anchor = t, this.focus = o, t._selection = this, o._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = e;
352
+ }
353
+ getStartEndPoints() {
354
+ return [this.anchor, this.focus];
355
+ }
356
+ isValid() {
357
+ return this.tableKey !== "root" && this.anchor.key !== "root" && this.anchor.type === "element" && this.focus.key !== "root" && this.focus.type === "element";
358
+ }
359
+ isBackward() {
360
+ return this.focus.isBefore(this.anchor);
361
+ }
362
+ getCachedNodes() {
363
+ return this._cachedNodes;
364
+ }
365
+ setCachedNodes(e) {
366
+ this._cachedNodes = e;
367
+ }
368
+ is(e) {
369
+ return R(e) && this.tableKey === e.tableKey && this.anchor.is(e.anchor) && this.focus.is(e.focus);
370
+ }
371
+ set(e, t, o) {
372
+ 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;
373
+ }
374
+ clone() {
375
+ 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));
376
+ }
377
+ isCollapsed() {
378
+ return !1;
379
+ }
380
+ extract() {
381
+ return this.getNodes();
382
+ }
383
+ insertRawText(e) {
384
+ }
385
+ insertText() {
386
+ }
387
+ hasFormat(e) {
388
+ let t = 0;
389
+ this.getNodes().filter(S).forEach((r) => {
390
+ const s = r.getFirstChild();
391
+ bt(s) && (t |= s.getTextFormat());
392
+ });
393
+ const o = gn[e];
394
+ return !!(t & o);
395
+ }
396
+ insertNodes(e) {
397
+ const t = this.focus.getNode();
398
+ H(t) || w(151), dn(t.select(0, t.getChildrenSize())).insertNodes(e);
399
+ }
400
+ getShape() {
401
+ const { anchorCell: e, focusCell: t } = at(this), o = it(e);
402
+ o === null && w(153);
403
+ const r = it(t);
404
+ r === null && w(155);
405
+ const s = Math.min(o.columnIndex, r.columnIndex), l = Math.max(o.columnIndex + o.colSpan - 1, r.columnIndex + r.colSpan - 1), i = Math.min(o.rowIndex, r.rowIndex), c = Math.max(o.rowIndex + o.rowSpan - 1, r.rowIndex + r.rowSpan - 1);
406
+ return { fromX: Math.min(s, l), fromY: Math.min(i, c), toX: Math.max(s, l), toY: Math.max(i, c) };
407
+ }
408
+ getNodes() {
409
+ if (!this.isValid()) return [];
410
+ const e = this._cachedNodes;
411
+ if (e !== null) return e;
412
+ const { anchorTable: t, anchorCell: o, focusCell: r } = at(this), s = r.getParents()[1];
413
+ if (s !== t) {
414
+ if (t.isParentOf(r)) {
415
+ const d = s.getParent();
416
+ d == null && w(159), this.set(this.tableKey, r.getKey(), d.getKey());
417
+ } else {
418
+ const d = t.getParent();
419
+ d == null && w(158), this.set(this.tableKey, d.getKey(), r.getKey());
420
+ }
421
+ return this.getNodes();
422
+ }
423
+ const [l, i, c] = U(t, o, r), { minColumn: f, maxColumn: h, minRow: p, maxRow: C } = $e(l, i, c), a = /* @__PURE__ */ new Map([[t.getKey(), t]]);
424
+ let u = null;
425
+ for (let d = p; d <= C; d++) for (let m = f; m <= h; m++) {
426
+ const { cell: _ } = l[d][m], b = _.getParent();
427
+ E(b) || w(160), b !== u && (a.set(b.getKey(), b), u = b), a.has(_.getKey()) || Nn(_, (y) => {
428
+ a.set(y.getKey(), y);
429
+ });
430
+ }
431
+ const g = Array.from(a.values());
432
+ return fn() || (this._cachedNodes = g), g;
433
+ }
434
+ getTextContent() {
435
+ const e = this.getNodes().filter((o) => S(o));
436
+ let t = "";
437
+ for (let o = 0; o < e.length; o++) {
438
+ const r = e[o], s = r.__parent, l = (e[o + 1] || {}).__parent;
439
+ t += r.getTextContent() + (l !== s ? `
440
+ ` : " ");
441
+ }
442
+ return t;
443
+ }
444
+ }
445
+ function R(n) {
446
+ return n instanceof Fe;
447
+ }
448
+ function Nt() {
449
+ const n = Ne("root", 0, "element"), e = Ne("root", 0, "element");
450
+ return new Fe("root", n, e);
451
+ }
452
+ function yn(n, e, t) {
453
+ n.getKey(), e.getKey(), t.getKey();
454
+ const o = L(), r = R(o) ? o.clone() : Nt();
455
+ return r.set(n.getKey(), e.getKey(), t.getKey()), r;
456
+ }
457
+ function Nn(n, e) {
458
+ const t = [[n]];
459
+ for (let o = t.at(-1); o !== void 0 && t.length > 0; o = t.at(-1)) {
460
+ const r = o.pop();
461
+ r === void 0 ? t.pop() : e(r) !== !1 && H(r) && t.push(r.getChildren());
462
+ }
463
+ }
464
+ function xt(n, e = Ct()) {
465
+ const t = be(n);
466
+ O(t) || w(231, n);
467
+ const o = G(t, e.getElementByKey(n));
468
+ return o === null && w(232, n), { tableElement: o, tableNode: t };
469
+ }
470
+ class xn {
471
+ constructor(e, t) {
472
+ 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();
473
+ }
474
+ getTable() {
475
+ return this.table;
476
+ }
477
+ removeListeners() {
478
+ this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach((e) => e()), this.listenersToRemove.clear();
479
+ }
480
+ $lookup() {
481
+ return xt(this.tableNodeKey, this.editor);
482
+ }
483
+ trackTable() {
484
+ const e = new MutationObserver((t) => {
485
+ this.editor.getEditorState().read(() => {
486
+ let o = !1;
487
+ for (let l = 0; l < t.length; l++) {
488
+ const i = t[l].target.nodeName;
489
+ if (i === "TABLE" || i === "TBODY" || i === "THEAD" || i === "TR") {
490
+ o = !0;
491
+ break;
492
+ }
493
+ }
494
+ if (!o) return;
495
+ const { tableNode: r, tableElement: s } = this.$lookup();
496
+ this.table = ie(r, s);
497
+ }, { editor: this.editor });
498
+ });
499
+ this.editor.getEditorState().read(() => {
500
+ const { tableNode: t, tableElement: o } = this.$lookup();
501
+ this.table = ie(t, o), e.observe(o, { attributes: !0, childList: !0, subtree: !0 });
502
+ }, { editor: this.editor });
503
+ }
504
+ $clearHighlight() {
505
+ const e = this.editor;
506
+ 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();
507
+ const { tableNode: t, tableElement: o } = this.$lookup();
508
+ _e(e, ie(t, o), null), L() !== null && (q(null), e.dispatchCommand(re, void 0));
509
+ }
510
+ $enableHighlightStyle() {
511
+ const e = this.editor, { tableElement: t } = this.$lookup();
512
+ se(t, e._config.theme.tableSelection), t.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1;
513
+ }
514
+ $disableHighlightStyle() {
515
+ const { tableElement: e } = this.$lookup();
516
+ X(e, this.editor._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0;
517
+ }
518
+ $updateTableTableSelection(e) {
519
+ if (e !== null) {
520
+ e.tableKey !== this.tableNodeKey && w(233, e.tableKey, this.tableNodeKey);
521
+ const t = this.editor;
522
+ this.tableSelection = e, this.isHighlightingCells = !0, this.$disableHighlightStyle(), this.updateDOMSelection(), _e(t, this.table, this.tableSelection);
523
+ } else this.$clearHighlight();
524
+ }
525
+ setShouldCheckSelection() {
526
+ this.shouldCheckSelection = !0;
527
+ }
528
+ getAndClearShouldCheckSelection() {
529
+ return !!this.shouldCheckSelection && (this.shouldCheckSelection = !1, !0);
530
+ }
531
+ setNextFocus(e) {
532
+ this.nextFocus = e;
533
+ }
534
+ getAndClearNextFocus() {
535
+ const { nextFocus: e } = this;
536
+ return e !== null && (this.nextFocus = null), e;
537
+ }
538
+ updateDOMSelection() {
539
+ if (this.anchorCell !== null && this.focusCell !== null) {
540
+ const e = Te(this.editor._window);
541
+ e && e.rangeCount > 0 && e.removeAllRanges();
542
+ }
543
+ }
544
+ $setFocusCellForSelection(e, t = !1) {
545
+ const o = this.editor, { tableNode: r } = this.$lookup(), s = e.x, l = e.y;
546
+ if (this.focusCell = e, this.isHighlightingCells || this.anchorX === s && this.anchorY === l && !t) {
547
+ if (s === this.focusX && l === this.focusY) return !1;
548
+ } else this.isHighlightingCells = !0, this.$disableHighlightStyle();
549
+ if (this.focusX = s, this.focusY = l, this.isHighlightingCells) {
550
+ const i = ze(r, e.elem);
551
+ if (this.tableSelection != null && this.anchorCellNodeKey != null && i !== null) return this.focusCellNodeKey = i.getKey(), this.tableSelection = yn(r, this.$getAnchorTableCellOrThrow(), i), q(this.tableSelection), o.dispatchCommand(re, void 0), _e(o, this.table, this.tableSelection), !0;
552
+ }
553
+ return !1;
554
+ }
555
+ $getAnchorTableCell() {
556
+ return this.anchorCellNodeKey ? be(this.anchorCellNodeKey) : null;
557
+ }
558
+ $getAnchorTableCellOrThrow() {
559
+ const e = this.$getAnchorTableCell();
560
+ return e === null && w(234), e;
561
+ }
562
+ $getFocusTableCell() {
563
+ return this.focusCellNodeKey ? be(this.focusCellNodeKey) : null;
564
+ }
565
+ $getFocusTableCellOrThrow() {
566
+ const e = this.$getFocusTableCell();
567
+ return e === null && w(235), e;
568
+ }
569
+ $setAnchorCellForSelection(e) {
570
+ this.isHighlightingCells = !1, this.anchorCell = e, this.anchorX = e.x, this.anchorY = e.y;
571
+ const { tableNode: t } = this.$lookup(), o = ze(t, e.elem);
572
+ if (o !== null) {
573
+ const r = o.getKey();
574
+ this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : Nt(), this.anchorCellNodeKey = r;
575
+ }
576
+ }
577
+ $formatCells(e) {
578
+ const t = L();
579
+ R(t) || w(236);
580
+ const o = on(), r = o.anchor, s = o.focus, l = t.getNodes().filter(S);
581
+ l.length > 0 || w(237);
582
+ const i = l[0].getFirstChild(), c = bt(i) ? i.getFormatFlags(e, null) : null;
583
+ l.forEach((f) => {
584
+ r.set(f.getKey(), 0, "element"), s.set(f.getKey(), f.getChildrenSize(), "element"), o.formatText(e, c);
585
+ }), q(t), this.editor.dispatchCommand(re, void 0);
586
+ }
587
+ $clearText() {
588
+ const { editor: e } = this, t = be(this.tableNodeKey);
589
+ if (!O(t)) throw new Error("Expected TableNode.");
590
+ const o = L();
591
+ R(o) || w(253);
592
+ const r = o.getNodes().filter(S);
593
+ if (r.length === this.table.columns * this.table.rows) {
594
+ t.selectPrevious();
595
+ const s = t.getParent();
596
+ return t.remove(), void (rn(s) && s.isEmpty() && e.dispatchCommand(wt, void 0));
597
+ }
598
+ r.forEach((s) => {
599
+ if (H(s)) {
600
+ const l = j(), i = We();
601
+ l.append(i), s.append(l), s.getChildren().forEach((c) => {
602
+ c !== l && c.remove();
603
+ });
604
+ }
605
+ }), _e(e, this.table, null), q(null), e.dispatchCommand(re, void 0);
606
+ }
607
+ }
608
+ const Me = "__lexicalTableSelection", Tn = (n) => !(1 & ~n.buttons);
609
+ function oe(n) {
610
+ return ye(n) && n.nodeName === "TABLE";
611
+ }
612
+ function G(n, e) {
613
+ if (!e) return e;
614
+ const t = oe(e) ? e : n.getDOMSlot(e).element;
615
+ return t.nodeName !== "TABLE" && w(245, e.nodeName), t;
616
+ }
617
+ function Xe(n) {
618
+ return n._window;
619
+ }
620
+ function fe(n, e) {
621
+ for (let t = e, o = null; t !== null; t = t.getParent()) {
622
+ if (n.is(t)) return o;
623
+ S(t) && (o = t);
624
+ }
625
+ return null;
626
+ }
627
+ const Fn = [[Bt, "down"], [Dt, "up"], [It, "backward"], [Jt, "forward"]], vn = [Yt, St, qt], Rn = [Ut, jt];
628
+ function Kn(n, e, t, o) {
629
+ const r = t.getRootElement(), s = Xe(t);
630
+ r !== null && s !== null || w(246);
631
+ const l = new xn(t, n.getKey()), i = G(n, e);
632
+ (function(a, u) {
633
+ ct(a) !== null && w(205), a[Me] = u;
634
+ })(i, l), l.listenersToRemove.add(() => function(a, u) {
635
+ ct(a) === u && delete a[Me];
636
+ }(i, l));
637
+ const c = (a) => {
638
+ if (l.pointerType = a.pointerType, a.button !== 0 || !de(a.target) || !s) return;
639
+ const u = xe(a.target);
640
+ u !== null && t.update(() => {
641
+ const g = et();
642
+ if (st && a.shiftKey && J(g, n) && (z(g) || R(g))) {
643
+ const d = g.anchor.getNode(), m = fe(n, g.anchor.getNode());
644
+ m ? (l.$setAnchorCellForSelection(Q(l, m)), l.$setFocusCellForSelection(u), Y(a)) : (n.isBefore(d) ? n.selectStart() : n.selectEnd()).anchor.set(g.anchor.key, g.anchor.offset, g.anchor.type);
645
+ } else l.$setAnchorCellForSelection(u);
646
+ }), (() => {
647
+ if (l.isSelecting) return;
648
+ const g = () => {
649
+ l.isSelecting = !1, s.removeEventListener("pointerup", g), s.removeEventListener("pointermove", d);
650
+ }, d = (m) => {
651
+ if (!Tn(m) && l.isSelecting) return l.isSelecting = !1, s.removeEventListener("pointerup", g), void s.removeEventListener("pointermove", d);
652
+ if (!de(m.target)) return;
653
+ let _ = null;
654
+ const b = !(st || i.contains(m.target));
655
+ if (b) _ = ut(i, m.target);
656
+ else for (const y of document.elementsFromPoint(m.clientX, m.clientY)) if (_ = ut(i, y), _) break;
657
+ !_ || l.focusCell !== null && _.elem === l.focusCell.elem || (l.setNextFocus({ focusCell: _, override: b }), t.dispatchCommand(re, void 0));
658
+ };
659
+ l.isSelecting = !0, s.addEventListener("pointerup", g, l.listenerOptions), s.addEventListener("pointermove", d, l.listenerOptions);
660
+ })();
661
+ };
662
+ i.addEventListener("pointerdown", c, l.listenerOptions), l.listenersToRemove.add(() => {
663
+ i.removeEventListener("pointerdown", c);
664
+ });
665
+ const f = (a) => {
666
+ a.detail >= 3 && de(a.target) && xe(a.target) !== null && a.preventDefault();
667
+ };
668
+ i.addEventListener("mousedown", f, l.listenerOptions), l.listenersToRemove.add(() => {
669
+ i.removeEventListener("mousedown", f);
670
+ });
671
+ const h = (a) => {
672
+ const u = a.target;
673
+ a.button === 0 && de(u) && t.update(() => {
674
+ const g = L();
675
+ R(g) && g.tableKey === l.tableNodeKey && r.contains(u) && l.$clearHighlight();
676
+ });
677
+ };
678
+ s.addEventListener("pointerdown", h, l.listenerOptions), l.listenersToRemove.add(() => {
679
+ s.removeEventListener("pointerdown", h);
680
+ });
681
+ for (const [a, u] of Fn) l.listenersToRemove.add(t.registerCommand(a, (g) => vt(t, g, u, n, l), Ae));
682
+ l.listenersToRemove.add(t.registerCommand(Xt, (a) => {
683
+ const u = L();
684
+ if (R(u)) {
685
+ const g = fe(n, u.focus.getNode());
686
+ if (g !== null) return Y(a), g.selectEnd(), !0;
687
+ }
688
+ return !1;
689
+ }, Ae));
690
+ const p = (a) => () => {
691
+ const u = L();
692
+ if (!J(u, n)) return !1;
693
+ if (R(u)) return l.$clearText(), !0;
694
+ if (z(u)) {
695
+ if (!S(fe(n, u.anchor.getNode()))) return !1;
696
+ const g = u.anchor.getNode(), d = u.focus.getNode(), m = n.isParentOf(g), _ = n.isParentOf(d);
697
+ if (m && !_ || _ && !m) return l.$clearText(), !0;
698
+ const b = N(u.anchor.getNode(), (x) => H(x)), y = b && N(b, (x) => H(x) && S(x.getParent()));
699
+ if (!H(y) || !H(b)) return !1;
700
+ if (a === St && y.getPreviousSibling() === null) return !0;
701
+ }
702
+ return !1;
703
+ };
704
+ for (const a of vn) l.listenersToRemove.add(t.registerCommand(a, p(a), I));
705
+ const C = (a) => {
706
+ const u = L();
707
+ if (!R(u) && !z(u)) return !1;
708
+ const g = n.isParentOf(u.anchor.getNode());
709
+ if (g !== n.isParentOf(u.focus.getNode())) {
710
+ const d = g ? "anchor" : "focus", m = g ? "focus" : "anchor", { key: _, offset: b, type: y } = u[m];
711
+ return n[u[d].isBefore(u[m]) ? "selectPrevious" : "selectNext"]()[m].set(_, b, y), !1;
712
+ }
713
+ return !!J(u, n) && !!R(u) && (a && (a.preventDefault(), a.stopPropagation()), l.$clearText(), !0);
714
+ };
715
+ for (const a of Rn) l.listenersToRemove.add(t.registerCommand(a, C, I));
716
+ return l.listenersToRemove.add(t.registerCommand(Vt, (a) => {
717
+ const u = L();
718
+ if (u) {
719
+ if (!R(u) && !z(u)) return !1;
720
+ mn(t, zt(a, ClipboardEvent) ? a : null, pn(u));
721
+ const g = C(a);
722
+ return z(u) ? (u.removeText(), !0) : g;
723
+ }
724
+ return !1;
725
+ }, I)), l.listenersToRemove.add(t.registerCommand(Qt, (a) => {
726
+ const u = L();
727
+ if (!J(u, n)) return !1;
728
+ if (R(u)) return l.$formatCells(a), !0;
729
+ if (z(u)) {
730
+ const g = N(u.anchor.getNode(), (d) => S(d));
731
+ if (!S(g)) return !1;
732
+ }
733
+ return !1;
734
+ }, I)), l.listenersToRemove.add(t.registerCommand(Gt, (a) => {
735
+ const u = L();
736
+ if (!R(u) || !J(u, n)) return !1;
737
+ const g = u.anchor.getNode(), d = u.focus.getNode();
738
+ if (!S(g) || !S(d)) return !1;
739
+ if (function(T, A) {
740
+ if (R(T)) {
741
+ const F = T.anchor.getNode(), K = T.focus.getNode();
742
+ if (A && F && K) {
743
+ const [M] = U(A, F, K);
744
+ return F.getKey() === M[0][0].cell.getKey() && K.getKey() === M[M.length - 1].at(-1).cell.getKey();
745
+ }
746
+ }
747
+ return !1;
748
+ }(u, n)) return n.setFormat(a), !0;
749
+ 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), k = /* @__PURE__ */ new Set();
750
+ for (let T = v; T <= y; T++) for (let A = $; A <= x; A++) {
751
+ const F = m[T][A].cell;
752
+ if (k.has(F)) continue;
753
+ k.add(F), F.setFormat(a);
754
+ const K = F.getChildren();
755
+ for (let M = 0; M < K.length; M++) {
756
+ const P = K[M];
757
+ H(P) && !P.isInline() && P.setFormat(a);
758
+ }
759
+ }
760
+ return !0;
761
+ }, I)), l.listenersToRemove.add(t.registerCommand(Zt, (a) => {
762
+ const u = L();
763
+ if (!J(u, n)) return !1;
764
+ if (R(u)) return l.$clearHighlight(), !1;
765
+ if (z(u)) {
766
+ const g = N(u.anchor.getNode(), (d) => S(d));
767
+ if (!S(g)) return !1;
768
+ if (typeof a == "string") {
769
+ const d = ft(t, u, n);
770
+ if (d) return dt(d, n, [We(a)]), !0;
771
+ }
772
+ }
773
+ return !1;
774
+ }, I)), o && l.listenersToRemove.add(t.registerCommand(en, (a) => {
775
+ const u = L();
776
+ if (!z(u) || !u.isCollapsed() || !J(u, n)) return !1;
777
+ const g = he(u.anchor.getNode());
778
+ return !(g === null || !n.is(ae(g))) && (Y(a), function(d, m) {
779
+ const _ = m === "next" ? "getNextSibling" : "getPreviousSibling", b = m === "next" ? "getFirstChild" : "getLastChild", y = d[_]();
780
+ if (H(y)) return y.selectEnd();
781
+ const x = N(d, E);
782
+ x === null && w(247);
783
+ for (let $ = x[_](); E($); $ = $[_]()) {
784
+ const k = $[b]();
785
+ if (H(k)) return k.selectEnd();
786
+ }
787
+ const v = N(x, O);
788
+ v === null && w(248), m === "next" ? v.selectNext() : v.selectPrevious();
789
+ }(g, a.shiftKey ? "previous" : "next"), !0);
790
+ }, I)), l.listenersToRemove.add(t.registerCommand(tn, (a) => n.isSelected(), Ae)), l.listenersToRemove.add(t.registerCommand(_t, (a) => {
791
+ 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;
792
+ if (u.length !== 1 || !O(u[0]) || !_ || d === null) return !1;
793
+ const [b] = d, y = u[0], x = y.getChildren(), v = y.getFirstChildOrThrow().getChildrenSize(), $ = y.getChildrenSize(), k = N(b.getNode(), (W) => S(W)), T = k && N(k, (W) => E(W)), A = T && N(T, (W) => O(W));
794
+ if (!S(k) || !E(T) || !O(A)) return !1;
795
+ const F = T.getIndexWithinParent(), K = Math.min(A.getChildrenSize() - 1, F + $ - 1), M = k.getIndexWithinParent(), P = Math.min(T.getChildrenSize() - 1, M + v - 1), ue = Math.min(M, P), ve = Math.min(F, K), Re = Math.max(M, P), B = Math.max(F, K), Kt = A.getChildren();
796
+ let Ue = 0;
797
+ for (let W = ve; W <= B; W++) {
798
+ const je = Kt[W];
799
+ if (!E(je)) return !1;
800
+ const Ve = x[Ue];
801
+ if (!E(Ve)) return !1;
802
+ const Ot = je.getChildren(), At = Ve.getChildren();
803
+ let Qe = 0;
804
+ for (let Ke = ue; Ke <= Re; Ke++) {
805
+ const pe = Ot[Ke];
806
+ if (!S(pe)) return !1;
807
+ const Ge = At[Qe];
808
+ if (!S(Ge)) return !1;
809
+ const kt = pe.getChildren();
810
+ Ge.getChildren().forEach((te) => {
811
+ ce(te) && j().append(te), pe.append(te);
812
+ }), kt.forEach((te) => te.remove()), Qe++;
813
+ }
814
+ Ue++;
815
+ }
816
+ return !0;
817
+ }, I)), l.listenersToRemove.add(t.registerCommand(re, () => {
818
+ const a = L(), u = et(), g = l.getAndClearNextFocus();
819
+ if (g !== null) {
820
+ const { focusCell: d } = g;
821
+ if (R(a) && a.tableKey === l.tableNodeKey) return (d.x !== l.focusX || d.y !== l.focusY) && (l.$setFocusCellForSelection(d), !0);
822
+ if (d !== l.anchorCell && J(a, n)) return l.$setFocusCellForSelection(d), !0;
823
+ }
824
+ if (l.getAndClearShouldCheckSelection() && z(u) && z(a) && a.isCollapsed()) {
825
+ const d = a.anchor.getNode(), m = n.getFirstChild(), _ = he(d);
826
+ if (_ !== null && E(m)) {
827
+ const b = m.getFirstChild();
828
+ if (S(b) && n.is(N(_, (y) => y.is(n) || y.is(b)))) return b.selectStart(), !0;
829
+ }
830
+ }
831
+ if (z(a)) {
832
+ 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))), k = v !== $, T = v && $, A = a.isBackward();
833
+ if (k) {
834
+ const F = a.clone();
835
+ if ($) {
836
+ const [K] = U(n, x, x), M = K[0][0].cell, P = K[K.length - 1].at(-1).cell;
837
+ F.focus.set(A ? M.getKey() : P.getKey(), A ? M.getChildrenSize() : P.getChildrenSize(), "element");
838
+ } else if (v) {
839
+ const [K] = U(n, y, y), M = K[0][0].cell, P = K[K.length - 1].at(-1).cell;
840
+ F.anchor.set(A ? P.getKey() : M.getKey(), A ? P.getChildrenSize() : 0, "element");
841
+ }
842
+ q(F), ht(t, l);
843
+ } else if (T && (y.is(x) || (l.$setAnchorCellForSelection(Q(l, y)), l.$setFocusCellForSelection(Q(l, x), !0)), l.pointerType === "touch" && a.isCollapsed() && z(u) && u.isCollapsed())) {
844
+ const F = he(u.anchor.getNode());
845
+ F && !F.is(x) && (l.$setAnchorCellForSelection(Q(l, F)), l.$setFocusCellForSelection(Q(l, x), !0), l.pointerType = null);
846
+ }
847
+ } else if (a && R(a) && a.is(u) && a.tableKey === n.getKey()) {
848
+ const d = Te(s);
849
+ if (d && d.anchorNode && d.focusNode) {
850
+ const m = V(d.focusNode), _ = m && !n.isParentOf(m), b = V(d.anchorNode), y = b && n.isParentOf(b);
851
+ if (_ && y && d.rangeCount > 0) {
852
+ const x = nn(d, t);
853
+ x && (x.anchor.set(n.getKey(), a.isBackward() ? n.getChildrenSize() : 0, "element"), d.removeAllRanges(), q(x));
854
+ }
855
+ }
856
+ }
857
+ return a && !a.is(u) && (R(a) || R(u)) && l.tableSelection && !l.tableSelection.is(u) ? (R(a) && a.tableKey === l.tableNodeKey ? l.$updateTableTableSelection(a) : !R(a) && R(u) && u.tableKey === l.tableNodeKey && l.$updateTableTableSelection(null), !1) : (l.hasHijackedSelectionStyles && !n.isSelected() ? function(d, m) {
858
+ m.$enableHighlightStyle(), Ye(m.table, (_) => {
859
+ const b = _.elem;
860
+ _.highlighted = !1, Ft(d, _), b.getAttribute("style") || b.removeAttribute("style");
861
+ });
862
+ }(t, l) : !l.hasHijackedSelectionStyles && n.isSelected() && ht(t, l), !1);
863
+ }, I)), l.listenersToRemove.add(t.registerCommand(wt, () => {
864
+ const a = L();
865
+ if (!z(a) || !a.isCollapsed() || !J(a, n)) return !1;
866
+ const u = ft(t, a, n);
867
+ return !!u && (dt(u, n), !0);
868
+ }, I)), l;
869
+ }
870
+ function ct(n) {
871
+ return n[Me] || null;
872
+ }
873
+ function xe(n) {
874
+ let e = n;
875
+ for (; e != null; ) {
876
+ const t = e.nodeName;
877
+ if (t === "TD" || t === "TH") {
878
+ const o = e._cell;
879
+ return o === void 0 ? null : o;
880
+ }
881
+ e = e.parentNode;
882
+ }
883
+ return null;
884
+ }
885
+ function ut(n, e) {
886
+ if (!n.contains(e)) return null;
887
+ let t = null;
888
+ for (let o = e; o != null; o = o.parentNode) {
889
+ if (o === n) return t;
890
+ const r = o.nodeName;
891
+ r !== "TD" && r !== "TH" || (t = o._cell || null);
892
+ }
893
+ return null;
894
+ }
895
+ function ie(n, e) {
896
+ const t = [], o = { columns: 0, domRows: t, rows: 0 };
897
+ let r = G(n, e).querySelector("tr"), s = 0, l = 0;
898
+ for (t.length = 0; r != null; ) {
899
+ const i = r.nodeName;
900
+ if (i === "TD" || i === "TH") {
901
+ const h = { elem: r, hasBackgroundColor: r.style.backgroundColor !== "", highlighted: !1, x: s, y: l };
902
+ r._cell = h;
903
+ let p = t[l];
904
+ p === void 0 && (p = t[l] = []), p[s] = h;
905
+ } else {
906
+ const h = r.firstChild;
907
+ if (h != null) {
908
+ r = h;
909
+ continue;
910
+ }
911
+ }
912
+ const c = r.nextSibling;
913
+ if (c != null) {
914
+ s++, r = c;
915
+ continue;
916
+ }
917
+ const f = r.parentNode;
918
+ if (f != null) {
919
+ const h = f.nextSibling;
920
+ if (h == null) break;
921
+ l++, s = 0, r = h;
922
+ }
923
+ }
924
+ return o.columns = s + 1, o.rows = l + 1, o;
925
+ }
926
+ function _e(n, e, t) {
927
+ const o = new Set(t ? t.getNodes() : []);
928
+ Ye(e, (r, s) => {
929
+ const l = r.elem;
930
+ o.has(s) ? (r.highlighted = !0, Tt(n, r)) : (r.highlighted = !1, Ft(n, r), l.getAttribute("style") || l.removeAttribute("style"));
931
+ });
932
+ }
933
+ function Ye(n, e) {
934
+ const { domRows: t } = n;
935
+ for (let o = 0; o < t.length; o++) {
936
+ const r = t[o];
937
+ if (r) for (let s = 0; s < r.length; s++) {
938
+ const l = r[s];
939
+ if (!l) continue;
940
+ const i = V(l.elem);
941
+ i !== null && e(l, i, { x: s, y: o });
942
+ }
943
+ }
944
+ }
945
+ function ht(n, e) {
946
+ e.$disableHighlightStyle(), Ye(e.table, (t) => {
947
+ t.highlighted = !0, Tt(n, t);
948
+ });
949
+ }
950
+ const On = (n, e, t, o, r) => {
951
+ const s = r === "forward";
952
+ switch (r) {
953
+ case "backward":
954
+ case "forward":
955
+ return t !== (s ? n.table.columns - 1 : 0) ? we(e.getCellNodeFromCordsOrThrow(t + (s ? 1 : -1), o, n.table), s) : o !== (s ? n.table.rows - 1 : 0) ? we(e.getCellNodeFromCordsOrThrow(s ? 0 : n.table.columns - 1, o + (s ? 1 : -1), n.table), s) : s ? e.selectNext() : e.selectPrevious(), !0;
956
+ case "up":
957
+ return o !== 0 ? we(e.getCellNodeFromCordsOrThrow(t, o - 1, n.table), !1) : e.selectPrevious(), !0;
958
+ case "down":
959
+ return o !== n.table.rows - 1 ? we(e.getCellNodeFromCordsOrThrow(t, o + 1, n.table), !0) : e.selectNext(), !0;
960
+ default:
961
+ return !1;
962
+ }
963
+ };
964
+ function ke(n, e) {
965
+ let t, o;
966
+ if (e.startColumn === n.minColumn) t = "minColumn";
967
+ else {
968
+ if (e.startColumn + e.cell.__colSpan - 1 !== n.maxColumn) return null;
969
+ t = "maxColumn";
970
+ }
971
+ if (e.startRow === n.minRow) o = "minRow";
972
+ else {
973
+ if (e.startRow + e.cell.__rowSpan - 1 !== n.maxRow) return null;
974
+ o = "maxRow";
975
+ }
976
+ return [t, o];
977
+ }
978
+ function Se([n, e]) {
979
+ return [n === "minColumn" ? "maxColumn" : "minColumn", e === "minRow" ? "maxRow" : "minRow"];
980
+ }
981
+ function ne(n, e, [t, o]) {
982
+ const r = e[o], s = n[r];
983
+ s === void 0 && w(250, o, String(r));
984
+ const l = e[t], i = s[l];
985
+ return i === void 0 && w(250, t, String(l)), i;
986
+ }
987
+ function An(n, e, t, o, r) {
988
+ const s = $e(e, t, o), l = function(v, $) {
989
+ const { minColumn: k, maxColumn: T, minRow: A, maxRow: F } = $;
990
+ let K = 1, M = 1, P = 1, ue = 1;
991
+ const ve = v[A], Re = v[F];
992
+ for (let B = k; B <= T; B++) K = Math.max(K, ve[B].cell.__rowSpan), ue = Math.max(ue, Re[B].cell.__rowSpan);
993
+ for (let B = A; B <= F; B++) M = Math.max(M, v[B][k].cell.__colSpan), P = Math.max(P, v[B][T].cell.__colSpan);
994
+ return { bottomSpan: ue, leftSpan: M, rightSpan: P, topSpan: K };
995
+ }(e, s), { topSpan: i, leftSpan: c, bottomSpan: f, rightSpan: h } = l, p = function(v, $) {
996
+ const k = ke(v, $);
997
+ return k === null && w(249, $.cell.getKey()), k;
998
+ }(s, t), [C, a] = Se(p);
999
+ let u = s[C], g = s[a];
1000
+ r === "forward" ? u += C === "maxColumn" ? 1 : c : r === "backward" ? u -= C === "minColumn" ? 1 : h : r === "down" ? g += a === "maxRow" ? 1 : i : r === "up" && (g -= a === "minRow" ? 1 : f);
1001
+ const d = e[g];
1002
+ if (d === void 0) return !1;
1003
+ const m = d[u];
1004
+ if (m === void 0) return !1;
1005
+ const [_, b] = function(v, $, k) {
1006
+ const T = $e(v, $, k), A = ke(T, $);
1007
+ if (A) return [ne(v, T, A), ne(v, T, Se(A))];
1008
+ const F = ke(T, k);
1009
+ if (F) return [ne(v, T, Se(F)), ne(v, T, F)];
1010
+ const K = ["minColumn", "minRow"];
1011
+ return [ne(v, T, K), ne(v, T, Se(K))];
1012
+ }(e, t, m), y = Q(n, _.cell), x = Q(n, b.cell);
1013
+ return n.$setAnchorCellForSelection(y), n.$setFocusCellForSelection(x, !0), !0;
1014
+ }
1015
+ function J(n, e) {
1016
+ if (z(n) || R(n)) {
1017
+ const t = e.isParentOf(n.anchor.getNode()), o = e.isParentOf(n.focus.getNode());
1018
+ return t && o;
1019
+ }
1020
+ return !1;
1021
+ }
1022
+ function we(n, e) {
1023
+ e ? n.selectStart() : n.selectEnd();
1024
+ }
1025
+ function Tt(n, e) {
1026
+ const t = e.elem, o = n._config.theme;
1027
+ S(V(t)) || w(131), X(t, o.tableCellSelected);
1028
+ }
1029
+ function Ft(n, e) {
1030
+ const t = e.elem;
1031
+ S(V(t)) || w(131);
1032
+ const o = n._config.theme;
1033
+ se(t, o.tableCellSelected);
1034
+ }
1035
+ function he(n) {
1036
+ const e = N(n, S);
1037
+ return S(e) ? e : null;
1038
+ }
1039
+ function ae(n) {
1040
+ const e = N(n, O);
1041
+ return O(e) ? e : null;
1042
+ }
1043
+ function kn(n, e, t, o, r, s, l) {
1044
+ const i = sn(t.focus, r ? "previous" : "next");
1045
+ if (an(i)) return !1;
1046
+ let c = i;
1047
+ for (const d of tt(i).iterNodeCarets("shadowRoot")) {
1048
+ if (!cn(d) || !H(d.origin)) return !1;
1049
+ c = d;
1050
+ }
1051
+ const f = c.getParentAtCaret();
1052
+ if (!S(f)) return !1;
1053
+ const h = f, p = function(d) {
1054
+ for (const m of tt(d).iterNodeCarets("root")) {
1055
+ const { origin: _ } = m;
1056
+ if (S(_)) {
1057
+ if (nt(m)) return un(_, d.direction);
1058
+ } else if (!E(_)) break;
1059
+ }
1060
+ return null;
1061
+ }(ot(h, c.direction)), C = N(h, O);
1062
+ if (!C || !C.is(s)) return !1;
1063
+ const a = n.getElementByKey(h.getKey()), u = xe(a);
1064
+ if (!a || !u) return !1;
1065
+ const g = En(n, C);
1066
+ if (l.table = g, p) if (o === "extend") {
1067
+ const d = xe(n.getElementByKey(p.origin.getKey()));
1068
+ if (!d) return !1;
1069
+ l.$setAnchorCellForSelection(u), l.$setFocusCellForSelection(d, !0);
1070
+ } else {
1071
+ const d = rt(p);
1072
+ Ce(t.anchor, d), Ce(t.focus, d);
1073
+ }
1074
+ else if (o === "extend") l.$setAnchorCellForSelection(u), l.$setFocusCellForSelection(u, !0);
1075
+ else {
1076
+ const d = function(m) {
1077
+ const _ = hn(m);
1078
+ return nt(_) ? rt(_) : m;
1079
+ }(ot(C, i.direction));
1080
+ Ce(t.anchor, d), Ce(t.focus, d);
1081
+ }
1082
+ return Y(e), !0;
1083
+ }
1084
+ function vt(n, e, t, o, r) {
1085
+ if ((t === "up" || t === "down") && function(l) {
1086
+ const i = l.getRootElement();
1087
+ return i ? i.hasAttribute("aria-controls") && i.getAttribute("aria-controls") === "typeahead-menu" : !1;
1088
+ }(n)) return !1;
1089
+ const s = L();
1090
+ if (!J(s, o)) {
1091
+ if (z(s)) {
1092
+ if (t === "backward") {
1093
+ if (s.focus.offset > 0) return !1;
1094
+ const l = function(c) {
1095
+ for (let f = c, h = c; h !== null; f = h, h = h.getParent()) if (H(h)) {
1096
+ if (h !== f && h.getFirstChild() !== f) return null;
1097
+ if (!h.isInline()) return h;
1098
+ }
1099
+ return null;
1100
+ }(s.focus.getNode());
1101
+ if (!l) return !1;
1102
+ const i = l.getPreviousSibling();
1103
+ return !!O(i) && (Y(e), e.shiftKey ? s.focus.set(i.getParentOrThrow().getKey(), i.getIndexWithinParent(), "element") : i.selectEnd(), !0);
1104
+ }
1105
+ if (e.shiftKey && (t === "up" || t === "down")) {
1106
+ const l = s.focus.getNode();
1107
+ if (!s.isCollapsed() && (t === "up" && !s.isBackward() || t === "down" && s.isBackward())) {
1108
+ let i = N(l, (C) => O(C));
1109
+ if (S(i) && (i = N(i, O)), i !== o || !i) return !1;
1110
+ const c = t === "down" ? i.getNextSibling() : i.getPreviousSibling();
1111
+ if (!c) return !1;
1112
+ let f = 0;
1113
+ t === "up" && H(c) && (f = c.getChildrenSize());
1114
+ let h = c;
1115
+ t === "up" && H(c) && (h = c.getLastChild() || c, f = ce(h) ? h.getTextContentSize() : 0);
1116
+ const p = s.clone();
1117
+ return p.focus.set(h.getKey(), f, ce(h) ? "text" : "element"), q(p), Y(e), !0;
1118
+ }
1119
+ if (ln(l)) {
1120
+ const i = t === "up" ? s.getNodes()[s.getNodes().length - 1] : s.getNodes()[0];
1121
+ if (i && fe(o, i) !== null) {
1122
+ const c = o.getFirstDescendant(), f = o.getLastDescendant();
1123
+ if (!c || !f) return !1;
1124
+ const [h] = le(c), [p] = le(f), C = o.getCordsFromCellNode(h, r.table), a = o.getCordsFromCellNode(p, r.table), u = o.getDOMCellFromCordsOrThrow(C.x, C.y, r.table), g = o.getDOMCellFromCordsOrThrow(a.x, a.y, r.table);
1125
+ return r.$setAnchorCellForSelection(u), r.$setFocusCellForSelection(g, !0), !0;
1126
+ }
1127
+ return !1;
1128
+ }
1129
+ {
1130
+ let i = N(l, (f) => H(f) && !f.isInline());
1131
+ if (S(i) && (i = N(i, O)), !i) return !1;
1132
+ const c = t === "down" ? i.getNextSibling() : i.getPreviousSibling();
1133
+ if (O(c) && r.tableNodeKey === c.getKey()) {
1134
+ const f = c.getFirstDescendant(), h = c.getLastDescendant();
1135
+ if (!f || !h) return !1;
1136
+ const [p] = le(f), [C] = le(h), a = s.clone();
1137
+ return a.focus.set((t === "up" ? p : C).getKey(), t === "up" ? 0 : C.getChildrenSize(), "element"), Y(e), q(a), !0;
1138
+ }
1139
+ }
1140
+ }
1141
+ }
1142
+ return t === "down" && Rt(n) && r.setShouldCheckSelection(), !1;
1143
+ }
1144
+ if (z(s)) {
1145
+ if (t === "backward" || t === "forward")
1146
+ return kn(n, e, s, e.shiftKey ? "extend" : "move", t === "backward", o, r);
1147
+ if (s.isCollapsed()) {
1148
+ const { anchor: l, focus: i } = s, c = N(l.getNode(), S), f = N(i.getNode(), S);
1149
+ if (!S(c) || !c.is(f)) return !1;
1150
+ const h = ae(c);
1151
+ if (h !== o && h != null) {
1152
+ const m = G(h, n.getElementByKey(h.getKey()));
1153
+ if (m != null) return r.table = ie(h, m), vt(n, e, t, h, r);
1154
+ }
1155
+ const p = n.getElementByKey(c.__key), C = n.getElementByKey(l.key);
1156
+ if (C == null || p == null) return !1;
1157
+ let a;
1158
+ if (l.type === "element") a = C.getBoundingClientRect();
1159
+ else {
1160
+ const m = Te(Xe(n));
1161
+ if (m === null || m.rangeCount === 0) return !1;
1162
+ a = m.getRangeAt(0).getBoundingClientRect();
1163
+ }
1164
+ const u = t === "up" ? c.getFirstChild() : c.getLastChild();
1165
+ if (u == null) return !1;
1166
+ const g = n.getElementByKey(u.__key);
1167
+ if (g == null) return !1;
1168
+ const d = g.getBoundingClientRect();
1169
+ if (t === "up" ? d.top > a.top - a.height : a.bottom + a.height > d.bottom) {
1170
+ Y(e);
1171
+ const m = o.getCordsFromCellNode(c, r.table);
1172
+ if (!e.shiftKey) return On(r, o, m.x, m.y, t);
1173
+ {
1174
+ const _ = o.getDOMCellFromCordsOrThrow(m.x, m.y, r.table);
1175
+ r.$setAnchorCellForSelection(_), r.$setFocusCellForSelection(_, !0);
1176
+ }
1177
+ return !0;
1178
+ }
1179
+ }
1180
+ } else if (R(s)) {
1181
+ const { anchor: l, focus: i } = s, c = N(l.getNode(), S), f = N(i.getNode(), S), [h] = s.getNodes();
1182
+ O(h) || w(251);
1183
+ const p = G(h, n.getElementByKey(h.getKey()));
1184
+ if (!S(c) || !S(f) || !O(h) || p == null) return !1;
1185
+ r.$updateTableTableSelection(s);
1186
+ const C = ie(h, p), a = o.getCordsFromCellNode(c, C), u = o.getDOMCellFromCordsOrThrow(a.x, a.y, C);
1187
+ if (r.$setAnchorCellForSelection(u), Y(e), e.shiftKey) {
1188
+ const [g, d, m] = U(o, c, f);
1189
+ return An(r, g, d, m, t);
1190
+ }
1191
+ return f.selectEnd(), !0;
1192
+ }
1193
+ return !1;
1194
+ }
1195
+ function Y(n) {
1196
+ n.preventDefault(), n.stopImmediatePropagation(), n.stopPropagation();
1197
+ }
1198
+ function dt(n, e, t) {
1199
+ const o = j();
1200
+ n === "first" ? e.insertBefore(o) : e.insertAfter(o), o.append(...t || []), o.selectEnd();
1201
+ }
1202
+ function ft(n, e, t) {
1203
+ const o = t.getParent();
1204
+ if (!o) return;
1205
+ const r = Te(Xe(n));
1206
+ if (!r) return;
1207
+ const s = r.anchorNode, l = n.getElementByKey(o.getKey()), i = G(t, n.getElementByKey(t.getKey()));
1208
+ if (!s || !l || !i || !l.contains(s) || i.contains(s)) return;
1209
+ const c = N(e.anchor.getNode(), (_) => S(_));
1210
+ if (!c) return;
1211
+ const f = N(c, (_) => O(_));
1212
+ if (!O(f) || !f.is(t)) return;
1213
+ 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;
1214
+ return d ? "first" : m ? "last" : void 0;
1215
+ }
1216
+ function Q(n, e) {
1217
+ const { tableNode: t } = n.$lookup(), o = t.getCordsFromCellNode(e, n.table);
1218
+ return t.getDOMCellFromCordsOrThrow(o.x, o.y, n.table);
1219
+ }
1220
+ function ze(n, e, t) {
1221
+ return fe(n, V(e, t));
1222
+ }
1223
+ function gt(n, e, t) {
1224
+ if (!e.theme.tableAlignment) return;
1225
+ const o = [], r = [];
1226
+ for (const s of ["center", "right"]) {
1227
+ const l = e.theme.tableAlignment[s];
1228
+ l && (s === t ? r : o).push(l);
1229
+ }
1230
+ se(n, ...o), X(n, ...r);
1231
+ }
1232
+ const Le = /* @__PURE__ */ new WeakSet();
1233
+ function Rt(n = Ct()) {
1234
+ return Le.has(n);
1235
+ }
1236
+ function qn(n, e) {
1237
+ e ? Le.add(n) : Le.delete(n);
1238
+ }
1239
+ class Z extends Pe {
1240
+ static getType() {
1241
+ return "table";
1242
+ }
1243
+ getColWidths() {
1244
+ return this.getLatest().__colWidths;
1245
+ }
1246
+ setColWidths(e) {
1247
+ const t = this.getWritable();
1248
+ return t.__colWidths = e, t;
1249
+ }
1250
+ static clone(e) {
1251
+ return new Z(e.__key);
1252
+ }
1253
+ afterCloneFrom(e) {
1254
+ super.afterCloneFrom(e), this.__colWidths = e.__colWidths, this.__rowStriping = e.__rowStriping, this.__frozenColumnCount = e.__frozenColumnCount, this.__frozenRowCount = e.__frozenRowCount;
1255
+ }
1256
+ static importDOM() {
1257
+ return { table: (e) => ({ conversion: $n, priority: 1 }) };
1258
+ }
1259
+ static importJSON(e) {
1260
+ return qe().updateFromJSON(e);
1261
+ }
1262
+ updateFromJSON(e) {
1263
+ return super.updateFromJSON(e).setRowStriping(e.rowStriping || !1).setFrozenColumns(e.frozenColumnCount || 0).setFrozenRows(e.frozenRowCount || 0).setColWidths(e.colWidths);
1264
+ }
1265
+ constructor(e) {
1266
+ super(e), this.__rowStriping = !1, this.__frozenColumnCount = 0, this.__frozenRowCount = 0;
1267
+ }
1268
+ exportJSON() {
1269
+ 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 };
1270
+ }
1271
+ extractWithChild(e, t, o) {
1272
+ return o === "html";
1273
+ }
1274
+ getDOMSlot(e) {
1275
+ const t = oe(e) ? e : e.querySelector("table");
1276
+ return oe(t) || w(229), super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"));
1277
+ }
1278
+ createDOM(e, t) {
1279
+ const o = document.createElement("table");
1280
+ this.__style && (o.style.cssText = this.__style);
1281
+ const r = document.createElement("colgroup");
1282
+ if (o.appendChild(r), Pt(r), X(o, e.theme.table), this.updateTableElement(null, o, e), Rt(t)) {
1283
+ const s = document.createElement("div"), l = e.theme.tableScrollableWrapper;
1284
+ return l ? X(s, l) : s.style.cssText = "overflow-x: auto;", s.appendChild(o), s;
1285
+ }
1286
+ return o;
1287
+ }
1288
+ updateTableElement(e, t, o) {
1289
+ this.__style !== (e ? e.__style : "") && (t.style.cssText = this.__style), this.__rowStriping !== (!!e && e.__rowStriping) && function(r, s, l) {
1290
+ l ? (X(r, s.theme.tableRowStriping), r.setAttribute("data-lexical-row-striping", "true")) : (se(r, s.theme.tableRowStriping), r.removeAttribute("data-lexical-row-striping"));
1291
+ }(t, o, this.__rowStriping), this.__frozenColumnCount !== (e ? e.__frozenColumnCount : 0) && function(r, s, l) {
1292
+ l > 0 ? (X(r, s.theme.tableFrozenColumn), r.setAttribute("data-lexical-frozen-column", "true")) : (se(r, s.theme.tableFrozenColumn), r.removeAttribute("data-lexical-frozen-column"));
1293
+ }(t, o, this.__frozenColumnCount), this.__frozenRowCount !== (e ? e.__frozenRowCount : 0) && function(r, s, l) {
1294
+ l > 0 ? (X(r, s.theme.tableFrozenRow), r.setAttribute("data-lexical-frozen-row", "true")) : (se(r, s.theme.tableFrozenRow), r.removeAttribute("data-lexical-frozen-row"));
1295
+ }(t, o, this.__frozenRowCount), function(r, s, l, i) {
1296
+ const c = r.querySelector("colgroup");
1297
+ if (!c) return;
1298
+ const f = [];
1299
+ for (let h = 0; h < l; h++) {
1300
+ const p = document.createElement("col"), C = i && i[h];
1301
+ C && (p.style.width = `${C}px`), f.push(p);
1302
+ }
1303
+ c.replaceChildren(...f);
1304
+ }(t, 0, this.getColumnCount(), this.getColWidths()), gt(t, o, this.getFormatType());
1305
+ }
1306
+ updateDOM(e, t, o) {
1307
+ return this.updateTableElement(e, this.getDOMSlot(t).element, o), !1;
1308
+ }
1309
+ exportDOM(e) {
1310
+ const t = super.exportDOM(e), { element: o } = t;
1311
+ return { after: (r) => {
1312
+ if (t.after && (r = t.after(r)), !oe(r) && ye(r) && (r = r.querySelector("table")), !oe(r)) return null;
1313
+ gt(r, e._config, this.getFormatType());
1314
+ const [s] = Je(this, null, null), l = /* @__PURE__ */ new Map();
1315
+ for (const h of s) for (const p of h) {
1316
+ const C = p.cell.getKey();
1317
+ l.has(C) || l.set(C, { colSpan: p.cell.getColSpan(), startColumn: p.startColumn });
1318
+ }
1319
+ const i = /* @__PURE__ */ new Set();
1320
+ for (const h of r.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")) {
1321
+ const p = h.getAttribute("data-temporary-table-cell-lexical-key");
1322
+ if (p) {
1323
+ const C = l.get(p);
1324
+ if (h.removeAttribute("data-temporary-table-cell-lexical-key"), C) {
1325
+ l.delete(p);
1326
+ for (let a = 0; a < C.colSpan; a++) i.add(a + C.startColumn);
1327
+ }
1328
+ }
1329
+ }
1330
+ const c = r.querySelector(":scope > colgroup");
1331
+ if (c) {
1332
+ const h = Array.from(r.querySelectorAll(":scope > colgroup > col")).filter((p, C) => i.has(C));
1333
+ c.replaceChildren(...h);
1334
+ }
1335
+ const f = r.querySelectorAll(":scope > tr");
1336
+ if (f.length > 0) {
1337
+ const h = document.createElement("tbody");
1338
+ for (const p of f) h.appendChild(p);
1339
+ r.append(h);
1340
+ }
1341
+ return r;
1342
+ }, element: !oe(o) && ye(o) ? o.querySelector("table") : o };
1343
+ }
1344
+ canBeEmpty() {
1345
+ return !1;
1346
+ }
1347
+ isShadowRoot() {
1348
+ return !0;
1349
+ }
1350
+ getCordsFromCellNode(e, t) {
1351
+ const { rows: o, domRows: r } = t;
1352
+ for (let s = 0; s < o; s++) {
1353
+ const l = r[s];
1354
+ if (l != null) for (let i = 0; i < l.length; i++) {
1355
+ const c = l[i];
1356
+ if (c == null) continue;
1357
+ const { elem: f } = c, h = ze(this, f);
1358
+ if (h !== null && e.is(h)) return { x: i, y: s };
1359
+ }
1360
+ }
1361
+ throw new Error("Cell not found in table.");
1362
+ }
1363
+ getDOMCellFromCords(e, t, o) {
1364
+ const { domRows: r } = o, s = r[t];
1365
+ if (s == null) return null;
1366
+ const l = s[e < s.length ? e : s.length - 1];
1367
+ return l ?? null;
1368
+ }
1369
+ getDOMCellFromCordsOrThrow(e, t, o) {
1370
+ const r = this.getDOMCellFromCords(e, t, o);
1371
+ if (!r) throw new Error("Cell not found at cords.");
1372
+ return r;
1373
+ }
1374
+ getCellNodeFromCords(e, t, o) {
1375
+ const r = this.getDOMCellFromCords(e, t, o);
1376
+ if (r == null) return null;
1377
+ const s = V(r.elem);
1378
+ return S(s) ? s : null;
1379
+ }
1380
+ getCellNodeFromCordsOrThrow(e, t, o) {
1381
+ const r = this.getCellNodeFromCords(e, t, o);
1382
+ if (!r) throw new Error("Node at cords not TableCellNode.");
1383
+ return r;
1384
+ }
1385
+ getRowStriping() {
1386
+ return !!this.getLatest().__rowStriping;
1387
+ }
1388
+ setRowStriping(e) {
1389
+ const t = this.getWritable();
1390
+ return t.__rowStriping = e, t;
1391
+ }
1392
+ setFrozenColumns(e) {
1393
+ const t = this.getWritable();
1394
+ return t.__frozenColumnCount = e, t;
1395
+ }
1396
+ getFrozenColumns() {
1397
+ return this.getLatest().__frozenColumnCount;
1398
+ }
1399
+ setFrozenRows(e) {
1400
+ const t = this.getWritable();
1401
+ return t.__frozenRowCount = e, t;
1402
+ }
1403
+ getFrozenRows() {
1404
+ return this.getLatest().__frozenRowCount;
1405
+ }
1406
+ canSelectBefore() {
1407
+ return !0;
1408
+ }
1409
+ canIndent() {
1410
+ return !1;
1411
+ }
1412
+ getColumnCount() {
1413
+ const e = this.getFirstChild();
1414
+ if (!e) return 0;
1415
+ let t = 0;
1416
+ return e.getChildren().forEach((o) => {
1417
+ S(o) && (t += o.getColSpan());
1418
+ }), t;
1419
+ }
1420
+ }
1421
+ function En(n, e) {
1422
+ const t = n.getElementByKey(e.getKey());
1423
+ return t === null && w(230), ie(e, t);
1424
+ }
1425
+ function $n(n) {
1426
+ const e = qe();
1427
+ n.hasAttribute("data-lexical-row-striping") && e.setRowStriping(!0);
1428
+ const t = n.querySelector(":scope > colgroup");
1429
+ if (t) {
1430
+ let o = [];
1431
+ for (const r of t.querySelectorAll(":scope > col")) {
1432
+ let s = r.style.width || "";
1433
+ if (!Be.test(s) && (s = r.getAttribute("width") || "", !/^\d+$/.test(s))) {
1434
+ o = void 0;
1435
+ break;
1436
+ }
1437
+ o.push(parseFloat(s));
1438
+ }
1439
+ o && e.setColWidths(o);
1440
+ }
1441
+ return { after: (o) => mt(o, E), node: e };
1442
+ }
1443
+ function qe() {
1444
+ return He(new Z());
1445
+ }
1446
+ function O(n) {
1447
+ return n instanceof Z;
1448
+ }
1449
+ function Mn({ rows: n, columns: e, includeHeaders: t }) {
1450
+ const o = L();
1451
+ if (!o || !z(o) || ae(o.anchor.getNode())) return !1;
1452
+ const r = wn(Number(n), Number(e), t);
1453
+ Mt(r);
1454
+ const s = r.getFirstDescendant();
1455
+ return ce(s) && s.select(), !0;
1456
+ }
1457
+ function zn(n) {
1458
+ E(n.getParent()) ? n.isEmpty() && n.append(j()) : n.remove();
1459
+ }
1460
+ function Ln(n) {
1461
+ O(n.getParent()) ? pt(n, S) : n.remove();
1462
+ }
1463
+ function Pn(n) {
1464
+ pt(n, E);
1465
+ const [e] = Je(n, null, null), t = e.reduce((r, s) => Math.max(r, s.length), 0), o = n.getChildren();
1466
+ for (let r = 0; r < e.length; ++r) {
1467
+ const s = o[r];
1468
+ if (!s) continue;
1469
+ E(s) || w(254, s.constructor.name, s.getType());
1470
+ const l = e[r].reduce((i, c) => c ? 1 + i : i, 0);
1471
+ if (l !== t) for (let i = l; i < t; ++i) {
1472
+ const c = ge();
1473
+ c.append(j()), s.append(c);
1474
+ }
1475
+ }
1476
+ }
1477
+ function Hn(n) {
1478
+ if (n.detail < 3 || !de(n.target)) return !1;
1479
+ const e = V(n.target);
1480
+ if (e === null) return !1;
1481
+ const t = N(e, (o) => H(o) && !o.isInline());
1482
+ return t === null ? !1 : !!S(t.getParent()) && (t.select(0), !0);
1483
+ }
1484
+ function Un(n) {
1485
+ return n.registerNodeTransform(ee, (e) => {
1486
+ if (e.getColSpan() > 1 || e.getRowSpan() > 1) {
1487
+ const [, , t] = le(e), [o] = U(t, e, e), r = o.length, s = o[0].length;
1488
+ let l = t.getFirstChild();
1489
+ E(l) || w(175);
1490
+ const i = [];
1491
+ for (let c = 0; c < r; c++) {
1492
+ c !== 0 && (l = l.getNextSibling(), E(l) || w(175));
1493
+ let f = null;
1494
+ for (let h = 0; h < s; h++) {
1495
+ const p = o[c][h], C = p.cell;
1496
+ if (p.startRow === c && p.startColumn === h) f = C, i.push(C);
1497
+ else if (C.getColSpan() > 1 || C.getRowSpan() > 1) {
1498
+ S(C) || w(176);
1499
+ const a = ge(C.__headerState);
1500
+ f !== null ? f.insertAfter(a) : $t(l, a);
1501
+ }
1502
+ }
1503
+ }
1504
+ for (const c of i) c.setColSpan(1), c.setRowSpan(1);
1505
+ }
1506
+ });
1507
+ }
1508
+ function jn(n, e = !0) {
1509
+ const t = /* @__PURE__ */ new Map(), o = (s, l, i) => {
1510
+ const c = G(s, i), f = Kn(s, c, n, e);
1511
+ t.set(l, [f, c]);
1512
+ }, r = n.registerMutationListener(Z, (s) => {
1513
+ n.getEditorState().read(() => {
1514
+ for (const [l, i] of s) {
1515
+ const c = t.get(l);
1516
+ if (i === "created" || i === "updated") {
1517
+ const { tableNode: f, tableElement: h } = xt(l);
1518
+ c === void 0 ? o(f, l, h) : h !== c[1] && (c[0].removeListeners(), t.delete(l), o(f, l, h));
1519
+ } else i === "destroyed" && c !== void 0 && (c[0].removeListeners(), t.delete(l));
1520
+ }
1521
+ }, { editor: n });
1522
+ }, { skipInitialization: !1 });
1523
+ return () => {
1524
+ r();
1525
+ for (const [, [s]] of t) s.removeListeners();
1526
+ };
1527
+ }
1528
+ function Vn(n) {
1529
+ return n.hasNodes([Z]) || w(255), Et(n.registerCommand(Cn, Mn, Oe), n.registerCommand(_t, ({ nodes: e, selection: t }) => z(t) ? ae(t.anchor.getNode()) !== null && e.some(O) : !1, Oe), n.registerCommand(Ht, Hn, Oe), n.registerNodeTransform(Z, Pn), n.registerNodeTransform(me, Ln), n.registerNodeTransform(ee, zn));
1530
+ }
1531
+ export {
1532
+ Xn as B,
1533
+ bn as H,
1534
+ De as K,
1535
+ wn as L,
1536
+ me as O,
1537
+ Jn as P,
1538
+ qn as Q,
1539
+ S as T,
1540
+ yt as W,
1541
+ Z,
1542
+ Vn as d,
1543
+ jn as h,
1544
+ Yn as j,
1545
+ Un as u,
1546
+ ge as v,
1547
+ ee as y,
1548
+ In as z
1549
+ };
1550
+ //# sourceMappingURL=LexicalTable.prod-BsmIydKv.js.map