@sheetxl/scripting 0.8.0-beta.2 → 0.8.0-beta.21

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