@uva-glass/component-library 1.55.1 → 1.56.0

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