@uva-glass/component-library 3.6.0 → 3.6.1

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 (79) hide show
  1. package/dist/{Lexical.prod-CniF7zEE.js → Lexical.prod-CWyHQUEM.js} +738 -736
  2. package/dist/Lexical.prod-CWyHQUEM.js.map +1 -0
  3. package/dist/{LexicalClipboard.prod-BXVNkwwS.js → LexicalClipboard.prod-DbqSWANZ.js} +41 -41
  4. package/dist/{LexicalClipboard.prod-BXVNkwwS.js.map → LexicalClipboard.prod-DbqSWANZ.js.map} +1 -1
  5. package/dist/LexicalLink.prod-DbxnRszt.js +275 -0
  6. package/dist/LexicalLink.prod-DbxnRszt.js.map +1 -0
  7. package/dist/{LexicalList.prod-BUcoZhe4.js → LexicalList.prod-pZmYrwOC.js} +212 -172
  8. package/dist/LexicalList.prod-pZmYrwOC.js.map +1 -0
  9. package/dist/{LexicalSelection.prod-BfAlhGGm.js → LexicalSelection.prod-DkvWlcln.js} +14 -14
  10. package/dist/{LexicalSelection.prod-BfAlhGGm.js.map → LexicalSelection.prod-DkvWlcln.js.map} +1 -1
  11. package/dist/LexicalTable.prod-C6duSS2P.js +1720 -0
  12. package/dist/LexicalTable.prod-C6duSS2P.js.map +1 -0
  13. package/dist/{LexicalUtils.prod-DVr8VsHc.js → LexicalUtils.prod-Dny9Fu94.js} +43 -43
  14. package/dist/{LexicalUtils.prod-DVr8VsHc.js.map → LexicalUtils.prod-Dny9Fu94.js.map} +1 -1
  15. package/dist/{TablePlugin-MjKuocl4.js → TablePlugin-Ba6PaBhf.js} +28 -28
  16. package/dist/{TablePlugin-MjKuocl4.js.map → TablePlugin-Ba6PaBhf.js.map} +1 -1
  17. package/dist/components/Accordion/Accordion.test.js +2 -2
  18. package/dist/components/AccordionCard/AccordionCard.test.js +2 -2
  19. package/dist/components/ActionList/ActionList.test.js +2 -2
  20. package/dist/components/AppStatusBar/AppStatusBar.test.js +1 -1
  21. package/dist/components/Attention/Attention.test.js +1 -1
  22. package/dist/components/Backdrop/Backdrop.test.js +1 -1
  23. package/dist/components/Buttons/Button.test.js +1 -1
  24. package/dist/components/Buttons/LinkButton.test.js +1 -1
  25. package/dist/components/Buttons/MenuButton.test.js +1 -1
  26. package/dist/components/Card/Card.test.js +1 -1
  27. package/dist/components/Checkbox/Checkbox.test.js +1 -1
  28. package/dist/components/CheckboxButton/CheckboxButton.test.js +1 -1
  29. package/dist/components/CheckboxButtonBar/CheckboxButtonBar.test.js +1 -1
  30. package/dist/components/CheckboxTree/CheckboxTree.js +1 -1
  31. package/dist/components/FeedbackBar/FeedbackBar.test.js +1 -1
  32. package/dist/components/FormInput/FormInput.js +1 -1
  33. package/dist/components/InputField/InputField.stories.js +1 -1
  34. package/dist/components/Label/Label.test.js +1 -1
  35. package/dist/components/MultiSelect/MultiSelect.js +1 -1
  36. package/dist/components/MultiSelect/MultiSelect.stories.js +1 -1
  37. package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -1
  38. package/dist/components/MultiSelect/index.js +1 -1
  39. package/dist/components/OverlayStepBar/OverlayStepBar.js +1 -1
  40. package/dist/components/PeriodSelector/PeriodSelector.js +1 -1
  41. package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +1 -1
  42. package/dist/components/RadioGroup/Radiogroup.test.js +1 -1
  43. package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -1
  44. package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +1 -1
  45. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +2 -2
  46. package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +2 -2
  47. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +1 -1
  48. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +35 -35
  49. package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
  50. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +25 -25
  51. package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +13 -13
  52. package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +1 -1
  53. package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +3 -3
  54. package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +11 -11
  55. package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
  56. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +7 -7
  57. package/dist/components/RteEditor/Plugins/index.js +1 -1
  58. package/dist/components/RteEditor/RteEditor.js +237 -235
  59. package/dist/components/RteEditor/RteEditor.js.map +1 -1
  60. package/dist/components/RteEditor/helpers.js +4 -4
  61. package/dist/components/StatusBadge/StatusBadge.test.js +1 -1
  62. package/dist/components/TextArea/TextArea.test.js +1 -1
  63. package/dist/components/Timeline/Timeline.test.js +2 -2
  64. package/dist/components/VarIndicator/VarIndicator.test.js +2 -2
  65. package/dist/components/index.js +1 -1
  66. package/dist/{helpers-ChM6xtQG.js → helpers-BUwfVZhW.js} +15 -15
  67. package/dist/{helpers-ChM6xtQG.js.map → helpers-BUwfVZhW.js.map} +1 -1
  68. package/dist/{index-hwMTfLfH.js → index-Ck15_vKo.js} +2 -2
  69. package/dist/{index-hwMTfLfH.js.map → index-Ck15_vKo.js.map} +1 -1
  70. package/dist/index.js +1 -1
  71. package/dist/{react.esm-DI5ilWeT.js → react.esm-CMg7bmSn.js} +372 -366
  72. package/dist/{react.esm-DI5ilWeT.js.map → react.esm-CMg7bmSn.js.map} +1 -1
  73. package/package.json +28 -28
  74. package/dist/Lexical.prod-CniF7zEE.js.map +0 -1
  75. package/dist/LexicalLink.prod-Du8ZoNsh.js +0 -259
  76. package/dist/LexicalLink.prod-Du8ZoNsh.js.map +0 -1
  77. package/dist/LexicalList.prod-BUcoZhe4.js.map +0 -1
  78. package/dist/LexicalTable.prod-CYafu_j9.js +0 -1555
  79. package/dist/LexicalTable.prod-CYafu_j9.js.map +0 -1
@@ -1,1555 +0,0 @@
1
- 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";
2
- 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";
3
- import { _ as mn, M as pn } from "./LexicalClipboard.prod-BXVNkwwS.js";
4
- const Be = /^(\d+(?:\.\d+)?)px$/, B = { 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 me().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 = B.NO_STATUS, t = 1, o, l) {
25
- super(l), 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), $e(this.__verticalAlign) && (t.style.verticalAlign = this.__verticalAlign), Y(t, e.theme.tableCell, this.hasHeader() && e.theme.tableCellHeader), t;
30
- }
31
- exportDOM(e) {
32
- const t = super.exportDOM(e);
33
- if (fe(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(), ...$e(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 = B.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 !== B.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 $e(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 l = me(t === "th" ? B.ROW : B.NO_STATUS, e.colSpan, o);
121
- l.__rowSpan = e.rowSpan;
122
- const s = e.style.backgroundColor;
123
- s !== "" && (l.__backgroundColor = s);
124
- const r = e.style.verticalAlign;
125
- $e(r) && (l.__verticalAlign = r);
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
- et(m) && g.getChildrenSize() === 1 && m.remove();
134
- }
135
- };
136
- 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);
137
- return d(), u.length === 0 && u.push(j()), u;
138
- }, node: l };
139
- }
140
- function me(n = B.NO_STATUS, e = 1, t) {
141
- return We(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 l of e) o.append("v", l);
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 pe extends Pe {
154
- static getType() {
155
- return "tablerow";
156
- }
157
- static clone(e) {
158
- return new pe(e.__height, e.__key);
159
- }
160
- static importDOM() {
161
- return { tr: (e) => ({ conversion: _n, priority: 0 }) };
162
- }
163
- static importJSON(e) {
164
- return Ie().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`), Y(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: Ie(t) };
207
- }
208
- function Ie(n) {
209
- return We(new pe(n));
210
- }
211
- function k(n) {
212
- return n instanceof pe;
213
- }
214
- 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);
215
- function wn(n, e, t = !0) {
216
- const o = Ue();
217
- for (let l = 0; l < n; l++) {
218
- const s = Ie();
219
- for (let r = 0; r < e; r++) {
220
- let i = B.NO_STATUS;
221
- 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));
222
- const c = me(i), f = j();
223
- f.append(De()), 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) => k(t));
235
- if (k(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 Yn(n) {
248
- return yt(n).getChildren().findIndex((e) => e.is(n));
249
- }
250
- Je && "InputEvent" in window && !Sn && new window.InputEvent("input");
251
- function Xn(n, e) {
252
- const t = n.getChildren();
253
- for (let o = 0; o < t.length; o++) {
254
- const l = t[o];
255
- if (k(l)) {
256
- const s = l.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, l, s] = Ye(n, e, t);
265
- return l === null && w(207), s === null && w(208), [o, l, s];
266
- }
267
- function Ye(n, e, t) {
268
- const o = [];
269
- let l = null, s = null;
270
- function r(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
- k(f) || w(209);
278
- const h = r(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 = r(c + d);
284
- for (let _ = 0; _ < g; _++) m[C + _] = a;
285
- }
286
- e !== null && l === null && e.is(p) && (l = a), t !== null && s === null && t.is(p) && (s = a);
287
- }
288
- }
289
- return [o, l, s];
290
- }
291
- function le(n) {
292
- let e;
293
- if (n instanceof ee) e = n;
294
- else if ("__type" in n) {
295
- const l = N(n, S);
296
- S(l) || w(148), e = l;
297
- } else {
298
- const l = N(n.getNode(), S);
299
- S(l) || w(148), e = l;
300
- }
301
- const t = e.getParent();
302
- k(t) || w(149);
303
- const o = t.getParent();
304
- return O(o) || w(210), [e, t, o];
305
- }
306
- function Me(n, e, t) {
307
- 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);
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 <= r && p >= l, u = h.startRow <= i && C >= s;
314
- if (a && u) {
315
- const g = Math.min(l, h.startColumn), d = Math.max(r, p), m = Math.min(s, h.startRow), _ = Math.max(i, C);
316
- g === l && d === r && m === s && _ === i || (l = g, r = d, s = m, i = _, o = !0);
317
- }
318
- }
319
- } while (o);
320
- return { maxColumn: r, maxRow: i, minColumn: l, minRow: s };
321
- }
322
- function it(n) {
323
- const [e, , t] = le(n), o = t.getChildren(), l = o.length, s = o[0].getChildren().length, r = new Array(l);
324
- for (let i = 0; i < l; i++) r[i] = new Array(s);
325
- for (let i = 0; i < l; i++) {
326
- const c = o[i].getChildren();
327
- let f = 0;
328
- for (let h = 0; h < c.length; h++) {
329
- for (; r[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++) r[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, l], [s, r, 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
- k(C) || w(239, f);
344
- const a = C.getParent();
345
- return O(a) || w(240, f), [h, p, C, a];
346
- });
347
- return l.is(c) || w(241), { anchorCell: t, anchorNode: e, anchorRow: o, anchorTable: l, focusCell: r, 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((l) => {
390
- const s = l.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
- P(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 l = it(t);
404
- l === null && w(155);
405
- 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);
406
- return { fromX: Math.min(s, r), fromY: Math.min(i, c), toX: Math.max(s, r), 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: l } = at(this), s = l.getParents()[1];
413
- if (s !== t) {
414
- if (t.isParentOf(l)) {
415
- const d = s.getParent();
416
- d == null && w(159), this.set(this.tableKey, l.getKey(), d.getKey());
417
- } else {
418
- const d = t.getParent();
419
- d == null && w(158), this.set(this.tableKey, d.getKey(), l.getKey());
420
- }
421
- return this.getNodes();
422
- }
423
- 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]]);
424
- let u = null;
425
- for (let d = p; d <= C; d++) for (let m = f; m <= h; m++) {
426
- const { cell: _ } = r[d][m], b = _.getParent();
427
- k(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 l = e[o], s = l.__parent, r = (e[o + 1] || {}).__parent;
439
- t += l.getTextContent() + (r !== 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(), l = R(o) ? o.clone() : Nt();
455
- return l.set(n.getKey(), e.getKey(), t.getKey()), l;
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 l = o.pop();
461
- l === void 0 ? t.pop() : e(l) !== !1 && P(l) && t.push(l.getChildren());
462
- }
463
- }
464
- function xt(n, e = Ct()) {
465
- const t = ye(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 r = 0; r < t.length; r++) {
488
- const i = t[r].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: l, tableElement: s } = this.$lookup();
496
- this.table = ie(l, 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
- Se(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
- Y(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(), Se(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: l } = this.$lookup(), s = e.x, r = e.y;
546
- if (this.focusCell = e, this.isHighlightingCells || this.anchorX === s && this.anchorY === r && !t) {
547
- if (s === this.focusX && r === this.focusY) return !1;
548
- } else this.isHighlightingCells = !0, this.$disableHighlightStyle();
549
- if (this.focusX = s, this.focusY = r, this.isHighlightingCells) {
550
- const i = Le(l, e.elem);
551
- 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;
552
- }
553
- return !1;
554
- }
555
- $getAnchorTableCell() {
556
- return this.anchorCellNodeKey ? ye(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 ? ye(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 = Le(t, e.elem);
572
- if (o !== null) {
573
- const l = o.getKey();
574
- this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : Nt(), this.anchorCellNodeKey = l;
575
- }
576
- }
577
- $formatCells(e) {
578
- const t = L();
579
- R(t) || w(236);
580
- const o = on(), l = o.anchor, s = o.focus, r = t.getNodes().filter(S);
581
- r.length > 0 || w(237);
582
- const i = r[0].getFirstChild(), c = bt(i) ? i.getFormatFlags(e, null) : null;
583
- r.forEach((f) => {
584
- l.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 = ye(this.tableNodeKey);
589
- if (!O(t)) throw new Error("Expected TableNode.");
590
- const o = L();
591
- R(o) || w(253);
592
- const l = o.getNodes().filter(S);
593
- if (l.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
- l.forEach((s) => {
599
- if (P(s)) {
600
- const r = j(), i = De();
601
- r.append(i), s.append(r), s.getChildren().forEach((c) => {
602
- c !== r && c.remove();
603
- });
604
- }
605
- }), Se(e, this.table, null), q(null), e.dispatchCommand(re, void 0);
606
- }
607
- }
608
- const ze = "__lexicalTableSelection", Tn = (n) => !(1 & ~n.buttons);
609
- function oe(n) {
610
- return fe(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 ge(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 = [[Dt, "down"], [Bt, "up"], [It, "backward"], [Jt, "forward"]], vn = [Xt, St, qt], Rn = [Ut, jt];
628
- function Kn(n, e, t, o) {
629
- const l = t.getRootElement(), s = Xe(t);
630
- l !== null && s !== null || w(246);
631
- const r = new xn(t, n.getKey()), i = G(n, e);
632
- (function(a, u) {
633
- ct(a) !== null && w(205), a[ze] = u;
634
- })(i, r), r.listenersToRemove.add(() => function(a, u) {
635
- ct(a) === u && delete a[ze];
636
- }(i, r));
637
- const c = (a) => {
638
- if (r.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 = ke();
642
- if (st && a.shiftKey && J(g, n) && (z(g) || R(g))) {
643
- const d = g.anchor.getNode(), m = ge(n, g.anchor.getNode());
644
- 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);
645
- } else r.$setAnchorCellForSelection(u);
646
- }), (() => {
647
- if (r.isSelecting) return;
648
- const g = () => {
649
- r.isSelecting = !1, s.removeEventListener("pointerup", g), s.removeEventListener("pointermove", d);
650
- }, d = (m) => {
651
- if (!Tn(m) && r.isSelecting) return r.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
- !_ || r.focusCell !== null && _.elem === r.focusCell.elem || (r.setNextFocus({ focusCell: _, override: b }), t.dispatchCommand(re, void 0));
658
- };
659
- r.isSelecting = !0, s.addEventListener("pointerup", g, r.listenerOptions), s.addEventListener("pointermove", d, r.listenerOptions);
660
- })();
661
- };
662
- i.addEventListener("pointerdown", c, r.listenerOptions), r.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, r.listenerOptions), r.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 === r.tableNodeKey && l.contains(u) && r.$clearHighlight();
676
- });
677
- };
678
- s.addEventListener("pointerdown", h, r.listenerOptions), r.listenersToRemove.add(() => {
679
- s.removeEventListener("pointerdown", h);
680
- });
681
- for (const [a, u] of Fn) r.listenersToRemove.add(t.registerCommand(a, (g) => vt(t, g, u, n, r), Ae));
682
- r.listenersToRemove.add(t.registerCommand(Yt, (a) => {
683
- const u = L();
684
- if (R(u)) {
685
- const g = ge(n, u.focus.getNode());
686
- if (g !== null) return X(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 r.$clearText(), !0;
694
- if (z(u)) {
695
- if (!S(ge(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 r.$clearText(), !0;
698
- const b = N(u.anchor.getNode(), (x) => P(x)), y = b && N(b, (x) => P(x) && S(x.getParent()));
699
- if (!P(y) || !P(b)) return !1;
700
- if (a === St && y.getPreviousSibling() === null) return !0;
701
- }
702
- return !1;
703
- };
704
- for (const a of vn) r.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()), r.$clearText(), !0);
714
- };
715
- for (const a of Rn) r.listenersToRemove.add(t.registerCommand(a, C, I));
716
- return r.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)), r.listenersToRemove.add(t.registerCommand(Zt, (a) => {
726
- const u = L();
727
- if (!J(u, n)) return !1;
728
- if (R(u)) return r.$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)), r.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), E = /* @__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 (E.has(F)) continue;
753
- E.add(F), F.setFormat(a);
754
- const K = F.getChildren();
755
- for (let M = 0; M < K.length; M++) {
756
- const H = K[M];
757
- P(H) && !H.isInline() && H.setFormat(a);
758
- }
759
- }
760
- return !0;
761
- }, I)), r.listenersToRemove.add(t.registerCommand(Qt, (a) => {
762
- const u = L();
763
- if (!J(u, n)) return !1;
764
- if (R(u)) return r.$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, [De(a)]), !0;
771
- }
772
- }
773
- return !1;
774
- }, I)), o && r.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))) && (X(a), function(d, m) {
779
- const _ = m === "next" ? "getNextSibling" : "getPreviousSibling", b = m === "next" ? "getFirstChild" : "getLastChild", y = d[_]();
780
- if (P(y)) return y.selectEnd();
781
- const x = N(d, k);
782
- x === null && w(247);
783
- for (let $ = x[_](); k($); $ = $[_]()) {
784
- const E = $[b]();
785
- if (P(E)) return E.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)), r.listenersToRemove.add(t.registerCommand(tn, (a) => n.isSelected(), Ae)), r.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(), E = N(b.getNode(), (W) => S(W)), T = E && N(E, (W) => k(W)), A = T && N(T, (W) => O(W));
794
- if (!S(E) || !k(T) || !O(A)) return !1;
795
- 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();
796
- let je = 0;
797
- for (let W = ve; W <= D; W++) {
798
- const Ve = Kt[W];
799
- if (!k(Ve)) return !1;
800
- const Ze = x[je];
801
- if (!k(Ze)) return !1;
802
- const Ot = Ve.getChildren(), At = Ze.getChildren();
803
- let Ge = 0;
804
- for (let Ke = ue; Ke <= Re; Ke++) {
805
- const Ce = Ot[Ke];
806
- if (!S(Ce)) return !1;
807
- const Qe = At[Ge];
808
- if (!S(Qe)) return !1;
809
- const Et = Ce.getChildren();
810
- Qe.getChildren().forEach((te) => {
811
- ce(te) && j().append(te), Ce.append(te);
812
- }), Et.forEach((te) => te.remove()), Ge++;
813
- }
814
- je++;
815
- }
816
- return !0;
817
- }, I)), r.listenersToRemove.add(t.registerCommand(re, () => {
818
- const a = L(), u = ke(), g = r.getAndClearNextFocus();
819
- if (g !== null) {
820
- const { focusCell: d } = g;
821
- if (R(a) && a.tableKey === r.tableNodeKey) return (d.x !== r.focusX || d.y !== r.focusY) && (r.$setFocusCellForSelection(d), !0);
822
- if (d !== r.anchorCell && J(a, n)) return r.$setFocusCellForSelection(d), !0;
823
- }
824
- if (r.getAndClearShouldCheckSelection() && z(u) && z(a) && a.isCollapsed()) {
825
- const d = a.anchor.getNode(), m = n.getFirstChild(), _ = he(d);
826
- if (_ !== null && k(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))), E = v !== $, T = v && $, A = a.isBackward();
833
- if (E) {
834
- const F = a.clone();
835
- if ($) {
836
- const [K] = U(n, x, x), M = K[0][0].cell, H = K[K.length - 1].at(-1).cell;
837
- F.focus.set(A ? M.getKey() : H.getKey(), A ? M.getChildrenSize() : H.getChildrenSize(), "element");
838
- } else if (v) {
839
- const [K] = U(n, y, y), M = K[0][0].cell, H = K[K.length - 1].at(-1).cell;
840
- F.anchor.set(A ? H.getKey() : M.getKey(), A ? H.getChildrenSize() : 0, "element");
841
- }
842
- q(F), ht(t, r);
843
- } 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())) {
844
- const F = he(u.anchor.getNode());
845
- F && !F.is(x) && (r.$setAnchorCellForSelection(Z(r, F)), r.$setFocusCellForSelection(Z(r, x), !0), r.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)) && 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) {
858
- m.$enableHighlightStyle(), qe(m.table, (_) => {
859
- const b = _.elem;
860
- _.highlighted = !1, Ft(d, _), b.getAttribute("style") || b.removeAttribute("style");
861
- });
862
- }(t, r) : !r.hasHijackedSelectionStyles && n.isSelected() && ht(t, r), !1);
863
- }, I)), r.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)), r;
869
- }
870
- function ct(n) {
871
- return n[ze] || 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 l = o.nodeName;
891
- l !== "TD" && l !== "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 l = G(n, e).querySelector("tr"), s = 0, r = 0;
898
- for (t.length = 0; l != null; ) {
899
- const i = l.nodeName;
900
- if (i === "TD" || i === "TH") {
901
- const h = { elem: l, hasBackgroundColor: l.style.backgroundColor !== "", highlighted: !1, x: s, y: r };
902
- l._cell = h;
903
- let p = t[r];
904
- p === void 0 && (p = t[r] = []), p[s] = h;
905
- } else {
906
- const h = l.firstChild;
907
- if (h != null) {
908
- l = h;
909
- continue;
910
- }
911
- }
912
- const c = l.nextSibling;
913
- if (c != null) {
914
- s++, l = c;
915
- continue;
916
- }
917
- const f = l.parentNode;
918
- if (f != null) {
919
- const h = f.nextSibling;
920
- if (h == null) break;
921
- r++, s = 0, l = h;
922
- }
923
- }
924
- return o.columns = s + 1, o.rows = r + 1, o;
925
- }
926
- function Se(n, e, t) {
927
- const o = new Set(t ? t.getNodes() : []);
928
- qe(e, (l, s) => {
929
- const r = l.elem;
930
- o.has(s) ? (l.highlighted = !0, Tt(n, l)) : (l.highlighted = !1, Ft(n, l), r.getAttribute("style") || r.removeAttribute("style"));
931
- });
932
- }
933
- function qe(n, e) {
934
- const { domRows: t } = n;
935
- for (let o = 0; o < t.length; o++) {
936
- const l = t[o];
937
- if (l) for (let s = 0; s < l.length; s++) {
938
- const r = l[s];
939
- if (!r) continue;
940
- const i = V(r.elem);
941
- i !== null && e(r, i, { x: s, y: o });
942
- }
943
- }
944
- }
945
- function ht(n, e) {
946
- e.$disableHighlightStyle(), qe(e.table, (t) => {
947
- t.highlighted = !0, Tt(n, t);
948
- });
949
- }
950
- const On = (n, e, t, o, l) => {
951
- const s = l === "forward";
952
- switch (l) {
953
- case "backward":
954
- case "forward":
955
- 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;
956
- case "up":
957
- return o !== 0 ? be(e.getCellNodeFromCordsOrThrow(t, o - 1, n.table), !1) : e.selectPrevious(), !0;
958
- case "down":
959
- return o !== n.table.rows - 1 ? be(e.getCellNodeFromCordsOrThrow(t, o + 1, n.table), !0) : e.selectNext(), !0;
960
- default:
961
- return !1;
962
- }
963
- };
964
- function Ee(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 we([n, e]) {
979
- return [n === "minColumn" ? "maxColumn" : "minColumn", e === "minRow" ? "maxRow" : "minRow"];
980
- }
981
- function ne(n, e, [t, o]) {
982
- const l = e[o], s = n[l];
983
- s === void 0 && w(250, o, String(l));
984
- const r = e[t], i = s[r];
985
- return i === void 0 && w(250, t, String(r)), i;
986
- }
987
- function An(n, e, t, o, l) {
988
- const s = Me(e, t, o), r = function(v, $) {
989
- const { minColumn: E, maxColumn: T, minRow: A, maxRow: F } = $;
990
- let K = 1, M = 1, H = 1, ue = 1;
991
- const ve = v[A], Re = v[F];
992
- for (let D = E; D <= T; D++) K = Math.max(K, ve[D].cell.__rowSpan), ue = Math.max(ue, Re[D].cell.__rowSpan);
993
- 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);
994
- return { bottomSpan: ue, leftSpan: M, rightSpan: H, topSpan: K };
995
- }(e, s), { topSpan: i, leftSpan: c, bottomSpan: f, rightSpan: h } = r, p = function(v, $) {
996
- const E = Ee(v, $);
997
- return E === null && w(249, $.cell.getKey()), E;
998
- }(s, t), [C, a] = we(p);
999
- let u = s[C], g = s[a];
1000
- 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);
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, $, E) {
1006
- const T = Me(v, $, E), A = Ee(T, $);
1007
- if (A) return [ne(v, T, A), ne(v, T, we(A))];
1008
- const F = Ee(T, E);
1009
- if (F) return [ne(v, T, we(F)), ne(v, T, F)];
1010
- const K = ["minColumn", "minRow"];
1011
- return [ne(v, T, K), ne(v, T, we(K))];
1012
- }(e, t, m), y = Z(n, _.cell), x = Z(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 be(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), Y(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 En(n, e, t, o, l, s, r) {
1044
- const i = sn(t.focus, l ? "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) || !P(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 (!k(_)) 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 = kn(n, C);
1066
- if (r.table = g, p) if (o === "extend") {
1067
- const d = xe(n.getElementByKey(p.origin.getKey()));
1068
- if (!d) return !1;
1069
- r.$setAnchorCellForSelection(u), r.$setFocusCellForSelection(d, !0);
1070
- } else {
1071
- const d = rt(p);
1072
- _e(t.anchor, d), _e(t.focus, d);
1073
- }
1074
- else if (o === "extend") r.$setAnchorCellForSelection(u), r.$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
- _e(t.anchor, d), _e(t.focus, d);
1081
- }
1082
- return X(e), !0;
1083
- }
1084
- function vt(n, e, t, o, l) {
1085
- if ((t === "up" || t === "down") && function(r) {
1086
- const i = r.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 r = function(c) {
1095
- for (let f = c, h = c; h !== null; f = h, h = h.getParent()) if (P(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 (!r) return !1;
1102
- const i = r.getPreviousSibling();
1103
- return !!O(i) && (X(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 r = s.focus.getNode();
1107
- if (!s.isCollapsed() && (t === "up" && !s.isBackward() || t === "down" && s.isBackward())) {
1108
- let i = N(r, (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" && P(c) && (f = c.getChildrenSize());
1114
- let h = c;
1115
- t === "up" && P(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), X(e), !0;
1118
- }
1119
- if (ln(r)) {
1120
- const i = t === "up" ? s.getNodes()[s.getNodes().length - 1] : s.getNodes()[0];
1121
- if (i && ge(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, 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);
1125
- return l.$setAnchorCellForSelection(u), l.$setFocusCellForSelection(g, !0), !0;
1126
- }
1127
- return !1;
1128
- }
1129
- {
1130
- let i = N(r, (f) => P(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) && l.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"), X(e), q(a), !0;
1138
- }
1139
- }
1140
- }
1141
- }
1142
- return t === "down" && Rt(n) && l.setShouldCheckSelection(), !1;
1143
- }
1144
- if (z(s)) {
1145
- if (t === "backward" || t === "forward")
1146
- return En(n, e, s, e.shiftKey ? "extend" : "move", t === "backward", o, l);
1147
- if (s.isCollapsed()) {
1148
- const { anchor: r, focus: i } = s, c = N(r.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 l.table = ie(h, m), vt(n, e, t, h, l);
1154
- }
1155
- const p = n.getElementByKey(c.__key), C = n.getElementByKey(r.key);
1156
- if (C == null || p == null) return !1;
1157
- let a;
1158
- if (r.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
- X(e);
1171
- const m = o.getCordsFromCellNode(c, l.table);
1172
- if (!e.shiftKey) return On(l, o, m.x, m.y, t);
1173
- {
1174
- const _ = o.getDOMCellFromCordsOrThrow(m.x, m.y, l.table);
1175
- l.$setAnchorCellForSelection(_), l.$setFocusCellForSelection(_, !0);
1176
- }
1177
- return !0;
1178
- }
1179
- }
1180
- } else if (R(s)) {
1181
- const { anchor: r, focus: i } = s, c = N(r.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
- l.$updateTableTableSelection(s);
1186
- const C = ie(h, p), a = o.getCordsFromCellNode(c, C), u = o.getDOMCellFromCordsOrThrow(a.x, a.y, C);
1187
- if (l.$setAnchorCellForSelection(u), X(e), e.shiftKey) {
1188
- const [g, d, m] = U(o, c, f);
1189
- return An(l, g, d, m, t);
1190
- }
1191
- return f.selectEnd(), !0;
1192
- }
1193
- return !1;
1194
- }
1195
- function X(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 l = Te(Xe(n));
1206
- if (!l) return;
1207
- const s = l.anchorNode, r = n.getElementByKey(o.getKey()), i = G(t, n.getElementByKey(t.getKey()));
1208
- if (!s || !r || !i || !r.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 Z(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 Le(n, e, t) {
1221
- return ge(n, V(e, t));
1222
- }
1223
- function gt(n, e, t) {
1224
- if (!e.theme.tableAlignment) return;
1225
- const o = [], l = [];
1226
- for (const s of ["center", "right"]) {
1227
- const r = e.theme.tableAlignment[s];
1228
- r && (s === t ? l : o).push(r);
1229
- }
1230
- se(n, ...o), Y(n, ...l);
1231
- }
1232
- const He = /* @__PURE__ */ new WeakSet();
1233
- function Rt(n = Ct()) {
1234
- return He.has(n);
1235
- }
1236
- function qn(n, e) {
1237
- e ? He.add(n) : He.delete(n);
1238
- }
1239
- class Q 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 Q(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 Ue().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 l = document.createElement("colgroup");
1282
- if (o.appendChild(l), Ht(l), Y(o, e.theme.table), this.updateTableElement(null, o, e), Rt(t)) {
1283
- const s = document.createElement("div"), r = e.theme.tableScrollableWrapper;
1284
- return r ? Y(s, r) : s.style.cssText = "overflow-x: auto;", s.appendChild(o), this.updateTableWrapper(null, s, o, e), s;
1285
- }
1286
- return o;
1287
- }
1288
- updateTableWrapper(e, t, o, l) {
1289
- this.__frozenColumnCount !== (e ? e.__frozenColumnCount : 0) && function(s, r, i, c) {
1290
- c > 0 ? (Y(s, i.theme.tableFrozenColumn), r.setAttribute("data-lexical-frozen-column", "true")) : (se(s, i.theme.tableFrozenColumn), r.removeAttribute("data-lexical-frozen-column"));
1291
- }(t, o, l, this.__frozenColumnCount), this.__frozenRowCount !== (e ? e.__frozenRowCount : 0) && function(s, r, i, c) {
1292
- c > 0 ? (Y(s, i.theme.tableFrozenRow), r.setAttribute("data-lexical-frozen-row", "true")) : (se(s, i.theme.tableFrozenRow), r.removeAttribute("data-lexical-frozen-row"));
1293
- }(t, o, l, this.__frozenRowCount);
1294
- }
1295
- updateTableElement(e, t, o) {
1296
- this.__style !== (e ? e.__style : "") && (t.style.cssText = this.__style), this.__rowStriping !== (!!e && e.__rowStriping) && function(l, s, r) {
1297
- r ? (Y(l, s.theme.tableRowStriping), l.setAttribute("data-lexical-row-striping", "true")) : (se(l, s.theme.tableRowStriping), l.removeAttribute("data-lexical-row-striping"));
1298
- }(t, o, this.__rowStriping), function(l, s, r, i) {
1299
- const c = l.querySelector("colgroup");
1300
- if (!c) return;
1301
- const f = [];
1302
- for (let h = 0; h < r; h++) {
1303
- const p = document.createElement("col"), C = i && i[h];
1304
- C && (p.style.width = `${C}px`), f.push(p);
1305
- }
1306
- c.replaceChildren(...f);
1307
- }(t, 0, this.getColumnCount(), this.getColWidths()), gt(t, o, this.getFormatType());
1308
- }
1309
- updateDOM(e, t, o) {
1310
- const l = this.getDOMSlot(t).element;
1311
- var s;
1312
- return fe(s = t) && s.nodeName === "DIV" && this.updateTableWrapper(e, t, l, o), this.updateTableElement(e, this.getDOMSlot(t).element, o), !1;
1313
- }
1314
- exportDOM(e) {
1315
- const t = super.exportDOM(e), { element: o } = t;
1316
- return { after: (l) => {
1317
- if (t.after && (l = t.after(l)), !oe(l) && fe(l) && (l = l.querySelector("table")), !oe(l)) return null;
1318
- gt(l, e._config, this.getFormatType());
1319
- const [s] = Ye(this, null, null), r = /* @__PURE__ */ new Map();
1320
- for (const h of s) for (const p of h) {
1321
- const C = p.cell.getKey();
1322
- r.has(C) || r.set(C, { colSpan: p.cell.getColSpan(), startColumn: p.startColumn });
1323
- }
1324
- const i = /* @__PURE__ */ new Set();
1325
- for (const h of l.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")) {
1326
- const p = h.getAttribute("data-temporary-table-cell-lexical-key");
1327
- if (p) {
1328
- const C = r.get(p);
1329
- if (h.removeAttribute("data-temporary-table-cell-lexical-key"), C) {
1330
- r.delete(p);
1331
- for (let a = 0; a < C.colSpan; a++) i.add(a + C.startColumn);
1332
- }
1333
- }
1334
- }
1335
- const c = l.querySelector(":scope > colgroup");
1336
- if (c) {
1337
- const h = Array.from(l.querySelectorAll(":scope > colgroup > col")).filter((p, C) => i.has(C));
1338
- c.replaceChildren(...h);
1339
- }
1340
- const f = l.querySelectorAll(":scope > tr");
1341
- if (f.length > 0) {
1342
- const h = document.createElement("tbody");
1343
- for (const p of f) h.appendChild(p);
1344
- l.append(h);
1345
- }
1346
- return l;
1347
- }, element: !oe(o) && fe(o) ? o.querySelector("table") : o };
1348
- }
1349
- canBeEmpty() {
1350
- return !1;
1351
- }
1352
- isShadowRoot() {
1353
- return !0;
1354
- }
1355
- getCordsFromCellNode(e, t) {
1356
- const { rows: o, domRows: l } = t;
1357
- for (let s = 0; s < o; s++) {
1358
- const r = l[s];
1359
- if (r != null) for (let i = 0; i < r.length; i++) {
1360
- const c = r[i];
1361
- if (c == null) continue;
1362
- const { elem: f } = c, h = Le(this, f);
1363
- if (h !== null && e.is(h)) return { x: i, y: s };
1364
- }
1365
- }
1366
- throw new Error("Cell not found in table.");
1367
- }
1368
- getDOMCellFromCords(e, t, o) {
1369
- const { domRows: l } = o, s = l[t];
1370
- if (s == null) return null;
1371
- const r = s[e < s.length ? e : s.length - 1];
1372
- return r ?? null;
1373
- }
1374
- getDOMCellFromCordsOrThrow(e, t, o) {
1375
- const l = this.getDOMCellFromCords(e, t, o);
1376
- if (!l) throw new Error("Cell not found at cords.");
1377
- return l;
1378
- }
1379
- getCellNodeFromCords(e, t, o) {
1380
- const l = this.getDOMCellFromCords(e, t, o);
1381
- if (l == null) return null;
1382
- const s = V(l.elem);
1383
- return S(s) ? s : null;
1384
- }
1385
- getCellNodeFromCordsOrThrow(e, t, o) {
1386
- const l = this.getCellNodeFromCords(e, t, o);
1387
- if (!l) throw new Error("Node at cords not TableCellNode.");
1388
- return l;
1389
- }
1390
- getRowStriping() {
1391
- return !!this.getLatest().__rowStriping;
1392
- }
1393
- setRowStriping(e) {
1394
- const t = this.getWritable();
1395
- return t.__rowStriping = e, t;
1396
- }
1397
- setFrozenColumns(e) {
1398
- const t = this.getWritable();
1399
- return t.__frozenColumnCount = e, t;
1400
- }
1401
- getFrozenColumns() {
1402
- return this.getLatest().__frozenColumnCount;
1403
- }
1404
- setFrozenRows(e) {
1405
- const t = this.getWritable();
1406
- return t.__frozenRowCount = e, t;
1407
- }
1408
- getFrozenRows() {
1409
- return this.getLatest().__frozenRowCount;
1410
- }
1411
- canSelectBefore() {
1412
- return !0;
1413
- }
1414
- canIndent() {
1415
- return !1;
1416
- }
1417
- getColumnCount() {
1418
- const e = this.getFirstChild();
1419
- if (!e) return 0;
1420
- let t = 0;
1421
- return e.getChildren().forEach((o) => {
1422
- S(o) && (t += o.getColSpan());
1423
- }), t;
1424
- }
1425
- }
1426
- function kn(n, e) {
1427
- const t = n.getElementByKey(e.getKey());
1428
- return t === null && w(230), ie(e, t);
1429
- }
1430
- function $n(n) {
1431
- const e = Ue();
1432
- n.hasAttribute("data-lexical-row-striping") && e.setRowStriping(!0);
1433
- const t = n.querySelector(":scope > colgroup");
1434
- if (t) {
1435
- let o = [];
1436
- for (const l of t.querySelectorAll(":scope > col")) {
1437
- let s = l.style.width || "";
1438
- if (!Be.test(s) && (s = l.getAttribute("width") || "", !/^\d+$/.test(s))) {
1439
- o = void 0;
1440
- break;
1441
- }
1442
- o.push(parseFloat(s));
1443
- }
1444
- o && e.setColWidths(o);
1445
- }
1446
- return { after: (o) => mt(o, k), node: e };
1447
- }
1448
- function Ue() {
1449
- return We(new Q());
1450
- }
1451
- function O(n) {
1452
- return n instanceof Q;
1453
- }
1454
- function Mn({ rows: n, columns: e, includeHeaders: t }) {
1455
- const o = L() || ke();
1456
- if (!o || !z(o) || ae(o.anchor.getNode())) return !1;
1457
- const l = wn(Number(n), Number(e), t);
1458
- Mt(l);
1459
- const s = l.getFirstDescendant();
1460
- return ce(s) && s.select(), !0;
1461
- }
1462
- function zn(n) {
1463
- k(n.getParent()) ? n.isEmpty() && n.append(j()) : n.remove();
1464
- }
1465
- function Ln(n) {
1466
- O(n.getParent()) ? pt(n, S) : n.remove();
1467
- }
1468
- function Hn(n) {
1469
- pt(n, k);
1470
- const [e] = Ye(n, null, null), t = e.reduce((l, s) => Math.max(l, s.length), 0), o = n.getChildren();
1471
- for (let l = 0; l < e.length; ++l) {
1472
- const s = o[l];
1473
- if (!s) continue;
1474
- k(s) || w(254, s.constructor.name, s.getType());
1475
- const r = e[l].reduce((i, c) => c ? 1 + i : i, 0);
1476
- if (r !== t) for (let i = r; i < t; ++i) {
1477
- const c = me();
1478
- c.append(j()), s.append(c);
1479
- }
1480
- }
1481
- }
1482
- function Pn(n) {
1483
- if (n.detail < 3 || !de(n.target)) return !1;
1484
- const e = V(n.target);
1485
- if (e === null) return !1;
1486
- const t = N(e, (o) => P(o) && !o.isInline());
1487
- return t === null ? !1 : !!S(t.getParent()) && (t.select(0), !0);
1488
- }
1489
- function Un(n) {
1490
- return n.registerNodeTransform(ee, (e) => {
1491
- if (e.getColSpan() > 1 || e.getRowSpan() > 1) {
1492
- const [, , t] = le(e), [o] = U(t, e, e), l = o.length, s = o[0].length;
1493
- let r = t.getFirstChild();
1494
- k(r) || w(175);
1495
- const i = [];
1496
- for (let c = 0; c < l; c++) {
1497
- c !== 0 && (r = r.getNextSibling(), k(r) || w(175));
1498
- let f = null;
1499
- for (let h = 0; h < s; h++) {
1500
- const p = o[c][h], C = p.cell;
1501
- if (p.startRow === c && p.startColumn === h) f = C, i.push(C);
1502
- else if (C.getColSpan() > 1 || C.getRowSpan() > 1) {
1503
- S(C) || w(176);
1504
- const a = me(C.__headerState);
1505
- f !== null ? f.insertAfter(a) : $t(r, a);
1506
- }
1507
- }
1508
- }
1509
- for (const c of i) c.setColSpan(1), c.setRowSpan(1);
1510
- }
1511
- });
1512
- }
1513
- function jn(n, e = !0) {
1514
- const t = /* @__PURE__ */ new Map(), o = (s, r, i) => {
1515
- const c = G(s, i), f = Kn(s, c, n, e);
1516
- t.set(r, [f, c]);
1517
- }, l = n.registerMutationListener(Q, (s) => {
1518
- n.getEditorState().read(() => {
1519
- for (const [r, i] of s) {
1520
- const c = t.get(r);
1521
- if (i === "created" || i === "updated") {
1522
- const { tableNode: f, tableElement: h } = xt(r);
1523
- c === void 0 ? o(f, r, h) : h !== c[1] && (c[0].removeListeners(), t.delete(r), o(f, r, h));
1524
- } else i === "destroyed" && c !== void 0 && (c[0].removeListeners(), t.delete(r));
1525
- }
1526
- }, { editor: n });
1527
- }, { skipInitialization: !1 });
1528
- return () => {
1529
- l();
1530
- for (const [, [s]] of t) s.removeListeners();
1531
- };
1532
- }
1533
- function Vn(n) {
1534
- return n.hasNodes([Q]) || w(255), kt(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(Pt, Pn, Oe), n.registerNodeTransform(Q, Hn), n.registerNodeTransform(pe, Ln), n.registerNodeTransform(ee, zn));
1535
- }
1536
- export {
1537
- Yn as B,
1538
- bn as H,
1539
- Ie as K,
1540
- In as L,
1541
- pe as O,
1542
- Jn as P,
1543
- qn as Q,
1544
- S as T,
1545
- wn as W,
1546
- Q as Z,
1547
- Vn as d,
1548
- jn as h,
1549
- Xn as j,
1550
- Un as u,
1551
- me as v,
1552
- ee as y,
1553
- yt as z
1554
- };
1555
- //# sourceMappingURL=LexicalTable.prod-CYafu_j9.js.map