@sheetxl/grid-react 0.4.9 → 0.4.11

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.
@@ -1,3415 +1,13 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-grid_h9wwa_7{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_h9wwa_7 *{box-sizing:border-box!important}._sheetxl-grid_h9wwa_7 *:focus{outline:none}._sheetxl-grid_h9wwa_7 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_h9wwa_7 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_h9wwa_7 .sheetxl-stage{contain:strict}._sheetxl-grid_h9wwa_7 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- import { jsx as q, jsxs as Ht, Fragment as wn } from "react/jsx-runtime";
3
- import Sn, { memo as At, useCallback as D, useRef as G, useEffect as st, useImperativeHandle as Ur, forwardRef as Ut, useMemo as Ee, useLayoutEffect as tn, useState as Ze, version as Kr, createElement as Jo, useReducer as Qo } from "react";
4
- import { createRoot as $i } from "react-dom/client";
5
- import { unstable_batchedUpdates as Bi, createPortal as qr } from "react-dom";
1
+ (function () {
2
+ 'use strict';
3
+
4
+ try{if(typeof document != 'undefined'){var elementStyle = document.createElement('style');elementStyle.appendChild(document.createTextNode("/**\n * CSS files with the .module.css suffix will be treated as CSS modules\n * and scoped locally.\n */\n\n._sheetxl-grid_h9wwa_7 {\n position: relative;\n box-sizing: border-box;\n user-select: none;\n}\n\n._sheetxl-grid_h9wwa_7 * {\n box-sizing: border-box !important;\n}\n\n._sheetxl-grid_h9wwa_7 *:focus {\n outline: none;\n}\n\n/*\n.sheetxl-grid :global(.view) > * {\n pointer-events: auto;\n}\n*/\n\n._sheetxl-grid_h9wwa_7 .cell-container {\n position: absolute;\n overflow: visible;\n white-space: pre;\n /* overflow: hidden; */\n /* This is supposed to make rendering faster but instead it is making it blurry */\n /* will-change: transform; */\n}\n\n._sheetxl-grid_h9wwa_7 .cell-container > * {\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n position: absolute;\n}\n\n\n._sheetxl-grid_h9wwa_7 .sheetxl-stage {\n contain: strict;\n}\n._sheetxl-grid_h9wwa_7 .sheetxl-stage > * {\n contain: strict;\n}"));document.head.appendChild(elementStyle);}}catch(e){console.error('vite-plugin-css-injected-by-js', e);}
5
+
6
+ })();
6
7
  /**
7
- * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.4.9
8
+ * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.4.11
8
9
  *
9
10
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
10
11
  * License: The license can be found at https://www.sheetxl.com/license.
11
12
  */
12
- const it = "up", lt = "down", ot = "left", Ke = "right", uo = "tl", Hn = "t", Nn = "l", Xt = "c", Ft = "text/html", fn = "text/plain", Mo = "image/png", Fi = Object.freeze({ left: 0, top: 0 }), ji = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), Vi = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
13
- Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: Vi, EmptyRect: ji, EmptyTopLeft: Fi }, Symbol.toStringTag, { value: "Module" }));
14
- const Nt = "column", an = "row", Wi = Object.freeze({ colIndex: 0, rowIndex: 0 }), Hi = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), Yr = (e, t) => e.colStart === t.colStart ? e.rowStart - t.rowStart : e.colStart - t.colStart, Xr = (e, t) => e.rowStart === t.rowStart ? e.colStart - t.colStart : e.rowStart - t.rowStart, Ni = (e, t) => e.rowEnd === t.rowEnd ? t.colEnd - e.colEnd : t.rowEnd - e.rowEnd, Ui = (e, t) => e.colEnd === t.colEnd ? t.rowEnd - e.rowEnd : t.colEnd - e.colEnd, or = (e, t) => e.colIndex === t.colIndex ? e.rowIndex - t.rowIndex : e.colIndex - t.colIndex, rr = (e, t) => e.rowIndex === t.rowIndex ? e.colIndex - t.colIndex : e.rowIndex - t.rowIndex, Gr = (e = an, t = !1) => t ? e !== Nt ? Ni : Ui : e !== Nt ? Xr : Yr, ir = (e, t) => e === t || !(!e || !t) && e.rowIndex === t.rowIndex && e.colIndex === t.colIndex, jo = (e, t) => e === t || !(!e || !t) && e.rowStart === t.rowStart && e.rowEnd === t.rowEnd && e.colStart === t.colStart && e.colEnd === t.colEnd, Vo = (e, t) => !(!e || !t || e.colStart > t.colEnd || t.colStart > e.colEnd || e.rowStart > t.rowEnd || t.rowStart > e.rowEnd), lr = (e, t) => {
15
- if (e === t) return !0;
16
- if (!e || !t || e.length !== t.length) return !1;
17
- for (let n = 0; n < e.length; n++) if (!jo(e[n], t[n])) return !1;
18
- return !0;
19
- }, To = (e, t, n) => {
20
- if (!e && !t) return null;
21
- if (!e) return n ? t : { ...t };
22
- if (!t) return n ? e : { ...e };
23
- const o = Math.min(e.colStart, t.colStart), r = Math.min(e.rowStart, t.rowStart), i = Math.max(e.colEnd, t.colEnd), l = Math.max(e.rowEnd, t.rowEnd);
24
- let s = n;
25
- return s ? (s.colStart = o, s.rowStart = r, s.colEnd = i, s.rowEnd = l) : s = { colStart: o, rowStart: r, colEnd: i, rowEnd: l }, s;
26
- }, sr = (e, t) => {
27
- if (!t || t.length === 0) return e;
28
- const n = { ...e };
29
- for (let o = 0; o < t.length; o++) {
30
- const r = t[o];
31
- Vo(n, r) && (n.rowStart = Math.min(n.rowStart, r.rowStart), n.colStart = Math.min(n.colStart, r.colStart), n.rowEnd = Math.max(n.rowEnd, r.rowEnd), n.colEnd = Math.max(n.colEnd, r.colEnd));
32
- }
33
- return n;
34
- }, Ki = [null, null], qi = (e, t, n) => {
35
- if (e[0].value === e[1].value) return t;
36
- };
37
- function cr(e, t = 2, n, o = an, r) {
38
- let i = [...e];
39
- if (t <= 0 || e.length <= 1) return i;
40
- let l = o === Nt, s = 0, a = !1;
41
- do {
42
- const d = i.sort(Gr(l ? an : Nt));
43
- i = [], i.push(d[0]);
44
- const g = d.length;
45
- let m = 0, u = d[0], x = u.colStart, M = u.rowStart, E = u.colEnd, P = u.rowEnd;
46
- for (let Q = 1; Q < g; Q++) {
47
- const k = d[Q];
48
- let I = !1;
49
- if (I = l ? u && M === k.rowStart && P === k.rowEnd && E + 1 === k.colStart : u && x === k.colStart && E === k.colEnd && P + 1 === k.rowStart, I) {
50
- let z = { colStart: x, rowStart: M, colEnd: l ? k.colEnd : E, rowEnd: l ? P : k.rowEnd };
51
- if (u.value !== void 0 && (z.value = u.value), n) {
52
- const se = r ?? [null, null];
53
- se[0] = u, se[1] = k, z = n(se, z, o);
54
- }
55
- if (z) {
56
- i[m] = z, a = !0, u = z, x = u.colStart, M = u.rowStart, E = u.colEnd, P = u.rowEnd;
57
- continue;
58
- }
59
- }
60
- i[++m] = k, u = k, x = u.colStart, M = u.rowStart, E = u.colEnd, P = u.rowEnd;
61
- }
62
- s++, l = !l, s === 1 && (a = !0);
63
- } while (s < t && a && i.length > 1);
64
- return i;
65
- }
66
- const Z = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: Wi, EmptyRange: Hi, cellToRange: (e, t) => {
67
- if (!e) return null;
68
- let n = t;
69
- return n || (n = { ...e }, delete n.colIndex, delete n.rowIndex), n.colStart = e.colIndex ?? 0, n.rowStart = e.rowIndex ?? 0, n.colEnd = e.colIndex ?? 0, n.rowEnd = e.rowIndex ?? 0, n;
70
- }, columnFirstCellComparator: or, columnFirstRangeComparator: Yr, createCellComparator: (e = an, t = !1) => t ? e !== Nt ? (n, o) => n.rowIndex === o.rowIndex ? o.colIndex - n.colIndex : o.rowIndex - n.rowIndex : (n, o) => n.colIndex === o.colIndex ? o.rowIndex - n.rowIndex : o.colIndex - n.colIndex : e !== Nt ? rr : or, createConflatingRanges: (e, t = !1) => {
71
- const n = [];
72
- let o, r, i = Number.MIN_SAFE_INTEGER, l = Number.MIN_SAFE_INTEGER;
73
- return { append: (s, a, d) => {
74
- let g = !0;
75
- const m = d !== void 0;
76
- if (m) {
77
- const M = e ? e(r, d, t) : r === d ? d : void 0;
78
- M === void 0 ? g = !1 : d = M;
79
- }
80
- if (g && a === l + 1 && s === i) return t ? o.rowEnd = a : o.colEnd = a, l = a, void (r = d);
81
- o && n.push(o);
82
- const u = t ? s : a, x = t ? a : s;
83
- o = { colStart: u, rowStart: x, colEnd: u, rowEnd: x }, m && (o.value = d), i = s, l = a, r = d;
84
- }, done: (s) => (o && (n.push(o), o = null), s ? cr(n, 3, s === !0 ? qi : s, t ? Nt : an, Ki) : n) };
85
- }, createRangeComparator: Gr, defaultRange: (e, t, n) => e ? n ? (n.colStart = e.colStart ?? t.colStart, n.rowStart = e.rowStart ?? t.rowStart, n.colEnd = e.colEnd ?? t.colEnd, n.rowEnd = e.rowEnd ?? t.rowEnd, n) : { colStart: e.colStart ?? t.colStart, rowStart: e.rowStart ?? t.rowStart, colEnd: e.colEnd ?? t.colEnd, rowEnd: e.rowEnd ?? t.rowEnd } : t, extendRangeToIntersectingRanges: sr, extendRangeToUnionRanges: (e, t) => {
86
- if (!t || t.length === 0) return e;
87
- let n = e, o = null;
88
- for (; !jo(n, o); ) o = n, n = sr(o, t);
89
- return n;
90
- }, indexOfCoords: (e, t) => {
91
- const n = { colStart: e.colIndex, rowStart: e.rowIndex, colEnd: e.colIndex, rowEnd: e.rowIndex };
92
- for (let o = t.length - 1; o >= 0; o--) if (Vo(n, t[o])) return o;
93
- return -1;
94
- }, intersectRanges: (e, t, n) => {
95
- if (!e) return n ? t : { ...t };
96
- if (!t) return n ? e : { ...e };
97
- if (!e && !t || e.rowStart > t.rowEnd || e.rowEnd < t.rowStart || e.colStart > t.colEnd || e.colEnd < t.colStart) return null;
98
- const o = Math.max(e.colStart, t.colStart), r = Math.max(e.rowStart, t.rowStart), i = Math.min(e.colEnd, t.colEnd), l = Math.min(e.rowEnd, t.rowEnd);
99
- let s = n;
100
- return s ? (s.colStart = o, s.rowStart = r, s.colEnd = i, s.rowEnd = l) : s = { colStart: o, rowStart: r, colEnd: i, rowEnd: l }, s;
101
- }, isCellWithinRange: (e, t) => !(!e || !t || e.rowIndex < t.rowStart || e.rowIndex > t.rowEnd || e.colIndex < t.colStart || e.colIndex > t.colEnd), isEqualCells: ir, isEqualRanges: jo, isEqualRangesArrays: lr, isEqualSelectionCoords: (e, t) => e === t || !(!e || !t) && e.rangeIndex === t.rangeIndex && !!ir(e.cell, t.cell) && lr(e.ranges, t.ranges), isRangeWithinRange: (e, t) => !(e.rowStart < t.rowStart || e.rowEnd > t.rowEnd || e.colStart < t.colStart || e.colEnd > t.colEnd), isRangesIntersect: Vo, isSingleCell: (e) => !!e && e.rowEnd === e.rowStart && e.colStart === e.colEnd, isValidRange: (e) => !(!e || typeof e.colStart != "number" || e.colStart < 0 || typeof e.colEnd != "number" || e.colEnd < e.colStart || typeof e.rowStart != "number" || e.rowStart < 0 || typeof e.rowEnd != "number" || e.rowEnd < e.rowStart), mergeRangedValues: cr, rowFirstCellComparator: rr, rowFirstRangeComparator: Xr, sanitizeRange: (e) => e ? { colStart: e.colIndex ?? e.colStart ?? 0, rowStart: e.rowIndex ?? e.rowStart ?? 0, colEnd: e.colIndex ?? e.colEnd ?? 0, rowEnd: e.rowIndex ?? e.rowEnd ?? 0 } : null, translateRange: (e, t = -e.rowStart, n = -e.colStart, o) => o ? (o.colStart = e.colStart + n, o.rowStart = e.rowStart + t, o.colEnd = e.colEnd + n, o.rowEnd = e.rowEnd + t, o) : { colStart: e.colStart + n, rowStart: e.rowStart + t, colEnd: e.colEnd + n, rowEnd: e.rowEnd + t }, unionRanges: To, unionRangesArrays: (e, t, n) => {
102
- if (!e || e.length === 0) return null;
103
- if (e.length === 1 && !t) return e[0];
104
- let o = e[0];
105
- for (let r = 1; r < e.length; r++) o = To(o, e[r], n);
106
- return t && (o = To(o, t, n)), o;
107
- } }, Symbol.toStringTag, { value: "Module" })), Yi = typeof Symbol == "function" && Symbol.for ? Symbol.for("react.element") : 60103;
108
- function Xi(e) {
109
- return /* @__PURE__ */ function(t) {
110
- return !!t && typeof t == "object";
111
- }(e) && !function(t) {
112
- const n = Object.prototype.toString.call(t);
113
- return n === "[object RegExp]" || n === "[object Date]" || t.$$typeof === Yi;
114
- }(e);
115
- }
116
- function Vn(e, t) {
117
- return t.clone !== !1 && t.isMergeableObject(e) ? En((n = e, Array.isArray(n) ? [] : {}), e, t) : e;
118
- var n;
119
- }
120
- function Gi(e, t, n) {
121
- return e.concat(t).map(function(o) {
122
- return Vn(o, n);
123
- });
124
- }
125
- function ar(e) {
126
- return Object.keys(e).concat((t = e, Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(n) {
127
- return Object.propertyIsEnumerable.call(t, n);
128
- }) : []));
129
- var t;
130
- }
131
- function dr(e, t) {
132
- try {
133
- return t in e;
134
- } catch {
135
- return !1;
136
- }
137
- }
138
- function En(e, t, n) {
139
- (n = n || {}).arrayMerge = n.arrayMerge || Gi, n.isMergeableObject = n.isMergeableObject || Xi, n.cloneUnlessOtherwiseSpecified = Vn;
140
- const o = Array.isArray(t);
141
- return o === Array.isArray(e) ? o ? n.arrayMerge(e, t, n) : function(r, i, l) {
142
- const s = {};
143
- return l.isMergeableObject(r) && ar(r).forEach(function(a) {
144
- s[a] = Vn(r[a], l);
145
- }), ar(i).forEach(function(a) {
146
- var d, g;
147
- dr(d = r, g = a) && (!Object.hasOwnProperty.call(d, g) || !Object.propertyIsEnumerable.call(d, g)) || (dr(r, a) && l.isMergeableObject(i[a]) ? s[a] = function(m, u) {
148
- if (!u.customMerge) return En;
149
- const x = u.customMerge(m);
150
- return typeof x == "function" ? x : En;
151
- }(a, l)(r[a], i[a], l) : s[a] = Vn(i[a], l));
152
- }), s;
153
- }(e, t, n) : Vn(t, n);
154
- }
155
- En.all = function(e, t) {
156
- if (!Array.isArray(e)) throw new Error("first argument should be an array");
157
- return e.reduce(function(n, o) {
158
- return En(n, o, t);
159
- }, {});
160
- };
161
- const Zi = Object.freeze([]), Ji = Object.freeze({}), ur = (e) => e, so = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
162
- let t = 16 * Math.random() | 0;
163
- return (e === "x" ? t : 3 & t | 8).toString(16);
164
- }), Zr = (e, t) => e === t || !(!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length) && e.every((n, o) => n === t[o]), Fn = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, Jr = (e) => typeof e != "object" || Array.isArray(e) || e === null ? e : (Object.keys(e).forEach(function(t) {
165
- e[t] && typeof e[t] == "object" ? Jr(e[t]) : e[t] !== null && e[t] !== void 0 || delete e[t], typeof e[t] == "object" && Object.keys(e[t]).length === 0 && delete e[t];
166
- }), Object.keys(e).length === 0 ? null : e), Qi = (e, t) => !(e !== t && !Zr(e, t) && !e.isEqual?.(t)), Qr = (e, t, n = Qi) => {
167
- if (e == null || e === t) return null;
168
- if (!e || typeof e != "object" || Array.isArray(e) || e.isImmutable?.()) return n(e, t) ? null : e;
169
- const o = Object.keys(e);
170
- if (o.length === 0) return null;
171
- let r = !1;
172
- for (let i = 0; i < o.length; i++) {
173
- const l = o[i];
174
- Qr(e[l], t?.[l], n) === null && (r = !0, delete e[l]);
175
- }
176
- return r && Object.keys(e).length === 0 ? null : void 0;
177
- }, hr = typeof performance == "object" && typeof performance.now == "function" ? () => performance.now() : () => Date.now(), fr = (e) => e == null, pr = (e, t) => !(t.left > e.right || t.right < e.left || t.top > e.bottom || t.bottom < e.top), gr = !(typeof window > "u" || !window.document || !window.document.createElement), jt = { Windows: "windows", MacOS: "macos", IOS: "ios", Linux: "linux", Android: "android", Safari: "safari", Firefox: "firefox", Node: "node", Unknown: "unknown" }, Un = () => {
178
- if (ei()) return jt.Node;
179
- const e = globalThis.navigator !== void 0 && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : "";
180
- return e ? /(win32|win64|windows|wince)/i.test(e) ? jt.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(e) ? jt.MacOS : /(iphone|ipad|ipod)/i.test(e) ? jt.IOS : /android/.test(e) ? jt.Android : /linux/.test(e) ? jt.Linux : /^((?!chrome|android|).)*safari/i.test(e) ? jt.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(e) ? jt.Firefox : jt.Unknown : jt.Unknown;
181
- };
182
- function ei() {
183
- return typeof process < "u" && process.release?.name === "node" || (typeof process < "u" && process.browser, !1);
184
- }
185
- const wr = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeElement || e?.contains(document.activeElement)), Ct = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray: Zi, EmptyObject: Ji, OSType: jt, arrayMove: function(e, t, n) {
186
- const o = e.slice();
187
- return o.splice(n < 0 ? o.length + n : n, 0, o.splice(t, 1)[0]), o;
188
- }, asNumber: (e) => {
189
- const t = ((n) => 1 * n)(e);
190
- return Number.isFinite(t) ? t : 0;
191
- }, camelToPrettyCase: (e) => e.length === 1 ? e.toUpperCase() : e.replace(/([A-Z])/g, " $1").replace(/^./, function(t) {
192
- return t.toUpperCase();
193
- }).trim(), canUseDOM: gr, cancelTimeout: (e) => {
194
- cancelAnimationFrame(e.id);
195
- }, castToString: (e) => e == null || e === void 0 ? "" : typeof e != "string" ? "" + e : e, cloneObject: (e) => fr(e) ? e : JSON.parse(JSON.stringify(e)), consoleWithNoSource: (...e) => new Promise((t) => {
196
- setTimeout(() => {
197
- Function("console.log.apply(console, arguments)").apply(null, e), t();
198
- });
199
- }), debounce: function(e, t = 300, n = !1) {
200
- let o, r, i, l, s = 0;
201
- function a() {
202
- let g = Date.now() - s;
203
- g < t && g >= 0 ? o = setTimeout(a, t - g) : (o = null, n || (l = e.apply(i, r), i = r = null));
204
- }
205
- t == null && (t = 100);
206
- const d = function() {
207
- i = globalThis, r = arguments, s = Date.now();
208
- var g = n && !o;
209
- return o || (o = setTimeout(a, t)), g && (l = e.apply(i, r), i = r = null), l;
210
- };
211
- return d.clear = function() {
212
- o && (clearTimeout(o), o = null);
213
- }, d.flush = function() {
214
- o && (l = e.apply(i, r), i = r = null, clearTimeout(o), o = null);
215
- }, d;
216
- }, deepEqual: function e(t, n) {
217
- if (t === n) return !0;
218
- if (t && n && typeof t == "object" && typeof n == "object") {
219
- if (t.constructor !== n.constructor) return !1;
220
- let o, r, i;
221
- if (Array.isArray(t)) {
222
- if (o = t.length, o != n.length) return !1;
223
- for (r = o; r-- !== 0; ) if (!e(t[r], n[r])) return !1;
224
- return !0;
225
- }
226
- if (t instanceof Map && n instanceof Map) {
227
- if (t.size !== n.size) return !1;
228
- for (r of t.entries()) if (!n.has(r[0])) return !1;
229
- for (r of t.entries()) if (!e(r[1], n.get(r[0]))) return !1;
230
- return !0;
231
- }
232
- if (t instanceof Set && n instanceof Set) {
233
- if (t.size !== n.size) return !1;
234
- for (r of t.entries()) if (!n.has(r[0])) return !1;
235
- return !0;
236
- }
237
- if (ArrayBuffer.isView(t) && ArrayBuffer.isView(n)) {
238
- if (o = t.length, o != n.length) return !1;
239
- for (r = o; r-- !== 0; ) if (t[r] !== n[r]) return !1;
240
- return !0;
241
- }
242
- if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
243
- if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
244
- if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
245
- if (i = Object.keys(t), o = i.length, o !== Object.keys(n).length) return !1;
246
- for (r = o; r-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(n, i[r])) return !1;
247
- for (r = o; r-- !== 0; ) {
248
- let l = i[r];
249
- if (!(l === "_owner" && t.$$typeof || e(t[l], n[l]))) return !1;
250
- }
251
- return !0;
252
- }
253
- return t != t && n != n;
254
- }, deepFreeze: function e(t) {
255
- return Object.freeze(t), Object.keys(t).forEach((n) => {
256
- typeof t[n] != "object" || t[n] === null || Object.isFrozen(t[n]) || e(t[n]);
257
- }), t;
258
- }, deepMerge: En, diffValues: (e, t) => {
259
- const n = {}, o = Object.keys(t), r = o.length;
260
- for (let i = 0; i < r; i++) {
261
- const l = o[i];
262
- e[l] !== t[l] && (e[l] === void 0 ? n[l] = t[l] : n[l] = e[l]);
263
- }
264
- return Object.keys(n).length === 0 ? null : n;
265
- }, findEqualOrGreater: function(e, t, n = ur) {
266
- let o = 0, r = e.length - 1;
267
- for (; o <= r; ) {
268
- let i = Math.floor((o + r) / 2), l = n(e[i]);
269
- if (l === t) return i;
270
- l < t ? o = i + 1 : r = i - 1;
271
- }
272
- return o;
273
- }, findEqualOrLesser: function(e, t, n = ur) {
274
- let o = e.length - 1, r = 0;
275
- for (; o >= r; ) {
276
- let i = Math.floor((o + r) / 2), l = n(e[i]);
277
- if (l === t) return i;
278
- l > t ? o = i - 1 : r = i + 1;
279
- }
280
- return o;
281
- }, findNextStep: (e, t = !0, n = 15, o = 10, r = 400) => {
282
- const i = Math.max(e - o, 0) + (t ? 1 : -1);
283
- return Math.min(r, Math[t ? "ceil" : "floor"](i / n) * n + o);
284
- }, getDPI: () => {
285
- let e = 1;
286
- return typeof window == "object" && (e = window.devicePixelRatio || 1), e;
287
- }, getFromPath: (e, t) => {
288
- const n = t.split(".");
289
- let o = e;
290
- for (let r = 0; r < n.length; r++) {
291
- const i = n[r];
292
- if (!o) return null;
293
- let l = o[i];
294
- if (typeof l == "function" && (l = l.bind(o)()), !l || !Fn(l)) return l;
295
- o = l;
296
- }
297
- return o ?? null;
298
- }, getOS: Un, hasFocus: wr, isDefined: (e) => e != null, isEmpty: (e) => e == null || e === "", isEqualArrays: Zr, isEqualBounds: (e, t) => e === t || !(e && !t || t && !e) && e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height, isEqualObjectKeys: (e, t) => {
299
- if (e === t) return !0;
300
- if (e && !t || t && !e) return !1;
301
- const n = Object.keys(e);
302
- if (n.length !== Object.keys(t).length) return !1;
303
- for (let o = 0; o < n.length; o++) if (e[n[o]] !== t[n[o]]) return !1;
304
- return !0;
305
- }, isNode: ei, isNullOrUndefined: fr, isNumeric: (e) => {
306
- const t = 1 * e;
307
- return Number.isFinite(t) && typeof t == "number";
308
- }, isObject: Fn, isPromiseLike: (e) => !!e && typeof e.then == "function", isRectInsideRect: (e, t) => e.top >= t.top && e.bottom <= t.bottom && e.left >= t.left && e.right <= t.right, isRectIntersect: pr, mergeContentful: (...e) => {
309
- const t = e.length;
310
- if (t > 0 && e[t - 1] !== void 0 && !Fn(e[t - 1])) return e[t - 1];
311
- let n = e[0] || {};
312
- for (let o = 1; o < t; o++) n = En(n, e[o] || {}, { arrayMerge: (r, i) => [...i] });
313
- return n;
314
- }, nextTick: (e) => {
315
- typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(() => {
316
- e();
317
- }) : (typeof setImmediate == "function" ? setImmediate : setTimeout)(() => {
318
- e();
319
- });
320
- }, openFileDialog: (e = "*.*") => new Promise((t, n) => {
321
- if (!gr) return void n("Unable to open dialog with no dom.");
322
- const o = document.createElement("input");
323
- o.type = "file", o.accept = e;
324
- let r = null, i = !1;
325
- globalThis.addEventListener?.("focus", () => {
326
- setTimeout(() => {
327
- r || i || (i = !0, t(null));
328
- }, 1e3);
329
- }, { once: !0, passive: !0 }), o.onchange = () => {
330
- if (r = o.files[0], r) {
331
- if (i) return void console.warn("File open detected after faux cancel.", r);
332
- t(r);
333
- }
334
- }, o.autofocus = !0, o.click();
335
- }), rafThrottle: (e) => {
336
- let t, n = !1, o = function() {
337
- n = !1, e(t);
338
- };
339
- return function(r) {
340
- t = r, t && t.persist && t.persist(), n || (n = !0, requestAnimationFrame(o));
341
- };
342
- }, removeEmptyProperties: Jr, removeEqualValues: Qr, removeListenerAll: (e) => {
343
- if (!e) return [];
344
- for (let t = 0; t < e.length; t++) e[t] && e[t]();
345
- return [];
346
- }, requestTimeout: (e, t) => {
347
- const n = hr(), o = { id: requestAnimationFrame(function r() {
348
- hr() - n >= t ? e.call(null) : o.id = requestAnimationFrame(r);
349
- }) };
350
- return o;
351
- }, roundAccurately: (e, t = 0) => {
352
- if (e == null || !isFinite(e)) return null;
353
- const n = 10 ** t;
354
- return Number(Math.round(e * n) / n);
355
- }, setToPath: (e, t, n) => {
356
- const o = t.split(".");
357
- let r = e;
358
- if (!r) throw new Error("Can not set path to a null path.");
359
- for (let i = 0; r && i < o.length - 1; i++) {
360
- const l = o[i];
361
- let s = r[l];
362
- if (s == null && (s = {}, r[l] = s), !Fn(s)) throw new Error("Can not set path to a non object path.");
363
- r = s;
364
- }
365
- if (typeof n != "number" && typeof n != "boolean" && typeof n != "string" && !Fn(n)) throw new Error(`Can not set path to ${n} that is not a a supported primitive.`);
366
- return r[o[o.length - 1]] = n, e;
367
- }, splitNumber: (e) => {
368
- let t = Math.abs(e);
369
- if (isNaN(t) || !isFinite(e)) return null;
370
- let n = 0 | t, o = t - n, r = 0, i = 0, l = 1;
371
- if (o > 5e-8) for (; i < 8 && Math.abs(r / l - o) > 5e-8; ) i++, l *= 10, r = Math.round(o * l);
372
- return { ip: Math.trunc(e), fp: r, ipLength: Math.ceil(Math.log10(n + 1)), fpLength: i };
373
- }, subtractRect: (e, t, n = !1) => {
374
- if (!t) return [e];
375
- if (!pr(e, t)) return [];
376
- const o = [];
377
- let r = e;
378
- const i = () => {
379
- t.top > r.top && t.top < r.bottom && (o.push({ ...r, bottom: t.top }), r = { ...r, top: t.top });
380
- }, l = () => {
381
- t.bottom > r.top && t.bottom < r.bottom && (o.push({ ...r, top: t.bottom }), r = { ...r, bottom: t.bottom });
382
- }, s = () => {
383
- t.right > r.left && t.right < r.right && (o.push({ ...r, left: t.right }), r = { ...r, right: t.right });
384
- }, a = () => {
385
- t.left > r.left && t.left < r.right && (o.push({ ...r, right: t.left }), r = { ...r, left: t.left });
386
- };
387
- return n ? (a(), s(), i(), l()) : (i(), l(), s(), a()), o;
388
- }, textToKey: (e) => e.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(), throttle: function(e, t) {
389
- let n = null;
390
- return (...o) => {
391
- const r = Date.now();
392
- (!n || r - n >= t) && (n = r, e(...o));
393
- };
394
- }, toSafeJSON: function e(t) {
395
- if (t === null || typeof t != "object") return t;
396
- if (typeof t.toJSON == "function") return t.toJSON();
397
- if (Array.isArray(t)) return t.map((o) => e(o));
398
- if (typeof t.toString == "function" && t.toString !== Object.prototype.toString) return t.toString();
399
- const n = {};
400
- for (const o in t) t.hasOwnProperty(o) && (n[o] = e(t[o]));
401
- return n;
402
- }, transpose: (e) => {
403
- if (!e) return e;
404
- const t = e.length, n = e[0].length, o = [];
405
- for (let r = 0; r < n; r++) o[r] = Array(t);
406
- for (let r = 0; r < t; r++) for (let i = 0; i < n; i++) o[i][r] = e[r][i];
407
- return o;
408
- }, uuidV4: so, validEnumValue: (e, t) => {
409
- if (!Object.values(e).includes(t)) throw new Error(`Invalid type: ${t ?? "null"}. Must be one of: ${Object.values(t).join(", ")}.`);
410
- }, whenFocus: async (e, t = !1) => new Promise((n) => {
411
- wr(e, t) ? n(!0) : e.addEventListener("focusin", () => {
412
- n(!0);
413
- }, { once: !0 }), e.focus();
414
- }) }, Symbol.toStringTag, { value: "Module" }));
415
- Object.freeze(Object.defineProperty({ __proto__: null, MESSAGE_ERROR_INVALID_ARG: (e) => `Invalid argument: '${e}'.` }, Symbol.toStringTag, { value: "Module" }));
416
- const ti = (e) => {
417
- const t = new Uint8Array(e), n = t.byteLength;
418
- let o = "";
419
- for (let r = 0; r < n; r++) o += String.fromCharCode(t[r]);
420
- if (typeof window < "u" && typeof globalThis.btoa == "function") return globalThis.btoa(o);
421
- if (typeof Buffer < "u") return Buffer.from(o, "binary").toString("base64");
422
- throw new Error("Unsupported environment");
423
- }, Wo = (e) => new Promise((t, n) => {
424
- if (e) if (typeof FileReader < "u") {
425
- const o = new FileReader();
426
- o.onload = () => {
427
- t(o.result);
428
- }, o.onerror = () => {
429
- n(o.error);
430
- }, o.readAsText(e);
431
- } else if (typeof Buffer < "u") {
432
- const o = (r) => Buffer.from(r).toString("utf-8");
433
- e.arrayBuffer().then((r) => {
434
- t(o(r));
435
- }).catch((r) => {
436
- n(r);
437
- });
438
- } else n(new Error("Unsupported environment"));
439
- else t("");
440
- });
441
- Object.freeze(Object.defineProperty({ __proto__: null, DEFAULT_MIME_TYPE: "*/*", arrayBufferToBase64: ti, base64ToArrayBuffer: (e) => {
442
- const t = typeof window < "u" && typeof globalThis.atob == "function" ? globalThis.atob(e) : Buffer.from(e, "base64").toString("binary"), n = t.length, o = new Uint8Array(n);
443
- for (let r = 0; r < n; r++) o[r] = t.charCodeAt(r);
444
- return o.buffer;
445
- }, blobToString: Wo }, Symbol.toStringTag, { value: "Module" }));
446
- const ni = "data:image/png;base64,", oi = "Unable to resolve image.", mr = (e) => new Promise(async (t, n) => {
447
- let o = null;
448
- try {
449
- o = new Image(), o.src = e, o.addEventListener("load", function() {
450
- t({ width: o.naturalWidth, height: o.naturalHeight });
451
- }, { once: !0 }), o.addEventListener("error", function() {
452
- URL.revokeObjectURL(e), n("Invalid Image");
453
- }, { once: !0 }), await o.decode("sync");
454
- } catch {
455
- o?.src && URL.revokeObjectURL(o.src);
456
- }
457
- o || n(oi);
458
- }), Ro = "image/svg+xml";
459
- var xr, yr;
460
- Object.freeze(Object.defineProperty({ __proto__: null, DATA_URL_PNG_PREFIX: ni, getImageDataUrl: (e, t = 1) => new Promise(async (n, o) => {
461
- let r = null;
462
- try {
463
- r = new Image(), r.src = e, r.addEventListener("load", function() {
464
- try {
465
- const i = document.createElement("canvas");
466
- i.width = r.naturalWidth, i.height = r.naturalHeight, i.getContext("2d").drawImage(r, 0, 0);
467
- const l = i.toDataURL("image/png", t);
468
- n({ elemImg: r, dataUrl: l });
469
- } catch (i) {
470
- URL.revokeObjectURL(e), o(i);
471
- }
472
- }, { once: !0 }), r.addEventListener("error", function() {
473
- URL.revokeObjectURL(e), o("Invalid Image");
474
- }, { once: !0 }), await r.decode("sync");
475
- } catch {
476
- r?.src && URL.revokeObjectURL(r.src);
477
- }
478
- r || o(oi);
479
- }), loadImageDetails: async (e, t = null) => {
480
- let n = null;
481
- const o = async () => {
482
- try {
483
- const i = t ?? "image/*", l = URL.createObjectURL(new Blob([e], { type: i })), s = await mr(l);
484
- n = { mimeType: i, naturalDimensions: s, asUrl: l };
485
- } catch {
486
- }
487
- }, r = async () => {
488
- try {
489
- const i = new TextDecoder().decode(e), l = URL.createObjectURL(new Blob([i], { type: Ro })), s = await mr(l);
490
- n = { mimeType: t ?? Ro, naturalDimensions: s, asUrl: l, asSVGText: i };
491
- } catch {
492
- }
493
- };
494
- if (t === Ro ? await r() : t.startsWith("image/") ? await o() : (await o(), n || await r()), !n) throw new Error("Failed to load image");
495
- return n;
496
- } }, Symbol.toStringTag, { value: "Module" })), (yr = xr || (xr = {})).resolveTypedUpdates = (e, t, n, o) => {
497
- if (e === null) return e;
498
- if (e === void 0) return o;
499
- let r = e;
500
- if (t?.shorthand) {
501
- const a = t?.shorthand(e, n);
502
- a !== void 0 && (r = a);
503
- }
504
- if (r !== null && t?.getSubType) {
505
- const a = t.getSubType(r);
506
- a && (t = a);
507
- }
508
- const i = t?.properties, l = t?.arrayType ?? !1;
509
- let s = r;
510
- if (t && t.merge && s && o) s = t.merge(s, o, n);
511
- else if (!l && i) {
512
- const a = Object.keys({ ...r, ...o });
513
- s = null;
514
- for (let d = 0; d < a.length; d++) {
515
- const g = a[d];
516
- let m, u = r[g];
517
- if (u !== void 0) {
518
- const x = i[g];
519
- m = x ? (0, yr.resolveTypedUpdates)(u, x, n, o?.[g]) : u;
520
- } else m = o?.[g];
521
- m != null && (s = s ?? {}, s[g] = m);
522
- }
523
- }
524
- return s;
525
- };
526
- const vr = `The Safari browser does not support advanced copy and paste.
527
- Copy and paste will be limited to within the browser tab.
528
-
529
- Please use Chrome or Edge if external copy and paste is required.`, ko = `You do not have permissions to access the clipboard.
530
- All copy and paste operations will be limited to the browser tab.`, ri = { Safari: `The Safari browser does not support advanced copy and paste.
531
- Copy and paste will be limited to within the browser tab.
532
-
533
- Please use Chrome or Edge if external copy and paste is required.`, Perms: ko, PermsWrite: Un() === jt.Safari ? vr : ko, PermsRead: Un() === jt.Safari ? vr : ko }, Po = async () => new Promise((e) => {
534
- document.hasFocus() ? e() : globalThis.addEventListener?.("focus", () => {
535
- e();
536
- }, { once: !0 }), document.activeElement.focus?.();
537
- }), Oo = async (e, t, n) => {
538
- if (Un() === jt.Safari) return await n(new Error(ri.Safari));
539
- try {
540
- const o = async (l) => {
541
- try {
542
- return await l();
543
- } catch (s) {
544
- if (s.message?.includes("Document is not focused")) return !1;
545
- throw s;
546
- }
547
- }, r = await globalThis?.navigator?.permissions?.query({ name: e, allowWithoutGesture: !0, allowWithoutSanitization: !0 });
548
- let i = !1;
549
- if (r.state === "prompt" && (i = await o(t)), i || r.state !== "granted" || (i = await t()), !i) return await n(new Error(r.state));
550
- } catch (o) {
551
- return o.message === "No valid data on clipboard" || o.name === "DataError" ? void 0 : await n(o);
552
- }
553
- }, ii = async (e) => {
554
- try {
555
- return await e.read({ unsanitized: [Ft] });
556
- } catch {
557
- }
558
- return await e.read();
559
- };
560
- if (!globalThis.ClipboardItem) {
561
- const e = (n, o) => new Blob([o], { type: n });
562
- class t {
563
- constructor(o, r) {
564
- this._items = {}, this._types = Object.keys(o);
565
- const i = {}, l = Object.keys(o);
566
- for (let s = 0; s < l.length; s++) {
567
- const a = l[s];
568
- let d = o[a];
569
- i[a] = typeof d == "string" ? e(a, d) : d;
570
- }
571
- this._items = i, this._presentationStyle = r?.presentationStyle ?? "unspecified";
572
- }
573
- get types() {
574
- return this._types;
575
- }
576
- getType(o) {
577
- return Promise.resolve(this._items[o]);
578
- }
579
- supports(o) {
580
- return !0;
581
- }
582
- }
583
- globalThis.ClipboardItem = t;
584
- }
585
- const Ho = async (e, t = Ft) => new Promise(async (n, o) => {
586
- try {
587
- const r = await (async (i, l) => {
588
- if (!i) return null;
589
- const s = await ii(i);
590
- let a = !1;
591
- for (let d = 0; !a && s && d < s.length; d++) if (a = s[d].types.includes(l), a) return await s[d].getType(l);
592
- return a ? void 0 : null;
593
- })(e, t);
594
- if (r) {
595
- const i = new FileReader();
596
- i.onload = () => {
597
- n(i.result);
598
- }, i.onerror = () => {
599
- n("");
600
- }, i.readAsText(r);
601
- } else n("");
602
- } catch (r) {
603
- o(r);
604
- }
605
- }), br = async (e, t = Ft) => {
606
- const n = await Ho(e, t);
607
- if (!n) return null;
608
- let o = null;
609
- try {
610
- o = new DOMParser().parseFromString(n, Ft);
611
- } catch {
612
- console.warn("Can't parse html from clipboard.");
613
- }
614
- return o;
615
- }, Kn = "clipboard-uuid", Tn = "web text/uuid", Sr = (e) => `<div style="display:none" ${Kn}="${e}"/>`, el = (e, t) => {
616
- let n = null;
617
- try {
618
- const o = new DOMParser().parseFromString(t, Ft);
619
- o.body.firstElementChild.setAttribute(Kn, e), n = o.getElementsByTagName("body")[0].innerHTML;
620
- } catch (o) {
621
- console.warn("Can't embed uuid.", o);
622
- }
623
- return n;
624
- }, _r = (e, t) => {
625
- if (!t || !e) return !1;
626
- try {
627
- const n = t.querySelectorAll(`[${Kn}="${e}"]`);
628
- if (n && n.length === 1) return !0;
629
- if (t.querySelector("parsererror")) throw new Error("We are unable to parse node");
630
- return !1;
631
- } catch {
632
- return !1;
633
- }
634
- };
635
- let ho = class {
636
- constructor(e) {
637
- if (e?.nativeClipboard === void 0 || e?.nativeClipboard === !0) try {
638
- this._nativeClipboard = globalThis?.navigator.clipboard;
639
- } catch {
640
- e?.nativeClipboard === !0 && console.warn("NativeClipboard option set to true but no native clipboard available.");
641
- }
642
- else this._nativeClipboard = e?.nativeClipboard === !1 ? null : e?.nativeClipboard;
643
- this._disableCheckOnFocus = e?.disableCheckOnFocus ?? !1, this._init();
644
- }
645
- async _checkForChanges() {
646
- this._nativeClipboard && this._state && !this._disableCheckOnFocus && await Oo("clipboard-read", async () => {
647
- await Po();
648
- const e = await Ho(this._nativeClipboard, Tn);
649
- if (!this._state || e && e === this._state.uuid) return !0;
650
- const t = await br(this._nativeClipboard, Ft);
651
- return !this._state || (_r(this._state.uuid, t) || this.clear(), !0);
652
- }, async (e) => {
653
- e?.message === "denied" || e.message?.includes("Document is not focused") || Un() === jt.Safari || console.warn("Unable to detect clipboard changes: ", e);
654
- });
655
- }
656
- _init() {
657
- const e = this;
658
- this._listeners = /* @__PURE__ */ new Map(), this._listenersCapture = /* @__PURE__ */ new Map(), this._state = null, this._nativeClipboard && (this._onFocus = () => {
659
- e._checkForChanges();
660
- }, this._onBlur = () => {
661
- globalThis.addEventListener?.("focus", e._onFocus, { once: !0 });
662
- }, globalThis.addEventListener?.("blur", this._onBlur), this._nativeClipboard.addEventListener("clipboardchange", (t) => {
663
- e._checkForChanges();
664
- }));
665
- }
666
- async read() {
667
- if (!this._nativeClipboard) return this._state?.items ?? null;
668
- const e = this;
669
- return await Oo("clipboard-read", async () => {
670
- if (await Po(), this._state?.uuid) {
671
- const t = await Ho(this._nativeClipboard, Tn);
672
- if (t && t === e._state.uuid) return !0;
673
- const n = await br(this._nativeClipboard, Ft);
674
- if (_r(e._state?.uuid, n)) return !0;
675
- }
676
- return e._state = { items: await ii(this._nativeClipboard), uuid: null, ref: null }, this.dispatchEvent(new Event("clipboardread")), !0;
677
- }, async (t) => {
678
- this.dispatchEvent(new Event("clipboarderrorread"));
679
- }), this._state?.items ?? [];
680
- }
681
- async write(e) {
682
- return this._write({ uuid: so(), items: e, ref: null });
683
- }
684
- async _write(e) {
685
- if (!this._nativeClipboard) return this._state = e, this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")), null;
686
- const t = this, n = [], o = e.uuid;
687
- let r = e.items ?? [];
688
- const i = () => {
689
- t._state = { uuid: o, ref: e.ref, items: n }, t.dispatchEvent(new Event("clipboardwrite")), t.dispatchEvent(new Event("clipboardchange"));
690
- };
691
- await Oo("clipboard-write", async () => {
692
- await Po(), o && r.length === 0 && (r.push(new ClipboardItem({ [Tn]: new Blob([o], { type: Tn }) })), r.push(new ClipboardItem({ [Ft]: new Blob([Sr(o)], { type: Ft }) })));
693
- for (let l = 0; l < Math.min(1, r.length); l++) {
694
- const s = r[l];
695
- let a = s.types.indexOf(Ft), d = null;
696
- if (a !== -1) {
697
- const u = await s.getType(Ft);
698
- d = await Wo(u), d && (d = el(o, d));
699
- }
700
- if (!d && s.types.includes(fn)) {
701
- const u = await s.getType(fn);
702
- if (u) {
703
- let x = null;
704
- typeof u == "string" ? (console.warn("text as string", u), x = u) : x = await Wo(u), x && (d = `<div ${Kn}="${o}">${x}</div>`);
705
- }
706
- }
707
- if (!d && s.types.includes(Mo)) {
708
- const u = await s.getType(Mo), x = ti(await u.arrayBuffer());
709
- d = `<div ${Kn}="${o}"><img src="${ni + x}"/></div>`;
710
- }
711
- !d && o && (d = Sr(o));
712
- const g = new Blob([d ?? ""], { type: Ft }), m = {};
713
- for (let u = 0; u < s.types.length; u++) {
714
- const x = s.types[u];
715
- m[x] = u === a ? g : s.getType(x);
716
- }
717
- d && a === -1 && (m[Ft] = g), o && (m[Tn] = new Blob([o], { type: Tn })), n.push(new ClipboardItem(m));
718
- }
719
- try {
720
- n && n.length !== 0 ? await this._nativeClipboard.write(n) : await (async (l) => {
721
- l && await l.writeText("");
722
- })(this._nativeClipboard);
723
- } catch (l) {
724
- l.message?.includes("Document is not focused") || console.warn("Unable to write to native clipboard: ", l);
725
- }
726
- return i(), !0;
727
- }, async (l) => {
728
- this.dispatchEvent(new Event("clipboarderrorwrite")), i();
729
- });
730
- }
731
- async writeReference(e) {
732
- if (!e) return void this.clear();
733
- let t = null;
734
- const n = {};
735
- try {
736
- const r = await e.toText?.() ?? null;
737
- r && (n[fn] = new Blob([r ?? ""], { type: fn }));
738
- } catch (r) {
739
- t = r;
740
- }
741
- try {
742
- const r = await e.toHtml?.() ?? null;
743
- r && (n[Ft] = new Blob([r], { type: Ft }));
744
- } catch (r) {
745
- t = r, console.warn("export to html", r);
746
- }
747
- try {
748
- const r = await e.toImage?.() ?? null;
749
- r && (n[Mo] = r);
750
- } catch (r) {
751
- t = r, console.warn("export to png", r);
752
- }
753
- const o = this._write({ uuid: so(), ref: e, items: Object.keys(n).length > 0 ? [new ClipboardItem(n)] : null });
754
- if (t) throw t;
755
- return o;
756
- }
757
- clear(e = !1) {
758
- this._state && (this._state = null, e && this._write({ uuid: null, ref: null, items: null }), this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")));
759
- }
760
- async readReference() {
761
- return await this.read(), this._state?.ref ?? null;
762
- }
763
- readText() {
764
- return new Promise(async (e, t) => {
765
- const n = await this.read();
766
- let o = null;
767
- for (let i = 0; !o && n && i < n.length; i++) n[i].types.includes(fn) && (o = await n[i].getType(fn));
768
- if (!o) return void e("");
769
- const r = new FileReader();
770
- r.onload = () => {
771
- e(r.result);
772
- }, r.readAsText(o), r.onerror = (i) => {
773
- t(i);
774
- };
775
- });
776
- }
777
- async writeText(e) {
778
- const t = [new ClipboardItem({ [fn]: new Blob([e], { type: fn }) })];
779
- return this._write({ uuid: so(), items: t, ref: null });
780
- }
781
- addEventListener(e, t, n = {}) {
782
- const o = n?.capture ? this._listenersCapture : this._listeners;
783
- let r = o.get(e);
784
- r || (r = /* @__PURE__ */ new Map(), o.set(e, r)), r.set(t, typeof n == "boolean" ? {} : n);
785
- }
786
- dispatchEvent(e) {
787
- if (!e) return;
788
- const t = (n) => {
789
- const o = n.get(e.type);
790
- o && o.forEach((r, i) => {
791
- try {
792
- typeof i == "function" ? i(e) : i.handleEvent && i.handleEvent(e), r.once && o.delete(i);
793
- } catch (l) {
794
- console.warn(l);
795
- }
796
- });
797
- };
798
- return t(this._listenersCapture), t(this._listeners), !0;
799
- }
800
- removeEventListener(e, t, n) {
801
- const o = n?.capture ? this._listenersCapture : this._listeners, r = o.get(e);
802
- r && (r.delete(t), r.size === 0 && o.delete(e));
803
- }
804
- close() {
805
- globalThis.removeEventListener?.("focus", this._onFocus), globalThis.removeEventListener?.("blur", this._onBlur);
806
- }
807
- };
808
- var Lo;
809
- (Lo = ho || (ho = {})).ErrorMessages = ri, Lo.Global = new Lo(), function() {
810
- try {
811
- if (typeof document < "u") {
812
- var e = document.createElement("style");
813
- e.appendChild(document.createTextNode("._sheetxl-scrollbar_eblx4_6 ::-webkit-scrollbar-button{background:transparent}._fullscreen-portal-root_1mjsr_4{pointer-events:none;position:absolute;inset:0;width:100%;height:100%;z-index:1200}._fullscreen-portal-root_1mjsr_4>*{pointer-events:auto}")), document.head.appendChild(e);
814
- }
815
- } catch (t) {
816
- console.error("vite-plugin-css-injected-by-js", t);
817
- }
818
- }();
819
- const Wn = { Left: "left", Right: "right", Center: "center" }, It = "shift", vn = "alt", zt = "ctrl", li = 9, si = 13, tl = 27, ci = 37, ai = 38, di = 39, ui = 40, nl = 113, Er = 3, mn = { Horizontal: "horizontal", Vertical: "vertical" };
820
- function hi(e) {
821
- var t, n, o = "";
822
- if (typeof e == "string" || typeof e == "number") o += e;
823
- else if (typeof e == "object") if (Array.isArray(e)) {
824
- var r = e.length;
825
- for (t = 0; t < r; t++) e[t] && (n = hi(e[t])) && (o && (o += " "), o += n);
826
- } else for (n in e) e[n] && (o && (o += " "), o += n);
827
- return o;
828
- }
829
- function Rn() {
830
- for (var e, t, n = 0, o = "", r = arguments.length; n < r; n++) (e = arguments[n]) && (t = hi(e)) && (o && (o += " "), o += t);
831
- return o;
832
- }
833
- var ol = function() {
834
- }, fi = typeof window < "u", rl = fi ? tn : st, Ir = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
835
- const In = fi && window.ResizeObserver !== void 0 ? function() {
836
- var e = Ze(null), t = e[0], n = e[1], o = Ze(Ir), r = o[0], i = o[1], l = Ee(function() {
837
- return new window.ResizeObserver(function(s) {
838
- if (s[0]) {
839
- var a = s[0].contentRect, d = a.x, g = a.y, m = a.width, u = a.height, x = a.top, M = a.left, E = a.bottom, P = a.right;
840
- i({ x: d, y: g, width: m, height: u, top: x, left: M, bottom: E, right: P });
841
- }
842
- });
843
- }, []);
844
- return rl(function() {
845
- if (t) return l.observe(t), function() {
846
- l.disconnect();
847
- };
848
- }, [t]), [n, r];
849
- } : function() {
850
- return [ol, Ir];
851
- }, R = (e, t) => {
852
- const n = D((...i) => e?.(...i), t), o = G(null);
853
- o.current = n;
854
- const r = D((...i) => o.current?.(...i), []);
855
- if (o.current) return r;
856
- }, il = (e) => {
857
- const { style: t, orientation: n = mn.Vertical, ...o } = e, r = n === mn.Vertical;
858
- return q("div", { style: { paddingBottom: "0px", paddingRight: "0px", paddingLeft: r ? "0px" : "3px", paddingTop: r ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...t }, ...o, children: q("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${r ? "vertical" : "horizontal"} single-button start`, children: q("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: q("path", { d: r ? "m 3.7274761,0.68060577 1.11969,1.93863003 1.12075,1.93912 c 0.0895,0.155 0.12152,0.33658 0.0904,0.51283 -0.0311,0.17625 -0.12336,0.33591 -0.26054,0.45091 -0.13715,0.11495 -0.31044,0.17793 -0.4894,0.17781 H 0.83095614 c -0.20186,0 -0.39542,-0.0802 -0.53814,-0.2229 -0.14272,-0.14272 -0.22291,-0.33629 -0.22291,-0.53814 -3e-4,-0.13308 0.0347,-0.26385 0.10147,-0.379 l 1.11872996,-1.94066 1.11921,-1.93864003 c 0.13594,-0.23541 0.38717,-0.38047 0.65905,-0.38047 0.27188,0 0.52311,0.14506 0.65905,0.38047 z" : "m 0.75051,2.3424298 1.93863,-1.11969 1.93912,-1.12075 c 0.155,-0.0895 0.33658,-0.12152 0.51283,-0.0904 0.17625,0.0311 0.33591,0.12336 0.45091,0.26054 0.11495,0.13715 0.17793,0.31044 0.17781,0.4894 v 4.47742 c 0,0.20186 -0.0802,0.39542 -0.2229,0.53814 -0.14272,0.14272 -0.33629,0.22291 -0.53814,0.22291 -0.13308,3e-4 -0.26385,-0.0347 -0.379,-0.10147 L 2.68911,4.7797998 0.75047,3.6605898 C 0.51506,3.5246498 0.37,3.2734198 0.37,3.0015398 c 0,-0.27188 0.14506,-0.52311 0.38047,-0.65905 z" }) }) }) });
859
- }, ll = (e) => {
860
- const { style: t, orientation: n = mn.Vertical, ...o } = e, r = n === mn.Vertical;
861
- return q("div", { style: { paddingLeft: "0px", paddingTop: "0px", paddingRight: r ? "0px" : "3px", paddingBottom: r ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...t }, ...o, children: q("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${r ? "vertical" : "horizontal"} single-button end`, children: q("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: q("path", { d: r ? "M 2.412334,5.319396 1.292644,3.3807659 0.17189405,1.4416459 c -0.0895,-0.155 -0.12152,-0.33658 -0.0904,-0.51282998 0.0311,-0.17625 0.12336,-0.33591 0.26054,-0.45091 0.13715,-0.11495 0.31044,-0.17793 0.4894,-0.17781 H 5.308854 c 0.20186,0 0.39542,0.0802 0.53814,0.2229 0.14272,0.14272 0.22291,0.33629 0.22291,0.53813998 3e-4,0.13308 -0.0347,0.26385 -0.10147,0.379 l -1.11873,1.94066 -1.11921,1.9386401 c -0.13594,0.23541 -0.38717,0.38047 -0.65905,0.38047 -0.27188,0 -0.52311,-0.14506 -0.65905,-0.38047 z" : "m 5.3893002,3.6575719 -1.9386301,1.11969 -1.93912,1.12075 c -0.155,0.0895 -0.33658,0.12152 -0.51282997,0.0904 -0.17625,-0.0311 -0.33591,-0.12336 -0.45091,-0.26054 -0.11495,-0.13715 -0.17793,-0.31044 -0.17781,-0.4894 V 0.76105195 c 0,-0.20186 0.0802,-0.39542 0.2229,-0.53814 C 0.73562013,0.08019195 0.92919013,1.9467784e-6 1.1310401,1.9467784e-6 1.2641201,-2.9805322e-4 1.3948901,0.03470195 1.5100401,0.10147195 l 1.94066,1.11872995 1.9386401,1.11921 c 0.23541,0.13594 0.38047,0.38717 0.38047,0.65905 0,0.27188 -0.14506,0.52311 -0.38047,0.65905 z" }) }) }) });
862
- }, No = (e, t, n, o, r = 0) => {
863
- for (let i = 0; i < n.length; i++) {
864
- const l = n[i].getBoundingClientRect();
865
- let s = l.left - t, a = s + l.width;
866
- if (o) {
867
- if (s < e && a >= e) return s;
868
- } else if (Math.ceil(a) > Math.ceil(e) + 2) return a;
869
- }
870
- return r;
871
- };
872
- Object.freeze(Object.defineProperty({ __proto__: null, getScrollTo: No }, Symbol.toStringTag, { value: "Module" }));
873
- const er = At(Ut((e, t) => {
874
- const { offset: n = 0, totalSize: o = 0, viewportSize: r = 0, style: i, className: l, orientation: s = mn.Vertical, onScrollOffset: a, onScroll: d, showCustomScrollButtons: g = !1, scrollButtonIncrement: m = 200, scrollButtonInitialRepeatDelay: u = 260, scrollButtonAdditionalRepeatDelay: x = 120, createScrollStartButton: M = il, createScrollEndButton: E = ll, ...P } = e, Q = R(d, [d]), k = G(null), [I, { width: z, height: se }] = In(), [B, { width: re, height: be }] = In(), N = s === mn.Vertical, H = N ? "top" : "left", X = N ? "scrollTop" : "scrollLeft", T = N ? se : z, S = N ? be : re, [f, J] = Ze(null);
875
- st(() => {
876
- f !== null && k.current && k.current.scrollTo({ behavior: "smooth", [H]: f });
877
- }, [f, N]);
878
- const K = D((Ye, $ = !1) => {
879
- if (!k.current) return 0;
880
- const _ = k.current.querySelector(".scrollbar-viewport"), Me = _.getBoundingClientRect(), ue = _.children, me = $ ? 0 : No(Ye, Me[H], ue, !0, Math.max(0, Ye - m));
881
- return J(me), Math.max(0, me);
882
- }, []), L = D((Ye, $ = !1) => {
883
- if (!k.current) return 0;
884
- const _ = k.current.querySelector(".scrollbar-viewport"), Me = _.getBoundingClientRect(), ue = _.children, me = Math.ceil(S - T), $e = $ ? me : No(Ye, Me[H], ue, !1, Math.max(0, Ye + m));
885
- return J($e), Math.min(me, $e);
886
- }, [S, T]), U = G(null), te = D((Ye) => {
887
- U.current = n;
888
- const $ = Ye.target[X];
889
- a($, r, o), Q?.(Ye);
890
- }, [a, r, o, n]);
891
- st(() => {
892
- const Ye = U.current;
893
- U.current = null, n !== Ye && (k.current[X] = n);
894
- }, [n, X]);
895
- const ne = G(null), Y = G(null), He = D(() => {
896
- ne.current && (clearTimeout(ne.current), ne.current = null, Y.current = null);
897
- }, []), Ve = D((Ye, $, _, Me = u) => {
898
- Y.current = Ye, ne.current = setTimeout(() => {
899
- const ue = _ ? K(Y.current || Ye) : L(Y.current || Ye);
900
- ue !== Y.current ? Ve(ue, !1, _, x) : He();
901
- }, $ ? 0 : Me);
902
- }, [K, L, He]);
903
- st(() => () => He(), [He]);
904
- const Ne = n, at = Ee(() => {
905
- if (!g) return null;
906
- const Ye = { orientation: s, disabled: Math.floor(Ne) <= 0 || Math.floor(S - T) === 0, onMouseUp: He, onMouseLeave: He, onMouseDown: () => Ve(Ne, !0, !0) };
907
- return M?.(Ye);
908
- }, [g, s, Ne, f, S, T]), Se = Ee(() => {
909
- if (!g) return null;
910
- const Ye = { orientation: s, disabled: Math.floor(S - T) <= Math.ceil(Ne), onMouseUp: He, onMouseLeave: He, onMouseDown: () => Ve(Ne, !0, !1) };
911
- return E?.(Ye);
912
- }, [g, s, Ne, f, S, T]);
913
- return Ht("div", { ref: t, style: { display: "flex", flex: "1", flexDirection: N ? "column" : "row", padding: "0", ...i }, className: Rn("_sheetxl-scrollbar_eblx4_6", l), ...P, children: [at, q("div", { className: "pseudo-scrollbar", style: { flex: "1 1 100%", display: "flex", boxSizing: "content-box", flexDirection: N ? "column" : "row", justifyContent: "center", alignItems: "center" }, ref: I, children: q("div", { tabIndex: -1, style: { flex: "1 1 100%", overflowY: N ? "scroll" : "hidden", overflowX: N ? "hidden" : "scroll", position: "relative", willChange: "transform" }, onScroll: te, ref: k, children: q("div", { ref: B, style: { position: "absolute", height: N ? o - r + (se ?? 0) : 1, width: N ? 1 : o - r + (z ?? 0) }, className: "scrollbar-viewport" }) }) }), Se] });
914
- }));
915
- er.displayName = "Scrollbar";
916
- let Cr = Date.now, gn = {}, sl = 1;
917
- const jn = (e) => {
918
- let t = gn[e] !== null;
919
- return t && (gn[e] = null), t;
920
- }, Mr = (e, t, n, o = 0, r) => {
921
- let i = Cr(), l = i, s = 0, a = 0, d = 0, g = sl++;
922
- if (g % 20 == 0) {
923
- const u = {};
924
- for (let x in gn) u[x] = !0;
925
- gn = u;
926
- }
927
- const m = function(u) {
928
- let x = u !== !0, M = Cr(), E = !0;
929
- try {
930
- E = (!t || t(g)) ?? !0;
931
- } catch {
932
- E = !1;
933
- }
934
- if (!gn[g] || !E) return gn[g] = null, void n?.(60 - a / ((M - i) / 1e3), g, !1);
935
- if (x) {
936
- d = Math.round((M - l) / 16.666666666666668) - 1;
937
- for (let k = 0; k < Math.min(d, 4); k++) m(!0), a++;
938
- }
939
- o && (s = (M - i) / o, s > 1 && (s = 1));
940
- let P = r ? r(s) : s, Q = !1;
941
- try {
942
- Q = e(P, M, x);
943
- } catch {
944
- Q = !1;
945
- }
946
- Q !== !1 && s !== 1 || !x ? x && (l = M, requestAnimationFrame(m)) : (gn[g] = null, n?.(60 - a / ((M - i) / 1e3), g, s === 1 || o == null));
947
- };
948
- return gn[g] = !0, requestAnimationFrame(m), g;
949
- }, cl = function(e) {
950
- return Math.pow(e - 1, 3) + 1;
951
- }, al = function(e) {
952
- return (e /= 0.5) < 1 ? 0.5 * Math.pow(e, 3) : 0.5 * (Math.pow(e - 2, 3) + 2);
953
- };
954
- class dl {
955
- constructor(t, n) {
956
- this.__isSingleTouch = !1, this.__isTracking = !1, this.__didDecelerationComplete = !1, this.__isGesturing = !1, this.__isDragging = !1, this.__isDecelerating = 0, this.__isAnimating = 0, this.__interruptedAnimation = !1, this.__lastScale = 1, this.__enableScrollX = !0, this.__enableScrollY = !0, this.__clientLeft = 0, this.__clientTop = 0, this.__clientWidth = 0, this.__clientHeight = 0, this.__contentWidth = 0, this.__contentHeight = 0, this.__snapWidth = 100, this.__snapHeight = 100, this.__zoomLevel = 1, this.__scrollLeft = 0, this.__scrollTop = 0, this.__maxScrollLeft = 0, this.__maxScrollTop = 0, this.__scheduledLeft = 0, this.__scheduledTop = 0, this.__scheduledZoom = 0, this.__lastTouchLeft = 0, this.__lastTouchTop = 0, this.__lastTouchMove = 0, this.__positions = [], this.__initialTouchLeft = 0, this.__initialTouchTop = 0, this.__zoomLevelStart = 1, this.__minDecelerationScrollLeft = null, this.__minDecelerationScrollTop = null, this.__maxDecelerationScrollLeft = null, this.__maxDecelerationScrollTop = null, this.__decelerationVelocityX = null, this.__decelerationVelocityY = 0, this.__callback = t, this.options = { scrollingX: !0, scrollingY: !0, animating: !0, animationDuration: 250, bouncing: !0, locking: !0, paging: !1, snapping: !1, zooming: !1, minZoom: 0.5, maxZoom: 3, speedMultiplier: 1, scrollingComplete: void 0, penetrationDeceleration: 0.03, penetrationAcceleration: 0.08, ...n };
957
- }
958
- setDimensions(t, n, o, r) {
959
- t !== null && (this.__clientWidth = t), n !== null && (this.__clientHeight = n), o !== null && (this.__contentWidth = o), r !== null && (this.__contentHeight = r), this.__computeScrollMax(), this.scrollTo(this.__scrollLeft, this.__scrollTop, !0);
960
- }
961
- setPosition(t, n) {
962
- this.__clientLeft = t || 0, this.__clientTop = n || 0;
963
- }
964
- setSnapSize(t, n) {
965
- this.__snapWidth = t, this.__snapHeight = n;
966
- }
967
- getValues() {
968
- return { left: this.__scrollLeft, top: this.__scrollTop, right: this.__scrollLeft + this.__clientWidth / this.__zoomLevel, bottom: this.__scrollTop + this.__clientHeight / this.__zoomLevel, zoom: this.__zoomLevel };
969
- }
970
- getPoint(t, n) {
971
- const o = this.getValues();
972
- return { left: t / o.zoom, top: n / o.zoom };
973
- }
974
- getScrollMax() {
975
- return { left: this.__maxScrollLeft, top: this.__maxScrollTop };
976
- }
977
- zoomTo(t, n = !1, o, r, i) {
978
- if (!this.options.zooming) throw new Error("Zooming is not enabled!");
979
- i && (this.__zoomComplete = i), this.__isDecelerating && (jn(this.__isDecelerating), this.__isDecelerating = 0);
980
- const l = this.__zoomLevel;
981
- o === void 0 && (o = this.__clientWidth / 2), r === void 0 && (r = this.__clientHeight / 2), t = Math.max(Math.min(t, this.options.maxZoom), this.options.minZoom), this.__computeScrollMax(t);
982
- const s = t / l;
983
- let a = s * (this.__scrollLeft + o) - o, d = s * (this.__scrollTop + r) - r;
984
- a > this.__maxScrollLeft ? a = this.__maxScrollLeft : a < 0 && (a = 0), d > this.__maxScrollTop ? d = this.__maxScrollTop : d < 0 && (d = 0), this.__publish(a, d, t, n);
985
- }
986
- zoomBy(t, n = !1, o = 0, r = 0, i) {
987
- this.zoomTo(this.__zoomLevel * t, n, o, r, i);
988
- }
989
- scrollTo(t, n, o = !1, r = 1) {
990
- if (this.__isDecelerating && (jn(this.__isDecelerating), this.__isDecelerating = 0), r !== void 0 && r !== this.__zoomLevel) {
991
- if (!this.options.zooming) throw new Error("Zooming is not enabled!");
992
- t *= r, n *= r, this.__computeScrollMax(r);
993
- } else r = this.__zoomLevel;
994
- this.options.scrollingX ? this.options.paging ? t = Math.round(t / this.__clientWidth) * this.__clientWidth : this.options.snapping && (t = Math.round(t / this.__snapWidth) * this.__snapWidth) : t = this.__scrollLeft, this.options.scrollingY ? this.options.paging ? n = Math.round(n / this.__clientHeight) * this.__clientHeight : this.options.snapping && (n = Math.round(n / this.__snapHeight) * this.__snapHeight) : n = this.__scrollTop, t = Math.max(Math.min(this.__maxScrollLeft, t), 0), n = Math.max(Math.min(this.__maxScrollTop, n), 0), t === this.__scrollLeft && n === this.__scrollTop && (o = !1), this.__publish(t, n, r, o);
995
- }
996
- scrollBy(t = 0, n = 0, o = !1) {
997
- const r = this.__isAnimating ? this.__scheduledLeft : this.__scrollLeft, i = this.__isAnimating ? this.__scheduledTop : this.__scrollTop;
998
- this.scrollTo(r + (t || 0), i + (n || 0), o);
999
- }
1000
- doMouseZoom(t, n, o, r) {
1001
- const i = t > 0 ? 0.97 : 1.03;
1002
- return this.zoomTo(this.__zoomLevel * i, !1, o - this.__clientLeft, r - this.__clientTop);
1003
- }
1004
- doTouchStart(t, n) {
1005
- if (t.length === void 0) throw new Error("Invalid touch list: " + t);
1006
- if (n instanceof Date && (n = n.valueOf()), typeof n != "number") throw new Error("Invalid timestamp value: " + n);
1007
- let o, r;
1008
- this.__interruptedAnimation = !0, this.__isDecelerating && (jn(this.__isDecelerating), this.__isDecelerating = 0, this.__interruptedAnimation = !0), this.__isAnimating && (jn(this.__isAnimating), this.__isAnimating = 0, this.__interruptedAnimation = !0);
1009
- let i = t.length === 1;
1010
- i ? (o = t[0].pageX, r = t[0].pageY) : (o = Math.abs(t[0].pageX + t[1].pageX) / 2, r = Math.abs(t[0].pageY + t[1].pageY) / 2), this.__initialTouchLeft = o, this.__initialTouchTop = r, this.__zoomLevelStart = this.__zoomLevel, this.__lastTouchLeft = o, this.__lastTouchTop = r, this.__lastTouchMove = n, this.__lastScale = 1, this.__enableScrollX = !i && this.options.scrollingX, this.__enableScrollY = !i && this.options.scrollingY, this.__isTracking = !0, this.__didDecelerationComplete = !1, this.__isDragging = !i, this.__isSingleTouch = i, this.__positions = [];
1011
- }
1012
- doTouchMove(t, n, o = 1) {
1013
- if (t.length === void 0) throw new Error("Invalid touch list: " + t);
1014
- if (n instanceof Date && (n = n.valueOf()), typeof n != "number") throw new Error("Invalid timestamp value: " + n);
1015
- if (!this.__isTracking) return;
1016
- let r, i;
1017
- t.length === 2 ? (r = Math.abs(t[0].pageX + t[1].pageX) / 2, i = Math.abs(t[0].pageY + t[1].pageY) / 2) : (r = t[0].pageX, i = t[0].pageY);
1018
- let l = this.__positions;
1019
- if (this.__isDragging) {
1020
- let s = r - this.__lastTouchLeft, a = i - this.__lastTouchTop, d = this.__scrollLeft, g = this.__scrollTop, m = this.__zoomLevel;
1021
- if (o !== void 0 && this.options.zooming) {
1022
- let u = m;
1023
- if (m = m / this.__lastScale * o, m = Math.max(Math.min(m, this.options.maxZoom), this.options.minZoom), u !== m) {
1024
- let x = r - this.__clientLeft, M = i - this.__clientTop;
1025
- d = (x + d) * m / u - x, g = (M + g) * m / u - M, this.__computeScrollMax(m);
1026
- }
1027
- }
1028
- if (this.__enableScrollX) {
1029
- d -= s * this.options.speedMultiplier;
1030
- let u = this.__maxScrollLeft;
1031
- (d > u || d < 0) && (this.options.bouncing ? d += s / 2 * this.options.speedMultiplier : d = d > u ? u : 0);
1032
- }
1033
- if (this.__enableScrollY) {
1034
- g -= a * this.options.speedMultiplier;
1035
- const u = this.__maxScrollTop;
1036
- (g > u || g < 0) && (this.options.bouncing ? g += a / 2 * this.options.speedMultiplier : g = g > u ? u : 0);
1037
- }
1038
- l.length > 60 && l.splice(0, 30), l.push(d, g, n), this.__publish(d, g, m);
1039
- } else {
1040
- let s = this.options.locking ? 3 : 0, a = 5, d = Math.abs(r - this.__initialTouchLeft), g = Math.abs(i - this.__initialTouchTop);
1041
- this.__enableScrollX = this.options.scrollingX && d >= s, this.__enableScrollY = this.options.scrollingY && g >= s, l.push(this.__scrollLeft, this.__scrollTop, n), this.__isDragging = (this.__enableScrollX || this.__enableScrollY) && (d >= a || g >= a), this.__isDragging && (this.__interruptedAnimation = !1);
1042
- }
1043
- this.__lastTouchLeft = r, this.__lastTouchTop = i, this.__lastTouchMove = n, this.__lastScale = o;
1044
- }
1045
- doTouchEnd(t) {
1046
- if (t instanceof Date && (t = t.valueOf()), typeof t != "number") throw new Error("Invalid timestamp value: " + t);
1047
- if (this.__isTracking) {
1048
- if (this.__isTracking = !1, this.__isDragging) if (this.__isDragging = !1, this.__isSingleTouch && this.options.animating && t - this.__lastTouchMove <= 100) {
1049
- let n = this.__positions, o = n.length - 1, r = o;
1050
- for (let i = o; i > 0 && n[i] > this.__lastTouchMove - 100; i -= 3) r = i;
1051
- if (r !== o) {
1052
- const i = n[o] - n[r], l = this.__scrollLeft - n[r - 2], s = this.__scrollTop - n[r - 1];
1053
- this.__decelerationVelocityX = l / i * (1e3 / 60), this.__decelerationVelocityY = s / i * (1e3 / 60);
1054
- const a = this.options.paging || this.options.snapping ? 4 : 1;
1055
- (Math.abs(this.__decelerationVelocityX) > a || Math.abs(this.__decelerationVelocityY) > a) && this.__startDeceleration(t);
1056
- } else this.options.scrollingComplete?.();
1057
- } else t - this.__lastTouchMove > 100 && this.options.scrollingComplete?.();
1058
- this.__isDecelerating || ((this.__interruptedAnimation || this.__isDragging) && this.options.scrollingComplete?.(), this.scrollTo(this.__scrollLeft, this.__scrollTop, !0, this.__zoomLevel)), this.__positions.length = 0;
1059
- }
1060
- }
1061
- __publish(t, n, o, r = !1) {
1062
- const i = this.__isAnimating;
1063
- if (i && (jn(i), this.__isAnimating = 0), r && this.options.animating) {
1064
- this.__scheduledLeft = t, this.__scheduledTop = n, this.__scheduledZoom = o;
1065
- const l = this.__scrollLeft, s = this.__scrollTop, a = this.__zoomLevel, d = t - l, g = n - s, m = o - a, u = function(E, P, Q) {
1066
- Q && (this.__scrollLeft = l + d * E, this.__scrollTop = s + g * E, this.__zoomLevel = a + m * E, this.__callback && this.__callback(this.__scrollLeft, this.__scrollTop, this.__zoomLevel));
1067
- }.bind(this), x = function(E) {
1068
- return this.__isAnimating === E;
1069
- }.bind(this), M = function(E, P, Q) {
1070
- P === this.__isAnimating && (this.__isAnimating = !1), (this.__didDecelerationComplete || Q) && this.options.scrollingComplete?.(), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
1071
- }.bind(this);
1072
- this.__isAnimating = Mr(u, x, M, this.options.animationDuration, i ? cl : al);
1073
- } else this.__scheduledLeft = this.__scrollLeft = t, this.__scheduledTop = this.__scrollTop = n, this.__scheduledZoom = this.__zoomLevel = o, this.__callback && this.__callback(t, n, o), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
1074
- }
1075
- __computeScrollMax(t = this.__zoomLevel) {
1076
- this.__maxScrollLeft = Math.max(this.__contentWidth * t - this.__clientWidth, 0), this.__maxScrollTop = Math.max(this.__contentHeight * t - this.__clientHeight, 0);
1077
- }
1078
- __startDeceleration(t) {
1079
- if (this.options.paging) {
1080
- const l = Math.max(Math.min(this.__scrollLeft, this.__maxScrollLeft), 0), s = Math.max(Math.min(this.__scrollTop, this.__maxScrollTop), 0), a = this.__clientWidth, d = this.__clientHeight;
1081
- this.__minDecelerationScrollLeft = Math.floor(l / a) * a, this.__minDecelerationScrollTop = Math.floor(s / d) * d, this.__maxDecelerationScrollLeft = Math.ceil(l / a) * a, this.__maxDecelerationScrollTop = Math.ceil(s / d) * d;
1082
- } else this.__minDecelerationScrollLeft = 0, this.__minDecelerationScrollTop = 0, this.__maxDecelerationScrollLeft = this.__maxScrollLeft, this.__maxDecelerationScrollTop = this.__maxScrollTop;
1083
- const n = function(l, s, a) {
1084
- this.__stepThroughDeceleration(a);
1085
- }.bind(this), o = this.options.snapping ? 4 : 0.1, r = function() {
1086
- const l = Math.abs(this.__decelerationVelocityX) >= o || Math.abs(this.__decelerationVelocityY) >= o;
1087
- return l || (this.__didDecelerationComplete = !0), l;
1088
- }.bind(this), i = function(l, s, a) {
1089
- this.__isDecelerating = 0, this.__didDecelerationComplete && this.options.scrollingComplete?.(), this.scrollTo(this.__scrollLeft, this.__scrollTop, this.options.snapping);
1090
- }.bind(this);
1091
- this.__isDecelerating = Mr(n, r, i);
1092
- }
1093
- __stepThroughDeceleration(t) {
1094
- let n = this.__scrollLeft + this.__decelerationVelocityX, o = this.__scrollTop + this.__decelerationVelocityY;
1095
- if (!this.options.bouncing) {
1096
- const r = Math.max(Math.min(this.__maxDecelerationScrollLeft, n), this.__minDecelerationScrollLeft);
1097
- r !== n && (n = r, this.__decelerationVelocityX = 0);
1098
- const i = Math.max(Math.min(this.__maxDecelerationScrollTop, o), this.__minDecelerationScrollTop);
1099
- i !== o && (o = i, this.__decelerationVelocityY = 0);
1100
- }
1101
- if (t ? this.__publish(n, o, this.__zoomLevel) : (this.__scrollLeft = n, this.__scrollTop = o), !this.options.paging && (this.__decelerationVelocityX *= 0.95, this.__decelerationVelocityY *= 0.95), this.options.bouncing) {
1102
- let r = 0, i = 0, l = this.options.penetrationDeceleration, s = this.options.penetrationAcceleration;
1103
- n < this.__minDecelerationScrollLeft ? r = this.__minDecelerationScrollLeft - n : n > this.__maxDecelerationScrollLeft && (r = this.__maxDecelerationScrollLeft - n), o < this.__minDecelerationScrollTop ? i = this.__minDecelerationScrollTop - o : o > this.__maxDecelerationScrollTop && (i = this.__maxDecelerationScrollTop - o), r !== 0 && (r * this.__decelerationVelocityX <= 0 ? this.__decelerationVelocityX += r * l : this.__decelerationVelocityX = r * s), i !== 0 && (i * this.__decelerationVelocityY <= 0 ? this.__decelerationVelocityY += i * l : this.__decelerationVelocityY = i * s);
1104
- }
1105
- }
1106
- }
1107
- var Gt = typeof window < "u" ? window : { screen: {}, navigator: {} }, Ln = (Gt.matchMedia || function() {
1108
- return { matches: !1 };
1109
- }).bind(Gt), pi = !1, ul = { get passive() {
1110
- return pi = !0;
1111
- } }, Tr = function() {
1112
- };
1113
- Gt.addEventListener && Gt.addEventListener("p", Tr, ul), Gt.removeEventListener && Gt.removeEventListener("p", Tr, !1);
1114
- var hl = pi, fl = "PointerEvent" in Gt, tr = "ontouchstart" in Gt, gi = tr || "TouchEvent" in Gt && Ln("(any-pointer: coarse)").matches, Rr = (Gt.navigator.maxTouchPoints || 0) > 0 || gi, wi = Gt.navigator.userAgent || "", pl = Ln("(pointer: coarse)").matches && /iPad|Macintosh/.test(wi) && Math.min(Gt.screen.width || 0, Gt.screen.height || 0) >= 768, mi = (Ln("(pointer: coarse)").matches || !Ln("(pointer: fine)").matches && tr) && !/Windows.*Firefox/.test(wi), gl = Ln("(any-pointer: fine)").matches || Ln("(any-hover: hover)").matches || pl || !tr, Uo = !Rr || !gl && mi ? Rr ? "touchOnly" : "mouseOnly" : "hybrid", wl = Uo === "mouseOnly" ? "mouse" : Uo === "touchOnly" || mi ? "touch" : "mouse";
1115
- const ml = Object.freeze(Object.defineProperty({ __proto__: null, deviceType: Uo, primaryInput: wl, supportsPassiveEvents: hl, supportsPointerEvents: fl, supportsTouchEvents: gi }, Symbol.toStringTag, { value: "Module" })), xl = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]), xi = {};
1116
- function Ko() {
1117
- return ml;
1118
- }
1119
- const we = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProperties: xi, boundPixel: function(e, t = !1, n = 0) {
1120
- return e;
1121
- }, createSyntheticEvent: (e) => {
1122
- let t = !1, n = !1;
1123
- return { nativeEvent: e, currentTarget: e.currentTarget, target: e.target, bubbles: e.bubbles, cancelable: e.cancelable, defaultPrevented: e.defaultPrevented, eventPhase: e.eventPhase, isTrusted: e.isTrusted, preventDefault: () => {
1124
- t = !0, e.preventDefault();
1125
- }, isDefaultPrevented: () => t, stopPropagation: () => {
1126
- n = !0, e.stopPropagation();
1127
- }, isPropagationStopped: () => n, persist: () => {
1128
- }, timeStamp: e.timeStamp, type: e.type };
1129
- }, detectIt: Ko, focusableNodeNames: xl, toPrettyKeyCode: (e) => e === "BracketLeft" ? "[" : e === "BracketRight" ? "]" : Ct.camelToPrettyCase(e) }, Symbol.toStringTag, { value: "Module" })), yl = [];
1130
- function wo(e, t, n = yl) {
1131
- const o = G(null);
1132
- return Ur(e, () => {
1133
- if (!o.current) return;
1134
- const r = o.current, i = t?.();
1135
- if (!i || typeof i != "object") throw new Error("attributes must return a plain object of values");
1136
- const l = Object.keys(i), s = l.length;
1137
- for (let a = 0; a < s; a++) {
1138
- const d = l[a], g = i[d];
1139
- Object.defineProperty(r, d, { value: g, writable: !0, configurable: !0, enumerable: !0 });
1140
- }
1141
- return r;
1142
- }, n), o;
1143
- }
1144
- const kr = (e) => q(er, { ...e }), vl = ({ width: e, height: t }) => q("div", { className: "corner", style: { minWidth: `${e}px`, width: `${e}px`, minHeight: `${t}px`, height: `${t}px` } }), yi = At(Ut((e, t) => {
1145
- const { children: n, viewport: o, onScrollViewport: r, showHorizontalScrollbar: i = !0, showVerticalScrollbar: l = !0, createScrollCorner: s = vl, createHorizontalScrollbar: a = kr, createVerticalScrollbar: d = kr, style: g, touchElement: m, disableTouch: u, ...x } = e, M = R(r, [r]), E = wo(t, () => ({ isScrollPane: () => !0 }), []), P = G(null);
1146
- st(() => {
1147
- P.current && (P.current.__scrollTop === o?.top && P.current.__scrollLeft === o?.left || P.current.__isDecelerating || P.current?.scrollTo(o?.left, o?.top, !1));
1148
- }, [o?.left, o?.top, m]);
1149
- const Q = D((T, S) => {
1150
- M?.({ left: T, top: S });
1151
- }, []), k = D((T) => {
1152
- P.current?.doTouchStart(T.touches, T.timeStamp);
1153
- }, []), I = D((T) => {
1154
- T.preventDefault(), P.current?.doTouchMove(T.touches, T.timeStamp);
1155
- }, []), z = D((T) => {
1156
- P.current?.doTouchEnd(T.timeStamp);
1157
- }, []), se = D(({ containerWidth: T, containerHeight: S, totalWidth: f, totalHeight: J }) => {
1158
- P.current.setDimensions(T, S, f, J);
1159
- }, []);
1160
- st(() => {
1161
- const T = m ?? E.current;
1162
- if (!u && Ko().supportsTouchEvents && T && o) {
1163
- if (!P.current) {
1164
- const S = { scrollingX: !0, scrollingY: !0, decelerationRate: 0.95, penetrationAcceleration: 0.08 };
1165
- P.current = new dl(Q, S);
1166
- }
1167
- Ko().supportsTouchEvents && (T.addEventListener("touchstart", k), T.addEventListener("touchend", z), T.addEventListener("touchmove", I)), se({ containerWidth: o?.width, containerHeight: o?.height, totalWidth: o?.totalWidth, totalHeight: o?.totalHeight });
1168
- }
1169
- return () => {
1170
- T?.removeEventListener("touchstart", k), T?.removeEventListener("touchend", z), T?.removeEventListener("touchmove", I);
1171
- };
1172
- }, [o?.width, o?.height, o?.totalWidth, o?.totalHeight, u, m]);
1173
- const [B, { width: re }] = In(), [be, { height: N }] = In(), H = Ee(() => {
1174
- const T = d({ orientation: mn.Vertical, offset: o?.top, viewportSize: o?.height, totalSize: o?.totalHeight, onScrollOffset: (S) => {
1175
- M?.({ top: S });
1176
- } });
1177
- return q("div", { style: { display: "flex", flex: "0" }, ref: B, children: T });
1178
- }, [d, o?.top, o?.height, o?.totalHeight]), X = Ee(() => {
1179
- const T = a({ orientation: mn.Horizontal, offset: o?.left, viewportSize: o?.width, totalSize: o?.totalWidth, onScrollOffset: (S) => M?.({ left: S }) });
1180
- return Ht("div", { style: { display: "flex", flex: "none", flexDirection: "row", alignItems: "stretch", justifyContent: "center" }, children: [q("div", { style: { display: "flex", flex: "1 1 100%", flexDirection: "column", width: `calc(100% - ${re}px)` }, children: q("div", { ref: be, className: "sizer", children: T }) }), l ? s({ width: re, height: N }) : q(wn, {})] });
1181
- }, [a, o?.left, o?.width, o?.totalWidth, l, s, re, N]);
1182
- return q("div", { style: { position: "relative", display: "flex", minWidth: l ? `${re}px` : void 0, minHeight: i ? `${N}px` : void 0, ...g }, ...x, ref: E, children: Ht("div", { style: { position: "relative", width: "100%", flex: "1 1 100%", display: "flex", flexDirection: "column", boxSizing: "border-box" }, children: [Ht("div", { style: { display: "flex", flex: "1 1 100%", overflow: "hidden" }, children: [q("div", { style: { display: "flex", flex: "1 1 100%", overflow: "hidden" }, children: n }), l ? H : q(wn, {})] }), i ? X : q(wn, {})] }) });
1183
- }));
1184
- yi.displayName = "ScrollPane";
1185
- const bl = () => {
1186
- const e = document.fullscreenElement;
1187
- return e ? e.querySelector(".fullscreen-portal-root") || e : document.body;
1188
- };
1189
- let no = 0;
1190
- function vi() {
1191
- return st(() => {
1192
- function e() {
1193
- const t = document.fullscreenElement;
1194
- if (!t) return;
1195
- let n = t.querySelector(".fullscreen-portal-root");
1196
- n || (n = document.createElement("div"), n.className = "fullscreen-portal-root _fullscreen-portal-root_1mjsr_4", t.appendChild(n));
1197
- }
1198
- return no++, e(), document.addEventListener("fullscreenchange", e), () => {
1199
- document.removeEventListener("fullscreenchange", e), no--, no <= 0 && (document.querySelectorAll(".fullscreen-portal-root").forEach((t) => {
1200
- t.parentNode && t.parentNode.removeChild(t);
1201
- }), no = 0);
1202
- };
1203
- }, []), { getPortalContainer: bl };
1204
- }
1205
- const Sl = 100, _l = 100, El = 1e6, Il = 100, Cl = 50, Ml = At(Ut((e, t) => {
1206
- const { offset: n = 0, viewportSize: o = 0, totalSize: r = 0, minSize: i = 0, endGap: l = Sl, endScrollIncrement: s = _l, style: a = xi, onMouseDown: d, onScrollOffset: g, onScroll: m, scaleLimit: u = El, scaleFactor: x = Il, precisionFactor: M = Cl, ...E } = e;
1207
- m && console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");
1208
- const P = R(d, [d]), Q = () => ({ offset: n, totalSize: u === 0 ? r : Math.min(r ?? 0, Math.max(i ?? 0, (n ?? 0) + (o ?? 0)) + (l ?? 0)) }), [k, I] = Ze(Q), z = u !== 0 && k.totalSize > u ? x : 1, se = z / M, B = Math.ceil(k.totalSize / z), re = Math.ceil(k.offset / z), be = Math.ceil(o / z), N = D((K) => {
1209
- }, []), [H, X] = Ze(!1), T = G(null);
1210
- tn(() => {
1211
- if (!H) {
1212
- T.current = { propTotalSize: r, propViewportSize: o, propOffset: n };
1213
- const K = Q();
1214
- I(K);
1215
- }
1216
- }, [r, o, n, H, i, l, s]);
1217
- const S = R((K, L, U) => {
1218
- const te = T.current;
1219
- T.current = null, te && te.propTotalSize === r && te.propViewportSize === o && te.propOffset === n || (Math.abs(K - re) < se && (K = re), g?.(K * z, re, be));
1220
- }, [g, z, se, re, be]), f = D((K) => {
1221
- document.removeEventListener("mousemove", N), document.removeEventListener("mouseup", f), X(!1);
1222
- }, []), J = D((K) => {
1223
- P?.(K), X(!0), document.addEventListener("mousemove", N, { passive: !0 }), document.addEventListener("mouseup", f, { passive: !0 });
1224
- }, [N, f]);
1225
- return q(er, { ref: t, style: { ...a }, ...E, offset: re, totalSize: B, viewportSize: be, onMouseDown: J, onScrollOffset: S });
1226
- }));
1227
- function Do(e, t) {
1228
- if (typeof e == "function") return e(t);
1229
- e && (e.current = t);
1230
- }
1231
- Ml.displayName = "VirtualScrollbar";
1232
- var fo = parseInt(Kr.split(".")[0], 10) >= 19 ? function(e) {
1233
- return (t) => {
1234
- const n = [];
1235
- for (const o of e) {
1236
- const r = Do(o, t), i = typeof r == "function";
1237
- n.push(i ? r : () => Do(o, null));
1238
- }
1239
- return () => {
1240
- for (const o of n) o();
1241
- };
1242
- };
1243
- } : function(e) {
1244
- return (t) => {
1245
- for (const n of e) Do(n, t);
1246
- };
1247
- };
1248
- At(Ut((e, t) => {
1249
- const { refFocusStart: n, ...o } = e, r = G(null), i = D(() => {
1250
- if (n) return void n?.current?.focus();
1251
- const l = r.current.parentElement.children;
1252
- let s = [];
1253
- for (let a = 0; a < l.length && l[a] !== r.current; a++) {
1254
- const d = l[a].getAttribute("tabindex");
1255
- if (d == null || d === "-1" || l[a].getAttribute("disabled") === "true") continue;
1256
- const g = l[a];
1257
- g.focus && s.push({ tabindex: parseInt(d), child: g });
1258
- }
1259
- s.length !== 0 && (s.sort(function(a, d) {
1260
- return a.tabindex - d.tabindex;
1261
- }), s[0].child.focus());
1262
- }, [n]);
1263
- return q("div", { tabIndex: 0, ref: fo([r, t]), onFocus: i, ...o });
1264
- })), At(Ut((e, t) => {
1265
- const { className: n, style: o, children: r, radius: i = 4, strokeWidth: l = 1, strokeColor: s = "grey", ...a } = e, [d, { width: g, height: m }] = In(), u = G(null), x = (Q, k = 0) => {
1266
- const I = Q / 2, z = m - I + k;
1267
- return function(se, B, re = !1) {
1268
- if (B === 0) return se;
1269
- function be(f, J, K) {
1270
- let L = J.x - f.x, U = J.y - f.y, te = Math.sqrt(L * L + U * U);
1271
- return N(f, J, Math.min(1, K / te));
1272
- }
1273
- function N(f, J, K) {
1274
- return { x: f.x + (J.x - f.x) * K, y: f.y + (J.y - f.y) * K };
1275
- }
1276
- function H(f, J) {
1277
- f.length > 2 && (f[f.length - 2] = J.x, f[f.length - 1] = J.y);
1278
- }
1279
- function X(f) {
1280
- return { x: parseFloat(f[f.length - 2]), y: parseFloat(f[f.length - 1]) };
1281
- }
1282
- let T = se.split(/[,\s]/).reduce(function(f, J) {
1283
- let K = J.match("([a-zA-Z])(.+)");
1284
- return K ? (f.push(K[1]), f.push(K[2])) : f.push(J), f;
1285
- }, []).reduce(function(f, J) {
1286
- return parseFloat(J) == J && f.length ? f[f.length - 1].push(J) : f.push([J]), f;
1287
- }, []), S = [];
1288
- if (T.length > 1) {
1289
- let f = X(T[0]), J = null;
1290
- T[T.length - 1][0] === "Z" && T[0].length > 2 && (J = ["L", f.x, f.y], T[T.length - 1] = J), S.push(T[0]);
1291
- for (let K = 1; K < T.length; K++) {
1292
- let L = S[S.length - 1], U = T[K], te = U === J ? T[1] : T[K + 1];
1293
- if (te && L && L.length > 2 && U[0] === "L" && te.length > 2 && te[0] === "L") {
1294
- let ne, Y, He = X(L), Ve = X(U), Ne = X(te);
1295
- re ? (ne = N(Ve, L.origPoint || He, B), Y = N(Ve, te.origPoint || Ne, B)) : (ne = be(Ve, He, B), Y = be(Ve, Ne, B)), H(U, ne), U.origPoint = Ve, S.push(U);
1296
- let at = N(ne, Ve, 0.5), Se = N(Ve, Y, 0.5), Ye = ["C", at.x, at.y, Se.x, Se.y, Y.x, Y.y];
1297
- Ye.origPoint = Ve, S.push(Ye);
1298
- } else S.push(U);
1299
- }
1300
- if (J) {
1301
- let K = X(S[S.length - 1]);
1302
- S.push(["Z"]), H(S[0], K);
1303
- }
1304
- } else S = T;
1305
- return S.reduce(function(f, J) {
1306
- return f + J.join(" ") + " ";
1307
- }, "");
1308
- }(`M 0 ${I} L ${i - 0.5} ${I} L ${i - 0.5} ${z} L ${2 * i} ${z} L ${g - 2 * i} ${z} M ${g - 2 * i} ${z} L ${g - i} ${z} L ${g - i} ${I} L ${g} ${I}`, i);
1309
- }, M = Ee(() => x(l), [g, m, i, l]), E = Ee(() => {
1310
- if (i === 0) return;
1311
- const Q = i / 2;
1312
- return x(i) + `L ${g} 0 L 0 0 L 0 ${Q}`;
1313
- }, [M, i, l]), P = Ee(() => ({ style: { clipPath: `path('${E}')` } }), [E]);
1314
- return Ht("div", { className: n, style: { display: "flex", flexDirection: "row", ...o }, ...a, ref: fo([u, d, t]), children: [Sn.isValidElement(r) ? Sn.cloneElement(r, P) : q(wn, {}), q("svg", { style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" }, width: g, height: m, viewBox: `0 0 ${g} ${m}`, children: q("path", { d: M, stroke: s, fill: "none", vectorEffect: "non-scaling-stroke", strokeWidth: l }) })] });
1315
- }));
1316
- const Tl = {}, Rl = (e) => {
1317
- const { onPointerDown: t, style: n, splitDirection: o, paddingBefore: r = 0, paddingAfter: i = 0, disabled: l, key: s, hitAreaProps: a = Tl, ...d } = e, g = o === "row", { style: m, className: u, ...x } = a;
1318
- return q("div", { style: { ...n, position: "relative" }, ...d, children: q("div", { className: Rn("hit-box", u), style: { left: (g ? -r : 0) + "px", width: `calc(100% + ${g ? r + i : 0}px)`, top: (g ? 0 : -r) + "px", height: `calc(100% + ${g ? 0 : r + i}px)`, position: "absolute", ...m }, onPointerDown: l ? void 0 : t, ...x }) }, s);
1319
- }, oo = {}, bn = (e, t, n = !0) => e === null ? null : e.pixels !== null ? n ? e.pixels : t - e.pixels : (n ? e.percent : 100 - e.percent) / 100 * t, ro = (e, t = !0) => e?.percent ? `${t ? e.percent : 100 - e.percent}%` : e?.pixels ? `${e.pixels}px` : void 0, pn = (e, t) => {
1320
- if (e == null) return null;
1321
- const n = { percent: null, pixels: null };
1322
- let o = t;
1323
- return typeof e == "string" && ((e = e.trim().toLowerCase()).endsWith("px") ? (e = e.substring(0, e.length - 2), o = !1) : e.endsWith("%") && (e = e.substring(0, e.length - 1), o = !0), e = parseFloat(e)), o ? n.percent = e : n.pixels = e, Object.freeze(n);
1324
- };
1325
- function On(e) {
1326
- if (!e) throw new Error("must have a PointerHandlerOptions");
1327
- const { onPointerDown: t, onPointerUp: n, onPointerMoveOrWait: o, processTouch: r = !1, consumeTouch: i = !0 } = e, l = R(t, [t]), s = R(n, [n]), a = R(o, [o]), d = G(!1), g = e?.timerInitial ?? 230, m = e?.timerContinuous ?? g / 2, u = G(null), x = G(null), M = G(null), E = G(null), P = D(() => {
1328
- E.current && (clearTimeout(E.current), E.current = null);
1329
- }, []), Q = D((H) => {
1330
- E.current = setTimeout(() => {
1331
- window.requestAnimationFrame(() => {
1332
- d.current !== !1 && a?.(x.current, M.current, u.current);
1333
- }), Q(m);
1334
- }, H ?? g);
1335
- }, []);
1336
- st(() => () => P(), []);
1337
- const k = r ? "pointer" : "mouse", I = D((H) => {
1338
- H.stopPropagation(), H.stopImmediatePropagation(), H.preventDefault();
1339
- }, []), z = R((H) => {
1340
- document.removeEventListener(`${k}move`, re), document.removeEventListener(`${k}up`, z), document.removeEventListener("keydown", be), document.removeEventListener("keyup", N), document.removeEventListener("touchstart", I, { capture: !0 }), document.removeEventListener("touchmove", I, { capture: !0 }), window.removeEventListener("blur", se), P(), window.requestAnimationFrame(() => {
1341
- d.current !== !1 && (d.current = !1, s?.(H, M.current, u.current), M.current = null);
1342
- });
1343
- }, []), se = D(() => {
1344
- d.current !== !1 && (d.current = !1, z(x.current));
1345
- }, []), B = R(() => {
1346
- P(), Q(m), window.requestAnimationFrame(() => {
1347
- d.current !== !1 && a?.(x.current, M.current, u.current);
1348
- });
1349
- }, [m]), re = R((H) => {
1350
- x.current = H, B();
1351
- }, []), be = R((H) => {
1352
- M.current = { ctrlKey: H.ctrlKey, shiftKey: H.shiftKey, altKey: H.altKey, metaKey: H.metaKey }, B();
1353
- }, []), N = R((H) => {
1354
- M.current = { ctrlKey: H.ctrlKey, shiftKey: H.shiftKey, altKey: H.altKey, metaKey: H.metaKey }, B();
1355
- }, [m]);
1356
- return R((H) => {
1357
- H.isDefaultPrevented() || (M.current = { ctrlKey: H.ctrlKey, shiftKey: H.shiftKey, altKey: H.altKey, metaKey: H.metaKey }, l(H, M.current) !== !1 && (u.current = H, x.current = H.nativeEvent, document.addEventListener(`${k}up`, z, { passive: !1 }), document.addEventListener(`${k}move`, re, { passive: !1 }), document.addEventListener("keydown", be, { passive: !1 }), document.addEventListener("keyup", N, { passive: !1 }), window.addEventListener("blur", se, { passive: !0 }), r && i && (document.addEventListener("touchstart", I, { passive: !1, capture: !0 }), document.addEventListener("touchmove", I, { passive: !1, capture: !0 })), d.current = !0, Q(g)));
1358
- }, [g, r]);
1359
- }
1360
- At(Ut((e, t) => {
1361
- const { elementBefore: n, elementAfter: o, splitDirection: r = "row", fixedPane: i = null, position: l, onPositionChange: s, minBefore: a, maxBefore: d, minAfter: g, maxAfter: m, children: u, className: x, style: M, disabled: E = !1, onDragStart: P, onDragResize: Q, onDragFinish: k, resizerProps: I = oo, paneProps: z = oo, paneBeforeProps: se = oo, paneAfterProps: B = oo, createResizer: re = Rl } = e;
1362
- if (u) throw new Error("Use elementBefore and elementAfter instead of children.");
1363
- const be = Ee(() => Sn.isValidElement(o) && Sn.isValidElement(n), [o, n]), N = Ee(() => {
1364
- let ee = null;
1365
- i && (i === "before" ? ee = 0 : i === "after" && (ee = 1));
1366
- const et = ee === null;
1367
- return { fixedPaneOffset: ee, isPercent: et, minBefore: pn(a, et), maxBefore: pn(d, et), minAfter: pn(g, et), maxAfter: pn(m, et) };
1368
- }, [a, d, g, m]), H = R(s, [s]), [X, T] = Ze(() => pn(l, i === null));
1369
- st(() => {
1370
- T(pn(l, i === null));
1371
- }, [l, i]);
1372
- const [S, { width: f, height: J }] = In(), [K, { width: L, height: U }] = In(), te = r === "row" ? L : U, ne = r === "row" ? f : J, Y = Ee(() => ((ee, et, Ue, ht) => {
1373
- const Ie = [null, null], Oe = [null, null];
1374
- if (ee || (ee = { percent: ht.fixedPaneOffset === null ? 50 : null, pixels: ht.fixedPaneOffset === null ? null : 0 }), et === 0) return ee?.pixels != null ? ht.fixedPaneOffset !== 1 ? (Ie[0] = ee?.pixels, Oe[1] = 100) : (Ie[1] = ee?.pixels - Ue, Oe[0] = 100) : ee?.percent != null && (ht.fixedPaneOffset !== 1 ? (Oe[0] = ee?.percent, Oe[1] = 100 - ee?.percent) : (Oe[1] = ee?.percent, Oe[0] = 100 - ee?.percent)), { percents: Oe, pixels: Ie, minBefore: ro(ht.minBefore, !0), maxBefore: ro(ht.maxBefore, !0), minAfter: ro(ht.minAfter), maxAfter: ro(ht.maxAfter) };
1375
- let rt = bn(ee, et, ht.fixedPaneOffset !== 1), tt = et - Ue, ze = bn(ht.minBefore, tt, !0) ?? 0, rn = bn(ht.maxBefore, tt, !0) ?? tt, Tt = 0, nt = 0, Rt = 0, Ot = tt;
1376
- Tt = (bn(ht.maxAfter, et, !1) ?? Ue) - Ue, nt = bn(ht.minAfter, et, !1) ?? et, Rt = Math.max(ze, Tt), Ot = Math.min(rn, nt), rt = Math.max(Rt, Math.min(rt, Ot)), nt = Math.min(tt - rt, bn(ht.maxAfter, tt - rt, !0) ?? tt), Tt = Math.min(tt - rt, bn(ht.minAfter, tt - rt, !0) ?? tt), Ie[0] = rt, Ie[1] = tt - Ie[0];
1377
- const hn = Math.max(0, Math.min(100, rt / tt * 100));
1378
- return Oe[0] = hn, Oe[1] = 100 - Oe[0], { percents: Oe, pixels: Ie, minBefore: `${ze}px`, minAfter: `${Tt}px`, maxBefore: `${Ie[0]}px`, maxAfter: `${Ie[1]}px` };
1379
- })(X, ne, te, N), [N, X, ne, te, r]), [He, Ve] = Ze(!1), Ne = R(P, [P]), at = R(Q, [Q]), Se = R(k, [k]), Ye = G(null), $ = G(null), _ = G(null), { style: Me, className: ue, ...me } = z, $e = { minWidth: 0, minHeight: 0, maxWidth: "100%", maxHeight: "100%", display: "flex", overflow: "hidden", ...Me }, { className: dt, style: kt, ...ut } = se, { className: Zt, style: St, ...C } = B, ye = { flex: "1 1 100%", width: "100%", ...M, flexDirection: r, display: "flex" }, { className: Je, style: mt, onPointerDown: Qe, ...cn } = I, on = R((ee) => {
1380
- const et = pn(ee, i === null);
1381
- T(et);
1382
- }, [i]), Mt = R((ee) => {
1383
- if (E || !He) return;
1384
- const et = De.current?.getBoundingClientRect();
1385
- let Ue = 0;
1386
- Ue = r === "row" ? (ee.clientX ?? ee.touches?.[0]?.clientX) - et.x : (ee.clientY ?? ee.touches?.[0]?.clientY) - et.y, Ue = Math.max(0, Math.min(ne, Ue)), N.fixedPaneOffset === 1 && (Ue = ne - Ue), l && X.pixels === Ue || T({ pixels: Ue, percent: null }), at?.(Ue), ee.stopPropagation(), ee.preventDefault();
1387
- }, [N, r, E, He, X, ne]), dn = R((ee) => {
1388
- if (document.removeEventListener("pointermove", Mt), document.removeEventListener("touchmove", Mt), document.removeEventListener("pointerup", dn), He && (Ve(!1), X)) {
1389
- if (Se(X.pixels), !pn(l, i === null) || X.pixels !== l) {
1390
- const et = { ...X };
1391
- et.percent === null && (et.percent = et.pixels / ne * 100), H(et);
1392
- }
1393
- ee.stopPropagation(), ee.preventDefault();
1394
- }
1395
- }, [X, He, l, i, ne]), nn = R((ee) => {
1396
- Qe?.(ee), ee.defaultPrevented || E || He || (Ve(!0), Ne(), document.addEventListener("pointermove", Mt, { passive: !1 }), document.addEventListener("touchmove", Mt, { passive: !1 }), document.addEventListener("pointerup", dn, { passive: !1 }));
1397
- }, [Qe]), De = wo(t, () => ({ setPosition: on, isSplitPane: () => !0 }), []), Kt = Ee(() => be ? re?.({ key: "resizer", ref: fo([K, $]), className: Rn("resizer", Je), onPointerDownCapture: nn, style: { cursor: E ? void 0 : r === "row" ? "ew-resize" : "ns-resize", minWidth: r === "row" ? "2px" : void 0, minHeight: r !== "row" ? "2px" : void 0, boxSizing: "border-box", pointerEvents: "all", zIndex: 1, ...mt }, splitDirection: r, disabled: E, ...cn }) : null, [be, Je, cn, r, mt, E]), xt = r === "row" ? "Width" : "Height", Vt = { ...$e, ...kt, flex: N.fixedPaneOffset === 0 && Y?.pixels[0] !== null ? `0 0 ${Math.round(Y?.pixels[0])}px` : `1 1 ${Math.round(Y?.percents[0] ?? 100)}%`, [`min${xt}`]: Y?.minBefore, [`max${xt}`]: o ? Y?.maxBefore : "100%" }, Cn = { ...$e, ...St, flex: N.fixedPaneOffset === 1 && Y?.pixels[1] !== null ? `0 0 ${Math.round(Y?.pixels[1])}px` : `1 1 ${Math.round(Y?.percents[1] ?? 100)}%`, [`min${xt}`]: Y?.minAfter, [`max${xt}`]: n ? Y?.maxAfter : "100%" }, un = Ee(() => n ? q("div", { ref: Ye, className: Rn("before", ue, dt), style: Vt, ...me, ...ut, children: n }, "before") : null, [n, z, se, N, Y]), We = Ee(() => o ? q("div", { ref: _, className: Rn("after", ue, Zt), style: Cn, ...me, ...C, children: o }, "after") : null, [o, z, B, N, Y]);
1398
- return Ht("div", { ref: fo([S, De]), className: Rn("splitPane", r === "row" ? "vertical" : "horizontal", { dragging: He }, x), style: ye, children: [un, Kt, We] });
1399
- }));
1400
- const kl = ({ initValue: e, useHookBody: t, applyStateChange: n }) => {
1401
- const o = G(e);
1402
- if (typeof t != "function") throw new Error("function expected as hook body parameter. got " + typeof t);
1403
- const r = t();
1404
- return tn(() => {
1405
- o.current !== r && (o.current = r, n(r));
1406
- }, [n, r]), null;
1407
- }, qo = (e) => {
1408
- console && console.warn && console.warn(e);
1409
- }, zo = typeof self == "object" && self.self === self && self || typeof global == "object" && global.global === global && global || void 0;
1410
- let Pl = 1, Yo = !1, bi = !1;
1411
- const co = [], kn = [], po = () => {
1412
- kn.forEach((e) => e());
1413
- }, Ol = ({ automaticContainerInternalUseOnly: e }) => {
1414
- const [t, n] = Ze([]), o = G([]);
1415
- return o.current = t, e || Yo !== !1 || (bi = !0), st(() => {
1416
- let r = !0;
1417
- function i() {
1418
- if (r) return kn[0] !== i ? (e || Yo !== !0 || qo("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."), void n((l) => [])) : void n([...co]);
1419
- }
1420
- return kn.push(i), po(), () => {
1421
- r = !1, o.current?.length > 0 && qo("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"), kn.splice(kn.indexOf(i), 1), po();
1422
- };
1423
- }, [e]), q(wn, { children: t.map(({ hook: r, key: i }) => Jo(kl, { ...r, key: i })) });
1424
- }, Si = (e, t, n = {}) => {
1425
- let o, r, i = !1, l = !1, s = [], { unmountIfNoConsumers: a = !1 } = n;
1426
- const d = (m) => {
1427
- r = m, Bi(() => s.forEach((u) => u(m)));
1428
- }, g = () => (l || (r = typeof e == "function" ? e() : e, l = !0), r);
1429
- return () => {
1430
- const [m, u] = Ze(g);
1431
- return st(() => (i || (i = !0, o = ((x) => {
1432
- const M = Pl++;
1433
- return co.push({ hook: x, key: M }), kn.length === 0 && bi === !1 && (Yo = !0, ((E) => {
1434
- if (zo.document && zo.document.createElement) {
1435
- const P = zo.document.createElement("div");
1436
- $i(P).render(q(E, { automaticContainerInternalUseOnly: !0 }));
1437
- } else qo("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.");
1438
- })(Ol)), po(), () => {
1439
- co.splice(co.findIndex((E) => E.key === M), 1), po();
1440
- };
1441
- })({ initValue: e, useHookBody: t, applyStateChange: d })), s.push(u), r !== m && u(r), () => {
1442
- s.splice(s.indexOf(u), 1), s.length === 0 && a && (o(), i = !1);
1443
- }), []), m;
1444
- };
1445
- };
1446
- Si(null, () => {
1447
- const [e, t] = Ze(null);
1448
- return e;
1449
- });
1450
- class Ll {
1451
- constructor(t, n, o, r) {
1452
- this._listenersProperties = /* @__PURE__ */ new Set(), this._listenersExecute = /* @__PURE__ */ new Set(), this._key = t, this._target = n, this._applyProps(o || {}), this._callback = r, r === void 0 && (this._callback = () => {
1453
- console.log(`implement: ${this.label()} : ${this.description()}`);
1454
- });
1455
- }
1456
- key() {
1457
- return this._key;
1458
- }
1459
- _resolve(t, n) {
1460
- if (typeof t == "function") {
1461
- const o = n ?? this._context;
1462
- return t(typeof o == "function" ? o() : o);
1463
- }
1464
- return t;
1465
- }
1466
- target() {
1467
- return typeof this._target == "function" ? this._target() : this._target;
1468
- }
1469
- label(t, n) {
1470
- const o = this._scopedLabels?.[t] || this._label;
1471
- let r = null;
1472
- if (typeof o == "function") {
1473
- const i = n ?? this._context;
1474
- r = o(typeof i == "function" ? i() : i);
1475
- } else r = o;
1476
- return r;
1477
- }
1478
- description(t) {
1479
- return this._resolve(this._description, t);
1480
- }
1481
- tags(t) {
1482
- return this._resolve(this._tags, t);
1483
- }
1484
- icon(t) {
1485
- return this._resolve(this._icon, t);
1486
- }
1487
- shortcut() {
1488
- return this._resolve(this._shortcut);
1489
- }
1490
- disabled() {
1491
- return this._resolve(this._disabled) || !this._callback;
1492
- }
1493
- state() {
1494
- return this._resolve(this._state);
1495
- }
1496
- context() {
1497
- return typeof this._context == "function" ? this._context() : this._context;
1498
- }
1499
- async execute(t, n) {
1500
- if (!this.disabled() && this._callback) {
1501
- try {
1502
- let o = !0;
1503
- if (n?.beforeExecute && (o = n?.beforeExecute(this, t)), await Promise.resolve(o) === !1) return !1;
1504
- const r = this._callback.bind(this)(t, this);
1505
- if (await Promise.resolve(r) === !1) return !1;
1506
- n?.onExecute?.(this, t), this._notifyExecute(t);
1507
- } catch (o) {
1508
- return console.warn(o), n?.onError(this, o, t), this._notifyError(t, o), !1;
1509
- }
1510
- return !0;
1511
- }
1512
- }
1513
- addPropertyListener(t, n = !1) {
1514
- if (!t) throw new Error("listener must be specified");
1515
- const o = this._listenersProperties;
1516
- return o.add(t), n && t({}, this), () => {
1517
- o.delete(t);
1518
- };
1519
- }
1520
- addExecuteListener(t) {
1521
- if (!t) throw new Error("listener must be specified");
1522
- const n = this._listenersExecute;
1523
- return n.add(t), function() {
1524
- n.delete(t);
1525
- };
1526
- }
1527
- _notifyExecute(t) {
1528
- const n = this;
1529
- this._listenersExecute.forEach((o) => {
1530
- o.onExecute(n, t);
1531
- });
1532
- }
1533
- _notifyError(t, n) {
1534
- const o = this;
1535
- this._listenersExecute.forEach((r) => {
1536
- r.onError?.(o, t, n);
1537
- });
1538
- }
1539
- updateCallback(t) {
1540
- return this._callback = t || null, this;
1541
- }
1542
- update(t) {
1543
- if (!t) return;
1544
- const n = this._applyProps(t);
1545
- return Object.keys(n).length > 0 && this._notifyPropertyChange(n), this;
1546
- }
1547
- _notifyPropertyChange(t) {
1548
- const n = this;
1549
- this._listenersProperties.forEach((o) => {
1550
- o(t, n);
1551
- });
1552
- }
1553
- _applyProps(t) {
1554
- let n = {}, o = this;
1555
- return Object.keys(t).forEach((r) => {
1556
- let i = t[r];
1557
- o["_" + r] !== i && (o["_" + r] = n[r] = i);
1558
- }), n;
1559
- }
1560
- }
1561
- class _e extends Ll {
1562
- }
1563
- Ct.getOS() === Ct.OSType.MacOS || (Ct.getOS(), Ct.OSType.IOS), Ct.getOS() === Ct.OSType.MacOS || (Ct.getOS(), Ct.OSType.IOS), Si({ setClipboard: (e) => {
1564
- throw new Error("This is only available via the useClipboard.");
1565
- }, getClipboard: () => ho.Global, refNativeCopy: { current: null }, refNativeLastKey: { current: null } }, () => {
1566
- const [e, t] = Ze(ho.Global);
1567
- return { setClipboard: (n) => t(n), getClipboard: () => e, refNativeCopy: G(null), refNativeLastKey: G(null) };
1568
- });
1569
- let Ao = !1, Dl = 0;
1570
- var zl = typeof document < "u" ? tn : st;
1571
- const Pr = () => "sheetxl-ui-" + Dl++, Al = Sn.useId ?? function() {
1572
- const [e, t] = Sn.useState(() => Ao ? Pr() : void 0);
1573
- return zl(() => {
1574
- e == null && t(Pr());
1575
- }, []), Sn.useEffect(() => {
1576
- Ao || (Ao = !0);
1577
- }, []), e;
1578
- }, Pn = ({ itemType: e, index: t, itemSize: n, instanceProps: o, scale: r = 1 }) => {
1579
- let i, l, s;
1580
- e === "column" ? (i = o.columnMetadataMap, l = o.lastMeasuredColumnIndex, s = o.recalcColumnIndices) : (i = o.rowMetadataMap, l = o.lastMeasuredRowIndex, s = o.recalcRowIndices);
1581
- const a = s.length > 0;
1582
- if (t > l) {
1583
- let d = 0;
1584
- if (l >= 0) {
1585
- const g = i[l];
1586
- d = g.offset + g.size;
1587
- }
1588
- for (let g = l + 1; g <= t; g++) {
1589
- let m = a ? s.includes(g) ? n(g) * r : i[g]?.size || n(g) * r : n(g) * r;
1590
- i[g] = { offset: d, size: m }, d += m;
1591
- }
1592
- e === "column" ? o.lastMeasuredColumnIndex = t : o.lastMeasuredRowIndex = t;
1593
- }
1594
- return i[t], i[t];
1595
- }, Or = ({ itemType: e, itemSize: t, itemCount: n, instanceProps: o, offset: r, scale: i }) => {
1596
- let l, s;
1597
- e === "column" ? (l = o.columnMetadataMap, s = o.lastMeasuredColumnIndex) : (l = o.rowMetadataMap, s = o.lastMeasuredRowIndex);
1598
- let a = 0;
1599
- return a = (s > 0 ? l[s].offset : 0) >= r ? _i({ itemType: e, itemSize: t, instanceProps: o, high: s, low: 0, offset: r, scale: i }) : $l({ itemType: e, itemSize: t, itemCount: n, instanceProps: o, index: Math.max(0, s), offset: r, scale: i }), a = Math.min(a, n), a;
1600
- }, _i = ({ itemType: e, itemSize: t, instanceProps: n, high: o, low: r, offset: i, scale: l }) => {
1601
- for (; r <= o; ) {
1602
- const s = r + Math.floor((o - r) / 2), a = Pn({ itemType: e, itemSize: t, index: s, instanceProps: n, scale: l }).offset;
1603
- if (a === i) return s;
1604
- a < i ? r = s + 1 : a > i && (o = s - 1);
1605
- }
1606
- return r > 0 ? r - 1 : 0;
1607
- }, $l = ({ itemType: e, itemSize: t, itemCount: n, instanceProps: o, index: r, offset: i, scale: l }) => {
1608
- let s = 1;
1609
- for (; r < n && Pn({ itemType: e, itemSize: t, index: r, instanceProps: o, scale: l }).offset < i; ) r += s, s *= 2;
1610
- return _i({ itemType: e, itemSize: t, instanceProps: o, high: Math.min(r, n - 1), low: Math.floor(r / 2), offset: i, scale: l });
1611
- }, Bl = (e) => {
1612
- const { rowCount: t, columnCount: n, defaultRowHeight: o, getRowHeight: r, defaultColumnWidth: i, getColumnWidth: l } = e || {}, s = G({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), a = R((I) => Or({ itemType: "row", itemCount: t, itemSize: r ?? (() => o ?? 20), instanceProps: s.current, offset: I }), [t, r, o]), d = R((I) => I === -1 ? 0 : Pn({ itemType: "row", index: I, itemSize: r ?? (() => o ?? 20), instanceProps: s.current }).offset, [r, o]), g = R((I) => Pn({ itemType: "row", index: I, itemSize: r ?? (() => o ?? 20), instanceProps: s.current }).size, [r, o]), m = R((I) => Or({ itemType: "column", itemCount: n, itemSize: l ?? (() => i ?? 75), instanceProps: s.current, offset: I }), [n, l, i]), u = R((I) => I === -1 ? 0 : Pn({ itemType: "column", index: I, itemSize: l ?? (() => i ?? 75), instanceProps: s.current }).offset, [l, i]), x = R((I) => Pn({ itemType: "column", index: I, itemSize: l ?? (() => i ?? 75), instanceProps: s.current }).size, [l, i]), [M, E] = Qo((I) => I + 1, 0), P = () => ({ getRowOffset: d, getColOffset: u, getRowIndex: a, getColIndex: m }), [Q, k] = Ze(() => e ? P() : null);
1613
- return st(() => {
1614
- k(e ? P() : null);
1615
- }, [M, t, n, i, o, g, x]), Q;
1616
- }, Ei = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", Lr = (e) => {
1617
- if (!e) return null;
1618
- if (e.eventType === "start") return { type: e.eventType };
1619
- if (e.eventType === "submit") return { type: e.eventType };
1620
- if (e.eventType === "cancel") return { type: e.eventType };
1621
- if (e.eventType === "keyboard") return { type: e.eventType, key: e.event.key };
1622
- if (e.eventType === "pointer") return { type: e.eventType };
1623
- if (e.eventType === "coordsChange") {
1624
- const t = { type: e.eventType };
1625
- return e.activeCoords && (t.activeCoords = e.activeCoords), t;
1626
- }
1627
- return { type: e.eventType ?? "unknown" };
1628
- }, Fl = (e) => !0, jl = (e) => !!e && !(e.ctrlKey || e.metaKey || e.altKey || e.isComposing) && (!(e.shiftKey || e.key !== "F2" && e.key !== " " && e.key !== "Backspace") || (!e.shiftKey || e.key !== " ") && Ei.indexOf(e.key) !== -1), Vl = (e) => !!e && e.type === "dblclick" && { editMode: !0 }, Wl = (e) => {
1629
- const { session: t, refLatestCoords: n, handleSubmitEdit: o, handleCancelEdit: r, cellBounds: i, isInBounds: l, getCellEditor: s, propsEditor: a, borderStrokeFill: d = "rgb(33, 115, 70)", borderStrokeWidth: g = 2, alignment: m = Wn.Left, style: u, ...x } = e, M = G(null), E = G(null), [P, Q] = Ze(!1), k = t.coords, I = D(async (X) => {
1630
- if (M.current?.getBoundingClientRect()) {
1631
- if (X.eventType === "keyboard") {
1632
- const S = X.event, f = new KeyboardEvent(S.type, { bubbles: !0, cancelable: !0, view: window, key: S.key, code: S.code, location: S.location, repeat: S.repeat, isComposing: S.isComposing, charCode: S.charCode, keyCode: S.keyCode, which: S.which, ctrlKey: S.ctrlKey, shiftKey: S.shiftKey, altKey: S.altKey, metaKey: S.metaKey });
1633
- f.isSynthetic = !0, f.key, E.current?.dispatchEvent(f);
1634
- } else X.eventType === "pointer" || console.warn("unsupported event type", X);
1635
- await new Promise((S) => requestAnimationFrame(S));
1636
- }
1637
- }, []);
1638
- st(() => {
1639
- const X = E.current;
1640
- return Q(!0), E.current.startEdit?.(t.startEvent), (async () => {
1641
- t.editorRefs.push(X), t.editorRefsDispatchEditorEvent.push(I);
1642
- const T = [...t.events];
1643
- for (let S = 0; S < T.length; S++) await I(T[S]);
1644
- t.onMount(X);
1645
- })(), () => {
1646
- const T = t.editorRefs.indexOf(X);
1647
- T !== -1 && t.editorRefs.splice(T, 1), t.onUnmount(X);
1648
- };
1649
- }, []);
1650
- const z = D(() => o(t), []), se = D(() => {
1651
- r(t);
1652
- }, []), B = n.current && Z.isEqualCells(n.current, k), re = l && B && P, be = s({ autoFocus: !!t.startEvent?.autoFocus, ...a, onSubmitEdit: z, onCancelEdit: se, ref: E }, k), N = i.x + we.boundPixel(-g / 2), H = we.boundPixel(i.width + g / 2, !0);
1653
- return q("div", { tabIndex: 0, ref: M, style: { background: void 0, ...u, opacity: re ? u?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${i.y + we.boundPixel(-g / 2)}px`, height: we.boundPixel(i.height + g / 2, !0), left: `${N}px`, width: H }, ...x, children: q("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${we.boundPixel(1)}px`, top: `${we.boundPixel(1)}px`, width: we.boundPixel(i.width - 2, !0), height: we.boundPixel(i.height - 2, !0), outline: `${g}px ${d} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: be }) });
1654
- }, ps = (e) => {
1655
- const { view: t, canEdit: n = Fl, getCellEditor: o, onBeforeStartEdit: r, onStartEdit: i, onSubmitEdit: l, onCancelEdit: s, onDoneEdit: a, isEditorStartKeyEvent: d = jl, isEditorStartPointerEvent: g = Vl, containerProps: m, borderStrokeFill: u, borderStrokeWidth: x = 2, getRangeCoords: M = null, activeCoords: E, alignment: P = Wn.Left } = e, [Q, k] = Ze(!1), [I, z] = Ze(void 0), se = R(($, _, Me, ue, me, $e) => {
1656
- if (!_) return null;
1657
- const dt = me?.(_, $), kt = $.getRangeCoordsBounds(dt), ut = $.toClipBounds(kt), Zt = kt, St = $.getZoom();
1658
- if (!ut) return null;
1659
- Me && (Me *= St), ue && (ue *= St);
1660
- let C = Zt, ye = !1;
1661
- if (Me !== void 0) {
1662
- let Qe = { ...dt }, cn = 0;
1663
- for (; !ye && C.width <= Me && cn < 20; ) {
1664
- cn++, cn > 19 && console.warn("max width reached");
1665
- const on = $.getTotalRangeCoords(), Mt = $.getLayout();
1666
- $e === Wn.Left ? Qe.colEnd + 1 < on.colEnd ? Qe.colEnd = Mt.getColIndex(C.x + Me) : ye = !0 : $e === Wn.Right ? Qe.colStart - 1 >= 0 ? Qe.colStart = Mt.getColIndex(C.x - (Me - C.width)) : ye = !0 : $e === Wn.Center && Qe.colEnd + 1 < on.colEnd && Qe.colStart - 1 >= 0 ? (Qe.colStart = Mt.getColIndex(C.x - (Me - C.width) / 2), Qe.colEnd = Mt.getColIndex(C.x + C.width + (Me - C.width) / 2)) : ye = !0, ye || (C = $.getRangeCoordsBounds(Qe));
1667
- }
1668
- }
1669
- C.height = Zt.height, ue !== void 0 && (C.height = Math.max(ue + 1, Zt.height));
1670
- const { width: Je, height: mt } = $.getViewportSize();
1671
- return { x: C.x ?? 0, y: C.y ?? 0, height: Math.min(mt - C.y, C.height) + 1, width: Math.min(Je - C.x, C.width) + 1 };
1672
- }, [P]), B = R(n, [n]), re = D(() => {
1673
- t?.getStage()?.focus();
1674
- }, [t]), be = G(null), N = R(($) => {
1675
- r?.($), ne(), k(!0), be.current = null;
1676
- }, [r]), H = R(($) => {
1677
- i?.($.coords);
1678
- }, [i]), X = R(($) => {
1679
- $.isSubmitted || $.isCancelled || (f.current.isEditorClosed = !0, re(), $.isCancelled = !0, s?.($.coords), ne());
1680
- }, [s]), T = R(($) => {
1681
- if ($.isSubmitted || $.isCancelled) return !1;
1682
- try {
1683
- return be.current = $.coords, $.isEditorClosing = !0, $.isSubmitted = !0, $.isEditorSubmitted || ($.isEditorSubmitted = !0, $.editorRefs[0]?.submitEdit?.()), $.coords, l?.($.coords), $.isEditorClosed = !0, re(), ne(), !0;
1684
- } catch (_) {
1685
- throw $.isEditorClosing = !1, $.isSubmitted = !1, _;
1686
- }
1687
- }, [l]), S = R(($) => {
1688
- k(!1), a?.($.coords), ne();
1689
- }, [a]), f = G(null), J = G(null), K = G(null), L = G([]), [U, te] = Qo(($) => $ + 1, 0), ne = D(($) => {
1690
- $ && L.current.push($), te();
1691
- }, []), Y = R(($) => {
1692
- if ($.defaultPrevented || $.isSynthetic || !t) return;
1693
- const _ = t?.getCellCoordsFromClient($.clientX, $.clientY);
1694
- _ && ne({ eventType: "pointer", event: $, coords: _ });
1695
- }, [t]), He = R(($) => {
1696
- const _ = $.nativeEvent;
1697
- Y(_);
1698
- }, [t]), Ve = R(($) => {
1699
- if ($.defaultPrevented || $.isSynthetic || !t?.getStage()) return;
1700
- const _ = J.current;
1701
- d($, _) && ($.stopPropagation(), $.preventDefault()), $.key, ne({ eventType: "keyboard", event: $, coords: _ });
1702
- }, [t]);
1703
- tn(() => {
1704
- const $ = (ue, me) => {
1705
- const $e = me?.cell ?? ue;
1706
- if (!$e) return null;
1707
- const dt = $e;
1708
- if (!B($e)) return null;
1709
- N?.($e);
1710
- const kt = Ct.uuidV4();
1711
- me = Object.freeze({ autoFocus: !0, ...me }), K.current = $e;
1712
- const ut = { coords: dt, startEvent: me, uuid: kt, isMounted: !1, isStarted: !1, isSubmitted: !1, isEditorSubmitted: !1, isEditorClosing: !1, isEditorClosed: !1, isCancelled: !1, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (Zt) => {
1713
- ut.isMounted || (ut.isMounted = !0, ne());
1714
- }, onUnmount: (Zt) => {
1715
- if (ut.editorRefs.length === 0) {
1716
- const St = () => {
1717
- ut.isMounted = !1, ne();
1718
- };
1719
- if (document.activeElement !== document.body) St();
1720
- else {
1721
- const C = (ye) => {
1722
- ye.defaultPrevented || ye.target !== document.body || Ve(ye);
1723
- };
1724
- window.addEventListener("keydown", C, !0), t.getStage()?.addEventListener("focusin", () => {
1725
- window.removeEventListener("keydown", C), St();
1726
- }, { once: !0 }), re();
1727
- }
1728
- }
1729
- } };
1730
- return ut;
1731
- };
1732
- if (L.current.length <= 0 && !f.current) return;
1733
- const _ = L.current[0];
1734
- Lr(_), ((ue) => {
1735
- const me = [], $e = ue?.length ?? 0;
1736
- for (let dt = 0; dt < $e; dt++) {
1737
- const kt = ue[dt];
1738
- me.push(Lr(kt));
1739
- }
1740
- })(L.current), f.current, f.current;
1741
- let Me = f.current;
1742
- if (f.current) {
1743
- if (f.current.isDone) f.current = null;
1744
- else if (f.current.isSubmitted || f.current.isCancelled) {
1745
- if (f.current.isMounted) return;
1746
- f.current.isDone || (S(f.current), f.current.isDone = !0);
1747
- }
1748
- }
1749
- if (_) {
1750
- if (_.eventType === "start") {
1751
- const ue = _, me = ue.startEvent?.cell ?? J.current;
1752
- f.current && Z.isEqualCells(f.current.coords, me) || (f.current = $(me, ue.startEvent));
1753
- } else if (_.eventType === "keyboard") {
1754
- const ue = _.event;
1755
- if (f.current) {
1756
- let me = !1;
1757
- switch (ue.which) {
1758
- case ci:
1759
- case di:
1760
- case ai:
1761
- case ui:
1762
- case si:
1763
- case li:
1764
- me = !0;
1765
- }
1766
- if (!me) {
1767
- f.current.events.push(_);
1768
- for (let $e = 0; $e < f.current.editorRefsDispatchEditorEvent.length; $e++) f.current.editorRefsDispatchEditorEvent[$e](_);
1769
- }
1770
- } else if (d(ue, _.coords)) {
1771
- let me;
1772
- const $e = $(me?.cell ?? J.current, me);
1773
- $e && $e.events.push(_), f.current = $e;
1774
- }
1775
- } else if (_.eventType === "pointer") {
1776
- const ue = _.event;
1777
- if (f.current) {
1778
- f.current.events.push(_);
1779
- for (let me = 0; me < f.current.editorRefsDispatchEditorEvent.length; me++) f.current.editorRefsDispatchEditorEvent[me](_);
1780
- } else {
1781
- const me = _?.coords ?? J.current, $e = g(ue, me);
1782
- if ($e) {
1783
- let dt;
1784
- typeof dt != "boolean" && (dt = $e);
1785
- const kt = $(me, dt);
1786
- kt && kt.events.push(_), f.current = kt;
1787
- }
1788
- }
1789
- } else if (_.eventType === "submit") {
1790
- if (f.current && !f.current.isSubmitted && !f.current.isCancelled) {
1791
- if (!f.current.isMounted) return;
1792
- T(f.current);
1793
- }
1794
- } else if (_.eventType === "cancel") {
1795
- if (f.current && !f.current.isSubmitted && !f.current.isCancelled) {
1796
- if (!f.current.isMounted) return;
1797
- X(f.current);
1798
- }
1799
- } else if (_.eventType === "coordsChange") {
1800
- const ue = _;
1801
- if (J.current = ue.activeCoords, f.current, f.current && !f.current.isSubmitted && !f.current.isCancelled) {
1802
- if (!f.current.isMounted) return;
1803
- try {
1804
- T(f.current);
1805
- } catch {
1806
- }
1807
- }
1808
- }
1809
- }
1810
- L.current.length > 0 && (L.current.shift(), ne()), L.current.length === 0 && (!f.current || f.current.isEditorClosing || f.current.isEditorClosed ? !f.current && Me && re() : f.current.isMounted && !f.current.isStarted && (f.current.isStarted = !0, f.current.startEvent.autoFocus && (typeof f.current.startEvent.autoFocus == "string" ? f.current.editorRefs[0]?.autoFocus(f.current.startEvent.autoFocus) : f.current.editorRefs[0]?.autoFocus()), H?.(f.current), requestAnimationFrame(() => {
1811
- t && f.current?.coords && t.scrollCellCoordsIntoView(f.current.coords);
1812
- })));
1813
- }, [U]), st(() => {
1814
- K.current = E;
1815
- const $ = f.current?.coords;
1816
- Z.isEqualCells($, E) || (f.current && (f.current.isEditorClosing = !0), ne({ eventType: "coordsChange", activeCoords: E }));
1817
- }, [E]);
1818
- const Ne = D(($) => {
1819
- Ve($.nativeEvent);
1820
- }, []), { width: at = 0, height: Se = 0 } = I ?? { width: 0, height: 0 }, Ye = R(o, [o]);
1821
- return { overlay: R(($) => {
1822
- if (!f.current || f.current.isEditorClosed) return f.current, null;
1823
- f.current.coords;
1824
- let _ = se($, f.current.coords, at, Se, M, P), Me = !0;
1825
- _ && _.width !== 0 && _.height !== 0 || (_ = { x: 0, y: 0, width: at, height: at }, Me = !1);
1826
- const ue = $.getZoom(), me = { containerBounds: { x: 0, y: 0, width: _.width / ue, height: _.height / ue }, setNaturalDimensions: z, zoom: ue };
1827
- return q(Wl, { session: f.current, refLatestCoords: K, handleSubmitEdit: T, handleCancelEdit: X, cellBounds: _, borderStrokeWidth: x, borderStrokeFill: u, isInBounds: Me, getCellEditor: Ye, propsEditor: me, alignment: P, ...m }, "editor:" + f.current.uuid);
1828
- }, [o, M, U, at, Se, P, x, u]), startEdit: D(($) => {
1829
- ne({ eventType: "start", startEvent: $ });
1830
- }, []), submitEdit: D(() => {
1831
- ne({ eventType: "submit" });
1832
- }, []), cancelEdit: D(() => {
1833
- ne({ eventType: "cancel" });
1834
- }, []), onKeyboardEvent: Ne, onPointerEvent: He, onKeyboardEventNative: Ve, onPointerEventNative: Y, isEditing: Q };
1835
- }, gs = ({ gridRef: e, gridMainRef: t, orientation: n = an, headerCount: o, selectionPolicy: r = "multiple", newSelectionMode: i = "clear", alwaysScrollToActiveCoords: l = !0, onDragStart: s, onDragEnd: a, pointerDownInterceptor: d, pointerMoveInterceptor: g, onPointerUp: m, newSelection: u, modifySelection: x, appendSelection: M, clearSelections: E }) => {
1836
- const P = o ?? ((n === an ? e.current?.rowCount : e.current?.columnCount) || 0), Q = G(null), k = G(null), I = G(!1), z = G(null), se = D((S) => n === Nt ? { rowIndex: 0, colIndex: S.colIndex } : { rowIndex: S.rowIndex, colIndex: 0 }, [n]), B = D((S) => n === Nt ? { rowIndex: t.current ? t.current.rowCount - 1 : 0, colIndex: S.colIndex } : { rowIndex: S.rowIndex, colIndex: t.current ? t.current.columnCount - 1 : 0 }, [n]), re = (S) => {
1837
- k.current = B(S), x(k.current, Q.current);
1838
- }, be = D((S, f) => {
1839
- if (!e.current) return;
1840
- const J = e.current.getViewFromClient(S, f)?.getCellCoordsFromClient(S, f);
1841
- return J ? (n === Nt ? J.rowIndex = t.current.getViewport().rowStart : J.colIndex = t.current.getViewport().colStart, J) : void 0;
1842
- }, []), N = D((S, f = !1) => {
1843
- let J = S;
1844
- return f || (J = { ...S }, n === an ? delete J.colIndex : delete J.rowIndex), t.current?.scrollCellCoordsIntoView(J);
1845
- }, [n]), H = R(a, [a]), X = R(s, [s]), T = Ee(() => ({ onPointerDown: (S) => {
1846
- if (!e || !e.current || S.nativeEvent.defaultPrevented) return;
1847
- const f = be(S.nativeEvent.clientX, S.nativeEvent.clientY);
1848
- if (!f) return;
1849
- S.nativeEvent.which;
1850
- const J = S.nativeEvent.shiftKey, K = S.nativeEvent.ctrlKey || S.nativeEvent.metaKey;
1851
- if (d?.(S, f) === !1) return;
1852
- X?.(), I.current = !0;
1853
- const L = t.current?.getViewFromClient(S.nativeEvent.clientX, S.nativeEvent.clientY), U = ((te, ne) => n === Nt ? { ...te, rowIndex: ne.rowStart } : { ...te, colIndex: ne.colStart })(f, L.getVisibleRangeCoords());
1854
- if (J) re(f);
1855
- else {
1856
- if (K) return ((te, ne = te, Y) => {
1857
- Q.current = se(te), k.current = B(ne), M(Q.current, k.current, Y);
1858
- })(f, f, U), void (l && N(U, !0));
1859
- ((te, ne = te, Y) => {
1860
- Q.current = se(te), k.current = B(ne), u(Q.current, k.current, Y);
1861
- })(f, f, U), re(f), l && N(U, !0);
1862
- }
1863
- }, onPointerMoveOrWait: Ct.throttle((S) => {
1864
- if (!I.current || !e?.current) return;
1865
- const f = be(S.clientX, S.clientY);
1866
- if (f && g?.(S, f) !== !1) {
1867
- if (Z.isEqualCells(z.current, f)) return E();
1868
- re(f), N(f);
1869
- }
1870
- }, 60), onPointerUp: (S) => {
1871
- I.current = !1, H?.(), m?.(S);
1872
- }, processTouch: !0, consumeTouch: !0 }), [r, l, P, i, E, d, m]);
1873
- return { onPointerDown: R(On(T), []), getCellCoordsFromClient: be };
1874
- }, qe = (e, t, n) => {
1875
- if (!e) return t;
1876
- let o = t;
1877
- const r = n === Ke || n === lt;
1878
- for (; ; ) {
1879
- const i = e(o, !r);
1880
- if (i === 0) return o;
1881
- r ? o += i : o -= i;
1882
- }
1883
- }, io = (e, t, n) => {
1884
- const o = [];
1885
- let r = t;
1886
- for (; r <= n; ) {
1887
- const i = Math.max(0, e(r));
1888
- i === 0 ? (o.push(r), r++) : r += i;
1889
- }
1890
- return o;
1891
- }, Hl = (e, t, n, o, r, i) => {
1892
- if (!t) return i;
1893
- let { rowIndex: l, colIndex: s } = e;
1894
- switch (o) {
1895
- case lt: {
1896
- l = qe(n, Math.min(l + 1, i), o);
1897
- let a = t({ rowIndex: l, colIndex: s });
1898
- for (; !a && l < i; ) l = qe(n, Math.min(++l, i), o), a = t({ rowIndex: l, colIndex: s });
1899
- return l;
1900
- }
1901
- case it: {
1902
- l = qe(n, Math.max(l - 1, i), o);
1903
- let a = t({ rowIndex: l, colIndex: s });
1904
- for (; !a && l > i; ) l = qe(n, Math.max(--l, i), o), a = t({ rowIndex: l, colIndex: s });
1905
- return l;
1906
- }
1907
- case Ke: {
1908
- s = qe(n, Math.min(s + 1, i), o);
1909
- let a = t({ rowIndex: l, colIndex: s });
1910
- for (; !a && s < i; ) s = qe(n, Math.min(++s, i), o), a = t({ rowIndex: l, colIndex: s });
1911
- return s;
1912
- }
1913
- case ot: {
1914
- s = qe(n, Math.max(s - 1, i), o);
1915
- let a = t({ rowIndex: l, colIndex: s });
1916
- for (; !a && s > i; ) s = qe(n, Math.max(--s, i), o), a = t({ rowIndex: l, colIndex: s });
1917
- return s;
1918
- }
1919
- default:
1920
- return i;
1921
- }
1922
- }, Nl = (e, t = () => !0, n, o, r, i) => {
1923
- let { rowIndex: l, colIndex: s } = e;
1924
- switch (o) {
1925
- case lt: {
1926
- l = qe(n, Math.min(l + 1, i), o);
1927
- let a = t?.({ rowIndex: l, colIndex: s });
1928
- for (; a && l < i; ) l = qe(n, Math.min(++l, i), o), a = t?.({ rowIndex: l, colIndex: s });
1929
- return t?.({ rowIndex: l, colIndex: s }) ? l : l - 1;
1930
- }
1931
- case it: {
1932
- l = qe(n, Math.max(l - 1, i), o);
1933
- let a = t?.({ rowIndex: l, colIndex: s });
1934
- for (; a && l > i; ) l = qe(n, Math.max(--l, i), o), a = t?.({ rowIndex: l, colIndex: s });
1935
- return t?.({ rowIndex: l, colIndex: s }) ? l : l + 1;
1936
- }
1937
- case Ke: {
1938
- s = qe(n, Math.min(s + 1, i), o);
1939
- let a = t?.({ rowIndex: l, colIndex: s });
1940
- for (; a && s < i; ) s = qe(n, Math.min(++s, i), o), a = t?.({ rowIndex: l, colIndex: s });
1941
- return t?.({ rowIndex: l, colIndex: s }) ? s : s - 1;
1942
- }
1943
- case ot: {
1944
- s = qe(n, Math.max(s - 1, i), o);
1945
- let a = t?.({ rowIndex: l, colIndex: s });
1946
- for (; a && s > i; ) s = qe(n, Math.max(--s, i), o), a = t?.({ rowIndex: l, colIndex: s });
1947
- return t?.({ rowIndex: l, colIndex: s }) ? s : s + 1;
1948
- }
1949
- default:
1950
- return null;
1951
- }
1952
- }, Ul = (e, t, n, o, r, i) => {
1953
- if (!t) return i;
1954
- let l, { rowIndex: s, colIndex: a } = e;
1955
- o === lt ? l = { rowIndex: s + 1, colIndex: a } : o === it ? l = { rowIndex: s - 1, colIndex: a } : o === Ke ? l = { rowIndex: s, colIndex: a + 1 } : o === ot && (l = { rowIndex: s, colIndex: a - 1 });
1956
- const d = t(e), g = t(l);
1957
- var m, u;
1958
- return (u = g, !(m = d) && !u || !m && u || m && !u ? Hl : Nl)(e, t, n, o, !1, i) ?? i;
1959
- }, Dr = (e, t) => `${e}:${t}`, zr = (e, t, n, o, r, i) => {
1960
- if (n - t >= r - o) return o;
1961
- let l = o;
1962
- return e === "nearest" && (o - t > 0 ? e = "start" : n - r > 0 && (e = "end")), e === "start" ? l = t : e === "end" ? l = n - (r - o) : e === "center" && (l = t + (n - t) / 2 - (r - o) / 2), Math.max(0, Math.min(l, i - (r - o)));
1963
- }, Ar = (e, t, n, o) => (console.log("todo: implement convertToVisibleRanges"), e), Xo = (e, t = Ke, n, o, r, i = null) => {
1964
- if (i && Z.isEqualSelectionCoords(i, e)) return e;
1965
- const l = e.ranges[e.rangeIndex];
1966
- if (!Z.isRangesIntersect({ rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, l)) return e;
1967
- let s = { ...e.cell }, a = e.rangeIndex;
1968
- switch (t) {
1969
- case Ke:
1970
- s.colIndex = qe(r, s.colIndex + 1, t);
1971
- break;
1972
- case ot:
1973
- s.colIndex = qe(r, s.colIndex - 1, t);
1974
- break;
1975
- case lt:
1976
- s.rowIndex = qe(o, s.rowIndex + 1, t);
1977
- break;
1978
- case it:
1979
- s.rowIndex = qe(o, s.rowIndex - 1, t);
1980
- }
1981
- const d = (u) => {
1982
- if (u) {
1983
- a = e.rangeIndex >= e.ranges.length - 1 ? 0 : e.rangeIndex + 1;
1984
- const x = e.ranges[a];
1985
- s = { colIndex: x.colStart, rowIndex: x.rowStart };
1986
- } else {
1987
- a = e.rangeIndex <= 0 ? e.ranges.length - 1 : e.rangeIndex - 1;
1988
- const x = e.ranges[a];
1989
- s = { colIndex: x.colEnd, rowIndex: x.rowEnd };
1990
- }
1991
- };
1992
- if (t === Ke && s.colIndex > l.colEnd && s.rowIndex === l.rowEnd) d(!0);
1993
- else if (t === ot && s.colIndex < l.colStart && s.rowIndex === l.rowStart) d(!1);
1994
- else if (t === lt && s.colIndex === l.colEnd && s.rowIndex > l.rowEnd) d(!0);
1995
- else if (t === it && s.colIndex === l.colStart && s.rowIndex < l.rowStart) d(!1);
1996
- else {
1997
- let u = s.rowIndex, x = s.colIndex;
1998
- switch (t) {
1999
- case Ke:
2000
- x > l.colEnd && (u = qe(o, u + 1, t), x = l.colStart, u > l.rowEnd && (u = l.rowStart));
2001
- break;
2002
- case ot:
2003
- x < l.colStart && (u = qe(o, u - 1, t), x = l.colEnd, u < l.rowStart && (u = l.rowEnd));
2004
- break;
2005
- case lt:
2006
- u > l.rowEnd && (x = qe(r, x + 1, t), u = l.rowStart, x > l.colEnd && (x = l.colStart));
2007
- break;
2008
- case it:
2009
- u < l.rowStart && (x = qe(r, x - 1, t), u = l.rowEnd, x < l.colStart && (x = l.colEnd));
2010
- }
2011
- s = { rowIndex: u, colIndex: x };
2012
- }
2013
- let g = n(s);
2014
- if (!Z.isRangeWithinRange(g, l)) {
2015
- const u = Z.intersectRanges(g, l);
2016
- u && (g = u);
2017
- }
2018
- let m = { rowStart: qe(o, g.rowStart, lt), colStart: qe(r, g.colStart, Ke), rowEnd: qe(o, g.rowEnd, it), colEnd: qe(r, g.colEnd, ot) };
2019
- if (m.rowStart !== s.rowIndex || m.colStart !== s.colIndex) {
2020
- switch (t) {
2021
- case Ke:
2022
- e.ranges[a].colStart === m.colStart && e.ranges[a].colEnd === m.colEnd && (s.rowIndex = m.rowEnd), s.colIndex = m.colEnd;
2023
- break;
2024
- case ot:
2025
- e.ranges[a].colStart === m.colStart && e.ranges[a].colEnd === m.colEnd && (s.rowIndex = m.rowStart), s.rowIndex === m.rowStart ? s.colIndex = m.colStart + 1 : s.colIndex = m.colStart;
2026
- break;
2027
- case lt:
2028
- e.ranges[a].rowStart === m.rowStart && e.ranges[a].rowEnd === m.rowEnd && (s.colIndex = m.colEnd), s.rowIndex = m.rowEnd;
2029
- break;
2030
- case it:
2031
- e.ranges[a].rowStart === m.rowStart && e.ranges[a].rowEnd === m.rowEnd && (s.colIndex = m.colStart), s.colIndex === m.colStart ? s.rowIndex = m.rowStart + 1 : s.rowIndex = m.rowStart;
2032
- }
2033
- return Xo({ cell: s, ranges: e.ranges, rangeIndex: a }, t, n, o, r, i ?? e);
2034
- }
2035
- return { ranges: e.ranges, cell: s, rangeIndex: a };
2036
- }, $r = (e, t) => {
2037
- let n, o = 0, r = 0;
2038
- return t.colStart < e.colStart ? (n = ot, o = e.colStart - t.colStart, r = t.colStart) : t.colEnd > e.colEnd ? (n = Ke, o = t.colEnd - e.colEnd, r = t.colEnd) : t.rowStart < e.rowStart ? (n = it, o = e.rowStart - t.rowStart, r = t.rowStart) : t.rowEnd > e.rowEnd && (n = lt, o = t.rowEnd - e.rowEnd, r = t.rowEnd), { direction: n, amount: o, index: r };
2039
- }, go = (e, t = !1, n, o) => {
2040
- if (!n) return 0;
2041
- const r = !t, i = r ? 1 : -1;
2042
- let l = n(r ? e : e + 1), s = n(r ? e + 1 : e), a = e + (r ? 2 : -1), d = 0;
2043
- for (; (s - l) * i <= 0; ) {
2044
- if (r && a - 1 > o + 1 || !r && a + 1 < o) return d;
2045
- l = s, s = n(a), a += i, d++;
2046
- }
2047
- return d;
2048
- }, Br = (e, t, n, o, r) => {
2049
- const i = {};
2050
- let l = null, s = null;
2051
- for (let a = 0; a <= n.length && n[a] <= r; a++) {
2052
- const d = n[a];
2053
- if (d < o) continue;
2054
- const g = l === d ? s : t ? e.getColOffset(d) : e.getRowOffset(d), m = t ? e.getColOffset(d + 1) : e.getRowOffset(d + 1);
2055
- l = d + 1, s = m, i[d] = Object.freeze({ offset: g, size: m - g, spanIndex: a });
2056
- }
2057
- return Object.freeze(i);
2058
- }, Fr = (e, t, n) => {
2059
- const o = e.getColOffset(t.colStart) + (n?.left ?? 0), r = e.getRowOffset(t.rowStart) + (n?.top ?? 0);
2060
- return { x: o, y: r, width: e.getColOffset(t.colEnd + 1) + (n?.right ?? 0) - (n?.left ?? 0) - o, height: e.getRowOffset(t.rowEnd + 1) + (n?.bottom ?? 0) - (n?.top ?? 0) - r };
2061
- }, Kl = (e, t, n) => !!n && !(e < n.x || e > n.x + n.width) && !(t < n.y || t > n.y + n.height), $o = (e, t = !0) => `M ${we.boundPixel(e.left)} ${we.boundPixel(e.top)} L ${we.boundPixel(e.right, !0)} ${we.boundPixel(e.top)} L ${we.boundPixel(e.right, !0)} ${we.boundPixel(e.bottom, !0)} L ${we.boundPixel(e.left)} ${we.boundPixel(e.bottom, !0)} L ${we.boundPixel(e.left)} ${we.boundPixel(e.top)} ${t ? "Z" : ""}`, jr = (e) => {
2062
- const { linePoints: t, bounds: n, pathProps: o, style: r, ...i } = e;
2063
- return q("svg", { width: `${we.boundPixel(n.width, !0)}`, height: `${we.boundPixel(n.height, !0)}`, viewBox: `0 0 ${we.boundPixel(n.width, !0)} ${we.boundPixel(n.height, !0)}`, style: { position: "absolute", left: `${we.boundPixel(n.x)}px`, top: `${we.boundPixel(n.y)}px`, width: `${we.boundPixel(n.width, !0)}px`, height: `${we.boundPixel(n.height, !0)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...r }, ...i, children: q("path", { d: `M ${we.boundPixel(t[0])} ${we.boundPixel(t[1])} L ${we.boundPixel(t[2])} ${we.boundPixel(t[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...o }) });
2064
- }, ql = (e) => {
2065
- const { x: t = 0, y: n = 0, width: o = 0, height: r = 0, fill: i, stroke: l, strokeWidth: s = 0, strokeDasharray: a, strokeDashoffset: d, clipPath: g, pathBounds: m, pathProps: u, style: x, ...M } = e, E = n, P = t, Q = o, k = r;
2066
- let I = null;
2067
- if (i) {
2068
- let z = $o({ top: 0, left: 0, bottom: k, right: Q });
2069
- m && (z = z + " " + $o({ top: m.y - E, left: m.x - P, bottom: m.height + m.y - E, right: m.width + m.x - P })), I = [q("path", { d: z, fill: i, stroke: "none", fillRule: "evenodd" }, "fill")];
2070
- }
2071
- return Ht("svg", { width: `${we.boundPixel(o, !0)}`, height: `${we.boundPixel(r, !0)}`, viewBox: `0 0 ${we.boundPixel(o, !0)} ${we.boundPixel(r, !0)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${we.boundPixel(t)}px`, top: `${we.boundPixel(n)}px`, pointerEvents: "none", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", boxShadow: "rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px", overflow: "visible", ...x }, ...M, children: [I, q("path", { d: $o({ top: 0, left: 0, right: Q, bottom: k }), fill: "none", strokeDasharray: a, strokeDashoffset: d, stroke: l, vectorEffect: "non-scaling-stroke", strokeWidth: s, ...u })] });
2072
- }, Yl = (e) => {
2073
- const { key: t, ...n } = e;
2074
- return q(Ii, { ...n }, t);
2075
- }, Ii = At((e) => {
2076
- const { stroke: t, fill: n, x: o = 0, y: r = 0, width: i = 0, height: l = 0, style: s, isAnimatedStroke: a, animatedStrokeProps: d, range: g, cell: m, ...u } = e, x = a || !!d, M = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...d };
2077
- let E = M.dashGap + M.dashLength;
2078
- const P = M.speed * E, Q = Al().replaceAll(":", ""), k = `${M.name}-${Q}`;
2079
- let I;
2080
- return st(() => {
2081
- if (!x) return;
2082
- const z = `@keyframes ${k} {
2083
- to {
2084
- stroke-dashoffset: 0px;
2085
- }
2086
- }`, se = document.createElement("style");
2087
- return se.appendChild(document.createTextNode(z)), document.head.appendChild(se), se.sheet.insertRule(z, 0), () => {
2088
- document.head.removeChild(se);
2089
- };
2090
- }, [x]), x && (I = { strokeDasharray: `${M.dashLength}px ${M.dashGap}px`, strokeDashoffset: `${E}px`, animation: `${k} ${P}ms linear infinite`, willChange: "stroke-dashoffset" }), q(ql, { x: o, y: r, width: i, height: l, stroke: t, fill: n, shapeRendering: "crispEdges", style: { ...I, ...s }, ...u });
2091
- });
2092
- function Ci(e) {
2093
- var t, n, o = "";
2094
- if (typeof e == "string" || typeof e == "number") o += e;
2095
- else if (typeof e == "object") if (Array.isArray(e)) {
2096
- var r = e.length;
2097
- for (t = 0; t < r; t++) e[t] && (n = Ci(e[t])) && (o && (o += " "), o += n);
2098
- } else for (n in e) e[n] && (o && (o += " "), o += n);
2099
- return o;
2100
- }
2101
- function _n() {
2102
- for (var e, t, n = 0, o = "", r = arguments.length; n < r; n++) (e = arguments[n]) && (t = Ci(e)) && (o && (o += " "), o += t);
2103
- return o;
2104
- }
2105
- Ii.displayName = "Selection";
2106
- const Mi = At(Ut((e, t) => {
2107
- const { x: n = 0, y: o = 0, borderWidth: r = 1, size: i = 6, borderStroke: l, corner: s, style: a, className: d, background: g, ...m } = e;
2108
- if (n === 0 || o === 0) return null;
2109
- let u = !0, x = !0, M = !0, E = !0;
2110
- switch (s) {
2111
- case "tl":
2112
- u = !1, x = !1;
2113
- break;
2114
- case "bl":
2115
- u = !1, E = !1;
2116
- break;
2117
- case "br":
2118
- M = !1, E = !1;
2119
- break;
2120
- case "tr":
2121
- x = !1, M = !1;
2122
- }
2123
- return q("div", { className: _n("fill-handle", d), style: { position: "absolute", left: n - (i + (u ? r : 0)) / 2, top: o - (i + (x ? r : 0)) / 2, width: i, height: i, borderLeft: u ? `${r}px ${l}` : void 0, borderTop: x ? `${r}px ${l}` : void 0, borderRight: M ? `${r}px ${l}` : void 0, borderBottom: E ? `${r}px ${l}` : void 0, background: g, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...a }, tabIndex: -1, ...m });
2124
- }));
2125
- Mi.displayName = "FillHandle";
2126
- var Xl = function() {
2127
- }, Ti = typeof window < "u", Gl = Ti ? tn : st, Vr = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
2128
- const Ri = Ti && window.ResizeObserver !== void 0 ? function() {
2129
- var e = Ze(null), t = e[0], n = e[1], o = Ze(Vr), r = o[0], i = o[1], l = Ee(function() {
2130
- return new window.ResizeObserver(function(s) {
2131
- if (s[0]) {
2132
- var a = s[0].contentRect, d = a.x, g = a.y, m = a.width, u = a.height, x = a.top, M = a.left, E = a.bottom, P = a.right;
2133
- i({ x: d, y: g, width: m, height: u, top: x, left: M, bottom: E, right: P });
2134
- }
2135
- });
2136
- }, []);
2137
- return Gl(function() {
2138
- if (t) return l.observe(t), function() {
2139
- l.disconnect();
2140
- };
2141
- }, [t]), [n, r];
2142
- } : function() {
2143
- return [Xl, Vr];
2144
- };
2145
- function Bo(e, t) {
2146
- if (typeof e == "function") return e(t);
2147
- e && (e.current = t);
2148
- }
2149
- var Zl = parseInt(Kr.split(".")[0], 10) >= 19 ? function(e) {
2150
- return (t) => {
2151
- const n = [];
2152
- for (const o of e) {
2153
- const r = Bo(o, t), i = typeof r == "function";
2154
- n.push(i ? r : () => Bo(o, null));
2155
- }
2156
- return () => {
2157
- for (const o of n) o();
2158
- };
2159
- };
2160
- } : function(e) {
2161
- return (t) => {
2162
- for (const n of e) Bo(n, t);
2163
- };
2164
- };
2165
- const Go = At(Ut((e, t) => {
2166
- const { range: n, view: o, anchor: r, borderStroke: i = "rgb(33, 115, 70)", background: l = "white", borderWidth: s = 1.5, size: a = 22, style: d, className: g, selectionTouchPointerHandler: m, onTouchSelectStart: u, onTouchSelectEnd: x, currentTouchAnchor: M, scrollableElement: E, scrollableRoot: P = document.body, ...Q } = e, k = R(u, [u]), I = R(x, [x]), { bounds: z, coordsPivot: se, key: B } = Ee(() => {
2167
- if (!n || !o) return null;
2168
- let K = null, L = null;
2169
- switch (r) {
2170
- case "tl":
2171
- K = { colIndex: n.colEnd, rowIndex: n.rowEnd }, L = { colIndex: n.colStart, rowIndex: n.rowStart };
2172
- break;
2173
- case "br":
2174
- K = { colIndex: n.colStart, rowIndex: n.rowStart }, L = { colIndex: n.colEnd, rowIndex: n.rowEnd };
2175
- break;
2176
- case "t":
2177
- case "l":
2178
- K = { colIndex: n.colEnd, rowIndex: n.rowEnd };
2179
- break;
2180
- case "b":
2181
- K = { colIndex: n.colStart, rowIndex: n.rowStart };
2182
- break;
2183
- case "r":
2184
- K = { colIndex: n.colStart, rowIndex: n.rowEnd };
2185
- }
2186
- let U = o.getRangeCoordsBounds(L ? { rowStart: L.rowIndex, colStart: L.colIndex, rowEnd: L.rowIndex, colEnd: L.colIndex } : n);
2187
- const te = o.getBounds(), ne = o.getViewportSize(), Y = te.x, He = te.y, Ve = ne.width, Ne = ne.height;
2188
- switch (r) {
2189
- case "tl":
2190
- break;
2191
- case "br":
2192
- U.x = U.x + U.width, U.y = U.y + U.height;
2193
- break;
2194
- case "t":
2195
- U.x = Ve / 2 - Y;
2196
- break;
2197
- case "b":
2198
- U.x = Ve / 2 - Y, U.y = U.y + U.height;
2199
- break;
2200
- case "l":
2201
- U.y = Ne / 2 - He;
2202
- break;
2203
- case "r":
2204
- U.x = U.x + U.width, U.y = Ne / 2 - He;
2205
- }
2206
- const at = o.toClipBounds(U, 0);
2207
- return !at || at.width <= 0 || at.height <= 0 || U.x < 0 || U.y < 0 || U.x > Ve || U.y > Ne ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: U, coordsAnchor: null, coordsPivot: K, key: "touchSelect-" + o.getAnchor() + "-" + r };
2208
- }, [n, o, r]), re = G(null), be = On(Ee(() => {
2209
- const K = (L) => r === "t" || r === "b" ? { ...L, colIndex: void 0 } : r === "l" || r === "r" ? { ...L, rowIndex: void 0 } : L;
2210
- return { processTouch: !0, consumeTouch: !0, onPointerDown: (L, U) => {
2211
- const te = K(o.getCellCoordsFromClient(L.clientX, L.clientY));
2212
- return re.current = { coordsPivot: se }, k?.(r), m.onSelectionPointerDown(L, U, o, te, se, !1, !0);
2213
- }, onPointerMoveOrWait: (L, U, te) => {
2214
- const ne = K(o.getCellCoordsFromClient(L.clientX, L.clientY));
2215
- return m.onSelectionPointerMoveOrWait(L, U, te, o, ne, re.current?.coordsPivot, !0, !0);
2216
- }, onPointerUp: (L, U, te) => (re.current = null, I?.(r), m.onPointerUp(L, U, te)) };
2217
- }, [m, n, o, r])), [N, { y: H, x: X }] = Ri(), T = G(null), { getPortalContainer: S } = vi(), [f, J] = Ze(null);
2218
- return st(() => {
2219
- const K = T.current?.getBoundingClientRect();
2220
- if (!K || !z) return void J(null);
2221
- let L = 0, U = 0, te = E;
2222
- for (; te; ) L += te.scrollLeft, U += te.scrollTop, te = P && te === P.parentElement ? null : te.parentElement;
2223
- J(qr(q("div", { className: _n("touch-select-handle", g), ref: t, style: { position: "absolute", left: L + (K?.x ?? 0) - (a + s) / 2, top: U + (K?.y ?? 0) - (a + s) / 2, width: a, height: a, borderWidth: `${s}px`, border: i, borderRadius: "50%", background: l, boxShadow: `0 0 0 1.5px ${l}`, cursor: "grab", pointerEvents: "all", opacity: M ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...d }, tabIndex: -1, onPointerDown: be, ...Q }), P ?? S(), B));
2224
- }, [H, X, z?.x, z?.y, z?.width, z?.height, g, M, l, a, s, i, E]), z ? Ht(wn, { children: [q("div", { ref: Zl([N, T]), style: { position: "absolute", left: z.x, top: z.y, opacity: 0 } }), f] }) : null;
2225
- }));
2226
- Go.displayName = "TouchSelectHandle";
2227
- const en = -10, Jl = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), ki = Object.freeze({ colIndex: 0, rowIndex: 0 }), Zo = Object.freeze([]), Yt = (e) => {
2228
- if (e && e.cell && e.ranges && e.rangeIndex > -1 && e.rangeIndex <= e.ranges.length) return e;
2229
- const t = { cell: null, ranges: e?.ranges ?? Zo };
2230
- return t.rangeIndex = e?.rangeIndex ?? t.ranges.length - 1, t.cell = e?.cell, !t.cell && t.ranges.length > 0 && (t.cell = { rowIndex: t.ranges[t.rangeIndex].rowStart, colIndex: t.ranges[t.rangeIndex].colStart }), t.cell || (t.cell = ki), Z.isEqualSelectionCoords(t, e) ? e : t;
2231
- }, lo = (e, t, n) => {
2232
- const o = e.getVisibleRangeCoords(), r = e.getScrollOrientation();
2233
- !r.horizontal && (t.colIndex > o.colEnd || t.colIndex < o.colStart) && (t = { ...t, colIndex: t.colIndex > o.colEnd ? o.colEnd + 1 : o.colEnd - 1 }, e = n.current.getViewFromLocation(Xt)), !r.vertical && (t.rowIndex > o.rowEnd || t.rowIndex < o.rowStart) && (t = { ...t, rowIndex: t.rowIndex > o.rowEnd ? o.rowEnd + 1 : o.rowEnd - 1 }, e = n.current.getViewFromLocation(Xt)), e.scrollCellCoordsIntoView(t);
2234
- }, Ql = () => !1, ws = ({ gridRef: e, commands: t, layout: n, selection: o, onSelectionChange: r, onSelectionDragStart: i, onSelectionDragEnd: l, selectionPolicy: s = "multiple", newSelectionMode: a = "clear", allowDeselectSelection: d = !0, onFillPreview: g, onFillCancel: m, onFillDone: u, onFill: x, disableFillDrag: M = !x, fillHandleBorderColor: E = "white", hiddenRowsAt: P, hiddenColumnsAt: Q, isContentfulCell: k, contentfulCellFinder: I = Ul, getDataCoords: z, alwaysScrollToActiveCoords: se = !1, selectionBounds: B, pointerDownInterceptor: re, pointerMoveInterceptor: be, mergedRanges: N, canSelectionSpanMergedCells: H = Ql, onMoveDragStart: X, onMoveDragUpdate: T, onMoveDragEnd: S, onMoveDragDone: f, selectionRenderer: J = Yl, disableMoveDrag: K = !S, getCellCoordsAsRangeCoords: L = Z.cellToRange, moveDragHitSize: U = 6, moveDragOutlineSize: te = 4, selectionBackgroundColor: ne = "rgba(16, 124, 65, 0.1)", selectionBorderColor: Y = "rgb(33, 115, 70)", selectionRemoveBorderColor: He = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: Ve = "rgba(250, 10, 10, 0.1)", disableTouchSelection: Ne = !1, touchSelectHandleProps: at }) => {
2235
- const Se = D(() => ({ top: B?.top ?? 0, left: B?.left ?? 0, bottom: e.current?.rowCount - 1 || 0, right: e.current?.columnCount - 1 || 0 }), []), Ye = R(x, [x]), $ = R(g, [g]), _ = R(m, [m]), Me = R(u, [u]), ue = R(k, [k]), me = R(J, [J]), $e = R((c, h = !1) => go(c, h, n.getRowOffset, h ? Se().bottom : Se().top), [n?.getRowOffset]), dt = R(P ?? $e, [P]), kt = R((c, h = !1) => go(c, h, n.getColOffset, h ? Se().right : Se().left), [n?.getColOffset]), ut = R(Q ?? kt, [Q]), [Zt, St] = Ze(() => Yt(o)), C = Ee(() => Yt(Zt), [Zt]), ye = G(C), Je = G(!0);
2236
- tn(Ct.throttle(() => {
2237
- St((c) => {
2238
- Je.current = !0;
2239
- const h = Yt(o);
2240
- return Z.isEqualSelectionCoords(h, c) ? c : h;
2241
- });
2242
- }, 0), [o]), tn(() => {
2243
- ye.current = C;
2244
- }, [C]), st(() => {
2245
- Je.current || !r || Z.isEqualSelectionCoords(o, C) || r(C);
2246
- }, [C]);
2247
- const mt = D((c) => {
2248
- St((h) => {
2249
- Je.current = !1, h = Yt(h);
2250
- let w = typeof c == "function" ? c(h.ranges) : c ?? Zo;
2251
- if (Z.isEqualRangesArrays(w, h.ranges)) return h;
2252
- let p = Math.max(w.length ? 0 : -1, Math.min(h.rangeIndex, w.length - 1)), v = h.cell;
2253
- p === -1 || Z.isCellWithinRange(v, w[p]) || (v = { rowIndex: w[p].rowStart, colIndex: w[p].colStart }), w.length === 1 && Z.isSingleCell(w[0]) && Z.isCellWithinRange(v, w[0]) && (w = [], p = -1);
2254
- const W = { cell: v, ranges: w, rangeIndex: p };
2255
- return Z.isEqualSelectionCoords(W, h) ? h : W;
2256
- });
2257
- }, []), Qe = R((c) => {
2258
- St((h) => {
2259
- Je.current = !1, h = Yt(h);
2260
- const w = c ?? ki, p = L(w);
2261
- if (!Z.isSingleCell(p) && h.ranges.length === 0) return { ranges: [p], rangeIndex: 0, cell: w };
2262
- if (Z.isEqualCells(w, h.cell)) return h;
2263
- let v = h.ranges, W = h.rangeIndex;
2264
- h.ranges.length === 1 && (Z.isSingleCell(h.ranges[0]) && Z.isCellWithinRange(w, h.ranges[0]) || !Z.isCellWithinRange(w, h.ranges[0])) && (v = [], W = -1);
2265
- const b = { ranges: v, rangeIndex: W, cell: w };
2266
- return Z.isEqualSelectionCoords(b, h) ? h : b;
2267
- });
2268
- }, [L]), [cn, on] = Ze(null), [Mt, dn] = Ze(null), nn = G(null), [De, Kt] = Ze(null), xt = G(null), Vt = G(null), [Cn, un] = Ze(null), We = G(null), ee = G(null), et = G(N);
2269
- st(() => {
2270
- et.current = N;
2271
- }, [N]);
2272
- const Ue = R((c, h = { inline: "nearest", block: "nearest" }) => {
2273
- let { rowIndex: w, colIndex: p } = c;
2274
- w === void 0 && C?.cell && (w = C.cell.rowIndex), p === void 0 && C?.cell && (p = C.cell.colIndex), w !== void 0 && p !== void 0 && e.current?.scrollCellCoordsIntoView({ rowIndex: w, colIndex: p }, h);
2275
- }, [C]), ht = D((c) => {
2276
- const h = Se();
2277
- return c.rowIndex < h.top || c.colIndex < h.left || c.colIndex > h.right || c.rowIndex > h.bottom;
2278
- }, []), Ie = R((c, h) => {
2279
- if (!e?.current) return null;
2280
- const w = { rowStart: Math.min(c.rowIndex, h.rowIndex), colStart: Math.min(c.colIndex, h.colIndex), rowEnd: Math.max(c.rowIndex, h.rowIndex), colEnd: Math.max(c.colIndex, h.colIndex) };
2281
- if (H?.(w)) return w;
2282
- const v = L(c), W = L(h), b = { rowStart: Math.min(v.rowStart, W.rowStart), colStart: Math.min(v.colStart, W.colStart), rowEnd: Math.max(v.rowEnd, W.rowEnd), colEnd: Math.max(v.colEnd, W.colEnd) };
2283
- let he;
2284
- return typeof et.current == "function" ? he = et.current(b) : N && (he = N), he ? Z.extendRangeToUnionRanges(b, he) : b;
2285
- }, [H, L]), Oe = R((c, h, w) => {
2286
- const p = c.ranges.length > 0 ? c.ranges[c.rangeIndex] : { rowStart: c.cell.rowIndex, colStart: c.cell.colIndex, rowEnd: c.cell.rowIndex, colEnd: c.cell.colIndex }, v = { rowStart: Math.min(h.rowIndex ?? p.rowStart, w.rowIndex ?? p.rowStart), colStart: Math.min(h.colIndex ?? p.colStart, w.colIndex ?? p.colStart), rowEnd: Math.max(h.rowIndex ?? p.rowEnd, w.rowIndex ?? p.rowEnd), colEnd: Math.max(h.colIndex ?? p.colEnd, w.colIndex ?? p.colEnd) }, W = { rowIndex: v.rowStart, colIndex: v.colStart }, b = { rowIndex: v.rowEnd, colIndex: v.colEnd };
2287
- if (!(ht(W) || ht(b)))
2288
- return Ie(W, b);
2289
- }, [Ie]), rt = R((c, h, w) => {
2290
- if (s === "single" || !ye.current) return;
2291
- const p = Oe(ye.current, c, h ?? ye.current.cell);
2292
- if (!p) return;
2293
- const v = ye.current.rangeIndex;
2294
- mt((W) => W.length ? W.map((b, he) => v === he ? p : b) : [p]), w && p && Qe({ colIndex: p.colStart, rowIndex: p.rowStart });
2295
- }, []), tt = D((c, h, w) => {
2296
- if (!ye.current) return;
2297
- c = { ...ye.current?.cell, ...c }, h = h ?? c;
2298
- const p = Oe(ye.current, c, h);
2299
- if (!p) return;
2300
- const v = { rowIndex: p.rowStart, colIndex: p.colStart }, W = { ...v, ...w };
2301
- a === "clear" ? (We.current = W, rn()) : a === "modify" ? rt(v) : ze(v), Qe(W);
2302
- }, []), ze = D((c, h = c, w) => {
2303
- s !== "multiple" || !c || ht(c) || ht(h) || St((p) => {
2304
- Je.current = !1, p = Yt(p);
2305
- const v = Ie(c, h);
2306
- if (!v) return p;
2307
- let W = p.ranges.length > 0 ? [...p.ranges] : [Ie(p.cell, p.cell)];
2308
- W.push(v);
2309
- const b = { ranges: W, cell: { rowIndex: v.rowStart, colIndex: v.colStart, ...w }, rangeIndex: W.length - 1 };
2310
- return Z.isEqualSelectionCoords(b, p) ? p : b;
2311
- });
2312
- }, []), rn = () => {
2313
- mt(Zo);
2314
- }, Tt = we.detectIt().primaryInput === "touch", nt = G(null), Rt = G(null), Ot = G(null), hn = Ee(() => ({ onPointerDown: (c) => {
2315
- if (!e || !e.current) return !1;
2316
- const h = c.nativeEvent, w = e.current.getViewFromClient(h.clientX, h.clientY);
2317
- if (h.pointerType === "touch" || h.type === "touchstart") return Rt.current = { topLeft: w.getScrollTopLeft(), point: { x: h.clientX, y: h.clientY } }, !0;
2318
- const p = w.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
2319
- if (!p) return !1;
2320
- nt.current = { anchor: w.getAnchor(), coords: p }, ee.current = null;
2321
- const v = c.nativeEvent.which === Er;
2322
- if (v && Z.indexOfCoords(p, C.ranges) !== -1)
2323
- return !1;
2324
- const W = c.nativeEvent.shiftKey, b = c.nativeEvent.ctrlKey || c.nativeEvent.metaKey, he = b, oe = d, ie = C.ranges.length > 0, ge = b && oe;
2325
- if (re?.(c, p, C) === !1) return !1;
2326
- i?.(ye.current, c.nativeEvent);
2327
- const Le = !v && s !== "single";
2328
- if (W) return rt(p), Le;
2329
- const de = Z.isEqualCells(p, C.cell);
2330
- if (he) {
2331
- if (de && (!ge || !ie)) return Le;
2332
- if (b && Z.indexOfCoords(p, C.ranges) !== -1 && oe) {
2333
- xt.current = p;
2334
- const le = Ie(p, p);
2335
- return Vt.current = le, Kt(le), Le;
2336
- }
2337
- return ze(p), Le;
2338
- }
2339
- se && Ue(p), de && C.ranges.length === 0 || tt(p);
2340
- }, onPointerMoveOrWait: Ct.throttle((c, h) => {
2341
- if (!e?.current || c.pointerType === "touch" || c.type === "touchmove" || !nt.current) return;
2342
- const w = nt.current.anchor;
2343
- let p = e.current.getViewFromLocation(w), v = p.getCellCoordsFromClient(c.clientX, c.clientY);
2344
- if (!Z.isEqualCells(v, nt.current?.coords) && (nt.current = { anchor: w, coords: v }, v && be?.(c, v, ye.current) !== !1)) {
2345
- if (xt.current) {
2346
- const W = { rowStart: Math.min(v.rowIndex, xt.current.rowIndex), colStart: Math.min(v.colIndex, xt.current.colIndex), rowEnd: Math.max(v.rowIndex, xt.current.rowIndex), colEnd: Math.max(v.colIndex, xt.current.colIndex) }, b = { rowIndex: W.rowStart, colIndex: W.colStart }, he = { rowIndex: W.rowEnd, colIndex: W.colEnd };
2347
- if (ht(b) || ht(he)) return;
2348
- const oe = Ie(b, he);
2349
- Vt.current = oe, Kt(oe);
2350
- } else rt(v);
2351
- Ot.current = h, lo(p, v, e);
2352
- }
2353
- }, 60), onPointerUp: (c) => {
2354
- if (nt.current = null, c.pointerType === "touch" || c.type === "touchend") {
2355
- if (Rt.current) {
2356
- const w = e.current.getViewFromClient(Rt.current.point.x, Rt.current.point.y), p = w.getScrollTopLeft();
2357
- if (p.left === Rt.current.topLeft.left && p.top === Rt.current.topLeft.top) {
2358
- const v = w.getCellCoordsFromClient(Rt.current.point.x, Rt.current.point.y);
2359
- tt(v);
2360
- }
2361
- }
2362
- return Rt.current = null, void (nt.current = null);
2363
- }
2364
- try {
2365
- l?.(ye.current, c);
2366
- } catch (w) {
2367
- console.warn(w);
2368
- }
2369
- if (!xt.current) return;
2370
- const h = Vt.current;
2371
- xt.current = null, Vt.current = null, Kt(null), St((w) => {
2372
- if (Je.current = !1, (w = Yt(w)).ranges.length === 0) return w;
2373
- let p = [], v = -1, W = w.cell;
2374
- for (let he = 0; he < w.ranges.length; he++) {
2375
- const oe = w.ranges[he];
2376
- if (Z.isRangesIntersect(oe, h)) {
2377
- const ie = Ct.subtractRect({ top: oe.rowStart, left: oe.colStart, bottom: oe.rowEnd + 1, right: oe.colEnd + 1 }, { top: h.rowStart, left: h.colStart, bottom: h.rowEnd + 1, right: h.colEnd + 1 });
2378
- for (let ge = 0; ge < ie.length; ge++) {
2379
- const Le = { rowStart: ie[ge].top, colStart: ie[ge].left, rowEnd: ie[ge].bottom - 1, colEnd: ie[ge].right - 1 };
2380
- p.push(Le), Z.isCellWithinRange(w.cell, Le) && (v = p.length - 1);
2381
- }
2382
- } else p.push(oe);
2383
- p.length > 0 && v === -1 && Z.isCellWithinRange(w.cell, oe) && (v = p.length - 1, W = { rowIndex: p[p.length - 1].rowStart, colIndex: p[p.length - 1].colStart });
2384
- }
2385
- const b = { cell: W, rangeIndex: v, ranges: p };
2386
- return Z.isEqualSelectionCoords(b, w) ? w : b;
2387
- });
2388
- }, processTouch: !0, consumeTouch: !1 }), [C, s, d, se, a]), mo = R(On(hn), []), xo = Ee(() => ({ onSelectionPointerDown: (c, h, w, p, v = C.cell, W = se, b = c.nativeEvent.shiftKey, he = !1) => {
2389
- if (!e || !e.current) return !1;
2390
- c.stopPropagation(), c.preventDefault(), c.nativeEvent.stopImmediatePropagation();
2391
- const oe = w ?? e.current.getViewFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY), ie = p ?? oe.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
2392
- if (!ie) return !1;
2393
- nt.current = { anchor: oe.getAnchor(), coords: ie }, ee.current = null;
2394
- const ge = c.nativeEvent.which === Er;
2395
- if (ge && Z.indexOfCoords(ie, C.ranges) !== -1)
2396
- return !1;
2397
- const Le = c.nativeEvent.ctrlKey || c.nativeEvent.metaKey, de = Le, le = d, Et = C.ranges.length > 0, F = Le && le;
2398
- if (re?.(c, ie, C) === !1) return !1;
2399
- i?.(ye.current, c.nativeEvent);
2400
- const ke = !ge && s !== "single";
2401
- if (b) return rt(ie, v, he), ke;
2402
- const Pt = Z.isEqualCells(ie, v);
2403
- if (de) {
2404
- if (Pt && (!F || !Et)) return ke;
2405
- if (F && Z.indexOfCoords(ie, C.ranges) !== -1 && le) {
2406
- xt.current = ie;
2407
- const Re = Ie(ie, ie);
2408
- return Vt.current = Re, Kt(Re), ke;
2409
- }
2410
- return ze(ie), ke;
2411
- }
2412
- W && Ue(ie), Pt && C.ranges.length === 0 || tt(ie);
2413
- }, onSelectionPointerMoveOrWait: (c, h, w, p, v, W = C.cell, b = !0, he = !1) => {
2414
- if (!e?.current || (c.stopPropagation(), c.preventDefault(), c.stopImmediatePropagation(), !nt.current)) return;
2415
- const oe = nt.current.anchor;
2416
- let ie = p ?? e.current.getViewFromLocation(oe), ge = v ?? ie.getCellCoordsFromClient(c.clientX, c.clientY);
2417
- if (!Z.isEqualCells(ge, nt.current?.coords) && (nt.current = { anchor: oe, coords: ge }, ge && be?.(c, ge, ye.current) !== !1)) {
2418
- if (xt.current) {
2419
- const Le = { rowStart: Math.min(ge.rowIndex, xt.current.rowIndex), colStart: Math.min(ge.colIndex, xt.current.colIndex), rowEnd: Math.max(ge.rowIndex, xt.current.rowIndex), colEnd: Math.max(ge.colIndex, xt.current.colIndex) }, de = { rowIndex: Le.rowStart, colIndex: Le.colStart }, le = { rowIndex: Le.rowEnd, colIndex: Le.colEnd };
2420
- if (ht(de) || ht(le)) return;
2421
- const Et = Ie(de, le);
2422
- Vt.current = Et, Kt(Et);
2423
- } else rt(ge, W, he);
2424
- b && lo(ie, ge, e);
2425
- }
2426
- }, onPointerUp: (c) => {
2427
- nt.current = null, c.stopPropagation(), c.preventDefault(), c.stopImmediatePropagation();
2428
- try {
2429
- l?.(ye.current, c);
2430
- } catch (w) {
2431
- console.warn(w);
2432
- }
2433
- if (!xt.current) return;
2434
- const h = Vt.current;
2435
- xt.current = null, Vt.current = null, Kt(null), St((w) => {
2436
- if (Je.current = !1, (w = Yt(w)).ranges.length === 0) return w;
2437
- let p = [], v = -1, W = w.cell;
2438
- for (let he = 0; he < w.ranges.length; he++) {
2439
- const oe = w.ranges[he];
2440
- if (Z.isRangesIntersect(oe, h)) {
2441
- const ie = Ct.subtractRect({ top: oe.rowStart, left: oe.colStart, bottom: oe.rowEnd + 1, right: oe.colEnd + 1 }, { top: h.rowStart, left: h.colStart, bottom: h.rowEnd + 1, right: h.colEnd + 1 });
2442
- for (let ge = 0; ge < ie.length; ge++) {
2443
- const Le = { rowStart: ie[ge].top, colStart: ie[ge].left, rowEnd: ie[ge].bottom - 1, colEnd: ie[ge].right - 1 };
2444
- p.push(Le), Z.isCellWithinRange(w.cell, Le) && (v = p.length - 1);
2445
- }
2446
- } else p.push(oe);
2447
- p.length > 0 && v === -1 && Z.isCellWithinRange(w.cell, oe) && (v = p.length - 1, W = { rowIndex: p[p.length - 1].rowStart, colIndex: p[p.length - 1].colStart });
2448
- }
2449
- const b = { cell: W, rangeIndex: v, ranges: p };
2450
- return Z.isEqualSelectionCoords(b, w) ? w : b;
2451
- });
2452
- } }), [C, s, d, se, a]), pt = R((c, h = !1, w = !1, p = 0) => {
2453
- if (!e.current || !C.cell) return;
2454
- let v = C.cell, W = C.cell;
2455
- if (h && C.ranges.length > 0) {
2456
- const F = C.ranges[C.rangeIndex], ke = C.cell;
2457
- switch (c) {
2458
- case it:
2459
- W = { rowIndex: ke.rowIndex === F.rowStart ? F.rowEnd : F.rowStart, colIndex: F.colEnd }, v = { rowIndex: ke.rowIndex === F.rowStart ? F.rowStart : F.rowEnd, colIndex: F.colStart };
2460
- break;
2461
- case lt:
2462
- W = { rowIndex: ke.rowIndex === F.rowEnd ? F.rowStart : F.rowEnd, colIndex: F.colEnd }, v = { rowIndex: ke.rowIndex === F.rowEnd ? F.rowEnd : F.rowStart, colIndex: F.colStart };
2463
- break;
2464
- case ot:
2465
- W = { rowIndex: F.rowEnd, colIndex: ke.colIndex === F.colStart ? F.colEnd : F.colStart }, v = { rowIndex: F.rowStart, colIndex: ke.colIndex === F.colStart ? F.colStart : F.colEnd };
2466
- break;
2467
- case Ke:
2468
- W = { rowIndex: F.rowEnd, colIndex: ke.colIndex === F.colEnd ? F.colStart : F.colEnd }, v = { rowIndex: F.rowStart, colIndex: ke.colIndex === F.colEnd ? F.colEnd : F.colStart };
2469
- }
2470
- }
2471
- const b = L(W);
2472
- let { rowStart: he, colStart: oe } = b;
2473
- const ie = Se();
2474
- if (ee.current) switch (c) {
2475
- case it:
2476
- case lt:
2477
- ee.current.colIndex >= b.colStart && ee.current.colIndex <= b.colEnd && (oe = ee.current.colIndex);
2478
- break;
2479
- case ot:
2480
- case Ke:
2481
- ee.current.rowIndex >= b.rowStart && ee.current.rowIndex <= b.rowEnd && (he = ee.current.rowIndex);
2482
- }
2483
- if (!p) {
2484
- switch (c) {
2485
- case it:
2486
- he = qe(dt, Math.max(b.rowStart - 1, ie.top), c);
2487
- break;
2488
- case lt:
2489
- he = qe(dt, Math.min(b.rowEnd + 1, ie.bottom), c);
2490
- break;
2491
- case ot:
2492
- oe = qe(ut, Math.max(b.colStart - 1, ie.left), c);
2493
- break;
2494
- case Ke:
2495
- oe = qe(ut, Math.min(b.colEnd + 1, ie.right), c);
2496
- }
2497
- if (w) switch (c) {
2498
- case it:
2499
- he = I({ ...W, colIndex: C.cell.colIndex }, ue, dt, c, !1, Math.max(ie.top, dt(ie.top, !1)));
2500
- break;
2501
- case lt:
2502
- he = I({ ...W, colIndex: C.cell.colIndex }, ue, dt, c, !1, Math.min(ie.bottom, ie.bottom - dt(ie.bottom, !0)));
2503
- break;
2504
- case ot:
2505
- oe = I({ ...W, rowIndex: C.cell.rowIndex }, ue, ut, c, !1, Math.max(ie.left, ut(ie.left, !1)));
2506
- break;
2507
- case Ke:
2508
- oe = I({ ...W, rowIndex: C.cell.rowIndex }, ue, ut, c, !1, Math.min(ie.right, ie.right - ut(ie.right, !0)));
2509
- }
2510
- }
2511
- let ge = null;
2512
- if (p) {
2513
- let F = 0;
2514
- switch (c) {
2515
- case it:
2516
- F = n.getRowOffset(he + 1), he = Math.max(ie.top, n.getRowIndex(F - p)), ge = { top: n.getRowOffset(he + 1) - (F - e.current.getScrollPosition().top) };
2517
- break;
2518
- case lt:
2519
- F = n.getRowOffset(he), he = Math.min(ie.bottom, n.getRowIndex(F + p)), ge = { top: n.getRowOffset(he) - (F - e.current.getScrollPosition().top) };
2520
- break;
2521
- case ot:
2522
- F = n.getColOffset(oe + 1), oe = Math.max(ie.left, n.getColIndex(F - p)), ge = { left: n.getColOffset(oe + 1) - (F - e.current.getScrollPosition().left) };
2523
- break;
2524
- case Ke:
2525
- F = n.getColOffset(oe), oe = Math.min(ie.right, n.getColIndex(F + p)), ge = { left: n.getColOffset(oe) - (F - e.current.getScrollPosition().left) };
2526
- }
2527
- }
2528
- const Le = { rowIndex: he, colIndex: oe }, de = L(Le), le = { rowIndex: de.rowStart, colIndex: de.colStart };
2529
- h || (ee.current = Le);
2530
- const Et = Z.isEqualCells(We.current, le) && Z.isEqualCells(We.current, v);
2531
- if (h && !Et ? rt(le, v) : tt(le), ge) e.current.scrollTo(ge);
2532
- else {
2533
- if (h && We.current) {
2534
- const F = Se();
2535
- if (c === Ke && We.current.colIndex === F.left || c === ot && We.current.colIndex === F.right || c === it && We.current.rowIndex === F.bottom || c === lt && We.current.rowIndex === F.top) return;
2536
- }
2537
- c === ot || c === Ke ? Ue({ colIndex: Le.colIndex }) : c !== it && c !== lt || Ue({ rowIndex: Le.rowIndex });
2538
- }
2539
- }, [C, L]), ln = R((c) => {
2540
- if (!e.current) return;
2541
- if (C.ranges.length === 0) return void pt(c);
2542
- const h = L(C.cell);
2543
- if (Z.isEqualRangesArrays([h], C.ranges)) return void pt(c);
2544
- const w = Xo(C, c, L, dt, ut);
2545
- St((p) => {
2546
- Je.current = !1, p = Yt(p);
2547
- const v = { ...p, cell: w.cell, rangeIndex: w.rangeIndex };
2548
- return Z.isEqualSelectionCoords(v, p) ? p : v;
2549
- }), w.cell && Ue(w.cell);
2550
- }, [C, L]), yo = D(() => {
2551
- const c = Se();
2552
- rt({ rowIndex: c.top }, { rowIndex: c.bottom });
2553
- }, []), vo = D(() => {
2554
- const c = Se();
2555
- rt({ colIndex: c.left }, { colIndex: c.right });
2556
- }, []), xn = R(() => {
2557
- C.cell && e?.current && Ue(C.cell);
2558
- }, [C.cell]), qn = D((c = !1) => {
2559
- const h = { rowIndex: Se().top };
2560
- c ? rt(h) : tt(h), Ue(h);
2561
- }, []), Yn = D((c = !1) => {
2562
- const h = { rowIndex: Se().bottom };
2563
- c ? rt(h) : tt(h), Ue(h);
2564
- }, []), Dn = D((c = !1) => {
2565
- const h = { colIndex: Se().left };
2566
- c ? rt(h) : tt(h), Ue(h);
2567
- }, []), Mn = D((c = !1) => {
2568
- const h = Se(), w = { rowIndex: h.top, colIndex: h.left };
2569
- c ? rt(w) : tt(w), Ue(w);
2570
- }, []), zn = D((c = !1) => {
2571
- const h = Se(), w = { colIndex: z?.()?.colEnd ?? h.right };
2572
- c ? rt(w) : tt(w), Ue(w);
2573
- }, [z]), yn = D((c = !1) => {
2574
- const h = Se(), w = { rowIndex: z?.()?.rowEnd ?? h.bottom, colIndex: z?.()?.colEnd ?? h.right };
2575
- c ? rt(w) : tt(w), Ue(w);
2576
- }, [z]), An = R((c) => {
2577
- if (!e.current || C.ranges.length <= 1) return;
2578
- const h = c === ot || c === it;
2579
- let w = C.rangeIndex + (h ? -1 : 1);
2580
- w < 0 ? w = C.ranges.length - 1 : w > C.ranges.length - 1 && (w = 0);
2581
- const p = C.ranges[w], v = Xo({ cell: { rowIndex: p.rowEnd, colIndex: p.colEnd }, rangeIndex: 0, ranges: [p] }, Ke, L, dt, ut);
2582
- St((W) => {
2583
- Je.current = !1, W = Yt(W);
2584
- const b = { ...W, cell: v.cell, rangeIndex: w };
2585
- return Z.isEqualSelectionCoords(b, W) ? W : b;
2586
- }), v.cell && Ue(v.cell);
2587
- }, [C, L]), bo = R(() => {
2588
- const c = Ar(C);
2589
- St((h) => {
2590
- Je.current = !1, h = Yt(h);
2591
- const w = { ...h, visibleSelection: c };
2592
- return Z.isEqualSelectionCoords(w, h) ? h : w;
2593
- }), c.cell && Ue(c.cell);
2594
- }, [C, L]), So = R(() => {
2595
- if (!e.current || C.ranges.length === 0) return;
2596
- const c = C.cell, h = C.ranges[C.rangeIndex], w = Ar({ cell: c, rangeIndex: 0, ranges: [h] }), p = w.ranges[w.rangeIndex];
2597
- let v;
2598
- v = p.rowStart === c.rowIndex && p.colStart === c.colIndex ? { rowIndex: p.rowStart, colIndex: p.colEnd } : p.rowStart === c.rowIndex && p.colEnd === c.colIndex ? { rowIndex: p.rowEnd, colIndex: p.colStart } : p.rowEnd === c.rowIndex && p.colStart === c.colIndex ? { rowIndex: p.rowEnd, colIndex: p.colEnd } : { rowIndex: p.rowStart, colIndex: p.colStart }, St((W) => {
2599
- W = Yt(W);
2600
- const b = { ...W, cell: v };
2601
- return Z.isEqualSelectionCoords(b, W) ? W : b;
2602
- }), v && Ue(v);
2603
- }, [C, L]), Xn = D((c = !1) => {
2604
- pt(lt, c, !1, e.current.getDimensions().containerHeight);
2605
- }, []), Jt = D((c = !1) => {
2606
- pt(it, c, !1, e.current.getDimensions().containerHeight);
2607
- }, []), Gn = D((c = !1) => {
2608
- pt(Ke, c, !1, e.current.getDimensions().containerWidth);
2609
- }, []), $n = D((c = !1) => {
2610
- pt(ot, c, !1, e.current.getDimensions().containerWidth);
2611
- }, []), Zn = D(() => {
2612
- ln(ot);
2613
- }, []), Jn = D(() => {
2614
- ln(Ke);
2615
- }, []), _o = D(() => {
2616
- ln(it);
2617
- }, []), Eo = D(() => {
2618
- ln(lt);
2619
- }, []), Bn = D(() => {
2620
- An(ot);
2621
- }, []), Io = D(() => {
2622
- An(Ke);
2623
- }, []), Co = D(() => {
2624
- So();
2625
- }, []), Qn = D(() => {
2626
- pt(ot, !1, !1);
2627
- }, []), y = D(() => {
2628
- pt(ot, !0, !1);
2629
- }, []), O = D(() => {
2630
- pt(ot, !1, !0);
2631
- }, []), A = D(() => {
2632
- pt(ot, !0, !0);
2633
- }, []), j = D(() => {
2634
- pt(Ke, !1, !1);
2635
- }, []), V = D(() => {
2636
- pt(Ke, !0, !1);
2637
- }, []), fe = D(() => {
2638
- pt(Ke, !1, !0);
2639
- }, []), ce = D(() => {
2640
- pt(Ke, !0, !0);
2641
- }, []), xe = D(() => {
2642
- pt(it, !1, !1);
2643
- }, []), ve = D(() => {
2644
- pt(it, !0, !1);
2645
- }, []), ae = D(() => {
2646
- pt(it, !1, !0);
2647
- }, []), je = D(() => {
2648
- pt(it, !0, !0);
2649
- }, []), ft = D(() => {
2650
- pt(lt, !1, !1);
2651
- }, []), Be = D(() => {
2652
- pt(lt, !0, !1);
2653
- }, []), Fe = D(() => {
2654
- pt(lt, !1, !0);
2655
- }, []), gt = D(() => {
2656
- pt(lt, !0, !0);
2657
- }, []), Xe = D(() => {
2658
- mt((c) => c.slice(0, -1));
2659
- }, []), Lt = Ee(() => {
2660
- const c = Se();
2661
- return ((h, w, p, v, W) => {
2662
- for (let b = 0; b < h.length; b++) {
2663
- const he = h[b];
2664
- if (he.rowStart === w && he.colStart === p && he.rowEnd === v && he.colEnd === W) return !0;
2665
- }
2666
- return !1;
2667
- })(C.ranges, c.top, c.left, c.bottom, c.right);
2668
- }, [B, C.ranges]), yt = D((c, h = !0) => {
2669
- We.current = c, Qe(c), h && c && e?.current && Ue(c);
2670
- }, []), pe = R((c = !0) => {
2671
- const h = nn.current;
2672
- if (!ye.current?.cell) return;
2673
- const w = ye.current?.ranges, p = ye.current?.cell;
2674
- if (!p || !h || !h) return;
2675
- let v = null;
2676
- if (v = w.length > 0 ? w[w.length - 1] : L(p), v.colEnd >= v.colStart && v.rowEnd >= v.rowStart) {
2677
- const W = $r(v, h);
2678
- let b = c ? Ye : $;
2679
- try {
2680
- b?.(v, h, W.direction);
2681
- } catch (he) {
2682
- console.warn(he);
2683
- } finally {
2684
- c && Me?.();
2685
- }
2686
- }
2687
- }, [L]), wt = G(null), $t = On(Ee(() => ({ onPointerDown: (c, h) => {
2688
- if (Ot.current = h, !e || !e.current) return !1;
2689
- const w = e.current.getViewFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY), p = w?.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
2690
- p && (c.stopPropagation(), on("crosshair"), wt.current = { anchor: w.getAnchor(), coords: p });
2691
- }, onPointerMoveOrWait: (c, h) => {
2692
- if (M || !e?.current || !ye.current || !wt.current) return;
2693
- const w = wt.current.anchor;
2694
- let p = e.current.getViewFromLocation(w), v = p.getCellCoordsFromClient(c.clientX, c.clientY);
2695
- if (!v) return;
2696
- wt.current = { anchor: w, coords: v };
2697
- const W = ye.current.ranges;
2698
- let b = Ie(ye.current.cell, v);
2699
- if (!b) return;
2700
- const he = W.length > 0, oe = he ? W[W.length - 1] : L(ye.current.cell);
2701
- if (!b) return;
2702
- const ie = b.rowStart < oe.rowStart ? it : b.rowEnd > oe.rowEnd ? lt : b.colEnd > oe.colEnd ? Ke : ot, ge = Se();
2703
- ie === ot && (b = { ...oe, colStart: Math.max(ge.left, b.colStart) }), ie === it && (b = { ...oe, rowStart: Math.max(ge.top, b.rowStart) }), ie === Ke && (b = { ...oe, colEnd: Math.min(ge.right, b.colEnd) }), ie === lt && (b = { ...oe, rowEnd: Math.min(ge.bottom, b.rowEnd) });
2704
- const Le = $r(oe, b);
2705
- if (!H?.(oe)) {
2706
- let de;
2707
- typeof et.current == "function" ? de = et.current(oe) : N && (de = N), b = ((le, Et, F, ke, Pt, Re) => {
2708
- const Te = { ...Et };
2709
- if (F.length === 0) return Te;
2710
- if (Pt === ot) {
2711
- const bt = le.colEnd + 1 - le.colStart;
2712
- Te.colStart = le.colStart - Math.ceil(Re / bt) * bt, Te.colStart < ke.left && (Te.colStart = Te.colStart + Math.ceil((ke.left - Te.colStart) / bt) * bt);
2713
- } else if (Pt === Ke) {
2714
- const bt = le.colEnd + 1 - le.colStart;
2715
- Te.colEnd = le.colEnd + Math.ceil(Re / bt) * bt, Te.colEnd > ke.right && (Te.colEnd = Te.colEnd - Math.ceil((ke.right - Te.colEnd) / bt) * bt);
2716
- } else if (Pt === it) {
2717
- const bt = le.rowEnd + 1 - le.rowStart;
2718
- Te.rowStart = le.rowStart - Math.ceil(Re / bt) * bt, Te.rowStart < ke.top && (Te.rowStart = Te.rowStart + Math.ceil((ke.top - Te.rowStart) / bt) * bt);
2719
- } else if (Pt === lt) {
2720
- const bt = le.rowEnd + 1 - le.rowStart;
2721
- Te.rowEnd = le.rowEnd + Math.ceil(Re / bt) * bt, Te.rowEnd > ke.bottom && (Te.rowEnd = Te.rowEnd - Math.ceil((ke.bottom - Te.rowEnd) / bt) * bt);
2722
- }
2723
- return Te;
2724
- })(oe, b, de, ge, Le.direction, Le.amount);
2725
- }
2726
- if (he && Z.isRangeWithinRange(b, oe) && (b = null), !Z.isEqualRanges(b, nn.current)) {
2727
- if (dn(b), nn.current = b, !b) {
2728
- try {
2729
- _?.();
2730
- } catch {
2731
- }
2732
- return void Me?.();
2733
- }
2734
- pe(!1);
2735
- }
2736
- Ot.current = h, lo(p, v, e);
2737
- }, onPointerUp: (c, h) => {
2738
- Ot.current = h, Promise.resolve(pe(!0)).finally(() => {
2739
- Me?.(), dn(null), nn.current = null, wt.current = null, on(null), e.current?.focus();
2740
- });
2741
- } }), [L])), Wt = Ee(() => ({ onPointerDown: $t }), [$t]), [Ce, Ge] = Ze(null), Ae = G(null), ct = Ee(() => ({ onPointerDown: (c, h) => {
2742
- if (Ot.current = h, !e || !e.current) return !1;
2743
- const w = e.current.getViewFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY), p = w?.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
2744
- if (!p) return;
2745
- if (re?.(c, p, C) === !1) return !1;
2746
- c.stopPropagation(), on("default");
2747
- const v = w.getRelativePointFromClient(0, 0), W = ye.current?.ranges[ye.current?.ranges.length - 1] ?? Z.cellToRange(ye.current?.cell), b = w.toClipBounds(w.getRangeCoordsBounds(W)), he = { x: 0, y: 0 };
2748
- b.x - v.x > c.nativeEvent.clientX ? he.x = c.nativeEvent.clientX - (b.x - v.x) : c.nativeEvent.clientX >= b.x - v.x + b.width && (he.x = Math.max(0, c.nativeEvent.clientX - (b.x - v.x + b.width)) + 1), b.y - v.y > c.nativeEvent.clientY ? he.y = c.nativeEvent.clientY - (b.y - v.y) : c.nativeEvent.clientY >= b.y - v.y + b.height && (he.y = Math.max(0, c.nativeEvent.clientY - (b.y - v.y + b.height)) + 1), X?.(W, c.nativeEvent, h), Ae.current = { range: W, anchor: w.getAnchor(), cell: p, isMoving: !1, extrusion: he };
2749
- }, onPointerMoveOrWait: (c, h, w) => {
2750
- if (K || !e?.current || !ye.current || !Ae.current) return;
2751
- const p = c.clientX - w.clientX, v = c.clientY - w.clientY;
2752
- if (Ae.current.isMoving = Ae.current.isMoving || Math.abs(p) > Math.max(1, 2) || Math.abs(v) > Math.max(1, 2) || performance.now() - w.timeStamp > 500, !Ae.current.isMoving) return;
2753
- const W = Ae.current.anchor, b = Ae.current.extrusion;
2754
- let he = e.current.getViewFromLocation(W), oe = he.getCellCoordsFromClient(c.clientX - b.x, c.clientY - b.y, !0);
2755
- if (!oe) return;
2756
- const ie = Ae.current.cell, ge = Ae.current.range, Le = Se(), de = ge.colEnd - ge.colStart + 1, le = Math.min(Math.max(0, ie.colIndex - ge.colStart), de - 1), Et = Math.min(Le.right - de + 1, Math.max(Le.left, oe.colIndex - le)), F = ge.rowEnd - ge.rowStart + 1, ke = Math.min(Math.max(0, ie.rowIndex - ge.rowStart), F - 1), Pt = Math.min(Le.bottom - F + 1, Math.max(Le.top, oe.rowIndex - ke)), Re = { colStart: Et, colEnd: Et + de - 1, rowStart: Pt, rowEnd: Pt + F - 1 };
2757
- Z.isEqualRanges(Ce, Re) && !((Te) => !Te || !Ot.current || Ot.current.ctrlKey !== Te.ctrlKey || Ot.current.shiftKey !== Te.shiftKey || Ot.current.altKey !== Te.altKey || Ot.current.metaKey !== Te.metaKey)(c) || (Ge(Re), T?.(Re, c, h)), Ot.current = h, lo(he, oe, e);
2758
- }, onPointerUp: (c, h) => {
2759
- Ot.current = h;
2760
- const w = () => {
2761
- Ge(null), Ae.current = null, on(null), e.current?.focus();
2762
- };
2763
- if (!Ae.current) return void w();
2764
- const p = Ae.current.range, v = Ce;
2765
- S?.(p, c, h), Promise.resolve(p && v && f?.(p, v, c, h)).finally(() => {
2766
- w();
2767
- });
2768
- } }), [Ce]), Pe = On(ct), _t = Ee(() => ({ onPointerDown: Pe }), [Pe]), vt = G(null), Bt = Ee(() => {
2769
- const c = Z.isEqualSelectionCoords(C, vt.current) ? vt.current : C;
2770
- return vt.current = c, c;
2771
- }, [C]), qt = D((c) => {
2772
- let h = null, w = "br";
2773
- const p = [], v = { stroke: E, fill: ne, strokeWidth: 0.5 }, W = (de, le, Et) => {
2774
- const F = c.toClipBounds(c.getRangeCoordsBounds(de), en);
2775
- if (!F) return;
2776
- F.x = F.width > 0 ? F.x : F.x - v.strokeWidth / 2, F.y = F.height > 0 ? F.y : F.y - v.strokeWidth / 2, F.width = Math.max(F.width, v.strokeWidth), F.height = Math.max(F.height, v.strokeWidth);
2777
- const ke = { key: `selection-fill-${le}`, range: de, ...F, ...v };
2778
- if (Et) {
2779
- const Pt = c.getCellCoordsAsRangeCoords(Et);
2780
- ke.cell = Et, ke.pathBounds = c.toClipBounds(c.getRangeCoordsBounds(Pt), en), ke.pathBounds && (ke.pathBounds.width <= 0 || ke.pathBounds.height <= 0) && (delete ke.pathBounds, delete ke.cell);
2781
- }
2782
- return me(ke);
2783
- };
2784
- let b = C ? Yt(C) : null;
2785
- const he = b?.cell ? c.getCellCoordsAsRangeCoords(b?.cell) : Jl;
2786
- !b || b.ranges && b.ranges.length !== 0 || (b = { ranges: [he], rangeIndex: 0, cell: b.cell });
2787
- for (let de = 0; b && de < b.ranges.length; de++) {
2788
- const le = b.ranges[de], Et = W(le, de, de === b.rangeIndex ? b.cell : null);
2789
- Et && p.push(Et);
2790
- const F = 2, ke = 0.5, Pt = c.toClipBounds(c.getRangeCoordsBounds(le, { top: 0, left: 0, right: 0, bottom: 0 }), en);
2791
- if (Pt) {
2792
- const Re = (b.ranges.length, 4);
2793
- p.push(me({ range: le, key: `selection-inside-edge-${de}`, x: Pt.x - 1, y: Pt.y - 1, width: Math.max(Pt.width + 1, 0), height: Math.max(Pt.height + 1, 0), style: { overflow: "hidden" }, stroke: E, strokeWidth: Re }));
2794
- }
2795
- if (b.ranges.length === 1) {
2796
- const Re = c.toClipBounds(c.getRangeCoordsBounds(le), en);
2797
- if (Re) {
2798
- K || p.push(me({ range: le, key: `move-selection-hit-box-${de}`, x: Re.width > 1 ? Re.x : Re.x - (U / 2 + 1), y: Re.height > 1 ? Re.y : Re.y - (U / 2 + 1), width: Math.max(Re.width + 2, 1), height: Math.max(Re.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: Ce ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: U, ..._t }));
2799
- const Te = F;
2800
- p.push(me({ range: le, key: `selection-single-${de}`, x: Re.x - Te / 2, y: Re.y - Te / 2, width: Math.max(Re.width + Te / 2, 1), height: Math.max(Re.height + Te / 2, 1), stroke: Y, strokeWidth: Te }));
2801
- }
2802
- } else {
2803
- const Re = c.toClipBounds(c.getRangeCoordsBounds(le, { top: -1, left: -1, right: -2, bottom: -2 }), en);
2804
- Re && p.push(me({ range: le, key: `selection-multi-${de}`, x: Re.width > 1 ? Re.x : Re.x - ke / 2, y: Re.height > 1 ? Re.y : Re.y - ke / 2, width: Math.max(Re.width, ke) + 1, height: Math.max(Re.height, ke) + 1, stroke: Y, style: { overflow: "hidden" }, strokeWidth: 2 }));
2805
- }
2806
- if (b.ranges.length > 1 && de === b.rangeIndex) {
2807
- const Re = c.getCellCoordsAsRangeCoords(b.cell), Te = c.toClipBounds(c.getRangeCoordsBounds(Re, { top: 1, left: 1, right: -1, bottom: -1 }), en);
2808
- Te && p.push(me({ range: le, key: `selection-anchor-${de}`, x: Te.x, y: Te.y, width: Math.max(Te.width, ke), height: Math.max(Te.height, ke), stroke: Y, style: { overflow: "hidden" }, strokeWidth: 2 }));
2809
- }
2810
- if (de === b.ranges.length - 1) {
2811
- h = null, w = null;
2812
- const Re = le.rowStart === Se().top && le.rowEnd === Se().bottom, Te = le.colStart === Se().left && le.colEnd === Se().right, bt = c.getRangeCoordsBounds(le);
2813
- let Qt = null;
2814
- if (Re || Te) {
2815
- if (Qt = c.toClipBounds(bt, en), Object.keys(c.allViews()).length > 1) {
2816
- const eo = c.getVisibleRangeCoords(), nr = c.allViews()[uo], zi = c.allViews()[Hn], Ai = c.allViews()[Nn], to = c.getAnchor();
2817
- (Te && (to === Hn && nr || to === Xt && Ai || !Z.isCellWithinRange({ colIndex: le.colStart, rowIndex: le.rowEnd }, eo) && !Z.isCellWithinRange({ colIndex: le.colStart, rowIndex: le.rowEnd + 1 }, eo)) || Re && (to === Nn && nr || to === Xt && zi || !Z.isCellWithinRange({ colIndex: le.colEnd, rowIndex: le.rowStart }, eo) && !Z.isCellWithinRange({ colIndex: le.colEnd + 1, rowIndex: le.rowStart }, eo))) && (Qt = null);
2818
- }
2819
- } else Qt = c.toClipBounds(bt, en);
2820
- if (!Qt || Qt.width === 0 || Qt.height === 0) continue;
2821
- h = { x: Qt.x + Qt.width + 1, y: Qt.y + Qt.height + 1 }, Qt.width === 0 || Qt.height === 0 || le.rowStart === Se().top && le.colStart === Se().left && le.rowEnd === Se().bottom && le.colEnd === Se().right || (Re ? (h.y = F, w = "tr") : Te && (h.x = F, w = "bl"));
2822
- }
2823
- }
2824
- let oe = null;
2825
- if (De) {
2826
- const de = c.toClipBounds(c.getRangeCoordsBounds(De, { top: 0, left: 0, right: 0, bottom: 0 }), en);
2827
- de && (oe = me({ ...v, range: De, key: "remove-selection", x: de.x, y: de.y, width: de.width, height: de.height, strokeWidth: 2, stroke: He, fill: Ve }));
2828
- }
2829
- let ie = null;
2830
- if (Mt) {
2831
- const de = c.toClipBounds(c.getRangeCoordsBounds(Mt, { top: 0, left: 0, right: 0, bottom: 0 }), en);
2832
- de && (ie = me({ range: Mt, key: "selection-fill-outline", x: de.x - 2 / 2, y: de.y - 2 / 2, width: de.width + 2 / 2, height: de.height + 2 / 2, strokeWidth: 2, stroke: Y, strokeDasharray: "3 2" }));
2833
- }
2834
- let ge = null;
2835
- !M && h && !Ce && (ge = Jo(Mi, { ...h, corner: w, size: 7.5, borderStroke: `${E} solid`, style: { borderRadius: 1 }, background: Y, ...Wt, key: "fillHandle" }));
2836
- const Le = [...p];
2837
- if (oe && Le.push(oe), ie && Le.push(ie), ge && Le.push(ge), !Ne && Tt && b?.ranges.length === 1 && b.ranges[b.ranges.length - 1]) {
2838
- const de = b.ranges[b.ranges.length - 1], le = de.rowStart === Se().top && de.rowEnd === Se().bottom, Et = de.colStart === Se().left && de.colEnd === Se().right, F = { view: c, range: de, borderStroke: `${Y} solid`, background: E, selectionTouchPointerHandler: xo, ...at, onTouchSelectStart: (ke) => un(ke), onTouchSelectEnd: () => un(null), currentTouchAnchor: Cn };
2839
- Le.push(q(Go, { anchor: Et ? "b" : le ? "r" : "br", scrollableElement: e.current, ...F }, "touch-select-handle-after")), Le.push(q(Go, { anchor: Et ? "t" : le ? "l" : "tl", scrollableElement: e.current, ...F }, "touch-select-handle-before"));
2840
- }
2841
- if (Ce) {
2842
- const de = c.toClipBounds(c.getRangeCoordsBounds(Ce, { top: 1, left: 1, right: 1, bottom: 1 }), en);
2843
- de && Le.push(me({ range: Ce, key: "selection-move-outline", x: de.x - te / 2, y: de.y - te / 2, width: Math.max(de.width + te / 2, 1), height: Math.max(de.height + te / 2, 1), stroke: Y, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: te }));
2844
- }
2845
- return q("div", { children: Le }, "selection");
2846
- }, [Bt, De, M, Mt, K, Ce, Se, E, Y, ne, He, Ve, Ne, at, Cn]), Dt = Ee(() => {
2847
- const c = () => e.current;
2848
- return [new _e("moveToPageDown", c, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => Xn(!1)), new _e("selectToPageDown", c, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [It] }] }, () => Xn(!0)), new _e("moveToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [vn] }] }, () => Gn(!1)), new _e("selectToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [vn, It] }] }, () => Gn(!0)), new _e("moveToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => Jt(!1)), new _e("selectToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [It] }] }, () => Jt(!0)), new _e("moveToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [vn] }] }, () => $n(!1)), new _e("selectToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [vn, It] }] }, () => $n(!0)), new _e("selectColumn", c, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [zt] } }, yo), new _e("selectRow", c, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [It] } }, vo), new _e("selectToColumnStart", c, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => qn(!0)), new _e("selectToColumnEnd", c, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => Yn(!0)), new _e("moveToRowStart", c, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => Dn(!1)), new _e("selectToRowStart", c, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [It] }] }, () => Dn(!0)), new _e("moveToSheetStart", c, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [zt] }] }, () => Mn(!1)), new _e("selectToSheetStart", c, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [zt, It] }] }, () => Mn(!0)), new _e("moveToRowEnd", c, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => zn(!1)), new _e("selectToRowEnd", c, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [It] }] }, () => zn(!0)), new _e("moveToSheetEnd", c, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [zt] }] }, () => yn(!1)), new _e("selectToSheetEnd", c, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [zt, It] }] }, () => yn(!0)), new _e("scrollToActiveCoords", c, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [zt] } }, xn), new _e("scrollToActiveCoordsClearSelection", c, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [It] } }, () => {
2849
- rn(), yt(C.cell, !0);
2850
- }), new _e("traverseSelectionRight", c, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, Jn), new _e("traverseSelectionLeft", c, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [It] } }, Zn), new _e("traverseSelectionDown", c, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, Eo), new _e("traverseSelectionUp", c, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [It] }, { key: "NumpadEnter", modifiers: [It] }] }, _o), new _e("moveLeft", c, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Qn), new _e("selectLeft", c, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [It] }] }, y), new _e("moveContentfulLeft", c, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [zt] }] }, O), new _e("selectContentfulLeft", c, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [zt, It] }] }, A), new _e("moveRight", c, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, j), new _e("selectRight", c, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [It] }] }, V), new _e("moveContentfulRight", c, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [zt] }] }, fe), new _e("selectContentfulRight", c, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [zt, It] }] }, ce), new _e("moveUp", c, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, xe), new _e("selectUp", c, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [It] }] }, ve), new _e("moveContentfulUp", c, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [zt] }] }, ae), new _e("selectContentfulUp", c, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [zt, It] }] }, je), new _e("moveDown", c, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, ft), new _e("selectDown", c, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [It] }] }, Be), new _e("moveContentfulDown", c, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [zt] }] }, Fe), new _e("selectContentfulDown", c, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [zt, It] }] }, gt), new _e("selectVisible", c, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [vn] } }, bo), new _e("traverseSelectionPreviousRange", c, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [zt, vn] } }, Bn), new _e("traverseSelectionNextRange", c, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [zt, vn] } }, Io), new _e("traverseSelectionCorners", c, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [zt] } }, Co)];
2851
- }, []);
2852
- return Ee(() => {
2853
- t?.addCommands(Dt, !0);
2854
- }, [t]), { selection: Bt, setSelectionCell: yt, setSelectionRanges: mt, overlay: qt, cursor: cn, onPointerDown: mo, clearLastSelection: Xe, newSelection: tt, modifySelection: rt, appendSelection: ze, clearSelections: rn, isEntire: Lt, navigate: pt, navigateSelection: ln };
2855
- };
2856
- function ao(e, t) {
2857
- if (!e) throw new Error("Invariant failed");
2858
- }
2859
- const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, es = Object.freeze({ top: 0, left: 0 }), ts = Object.freeze({ bottom: -4, right: -4 }), ns = Object.freeze({ horizontal: !0, vertical: !0 }), Hr = [uo, Hn, Nn, Xt], ms = 150, sn = 3e3, Fo = {}, Pi = At(Ut((e, t) => {
2860
- const { width: n, height: o, rowCount: r = 1, columnCount: i = 1, defaultRowHeight: l, defaultColumnWidth: s, getRowHeight: a, getColumnWidth: d, layout: g, onViewportScroll: m, onImmediateScroll: u, showGridLines: x = !0, gridLineColor: M = "rgb(224, 224, 224)", gridLineRowsProps: E, gridLineColumnsProps: P, clipCells: Q = !0, cursor: k, freezeLeft: I = 0, freezeTop: z = 0, freezeLeftProps: se, freezeTopProps: B, cellRenderer: re, onViewportChange: be, onFirstRender: N, overlayRenderer: H, overlayProps: X, overlays: T, overlaysProps: S, allowOverlaysOverflow: f = !1, stageProps: J, stageWrapper: K = null, hiddenRowsAt: L, hiddenColumnsAt: U, hiddenCellAt: te, getVisibleCells: ne, zoom: Y = 1, enableMouseWheel: He = !0, onWheelScroll: Ve, getCellCoordsAsRangeCoords: Ne = Z.cellToRange, scrollPoint: at = es, style: Se = {}, ...Ye } = e;
2861
- ao(re), ao(!e?.children);
2862
- const $ = R(u, [u]), _ = R(be, [be]), Me = R(m, [m]), ue = R(Ve, [Ve]), me = R(N, [N]), $e = G(null), dt = G(null), kt = G(null), [ut, Zt] = Qo((y) => y + 1, 0), [St, C] = Ze({ left: at?.left ?? 0, top: at?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), ye = G(null), Je = G(St), { top: mt, left: Qe, verticalScrollDirection: cn, horizontalScrollDirection: on } = St, Mt = G(!1), dn = Bl({ rowCount: r, columnCount: i, defaultRowHeight: l, defaultColumnWidth: s, getRowHeight: a, getColumnWidth: d }), nn = G(null), De = Ee(() => {
2863
- const y = g || dn;
2864
- return nn.current = null, { getColOffset: (O) => y.getColOffset(O) * Y, getColIndex: (O) => y.getColIndex(O / Y), getRowOffset: (O) => y.getRowOffset(O) * Y, getRowIndex: (O) => y.getRowIndex(O / Y) };
2865
- }, [dn, g, Y]), Kt = (y, O, A) => {
2866
- const j = (O?.left ?? 0) + 0, V = (O?.top ?? 0) + 0;
2867
- return { getColOffset: (fe) => y.getColOffset(fe) - j, getColIndex: (fe) => y.getColIndex(fe + j), getRowOffset: (fe) => y.getRowOffset(fe) - V, getRowIndex: (fe) => y.getRowIndex(fe + V) };
2868
- }, xt = D((y, O = !1) => go(y, O, De.getRowOffset, O ? 0 : r), [r, De?.getRowOffset]), Vt = R(L ?? xt, [L]), Cn = D((y, O = !1) => go(y, O, De.getColOffset, O ? i : 0), [i, De?.getColOffset]), un = R(U ?? Cn, [U]), We = Ee(() => Math.min(n ?? 800, De.getColOffset(i)), [De.getColOffset, i, n]), ee = Ee(() => Math.min(o ?? 600, De.getRowOffset(r)), [De.getRowOffset, r, o]), et = D((y) => {
2869
- Ct.canUseDOM && setTimeout(() => {
2870
- $e.current?.focus({ preventScroll: !0, ...y });
2871
- }, 0);
2872
- }, []), Ue = D((y) => $e.current?.contains(y) || dt.current?.contains(y), []);
2873
- st(() => {
2874
- Mt.current && (ye.current && ye.current.left !== Je.current?.left && ye.current.top !== Je.current?.top || (ye.current = null, Me?.({ left: Qe, top: mt })));
2875
- }, [Qe, mt]);
2876
- const ht = R(() => ({ top: mt, left: Qe }), [mt, Qe]), Ie = Ee(() => {
2877
- const y = [];
2878
- let O = 0, A = 0;
2879
- typeof z == "number" ? O = z : (O = z.index ?? 0, A = (z.scrollOffset ?? 0) * Y);
2880
- const j = A, V = De.getRowOffset(O), fe = V - j;
2881
- if (O > 0) {
2882
- const ft = Kt(De, { top: A + De.getRowOffset(0) }), Be = De.getRowIndex(j), Fe = De.getRowIndex(V - 1);
2883
- let gt;
2884
- y[1] = { minIndex: Be, maxIndex: Fe, minCoord: 0, maxCoord: O - 1, minBounds: 0, maxBounds: fe, visibleIndices: () => gt || (gt = Object.freeze(io(Vt, Be, Fe)), gt), layout: ft, maxVirtualBounds: V, scrollOffset: A, freezeOffset: A };
2885
- }
2886
- const ce = Math.max(0, ee - fe), xe = Kt(De, { top: mt + fe }), ve = xe.getRowIndex(0), ae = xe.getRowIndex(ce);
2887
- let je;
2888
- return y[0] = { minIndex: ve, maxIndex: ae, minCoord: O, maxCoord: r - 1, minBounds: fe, maxBounds: ce, visibleIndices: () => je || (je = Object.freeze(io(Vt, ve, ae)), je), layout: xe, maxVirtualBounds: De.getRowOffset(r), scrollOffset: mt, freezeOffset: (O > 0 ? De.getRowOffset(O) : 0) - A }, y;
2889
- }, [De.getRowIndex, De.getRowOffset, Vt, ee, r, z, mt, Y]), Oe = Ee(() => {
2890
- const y = [];
2891
- let O = 0, A = 0;
2892
- typeof I == "number" ? O = I : (O = I.index ?? 0, A = (I.scrollOffset ?? 0) * Y);
2893
- const j = A, V = De.getColOffset(O), fe = V - j;
2894
- if (O > 0) {
2895
- const ft = Kt(De, { left: A + De.getColOffset(0) }), Be = De.getColIndex(j), Fe = De.getColIndex(V - 1);
2896
- let gt;
2897
- y[1] = { minIndex: Be, maxIndex: Fe, minCoord: 0, maxCoord: O - 1, minBounds: 0, maxBounds: fe, visibleIndices: () => gt || (gt = Object.freeze(io(un, Be, Fe)), gt), layout: ft, maxVirtualBounds: V, scrollOffset: A, freezeOffset: A };
2898
- }
2899
- const ce = Math.max(0, We - fe), xe = Kt(De, { left: Qe + fe }), ve = xe.getColIndex(0), ae = xe.getColIndex(ce);
2900
- let je;
2901
- return y[0] = { minIndex: ve, maxIndex: ae, minCoord: O, maxCoord: i - 1, minBounds: fe, maxBounds: ce, visibleIndices: () => je || (je = Object.freeze(io(un, ve, ae)), je), layout: xe, maxVirtualBounds: De.getColOffset(i), scrollOffset: Qe, freezeOffset: (O > 0 ? De.getColOffset(O) : 0) - A }, y;
2902
- }, [De.getColIndex, De.getColOffset, un, We, i, I, Qe, Y]), rt = G({}), tt = G([]), ze = Ee(() => {
2903
- let y = {};
2904
- const O = (j, V, fe, ce, xe) => {
2905
- const ve = { vertical: ce?.vertical || !1, horizontal: ce?.horizontal || !1 };
2906
- if (j >= Oe.length || V >= Ie.length) return null;
2907
- const ae = { rowStart: Ie[V].minIndex, colStart: Oe[j].minIndex, rowEnd: Ie[V].maxIndex, colEnd: Oe[j].maxIndex };
2908
- if (ae.rowStart > ae.rowEnd || ae.colStart > ae.colEnd) return null;
2909
- const je = { getColIndex: (Ce) => Oe[j].layout.getColIndex(Ce), getColOffset: (Ce) => Oe[j].layout.getColOffset(Ce), getRowIndex: (Ce) => Ie[V].layout.getRowIndex(Ce), getRowOffset: (Ce) => Ie[V].layout.getRowOffset(Ce) }, ft = Object.freeze({ left: xe?.left ?? 0, top: xe?.top ?? 0, right: xe?.right ?? 0, bottom: xe?.bottom ?? 0 }), Be = Object.freeze({ x: Oe[j].minBounds, y: Ie[V].minBounds, width: Oe[j].maxBounds, height: Ie[V].maxBounds }), Fe = (Ce, Ge) => Fr(je, Ce ?? ae, Ge), gt = { width: Oe[j].maxVirtualBounds, height: Ie[V].maxVirtualBounds }, Xe = { left: Oe[j].scrollOffset, top: Ie[V].scrollOffset }, Lt = { left: Oe[j].freezeOffset, top: Ie[V].freezeOffset }, yt = { width: We, height: ee };
2910
- let pe = null, wt = null;
2911
- const $t = (Lt.top + (ce.vertical ? Xe.top : 0)) / Y, Wt = (Lt.left + (ce.horizontal ? Xe.left : 0)) / Y;
2912
- return { getStage: () => $e.current ?? null, getVisibleRangeCoords: () => ae, toClipBounds: (Ce, Ge) => {
2913
- let Ae, ct = 0;
2914
- return Ge === void 0 || typeof Ge == "number" ? (Ae = Fe(ae), ct = Ge) : Ae = Ge, ((Pe, _t, vt = 0) => {
2915
- if (Pe.x > _t.width || Pe.y > _t.height) return null;
2916
- const Bt = { left: Pe.x, top: Pe.y, bottom: Pe.height + Pe.y, right: Pe.width + Pe.x }, qt = { left: _t.x + vt, top: _t.y + vt, bottom: _t.height - 2 * vt + _t.y, right: _t.width - 2 * vt + _t.x }, Dt = { left: Math.max(Bt.left, qt.left), top: Math.max(Bt.top, qt.top), bottom: Math.min(Bt.bottom, qt.bottom), right: Math.min(Bt.right, qt.right) }, c = { x: Dt.left, y: Dt.top, width: Dt.right - Dt.left, height: Dt.bottom - Dt.top };
2917
- return c.height < 0 || c.width < 0 ? null : c;
2918
- })(Ce ?? { x: 0, y: 0, width: Be.width, height: Be.height }, Ae, ct);
2919
- }, toViewBounds: (Ce) => Wt === 0 && $t === 0 && Y === 1 ? Ce : { x: (Ce.x - Wt) * Y, y: (Ce.y - $t) * Y, width: Ce.width * Y, height: Ce.height * Y }, toAbsoluteBounds: (Ce) => Wt === 0 && $t === 0 && Y === 1 ? Ce : { x: Ce.x / Y + Wt, y: Ce.y / Y + $t, width: Ce.width / Y, height: Ce.height / Y }, getRelativePointFromClient: (Ce, Ge) => {
2920
- const Ae = hn(Ce, Ge);
2921
- return { x: Ae.x - Be.x, y: Ae.y - Be.y };
2922
- }, getLayout: () => je, getCellCoordsAsRangeCoords: Ne, getVisibleColumns: () => Oe[j].visibleIndices(), getVisibleRows: () => Ie[V].visibleIndices(), getVisibleColumnOffsets: () => (pe || (pe = Br(Oe[j].layout, !0, Oe[j].visibleIndices(), ae.colStart, ae.colEnd)), pe), getVisibleRowOffsets: () => (wt || (wt = Br(Ie[V].layout, !1, Ie[V].visibleIndices(), ae.rowStart, ae.rowEnd)), wt), getTotalRangeCoords: () => ({ colStart: Oe[j].minCoord, colEnd: Oe[j].maxCoord, rowStart: Ie[V].minCoord, rowEnd: Ie[V].maxCoord }), getRangeCoordsBounds: Fe, scrollCellCoordsIntoView: (Ce, Ge) => Dn(Ce, Ge, fe), getCellCoordsFromClient: (Ce, Ge, Ae = !1) => {
2923
- const ct = hn(Ce, Ge);
2924
- if (!ct) return null;
2925
- const Pe = je.getColIndex(ct.x - Be.x), _t = { rowIndex: je.getRowIndex(ct.y - Be.y), colIndex: Pe };
2926
- if (Ae) return _t;
2927
- const vt = Ne(_t);
2928
- return { rowIndex: vt.rowStart, colIndex: vt.colStart };
2929
- }, getZoom: () => Y, getAnchor: () => fe, getBounds: () => Be, getInsets: () => ft, getTotalSize: () => gt, getViewportSize: () => yt, getScrollTopLeft: () => Xe, getFreezeTopLeft: () => Lt, getScrollOrientation: () => ve, allViews: () => y };
2930
- };
2931
- let A = y[Xt] = O(0, 0, Xt, ns, ts);
2932
- return A && (y[Xt] = A), A = O(0, 1, Hn, { horizontal: !0 }), A && (y[Hn] = A), A = O(1, 0, Nn, { vertical: !0 }), A && (y[Nn] = A), A = O(1, 1, uo, {}), A && (y[uo] = A), rt.current = null, y = Object.freeze(y);
2933
- }, [Ie, Oe, Ne]), rn = Object.keys(ze), Tt = Oe[0]?.maxVirtualBounds ?? 0, nt = Ie[0]?.maxVirtualBounds ?? 0, Rt = Ee(() => ({ left: Oe[1] ? Oe[1].layout.getColOffset(Oe[1].maxIndex + 1) : 0, top: Ie[1] ? Ie[1].layout.getRowOffset(Ie[1].maxIndex + 1) : 0 }), [ze]);
2934
- st(() => {
2935
- if (tt.current.length > 0) {
2936
- for (let y = 0; y < tt.current.length; y++) tt.current[y]();
2937
- tt.current = [];
2938
- }
2939
- }, [ze]);
2940
- const Ot = R(() => ({ containerWidth: We, containerHeight: ee, totalWidth: Tt, totalHeight: nt }), [We, ee, De]);
2941
- st(() => {
2942
- !ye.current && Mt.current && _({ top: mt, left: Qe, width: We, height: ee, totalWidth: Tt, totalHeight: nt });
2943
- }, [mt, Qe, Tt, nt]), st(() => {
2944
- Mt.current && _({ top: mt, left: Qe, width: We, height: ee, totalWidth: Tt, totalHeight: nt });
2945
- }, [We, ee]);
2946
- const hn = D((y, O) => {
2947
- ao(typeof y == "number" && typeof O == "number");
2948
- const A = $e.current?.getBoundingClientRect();
2949
- return A ? { x: y - A.x, y: O - A.y } : { x: y, y: O };
2950
- }, []), mo = R((y) => ze[y] || null, [ze]), xo = R((y, O) => {
2951
- if (Object.keys(ze).length === 1) return ze[Xt];
2952
- const A = hn(y, O);
2953
- if (!A) return null;
2954
- const { x: j, y: V } = A;
2955
- let fe = null;
2956
- const ce = Hr;
2957
- for (let xe = 0; !fe && xe < ce.length; xe++) {
2958
- const ve = ze[ce[xe]];
2959
- ve && Kl(j, V, ve.getBounds()) && (fe = ve);
2960
- }
2961
- return fe || (fe = ze[Xt]), fe;
2962
- }, [ze, Ne]), pt = R(() => ze[Xt].getVisibleRangeCoords(), [ze[Xt]]), ln = G(null), yo = D(() => {
2963
- ln.current !== null && Ct.cancelTimeout(ln.current), ln.current = Ct.requestTimeout(vo, 150);
2964
- }, []), vo = D(() => {
2965
- ln.current = null, C((y) => {
2966
- const O = { ...y, verticalScrollDirection: null, horizontalScrollDirection: null };
2967
- return Je.current = O, O;
2968
- });
2969
- }, []), xn = R((y) => {
2970
- const O = y?.left ?? y?.[0], A = y?.top ?? y?.[1], j = O !== void 0 ? Math.min(Tt - We, Math.max(Oe?.[1]?.scrollOffset ?? 0, O)) : Je.current.left, V = A !== void 0 ? Math.min(nt - ee, Math.max(Ie?.[1]?.scrollOffset ?? 0, A)) : Je.current.top;
2971
- if (Je.current.left === j && Je.current.top === V) return;
2972
- let fe = null, ce = null;
2973
- Je.current.left > j ? fe = ot : Je.current.left < j && (fe = Ke), Je.current.top > V ? ce = it : Je.current.top < V && (ce = lt), Ct.throttle(() => {
2974
- C((xe) => {
2975
- const ve = { ...xe, left: j, top: V, horizontalScrollDirection: fe, verticalScrollDirection: ce };
2976
- return Je.current = ve, ve;
2977
- });
2978
- }, 17)(), ye.current?.top === V && ye.current?.left === j || (ye.current = { left: j, top: V }, $({ left: j, top: V }), _({ left: j, top: V, width: We, height: ee, totalWidth: Tt, totalHeight: nt })), yo();
2979
- }, [Tt, nt, Ie, Oe]);
2980
- st(() => {
2981
- ye.current || xn({ left: Qe, top: mt });
2982
- }, [Tt, We, nt, ee]), tn(() => {
2983
- ye.current = { left: at?.left, top: at?.top }, xn(ye.current);
2984
- }, [at?.left, at?.top]);
2985
- const qn = R((y) => {
2986
- const O = y?.left ?? y?.[0], A = y?.top ?? y?.[1], j = y?.behavior ?? "auto", V = { left: Je.current.left + (O ?? 0), top: Je.current.top + (A ?? 0) };
2987
- j && (V.behavior = j), xn(V);
2988
- }, [Tt, We, nt, ee]), Yn = D((y) => {
2989
- let O = null;
2990
- if (Object.keys(ze).length > 1) {
2991
- const A = Hr;
2992
- for (let j = 0; !O && j < A.length; j++) {
2993
- const V = ze[A[j]];
2994
- V && Z.isCellWithinRange(y, V.getVisibleRangeCoords()) && (O = V);
2995
- }
2996
- }
2997
- return O || (O = ze[Xt]), O;
2998
- }, [ze]), Dn = R((y, O = { inline: "nearest", block: "nearest" }, A = null) => {
2999
- const j = { rowIndex: 0, colIndex: 0, ...y };
3000
- let V = null;
3001
- if (A !== null) {
3002
- if (V = ze[A], V === null) return new Promise((yt, pe) => {
3003
- pe("Invalid view");
3004
- });
3005
- } else V = Yn(j);
3006
- const fe = Ne(j), ce = V.getLayout(), xe = ce.getColOffset(fe.colStart), ve = ce.getRowOffset(fe.rowStart), ae = ce.getColOffset(fe.colEnd + 1), je = ce.getRowOffset(fe.rowEnd + 1), ft = V.getBounds(), Be = V.getTotalSize(), Fe = V.getScrollTopLeft(), gt = ((yt, pe, wt = !0) => (wt = wt === !0 ? { block: "start", inline: "end" } : wt === !1 ? { block: "end", inline: "end" } : { block: "end", inline: "end", ...wt }, { left: zr(wt.inline, yt.x, yt.x + yt.width, pe.left, pe.left + pe.width, pe.totalWidth), top: zr(wt.block, yt.y, yt.y + yt.height, pe.top, pe.top + pe.height, pe.totalHeight) }))({ x: xe + Fe.left, y: ve + Fe.top, width: ae - xe, height: je - ve }, { left: Fe.left, top: Fe.top, width: ft.width, height: ft.height, totalWidth: Be.width, totalHeight: Be.height }, O), Xe = { ...gt };
3007
- Xe.left > Qe ? Xe.left += 20 : Xe.left < Qe && (Xe.left -= 0), Xe.top > mt ? Xe.top += 20 : Xe.top < mt && (Xe.top -= 0);
3008
- const Lt = V.getScrollOrientation();
3009
- return Lt.horizontal && y.colIndex !== void 0 || delete Xe.left, Lt.vertical && y.rowIndex !== void 0 || delete Xe.top, new Promise((yt, pe) => {
3010
- try {
3011
- xn(Xe), yt(Xe);
3012
- } catch (wt) {
3013
- pe(wt);
3014
- }
3015
- });
3016
- }, [Tt, nt, ze, Ne]), Mn = R((y) => {
3017
- const O = y.shiftKey;
3018
- y.preventDefault();
3019
- const { deltaX: A, deltaY: j, deltaMode: V } = y;
3020
- if (kt.current || ue?.(y) === !1) return;
3021
- let ce = O ? j : A, xe = j;
3022
- const ve = O || Math.abs(ce) > Math.abs(xe);
3023
- V === 1 && (xe *= 0), kt.current = window.requestAnimationFrame(() => {
3024
- kt.current = null, qn(ve ? { left: ce } : { top: xe });
3025
- });
3026
- }, [Tt, We, nt, ee, ue]), zn = D((y = null) => {
3027
- nn.current = null, rt.current = null, Zt();
3028
- }, []);
3029
- tn(() => {
3030
- zn();
3031
- }, [re]);
3032
- const yn = wo(t, () => ({ stage: $e.current, focus: et, contains: Ue, invalidate: zn, scrollTo: xn, scrollBy: qn, scrollCellCoordsIntoView: Dn, getScrollPosition: ht, getDimensions: Ot, getViewport: pt, handleWheel: Mn, rowCount: r, columnCount: i, getLayout: () => De, getRelativePointFromClient: hn, getViewFromClient: xo, getViewFromCellCoords: Yn, getViewFromLocation: mo, onViewChangeOnce: (y) => {
3033
- tt.current.push(y);
3034
- } }), [r, i, ze]);
3035
- st(() => (He && yn.current?.addEventListener("wheel", Mn, { passive: !1 }), Mt.current = !0, ye.current = null, () => {
3036
- yn.current?.removeEventListener("wheel", Mn);
3037
- }), [He]);
3038
- const An = G([]), bo = (y, O) => {
3039
- !y || !H || (An.current = [], O.push(((A, j) => {
3040
- const V = `view:${A.getAnchor()}:overlay:${O.length}`, fe = H?.({ key: V, view: A }, (xe) => An.current[j] = xe);
3041
- if (!fe) return null;
3042
- const ce = A.getBounds();
3043
- return q("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${ce.width}px`, height: `${ce.height}px`, overflow: "hidden" }, children: fe }, `overlay-${A.getAnchor()}-${j}`);
3044
- })(y, 0)));
3045
- }, So = Ee(() => {
3046
- const y = {}, O = Object.keys(ze);
3047
- for (let A = 0; A < O.length; A++) {
3048
- const j = O[A], V = [];
3049
- bo(ze[j], V), y[j] = { overlays: V };
3050
- }
3051
- return y;
3052
- }, [ut, H, r, i, Ie, Oe]), Xn = (y, O, A, j, V, fe, ce) => {
3053
- if (!y) return;
3054
- const xe = y.getVisibleColumns(), ve = y.getVisibleRows();
3055
- if (xe.length === 0 || ve.length === 0) return;
3056
- let ae = null;
3057
- if (ne) ae = ne(y);
3058
- else {
3059
- ae = [];
3060
- for (let Ge = 0; Ge < ve.length; Ge++) for (let Ae = 0; Ae < xe.length; Ae++) {
3061
- const ct = { rowIndex: ve[Ge], colIndex: xe[Ae] };
3062
- if (te?.(ct)) continue;
3063
- const Pe = { coords: ct, range: Ne(ct) };
3064
- ae.push(Pe);
3065
- }
3066
- }
3067
- const je = y.getVisibleColumnOffsets(), ft = y.getVisibleRowOffsets(), Be = y.getScrollTopLeft(), Fe = y.getFreezeTopLeft(), gt = Be.left + Fe.left, Xe = Be.top + Fe.top, Lt = Math.trunc(gt / sn), yt = Math.trunc(Xe / sn), pe = {}, wt = (Ge, Ae, ct, Pe, _t) => {
3068
- const vt = `view:${Ge.getAnchor()}:cell:${Dr(Ae.rowIndex, Ae.colIndex)}`, Bt = Pe.x, qt = Pe.y, Dt = Math.trunc((gt + Bt) / sn) - Lt, c = Math.trunc((Xe + qt) / sn) - yt;
3069
- pe[c] || (pe[c] = {});
3070
- let h = pe[c][Dt];
3071
- h || (h = pe[c][Dt] = []);
3072
- let w = fe?.get(vt);
3073
- if (!w) {
3074
- const p = (gt + Bt) % sn, v = (Xe + qt) % sn;
3075
- w = re({ key: vt, coords: Ae, bounds: Pe, zoom: Y, range: ct, view: Ge, value: _t, style: { left: we.boundPixel(p), top: we.boundPixel(v), width: we.boundPixel(Pe.width, !0), height: we.boundPixel(Pe.height, !0) } });
3076
- }
3077
- ce?.set(vt, w), h.push(w);
3078
- };
3079
- for (let Ge = 0; ae && Ge < ae.length; Ge++) {
3080
- const Ae = ae[Ge], ct = Ae?.coords ?? Ae;
3081
- if (!ct) continue;
3082
- const Pe = Ae?.range ?? { rowStart: ct.rowIndex, colStart: ct.colIndex, rowEnd: ct.rowIndex, colEnd: ct.colIndex }, _t = y.getVisibleRangeCoords();
3083
- if (!Z.isRangesIntersect(Pe, _t) && !Z.isRangeWithinRange(Pe, _t)) continue;
3084
- const vt = Pe && !Z.isSingleCell(Pe);
3085
- if (!vt && te?.(ct)) continue;
3086
- const Bt = ct.rowIndex, qt = ct.colIndex, Dt = ft[Bt], c = je[qt];
3087
- let h = null;
3088
- Dt && c && (h = { x: c.offset, y: Dt.offset, width: c.size, height: Dt.size });
3089
- const w = Dr(Pe.rowStart, Pe.colStart);
3090
- if (vt) {
3091
- if (V.has(w)) continue;
3092
- V.add(w), Pe.rowEnd - Pe.rowStart > 0 && A.push(Pe), Pe.colEnd - Pe.colStart > 0 && j.push(Pe);
3093
- }
3094
- if (vt && (h = Fr(y.getLayout(), Pe)), !h) {
3095
- console.warn("no bounds for cell", w);
3096
- continue;
3097
- }
3098
- const p = Ae?.value;
3099
- wt(y, ct, Pe, h, p);
3100
- }
3101
- const $t = gt % sn, Wt = Xe % sn, Ce = Object.keys(pe);
3102
- for (let Ge = 0; Ge < Ce.length; Ge++) {
3103
- const Ae = pe[Ce[Ge]];
3104
- if (!Ae) continue;
3105
- const ct = Object.keys(Ae);
3106
- for (let Pe = 0; Pe < ct.length; Pe++) {
3107
- const _t = Ae[ct[Pe]];
3108
- if (!_t) continue;
3109
- const vt = parseInt(Ce[Ge]), Bt = parseInt(ct[Pe]), qt = vt + yt, Dt = Bt + Lt, c = `view:${y.getAnchor()}:segment:${Dt}:${qt}`;
3110
- O.push(q("div", { className: "cell-container", style: { transform: `translate(${we.boundPixel(Bt * sn - $t, !0)}px, ${we.boundPixel(vt * sn - Wt, !0)}px)`, willChange: "transform" }, children: _t }, c));
3111
- }
3112
- }
3113
- }, Jt = Ee(() => {
3114
- const y = nn.current, O = /* @__PURE__ */ new Map(), A = {}, j = Object.keys(ze);
3115
- for (let V = 0; V < j.length; V++) {
3116
- const fe = j[V], ce = [], xe = [], ve = [];
3117
- Xn(ze[fe], ve, ce, xe, /* @__PURE__ */ new Set(), y, O), A[fe] = { cells: ve, rangesH: ce, rangesV: xe };
3118
- }
3119
- return nn.current = O, A;
3120
- }, [ut, r, i, Ie, Oe, x, Se, Q, te, ne, Ne]), Gn = (y, O, A, j, V) => {
3121
- if (y) if (O) {
3122
- const fe = `view:${y.getAnchor()}:hl:`, ce = y.getVisibleRows();
3123
- if (!ce || ce.length === 0) return;
3124
- const xe = 0, ve = y.getBounds().width;
3125
- let ae = [];
3126
- const je = V.sort(Z.rowFirstRangeComparator), ft = y.getVisibleRangeCoords();
3127
- for (let Be = 0; Be < ce.length && ce[Be] <= ft.rowEnd; Be++) {
3128
- const Fe = ce[Be];
3129
- if (Fe < ft.rowStart) continue;
3130
- let gt = !1;
3131
- for (; je.length > 0 && je[0].rowStart <= Fe; ) {
3132
- const pe = je.shift();
3133
- pe.rowEnd > Fe && (ae.push(pe), gt = !0);
3134
- }
3135
- gt && (ae = ae.sort(Z.columnFirstRangeComparator));
3136
- const Xe = y.getLayout(), Lt = Xe.getRowOffset(Fe + 1);
3137
- let yt = xe;
3138
- for (let pe = 0; pe < ae.length + 1; pe++) {
3139
- let wt = yt, $t = ve;
3140
- const Wt = ae[pe];
3141
- pe < ae.length && ($t = Math.min(ve, Xe.getColOffset(Wt.colStart)), yt = Math.min(ve, Xe.getColOffset(Wt.colEnd + 1))), j.push(Jo("path", { d: `M ${we.boundPixel(wt)} ${we.boundPixel(Lt, !1, A)} L ${we.boundPixel($t)} ${we.boundPixel(Lt, !1, A)}`, stroke: M, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...E, key: fe + Fe + ":" + pe }));
3142
- }
3143
- for (let pe = ae.length - 1; pe >= 0; pe--) ae[pe].rowEnd <= ce[Be + 1] && ae.splice(pe, 1);
3144
- }
3145
- } else {
3146
- const fe = `view:${y.getAnchor()}:vl:`, ce = y.getVisibleColumns();
3147
- if (!ce || ce.length === 0) return;
3148
- const xe = 0, ve = y.getBounds().height;
3149
- let ae = [];
3150
- const je = V.sort(Z.columnFirstRangeComparator), ft = y.getVisibleRangeCoords();
3151
- for (let Be = 0; Be < ce.length && ce[Be] <= ft.colEnd; Be++) {
3152
- const Fe = ce[Be];
3153
- if (Fe < ft.colStart) continue;
3154
- let gt = !1;
3155
- for (; je.length > 0 && je[0].colStart <= Fe; ) {
3156
- const pe = je.shift();
3157
- pe.colEnd > Fe && (ae.push(pe), gt = !0);
3158
- }
3159
- gt && (ae = ae.sort(Z.rowFirstRangeComparator));
3160
- const Xe = y.getLayout(), Lt = Xe.getColOffset(Fe + 1);
3161
- let yt = xe;
3162
- for (let pe = 0; pe < ae.length + 1; pe++) {
3163
- let wt = yt, $t = ve;
3164
- const Wt = ae[pe];
3165
- pe < ae.length && ($t = Math.min(ve, Xe.getRowOffset(Wt.rowStart)), yt = Math.min(ve, Xe.getRowOffset(Wt.rowEnd + 1)));
3166
- let Ce = M;
3167
- j.push(q("path", { d: `M ${we.boundPixel(Lt, !1, A)} ${we.boundPixel(wt)} L ${we.boundPixel(Lt, !1, A)} ${we.boundPixel($t)}`, stroke: Ce, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...P }, fe + Fe + ":" + pe));
3168
- }
3169
- for (let pe = ae.length - 1; pe >= 0; pe--) ae[pe].colEnd <= ce[Be + 1] && ae.splice(pe, 1);
3170
- }
3171
- }
3172
- }, $n = (y) => {
3173
- if (!Jt) return;
3174
- const O = {};
3175
- for (let A = 0; A < rn.length; A++) {
3176
- const j = rn[A], V = ze[j], fe = [];
3177
- Gn(V, y, 0, fe, y ? Jt[j].rangesH : Jt[j].rangesV);
3178
- const ce = V.getRangeCoordsBounds(), xe = Math.ceil(ce.width), ve = Math.ceil(ce.height);
3179
- O[j] = q("svg", { width: `${xe}`, height: `${ve}`, viewBox: `0 0 ${xe} ${ve}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: fe });
3180
- }
3181
- return O;
3182
- }, Zn = Ee(() => x === !0 || x?.horizontal === !0 ? $n(!0) : null, [ut, x, Ie, z, I, M, E, r, i, We, Tt, Jt]), Jn = Ee(() => x === !0 || x?.vertical === !0 ? $n(!1) : null, [ut, x, Oe, z, I, M, P, r, i, ee, nt, Jt]), _o = Ee(() => Rt.left === 0 ? null : q(jr, { linePoints: [0, 0, 0, ee + 1], bounds: { x: Rt.left, y: 0, width: 1, height: ee + 1 }, ...se }), [ut, Rt.left, ee, se]), Eo = Ee(() => Rt.top === 0 ? null : q(jr, { linePoints: [0, 0, We + 1, 0], bounds: { x: 0, y: Rt.top, width: We + 1, height: 1 }, ...B }), [ut, Rt.top, We, B]), Bn = Ee(() => {
3183
- const y = [], O = (A) => {
3184
- if (!A || !ze[A]) return;
3185
- const j = ze[A].getBounds();
3186
- return Ht("div", { style: { position: "absolute", pointerEvents: "none", left: j.x, top: j.y, width: j.width, height: j.height, clip: `rect(0, ${j.width + 1}px, ${j.height + 1}px, 0)` }, className: `view view-${A}`, children: [Zn?.[A], Jn?.[A], Jt?.[A].cells] }, `view:${A}`);
3187
- };
3188
- for (let A = 0; A < rn.length; A++) y.push(O(rn[A]));
3189
- return q(wn, { children: y });
3190
- }, [ze, Zn, Jn, Jt]), Io = Ee(() => {
3191
- if (!t) return;
3192
- const y = (ce, xe, ve, ae) => {
3193
- if (!ae || ae.length === 0) return;
3194
- const je = [];
3195
- for (let ft = 0; ft < ae.length; ft++) {
3196
- const Be = ae[ft];
3197
- let Fe = ce?.get(Be);
3198
- Fe !== Fo && (Fe = Be(ve) ?? Fo), xe.set(Be, Fe), Fe && Fe !== Fo && je.push(Fe);
3199
- }
3200
- return je;
3201
- }, O = (ce, xe, ve) => {
3202
- if (!ve) return;
3203
- const ae = ve.getBounds(), je = ve.getInsets(), ft = ve.getAnchor();
3204
- return Ht("div", { className: _n("view", `view-${ft}`, Wr.view), style: { position: "absolute", pointerEvents: "none", left: ae.x - je.left, top: ae.y - je.top, width: ae.width - (je.left + je.right), height: ae.height - (je.top + je.bottom), clipPath: f ? "inset(-2px)" : "inset(0px)" }, children: [y(ce, xe, ve, T), So?.[ft].overlays] }, `view:${ft}`);
3205
- }, A = rt.current, j = {}, V = [], fe = Object.keys(ze);
3206
- for (let ce = 0; ce < fe.length; ce++) {
3207
- const xe = fe[ce], ve = A?.[xe], ae = j[xe] = /* @__PURE__ */ new Map();
3208
- V.push(O(ve, ae, ze[xe]));
3209
- }
3210
- return rt.current = j, V;
3211
- }, [ut, ze, f, T]), Co = Ee(() => {
3212
- const { style: y, ...O } = J ?? {};
3213
- return q("div", { style: { width: We, height: ee, ...y }, className: "sheetxl-stage", tabIndex: 0, ref: $e, ...O, ...Ye, children: K ? K(Bn) : Bn });
3214
- }, [We, ee, Bn, J, K]), Qn = G(!1);
3215
- return st(() => {
3216
- !Qn.current && Jt && (Qn.current = !0, me?.(yn.current));
3217
- }, [Jt]), Ht("div", { className: _n("sheetxl-grid", Wr["sheetxl-grid"]), style: { overflow: "visible", cursor: k, maxWidth: We, maxHeight: ee, width: We, height: ee, ...Se }, ref: yn, children: [Co, Ht("div", { className: _n("sheetxl-overlays"), ref: dt, ...S, children: [Io, _o, Eo] })] });
3218
- }));
3219
- Pi.displayName = "BaseGrid";
3220
- const Oi = At(Ut((e, t) => {
3221
- const { width: n, height: o, style: r = {}, className: i, ...l } = e, [s, { width: a, height: d }] = Ri();
3222
- return q("div", { className: i, style: { ...r }, children: q("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: s, children: q(Pi, { ref: t, width: n ?? a, height: o ?? d, ...l }) }) });
3223
- }));
3224
- Oi.displayName = "Grid";
3225
- const os = At(Ut((e, t) => {
3226
- const { showVerticalScrollbar: n, showHorizontalScrollbar: o, createHorizontalScrollbar: r, createVerticalScrollbar: i, createScrollCorner: l, viewport: s, onScrollViewport: a, style: d = {}, className: g, onScroll: m, ...u } = e, [x, M] = Ze(null), E = G(null), P = G(null);
3227
- ao(!s), Ur(t, () => P.current && E.current ? Object.assign(P.current, E.current) : null);
3228
- const Q = D((k) => {
3229
- P.current?.scrollTo(k), a?.(k);
3230
- }, []);
3231
- return q(yi, { className: g, style: d, ref: E, showVerticalScrollbar: n, showHorizontalScrollbar: o, createHorizontalScrollbar: r, createVerticalScrollbar: i, createScrollCorner: l, viewport: x, onScrollViewport: Q, children: q(Oi, { style: { width: "100%", height: "100%" }, ...u, onViewportChange: (k) => M(k), ref: P }) });
3232
- }));
3233
- os.displayName = "ScrollableGrid";
3234
- const Nr = () => !1, rs = At((e) => {
3235
- const { index: t, value: n, zoom: o, zoomScale: r = 100, headerText: i = (T) => `${T}`, headerStyle: l, headerStyleSelect: s = l, headerStyleSelectAll: a = s, headerStyleHover: d = a, verticalPadding: g = 0, horizontalPadding: m = 0, isSelected: u = Nr, isSelectedAll: x = Nr, coords: M, bounds: E, range: P, orientation: Q, view: k, style: I, ...z } = e, se = r / 100, B = G(null), [re, be] = Ze(!1), N = u?.(t) || !1, H = x?.(t) ? a : N ? s : l;
3236
- let X = H;
3237
- if (re) {
3238
- let T = d;
3239
- typeof d == "function" && (T = d(H)), X = Ct.mergeContentful(H, T);
3240
- }
3241
- return q("div", { ref: B, style: { background: X.fill, color: X.text?.fill, fontFamily: X.text?.fontFamily ?? l.text?.fontFamily, fontSize: 96 * (X.text?.fontSize ?? 11) / 72 * se, fontStyle: X.text?.fontStyle, fontWeight: X.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${se}px`, ...I, left: I.left - (Q === Nt ? 1 : 0), top: I.top - (Q === an ? 1 : 0), width: I.width + 1, height: I.height + 1, overflow: "hidden" }, ...z, onMouseMove: (T) => {
3242
- we.detectIt().primaryInput !== "touch" && T.buttons === 0 && be(!0);
3243
- }, onMouseOut: (T) => {
3244
- be(!1);
3245
- }, children: i(t) });
3246
- });
3247
- rs.displayName = "HeaderRenderer";
3248
- const Li = "ew-resize", Di = "ns-resize", is = At(Ut((e, t) => {
3249
- const { orientation: n, view: o, index: r, className: i, style: l, disabled: s = !1, disabledResize: a = !1, isNextHidden: d, isHidden: g, isSelected: m, isSelectedAll: u, showTouchDivider: x, headerStyle: M, headerStyleSelect: E, headerStyleSelectAll: P, headerStyleHover: Q, bounds: k, onPointerDown: I, onAutoFit: z, ...se } = e, B = n === Nt;
3250
- let re = M;
3251
- m && E && (re = E), u && P && (re = P);
3252
- const be = we.detectIt().primaryInput === "touch";
3253
- let N = B ? 14 : 8, H = N / 2, X = 0;
3254
- d && (X = -2), g && (X = 2), g && (N = N / 2 + X, H = 2 * X);
3255
- let T = re.dividerStrokeFill ?? re.strokeFill;
3256
- return !(m || u) && X === 0 && (T = `linear-gradient(${B ? 180 : 90}deg, ${re.fill}, ${T} 55%, ${T} 100%)`), Ht("div", { className: _n("header-divider", { disabled: s }, i, `index-${r}`), ref: t, onPointerDown: be ? void 0 : I, onDoubleClick: be ? void 0 : () => z?.(), style: { top: (B ? 0 : -N / 2 + (X - 1)) + "px", left: (B ? -N / 2 + (X - 1) : 0) + "px", width: B ? N : "calc(100% + 1px)", height: B ? "calc(100% + 1px)" : N, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: s || a || be ? void 0 : B ? Li : Di, ...l }, ...se, children: [q("div", { style: { position: "relative", top: `${B ? 0 : H}px`, left: `${B ? H : 0}px`, width: B ? 1 : "100%", height: B ? "100%" : 1, background: T }, onDoubleClick: () => z?.() }), x && be ? q("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: B ? "-6px" : "2px", bottom: B ? "2px" : "-9px", height: "24px", width: B ? "24px" : "18px", maxHeight: B ? "calc(100% - 4px)" : void 0, maxWidth: B ? void 0 : "calc(100% - 4px)", background: re.fill, border: `${P.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${M.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: I, children: q("div", { style: { width: "6.4px", height: "12px", backgroundImage: `url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(E.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`, backgroundRepeat: "no-repeat", backgroundPosition: "center", transform: B ? void 0 : "rotate(90deg)" } }) }) : null] });
3257
- })), ls = (e, t) => q(is, { ...e, ref: t }), xs = At(Ut((e, t) => {
3258
- const { orientation: n, view: o, index: r, disabled: i = !1, disabledResize: l = !1, resizeThreshold: s = 1, dividerRenderer: a = ls, onDividerMouseDown: d, onDividerResizeStart: g, onDividerResize: m, onDividerResizeEnd: u, onDividerMouseUp: x, onDividerAutoFit: M, onPointerDown: E, ...P } = e, Q = R(E, [E]), k = R(M, [M]), I = n === Nt;
3259
- let z = I ? o.getVisibleColumns() : o.getVisibleRows(), se = null;
3260
- z.length > 0 && (I ? se = o.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: z[0], colEnd: z[z.length - 1] }) : o.getRangeCoordsBounds({ rowStart: z[0], rowEnd: z[z.length - 1], colStart: 0, colEnd: 0 }), se = o.toClipBounds(se, en));
3261
- const B = G(null), [re, be] = Ze(null), N = (L, U) => I ? L.clientX - U.clientX : L.clientY - U.clientY, H = o.getLayout(), X = I ? H.getColOffset(r + 1) : H.getRowOffset(r + 1), T = On({ processTouch: !0, onPointerDown: (L) => {
3262
- if (Q?.(L), !i && !l) {
3263
- const U = I ? H.getColOffset(r) : H.getRowOffset(r), te = X - U;
3264
- B.current = { isResizing: !1, startSize: te, index: r, view: o, orientation: n, onDividerMouseDown: d, onDividerResizeStart: g, onDividerResize: m, onDividerResizeEnd: u, onDividerMouseUp: x }, be(B.current), d?.(r, te);
3265
- }
3266
- L.stopPropagation(), L.preventDefault();
3267
- }, onPointerUp: (L, U, te) => {
3268
- if (!B.current) return;
3269
- B.current.isResizing && B.current.onDividerResizeEnd?.(B.current.index, Math.max(0, B.current.startSize + N(L, te)), B.current.startSize);
3270
- const ne = B.current;
3271
- B.current = null, be(B.current), ne.onDividerMouseUp?.(ne.index);
3272
- }, onPointerMoveOrWait: (L, U, te) => {
3273
- if (!B.current) return;
3274
- const ne = N(L, te);
3275
- B.current.isResizing ? B.current.onDividerResize?.(B.current.index, Math.max(0, B.current.startSize + ne), B.current.startSize) : Math.abs(ne) > Math.max(1, s) && (B.current = { ...B.current, isResizing: !0 }, be(B.current), B.current.onDividerResizeStart?.(B.current.index, Math.max(0, B.current.startSize + ne))), L.stopPropagation(), L.preventDefault();
3276
- } }), S = R(() => {
3277
- k?.(r);
3278
- }, [r]);
3279
- if (!se) return;
3280
- const f = a({ bounds: se, orientation: n, view: o, index: r, disabled: i, disabledResize: l, onAutoFit: S, onPointerDown: T, ...P }, t);
3281
- if (!f) return;
3282
- const { getPortalContainer: J } = vi();
3283
- let K = null;
3284
- return re && re.isResizing && re.index === r && (K = qr(q("div", { style: { position: "absolute", cursor: I ? Li : Di, left: 0, top: 0, width: "100%", height: "100%" } }), J(), "divider:" + r)), Ht(wn, { children: [K, q("div", { className: _n("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${I ? se.y : X}px`, left: `${I ? X : se.x}px`, width: (I ? 0 : se.width - 1) + "px", height: (I ? se.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: f })] });
3285
- }));
3286
- class ss {
3287
- naturalDimensions(t, n = {}) {
3288
- const o = document.createElement("div");
3289
- let r = n?.lineHeight ?? "1";
3290
- !n?.lineHeight && n.paintableText?.fontSize && (r = Math.ceil(1.2 * n.paintableText.fontSize) + "px");
3291
- const i = document.createElement("div");
3292
- i.style.visibility = "hidden", i.style.position = "absolute", i.style.textRendering = "geometricprecision", i.style.display = "inline-grid", i.style.overflowWrap = "break-word", i.style.maxWidth = n.maxWidth ? n.maxWidth + "px" : "100%", i.style.lineHeight = r, i.style.letterSpacing = (n.paintableText?.letterSpacing ?? 0) + "px", i.style.fontSize = n.paintableText?.fontSize ? n.paintableText.fontSize + "px" : "unset", i.style.fontFamily = n.paintableText?.fontSize ? n.paintableText.fontFamily : "unset", i.style.fontWeight = n.paintableText?.fontWeight ? "" + n.paintableText.fontWeight : "400", i.style.fontStyle = n.paintableText?.fontStyle ? n.paintableText.fontStyle : "normal", i.style.whiteSpace = n.paintableText?.wrap === "wrap" ? "break-spaces" : "pre", o.appendChild(i);
3293
- const l = t.split(`
3294
- `);
3295
- for (let a = 0; a < l.length; a++) {
3296
- let d = document.createElement("span");
3297
- i.appendChild(d), d.textContent = l[a];
3298
- }
3299
- l.length !== 0 && l[l.length - 1].length !== 0 || i.appendChild(document.createElement("br")), document.body.appendChild(i);
3300
- let s = i.getBoundingClientRect();
3301
- return i.remove(), { width: s.width, height: s.height, maxLineHeight: 1.2 * (n.paintableText?.fontSize || 1056 / 72) };
3302
- }
3303
- }
3304
- const cs = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1 }), as = cs(), ys = At(Ut((e, t) => {
3305
- const { editState: n = as, defaultTextStyle: o, onStartEdit: r, onChangeEdit: i, onSubmitEdit: l, onCancelEdit: s, onDoneEdit: a, containerBounds: d, setNaturalDimensions: g, onNavigate: m, textProperties: u, style: x, autoFocus: M, ...E } = e, P = G(null), { width: Q = 0 } = d ?? {}, [k, I] = Ze(() => n);
3306
- st(() => {
3307
- I(n);
3308
- }, [n]);
3309
- const z = u?.align || "left", se = u?.vAlign || "middle", B = u?.fill || "#040404", re = u?.wrap || "wrap", be = u?.fontFamily || "Calibri", N = u?.fontSize || 11, H = u?.fontWeight || 400, X = u?.fontStyle || "normal", T = k.dirty ?? k.clean ?? "";
3310
- let S = 2;
3311
- const f = 96 * N / 72, J = 1.2 * f;
3312
- se === "right" && (S += 1);
3313
- const K = Ee(() => new ss().naturalDimensions(T, { maxWidth: re === "wrap" ? Q - S : void 0, lineHeight: `${J}px`, paintableText: { fontStyle: X, wrap: re, letterSpacing: -0.25 } }), [T, re, S, f, be, H, X, g, Q]), L = D(() => K.maxLineHeight ? K.maxLineHeight + "px" : "1.2", [K]), [U, te] = Ze(L);
3314
- tn(() => {
3315
- te(L());
3316
- }, [d, K]), tn(() => {
3317
- g?.({ width: re === "wrap" ? void 0 : K.width + S, height: K.height });
3318
- }, [K, g]);
3319
- const ne = R(i, [i]), Y = R((_) => {
3320
- if (k.dirty === _) return;
3321
- const Me = { ...k };
3322
- Me.dirty = _, P.current, I(Me), ne?.(Me);
3323
- }, [k]), He = R((_) => {
3324
- if (k.editMode === _) return;
3325
- const Me = { ...k };
3326
- Me.editMode = _, I(Me), ne?.(Me);
3327
- }, [k]), Ve = R(() => {
3328
- try {
3329
- return l?.(k), a?.(), !0;
3330
- } catch {
3331
- return !1;
3332
- }
3333
- }, [l, k]), Ne = R(() => {
3334
- I(n), s?.(), a?.();
3335
- }, [s, n]), at = R((_) => {
3336
- if (!P.current) return;
3337
- if (_.isDefaultPrevented(), !(_.isTrusted || _.nativeEvent.ctrlKey || _.nativeEvent.metaKey || _.nativeEvent.altKey || _.nativeEvent.isComposing) && Ei.indexOf(_.nativeEvent.key) !== -1) {
3338
- const ue = { ...k };
3339
- return ue.dirty = _.nativeEvent.key === "Backspace" ? "" : (ue.dirty ?? "") + _.key, I(ue), ne?.(ue), void _.preventDefault();
3340
- }
3341
- const Me = _.nativeEvent.shiftKey;
3342
- if (_.which === tl) return _.preventDefault(), void Ne();
3343
- if (_.which === nl) return He(!0), void _.preventDefault();
3344
- if (_.which === si && (_.preventDefault(), Ve() && m?.(Me ? it : lt)), _.which === li) return _.preventDefault(), void (Ve() && m?.(Me ? ot : Ke));
3345
- if (!k.editMode) {
3346
- let ue = null;
3347
- switch (_.which) {
3348
- case ci:
3349
- ue = ot;
3350
- break;
3351
- case di:
3352
- ue = Ke;
3353
- break;
3354
- case ai:
3355
- ue = it;
3356
- break;
3357
- case ui:
3358
- ue = lt;
3359
- }
3360
- if (ue) return void Ve();
3361
- }
3362
- }, [k, m]), [Se, Ye] = Ze(!M);
3363
- st(() => {
3364
- Ye(!1);
3365
- }, []);
3366
- const $ = wo(t, () => ({ startEdit(_) {
3367
- let Me = _?.initialSelection;
3368
- if (!Me) {
3369
- const me = P.current.value.length ?? 0;
3370
- Me = { start: me, end: me, direction: "forward" };
3371
- }
3372
- P.current?.setSelectionRange(Me.start, Me.end, Me.direction);
3373
- const ue = { ...n, editMode: _?.editMode ?? !1 };
3374
- _?.text !== void 0 && (ue.dirty = _.text), ue.editMode === n.editMode && ue.dirty === n.dirty || (I(ue), ne?.(ue));
3375
- }, submitEdit: () => Ve(), cancelEdit() {
3376
- Ne();
3377
- }, autoFocus() {
3378
- P.current?.focus();
3379
- }, getLineHeight: () => K?.maxLineHeight ?? J, dispatchEvent: (_) => P.current.dispatchEvent(_) }), [n, r]);
3380
- return q("div", { ref: $, ...E, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: K.height, maxWidth: "100%", maxHeight: "100%", ...x }, children: q("textarea", { spellCheck: "false", ref: P, value: T, autoFocus: !1, disabled: Se, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${f}px`, fontFamily: `${be}`, fontWeight: `${H}`, fontStyle: `${X}`, padding: "0px", marginRight: z === "right" ? "3px" : "0px", marginLeft: z === "left" ? "2px" : "0px", lineHeight: U, height: K.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: z, background: "transparent", color: B, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: re === "wrap" ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (_) => {
3381
- Y(_.target.value);
3382
- }, onDoubleClick: (_) => {
3383
- _.isTrusted;
3384
- }, onMouseDown: (_) => {
3385
- He(!0);
3386
- }, onKeyDown: at }) });
3387
- })), vs = At((e) => {
3388
- const { value: t, view: n, bounds: o, range: r, zoom: i, children: l, style: s, ...a } = e;
3389
- return q("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: s?.fontSize || 1056 / 72, ...s }, ...a, children: t });
3390
- });
3391
- export {
3392
- Pi as BaseGrid,
3393
- ys as DefaultCellEditor,
3394
- vs as DefaultCellRenderer,
3395
- is as DefaultHeaderDivider,
3396
- Mi as FillHandle,
3397
- Oi as Grid,
3398
- xs as HeaderDivider,
3399
- rs as HeaderRenderer,
3400
- ms as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
3401
- en as SELECTION_CLIP_INSETS,
3402
- Ei as STANDARD_KEY_CHARS,
3403
- jr as SVGLine,
3404
- ql as SVGRect,
3405
- os as ScrollableGrid,
3406
- Ii as Selection,
3407
- Go as TouchSelectHandle,
3408
- Yl as defaultSelectionRenderer,
3409
- cs as getDefaultStringEditState,
3410
- Yt as safeSelectionCoords,
3411
- Bl as useCellLayout,
3412
- gs as useHeaderSelection,
3413
- ps as useKeyboardEditorOverlay,
3414
- ws as useSelection
3415
- };
13
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import o,{memo as r,useCallback as i,useRef as l,useEffect as s,useImperativeHandle as c,forwardRef as a,useMemo as d,useLayoutEffect as u,useState as h,version as f,createElement as p,useReducer as g}from"react";import{createRoot as w}from"react-dom/client";import{unstable_batchedUpdates as m,createPortal as x}from"react-dom";const y="up",v="down",b="left",S="right",_="tl",E="t",I="l",C="c",M="text/html",T="text/plain",k="image/png",R=Object.freeze({left:0,top:0}),P=Object.freeze({left:0,top:0,bottom:0,right:0}),O=Object.freeze({x:0,y:0,width:0,height:0});Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:O,EmptyRect:P,EmptyTopLeft:R},Symbol.toStringTag,{value:"Module"}));const L="column",D="row",z=Object.freeze({colIndex:0,rowIndex:0}),A=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),$=(e,t)=>e.colStart===t.colStart?e.rowStart-t.rowStart:e.colStart-t.colStart,B=(e,t)=>e.rowStart===t.rowStart?e.colStart-t.colStart:e.rowStart-t.rowStart,F=(e,t)=>e.rowEnd===t.rowEnd?t.colEnd-e.colEnd:t.rowEnd-e.rowEnd,j=(e,t)=>e.colEnd===t.colEnd?t.rowEnd-e.rowEnd:t.colEnd-e.colEnd,V=(e,t)=>e.colIndex===t.colIndex?e.rowIndex-t.rowIndex:e.colIndex-t.colIndex,W=(e,t)=>e.rowIndex===t.rowIndex?e.colIndex-t.colIndex:e.rowIndex-t.rowIndex,H=(e=D,t=!1)=>t?e!==L?F:j:e!==L?B:$,N=(e,t)=>e===t||!(!e||!t)&&e.rowIndex===t.rowIndex&&e.colIndex===t.colIndex,U=(e,t)=>e===t||!(!e||!t)&&e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd&&e.colStart===t.colStart&&e.colEnd===t.colEnd,K=(e,t)=>!(!e||!t||e.colStart>t.colEnd||t.colStart>e.colEnd||e.rowStart>t.rowEnd||t.rowStart>e.rowEnd),q=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!U(e[n],t[n]))return!1;return!0},Y=(e,t,n)=>{if(!e&&!t)return null;if(!e)return n?t:{...t};if(!t)return n?e:{...e};const o=Math.min(e.colStart,t.colStart),r=Math.min(e.rowStart,t.rowStart),i=Math.max(e.colEnd,t.colEnd),l=Math.max(e.rowEnd,t.rowEnd);let s=n;return s?(s.colStart=o,s.rowStart=r,s.colEnd=i,s.rowEnd=l):s={colStart:o,rowStart:r,colEnd:i,rowEnd:l},s},X=(e,t)=>{if(!t||0===t.length)return e;const n={...e};for(let e=0;e<t.length;e++){const o=t[e];K(n,o)&&(n.rowStart=Math.min(n.rowStart,o.rowStart),n.colStart=Math.min(n.colStart,o.colStart),n.rowEnd=Math.max(n.rowEnd,o.rowEnd),n.colEnd=Math.max(n.colEnd,o.colEnd))}return n},G=[null,null],Z=(e,t,n)=>{if(e[0].value===e[1].value)return t};function J(e,t=2,n,o=D,r){let i=[...e];if(t<=0||e.length<=1)return i;let l=o===L,s=0,c=!1;do{const e=i.sort(H(l?D:L));i=[],i.push(e[0]);const t=e.length;let a=0,d=e[0],u=d.colStart,h=d.rowStart,f=d.colEnd,p=d.rowEnd;for(let s=1;s<t;s++){const t=e[s];let g=!1;if(g=l?d&&h===t.rowStart&&p===t.rowEnd&&f+1===t.colStart:d&&u===t.colStart&&f===t.colEnd&&p+1===t.rowStart,g){let e={colStart:u,rowStart:h,colEnd:l?t.colEnd:f,rowEnd:l?p:t.rowEnd};if(void 0!==d.value&&(e.value=d.value),n){const i=r??[null,null];i[0]=d,i[1]=t,e=n(i,e,o)}if(e){i[a]=e,c=!0,d=e,u=d.colStart,h=d.rowStart,f=d.colEnd,p=d.rowEnd;continue}}i[++a]=t,d=t,u=d.colStart,h=d.rowStart,f=d.colEnd,p=d.rowEnd}s++,l=!l,1===s&&(c=!0)}while(s<t&&c&&i.length>1);return i}const Q=Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:z,EmptyRange:A,cellToRange:(e,t)=>{if(!e)return null;let n=t;return n||(n={...e},delete n.colIndex,delete n.rowIndex),n.colStart=e.colIndex??0,n.rowStart=e.rowIndex??0,n.colEnd=e.colIndex??0,n.rowEnd=e.rowIndex??0,n},columnFirstCellComparator:V,columnFirstRangeComparator:$,createCellComparator:(e=D,t=!1)=>t?e!==L?(e,t)=>e.rowIndex===t.rowIndex?t.colIndex-e.colIndex:t.rowIndex-e.rowIndex:(e,t)=>e.colIndex===t.colIndex?t.rowIndex-e.rowIndex:t.colIndex-e.colIndex:e!==L?W:V,createConflatingRanges:(e,t=!1)=>{const n=[];let o,r,i=Number.MIN_SAFE_INTEGER,l=Number.MIN_SAFE_INTEGER;return{append:(s,c,a)=>{let d=!0;const u=void 0!==a;if(u){const n=e?e(r,a,t):r===a?a:void 0;void 0===n?d=!1:a=n}if(d&&c===l+1&&s===i)return t?o.rowEnd=c:o.colEnd=c,l=c,void(r=a);o&&n.push(o);const h=t?s:c,f=t?c:s;o={colStart:h,rowStart:f,colEnd:h,rowEnd:f},u&&(o.value=a),i=s,l=c,r=a},done:e=>(o&&(n.push(o),o=null),e?J(n,3,!0===e?Z:e,t?L:D,G):n)}},createRangeComparator:H,defaultRange:(e,t,n)=>e?n?(n.colStart=e.colStart??t.colStart,n.rowStart=e.rowStart??t.rowStart,n.colEnd=e.colEnd??t.colEnd,n.rowEnd=e.rowEnd??t.rowEnd,n):{colStart:e.colStart??t.colStart,rowStart:e.rowStart??t.rowStart,colEnd:e.colEnd??t.colEnd,rowEnd:e.rowEnd??t.rowEnd}:t,extendRangeToIntersectingRanges:X,extendRangeToUnionRanges:(e,t)=>{if(!t||0===t.length)return e;let n=e,o=null;for(;!U(n,o);)o=n,n=X(o,t);return n},indexOfCoords:(e,t)=>{const n={colStart:e.colIndex,rowStart:e.rowIndex,colEnd:e.colIndex,rowEnd:e.rowIndex};for(let e=t.length-1;e>=0;e--)if(K(n,t[e]))return e;return-1},intersectRanges:(e,t,n)=>{if(!e)return n?t:{...t};if(!t)return n?e:{...e};if(!e&&!t)return null;if(e.rowStart>t.rowEnd||e.rowEnd<t.rowStart||e.colStart>t.colEnd||e.colEnd<t.colStart)return null;const o=Math.max(e.colStart,t.colStart),r=Math.max(e.rowStart,t.rowStart),i=Math.min(e.colEnd,t.colEnd),l=Math.min(e.rowEnd,t.rowEnd);let s=n;return s?(s.colStart=o,s.rowStart=r,s.colEnd=i,s.rowEnd=l):s={colStart:o,rowStart:r,colEnd:i,rowEnd:l},s},isCellWithinRange:(e,t)=>!(!e||!t||e.rowIndex<t.rowStart||e.rowIndex>t.rowEnd||e.colIndex<t.colStart||e.colIndex>t.colEnd),isEqualCells:N,isEqualRanges:U,isEqualRangesArrays:q,isEqualSelectionCoords:(e,t)=>e===t||!(!e||!t)&&e.rangeIndex===t.rangeIndex&&!!N(e.cell,t.cell)&&q(e.ranges,t.ranges),isRangeWithinRange:(e,t)=>!(e.rowStart<t.rowStart||e.rowEnd>t.rowEnd||e.colStart<t.colStart||e.colEnd>t.colEnd),isRangesIntersect:K,isSingleCell:e=>!!e&&e.rowEnd===e.rowStart&&e.colStart===e.colEnd,isValidRange:e=>!(!e||"number"!=typeof e.colStart||e.colStart<0||"number"!=typeof e.colEnd||e.colEnd<e.colStart||"number"!=typeof e.rowStart||e.rowStart<0||"number"!=typeof e.rowEnd||e.rowEnd<e.rowStart),mergeRangedValues:J,rowFirstCellComparator:W,rowFirstRangeComparator:B,sanitizeRange:e=>e?{colStart:e.colIndex??e.colStart??0,rowStart:e.rowIndex??e.rowStart??0,colEnd:e.colIndex??e.colEnd??0,rowEnd:e.rowIndex??e.rowEnd??0}:null,translateRange:(e,t=-e.rowStart,n=-e.colStart,o)=>o?(o.colStart=e.colStart+n,o.rowStart=e.rowStart+t,o.colEnd=e.colEnd+n,o.rowEnd=e.rowEnd+t,o):{colStart:e.colStart+n,rowStart:e.rowStart+t,colEnd:e.colEnd+n,rowEnd:e.rowEnd+t},unionRanges:Y,unionRangesArrays:(e,t,n)=>{if(!e||0===e.length)return null;if(1===e.length&&!t)return e[0];let o=e[0];for(let t=1;t<e.length;t++)o=Y(o,e[t],n);return t&&(o=Y(o,t,n)),o}},Symbol.toStringTag,{value:"Module"}));const ee="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function te(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){const t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===ee}(e)}(e)}function ne(e,t){return!1!==t.clone&&t.isMergeableObject(e)?le((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function oe(e,t,n){return e.concat(t).map(function(e){return ne(e,n)})}function re(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function ie(e,t){try{return t in e}catch(e){return!1}}function le(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||oe,n.isMergeableObject=n.isMergeableObject||te,n.cloneUnlessOtherwiseSpecified=ne;const o=Array.isArray(t);return o===Array.isArray(e)?o?n.arrayMerge(e,t,n):function(e,t,n){const o={};return n.isMergeableObject(e)&&re(e).forEach(function(t){o[t]=ne(e[t],n)}),re(t).forEach(function(r){(function(e,t){return ie(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,r)||(ie(e,r)&&n.isMergeableObject(t[r])?o[r]=function(e,t){if(!t.customMerge)return le;const n=t.customMerge(e);return"function"==typeof n?n:le}(r,n)(e[r],t[r],n):o[r]=ne(t[r],n))}),o}(e,t,n):ne(t,n)}le.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return le(e,n,t)},{})};const se=Object.freeze([]),ce=Object.freeze({}),ae=e=>e,de=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),ue=(e,t)=>e===t||!(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)&&e.every((e,n)=>e===t[n]),he=e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,fe=e=>"object"!=typeof e||Array.isArray(e)||null===e?e:(Object.keys(e).forEach(function(t){e[t]&&"object"==typeof e[t]?fe(e[t]):null!==e[t]&&void 0!==e[t]||delete e[t],"object"==typeof e[t]&&0===Object.keys(e[t]).length&&delete e[t]}),0===Object.keys(e).length?null:e),pe=(e,t)=>!(e!==t&&!ue(e,t)&&!e.isEqual?.(t)),ge=(e,t,n=pe)=>{if(null==e||e===t)return null;if(!e||"object"!=typeof e||Array.isArray(e)||e.isImmutable?.())return n(e,t)?null:e;const o=Object.keys(e);if(0===o.length)return null;let r=!1;for(let i=0;i<o.length;i++){const l=o[i];null===ge(e[l],t?.[l],n)&&(r=!0,delete e[l])}return r&&0===Object.keys(e).length?null:void 0},we="object"==typeof performance&&"function"==typeof performance.now?()=>performance.now():()=>Date.now(),me=e=>null==e,xe=(e,t)=>!(t.left>e.right||t.right<e.left||t.top>e.bottom||t.bottom<e.top),ye=!("undefined"==typeof window||!window.document||!window.document.createElement),ve={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},be=()=>{if(Se())return ve.Node;const e=void 0!==globalThis.navigator&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return e?/(win32|win64|windows|wince)/i.test(e)?ve.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(e)?ve.MacOS:/(iphone|ipad|ipod)/i.test(e)?ve.IOS:/android/.test(e)?ve.Android:/linux/.test(e)?ve.Linux:/^((?!chrome|android|).)*safari/i.test(e)?ve.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(e)?ve.Firefox:ve.Unknown:ve.Unknown};function Se(){return"undefined"!=typeof process&&"node"===process.release?.name||("undefined"!=typeof process&&process.browser,!1)}const _e=(e,t=!1)=>(document.hasFocus()||t)&&(e===document.activeElement||e?.contains(document.activeElement)),Ee=Object.freeze(Object.defineProperty({__proto__:null,EmptyArray:se,EmptyObject:ce,OSType:ve,arrayMove:function(e,t,n){const o=e.slice();return o.splice(n<0?o.length+n:n,0,o.splice(t,1)[0]),o},asNumber:e=>{const t=(e=>1*e)(e);return Number.isFinite(t)?t:0},camelToPrettyCase:e=>1===e.length?e.toUpperCase():e.replace(/([A-Z])/g," $1").replace(/^./,function(e){return e.toUpperCase()}).trim(),canUseDOM:ye,cancelTimeout:e=>{cancelAnimationFrame(e.id)},castToString:e=>null==e||void 0===e?"":"string"!=typeof e?""+e:e,cloneObject:e=>me(e)?e:JSON.parse(JSON.stringify(e)),consoleWithNoSource:(...e)=>new Promise(t=>{setTimeout(()=>{Function("console.log.apply(console, arguments)").apply(null,e),t()})}),debounce:function(e,t=300,n=!1){let o,r,i,l,s=0;function c(){let a=Date.now()-s;a<t&&a>=0?o=setTimeout(c,t-a):(o=null,n||(l=e.apply(i,r),i=r=null))}null==t&&(t=100);const a=function(){i=globalThis,r=arguments,s=Date.now();var a=n&&!o;return o||(o=setTimeout(c,t)),a&&(l=e.apply(i,r),i=r=null),l};return a.clear=function(){o&&(clearTimeout(o),o=null)},a.flush=function(){o&&(l=e.apply(i,r),i=r=null,clearTimeout(o),o=null)},a},deepEqual:function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;let o,r,i;if(Array.isArray(t)){if(o=t.length,o!=n.length)return!1;for(r=o;0!==r--;)if(!e(t[r],n[r]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;for(r of t.entries())if(!e(r[1],n.get(r[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(o=t.length,o!=n.length)return!1;for(r=o;0!==r--;)if(t[r]!==n[r])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(i=Object.keys(t),o=i.length,o!==Object.keys(n).length)return!1;for(r=o;0!==r--;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;0!==r--;){let o=i[r];if(!("_owner"===o&&t.$$typeof||e(t[o],n[o])))return!1}return!0}return t!=t&&n!=n},deepFreeze:function e(t){return Object.freeze(t),Object.keys(t).forEach(n=>{"object"!=typeof t[n]||null===t[n]||Object.isFrozen(t[n])||e(t[n])}),t},deepMerge:le,diffValues:(e,t)=>{const n={},o=Object.keys(t),r=o.length;for(let i=0;i<r;i++){const r=o[i];e[r]!==t[r]&&(void 0===e[r]?n[r]=t[r]:n[r]=e[r])}return 0===Object.keys(n).length?null:n},findEqualOrGreater:function(e,t,n=ae){let o=0,r=e.length-1;for(;o<=r;){let i=Math.floor((o+r)/2),l=n(e[i]);if(l===t)return i;l<t?o=i+1:r=i-1}return o},findEqualOrLesser:function(e,t,n=ae){let o=e.length-1,r=0;for(;o>=r;){let i=Math.floor((o+r)/2),l=n(e[i]);if(l===t)return i;l>t?o=i-1:r=i+1}return o},findNextStep:(e,t=!0,n=15,o=10,r=400)=>{const i=Math.max(e-o,0)+(t?1:-1);return Math.min(r,Math[t?"ceil":"floor"](i/n)*n+o)},getDPI:()=>{let e=1;return"object"==typeof window&&(e=window.devicePixelRatio||1),e},getFromPath:(e,t)=>{const n=t.split(".");let o=e;for(let e=0;e<n.length;e++){const t=n[e];if(!o)return null;let r=o[t];if("function"==typeof r&&(r=r.bind(o)()),!r||!he(r))return r;o=r}return o??null},getOS:be,hasFocus:_e,isDefined:e=>!(null==e),isEmpty:e=>null==e||""===e,isEqualArrays:ue,isEqualBounds:(e,t)=>e===t||!(e&&!t||t&&!e)&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,isEqualObjectKeys:(e,t)=>{if(e===t)return!0;if(e&&!t||t&&!e)return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(e[n[o]]!==t[n[o]])return!1;return!0},isNode:Se,isNullOrUndefined:me,isNumeric:e=>{const t=1*e;return Number.isFinite(t)&&"number"==typeof t},isObject:he,isPromiseLike:e=>!!e&&"function"==typeof e.then,isRectInsideRect:(e,t)=>e.top>=t.top&&e.bottom<=t.bottom&&e.left>=t.left&&e.right<=t.right,isRectIntersect:xe,mergeContentful:(...e)=>{const t=e.length;if(t>0&&void 0!==e[t-1]&&!he(e[t-1]))return e[t-1];let n=e[0]||{};for(let o=1;o<t;o++)n=le(n,e[o]||{},{arrayMerge:(e,t)=>[...t]});return n},nextTick:e=>{"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>{e()}):("function"==typeof setImmediate?setImmediate:setTimeout)(()=>{e()})},openFileDialog:(e="*.*")=>new Promise((t,n)=>{if(!ye)return void n("Unable to open dialog with no dom.");const o=document.createElement("input");o.type="file",o.accept=e;let r=null,i=!1;globalThis.addEventListener?.("focus",()=>{setTimeout(()=>{r||i||(i=!0,t(null))},1e3)},{once:!0,passive:!0}),o.onchange=()=>{if(r=o.files[0],r){if(i)return void console.warn("File open detected after faux cancel.",r);t(r)}},o.autofocus=!0,o.click()}),rafThrottle:e=>{let t,n=!1,o=function(){n=!1,e(t)};return function(e){t=e,t&&t.persist&&t.persist(),n||(n=!0,requestAnimationFrame(o))}},removeEmptyProperties:fe,removeEqualValues:ge,removeListenerAll:e=>{if(!e)return[];for(let t=0;t<e.length;t++)e[t]&&e[t]();return[]},requestTimeout:(e,t)=>{const n=we(),o={id:requestAnimationFrame(function r(){we()-n>=t?e.call(null):o.id=requestAnimationFrame(r)})};return o},roundAccurately:(e,t=0)=>{if(null==e||!isFinite(e))return null;const n=10**t;return Number(Math.round(e*n)/n)},setToPath:(e,t,n)=>{const o=t.split(".");let r=e;if(!r)throw new Error("Can not set path to a null path.");for(let e=0;r&&e<o.length-1;e++){const t=o[e];let n=r[t];if(null==n&&(n={},r[t]=n),!he(n))throw new Error("Can not set path to a non object path.");r=n}if("number"!=typeof n&&"boolean"!=typeof n&&"string"!=typeof n&&!he(n))throw new Error(`Can not set path to ${n} that is not a a supported primitive.`);return r[o[o.length-1]]=n,e},splitNumber:e=>{let t=Math.abs(e);if(isNaN(t)||!isFinite(e))return null;let n=0|t,o=t-n,r=0,i=0,l=1;if(o>5e-8)for(;i<8&&Math.abs(r/l-o)>5e-8;)i++,l*=10,r=Math.round(o*l);return{ip:Math.trunc(e),fp:r,ipLength:Math.ceil(Math.log10(n+1)),fpLength:i}},subtractRect:(e,t,n=!1)=>{if(!t)return[e];if(!xe(e,t))return[];const o=[];let r=e;const i=()=>{t.top>r.top&&t.top<r.bottom&&(o.push({...r,bottom:t.top}),r={...r,top:t.top})},l=()=>{t.bottom>r.top&&t.bottom<r.bottom&&(o.push({...r,top:t.bottom}),r={...r,bottom:t.bottom})},s=()=>{t.right>r.left&&t.right<r.right&&(o.push({...r,left:t.right}),r={...r,right:t.right})},c=()=>{t.left>r.left&&t.left<r.right&&(o.push({...r,right:t.left}),r={...r,left:t.left})};return n?(c(),s(),i(),l()):(i(),l(),s(),c()),o},textToKey:e=>e.replace(/[^a-zA-Z0-9]/g,"").toLowerCase(),throttle:function(e,t){let n=null;return(...o)=>{const r=Date.now();(!n||r-n>=t)&&(n=r,e(...o))}},toSafeJSON:function e(t){if(null===t||"object"!=typeof t)return t;if("function"==typeof t.toJSON)return t.toJSON();if(Array.isArray(t))return t.map(t=>e(t));if("function"==typeof t.toString&&t.toString!==Object.prototype.toString)return t.toString();const n={};for(const o in t)t.hasOwnProperty(o)&&(n[o]=e(t[o]));return n},transpose:e=>{if(!e)return e;const t=e.length,n=e[0].length,o=[];for(let e=0;e<n;e++)o[e]=Array(t);for(let r=0;r<t;r++)for(let t=0;t<n;t++)o[t][r]=e[r][t];return o},uuidV4:de,validEnumValue:(e,t)=>{if(!Object.values(e).includes(t))throw new Error(`Invalid type: ${t??"null"}. Must be one of: ${Object.values(t).join(", ")}.`)},whenFocus:async(e,t=!1)=>new Promise(n=>{_e(e,t)?n(!0):e.addEventListener("focusin",()=>{n(!0)},{once:!0}),e.focus()})},Symbol.toStringTag,{value:"Module"}));Object.freeze(Object.defineProperty({__proto__:null,MESSAGE_ERROR_INVALID_ARG:e=>`Invalid argument: '${e}'.`},Symbol.toStringTag,{value:"Module"}));const Ie=e=>{const t=new Uint8Array(e),n=t.byteLength;let o="";for(let e=0;e<n;e++)o+=String.fromCharCode(t[e]);if("undefined"!=typeof window&&"function"==typeof globalThis.btoa)return globalThis.btoa(o);if("undefined"!=typeof Buffer)return Buffer.from(o,"binary").toString("base64");throw new Error("Unsupported environment")},Ce=e=>new Promise((t,n)=>{if(e)if("undefined"!=typeof FileReader){const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{n(o.error)},o.readAsText(e)}else if("undefined"!=typeof Buffer){const o=e=>Buffer.from(e).toString("utf-8");e.arrayBuffer().then(e=>{t(o(e))}).catch(e=>{n(e)})}else n(new Error("Unsupported environment"));else t("")});Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIME_TYPE:"*/*",arrayBufferToBase64:Ie,base64ToArrayBuffer:e=>{const t="undefined"!=typeof window&&"function"==typeof globalThis.atob?globalThis.atob(e):Buffer.from(e,"base64").toString("binary"),n=t.length,o=new Uint8Array(n);for(let e=0;e<n;e++)o[e]=t.charCodeAt(e);return o.buffer},blobToString:Ce},Symbol.toStringTag,{value:"Module"}));const Me="data:image/png;base64,",Te="Unable to resolve image.",ke=e=>new Promise(async(t,n)=>{let o=null;try{o=new Image,o.src=e,o.addEventListener("load",function(){t({width:o.naturalWidth,height:o.naturalHeight})},{once:!0}),o.addEventListener("error",function(){URL.revokeObjectURL(e),n("Invalid Image")},{once:!0}),await o.decode("sync")}catch(e){o?.src&&URL.revokeObjectURL(o.src)}o||n(Te)}),Re="image/svg+xml";var Pe,Oe;Object.freeze(Object.defineProperty({__proto__:null,DATA_URL_PNG_PREFIX:Me,getImageDataUrl:(e,t=1)=>new Promise(async(n,o)=>{let r=null;try{r=new Image,r.src=e,r.addEventListener("load",function(){try{const e=document.createElement("canvas");e.width=r.naturalWidth,e.height=r.naturalHeight,e.getContext("2d").drawImage(r,0,0);const o=e.toDataURL("image/png",t);n({elemImg:r,dataUrl:o})}catch(t){URL.revokeObjectURL(e),o(t)}},{once:!0}),r.addEventListener("error",function(){URL.revokeObjectURL(e),o("Invalid Image")},{once:!0}),await r.decode("sync")}catch(e){r?.src&&URL.revokeObjectURL(r.src)}r||o(Te)}),loadImageDetails:async(e,t=null)=>{let n=null;const o=async()=>{try{const o=t??"image/*",r=URL.createObjectURL(new Blob([e],{type:o})),i=await ke(r);n={mimeType:o,naturalDimensions:i,asUrl:r}}catch(e){}},r=async()=>{try{const o=(new TextDecoder).decode(e),r=URL.createObjectURL(new Blob([o],{type:Re})),i=await ke(r);n={mimeType:t??Re,naturalDimensions:i,asUrl:r,asSVGText:o}}catch(e){}};if(t===Re?await r():t.startsWith("image/")?await o():(await o(),n||await r()),!n)throw new Error("Failed to load image");return n}},Symbol.toStringTag,{value:"Module"})),(Oe=Pe||(Pe={})).resolveTypedUpdates=(e,t,n,o)=>{if(null===e)return e;if(void 0===e)return o;let r=e;if(t?.shorthand){const o=t?.shorthand(e,n);void 0!==o&&(r=o)}if(null!==r&&t?.getSubType){const e=t.getSubType(r);e&&(t=e)}const i=t?.properties,l=t?.arrayType??!1;let s=r;if(t&&t.merge&&s&&o)s=t.merge(s,o,n);else if(l);else if(i){const e=Object.keys({...r,...o});s=null;for(let t=0;t<e.length;t++){const l=e[t];let c,a=r[l];if(void 0!==a){const e=i[l];c=e?(0,Oe.resolveTypedUpdates)(a,e,n,o?.[l]):a}else c=o?.[l];null!=c&&(s=s??{},s[l]=c)}}return s};const Le="The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.",De="You do not have permissions to access the clipboard.\nAll copy and paste operations will be limited to the browser tab.",ze={Safari:"The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.",Perms:De,PermsWrite:be()===ve.Safari?Le:De,PermsRead:be()===ve.Safari?Le:De},Ae=async()=>new Promise(e=>{document.hasFocus()?e():globalThis.addEventListener?.("focus",()=>{e()},{once:!0}),document.activeElement.focus?.()}),$e=async(e,t,n)=>{if(be()===ve.Safari)return await n(new Error(ze.Safari));try{const o=async e=>{try{return await e()}catch(e){if(e.message?.includes("Document is not focused"))return!1;throw e}},r=await(globalThis?.navigator?.permissions?.query({name:e,allowWithoutGesture:!0,allowWithoutSanitization:!0}));let i=!1;if("prompt"===r.state&&(i=await o(t)),i||"granted"!==r.state||(i=await t()),!i)return await n(new Error(r.state))}catch(e){if("No valid data on clipboard"===e.message||"DataError"===e.name)return;return await n(e)}},Be=async e=>{try{return await e.read({unsanitized:[M]})}catch(e){}return await e.read()};if(!globalThis.ClipboardItem){const e=(e,t)=>new Blob([t],{type:e});class t{constructor(t,n){this._items={},this._types=Object.keys(t);const o={},r=Object.keys(t);for(let n=0;n<r.length;n++){const i=r[n];let l=t[i];o[i]="string"==typeof l?e(i,l):l}this._items=o,this._presentationStyle=n?.presentationStyle??"unspecified"}get types(){return this._types}getType(e){return Promise.resolve(this._items[e])}supports(e){return!0}}globalThis.ClipboardItem=t}const Fe=async(e,t=M)=>new Promise(async(n,o)=>{try{const o=await(async(e,t)=>{if(!e)return null;const n=await Be(e);let o=!1;for(let e=0;!o&&n&&e<n.length;e++)if(o=n[e].types.includes(t),o)return await n[e].getType(t);return o?void 0:null})(e,t);if(o){const e=new FileReader;e.onload=()=>{n(e.result)},e.onerror=()=>{n("")},e.readAsText(o)}else n("")}catch(e){o(e)}}),je=async(e,t=M)=>{const n=await Fe(e,t);if(!n)return null;let o=null;try{o=(new DOMParser).parseFromString(n,M)}catch(e){console.warn("Can't parse html from clipboard.")}return o},Ve="clipboard-uuid",We="web text/uuid",He=e=>`<div style="display:none" ${Ve}="${e}"/>`,Ne=(e,t)=>{let n=null;try{const o=(new DOMParser).parseFromString(t,M);o.body.firstElementChild.setAttribute(Ve,e),n=o.getElementsByTagName("body")[0].innerHTML}catch(e){console.warn("Can't embed uuid.",e)}return n},Ue=(e,t)=>{if(!t||!e)return!1;try{const n=t.querySelectorAll(`[${Ve}="${e}"]`);if(n&&1===n.length)return!0;if(t.querySelector("parsererror"))throw new Error("We are unable to parse node");return!1}catch(e){return!1}};let Ke=class{constructor(e){if(void 0===e?.nativeClipboard||!0===e?.nativeClipboard)try{this._nativeClipboard=globalThis?.navigator.clipboard}catch(t){!0===e?.nativeClipboard&&console.warn("NativeClipboard option set to true but no native clipboard available.")}else this._nativeClipboard=!1===e?.nativeClipboard?null:e?.nativeClipboard;this._disableCheckOnFocus=e?.disableCheckOnFocus??!1,this._init()}async _checkForChanges(){this._nativeClipboard&&this._state&&!this._disableCheckOnFocus&&await $e("clipboard-read",async()=>{await Ae();const e=await Fe(this._nativeClipboard,We);if(!this._state)return!0;if(e&&e===this._state.uuid)return!0;const t=await je(this._nativeClipboard,M);return!this._state||(Ue(this._state.uuid,t)||this.clear(),!0)},async e=>{"denied"===e?.message||e.message?.includes("Document is not focused")||be()===ve.Safari||console.warn("Unable to detect clipboard changes: ",e)})}_init(){const e=this;this._listeners=new Map,this._listenersCapture=new Map,this._state=null,this._nativeClipboard&&(this._onFocus=()=>{e._checkForChanges()},this._onBlur=()=>{globalThis.addEventListener?.("focus",e._onFocus,{once:!0})},globalThis.addEventListener?.("blur",this._onBlur),this._nativeClipboard.addEventListener("clipboardchange",t=>{e._checkForChanges()}))}async read(){if(!this._nativeClipboard)return this._state?.items??null;const e=this;return await $e("clipboard-read",async()=>{if(await Ae(),this._state?.uuid){const t=await Fe(this._nativeClipboard,We);if(t&&t===e._state.uuid)return!0;const n=await je(this._nativeClipboard,M);if(Ue(e._state?.uuid,n))return!0}return e._state={items:await Be(this._nativeClipboard),uuid:null,ref:null},this.dispatchEvent(new Event("clipboardread")),!0},async e=>{this.dispatchEvent(new Event("clipboarderrorread"))}),this._state?.items??[]}async write(e){return this._write({uuid:de(),items:e,ref:null})}async _write(e){if(!this._nativeClipboard)return this._state=e,this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")),null;const t=this,n=[],o=e.uuid;let r=e.items??[];const i=()=>{t._state={uuid:o,ref:e.ref,items:n},t.dispatchEvent(new Event("clipboardwrite")),t.dispatchEvent(new Event("clipboardchange"))};await $e("clipboard-write",async()=>{await Ae(),o&&0===r.length&&(r.push(new ClipboardItem({[We]:new Blob([o],{type:We})})),r.push(new ClipboardItem({[M]:new Blob([He(o)],{type:M})})));for(let e=0;e<Math.min(1,r.length);e++){const t=r[e];let i=t.types.indexOf(M),l=null;if(-1!==i){const e=await t.getType(M);l=await Ce(e),l&&(l=Ne(o,l))}if(!l&&t.types.includes(T)){const e=await t.getType(T);if(e){let t=null;"string"==typeof e?(console.warn("text as string",e),t=e):t=await Ce(e),t&&(l=`<div ${Ve}="${o}">${t}</div>`)}}if(!l&&t.types.includes(k)){const e=await t.getType(k),n=Ie(await e.arrayBuffer());l=`<div ${Ve}="${o}"><img src="${Me+n}"/></div>`}!l&&o&&(l=He(o));const s=new Blob([l??""],{type:M}),c={};for(let e=0;e<t.types.length;e++){const n=t.types[e];c[n]=e===i?s:t.getType(n)}l&&-1===i&&(c[M]=s),o&&(c[We]=new Blob([o],{type:We})),n.push(new ClipboardItem(c))}try{n&&0!==n.length?await this._nativeClipboard.write(n):await(async e=>{e&&await e.writeText("")})(this._nativeClipboard)}catch(e){e.message?.includes("Document is not focused")||console.warn("Unable to write to native clipboard: ",e)}return i(),!0},async e=>{this.dispatchEvent(new Event("clipboarderrorwrite")),i()})}async writeReference(e){if(!e)return void this.clear();let t=null;const n={};try{const t=await(e.toText?.())??null;t&&(n[T]=new Blob([t??""],{type:T}))}catch(e){t=e}try{const t=await(e.toHtml?.())??null;t&&(n[M]=new Blob([t],{type:M}))}catch(e){t=e,console.warn("export to html",e)}try{const t=await(e.toImage?.())??null;t&&(n[k]=t)}catch(e){t=e,console.warn("export to png",e)}const o=this._write({uuid:de(),ref:e,items:Object.keys(n).length>0?[new ClipboardItem(n)]:null});if(t)throw t;return o}clear(e=!1){this._state&&(this._state=null,e&&this._write({uuid:null,ref:null,items:null}),this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")))}async readReference(){return await this.read(),this._state?.ref??null}readText(){return new Promise(async(e,t)=>{const n=await this.read();let o=null;for(let e=0;!o&&n&&e<n.length;e++)n[e].types.includes(T)&&(o=await n[e].getType(T));if(!o)return void e("");const r=new FileReader;r.onload=()=>{e(r.result)},r.readAsText(o),r.onerror=e=>{t(e)}})}async writeText(e){const t=[new ClipboardItem({[T]:new Blob([e],{type:T})})];return this._write({uuid:de(),items:t,ref:null})}addEventListener(e,t,n={}){const o=n?.capture?this._listenersCapture:this._listeners;let r=o.get(e);r||(r=new Map,o.set(e,r)),r.set(t,"boolean"==typeof n?{}:n)}dispatchEvent(e){if(!e)return;const t=t=>{const n=t.get(e.type);n&&n.forEach((t,o)=>{try{"function"==typeof o?o(e):o.handleEvent&&o.handleEvent(e),t.once&&n.delete(o)}catch(e){console.warn(e)}})};return t(this._listenersCapture),t(this._listeners),!0}removeEventListener(e,t,n){const o=n?.capture?this._listenersCapture:this._listeners,r=o.get(e);r&&(r.delete(t),0===r.size&&o.delete(e))}close(){globalThis.removeEventListener?.("focus",this._onFocus),globalThis.removeEventListener?.("blur",this._onBlur)}};var qe;(qe=Ke||(Ke={})).ErrorMessages=ze,qe.Global=new qe,function(){try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode("/**\n * CSS files with the .module.css suffix will be treated as CSS modules\n * and scoped locally.\n Note - this isn't working but was meant to enabled default scroll buttons to play nicely with rounded corners\n */\n/* & ::-webkit-scrollbar {\n background: gre;\n } */\n._sheetxl-scrollbar_eblx4_6 ::-webkit-scrollbar-button {\n background: transparent;\n }/**\n * Used for fullscreen portals.\n */\n._fullscreen-portal-root_1mjsr_4 {\n pointer-events: none;\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n z-index: 1200;\n}\n\n._fullscreen-portal-root_1mjsr_4 > * {\n pointer-events: auto;\n}")),document.head.appendChild(e)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();const Ye={Left:"left",Right:"right",Center:"center"},Xe="shift",Ge="alt",Ze="ctrl",Je=9,Qe=13,et=27,tt=37,nt=38,ot=39,rt=40,it=113,lt=3,st={Horizontal:"horizontal",Vertical:"vertical"};function ct(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=ct(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function at(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=ct(e))&&(o&&(o+=" "),o+=t);return o}var dt=function(){},ut="undefined"!=typeof window,ht=ut?u:s,ft={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const pt=ut&&void 0!==window.ResizeObserver?function(){var e=h(null),t=e[0],n=e[1],o=h(ft),r=o[0],i=o[1],l=d(function(){return new window.ResizeObserver(function(e){if(e[0]){var t=e[0].contentRect,n=t.x,o=t.y,r=t.width,l=t.height,s=t.top,c=t.left,a=t.bottom,d=t.right;i({x:n,y:o,width:r,height:l,top:s,left:c,bottom:a,right:d})}})},[]);return ht(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[dt,ft]},gt=(e,t)=>{const n=i((...t)=>e?.(...t),t),o=l(null);o.current=n;const r=i((...e)=>o.current?.(...e),[]);if(o.current)return r},wt=t=>{const{style:n,orientation:o=st.Vertical,...r}=t,i=o===st.Vertical;return e("div",{style:{paddingBottom:"0px",paddingRight:"0px",paddingLeft:i?"0px":"3px",paddingTop:i?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...n},...r,children:e("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${i?"vertical":"horizontal"} single-button start`,children:e("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:e("path",{d:i?"m 3.7274761,0.68060577 1.11969,1.93863003 1.12075,1.93912 c 0.0895,0.155 0.12152,0.33658 0.0904,0.51283 -0.0311,0.17625 -0.12336,0.33591 -0.26054,0.45091 -0.13715,0.11495 -0.31044,0.17793 -0.4894,0.17781 H 0.83095614 c -0.20186,0 -0.39542,-0.0802 -0.53814,-0.2229 -0.14272,-0.14272 -0.22291,-0.33629 -0.22291,-0.53814 -3e-4,-0.13308 0.0347,-0.26385 0.10147,-0.379 l 1.11872996,-1.94066 1.11921,-1.93864003 c 0.13594,-0.23541 0.38717,-0.38047 0.65905,-0.38047 0.27188,0 0.52311,0.14506 0.65905,0.38047 z":"m 0.75051,2.3424298 1.93863,-1.11969 1.93912,-1.12075 c 0.155,-0.0895 0.33658,-0.12152 0.51283,-0.0904 0.17625,0.0311 0.33591,0.12336 0.45091,0.26054 0.11495,0.13715 0.17793,0.31044 0.17781,0.4894 v 4.47742 c 0,0.20186 -0.0802,0.39542 -0.2229,0.53814 -0.14272,0.14272 -0.33629,0.22291 -0.53814,0.22291 -0.13308,3e-4 -0.26385,-0.0347 -0.379,-0.10147 L 2.68911,4.7797998 0.75047,3.6605898 C 0.51506,3.5246498 0.37,3.2734198 0.37,3.0015398 c 0,-0.27188 0.14506,-0.52311 0.38047,-0.65905 z"})})})})},mt=t=>{const{style:n,orientation:o=st.Vertical,...r}=t,i=o===st.Vertical;return e("div",{style:{paddingLeft:"0px",paddingTop:"0px",paddingRight:i?"0px":"3px",paddingBottom:i?"3px":"0px",display:"flex",alignItems:"center",justifyContent:"center",...n},...r,children:e("button",{style:{padding:"0",display:"flex",alignItems:"center",justifyContent:"center",border:"none"},className:`scrollbar-button ${i?"vertical":"horizontal"} single-button end`,children:e("svg",{width:"9",height:"9",viewBox:"0 0 6 6",style:{opacity:"inherit"},children:e("path",{d:i?"M 2.412334,5.319396 1.292644,3.3807659 0.17189405,1.4416459 c -0.0895,-0.155 -0.12152,-0.33658 -0.0904,-0.51282998 0.0311,-0.17625 0.12336,-0.33591 0.26054,-0.45091 0.13715,-0.11495 0.31044,-0.17793 0.4894,-0.17781 H 5.308854 c 0.20186,0 0.39542,0.0802 0.53814,0.2229 0.14272,0.14272 0.22291,0.33629 0.22291,0.53813998 3e-4,0.13308 -0.0347,0.26385 -0.10147,0.379 l -1.11873,1.94066 -1.11921,1.9386401 c -0.13594,0.23541 -0.38717,0.38047 -0.65905,0.38047 -0.27188,0 -0.52311,-0.14506 -0.65905,-0.38047 z":"m 5.3893002,3.6575719 -1.9386301,1.11969 -1.93912,1.12075 c -0.155,0.0895 -0.33658,0.12152 -0.51282997,0.0904 -0.17625,-0.0311 -0.33591,-0.12336 -0.45091,-0.26054 -0.11495,-0.13715 -0.17793,-0.31044 -0.17781,-0.4894 V 0.76105195 c 0,-0.20186 0.0802,-0.39542 0.2229,-0.53814 C 0.73562013,0.08019195 0.92919013,1.9467784e-6 1.1310401,1.9467784e-6 1.2641201,-2.9805322e-4 1.3948901,0.03470195 1.5100401,0.10147195 l 1.94066,1.11872995 1.9386401,1.11921 c 0.23541,0.13594 0.38047,0.38717 0.38047,0.65905 0,0.27188 -0.14506,0.52311 -0.38047,0.65905 z"})})})})},xt=(e,t,n,o,r=0)=>{for(let r=0;r<n.length;r++){const i=n[r].getBoundingClientRect();let l=i.left-t,s=l+i.width;if(o){if(l<e&&s>=e)return l}else if(Math.ceil(s)>Math.ceil(e)+2)return s}return r};Object.freeze(Object.defineProperty({__proto__:null,getScrollTo:xt},Symbol.toStringTag,{value:"Module"}));const yt=r(a((n,o)=>{const{offset:r=0,totalSize:c=0,viewportSize:a=0,style:u,className:f,orientation:p=st.Vertical,onScrollOffset:g,onScroll:w,showCustomScrollButtons:m=!1,scrollButtonIncrement:x=200,scrollButtonInitialRepeatDelay:y=260,scrollButtonAdditionalRepeatDelay:v=120,createScrollStartButton:b=wt,createScrollEndButton:S=mt,..._}=n,E=gt(w,[w]),I=l(null),[C,{width:M,height:T}]=pt(),[k,{width:R,height:P}]=pt(),O=p===st.Vertical,L=O?"top":"left",D=O?"scrollTop":"scrollLeft",z=O?T:M,A=O?P:R,[$,B]=h(null);s(()=>{null!==$&&I.current&&I.current.scrollTo({behavior:"smooth",[L]:$})},[$,O]);const F=i((e,t=!1)=>{if(!I.current)return 0;const n=I.current.querySelector(".scrollbar-viewport"),o=n.getBoundingClientRect(),r=n.children,i=t?0:xt(e,o[L],r,!0,Math.max(0,e-x));return B(i),Math.max(0,i)},[]),j=i((e,t=!1)=>{if(!I.current)return 0;const n=I.current.querySelector(".scrollbar-viewport"),o=n.getBoundingClientRect(),r=n.children,i=Math.ceil(A-z),l=t?i:xt(e,o[L],r,!1,Math.max(0,e+x));return B(l),Math.min(i,l)},[A,z]),V=l(null),W=i(e=>{V.current=r;const t=e.target[D];g(t,a,c),E?.(e)},[g,a,c,r]);s(()=>{const e=V.current;V.current=null,r!==e&&(I.current[D]=r)},[r,D]);const H=l(null),N=l(null),U=i(()=>{H.current&&(clearTimeout(H.current),H.current=null,N.current=null)},[]),K=i((e,t,n,o=y)=>{N.current=e,H.current=setTimeout(()=>{const t=n?F(N.current||e):j(N.current||e);t!==N.current?K(t,!1,n,v):U()},t?0:o)},[F,j,U]);s(()=>()=>U(),[U]);const q=r,Y=d(()=>{if(!m)return null;const e={orientation:p,disabled:Math.floor(q)<=0||0===Math.floor(A-z),onMouseUp:U,onMouseLeave:U,onMouseDown:()=>K(q,!0,!0)};return b?.(e)},[m,p,q,$,A,z]),X=d(()=>{if(!m)return null;const e={orientation:p,disabled:Math.floor(A-z)<=Math.ceil(q),onMouseUp:U,onMouseLeave:U,onMouseDown:()=>K(q,!0,!1)};return S?.(e)},[m,p,q,$,A,z]);return t("div",{ref:o,style:{display:"flex",flex:"1",flexDirection:O?"column":"row",padding:"0",...u},className:at("_sheetxl-scrollbar_eblx4_6",f),..._,children:[Y,e("div",{className:"pseudo-scrollbar",style:{flex:"1 1 100%",display:"flex",boxSizing:"content-box",flexDirection:O?"column":"row",justifyContent:"center",alignItems:"center"},ref:C,children:e("div",{tabIndex:-1,style:{flex:"1 1 100%",overflowY:O?"scroll":"hidden",overflowX:O?"hidden":"scroll",position:"relative",willChange:"transform"},onScroll:W,ref:I,children:e("div",{ref:k,style:{position:"absolute",height:O?c-a+(T??0):1,width:O?1:c-a+(M??0)},className:"scrollbar-viewport"})})}),X]})}));yt.displayName="Scrollbar";let vt=Date.now,bt={},St=1;const _t=e=>{let t=null!==bt[e];return t&&(bt[e]=null),t},Et=(e,t,n,o=0,r)=>{let i=vt(),l=i,s=0,c=0,a=0,d=St++;if(d%20==0){const e={};for(let t in bt)e[t]=!0;bt=e}const u=function(h){let f=!0!==h,p=vt(),g=!0;try{g=(!t||t(d))??!0}catch(e){g=!1}if(!bt[d]||!g)return bt[d]=null,void n?.(60-c/((p-i)/1e3),d,!1);if(f){a=Math.round((p-l)/16.666666666666668)-1;for(let e=0;e<Math.min(a,4);e++)u(!0),c++}o&&(s=(p-i)/o,s>1&&(s=1));let w=r?r(s):s,m=!1;try{m=e(w,p,f)}catch(e){m=!1}!1!==m&&1!==s||!f?f&&(l=p,requestAnimationFrame(u)):(bt[d]=null,n?.(60-c/((p-i)/1e3),d,1===s||null==o))};return bt[d]=!0,requestAnimationFrame(u),d},It=function(e){return Math.pow(e-1,3)+1},Ct=function(e){return(e/=.5)<1?.5*Math.pow(e,3):.5*(Math.pow(e-2,3)+2)};class Mt{constructor(e,t){this.__isSingleTouch=!1,this.__isTracking=!1,this.__didDecelerationComplete=!1,this.__isGesturing=!1,this.__isDragging=!1,this.__isDecelerating=0,this.__isAnimating=0,this.__interruptedAnimation=!1,this.__lastScale=1,this.__enableScrollX=!0,this.__enableScrollY=!0,this.__clientLeft=0,this.__clientTop=0,this.__clientWidth=0,this.__clientHeight=0,this.__contentWidth=0,this.__contentHeight=0,this.__snapWidth=100,this.__snapHeight=100,this.__zoomLevel=1,this.__scrollLeft=0,this.__scrollTop=0,this.__maxScrollLeft=0,this.__maxScrollTop=0,this.__scheduledLeft=0,this.__scheduledTop=0,this.__scheduledZoom=0,this.__lastTouchLeft=0,this.__lastTouchTop=0,this.__lastTouchMove=0,this.__positions=[],this.__initialTouchLeft=0,this.__initialTouchTop=0,this.__zoomLevelStart=1,this.__minDecelerationScrollLeft=null,this.__minDecelerationScrollTop=null,this.__maxDecelerationScrollLeft=null,this.__maxDecelerationScrollTop=null,this.__decelerationVelocityX=null,this.__decelerationVelocityY=0,this.__callback=e,this.options={scrollingX:!0,scrollingY:!0,animating:!0,animationDuration:250,bouncing:!0,locking:!0,paging:!1,snapping:!1,zooming:!1,minZoom:.5,maxZoom:3,speedMultiplier:1,scrollingComplete:void 0,penetrationDeceleration:.03,penetrationAcceleration:.08,...t}}setDimensions(e,t,n,o){null!==e&&(this.__clientWidth=e),null!==t&&(this.__clientHeight=t),null!==n&&(this.__contentWidth=n),null!==o&&(this.__contentHeight=o),this.__computeScrollMax(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0)}setPosition(e,t){this.__clientLeft=e||0,this.__clientTop=t||0}setSnapSize(e,t){this.__snapWidth=e,this.__snapHeight=t}getValues(){return{left:this.__scrollLeft,top:this.__scrollTop,right:this.__scrollLeft+this.__clientWidth/this.__zoomLevel,bottom:this.__scrollTop+this.__clientHeight/this.__zoomLevel,zoom:this.__zoomLevel}}getPoint(e,t){const n=this.getValues();return{left:e/n.zoom,top:t/n.zoom}}getScrollMax(){return{left:this.__maxScrollLeft,top:this.__maxScrollTop}}zoomTo(e,t=!1,n,o,r){if(!this.options.zooming)throw new Error("Zooming is not enabled!");r&&(this.__zoomComplete=r),this.__isDecelerating&&(_t(this.__isDecelerating),this.__isDecelerating=0);const i=this.__zoomLevel;void 0===n&&(n=this.__clientWidth/2),void 0===o&&(o=this.__clientHeight/2),e=Math.max(Math.min(e,this.options.maxZoom),this.options.minZoom),this.__computeScrollMax(e);const l=e/i;let s=l*(this.__scrollLeft+n)-n,c=l*(this.__scrollTop+o)-o;s>this.__maxScrollLeft?s=this.__maxScrollLeft:s<0&&(s=0),c>this.__maxScrollTop?c=this.__maxScrollTop:c<0&&(c=0),this.__publish(s,c,e,t)}zoomBy(e,t=!1,n=0,o=0,r){this.zoomTo(this.__zoomLevel*e,t,n,o,r)}scrollTo(e,t,n=!1,o=1){if(this.__isDecelerating&&(_t(this.__isDecelerating),this.__isDecelerating=0),void 0!==o&&o!==this.__zoomLevel){if(!this.options.zooming)throw new Error("Zooming is not enabled!");e*=o,t*=o,this.__computeScrollMax(o)}else o=this.__zoomLevel;this.options.scrollingX?this.options.paging?e=Math.round(e/this.__clientWidth)*this.__clientWidth:this.options.snapping&&(e=Math.round(e/this.__snapWidth)*this.__snapWidth):e=this.__scrollLeft,this.options.scrollingY?this.options.paging?t=Math.round(t/this.__clientHeight)*this.__clientHeight:this.options.snapping&&(t=Math.round(t/this.__snapHeight)*this.__snapHeight):t=this.__scrollTop,e=Math.max(Math.min(this.__maxScrollLeft,e),0),t=Math.max(Math.min(this.__maxScrollTop,t),0),e===this.__scrollLeft&&t===this.__scrollTop&&(n=!1),this.__publish(e,t,o,n)}scrollBy(e=0,t=0,n=!1){const o=this.__isAnimating?this.__scheduledLeft:this.__scrollLeft,r=this.__isAnimating?this.__scheduledTop:this.__scrollTop;this.scrollTo(o+(e||0),r+(t||0),n)}doMouseZoom(e,t,n,o){const r=e>0?.97:1.03;return this.zoomTo(this.__zoomLevel*r,!1,n-this.__clientLeft,o-this.__clientTop)}doTouchStart(e,t){if(void 0===e.length)throw new Error("Invalid touch list: "+e);if(t instanceof Date&&(t=t.valueOf()),"number"!=typeof t)throw new Error("Invalid timestamp value: "+t);let n,o;this.__interruptedAnimation=!0,this.__isDecelerating&&(_t(this.__isDecelerating),this.__isDecelerating=0,this.__interruptedAnimation=!0),this.__isAnimating&&(_t(this.__isAnimating),this.__isAnimating=0,this.__interruptedAnimation=!0);let r=1===e.length;r?(n=e[0].pageX,o=e[0].pageY):(n=Math.abs(e[0].pageX+e[1].pageX)/2,o=Math.abs(e[0].pageY+e[1].pageY)/2),this.__initialTouchLeft=n,this.__initialTouchTop=o,this.__zoomLevelStart=this.__zoomLevel,this.__lastTouchLeft=n,this.__lastTouchTop=o,this.__lastTouchMove=t,this.__lastScale=1,this.__enableScrollX=!r&&this.options.scrollingX,this.__enableScrollY=!r&&this.options.scrollingY,this.__isTracking=!0,this.__didDecelerationComplete=!1,this.__isDragging=!r,this.__isSingleTouch=r,this.__positions=[]}doTouchMove(e,t,n=1){if(void 0===e.length)throw new Error("Invalid touch list: "+e);if(t instanceof Date&&(t=t.valueOf()),"number"!=typeof t)throw new Error("Invalid timestamp value: "+t);if(!this.__isTracking)return;let o,r;2===e.length?(o=Math.abs(e[0].pageX+e[1].pageX)/2,r=Math.abs(e[0].pageY+e[1].pageY)/2):(o=e[0].pageX,r=e[0].pageY);let i=this.__positions;if(this.__isDragging){let e=o-this.__lastTouchLeft,l=r-this.__lastTouchTop,s=this.__scrollLeft,c=this.__scrollTop,a=this.__zoomLevel;if(void 0!==n&&this.options.zooming){let e=a;if(a=a/this.__lastScale*n,a=Math.max(Math.min(a,this.options.maxZoom),this.options.minZoom),e!==a){let t=o-this.__clientLeft,n=r-this.__clientTop;s=(t+s)*a/e-t,c=(n+c)*a/e-n,this.__computeScrollMax(a)}}if(this.__enableScrollX){s-=e*this.options.speedMultiplier;let t=this.__maxScrollLeft;(s>t||s<0)&&(this.options.bouncing?s+=e/2*this.options.speedMultiplier:s=s>t?t:0)}if(this.__enableScrollY){c-=l*this.options.speedMultiplier;const e=this.__maxScrollTop;(c>e||c<0)&&(this.options.bouncing?c+=l/2*this.options.speedMultiplier:c=c>e?e:0)}i.length>60&&i.splice(0,30),i.push(s,c,t),this.__publish(s,c,a)}else{let e=this.options.locking?3:0,n=5,l=Math.abs(o-this.__initialTouchLeft),s=Math.abs(r-this.__initialTouchTop);this.__enableScrollX=this.options.scrollingX&&l>=e,this.__enableScrollY=this.options.scrollingY&&s>=e,i.push(this.__scrollLeft,this.__scrollTop,t),this.__isDragging=(this.__enableScrollX||this.__enableScrollY)&&(l>=n||s>=n),this.__isDragging&&(this.__interruptedAnimation=!1)}this.__lastTouchLeft=o,this.__lastTouchTop=r,this.__lastTouchMove=t,this.__lastScale=n}doTouchEnd(e){if(e instanceof Date&&(e=e.valueOf()),"number"!=typeof e)throw new Error("Invalid timestamp value: "+e);if(this.__isTracking){if(this.__isTracking=!1,this.__isDragging)if(this.__isDragging=!1,this.__isSingleTouch&&this.options.animating&&e-this.__lastTouchMove<=100){let t=this.__positions,n=t.length-1,o=n;for(let e=n;e>0&&t[e]>this.__lastTouchMove-100;e-=3)o=e;if(o!==n){const r=t[n]-t[o],i=this.__scrollLeft-t[o-2],l=this.__scrollTop-t[o-1];this.__decelerationVelocityX=i/r*(1e3/60),this.__decelerationVelocityY=l/r*(1e3/60);const s=this.options.paging||this.options.snapping?4:1;(Math.abs(this.__decelerationVelocityX)>s||Math.abs(this.__decelerationVelocityY)>s)&&this.__startDeceleration(e)}else this.options.scrollingComplete?.()}else e-this.__lastTouchMove>100&&this.options.scrollingComplete?.();this.__isDecelerating||((this.__interruptedAnimation||this.__isDragging)&&this.options.scrollingComplete?.(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0,this.__zoomLevel)),this.__positions.length=0}}__publish(e,t,n,o=!1){const r=this.__isAnimating;if(r&&(_t(r),this.__isAnimating=0),o&&this.options.animating){this.__scheduledLeft=e,this.__scheduledTop=t,this.__scheduledZoom=n;const o=this.__scrollLeft,i=this.__scrollTop,l=this.__zoomLevel,s=e-o,c=t-i,a=n-l,d=function(e,t,n){n&&(this.__scrollLeft=o+s*e,this.__scrollTop=i+c*e,this.__zoomLevel=l+a*e,this.__callback&&this.__callback(this.__scrollLeft,this.__scrollTop,this.__zoomLevel))}.bind(this),u=function(e){return this.__isAnimating===e}.bind(this),h=function(e,t,n){t===this.__isAnimating&&(this.__isAnimating=!1),(this.__didDecelerationComplete||n)&&this.options.scrollingComplete?.(),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}.bind(this);this.__isAnimating=Et(d,u,h,this.options.animationDuration,r?It:Ct)}else this.__scheduledLeft=this.__scrollLeft=e,this.__scheduledTop=this.__scrollTop=t,this.__scheduledZoom=this.__zoomLevel=n,this.__callback&&this.__callback(e,t,n),this.options.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))}__computeScrollMax(e=this.__zoomLevel){this.__maxScrollLeft=Math.max(this.__contentWidth*e-this.__clientWidth,0),this.__maxScrollTop=Math.max(this.__contentHeight*e-this.__clientHeight,0)}__startDeceleration(e){if(this.options.paging){const e=Math.max(Math.min(this.__scrollLeft,this.__maxScrollLeft),0),t=Math.max(Math.min(this.__scrollTop,this.__maxScrollTop),0),n=this.__clientWidth,o=this.__clientHeight;this.__minDecelerationScrollLeft=Math.floor(e/n)*n,this.__minDecelerationScrollTop=Math.floor(t/o)*o,this.__maxDecelerationScrollLeft=Math.ceil(e/n)*n,this.__maxDecelerationScrollTop=Math.ceil(t/o)*o}else this.__minDecelerationScrollLeft=0,this.__minDecelerationScrollTop=0,this.__maxDecelerationScrollLeft=this.__maxScrollLeft,this.__maxDecelerationScrollTop=this.__maxScrollTop;const t=function(e,t,n){this.__stepThroughDeceleration(n)}.bind(this),n=this.options.snapping?4:.1,o=function(){const e=Math.abs(this.__decelerationVelocityX)>=n||Math.abs(this.__decelerationVelocityY)>=n;return e||(this.__didDecelerationComplete=!0),e}.bind(this),r=function(e,t,n){this.__isDecelerating=0,this.__didDecelerationComplete&&this.options.scrollingComplete?.(),this.scrollTo(this.__scrollLeft,this.__scrollTop,this.options.snapping)}.bind(this);this.__isDecelerating=Et(t,o,r)}__stepThroughDeceleration(e){let t=this.__scrollLeft+this.__decelerationVelocityX,n=this.__scrollTop+this.__decelerationVelocityY;if(!this.options.bouncing){const e=Math.max(Math.min(this.__maxDecelerationScrollLeft,t),this.__minDecelerationScrollLeft);e!==t&&(t=e,this.__decelerationVelocityX=0);const o=Math.max(Math.min(this.__maxDecelerationScrollTop,n),this.__minDecelerationScrollTop);o!==n&&(n=o,this.__decelerationVelocityY=0)}if(e?this.__publish(t,n,this.__zoomLevel):(this.__scrollLeft=t,this.__scrollTop=n),!this.options.paging){const e=.95;this.__decelerationVelocityX*=e,this.__decelerationVelocityY*=e}if(this.options.bouncing){let e=0,o=0,r=this.options.penetrationDeceleration,i=this.options.penetrationAcceleration;t<this.__minDecelerationScrollLeft?e=this.__minDecelerationScrollLeft-t:t>this.__maxDecelerationScrollLeft&&(e=this.__maxDecelerationScrollLeft-t),n<this.__minDecelerationScrollTop?o=this.__minDecelerationScrollTop-n:n>this.__maxDecelerationScrollTop&&(o=this.__maxDecelerationScrollTop-n),0!==e&&(e*this.__decelerationVelocityX<=0?this.__decelerationVelocityX+=e*r:this.__decelerationVelocityX=e*i),0!==o&&(o*this.__decelerationVelocityY<=0?this.__decelerationVelocityY+=o*r:this.__decelerationVelocityY=o*i)}}}var Tt="undefined"!=typeof window?window:{screen:{},navigator:{}},kt=(Tt.matchMedia||function(){return{matches:!1}}).bind(Tt),Rt=!1,Pt={get passive(){return Rt=!0}},Ot=function(){};Tt.addEventListener&&Tt.addEventListener("p",Ot,Pt),Tt.removeEventListener&&Tt.removeEventListener("p",Ot,!1);var Lt=Rt,Dt="PointerEvent"in Tt,zt="ontouchstart"in Tt,At=zt||"TouchEvent"in Tt&&kt("(any-pointer: coarse)").matches,$t=(Tt.navigator.maxTouchPoints||0)>0||At,Bt=Tt.navigator.userAgent||"",Ft=kt("(pointer: coarse)").matches&&/iPad|Macintosh/.test(Bt)&&Math.min(Tt.screen.width||0,Tt.screen.height||0)>=768,jt=(kt("(pointer: coarse)").matches||!kt("(pointer: fine)").matches&&zt)&&!/Windows.*Firefox/.test(Bt),Vt=kt("(any-pointer: fine)").matches||kt("(any-hover: hover)").matches||Ft||!zt,Wt=!$t||!Vt&&jt?$t?"touchOnly":"mouseOnly":"hybrid",Ht="mouseOnly"===Wt?"mouse":"touchOnly"===Wt||jt?"touch":"mouse";const Nt=Object.freeze(Object.defineProperty({__proto__:null,deviceType:Wt,primaryInput:Ht,supportsPassiveEvents:Lt,supportsPointerEvents:Dt,supportsTouchEvents:At},Symbol.toStringTag,{value:"Module"})),Ut=new Set(["INPUT","TEXTAREA","SELECT"]),Kt={};function qt(){return Nt}const Yt=Object.freeze(Object.defineProperty({__proto__:null,EmptyCssProperties:Kt,boundPixel:function(e,t=!1,n=0){return e},createSyntheticEvent:e=>{let t=!1,n=!1;return{nativeEvent:e,currentTarget:e.currentTarget,target:e.target,bubbles:e.bubbles,cancelable:e.cancelable,defaultPrevented:e.defaultPrevented,eventPhase:e.eventPhase,isTrusted:e.isTrusted,preventDefault:()=>{t=!0,e.preventDefault()},isDefaultPrevented:()=>t,stopPropagation:()=>{n=!0,e.stopPropagation()},isPropagationStopped:()=>n,persist:()=>{},timeStamp:e.timeStamp,type:e.type}},detectIt:qt,focusableNodeNames:Ut,toPrettyKeyCode:e=>"BracketLeft"===e?"[":"BracketRight"===e?"]":Ee.camelToPrettyCase(e)},Symbol.toStringTag,{value:"Module"})),Xt=[];function Gt(e,t,n=Xt){const o=l(null);return c(e,()=>{if(!o.current)return;const e=o.current,n=t?.();if(!n||"object"!=typeof n)throw new Error("attributes must return a plain object of values");const r=Object.keys(n),i=r.length;for(let t=0;t<i;t++){const o=r[t],i=n[o];Object.defineProperty(e,o,{value:i,writable:!0,configurable:!0,enumerable:!0})}return e},n),o}const Zt=t=>e(yt,{...t}),Jt=({width:t,height:n})=>e("div",{className:"corner",style:{minWidth:`${t}px`,width:`${t}px`,minHeight:`${n}px`,height:`${n}px`}}),Qt=r(a((o,r)=>{const{children:c,viewport:a,onScrollViewport:u,showHorizontalScrollbar:h=!0,showVerticalScrollbar:f=!0,createScrollCorner:p=Jt,createHorizontalScrollbar:g=Zt,createVerticalScrollbar:w=Zt,style:m,touchElement:x,disableTouch:y,...v}=o,b=gt(u,[u]),S=Gt(r,()=>({isScrollPane:()=>!0}),[]),_=l(null);s(()=>{_.current&&(_.current.__scrollTop===a?.top&&_.current.__scrollLeft===a?.left||_.current.__isDecelerating||_.current?.scrollTo(a?.left,a?.top,!1))},[a?.left,a?.top,x]);const E=i((e,t)=>{b?.({left:e,top:t})},[]),I=i(e=>{_.current?.doTouchStart(e.touches,e.timeStamp)},[]),C=i(e=>{e.preventDefault(),_.current?.doTouchMove(e.touches,e.timeStamp)},[]),M=i(e=>{_.current?.doTouchEnd(e.timeStamp)},[]),T=i(({containerWidth:e,containerHeight:t,totalWidth:n,totalHeight:o})=>{_.current.setDimensions(e,t,n,o)},[]);s(()=>{const e=x??S.current;if(!y&&qt().supportsTouchEvents&&e&&a){if(!_.current){const e={scrollingX:!0,scrollingY:!0,decelerationRate:.95,penetrationAcceleration:.08};_.current=new Mt(E,e)}qt().supportsTouchEvents&&(e.addEventListener("touchstart",I),e.addEventListener("touchend",M),e.addEventListener("touchmove",C)),T({containerWidth:a?.width,containerHeight:a?.height,totalWidth:a?.totalWidth,totalHeight:a?.totalHeight})}return()=>{e?.removeEventListener("touchstart",I),e?.removeEventListener("touchend",M),e?.removeEventListener("touchmove",C)}},[a?.width,a?.height,a?.totalWidth,a?.totalHeight,y,x]);const[k,{width:R}]=pt(),[P,{height:O}]=pt(),L=d(()=>{const t=w({orientation:st.Vertical,offset:a?.top,viewportSize:a?.height,totalSize:a?.totalHeight,onScrollOffset:e=>{b?.({top:e})}});return e("div",{style:{display:"flex",flex:"0"},ref:k,children:t})},[w,a?.top,a?.height,a?.totalHeight]),D=d(()=>{const o=g({orientation:st.Horizontal,offset:a?.left,viewportSize:a?.width,totalSize:a?.totalWidth,onScrollOffset:e=>b?.({left:e})});return t("div",{style:{display:"flex",flex:"none",flexDirection:"row",alignItems:"stretch",justifyContent:"center"},children:[e("div",{style:{display:"flex",flex:"1 1 100%",flexDirection:"column",width:`calc(100% - ${R}px)`},children:e("div",{ref:P,className:"sizer",children:o})}),f?p({width:R,height:O}):e(n,{})]})},[g,a?.left,a?.width,a?.totalWidth,f,p,R,O]);return e("div",{style:{position:"relative",display:"flex",minWidth:f?`${R}px`:void 0,minHeight:h?`${O}px`:void 0,...m},...v,ref:S,children:t("div",{style:{position:"relative",width:"100%",flex:"1 1 100%",display:"flex",flexDirection:"column",boxSizing:"border-box"},children:[t("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:[e("div",{style:{display:"flex",flex:"1 1 100%",overflow:"hidden"},children:c}),f?L:e(n,{})]}),h?D:e(n,{})]})})}));Qt.displayName="ScrollPane";const en=()=>{const e=document.fullscreenElement;return e?e.querySelector(".fullscreen-portal-root")||e:document.body};let tn=0;function nn(){return s(()=>{function e(){const e=document.fullscreenElement;if(!e)return;let t=e.querySelector(".fullscreen-portal-root");t||(t=document.createElement("div"),t.className="fullscreen-portal-root _fullscreen-portal-root_1mjsr_4",e.appendChild(t))}return tn++,e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),tn--,tn<=0&&(document.querySelectorAll(".fullscreen-portal-root").forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),tn=0)}},[]),{getPortalContainer:en}}const on=100,rn=100,ln=1e6,sn=100,cn=50,an=r(a((t,n)=>{const{offset:o=0,viewportSize:r=0,totalSize:s=0,minSize:c=0,endGap:a=on,endScrollIncrement:d=rn,style:f=Kt,onMouseDown:p,onScrollOffset:g,onScroll:w,scaleLimit:m=ln,scaleFactor:x=sn,precisionFactor:y=cn,...v}=t;w&&console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");const b=gt(p,[p]),S=()=>({offset:o,totalSize:0===m?s:Math.min(s??0,Math.max(c??0,(o??0)+(r??0))+(a??0))}),[_,E]=h(S),I=0!==m&&_.totalSize>m?x:1,C=I/y,M=Math.ceil(_.totalSize/I),T=Math.ceil(_.offset/I),k=Math.ceil(r/I),R=i(e=>{},[]),[P,O]=h(!1),L=l(null);u(()=>{if(!P){L.current={propTotalSize:s,propViewportSize:r,propOffset:o};const e=S();E(e)}},[s,r,o,P,c,a,d]);const D=gt((e,t,n)=>{const i=L.current;L.current=null,i&&i.propTotalSize===s&&i.propViewportSize===r&&i.propOffset===o||(Math.abs(e-T)<C&&(e=T),g?.(e*I,T,k))},[g,I,C,T,k]),z=i(e=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",z),O(!1)},[]),A=i(e=>{b?.(e),O(!0),document.addEventListener("mousemove",R,{passive:!0}),document.addEventListener("mouseup",z,{passive:!0})},[R,z]);return e(yt,{ref:n,style:{...f},...v,offset:T,totalSize:M,viewportSize:k,onMouseDown:A,onScrollOffset:D})}));function dn(e,t){if("function"==typeof e)return e(t);e&&(e.current=t)}an.displayName="VirtualScrollbar";var un=parseInt(f.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const e=dn(o,t),r="function"==typeof e;n.push(r?e:()=>dn(o,null))}return()=>{for(const e of n)e()}}}:function(e){return t=>{for(const n of e)dn(n,t)}};r(a((t,n)=>{const{refFocusStart:o,...r}=t,s=l(null),c=i(()=>{if(o)return void o?.current?.focus();const e=s.current.parentElement.children;let t=[];for(let n=0;n<e.length&&e[n]!==s.current;n++){const o=e[n].getAttribute("tabindex");if(null==o||"-1"===o)continue;if("true"===e[n].getAttribute("disabled"))continue;const r=e[n];r.focus&&t.push({tabindex:parseInt(o),child:r})}0!==t.length&&(t.sort(function(e,t){return e.tabindex-t.tabindex}),t[0].child.focus())},[o]);return e("div",{tabIndex:0,ref:un([s,n]),onFocus:c,...r})})),r(a((r,i)=>{const{className:s,style:c,children:a,radius:u=4,strokeWidth:h=1,strokeColor:f="grey",...p}=r,[g,{width:w,height:m}]=pt(),x=l(null),y=(e,t=0)=>{const n=e/2,o=m-n+t;return function(e,t,n=!1){if(0===t)return e;function o(e,t,n){let o=t.x-e.x,i=t.y-e.y,l=Math.sqrt(o*o+i*i);return r(e,t,Math.min(1,n/l))}function r(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function i(e,t){e.length>2&&(e[e.length-2]=t.x,e[e.length-1]=t.y)}function l(e){return{x:parseFloat(e[e.length-2]),y:parseFloat(e[e.length-1])}}let s=e.split(/[,\s]/).reduce(function(e,t){let n=t.match("([a-zA-Z])(.+)");return n?(e.push(n[1]),e.push(n[2])):e.push(t),e},[]).reduce(function(e,t){return parseFloat(t)==t&&e.length?e[e.length-1].push(t):e.push([t]),e},[]),c=[];if(s.length>1){let e=l(s[0]),a=null;"Z"===s[s.length-1][0]&&s[0].length>2&&(a=["L",e.x,e.y],s[s.length-1]=a),c.push(s[0]);for(let e=1;e<s.length;e++){let d=c[c.length-1],u=s[e],h=u===a?s[1]:s[e+1];if(h&&d&&d.length>2&&"L"===u[0]&&h.length>2&&"L"===h[0]){let e,s,a=l(d),f=l(u),p=l(h);n?(e=r(f,d.origPoint||a,t),s=r(f,h.origPoint||p,t)):(e=o(f,a,t),s=o(f,p,t)),i(u,e),u.origPoint=f,c.push(u);let g=r(e,f,.5),w=r(f,s,.5),m=["C",g.x,g.y,w.x,w.y,s.x,s.y];m.origPoint=f,c.push(m)}else c.push(u)}if(a){let e=l(c[c.length-1]);c.push(["Z"]),i(c[0],e)}}else c=s;return c.reduce(function(e,t){return e+t.join(" ")+" "},"")}(`M 0 ${n} L ${u-.5} ${n} L ${u-.5} ${o} L ${2*u} ${o} L ${w-2*u} ${o} M ${w-2*u} ${o} L ${w-u} ${o} L ${w-u} ${n} L ${w} ${n}`,u)},v=d(()=>y(h),[w,m,u,h]),b=d(()=>{if(0===u)return;const e=u/2;return y(u)+`L ${w} 0 L 0 0 L 0 ${e}`},[v,u,h]),S=d(()=>({style:{clipPath:`path('${b}')`}}),[b]);return t("div",{className:s,style:{display:"flex",flexDirection:"row",...c},...p,ref:un([x,g,i]),children:[o.isValidElement(a)?o.cloneElement(a,S):e(n,{}),e("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none"},width:w,height:m,viewBox:`0 0 ${w} ${m}`,children:e("path",{d:v,stroke:f,fill:"none",vectorEffect:"non-scaling-stroke",strokeWidth:h})})]})}));const hn={},fn=t=>{const{onPointerDown:n,style:o,splitDirection:r,paddingBefore:i=0,paddingAfter:l=0,disabled:s,key:c,hitAreaProps:a=hn,...d}=t,u="row"===r,{style:h,className:f,...p}=a;return e("div",{style:{...o,position:"relative"},...d,children:e("div",{className:at("hit-box",f),style:{left:(u?-i:0)+"px",width:`calc(100% + ${u?i+l:0}px)`,top:(u?0:-i)+"px",height:`calc(100% + ${u?0:i+l}px)`,position:"absolute",...h},onPointerDown:s?void 0:n,...p})},c)},pn={},gn=(e,t,n=!0)=>null===e?null:null!==e.pixels?n?e.pixels:t-e.pixels:(n?e.percent:100-e.percent)/100*t,wn=(e,t=!0)=>e?.percent?`${t?e.percent:100-e.percent}%`:e?.pixels?`${e.pixels}px`:void 0,mn=(e,t)=>{if(null==e)return null;const n={percent:null,pixels:null};let o=t;return"string"==typeof e&&((e=e.trim().toLowerCase()).endsWith("px")?(e=e.substring(0,e.length-2),o=!1):e.endsWith("%")&&(e=e.substring(0,e.length-1),o=!0),e=parseFloat(e)),o?n.percent=e:n.pixels=e,Object.freeze(n)};function xn(e){if(!e)throw new Error("must have a PointerHandlerOptions");const{onPointerDown:t,onPointerUp:n,onPointerMoveOrWait:o,processTouch:r=!1,consumeTouch:c=!0}=e,a=gt(t,[t]),d=gt(n,[n]),u=gt(o,[o]),h=l(!1),f=e?.timerInitial??230,p=e?.timerContinuous??f/2,g=l(null),w=l(null),m=l(null),x=l(null),y=i(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),v=i(e=>{x.current=setTimeout(()=>{window.requestAnimationFrame(()=>{!1!==h.current&&u?.(w.current,m.current,g.current)}),v(p)},e??f)},[]);s(()=>()=>y(),[]);const b=r?"pointer":"mouse",S=i(e=>{e.stopPropagation(),e.stopImmediatePropagation(),e.preventDefault()},[]),_=gt(e=>{document.removeEventListener(`${b}move`,C),document.removeEventListener(`${b}up`,_),document.removeEventListener("keydown",M),document.removeEventListener("keyup",T),document.removeEventListener("touchstart",S,{capture:!0}),document.removeEventListener("touchmove",S,{capture:!0}),window.removeEventListener("blur",E),y(),window.requestAnimationFrame(()=>{!1!==h.current&&(h.current=!1,d?.(e,m.current,g.current),m.current=null)})},[]),E=i(()=>{!1!==h.current&&(h.current=!1,_(w.current))},[]),I=gt(()=>{y(),v(p),window.requestAnimationFrame(()=>{!1!==h.current&&u?.(w.current,m.current,g.current)})},[p]),C=gt(e=>{w.current=e,I()},[]),M=gt(e=>{m.current={ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey},I()},[]),T=gt(e=>{m.current={ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey},I()},[p]);return gt(e=>{e.isDefaultPrevented()||(m.current={ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey},!1!==a(e,m.current)&&(g.current=e,w.current=e.nativeEvent,document.addEventListener(`${b}up`,_,{passive:!1}),document.addEventListener(`${b}move`,C,{passive:!1}),document.addEventListener("keydown",M,{passive:!1}),document.addEventListener("keyup",T,{passive:!1}),window.addEventListener("blur",E,{passive:!0}),r&&c&&(document.addEventListener("touchstart",S,{passive:!1,capture:!0}),document.addEventListener("touchmove",S,{passive:!1,capture:!0})),h.current=!0,v(f)))},[f,r])}r(a((n,r)=>{const{elementBefore:i,elementAfter:c,splitDirection:a="row",fixedPane:u=null,position:f,onPositionChange:p,minBefore:g,maxBefore:w,minAfter:m,maxAfter:x,children:y,className:v,style:b,disabled:S=!1,onDragStart:_,onDragResize:E,onDragFinish:I,resizerProps:C=pn,paneProps:M=pn,paneBeforeProps:T=pn,paneAfterProps:k=pn,createResizer:R=fn}=n;if(y)throw new Error("Use elementBefore and elementAfter instead of children.");const P=d(()=>o.isValidElement(c)&&o.isValidElement(i),[c,i]),O=d(()=>{let e=null;u&&("before"===u?e=0:"after"===u&&(e=1));const t=null===e;return{fixedPaneOffset:e,isPercent:t,minBefore:mn(g,t),maxBefore:mn(w,t),minAfter:mn(m,t),maxAfter:mn(x,t)}},[g,w,m,x]),L=gt(p,[p]),[D,z]=h(()=>mn(f,null===u));s(()=>{z(mn(f,null===u))},[f,u]);const[A,{width:$,height:B}]=pt(),[F,{width:j,height:V}]=pt(),W="row"===a?j:V,H="row"===a?$:B,N=d(()=>((e,t,n,o)=>{const r=[null,null],i=[null,null];if(e||(e={percent:null===o.fixedPaneOffset?50:null,pixels:null===o.fixedPaneOffset?null:0}),0===t)return null!=e?.pixels?1!==o.fixedPaneOffset?(r[0]=e?.pixels,i[1]=100):(r[1]=e?.pixels-n,i[0]=100):null!=e?.percent&&(1!==o.fixedPaneOffset?(i[0]=e?.percent,i[1]=100-e?.percent):(i[1]=e?.percent,i[0]=100-e?.percent)),{percents:i,pixels:r,minBefore:wn(o.minBefore,!0),maxBefore:wn(o.maxBefore,!0),minAfter:wn(o.minAfter),maxAfter:wn(o.maxAfter)};let l=gn(e,t,1!==o.fixedPaneOffset),s=t-n,c=gn(o.minBefore,s,!0)??0,a=gn(o.maxBefore,s,!0)??s,d=0,u=0,h=0,f=s;d=(gn(o.maxAfter,t,!1)??n)-n,u=gn(o.minAfter,t,!1)??t,h=Math.max(c,d),f=Math.min(a,u),l=Math.max(h,Math.min(l,f)),u=Math.min(s-l,gn(o.maxAfter,s-l,!0)??s),d=Math.min(s-l,gn(o.minAfter,s-l,!0)??s),r[0]=l,r[1]=s-r[0];const p=Math.max(0,Math.min(100,l/s*100));return i[0]=p,i[1]=100-i[0],{percents:i,pixels:r,minBefore:`${c}px`,minAfter:`${d}px`,maxBefore:`${r[0]}px`,maxAfter:`${r[1]}px`}})(D,H,W,O),[O,D,H,W,a]),[U,K]=h(!1),q=gt(_,[_]),Y=gt(E,[E]),X=gt(I,[I]),G=l(null),Z=l(null),J=l(null),{style:Q,className:ee,...te}=M,ne={minWidth:0,minHeight:0,maxWidth:"100%",maxHeight:"100%",display:"flex",overflow:"hidden",...Q},{className:oe,style:re,...ie}=T,{className:le,style:se,...ce}=k,ae={flex:"1 1 100%",width:"100%",...b,flexDirection:a,display:"flex"},{className:de,style:ue,onPointerDown:he,...fe}=C,pe=gt(e=>{const t=mn(e,null===u);z(t)},[u]),ge=gt(e=>{if(S||!U)return;const t=xe.current?.getBoundingClientRect();let n=0;n="row"===a?(e.clientX??e.touches?.[0]?.clientX)-t.x:(e.clientY??e.touches?.[0]?.clientY)-t.y,n=Math.max(0,Math.min(H,n)),1===O.fixedPaneOffset&&(n=H-n),f&&D.pixels===n||z({pixels:n,percent:null}),Y?.(n),e.stopPropagation(),e.preventDefault()},[O,a,S,U,D,H]),we=gt(e=>{if(document.removeEventListener("pointermove",ge),document.removeEventListener("touchmove",ge),document.removeEventListener("pointerup",we),U&&(K(!1),D)){if(X(D.pixels),!mn(f,null===u)||D.pixels!==f){const e={...D};null===e.percent&&(e.percent=e.pixels/H*100),L(e)}e.stopPropagation(),e.preventDefault()}},[D,U,f,u,H]),me=gt(e=>{he?.(e),e.defaultPrevented||S||U||(K(!0),q(),document.addEventListener("pointermove",ge,{passive:!1}),document.addEventListener("touchmove",ge,{passive:!1}),document.addEventListener("pointerup",we,{passive:!1}))},[he]),xe=Gt(r,()=>({setPosition:pe,isSplitPane:()=>!0}),[]),ye=d(()=>P?R?.({key:"resizer",ref:un([F,Z]),className:at("resizer",de),onPointerDownCapture:me,style:{cursor:S?void 0:"row"===a?"ew-resize":"ns-resize",minWidth:"row"===a?"2px":void 0,minHeight:"row"!==a?"2px":void 0,boxSizing:"border-box",pointerEvents:"all",zIndex:1,...ue},splitDirection:a,disabled:S,...fe}):null,[P,de,fe,a,ue,S]),ve="row"===a?"Width":"Height",be={...ne,...re,flex:0===O.fixedPaneOffset&&null!==N?.pixels[0]?`0 0 ${Math.round(N?.pixels[0])}px`:`1 1 ${Math.round(N?.percents[0]??100)}%`,[`min${ve}`]:N?.minBefore,[`max${ve}`]:c?N?.maxBefore:"100%"},Se={...ne,...se,flex:1===O.fixedPaneOffset&&null!==N?.pixels[1]?`0 0 ${Math.round(N?.pixels[1])}px`:`1 1 ${Math.round(N?.percents[1]??100)}%`,[`min${ve}`]:N?.minAfter,[`max${ve}`]:i?N?.maxAfter:"100%"},_e=d(()=>i?e("div",{ref:G,className:at("before",ee,oe),style:be,...te,...ie,children:i},"before"):null,[i,M,T,O,N]),Ee=d(()=>c?e("div",{ref:J,className:at("after",ee,le),style:Se,...te,...ce,children:c},"after"):null,[c,M,k,O,N]);return t("div",{ref:un([A,xe]),className:at("splitPane","row"===a?"vertical":"horizontal",{dragging:U},v),style:ae,children:[_e,ye,Ee]})}));const yn=({initValue:e,useHookBody:t,applyStateChange:n})=>{const o=l(e);if("function"!=typeof t)throw new Error("function expected as hook body parameter. got "+typeof t);const r=t();return u(()=>{o.current!==r&&(o.current=r,n(r))},[n,r]),null},vn=e=>{console&&console.warn&&console.warn(e)},bn="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||void 0;let Sn=1,_n=!1,En=!1;const In=[],Cn=[],Mn=()=>{Cn.forEach(e=>e())},Tn=({automaticContainerInternalUseOnly:t})=>{const[o,r]=h([]),i=l([]);return i.current=o,t||!1!==_n||(En=!0),s(()=>{let e=!0;function n(){if(e)return Cn[0]!==n?(t||!0!==_n||vn("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."),void r(e=>[])):void r([...In])}return Cn.push(n),Mn(),()=>{e=!1,i.current?.length>0&&vn("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"),Cn.splice(Cn.indexOf(n),1),Mn()}},[t]),e(n,{children:o.map(({hook:e,key:t})=>p(yn,{...e,key:t}))})},kn=(t,n,o={})=>{let r,i,l=!1,c=!1,a=[],{unmountIfNoConsumers:d=!1}=o;const u=e=>{i=e,m(()=>a.forEach(t=>t(e)))},f=()=>(c||(i="function"==typeof t?t():t,c=!0),i);return()=>{const[o,c]=h(f);return s(()=>(l||(l=!0,r=(t=>{const n=Sn++;return In.push({hook:t,key:n}),0===Cn.length&&!1===En&&(_n=!0,(t=>{if(bn.document&&bn.document.createElement){const n=bn.document.createElement("div");w(n).render(e(t,{automaticContainerInternalUseOnly:!0}))}else vn("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.")})(Tn)),Mn(),()=>{In.splice(In.findIndex(e=>e.key===n),1),Mn()}})({initValue:t,useHookBody:n,applyStateChange:u})),a.push(c),i!==o&&c(i),()=>{a.splice(a.indexOf(c),1),0===a.length&&d&&(r(),l=!1)}),[]),o}};kn(null,()=>{const[e,t]=h(null);return e});class Rn{constructor(e,t,n,o){this._listenersProperties=new Set,this._listenersExecute=new Set,this._key=e,this._target=t,this._applyProps(n||{}),this._callback=o,void 0===o&&(this._callback=()=>{console.log(`implement: ${this.label()} : ${this.description()}`)})}key(){return this._key}_resolve(e,t){if("function"==typeof e){const n=t??this._context;return e("function"==typeof n?n():n)}return e}target(){return"function"==typeof this._target?this._target():this._target}label(e,t){const n=this._scopedLabels?.[e]||this._label;let o=null;if("function"==typeof n){const e=t??this._context;o=n("function"==typeof e?e():e)}else o=n;return o}description(e){return this._resolve(this._description,e)}tags(e){return this._resolve(this._tags,e)}icon(e){return this._resolve(this._icon,e)}shortcut(){return this._resolve(this._shortcut)}disabled(){return this._resolve(this._disabled)||!this._callback}state(){return this._resolve(this._state)}context(){return"function"==typeof this._context?this._context():this._context}async execute(e,t){if(!this.disabled()&&this._callback){try{let n=!0;if(t?.beforeExecute&&(n=t?.beforeExecute(this,e)),!1===await Promise.resolve(n))return!1;const o=this._callback.bind(this)(e,this);if(!1===await Promise.resolve(o))return!1;t?.onExecute?.(this,e),this._notifyExecute(e)}catch(n){return console.warn(n),t?.onError(this,n,e),this._notifyError(e,n),!1}return!0}}addPropertyListener(e,t=!1){if(!e)throw new Error("listener must be specified");const n=this._listenersProperties;return n.add(e),t&&e({},this),()=>{n.delete(e)}}addExecuteListener(e){if(!e)throw new Error("listener must be specified");const t=this._listenersExecute;return t.add(e),function(){t.delete(e)}}_notifyExecute(e){const t=this;this._listenersExecute.forEach(n=>{n.onExecute(t,e)})}_notifyError(e,t){const n=this;this._listenersExecute.forEach(o=>{o.onError?.(n,e,t)})}updateCallback(e){return this._callback=e||null,this}update(e){if(!e)return;const t=this._applyProps(e);return Object.keys(t).length>0&&this._notifyPropertyChange(t),this}_notifyPropertyChange(e){const t=this;this._listenersProperties.forEach(n=>{n(e,t)})}_applyProps(e){let t={},n=this;return Object.keys(e).forEach(o=>{let r=e[o];n["_"+o]!==r&&(n["_"+o]=t[o]=r)}),t}}class Pn extends Rn{}Ee.getOS()===Ee.OSType.MacOS||(Ee.getOS(),Ee.OSType.IOS),Ee.getOS()===Ee.OSType.MacOS||(Ee.getOS(),Ee.OSType.IOS),kn({setClipboard:e=>{throw new Error("This is only available via the useClipboard.")},getClipboard:()=>Ke.Global,refNativeCopy:{current:null},refNativeLastKey:{current:null}},()=>{const[e,t]=h(Ke.Global);return{setClipboard:e=>t(e),getClipboard:()=>e,refNativeCopy:l(null),refNativeLastKey:l(null)}});let On=!1,Ln=0;var Dn="undefined"!=typeof document?u:s;const zn=()=>"sheetxl-ui-"+Ln++,An=o["useId".toString()],$n=null!=An?An:function(){const[e,t]=o.useState(()=>On?zn():void 0);return Dn(()=>{null==e&&t(zn())},[]),o.useEffect(()=>{On||(On=!0)},[]),e},Bn=({itemType:e,index:t,itemSize:n,instanceProps:o,scale:r=1})=>{let i,l,s;"column"===e?(i=o.columnMetadataMap,l=o.lastMeasuredColumnIndex,s=o.recalcColumnIndices):(i=o.rowMetadataMap,l=o.lastMeasuredRowIndex,s=o.recalcRowIndices);const c=s.length>0;if(t>l){let a=0;if(l>=0){const e=i[l];a=e.offset+e.size}for(let e=l+1;e<=t;e++){let t=c?s.includes(e)?n(e)*r:i[e]?.size||n(e)*r:n(e)*r;i[e]={offset:a,size:t},a+=t}"column"===e?o.lastMeasuredColumnIndex=t:o.lastMeasuredRowIndex=t}return i[t],i[t]},Fn=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,offset:r,scale:i})=>{let l,s;"column"===e?(l=o.columnMetadataMap,s=o.lastMeasuredColumnIndex):(l=o.rowMetadataMap,s=o.lastMeasuredRowIndex);let c=0;return c=(s>0?l[s].offset:0)>=r?jn({itemType:e,itemSize:t,instanceProps:o,high:s,low:0,offset:r,scale:i}):Vn({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:Math.max(0,s),offset:r,scale:i}),c=Math.min(c,n),c},jn=({itemType:e,itemSize:t,instanceProps:n,high:o,low:r,offset:i,scale:l})=>{for(;r<=o;){const s=r+Math.floor((o-r)/2),c=Bn({itemType:e,itemSize:t,index:s,instanceProps:n,scale:l}).offset;if(c===i)return s;c<i?r=s+1:c>i&&(o=s-1)}return r>0?r-1:0},Vn=({itemType:e,itemSize:t,itemCount:n,instanceProps:o,index:r,offset:i,scale:l})=>{let s=1;for(;r<n&&Bn({itemType:e,itemSize:t,index:r,instanceProps:o,scale:l}).offset<i;)r+=s,s*=2;return jn({itemType:e,itemSize:t,instanceProps:o,high:Math.min(r,n-1),low:Math.floor(r/2),offset:i,scale:l})},Wn=e=>{const{rowCount:t,columnCount:n,defaultRowHeight:o,getRowHeight:r,defaultColumnWidth:i,getColumnWidth:c}=e||{},a=l({columnMetadataMap:{},rowMetadataMap:{},lastMeasuredColumnIndex:-1,lastMeasuredRowIndex:-1,recalcColumnIndices:[],recalcRowIndices:[]}),d=gt(e=>Fn({itemType:"row",itemCount:t,itemSize:r??(()=>o??20),instanceProps:a.current,offset:e}),[t,r,o]),u=gt(e=>-1===e?0:Bn({itemType:"row",index:e,itemSize:r??(()=>o??20),instanceProps:a.current}).offset,[r,o]),f=gt(e=>Bn({itemType:"row",index:e,itemSize:r??(()=>o??20),instanceProps:a.current}).size,[r,o]),p=gt(e=>Fn({itemType:"column",itemCount:n,itemSize:c??(()=>i??75),instanceProps:a.current,offset:e}),[n,c,i]),w=gt(e=>-1===e?0:Bn({itemType:"column",index:e,itemSize:c??(()=>i??75),instanceProps:a.current}).offset,[c,i]),m=gt(e=>Bn({itemType:"column",index:e,itemSize:c??(()=>i??75),instanceProps:a.current}).size,[c,i]),[x,y]=g(e=>e+1,0),v=()=>({getRowOffset:u,getColOffset:w,getRowIndex:d,getColIndex:p}),[b,S]=h(()=>e?v():null);return s(()=>{S(e?v():null)},[x,t,n,i,o,f,m]),b},Hn="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\",Nn=e=>{if(!e)return null;if("start"===e.eventType)return{type:e.eventType};if("submit"===e.eventType)return{type:e.eventType};if("cancel"===e.eventType)return{type:e.eventType};if("keyboard"===e.eventType)return{type:e.eventType,key:e.event.key};if("pointer"===e.eventType)return{type:e.eventType};if("coordsChange"===e.eventType){const t={type:e.eventType};return e.activeCoords&&(t.activeCoords=e.activeCoords),t}return{type:e.eventType??"unknown"}},Un=e=>!0,Kn=e=>!!e&&(!(e.ctrlKey||e.metaKey||e.altKey||e.isComposing)&&(!(e.shiftKey||"F2"!==e.key&&" "!==e.key&&"Backspace"!==e.key)||(!e.shiftKey||" "!==e.key)&&-1!==Hn.indexOf(e.key))),qn=e=>!!e&&("dblclick"===e.type&&{editMode:!0}),Yn=t=>{const{session:n,refLatestCoords:o,handleSubmitEdit:r,handleCancelEdit:c,cellBounds:a,isInBounds:d,getCellEditor:u,propsEditor:f,borderStrokeFill:p="rgb(33, 115, 70)",borderStrokeWidth:g=2,alignment:w=Ye.Left,style:m,...x}=t,y=l(null),v=l(null),[b,S]=h(!1),_=n.coords,E=i(async e=>{const t=y.current?.getBoundingClientRect();if(t){if("keyboard"===e.eventType){const t=e.event,n=new KeyboardEvent(t.type,{bubbles:!0,cancelable:!0,view:window,key:t.key,code:t.code,location:t.location,repeat:t.repeat,isComposing:t.isComposing,charCode:t.charCode,keyCode:t.keyCode,which:t.which,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey});n.isSynthetic=!0,n.key,v.current?.dispatchEvent(n)}else"pointer"===e.eventType||console.warn("unsupported event type",e);await new Promise(e=>requestAnimationFrame(e))}},[]);s(()=>{const e=v.current;S(!0),v.current.startEdit?.(n.startEvent);return(async()=>{n.editorRefs.push(e),n.editorRefsDispatchEditorEvent.push(E);const t=[...n.events];for(let e=0;e<t.length;e++)await E(t[e]);n.onMount(e)})(),()=>{const t=n.editorRefs.indexOf(e);-1!==t&&n.editorRefs.splice(t,1),n.onUnmount(e)}},[]);const I=i(()=>r(n),[]),C=i(()=>{c(n)},[]),M=o.current&&Q.isEqualCells(o.current,_),T=d&&M&&b,k=u({autoFocus:!!n.startEvent?.autoFocus,...f,onSubmitEdit:I,onCancelEdit:C,ref:v},_),R=a.x+Yt.boundPixel(-g/2),P=Yt.boundPixel(a.width+g/2,!0);return e("div",{tabIndex:0,ref:y,style:{background:void 0,...m,opacity:T?m?.opacity??1:0,pointerEvents:"auto",position:"absolute",boxSizing:"border-box",top:`${a.y+Yt.boundPixel(-g/2)}px`,height:Yt.boundPixel(a.height+g/2,!0),left:`${R}px`,width:P},...x,children:e("div",{className:"editor-container",style:{position:"absolute",boxSizing:"border-box",left:`${Yt.boundPixel(1)}px`,top:`${Yt.boundPixel(1)}px`,width:Yt.boundPixel(a.width-2,!0),height:Yt.boundPixel(a.height-2,!0),outline:`${g}px ${p} solid`,boxShadow:"rgba(60,64,67,.35) 2px 2px 6px 3px",maxHeight:"100%",overflow:"hidden",display:"flex"},children:k})})},Xn=t=>{const{view:n,canEdit:o=Un,getCellEditor:r,onBeforeStartEdit:c,onStartEdit:a,onSubmitEdit:d,onCancelEdit:f,onDoneEdit:p,isEditorStartKeyEvent:w=Kn,isEditorStartPointerEvent:m=qn,containerProps:x,borderStrokeFill:y,borderStrokeWidth:v=2,getRangeCoords:b=null,activeCoords:S,alignment:_=Ye.Left}=t,[E,I]=h(!1),[C,M]=h(void 0),T=gt((e,t,n,o,r,i)=>{if(!t)return null;const l=r?.(t,e),s=e.getRangeCoordsBounds(l),c=e.toClipBounds(s),a=s,d=e.getZoom();if(!c)return null;n&&(n*=d),o&&(o*=d);let u=a,h=!1;if(void 0!==n){let t={...l},o=0;for(;!h&&u.width<=n&&o<20;){o++,o>19&&console.warn("max width reached");const r=e.getTotalRangeCoords(),l=e.getLayout();i===Ye.Left?t.colEnd+1<r.colEnd?t.colEnd=l.getColIndex(u.x+n):h=!0:i===Ye.Right?t.colStart-1>=0?t.colStart=l.getColIndex(u.x-(n-u.width)):h=!0:i===Ye.Center&&t.colEnd+1<r.colEnd&&t.colStart-1>=0?(t.colStart=l.getColIndex(u.x-(n-u.width)/2),t.colEnd=l.getColIndex(u.x+u.width+(n-u.width)/2)):h=!0,h||(u=e.getRangeCoordsBounds(t))}}u.height=a.height,void 0!==o&&(u.height=Math.max(o+1,a.height));const{width:f,height:p}=e.getViewportSize();return{x:u.x??0,y:u.y??0,height:Math.min(p-u.y,u.height)+1,width:Math.min(f-u.x,u.width)+1}},[_]),k=gt(o,[o]),R=i(()=>{n?.getStage()?.focus()},[n]),P=l(null),O=gt(e=>{c?.(e),H(),I(!0),P.current=null},[c]),L=gt(e=>{a?.(e.coords)},[a]),D=gt(e=>{e.isSubmitted||e.isCancelled||($.current.isEditorClosed=!0,R(),e.isCancelled=!0,f?.(e.coords),H())},[f]),z=gt(e=>{if(e.isSubmitted||e.isCancelled)return!1;try{return P.current=e.coords,e.isEditorClosing=!0,e.isSubmitted=!0,e.isEditorSubmitted||(e.isEditorSubmitted=!0,e.editorRefs[0]?.submitEdit?.()),e.coords,d?.(e.coords),e.isEditorClosed=!0,R(),H(),!0}catch(t){throw e.isEditorClosing=!1,e.isSubmitted=!1,t}},[d]),A=gt(e=>{I(!1),p?.(e.coords),H()},[p]),$=l(null),B=l(null),F=l(null),j=l([]),[V,W]=g(e=>e+1,0),H=i(e=>{e&&j.current.push(e),W()},[]),N=gt(e=>{if(e.defaultPrevented||e.isSynthetic)return;if(!n)return;const t=n?.getCellCoordsFromClient(e.clientX,e.clientY);if(!t)return;H({eventType:"pointer",event:e,coords:t})},[n]),U=gt(e=>{const t=e.nativeEvent;N(t)},[n]),K=gt(e=>{if(e.defaultPrevented||e.isSynthetic)return;if(!n?.getStage())return;const t=B.current;w(e,t)&&(e.stopPropagation(),e.preventDefault()),e.key;H({eventType:"keyboard",event:e,coords:t})},[n]);u(()=>{const e=(e,t)=>{const o=t?.cell??e;if(!o)return null;const r=o;if(!k(o))return null;O?.(o);const i=Ee.uuidV4();t=Object.freeze({autoFocus:!0,...t}),F.current=o;const l={coords:r,startEvent:t,uuid:i,isMounted:!1,isStarted:!1,isSubmitted:!1,isEditorSubmitted:!1,isEditorClosing:!1,isEditorClosed:!1,isCancelled:!1,events:[],editorRefsDispatchEditorEvent:[],editorRefs:[],onMount:e=>{l.isMounted||(l.isMounted=!0,H())},onUnmount:e=>{if(0===l.editorRefs.length){const e=()=>{l.isMounted=!1,H()};if(document.activeElement!==document.body)e();else{const t=e=>{e.defaultPrevented||e.target!==document.body||K(e)};window.addEventListener("keydown",t,!0),n.getStage()?.addEventListener("focusin",()=>{window.removeEventListener("keydown",t),e()},{once:!0}),R()}}}};return l};if(j.current.length<=0&&!$.current)return;const t=j.current[0];Nn(t),(e=>{const t=[],n=e?.length??0;for(let o=0;o<n;o++){const n=e[o];t.push(Nn(n))}})(j.current),$.current,$.current;let o=$.current;if($.current)if($.current.isDone)$.current=null;else if($.current.isSubmitted||$.current.isCancelled){if($.current.isMounted)return;$.current.isDone||(A($.current),$.current.isDone=!0)}if(t)if("start"===t.eventType){const n=t,o=n.startEvent?.cell??B.current;$.current&&Q.isEqualCells($.current.coords,o)||($.current=e(o,n.startEvent))}else if("keyboard"===t.eventType){const n=t.event;if($.current){let e=!1;switch(n.which){case tt:case ot:case nt:case rt:case Qe:case Je:e=!0}if(!e){$.current.events.push(t);for(let e=0;e<$.current.editorRefsDispatchEditorEvent.length;e++)$.current.editorRefsDispatchEditorEvent[e](t)}}else{if(w(n,t.coords)){let n;const o=e(n?.cell??B.current,n);o&&o.events.push(t),$.current=o}}}else if("pointer"===t.eventType){const n=t.event;if($.current){$.current.events.push(t);for(let e=0;e<$.current.editorRefsDispatchEditorEvent.length;e++)$.current.editorRefsDispatchEditorEvent[e](t)}else{const o=t?.coords??B.current,r=m(n,o);if(r){let n;"boolean"!=typeof n&&(n=r);const i=e(o,n);i&&i.events.push(t),$.current=i}}}else if("submit"===t.eventType){if($.current&&!$.current.isSubmitted&&!$.current.isCancelled){if(!$.current.isMounted)return;z($.current)}}else if("cancel"===t.eventType){if($.current&&!$.current.isSubmitted&&!$.current.isCancelled){if(!$.current.isMounted)return;D($.current)}}else if("coordsChange"===t.eventType){const e=t;if(B.current=e.activeCoords,$.current,$.current&&!$.current.isSubmitted&&!$.current.isCancelled){if(!$.current.isMounted)return;try{z($.current)}catch(e){}}}j.current.length>0&&(j.current.shift(),H()),0===j.current.length&&(!$.current||$.current.isEditorClosing||$.current.isEditorClosed?!$.current&&o&&R():$.current.isMounted&&!$.current.isStarted&&($.current.isStarted=!0,$.current.startEvent.autoFocus&&("string"==typeof $.current.startEvent.autoFocus?$.current.editorRefs[0]?.autoFocus($.current.startEvent.autoFocus):$.current.editorRefs[0]?.autoFocus()),L?.($.current),requestAnimationFrame(()=>{n&&$.current?.coords&&n.scrollCellCoordsIntoView($.current.coords)})))},[V]),s(()=>{F.current=S;const e=$.current?.coords;if(!Q.isEqualCells(e,S)){$.current&&($.current.isEditorClosing=!0);H({eventType:"coordsChange",activeCoords:S})}},[S]);const q=i(e=>{K(e.nativeEvent)},[]),{width:Y=0,height:X=0}=C??{width:0,height:0},G=gt(r,[r]);return{overlay:gt(t=>{if(!$.current||$.current.isEditorClosed)return $.current,null;$.current.coords;let n=T(t,$.current.coords,Y,X,b,_),o=!0;n&&0!==n.width&&0!==n.height||(n={x:0,y:0,width:Y,height:Y},o=!1);const r=t.getZoom(),i={containerBounds:{x:0,y:0,width:n.width/r,height:n.height/r},setNaturalDimensions:M,zoom:r};return e(Yn,{session:$.current,refLatestCoords:F,handleSubmitEdit:z,handleCancelEdit:D,cellBounds:n,borderStrokeWidth:v,borderStrokeFill:y,isInBounds:o,getCellEditor:G,propsEditor:i,alignment:_,...x},"editor:"+$.current.uuid)},[r,b,V,Y,X,_,v,y]),startEdit:i(e=>{H({eventType:"start",startEvent:e})},[]),submitEdit:i(()=>{H({eventType:"submit"})},[]),cancelEdit:i(()=>{H({eventType:"cancel"})},[]),onKeyboardEvent:q,onPointerEvent:U,onKeyboardEventNative:K,onPointerEventNative:N,isEditing:E}},Gn=({gridRef:e,gridMainRef:t,orientation:n=D,headerCount:o,selectionPolicy:r="multiple",newSelectionMode:s="clear",alwaysScrollToActiveCoords:c=!0,onDragStart:a,onDragEnd:u,pointerDownInterceptor:h,pointerMoveInterceptor:f,onPointerUp:p,newSelection:g,modifySelection:w,appendSelection:m,clearSelections:x})=>{const y=o??((n===D?e.current?.rowCount:e.current?.columnCount)||0),v=l(null),b=l(null),S=l(!1),_=l(null),E=i(e=>n===L?{rowIndex:0,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:0},[n]),I=i(e=>n===L?{rowIndex:t.current?t.current.rowCount-1:0,colIndex:e.colIndex}:{rowIndex:e.rowIndex,colIndex:t.current?t.current.columnCount-1:0},[n]),C=e=>{b.current=I(e),w(b.current,v.current)},M=i((o,r)=>{if(!e.current)return;const i=e.current.getViewFromClient(o,r)?.getCellCoordsFromClient(o,r);return i?(n===L?i.rowIndex=t.current.getViewport().rowStart:i.colIndex=t.current.getViewport().colStart,i):void 0},[]),T=i((e,o=!1)=>{let r=e;return o||(r={...e},n===D?delete r.colIndex:delete r.rowIndex),t.current?.scrollCellCoordsIntoView(r)},[n]),k=gt(u,[u]),R=gt(a,[a]),P=d(()=>({onPointerDown:o=>{if(!e||!e.current)return;if(o.nativeEvent.defaultPrevented)return;const r=M(o.nativeEvent.clientX,o.nativeEvent.clientY);if(!r)return;o.nativeEvent.which;const i=o.nativeEvent.shiftKey,l=o.nativeEvent.ctrlKey||o.nativeEvent.metaKey;if(!1===h?.(o,r))return;R?.(),S.current=!0;const s=t.current?.getViewFromClient(o.nativeEvent.clientX,o.nativeEvent.clientY),a=((e,t)=>n===L?{...e,rowIndex:t.rowStart}:{...e,colIndex:t.colStart})(r,s.getVisibleRangeCoords());if(i)C(r);else{if(l)return((e,t=e,n)=>{v.current=E(e),b.current=I(t),m(v.current,b.current,n)})(r,r,a),void(c&&T(a,!0));((e,t=e,n)=>{v.current=E(e),b.current=I(t),g(v.current,b.current,n)})(r,r,a),C(r),c&&T(a,!0)}},onPointerMoveOrWait:Ee.throttle(t=>{if(!S.current||!e?.current)return;const n=M(t.clientX,t.clientY);if(n&&!1!==f?.(t,n)){if(Q.isEqualCells(_.current,n))return x();C(n),T(n)}},60),onPointerUp:e=>{S.current=!1,k?.(),p?.(e)},processTouch:!0,consumeTouch:!0}),[r,c,y,s,x,h,p]);return{onPointerDown:gt(xn(P),[]),getCellCoordsFromClient:M}},Zn=(e,t,n)=>{if(!e)return t;let o=t;const r=n===S||n===v;for(;;){const t=e(o,!r);if(0===t)return o;r?o+=t:o-=t}},Jn=(e,t,n)=>{const o=[];let r=t;for(;r<=n;){const t=Math.max(0,e(r));0===t?(o.push(r),r++):r+=t}return o},Qn=(e,t,n,o,r,i)=>{if(!t)return i;let{rowIndex:l,colIndex:s}=e;switch(o){case v:{l=Zn(n,Math.min(l+1,i),o);let e=t({rowIndex:l,colIndex:s});for(;!e&&l<i;)l=Zn(n,Math.min(++l,i),o),e=t({rowIndex:l,colIndex:s});return l}case y:{l=Zn(n,Math.max(l-1,i),o);let e=t({rowIndex:l,colIndex:s});for(;!e&&l>i;)l=Zn(n,Math.max(--l,i),o),e=t({rowIndex:l,colIndex:s});return l}case S:{s=Zn(n,Math.min(s+1,i),o);let e=t({rowIndex:l,colIndex:s});for(;!e&&s<i;)s=Zn(n,Math.min(++s,i),o),e=t({rowIndex:l,colIndex:s});return s}case b:{s=Zn(n,Math.max(s-1,i),o);let e=t({rowIndex:l,colIndex:s});for(;!e&&s>i;)s=Zn(n,Math.max(--s,i),o),e=t({rowIndex:l,colIndex:s});return s}default:return i}},eo=(e,t=()=>!0,n,o,r,i)=>{let{rowIndex:l,colIndex:s}=e;switch(o){case v:{l=Zn(n,Math.min(l+1,i),o);let e=t?.({rowIndex:l,colIndex:s});for(;e&&l<i;)l=Zn(n,Math.min(++l,i),o),e=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l-1}case y:{l=Zn(n,Math.max(l-1,i),o);let e=t?.({rowIndex:l,colIndex:s});for(;e&&l>i;)l=Zn(n,Math.max(--l,i),o),e=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?l:l+1}case S:{s=Zn(n,Math.min(s+1,i),o);let e=t?.({rowIndex:l,colIndex:s});for(;e&&s<i;)s=Zn(n,Math.min(++s,i),o),e=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s-1}case b:{s=Zn(n,Math.max(s-1,i),o);let e=t?.({rowIndex:l,colIndex:s});for(;e&&s>i;)s=Zn(n,Math.max(--s,i),o),e=t?.({rowIndex:l,colIndex:s});return t?.({rowIndex:l,colIndex:s})?s:s+1}default:return null}},to=(e,t,n,o,r,i)=>{if(!t)return i;let l,{rowIndex:s,colIndex:c}=e;o===v?l={rowIndex:s+1,colIndex:c}:o===y?l={rowIndex:s-1,colIndex:c}:o===S?l={rowIndex:s,colIndex:c+1}:o===b&&(l={rowIndex:s,colIndex:c-1});const a=t(e),d=t(l);var u,h;return(h=d,!(u=a)&&!h||!u&&h||u&&!h?Qn:eo)(e,t,n,o,!1,i)??i},no=(e,t)=>`${e}:${t}`,oo=(e,t,n,o,r,i)=>{if(n-t>=r-o)return o;let l=o;if("nearest"===e&&(o-t>0?e="start":n-r>0&&(e="end")),"start"===e)l=t;else if("end"===e)l=n-(r-o);else if("center"===e){l=t+(n-t)/2-(r-o)/2}return Math.max(0,Math.min(l,i-(r-o)))},ro=(e,t,n,o)=>(console.log("todo: implement convertToVisibleRanges"),e),io=(e,t=S,n,o,r,i=null)=>{if(i&&Q.isEqualSelectionCoords(i,e))return e;const l=e.ranges[e.rangeIndex];if(!Q.isRangesIntersect({rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},l))return e;let s={...e.cell},c=e.rangeIndex;switch(t){case S:s.colIndex=Zn(r,s.colIndex+1,t);break;case b:s.colIndex=Zn(r,s.colIndex-1,t);break;case v:s.rowIndex=Zn(o,s.rowIndex+1,t);break;case y:s.rowIndex=Zn(o,s.rowIndex-1,t)}const a=t=>{if(t){c=e.rangeIndex>=e.ranges.length-1?0:e.rangeIndex+1;const t=e.ranges[c];s={colIndex:t.colStart,rowIndex:t.rowStart}}else{c=e.rangeIndex<=0?e.ranges.length-1:e.rangeIndex-1;const t=e.ranges[c];s={colIndex:t.colEnd,rowIndex:t.rowEnd}}};if(t===S&&s.colIndex>l.colEnd&&s.rowIndex===l.rowEnd)a(!0);else if(t===b&&s.colIndex<l.colStart&&s.rowIndex===l.rowStart)a(!1);else if(t===v&&s.colIndex===l.colEnd&&s.rowIndex>l.rowEnd)a(!0);else if(t===y&&s.colIndex===l.colStart&&s.rowIndex<l.rowStart)a(!1);else{let e=s.rowIndex,n=s.colIndex;switch(t){case S:n>l.colEnd&&(e=Zn(o,e+1,t),n=l.colStart,e>l.rowEnd&&(e=l.rowStart));break;case b:n<l.colStart&&(e=Zn(o,e-1,t),n=l.colEnd,e<l.rowStart&&(e=l.rowEnd));break;case v:e>l.rowEnd&&(n=Zn(r,n+1,t),e=l.rowStart,n>l.colEnd&&(n=l.colStart));break;case y:e<l.rowStart&&(n=Zn(r,n-1,t),e=l.rowEnd,n<l.colStart&&(n=l.colEnd))}s={rowIndex:e,colIndex:n}}let d=n(s);if(!Q.isRangeWithinRange(d,l)){const e=Q.intersectRanges(d,l);e&&(d=e)}let u={rowStart:Zn(o,d.rowStart,v),colStart:Zn(r,d.colStart,S),rowEnd:Zn(o,d.rowEnd,y),colEnd:Zn(r,d.colEnd,b)};if(u.rowStart!==s.rowIndex||u.colStart!==s.colIndex){switch(t){case S:e.ranges[c].colStart===u.colStart&&e.ranges[c].colEnd===u.colEnd&&(s.rowIndex=u.rowEnd),s.colIndex=u.colEnd;break;case b:e.ranges[c].colStart===u.colStart&&e.ranges[c].colEnd===u.colEnd&&(s.rowIndex=u.rowStart),s.rowIndex===u.rowStart?s.colIndex=u.colStart+1:s.colIndex=u.colStart;break;case v:e.ranges[c].rowStart===u.rowStart&&e.ranges[c].rowEnd===u.rowEnd&&(s.colIndex=u.colEnd),s.rowIndex=u.rowEnd;break;case y:e.ranges[c].rowStart===u.rowStart&&e.ranges[c].rowEnd===u.rowEnd&&(s.colIndex=u.colStart),s.colIndex===u.colStart?s.rowIndex=u.rowStart+1:s.rowIndex=u.rowStart}return io({cell:s,ranges:e.ranges,rangeIndex:c},t,n,o,r,i??e)}return{ranges:e.ranges,cell:s,rangeIndex:c}},lo=(e,t)=>{let n,o=0,r=0;return t.colStart<e.colStart?(n=b,o=e.colStart-t.colStart,r=t.colStart):t.colEnd>e.colEnd?(n=S,o=t.colEnd-e.colEnd,r=t.colEnd):t.rowStart<e.rowStart?(n=y,o=e.rowStart-t.rowStart,r=t.rowStart):t.rowEnd>e.rowEnd&&(n=v,o=t.rowEnd-e.rowEnd,r=t.rowEnd),{direction:n,amount:o,index:r}},so=(e,t=!1,n,o)=>{if(!n)return 0;const r=!t,i=r?1:-1;let l=n(r?e:e+1),s=n(r?e+1:e),c=e+(r?2:-1),a=0;for(;(s-l)*i<=0;){if(r&&c-1>o+1||!r&&c+1<o)return a;l=s,s=n(c),c+=i,a++}return a},co=(e,t,n,o,r)=>{const i={};let l=null,s=null;for(let c=0;c<=n.length&&n[c]<=r;c++){const r=n[c];if(r<o)continue;const a=l===r?s:t?e.getColOffset(r):e.getRowOffset(r),d=t?e.getColOffset(r+1):e.getRowOffset(r+1);l=r+1,s=d,i[r]=Object.freeze({offset:a,size:d-a,spanIndex:c})}return Object.freeze(i)},ao=(e,t,n)=>{const o=e.getColOffset(t.colStart)+(n?.left??0),r=e.getRowOffset(t.rowStart)+(n?.top??0);return{x:o,y:r,width:e.getColOffset(t.colEnd+1)+(n?.right??0)-(n?.left??0)-o,height:e.getRowOffset(t.rowEnd+1)+(n?.bottom??0)-(n?.top??0)-r}},uo=(e,t,n)=>!!n&&(!(e<n.x||e>n.x+n.width)&&!(t<n.y||t>n.y+n.height)),ho=(e,t=!0)=>`M ${Yt.boundPixel(e.left)} ${Yt.boundPixel(e.top)} L ${Yt.boundPixel(e.right,!0)} ${Yt.boundPixel(e.top)} L ${Yt.boundPixel(e.right,!0)} ${Yt.boundPixel(e.bottom,!0)} L ${Yt.boundPixel(e.left)} ${Yt.boundPixel(e.bottom,!0)} L ${Yt.boundPixel(e.left)} ${Yt.boundPixel(e.top)} ${t?"Z":""}`,fo=t=>{const{linePoints:n,bounds:o,pathProps:r,style:i,...l}=t;return e("svg",{width:`${Yt.boundPixel(o.width,!0)}`,height:`${Yt.boundPixel(o.height,!0)}`,viewBox:`0 0 ${Yt.boundPixel(o.width,!0)} ${Yt.boundPixel(o.height,!0)}`,style:{position:"absolute",left:`${Yt.boundPixel(o.x)}px`,top:`${Yt.boundPixel(o.y)}px`,width:`${Yt.boundPixel(o.width,!0)}px`,height:`${Yt.boundPixel(o.height,!0)}px`,pointerEvents:"none",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",...i},...l,children:e("path",{d:`M ${Yt.boundPixel(n[0])} ${Yt.boundPixel(n[1])} L ${Yt.boundPixel(n[2])} ${Yt.boundPixel(n[3])}`,fill:"none",vectorEffect:"non-scaling-stroke",stroke:"black",...r})})},po=n=>{const{x:o=0,y:r=0,width:i=0,height:l=0,fill:s,stroke:c,strokeWidth:a=0,strokeDasharray:d,strokeDashoffset:u,clipPath:h,pathBounds:f,pathProps:p,style:g,...w}=n,m=r,x=o,y=i,v=l;let b=null;if(s){let t=ho({top:0,left:0,bottom:v,right:y});f&&(t=t+" "+ho({top:f.y-m,left:f.x-x,bottom:f.height+f.y-m,right:f.width+f.x-x})),b=[e("path",{d:t,fill:s,stroke:"none",fillRule:"evenodd"},"fill")]}return t("svg",{width:`${Yt.boundPixel(i,!0)}`,height:`${Yt.boundPixel(l,!0)}`,viewBox:`0 0 ${Yt.boundPixel(i,!0)} ${Yt.boundPixel(l,!0)}`,preserveAspectRatio:"none",style:{position:"absolute",left:`${Yt.boundPixel(o)}px`,top:`${Yt.boundPixel(r)}px`,pointerEvents:"none",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top, width, height",willChange:"left, top, width, height, stroke-dashoffset",boxShadow:"rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px",overflow:"visible",...g},...w,children:[b,e("path",{d:ho({top:0,left:0,right:y,bottom:v}),fill:"none",strokeDasharray:d,strokeDashoffset:u,stroke:c,vectorEffect:"non-scaling-stroke",strokeWidth:a,...p})]})},go=t=>{const{key:n,...o}=t;return e(wo,{...o},n)},wo=r(t=>{const{stroke:n,fill:o,x:r=0,y:i=0,width:l=0,height:c=0,style:a,isAnimatedStroke:d,animatedStrokeProps:u,range:h,cell:f,...p}=t,g=d||!!u,w={name:"walking-offset",dashGap:2,speed:50,dashLength:8,...u};let m=w.dashGap+w.dashLength;const x=w.speed*m,y=$n().replaceAll(":",""),v=`${w.name}-${y}`;let b;return s(()=>{if(!g)return;const e=`@keyframes ${v} {\n to {\n stroke-dashoffset: 0px;\n }\n }`,t=document.createElement("style");t.appendChild(document.createTextNode(e)),document.head.appendChild(t);return t.sheet.insertRule(e,0),()=>{document.head.removeChild(t)}},[g]),g&&(b={strokeDasharray:`${w.dashLength}px ${w.dashGap}px`,strokeDashoffset:`${m}px`,animation:`${v} ${x}ms linear infinite`,willChange:"stroke-dashoffset"}),e(po,{x:r,y:i,width:l,height:c,stroke:n,fill:o,shapeRendering:"crispEdges",style:{...b,...a},...p})});function mo(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=mo(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function xo(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=mo(e))&&(o&&(o+=" "),o+=t);return o}wo.displayName="Selection";const yo=r(a((t,n)=>{const{x:o=0,y:r=0,borderWidth:i=1,size:l=6,borderStroke:s,corner:c,style:a,className:d,background:u,...h}=t;if(0===o||0===r)return null;let f=!0,p=!0,g=!0,w=!0;switch(c){case"tl":f=!1,p=!1;break;case"bl":f=!1,w=!1;break;case"br":g=!1,w=!1;break;case"tr":p=!1,g=!1}return e("div",{className:xo("fill-handle",d),style:{position:"absolute",left:o-(l+(f?i:0))/2,top:r-(l+(p?i:0))/2,width:l,height:l,borderLeft:f?`${i}px ${s}`:void 0,borderTop:p?`${i}px ${s}`:void 0,borderRight:g?`${i}px ${s}`:void 0,borderBottom:w?`${i}px ${s}`:void 0,background:u,cursor:"crosshair",pointerEvents:"all",transitionDuration:"0ms",transitionTimingFunction:"linear",transitionDelay:"0",transitionProperty:"left, top",willChange:"left, top",...a},tabIndex:-1,...h})}));yo.displayName="FillHandle";var vo=function(){},bo="undefined"!=typeof window,So=bo?u:s,_o={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const Eo=bo&&void 0!==window.ResizeObserver?function(){var e=h(null),t=e[0],n=e[1],o=h(_o),r=o[0],i=o[1],l=d(function(){return new window.ResizeObserver(function(e){if(e[0]){var t=e[0].contentRect,n=t.x,o=t.y,r=t.width,l=t.height,s=t.top,c=t.left,a=t.bottom,d=t.right;i({x:n,y:o,width:r,height:l,top:s,left:c,bottom:a,right:d})}})},[]);return So(function(){if(t)return l.observe(t),function(){l.disconnect()}},[t]),[n,r]}:function(){return[vo,_o]};function Io(e,t){if("function"==typeof e)return e(t);e&&(e.current=t)}var Co=parseInt(f.split(".")[0],10)>=19?function(e){return t=>{const n=[];for(const o of e){const e=Io(o,t),r="function"==typeof e;n.push(r?e:()=>Io(o,null))}return()=>{for(const e of n)e()}}}:function(e){return t=>{for(const n of e)Io(n,t)}};const Mo=r(a((o,r)=>{const{range:i,view:c,anchor:a,borderStroke:u="rgb(33, 115, 70)",background:f="white",borderWidth:p=1.5,size:g=22,style:w,className:m,selectionTouchPointerHandler:y,onTouchSelectStart:v,onTouchSelectEnd:b,currentTouchAnchor:S,scrollableElement:_,scrollableRoot:E=document.body,...I}=o,C=gt(v,[v]),M=gt(b,[b]),{bounds:T,coordsPivot:k,key:R}=d(()=>{if(!i||!c)return null;let e=null,t=null;switch(a){case"tl":e={colIndex:i.colEnd,rowIndex:i.rowEnd},t={colIndex:i.colStart,rowIndex:i.rowStart};break;case"br":e={colIndex:i.colStart,rowIndex:i.rowStart},t={colIndex:i.colEnd,rowIndex:i.rowEnd};break;case"t":case"l":e={colIndex:i.colEnd,rowIndex:i.rowEnd};break;case"b":e={colIndex:i.colStart,rowIndex:i.rowStart};break;case"r":e={colIndex:i.colStart,rowIndex:i.rowEnd}}let n=c.getRangeCoordsBounds(t?{rowStart:t.rowIndex,colStart:t.colIndex,rowEnd:t.rowIndex,colEnd:t.colIndex}:i);const o=c.getBounds(),r=c.getViewportSize(),l=o.x,s=o.y,d=r.width,u=r.height;switch(a){case"tl":break;case"br":n.x=n.x+n.width,n.y=n.y+n.height;break;case"t":n.x=d/2-l;break;case"b":n.x=d/2-l,n.y=n.y+n.height;break;case"l":n.y=u/2-s;break;case"r":n.x=n.x+n.width,n.y=u/2-s}const h=c.toClipBounds(n,0);return!h||h.width<=0||h.height<=0||n.x<0||n.y<0||n.x>d||n.y>u?{bounds:null,coordsAnchor:null,coordsPivot:null,key:null}:{bounds:n,coordsAnchor:null,coordsPivot:e,key:"touchSelect-"+c.getAnchor()+"-"+a}},[i,c,a]),P=l(null),O=xn(d(()=>{const e=e=>"t"===a||"b"===a?{...e,colIndex:void 0}:"l"===a||"r"===a?{...e,rowIndex:void 0}:e;return{processTouch:!0,consumeTouch:!0,onPointerDown:(t,n)=>{const o=e(c.getCellCoordsFromClient(t.clientX,t.clientY));return P.current={coordsPivot:k},C?.(a),y.onSelectionPointerDown(t,n,c,o,k,!1,!0)},onPointerMoveOrWait:(t,n,o)=>{const r=e(c.getCellCoordsFromClient(t.clientX,t.clientY));return y.onSelectionPointerMoveOrWait(t,n,o,c,r,P.current?.coordsPivot,!0,!0)},onPointerUp:(e,t,n)=>(P.current=null,M?.(a),y.onPointerUp(e,t,n))}},[y,i,c,a])),[L,{y:D,x:z}]=Eo(),A=l(null),{getPortalContainer:$}=nn(),[B,F]=h(null);return s(()=>{const t=A.current?.getBoundingClientRect();if(!t||!T)return void F(null);let n=0,o=0,i=_;for(;i;)n+=i.scrollLeft,o+=i.scrollTop,i=E&&i===E.parentElement?null:i.parentElement;F(x(e("div",{className:xo("touch-select-handle",m),ref:r,style:{position:"absolute",left:n+(t?.x??0)-(g+p)/2,top:o+(t?.y??0)-(g+p)/2,width:g,height:g,borderWidth:`${p}px`,border:u,borderRadius:"50%",background:f,boxShadow:`0 0 0 1.5px ${f}`,cursor:"grab",pointerEvents:"all",opacity:S?0:1,transitionDuration:"160ms",transitionProperty:"opacity",...w},tabIndex:-1,onPointerDown:O,...I}),E??$(),R))},[D,z,T?.x,T?.y,T?.width,T?.height,m,S,f,g,p,u,_]),T?t(n,{children:[e("div",{ref:Co([L,A]),style:{position:"absolute",left:T.x,top:T.y,opacity:0}}),B]}):null}));Mo.displayName="TouchSelectHandle";const To=-10,ko=Object.freeze({rowStart:0,colStart:0,rowEnd:0,colEnd:0}),Ro=Object.freeze({colIndex:0,rowIndex:0}),Po=Object.freeze([]),Oo=e=>{if(e&&e.cell&&e.ranges&&e.rangeIndex>-1&&e.rangeIndex<=e.ranges.length)return e;const t={cell:null,ranges:e?.ranges??Po};return t.rangeIndex=e?.rangeIndex??t.ranges.length-1,t.cell=e?.cell,!t.cell&&t.ranges.length>0&&(t.cell={rowIndex:t.ranges[t.rangeIndex].rowStart,colIndex:t.ranges[t.rangeIndex].colStart}),t.cell||(t.cell=Ro),Q.isEqualSelectionCoords(t,e)?e:t},Lo=(e,t,n)=>{const o=e.getVisibleRangeCoords(),r=e.getScrollOrientation();!r.horizontal&&(t.colIndex>o.colEnd||t.colIndex<o.colStart)&&(t={...t,colIndex:t.colIndex>o.colEnd?o.colEnd+1:o.colEnd-1},e=n.current.getViewFromLocation(C)),!r.vertical&&(t.rowIndex>o.rowEnd||t.rowIndex<o.rowStart)&&(t={...t,rowIndex:t.rowIndex>o.rowEnd?o.rowEnd+1:o.rowEnd-1},e=n.current.getViewFromLocation(C)),e.scrollCellCoordsIntoView(t)},Do=()=>!1,zo=({gridRef:t,commands:n,layout:o,selection:r,onSelectionChange:c,onSelectionDragStart:a,onSelectionDragEnd:f,selectionPolicy:g="multiple",newSelectionMode:w="clear",allowDeselectSelection:m=!0,onFillPreview:x,onFillCancel:M,onFillDone:T,onFill:k,disableFillDrag:R=!k,fillHandleBorderColor:P="white",hiddenRowsAt:O,hiddenColumnsAt:L,isContentfulCell:D,contentfulCellFinder:z=to,getDataCoords:A,alwaysScrollToActiveCoords:$=!1,selectionBounds:B,pointerDownInterceptor:F,pointerMoveInterceptor:j,mergedRanges:V,canSelectionSpanMergedCells:W=Do,onMoveDragStart:H,onMoveDragUpdate:N,onMoveDragEnd:U,onMoveDragDone:K,selectionRenderer:q=go,disableMoveDrag:Y=!U,getCellCoordsAsRangeCoords:X=Q.cellToRange,moveDragHitSize:G=6,moveDragOutlineSize:Z=4,selectionBackgroundColor:J="rgba(16, 124, 65, 0.1)",selectionBorderColor:ee="rgb(33, 115, 70)",selectionRemoveBorderColor:te="rgb(255, 0, 0)",selectionRemoveBackgroundColor:ne="rgba(250, 10, 10, 0.1)",disableTouchSelection:oe=!1,touchSelectHandleProps:re})=>{const ie=i(()=>({top:B?.top??0,left:B?.left??0,bottom:t.current?.rowCount-1||0,right:t.current?.columnCount-1||0}),[]),le=gt(k,[k]),se=gt(x,[x]),ce=gt(M,[M]),ae=gt(T,[T]),de=gt(D,[D]),ue=gt(q,[q]),he=gt((e,t=!1)=>so(e,t,o.getRowOffset,t?ie().bottom:ie().top),[o?.getRowOffset]),fe=gt(O??he,[O]),pe=gt((e,t=!1)=>so(e,t,o.getColOffset,t?ie().right:ie().left),[o?.getColOffset]),ge=gt(L??pe,[L]),[we,me]=h(()=>Oo(r)),xe=d(()=>Oo(we),[we]),ye=l(xe),ve=l(!0);u(Ee.throttle(()=>{me(e=>{ve.current=!0;const t=Oo(r);return Q.isEqualSelectionCoords(t,e)?e:t})},0),[r]),u(()=>{ye.current=xe},[xe]),s(()=>{ve.current||!c||Q.isEqualSelectionCoords(r,xe)||c(xe)},[xe]);const be=i(e=>{me(t=>{ve.current=!1,t=Oo(t);let n="function"==typeof e?e(t.ranges):e??Po;if(Q.isEqualRangesArrays(n,t.ranges))return t;let o=Math.max(n.length?0:-1,Math.min(t.rangeIndex,n.length-1)),r=t.cell;-1===o||Q.isCellWithinRange(r,n[o])||(r={rowIndex:n[o].rowStart,colIndex:n[o].colStart}),1===n.length&&Q.isSingleCell(n[0])&&Q.isCellWithinRange(r,n[0])&&(n=[],o=-1);const i={cell:r,ranges:n,rangeIndex:o};return Q.isEqualSelectionCoords(i,t)?t:i})},[]),Se=gt(e=>{me(t=>{ve.current=!1,t=Oo(t);const n=e??Ro,o=X(n);if(!Q.isSingleCell(o)&&0===t.ranges.length)return{ranges:[o],rangeIndex:0,cell:n};if(Q.isEqualCells(n,t.cell))return t;let r=t.ranges,i=t.rangeIndex;1===t.ranges.length&&(Q.isSingleCell(t.ranges[0])&&Q.isCellWithinRange(n,t.ranges[0])||!Q.isCellWithinRange(n,t.ranges[0]))&&(r=[],i=-1);const l={ranges:r,rangeIndex:i,cell:n};return Q.isEqualSelectionCoords(l,t)?t:l})},[X]),[_e,Ie]=h(null),[Ce,Me]=h(null),Te=l(null),[ke,Re]=h(null),Pe=l(null),Oe=l(null),[Le,De]=h(null),ze=l(null),Ae=l(null),$e=l(V);s(()=>{$e.current=V},[V]);const Be=gt((e,n={inline:"nearest",block:"nearest"})=>{let{rowIndex:o,colIndex:r}=e;void 0===o&&xe?.cell&&(o=xe.cell.rowIndex),void 0===r&&xe?.cell&&(r=xe.cell.colIndex),void 0!==o&&void 0!==r&&t.current?.scrollCellCoordsIntoView({rowIndex:o,colIndex:r},n)},[xe]),Fe=i(e=>{const t=ie();return e.rowIndex<t.top||e.colIndex<t.left||e.colIndex>t.right||e.rowIndex>t.bottom},[]),je=gt((e,n)=>{if(!t?.current)return null;const o={rowStart:Math.min(e.rowIndex,n.rowIndex),colStart:Math.min(e.colIndex,n.colIndex),rowEnd:Math.max(e.rowIndex,n.rowIndex),colEnd:Math.max(e.colIndex,n.colIndex)},r=W?.(o);if(r)return o;const i=X(e),l=X(n),s={rowStart:Math.min(i.rowStart,l.rowStart),colStart:Math.min(i.colStart,l.colStart),rowEnd:Math.max(i.rowEnd,l.rowEnd),colEnd:Math.max(i.colEnd,l.colEnd)};let c;return"function"==typeof $e.current?c=$e.current(s):V&&(c=V),c?Q.extendRangeToUnionRanges(s,c):s},[W,X]),Ve=gt((e,t,n)=>{const o=e.ranges.length>0?e.ranges[e.rangeIndex]:{rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},r={rowStart:Math.min(t.rowIndex??o.rowStart,n.rowIndex??o.rowStart),colStart:Math.min(t.colIndex??o.colStart,n.colIndex??o.colStart),rowEnd:Math.max(t.rowIndex??o.rowEnd,n.rowIndex??o.rowEnd),colEnd:Math.max(t.colIndex??o.colEnd,n.colIndex??o.colEnd)},i={rowIndex:r.rowStart,colIndex:r.colStart},l={rowIndex:r.rowEnd,colIndex:r.colEnd};if(Fe(i)||Fe(l))return;return je(i,l)},[je]),We=gt((e,t,n)=>{if("single"===g)return;if(!ye.current)return;const o=Ve(ye.current,e,t??ye.current.cell);if(!o)return;const r=ye.current.rangeIndex;be(e=>e.length?e.map((e,t)=>r===t?o:e):[o]),n&&o&&Se({colIndex:o.colStart,rowIndex:o.rowStart})},[]),He=i((e,t,n)=>{if(!ye.current)return;e={...ye.current?.cell,...e},t=t??e;const o=Ve(ye.current,e,t);if(!o)return;const r={rowIndex:o.rowStart,colIndex:o.colStart},i={...r,...n};"clear"===w?(ze.current=i,Ue()):"modify"===w?We(r):Ne(r),Se(i)},[]),Ne=i((e,t=e,n)=>{"multiple"!==g||!e||Fe(e)||Fe(t)||me(o=>{ve.current=!1,o=Oo(o);const r=je(e,t);if(!r)return o;let i=o.ranges.length>0?[...o.ranges]:[je(o.cell,o.cell)];i.push(r);const l={ranges:i,cell:{rowIndex:r.rowStart,colIndex:r.colStart,...n},rangeIndex:i.length-1};return Q.isEqualSelectionCoords(l,o)?o:l})},[]),Ue=()=>{be(Po)},Ke="touch"===Yt.detectIt().primaryInput,qe=l(null),Ye=l(null),Je=l(null),Qe=d(()=>({onPointerDown:e=>{if(!t||!t.current)return!1;const n=e.nativeEvent,o=t.current.getViewFromClient(n.clientX,n.clientY);if("touch"===n.pointerType||"touchstart"===n.type)return Ye.current={topLeft:o.getScrollTopLeft(),point:{x:n.clientX,y:n.clientY}},!0;const r=o.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);if(!r)return!1;qe.current={anchor:o.getAnchor(),coords:r},Ae.current=null;const i=e.nativeEvent.which===lt;if(i){if(-1!==Q.indexOfCoords(r,xe.ranges))return!1}const l=e.nativeEvent.shiftKey,s=e.nativeEvent.ctrlKey||e.nativeEvent.metaKey,c=s,d=m,u=xe.ranges.length>0,h=s&&d;if(!1===F?.(e,r,xe))return!1;a?.(ye.current,e.nativeEvent);const f=!i&&"single"!==g;if(l)return We(r),f;const p=Q.isEqualCells(r,xe.cell);if(c){if(p&&(!h||!u))return f;if(s){if(-1!==Q.indexOfCoords(r,xe.ranges)&&d){Pe.current=r;const e=je(r,r);return Oe.current=e,Re(e),f}}return Ne(r),f}$&&Be(r),p&&0===xe.ranges.length||He(r)},onPointerMoveOrWait:Ee.throttle((e,n)=>{if(!t?.current)return;if("touch"===e.pointerType||"touchmove"===e.type)return;if(!qe.current)return;const o=qe.current.anchor;let r=t.current.getViewFromLocation(o),i=r.getCellCoordsFromClient(e.clientX,e.clientY);if(!Q.isEqualCells(i,qe.current?.coords)&&(qe.current={anchor:o,coords:i},i&&!1!==j?.(e,i,ye.current))){if(Pe.current){const e={rowStart:Math.min(i.rowIndex,Pe.current.rowIndex),colStart:Math.min(i.colIndex,Pe.current.colIndex),rowEnd:Math.max(i.rowIndex,Pe.current.rowIndex),colEnd:Math.max(i.colIndex,Pe.current.colIndex)},t={rowIndex:e.rowStart,colIndex:e.colStart},n={rowIndex:e.rowEnd,colIndex:e.colEnd};if(Fe(t)||Fe(n))return;const o=je(t,n);Oe.current=o,Re(o)}else We(i);Je.current=n,Lo(r,i,t)}},60),onPointerUp:e=>{if(qe.current=null,"touch"===e.pointerType||"touchend"===e.type){if(Ye.current){const e=t.current.getViewFromClient(Ye.current.point.x,Ye.current.point.y),n=e.getScrollTopLeft();if(n.left===Ye.current.topLeft.left&&n.top===Ye.current.topLeft.top){const t=e.getCellCoordsFromClient(Ye.current.point.x,Ye.current.point.y);He(t)}}return Ye.current=null,void(qe.current=null)}try{f?.(ye.current,e)}catch(e){console.warn(e)}if(!Pe.current)return;const n=Oe.current;Pe.current=null,Oe.current=null,Re(null),me(e=>{if(ve.current=!1,0===(e=Oo(e)).ranges.length)return e;let t=[],o=-1,r=e.cell;for(let i=0;i<e.ranges.length;i++){const l=e.ranges[i];if(Q.isRangesIntersect(l,n)){const r=Ee.subtractRect({top:l.rowStart,left:l.colStart,bottom:l.rowEnd+1,right:l.colEnd+1},{top:n.rowStart,left:n.colStart,bottom:n.rowEnd+1,right:n.colEnd+1});for(let n=0;n<r.length;n++){const i={rowStart:r[n].top,colStart:r[n].left,rowEnd:r[n].bottom-1,colEnd:r[n].right-1};t.push(i),Q.isCellWithinRange(e.cell,i)&&(o=t.length-1)}}else t.push(l);t.length>0&&-1===o&&Q.isCellWithinRange(e.cell,l)&&(o=t.length-1,r={rowIndex:t[t.length-1].rowStart,colIndex:t[t.length-1].colStart})}const i={cell:r,rangeIndex:o,ranges:t};return Q.isEqualSelectionCoords(i,e)?e:i})},processTouch:!0,consumeTouch:!1}),[xe,g,m,$,w]),et=gt(xn(Qe),[]),tt=d(()=>({onSelectionPointerDown:(e,n,o,r,i=xe.cell,l=$,s=e.nativeEvent.shiftKey,c=!1)=>{if(!t||!t.current)return!1;e.stopPropagation(),e.preventDefault(),e.nativeEvent.stopImmediatePropagation();const d=o??t.current.getViewFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY),u=r??d.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);if(!u)return!1;qe.current={anchor:d.getAnchor(),coords:u},Ae.current=null;const h=e.nativeEvent.which===lt;if(h){if(-1!==Q.indexOfCoords(u,xe.ranges))return!1}const f=e.nativeEvent.ctrlKey||e.nativeEvent.metaKey,p=f,w=m,x=xe.ranges.length>0,y=f&&w;if(!1===F?.(e,u,xe))return!1;a?.(ye.current,e.nativeEvent);const v=!h&&"single"!==g;if(s)return We(u,i,c),v;const b=Q.isEqualCells(u,i);if(p){if(b&&(!y||!x))return v;if(y){if(-1!==Q.indexOfCoords(u,xe.ranges)&&w){Pe.current=u;const e=je(u,u);return Oe.current=e,Re(e),v}}return Ne(u),v}l&&Be(u),b&&0===xe.ranges.length||He(u)},onSelectionPointerMoveOrWait:(e,n,o,r,i,l=xe.cell,s=!0,c=!1)=>{if(!t?.current)return;if(e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation(),!qe.current)return;const a=qe.current.anchor;let d=r??t.current.getViewFromLocation(a),u=i??d.getCellCoordsFromClient(e.clientX,e.clientY);if(!Q.isEqualCells(u,qe.current?.coords)&&(qe.current={anchor:a,coords:u},u&&!1!==j?.(e,u,ye.current))){if(Pe.current){const e={rowStart:Math.min(u.rowIndex,Pe.current.rowIndex),colStart:Math.min(u.colIndex,Pe.current.colIndex),rowEnd:Math.max(u.rowIndex,Pe.current.rowIndex),colEnd:Math.max(u.colIndex,Pe.current.colIndex)},t={rowIndex:e.rowStart,colIndex:e.colStart},n={rowIndex:e.rowEnd,colIndex:e.colEnd};if(Fe(t)||Fe(n))return;const o=je(t,n);Oe.current=o,Re(o)}else We(u,l,c);s&&Lo(d,u,t)}},onPointerUp:e=>{qe.current=null,e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation();try{f?.(ye.current,e)}catch(e){console.warn(e)}if(!Pe.current)return;const t=Oe.current;Pe.current=null,Oe.current=null,Re(null),me(e=>{if(ve.current=!1,0===(e=Oo(e)).ranges.length)return e;let n=[],o=-1,r=e.cell;for(let i=0;i<e.ranges.length;i++){const l=e.ranges[i];if(Q.isRangesIntersect(l,t)){const r=Ee.subtractRect({top:l.rowStart,left:l.colStart,bottom:l.rowEnd+1,right:l.colEnd+1},{top:t.rowStart,left:t.colStart,bottom:t.rowEnd+1,right:t.colEnd+1});for(let t=0;t<r.length;t++){const i={rowStart:r[t].top,colStart:r[t].left,rowEnd:r[t].bottom-1,colEnd:r[t].right-1};n.push(i),Q.isCellWithinRange(e.cell,i)&&(o=n.length-1)}}else n.push(l);n.length>0&&-1===o&&Q.isCellWithinRange(e.cell,l)&&(o=n.length-1,r={rowIndex:n[n.length-1].rowStart,colIndex:n[n.length-1].colStart})}const i={cell:r,rangeIndex:o,ranges:n};return Q.isEqualSelectionCoords(i,e)?e:i})}}),[xe,g,m,$,w]),nt=gt((e,n=!1,r=!1,i=0)=>{if(!t.current||!xe.cell)return;let l=xe.cell,s=xe.cell;if(n&&xe.ranges.length>0){const t=xe.ranges[xe.rangeIndex],n=xe.cell;switch(e){case y:s={rowIndex:n.rowIndex===t.rowStart?t.rowEnd:t.rowStart,colIndex:t.colEnd},l={rowIndex:n.rowIndex===t.rowStart?t.rowStart:t.rowEnd,colIndex:t.colStart};break;case v:s={rowIndex:n.rowIndex===t.rowEnd?t.rowStart:t.rowEnd,colIndex:t.colEnd},l={rowIndex:n.rowIndex===t.rowEnd?t.rowEnd:t.rowStart,colIndex:t.colStart};break;case b:s={rowIndex:t.rowEnd,colIndex:n.colIndex===t.colStart?t.colEnd:t.colStart},l={rowIndex:t.rowStart,colIndex:n.colIndex===t.colStart?t.colStart:t.colEnd};break;case S:s={rowIndex:t.rowEnd,colIndex:n.colIndex===t.colEnd?t.colStart:t.colEnd},l={rowIndex:t.rowStart,colIndex:n.colIndex===t.colEnd?t.colEnd:t.colStart}}}const c=X(s);let{rowStart:a,colStart:d}=c;const u=ie();if(Ae.current)switch(e){case y:case v:Ae.current.colIndex>=c.colStart&&Ae.current.colIndex<=c.colEnd&&(d=Ae.current.colIndex);break;case b:case S:Ae.current.rowIndex>=c.rowStart&&Ae.current.rowIndex<=c.rowEnd&&(a=Ae.current.rowIndex)}if(!i){switch(e){case y:a=Zn(fe,Math.max(c.rowStart-1,u.top),e);break;case v:a=Zn(fe,Math.min(c.rowEnd+1,u.bottom),e);break;case b:d=Zn(ge,Math.max(c.colStart-1,u.left),e);break;case S:d=Zn(ge,Math.min(c.colEnd+1,u.right),e)}if(r)switch(e){case y:a=z({...s,colIndex:xe.cell.colIndex},de,fe,e,!1,Math.max(u.top,fe(u.top,!1)));break;case v:a=z({...s,colIndex:xe.cell.colIndex},de,fe,e,!1,Math.min(u.bottom,u.bottom-fe(u.bottom,!0)));break;case b:d=z({...s,rowIndex:xe.cell.rowIndex},de,ge,e,!1,Math.max(u.left,ge(u.left,!1)));break;case S:d=z({...s,rowIndex:xe.cell.rowIndex},de,ge,e,!1,Math.min(u.right,u.right-ge(u.right,!0)))}}let h=null;if(i){let n=0;switch(e){case y:n=o.getRowOffset(a+1),a=Math.max(u.top,o.getRowIndex(n-i)),h={top:o.getRowOffset(a+1)-(n-t.current.getScrollPosition().top)};break;case v:n=o.getRowOffset(a),a=Math.min(u.bottom,o.getRowIndex(n+i)),h={top:o.getRowOffset(a)-(n-t.current.getScrollPosition().top)};break;case b:n=o.getColOffset(d+1),d=Math.max(u.left,o.getColIndex(n-i)),h={left:o.getColOffset(d+1)-(n-t.current.getScrollPosition().left)};break;case S:n=o.getColOffset(d),d=Math.min(u.right,o.getColIndex(n+i)),h={left:o.getColOffset(d)-(n-t.current.getScrollPosition().left)}}}const f={rowIndex:a,colIndex:d},p=X(f),g={rowIndex:p.rowStart,colIndex:p.colStart};n||(Ae.current=f);const w=Q.isEqualCells(ze.current,g)&&Q.isEqualCells(ze.current,l);if(n&&!w?We(g,l):He(g),h)t.current.scrollTo(h);else{if(n&&ze.current){const t=ie();if(e===S&&ze.current.colIndex===t.left||e===b&&ze.current.colIndex===t.right||e===y&&ze.current.rowIndex===t.bottom||e===v&&ze.current.rowIndex===t.top)return}e===b||e===S?Be({colIndex:f.colIndex}):e!==y&&e!==v||Be({rowIndex:f.rowIndex})}},[xe,X]),ot=gt(e=>{if(!t.current)return;if(0===xe.ranges.length)return void nt(e);const n=X(xe.cell);if(Q.isEqualRangesArrays([n],xe.ranges))return void nt(e);const o=io(xe,e,X,fe,ge);me(e=>{ve.current=!1,e=Oo(e);const t={...e,cell:o.cell,rangeIndex:o.rangeIndex};return Q.isEqualSelectionCoords(t,e)?e:t}),o.cell&&Be(o.cell)},[xe,X]),rt=i(()=>{const e=ie();We({rowIndex:e.top},{rowIndex:e.bottom})},[]),it=i(()=>{const e=ie();We({colIndex:e.left},{colIndex:e.right})},[]),st=gt(()=>{xe.cell&&t?.current&&Be(xe.cell)},[xe.cell]),ct=i((e=!1)=>{const t={rowIndex:ie().top};e?We(t):He(t),Be(t)},[]),at=i((e=!1)=>{const t={rowIndex:ie().bottom};e?We(t):He(t),Be(t)},[]),dt=i((e=!1)=>{const t={colIndex:ie().left};e?We(t):He(t),Be(t)},[]),ut=i((e=!1)=>{const t=ie(),n={rowIndex:t.top,colIndex:t.left};e?We(n):He(n),Be(n)},[]),ht=i((e=!1)=>{const t=ie(),n={colIndex:A?.()?.colEnd??t.right};e?We(n):He(n),Be(n)},[A]),ft=i((e=!1)=>{const t=ie(),n={rowIndex:A?.()?.rowEnd??t.bottom,colIndex:A?.()?.colEnd??t.right};e?We(n):He(n),Be(n)},[A]),pt=gt(e=>{if(!t.current)return;if(xe.ranges.length<=1)return;const n=e===b||e===y;let o=xe.rangeIndex+(n?-1:1);o<0?o=xe.ranges.length-1:o>xe.ranges.length-1&&(o=0);const r=xe.ranges[o],i=io({cell:{rowIndex:r.rowEnd,colIndex:r.colEnd},rangeIndex:0,ranges:[r]},S,X,fe,ge);me(e=>{ve.current=!1,e=Oo(e);const t={...e,cell:i.cell,rangeIndex:o};return Q.isEqualSelectionCoords(t,e)?e:t}),i.cell&&Be(i.cell)},[xe,X]),wt=gt(()=>{const e=ro(xe);me(t=>{ve.current=!1,t=Oo(t);const n={...t,visibleSelection:e};return Q.isEqualSelectionCoords(n,t)?t:n}),e.cell&&Be(e.cell)},[xe,X]),mt=gt(()=>{if(!t.current)return;if(0===xe.ranges.length)return;const e=xe.cell,n=xe.ranges[xe.rangeIndex],o=ro({cell:e,rangeIndex:0,ranges:[n]}),r=o.ranges[o.rangeIndex];let i;i=r.rowStart===e.rowIndex&&r.colStart===e.colIndex?{rowIndex:r.rowStart,colIndex:r.colEnd}:r.rowStart===e.rowIndex&&r.colEnd===e.colIndex?{rowIndex:r.rowEnd,colIndex:r.colStart}:r.rowEnd===e.rowIndex&&r.colStart===e.colIndex?{rowIndex:r.rowEnd,colIndex:r.colEnd}:{rowIndex:r.rowStart,colIndex:r.colStart},me(e=>{e=Oo(e);const t={...e,cell:i};return Q.isEqualSelectionCoords(t,e)?e:t}),i&&Be(i)},[xe,X]),xt=i((e=!1)=>{nt(v,e,!1,t.current.getDimensions().containerHeight)},[]),yt=i((e=!1)=>{nt(y,e,!1,t.current.getDimensions().containerHeight)},[]),vt=i((e=!1)=>{nt(S,e,!1,t.current.getDimensions().containerWidth)},[]),bt=i((e=!1)=>{nt(b,e,!1,t.current.getDimensions().containerWidth)},[]),St=i(()=>{ot(b)},[]),_t=i(()=>{ot(S)},[]),Et=i(()=>{ot(y)},[]),It=i(()=>{ot(v)},[]),Ct=i(()=>{pt(b)},[]),Mt=i(()=>{pt(S)},[]),Tt=i(()=>{mt()},[]),kt=i(()=>{nt(b,!1,!1)},[]),Rt=i(()=>{nt(b,!0,!1)},[]),Pt=i(()=>{nt(b,!1,!0)},[]),Ot=i(()=>{nt(b,!0,!0)},[]),Lt=i(()=>{nt(S,!1,!1)},[]),Dt=i(()=>{nt(S,!0,!1)},[]),zt=i(()=>{nt(S,!1,!0)},[]),At=i(()=>{nt(S,!0,!0)},[]),$t=i(()=>{nt(y,!1,!1)},[]),Bt=i(()=>{nt(y,!0,!1)},[]),Ft=i(()=>{nt(y,!1,!0)},[]),jt=i(()=>{nt(y,!0,!0)},[]),Vt=i(()=>{nt(v,!1,!1)},[]),Wt=i(()=>{nt(v,!0,!1)},[]),Ht=i(()=>{nt(v,!1,!0)},[]),Nt=i(()=>{nt(v,!0,!0)},[]),Ut=i(()=>{be(e=>e.slice(0,-1))},[]),Kt=d(()=>{const e=ie();return((e,t,n,o,r)=>{for(let i=0;i<e.length;i++){const l=e[i];if(l.rowStart===t&&l.colStart===n&&l.rowEnd===o&&l.colEnd===r)return!0}return!1})(xe.ranges,e.top,e.left,e.bottom,e.right)},[B,xe.ranges]),qt=i((e,n=!0)=>{ze.current=e,Se(e),n&&e&&t?.current&&Be(e)},[]),Xt=gt((e=!0)=>{const t=Te.current;if(!ye.current?.cell)return;const n=ye.current?.ranges,o=ye.current?.cell;if(!o||!t)return;if(!t)return;let r=null;if(r=n.length>0?n[n.length-1]:X(o),r.colEnd>=r.colStart&&r.rowEnd>=r.rowStart){const n=lo(r,t);let o=e?le:se;try{o?.(r,t,n.direction)}catch(e){console.warn(e)}finally{e&&ae?.()}}},[X]),Gt=l(null),Zt=d(()=>({onPointerDown:(e,n)=>{if(Je.current=n,!t||!t.current)return!1;const o=t.current.getViewFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY),r=o?.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);r&&(e.stopPropagation(),Ie("crosshair"),Gt.current={anchor:o.getAnchor(),coords:r})},onPointerMoveOrWait:(e,n)=>{if(R||!t?.current||!ye.current||!Gt.current)return;const o=Gt.current.anchor;let r=t.current.getViewFromLocation(o),i=r.getCellCoordsFromClient(e.clientX,e.clientY);if(!i)return;Gt.current={anchor:o,coords:i};const l=ye.current.ranges;let s=je(ye.current.cell,i);if(!s)return;const c=l.length>0,a=c?l[l.length-1]:X(ye.current.cell);if(!s)return;const d=s.rowStart<a.rowStart?y:s.rowEnd>a.rowEnd?v:s.colEnd>a.colEnd?S:b,u=ie();d===b&&(s={...a,colStart:Math.max(u.left,s.colStart)}),d===y&&(s={...a,rowStart:Math.max(u.top,s.rowStart)}),d===S&&(s={...a,colEnd:Math.min(u.right,s.colEnd)}),d===v&&(s={...a,rowEnd:Math.min(u.bottom,s.rowEnd)});const h=lo(a,s);if(!W?.(a)){let e;"function"==typeof $e.current?e=$e.current(a):V&&(e=V),s=((e,t,n,o,r,i)=>{const l={...t};if(0===n.length)return l;if(r===b){const t=e.colEnd+1-e.colStart;l.colStart=e.colStart-Math.ceil(i/t)*t,l.colStart<o.left&&(l.colStart=l.colStart+Math.ceil((o.left-l.colStart)/t)*t)}else if(r===S){const t=e.colEnd+1-e.colStart;l.colEnd=e.colEnd+Math.ceil(i/t)*t,l.colEnd>o.right&&(l.colEnd=l.colEnd-Math.ceil((o.right-l.colEnd)/t)*t)}else if(r===y){const t=e.rowEnd+1-e.rowStart;l.rowStart=e.rowStart-Math.ceil(i/t)*t,l.rowStart<o.top&&(l.rowStart=l.rowStart+Math.ceil((o.top-l.rowStart)/t)*t)}else if(r===v){const t=e.rowEnd+1-e.rowStart;l.rowEnd=e.rowEnd+Math.ceil(i/t)*t,l.rowEnd>o.bottom&&(l.rowEnd=l.rowEnd-Math.ceil((o.bottom-l.rowEnd)/t)*t)}return l})(a,s,e,u,h.direction,h.amount)}if(c&&Q.isRangeWithinRange(s,a)&&(s=null),!Q.isEqualRanges(s,Te.current)){if(Me(s),Te.current=s,!s){try{ce?.()}catch(e){}return void ae?.()}Xt(!1)}Je.current=n,Lo(r,i,t)},onPointerUp:(e,n)=>{Je.current=n,Promise.resolve(Xt(!0)).finally(()=>{ae?.(),Me(null),Te.current=null,Gt.current=null,Ie(null),t.current?.focus()})}}),[X]),Jt=xn(Zt),Qt=d(()=>({onPointerDown:Jt}),[Jt]),[en,tn]=h(null),nn=l(null),on=d(()=>({onPointerDown:(e,n)=>{if(Je.current=n,!t||!t.current)return!1;const o=t.current.getViewFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY),r=o?.getCellCoordsFromClient(e.nativeEvent.clientX,e.nativeEvent.clientY);if(!r)return;if(!1===F?.(e,r,xe))return!1;e.stopPropagation(),Ie("default");const i=o.getRelativePointFromClient(0,0),l=ye.current?.ranges[ye.current?.ranges.length-1]??Q.cellToRange(ye.current?.cell),s=o.toClipBounds(o.getRangeCoordsBounds(l)),c={x:0,y:0};s.x-i.x>e.nativeEvent.clientX?c.x=e.nativeEvent.clientX-(s.x-i.x):e.nativeEvent.clientX>=s.x-i.x+s.width&&(c.x=Math.max(0,e.nativeEvent.clientX-(s.x-i.x+s.width))+1),s.y-i.y>e.nativeEvent.clientY?c.y=e.nativeEvent.clientY-(s.y-i.y):e.nativeEvent.clientY>=s.y-i.y+s.height&&(c.y=Math.max(0,e.nativeEvent.clientY-(s.y-i.y+s.height))+1),H?.(l,e.nativeEvent,n),nn.current={range:l,anchor:o.getAnchor(),cell:r,isMoving:!1,extrusion:c}},onPointerMoveOrWait:(e,n,o)=>{if(Y||!t?.current||!ye.current||!nn.current)return;const r=e.clientX-o.clientX,i=e.clientY-o.clientY;if(nn.current.isMoving=nn.current.isMoving||Math.abs(r)>Math.max(1,2)||Math.abs(i)>Math.max(1,2)||performance.now()-o.timeStamp>500,!nn.current.isMoving)return;const l=nn.current.anchor,s=nn.current.extrusion;let c=t.current.getViewFromLocation(l),a=c.getCellCoordsFromClient(e.clientX-s.x,e.clientY-s.y,!0);if(!a)return;const d=nn.current.cell,u=nn.current.range,h=ie(),f=u.colEnd-u.colStart+1,p=Math.min(Math.max(0,d.colIndex-u.colStart),f-1),g=Math.min(h.right-f+1,Math.max(h.left,a.colIndex-p)),w=u.rowEnd-u.rowStart+1,m=Math.min(Math.max(0,d.rowIndex-u.rowStart),w-1),x=Math.min(h.bottom-w+1,Math.max(h.top,a.rowIndex-m)),y={colStart:g,colEnd:g+f-1,rowStart:x,rowEnd:x+w-1};Q.isEqualRanges(en,y)&&!(e=>!e||!Je.current||Je.current.ctrlKey!==e.ctrlKey||Je.current.shiftKey!==e.shiftKey||Je.current.altKey!==e.altKey||Je.current.metaKey!==e.metaKey)(e)||(tn(y),N?.(y,e,n)),Je.current=n,Lo(c,a,t)},onPointerUp:(e,n)=>{Je.current=n;const o=()=>{tn(null),nn.current=null,Ie(null),t.current?.focus()};if(!nn.current)return void o();const r=nn.current.range,i=en;U?.(r,e,n),Promise.resolve(r&&i&&K?.(r,i,e,n)).finally(()=>{o()})}}),[en]),rn=xn(on),ln=d(()=>({onPointerDown:rn}),[rn]),sn=l(null),cn=d(()=>{const e=Q.isEqualSelectionCoords(xe,sn.current)?sn.current:xe;return sn.current=e,e},[xe]),an=i(n=>{let o=null,r="br";const i=[],l={stroke:P,fill:J,strokeWidth:.5},s=(e,t,o)=>{const r=n.toClipBounds(n.getRangeCoordsBounds(e),To);if(!r)return;r.x=r.width>0?r.x:r.x-l.strokeWidth/2,r.y=r.height>0?r.y:r.y-l.strokeWidth/2,r.width=Math.max(r.width,l.strokeWidth),r.height=Math.max(r.height,l.strokeWidth);const i={key:`selection-fill-${t}`,range:e,...r,...l};if(o){const e=n.getCellCoordsAsRangeCoords(o);i.cell=o,i.pathBounds=n.toClipBounds(n.getRangeCoordsBounds(e),To),i.pathBounds&&(i.pathBounds.width<=0||i.pathBounds.height<=0)&&(delete i.pathBounds,delete i.cell)}return ue(i)};let c=xe?Oo(xe):null;const a=c?.cell?n.getCellCoordsAsRangeCoords(c?.cell):ko;!c||c.ranges&&0!==c.ranges.length||(c={ranges:[a],rangeIndex:0,cell:c.cell});for(let e=0;c&&e<c.ranges.length;e++){const t=c.ranges[e],l=s(t,e,e===c.rangeIndex?c.cell:null);l&&i.push(l);const a=2,d=.5,u=n.toClipBounds(n.getRangeCoordsBounds(t,{top:0,left:0,right:0,bottom:0}),To);if(u){const n=(c.ranges.length,4);i.push(ue({range:t,key:`selection-inside-edge-${e}`,x:u.x-1,y:u.y-1,width:Math.max(u.width+1,0),height:Math.max(u.height+1,0),style:{overflow:"hidden"},stroke:P,strokeWidth:n}))}if(1===c.ranges.length){const o=n.toClipBounds(n.getRangeCoordsBounds(t),To);if(o){Y||i.push(ue({range:t,key:`move-selection-hit-box-${e}`,x:o.width>1?o.x:o.x-(G/2+1),y:o.height>1?o.y:o.y-(G/2+1),width:Math.max(o.width+2,1),height:Math.max(o.height+2,1),stroke:"transparent",style:{boxShadow:"none"},pathProps:{cursor:en?void 0:"move",pointerEvents:"stroke"},strokeWidth:G,...ln}));const n=a;i.push(ue({range:t,key:`selection-single-${e}`,x:o.x-n/2,y:o.y-n/2,width:Math.max(o.width+n/2,1),height:Math.max(o.height+n/2,1),stroke:ee,strokeWidth:n}))}}else{const o=n.toClipBounds(n.getRangeCoordsBounds(t,{top:-1,left:-1,right:-2,bottom:-2}),To);o&&i.push(ue({range:t,key:`selection-multi-${e}`,x:o.width>1?o.x:o.x-d/2,y:o.height>1?o.y:o.y-d/2,width:Math.max(o.width,d)+1,height:Math.max(o.height,d)+1,stroke:ee,style:{overflow:"hidden"},strokeWidth:2}))}if(c.ranges.length>1&&e===c.rangeIndex){const o=n.getCellCoordsAsRangeCoords(c.cell),r=n.toClipBounds(n.getRangeCoordsBounds(o,{top:1,left:1,right:-1,bottom:-1}),To);r&&i.push(ue({range:t,key:`selection-anchor-${e}`,x:r.x,y:r.y,width:Math.max(r.width,d),height:Math.max(r.height,d),stroke:ee,style:{overflow:"hidden"},strokeWidth:2}))}if(e===c.ranges.length-1){o=null,r=null;const e=t.rowStart===ie().top&&t.rowEnd===ie().bottom,i=t.colStart===ie().left&&t.colEnd===ie().right,l=n.getRangeCoordsBounds(t);let s=null;if(e||i){if(s=n.toClipBounds(l,To),Object.keys(n.allViews()).length>1){const o=n.getVisibleRangeCoords(),r=n.allViews()[_],l=n.allViews()[E],c=n.allViews()[I],a=n.getAnchor();(i&&(a===E&&r||a===C&&c||!Q.isCellWithinRange({colIndex:t.colStart,rowIndex:t.rowEnd},o)&&!Q.isCellWithinRange({colIndex:t.colStart,rowIndex:t.rowEnd+1},o))||e&&(a===I&&r||a===C&&l||!Q.isCellWithinRange({colIndex:t.colEnd,rowIndex:t.rowStart},o)&&!Q.isCellWithinRange({colIndex:t.colEnd+1,rowIndex:t.rowStart},o)))&&(s=null)}}else s=n.toClipBounds(l,To);if(!s||0===s.width||0===s.height)continue;o={x:s.x+s.width+1,y:s.y+s.height+1},0===s.width||0===s.height||t.rowStart===ie().top&&t.colStart===ie().left&&t.rowEnd===ie().bottom&&t.colEnd===ie().right||(e?(o.y=a,r="tr"):i&&(o.x=a,r="bl"))}}let d=null;if(ke){const e=n.toClipBounds(n.getRangeCoordsBounds(ke,{top:0,left:0,right:0,bottom:0}),To);if(e){const t=2;d=ue({...l,range:ke,key:"remove-selection",x:e.x,y:e.y,width:e.width,height:e.height,strokeWidth:t,stroke:te,fill:ne})}}let u=null;if(Ce){const e=n.toClipBounds(n.getRangeCoordsBounds(Ce,{top:0,left:0,right:0,bottom:0}),To);if(e){const t=2;u=ue({range:Ce,key:"selection-fill-outline",x:e.x-t/2,y:e.y-t/2,width:e.width+t/2,height:e.height+t/2,strokeWidth:t,stroke:ee,strokeDasharray:"3 2"})}}let h=null;!R&&o&&!en&&(h=p(yo,{...o,corner:r,size:7.5,borderStroke:`${P} solid`,style:{borderRadius:1},background:ee,...Qt,key:"fillHandle"}));const f=[...i];if(d&&f.push(d),u&&f.push(u),h&&f.push(h),!oe&&Ke&&1===c?.ranges.length&&c.ranges[c.ranges.length-1]){const o=c.ranges[c.ranges.length-1],r=o.rowStart===ie().top&&o.rowEnd===ie().bottom,i=o.colStart===ie().left&&o.colEnd===ie().right,l={view:n,range:o,borderStroke:`${ee} solid`,background:P,selectionTouchPointerHandler:tt,...re,onTouchSelectStart:e=>De(e),onTouchSelectEnd:()=>De(null),currentTouchAnchor:Le};f.push(e(Mo,{anchor:i?"b":r?"r":"br",scrollableElement:t.current,...l},"touch-select-handle-after")),f.push(e(Mo,{anchor:i?"t":r?"l":"tl",scrollableElement:t.current,...l},"touch-select-handle-before"))}if(en){const e=n.toClipBounds(n.getRangeCoordsBounds(en,{top:1,left:1,right:1,bottom:1}),To);e&&f.push(ue({range:en,key:"selection-move-outline",x:e.x-Z/2,y:e.y-Z/2,width:Math.max(e.width+Z/2,1),height:Math.max(e.height+Z/2,1),stroke:ee,style:{boxShadow:"none",transitionDuration:"70ms",transitionTimingFunction:"ease-in",transitionProperty:"left, top, width, height",willChange:"left, top, width, height"},strokeWidth:Z}))}return e("div",{children:f},"selection")},[cn,ke,R,Ce,Y,en,ie,P,ee,J,te,ne,oe,re,Le]),dn=d(()=>{const e=()=>t.current;return[new Pn("moveToPageDown",e,{label:"Page Down",description:"Shift viewport down one page.",shortcut:[{key:"PageDown"}]},()=>xt(!1)),new Pn("selectToPageDown",e,{label:"Select To Page Down",description:"Shift viewport and select down one page.",shortcut:[{key:"PageDown",modifiers:[Xe]}]},()=>xt(!0)),new Pn("moveToPageRight",e,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[Ge]}]},()=>vt(!1)),new Pn("selectToPageRight",e,{label:"Page Right",description:"Shift viewport right one page.",shortcut:[{key:"PageDown",modifiers:[Ge,Xe]}]},()=>vt(!0)),new Pn("moveToPageUp",e,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp"}]},()=>yt(!1)),new Pn("selectToPageUp",e,{label:"Page Up",description:"Shift viewport up one page.",shortcut:[{key:"PageUp",modifiers:[Xe]}]},()=>yt(!0)),new Pn("moveToPageLeft",e,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[Ge]}]},()=>bt(!1)),new Pn("selectToPageLeft",e,{label:"Page Left",description:"Shift viewport left one page.",shortcut:[{key:"PageUp",modifiers:[Ge,Xe]}]},()=>bt(!0)),new Pn("selectColumn",e,{label:"Select Column",description:"Select the columns for the selected cells.",shortcut:{key:"Space",modifiers:[Ze]}},rt),new Pn("selectRow",e,{label:"Select Row",description:"Select the rows for the selected cells.",shortcut:{key:"Space",modifiers:[Xe]}},it),new Pn("selectToColumnStart",e,{label:"Select To Column Start",description:"Select the columns to the beginning of the sheet."},()=>ct(!0)),new Pn("selectToColumnEnd",e,{label:"Select To Column End",description:"Select the columns to the end of the sheet."},()=>at(!0)),new Pn("moveToRowStart",e,{label:"Move to Row Home",description:"Move to the beginning of the row.",shortcut:[{key:"Home"}]},()=>dt(!1)),new Pn("selectToRowStart",e,{label:"Select to Row Home",description:"Select to the beginning of the row.",shortcut:[{key:"Home",modifiers:[Xe]}]},()=>dt(!0)),new Pn("moveToSheetStart",e,{label:"Move to Sheet Home",description:"Move to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[Ze]}]},()=>ut(!1)),new Pn("selectToSheetStart",e,{label:"Select to Sheet Home",description:"Select to the beginning of the sheet.",shortcut:[{key:"Home",modifiers:[Ze,Xe]}]},()=>ut(!0)),new Pn("moveToRowEnd",e,{label:"Move to Row End",description:"Move to the end of the row.",shortcut:[{key:"End"}]},()=>ht(!1)),new Pn("selectToRowEnd",e,{label:"Select to Row End",description:"Select to the end of the row.",shortcut:[{key:"End",modifiers:[Xe]}]},()=>ht(!0)),new Pn("moveToSheetEnd",e,{label:"Move to Sheet End",description:"Move to the end of the sheet.",shortcut:[{key:"End",modifiers:[Ze]}]},()=>ft(!1)),new Pn("selectToSheetEnd",e,{label:"Select to Sheet End",description:"Select to the end of the sheet.",shortcut:[{key:"End",modifiers:[Ze,Xe]}]},()=>ft(!0)),new Pn("scrollToActiveCoords",e,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell.",shortcut:{key:"Backspace",modifiers:[Ze]}},st),new Pn("scrollToActiveCoordsClearSelection",e,{label:"Scroll to Active Cell",description:"Scroll to the Active Cell and clear selection.",shortcut:{key:"Backspace",modifiers:[Xe]}},()=>{Ue(),qt(xe.cell,!0)}),new Pn("traverseSelectionRight",e,{label:"Traverse Right",description:"Traverse the selection moving rightward.",shortcut:{key:"Tab"}},_t),new Pn("traverseSelectionLeft",e,{label:"Traverse Left",description:"Traverse the selection moving leftward.",shortcut:{key:"Tab",modifiers:[Xe]}},St),new Pn("traverseSelectionDown",e,{label:"Traverse Down",description:"Traverse the selection moving downward.",shortcut:[{key:"Enter"},{key:"NumpadEnter"}]},It),new Pn("traverseSelectionUp",e,{label:"Traverse Up",description:"Traverse the selection moving upward.",shortcut:[{key:"Enter",modifiers:[Xe]},{key:"NumpadEnter",modifiers:[Xe]}]},Et),new Pn("moveLeft",e,{label:"Move Left",description:"Move active cell to the left.",shortcut:[{key:"ArrowLeft"}]},kt),new Pn("selectLeft",e,{label:"Select Left",description:"Extend selection left.",shortcut:[{key:"ArrowLeft",modifiers:[Xe]}]},Rt),new Pn("moveContentfulLeft",e,{label:"Move Left Contentful",description:"Move left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[Ze]}]},Pt),new Pn("selectContentfulLeft",e,{label:"Select Left Contentful",description:"Extend selection left to the next cell with content.",shortcut:[{key:"ArrowLeft",modifiers:[Ze,Xe]}]},Ot),new Pn("moveRight",e,{label:"Move Right",description:"Move active cell to the right.",shortcut:[{key:"ArrowRight"}]},Lt),new Pn("selectRight",e,{label:"Select Right",description:"Extend selection right.",shortcut:[{key:"ArrowRight",modifiers:[Xe]}]},Dt),new Pn("moveContentfulRight",e,{label:"Move Right Contentful",description:"Move right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[Ze]}]},zt),new Pn("selectContentfulRight",e,{label:"Select Right Contentful",description:"Extend selection right to the next cell with content.",shortcut:[{key:"ArrowRight",modifiers:[Ze,Xe]}]},At),new Pn("moveUp",e,{label:"Move Up",description:"Move active cell to the up.",shortcut:[{key:"ArrowUp"}]},$t),new Pn("selectUp",e,{label:"Select Up",description:"Extend selection up.",shortcut:[{key:"ArrowUp",modifiers:[Xe]}]},Bt),new Pn("moveContentfulUp",e,{label:"Move Up Contentful",description:"Move up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[Ze]}]},Ft),new Pn("selectContentfulUp",e,{label:"Select Up Contentful",description:"Extend selection up to the next cell with content.",shortcut:[{key:"ArrowUp",modifiers:[Ze,Xe]}]},jt),new Pn("moveDown",e,{label:"Move Down",description:"Move active cell to the down.",shortcut:[{key:"ArrowDown"}]},Vt),new Pn("selectDown",e,{label:"Select Down",description:"Extend selection down.",shortcut:[{key:"ArrowDown",modifiers:[Xe]}]},Wt),new Pn("moveContentfulDown",e,{label:"Move Down Contentful",description:"Move down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[Ze]}]},Ht),new Pn("selectContentfulDown",e,{label:"Select Down Contentful",description:"Extend selection down to the next cell with content.",shortcut:[{key:"ArrowDown",modifiers:[Ze,Xe]}]},Nt),new Pn("selectVisible",e,{label:"Select Visible",description:"Select visible cells only.",shortcut:{key:";",modifiers:[Ge]}},wt),new Pn("traverseSelectionPreviousRange",e,{label:"Traverse Previous Range",description:"Traverse the selection to the previous range.",shortcut:{key:"ArrowLeft",modifiers:[Ze,Ge]}},Ct),new Pn("traverseSelectionNextRange",e,{label:"Traverse Next Range",description:"Traverse the selection to the next range.",shortcut:{key:"ArrowRight",modifiers:[Ze,Ge]}},Mt),new Pn("traverseSelectionCorners",e,{label:"Traverse Corners",description:"Traverse the selection through the corners of the selected range.",shortcut:{key:".",modifiers:[Ze]}},Tt)]},[]);return d(()=>{n?.addCommands(dn,!0)},[n]),{selection:cn,setSelectionCell:qt,setSelectionRanges:be,overlay:an,cursor:_e,onPointerDown:et,clearLastSelection:Ut,newSelection:He,modifySelection:We,appendSelection:Ne,clearSelections:Ue,isEntire:Kt,navigate:nt,navigateSelection:ot}};function Ao(e,t){if(!e)throw new Error("Invariant failed")}const $o={"sheetxl-grid":"_sheetxl-grid_h9wwa_7"},Bo=Object.freeze({top:0,left:0}),Fo=Object.freeze({bottom:-4,right:-4}),jo=Object.freeze({horizontal:!0,vertical:!0}),Vo=[_,E,I,C],Wo=150,Ho=3e3,No={},Uo=r(a((o,r)=>{const{width:c,height:a,rowCount:f=1,columnCount:w=1,defaultRowHeight:m,defaultColumnWidth:x,getRowHeight:M,getColumnWidth:T,layout:k,onViewportScroll:R,onImmediateScroll:P,showGridLines:O=!0,gridLineColor:L="rgb(224, 224, 224)",gridLineRowsProps:D,gridLineColumnsProps:z,clipCells:A=!0,cursor:$,freezeLeft:B=0,freezeTop:F=0,freezeLeftProps:j,freezeTopProps:V,cellRenderer:W,onViewportChange:H,onFirstRender:N,overlayRenderer:U,overlayProps:K,overlays:q,overlaysProps:Y,allowOverlaysOverflow:X=!1,stageProps:G,stageWrapper:Z=null,hiddenRowsAt:J,hiddenColumnsAt:ee,hiddenCellAt:te,getVisibleCells:ne,zoom:oe=1,enableMouseWheel:re=!0,onWheelScroll:ie,getCellCoordsAsRangeCoords:le=Q.cellToRange,scrollPoint:se=Bo,style:ce={},...ae}=o;Ao(W),Ao(!o?.children);const de=gt(P,[P]),ue=gt(H,[H]),he=gt(R,[R]),fe=gt(ie,[ie]),pe=gt(N,[N]),ge=l(null),we=l(null),me=l(null),[xe,ye]=g(e=>e+1,0),[ve,be]=h({left:se?.left??0,top:se?.top??0,horizontalScrollDirection:null,verticalScrollDirection:null}),Se=l(null),_e=l(ve),{top:Ie,left:Ce,verticalScrollDirection:Me,horizontalScrollDirection:Te}=ve,ke=l(!1),Re=Wn({rowCount:f,columnCount:w,defaultRowHeight:m,defaultColumnWidth:x,getRowHeight:M,getColumnWidth:T}),Pe=l(null),Oe=d(()=>{const e=k||Re;return Pe.current=null,{getColOffset:t=>e.getColOffset(t)*oe,getColIndex:t=>e.getColIndex(t/oe),getRowOffset:t=>e.getRowOffset(t)*oe,getRowIndex:t=>e.getRowIndex(t/oe)}},[Re,k,oe]),Le=(e,t,n)=>{const o=(t?.left??0)+0,r=(t?.top??0)+0;return{getColOffset:t=>e.getColOffset(t)-o,getColIndex:t=>e.getColIndex(t+o),getRowOffset:t=>e.getRowOffset(t)-r,getRowIndex:t=>e.getRowIndex(t+r)}},De=i((e,t=!1)=>so(e,t,Oe.getRowOffset,t?0:f),[f,Oe?.getRowOffset]),ze=gt(J??De,[J]),Ae=i((e,t=!1)=>so(e,t,Oe.getColOffset,t?w:0),[w,Oe?.getColOffset]),$e=gt(ee??Ae,[ee]),Be=d(()=>Math.min(c??800,Oe.getColOffset(w)),[Oe.getColOffset,w,c]),Fe=d(()=>Math.min(a??600,Oe.getRowOffset(f)),[Oe.getRowOffset,f,a]),je=i(e=>{Ee.canUseDOM&&setTimeout(()=>{ge.current?.focus({preventScroll:!0,...e})},0)},[]),Ve=i(e=>ge.current?.contains(e)||we.current?.contains(e),[]);s(()=>{ke.current&&(Se.current&&Se.current.left!==_e.current?.left&&Se.current.top!==_e.current?.top||(Se.current=null,he?.({left:Ce,top:Ie})))},[Ce,Ie]);const We=gt(()=>({top:Ie,left:Ce}),[Ie,Ce]),He=d(()=>{const e=[];let t=0,n=0;"number"==typeof F?t=F:(t=F.index??0,n=(F.scrollOffset??0)*oe);const o=n,r=Oe.getRowOffset(t),i=r-o;if(t>0){const l=Le(Oe,{top:n+Oe.getRowOffset(0)}),s=Oe.getRowIndex(o),c=Oe.getRowIndex(r-1);let a;e[1]={minIndex:s,maxIndex:c,minCoord:0,maxCoord:t-1,minBounds:0,maxBounds:i,visibleIndices:()=>a||(a=Object.freeze(Jn(ze,s,c)),a),layout:l,maxVirtualBounds:r,scrollOffset:n,freezeOffset:n}}const l=Math.max(0,Fe-i),s=Le(Oe,{top:Ie+i}),c=s.getRowIndex(0),a=s.getRowIndex(l);let d;return e[0]={minIndex:c,maxIndex:a,minCoord:t,maxCoord:f-1,minBounds:i,maxBounds:l,visibleIndices:()=>d||(d=Object.freeze(Jn(ze,c,a)),d),layout:s,maxVirtualBounds:Oe.getRowOffset(f),scrollOffset:Ie,freezeOffset:(t>0?Oe.getRowOffset(t):0)-n},e},[Oe.getRowIndex,Oe.getRowOffset,ze,Fe,f,F,Ie,oe]),Ne=d(()=>{const e=[];let t=0,n=0;"number"==typeof B?t=B:(t=B.index??0,n=(B.scrollOffset??0)*oe);const o=n,r=Oe.getColOffset(t),i=r-o;if(t>0){const l=Le(Oe,{left:n+Oe.getColOffset(0)}),s=Oe.getColIndex(o),c=Oe.getColIndex(r-1);let a;e[1]={minIndex:s,maxIndex:c,minCoord:0,maxCoord:t-1,minBounds:0,maxBounds:i,visibleIndices:()=>a||(a=Object.freeze(Jn($e,s,c)),a),layout:l,maxVirtualBounds:r,scrollOffset:n,freezeOffset:n}}const l=Math.max(0,Be-i),s=Le(Oe,{left:Ce+i}),c=s.getColIndex(0),a=s.getColIndex(l);let d;return e[0]={minIndex:c,maxIndex:a,minCoord:t,maxCoord:w-1,minBounds:i,maxBounds:l,visibleIndices:()=>d||(d=Object.freeze(Jn($e,c,a)),d),layout:s,maxVirtualBounds:Oe.getColOffset(w),scrollOffset:Ce,freezeOffset:(t>0?Oe.getColOffset(t):0)-n},e},[Oe.getColIndex,Oe.getColOffset,$e,Be,w,B,Ce,oe]),Ue=l({}),Ke=l([]),qe=d(()=>{let e={};const t=(t,n,o,r,i)=>{const l={vertical:r?.vertical||!1,horizontal:r?.horizontal||!1};if(t>=Ne.length||n>=He.length)return null;const s={rowStart:He[n].minIndex,colStart:Ne[t].minIndex,rowEnd:He[n].maxIndex,colEnd:Ne[t].maxIndex};if(s.rowStart>s.rowEnd||s.colStart>s.colEnd)return null;const c={getColIndex:e=>Ne[t].layout.getColIndex(e),getColOffset:e=>Ne[t].layout.getColOffset(e),getRowIndex:e=>He[n].layout.getRowIndex(e),getRowOffset:e=>He[n].layout.getRowOffset(e)},a=Object.freeze({left:i?.left??0,top:i?.top??0,right:i?.right??0,bottom:i?.bottom??0}),d=Object.freeze({x:Ne[t].minBounds,y:He[n].minBounds,width:Ne[t].maxBounds,height:He[n].maxBounds}),u=(e,t)=>ao(c,e??s,t),h={width:Ne[t].maxVirtualBounds,height:He[n].maxVirtualBounds},f={left:Ne[t].scrollOffset,top:He[n].scrollOffset},p={left:Ne[t].freezeOffset,top:He[n].freezeOffset},g={width:Be,height:Fe};let w=null,m=null;const x=(p.top+(r.vertical?f.top:0))/oe,y=(p.left+(r.horizontal?f.left:0))/oe;return{getStage:()=>ge.current??null,getVisibleRangeCoords:()=>s,toClipBounds:(e,t)=>{let n,o=0;return void 0===t||"number"==typeof t?(n=u(s),o=t):n=t,((e,t,n=0)=>{if(e.x>t.width||e.y>t.height)return null;const o={left:e.x,top:e.y,bottom:e.height+e.y,right:e.width+e.x},r={left:t.x+n,top:t.y+n,bottom:t.height-2*n+t.y,right:t.width-2*n+t.x},i={left:Math.max(o.left,r.left),top:Math.max(o.top,r.top),bottom:Math.min(o.bottom,r.bottom),right:Math.min(o.right,r.right)},l={x:i.left,y:i.top,width:i.right-i.left,height:i.bottom-i.top};return l.height<0||l.width<0?null:l})(e??{x:0,y:0,width:d.width,height:d.height},n,o)},toViewBounds:e=>0===y&&0===x&&1===oe?e:{x:(e.x-y)*oe,y:(e.y-x)*oe,width:e.width*oe,height:e.height*oe},toAbsoluteBounds:e=>0===y&&0===x&&1===oe?e:{x:e.x/oe+y,y:e.y/oe+x,width:e.width/oe,height:e.height/oe},getRelativePointFromClient:(e,t)=>{const n=Qe(e,t);return{x:n.x-d.x,y:n.y-d.y}},getLayout:()=>c,getCellCoordsAsRangeCoords:le,getVisibleColumns:()=>Ne[t].visibleIndices(),getVisibleRows:()=>He[n].visibleIndices(),getVisibleColumnOffsets:()=>(w||(w=co(Ne[t].layout,!0,Ne[t].visibleIndices(),s.colStart,s.colEnd)),w),getVisibleRowOffsets:()=>(m||(m=co(He[n].layout,!1,He[n].visibleIndices(),s.rowStart,s.rowEnd)),m),getTotalRangeCoords:()=>({colStart:Ne[t].minCoord,colEnd:Ne[t].maxCoord,rowStart:He[n].minCoord,rowEnd:He[n].maxCoord}),getRangeCoordsBounds:u,scrollCellCoordsIntoView:(e,t)=>at(e,t,o),getCellCoordsFromClient:(e,t,n=!1)=>{const o=Qe(e,t);if(!o)return null;const r=c.getColIndex(o.x-d.x),i={rowIndex:c.getRowIndex(o.y-d.y),colIndex:r};if(n)return i;const l=le(i);return{rowIndex:l.rowStart,colIndex:l.colStart}},getZoom:()=>oe,getAnchor:()=>o,getBounds:()=>d,getInsets:()=>a,getTotalSize:()=>h,getViewportSize:()=>g,getScrollTopLeft:()=>f,getFreezeTopLeft:()=>p,getScrollOrientation:()=>l,allViews:()=>e}};let n=e[C]=t(0,0,C,jo,Fo);return n&&(e[C]=n),n=t(0,1,E,{horizontal:!0}),n&&(e[E]=n),n=t(1,0,I,{vertical:!0}),n&&(e[I]=n),n=t(1,1,_,{}),n&&(e[_]=n),Ue.current=null,e=Object.freeze(e)},[He,Ne,le]),Ye=Object.keys(qe),Xe=Ne[0]?.maxVirtualBounds??0,Ge=He[0]?.maxVirtualBounds??0,Ze=d(()=>({left:Ne[1]?Ne[1].layout.getColOffset(Ne[1].maxIndex+1):0,top:He[1]?He[1].layout.getRowOffset(He[1].maxIndex+1):0}),[qe]);s(()=>{if(Ke.current.length>0){for(let e=0;e<Ke.current.length;e++)Ke.current[e]();Ke.current=[]}},[qe]);const Je=gt(()=>({containerWidth:Be,containerHeight:Fe,totalWidth:Xe,totalHeight:Ge}),[Be,Fe,Oe]);s(()=>{!Se.current&&ke.current&&ue({top:Ie,left:Ce,width:Be,height:Fe,totalWidth:Xe,totalHeight:Ge})},[Ie,Ce,Xe,Ge]),s(()=>{ke.current&&ue({top:Ie,left:Ce,width:Be,height:Fe,totalWidth:Xe,totalHeight:Ge})},[Be,Fe]);const Qe=i((e,t)=>{Ao("number"==typeof e&&"number"==typeof t);const n=ge.current?.getBoundingClientRect();return n?{x:e-n.x,y:t-n.y}:{x:e,y:t}},[]),et=gt(e=>qe[e]||null,[qe]),tt=gt((e,t)=>{if(1===Object.keys(qe).length)return qe[C];const n=Qe(e,t);if(!n)return null;const{x:o,y:r}=n;let i=null;const l=Vo;for(let e=0;!i&&e<l.length;e++){const t=qe[l[e]];t&&uo(o,r,t.getBounds())&&(i=t)}return i||(i=qe[C]),i},[qe,le]),nt=gt(()=>qe[C].getVisibleRangeCoords(),[qe[C]]),ot=l(null),rt=i(()=>{null!==ot.current&&Ee.cancelTimeout(ot.current),ot.current=Ee.requestTimeout(it,150)},[]),it=i(()=>{ot.current=null,be(e=>{const t={...e,verticalScrollDirection:null,horizontalScrollDirection:null};return _e.current=t,t})},[]),lt=gt(e=>{const t=e?.left??e?.[0],n=e?.top??e?.[1],o=void 0!==t?Math.min(Xe-Be,Math.max(Ne?.[1]?.scrollOffset??0,t)):_e.current.left,r=void 0!==n?Math.min(Ge-Fe,Math.max(He?.[1]?.scrollOffset??0,n)):_e.current.top;if(_e.current.left===o&&_e.current.top===r)return;let i=null,l=null;_e.current.left>o?i=b:_e.current.left<o&&(i=S),_e.current.top>r?l=y:_e.current.top<r&&(l=v),Ee.throttle(()=>{be(e=>{const t={...e,left:o,top:r,horizontalScrollDirection:i,verticalScrollDirection:l};return _e.current=t,t})},17)(),Se.current?.top===r&&Se.current?.left===o||(Se.current={left:o,top:r},de({left:o,top:r}),ue({left:o,top:r,width:Be,height:Fe,totalWidth:Xe,totalHeight:Ge})),rt()},[Xe,Ge,He,Ne]);s(()=>{Se.current||lt({left:Ce,top:Ie})},[Xe,Be,Ge,Fe]),u(()=>{Se.current={left:se?.left,top:se?.top},lt(Se.current)},[se?.left,se?.top]);const st=gt(e=>{const t=e?.left??e?.[0],n=e?.top??e?.[1],o=e?.behavior??"auto",r={left:_e.current.left+(t??0),top:_e.current.top+(n??0)};o&&(r.behavior=o),lt(r)},[Xe,Be,Ge,Fe]),ct=i(e=>{let t=null;if(Object.keys(qe).length>1){const n=Vo;for(let o=0;!t&&o<n.length;o++){const r=qe[n[o]];r&&Q.isCellWithinRange(e,r.getVisibleRangeCoords())&&(t=r)}}return t||(t=qe[C]),t},[qe]),at=gt((e,t={inline:"nearest",block:"nearest"},n=null)=>{const o={rowIndex:0,colIndex:0,...e};let r=null;if(null!==n){if(r=qe[n],null===r)return new Promise((e,t)=>{t("Invalid view")})}else r=ct(o);const i=le(o),l=r.getLayout(),s=l.getColOffset(i.colStart),c=l.getRowOffset(i.rowStart),a=l.getColOffset(i.colEnd+1),d=l.getRowOffset(i.rowEnd+1),u=r.getBounds(),h=r.getTotalSize(),f=r.getScrollTopLeft(),p=((e,t,n=!0)=>(n=!0===n?{block:"start",inline:"end"}:!1===n?{block:"end",inline:"end"}:{block:"end",inline:"end",...n},{left:oo(n.inline,e.x,e.x+e.width,t.left,t.left+t.width,t.totalWidth),top:oo(n.block,e.y,e.y+e.height,t.top,t.top+t.height,t.totalHeight)}))({x:s+f.left,y:c+f.top,width:a-s,height:d-c},{left:f.left,top:f.top,width:u.width,height:u.height,totalWidth:h.width,totalHeight:h.height},t),g={...p};g.left>Ce?g.left+=20:g.left<Ce&&(g.left-=0),g.top>Ie?g.top+=20:g.top<Ie&&(g.top-=0);const w=r.getScrollOrientation();return w.horizontal&&void 0!==e.colIndex||delete g.left,w.vertical&&void 0!==e.rowIndex||delete g.top,new Promise((e,t)=>{try{lt(g),e(g)}catch(e){t(e)}})},[Xe,Ge,qe,le]),dt=gt(e=>{const t=e.shiftKey;e.preventDefault();const{deltaX:n,deltaY:o,deltaMode:r}=e;if(me.current)return;let i=fe?.(e);if(!1===i)return;let l=t?o:n,s=o;const c=t||Math.abs(l)>Math.abs(s);1===r&&(s*=0),me.current=window.requestAnimationFrame(()=>{me.current=null,st(c?{left:l}:{top:s})})},[Xe,Be,Ge,Fe,fe]),ut=i((e=null)=>{Pe.current=null,Ue.current=null,ye()},[]);u(()=>{ut()},[W]);const ht=Gt(r,()=>({stage:ge.current,focus:je,contains:Ve,invalidate:ut,scrollTo:lt,scrollBy:st,scrollCellCoordsIntoView:at,getScrollPosition:We,getDimensions:Je,getViewport:nt,handleWheel:dt,rowCount:f,columnCount:w,getLayout:()=>Oe,getRelativePointFromClient:Qe,getViewFromClient:tt,getViewFromCellCoords:ct,getViewFromLocation:et,onViewChangeOnce:e=>{Ke.current.push(e)}}),[f,w,qe]);s(()=>(re&&ht.current?.addEventListener("wheel",dt,{passive:!1}),ke.current=!0,Se.current=null,()=>{ht.current?.removeEventListener("wheel",dt)}),[re]);const ft=l([]),pt=(t,n)=>{if(!t||!U)return;ft.current=[];n.push(((t,o)=>{const r=`view:${t.getAnchor()}:overlay:${n.length}`,i=U?.({key:r,view:t},e=>ft.current[o]=e);if(!i)return null;const l=t.getBounds();return e("div",{style:{position:"absolute",left:"0px",top:"0px",width:`${l.width}px`,height:`${l.height}px`,overflow:"hidden"},children:i},`overlay-${t.getAnchor()}-${o}`)})(t,0))},wt=d(()=>{const e={},t=Object.keys(qe);for(let n=0;n<t.length;n++){const o=t[n],r=[];pt(qe[o],r),e[o]={overlays:r}}return e},[xe,U,f,w,He,Ne]),mt=(t,n,o,r,i,l,s)=>{if(!t)return;const c=t.getVisibleColumns(),a=t.getVisibleRows();if(0===c.length||0===a.length)return;let d=null;if(ne)d=ne(t);else{d=[];for(let e=0;e<a.length;e++)for(let t=0;t<c.length;t++){const n={rowIndex:a[e],colIndex:c[t]};if(te?.(n))continue;const o={coords:n,range:le(n)};d.push(o)}}const u=t.getVisibleColumnOffsets(),h=t.getVisibleRowOffsets(),f=t.getScrollTopLeft(),p=t.getFreezeTopLeft(),g=f.left+p.left,w=f.top+p.top,m=Math.trunc(g/Ho),x=Math.trunc(w/Ho),y={},v=(e,t,n,o,r)=>{const i=`view:${e.getAnchor()}:cell:${no(t.rowIndex,t.colIndex)}`,c=o.x,a=o.y,d=Math.trunc((g+c)/Ho)-m,u=Math.trunc((w+a)/Ho)-x;y[u]||(y[u]={});let h=y[u][d];h||(h=y[u][d]=[]);let f=l?.get(i);if(!f){const l=(g+c)%Ho,s=(w+a)%Ho;f=W({key:i,coords:t,bounds:o,zoom:oe,range:n,view:e,value:r,style:{left:Yt.boundPixel(l),top:Yt.boundPixel(s),width:Yt.boundPixel(o.width,!0),height:Yt.boundPixel(o.height,!0)}})}s?.set(i,f),h.push(f)};for(let e=0;d&&e<d.length;e++){const n=d[e],l=n?.coords??n;if(!l)continue;const s=n?.range??{rowStart:l.rowIndex,colStart:l.colIndex,rowEnd:l.rowIndex,colEnd:l.colIndex},c=t.getVisibleRangeCoords();if(!Q.isRangesIntersect(s,c)&&!Q.isRangeWithinRange(s,c))continue;const a=s&&!Q.isSingleCell(s);if(!a&&te?.(l))continue;const f=l.rowIndex,p=l.colIndex,g=h[f],w=u[p];let m=null;g&&w&&(m={x:w.offset,y:g.offset,width:w.size,height:g.size});const x=no(s.rowStart,s.colStart);if(a){if(i.has(x))continue;i.add(x),s.rowEnd-s.rowStart>0&&o.push(s),s.colEnd-s.colStart>0&&r.push(s)}if(a&&(m=ao(t.getLayout(),s)),!m){console.warn("no bounds for cell",x);continue}const y=n?.value;v(t,l,s,m,y)}const b=g%Ho,S=w%Ho,_=Object.keys(y);for(let o=0;o<_.length;o++){const r=y[_[o]];if(!r)continue;const i=Object.keys(r);for(let l=0;l<i.length;l++){const s=r[i[l]];if(!s)continue;const c=parseInt(_[o]),a=parseInt(i[l]),d=c+x,u=a+m,h=`view:${t.getAnchor()}:segment:${u}:${d}`;n.push(e("div",{className:"cell-container",style:{transform:`translate(${Yt.boundPixel(a*Ho-b,!0)}px, ${Yt.boundPixel(c*Ho-S,!0)}px)`,willChange:"transform"},children:s},h))}}},xt=d(()=>{const e=Pe.current,t=new Map,n={},o=Object.keys(qe);for(let r=0;r<o.length;r++){const i=o[r],l=[],s=[],c=[];mt(qe[i],c,l,s,new Set,e,t),n[i]={cells:c,rangesH:l,rangesV:s}}return Pe.current=t,n},[xe,f,w,He,Ne,O,ce,A,te,ne,le]),yt=(t,n,o,r,i)=>{if(t)if(n){const e=`view:${t.getAnchor()}:hl:`,n=t.getVisibleRows();if(!n||0===n.length)return;const l=0,s=t.getBounds().width;let c=[];const a=i.sort(Q.rowFirstRangeComparator),d=t.getVisibleRangeCoords();for(let i=0;i<n.length&&n[i]<=d.rowEnd;i++){const u=n[i];if(u<d.rowStart)continue;let h=!1;for(;a.length>0&&a[0].rowStart<=u;){const e=a.shift();e.rowEnd>u&&(c.push(e),h=!0)}h&&(c=c.sort(Q.columnFirstRangeComparator));const f=t.getLayout(),g=f.getRowOffset(u+1);let w=l;for(let t=0;t<c.length+1;t++){let n=w,i=s;const l=c[t];t<c.length&&(i=Math.min(s,f.getColOffset(l.colStart)),w=Math.min(s,f.getColOffset(l.colEnd+1))),r.push(p("path",{d:`M ${Yt.boundPixel(n)} ${Yt.boundPixel(g,!1,o)} L ${Yt.boundPixel(i)} ${Yt.boundPixel(g,!1,o)}`,stroke:L,strokeWidth:1,vectorEffect:"non-scaling-stroke",...D,key:e+u+":"+t}))}for(let e=c.length-1;e>=0;e--)c[e].rowEnd<=n[i+1]&&c.splice(e,1)}}else{const n=`view:${t.getAnchor()}:vl:`,l=t.getVisibleColumns();if(!l||0===l.length)return;const s=0,c=t.getBounds().height;let a=[];const d=i.sort(Q.columnFirstRangeComparator),u=t.getVisibleRangeCoords();for(let i=0;i<l.length&&l[i]<=u.colEnd;i++){const h=l[i];if(h<u.colStart)continue;let f=!1;for(;d.length>0&&d[0].colStart<=h;){const e=d.shift();e.colEnd>h&&(a.push(e),f=!0)}f&&(a=a.sort(Q.rowFirstRangeComparator));const p=t.getLayout(),g=p.getColOffset(h+1);let w=s;for(let t=0;t<a.length+1;t++){let i=w,l=c;const s=a[t];t<a.length&&(l=Math.min(c,p.getRowOffset(s.rowStart)),w=Math.min(c,p.getRowOffset(s.rowEnd+1)));let d=L;r.push(e("path",{d:`M ${Yt.boundPixel(g,!1,o)} ${Yt.boundPixel(i)} L ${Yt.boundPixel(g,!1,o)} ${Yt.boundPixel(l)}`,stroke:d,strokeWidth:1,vectorEffect:"non-scaling-stroke",...z},n+h+":"+t))}for(let e=a.length-1;e>=0;e--)a[e].colEnd<=l[i+1]&&a.splice(e,1)}}},vt=t=>{if(!xt)return;const n={};for(let o=0;o<Ye.length;o++){const r=Ye[o],i=qe[r],l=[];yt(i,t,0,l,t?xt[r].rangesH:xt[r].rangesV);const s=i.getRangeCoordsBounds(),c=Math.ceil(s.width),a=Math.ceil(s.height);n[r]=e("svg",{width:`${c}`,height:`${a}`,viewBox:`0 0 ${c} ${a}`,preserveAspectRatio:"none",shapeRendering:"crispEdges",style:{position:"absolute"},children:l})}return n},bt=d(()=>!0===O||!0===O?.horizontal?vt(!0):null,[xe,O,He,F,B,L,D,f,w,Be,Xe,xt]),St=d(()=>!0===O||!0===O?.vertical?vt(!1):null,[xe,O,Ne,F,B,L,z,f,w,Fe,Ge,xt]),_t=d(()=>0===Ze.left?null:e(fo,{linePoints:[0,0,0,Fe+1],bounds:{x:Ze.left,y:0,width:1,height:Fe+1},...j}),[xe,Ze.left,Fe,j]),Et=d(()=>0===Ze.top?null:e(fo,{linePoints:[0,0,Be+1,0],bounds:{x:0,y:Ze.top,width:Be+1,height:1},...V}),[xe,Ze.top,Be,V]),It=d(()=>{const o=[],r=e=>{if(!e||!qe[e])return;const n=qe[e].getBounds();return t("div",{style:{position:"absolute",pointerEvents:"none",left:n.x,top:n.y,width:n.width,height:n.height,clip:`rect(0, ${n.width+1}px, ${n.height+1}px, 0)`},className:`view view-${e}`,children:[bt?.[e],St?.[e],xt?.[e].cells]},`view:${e}`)};for(let e=0;e<Ye.length;e++)o.push(r(Ye[e]));return e(n,{children:o})},[qe,bt,St,xt]),Ct=d(()=>{if(!r)return;const e=(e,t,n,o)=>{if(!o||0===o.length)return;const r=[];for(let i=0;i<o.length;i++){const l=o[i];let s=e?.get(l);s!==No&&(s=l(n)??No),t.set(l,s),s&&s!==No&&r.push(s)}return r},n=(n,o,r)=>{if(!r)return;const i=r.getBounds(),l=r.getInsets(),s=r.getAnchor();return t("div",{className:xo("view",`view-${s}`,$o.view),style:{position:"absolute",pointerEvents:"none",left:i.x-l.left,top:i.y-l.top,width:i.width-(l.left+l.right),height:i.height-(l.top+l.bottom),clipPath:X?"inset(-2px)":"inset(0px)"},children:[e(n,o,r,q),wt?.[s].overlays]},`view:${s}`)},o=Ue.current,i={},l=[],s=Object.keys(qe);for(let e=0;e<s.length;e++){const t=s[e],r=o?.[t],c=i[t]=new Map;l.push(n(r,c,qe[t]))}return Ue.current=i,l},[xe,qe,X,q]),Mt=d(()=>{const{style:t,...n}=G??{};return e("div",{style:{width:Be,height:Fe,...t},className:"sheetxl-stage",tabIndex:0,ref:ge,...n,...ae,children:Z?Z(It):It})},[Be,Fe,It,G,Z]),Tt=l(!1);return s(()=>{!Tt.current&&xt&&(Tt.current=!0,pe?.(ht.current))},[xt]),t("div",{className:xo("sheetxl-grid",$o["sheetxl-grid"]),style:{overflow:"visible",cursor:$,maxWidth:Be,maxHeight:Fe,width:Be,height:Fe,...ce},ref:ht,children:[Mt,t("div",{className:xo("sheetxl-overlays"),ref:we,...Y,children:[Ct,_t,Et]})]})}));Uo.displayName="BaseGrid";const Ko=r(a((t,n)=>{const{width:o,height:r,style:i={},className:l,...s}=t,[c,{width:a,height:d}]=Eo();return e("div",{className:l,style:{...i},children:e("div",{style:{position:"relative",top:"0px",left:"0px",width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",boxSizing:"content-box"},ref:c,children:e(Uo,{ref:n,width:o??a,height:r??d,...s})})})}));Ko.displayName="Grid";const qo=r(a((t,n)=>{const{showVerticalScrollbar:o,showHorizontalScrollbar:r,createHorizontalScrollbar:s,createVerticalScrollbar:a,createScrollCorner:d,viewport:u,onScrollViewport:f,style:p={},className:g,onScroll:w,...m}=t,[x,y]=h(null),v=l(null),b=l(null);Ao(!u),c(n,()=>b.current&&v.current?Object.assign(b.current,v.current):null);const S=i(e=>{b.current?.scrollTo(e),f?.(e)},[]);return e(Qt,{className:g,style:p,ref:v,showVerticalScrollbar:o,showHorizontalScrollbar:r,createHorizontalScrollbar:s,createVerticalScrollbar:a,createScrollCorner:d,viewport:x,onScrollViewport:S,children:e(Ko,{style:{width:"100%",height:"100%"},...m,onViewportChange:e=>y(e),ref:b})})}));qo.displayName="ScrollableGrid";const Yo=()=>!1,Xo=r(t=>{const{index:n,value:o,zoom:r,zoomScale:i=100,headerText:s=e=>`${e}`,headerStyle:c,headerStyleSelect:a=c,headerStyleSelectAll:d=a,headerStyleHover:u=d,verticalPadding:f=0,horizontalPadding:p=0,isSelected:g=Yo,isSelectedAll:w=Yo,coords:m,bounds:x,range:y,orientation:v,view:b,style:S,..._}=t,E=i/100,I=l(null),[C,M]=h(!1),T=g?.(n)||!1,k=w?.(n)||!1?d:T?a:c;let R=k;if(C){let e=u;"function"==typeof u&&(e=u(k)),R=Ee.mergeContentful(k,e)}return e("div",{ref:I,style:{background:R.fill,color:R.text?.fill,fontFamily:R.text?.fontFamily??c.text?.fontFamily,fontSize:96*(R.text?.fontSize??11)/72*E,fontStyle:R.text?.fontStyle,fontWeight:R.text?.fontWeight,lineHeight:1.2,display:"flex",justifyContent:"center",alignItems:"end",pointerEvents:"auto",paddingBottom:`${E}px`,...S,left:S.left-(v===L?1:0),top:S.top-(v===D?1:0),width:S.width+1,height:S.height+1,overflow:"hidden"},..._,onMouseMove:e=>{"touch"!==Yt.detectIt().primaryInput&&0===e.buttons&&M(!0)},onMouseOut:e=>{M(!1)},children:s(n)})});Xo.displayName="HeaderRenderer";const Go="ew-resize",Zo="ns-resize",Jo=r(a((n,o)=>{const{orientation:r,view:i,index:l,className:s,style:c,disabled:a=!1,disabledResize:d=!1,isNextHidden:u,isHidden:h,isSelected:f,isSelectedAll:p,showTouchDivider:g,headerStyle:w,headerStyleSelect:m,headerStyleSelectAll:x,headerStyleHover:y,bounds:v,onPointerDown:b,onAutoFit:S,..._}=n,E=r===L;let I=w;f&&m&&(I=m),p&&x&&(I=x);const C="touch"===Yt.detectIt().primaryInput;let M=E?14:8,T=M/2,k=0;u&&(k=-2),h&&(k=2),h&&(M=M/2+k,T=2*k);let R=I.dividerStrokeFill??I.strokeFill;return!(f||p)&&0===k&&(R=`linear-gradient(${E?180:90}deg, ${I.fill}, ${R} 55%, ${R} 100%)`),t("div",{className:xo("header-divider",{disabled:a},s,`index-${l}`),ref:o,onPointerDown:C?void 0:b,onDoubleClick:C?void 0:()=>S?.(),style:{top:(E?0:-M/2+(k-1))+"px",left:(E?-M/2+(k-1):0)+"px",width:E?M:"calc(100% + 1px)",height:E?"calc(100% + 1px)":M,position:"absolute",overflow:"visible",pointerEvents:"all",cursor:a||d||C?void 0:E?Go:Zo,...c},..._,children:[e("div",{style:{position:"relative",top:`${E?0:T}px`,left:`${E?T:0}px`,width:E?1:"100%",height:E?"100%":1,background:R},onDoubleClick:()=>S?.()}),g&&C?e("div",{style:{position:"absolute",cursor:"grab",zIndex:1,borderRadius:"4px",right:E?"-6px":"2px",bottom:E?"2px":"-9px",height:"24px",width:E?"24px":"18px",maxHeight:E?"calc(100% - 4px)":void 0,maxWidth:E?void 0:"calc(100% - 4px)",background:I.fill,border:`${x.edgeStrokeFill} solid 1px`,boxShadow:`0.5px 0.5px 0px 0px ${w.text.fill}`,display:"flex",alignItems:"center",justifyContent:"center"},onPointerDown:b,children:e("div",{style:{width:"6.4px",height:"12px",backgroundImage:`url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(m.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`,backgroundRepeat:"no-repeat",backgroundPosition:"center",transform:E?void 0:"rotate(90deg)"}})}):null]})})),Qo=(t,n)=>e(Jo,{...t,ref:n}),er=r(a((o,r)=>{const{orientation:i,view:s,index:c,disabled:a=!1,disabledResize:d=!1,resizeThreshold:u=1,dividerRenderer:f=Qo,onDividerMouseDown:p,onDividerResizeStart:g,onDividerResize:w,onDividerResizeEnd:m,onDividerMouseUp:y,onDividerAutoFit:v,onPointerDown:b,...S}=o,_=gt(b,[b]),E=gt(v,[v]),I=i===L;let C=I?s.getVisibleColumns():s.getVisibleRows(),M=null;C.length>0&&(I?M=s.getRangeCoordsBounds({rowStart:0,rowEnd:0,colStart:C[0],colEnd:C[C.length-1]}):s.getRangeCoordsBounds({rowStart:C[0],rowEnd:C[C.length-1],colStart:0,colEnd:0}),M=s.toClipBounds(M,To));const T=l(null),[k,R]=h(null),P=(e,t)=>I?e.clientX-t.clientX:e.clientY-t.clientY,O=s.getLayout(),D=I?O.getColOffset(c+1):O.getRowOffset(c+1),z=xn({processTouch:!0,onPointerDown:e=>{if(_?.(e),!a&&!d){const e=I?O.getColOffset(c):O.getRowOffset(c),t=D-e;T.current={isResizing:!1,startSize:t,index:c,view:s,orientation:i,onDividerMouseDown:p,onDividerResizeStart:g,onDividerResize:w,onDividerResizeEnd:m,onDividerMouseUp:y},R(T.current),p?.(c,t)}e.stopPropagation(),e.preventDefault()},onPointerUp:(e,t,n)=>{if(!T.current)return;T.current.isResizing&&T.current.onDividerResizeEnd?.(T.current.index,Math.max(0,T.current.startSize+P(e,n)),T.current.startSize);const o=T.current;T.current=null,R(T.current),o.onDividerMouseUp?.(o.index)},onPointerMoveOrWait:(e,t,n)=>{if(!T.current)return;const o=P(e,n);T.current.isResizing?T.current.onDividerResize?.(T.current.index,Math.max(0,T.current.startSize+o),T.current.startSize):Math.abs(o)>Math.max(1,u)&&(T.current={...T.current,isResizing:!0},R(T.current),T.current.onDividerResizeStart?.(T.current.index,Math.max(0,T.current.startSize+o))),e.stopPropagation(),e.preventDefault()}}),A=gt(()=>{E?.(c)},[c]);if(!M)return;const $=f({bounds:M,orientation:i,view:s,index:c,disabled:a,disabledResize:d,onAutoFit:A,onPointerDown:z,...S},r);if(!$)return;const{getPortalContainer:B}=nn();let F=null;return k&&k.isResizing&&k.index===c&&(F=x(e("div",{style:{position:"absolute",cursor:I?Go:Zo,left:0,top:0,width:"100%",height:"100%"}}),B(),"divider:"+c)),t(n,{children:[F,e("div",{className:xo("header-divider-anchor"),style:{position:"absolute",pointerEvents:"auto",top:`${I?M.y:D}px`,left:`${I?D:M.x}px`,width:(I?0:M.width-1)+"px",height:(I?M.height-1:0)+"px",display:"flex"},tabIndex:-1,children:$})]})}));class tr{naturalDimensions(e,t={}){const n=document.createElement("div");let o=t?.lineHeight??"1";!t?.lineHeight&&t.paintableText?.fontSize&&(o=Math.ceil(1.2*t.paintableText.fontSize)+"px");const r=document.createElement("div");r.style.visibility="hidden",r.style.position="absolute",r.style.textRendering="geometricprecision",r.style.display="inline-grid",r.style.overflowWrap="break-word",r.style.maxWidth=t.maxWidth?t.maxWidth+"px":"100%",r.style.lineHeight=o,r.style.letterSpacing=(t.paintableText?.letterSpacing??0)+"px",r.style.fontSize=t.paintableText?.fontSize?t.paintableText.fontSize+"px":"unset",r.style.fontFamily=t.paintableText?.fontSize?t.paintableText.fontFamily:"unset",r.style.fontWeight=t.paintableText?.fontWeight?""+t.paintableText.fontWeight:"400",r.style.fontStyle=t.paintableText?.fontStyle?t.paintableText.fontStyle:"normal",r.style.whiteSpace="wrap"===t.paintableText?.wrap?"break-spaces":"pre",n.appendChild(r);const i=e.split("\n");for(let e=0;e<i.length;e++){let t=document.createElement("span");r.appendChild(t),t.textContent=i[e]}0!==i.length&&0!==i[i.length-1].length||r.appendChild(document.createElement("br")),document.body.appendChild(r);let l=r.getBoundingClientRect();return r.remove(),{width:l.width,height:l.height,maxLineHeight:1.2*(t.paintableText?.fontSize||1056/72)}}}const nr=(e=void 0)=>Object.freeze({clean:e,dirty:void 0,editMode:!1}),or=nr(),rr=r(a((t,n)=>{const{editState:o=or,defaultTextStyle:r,onStartEdit:c,onChangeEdit:a,onSubmitEdit:f,onCancelEdit:p,onDoneEdit:g,containerBounds:w,setNaturalDimensions:m,onNavigate:x,textProperties:_,style:E,autoFocus:I,...C}=t,M=l(null),{width:T=0}=w??{},[k,R]=h(()=>o);s(()=>{R(o)},[o]);const P=_?.align||"left",O=_?.vAlign||"middle",L=_?.fill||"#040404",D=_?.wrap||"wrap",z=_?.fontFamily||"Calibri",A=_?.fontSize||11,$=_?.fontWeight||400,B=_?.fontStyle||"normal",F=k.dirty??k.clean??"";let j=2;const V=96*A/72,W=1.2*V;"right"===O&&(j+=1);const H=d(()=>(new tr).naturalDimensions(F,{maxWidth:"wrap"===D?T-j:void 0,lineHeight:`${W}px`,paintableText:{fontStyle:B,wrap:D,letterSpacing:-.25}}),[F,D,j,V,z,$,B,m,T]),N=i(()=>H.maxLineHeight?H.maxLineHeight+"px":"1.2",[H]),[U,K]=h(N);u(()=>{K(N())},[w,H]),u(()=>{m?.({width:"wrap"===D?void 0:H.width+j,height:H.height})},[H,m]);const q=gt(a,[a]),Y=gt(e=>{if(k.dirty===e)return;const t={...k};t.dirty=e,M.current,R(t),q?.(t)},[k]),X=gt(e=>{if(k.editMode===e)return;const t={...k};t.editMode=e,R(t),q?.(t)},[k]),G=gt(()=>{try{return f?.(k),g?.(),!0}catch(e){return!1}},[f,k]),Z=gt(()=>{R(o),p?.(),g?.()},[p,o]),J=gt(e=>{if(!M.current)return;if(e.isDefaultPrevented(),!(e.isTrusted||e.nativeEvent.ctrlKey||e.nativeEvent.metaKey||e.nativeEvent.altKey||e.nativeEvent.isComposing)&&-1!==Hn.indexOf(e.nativeEvent.key)){const t={...k};return t.dirty="Backspace"===e.nativeEvent.key?"":(t.dirty??"")+e.key,R(t),q?.(t),void e.preventDefault()}const t=e.nativeEvent.shiftKey;if(e.which===et)return e.preventDefault(),void Z();if(e.which===it)return X(!0),void e.preventDefault();if(e.which===Qe&&(e.preventDefault(),G()&&x?.(t?y:v)),e.which===Je)return e.preventDefault(),void(G()&&x?.(t?b:S));if(!k.editMode){let t=null;switch(e.which){case tt:t=b;break;case ot:t=S;break;case nt:t=y;break;case rt:t=v}if(t)return void G()}},[k,x]),[Q,ee]=h(!I);s(()=>{ee(!1)},[]);const te=Gt(n,()=>({startEdit(e){let t=e?.initialSelection;if(!t){const e=M.current.value.length??0;t={start:e,end:e,direction:"forward"}}M.current?.setSelectionRange(t.start,t.end,t.direction);const n={...o,editMode:e?.editMode??!1};void 0!==e?.text&&(n.dirty=e.text),n.editMode===o.editMode&&n.dirty===o.dirty||(R(n),q?.(n))},submitEdit:()=>G(),cancelEdit(){Z()},autoFocus(){M.current?.focus()},getLineHeight:()=>H?.maxLineHeight??W,dispatchEvent:e=>M.current.dispatchEvent(e)}),[o,c]);return e("div",{ref:te,...C,style:{background:"transparent",display:"flex",flexGrow:1,alignSelf:"center",height:H.height,maxWidth:"100%",maxHeight:"100%",...E},children:e("textarea",{spellCheck:"false",ref:M,value:F,autoFocus:!1,disabled:Q,name:"cell-editor",autoComplete:"off",autoCapitalize:"off",style:{flex:"1 1 100%",position:"relative",fontSize:`${V}px`,fontFamily:`${z}`,fontWeight:`${$}`,fontStyle:`${B}`,padding:"0px",marginRight:"right"===P?"3px":"0px",marginLeft:"left"===P?"2px":"0px",lineHeight:U,height:H.height,textRendering:"geometricPrecision",letterSpacing:"-0.25px",boxSizing:"border-box",borderWidth:0,outline:"none",resize:"none",overflow:"hidden",verticalAlign:"baseline",textAlign:P,background:"transparent",color:L,marginBottom:"0px",userSelect:"text",maxHeight:"100%",whiteSpace:"wrap"===D?"break-spaces":"pre",wordWrap:"break-word"},onChange:e=>{Y(e.target.value)},onDoubleClick:e=>{e.isTrusted},onMouseDown:e=>{X(!0)},onKeyDown:J})})})),ir=r(t=>{const{value:n,view:o,bounds:r,range:i,zoom:l,children:s,style:c,...a}=t;return e("div",{style:{padding:"2px 4px",fontFamily:"Calibri",letterSpacing:-.25,lineHeight:1.2,fontSize:c?.fontSize||1056/72,...c},...a,children:n})});export{Uo as BaseGrid,rr as DefaultCellEditor,ir as DefaultCellRenderer,Jo as DefaultHeaderDivider,yo as FillHandle,Ko as Grid,er as HeaderDivider,Xo as HeaderRenderer,Wo as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,To as SELECTION_CLIP_INSETS,Hn as STANDARD_KEY_CHARS,fo as SVGLine,po as SVGRect,qo as ScrollableGrid,wo as Selection,Mo as TouchSelectHandle,go as defaultSelectionRenderer,nr as getDefaultStringEditState,Oo as safeSelectionCoords,Wn as useCellLayout,Gn as useHeaderSelection,Xn as useKeyboardEditorOverlay,zo as useSelection};