@sheetxl/scripting 0.8.0-beta.1 → 0.8.0-beta.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.
Files changed (62) hide show
  1. package/README.md +5 -5
  2. package/browser/esm/4VkvY2rXOd49uHcQ.mjs +4 -0
  3. package/browser/esm/B73J41HhbJvswDz1.mjs +17 -0
  4. package/browser/esm/BPtHkO7z1Di3YIjV.mjs +162 -0
  5. package/browser/esm/B_2CC0NvNtPBw_ad.mjs +22 -0
  6. package/browser/esm/BxiAkxNyUQseLNBv.mjs +10 -0
  7. package/browser/esm/CV6NN6Ju5xBT1o6B.mjs +3955 -0
  8. package/browser/esm/Cg2-n5X_c3X8uPPp.mjs +581 -0
  9. package/browser/esm/D9jTpNifykCuQkTL.mjs +18 -0
  10. package/browser/esm/NpFv8YNKRgVPGXOq.mjs +9 -0
  11. package/browser/esm/_cUijEyyZifD_LZf.mjs +23 -0
  12. package/browser/esm/index.mjs +71 -41
  13. package/node/esm/4VkvY2rXOd49uHcQ.mjs +4 -0
  14. package/node/esm/ByvsA4Gi2N_jmjO4.mjs +161 -0
  15. package/node/esm/C8P-wHdBmweFS0Ex.mjs +20 -0
  16. package/node/esm/CLpM4kzEeZk_kWj4.mjs +23 -0
  17. package/node/esm/Cgbq_-KJhRYkRJw-.mjs +581 -0
  18. package/node/esm/ClxOMp6IdEZdW4Qd.mjs +8 -0
  19. package/node/esm/D0CDObJV23Rxk8-r.mjs +15 -0
  20. package/node/esm/index.mjs +83 -148
  21. package/node/esm/og3Pk2ReS3UiORbF.mjs +21 -0
  22. package/package.json +6 -7
  23. package/types/src/compiler/Bundler.d.ts +1 -1
  24. package/types/src/compiler/insertRunGuard.d.ts +11 -0
  25. package/types/src/lib/typescript/typescript.browser.d.ts +6 -0
  26. package/types/src/lib/typescript/typescript.node.d.ts +11 -0
  27. package/types/src/linter/Linter.d.ts +20 -0
  28. package/types/src/runtime/RunGuard.d.ts +31 -0
  29. package/types/src/runtime/index.d.ts +1 -0
  30. package/types/src/type/CompileOptions.d.ts +50 -0
  31. package/types/src/type/CompiledModule.d.ts +36 -6
  32. package/types/src/type/Diagnostic.d.ts +25 -3
  33. package/types/src/type/Types.d.ts +61 -5
  34. package/browser/cjs/BJpcKKDPQlQbi5O5.cjs +0 -7
  35. package/browser/cjs/Bu4cZ8iSZ3rij-oV.cjs +0 -1
  36. package/browser/cjs/BvG8N7G_8CXIAlT-.cjs +0 -1
  37. package/browser/cjs/CY8w1D0xPdaNysFJ.cjs +0 -1
  38. package/browser/cjs/C_7w8EJZpHw8ueuq.cjs +0 -1
  39. package/browser/cjs/C_IEgjM-hSJCv6Gm.cjs +0 -1
  40. package/browser/cjs/CctaCN_w3o34V9AR.cjs +0 -1
  41. package/browser/cjs/DIf4GvYEqb4ayb6a.cjs +0 -1
  42. package/browser/cjs/DcNeWEf5ZqALrCr4.cjs +0 -1
  43. package/browser/cjs/_PKWNtAymIZGtvCb.cjs +0 -21
  44. package/browser/cjs/index.cjs +0 -1
  45. package/browser/esm/1kUe1fPM50LHqYNI.mjs +0 -15
  46. package/browser/esm/3YV545IwjRqG3c1v.mjs +0 -27
  47. package/browser/esm/CFj5DZ16U361ltLj.mjs +0 -8
  48. package/browser/esm/CSXzDPdxAeONd9Br.mjs +0 -152
  49. package/browser/esm/DCIZplzRAR9pzoyD.mjs +0 -12
  50. package/browser/esm/DL0Hj5P777IybKK1.mjs +0 -25
  51. package/browser/esm/Dn3tZ47l4kfqm82M.mjs +0 -434
  52. package/browser/esm/Im_056DAe1M8tSZK.mjs +0 -23
  53. package/browser/esm/bJcM1PsEX9VZuqnT.mjs +0 -87
  54. package/browser/esm/v5FtHwExzUecgxho.mjs +0 -112
  55. package/node/esm/CFj5DZ16U361ltLj.mjs +0 -8
  56. package/node/esm/CL56uy8tfvhJRKYS.mjs +0 -434
  57. package/node/esm/CZgThiQ_9yYAaYaW.mjs +0 -152
  58. package/node/esm/DDDZ5Wv9-gK2v6Qt.mjs +0 -23
  59. package/node/esm/DEIcuGll5aCjPisP.mjs +0 -27
  60. package/node/esm/DOv0wuhb-kNvUT7-.mjs +0 -12
  61. package/node/esm/NgoqymNyfjBf3Vbn.mjs +0 -17
  62. package/node/esm/P5z0UPrc8__6uFCR.mjs +0 -14
@@ -0,0 +1,3955 @@
1
+ var c = class {
2
+ constructor(t) {
3
+ this._worker = null, this._nextId = 1, this._pendingRequests = /* @__PURE__ */ new Map(), this._workerFactory = t;
4
+ }
5
+ start() {
6
+ if (typeof Worker > "u") throw new Error("Web Workers are not supported in this environment.");
7
+ return this._worker || (this._worker = this._workerFactory(), this._worker.onmessage = (t) => {
8
+ const { id: n, result: e, error: r } = t.data, o = this._pendingRequests.get(n);
9
+ if (o) if (this._pendingRequests.delete(n), r) {
10
+ const i = new Error(r.message);
11
+ i.stack = r.stack, r.cause && (i.cause = r.cause), o.reject(i);
12
+ } else o.resolve(e);
13
+ }, this._worker.onerror = (t) => {
14
+ console.error("Worker error:", t), this._pendingRequests.forEach((n) => {
15
+ n.reject(new Error(`Worker failed: ${t.message}`));
16
+ }), this._pendingRequests.clear(), this._worker = null;
17
+ }), Promise.resolve();
18
+ }
19
+ execute(t) {
20
+ if (!this._worker) throw new Error("Worker is not initialized. Call start() first.");
21
+ const n = this._nextId++;
22
+ return new Promise((e, r) => {
23
+ this._pendingRequests.set(n, { resolve: e, reject: r }), this._worker.postMessage({ id: n, params: t });
24
+ });
25
+ }
26
+ terminate() {
27
+ this._worker && (this._worker.terminate(), this._worker = null);
28
+ }
29
+ }, u = class {
30
+ constructor(t) {
31
+ this._onExecute = t;
32
+ }
33
+ execute(t) {
34
+ return this._onExecute(t);
35
+ }
36
+ start() {
37
+ return Promise.resolve();
38
+ }
39
+ terminate() {
40
+ }
41
+ }, s = `var bt = Object.defineProperty, tr = (e, t, r) => () => {
42
+ if (r) throw r[0];
43
+ try {
44
+ return e && (t = e(e = 0)), t;
45
+ } catch (n) {
46
+ throw r = [n], n;
47
+ }
48
+ }, rr = (e, t) => {
49
+ let r = {};
50
+ for (var n in e) bt(r, n, {
51
+ get: e[n],
52
+ enumerable: !0
53
+ });
54
+ return t || bt(r, Symbol.toStringTag, { value: "Module" }), r;
55
+ }, vt = Object.defineProperty, ge = (e, t) => {
56
+ let r = {};
57
+ for (var n in e) vt(r, n, {
58
+ get: e[n],
59
+ enumerable: !0
60
+ });
61
+ return t || vt(r, Symbol.toStringTag, { value: "Module" }), r;
62
+ }, oe = {
63
+ Column: "column",
64
+ Row: "row"
65
+ };
66
+ ({ ...oe });
67
+ function ze(e, t) {
68
+ if (e === t) return !0;
69
+ if (e && t && typeof e == "object" && typeof t == "object") {
70
+ if (e.constructor !== t.constructor) return !1;
71
+ let r, n, i;
72
+ if (Array.isArray(e)) {
73
+ if (r = e.length, r != t.length) return !1;
74
+ for (n = r; n-- !== 0;) if (!ze(e[n], t[n])) return !1;
75
+ return !0;
76
+ }
77
+ if (e instanceof Map && t instanceof Map) {
78
+ if (e.size !== t.size) return !1;
79
+ for (n of e.entries()) if (!t.has(n[0])) return !1;
80
+ for (n of e.entries()) if (!ze(n[1], t.get(n[0]))) return !1;
81
+ return !0;
82
+ }
83
+ if (e instanceof Set && t instanceof Set) {
84
+ if (e.size !== t.size) return !1;
85
+ for (n of e.entries()) if (!t.has(n[0])) return !1;
86
+ return !0;
87
+ }
88
+ if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) {
89
+ if (r = e.length, r != t.length) return !1;
90
+ for (n = r; n-- !== 0;) if (e[n] !== t[n]) return !1;
91
+ return !0;
92
+ }
93
+ if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
94
+ if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
95
+ if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
96
+ if (i = Object.keys(e), r = i.length, r !== Object.keys(t).length) return !1;
97
+ for (n = r; n-- !== 0;) if (!Object.prototype.hasOwnProperty.call(t, i[n])) return !1;
98
+ for (n = r; n-- !== 0;) {
99
+ let o = i[n];
100
+ if ((o !== "_owner" || !e.$$typeof) && !ze(e[o], t[o])) return !1;
101
+ }
102
+ return !0;
103
+ }
104
+ return e != e && t != t;
105
+ }
106
+ function an(e) {
107
+ let t = Object.prototype.toString.call(e);
108
+ return t === "[object RegExp]" || t === "[object Date]" || (function(r) {
109
+ return r.$$typeof === ln;
110
+ })(e);
111
+ }
112
+ var ln = typeof Symbol == "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
113
+ function sn(e) {
114
+ return /* @__PURE__ */ (function(t) {
115
+ return !!t && typeof t == "object";
116
+ })(e) && !an(e);
117
+ }
118
+ function Le(e, t) {
119
+ return t.clone !== !1 && t.isMergeableObject(e) ? ve((r = e, Array.isArray(r) ? [] : {}), e, t) : e;
120
+ var r;
121
+ }
122
+ function cn(e, t, r) {
123
+ return e.concat(t).map(function(n) {
124
+ return Le(n, r);
125
+ });
126
+ }
127
+ function Et(e) {
128
+ return Object.keys(e).concat((function(t) {
129
+ return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(r) {
130
+ return Object.propertyIsEnumerable.call(t, r);
131
+ }) : [];
132
+ })(e));
133
+ }
134
+ function _t(e, t) {
135
+ try {
136
+ return t in e;
137
+ } catch {
138
+ return !1;
139
+ }
140
+ }
141
+ function un(e, t, r) {
142
+ let n = {};
143
+ return r.isMergeableObject(e) && Et(e).forEach(function(i) {
144
+ n[i] = Le(e[i], r);
145
+ }), Et(t).forEach(function(i) {
146
+ (function(o, l) {
147
+ return _t(o, l) && !(Object.hasOwnProperty.call(o, l) && Object.propertyIsEnumerable.call(o, l));
148
+ })(e, i) || (_t(e, i) && r.isMergeableObject(t[i]) ? n[i] = (function(o, l) {
149
+ if (!l.customMerge) return ve;
150
+ let s = l.customMerge(o);
151
+ return typeof s == "function" ? s : ve;
152
+ })(i, r)(e[i], t[i], r) : n[i] = Le(t[i], r));
153
+ }), n;
154
+ }
155
+ function ve(e, t, r) {
156
+ (r ||= {}).arrayMerge = r.arrayMerge || cn, r.isMergeableObject = r.isMergeableObject || sn, r.cloneUnlessOtherwiseSpecified = Le;
157
+ let n = Array.isArray(t);
158
+ return n === Array.isArray(e) ? n ? r.arrayMerge(e, t, r) : un(e, t, r) : Le(t, r);
159
+ }
160
+ ve.all = function(e, t) {
161
+ if (!Array.isArray(e)) throw Error("first argument should be an array");
162
+ return e.reduce(function(r, n) {
163
+ return ve(r, n, t);
164
+ }, {});
165
+ };
166
+ var nr = ge({
167
+ DonePromise: () => fn,
168
+ EmptyArray: () => ke,
169
+ EmptyObject: () => dn,
170
+ OSType: () => fe,
171
+ arrayMove: () => Rn,
172
+ asNumber: () => gn,
173
+ camelToPrettyCase: () => mn,
174
+ castToString: () => $n,
175
+ cloneObject: () => bn,
176
+ consoleWithNoSource: () => Un,
177
+ deepEqual: () => ze,
178
+ deepFreeze: () => fr,
179
+ deepMerge: () => ve,
180
+ diffValues: () => Cn,
181
+ findEqualOrGreater: () => In,
182
+ findEqualOrLesser: () => An,
183
+ getFromPath: () => Fn,
184
+ getPlatform: () => He,
185
+ isDefined: () => Nn,
186
+ isEmpty: () => Ln,
187
+ isEqualArrays: () => or,
188
+ isEqualBounds: () => En,
189
+ isNullOrUndefined: () => ur,
190
+ isNumeric: () => yn,
191
+ isObject: () => Me,
192
+ isPromiseLike: () => kn,
193
+ isRectInsideRect: () => Mn,
194
+ isRectIntersect: () => dr,
195
+ mergeContentful: () => Tn,
196
+ removeEmptyProperties: () => ar,
197
+ removeEqualValues: () => sr,
198
+ removeEqualValuesLayered: () => cr,
199
+ removeListenerAll: () => _n,
200
+ roundAccurately: () => Sn,
201
+ setToPath: () => Dn,
202
+ splitNumber: () => wn,
203
+ subtractRect: () => On,
204
+ textToKey: () => hn,
205
+ toSafeJSON: () => st,
206
+ transpose: () => xn,
207
+ uuidV4: () => Ve,
208
+ validEnumValue: () => pn
209
+ }), ke = Object.freeze([]), dn = Object.freeze({}), fn = Promise.resolve(), ir = (e) => e;
210
+ function pn(e, t) {
211
+ if (!Object.values(e).includes(t)) throw Error(\`Invalid type: \${t ?? "null"}. Must be one of: \${Object.values(e).join(", ")}.\`);
212
+ }
213
+ function mn(e) {
214
+ return e ? e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/^./, (t) => t.toUpperCase()) : "";
215
+ }
216
+ function hn(e) {
217
+ return e.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
218
+ }
219
+ var le = Array.from({ length: 256 }, (e, t) => (t + 256).toString(16).slice(1));
220
+ function Ve() {
221
+ let e = globalThis.crypto;
222
+ if (e?.randomUUID) return e.randomUUID();
223
+ if (e?.getRandomValues) {
224
+ let t = e.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
225
+ return t[6] = 15 & t[6] | 64, t[8] = 63 & t[8] | 128, le[t[0]] + le[t[1]] + le[t[2]] + le[t[3]] + "-" + le[t[4]] + le[t[5]] + "-" + le[t[6]] + le[t[7]] + "-" + le[t[8]] + le[t[9]] + "-" + le[t[10]] + le[t[11]] + le[t[12]] + le[t[13]] + le[t[14]] + le[t[15]];
226
+ }
227
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
228
+ let r = 16 * Math.random() | 0;
229
+ return (t === "x" ? r : 3 & r | 8).toString(16);
230
+ });
231
+ }
232
+ function gn(e) {
233
+ let t = (function(r) {
234
+ return 1 * r;
235
+ })(e);
236
+ return Number.isFinite(t) ? t : 0;
237
+ }
238
+ function yn(e) {
239
+ let t = 1 * e;
240
+ return Number.isFinite(t) && typeof t == "number";
241
+ }
242
+ var qe = [
243
+ 1,
244
+ 10,
245
+ 100,
246
+ 1e3,
247
+ 1e4,
248
+ 1e5,
249
+ 1e6,
250
+ 1e7,
251
+ 1e8,
252
+ 1e9,
253
+ 1e10,
254
+ 1e11,
255
+ 0xe8d4a51000,
256
+ 0x9184e72a000,
257
+ 0x5af3107a4000,
258
+ 0x38d7ea4c68000,
259
+ 0x2386f26fc10000
260
+ ];
261
+ function wn(e) {
262
+ let t = Math.abs(e);
263
+ if (!Number.isFinite(t)) return null;
264
+ let r = Math.trunc(t), n = t - r, i;
265
+ r > 2 ** 53 - 1 ? i = Number(r.toExponential().split("e")[1]) + 1 : (i = Math.ceil(Math.log10(r + 1)), qe[i] <= r && i++);
266
+ let o = 0, l = 0, s = 15 - i;
267
+ if (n > 0 && s > 0) {
268
+ let c = qe[s];
269
+ if (o = Math.round(n * c), o === c) r++, o = 0, r >= qe[i] && i++;
270
+ else if (o > 0) for (l = s; o % 10 == 0;) o /= 10, l--;
271
+ }
272
+ return {
273
+ ip: e < 0 ? -r : r,
274
+ fp: o,
275
+ ipLength: i,
276
+ fpLength: l
277
+ };
278
+ }
279
+ function Sn(e, t = 0) {
280
+ if (e == null || !isFinite(e)) return null;
281
+ let r = 10 ** t;
282
+ return Number(Math.round(e * r) / r);
283
+ }
284
+ function bn(e) {
285
+ return ur(e) ? e : JSON.parse(JSON.stringify(e));
286
+ }
287
+ var vn = (e, t) => e === t;
288
+ function or(e, t, r) {
289
+ if (e === t) return !0;
290
+ if (!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length) return !1;
291
+ r ||= vn;
292
+ let n = e.length;
293
+ for (let i = 0; i < n; i++) if (!r(e[i], t[i])) return !1;
294
+ return !0;
295
+ }
296
+ function En(e, t) {
297
+ return e === t || !(!e || !t) && e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
298
+ }
299
+ function Me(e) {
300
+ return typeof e == "object" && !Array.isArray(e) && e !== null;
301
+ }
302
+ function ar(e) {
303
+ if (typeof e != "object" || Array.isArray(e) || e === null) return e;
304
+ let t = e;
305
+ return Object.keys(t).forEach(function(r) {
306
+ t[r] && typeof t[r] == "object" ? ar(t[r]) : t[r] !== null && t[r] !== void 0 || delete t[r], typeof t[r] == "object" && Object.keys(t[r]).length === 0 && delete t[r];
307
+ }), Object.keys(e).length === 0 ? null : e;
308
+ }
309
+ function _n(e, t) {
310
+ if (!e) return ke;
311
+ let r = e.length;
312
+ for (let n = 0; n < r; n++) {
313
+ let i = e[n];
314
+ i && i(t);
315
+ }
316
+ return ke;
317
+ }
318
+ function xn(e) {
319
+ if (!e) return e;
320
+ let t = e.length, r = e[0].length, n = [];
321
+ for (let i = 0; i < r; i++) n[i] = Array(t);
322
+ for (let i = 0; i < t; i++) {
323
+ let o = e[i];
324
+ for (let l = 0; l < r; l++) n[l][i] = o[l];
325
+ }
326
+ return n;
327
+ }
328
+ var lr = (e, t) => !(e !== t && !or(e, t)) || !!e.isEqual?.(t);
329
+ function sr(e, t, r = lr) {
330
+ if (e == null || e === t) return null;
331
+ if (!e || typeof e != "object" || Array.isArray(e) || e.isImmutable?.()) return r(e, t) ? null : e;
332
+ let n = Object.keys(e), i = n.length;
333
+ if (i === 0) return null;
334
+ let o = !1;
335
+ for (let l = 0; l < i; l++) {
336
+ let s = n[l];
337
+ sr(e[s], t?.[s], r) === null && (o = !0, delete e[s]);
338
+ }
339
+ return o && Object.keys(e).length === 0 ? null : void 0;
340
+ }
341
+ function cr(e, t, r = lr) {
342
+ if (e == null) return !0;
343
+ if (!e || typeof e != "object" || Array.isArray(e) || e.isImmutable?.()) {
344
+ let s, c = !1;
345
+ for (let d = 0; !c && d < t.length; d++) t[d] !== void 0 && (c = !0, s = t[d]);
346
+ return c && (e === s || r(e, s));
347
+ }
348
+ let n = Object.keys(e), i = n.length;
349
+ if (i === 0) return !0;
350
+ let o = t.length, l = !1;
351
+ for (let s = 0; s < i; s++) {
352
+ let c = n[s], d = [];
353
+ for (let m = 0; m < o; m++) {
354
+ let a = t[m]?.[c];
355
+ a !== void 0 && d.push(a);
356
+ }
357
+ cr(e[c], d, r) && (l = !0, delete e[c]);
358
+ }
359
+ return l && Object.keys(e).length === 0;
360
+ }
361
+ function Tn(...e) {
362
+ let t = e.length;
363
+ if (t > 0 && e[t - 1] !== void 0 && !Me(e[t - 1])) return e[t - 1];
364
+ let r = e[0] || {};
365
+ for (let n = 1; n < t; n++) r = ve(r, e[n] || {}, { arrayMerge: (i, o) => [...o] });
366
+ return r;
367
+ }
368
+ function Cn(e, t) {
369
+ let r = {}, n = Object.keys(t), i = n.length;
370
+ for (let o = 0; o < i; o++) {
371
+ let l = n[o], s = e[l], c = t[l];
372
+ s !== c && (r[l] = s === void 0 ? c : s);
373
+ }
374
+ return Object.keys(r).length === 0 ? null : r;
375
+ }
376
+ function In(e, t, r = ir) {
377
+ let n = 0, i = e.length - 1;
378
+ for (; n <= i;) {
379
+ let o = Math.floor((n + i) / 2), l = r(e[o]);
380
+ if (l === t) return o;
381
+ l < t ? n = o + 1 : i = o - 1;
382
+ }
383
+ return n;
384
+ }
385
+ function An(e, t, r = ir) {
386
+ let n = e.length - 1, i = 0;
387
+ for (; n >= i;) {
388
+ let o = Math.floor((n + i) / 2), l = r(e[o]);
389
+ if (l === t) return o;
390
+ l > t ? n = o - 1 : i = o + 1;
391
+ }
392
+ return n;
393
+ }
394
+ function Rn(e, t, r) {
395
+ let n = e.slice();
396
+ return n.splice(r < 0 ? n.length + r : r, 0, n.splice(t, 1)[0]), n;
397
+ }
398
+ function $n(e) {
399
+ return e == null || e === void 0 ? "" : typeof e == "string" ? e : "" + e;
400
+ }
401
+ function ur(e) {
402
+ return e == null;
403
+ }
404
+ function Nn(e) {
405
+ return e != null;
406
+ }
407
+ function Ln(e) {
408
+ return e == null || e === "";
409
+ }
410
+ function kn(e) {
411
+ return !!e && typeof e.then == "function";
412
+ }
413
+ function dr(e, t) {
414
+ return !(t.left > e.right || t.right < e.left || t.top > e.bottom || t.bottom < e.top);
415
+ }
416
+ function Mn(e, t) {
417
+ return e.top >= t.top && e.bottom <= t.bottom && e.left >= t.left && e.right <= t.right;
418
+ }
419
+ function On(e, t, r = !1) {
420
+ if (!t) return [e];
421
+ if (!dr(e, t)) return [];
422
+ let n = [], i = e, o = () => {
423
+ t.top > i.top && t.top < i.bottom && (n.push({
424
+ ...i,
425
+ bottom: t.top
426
+ }), i = {
427
+ ...i,
428
+ top: t.top
429
+ });
430
+ }, l = () => {
431
+ t.bottom > i.top && t.bottom < i.bottom && (n.push({
432
+ ...i,
433
+ top: t.bottom
434
+ }), i = {
435
+ ...i,
436
+ bottom: t.bottom
437
+ });
438
+ }, s = () => {
439
+ t.right > i.left && t.right < i.right && (n.push({
440
+ ...i,
441
+ left: t.right
442
+ }), i = {
443
+ ...i,
444
+ right: t.right
445
+ });
446
+ }, c = () => {
447
+ t.left > i.left && t.left < i.right && (n.push({
448
+ ...i,
449
+ right: t.left
450
+ }), i = {
451
+ ...i,
452
+ left: t.left
453
+ });
454
+ };
455
+ return r ? (c(), s(), o(), l()) : (o(), l(), s(), c()), n;
456
+ }
457
+ function Fn(e, t) {
458
+ let r = t.split("."), n = e, i = r.length;
459
+ for (let o = 0; o < i; o++) {
460
+ let l = r[o];
461
+ if (!n) return null;
462
+ let s = n[l];
463
+ if (typeof s == "function" && (s = s.bind(n)()), !s || !Me(s)) return s;
464
+ n = s;
465
+ }
466
+ return n ?? null;
467
+ }
468
+ function Dn(e, t, r) {
469
+ let n = t.split("."), i = e;
470
+ if (!i) throw Error("Can not set path to a null path.");
471
+ let o = n.length;
472
+ for (let l = 0; i && l < o - 1; l++) {
473
+ let s = n[l], c = i[s];
474
+ if (c ?? (c = {}, i[s] = c), !Me(c)) throw Error("Can not set path to a non object path.");
475
+ i = c;
476
+ }
477
+ if (typeof r != "number" && typeof r != "boolean" && typeof r != "string" && !Me(r)) throw Error(\`Can not set path to \${r} that is not a a supported primitive.\`);
478
+ return i[n[o - 1]] = r, e;
479
+ }
480
+ function Un(...e) {
481
+ return new Promise((t) => {
482
+ setTimeout(() => {
483
+ Function("console.log.apply(console, arguments)").apply(null, e), t();
484
+ });
485
+ });
486
+ }
487
+ var fe = {
488
+ Windows: "windows",
489
+ MacOS: "macos",
490
+ IOS: "ios",
491
+ Linux: "linux",
492
+ Android: "android",
493
+ Safari: "safari",
494
+ Firefox: "firefox",
495
+ Unknown: "unknown"
496
+ };
497
+ function He() {
498
+ let e = globalThis.navigator !== void 0 && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : "";
499
+ return e ? /(win32|win64|windows|wince)/i.test(e) ? fe.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(e) ? fe.MacOS : /(iphone|ipad|ipod)/i.test(e) ? fe.IOS : /android/.test(e) ? fe.Android : /linux/.test(e) ? fe.Linux : /^((?!chrome|android|).)*safari/i.test(e) ? fe.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(e) ? fe.Firefox : fe.Unknown : fe.Unknown;
500
+ }
501
+ function fr(e) {
502
+ Object.freeze(e);
503
+ let t = e;
504
+ return Object.keys(t).forEach((r) => {
505
+ typeof t[r] != "object" || t[r] === null || Object.isFrozen(t[r]) || fr(t[r]);
506
+ }), e;
507
+ }
508
+ function st(e) {
509
+ if (typeof e != "object" || !e) return e;
510
+ if (typeof e.toJSON == "function") return e.toJSON();
511
+ if (Array.isArray(e)) return e.map((r) => st(r));
512
+ if (typeof e.toString == "function" && e.toString !== Object.prototype.toString) return e.toString();
513
+ let t = {};
514
+ for (let r in e) e.hasOwnProperty(r) && (t[r] = st(e[r]));
515
+ return t;
516
+ }
517
+ ge({
518
+ EmptyCell: () => pr,
519
+ EmptyRange: () => Bn,
520
+ EmptyRanges: () => Pn,
521
+ EmptySelection: () => jn,
522
+ InsertCutShift: () => be,
523
+ cellToRange: () => Vn,
524
+ classifyInsertCut: () => ei,
525
+ columnFirstCellComparator: () => wr,
526
+ columnFirstRangeComparator: () => mr,
527
+ createCellComparator: () => _r,
528
+ createConflatingRanges: () => Qn,
529
+ createRangeComparator: () => Er,
530
+ defaultRange: () => Yn,
531
+ extendRangeToIntersectingRanges: () => Rr,
532
+ extendRangeToUnionRanges: () => Hn,
533
+ intersectRanges: () => Ir,
534
+ isCellWithinRange: () => Kn,
535
+ isEqualCells: () => xr,
536
+ isEqualRanges: () => mt,
537
+ isEqualRangesArrays: () => Cr,
538
+ isEqualSelectionCoords: () => Ar,
539
+ isRangeWithinRange: () => Tr,
540
+ isRangesIntersect: () => ht,
541
+ isRefusedInsertCut: () => ti,
542
+ isSingleCell: () => zn,
543
+ isValidRange: () => Gn,
544
+ mergeRangeCoordValues: () => Nr,
545
+ reverseColumnFirstCellComparator: () => vr,
546
+ reverseColumnFirstRangeComparator: () => yr,
547
+ reverseRowFirstCellComparator: () => br,
548
+ reverseRowFirstRangeComparator: () => gr,
549
+ rowFirstCellComparator: () => Sr,
550
+ rowFirstRangeComparator: () => hr,
551
+ sanitizeRange: () => $r,
552
+ sanitizeRangeArray: () => Jn,
553
+ translateRange: () => Wn,
554
+ unionRanges: () => ct,
555
+ unionRangesArrays: () => Xn
556
+ });
557
+ var pr = Object.freeze({
558
+ colIndex: 0,
559
+ rowIndex: 0
560
+ }), Bn = Object.freeze({
561
+ colStart: 0,
562
+ rowStart: 0,
563
+ colEnd: 0,
564
+ rowEnd: 0
565
+ }), Pn = ke, jn = Object.freeze({
566
+ cell: pr,
567
+ ranges: ke,
568
+ rangeIndex: -1
569
+ });
570
+ function mr(e, t) {
571
+ return e.colStart === t.colStart ? e.rowStart - t.rowStart : e.colStart - t.colStart;
572
+ }
573
+ function hr(e, t) {
574
+ return e.rowStart === t.rowStart ? e.colStart - t.colStart : e.rowStart - t.rowStart;
575
+ }
576
+ function gr(e, t) {
577
+ return e.rowEnd === t.rowEnd ? t.colEnd - e.colEnd : t.rowEnd - e.rowEnd;
578
+ }
579
+ function yr(e, t) {
580
+ return e.colEnd === t.colEnd ? t.rowEnd - e.rowEnd : t.colEnd - e.colEnd;
581
+ }
582
+ function wr(e, t) {
583
+ return e.colIndex === t.colIndex ? e.rowIndex - t.rowIndex : e.colIndex - t.colIndex;
584
+ }
585
+ function Sr(e, t) {
586
+ return e.rowIndex === t.rowIndex ? e.colIndex - t.colIndex : e.rowIndex - t.rowIndex;
587
+ }
588
+ function br(e, t) {
589
+ return e.rowIndex === t.rowIndex ? t.colIndex - e.colIndex : t.rowIndex - e.rowIndex;
590
+ }
591
+ function vr(e, t) {
592
+ return e.colIndex === t.colIndex ? t.rowIndex - e.rowIndex : t.colIndex - e.colIndex;
593
+ }
594
+ function Er(e = oe.Row, t = !1) {
595
+ return t ? e === oe.Column ? yr : gr : e === oe.Column ? mr : hr;
596
+ }
597
+ function _r(e = oe.Row, t = !1) {
598
+ return t ? e === oe.Column ? vr : br : e === oe.Column ? wr : Sr;
599
+ }
600
+ function xr(e, t) {
601
+ return e === t || !(!e || !t) && e.rowIndex === t.rowIndex && e.colIndex === t.colIndex && e.scope === t.scope;
602
+ }
603
+ function mt(e, t) {
604
+ return e === t || !(!e || !t) && e.rowStart === t.rowStart && e.rowEnd === t.rowEnd && e.colStart === t.colStart && e.colEnd === t.colEnd && e.scope === t.scope;
605
+ }
606
+ function Kn(e, t) {
607
+ if (!e || !t) return !1;
608
+ let r = e.rowIndex;
609
+ if (r < t.rowStart || r > t.rowEnd) return !1;
610
+ let n = e.colIndex;
611
+ return !(n < t.colStart || n > t.colEnd);
612
+ }
613
+ function Tr(e, t) {
614
+ return !(!e || !t) && !(e.rowStart < t.rowStart || e.rowEnd > t.rowEnd) && !(e.colStart < t.colStart || e.colEnd > t.colEnd);
615
+ }
616
+ function ht(e, t) {
617
+ return !(!e || !t) && !(e.colStart > t.colEnd || t.colStart > e.colEnd) && !(e.rowStart > t.rowEnd || t.rowStart > e.rowEnd);
618
+ }
619
+ function Cr(e, t) {
620
+ if (e === t) return !0;
621
+ if (!e || !t || e.length !== t.length) return !1;
622
+ for (let r = 0; r < e.length; r++) if (!mt(e[r], t[r])) return !1;
623
+ return !0;
624
+ }
625
+ function zn(e) {
626
+ return !!e && e.rowEnd === e.rowStart && e.colStart === e.colEnd;
627
+ }
628
+ function Vn(e, t) {
629
+ if (!e) return null;
630
+ let r = t;
631
+ return r || (r = { ...e }, delete r.colIndex, delete r.rowIndex), r.colStart = e.colIndex ?? 0, r.rowStart = e.rowIndex ?? 0, r.colEnd = e.colIndex ?? 0, r.rowEnd = e.rowIndex ?? 0, r;
632
+ }
633
+ function Ir(e, t, r) {
634
+ if (!e) return r ? t : { ...t };
635
+ if (!t) return r ? e : { ...e };
636
+ if (!e && !t || e.rowStart > t.rowEnd || e.rowEnd < t.rowStart || e.colStart > t.colEnd || e.colEnd < t.colStart) return null;
637
+ let n = Math.max(e.colStart, t.colStart), i = Math.max(e.rowStart, t.rowStart), o = Math.min(e.colEnd, t.colEnd), l = Math.min(e.rowEnd, t.rowEnd), s = r;
638
+ return s ? (s.colStart = n, s.rowStart = i, s.colEnd = o, s.rowEnd = l) : s = {
639
+ colStart: n,
640
+ rowStart: i,
641
+ colEnd: o,
642
+ rowEnd: l
643
+ }, s;
644
+ }
645
+ function ct(e, t, r) {
646
+ if (!e && !t) return null;
647
+ if (!e) return r ? t : { ...t };
648
+ if (!t) return r ? e : { ...e };
649
+ let n = Math.min(e.colStart, t.colStart), i = Math.min(e.rowStart, t.rowStart), o = Math.max(e.colEnd, t.colEnd), l = Math.max(e.rowEnd, t.rowEnd), s = r;
650
+ return s ? (s.colStart = n, s.rowStart = i, s.colEnd = o, s.rowEnd = l) : s = {
651
+ colStart: n,
652
+ rowStart: i,
653
+ colEnd: o,
654
+ rowEnd: l
655
+ }, s;
656
+ }
657
+ function Ar(e, t) {
658
+ return e === t || !(!e || !t) && e.rangeIndex === t.rangeIndex && !!xr(e.cell, t.cell) && Cr(e.ranges, t.ranges);
659
+ }
660
+ function Xn(e, t, r) {
661
+ if (!e || e.length === 0) return null;
662
+ if (e.length === 1 && !t) return e[0];
663
+ let n = e[0];
664
+ for (let i = 1; i < e.length; i++) n = ct(n, e[i], r);
665
+ return t && (n = ct(n, t, r)), n;
666
+ }
667
+ function Gn(e) {
668
+ return !!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);
669
+ }
670
+ function Hn(e, t) {
671
+ if (!t || t.length === 0) return e;
672
+ let r = e, n = null;
673
+ for (; !mt(r, n);) n = r, r = Rr(n, t);
674
+ return r;
675
+ }
676
+ function Rr(e, t) {
677
+ if (!t || t.length === 0) return e;
678
+ let r = { ...e };
679
+ for (let n = 0; n < t.length; n++) {
680
+ let i = t[n];
681
+ ht(r, i) && (r.rowStart = Math.min(r.rowStart, i.rowStart), r.colStart = Math.min(r.colStart, i.colStart), r.rowEnd = Math.max(r.rowEnd, i.rowEnd), r.colEnd = Math.max(r.colEnd, i.colEnd));
682
+ }
683
+ return r;
684
+ }
685
+ function Wn(e, t = -e.rowStart, r = -e.colStart, n) {
686
+ return n ? (n.colStart = e.colStart + r, n.rowStart = e.rowStart + t, n.colEnd = e.colEnd + r, n.rowEnd = e.rowEnd + t, n) : {
687
+ colStart: e.colStart + r,
688
+ rowStart: e.rowStart + t,
689
+ colEnd: e.colEnd + r,
690
+ rowEnd: e.rowEnd + t
691
+ };
692
+ }
693
+ function $r(e, t) {
694
+ return e ? e.scope ? {
695
+ colStart: e.colIndex ?? e.colStart ?? t?.colStart ?? 0,
696
+ rowStart: e.rowIndex ?? e.rowStart ?? t?.rowStart ?? 0,
697
+ colEnd: e.colIndex ?? e.colEnd ?? t?.colEnd ?? 0,
698
+ rowEnd: e.rowIndex ?? e.rowEnd ?? t?.rowEnd ?? 0,
699
+ scope: e.scope
700
+ } : {
701
+ colStart: e.colIndex ?? e.colStart ?? t?.colStart ?? 0,
702
+ rowStart: e.rowIndex ?? e.rowStart ?? t?.rowStart ?? 0,
703
+ colEnd: e.colIndex ?? e.colEnd ?? t?.colEnd ?? 0,
704
+ rowEnd: e.rowIndex ?? e.rowEnd ?? t?.rowEnd ?? 0
705
+ } : null;
706
+ }
707
+ function Jn(e, t) {
708
+ if (!e) return null;
709
+ let r = e.length, n = Array(r);
710
+ for (let i = 0; i < r; i++) n[i] = $r(e[i], t);
711
+ return n;
712
+ }
713
+ function Yn(e, t, r) {
714
+ return e ? r ? (r.colStart = e.colStart ?? t.colStart, r.rowStart = e.rowStart ?? t.rowStart, r.colEnd = e.colEnd ?? t.colEnd, r.rowEnd = e.rowEnd ?? t.rowEnd, r) : {
715
+ colStart: e.colStart ?? t.colStart,
716
+ rowStart: e.rowStart ?? t.rowStart,
717
+ colEnd: e.colEnd ?? t.colEnd,
718
+ rowEnd: e.rowEnd ?? t.rowEnd
719
+ } : t;
720
+ }
721
+ var qn = [null, null], Zn = (e, t, r) => {
722
+ if (e[0].value === e[1].value) return t;
723
+ };
724
+ function Nr(e, t = 2, r, n = oe.Row, i) {
725
+ let o = [...e];
726
+ if (t <= 0 || e.length <= 1) return o;
727
+ let l = n === oe.Column, s = 0, c = !1;
728
+ do {
729
+ let d = o.sort(Er(l ? oe.Row : oe.Column));
730
+ o = [], o.push(d[0]);
731
+ let m = d.length, a = 0, f = d[0], b = f.colStart, v = f.rowStart, A = f.colEnd, U = f.rowEnd;
732
+ for (let h = 1; h < m; h++) {
733
+ let w = d[h], S = !1;
734
+ if (S = l ? f && v === w.rowStart && U === w.rowEnd && A + 1 === w.colStart : f && b === w.colStart && A === w.colEnd && U + 1 === w.rowStart, S) {
735
+ let F = {
736
+ colStart: b,
737
+ rowStart: v,
738
+ colEnd: l ? w.colEnd : A,
739
+ rowEnd: l ? U : w.rowEnd
740
+ };
741
+ if (f.value !== void 0 && (F.value = f.value), r) {
742
+ let z = i ?? [null, null];
743
+ z[0] = f, z[1] = w, F = r(z, F, n);
744
+ }
745
+ if (F) {
746
+ o[a] = F, c = !0, f = F, b = f.colStart, v = f.rowStart, A = f.colEnd, U = f.rowEnd;
747
+ continue;
748
+ }
749
+ }
750
+ o[++a] = w, f = w, b = f.colStart, v = f.rowStart, A = f.colEnd, U = f.rowEnd;
751
+ }
752
+ s++, l = !l, s === 1 && (c = !0);
753
+ } while (s < t && c && o.length > 1);
754
+ return o;
755
+ }
756
+ function Qn(e, t = !1) {
757
+ let r = [], n, i = null, o = -(2 ** 53 - 1), l = -(2 ** 53 - 1);
758
+ return {
759
+ append: (s, c, d) => {
760
+ let m = !0, a = d !== void 0;
761
+ if (a) {
762
+ let v = e ? e(n, d, t) : n === d ? d : void 0;
763
+ v === void 0 ? m = !1 : d = v;
764
+ }
765
+ if (m && c === l + 1 && s === o) return t ? i.rowEnd = c : i.colEnd = c, l = c, void (n = d);
766
+ i && r.push(i);
767
+ let f = t ? s : c, b = t ? c : s;
768
+ i = {
769
+ colStart: f,
770
+ rowStart: b,
771
+ colEnd: f,
772
+ rowEnd: b
773
+ }, a && (i.value = d), o = s, l = c, n = d;
774
+ },
775
+ done: (s) => (i &&= (r.push(i), null), s ? Nr(r, 3, s === !0 ? Zn : s, t ? oe.Column : oe.Row, qn) : r)
776
+ };
777
+ }
778
+ var be = {
779
+ Close: "close",
780
+ Blank: "blank",
781
+ Inside: "inside",
782
+ Tear: "tear"
783
+ };
784
+ function ei(e, t, r) {
785
+ let n = r === oe.Row;
786
+ return (n ? e.colStart === t.colStart && e.colEnd === t.colEnd : e.rowStart === t.rowStart && e.rowEnd === t.rowEnd) ? (n ? t.rowStart > e.rowStart && t.rowStart <= e.rowEnd : t.colStart > e.colStart && t.colStart <= e.colEnd) ? be.Inside : be.Close : (n ? e.rowEnd >= t.rowStart && e.colStart <= t.colEnd && e.colEnd >= t.colStart : e.colEnd >= t.colStart && e.rowStart <= t.rowEnd && e.rowEnd >= t.rowStart) ? be.Tear : be.Blank;
787
+ }
788
+ function ti(e) {
789
+ return e === be.Inside || e === be.Tear;
790
+ }
791
+ var Z = {
792
+ Up: "up",
793
+ Down: "down",
794
+ Left: "left",
795
+ Right: "right"
796
+ }, J = {
797
+ Html: "text/html",
798
+ Plain: "text/plain",
799
+ Png: "image/png"
800
+ };
801
+ ge({
802
+ findNextCellWithinSelection: () => Lr,
803
+ traverseHiddenHeaders: () => de
804
+ });
805
+ function de(e, t, r, n) {
806
+ if (!e) return t;
807
+ let i = t, o = r === Z.Right || r === Z.Down;
808
+ for (;;) {
809
+ let l = e(i, !o);
810
+ if (l === 0) return i;
811
+ let s = o ? i + l : i - l;
812
+ if (n !== void 0 && (o ? s > n : s < n)) return n;
813
+ i = s;
814
+ }
815
+ }
816
+ function Lr(e, t = Z.Right, r, n, i, o = null) {
817
+ if (o && Ar(o, e)) return e;
818
+ let l = e.ranges, s = e.rangeIndex, c = l[s];
819
+ if (!ht({
820
+ rowStart: e.cell.rowIndex,
821
+ colStart: e.cell.colIndex,
822
+ rowEnd: e.cell.rowIndex,
823
+ colEnd: e.cell.colIndex
824
+ }, c)) return e;
825
+ let d = { ...e.cell }, m = s;
826
+ switch (t) {
827
+ case Z.Right:
828
+ d.colIndex = de(i, d.colIndex + 1, t, c.colEnd + 1);
829
+ break;
830
+ case Z.Left:
831
+ d.colIndex = de(i, d.colIndex - 1, t, c.colStart - 1);
832
+ break;
833
+ case Z.Down:
834
+ d.rowIndex = de(n, d.rowIndex + 1, t, c.rowEnd + 1);
835
+ break;
836
+ case Z.Up: d.rowIndex = de(n, d.rowIndex - 1, t, c.rowStart - 1);
837
+ }
838
+ let a = (v) => {
839
+ if (v) {
840
+ m = s >= l.length - 1 ? 0 : s + 1;
841
+ let A = l[m];
842
+ d = {
843
+ colIndex: A.colStart,
844
+ rowIndex: A.rowStart
845
+ };
846
+ } else {
847
+ m = s <= 0 ? l.length - 1 : s - 1;
848
+ let A = l[m];
849
+ d = {
850
+ colIndex: A.colEnd,
851
+ rowIndex: A.rowEnd
852
+ };
853
+ }
854
+ };
855
+ if (t === Z.Right && d.colIndex > c.colEnd && d.rowIndex === c.rowEnd) a(!0);
856
+ else if (t === Z.Left && d.colIndex < c.colStart && d.rowIndex === c.rowStart) a(!1);
857
+ else if (t === Z.Down && d.colIndex === c.colEnd && d.rowIndex > c.rowEnd) a(!0);
858
+ else if (t === Z.Up && d.colIndex === c.colStart && d.rowIndex < c.rowStart) a(!1);
859
+ else {
860
+ let v = d.rowIndex, A = d.colIndex;
861
+ switch (t) {
862
+ case Z.Right:
863
+ A > c.colEnd && (v = de(n, v + 1, t, c.rowEnd + 1), A = c.colStart, v > c.rowEnd && (v = c.rowStart));
864
+ break;
865
+ case Z.Left:
866
+ A < c.colStart && (v = de(n, v - 1, t, c.rowStart - 1), A = c.colEnd, v < c.rowStart && (v = c.rowEnd));
867
+ break;
868
+ case Z.Down:
869
+ v > c.rowEnd && (A = de(i, A + 1, t, c.colEnd + 1), v = c.rowStart, A > c.colEnd && (A = c.colStart));
870
+ break;
871
+ case Z.Up: v < c.rowStart && (A = de(i, A - 1, t, c.colStart - 1), v = c.rowEnd, A < c.colStart && (A = c.colEnd));
872
+ }
873
+ d = {
874
+ rowIndex: v,
875
+ colIndex: A
876
+ };
877
+ }
878
+ let f = r(d);
879
+ if (!Tr(f, c)) {
880
+ let v = Ir(f, c);
881
+ v && (f = v);
882
+ }
883
+ let b = {
884
+ rowStart: de(n, f.rowStart, Z.Down, f.rowEnd),
885
+ colStart: de(i, f.colStart, Z.Right, f.colEnd),
886
+ rowEnd: de(n, f.rowEnd, Z.Up, f.rowStart),
887
+ colEnd: de(i, f.colEnd, Z.Left, f.colStart)
888
+ };
889
+ if (b.rowStart !== d.rowIndex || b.colStart !== d.colIndex) {
890
+ switch (t) {
891
+ case Z.Right:
892
+ l[m].colStart === b.colStart && l[m].colEnd === b.colEnd && (d.rowIndex = b.rowEnd), d.colIndex = b.colEnd;
893
+ break;
894
+ case Z.Left:
895
+ l[m].colStart === b.colStart && l[m].colEnd === b.colEnd && (d.rowIndex = b.rowStart), d.rowIndex === b.rowStart ? d.colIndex = b.colStart + 1 : d.colIndex = b.colStart;
896
+ break;
897
+ case Z.Down:
898
+ l[m].rowStart === b.rowStart && l[m].rowEnd === b.rowEnd && (d.colIndex = b.colEnd), d.rowIndex = b.rowEnd;
899
+ break;
900
+ case Z.Up: l[m].rowStart === b.rowStart && l[m].rowEnd === b.rowEnd && (d.colIndex = b.colStart), d.colIndex === b.colStart ? d.rowIndex = b.rowStart + 1 : d.rowIndex = b.rowStart;
901
+ }
902
+ return Lr({
903
+ cell: d,
904
+ ranges: e.ranges,
905
+ rangeIndex: m
906
+ }, t, r, n, i, o ?? e);
907
+ }
908
+ return {
909
+ ranges: e.ranges,
910
+ cell: d,
911
+ rangeIndex: m
912
+ };
913
+ }
914
+ var ri, Ae = (e, t) => {
915
+ if (e.length >= t) return e;
916
+ let r = new Int32Array(Math.max(t, 2 * e.length));
917
+ return r.set(e), r;
918
+ }, Re = /* @__PURE__ */ new Int32Array(1024), Ze = (e) => (Re.length < e && (Re = new Int32Array(Math.max(e, 2 * Re.length))), Re.fill(0, 0, e), Re), ni = class {
919
+ constructor(e, t, r, n) {
920
+ this._nextOrder = 0, this._activeLen = 0, this._events = /* @__PURE__ */ new Int32Array(64), this._hasBand = !1, this._bandStart = 0, this._bandEnd = 0, this._rMinS = /* @__PURE__ */ new Int32Array(64), this._rMinE = /* @__PURE__ */ new Int32Array(64), this._rOff = /* @__PURE__ */ new Int32Array(65), this._rCount = 0, this._pool = /* @__PURE__ */ new Int32Array(256), this._overlaps = /* @__PURE__ */ new Int32Array(16), this._rInter = null, this._region = -1, this._major = 0, this._minor = 0, this._done = !1, this.rowStart = 0, this.rowEnd = 0, this.colStart = 0, this.colEnd = 0, this.cellRow = 0, this.cellCol = 0, this.intersection = null, this._isColumn = r, this._isReverse = n, this._store = e;
921
+ let i = e.count;
922
+ this._n = i;
923
+ let o = new Int32Array(i), l = new Int32Array(i), s = new Int32Array(i), c = new Int32Array(i), d = r ? e.colS : e.rowS, m = r ? e.colE : e.rowE, a = r ? e.rowS : e.colS, f = r ? e.rowE : e.colE;
924
+ for (let h = 0; h < i; h++) n ? (o[h] = -m[h], l[h] = -d[h], s[h] = -f[h], c[h] = -a[h]) : (o[h] = d[h], l[h] = m[h], s[h] = a[h], c[h] = f[h]);
925
+ this._M0 = o, this._M1 = l, this._m0 = s, this._m1 = c;
926
+ let b = r ? t.colStart : t.rowStart, v = r ? t.colEnd : t.rowEnd, A = v - b + 1, U = new Int32Array(i);
927
+ if (i < 256 || A > 16 * i) {
928
+ for (let h = 0; h < i; h++) U[h] = h;
929
+ U.sort((h, w) => o[h] - o[w] || h - w);
930
+ } else {
931
+ let h = n ? -v : b, w = Ze(A + 1);
932
+ for (let S = 0; S < i; S++) w[o[S] - h + 1]++;
933
+ for (let S = 1; S <= A; S++) w[S] += w[S - 1];
934
+ for (let S = 0; S < i; S++) U[w[o[S] - h]++] = S;
935
+ }
936
+ this._order = U, this._active = new Int32Array(Math.min(2 * i, 1024)), this._scratch = new Int32Array(this._active.length);
937
+ }
938
+ _stable(e) {
939
+ return this._isReverse ? this._n - 1 - e : e;
940
+ }
941
+ _compareEvents(e, t) {
942
+ let r = e >> 1, n = t >> 1, i = 1 & e, o = 1 & t, l = this._m0, s = this._m1, c = i ? s[r] : l[r], d = o ? s[n] : l[n];
943
+ if (c !== d) return c - d;
944
+ if (i !== o) return i - o;
945
+ let m = i ? l[r] : s[r], a = o ? l[n] : s[n];
946
+ return m === a ? this._stable(r) - this._stable(n) : m - a;
947
+ }
948
+ _sortEvents(e, t, r, n) {
949
+ let i = n - r + 1;
950
+ if (t < 256 || i > 16 * t) return e.subarray(0, t).sort((a, f) => this._compareEvents(a, f)), e;
951
+ let o = this._m0, l = this._m1, s = e, c = this._scratch;
952
+ c.length < t && (c = this._scratch = new Int32Array(t));
953
+ let d = Ze(i + 1);
954
+ for (let a = 0; a < t; a++) {
955
+ let f = s[a];
956
+ d[(1 & f ? o[f >> 1] : l[f >> 1]) - r + 1]++;
957
+ }
958
+ for (let a = 1; a <= i; a++) d[a] += d[a - 1];
959
+ for (let a = 0; a < t; a++) {
960
+ let f = s[a];
961
+ c[d[(1 & f ? o[f >> 1] : l[f >> 1]) - r]++] = f;
962
+ }
963
+ let m = 0;
964
+ for (let a = 0; a < t; a++) 1 & c[a] || (s[m++] = c[a]);
965
+ for (let a = 0; a < t; a++) 1 & ~c[a] || (s[m++] = c[a]);
966
+ d = Ze(i + 1);
967
+ for (let a = 0; a < t; a++) {
968
+ let f = s[a];
969
+ d[(1 & f ? l[f >> 1] : o[f >> 1]) - r + 1]++;
970
+ }
971
+ for (let a = 1; a <= i; a++) d[a] += d[a - 1];
972
+ for (let a = 0; a < t; a++) {
973
+ let f = s[a];
974
+ c[d[(1 & f ? l[f >> 1] : o[f >> 1]) - r]++] = f;
975
+ }
976
+ return this._scratch = s, this._events = c, c;
977
+ }
978
+ _advanceBand() {
979
+ let e = this._n, t = this._M0, r = this._M1, n = this._order, i, o = this._active, l = this._activeLen;
980
+ if (this._hasBand) {
981
+ let a = this._bandEnd, f = 0;
982
+ for (let b = 0; b < l; b++) {
983
+ let v = o[b];
984
+ r[v >> 1] > a && (o[f++] = v);
985
+ }
986
+ l = f;
987
+ }
988
+ let s = this._nextOrder;
989
+ if (l > 0) i = this._bandEnd + 1;
990
+ else {
991
+ if (s >= e) return this._activeLen = 0, this._done = !0, !1;
992
+ i = t[n[s]];
993
+ }
994
+ let c = s;
995
+ for (; c < e && t[n[c]] === i;) c++;
996
+ let d = c - s;
997
+ if (d > 0) {
998
+ let a = 2 * d, f = this._events;
999
+ f.length < a && (f = this._events = new Int32Array(Math.max(a, 2 * f.length)));
1000
+ let b = this._m0, v = this._m1, A = 2 ** 53 - 1, U = -(2 ** 53 - 1), h = 0;
1001
+ if (this._isReverse) for (let z = c - 1; z >= s; z--) {
1002
+ let L = n[z];
1003
+ f[h++] = L << 1, f[h++] = L << 1 | 1, b[L] < A && (A = b[L]), v[L] > U && (U = v[L]);
1004
+ }
1005
+ else for (let z = s; z < c; z++) {
1006
+ let L = n[z];
1007
+ f[h++] = L << 1, f[h++] = L << 1 | 1, b[L] < A && (A = b[L]), v[L] > U && (U = v[L]);
1008
+ }
1009
+ let w = this._sortEvents(f, a, A, U), S = l + a, F = this._scratch;
1010
+ if ((F === w || F.length < S) && (F = new Int32Array(Math.max(S, 2 * o.length))), l === 0) F.set(w.subarray(0, a));
1011
+ else {
1012
+ let z = 0, L = 0, R = 0;
1013
+ for (; z < l && L < a;) this._compareEvents(o[z], w[L]) <= 0 ? F[R++] = o[z++] : F[R++] = w[L++];
1014
+ for (; z < l;) F[R++] = o[z++];
1015
+ for (; L < a;) F[R++] = w[L++];
1016
+ }
1017
+ this._scratch = o.length >= F.length ? o : new Int32Array(F.length), o = this._active = F, l = S;
1018
+ }
1019
+ this._activeLen = l, this._nextOrder = c;
1020
+ let m = c < e ? t[n[c]] - 1 : 2 ** 53 - 1;
1021
+ for (let a = 0; a < l; a++) {
1022
+ let f = r[o[a] >> 1];
1023
+ f < m && (m = f);
1024
+ }
1025
+ return this._bandStart = i, this._bandEnd = m, this._hasBand = !0, this._sweepBand(), !0;
1026
+ }
1027
+ _sweepBand() {
1028
+ let e = this._active, t = this._activeLen, r = this._m0, n = this._m1, i = this._rMinS, o = this._rMinE, l = this._rOff, s = this._pool, c = this._overlaps, d = 0, m = 0, a = 0, f = 0, b = (v, A) => {
1029
+ a >= i.length && (i = this._rMinS = Ae(i, a + 1), o = this._rMinE = Ae(o, a + 1), l = this._rOff = Ae(l, i.length + 1)), i[a] = v, o[a] = A, l[a] = m, a++, m + d > s.length && (s = this._pool = Ae(s, m + d));
1030
+ for (let U = 0; U < d; U++) s[m++] = c[U];
1031
+ };
1032
+ for (let v = 0; v < t; v++) {
1033
+ let A = e[v], U = A >> 1;
1034
+ if (1 & A) {
1035
+ let h = n[U];
1036
+ if (f <= h && b(f, h), d > 1) {
1037
+ let w = d - 1;
1038
+ for (; w >= 0 && c[w] !== U;) w--;
1039
+ w !== -1 && (c[w] = c[d - 1]);
1040
+ }
1041
+ d--, f = h + 1;
1042
+ } else {
1043
+ let h = r[U];
1044
+ d > 0 && f < h && b(f, h - 1), d >= c.length && (c = this._overlaps = Ae(c, d + 1)), c[d++] = U, f = h;
1045
+ }
1046
+ }
1047
+ l[a] = m, this._rCount = a, this._region = -1, this._rInter = null;
1048
+ }
1049
+ _setRegion(e) {
1050
+ let t = this._isReverse, r = t ? 0 - this._bandEnd : this._bandStart, n = t ? 0 - this._bandStart : this._bandEnd, i = this._rMinS[e], o = this._rMinE[e], l = t ? 0 - o : i, s = t ? 0 - i : o;
1051
+ this._isColumn ? (this.colStart = r, this.colEnd = n, this.rowStart = l, this.rowEnd = s) : (this.rowStart = r, this.rowEnd = n, this.colStart = l, this.colEnd = s);
1052
+ let c = this._rInter;
1053
+ if (c) {
1054
+ let d = c[e];
1055
+ d ||= c[e] = this._materialize(e), this.intersection = d;
1056
+ } else this.intersection = this._materialize(e);
1057
+ }
1058
+ nextRegion() {
1059
+ if (this._done) return !1;
1060
+ let e = this._region + 1;
1061
+ for (; !this._hasBand || e >= this._rCount;) {
1062
+ if (!this._advanceBand()) return !1;
1063
+ e = 0;
1064
+ }
1065
+ return this._region = e, this._setRegion(e), !0;
1066
+ }
1067
+ _setCell(e) {
1068
+ let t = this._isReverse, r = t ? 0 - this._major : this._major, n = t ? 0 - this._minor : this._minor;
1069
+ this._isColumn ? (this.cellCol = r, this.cellRow = n) : (this.cellRow = r, this.cellCol = n), e !== this._region && (this._region = e, this._setRegion(e));
1070
+ }
1071
+ _enterBandByCell() {
1072
+ this._rInter = this._bandEnd > this._bandStart ? Array(this._rCount) : null, this._major = this._bandStart;
1073
+ }
1074
+ nextCell() {
1075
+ if (this._done) return !1;
1076
+ let e = this._region;
1077
+ if (!this._hasBand || e < 0) {
1078
+ if (!this._hasBand) {
1079
+ if (!this._advanceBand()) return !1;
1080
+ this._enterBandByCell();
1081
+ }
1082
+ return this._minor = this._rMinS[0], this._setCell(0), !0;
1083
+ }
1084
+ let t = this._minor + 1;
1085
+ if (t <= this._rMinE[e]) return this._minor = t, this._setCell(e), !0;
1086
+ if (e++, e >= this._rCount && (e = 0, ++this._major > this._bandEnd)) {
1087
+ if (!this._advanceBand()) return !1;
1088
+ this._enterBandByCell();
1089
+ }
1090
+ return this._minor = this._rMinS[e], this._setCell(e), !0;
1091
+ }
1092
+ seekCell(e, t) {
1093
+ if (this._done) return !1;
1094
+ let r = this._isReverse, n = this._isColumn ? t : e, i = this._isColumn ? e : t;
1095
+ if (r && (n = -n, i = -i), this._hasBand && this._region >= 0 && (n < this._major || n === this._major && i <= this._minor)) return this.nextCell();
1096
+ for (;;) {
1097
+ if (!this._hasBand || n > this._bandEnd) {
1098
+ if (!this._advanceBand()) return !1;
1099
+ this._enterBandByCell();
1100
+ continue;
1101
+ }
1102
+ if (n < this._bandStart) return this._major = this._bandStart, this._minor = this._rMinS[0], this._setCell(0), !0;
1103
+ this._major = n;
1104
+ let o = this._rMinE, l = 0, s = this._rCount;
1105
+ for (; l < s;) {
1106
+ let c = l + s >>> 1;
1107
+ o[c] < i ? l = c + 1 : s = c;
1108
+ }
1109
+ if (l < this._rCount) {
1110
+ let c = this._rMinS[l];
1111
+ return this._minor = c > i ? c : i, this._setCell(l), !0;
1112
+ }
1113
+ if (!(++this._major > this._bandEnd)) return this._minor = this._rMinS[0], this._setCell(0), !0;
1114
+ if (!this._advanceBand()) return !1;
1115
+ this._enterBandByCell();
1116
+ }
1117
+ }
1118
+ }, xt = Object.freeze({
1119
+ done: !0,
1120
+ value: void 0
1121
+ });
1122
+ (function(e) {
1123
+ class t extends ni {
1124
+ constructor(...i) {
1125
+ super(...i), this._reuseOverlaps = null;
1126
+ }
1127
+ _materialize(i) {
1128
+ let o = this._rOff, l = this._pool, s = this._store.value, c = o[i], d = o[i + 1], m = this._reuseOverlaps;
1129
+ m ? m.length = 0 : m = [];
1130
+ for (let a = c; a < d; a++) m.push(s[l[a]]);
1131
+ return m;
1132
+ }
1133
+ }
1134
+ class r {
1135
+ constructor(i, o) {
1136
+ if (this._sweep = null, this._isByCell = !1, this._cellComparator = null, this._lastCell = null, this._reuse = null, !i || i.length === 0) return;
1137
+ let l, s = !0, c = !1, d = !1;
1138
+ if (o && (s = (o.axis ?? oe.Column) !== oe.Row, c = o.reverse ?? !1, d = o.byCell ?? !1, l = o.reuseIterator), this._isByCell = d, l) {
1139
+ let w = typeof l == "boolean" ? {
1140
+ done: !1,
1141
+ value: {
1142
+ cell: null,
1143
+ range: null,
1144
+ overlaps: null
1145
+ }
1146
+ } : l;
1147
+ w.done = !1;
1148
+ let S = w.value;
1149
+ S ||= w.value = {
1150
+ cell: null,
1151
+ range: null,
1152
+ overlaps: null
1153
+ }, S.range || (S.range = {
1154
+ colStart: 0,
1155
+ rowStart: 0,
1156
+ colEnd: 0,
1157
+ rowEnd: 0
1158
+ }), S.cell = d ? S.cell ?? {
1159
+ colIndex: -1,
1160
+ rowIndex: -1
1161
+ } : null, this._reuse = w;
1162
+ }
1163
+ let m = i.length, a = {
1164
+ count: m,
1165
+ rowS: new Int32Array(m),
1166
+ rowE: new Int32Array(m),
1167
+ colS: new Int32Array(m),
1168
+ colE: new Int32Array(m),
1169
+ type: new Uint16Array(m),
1170
+ value: [],
1171
+ keys: ["range"]
1172
+ }, f = 2 ** 53 - 1, b = -(2 ** 53 - 1), v = 2 ** 53 - 1, A = -(2 ** 53 - 1);
1173
+ for (let w = 0; w < m; w++) {
1174
+ let S = i[w];
1175
+ a.rowS[w] = S.rowStart, a.rowE[w] = S.rowEnd, a.colS[w] = S.colStart, a.colE[w] = S.colEnd, a.value.push(S), S.rowStart < f && (f = S.rowStart), S.rowEnd > b && (b = S.rowEnd), S.colStart < v && (v = S.colStart), S.colEnd > A && (A = S.colEnd);
1176
+ }
1177
+ let U = {
1178
+ rowStart: f,
1179
+ rowEnd: b,
1180
+ colStart: v,
1181
+ colEnd: A
1182
+ }, h = this._sweep = new t(a, U, s, c);
1183
+ d ? this._cellComparator = _r(s ? oe.Column : oe.Row, c) : l && (h._reuseOverlaps = []);
1184
+ }
1185
+ next(i) {
1186
+ let o = this._sweep;
1187
+ if (!o) return xt;
1188
+ let l = this._isByCell, s;
1189
+ if (i) {
1190
+ if (!l) throw Error("nextCell is only supported when byCell is true");
1191
+ let a = this._lastCell;
1192
+ if (a && this._cellComparator(a, i) >= 0) throw Error("nextCell must be after the current iteration cell");
1193
+ s = o.seekCell(i.rowIndex, i.colIndex);
1194
+ } else s = l ? o.nextCell() : o.nextRegion();
1195
+ if (!s) return this._sweep = null, xt;
1196
+ let c = this._reuse;
1197
+ if (c) {
1198
+ let a = c.value;
1199
+ c.done = !1;
1200
+ let f = a.range;
1201
+ if (f.colStart = o.colStart, f.rowStart = o.rowStart, f.colEnd = o.colEnd, f.rowEnd = o.rowEnd, l) {
1202
+ let b = a.cell;
1203
+ b.colIndex = o.cellCol, b.rowIndex = o.cellRow;
1204
+ let v = this._lastCell;
1205
+ v ||= this._lastCell = {
1206
+ colIndex: 0,
1207
+ rowIndex: 0
1208
+ }, v.colIndex = o.cellCol, v.rowIndex = o.cellRow;
1209
+ }
1210
+ return a.overlaps = o.intersection, c;
1211
+ }
1212
+ let d = null, m = o.intersection;
1213
+ return l && (d = this._lastCell = {
1214
+ colIndex: o.cellCol,
1215
+ rowIndex: o.cellRow
1216
+ }, m = m.slice()), {
1217
+ done: !1,
1218
+ value: {
1219
+ cell: d,
1220
+ range: {
1221
+ colStart: o.colStart,
1222
+ rowStart: o.rowStart,
1223
+ colEnd: o.colEnd,
1224
+ rowEnd: o.rowEnd
1225
+ },
1226
+ overlaps: m
1227
+ }
1228
+ };
1229
+ }
1230
+ return(i) {
1231
+ return null;
1232
+ }
1233
+ throw(i) {
1234
+ return null;
1235
+ }
1236
+ [Symbol.iterator]() {
1237
+ return this;
1238
+ }
1239
+ }
1240
+ e.IteratorInstance = r;
1241
+ })(ri ||= {});
1242
+ var ii = class {
1243
+ constructor() {
1244
+ this._onceMessageKeys = /* @__PURE__ */ new Set(), this._overrides = null;
1245
+ }
1246
+ setOverrides(e) {
1247
+ this._overrides = e ?? null;
1248
+ }
1249
+ getOverrides() {
1250
+ return this._overrides;
1251
+ }
1252
+ _write(e, t, r) {
1253
+ if (r?.onceKey) {
1254
+ let o = this._onceMessageKeys;
1255
+ if (o.has(r.onceKey)) return;
1256
+ o.add(r.onceKey);
1257
+ }
1258
+ let n = r?.meta, i = this._overrides;
1259
+ if (i) {
1260
+ let o = i[e];
1261
+ if (o) return void o.bind(i)(t, r);
1262
+ }
1263
+ n === void 0 ? console[e](t) : console[e](t, n);
1264
+ }
1265
+ log(e, t) {
1266
+ return this._write("log", e, t);
1267
+ }
1268
+ error(e, t) {
1269
+ return this._write("error", e, t);
1270
+ }
1271
+ warn(e, t) {
1272
+ return this._write("warn", e, t);
1273
+ }
1274
+ debug(e, t) {
1275
+ return this._write("debug", e, t);
1276
+ }
1277
+ };
1278
+ new ii();
1279
+ var Qe;
1280
+ ge({
1281
+ EmptyBounds: () => li,
1282
+ EmptyRect: () => ai,
1283
+ EmptyTopLeft: () => oi
1284
+ });
1285
+ var oi = Object.freeze({
1286
+ left: 0,
1287
+ top: 0
1288
+ }), ai = Object.freeze({
1289
+ left: 0,
1290
+ top: 0,
1291
+ bottom: 0,
1292
+ right: 0
1293
+ }), li = Object.freeze({
1294
+ x: 0,
1295
+ y: 0,
1296
+ width: 0,
1297
+ height: 0
1298
+ });
1299
+ ge({
1300
+ canUseDOM: () => kr,
1301
+ getDPI: () => ci,
1302
+ hasFocus: () => Mr,
1303
+ openFileDialog: () => si,
1304
+ scrollIntoContainer: () => ui,
1305
+ whenFocus: () => di
1306
+ });
1307
+ var kr = !(typeof window > "u" || !window.document || !window.document.createElement), si = (e = "*.*") => new Promise((t, r) => {
1308
+ if (!kr) return void r("Unable to open dialog with no dom.");
1309
+ let n = document.createElement("input");
1310
+ n.type = "file", n.accept = e;
1311
+ let i = null, o = !1;
1312
+ globalThis.addEventListener?.("focus", () => {
1313
+ setTimeout(() => {
1314
+ i || o || (o = !0, t(null));
1315
+ }, 1e3);
1316
+ }, {
1317
+ once: !0,
1318
+ passive: !0
1319
+ }), n.onchange = () => {
1320
+ if (i = n.files?.[0] ?? null, i) {
1321
+ if (o) return void console.warn("File open detected after faux cancel.", i);
1322
+ t(i);
1323
+ }
1324
+ }, n.autofocus = !0, n.click();
1325
+ }), ci = () => {
1326
+ let e = 1;
1327
+ return typeof window == "object" && (e = window.devicePixelRatio || 1), e;
1328
+ }, Mr = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeElement || e?.contains(document.activeElement)), ui = (e, t, r = "auto") => {
1329
+ if ((() => {
1330
+ if (Qe === void 0) {
1331
+ let c = !1;
1332
+ try {
1333
+ document.createElement("div").scrollIntoView({ get container() {
1334
+ return c = !0, "nearest";
1335
+ } });
1336
+ } catch {}
1337
+ Qe = c;
1338
+ }
1339
+ return Qe;
1340
+ })()) return void t.scrollIntoView({
1341
+ block: "nearest",
1342
+ inline: "nearest",
1343
+ behavior: r,
1344
+ container: "nearest"
1345
+ });
1346
+ let n = e.getBoundingClientRect(), i = t.getBoundingClientRect(), o = n.top + e.clientTop, l = o + e.clientHeight, s = 0;
1347
+ i.top < o ? s = i.top - o : i.bottom > l && (s = Math.min(i.bottom - l, i.top - o)), s !== 0 && e.scrollBy({
1348
+ top: s,
1349
+ behavior: r
1350
+ });
1351
+ }, di = async (e, t = !1) => new Promise((r) => {
1352
+ Mr(e, t) ? r(!0) : e.addEventListener("focusin", () => {
1353
+ r(!0);
1354
+ }, { once: !0 }), e.focus();
1355
+ });
1356
+ ge({
1357
+ cancelTimeout: () => yi,
1358
+ debounce: () => mi,
1359
+ nextTick: () => gi,
1360
+ rafThrottle: () => hi,
1361
+ requestTimeout: () => wi,
1362
+ throttle: () => pi
1363
+ });
1364
+ var Oe = globalThis.requestAnimationFrame, fi = globalThis.cancelAnimationFrame;
1365
+ function pi(e, t) {
1366
+ let r = null;
1367
+ return (...n) => {
1368
+ let i = Date.now();
1369
+ (!r || i - r >= t) && (r = i, e(...n));
1370
+ };
1371
+ }
1372
+ function mi(e, t = 300, r = !1) {
1373
+ let n, i, o, l = null, s = 0;
1374
+ function c() {
1375
+ let m = Date.now() - s;
1376
+ m < t && m >= 0 ? l = setTimeout(c, t - m) : (l = null, r || (o = e.apply(i, n), i = n = null));
1377
+ }
1378
+ t ??= 100;
1379
+ let d = function() {
1380
+ i = globalThis, n = arguments, s = Date.now();
1381
+ var m = r && !l;
1382
+ return l ||= setTimeout(c, t), m && (o = e.apply(i, n), i = n = null), o;
1383
+ };
1384
+ return d.clear = function() {
1385
+ l &&= (clearTimeout(l), null);
1386
+ }, d.flush = function() {
1387
+ l &&= (o = e.apply(i, n), i = n = null, clearTimeout(l), null);
1388
+ }, d;
1389
+ }
1390
+ var hi = (e) => {
1391
+ let t, r = !1, n = function() {
1392
+ r = !1, e(t);
1393
+ };
1394
+ return function(i) {
1395
+ t = i, t && t.persist && t.persist(), r || (r = !0, Oe(n));
1396
+ };
1397
+ }, gi = (e) => {
1398
+ if (typeof Oe == "function") Oe(() => {
1399
+ e();
1400
+ });
1401
+ else {
1402
+ let t = globalThis.setImmediate;
1403
+ (typeof t == "function" ? t : setTimeout)(() => {
1404
+ e();
1405
+ });
1406
+ }
1407
+ }, Tt = typeof performance == "object" && typeof performance.now == "function" ? () => performance.now() : () => Date.now(), yi = (e) => {
1408
+ fi(e.id);
1409
+ }, wi = (e, t) => {
1410
+ let r = Tt(), n = { id: Oe(function i() {
1411
+ Tt() - r >= t ? e.call(null) : n.id = Oe(i);
1412
+ }) };
1413
+ return n;
1414
+ };
1415
+ ge({ MESSAGE_ERROR_INVALID_ARG: () => Si });
1416
+ var Si = (e) => \`Invalid argument: '\${e}'.\`;
1417
+ ge({
1418
+ APP_MIME_TYPE: () => bi,
1419
+ DEFAULT_MIME_TYPE: () => "*/*",
1420
+ JSONStableStringify: () => Ti,
1421
+ arrayBufferToBase64: () => Or,
1422
+ base64ToArrayBuffer: () => xi,
1423
+ blobToString: () => ut,
1424
+ isLittleEndian: () => _i,
1425
+ isNodeBuffer: () => vi,
1426
+ isSharedArrayBufferSupported: () => Ei
1427
+ });
1428
+ var bi = "application/octet-stream", Ce = globalThis.Buffer, vi = (e) => Ce?.isBuffer(e) ?? !1, Ei = typeof SharedArrayBuffer == "function" && (globalThis.crossOriginIsolated === void 0 || globalThis.crossOriginIsolated === !0), _i = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1, Ct = globalThis.FileReader, xi = (e) => {
1429
+ let t = typeof globalThis.atob == "function" ? globalThis.atob(e) : Ce.from(e, "base64").toString("binary"), r = t.length, n = new Uint8Array(r);
1430
+ for (let i = 0; i < r; i++) n[i] = t.charCodeAt(i);
1431
+ return n.buffer;
1432
+ }, Or = (e) => {
1433
+ let t = new Uint8Array(e), r = t.byteLength, n = "";
1434
+ for (let i = 0; i < r; i++) n += String.fromCharCode(t[i]);
1435
+ if (typeof globalThis.btoa == "function") return globalThis.btoa(n);
1436
+ if (Ce) return Ce.from(n, "binary").toString("base64");
1437
+ throw Error("Unsupported environment");
1438
+ }, ut = (e) => new Promise((t, r) => {
1439
+ if (e) if (Ct) {
1440
+ let n = new Ct();
1441
+ n.onload = () => {
1442
+ t(n.result);
1443
+ }, n.onerror = () => {
1444
+ r(n.error);
1445
+ }, n.readAsText(e);
1446
+ } else if (Ce) {
1447
+ let n = (i) => Ce.from(i).toString("utf-8");
1448
+ e.arrayBuffer().then((i) => {
1449
+ t(n(i));
1450
+ }).catch((i) => {
1451
+ r(i);
1452
+ });
1453
+ } else r(/* @__PURE__ */ Error("Unsupported environment"));
1454
+ else t("");
1455
+ });
1456
+ function Ti(e, t) {
1457
+ t ||= {}, typeof t == "function" && (t = { cmp: t });
1458
+ let r = typeof t.cycles == "boolean" && t.cycles, n = t.cmp && (i = t.cmp, function(l) {
1459
+ return function(s, c) {
1460
+ return i({
1461
+ key: s,
1462
+ value: l[s]
1463
+ }, {
1464
+ key: c,
1465
+ value: l[c]
1466
+ });
1467
+ };
1468
+ });
1469
+ var i;
1470
+ let o = [];
1471
+ return (function l(s) {
1472
+ if (s && s.toJSON && typeof s.toJSON == "function" && (s = s.toJSON()), s === void 0) return;
1473
+ if (typeof s == "number") return isFinite(s) ? "" + s : "null";
1474
+ if (typeof s != "object") return JSON.stringify(s);
1475
+ let c;
1476
+ if (Array.isArray(s)) {
1477
+ c = "[";
1478
+ for (let a = 0; a < s.length; a++) a && (c += ","), c += l(s[a]) || "null";
1479
+ return c + "]";
1480
+ }
1481
+ if (s === null) return "null";
1482
+ if (o.indexOf(s) !== -1) {
1483
+ if (r) return JSON.stringify("__cycle__");
1484
+ throw TypeError("Converting circular structure to JSON");
1485
+ }
1486
+ let d = o.push(s) - 1, m = Object.keys(s).sort(n && n(s));
1487
+ c = "";
1488
+ for (let a = 0; a < m.length; a++) {
1489
+ let f = m[a], b = l(s[f]);
1490
+ b && (c && (c += ","), c += JSON.stringify(f) + ":" + b);
1491
+ }
1492
+ return o.splice(d, 1), "{" + c + "}";
1493
+ })(e);
1494
+ }
1495
+ var Ci;
1496
+ ge({
1497
+ DATA_URL_PNG_PREFIX: () => Fr,
1498
+ getImageDataUrl: () => Ii,
1499
+ loadImageDetails: () => Ai
1500
+ });
1501
+ var Fr = "data:image/png;base64,", Dr = "Unable to resolve image.", It = (e) => new Promise(async (t, r) => {
1502
+ let n = null;
1503
+ try {
1504
+ let i = n = new Image();
1505
+ i.src = e, i.addEventListener("load", function() {
1506
+ t({
1507
+ width: i.naturalWidth,
1508
+ height: i.naturalHeight
1509
+ });
1510
+ }, { once: !0 }), i.addEventListener("error", function(o) {
1511
+ URL.revokeObjectURL(e);
1512
+ let l = o?.error?.message ?? "";
1513
+ l &&= \`: \${l}\`, r(\`Invalid Image\${l}\`);
1514
+ }, { once: !0 }), await i.decode();
1515
+ } catch {
1516
+ n?.src && URL.revokeObjectURL(n.src);
1517
+ }
1518
+ n || r(Error(Dr));
1519
+ }), Ii = (e, t = 1) => new Promise(async (r, n) => {
1520
+ let i = null;
1521
+ try {
1522
+ let o = i = new Image();
1523
+ o.src = e, o.addEventListener("load", function() {
1524
+ try {
1525
+ let l = document.createElement("canvas");
1526
+ l.width = o.naturalWidth, l.height = o.naturalHeight;
1527
+ let s = l.getContext("2d");
1528
+ if (!s) throw Error("Unable to create 2d context");
1529
+ s.drawImage(o, 0, 0);
1530
+ let c = l.toDataURL("image/png", t);
1531
+ r({
1532
+ elemImg: o,
1533
+ dataUrl: c
1534
+ });
1535
+ } catch (l) {
1536
+ URL.revokeObjectURL(e), n(l);
1537
+ }
1538
+ }, { once: !0 }), o.addEventListener("error", function() {
1539
+ URL.revokeObjectURL(e), n("Invalid Image");
1540
+ }, { once: !0 }), await o.decode();
1541
+ } catch {
1542
+ i?.src && URL.revokeObjectURL(i.src);
1543
+ }
1544
+ i || n(Error(Dr));
1545
+ }), et = "image/svg+xml", Ai = async (e, t = null) => {
1546
+ let r = null, n = async () => {
1547
+ try {
1548
+ let o = t ?? "image/*", l = URL.createObjectURL(new Blob([e], { type: o }));
1549
+ r = {
1550
+ mimeType: o,
1551
+ naturalSize: await It(l),
1552
+ asUrl: l
1553
+ };
1554
+ } catch {}
1555
+ }, i = async () => {
1556
+ try {
1557
+ let o = new TextDecoder().decode(e), l = URL.createObjectURL(new Blob([o], { type: et })), s = await It(l);
1558
+ r = {
1559
+ mimeType: t ?? et,
1560
+ naturalSize: s,
1561
+ asUrl: l,
1562
+ asSVGText: o
1563
+ };
1564
+ } catch {}
1565
+ };
1566
+ if (t === et ? await i() : t?.startsWith("image/") ? await n() : (await n(), r || await i()), !r) throw Error("Failed to load image");
1567
+ return r;
1568
+ }, At = /* @__PURE__ */ new Set(), Ri = (e) => {
1569
+ At.has(e) || (At.add(e), console.warn(\`Unknown property '\${e}' in update; ignoring.\`));
1570
+ };
1571
+ (function(e) {
1572
+ e.PassThrough = Object.freeze({});
1573
+ let t = e.resolveTypedUpdates = (r, n, i, o, l = !1) => {
1574
+ if (r === null) return r;
1575
+ if (r === void 0) return o;
1576
+ let s = r;
1577
+ if (n?.shorthand) {
1578
+ let a = n?.shorthand(r, i);
1579
+ a !== void 0 && (s = a);
1580
+ }
1581
+ if (s !== null && n?.getSubType) {
1582
+ let a = n.getSubType(s, o);
1583
+ a && (n = a);
1584
+ }
1585
+ let c = n?.properties, d = n?.arrayType ?? !1, m = s;
1586
+ if (n && n.merge && m && o) m = n.merge(m, o, i);
1587
+ else if (!d && c) {
1588
+ let a = Object.keys({
1589
+ ...s,
1590
+ ...o
1591
+ });
1592
+ m = null;
1593
+ let f = a.length;
1594
+ for (let b = 0; b < f; b++) {
1595
+ let v = a[b], A, U = s?.[v];
1596
+ if (U !== void 0) {
1597
+ let h = c[v];
1598
+ if (!h) {
1599
+ Ri(v);
1600
+ continue;
1601
+ }
1602
+ A = t(U, h, i, o?.[v], l);
1603
+ } else A = o?.[v];
1604
+ A == null ? l && U === null && (m ??= {}, m[v] = null) : (m ??= {}, m[v] = A);
1605
+ }
1606
+ }
1607
+ return m;
1608
+ };
1609
+ })(Ci ||= {});
1610
+ var gt = {
1611
+ code: "safari",
1612
+ message: \`The Safari browser does not support advanced copy and paste.
1613
+ Copy and paste will be limited to within the browser tab.
1614
+
1615
+ Please use Chrome or Edge if external copy and paste is required.\`
1616
+ }, Ur = {
1617
+ code: "perms",
1618
+ message: \`You do not have permissions to access the clipboard.
1619
+ All copy and paste operations will be limited to the browser tab.\`
1620
+ }, Rt = He() === fe.Safari ? gt : Ur, $i = {
1621
+ Safari: gt,
1622
+ Perms: Ur,
1623
+ PermsWrite: Rt,
1624
+ PermsRead: Rt
1625
+ }, tt = async () => new Promise((e) => {
1626
+ document.hasFocus() ? e() : globalThis.addEventListener?.("focus", () => {
1627
+ e();
1628
+ }, { once: !0 }), document.activeElement.focus?.();
1629
+ }), rt = async (e, t, r) => {
1630
+ if (He() === fe.Safari) return await r(Error(gt.message));
1631
+ try {
1632
+ let n = async (l) => {
1633
+ try {
1634
+ return await l();
1635
+ } catch (s) {
1636
+ if (s.message?.includes("Document is not focused")) return !1;
1637
+ throw s;
1638
+ }
1639
+ }, i = await globalThis?.navigator?.permissions?.query({
1640
+ name: e,
1641
+ allowWithoutGesture: !0,
1642
+ allowWithoutSanitization: !0
1643
+ }), o = !1;
1644
+ if (i.state === "prompt" && (o = await n(t)), o || i.state !== "granted" || (o = await t()), !o) return await r(Error(i.state));
1645
+ } catch (n) {
1646
+ return n.message === "No valid data on clipboard" || n.name === "DataError" ? void 0 : await r(n);
1647
+ }
1648
+ }, Br = async (e) => {
1649
+ if (!e) return null;
1650
+ try {
1651
+ return await e.read({ unsanitized: [J.Html] });
1652
+ } catch {}
1653
+ return await e.read();
1654
+ }, Ni = async (e, t) => {
1655
+ if (!e) return null;
1656
+ let r = await Br(e), n = !1;
1657
+ for (let i = 0; !n && r && i < r.length; i++) if (n = r[i].types.includes(t), n) return await r[i].getType(t);
1658
+ return null;
1659
+ };
1660
+ if (!globalThis.ClipboardItem) {
1661
+ let e = (r, n) => new Blob([n], { type: r });
1662
+ class t {
1663
+ constructor(n, i) {
1664
+ this._items = {}, this._types = Object.keys(n);
1665
+ let o = {}, l = Object.keys(n);
1666
+ for (let s = 0; s < l.length; s++) {
1667
+ let c = l[s], d = n[c];
1668
+ o[c] = typeof d == "string" ? e(c, d) : d;
1669
+ }
1670
+ this._items = o, this._presentationStyle = i?.presentationStyle ?? "unspecified";
1671
+ }
1672
+ get types() {
1673
+ return this._types;
1674
+ }
1675
+ getType(n) {
1676
+ return Promise.resolve(this._items[n]);
1677
+ }
1678
+ supports(n) {
1679
+ return !0;
1680
+ }
1681
+ }
1682
+ globalThis.ClipboardItem = t;
1683
+ }
1684
+ var $t, dt = async (e, t = J.Html) => new Promise(async (r, n) => {
1685
+ try {
1686
+ let i = await Ni(e, t);
1687
+ if (i) {
1688
+ let o = new FileReader();
1689
+ o.onload = () => {
1690
+ r(o.result);
1691
+ }, o.onerror = () => {
1692
+ r("");
1693
+ }, o.readAsText(i);
1694
+ } else r("");
1695
+ } catch (i) {
1696
+ n(i);
1697
+ }
1698
+ }), Nt = async (e, t = J.Html) => {
1699
+ let r = await dt(e, t);
1700
+ if (!r) return null;
1701
+ let n = null;
1702
+ try {
1703
+ n = new DOMParser().parseFromString(r, J.Html);
1704
+ } catch {
1705
+ console.warn("Can't parse html from clipboard.");
1706
+ }
1707
+ return n;
1708
+ }, Li = async (e) => {
1709
+ e && await e.writeText("");
1710
+ }, Fe = "clipboard-uuid", Ne = "web text/uuid", Lt = (e) => \`<div style="display:none" \${Fe}="\${e}"/>\`, kt = { type: J.Plain }, Mt = { type: J.Html }, Ot = { type: Ne }, ki = (e, t) => {
1711
+ let r = null;
1712
+ try {
1713
+ let n = new DOMParser().parseFromString(t, J.Html);
1714
+ n.body.firstElementChild?.setAttribute(Fe, e), r = n.getElementsByTagName("body")[0].innerHTML;
1715
+ } catch (n) {
1716
+ console.warn("Can't embed uuid.", n);
1717
+ }
1718
+ return r;
1719
+ }, Ft = (e, t) => {
1720
+ if (!t || !e) return !1;
1721
+ try {
1722
+ let r = t.querySelectorAll(\`[\${Fe}="\${e}"]\`);
1723
+ if (r && r.length === 1) return !0;
1724
+ if (t.querySelector("parsererror")) throw Error("We are unable to parse node");
1725
+ return !1;
1726
+ } catch {
1727
+ return !1;
1728
+ }
1729
+ }, Dt = class {
1730
+ constructor(e) {
1731
+ if (this._state = null, this._nativeClipboard = null, this._onFocus = null, this._onBlur = null, e?.nativeClipboard === void 0 || e?.nativeClipboard === !0) try {
1732
+ this._nativeClipboard = globalThis?.navigator.clipboard;
1733
+ } catch {
1734
+ e?.nativeClipboard === !0 && console.warn("NativeClipboard option set to true but no native clipboard available.");
1735
+ }
1736
+ else this._nativeClipboard = e?.nativeClipboard === !1 ? null : e?.nativeClipboard ?? null;
1737
+ this._disableCheckOnFocus = e?.disableCheckOnFocus ?? !1, this._init();
1738
+ }
1739
+ async _checkForChanges() {
1740
+ this._nativeClipboard && this._state && !this._disableCheckOnFocus && await rt("clipboard-read", async () => {
1741
+ await tt();
1742
+ let e = await dt(this._nativeClipboard, Ne);
1743
+ if (!this._state || e && e === this._state.uuid) return !0;
1744
+ let t = await Nt(this._nativeClipboard, J.Html);
1745
+ return !this._state || (Ft(this._state.uuid, t) || this.clear(), !0);
1746
+ }, async (e) => {
1747
+ e?.message === "denied" || e.message?.includes("Document is not focused") || He() === fe.Safari || console.warn("Unable to detect clipboard changes: ", e);
1748
+ });
1749
+ }
1750
+ _init() {
1751
+ let e = this;
1752
+ this._listeners = /* @__PURE__ */ new Map(), this._listenersCapture = /* @__PURE__ */ new Map(), this._state = null, this._nativeClipboard && (this._onFocus = () => {
1753
+ e._checkForChanges();
1754
+ }, this._onBlur = () => {
1755
+ globalThis.addEventListener?.("focus", e._onFocus, { once: !0 });
1756
+ }, globalThis.addEventListener?.("blur", this._onBlur), this._nativeClipboard.addEventListener("clipboardchange", (t) => {
1757
+ e._checkForChanges();
1758
+ }));
1759
+ }
1760
+ async read() {
1761
+ if (!this._nativeClipboard) return this._state?.items ?? null;
1762
+ let e = this;
1763
+ return await rt("clipboard-read", async () => {
1764
+ if (await tt(), this._state?.uuid) {
1765
+ let t = await dt(this._nativeClipboard, Ne);
1766
+ if (t && t === e._state?.uuid) return !0;
1767
+ let r = await Nt(this._nativeClipboard, J.Html);
1768
+ if (Ft(e._state?.uuid, r)) return !0;
1769
+ }
1770
+ return e._state = {
1771
+ items: await Br(this._nativeClipboard),
1772
+ uuid: null,
1773
+ ref: null
1774
+ }, this.dispatchEvent(new Event("clipboardread")), !0;
1775
+ }, async (t) => {
1776
+ this.dispatchEvent(new Event("clipboarderrorread"));
1777
+ }), this._state?.items ?? [];
1778
+ }
1779
+ async write(e) {
1780
+ return this._write({
1781
+ uuid: Ve(),
1782
+ items: e,
1783
+ ref: null
1784
+ });
1785
+ }
1786
+ async _write(e) {
1787
+ if (!this._nativeClipboard) return this._state = e, this.dispatchEvent(new Event("clipboardwrite")), void this.dispatchEvent(new Event("clipboardchange"));
1788
+ let t = this, r = [], n = e.uuid, i = e.items ?? [], o = () => {
1789
+ t._state = {
1790
+ uuid: n,
1791
+ ref: e.ref,
1792
+ items: r
1793
+ }, t.dispatchEvent(new Event("clipboardwrite")), t.dispatchEvent(new Event("clipboardchange"));
1794
+ };
1795
+ await rt("clipboard-write", async () => {
1796
+ await tt(), n && i.length === 0 && (i.push(new ClipboardItem({ [Ne]: new Blob([n], Ot) })), i.push(new ClipboardItem({ [J.Html]: new Blob([Lt(n)], Mt) })));
1797
+ for (let l = 0; l < Math.min(1, i.length); l++) {
1798
+ let s = i[l], c = s.types.indexOf(J.Html), d = null;
1799
+ if (c !== -1 && (d = await ut(await s.getType(J.Html)), d &&= ki(n, d)), !d && s.types.includes(J.Plain)) {
1800
+ let v = await s.getType(J.Plain);
1801
+ if (v) {
1802
+ let A = null;
1803
+ typeof v == "string" ? (console.warn("text as string", v), A = v) : A = await ut(v), A && (d = \`<div \${Fe}="\${n}">\${A}</div>\`);
1804
+ }
1805
+ }
1806
+ if (!d && s.types.includes(J.Png)) {
1807
+ let v = Or(await (await s.getType(J.Png)).arrayBuffer());
1808
+ d = \`<div \${Fe}="\${n}"><img src="\${Fr + v}"/></div>\`;
1809
+ }
1810
+ !d && n && (d = Lt(n));
1811
+ let m = new Blob([d ?? ""], Mt), a = {}, f = s.types, b = f.length;
1812
+ for (let v = 0; v < b; v++) {
1813
+ let A = f[v];
1814
+ a[A] = v === c ? m : s.getType(A);
1815
+ }
1816
+ d && c === -1 && (a[J.Html] = m), n && (a[Ne] = new Blob([n], Ot)), r.push(new ClipboardItem(a));
1817
+ }
1818
+ try {
1819
+ r && r.length !== 0 ? await this._nativeClipboard.write(r) : await Li(this._nativeClipboard);
1820
+ } catch (l) {
1821
+ l.message?.includes("Document is not focused") || console.warn("Unable to write to native clipboard: ", l);
1822
+ }
1823
+ return o(), !0;
1824
+ }, async (l) => {
1825
+ this.dispatchEvent(new Event("clipboarderrorwrite")), o();
1826
+ });
1827
+ }
1828
+ async writeReference(e) {
1829
+ if (!e) return void this.clear();
1830
+ let t = null, r = {};
1831
+ try {
1832
+ let i = await e.toText?.() ?? null;
1833
+ i && (r[J.Plain] = new Blob([i ?? ""], kt));
1834
+ } catch (i) {
1835
+ t = i;
1836
+ }
1837
+ try {
1838
+ let i = await e.toHtml?.() ?? null;
1839
+ i && (r[J.Html] = new Blob([i], { type: J.Html }));
1840
+ } catch (i) {
1841
+ t = i, console.warn("export to html", i);
1842
+ }
1843
+ try {
1844
+ let i = await e.toImage?.() ?? null;
1845
+ i && (r[J.Png] = i);
1846
+ } catch (i) {
1847
+ t = i, console.warn("export to png", i);
1848
+ }
1849
+ let n = this._write({
1850
+ uuid: Ve(),
1851
+ ref: e,
1852
+ items: Object.keys(r).length > 0 ? [new ClipboardItem(r)] : null
1853
+ });
1854
+ if (t) throw t;
1855
+ return n;
1856
+ }
1857
+ clear(e = !1) {
1858
+ this._state && (this._state = null, e && this._write({
1859
+ uuid: null,
1860
+ ref: null,
1861
+ items: null
1862
+ }), this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")));
1863
+ }
1864
+ async readReference() {
1865
+ return await this.read(), this._state?.ref ?? null;
1866
+ }
1867
+ readText() {
1868
+ return new Promise(async (e, t) => {
1869
+ let r = await this.read(), n = null, i = r ? r.length : 0;
1870
+ for (let l = 0; !n && l < i; l++) {
1871
+ let s = r[l];
1872
+ s.types.includes(J.Plain) && (n = await s.getType(J.Plain));
1873
+ }
1874
+ if (!n) return void e("");
1875
+ let o = new FileReader();
1876
+ o.onload = () => {
1877
+ e(o.result);
1878
+ }, o.readAsText(n), o.onerror = (l) => {
1879
+ t(l);
1880
+ };
1881
+ });
1882
+ }
1883
+ async writeText(e) {
1884
+ let t = [new ClipboardItem({ [J.Plain]: new Blob([e], kt) })];
1885
+ return this._write({
1886
+ uuid: Ve(),
1887
+ items: t,
1888
+ ref: null
1889
+ });
1890
+ }
1891
+ addEventListener(e, t, r = {}) {
1892
+ let n = r?.capture ? this._listenersCapture : this._listeners, i = n.get(e);
1893
+ i || (i = /* @__PURE__ */ new Map(), n.set(e, i)), t && i.set(t, typeof r == "boolean" ? {} : r);
1894
+ }
1895
+ dispatchEvent(e) {
1896
+ if (!e) return !1;
1897
+ let t = (r) => {
1898
+ let n = r.get(e.type);
1899
+ n && n.forEach((i, o) => {
1900
+ try {
1901
+ typeof o == "function" ? o(e) : o.handleEvent && o.handleEvent(e), i.once && n.delete(o);
1902
+ } catch (l) {
1903
+ console.warn(l);
1904
+ }
1905
+ });
1906
+ };
1907
+ return t(this._listenersCapture), t(this._listeners), !0;
1908
+ }
1909
+ removeEventListener(e, t, r) {
1910
+ let n = r?.capture ? this._listenersCapture : this._listeners, i = n.get(e);
1911
+ i && t && (i.delete(t), i.size === 0 && n.delete(e));
1912
+ }
1913
+ close() {
1914
+ this._onFocus && globalThis.removeEventListener?.("focus", this._onFocus), this._onBlur && globalThis.removeEventListener?.("blur", this._onBlur);
1915
+ }
1916
+ };
1917
+ ($t = Dt ||= {}).ErrorMessages = $i, $t.Global = new Dt();
1918
+ Object.freeze({});
1919
+ new TextDecoder();
1920
+ const _ = Object.freeze({
1921
+ /** Exported function has no body. */
1922
+ NoBody: "SXL1001",
1923
+ /** Anonymous exported function is not allowed. */
1924
+ Anonymous: "SXL1002",
1925
+ /** Internal parse failure while analyzing the module. */
1926
+ ParseError: "SXL1003",
1927
+ /** Invalid parameter type. */
1928
+ InvalidParamType: "SXL2001",
1929
+ /** Invalid return type. */
1930
+ InvalidReturnType: "SXL2002",
1931
+ /** \`undefined\` / \`null\` / \`void\` is not valid as an input type. */
1932
+ UndefinedInput: "SXL2003",
1933
+ /** A type annotation is required but missing. */
1934
+ MissingType: "SXL2004",
1935
+ /** An \`Array\` must be typed (e.g. \`number[]\`, not bare \`[]\`). */
1936
+ UntypedArray: "SXL2005",
1937
+ /** A generic type must be supplied exactly one type argument. */
1938
+ GenericArity: "SXL2006",
1939
+ /** A return type cannot combine multiple modifiers (e.g. async + stream). */
1940
+ MultipleModifiers: "SXL2007",
1941
+ /** A context parameter must be the first parameter. */
1942
+ ContextNotFirst: "SXL2010",
1943
+ /** More than one \`Lambda\` parameter. */
1944
+ MultipleLambda: "SXL2020",
1945
+ /** A \`Lambda\` parameter must be the last parameter. */
1946
+ LambdaNotLast: "SXL2021",
1947
+ /** A \`Lambda\` parameter/return scalar type mismatch. */
1948
+ LambdaScalarMismatch: "SXL2022",
1949
+ /** \`Lambda\` is not valid as a return type. */
1950
+ LambdaReturn: "SXL2023",
1951
+ /** A bare function type is not valid as a return type. */
1952
+ FunctionReturn: "SXL2024",
1953
+ /** A \`Lambda\` function type has the wrong number of parameters. */
1954
+ LambdaArity: "SXL2025",
1955
+ /** Arrays of more than 2 dimensions are not supported. */
1956
+ ArrayDepth: "SXL2030",
1957
+ /** \`Repeating<T>\` used somewhere it cannot be (a return type, a rest parameter, nested in an array). */
1958
+ RepeatingPosition: "SXL2040",
1959
+ /** More than one \`Repeating<T>\` parameter. */
1960
+ MultipleRepeating: "SXL2041",
1961
+ /** A \`Repeating<T>\` group's slots are malformed (unlabelled tuple member, or a 1-element tuple). */
1962
+ RepeatingSlots: "SXL2042",
1963
+ /** An optional parameter/slot where a repeating group does not allow one. */
1964
+ RepeatingOptional: "SXL2043",
1965
+ /** \`Repeating<T, Max>\`'s maximum argument count is not a whole number in range. */
1966
+ RepeatingMax: "SXL2044",
1967
+ /** An enum mixes number and string members. */
1968
+ EnumMixed: "SXL2050",
1969
+ /** An enum member is not a constant number or string. */
1970
+ EnumMemberNotConstant: "SXL2051",
1971
+ /** A parameter type that is not declared in this module, so an enum behind it cannot be read. */
1972
+ EnumNotLocal: "SXL2052",
1973
+ /** An \`as const\` object used as a parameter type without its same-name type alias. */
1974
+ EnumMissingAlias: "SXL2053",
1975
+ /** An enum where no single argument is coerced to it (\`IRange<E>\`, \`Lazy<E>\`). */
1976
+ EnumPosition: "SXL2054",
1977
+ /** \`Omittable<E, V>\` whose \`V\` is neither a member of \`E\` nor \`null\`. */
1978
+ EnumOmittedValue: "SXL2055",
1979
+ /** No exported functions found in the module. */
1980
+ NoExports: "SXL3001",
1981
+ /** A \`@param\` tag references a parameter that does not exist. */
1982
+ UnknownParam: "SXL3002",
1983
+ /** A calculation function takes a built-in function's name. */
1984
+ BuiltInName: "SXL3003",
1985
+ /** A \`@returnKind\` tag names a value kind that does not exist, or names none at all. */
1986
+ UnknownReturnKind: "SXL3005",
1987
+ /** A calculation function's name (its \`@name\`, or else its own) is not a name a formula can call. */
1988
+ InvalidName: "SXL3006",
1989
+ /** Two functions in one module register under the same name (an \`@name\` repeats another's). */
1990
+ DuplicateName: "SXL3007",
1991
+ /** A function has no JSDoc description. */
1992
+ MissingSummary: "SXL9001",
1993
+ /** A \`@param\` is missing a description. */
1994
+ MissingParamDescription: "SXL9002",
1995
+ /**
1996
+ * Missing \`@returns\` on a non-void function.
1997
+ * @deprecated Retained for code stability but no longer emitted - Excel-style tooltips describe
1998
+ * behavior via the summary, so a standalone \`@returns\` warning is noise.
1999
+ */
2000
+ MissingReturns: "SXL9003",
2001
+ /** Two enum members share a value. */
2002
+ EnumDuplicateValue: "SXL9004",
2003
+ /** An enum member has no doc comment. */
2004
+ EnumMemberUndocumented: "SXL9005"
2005
+ });
2006
+ var ji;
2007
+ (function(e) {
2008
+ e.MAX_TEXT_LENGTH = 32767;
2009
+ let t = e.MAX_SIGNIFICANT_DIGITS = 15;
2010
+ e.truncateNumberText = function(r) {
2011
+ let n = r.length;
2012
+ if (n <= t) return r;
2013
+ let i = 0, o = null;
2014
+ for (let l = 0; l < n; l++) {
2015
+ let s = r.charCodeAt(l);
2016
+ if (s >= 48 && s <= 57) {
2017
+ if (i === 0 && s === 48) continue;
2018
+ i++, i > t && ((o ??= r.split(""))[l] = "0");
2019
+ } else if ((s === 69 || s === 101) && i > 0) break;
2020
+ }
2021
+ return o === null ? r : o.join("");
2022
+ };
2023
+ })(ji ||= {});
2024
+ var Kt, nt, Ki, T, me = {
2025
+ Number: "number",
2026
+ String: "string",
2027
+ Boolean: "boolean",
2028
+ Error: "error",
2029
+ RichData: "richData",
2030
+ Null: "null"
2031
+ }, zt = {
2032
+ ...me,
2033
+ Date: "date"
2034
+ }, Vt = {
2035
+ ...me,
2036
+ Reference: "reference",
2037
+ Array: "array",
2038
+ Lambda: "lambda",
2039
+ Omitted: "omitted"
2040
+ };
2041
+ (nt = Kt ||= {}).Axis = {
2042
+ Column: "column",
2043
+ Row: "row"
2044
+ }, nt.AxisSelection = {
2045
+ ...Kt.Axis,
2046
+ Both: "both"
2047
+ }, nt.Direction = {
2048
+ Up: "up",
2049
+ Down: "down",
2050
+ Left: "left",
2051
+ Right: "right"
2052
+ }, (Ki ||= {}).Aggregate = {
2053
+ Count: "count",
2054
+ NumericalCount: "numericalCount",
2055
+ Sum: "sum",
2056
+ Average: "average",
2057
+ StdDev: "stdDev",
2058
+ PopulationStdDev: "stdDevP",
2059
+ Variance: "var",
2060
+ PopulationVariance: "varP",
2061
+ Min: "min",
2062
+ Max: "max"
2063
+ }, (function(e) {
2064
+ let t = e.Code = {
2065
+ Parse: 0,
2066
+ Null: 1,
2067
+ Div0: 2,
2068
+ Value: 3,
2069
+ Ref: 4,
2070
+ Name: 5,
2071
+ Num: 6,
2072
+ NA: 7,
2073
+ GettingData: 8,
2074
+ Spill: 9,
2075
+ Connect: 10,
2076
+ Blocked: 11,
2077
+ Unknown: 12,
2078
+ Field: 13,
2079
+ Calc: 14,
2080
+ Busy: 16,
2081
+ Python: 19,
2082
+ Timeout: 20
2083
+ }, r = e.Label = {
2084
+ Parse: "#PARSE!",
2085
+ Null: "#NULL!",
2086
+ Div0: "#DIV/0!",
2087
+ Value: "#VALUE!",
2088
+ Ref: "#REF!",
2089
+ Name: "#NAME?",
2090
+ Num: "#NUM!",
2091
+ NA: "#N/A",
2092
+ GettingData: "#GETTING_DATA",
2093
+ Spill: "#SPILL!",
2094
+ Connect: "#CONNECT!",
2095
+ Blocked: "#BLOCKED!",
2096
+ Unknown: "#UNKNOWN!",
2097
+ Field: "#FIELD!",
2098
+ Calc: "#CALC!",
2099
+ Busy: "#BUSY!",
2100
+ Python: "#PYTHON!",
2101
+ Timeout: "#TIMEOUT!"
2102
+ };
2103
+ class n extends Error {
2104
+ constructor(R, M, pe, Y) {
2105
+ super(pe, Y), this._label = M, this._code = R, this.details = Y;
2106
+ }
2107
+ static {
2108
+ this.code = T.Code.Unknown;
2109
+ }
2110
+ get isFormulaError() {
2111
+ return !0;
2112
+ }
2113
+ getLabel() {
2114
+ return this._label;
2115
+ }
2116
+ getCode() {
2117
+ return this._code;
2118
+ }
2119
+ equals(R) {
2120
+ return !!R && (this._code === R._code || this._code === R.code);
2121
+ }
2122
+ get [Symbol.toStringTag]() {
2123
+ return "[FormulaError]";
2124
+ }
2125
+ toString() {
2126
+ return this._label;
2127
+ }
2128
+ }
2129
+ e.Known = n;
2130
+ class i extends n {
2131
+ constructor(R, M) {
2132
+ super(t.Parse, r.Parse, R, M);
2133
+ }
2134
+ static {
2135
+ this.code = T.Code.Parse;
2136
+ }
2137
+ getDetails() {
2138
+ let R = this.details;
2139
+ return {
2140
+ line: R?.line ?? 1,
2141
+ column: R?.column ?? 1,
2142
+ offset: R?.offset ?? 0,
2143
+ length: R?.length ?? 0
2144
+ };
2145
+ }
2146
+ }
2147
+ e.Parse = i;
2148
+ class o extends n {
2149
+ constructor(R, M) {
2150
+ super(t.Null, r.Null, R, M);
2151
+ }
2152
+ static {
2153
+ this.code = T.Code.Null;
2154
+ }
2155
+ }
2156
+ e.Null = o;
2157
+ class l extends n {
2158
+ constructor(R, M) {
2159
+ super(t.Div0, r.Div0, R, M);
2160
+ }
2161
+ static {
2162
+ this.code = T.Code.Div0;
2163
+ }
2164
+ }
2165
+ e.Div0 = l;
2166
+ class s extends n {
2167
+ constructor(R, M) {
2168
+ super(t.Value, r.Value, R, M);
2169
+ }
2170
+ static {
2171
+ this.code = T.Code.Value;
2172
+ }
2173
+ }
2174
+ e.Value = s;
2175
+ class c extends n {
2176
+ constructor(R, M) {
2177
+ super(t.Ref, r.Ref, R, M);
2178
+ }
2179
+ static {
2180
+ this.code = T.Code.Ref;
2181
+ }
2182
+ }
2183
+ e.Ref = c;
2184
+ class d extends n {
2185
+ constructor(R, M) {
2186
+ super(t.Name, r.Name, R, M);
2187
+ }
2188
+ static {
2189
+ this.code = T.Code.Name;
2190
+ }
2191
+ }
2192
+ e.Name = d;
2193
+ class m extends n {
2194
+ constructor(R, M) {
2195
+ super(t.Num, r.Num, R, M);
2196
+ }
2197
+ static {
2198
+ this.code = T.Code.Num;
2199
+ }
2200
+ }
2201
+ e.Num = m;
2202
+ class a extends n {
2203
+ constructor(R, M) {
2204
+ super(t.NA, r.NA, R, M);
2205
+ }
2206
+ static {
2207
+ this.code = T.Code.NA;
2208
+ }
2209
+ }
2210
+ e.NA = a;
2211
+ class f extends n {
2212
+ constructor(R, M) {
2213
+ super(t.GettingData, r.GettingData, R, M);
2214
+ }
2215
+ static {
2216
+ this.code = T.Code.GettingData;
2217
+ }
2218
+ }
2219
+ e.GettingData = f;
2220
+ class b extends n {
2221
+ constructor(R, M) {
2222
+ super(t.Spill, r.Spill, R, M);
2223
+ }
2224
+ static {
2225
+ this.code = T.Code.Spill;
2226
+ }
2227
+ }
2228
+ e.Spill = b;
2229
+ class v extends n {
2230
+ constructor(R, M) {
2231
+ super(t.Connect, r.Connect, R, M);
2232
+ }
2233
+ static {
2234
+ this.code = T.Code.Connect;
2235
+ }
2236
+ }
2237
+ e.Connect = v;
2238
+ class A extends n {
2239
+ constructor(R, M) {
2240
+ super(t.Blocked, r.Blocked, R, M);
2241
+ }
2242
+ static {
2243
+ this.code = T.Code.Blocked;
2244
+ }
2245
+ }
2246
+ e.Blocked = A;
2247
+ class U extends n {
2248
+ constructor(R, M) {
2249
+ super(t.Unknown, r.Unknown, R, M);
2250
+ }
2251
+ static {
2252
+ this.code = T.Code.Unknown;
2253
+ }
2254
+ }
2255
+ e.Unknown = U;
2256
+ class h extends n {
2257
+ constructor(R, M) {
2258
+ super(t.Field, r.Field, R, M);
2259
+ }
2260
+ static {
2261
+ this.code = T.Code.Field;
2262
+ }
2263
+ }
2264
+ e.Field = h;
2265
+ class w extends n {
2266
+ constructor(R, M) {
2267
+ super(t.Calc, r.Calc, R, M);
2268
+ }
2269
+ static {
2270
+ this.code = T.Code.Calc;
2271
+ }
2272
+ }
2273
+ e.Calc = w;
2274
+ class S extends n {
2275
+ constructor(R, M) {
2276
+ super(t.Busy, r.Busy, R, M);
2277
+ }
2278
+ static {
2279
+ this.code = T.Code.Busy;
2280
+ }
2281
+ }
2282
+ e.Busy = S;
2283
+ class F extends n {
2284
+ constructor(R, M) {
2285
+ super(t.Python, r.Python, R, M);
2286
+ }
2287
+ static {
2288
+ this.code = T.Code.Python;
2289
+ }
2290
+ }
2291
+ e.Python = F;
2292
+ class z extends n {
2293
+ constructor(R, M) {
2294
+ super(t.Timeout, r.Timeout, R, M);
2295
+ }
2296
+ static {
2297
+ this.code = T.Code.Timeout;
2298
+ }
2299
+ }
2300
+ e.Timeout = z;
2301
+ })(T ||= {});
2302
+ var te = {};
2303
+ te[T.Code.Parse] = T.Parse, te[T.Code.Null] = T.Null, te[T.Code.Div0] = T.Div0, te[T.Code.Value] = T.Value, te[T.Code.Ref] = T.Ref, te[T.Code.Name] = T.Name, te[T.Code.Num] = T.Num, te[T.Code.NA] = T.NA, te[T.Code.GettingData] = T.GettingData, te[T.Code.Spill] = T.Spill, te[T.Code.Connect] = T.Connect, te[T.Code.Blocked] = T.Blocked, te[T.Code.Unknown] = T.Unknown, te[T.Code.Field] = T.Field, te[T.Code.Calc] = T.Calc, te[T.Code.Busy] = T.Busy, te[T.Code.Python] = T.Python, te[T.Code.Timeout] = T.Timeout;
2304
+ var Kr = /* @__PURE__ */ new Map(), zr = /* @__PURE__ */ new Map(), Vr = /* @__PURE__ */ new Map(), Xr = /* @__PURE__ */ new Map(), Xt = Object.keys(te);
2305
+ for (let e = 0; e < Xt.length; e++) {
2306
+ let t = te[Xt[e]], r = new t();
2307
+ Vr.set(r.getLabel(), t), Xr.set(r.getCode(), t), Kr.set(r.getLabel(), r), zr.set(r.getCode(), r);
2308
+ }
2309
+ (function(e) {
2310
+ let t = e.getBuiltInByCode = (r) => zr.get(r);
2311
+ e.BuiltIn = {
2312
+ Parse: t(T.Code.Parse),
2313
+ Null: t(T.Code.Null),
2314
+ Div0: t(T.Code.Div0),
2315
+ Value: t(T.Code.Value),
2316
+ Ref: t(T.Code.Ref),
2317
+ Name: t(T.Code.Name),
2318
+ Num: t(T.Code.Num),
2319
+ NA: t(T.Code.NA),
2320
+ GettingData: t(T.Code.GettingData),
2321
+ Spill: t(T.Code.Spill),
2322
+ Connect: t(T.Code.Connect),
2323
+ Blocked: t(T.Code.Blocked),
2324
+ Unknown: t(T.Code.Unknown),
2325
+ Field: t(T.Code.Field),
2326
+ Calc: t(T.Code.Calc),
2327
+ Busy: t(T.Code.Busy),
2328
+ Python: t(T.Code.Python),
2329
+ Timeout: t(T.Code.Timeout)
2330
+ }, e.newTypedError = (r, n, i) => {
2331
+ let o;
2332
+ return o = typeof r == "string" ? Vr.get(r) : Xr.get(r), o ||= T.Unknown, new o(n, i);
2333
+ }, e.getBuiltInByLabel = (r) => Kr.get(r), e.isError = function(r, n) {
2334
+ return !!r && r.isFormulaError === !0 && (n === void 0 || r.getCode() === n);
2335
+ };
2336
+ })(T ||= {});
2337
+ var zi = class {
2338
+ createRange(e, t, r) {
2339
+ throw new ie();
2340
+ }
2341
+ flattenAreas(e) {
2342
+ throw new ie();
2343
+ }
2344
+ getReference(e, t) {
2345
+ throw new ie();
2346
+ }
2347
+ getResizedReference(e, t, r) {
2348
+ throw new ie();
2349
+ }
2350
+ getNumberFormat(e, t) {
2351
+ throw new ie();
2352
+ }
2353
+ fromSerialDate(e, t) {
2354
+ throw new ie();
2355
+ }
2356
+ toSerialDate(e, t) {
2357
+ throw new ie();
2358
+ }
2359
+ getDateParts(e, t) {
2360
+ throw new ie();
2361
+ }
2362
+ getSerialDate(e, t, r, n, i, o, l) {
2363
+ throw new ie();
2364
+ }
2365
+ getNow() {
2366
+ throw new ie();
2367
+ }
2368
+ getRandom() {
2369
+ return Math.random();
2370
+ }
2371
+ getValueAt(e, t, r, n) {
2372
+ return null;
2373
+ }
2374
+ getEntireCoords() {
2375
+ return Hr;
2376
+ }
2377
+ isValidDate(e, t) {
2378
+ return e instanceof Date || Object.prototype.toString.call(e) === "[object Date]" ? !isNaN(e.getTime()) : !t && typeof e == "number" && !(e < 0 || e > Xi);
2379
+ }
2380
+ getRow() {
2381
+ return 0;
2382
+ }
2383
+ getColumn() {
2384
+ return 0;
2385
+ }
2386
+ isImplicitIntersect() {
2387
+ return !1;
2388
+ }
2389
+ getFormulaAt(e, t, r) {
2390
+ return null;
2391
+ }
2392
+ getSpillAt(e, t, r) {
2393
+ return null;
2394
+ }
2395
+ getSheetIndex(e) {
2396
+ return -1;
2397
+ }
2398
+ getSheetCount() {
2399
+ return 1;
2400
+ }
2401
+ markVolatile() {}
2402
+ formatResults(e) {}
2403
+ filterHidden(e, t) {
2404
+ return e;
2405
+ }
2406
+ filterTotals(e) {
2407
+ return e;
2408
+ }
2409
+ getFunction(e) {
2410
+ return null;
2411
+ }
2412
+ getAddress(e, t) {
2413
+ throw new ie();
2414
+ }
2415
+ parseAsSerialDate(e, t) {
2416
+ throw new ie();
2417
+ }
2418
+ parseAsDate(e, t) {
2419
+ throw new ie();
2420
+ }
2421
+ parseAsNumber(e, t) {
2422
+ throw new ie();
2423
+ }
2424
+ createCriteria(e, t) {
2425
+ throw new ie();
2426
+ }
2427
+ createGrouping(e, t) {
2428
+ throw new ie();
2429
+ }
2430
+ parseAsLiteral(e) {
2431
+ let t = e.toUpperCase();
2432
+ return t === "TRUE" || t !== "FALSE" && T.getBuiltInByLabel(t);
2433
+ }
2434
+ toText(e) {
2435
+ return typeof e == "string" ? e : e == null ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e?.isFormulaError ? e.getLabel() : String(e);
2436
+ }
2437
+ compare(e, t, r) {
2438
+ if (e === t) return 0;
2439
+ let n = Gt(e), i = Gt(t);
2440
+ return n === i ? e < t ? -1 : +(e > t) : n < i ? -1 : 1;
2441
+ }
2442
+ getRuntime() {
2443
+ return Vi;
2444
+ }
2445
+ getArgs() {
2446
+ throw new ie(Gr);
2447
+ }
2448
+ }, Gt = (e) => {
2449
+ if (e == null) return 0;
2450
+ switch (typeof e) {
2451
+ case "number": return 1;
2452
+ case "string": return 2;
2453
+ case "boolean": return 3;
2454
+ default: return 4;
2455
+ }
2456
+ }, Gr = "FormulaContext.getArgs() is only valid while a function body is running", ie = class extends Error {
2457
+ constructor(e = "Not implemented in StubbedFormulaContext") {
2458
+ super(e), this.name = "NotImplementedError";
2459
+ }
2460
+ }, Hr = Object.freeze({
2461
+ colStart: 0,
2462
+ rowStart: 0,
2463
+ colEnd: 2 ** 14 - 1,
2464
+ rowEnd: 2 ** 20 - 1
2465
+ }), Vi = {
2466
+ isDate1904: () => !1,
2467
+ getLocale: () => Ht.tag,
2468
+ getLocaleProfile: () => Ht,
2469
+ isR1C1: () => !1,
2470
+ getNow: () => 0,
2471
+ getRandom: () => Math.random(),
2472
+ getLocation: () => "unknown",
2473
+ getVersion: () => "1.0.0",
2474
+ getOS: () => "unknown",
2475
+ getUser: () => "unidentified",
2476
+ getDescription: () => "Stubbed Formula Context"
2477
+ }, Xi = 2958465, Pe = new zi(), Gi = class {
2478
+ constructor() {
2479
+ this._scope = Pe, this._argsFn = null;
2480
+ }
2481
+ _setScope(e) {
2482
+ this._scope = e ?? Pe;
2483
+ }
2484
+ _getScope() {
2485
+ return this._scope;
2486
+ }
2487
+ _setArgsProvider(e) {
2488
+ this._argsFn = e;
2489
+ }
2490
+ getNumberFormat(e, t) {
2491
+ return this._getScope().getNumberFormat(e, t);
2492
+ }
2493
+ getEntireCoords() {
2494
+ return this._getScope().getEntireCoords() ?? Hr;
2495
+ }
2496
+ parseAsSerialDate(e, t) {
2497
+ return this._getScope().parseAsSerialDate(e, t);
2498
+ }
2499
+ parseAsDate(e, t) {
2500
+ return this._getScope().parseAsDate(e, t);
2501
+ }
2502
+ parseAsNumber(e, t) {
2503
+ return this._getScope().parseAsNumber(e, t);
2504
+ }
2505
+ createCriteria(e, t) {
2506
+ return this._getScope().createCriteria(e, t);
2507
+ }
2508
+ createGrouping(e, t) {
2509
+ return this._getScope().createGrouping(e, t);
2510
+ }
2511
+ parseAsLiteral(e) {
2512
+ let t = this._getScope();
2513
+ return t.parseAsLiteral ? t.parseAsLiteral(e) : Pe.parseAsLiteral(e);
2514
+ }
2515
+ toText(e) {
2516
+ return this._getScope().toText(e);
2517
+ }
2518
+ isValidDate(e, t = !1) {
2519
+ return this._getScope().isValidDate(e, t);
2520
+ }
2521
+ fromSerialDate(e, t = !1) {
2522
+ return this._getScope().fromSerialDate(e, t);
2523
+ }
2524
+ toSerialDate(e, t = !1) {
2525
+ return this._getScope().toSerialDate(e, t);
2526
+ }
2527
+ getDateParts(e, t) {
2528
+ return this._getScope().getDateParts(e, t);
2529
+ }
2530
+ getSerialDate(e, t, r, n = 0, i = 0, o = 0, l = 0) {
2531
+ return this._getScope().getSerialDate(e, t, r, n, i, o, l);
2532
+ }
2533
+ getNow() {
2534
+ return this._getScope().getNow();
2535
+ }
2536
+ getRandom() {
2537
+ return this._getScope().getRandom?.() ?? Math.random();
2538
+ }
2539
+ createRange(e, t, r) {
2540
+ return this._getScope().createRange(e, t, r);
2541
+ }
2542
+ flattenAreas(e) {
2543
+ if (!Array.isArray(e)) return e;
2544
+ let t = [];
2545
+ for (let r = 0; r < e.length; r++) {
2546
+ let n = e[r], { rows: i, columns: o } = n.getShape();
2547
+ for (let l = 0; l < i; l++) for (let s = 0; s < o; s++) t.push(n.getValueAt(l, s));
2548
+ }
2549
+ return this.createRange(t.length, 1, (r, n) => t[n.rowIndex]);
2550
+ }
2551
+ getRow() {
2552
+ return this._getScope().getRow?.() ?? 0;
2553
+ }
2554
+ getColumn() {
2555
+ return this._getScope().getColumn?.() ?? 0;
2556
+ }
2557
+ isImplicitIntersect() {
2558
+ return this._getScope().isImplicitIntersect?.() ?? !1;
2559
+ }
2560
+ getReference(e, t) {
2561
+ return this._getScope().getReference(e, t);
2562
+ }
2563
+ getResizedReference(e, t, r) {
2564
+ return this._getScope().getResizedReference(e, t, r);
2565
+ }
2566
+ getValueAt(e, t, r) {
2567
+ return this._getScope().getValueAt(e, t, r);
2568
+ }
2569
+ getFormulaAt(e, t, r) {
2570
+ return this._getScope().getFormulaAt?.(e, t, r) ?? null;
2571
+ }
2572
+ getSpillAt(e, t, r) {
2573
+ return this._getScope().getSpillAt?.(e, t, r) ?? null;
2574
+ }
2575
+ getSheetIndex(e) {
2576
+ return this._getScope().getSheetIndex?.(e) ?? -1;
2577
+ }
2578
+ getSheetCount() {
2579
+ return this._getScope().getSheetCount?.() ?? 1;
2580
+ }
2581
+ markVolatile() {
2582
+ this._getScope().markVolatile?.();
2583
+ }
2584
+ formatResults(e) {
2585
+ this._getScope().formatResults?.(e);
2586
+ }
2587
+ filterHidden(e, t) {
2588
+ return this._getScope().filterHidden?.(e, t) ?? e;
2589
+ }
2590
+ filterTotals(e) {
2591
+ return this._getScope().filterTotals?.(e) ?? e;
2592
+ }
2593
+ getFunction(e) {
2594
+ return this._getScope().getFunction?.(e) ?? null;
2595
+ }
2596
+ getAddress(e, t) {
2597
+ return this._getScope().getAddress(e, t);
2598
+ }
2599
+ compare(e, t, r) {
2600
+ return this._getScope().compare?.(e, t, r) ?? Pe.compare(e, t, r);
2601
+ }
2602
+ getRuntime() {
2603
+ return this._getScope().getRuntime();
2604
+ }
2605
+ getArgs() {
2606
+ let e = this._argsFn, t = e ? e() : null;
2607
+ if (!t) throw new ie(Gr);
2608
+ return t;
2609
+ }
2610
+ get [Symbol.toStringTag]() {
2611
+ return "[FormulaContext]";
2612
+ }
2613
+ toString() {
2614
+ return this._getScope()?.toString?.() ?? "{STUB SCOPE}";
2615
+ }
2616
+ }, Ht = Object.freeze({
2617
+ tag: "en-US",
2618
+ numberingSystem: "latn",
2619
+ decimal: ".",
2620
+ group: ",",
2621
+ grouping: [3],
2622
+ minusSign: "-",
2623
+ percentSign: "%",
2624
+ permilleSign: "‰",
2625
+ currencyCode: "USD",
2626
+ currencySymbol: "$",
2627
+ currencyDisplay: "symbol",
2628
+ currencyPosition: "before",
2629
+ currencySpacing: "tight",
2630
+ date: Object.freeze({
2631
+ calendar: "gregory",
2632
+ short: "M/d/yy",
2633
+ medium: "MMM d, y",
2634
+ long: "MMMM d, y",
2635
+ timeShort: "h:mm a",
2636
+ timeLong: "h:mm:ss a",
2637
+ am: "AM",
2638
+ pm: "PM",
2639
+ firstDay: 0,
2640
+ weekend: [6, 0],
2641
+ monthsWide: [
2642
+ "January",
2643
+ "February",
2644
+ "March",
2645
+ "April",
2646
+ "May",
2647
+ "June",
2648
+ "July",
2649
+ "August",
2650
+ "September",
2651
+ "October",
2652
+ "November",
2653
+ "December"
2654
+ ],
2655
+ monthsAbbr: [
2656
+ "Jan",
2657
+ "Feb",
2658
+ "Mar",
2659
+ "Apr",
2660
+ "May",
2661
+ "Jun",
2662
+ "Jul",
2663
+ "Aug",
2664
+ "Sep",
2665
+ "Oct",
2666
+ "Nov",
2667
+ "Dec"
2668
+ ],
2669
+ weekdaysWide: [
2670
+ "Sunday",
2671
+ "Monday",
2672
+ "Tuesday",
2673
+ "Wednesday",
2674
+ "Thursday",
2675
+ "Friday",
2676
+ "Saturday"
2677
+ ],
2678
+ weekdaysAbbr: [
2679
+ "Sun",
2680
+ "Mon",
2681
+ "Tue",
2682
+ "Wed",
2683
+ "Thu",
2684
+ "Fri",
2685
+ "Sat"
2686
+ ],
2687
+ hour12: !0
2688
+ }),
2689
+ listSeparator: ",",
2690
+ csvDelimiter: ",",
2691
+ rtl: !1,
2692
+ collator: Object.freeze({
2693
+ sensitivity: "base",
2694
+ numeric: !0
2695
+ })
2696
+ });
2697
+ new Gi();
2698
+ const Hi = [
2699
+ {
2700
+ name: "param",
2701
+ group: "jsdoc",
2702
+ description: "Document a parameter. A string union type becomes a dropdown of allowed options.",
2703
+ snippet: "param \${1:name} \${2:description}"
2704
+ },
2705
+ {
2706
+ name: "returns",
2707
+ aliases: ["return"],
2708
+ group: "jsdoc",
2709
+ description: "Describe the return value."
2710
+ },
2711
+ {
2712
+ name: "category",
2713
+ group: "sheetxl",
2714
+ description: "Group the function under a category in the function list.",
2715
+ snippet: "category \${1:name}"
2716
+ },
2717
+ {
2718
+ name: "name",
2719
+ group: "sheetxl",
2720
+ description: "A name an identifier cannot spell: the name formulas call a function by (MY.FUNC), or an enum member's label.",
2721
+ snippet: "name \${1:NAME}"
2722
+ },
2723
+ {
2724
+ name: "description",
2725
+ group: "sheetxl",
2726
+ description: "A longer description of the function."
2727
+ },
2728
+ {
2729
+ name: "deprecated",
2730
+ group: "sheetxl",
2731
+ standalone: !0,
2732
+ description: "Mark the function as deprecated (optionally with a reason)."
2733
+ },
2734
+ {
2735
+ name: "hidden",
2736
+ group: "sheetxl",
2737
+ standalone: !0,
2738
+ description: "Hide the function from the function list."
2739
+ },
2740
+ {
2741
+ name: "returnkind",
2742
+ group: "sheetxl",
2743
+ description: "Declare the value kind of the return (a ValueKind word, e.g. \`number\`, \`array\`, \`reference\`) where the type spelling cannot say it (a union return collapses to any).",
2744
+ snippet: "returnKind \${1:number}"
2745
+ },
2746
+ {
2747
+ name: "example",
2748
+ group: "jsdoc",
2749
+ description: "Provide a usage example."
2750
+ },
2751
+ {
2752
+ name: "see",
2753
+ group: "jsdoc",
2754
+ description: "Reference a related function or link."
2755
+ }
2756
+ ], Wi = (() => {
2757
+ const e = /* @__PURE__ */ new Map();
2758
+ for (const t of Hi) if (e.set(t.name, t), t.aliases) for (const r of t.aliases) e.set(r, t);
2759
+ return e;
2760
+ })();
2761
+ function Ji(e) {
2762
+ if (!e) return;
2763
+ const t = (e.startsWith("@") ? e.slice(1) : e).toLowerCase();
2764
+ return Wi.get(t);
2765
+ }
2766
+ function Yi(e) {
2767
+ return Ji(e)?.standalone === !0;
2768
+ }
2769
+ const ft = /* @__PURE__ */ new Map([["IReferenceRange", "p"], ["IRange", "r"]]), it = new Set(Object.values(Vt).filter((e) => e !== Vt.Omitted)), yt = /* @__PURE__ */ new Map([
2770
+ ["IWorkbook", "workbook"],
2771
+ ["IWorksheet", "sheet"],
2772
+ ["ICellRanges", "ranges"],
2773
+ ["ICellRange", "range"]
2774
+ ]), qi = Array.from(yt.keys()), wt = (e, t) => {
2775
+ Array.from(t.keys()).forEach((r) => {
2776
+ const n = t.get(r);
2777
+ t.set(\`\${e}.\${r}\`, n);
2778
+ });
2779
+ }, Zi = /* @__PURE__ */ new Map([
2780
+ ["Scalar", "*"],
2781
+ ["Lambda", "l"],
2782
+ ["FormulaError.Known", me.Error],
2783
+ ["Date", zt.Date],
2784
+ ["IRichData", zt.RichData]
2785
+ ]), Wr = /* @__PURE__ */ new Map([["Repeating", "repeating"]]), Qi = /* @__PURE__ */ new Set(["Flatten", "SheetXL.Flatten"]), Jr = /* @__PURE__ */ new Set(["AcceptError"]), Yr = /* @__PURE__ */ new Set(["Omittable"]), qr = /* @__PURE__ */ new Set(["NoLift"]), Zr = /* @__PURE__ */ new Set(["NoFilter"]), Qr = /* @__PURE__ */ new Set(["Lazy"]), pt = /* @__PURE__ */ new Set(["ReportType"]), Wt = 255, eo = /^[a-zA-Z_-￿][a-zA-Z0-9_.-￿]*$/, to = /^([a-z]{1,3})([0-9]+)$/i, ro = /^r[0-9]*c[0-9]*$/i, no = (e) => {
2786
+ if (ro.test(e)) return !0;
2787
+ const t = to.exec(e);
2788
+ if (!t) return !1;
2789
+ let r = 0;
2790
+ for (const i of t[1].toUpperCase()) r = r * 26 + (i.charCodeAt(0) - 64);
2791
+ const n = Number(t[2]);
2792
+ return r <= 16384 && n >= 1 && n <= 1048576;
2793
+ }, se = "SheetXL", Ee = (e) => {
2794
+ const t = e.typeName.getText();
2795
+ return t.startsWith(\`\${se}.\`) ? t.slice(8) : t;
2796
+ };
2797
+ wt(se, ft);
2798
+ wt(se, yt);
2799
+ wt(se, Wr);
2800
+ Jr.add(se + ".AcceptError");
2801
+ Yr.add(\`\${se}.Omittable\`);
2802
+ qr.add(\`\${se}.NoLift\`);
2803
+ Zr.add(\`\${se}.NoFilter\`);
2804
+ Qr.add(\`\${se}.Lazy\`);
2805
+ pt.add(\`\${se}.ReportType\`);
2806
+ const io = /* @__PURE__ */ new Map([
2807
+ ["Promise", () => ({ async: !0 })],
2808
+ ["Observable", () => ({ stream: !0 })],
2809
+ ["Volatile", () => ({ volatile: !0 })],
2810
+ [\`\${se}.Volatile\`, () => ({ volatile: !0 })]
2811
+ ]), Jt = "__scriptContext__", Yt = "script", oo = /* @__PURE__ */ new Set([
2812
+ "IScript.ScriptContext",
2813
+ \`\${se}.IScript.ScriptContext\`,
2814
+ "ScriptContext"
2815
+ ]), qt = (e, t) => {
2816
+ const r = t.literal;
2817
+ if (r === void 0) return;
2818
+ const n = e.SyntaxKind;
2819
+ switch (r.kind) {
2820
+ case n.StringLiteral: return r.text;
2821
+ case n.NumericLiteral: return parseFloat(r.text);
2822
+ case n.TrueKeyword: return !0;
2823
+ case n.FalseKeyword: return !1;
2824
+ case n.NullKeyword: return null;
2825
+ case n.PrefixUnaryExpression: return r.operator === n.MinusToken && r.operand?.kind === n.NumericLiteral ? -parseFloat(r.operand.text) : void 0;
2826
+ default: return;
2827
+ }
2828
+ }, $e = (e) => {
2829
+ if (!e || e.length === 0) return "";
2830
+ let t = "";
2831
+ for (let r = 0; r < e.length; r++) {
2832
+ const n = e[r], i = n.kind;
2833
+ if (i !== "link") {
2834
+ if (i === "linkName") {
2835
+ const o = e[r + 1];
2836
+ if (o?.kind === "linkText" && o.text.trim()) continue;
2837
+ t += n.text;
2838
+ continue;
2839
+ }
2840
+ if (i === "linkText") {
2841
+ t += n.text.trim();
2842
+ continue;
2843
+ }
2844
+ t += n.text;
2845
+ }
2846
+ }
2847
+ return t.replace(/\\r\\n?/g, \`
2848
+ \`).split(/\\n[^\\S\\n]*\\n\\s*/).map((r) => r.split(\`
2849
+ \`).map((n) => n.trim()).filter(Boolean).join(" ")).filter(Boolean).join(\`
2850
+ \`).trim();
2851
+ };
2852
+ function ao(e, t, r, n) {
2853
+ const i = n?.builtInNames?.length ? new Set(n.builtInNames.map((u) => u.toUpperCase())) : null, o = [], l = /* @__PURE__ */ new Map(), s = [];
2854
+ let c = null;
2855
+ const d = (u) => {
2856
+ if (!u || typeof u.getStart != "function") return {
2857
+ start: 0,
2858
+ length: 0
2859
+ };
2860
+ try {
2861
+ return {
2862
+ start: u.getStart(),
2863
+ length: u.getWidth()
2864
+ };
2865
+ } catch {
2866
+ return {
2867
+ start: 0,
2868
+ length: 0
2869
+ };
2870
+ }
2871
+ }, m = (u, g, p, E) => {
2872
+ const { start: C, length: O } = d(u);
2873
+ s.push({
2874
+ start: C,
2875
+ length: O,
2876
+ severity: p,
2877
+ code: g,
2878
+ message: E
2879
+ });
2880
+ }, a = (u, g, p) => {
2881
+ m(u, g, "error", p);
2882
+ }, f = (u) => u?.parent?.name?.escapedText, b = (u, g, p, E, C = !1, O = !1, j = !1) => {
2883
+ const D = { count: 0 }, $ = Y(u, g, p, E, D, C, O, j);
2884
+ D.count >= 2 && (g.range || (g.range = "m", D.count -= 2), !E && D.count >= 1 && (D.count -= 1, D.count > 0 && a(u, _.ArrayDepth, \`Arrays of more than 2 dimensions are not supported: '\${f(u)}'.\`))), D.count > 0 && (g.arrayDepth = D.count);
2885
+ const P = g.enum;
2886
+ return P && (D.count > (j ? 1 : 0) || g.range) && !F.has(g) && (g.valueOrRange || (a(u, _.EnumPosition, \`A list cannot hold the enum '\${P.id}': '\${g.name ?? f(u)}'. Its members reach the body as they are, so nothing checks them against the enum. Take one value per argument ('...x: \${P.id}[]'), or type the list by its scalar ('\${P.type}').\`), delete g.enum)), $;
2887
+ }, v = (u, g, p, E, C) => {
2888
+ if (g !== "Lambda" && g !== \`\${se}.Lambda\`) return !1;
2889
+ const O = u.typeArguments;
2890
+ let j = "*";
2891
+ if (O && O.length === 2) if (C && O[0].kind === e.SyntaxKind.TupleType && (p.lambdaArity = O[0].elements.length), O[1].kind === e.SyntaxKind.AnyKeyword) j = "raw";
2892
+ else {
2893
+ const D = {};
2894
+ Y(O[1], D, E, !1, { count: 0 }), j = D.scalar ?? "*";
2895
+ }
2896
+ else if (O && O.length === 1 && O[0].kind !== e.SyntaxKind.TupleType && O[0].kind !== e.SyntaxKind.ArrayType) if (C && (p.lambdaArity = 2), O[0].kind === e.SyntaxKind.AnyKeyword) j = "raw";
2897
+ else {
2898
+ const D = {};
2899
+ Y(O[0], D, E, !1, { count: 0 }), j = D.scalar ?? "*";
2900
+ }
2901
+ return p.lambda = j, !0;
2902
+ }, A = (u, g, p, E) => {
2903
+ if (!E) {
2904
+ a(u, _.FunctionReturn, \`Function type is not a valid return type: '\${f(u)}'. Declare a 'Lambda' return instead.\`);
2905
+ return;
2906
+ }
2907
+ const C = u.type, O = {};
2908
+ let j = "*";
2909
+ C && (C.kind === e.SyntaxKind.AnyKeyword ? j = "raw" : (Y(C, O, p, !1, { count: 0 }), j = O.scalar ?? "*"));
2910
+ const D = u.parameters;
2911
+ D && !D.some(($) => $.dotDotDotToken) && (g.lambdaArity = D.length), g.lambda = j;
2912
+ }, U = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set(), F = /* @__PURE__ */ new WeakSet(), z = (u) => u !== void 0 && u.getSourceFile() === t, L = (u, g = !1) => {
2913
+ return u.getJsDocTags(r).find((E) => E.name === "name")?.text?.map((E) => E.text).join("").trim() || (g ? nr.camelToPrettyCase(u.name) : u.name);
2914
+ }, R = (u) => {
2915
+ const g = u.getJsDocTags(r).find((p) => p.name === "deprecated");
2916
+ if (g) return g.text?.map((p) => p.text).join("").trim() || !0;
2917
+ }, M = (u, g) => {
2918
+ const p = e.isTypeReferenceNode(u) ? u.typeName : void 0, E = p ? r.getSymbolAtLocation(p) : void 0, C = E?.declarations?.length ? E : void 0;
2919
+ if (p) {
2920
+ if (C && C.flags & e.SymbolFlags.Alias) {
2921
+ a(u, _.EnumNotLocal, \`'\${p.getText()}' is imported, so its declaration cannot be read: '\${g}'. An enum must be declared in the module that uses it.\`);
2922
+ return;
2923
+ }
2924
+ if (!C || !(C.flags & e.SymbolFlags.Type)) {
2925
+ const x = p.getText();
2926
+ if (!(C ? (C.flags & e.SymbolFlags.Variable) !== 0 : t.statements.some((I) => e.isVariableStatement(I) && I.declarationList.declarations.some((V) => e.isIdentifier(V.name) && V.name.text === x)))) return null;
2927
+ a(u, _.EnumMissingAlias, \`'\${x}' is a value, not a type: '\${g}'. Pair the object with a same-name type — 'type \${x} = typeof \${x}[keyof typeof \${x}];' — or declare it as 'enum \${x} { … }'.\`);
2928
+ return;
2929
+ }
2930
+ const y = U.get(C);
2931
+ if (y !== void 0) return y;
2932
+ if (S.has(C)) return;
2933
+ }
2934
+ const O = [];
2935
+ let j = !1;
2936
+ if (C && C.flags & e.SymbolFlags.Enum) {
2937
+ if (!C.declarations?.some(z)) {
2938
+ a(u, _.EnumNotLocal, \`'\${C.name}' is not declared in this module: '\${g}'. An enum must be declared in the module that uses it.\`);
2939
+ return;
2940
+ }
2941
+ j = !0;
2942
+ let y = !1;
2943
+ if (C.exports?.forEach((x) => {
2944
+ const I = x.valueDeclaration;
2945
+ if (!I || !e.isEnumMember(I)) return;
2946
+ const V = r.getConstantValue(I);
2947
+ if (V === void 0) {
2948
+ a(I, _.EnumMemberNotConstant, \`'\${C.name}.\${x.name}' is not a constant number or string. A formula passes the VALUE, so every member needs one that can be read at compile time.\`), y = !0;
2949
+ return;
2950
+ }
2951
+ O.push([
2952
+ L(x, !0),
2953
+ V,
2954
+ I,
2955
+ $e(x.getDocumentationComment(r)),
2956
+ R(x)
2957
+ ]);
2958
+ }), y) {
2959
+ S.add(C);
2960
+ return;
2961
+ }
2962
+ } else {
2963
+ const y = r.getTypeFromTypeNode(u), x = e.TypeFlags.Null | e.TypeFlags.Undefined | e.TypeFlags.Void, I = (y.isUnion() ? y.types : [y]).filter((B) => !(B.flags & x)), V = [];
2964
+ for (const B of I) {
2965
+ if (!(B.flags & (e.TypeFlags.NumberLiteral | e.TypeFlags.StringLiteral))) return C && U.set(C, null), null;
2966
+ V.push(B.value);
2967
+ }
2968
+ if (V.length === 0) return null;
2969
+ const re = C?.declarations?.find((B) => e.isTypeAliasDeclaration(B)), q = e.isUnionTypeNode(u) ? u : re?.type;
2970
+ if (q && e.isUnionTypeNode(q)) {
2971
+ const B = q.types.map((N) => {
2972
+ const ne = r.getTypeFromTypeNode(N);
2973
+ return ne.isLiteral() ? ne.value : void 0;
2974
+ }), k = (N) => {
2975
+ const ne = B.indexOf(N);
2976
+ return ne < 0 ? B.length : ne;
2977
+ };
2978
+ V.sort((N, ne) => k(N) - k(ne));
2979
+ }
2980
+ const ee = C && C.flags & e.SymbolFlags.Variable ? C.valueDeclaration : void 0, he = new Set(V);
2981
+ if (C && ee && z(ee)) for (const B of r.getTypeOfSymbolAtLocation(C, ee).getProperties()) {
2982
+ const k = B.valueDeclaration, N = r.getTypeOfSymbolAtLocation(B, k ?? ee);
2983
+ if (!(N.flags & (e.TypeFlags.NumberLiteral | e.TypeFlags.StringLiteral))) continue;
2984
+ const ne = N.value;
2985
+ V.includes(ne) && (j = !0, he.delete(ne), O.push([
2986
+ L(B, !0),
2987
+ ne,
2988
+ k,
2989
+ $e(B.getDocumentationComment(r)),
2990
+ R(B)
2991
+ ]));
2992
+ }
2993
+ for (const B of V) he.has(B) && O.push([
2994
+ String(B),
2995
+ B,
2996
+ void 0,
2997
+ null
2998
+ ]);
2999
+ }
3000
+ if (O.length === 0) return null;
3001
+ const D = typeof O[0][1] == "number";
3002
+ if (O.some(([, y]) => typeof y == "number" !== D)) {
3003
+ a(u, _.EnumMixed, \`'\${C?.name ?? u.getText()}' mixes number and string members: '\${g}'. A parameter has one type, so an enum is all numbers or all strings.\`);
3004
+ return;
3005
+ }
3006
+ const $ = C ? L(C) : O.map(([, y]) => String(y)).join("|"), P = C ? void 0 : h.get($);
3007
+ if (P) return P;
3008
+ if (j) {
3009
+ const y = /* @__PURE__ */ new Map();
3010
+ for (const [x, I, V, re] of O) {
3011
+ const q = V?.name?.getText() ?? x, ee = y.get(I);
3012
+ ee !== void 0 ? m(V ?? u, _.EnumDuplicateValue, "warning", \`'\${$}.\${q}' has the same value as '\${$}.\${ee}' (\${JSON.stringify(I)}). A formula passes the value, so the two cannot be told apart.\`) : y.set(I, q), re === "" && m(V ?? u, _.EnumMemberUndocumented, "warning", \`'\${$}.\${q}' is missing a description. Add a doc comment above the member — it is what the argument dropdown shows.\`);
3013
+ }
3014
+ }
3015
+ const G = {
3016
+ id: $,
3017
+ type: D ? me.Number : me.String,
3018
+ members: O.map(([y, x, , , I]) => I ? [
3019
+ y,
3020
+ x,
3021
+ I
3022
+ ] : [y, x])
3023
+ };
3024
+ C ? U.set(C, G) : h.set($, G);
3025
+ const X = C ? $e(C.getDocumentationComment(r)) : "", K = {};
3026
+ for (const [y, , , x] of O) x && (K[y] = { description: x });
3027
+ if (X || Object.keys(K).length > 0) {
3028
+ const y = {};
3029
+ X && (y.summary = X), Object.keys(K).length > 0 && (y.members = K), w.set(G, y);
3030
+ }
3031
+ return G;
3032
+ }, pe = (u, g, p, E) => {
3033
+ const C = (D, $, P) => {
3034
+ const G = { name: D };
3035
+ return b($, G, p, !0), P && (G.optional = !0), E && !G.acceptError && (G.acceptError = !0), G;
3036
+ };
3037
+ if (u.kind !== e.SyntaxKind.TupleType) return [C(g, u, !1)];
3038
+ const O = u.elements;
3039
+ if (O.length < 2) return a(u, _.RepeatingSlots, \`'\${g}': a repeating group of period \${O.length} must be spelled 'Repeating<T>' without the tuple.\`), null;
3040
+ const j = [];
3041
+ for (let D = 0; D < O.length; D++) {
3042
+ const $ = O[D];
3043
+ if ($.kind !== e.SyntaxKind.NamedTupleMember) return a($, _.RepeatingSlots, \`'\${g}': every slot of a repeating group must be labelled, e.g. 'Repeating<[criteriaRange: IRange, criteria: Scalar]>'.\`), null;
3044
+ const P = !!$.questionToken;
3045
+ if (P && D !== O.length - 1) return a($, _.RepeatingOptional, \`'\${g}': only the LAST slot of a repeating group may be optional (slot '\${$.name?.getText?.()}' is not).\`), null;
3046
+ j.push(C($.name?.getText?.() ?? \`\${D}\`, $.type, P));
3047
+ }
3048
+ return j;
3049
+ }, Y = (u, g, p, E, C, O = !1, j = !1, D = !1) => {
3050
+ if (!u) {
3051
+ a(u, _.MissingType, \`Type is not defined for '\${g?.name ?? "return"}'.\`);
3052
+ return;
3053
+ }
3054
+ if (u.kind === e.SyntaxKind.ParenthesizedType) return Y(u.type, g, p, E, C, O, j, D);
3055
+ if (u.kind === e.SyntaxKind.UnionType) {
3056
+ const $ = (X) => X.kind === e.SyntaxKind.UndefinedKeyword || X.kind === e.SyntaxKind.VoidKeyword || X.kind === e.SyntaxKind.NullKeyword || X.kind === e.SyntaxKind.LiteralType && X.literal?.kind === e.SyntaxKind.NullKeyword, P = u.types.filter((X) => !$(X));
3057
+ if (P.length === 1) return Y(P[0], g, p, E, C, O, j, D);
3058
+ const G = M(u, g.name ?? f(u));
3059
+ if (G === void 0) return;
3060
+ if (G !== null) {
3061
+ g.scalar = G.type, E && (g.enum = G);
3062
+ return;
3063
+ }
3064
+ if (!E) {
3065
+ g.scalar = "*";
3066
+ return;
3067
+ }
3068
+ if (P.length === 2) {
3069
+ const X = (y) => y.kind !== e.SyntaxKind.TypeReference ? !1 : e.isTypeReferenceNode(y) && Ee(y) === "Lambda", K = P.findIndex(X);
3070
+ if (K >= 0 && !X(P[1 - K])) {
3071
+ Y(P[1 - K], g, p, E, C, O, j, D), v(P[K], Ee(P[K]), g, p, E);
3072
+ return;
3073
+ }
3074
+ }
3075
+ if (E && P.length === 2) {
3076
+ const X = (y) => {
3077
+ if (!(y.kind !== e.SyntaxKind.TypeReference || y.typeArguments?.length)) return ft.get(Ee(y));
3078
+ }, K = P.findIndex((y) => X(y) !== void 0);
3079
+ if (K >= 0 && X(P[1 - K]) === void 0) {
3080
+ const y = {}, x = C.count;
3081
+ if (Y(P[1 - K], y, p, E, C, O, !1), y.scalar && !y.range && y.lambda == null && C.count === x) {
3082
+ g.range = X(P[K]), g.scalar = y.scalar, g.valueOrRange = !0;
3083
+ const I = y.enum;
3084
+ I && (g.enum = I);
3085
+ return;
3086
+ }
3087
+ }
3088
+ }
3089
+ if (E && P.length === 2) {
3090
+ const X = (y) => y.kind === e.SyntaxKind.TypeReference && !y.typeArguments?.length && Ee(y) === "Scalar", K = P.findIndex(X);
3091
+ if (K >= 0 && !X(P[1 - K])) {
3092
+ const y = M(P[1 - K], g.name ?? f(u));
3093
+ if (y === void 0) return;
3094
+ if (y !== null) {
3095
+ g.scalar = "*", g.enum = y;
3096
+ return;
3097
+ }
3098
+ }
3099
+ }
3100
+ a(u, _.InvalidParamType, \`Union parameter types are not supported: '\${f(u)}'. Use a single type, optionally with '| null' or '| undefined', 'T | Lambda<…>' for a value-or-lambda slot, 'IRange | Scalar' for a value-or-range slot, or 'E | Scalar' for an uncoerced slot whose values an enum documents.\`);
3101
+ return;
3102
+ }
3103
+ if (u.kind === e.SyntaxKind.NumberKeyword) g.scalar = me.Number;
3104
+ else if (u.kind === e.SyntaxKind.StringKeyword) g.scalar = me.String;
3105
+ else if (u.kind === e.SyntaxKind.BooleanKeyword) g.scalar = me.Boolean;
3106
+ else if (u.kind === e.SyntaxKind.UndefinedKeyword || u.kind === e.SyntaxKind.NullKeyword || u.kind === e.SyntaxKind.VoidKeyword) {
3107
+ if (E) {
3108
+ a(u, _.UndefinedInput, \`'undefined' is not a valid type for input: '\${f(u)}'.\`);
3109
+ return;
3110
+ }
3111
+ g.scalar = me.Null;
3112
+ } else if (u.kind === e.SyntaxKind.BigIntKeyword) g.scalar = me.Number;
3113
+ else if (u.kind === e.SyntaxKind.AnyKeyword) E && (g.range = "*");
3114
+ else if (u.kind === e.SyntaxKind.ArrayType) {
3115
+ const $ = u.elementType;
3116
+ if (!$) {
3117
+ a(u, _.UntypedArray, \`'Array' must be typed: '\${f(u)}'.\`);
3118
+ return;
3119
+ }
3120
+ if (E && j) {
3121
+ const P = g, G = P.name ?? f(u) ?? "parameter", X = P.acceptError;
3122
+ delete P.acceptError;
3123
+ const K = { name: G };
3124
+ b($, K, p, !0), X && !K.acceptError && (K.acceptError = !0), P.repeating = [K];
3125
+ return;
3126
+ }
3127
+ C.count++, Y($, g, p, E, C);
3128
+ } else if (u.kind !== e.SyntaxKind.TupleType) if (u.kind === e.SyntaxKind.TypeReference) {
3129
+ const $ = Ee(u);
3130
+ if (Jr.has($)) {
3131
+ const y = f(u);
3132
+ if (!E) {
3133
+ a(u, _.InvalidReturnType, \`'\${$}' is not a valid return type: '\${y}'. It describes how an ARGUMENT is received.\`);
3134
+ return;
3135
+ }
3136
+ const x = g;
3137
+ if (x.acceptError) {
3138
+ a(u, _.InvalidParamType, \`'\${y}' declares 'AcceptError' more than once.\`);
3139
+ return;
3140
+ }
3141
+ const I = u.typeArguments;
3142
+ if (!I || I.length !== 1) {
3143
+ a(u, _.GenericArity, \`'\${$}' must be typed with exactly 1 type: '\${y}'.\`);
3144
+ return;
3145
+ }
3146
+ return x.acceptError = !0, Y(I[0], g, p, E, C, O, j, D);
3147
+ }
3148
+ if (pt.has($)) {
3149
+ const y = g.name ?? f(u);
3150
+ if (!E) {
3151
+ a(u, _.InvalidReturnType, \`'ReportType' is not a valid return type: '\${y}'. It describes how an ARGUMENT is received.\`);
3152
+ return;
3153
+ }
3154
+ const x = u.typeArguments;
3155
+ if (!x || x.length !== 1) {
3156
+ a(u, _.GenericArity, \`'\${$}' must be typed with exactly 1 type: '\${y}'.\`);
3157
+ return;
3158
+ }
3159
+ return g.reportType = !0, Y(x[0], g, p, E, C, O, j, D);
3160
+ }
3161
+ if (qr.has($)) {
3162
+ const y = g.name ?? f(u);
3163
+ if (!E) {
3164
+ a(u, _.InvalidReturnType, \`'NoLift' is not a valid return type: '\${y}'. It describes how an ARGUMENT is received.\`);
3165
+ return;
3166
+ }
3167
+ const x = u.typeArguments;
3168
+ if (!x || x.length !== 1) {
3169
+ a(u, _.GenericArity, \`'\${$}' must be typed with exactly 1 type: '\${y}'.\`);
3170
+ return;
3171
+ }
3172
+ const I = g;
3173
+ I.noLift = !0;
3174
+ const V = C.count;
3175
+ Y(x[0], g, p, E, C, O, j, D), (I.range || I.lambda != null || I.repeating || C.count !== V) && a(u, _.InvalidParamType, \`'\${y}': 'NoLift' applies to a SCALAR parameter only - a range, list, repeating or lambda slot never lifts.\`);
3176
+ return;
3177
+ }
3178
+ if (Zr.has($)) {
3179
+ const y = g.name ?? f(u);
3180
+ if (!E) {
3181
+ a(u, _.InvalidReturnType, \`'NoFilter' is not a valid return type: '\${y}'. It describes how an ARGUMENT is received.\`);
3182
+ return;
3183
+ }
3184
+ const x = u.typeArguments;
3185
+ if (!x || x.length !== 1) {
3186
+ a(u, _.GenericArity, \`'\${$}' must be typed with exactly 1 type: '\${y}'.\`);
3187
+ return;
3188
+ }
3189
+ const I = g;
3190
+ I.noFilter = !0;
3191
+ const V = C.count;
3192
+ if (Y(x[0], g, p, E, C, O, j, D), I.range || I.lambda != null || C.count !== V) {
3193
+ a(u, _.InvalidParamType, \`'\${y}': 'NoFilter' applies to a SCALAR slot only - a range, list or lambda slot has no members to coerce.\`);
3194
+ return;
3195
+ }
3196
+ const re = I.repeating;
3197
+ if (re) {
3198
+ if (delete I.noFilter, re.length !== 1) {
3199
+ a(u, _.InvalidParamType, \`'\${y}': 'NoFilter' over a repeating group applies to a period-1 group only - write it on the slot that takes the members.\`);
3200
+ return;
3201
+ }
3202
+ re[0].noFilter = !0;
3203
+ } else j && a(u, _.InvalidParamType, \`'\${y}': 'NoFilter' applies to a REPEATING slot only - a single scalar argument has no members to coerce.\`);
3204
+ return;
3205
+ }
3206
+ if (Yr.has($)) {
3207
+ const y = g.name ?? f(u);
3208
+ if (!E) {
3209
+ a(u, _.InvalidReturnType, \`'Omittable' is not a valid return type: '\${y}'. It describes how an ARGUMENT is received.\`);
3210
+ return;
3211
+ }
3212
+ const x = u.typeArguments;
3213
+ if (!x || x.length < 1 || x.length > 2) {
3214
+ a(u, _.GenericArity, \`'\${$}' must be typed with 1 or 2 types: '\${y}'.\`);
3215
+ return;
3216
+ }
3217
+ const I = g;
3218
+ if (I.omittable = !0, x.length === 2) {
3219
+ const q = qt(e, x[1]);
3220
+ if (q === void 0) {
3221
+ a(u, _.InvalidParamType, \`'\${y}' declares '\${$}' with a second type that is not a literal value. Use a number, string, boolean or null - the engine substitutes it for an omitted argument.\`);
3222
+ return;
3223
+ }
3224
+ I.omittedValue = q;
3225
+ }
3226
+ const V = Y(x[0], g, p, E, C, O, j, D), re = I.omittedValue;
3227
+ return I.enum && re !== void 0 && re !== null && !I.enum.members.some(([, q]) => q === re) && a(x[1], _.EnumOmittedValue, \`'\${y}': \${JSON.stringify(re)} is not a member of '\${I.enum.id}'. An omitted argument must mean a member (\${I.enum.members.map(([, q]) => JSON.stringify(q)).join(", ")}) or null.\`), V;
3228
+ }
3229
+ if (Qr.has($)) {
3230
+ const y = g.name ?? f(u);
3231
+ if (!E) {
3232
+ a(u, _.InvalidReturnType, \`'Lazy' is not a valid return type: '\${y}'. It describes how an ARGUMENT is received.\`);
3233
+ return;
3234
+ }
3235
+ const x = g;
3236
+ if (x.lazy) {
3237
+ a(u, _.InvalidParamType, \`'\${y}' declares 'Lazy' more than once.\`);
3238
+ return;
3239
+ }
3240
+ const I = u.typeArguments;
3241
+ if (!I || I.length < 1 || I.length > 2) {
3242
+ a(u, _.GenericArity, \`'\${$}' must be typed with 1 or 2 types: '\${y}'.\`);
3243
+ return;
3244
+ }
3245
+ if (x.lazy = !0, I.length === 2) {
3246
+ const V = qt(e, I[1]);
3247
+ if (V === void 0) {
3248
+ a(u, _.InvalidParamType, \`'\${y}' declares '\${$}' with a second type that is not a literal value. Use a number, string, boolean or null - the engine substitutes it for an absent argument.\`);
3249
+ return;
3250
+ }
3251
+ x.optional = !0, x.defaultValue = V;
3252
+ }
3253
+ Y(I[0], g, p, E, C, O, j, D), x.enum ? (a(u, _.EnumPosition, \`'\${y}': 'Lazy' cannot hold the enum '\${x.enum.id}'. The argument may never be evaluated, so there is no point at which it could be checked against the members.\`), delete x.enum) : x.lambda != null ? a(u, _.InvalidParamType, \`'\${y}': 'Lazy' cannot be combined with a Lambda parameter - a callable slot is already the body's to call, or not.\`) : x.repeating && a(u, _.InvalidParamType, \`'\${y}': 'Lazy' applies to a VALUE, not to a repeating group - mark the group's slots instead.\`);
3254
+ return;
3255
+ }
3256
+ if (Qi.has($)) {
3257
+ const y = g.name ?? f(u);
3258
+ if (!E) {
3259
+ a(u, _.InvalidReturnType, \`'Flatten' is not a valid return type: '\${y}'. It describes how an ARGUMENT is received.\`);
3260
+ return;
3261
+ }
3262
+ const x = u.typeArguments;
3263
+ if (!x || x.length !== 1) {
3264
+ a(u, _.GenericArity, \`'\${$}' must be typed with exactly 1 type: '\${y}'.\`);
3265
+ return;
3266
+ }
3267
+ return C.count++, Y(x[0], g, p, E, C, O);
3268
+ }
3269
+ if (Wr.get($) === "repeating") {
3270
+ const y = g.name ?? f(u);
3271
+ if (!E) {
3272
+ a(u, _.RepeatingPosition, \`'Repeating' is not a valid return type: '\${y}'.\`);
3273
+ return;
3274
+ }
3275
+ if (C.count !== 0) {
3276
+ a(u, _.RepeatingPosition, \`'Repeating' cannot be nested inside another type: '\${y}'.\`);
3277
+ return;
3278
+ }
3279
+ const x = g, I = u.typeArguments;
3280
+ if (!I || I.length < 1 || I.length > 2) {
3281
+ a(u, _.GenericArity, \`'\${$}' must be typed with 1 type, optionally followed by a maximum argument count: '\${y}'.\`);
3282
+ return;
3283
+ }
3284
+ let V;
3285
+ if (I.length === 2) {
3286
+ const ee = I[1], he = ee.kind === e.SyntaxKind.LiteralType ? ee.literal : null, B = he && he.kind === e.SyntaxKind.NumericLiteral ? Number(he.text) : NaN;
3287
+ if (!Number.isInteger(B) || B < 1 || B > Wt) {
3288
+ a(ee, _.RepeatingMax, \`'\${y}': '\${$}'’s maximum must be a whole number between 1 and \${Wt}.\`);
3289
+ return;
3290
+ }
3291
+ V = B, p.maxArguments = B;
3292
+ }
3293
+ if (D) {
3294
+ if (V === void 0) {
3295
+ a(u, _.RepeatingPosition, \`'\${y}' is a rest parameter and a repeating group. A group already repeats — drop the '...', or give the group a maximum ('Repeating<T, 254>') if the ceiling is all you meant.\`);
3296
+ return;
3297
+ }
3298
+ return Y(I[0], g, p, E, C, O, j);
3299
+ }
3300
+ const re = x.acceptError;
3301
+ delete x.acceptError;
3302
+ const q = pe(I[0], y ?? "parameter", p, re);
3303
+ q && (x.repeating = q);
3304
+ return;
3305
+ }
3306
+ const P = ft.get($);
3307
+ let G = !1;
3308
+ P && (g.range = P, G = !0);
3309
+ const X = Zi.get($);
3310
+ if (X && (g.scalar = X), X !== void 0 && (G = !0), v(u, $, g, p, E)) return;
3311
+ if (E) {
3312
+ if ($ === "Volatile" || $ === \`\${se}.Volatile\`) {
3313
+ a(u, _.InvalidParamType, \`'Volatile' is not a valid parameter type: '\${f(u)}'. It describes the function's RESULT, so it belongs on the return type.\`);
3314
+ return;
3315
+ }
3316
+ if (oo.has($)) return Jt;
3317
+ const y = yt.get($);
3318
+ if (y) return y;
3319
+ } else {
3320
+ const y = io.get($);
3321
+ if (y) {
3322
+ const x = Object.assign(g, y());
3323
+ let I = 0;
3324
+ if (x.async && I++, x.stream && I++, I > 1) {
3325
+ a(u, _.MultipleModifiers, \`'\${$}' cannot have multiple modifiers: '\${f(u)}'.\`);
3326
+ return;
3327
+ }
3328
+ G = !0;
3329
+ }
3330
+ }
3331
+ if (!G) {
3332
+ const y = M(u, g.name ?? f(u));
3333
+ if (y === void 0) return;
3334
+ if (y !== null) {
3335
+ g.scalar = y.type, E && (g.enum = y);
3336
+ return;
3337
+ }
3338
+ }
3339
+ if (!G) {
3340
+ const y = "number, string, boolean, Scalar, Lambda, Date, FormulaError.Known, IRichData, IRange, IReferenceRange (and arrays of these; optionally wrapped in AcceptError<T>, or grouped with Repeating<T>)", x = "number, string, boolean, Scalar, Date, FormulaError.Known, IRichData, IRange, Promise<T>, Observable<T>, Volatile<T> (and arrays of these)";
3341
+ let I;
3342
+ E ? O ? I = \`'\${$}' is not a valid first parameter: '\${f(u)}'. The first parameter is EITHER a macro target (making this a macro) OR a calculation input (making this a calculation function). Allowed: \${qi.join(", ")} (macro target); \${y} (calculation input).\` : I = \`'\${$}' is not a valid parameter type: '\${f(u)}'. Allowed: \${y}.\` : I = \`'\${$}' is not a valid return type: '\${f(u)}'. Allowed: \${x}.\`, a(u, E ? _.InvalidParamType : _.InvalidReturnType, I);
3343
+ return;
3344
+ }
3345
+ const K = u.typeArguments;
3346
+ if (K) {
3347
+ if (K.length !== 1) {
3348
+ a(u, _.GenericArity, \`'\${$}' must be typed with exactly 1 type: '\${f(u)}'.\`);
3349
+ return;
3350
+ }
3351
+ const y = K[0], x = E && e.isTypeReferenceNode(y) && pt.has(Ee(y)), I = g.reportType;
3352
+ x && F.add(g), b(y, g, p, E), x && I === void 0 && delete g.reportType;
3353
+ const V = g.enum;
3354
+ V && !x && (a(K[0], _.EnumPosition, \`'\${$}' cannot hold the enum '\${V.id}': '\${f(u)}'. The members of a range reach the body as they are, so nothing checks them against the enum. Take the enum as a value, or type the range by its scalar ('\${$}<\${V.type}>').\`), delete g.enum);
3355
+ }
3356
+ } else u.kind === e.SyntaxKind.FunctionType && A(u, g, p, E);
3357
+ }, We = (u) => (e.getCombinedModifierFlags(u) & e.ModifierFlags.Export) !== 0, Je = (u) => (e.getCombinedModifierFlags(u) & e.ModifierFlags.Default) !== 0;
3358
+ try {
3359
+ e.forEachChild(t, (u) => {
3360
+ if (We(u) && e.isFunctionDeclaration(u)) {
3361
+ const g = u?.name?.getText();
3362
+ if (!u.body) {
3363
+ a(u, _.NoBody, \`'\${g}': function has no body.\`);
3364
+ return;
3365
+ }
3366
+ if (!g) {
3367
+ a(u, _.Anonymous, "Anonymous exported functions are not allowed.");
3368
+ return;
3369
+ }
3370
+ const p = {}, E = { parameters: {} };
3371
+ try {
3372
+ p.name = g;
3373
+ const C = r.getSymbolAtLocation(u.name), O = $e(C?.getDocumentationComment(r));
3374
+ O && (E.summary = O);
3375
+ const j = {};
3376
+ b(u.type, j, p, !1), p.returnType = j;
3377
+ const D = {};
3378
+ Je(u) && (D.default = !0, c = g), p.parameters = [];
3379
+ const $ = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Set();
3380
+ let X = null, K = null, y = null, x = 0, I = !1, V = 0;
3381
+ for (let B = 0; B < u.parameters.length; B++) {
3382
+ const k = u.parameters[B], N = {};
3383
+ N.name = k.name?.getText();
3384
+ const ne = p.parameters.length === 0;
3385
+ if (n?.lenient && B === 0 && !k.type && D.default) {
3386
+ p.context = Yt;
3387
+ continue;
3388
+ }
3389
+ const Ie = b(k.type, N, p, !0, ne, !k.dotDotDotToken, !!k.dotDotDotToken);
3390
+ if (Ie === Jt) {
3391
+ B === 0 && p.context === void 0 && (p.context = Yt);
3392
+ continue;
3393
+ }
3394
+ if (Ie) {
3395
+ if (p.parameters.length !== 0) {
3396
+ a(k, _.ContextNotFirst, \`'\${p.name}' contexts must be the first parameter: '\${N.name}'.\`);
3397
+ return;
3398
+ }
3399
+ p.context = Ie;
3400
+ continue;
3401
+ }
3402
+ if (N.lambda !== void 0) {
3403
+ if (X !== null) {
3404
+ a(k, _.MultipleLambda, \`'\${p.name}' has more than one Lambda parameter ('\${X}' and '\${N.name}'). Only one Lambda parameter is allowed.\`);
3405
+ return;
3406
+ }
3407
+ X = N.name;
3408
+ } else if (X !== null) {
3409
+ a(k, _.LambdaNotLast, \`'\${p.name}' Lambda parameter ('\${X}') must be the last parameter, but '\${N.name}' follows it.\`);
3410
+ return;
3411
+ }
3412
+ const ye = N.optional === !0 || !((k.initializer === void 0 || k.initializer === null) && (k.questionToken === void 0 || k.questionToken === null));
3413
+ let ae;
3414
+ if (ye && (N.optional = !0, k.initializer)) try {
3415
+ if (k.initializer.kind === e.SyntaxKind.StringLiteral) ae = k.initializer.text;
3416
+ else if (k.initializer.kind === e.SyntaxKind.NumericLiteral) ae = parseFloat(k.initializer.text);
3417
+ else if (k.initializer.kind === e.SyntaxKind.TrueKeyword || k.initializer.kind === e.SyntaxKind.FalseKeyword) ae = k.initializer.kind === e.SyntaxKind.TrueKeyword;
3418
+ else if (k.initializer.kind === e.SyntaxKind.NullKeyword) ae = null;
3419
+ else if (e.isPrefixUnaryExpression(k.initializer) && k.initializer.operator === e.SyntaxKind.MinusToken && k.initializer.operand.kind === e.SyntaxKind.NumericLiteral) ae = -parseFloat(k.initializer.operand.text);
3420
+ else if (e.isPropertyAccessExpression(k.initializer) || e.isElementAccessExpression(k.initializer)) {
3421
+ const ue = r.getTypeAtLocation(k.initializer);
3422
+ ue.flags & (e.TypeFlags.NumberLiteral | e.TypeFlags.StringLiteral) && (ae = ue.value);
3423
+ }
3424
+ } catch (ue) {
3425
+ console.warn(\`Couldn't extract default value for parameter '\${N.name}'\`, ue);
3426
+ }
3427
+ k.dotDotDotToken && (N.rest = !0);
3428
+ const H = N.repeating;
3429
+ if (H) {
3430
+ if (N.rest) {
3431
+ a(k, _.RepeatingPosition, \`'\${p.name}' parameter '\${N.name}' is both a rest parameter and a repeating group. A group already repeats — drop the '...'.\`);
3432
+ return;
3433
+ }
3434
+ if (ye && H.length === 1) {
3435
+ a(k, _.RepeatingOptional, \`'\${p.name}' parameter '\${N.name}' cannot be an optional repeating group. Use '...\${N.name}: T[]' for zero-or-more, or drop the '?' for one-or-more.\`);
3436
+ return;
3437
+ }
3438
+ if (K !== null) {
3439
+ a(k, _.MultipleRepeating, \`'\${p.name}' has more than one repeating group ('\${K}' and '\${N.name}'). Only one is allowed — two would make the argument count ambiguous.\`);
3440
+ return;
3441
+ }
3442
+ if (y !== null) {
3443
+ a(k, _.RepeatingOptional, \`'\${p.name}' parameter '\${y}' is optional and precedes the repeating group '\${N.name}'. Every parameter outside a group must be required.\`);
3444
+ return;
3445
+ }
3446
+ K = N.name, x = H.length, I = H[H.length - 1].optional === !0;
3447
+ } else if (K !== null && N.rest) {
3448
+ a(k, _.RepeatingOptional, \`'\${p.name}' parameter '\${N.name}' is a rest parameter and follows the repeating group '\${K}'. Two variadic tails would make the argument count ambiguous.\`);
3449
+ return;
3450
+ } else if (K !== null && ye) {
3451
+ if (V >= x - 1) {
3452
+ a(k, _.RepeatingOptional, x === 1 ? \`'\${p.name}' parameter '\${N.name}' is optional and follows the period-1 repeating group '\${K}'. One more argument is indistinguishable from one more repetition — make it required, or give the group a period.\` : \`'\${p.name}' has \${V + 1} optional parameters after the repeating group '\${K}', which has period \${x}. At most \${x - 1} may be optional, or the argument count no longer decides the parse.\`);
3453
+ return;
3454
+ }
3455
+ if (I) {
3456
+ a(k, _.RepeatingOptional, \`'\${p.name}' parameter '\${N.name}' is optional and follows '\${K}', whose own last slot is already optional. Both omissions reach the same argument count — drop one.\`);
3457
+ return;
3458
+ }
3459
+ V++;
3460
+ }
3461
+ ye && !H && (y = N.name);
3462
+ const W = (N.range ? 2 : 0) + (N.arrayDepth ?? 0), De = N.range === "r" || N.range === "p" || N.range === "*", Q = N.rest || De ? 3 : 2;
3463
+ if (W > Q) {
3464
+ a(k, _.ArrayDepth, \`'\${p.name}' parameter '\${N.name}' has an array depth of \${W}; the maximum is \${Q}\${N.rest ? " for a rest parameter" : " (use a rest parameter for one more level, or an IRange)"}.\`);
3465
+ return;
3466
+ }
3467
+ p.parameters.push(N);
3468
+ const ce = { description: "" };
3469
+ E.parameters[N.name] = ce;
3470
+ const Ye = r.getSymbolAtLocation(k.name);
3471
+ ce.description = $e(Ye?.getDocumentationComment(r)), ae !== void 0 && (N.defaultValue = ae);
3472
+ for (const ue of [N, ...N.repeating ?? []]) {
3473
+ const we = ue.enum ? w.get(ue.enum) : void 0;
3474
+ we && ((E.enums ??= {})[ue.enum.id] = we);
3475
+ }
3476
+ if ($.set(N.name, N), P.set(N.name, k), H && H.length > 1) {
3477
+ G.add(N.name);
3478
+ for (const ue of H) {
3479
+ const we = \`\${N.name}.\${ue.name}\`;
3480
+ E.parameters[we] = { description: "" }, $.set(we, ue), P.set(we, k);
3481
+ }
3482
+ }
3483
+ }
3484
+ const re = p.maxArguments;
3485
+ if (re !== void 0) {
3486
+ const B = p.parameters ?? [];
3487
+ if (!B.some((N) => N.rest === !0 || N.repeating !== void 0)) {
3488
+ a(u, _.RepeatingMax, \`'\${p.name}' declares a maximum of \${re} arguments but takes a fixed \${B.length}. A maximum only means something on a variadic tail.\`);
3489
+ return;
3490
+ }
3491
+ let k = 0;
3492
+ for (const N of B) N.rest === !0 || N.optional === !0 || (k += N.repeating ? N.repeating.length : 1);
3493
+ if (re < k) {
3494
+ a(u, _.RepeatingMax, \`'\${p.name}' declares a maximum of \${re} arguments but requires \${k}.\`);
3495
+ return;
3496
+ }
3497
+ }
3498
+ if (u.jsDoc && u.jsDoc.length > 0) {
3499
+ const B = u.jsDoc, k = B.length;
3500
+ for (let N = 0; N < k; N++) {
3501
+ const ne = B[N]?.tags;
3502
+ if (!ne) continue;
3503
+ const Ie = ne.length;
3504
+ for (let ye = 0; ye < Ie; ye++) {
3505
+ const ae = ne[ye];
3506
+ let H = ae?.tagName?.text;
3507
+ if (!H) continue;
3508
+ H = H.toLowerCase();
3509
+ let W = ae.comment;
3510
+ const De = Yi(H);
3511
+ if (typeof W != "string" && !De) {
3512
+ H === "returnkind" && a(ae, _.UnknownReturnKind, \`'@returnKind' needs a value kind. Known: \${[...it].map((Q) => \`'\${Q}'\`).join(", ")}.\`);
3513
+ continue;
3514
+ }
3515
+ if (typeof W == "string" && (W = W.replace(/\\r\\n?/g, \`
3516
+ \`).trim()), !(!De && W && (W = W.split(\`
3517
+ \`)[0].trim(), !W || W.length === 0))) {
3518
+ if (W && typeof W == "string") {
3519
+ const Q = /\\{@link(code|plain)?\\s+([^}|]+)(?:\\s*\\|\\s*([^}]+))?\\}/g;
3520
+ let ce, Ye = W, ue = [];
3521
+ for (; (ce = Q.exec(W)) !== null;) {
3522
+ const [we, xo, nn, St] = ce, on = [nn.trim()];
3523
+ St && on.push(St.trim());
3524
+ }
3525
+ W = Ye, ue.length > 0 && H === "see" && (E.links || (E.links = []), E.links.push(...ue));
3526
+ }
3527
+ if (H === "name") {
3528
+ const Q = W;
3529
+ Q !== g && (E.name = Q);
3530
+ } else if (H !== "description") {
3531
+ if (H === "param") {
3532
+ const Q = ae.name?.getText?.() ?? ae.name?.text;
3533
+ if (!$.get(Q)) {
3534
+ a(ae, _.UnknownParam, \`Parameter '\${Q}' not found in function '\${g}'.\`);
3535
+ continue;
3536
+ }
3537
+ const ce = E.parameters?.[Q];
3538
+ ce && !ce.description && typeof W == "string" && W && (ce.description = W);
3539
+ } else if (H === "returns" || H === "return") p.returnType.description = W;
3540
+ else if (H === "returnkind") {
3541
+ const Q = (W ?? "").trim().toLowerCase();
3542
+ it.has(Q) ? p.returnType.kind = Q : a(ae, _.UnknownReturnKind, \`'@returnKind \${Q}' is not a known value kind. Known: \${[...it].map((ce) => \`'\${ce}'\`).join(", ")}.\`);
3543
+ } else if (H === "category") E.category = W;
3544
+ else if (H === "deprecated" || H === "hidden") {
3545
+ let Q = !0;
3546
+ const ce = W?.toLowerCase();
3547
+ ce === "false" ? Q = !1 : ce !== "true" && (Q = W), Q !== !1 && (E.deprecated = Q ?? !0, p.hidden = !0);
3548
+ }
3549
+ }
3550
+ }
3551
+ }
3552
+ }
3553
+ }
3554
+ Object.keys(p.returnType).length === 0 && delete p.returnType, Object.keys(D).length > 0 && (p.behavior = D), E.summary || m(u.name ?? u, _.MissingSummary, "warning", \`'\${g}': missing a description. Add a JSDoc comment above the function.\`);
3555
+ const q = !p.context, ee = q && E.name || g;
3556
+ if (q && !eo.test(ee)) {
3557
+ const B = E.name ? \`'@name \${E.name}'\` : \`'\${ee}'\`;
3558
+ a(u.name ?? u, _.InvalidName, \`'\${g}': \${B} cannot be called from a formula. A function name starts with a letter or '_', and continues with letters, digits, '_' or '.'.\` + (E.name ? "" : " Add an '@name' tag to register it under another name."));
3559
+ return;
3560
+ }
3561
+ if (q && !n?.isBuiltIn && no(ee)) {
3562
+ const B = E.name ? \`'@name \${E.name}'\` : \`'\${ee}'\`;
3563
+ a(u.name ?? u, _.InvalidName, \`'\${g}': \${B} cannot be called from a formula. It reads as a cell address.\` + (E.name ? "" : " Add an '@name' tag to register it under another name."));
3564
+ return;
3565
+ }
3566
+ const he = l.get(ee.toUpperCase());
3567
+ if (he !== void 0) {
3568
+ a(u.name ?? u, _.DuplicateName, \`'\${g}': '\${ee}' is already the name of '\${he}' in this module.\`);
3569
+ return;
3570
+ }
3571
+ if (l.set(ee.toUpperCase(), g), q && i?.has(ee.toUpperCase())) {
3572
+ a(u.name ?? u, _.BuiltInName, \`'\${ee}' is a built-in function. Choose a different name - a calculation function cannot replace a built-in.\`);
3573
+ return;
3574
+ }
3575
+ if (q) {
3576
+ const B = E.parameters ?? {};
3577
+ for (const [k, N] of Object.entries(B)) if (!G.has(k) && !N.description) {
3578
+ const ne = P.get(k);
3579
+ m(ne, _.MissingParamDescription, "warning", \`'\${g}': parameter '\${k}' is missing a description. Add an '@param \${k}' tag.\`);
3580
+ }
3581
+ }
3582
+ o.push([p, E]);
3583
+ } catch (C) {
3584
+ a(u, _.ParseError, \`'\${g}': \${C.message}\`);
3585
+ }
3586
+ }
3587
+ });
3588
+ } catch (u) {
3589
+ a(void 0, _.ParseError, \`Unable to analyze module: \${u?.message ?? u}\`);
3590
+ }
3591
+ return {
3592
+ functions: o,
3593
+ autoRun: c,
3594
+ diagnostics: s
3595
+ };
3596
+ }
3597
+ const Ge = "__SHEETXL";
3598
+ var lo = /* @__PURE__ */ rr({ initialize: () => so });
3599
+ async function so() {
3600
+ return xe || (xe = new Promise(async (e, t) => {
3601
+ try {
3602
+ const r = "0.20.2", n = \`https://esm.sh/esbuild-wasm@\${r}\`, i = \`https://esm.sh/esbuild-wasm@\${r}/esbuild.wasm\`, o = (await import(
3603
+ /* webpackIgnore: true */
3604
+ /* @vite-ignore */
3605
+ n
3606
+ )).default;
3607
+ await o.initialize({
3608
+ wasmURL: i,
3609
+ worker: !1
3610
+ }), e(o);
3611
+ } catch (r) {
3612
+ console.error("Error initializing esbuild:", r), xe = null, t(new Error("The script bundler could not be loaded. Check your connection and try again.", { cause: r }));
3613
+ }
3614
+ }), xe);
3615
+ }
3616
+ var xe, co = tr((() => {
3617
+ xe = null;
3618
+ }));
3619
+ let _e = null, je = null;
3620
+ async function uo() {
3621
+ if (_e) return _e;
3622
+ if (je) {
3623
+ if (await je, !_e) throw new Error("ESBuild initialization promise resolved, but instance is not available.");
3624
+ return _e;
3625
+ }
3626
+ let e, t;
3627
+ je = new Promise((r, n) => {
3628
+ e = r, t = n;
3629
+ });
3630
+ try {
3631
+ const { initialize: r } = await Promise.resolve().then(() => (co(), lo));
3632
+ return _e = await r(), e(), _e;
3633
+ } catch (r) {
3634
+ throw console.error("Failed to import or initialize esbuild:", r), je = null, t(r), r;
3635
+ }
3636
+ }
3637
+ const fo = { compilerOptions: { target: "esnext" } };
3638
+ async function po(e, t, r = "/script.js", n = Ge, i = !1) {
3639
+ try {
3640
+ const o = await uo(), l = "@sheetxl/primitives", s = \`
3641
+ export const FormulaContext = globalThis.\${n}?.FormulaContext;
3642
+ export const ScalarType = globalThis.\${n}?.ScalarType;
3643
+ export const Observable = globalThis.\${n}?.Observable;
3644
+ export const IRange = globalThis.\${n}?.IRange;
3645
+ export const FormulaError = globalThis.\${n}?.FormulaError;
3646
+ // Add more exports as needed
3647
+ \`, c = await o.build({
3648
+ entryPoints: [r],
3649
+ bundle: !0,
3650
+ write: !1,
3651
+ format: "esm",
3652
+ plugins: [{
3653
+ name: "sheetxl-esbuild-in-memory",
3654
+ setup(d) {
3655
+ const m = "sheetxl-" + (/* @__PURE__ */ new Date()).getTime();
3656
+ d.onResolve({ filter: new RegExp(\`^(\${r.replace("/", "\\\\/")}|\${l})$\`) }, (a) => ({
3657
+ path: a.path,
3658
+ namespace: m
3659
+ })), d.onResolve({ filter: /.*/ }, (a) => {
3660
+ if (a.namespace !== m) return console.warn(\`esbuild: Treating import "\${a.path}" as external.\`), {
3661
+ path: a.path,
3662
+ external: !0
3663
+ };
3664
+ }), d.onLoad({
3665
+ filter: /.*/,
3666
+ namespace: m
3667
+ }, (a) => {
3668
+ let f;
3669
+ if (a.path === r) f = t;
3670
+ else if (a.path === l) f = s;
3671
+ else return { errors: [{ text: \`Cannot load unknown path in \${m}: \${a.path}\` }] };
3672
+ return {
3673
+ contents: f,
3674
+ loader: "ts"
3675
+ };
3676
+ });
3677
+ }
3678
+ }],
3679
+ sourcemap: "inline",
3680
+ tsconfigRaw: fo,
3681
+ minify: i,
3682
+ platform: "neutral"
3683
+ });
3684
+ if (c.outputFiles && c.outputFiles.length > 0) return c.outputFiles[0].text;
3685
+ throw c.errors && c.errors.length > 0 ? /* @__PURE__ */ new Error(\`esbuild bundling failed: \${c.errors.map((d) => d.text).join(\`
3686
+ \`)}\`) : /* @__PURE__ */ new Error("esbuild did not produce an output file.");
3687
+ } catch (o) {
3688
+ throw console.error("esbuild bundling process failed:", o), o;
3689
+ }
3690
+ }
3691
+ function mo(e, t, r) {
3692
+ return (n) => {
3693
+ const i = n.factory, o = () => i.createExpressionStatement(i.createCallChain(i.createPropertyAccessExpression(i.createIdentifier(Ge), "checkRun"), i.createToken(e.SyntaxKind.QuestionDotToken), void 0, [i.createStringLiteral(t), i.createNumericLiteral(r)])), l = (a) => {
3694
+ const f = a.statements;
3695
+ let b = 0;
3696
+ for (; b < f.length && e.isExpressionStatement(f[b]) && e.isStringLiteral(f[b].expression);) b++;
3697
+ return i.updateBlock(a, [
3698
+ ...f.slice(0, b),
3699
+ o(),
3700
+ ...f.slice(b)
3701
+ ]);
3702
+ }, s = (a) => e.isBlock(a) ? l(a) : i.createBlock([o(), a], !0), c = (a) => e.isBlock(a) ? l(a) : i.createBlock([o(), i.createReturnStatement(a)], !0), d = (a) => e.isForStatement(a) || e.isForInStatement(a) || e.isForOfStatement(a) || e.isWhileStatement(a) || e.isDoStatement(a), m = (a) => {
3703
+ if (d(a)) {
3704
+ const f = a.statement;
3705
+ return e.visitEachChild(a, (b) => {
3706
+ const v = m(b);
3707
+ return b === f ? s(v) : v;
3708
+ }, n);
3709
+ }
3710
+ if (e.isFunctionLike(a) && a.body) {
3711
+ const f = a.body;
3712
+ return e.visitEachChild(a, (b) => {
3713
+ const v = m(b);
3714
+ return b === f ? c(v) : v;
3715
+ }, n);
3716
+ }
3717
+ return e.visitEachChild(a, m, n);
3718
+ };
3719
+ return (a) => e.visitNode(a, m);
3720
+ };
3721
+ }
3722
+ const Zt = "//# sourceMappingURL";
3723
+ var en = /* @__PURE__ */ rr({
3724
+ initialize: () => ho,
3725
+ readLibFile: () => go
3726
+ });
3727
+ async function ho() {
3728
+ return Te || (Te = new Promise(async (e, t) => {
3729
+ let r = null;
3730
+ try {
3731
+ r = await import(
3732
+ /* webpackIgnore: true */
3733
+ /* @vite-ignore */
3734
+ "https://esm.sh/typescript@5.7.2"
3735
+ );
3736
+ } catch (n) {
3737
+ console.error("Error initializing Browser TypeScript module:", n);
3738
+ }
3739
+ r || (console.log("use script fallback"), Te = null), e(r);
3740
+ }), Te);
3741
+ }
3742
+ function go(e, t) {}
3743
+ var Te, tn = tr((() => {
3744
+ Te = null;
3745
+ }));
3746
+ const yo = \`
3747
+ /**
3748
+ * Represents the completion of an asynchronous operation
3749
+ */
3750
+ interface Promise<T> {
3751
+ /**
3752
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
3753
+ * resolved value cannot be modified from the callback.
3754
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
3755
+ * @returns A Promise for the completion of the callback.
3756
+ */
3757
+ finally(onfinally?: (() => void) | undefined | null): Promise<T>;
3758
+ }
3759
+ \`, wo = \`
3760
+ interface FirstTest {
3761
+ isTrue?: boolean;
3762
+ }
3763
+ \`, So = async () => wo;
3764
+ let Ke = null;
3765
+ const ot = "sheetxl.d.ts", Qt = "sheetxl-modules.d.ts", bo = \`declare module '@sheetxl/primitives' { export = SheetXL; }
3766
+ \`, vo = [
3767
+ "lib.webworker.d.ts",
3768
+ "lib.es2020.d.ts",
3769
+ "lib.esnext.asynciterable.d.ts"
3770
+ ], er = /* @__PURE__ */ new Map();
3771
+ let at = null, lt = null;
3772
+ async function Eo() {
3773
+ return lt || (lt = Promise.resolve().then(() => (tn(), en)).then(async (e) => {
3774
+ const t = await rn();
3775
+ return e.readLibFile(t, "lib.es5.d.ts") !== void 0 ? e.readLibFile : null;
3776
+ })), lt;
3777
+ }
3778
+ async function rn() {
3779
+ if (Ke) return Ke;
3780
+ try {
3781
+ const e = await (await Promise.resolve().then(() => (tn(), en))).initialize();
3782
+ if (!e) throw new Error("TypeScript could not be loaded. Check your connection and try again.");
3783
+ return e;
3784
+ } catch (e) {
3785
+ throw Ke = null, e;
3786
+ } finally {
3787
+ Ke = null;
3788
+ }
3789
+ }
3790
+ async function _o(e) {
3791
+ const t = e?.source ?? null;
3792
+ if (!t) return {
3793
+ module: null,
3794
+ diagnostics: []
3795
+ };
3796
+ const r = (e.disableBundle || e.declarationsOnly) ?? !1, [n, i, o] = await Promise.all([
3797
+ So(),
3798
+ rn(),
3799
+ e.ambientTypes ? Eo() : null
3800
+ ]), l = o ? e.ambientTypes ?? null : null;
3801
+ let s = "";
3802
+ const c = {
3803
+ allowJs: !0,
3804
+ declaration: !1,
3805
+ sourceMap: !1,
3806
+ inlineSourceMap: !1,
3807
+ inlineSources: !1,
3808
+ isolatedModules: !0,
3809
+ preserveConstEnums: !1,
3810
+ module: 99,
3811
+ noResolve: !0,
3812
+ emitDeclarationOnly: !1,
3813
+ target: i.ScriptTarget.ES2020,
3814
+ ...l ? {
3815
+ lib: vo,
3816
+ skipLibCheck: !0,
3817
+ strict: !0
3818
+ } : {}
3819
+ }, d = "script", m = \`\${d}.ts\`, a = "lib.d.ts", f = "global.d.ts", b = {
3820
+ [m]: t,
3821
+ [a]: yo,
3822
+ [f]: n,
3823
+ ...l ? {
3824
+ [ot]: l,
3825
+ [Qt]: bo
3826
+ } : {}
3827
+ }, v = (p) => b[p] ?? (o && p.startsWith("lib.") ? o(i, p) : void 0), A = {
3828
+ getSourceFile: (p, E, C, O) => {
3829
+ if (p === ot) return at?.text !== l && (at = {
3830
+ text: l,
3831
+ file: i.createSourceFile(p, l, i.ScriptTarget.Latest, !1)
3832
+ }), at.file;
3833
+ if (b[p] === void 0) {
3834
+ let j = er.get(p);
3835
+ if (!j) {
3836
+ const D = v(p);
3837
+ if (D === void 0) return;
3838
+ j = i.createSourceFile(p, D, i.ScriptTarget.Latest, !1), er.set(p, j);
3839
+ }
3840
+ return j;
3841
+ }
3842
+ return i.createSourceFile(p, b[p], i.ScriptTarget.Latest, !0);
3843
+ },
3844
+ fileExists: (p) => v(p) !== void 0,
3845
+ readFile: v,
3846
+ writeFile: (p, E) => {
3847
+ b[p] = E;
3848
+ },
3849
+ getCurrentDirectory: () => "./",
3850
+ getCanonicalFileName: (p) => p,
3851
+ useCaseSensitiveFileNames: () => !0,
3852
+ getDefaultLibFileName: (p) => a,
3853
+ getNewLine: () => \`
3854
+ \`
3855
+ }, U = i.createProgram([
3856
+ m,
3857
+ f,
3858
+ ...l ? [ot, Qt] : []
3859
+ ], c, A), h = U.getTypeChecker(), w = U.getSourceFile(m), S = e.runGuard;
3860
+ U.emit(void 0, void 0, void 0, void 0, S ? { before: [mo(i, S.key, S.timeoutMs)] } : void 0), s = b[\`\${d}.js\`] ?? "";
3861
+ const F = (p) => ({
3862
+ start: p.start ?? 0,
3863
+ length: p.length ?? 0,
3864
+ severity: p.category === i.DiagnosticCategory.Warning ? "warning" : "error",
3865
+ code: \`TS\${p.code}\`,
3866
+ message: i.flattenDiagnosticMessageText(p.messageText, \`
3867
+ \`)
3868
+ }), z = U.getSyntacticDiagnostics(w).map(F), L = l ? U.getSemanticDiagnostics(w).filter((p) => p.category === i.DiagnosticCategory.Error || p.category === i.DiagnosticCategory.Warning).map(F) : [], R = ao(i, w, h, {
3869
+ builtInNames: e.builtInNames,
3870
+ isBuiltIn: e.isBuiltIn,
3871
+ lenient: e.lenient
3872
+ });
3873
+ let M = [
3874
+ ...z,
3875
+ ...L,
3876
+ ...R.diagnostics
3877
+ ];
3878
+ e.lenient && (M = M.filter((p) => p.code !== _.MissingType));
3879
+ const pe = R.functions, Y = R.autoRun, We = M.some((p) => p.severity === "error"), Je = \`\${nr.uuidV4()}-script\`;
3880
+ let u = null;
3881
+ if (We) s = "";
3882
+ else {
3883
+ try {
3884
+ r || (s = await po(i, s, d, void 0, e.minify ?? !1));
3885
+ } catch {
3886
+ console.warn("Error bundling script");
3887
+ }
3888
+ const p = s.indexOf(Zt);
3889
+ p > -1 && (u = s.substring(p + 20 + 1, s.length), s = s.substring(0, p), s = s.replaceAll("globalThis." + Ge, Ge));
3890
+ }
3891
+ const g = {
3892
+ functions: pe,
3893
+ commitId: Je,
3894
+ source: t,
3895
+ language: "typescript",
3896
+ compiled: s
3897
+ };
3898
+ return u && (g.sourceMap = u), Y && (g.autoRun = Y), {
3899
+ module: g,
3900
+ diagnostics: M
3901
+ };
3902
+ }
3903
+ self.addEventListener("message", async (e) => {
3904
+ const { id: t, params: r } = e.data;
3905
+ try {
3906
+ const n = await _o(r);
3907
+ self.postMessage({
3908
+ id: t,
3909
+ result: n,
3910
+ error: null
3911
+ });
3912
+ } catch (n) {
3913
+ self.postMessage({
3914
+ id: t,
3915
+ result: null,
3916
+ error: {
3917
+ message: n.message,
3918
+ stack: n.stack,
3919
+ cause: n.cause
3920
+ }
3921
+ });
3922
+ }
3923
+ });
3924
+ `, a = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", s], { type: "text/javascript;charset=utf-8" });
3925
+ function d(t) {
3926
+ let n;
3927
+ try {
3928
+ if (n = a && (self.URL || self.webkitURL).createObjectURL(a), !n) throw "";
3929
+ const e = new Worker(n, { type: "module", name: t?.name });
3930
+ return e.addEventListener("error", () => {
3931
+ (self.URL || self.webkitURL).revokeObjectURL(n);
3932
+ }), e;
3933
+ } catch {
3934
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(s), { type: "module", name: t?.name });
3935
+ }
3936
+ }
3937
+ async function m() {
3938
+ if (globalThis.process?.versions?.node && typeof Worker > "u") return await l();
3939
+ if (typeof Worker < "u") {
3940
+ const t = new c(() => new d());
3941
+ try {
3942
+ return await t.start(), t;
3943
+ } catch (n) {
3944
+ console.error("Failed to start TypescriptCompiler worker reverting to fallback:", n);
3945
+ }
3946
+ }
3947
+ return await l();
3948
+ }
3949
+ var l = async () => {
3950
+ const { compileModule: t } = await import("./BPtHkO7z1Di3YIjV.mjs"), n = new u((e) => t(e));
3951
+ return await n.start(), n;
3952
+ };
3953
+ export {
3954
+ m as createCompilerWorker
3955
+ };