@uva-glass/component-library 1.62.9 → 1.62.10

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