@sheetxl/scripting 0.7.27 → 0.7.28-beta.1
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.
- package/README.md +206 -247
- package/browser/cjs/1_xhnTjP6m5oj6za.cjs +21 -0
- package/browser/cjs/Bu4cZ8iSZ3rij-oV.cjs +1 -0
- package/browser/cjs/BvG8N7G_8CXIAlT-.cjs +1 -0
- package/browser/cjs/C_7w8EJZpHw8ueuq.cjs +1 -0
- package/browser/cjs/C_IEgjM-hSJCv6Gm.cjs +1 -0
- package/browser/cjs/CctaCN_w3o34V9AR.cjs +1 -0
- package/browser/cjs/DSEShe7kGtxvljOr.cjs +1 -0
- package/browser/cjs/btgKzY3qMXIaaNlB.cjs +1 -0
- package/browser/cjs/g7NzVvjLm_oCf_dd.cjs +1 -0
- package/browser/cjs/index.cjs +1 -6
- package/browser/cjs/qWYyYsBboXc9p0Lw.cjs +7 -0
- package/browser/esm/3M5kvBOeC9dO1anl.mjs +12 -0
- package/browser/esm/BO33MdJ1knSwnDFc.mjs +421 -0
- package/browser/esm/Buk8t7jbvkBl210h.mjs +25 -0
- package/browser/esm/DEMLy75ghnJrOdbg.mjs +23 -0
- package/browser/esm/D_RaFJ9L6p0FWrsc.mjs +87 -0
- package/browser/esm/DkclmJ-rIJcNsfWQ.mjs +27 -0
- package/browser/esm/DqlXZuvMsFv7k9Op.mjs +105 -0
- package/browser/esm/S3dk0h6UOMvLEQYW.mjs +152 -0
- package/browser/esm/SJ37xnNH-b4AhQOe.mjs +8 -0
- package/browser/esm/index.mjs +40 -20
- package/browser/esm/xhrsKI0xcttmWNAI.mjs +15 -0
- package/node/esm/BvEpRtUTq_sFtAnk.mjs +421 -0
- package/node/esm/BzB380N0KvPvx3Va.mjs +23 -0
- package/node/esm/CYHVS16ZrqxOoRVQ.mjs +17 -0
- package/node/esm/CcqVU5-hFGk6MS45.mjs +27 -0
- package/node/esm/DBuGDPGKGMJGN0-R.mjs +12 -0
- package/node/esm/Dx2TL-2TFdOTGPZo.mjs +14 -0
- package/node/esm/SJ37xnNH-b4AhQOe.mjs +8 -0
- package/node/esm/fVQ1ZTi1igB3_IOU.mjs +152 -0
- package/node/esm/index.mjs +144 -20
- package/package.json +11 -8
- package/types/index.d.ts +2 -165
- package/types/src/ScriptCompiler.d.ts +40 -0
- package/types/src/compiler/Bundler.d.ts +7 -0
- package/types/src/compiler/TypescriptCompiler.d.ts +27 -0
- package/types/src/compiler/TypescriptCompiler.impl.d.ts +17 -0
- package/types/src/compiler/TypescriptCompiler.worker.d.ts +2 -0
- package/types/src/compiler/compiler.browser.d.ts +8 -0
- package/types/src/compiler/compiler.node.d.ts +14 -0
- package/types/src/compiler/constants.d.ts +10 -0
- package/types/src/compiler/insertYieldBetweenStatements.d.ts +5 -0
- package/types/src/compiler/transformAwaitToYield.d.ts +6 -0
- package/types/src/index.d.ts +7 -0
- package/types/src/lib/esbuild/esbuild.browser.d.ts +4 -0
- package/types/src/lib/esbuild/esbuild.node.d.ts +11 -0
- package/types/src/lib/typescript/typescript.browser.d.ts +4 -0
- package/types/src/lib/typescript/typescript.node.d.ts +4 -0
- package/types/src/linter/Linter.d.ts +63 -0
- package/types/src/linter/index.d.ts +2 -0
- package/types/src/loader/index.d.ts +2 -0
- package/types/src/loader/loadCompiledModule.d.ts +19 -0
- package/types/src/loader/moduleLoader.browser.d.ts +11 -0
- package/types/src/loader/moduleLoader.node.d.ts +15 -0
- package/types/src/plugin/generate.d.ts +17 -0
- package/types/src/plugin/vite.d.ts +24 -0
- package/types/src/runtime/Constants.d.ts +9 -0
- package/types/src/runtime/index.d.ts +2 -0
- package/types/src/tags/DocTags.d.ts +46 -0
- package/types/src/tags/index.d.ts +2 -0
- package/types/src/type/CompileOptions.d.ts +58 -0
- package/types/src/type/CompiledModule.d.ts +70 -0
- package/types/src/type/Diagnostic.d.ts +120 -0
- package/types/src/type/Types.d.ts +72 -0
- package/types/src/type/index.d.ts +6 -0
- package/types/src/worker/WorkerWrapper.d.ts +44 -0
- package/types/src/worker/index.d.ts +2 -0
- package/browser/cjs/B4lAANRqTGnvOqGs.cjs +0 -1518
- package/browser/cjs/BRnBwa7X_-2hZkPR.cjs +0 -6
- package/browser/cjs/BgmE5dDR60P-0D05.cjs +0 -6
- package/browser/cjs/C6FgXFuZyUBSYx74.cjs +0 -6
- package/browser/cjs/Cmsp48m0ZoKEApI_.cjs +0 -32
- package/browser/esm/BCtqf7TlVX2XI9Sk.mjs +0 -29
- package/browser/esm/BUrlmQqFvt49Snxt.mjs +0 -1593
- package/browser/esm/BeDi9Rjq6Mj_zC_O.mjs +0 -24
- package/browser/esm/C1nmZG6Nh598I5Cy.mjs +0 -266
- package/browser/esm/C9oTtQ5kcPvveo9r.mjs +0 -21
- package/node/esm/B8mFYKKfM-fFEqr4.mjs +0 -1593
- package/node/esm/D3tC0pmcUWYhM3aH.mjs +0 -14
- package/node/esm/DUk3E5XxCEk6dBja.mjs +0 -16
- package/node/esm/Db6wgeAGcGPbeesO.mjs +0 -266
- package/node/esm/YSXanagcUr6QMDaF.mjs +0 -29
|
@@ -1,1593 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license @sheetxl/scripting - Scripting - Scripting engine for Macros and formulas; includes TypeScript and EsBuild. - v0.7.27
|
|
3
|
-
*
|
|
4
|
-
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
5
|
-
* License: The license can be found at https://www.sheetxl.com/license.
|
|
6
|
-
*/
|
|
7
|
-
let c = class {
|
|
8
|
-
constructor(e) {
|
|
9
|
-
this._worker = null, this._nextId = 1, this._pendingRequests = /* @__PURE__ */ new Map(), this._workerFactory = e;
|
|
10
|
-
}
|
|
11
|
-
start() {
|
|
12
|
-
if (typeof Worker > "u") throw new Error("Web Workers are not supported in this environment.");
|
|
13
|
-
return this._worker || (this._worker = this._workerFactory(), this._worker.onmessage = (e) => {
|
|
14
|
-
const { id: n, result: t, error: r } = e.data, o = this._pendingRequests.get(n);
|
|
15
|
-
if (o) if (this._pendingRequests.delete(n), r) {
|
|
16
|
-
const a = new Error(r.message);
|
|
17
|
-
a.stack = r.stack, r.cause && (a.cause = r.cause), o.reject(a);
|
|
18
|
-
} else o.resolve(t);
|
|
19
|
-
}, this._worker.onerror = (e) => {
|
|
20
|
-
console.error("Worker error:", e), this._pendingRequests.forEach((n) => {
|
|
21
|
-
n.reject(new Error(`Worker failed: ${e.message}`));
|
|
22
|
-
}), this._pendingRequests.clear(), this._worker = null;
|
|
23
|
-
}), Promise.resolve();
|
|
24
|
-
}
|
|
25
|
-
execute(e) {
|
|
26
|
-
if (!this._worker) throw new Error("Worker is not initialized. Call start() first.");
|
|
27
|
-
const n = this._nextId++;
|
|
28
|
-
return new Promise((t, r) => {
|
|
29
|
-
this._pendingRequests.set(n, { resolve: t, reject: r }), this._worker.postMessage({ id: n, params: e });
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
terminate() {
|
|
33
|
-
this._worker && (this._worker.terminate(), this._worker = null);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
class u {
|
|
37
|
-
constructor(n) {
|
|
38
|
-
this._onExecute = n;
|
|
39
|
-
}
|
|
40
|
-
execute(n) {
|
|
41
|
-
return this._onExecute(n);
|
|
42
|
-
}
|
|
43
|
-
start() {
|
|
44
|
-
return Promise.resolve();
|
|
45
|
-
}
|
|
46
|
-
terminate() {
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const s = `/**
|
|
50
|
-
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.7.27
|
|
51
|
-
*
|
|
52
|
-
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
53
|
-
* License: The license can be found at https://www.sheetxl.com/license.
|
|
54
|
-
*/
|
|
55
|
-
const W = { Number: "n", String: "s", Boolean: "b", Error: "e", Null: "z" };
|
|
56
|
-
var Ae, le, d;
|
|
57
|
-
(le = Ae || (Ae = {})).Orientation = { Column: "column", Row: "row" }, le.Orientations = { ...le.Orientation, Both: "both" }, le.Direction = { Up: "up", Down: "down", Left: "left", Right: "right" }, ((e) => {
|
|
58
|
-
e.Code = { Parse: 0, Null: 1, Div0: 2, Value: 3, Ref: 4, Name: 5, Num: 6, NA: 7, GettingData: 8, Spill: 9, Connect: 10, Blocked: 11, Unknown: 12, Field: 13, Calc: 14, Busy: 16, Python: 19, Timeout: 20 }, e.Label = { Parse: "#PARSE!", Null: "#NULL!", Div0: "#DIV/0!", Value: "#VALUE!", Ref: "#REF!", Name: "#NAME?", Num: "#NUM!", NA: "#N/A", GettingData: "#GETTING_DATA", Spill: "#SPILL!", Connect: "#CONNECT!", Blocked: "#BLOCKED!", Unknown: "#UNKNOWN!", Field: "#FIELD!", Calc: "#CALC!", Busy: "#BUSY!", Python: "#PYTHON!", Timeout: "#TIMEOUT!" };
|
|
59
|
-
class t extends Error {
|
|
60
|
-
constructor(u, h, pe, $) {
|
|
61
|
-
super(pe, $), this._label = h, this._code = u, this.details = $;
|
|
62
|
-
}
|
|
63
|
-
static {
|
|
64
|
-
this.code = e.Code.Unknown;
|
|
65
|
-
}
|
|
66
|
-
get isFormulaError() {
|
|
67
|
-
return !0;
|
|
68
|
-
}
|
|
69
|
-
getLabel() {
|
|
70
|
-
return this._label;
|
|
71
|
-
}
|
|
72
|
-
getCode() {
|
|
73
|
-
return this._code;
|
|
74
|
-
}
|
|
75
|
-
equals(u) {
|
|
76
|
-
return !!u && (this._code === u._code || this._code === u.code);
|
|
77
|
-
}
|
|
78
|
-
get [Symbol.toStringTag]() {
|
|
79
|
-
return "[FormulaError]";
|
|
80
|
-
}
|
|
81
|
-
toString() {
|
|
82
|
-
return this.message || this._label;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
e.Known = t;
|
|
86
|
-
class n extends t {
|
|
87
|
-
constructor(u, h) {
|
|
88
|
-
super(e.Code.Parse, e.Label.Parse, u, h);
|
|
89
|
-
}
|
|
90
|
-
static {
|
|
91
|
-
this.code = e.Code.Parse;
|
|
92
|
-
}
|
|
93
|
-
getDetails() {
|
|
94
|
-
const u = this.details;
|
|
95
|
-
return { line: u?.line ?? 1, column: u?.column ?? 1, offset: u?.offset ?? 0, length: u?.length ?? 0 };
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
e.Parse = n;
|
|
99
|
-
class r extends t {
|
|
100
|
-
constructor(u, h) {
|
|
101
|
-
super(e.Code.Null, e.Label.Null, u, h);
|
|
102
|
-
}
|
|
103
|
-
static {
|
|
104
|
-
this.code = e.Code.Null;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
e.Null = r;
|
|
108
|
-
class o extends t {
|
|
109
|
-
constructor(u, h) {
|
|
110
|
-
super(e.Code.Div0, e.Label.Div0, u, h);
|
|
111
|
-
}
|
|
112
|
-
static {
|
|
113
|
-
this.code = e.Code.Div0;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
e.Div0 = o;
|
|
117
|
-
class a extends t {
|
|
118
|
-
constructor(u, h) {
|
|
119
|
-
super(e.Code.Value, e.Label.Value, u, h);
|
|
120
|
-
}
|
|
121
|
-
static {
|
|
122
|
-
this.code = e.Code.Value;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
e.Value = a;
|
|
126
|
-
class i extends t {
|
|
127
|
-
constructor(u, h) {
|
|
128
|
-
super(e.Code.Ref, e.Label.Ref, u, h);
|
|
129
|
-
}
|
|
130
|
-
static {
|
|
131
|
-
this.code = e.Code.Ref;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
e.Ref = i;
|
|
135
|
-
class l extends t {
|
|
136
|
-
constructor(u, h) {
|
|
137
|
-
super(e.Code.Name, e.Label.Name, u, h);
|
|
138
|
-
}
|
|
139
|
-
static {
|
|
140
|
-
this.code = e.Code.Name;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
e.Name = l;
|
|
144
|
-
class s extends t {
|
|
145
|
-
constructor(u, h) {
|
|
146
|
-
super(e.Code.Num, e.Label.Num, u, h);
|
|
147
|
-
}
|
|
148
|
-
static {
|
|
149
|
-
this.code = e.Code.Num;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
e.Num = s;
|
|
153
|
-
class p extends t {
|
|
154
|
-
constructor(u, h) {
|
|
155
|
-
super(e.Code.NA, e.Label.NA, u, h);
|
|
156
|
-
}
|
|
157
|
-
static {
|
|
158
|
-
this.code = e.Code.NA;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
e.NA = p;
|
|
162
|
-
class w extends t {
|
|
163
|
-
constructor(u, h) {
|
|
164
|
-
super(e.Code.GettingData, e.Label.GettingData, u, h);
|
|
165
|
-
}
|
|
166
|
-
static {
|
|
167
|
-
this.code = e.Code.GettingData;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
e.GettingData = w;
|
|
171
|
-
class g extends t {
|
|
172
|
-
constructor(u, h) {
|
|
173
|
-
super(e.Code.Spill, e.Label.Spill, u, h);
|
|
174
|
-
}
|
|
175
|
-
static {
|
|
176
|
-
this.code = e.Code.Spill;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
e.Spill = g;
|
|
180
|
-
class f extends t {
|
|
181
|
-
constructor(u, h) {
|
|
182
|
-
super(e.Code.Connect, e.Label.Connect, u, h);
|
|
183
|
-
}
|
|
184
|
-
static {
|
|
185
|
-
this.code = e.Code.Connect;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
e.Connect = f;
|
|
189
|
-
class y extends t {
|
|
190
|
-
constructor(u, h) {
|
|
191
|
-
super(e.Code.Blocked, e.Label.Blocked, u, h);
|
|
192
|
-
}
|
|
193
|
-
static {
|
|
194
|
-
this.code = e.Code.Blocked;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
e.Blocked = y;
|
|
198
|
-
class x extends t {
|
|
199
|
-
constructor(u, h) {
|
|
200
|
-
super(e.Code.Unknown, e.Label.Unknown, u, h);
|
|
201
|
-
}
|
|
202
|
-
static {
|
|
203
|
-
this.code = e.Code.Unknown;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
e.Unknown = x;
|
|
207
|
-
class A extends t {
|
|
208
|
-
constructor(u, h) {
|
|
209
|
-
super(e.Code.Field, e.Label.Field, u, h);
|
|
210
|
-
}
|
|
211
|
-
static {
|
|
212
|
-
this.code = e.Code.Field;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
e.Field = A;
|
|
216
|
-
class U extends t {
|
|
217
|
-
constructor(u, h) {
|
|
218
|
-
super(e.Code.Calc, e.Label.Calc, u, h);
|
|
219
|
-
}
|
|
220
|
-
static {
|
|
221
|
-
this.code = e.Code.Calc;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
e.Calc = U;
|
|
225
|
-
class B extends t {
|
|
226
|
-
constructor(u, h) {
|
|
227
|
-
super(e.Code.Busy, e.Label.Busy, u, h);
|
|
228
|
-
}
|
|
229
|
-
static {
|
|
230
|
-
this.code = e.Code.Busy;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
e.Busy = B;
|
|
234
|
-
class O extends t {
|
|
235
|
-
constructor(u, h) {
|
|
236
|
-
super(e.Code.Python, e.Label.Python, u, h);
|
|
237
|
-
}
|
|
238
|
-
static {
|
|
239
|
-
this.code = e.Code.Python;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
e.Python = O;
|
|
243
|
-
class J extends t {
|
|
244
|
-
constructor(u, h) {
|
|
245
|
-
super(e.Code.Timeout, e.Label.Timeout, u, h);
|
|
246
|
-
}
|
|
247
|
-
static {
|
|
248
|
-
this.code = e.Code.Timeout;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
e.Timeout = J;
|
|
252
|
-
})(d || (d = {}));
|
|
253
|
-
const T = {};
|
|
254
|
-
T[d.Code.Parse] = d.Parse, T[d.Code.Null] = d.Null, T[d.Code.Div0] = d.Div0, T[d.Code.Value] = d.Value, T[d.Code.Ref] = d.Ref, T[d.Code.Name] = d.Name, T[d.Code.Num] = d.Num, T[d.Code.NA] = d.NA, T[d.Code.GettingData] = d.GettingData, T[d.Code.Spill] = d.Spill, T[d.Code.Connect] = d.Connect, T[d.Code.Blocked] = d.Blocked, T[d.Code.Unknown] = d.Unknown, T[d.Code.Field] = d.Field, T[d.Code.Calc] = d.Calc, T[d.Code.Busy] = d.Busy, T[d.Code.Python] = d.Python, T[d.Code.Timeout] = d.Timeout;
|
|
255
|
-
const at = /* @__PURE__ */ new Map(), Ie = /* @__PURE__ */ new Map(), it = /* @__PURE__ */ new Map(), lt = /* @__PURE__ */ new Map(), Me = Object.keys(T);
|
|
256
|
-
for (let e = 0; e < Me.length; e++) {
|
|
257
|
-
const t = Me[e], n = T[t];
|
|
258
|
-
it.set(d.Label[t], n), lt.set(d.Code[t], n);
|
|
259
|
-
const r = new n();
|
|
260
|
-
at.set(r.getLabel(), r), Ie.set(r.getCode(), r);
|
|
261
|
-
}
|
|
262
|
-
const Tt = Ie.get(d.Code.Unknown);
|
|
263
|
-
var v;
|
|
264
|
-
(v = d || (d = {})).BuiltIn = { Parse: new v.Parse(), Null: new v.Null(), Div0: new v.Div0(), Value: new v.Value(), Ref: new v.Ref(), Name: new v.Name(), Num: new v.Num(), NA: new v.NA(), GettingData: new v.GettingData(), Spill: new v.Spill(), Connect: new v.Connect(), Blocked: new v.Blocked(), Unknown: new v.Unknown(), Field: new v.Field(), Calc: new v.Calc(), Busy: new v.Busy(), Python: new v.Python(), Timeout: new v.Timeout() }, v.getBuiltInByLabel = (e) => at.get(e), v.newTypedError = (e, t, n) => {
|
|
265
|
-
let r;
|
|
266
|
-
return r = typeof e == "string" ? it.get(e) : lt.get(e), r || (r = v.Unknown), new r(t, n);
|
|
267
|
-
}, v.getBuiltInById = (e) => Ie.get(e) || Tt;
|
|
268
|
-
/**
|
|
269
|
-
* @license @sheetxl/utils - Utils - Utilities used by most SheetXL components. - v0.7.27
|
|
270
|
-
*
|
|
271
|
-
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
272
|
-
* License: The license can be found at https://www.sheetxl.com/license.
|
|
273
|
-
*/
|
|
274
|
-
const P = { Column: "column", Row: "row" }, _t = Object.freeze({ colIndex: 0, rowIndex: 0 }), Ot = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), st = (e, t) => e.colStart === t.colStart ? e.rowStart - t.rowStart : e.colStart - t.colStart, ct = (e, t) => e.rowStart === t.rowStart ? e.colStart - t.colStart : e.rowStart - t.rowStart, It = (e, t) => e.rowEnd === t.rowEnd ? t.colEnd - e.colEnd : t.rowEnd - e.rowEnd, Nt = (e, t) => e.colEnd === t.colEnd ? t.rowEnd - e.rowEnd : t.colEnd - e.colEnd, je = (e, t) => e.colIndex === t.colIndex ? e.rowIndex - t.rowIndex : e.colIndex - t.colIndex, Pe = (e, t) => e.rowIndex === t.rowIndex ? e.colIndex - t.colIndex : e.rowIndex - t.rowIndex, Fe = (e, t) => e.rowIndex === t.rowIndex ? t.colIndex - e.colIndex : t.rowIndex - e.rowIndex, De = (e, t) => e.colIndex === t.colIndex ? t.rowIndex - e.rowIndex : t.colIndex - e.colIndex, ut = (e = P.Row, t = !1) => t ? e !== P.Column ? It : Nt : e !== P.Column ? ct : st, Ue = (e, t) => e === t || !(!e || !t) && e.rowIndex === t.rowIndex && e.colIndex === t.colIndex, ve = (e, t) => e === t || !(!e || !t) && e.rowStart === t.rowStart && e.rowEnd === t.rowEnd && e.colStart === t.colStart && e.colEnd === t.colEnd, Te = (e, t) => !(!e || !t) && !(e.colStart > t.colEnd || t.colStart > e.colEnd) && !(e.rowStart > t.rowEnd || t.rowStart > e.rowEnd), Be = (e, t) => {
|
|
275
|
-
if (e === t) return !0;
|
|
276
|
-
if (!e || !t || e.length !== t.length) return !1;
|
|
277
|
-
for (let n = 0; n < e.length; n++) if (!ve(e[n], t[n])) return !1;
|
|
278
|
-
return !0;
|
|
279
|
-
}, ye = (e, t, n) => {
|
|
280
|
-
if (!e && !t) return null;
|
|
281
|
-
if (!e) return n ? t : { ...t };
|
|
282
|
-
if (!t) return n ? e : { ...e };
|
|
283
|
-
const r = Math.min(e.colStart, t.colStart), o = Math.min(e.rowStart, t.rowStart), a = Math.max(e.colEnd, t.colEnd), i = Math.max(e.rowEnd, t.rowEnd);
|
|
284
|
-
let l = n;
|
|
285
|
-
return l ? (l.colStart = r, l.rowStart = o, l.colEnd = a, l.rowEnd = i) : l = { colStart: r, rowStart: o, colEnd: a, rowEnd: i }, l;
|
|
286
|
-
}, $e = (e, t) => {
|
|
287
|
-
if (!t || t.length === 0) return e;
|
|
288
|
-
const n = { ...e };
|
|
289
|
-
for (let r = 0; r < t.length; r++) {
|
|
290
|
-
const o = t[r];
|
|
291
|
-
Te(n, o) && (n.rowStart = Math.min(n.rowStart, o.rowStart), n.colStart = Math.min(n.colStart, o.colStart), n.rowEnd = Math.max(n.rowEnd, o.rowEnd), n.colEnd = Math.max(n.colEnd, o.colEnd));
|
|
292
|
-
}
|
|
293
|
-
return n;
|
|
294
|
-
}, Rt = [null, null], kt = (e, t, n) => {
|
|
295
|
-
if (e[0].value === e[1].value) return t;
|
|
296
|
-
};
|
|
297
|
-
function ze(e, t = 2, n, r = P.Row, o) {
|
|
298
|
-
let a = [...e];
|
|
299
|
-
if (t <= 0 || e.length <= 1) return a;
|
|
300
|
-
let i = r === P.Column, l = 0, s = !1;
|
|
301
|
-
do {
|
|
302
|
-
const p = a.sort(ut(i ? P.Row : P.Column));
|
|
303
|
-
a = [], a.push(p[0]);
|
|
304
|
-
const w = p.length;
|
|
305
|
-
let g = 0, f = p[0], y = f.colStart, x = f.rowStart, A = f.colEnd, U = f.rowEnd;
|
|
306
|
-
for (let B = 1; B < w; B++) {
|
|
307
|
-
const O = p[B];
|
|
308
|
-
let J = !1;
|
|
309
|
-
if (J = i ? f && x === O.rowStart && U === O.rowEnd && A + 1 === O.colStart : f && y === O.colStart && A === O.colEnd && U + 1 === O.rowStart, J) {
|
|
310
|
-
let b = { colStart: y, rowStart: x, colEnd: i ? O.colEnd : A, rowEnd: i ? U : O.rowEnd };
|
|
311
|
-
if (f.value !== void 0 && (b.value = f.value), n) {
|
|
312
|
-
const u = o ?? [null, null];
|
|
313
|
-
u[0] = f, u[1] = O, b = n(u, b, r);
|
|
314
|
-
}
|
|
315
|
-
if (b) {
|
|
316
|
-
a[g] = b, s = !0, f = b, y = f.colStart, x = f.rowStart, A = f.colEnd, U = f.rowEnd;
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
a[++g] = O, f = O, y = f.colStart, x = f.rowStart, A = f.colEnd, U = f.rowEnd;
|
|
321
|
-
}
|
|
322
|
-
l++, i = !i, l === 1 && (s = !0);
|
|
323
|
-
} while (l < t && s && a.length > 1);
|
|
324
|
-
return a;
|
|
325
|
-
}
|
|
326
|
-
Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: _t, EmptyRange: Ot, cellToRange: (e, t) => {
|
|
327
|
-
if (!e) return null;
|
|
328
|
-
let n = t;
|
|
329
|
-
return n || (n = { ...e }, delete n.colIndex, delete n.rowIndex), n.colStart = e.colIndex ?? 0, n.rowStart = e.rowIndex ?? 0, n.colEnd = e.colIndex ?? 0, n.rowEnd = e.rowIndex ?? 0, n;
|
|
330
|
-
}, columnFirstCellComparator: je, columnFirstRangeComparator: st, createCellComparator: (e = P.Row, t = !1) => t ? e !== P.Column ? Fe : De : e !== P.Column ? Pe : je, createConflatingRanges: (e, t = !1) => {
|
|
331
|
-
const n = [];
|
|
332
|
-
let r, o, a = Number.MIN_SAFE_INTEGER, i = Number.MIN_SAFE_INTEGER;
|
|
333
|
-
return { append: (l, s, p) => {
|
|
334
|
-
let w = !0;
|
|
335
|
-
const g = p !== void 0;
|
|
336
|
-
if (g) {
|
|
337
|
-
const x = e ? e(o, p, t) : o === p ? p : void 0;
|
|
338
|
-
x === void 0 ? w = !1 : p = x;
|
|
339
|
-
}
|
|
340
|
-
if (w && s === i + 1 && l === a) return t ? r.rowEnd = s : r.colEnd = s, i = s, void (o = p);
|
|
341
|
-
r && n.push(r);
|
|
342
|
-
const f = t ? l : s, y = t ? s : l;
|
|
343
|
-
r = { colStart: f, rowStart: y, colEnd: f, rowEnd: y }, g && (r.value = p), a = l, i = s, o = p;
|
|
344
|
-
}, done: (l) => (r && (n.push(r), r = null), l ? ze(n, 3, l === !0 ? kt : l, t ? P.Column : P.Row, Rt) : n) };
|
|
345
|
-
}, createRangeComparator: ut, defaultRange: (e, t, n) => e ? n ? (n.colStart = e.colStart ?? t.colStart, n.rowStart = e.rowStart ?? t.rowStart, n.colEnd = e.colEnd ?? t.colEnd, n.rowEnd = e.rowEnd ?? t.rowEnd, n) : { colStart: e.colStart ?? t.colStart, rowStart: e.rowStart ?? t.rowStart, colEnd: e.colEnd ?? t.colEnd, rowEnd: e.rowEnd ?? t.rowEnd } : t, extendRangeToIntersectingRanges: $e, extendRangeToUnionRanges: (e, t) => {
|
|
346
|
-
if (!t || t.length === 0) return e;
|
|
347
|
-
let n = e, r = null;
|
|
348
|
-
for (; !ve(n, r); ) r = n, n = $e(r, t);
|
|
349
|
-
return n;
|
|
350
|
-
}, indexOfCoords: (e, t) => {
|
|
351
|
-
const n = { colStart: e.colIndex, rowStart: e.rowIndex, colEnd: e.colIndex, rowEnd: e.rowIndex };
|
|
352
|
-
for (let r = t.length - 1; r >= 0; r--) if (Te(n, t[r])) return r;
|
|
353
|
-
return -1;
|
|
354
|
-
}, intersectRanges: (e, t, n) => {
|
|
355
|
-
if (!e) return n ? t : { ...t };
|
|
356
|
-
if (!t) return n ? e : { ...e };
|
|
357
|
-
if (!e && !t || e.rowStart > t.rowEnd || e.rowEnd < t.rowStart || e.colStart > t.colEnd || e.colEnd < t.colStart) return null;
|
|
358
|
-
const r = Math.max(e.colStart, t.colStart), o = Math.max(e.rowStart, t.rowStart), a = Math.min(e.colEnd, t.colEnd), i = Math.min(e.rowEnd, t.rowEnd);
|
|
359
|
-
let l = n;
|
|
360
|
-
return l ? (l.colStart = r, l.rowStart = o, l.colEnd = a, l.rowEnd = i) : l = { colStart: r, rowStart: o, colEnd: a, rowEnd: i }, l;
|
|
361
|
-
}, isCellWithinRange: (e, t) => {
|
|
362
|
-
if (!e || !t) return !1;
|
|
363
|
-
const n = e.rowIndex;
|
|
364
|
-
if (n < t.rowStart || n > t.rowEnd) return !1;
|
|
365
|
-
const r = e.colIndex;
|
|
366
|
-
return !(r < t.colStart || r > t.colEnd);
|
|
367
|
-
}, isEqualCells: Ue, isEqualRanges: ve, isEqualRangesArrays: Be, isEqualSelectionCoords: (e, t) => e === t || !(!e || !t) && e.rangeIndex === t.rangeIndex && !!Ue(e.cell, t.cell) && Be(e.ranges, t.ranges), isRangeWithinRange: (e, t) => !(e.rowStart < t.rowStart || e.rowEnd > t.rowEnd) && !(e.colStart < t.colStart || e.colEnd > t.colEnd), isRangesIntersect: Te, isSingleCell: (e) => !!e && e.rowEnd === e.rowStart && e.colStart === e.colEnd, isValidRange: (e) => !!e && !(typeof e.colStart != "number" || e.colStart < 0) && !(typeof e.colEnd != "number" || e.colEnd < e.colStart) && !(typeof e.rowStart != "number" || e.rowStart < 0) && !(typeof e.rowEnd != "number" || e.rowEnd < e.rowStart), mergeRangedValues: ze, reverseColumnFirstCellComparator: De, reverseRowFirstCellComparator: Fe, rowFirstCellComparator: Pe, rowFirstRangeComparator: ct, sanitizeRange: (e) => e ? { colStart: e.colIndex ?? e.colStart ?? 0, rowStart: e.rowIndex ?? e.rowStart ?? 0, colEnd: e.colIndex ?? e.colEnd ?? 0, rowEnd: e.rowIndex ?? e.rowEnd ?? 0 } : null, translateRange: (e, t = -e.rowStart, n = -e.colStart, r) => r ? (r.colStart = e.colStart + n, r.rowStart = e.rowStart + t, r.colEnd = e.colEnd + n, r.rowEnd = e.rowEnd + t, r) : { colStart: e.colStart + n, rowStart: e.rowStart + t, colEnd: e.colEnd + n, rowEnd: e.rowEnd + t }, unionRanges: ye, unionRangesArrays: (e, t, n) => {
|
|
368
|
-
if (!e || e.length === 0) return null;
|
|
369
|
-
if (e.length === 1 && !t) return e[0];
|
|
370
|
-
let r = e[0];
|
|
371
|
-
for (let o = 1; o < e.length; o++) r = ye(r, e[o], n);
|
|
372
|
-
return t && (r = ye(r, t, n)), r;
|
|
373
|
-
} }, Symbol.toStringTag, { value: "Module" }));
|
|
374
|
-
const S = { html: "text/html", plain: "text/plain", png: "image/png" }, Lt = Object.freeze({ left: 0, top: 0 }), At = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), Mt = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
|
|
375
|
-
Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: Mt, EmptyRect: At, EmptyTopLeft: Lt }, Symbol.toStringTag, { value: "Module" }));
|
|
376
|
-
function jt(e) {
|
|
377
|
-
const t = Object.prototype.toString.call(e);
|
|
378
|
-
return t === "[object RegExp]" || t === "[object Date]" || (function(n) {
|
|
379
|
-
return n.$$typeof === Pt;
|
|
380
|
-
})(e);
|
|
381
|
-
}
|
|
382
|
-
const Pt = typeof Symbol == "function" && Symbol.for ? Symbol.for("react.element") : 60103;
|
|
383
|
-
function Ft(e) {
|
|
384
|
-
return /* @__PURE__ */ (function(t) {
|
|
385
|
-
return !!t && typeof t == "object";
|
|
386
|
-
})(e) && !jt(e);
|
|
387
|
-
}
|
|
388
|
-
function re(e, t) {
|
|
389
|
-
return t.clone !== !1 && t.isMergeableObject(e) ? Y((n = e, Array.isArray(n) ? [] : {}), e, t) : e;
|
|
390
|
-
var n;
|
|
391
|
-
}
|
|
392
|
-
function Dt(e, t, n) {
|
|
393
|
-
return e.concat(t).map(function(r) {
|
|
394
|
-
return re(r, n);
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
function Ke(e) {
|
|
398
|
-
return Object.keys(e).concat((function(t) {
|
|
399
|
-
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(n) {
|
|
400
|
-
return Object.propertyIsEnumerable.call(t, n);
|
|
401
|
-
}) : [];
|
|
402
|
-
})(e));
|
|
403
|
-
}
|
|
404
|
-
function Ve(e, t) {
|
|
405
|
-
try {
|
|
406
|
-
return t in e;
|
|
407
|
-
} catch {
|
|
408
|
-
return !1;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
function Ut(e, t, n) {
|
|
412
|
-
const r = {};
|
|
413
|
-
return n.isMergeableObject(e) && Ke(e).forEach(function(o) {
|
|
414
|
-
r[o] = re(e[o], n);
|
|
415
|
-
}), Ke(t).forEach(function(o) {
|
|
416
|
-
(function(a, i) {
|
|
417
|
-
return Ve(a, i) && !(Object.hasOwnProperty.call(a, i) && Object.propertyIsEnumerable.call(a, i));
|
|
418
|
-
})(e, o) || (Ve(e, o) && n.isMergeableObject(t[o]) ? r[o] = (function(a, i) {
|
|
419
|
-
if (!i.customMerge) return Y;
|
|
420
|
-
const l = i.customMerge(a);
|
|
421
|
-
return typeof l == "function" ? l : Y;
|
|
422
|
-
})(o, n)(e[o], t[o], n) : r[o] = re(t[o], n));
|
|
423
|
-
}), r;
|
|
424
|
-
}
|
|
425
|
-
function Y(e, t, n) {
|
|
426
|
-
(n = n || {}).arrayMerge = n.arrayMerge || Dt, n.isMergeableObject = n.isMergeableObject || Ft, n.cloneUnlessOtherwiseSpecified = re;
|
|
427
|
-
const r = Array.isArray(t);
|
|
428
|
-
return r === Array.isArray(e) ? r ? n.arrayMerge(e, t, n) : Ut(e, t, n) : re(t, n);
|
|
429
|
-
}
|
|
430
|
-
Y.all = function(e, t) {
|
|
431
|
-
if (!Array.isArray(e)) throw new Error("first argument should be an array");
|
|
432
|
-
return e.reduce(function(n, r) {
|
|
433
|
-
return Y(n, r, t);
|
|
434
|
-
}, {});
|
|
435
|
-
};
|
|
436
|
-
const ge = Object.freeze([]), Bt = Object.freeze({}), qe = (e) => e, fe = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
437
|
-
let t = 16 * Math.random() | 0;
|
|
438
|
-
return (e === "x" ? t : 3 & t | 8).toString(16);
|
|
439
|
-
}), $t = (e) => 1 * e, dt = (e, t) => e === t || !(!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length) && e.every((n, r) => n === t[r]), ne = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, ft = (e) => typeof e != "object" || Array.isArray(e) || e === null ? e : (Object.keys(e).forEach(function(t) {
|
|
440
|
-
e[t] && typeof e[t] == "object" ? ft(e[t]) : e[t] !== null && e[t] !== void 0 || delete e[t], typeof e[t] == "object" && Object.keys(e[t]).length === 0 && delete e[t];
|
|
441
|
-
}), Object.keys(e).length === 0 ? null : e), zt = (e, t) => !(e !== t && !dt(e, t)) || !!e.isEqual?.(t), pt = (e, t, n = zt) => {
|
|
442
|
-
if (e == null || e === t) return null;
|
|
443
|
-
if (!e || typeof e != "object" || Array.isArray(e) || e.isImmutable?.()) return n(e, t) ? null : e;
|
|
444
|
-
const r = Object.keys(e), o = r.length;
|
|
445
|
-
if (o === 0) return null;
|
|
446
|
-
let a = !1;
|
|
447
|
-
for (let i = 0; i < o; i++) {
|
|
448
|
-
const l = r[i];
|
|
449
|
-
pt(e[l], t?.[l], n) === null && (a = !0, delete e[l]);
|
|
450
|
-
}
|
|
451
|
-
return a && Object.keys(e).length === 0 ? null : void 0;
|
|
452
|
-
}, Ge = typeof performance == "object" && typeof performance.now == "function" ? () => performance.now() : () => Date.now(), We = (e) => e == null, Ye = (e, t) => !(t.left > e.right || t.right < e.left || t.top > e.bottom || t.bottom < e.top), Je = !(typeof window > "u" || !window.document || !window.document.createElement), k = { Windows: "windows", MacOS: "macos", IOS: "ios", Linux: "linux", Android: "android", Safari: "safari", Firefox: "firefox", Node: "node", Unknown: "unknown" }, oe = () => {
|
|
453
|
-
if (ht()) return k.Node;
|
|
454
|
-
const e = globalThis.navigator !== void 0 && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : "";
|
|
455
|
-
return e ? /(win32|win64|windows|wince)/i.test(e) ? k.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(e) ? k.MacOS : /(iphone|ipad|ipod)/i.test(e) ? k.IOS : /android/.test(e) ? k.Android : /linux/.test(e) ? k.Linux : /^((?!chrome|android|).)*safari/i.test(e) ? k.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(e) ? k.Firefox : k.Unknown : k.Unknown;
|
|
456
|
-
};
|
|
457
|
-
function ht() {
|
|
458
|
-
return typeof process < "u" && process.release?.name === "node" || (typeof process < "u" && process.browser, !1);
|
|
459
|
-
}
|
|
460
|
-
const He = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeElement || e?.contains(document.activeElement)), Kt = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray: ge, EmptyObject: Bt, OSType: k, arrayMove: function(e, t, n) {
|
|
461
|
-
const r = e.slice();
|
|
462
|
-
return r.splice(n < 0 ? r.length + n : n, 0, r.splice(t, 1)[0]), r;
|
|
463
|
-
}, asNumber: (e) => {
|
|
464
|
-
const t = $t(e);
|
|
465
|
-
return Number.isFinite(t) ? t : 0;
|
|
466
|
-
}, camelToPrettyCase: (e) => e.length === 1 ? e.toUpperCase() : e.replace(/([A-Z])/g, " $1").replace(/^./, function(t) {
|
|
467
|
-
return t.toUpperCase();
|
|
468
|
-
}).trim(), canUseDOM: Je, cancelTimeout: (e) => {
|
|
469
|
-
cancelAnimationFrame(e.id);
|
|
470
|
-
}, castToString: (e) => e == null || e === void 0 ? "" : typeof e != "string" ? "" + e : e, cloneObject: (e) => We(e) ? e : JSON.parse(JSON.stringify(e)), consoleWithNoSource: (...e) => new Promise((t) => {
|
|
471
|
-
setTimeout(() => {
|
|
472
|
-
Function("console.log.apply(console, arguments)").apply(null, e), t();
|
|
473
|
-
});
|
|
474
|
-
}), debounce: function(e, t = 300, n = !1) {
|
|
475
|
-
let r, o, a, i, l = 0;
|
|
476
|
-
function s() {
|
|
477
|
-
let w = Date.now() - l;
|
|
478
|
-
w < t && w >= 0 ? r = setTimeout(s, t - w) : (r = null, n || (i = e.apply(a, o), a = o = null));
|
|
479
|
-
}
|
|
480
|
-
t == null && (t = 100);
|
|
481
|
-
const p = function() {
|
|
482
|
-
a = globalThis, o = arguments, l = Date.now();
|
|
483
|
-
var w = n && !r;
|
|
484
|
-
return r || (r = setTimeout(s, t)), w && (i = e.apply(a, o), a = o = null), i;
|
|
485
|
-
};
|
|
486
|
-
return p.clear = function() {
|
|
487
|
-
r && (clearTimeout(r), r = null);
|
|
488
|
-
}, p.flush = function() {
|
|
489
|
-
r && (i = e.apply(a, o), a = o = null, clearTimeout(r), r = null);
|
|
490
|
-
}, p;
|
|
491
|
-
}, deepEqual: function e(t, n) {
|
|
492
|
-
if (t === n) return !0;
|
|
493
|
-
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
494
|
-
if (t.constructor !== n.constructor) return !1;
|
|
495
|
-
let r, o, a;
|
|
496
|
-
if (Array.isArray(t)) {
|
|
497
|
-
if (r = t.length, r != n.length) return !1;
|
|
498
|
-
for (o = r; o-- !== 0; ) if (!e(t[o], n[o])) return !1;
|
|
499
|
-
return !0;
|
|
500
|
-
}
|
|
501
|
-
if (t instanceof Map && n instanceof Map) {
|
|
502
|
-
if (t.size !== n.size) return !1;
|
|
503
|
-
for (o of t.entries()) if (!n.has(o[0])) return !1;
|
|
504
|
-
for (o of t.entries()) if (!e(o[1], n.get(o[0]))) return !1;
|
|
505
|
-
return !0;
|
|
506
|
-
}
|
|
507
|
-
if (t instanceof Set && n instanceof Set) {
|
|
508
|
-
if (t.size !== n.size) return !1;
|
|
509
|
-
for (o of t.entries()) if (!n.has(o[0])) return !1;
|
|
510
|
-
return !0;
|
|
511
|
-
}
|
|
512
|
-
if (ArrayBuffer.isView(t) && ArrayBuffer.isView(n)) {
|
|
513
|
-
if (r = t.length, r != n.length) return !1;
|
|
514
|
-
for (o = r; o-- !== 0; ) if (t[o] !== n[o]) return !1;
|
|
515
|
-
return !0;
|
|
516
|
-
}
|
|
517
|
-
if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
|
|
518
|
-
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
|
|
519
|
-
if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
|
|
520
|
-
if (a = Object.keys(t), r = a.length, r !== Object.keys(n).length) return !1;
|
|
521
|
-
for (o = r; o-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(n, a[o])) return !1;
|
|
522
|
-
for (o = r; o-- !== 0; ) {
|
|
523
|
-
let i = a[o];
|
|
524
|
-
if ((i !== "_owner" || !t.$$typeof) && !e(t[i], n[i])) return !1;
|
|
525
|
-
}
|
|
526
|
-
return !0;
|
|
527
|
-
}
|
|
528
|
-
return t != t && n != n;
|
|
529
|
-
}, deepFreeze: function e(t) {
|
|
530
|
-
return Object.freeze(t), Object.keys(t).forEach((n) => {
|
|
531
|
-
typeof t[n] != "object" || t[n] === null || Object.isFrozen(t[n]) || e(t[n]);
|
|
532
|
-
}), t;
|
|
533
|
-
}, deepMerge: Y, diffValues: (e, t) => {
|
|
534
|
-
const n = {}, r = Object.keys(t), o = r.length;
|
|
535
|
-
for (let a = 0; a < o; a++) {
|
|
536
|
-
const i = r[a], l = e[i], s = t[i];
|
|
537
|
-
l !== s && (n[i] = l === void 0 ? s : l);
|
|
538
|
-
}
|
|
539
|
-
return Object.keys(n).length === 0 ? null : n;
|
|
540
|
-
}, findEqualOrGreater: function(e, t, n = qe) {
|
|
541
|
-
let r = 0, o = e.length - 1;
|
|
542
|
-
for (; r <= o; ) {
|
|
543
|
-
let a = Math.floor((r + o) / 2), i = n(e[a]);
|
|
544
|
-
if (i === t) return a;
|
|
545
|
-
i < t ? r = a + 1 : o = a - 1;
|
|
546
|
-
}
|
|
547
|
-
return r;
|
|
548
|
-
}, findEqualOrLesser: function(e, t, n = qe) {
|
|
549
|
-
let r = e.length - 1, o = 0;
|
|
550
|
-
for (; r >= o; ) {
|
|
551
|
-
let a = Math.floor((r + o) / 2), i = n(e[a]);
|
|
552
|
-
if (i === t) return a;
|
|
553
|
-
i > t ? r = a - 1 : o = a + 1;
|
|
554
|
-
}
|
|
555
|
-
return r;
|
|
556
|
-
}, findNextStep: (e, t = !0, n = 15, r = 10, o = 400) => {
|
|
557
|
-
const a = Math.max(e - r, 0) + (t ? 1 : -1);
|
|
558
|
-
return Math.min(o, Math[t ? "ceil" : "floor"](a / n) * n + r);
|
|
559
|
-
}, getDPI: () => {
|
|
560
|
-
let e = 1;
|
|
561
|
-
return typeof window == "object" && (e = window.devicePixelRatio || 1), e;
|
|
562
|
-
}, getFromPath: (e, t) => {
|
|
563
|
-
const n = t.split(".");
|
|
564
|
-
let r = e;
|
|
565
|
-
const o = n.length;
|
|
566
|
-
for (let a = 0; a < o; a++) {
|
|
567
|
-
const i = n[a];
|
|
568
|
-
if (!r) return null;
|
|
569
|
-
let l = r[i];
|
|
570
|
-
if (typeof l == "function" && (l = l.bind(r)()), !l || !ne(l)) return l;
|
|
571
|
-
r = l;
|
|
572
|
-
}
|
|
573
|
-
return r ?? null;
|
|
574
|
-
}, getOS: oe, hasFocus: He, isDefined: (e) => e != null, isEmpty: (e) => e == null || e === "", isEqualArrays: dt, isEqualBounds: (e, t) => e === t || !(e && !t || t && !e) && e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height, isEqualObjectKeys: (e, t) => {
|
|
575
|
-
if (e === t) return !0;
|
|
576
|
-
if (e && !t || t && !e) return !1;
|
|
577
|
-
const n = Object.keys(e), r = n.length;
|
|
578
|
-
if (r !== Object.keys(t).length) return !1;
|
|
579
|
-
for (let o = 0; o < r; o++) {
|
|
580
|
-
const a = n[o];
|
|
581
|
-
if (e[a] !== t[a]) return !1;
|
|
582
|
-
}
|
|
583
|
-
return !0;
|
|
584
|
-
}, isNode: ht, isNullOrUndefined: We, isNumeric: (e) => {
|
|
585
|
-
const t = 1 * e;
|
|
586
|
-
return Number.isFinite(t) && typeof t == "number";
|
|
587
|
-
}, isObject: ne, isPromiseLike: (e) => !!e && typeof e.then == "function", isRectInsideRect: (e, t) => e.top >= t.top && e.bottom <= t.bottom && e.left >= t.left && e.right <= t.right, isRectIntersect: Ye, mergeContentful: (...e) => {
|
|
588
|
-
const t = e.length;
|
|
589
|
-
if (t > 0 && e[t - 1] !== void 0 && !ne(e[t - 1])) return e[t - 1];
|
|
590
|
-
let n = e[0] || {};
|
|
591
|
-
for (let r = 1; r < t; r++) n = Y(n, e[r] || {}, { arrayMerge: (o, a) => [...a] });
|
|
592
|
-
return n;
|
|
593
|
-
}, nextTick: (e) => {
|
|
594
|
-
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(() => {
|
|
595
|
-
e();
|
|
596
|
-
}) : (typeof setImmediate == "function" ? setImmediate : setTimeout)(() => {
|
|
597
|
-
e();
|
|
598
|
-
});
|
|
599
|
-
}, openFileDialog: (e = "*.*") => new Promise((t, n) => {
|
|
600
|
-
if (!Je) return void n("Unable to open dialog with no dom.");
|
|
601
|
-
const r = document.createElement("input");
|
|
602
|
-
r.type = "file", r.accept = e;
|
|
603
|
-
let o = null, a = !1;
|
|
604
|
-
globalThis.addEventListener?.("focus", () => {
|
|
605
|
-
setTimeout(() => {
|
|
606
|
-
o || a || (a = !0, t(null));
|
|
607
|
-
}, 1e3);
|
|
608
|
-
}, { once: !0, passive: !0 }), r.onchange = () => {
|
|
609
|
-
if (o = r.files[0], o) {
|
|
610
|
-
if (a) return void console.warn("File open detected after faux cancel.", o);
|
|
611
|
-
t(o);
|
|
612
|
-
}
|
|
613
|
-
}, r.autofocus = !0, r.click();
|
|
614
|
-
}), rafThrottle: (e) => {
|
|
615
|
-
let t, n = !1, r = function() {
|
|
616
|
-
n = !1, e(t);
|
|
617
|
-
};
|
|
618
|
-
return function(o) {
|
|
619
|
-
t = o, t && t.persist && t.persist(), n || (n = !0, requestAnimationFrame(r));
|
|
620
|
-
};
|
|
621
|
-
}, removeEmptyProperties: ft, removeEqualValues: pt, removeListenerAll: (e) => {
|
|
622
|
-
if (!e) return ge;
|
|
623
|
-
const t = e.length;
|
|
624
|
-
for (let n = 0; n < t; n++) {
|
|
625
|
-
const r = e[n];
|
|
626
|
-
r && r();
|
|
627
|
-
}
|
|
628
|
-
return ge;
|
|
629
|
-
}, requestTimeout: (e, t) => {
|
|
630
|
-
const n = Ge(), r = { id: requestAnimationFrame(function o() {
|
|
631
|
-
Ge() - n >= t ? e.call(null) : r.id = requestAnimationFrame(o);
|
|
632
|
-
}) };
|
|
633
|
-
return r;
|
|
634
|
-
}, roundAccurately: (e, t = 0) => {
|
|
635
|
-
if (e == null || !isFinite(e)) return null;
|
|
636
|
-
const n = 10 ** t;
|
|
637
|
-
return Number(Math.round(e * n) / n);
|
|
638
|
-
}, setToPath: (e, t, n) => {
|
|
639
|
-
const r = t.split(".");
|
|
640
|
-
let o = e;
|
|
641
|
-
if (!o) throw new Error("Can not set path to a null path.");
|
|
642
|
-
const a = r.length;
|
|
643
|
-
for (let i = 0; o && i < a - 1; i++) {
|
|
644
|
-
const l = r[i];
|
|
645
|
-
let s = o[l];
|
|
646
|
-
if (s == null && (s = {}, o[l] = s), !ne(s)) throw new Error("Can not set path to a non object path.");
|
|
647
|
-
o = s;
|
|
648
|
-
}
|
|
649
|
-
if (typeof n != "number" && typeof n != "boolean" && typeof n != "string" && !ne(n)) throw new Error(\`Can not set path to \${n} that is not a a supported primitive.\`);
|
|
650
|
-
return o[r[a - 1]] = n, e;
|
|
651
|
-
}, splitNumber: (e) => {
|
|
652
|
-
let t = Math.abs(e);
|
|
653
|
-
if (isNaN(t) || !isFinite(e)) return null;
|
|
654
|
-
let n = 0 | t, r = t - n, o = 0, a = 0, i = 1;
|
|
655
|
-
if (r > 5e-8) for (; a < 8 && Math.abs(o / i - r) > 5e-8; ) a++, i *= 10, o = Math.round(r * i);
|
|
656
|
-
return { ip: Math.trunc(e), fp: o, ipLength: Math.ceil(Math.log10(n + 1)), fpLength: a };
|
|
657
|
-
}, subtractRect: (e, t, n = !1) => {
|
|
658
|
-
if (!t) return [e];
|
|
659
|
-
if (!Ye(e, t)) return [];
|
|
660
|
-
const r = [];
|
|
661
|
-
let o = e;
|
|
662
|
-
const a = () => {
|
|
663
|
-
t.top > o.top && t.top < o.bottom && (r.push({ ...o, bottom: t.top }), o = { ...o, top: t.top });
|
|
664
|
-
}, i = () => {
|
|
665
|
-
t.bottom > o.top && t.bottom < o.bottom && (r.push({ ...o, top: t.bottom }), o = { ...o, bottom: t.bottom });
|
|
666
|
-
}, l = () => {
|
|
667
|
-
t.right > o.left && t.right < o.right && (r.push({ ...o, left: t.right }), o = { ...o, right: t.right });
|
|
668
|
-
}, s = () => {
|
|
669
|
-
t.left > o.left && t.left < o.right && (r.push({ ...o, right: t.left }), o = { ...o, left: t.left });
|
|
670
|
-
};
|
|
671
|
-
return n ? (s(), l(), a(), i()) : (a(), i(), l(), s()), r;
|
|
672
|
-
}, textToKey: (e) => e.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(), throttle: function(e, t) {
|
|
673
|
-
let n = null;
|
|
674
|
-
return (...r) => {
|
|
675
|
-
const o = Date.now();
|
|
676
|
-
(!n || o - n >= t) && (n = o, e(...r));
|
|
677
|
-
};
|
|
678
|
-
}, toSafeJSON: function e(t) {
|
|
679
|
-
if (t === null || typeof t != "object") return t;
|
|
680
|
-
if (typeof t.toJSON == "function") return t.toJSON();
|
|
681
|
-
if (Array.isArray(t)) return t.map((r) => e(r));
|
|
682
|
-
if (typeof t.toString == "function" && t.toString !== Object.prototype.toString) return t.toString();
|
|
683
|
-
const n = {};
|
|
684
|
-
for (const r in t) t.hasOwnProperty(r) && (n[r] = e(t[r]));
|
|
685
|
-
return n;
|
|
686
|
-
}, transpose: (e) => {
|
|
687
|
-
if (!e) return e;
|
|
688
|
-
const t = e.length, n = e[0].length, r = [];
|
|
689
|
-
for (let o = 0; o < n; o++) r[o] = Array(t);
|
|
690
|
-
for (let o = 0; o < t; o++) for (let a = 0; a < n; a++) r[a][o] = e[o][a];
|
|
691
|
-
return r;
|
|
692
|
-
}, uuidV4: fe, validEnumValue: (e, t) => {
|
|
693
|
-
if (!Object.values(e).includes(t)) throw new Error(\`Invalid type: \${t ?? "null"}. Must be one of: \${Object.values(t).join(", ")}.\`);
|
|
694
|
-
}, whenFocus: async (e, t = !1) => new Promise((n) => {
|
|
695
|
-
He(e, t) ? n(!0) : e.addEventListener("focusin", () => {
|
|
696
|
-
n(!0);
|
|
697
|
-
}, { once: !0 }), e.focus();
|
|
698
|
-
}) }, Symbol.toStringTag, { value: "Module" }));
|
|
699
|
-
Object.freeze(Object.defineProperty({ __proto__: null, MESSAGE_ERROR_INVALID_ARG: (e) => \`Invalid argument: '\${e}'.\` }, Symbol.toStringTag, { value: "Module" }));
|
|
700
|
-
const mt = (e) => {
|
|
701
|
-
const t = new Uint8Array(e), n = t.byteLength;
|
|
702
|
-
let r = "";
|
|
703
|
-
for (let o = 0; o < n; o++) r += String.fromCharCode(t[o]);
|
|
704
|
-
if (typeof window < "u" && typeof globalThis.btoa == "function") return globalThis.btoa(r);
|
|
705
|
-
if (typeof Buffer < "u") return Buffer.from(r, "binary").toString("base64");
|
|
706
|
-
throw new Error("Unsupported environment");
|
|
707
|
-
}, _e = (e) => new Promise((t, n) => {
|
|
708
|
-
if (e) if (typeof FileReader < "u") {
|
|
709
|
-
const r = new FileReader();
|
|
710
|
-
r.onload = () => {
|
|
711
|
-
t(r.result);
|
|
712
|
-
}, r.onerror = () => {
|
|
713
|
-
n(r.error);
|
|
714
|
-
}, r.readAsText(e);
|
|
715
|
-
} else if (typeof Buffer < "u") {
|
|
716
|
-
const r = (o) => Buffer.from(o).toString("utf-8");
|
|
717
|
-
e.arrayBuffer().then((o) => {
|
|
718
|
-
t(r(o));
|
|
719
|
-
}).catch((o) => {
|
|
720
|
-
n(o);
|
|
721
|
-
});
|
|
722
|
-
} else n(new Error("Unsupported environment"));
|
|
723
|
-
else t("");
|
|
724
|
-
});
|
|
725
|
-
Object.freeze(Object.defineProperty({ __proto__: null, DEFAULT_MIME_TYPE: "*/*", arrayBufferToBase64: mt, base64ToArrayBuffer: (e) => {
|
|
726
|
-
const t = typeof window < "u" && typeof globalThis.atob == "function" ? globalThis.atob(e) : Buffer.from(e, "base64").toString("binary"), n = t.length, r = new Uint8Array(n);
|
|
727
|
-
for (let o = 0; o < n; o++) r[o] = t.charCodeAt(o);
|
|
728
|
-
return r.buffer;
|
|
729
|
-
}, blobToString: _e }, Symbol.toStringTag, { value: "Module" }));
|
|
730
|
-
const wt = "data:image/png;base64,", yt = "Unable to resolve image.", Xe = (e) => new Promise(async (t, n) => {
|
|
731
|
-
let r = null;
|
|
732
|
-
try {
|
|
733
|
-
r = new Image(), r.src = e, r.addEventListener("load", function() {
|
|
734
|
-
t({ width: r.naturalWidth, height: r.naturalHeight });
|
|
735
|
-
}, { once: !0 }), r.addEventListener("error", function() {
|
|
736
|
-
URL.revokeObjectURL(e), n("Invalid Image");
|
|
737
|
-
}, { once: !0 }), await r.decode("sync");
|
|
738
|
-
} catch {
|
|
739
|
-
r?.src && URL.revokeObjectURL(r.src);
|
|
740
|
-
}
|
|
741
|
-
r || n(yt);
|
|
742
|
-
}), be = "image/svg+xml";
|
|
743
|
-
Object.freeze(Object.defineProperty({ __proto__: null, DATA_URL_PNG_PREFIX: wt, getImageDataUrl: (e, t = 1) => new Promise(async (n, r) => {
|
|
744
|
-
let o = null;
|
|
745
|
-
try {
|
|
746
|
-
o = new Image(), o.src = e, o.addEventListener("load", function() {
|
|
747
|
-
try {
|
|
748
|
-
const a = document.createElement("canvas");
|
|
749
|
-
a.width = o.naturalWidth, a.height = o.naturalHeight, a.getContext("2d").drawImage(o, 0, 0);
|
|
750
|
-
const i = a.toDataURL("image/png", t);
|
|
751
|
-
n({ elemImg: o, dataUrl: i });
|
|
752
|
-
} catch (a) {
|
|
753
|
-
URL.revokeObjectURL(e), r(a);
|
|
754
|
-
}
|
|
755
|
-
}, { once: !0 }), o.addEventListener("error", function() {
|
|
756
|
-
URL.revokeObjectURL(e), r("Invalid Image");
|
|
757
|
-
}, { once: !0 }), await o.decode("sync");
|
|
758
|
-
} catch {
|
|
759
|
-
o?.src && URL.revokeObjectURL(o.src);
|
|
760
|
-
}
|
|
761
|
-
o || r(yt);
|
|
762
|
-
}), loadImageDetails: async (e, t = null) => {
|
|
763
|
-
let n = null;
|
|
764
|
-
const r = async () => {
|
|
765
|
-
try {
|
|
766
|
-
const a = t ?? "image/*", i = URL.createObjectURL(new Blob([e], { type: a })), l = await Xe(i);
|
|
767
|
-
n = { mimeType: a, naturalSize: l, asUrl: i };
|
|
768
|
-
} catch {
|
|
769
|
-
}
|
|
770
|
-
}, o = async () => {
|
|
771
|
-
try {
|
|
772
|
-
const a = new TextDecoder().decode(e), i = URL.createObjectURL(new Blob([a], { type: be })), l = await Xe(i);
|
|
773
|
-
n = { mimeType: t ?? be, naturalSize: l, asUrl: i, asSVGText: a };
|
|
774
|
-
} catch {
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
if (t === be ? await o() : t.startsWith("image/") ? await r() : (await r(), n || await o()), !n) throw new Error("Failed to load image");
|
|
778
|
-
return n;
|
|
779
|
-
} }, Symbol.toStringTag, { value: "Module" }));
|
|
780
|
-
var Ze, Qe;
|
|
781
|
-
(Qe = Ze || (Ze = {})).resolveTypedUpdates = (e, t, n, r) => {
|
|
782
|
-
if (e === null) return e;
|
|
783
|
-
if (e === void 0) return r;
|
|
784
|
-
let o = e;
|
|
785
|
-
if (t?.shorthand) {
|
|
786
|
-
const s = t?.shorthand(e, n);
|
|
787
|
-
s !== void 0 && (o = s);
|
|
788
|
-
}
|
|
789
|
-
if (o !== null && t?.getSubType) {
|
|
790
|
-
const s = t.getSubType(o);
|
|
791
|
-
s && (t = s);
|
|
792
|
-
}
|
|
793
|
-
const a = t?.properties, i = t?.arrayType ?? !1;
|
|
794
|
-
let l = o;
|
|
795
|
-
if (t && t.merge && l && r) l = t.merge(l, r, n);
|
|
796
|
-
else if (!i && a) {
|
|
797
|
-
const s = Object.keys({ ...o, ...r });
|
|
798
|
-
l = null;
|
|
799
|
-
const p = s.length;
|
|
800
|
-
for (let w = 0; w < p; w++) {
|
|
801
|
-
const g = s[w];
|
|
802
|
-
let f, y = o[g];
|
|
803
|
-
if (y !== void 0) {
|
|
804
|
-
const x = a[g];
|
|
805
|
-
f = x ? (0, Qe.resolveTypedUpdates)(y, x, n, r?.[g]) : y;
|
|
806
|
-
} else f = r?.[g];
|
|
807
|
-
f != null && (l = l ?? {}, l[g] = f);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
return l;
|
|
811
|
-
};
|
|
812
|
-
const et = \`The Safari browser does not support advanced copy and paste.
|
|
813
|
-
Copy and paste will be limited to within the browser tab.
|
|
814
|
-
|
|
815
|
-
Please use Chrome or Edge if external copy and paste is required.\`, Ee = \`You do not have permissions to access the clipboard.
|
|
816
|
-
All copy and paste operations will be limited to the browser tab.\`, gt = { Safari: \`The Safari browser does not support advanced copy and paste.
|
|
817
|
-
Copy and paste will be limited to within the browser tab.
|
|
818
|
-
|
|
819
|
-
Please use Chrome or Edge if external copy and paste is required.\`, Perms: Ee, PermsWrite: oe() === k.Safari ? et : Ee, PermsRead: oe() === k.Safari ? et : Ee }, Se = async () => new Promise((e) => {
|
|
820
|
-
document.hasFocus() ? e() : globalThis.addEventListener?.("focus", () => {
|
|
821
|
-
e();
|
|
822
|
-
}, { once: !0 }), document.activeElement.focus?.();
|
|
823
|
-
}), xe = async (e, t, n) => {
|
|
824
|
-
if (oe() === k.Safari) return await n(new Error(gt.Safari));
|
|
825
|
-
try {
|
|
826
|
-
const r = async (i) => {
|
|
827
|
-
try {
|
|
828
|
-
return await i();
|
|
829
|
-
} catch (l) {
|
|
830
|
-
if (l.message?.includes("Document is not focused")) return !1;
|
|
831
|
-
throw l;
|
|
832
|
-
}
|
|
833
|
-
}, o = await globalThis?.navigator?.permissions?.query({ name: e, allowWithoutGesture: !0, allowWithoutSanitization: !0 });
|
|
834
|
-
let a = !1;
|
|
835
|
-
if (o.state === "prompt" && (a = await r(t)), a || o.state !== "granted" || (a = await t()), !a) return await n(new Error(o.state));
|
|
836
|
-
} catch (r) {
|
|
837
|
-
return r.message === "No valid data on clipboard" || r.name === "DataError" ? void 0 : await n(r);
|
|
838
|
-
}
|
|
839
|
-
}, bt = async (e) => {
|
|
840
|
-
try {
|
|
841
|
-
return await e.read({ unsanitized: [S.html] });
|
|
842
|
-
} catch {
|
|
843
|
-
}
|
|
844
|
-
return await e.read();
|
|
845
|
-
}, Vt = async (e, t) => {
|
|
846
|
-
if (!e) return null;
|
|
847
|
-
const n = await bt(e);
|
|
848
|
-
let r = !1;
|
|
849
|
-
for (let o = 0; !r && n && o < n.length; o++) if (r = n[o].types.includes(t), r)
|
|
850
|
-
return await n[o].getType(t);
|
|
851
|
-
return r ? void 0 : null;
|
|
852
|
-
};
|
|
853
|
-
if (!globalThis.ClipboardItem) {
|
|
854
|
-
const e = (n, r) => new Blob([r], { type: n });
|
|
855
|
-
class t {
|
|
856
|
-
constructor(r, o) {
|
|
857
|
-
this._items = {}, this._types = Object.keys(r);
|
|
858
|
-
const a = {}, i = Object.keys(r);
|
|
859
|
-
for (let l = 0; l < i.length; l++) {
|
|
860
|
-
const s = i[l];
|
|
861
|
-
let p = r[s];
|
|
862
|
-
a[s] = typeof p == "string" ? e(s, p) : p;
|
|
863
|
-
}
|
|
864
|
-
this._items = a, this._presentationStyle = o?.presentationStyle ?? "unspecified";
|
|
865
|
-
}
|
|
866
|
-
get types() {
|
|
867
|
-
return this._types;
|
|
868
|
-
}
|
|
869
|
-
getType(r) {
|
|
870
|
-
return Promise.resolve(this._items[r]);
|
|
871
|
-
}
|
|
872
|
-
supports(r) {
|
|
873
|
-
return !0;
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
globalThis.ClipboardItem = t;
|
|
877
|
-
}
|
|
878
|
-
const Oe = async (e, t = S.html) => new Promise(async (n, r) => {
|
|
879
|
-
try {
|
|
880
|
-
const o = await Vt(e, t);
|
|
881
|
-
if (o) {
|
|
882
|
-
const a = new FileReader();
|
|
883
|
-
a.onload = () => {
|
|
884
|
-
n(a.result);
|
|
885
|
-
}, a.onerror = () => {
|
|
886
|
-
n("");
|
|
887
|
-
}, a.readAsText(o);
|
|
888
|
-
} else n("");
|
|
889
|
-
} catch (o) {
|
|
890
|
-
r(o);
|
|
891
|
-
}
|
|
892
|
-
}), tt = async (e, t = S.html) => {
|
|
893
|
-
const n = await Oe(e, t);
|
|
894
|
-
if (!n) return null;
|
|
895
|
-
let r = null;
|
|
896
|
-
try {
|
|
897
|
-
r = new DOMParser().parseFromString(n, S.html);
|
|
898
|
-
} catch {
|
|
899
|
-
console.warn("Can't parse html from clipboard.");
|
|
900
|
-
}
|
|
901
|
-
return r;
|
|
902
|
-
}, qt = async (e) => {
|
|
903
|
-
e && await e.writeText("");
|
|
904
|
-
}, ae = "clipboard-uuid", Q = "web text/uuid", nt = (e) => \`<div style="display:none" \${ae}="\${e}"/>\`, Gt = (e, t) => {
|
|
905
|
-
let n = null;
|
|
906
|
-
try {
|
|
907
|
-
const r = new DOMParser().parseFromString(t, S.html);
|
|
908
|
-
r.body.firstElementChild.setAttribute(ae, e), n = r.getElementsByTagName("body")[0].innerHTML;
|
|
909
|
-
} catch (r) {
|
|
910
|
-
console.warn("Can't embed uuid.", r);
|
|
911
|
-
}
|
|
912
|
-
return n;
|
|
913
|
-
}, rt = (e, t) => {
|
|
914
|
-
if (!t || !e) return !1;
|
|
915
|
-
try {
|
|
916
|
-
const n = t.querySelectorAll(\`[\${ae}="\${e}"]\`);
|
|
917
|
-
if (n && n.length === 1) return !0;
|
|
918
|
-
if (t.querySelector("parsererror")) throw new Error("We are unable to parse node");
|
|
919
|
-
return !1;
|
|
920
|
-
} catch {
|
|
921
|
-
return !1;
|
|
922
|
-
}
|
|
923
|
-
};
|
|
924
|
-
class ot {
|
|
925
|
-
constructor(t) {
|
|
926
|
-
if (t?.nativeClipboard === void 0 || t?.nativeClipboard === !0) try {
|
|
927
|
-
this._nativeClipboard = globalThis?.navigator.clipboard;
|
|
928
|
-
} catch {
|
|
929
|
-
t?.nativeClipboard === !0 && console.warn("NativeClipboard option set to true but no native clipboard available.");
|
|
930
|
-
}
|
|
931
|
-
else this._nativeClipboard = t?.nativeClipboard === !1 ? null : t?.nativeClipboard;
|
|
932
|
-
this._disableCheckOnFocus = t?.disableCheckOnFocus ?? !1, this._init();
|
|
933
|
-
}
|
|
934
|
-
async _checkForChanges() {
|
|
935
|
-
this._nativeClipboard && this._state && !this._disableCheckOnFocus && await xe("clipboard-read", async () => {
|
|
936
|
-
await Se();
|
|
937
|
-
const t = await Oe(this._nativeClipboard, Q);
|
|
938
|
-
if (!this._state || t && t === this._state.uuid) return !0;
|
|
939
|
-
const n = await tt(this._nativeClipboard, S.html);
|
|
940
|
-
return !this._state || (rt(this._state.uuid, n) || this.clear(), !0);
|
|
941
|
-
}, async (t) => {
|
|
942
|
-
t?.message === "denied" || t.message?.includes("Document is not focused") || oe() === k.Safari || console.warn("Unable to detect clipboard changes: ", t);
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
_init() {
|
|
946
|
-
const t = this;
|
|
947
|
-
this._listeners = /* @__PURE__ */ new Map(), this._listenersCapture = /* @__PURE__ */ new Map(), this._state = null, this._nativeClipboard && (this._onFocus = () => {
|
|
948
|
-
t._checkForChanges();
|
|
949
|
-
}, this._onBlur = () => {
|
|
950
|
-
globalThis.addEventListener?.("focus", t._onFocus, { once: !0 });
|
|
951
|
-
}, globalThis.addEventListener?.("blur", this._onBlur), this._nativeClipboard.addEventListener("clipboardchange", (n) => {
|
|
952
|
-
t._checkForChanges();
|
|
953
|
-
}));
|
|
954
|
-
}
|
|
955
|
-
async read() {
|
|
956
|
-
if (!this._nativeClipboard) return this._state?.items ?? null;
|
|
957
|
-
const t = this;
|
|
958
|
-
return await xe("clipboard-read", async () => {
|
|
959
|
-
if (await Se(), this._state?.uuid) {
|
|
960
|
-
const n = await Oe(this._nativeClipboard, Q);
|
|
961
|
-
if (n && n === t._state.uuid) return !0;
|
|
962
|
-
const r = await tt(this._nativeClipboard, S.html);
|
|
963
|
-
if (rt(t._state?.uuid, r)) return !0;
|
|
964
|
-
}
|
|
965
|
-
return t._state = { items: await bt(this._nativeClipboard), uuid: null, ref: null }, this.dispatchEvent(new Event("clipboardread")), !0;
|
|
966
|
-
}, async (n) => {
|
|
967
|
-
this.dispatchEvent(new Event("clipboarderrorread"));
|
|
968
|
-
}), this._state?.items ?? [];
|
|
969
|
-
}
|
|
970
|
-
async write(t) {
|
|
971
|
-
return this._write({ uuid: fe(), items: t, ref: null });
|
|
972
|
-
}
|
|
973
|
-
async _write(t) {
|
|
974
|
-
if (!this._nativeClipboard) return this._state = t, this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")), null;
|
|
975
|
-
const n = this, r = [], o = t.uuid;
|
|
976
|
-
let a = t.items ?? [];
|
|
977
|
-
const i = () => {
|
|
978
|
-
n._state = { uuid: o, ref: t.ref, items: r }, n.dispatchEvent(new Event("clipboardwrite")), n.dispatchEvent(new Event("clipboardchange"));
|
|
979
|
-
};
|
|
980
|
-
await xe("clipboard-write", async () => {
|
|
981
|
-
await Se(), o && a.length === 0 && (a.push(new ClipboardItem({ [Q]: new Blob([o], { type: Q }) })), a.push(new ClipboardItem({ [S.html]: new Blob([nt(o)], { type: S.html }) })));
|
|
982
|
-
for (let l = 0; l < Math.min(1, a.length); l++) {
|
|
983
|
-
const s = a[l];
|
|
984
|
-
let p = s.types.indexOf(S.html), w = null;
|
|
985
|
-
if (p !== -1) {
|
|
986
|
-
const y = await s.getType(S.html);
|
|
987
|
-
w = await _e(y), w && (w = Gt(o, w));
|
|
988
|
-
}
|
|
989
|
-
if (!w && s.types.includes(S.plain)) {
|
|
990
|
-
const y = await s.getType(S.plain);
|
|
991
|
-
if (y) {
|
|
992
|
-
let x = null;
|
|
993
|
-
typeof y == "string" ? (console.warn("text as string", y), x = y) : x = await _e(y), x && (w = \`<div \${ae}="\${o}">\${x}</div>\`);
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
if (!w && s.types.includes(S.png)) {
|
|
997
|
-
const y = await s.getType(S.png), x = mt(await y.arrayBuffer());
|
|
998
|
-
w = \`<div \${ae}="\${o}"><img src="\${wt + x}"/></div>\`;
|
|
999
|
-
}
|
|
1000
|
-
!w && o && (w = nt(o));
|
|
1001
|
-
const g = new Blob([w ?? ""], { type: S.html }), f = {};
|
|
1002
|
-
for (let y = 0; y < s.types.length; y++) {
|
|
1003
|
-
const x = s.types[y];
|
|
1004
|
-
f[x] = y === p ? g : s.getType(x);
|
|
1005
|
-
}
|
|
1006
|
-
w && p === -1 && (f[S.html] = g), o && (f[Q] = new Blob([o], { type: Q })), r.push(new ClipboardItem(f));
|
|
1007
|
-
}
|
|
1008
|
-
try {
|
|
1009
|
-
r && r.length !== 0 ? await this._nativeClipboard.write(r) : await qt(this._nativeClipboard);
|
|
1010
|
-
} catch (l) {
|
|
1011
|
-
l.message?.includes("Document is not focused") || console.warn("Unable to write to native clipboard: ", l);
|
|
1012
|
-
}
|
|
1013
|
-
return i(), !0;
|
|
1014
|
-
}, async (l) => {
|
|
1015
|
-
this.dispatchEvent(new Event("clipboarderrorwrite")), i();
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
async writeReference(t) {
|
|
1019
|
-
if (!t) return void this.clear();
|
|
1020
|
-
let n = null;
|
|
1021
|
-
const r = {};
|
|
1022
|
-
try {
|
|
1023
|
-
const a = await t.toText?.() ?? null;
|
|
1024
|
-
a && (r[S.plain] = new Blob([a ?? ""], { type: S.plain }));
|
|
1025
|
-
} catch (a) {
|
|
1026
|
-
n = a;
|
|
1027
|
-
}
|
|
1028
|
-
try {
|
|
1029
|
-
const a = await t.toHtml?.() ?? null;
|
|
1030
|
-
a && (r[S.html] = new Blob([a], { type: S.html }));
|
|
1031
|
-
} catch (a) {
|
|
1032
|
-
n = a, console.warn("export to html", a);
|
|
1033
|
-
}
|
|
1034
|
-
try {
|
|
1035
|
-
const a = await t.toImage?.() ?? null;
|
|
1036
|
-
a && (r[S.png] = a);
|
|
1037
|
-
} catch (a) {
|
|
1038
|
-
n = a, console.warn("export to png", a);
|
|
1039
|
-
}
|
|
1040
|
-
const o = this._write({ uuid: fe(), ref: t, items: Object.keys(r).length > 0 ? [new ClipboardItem(r)] : null });
|
|
1041
|
-
if (n) throw n;
|
|
1042
|
-
return o;
|
|
1043
|
-
}
|
|
1044
|
-
clear(t = !1) {
|
|
1045
|
-
this._state && (this._state = null, t && this._write({ uuid: null, ref: null, items: null }), this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")));
|
|
1046
|
-
}
|
|
1047
|
-
async readReference() {
|
|
1048
|
-
return await this.read(), this._state?.ref ?? null;
|
|
1049
|
-
}
|
|
1050
|
-
readText() {
|
|
1051
|
-
return new Promise(async (t, n) => {
|
|
1052
|
-
const r = await this.read();
|
|
1053
|
-
let o = null;
|
|
1054
|
-
for (let i = 0; !o && r && i < r.length; i++) r[i].types.includes(S.plain) && (o = await r[i].getType(S.plain));
|
|
1055
|
-
if (!o) return void t("");
|
|
1056
|
-
const a = new FileReader();
|
|
1057
|
-
a.onload = () => {
|
|
1058
|
-
t(a.result);
|
|
1059
|
-
}, a.readAsText(o), a.onerror = (i) => {
|
|
1060
|
-
n(i);
|
|
1061
|
-
};
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
async writeText(t) {
|
|
1065
|
-
const n = [new ClipboardItem({ [S.plain]: new Blob([t], { type: S.plain }) })];
|
|
1066
|
-
return this._write({ uuid: fe(), items: n, ref: null });
|
|
1067
|
-
}
|
|
1068
|
-
addEventListener(t, n, r = {}) {
|
|
1069
|
-
const o = r?.capture ? this._listenersCapture : this._listeners;
|
|
1070
|
-
let a = o.get(t);
|
|
1071
|
-
a || (a = /* @__PURE__ */ new Map(), o.set(t, a)), a.set(n, typeof r == "boolean" ? {} : r);
|
|
1072
|
-
}
|
|
1073
|
-
dispatchEvent(t) {
|
|
1074
|
-
if (!t) return;
|
|
1075
|
-
const n = (r) => {
|
|
1076
|
-
const o = r.get(t.type);
|
|
1077
|
-
o && o.forEach((a, i) => {
|
|
1078
|
-
try {
|
|
1079
|
-
typeof i == "function" ? i(t) : i.handleEvent && i.handleEvent(t), a.once && o.delete(i);
|
|
1080
|
-
} catch (l) {
|
|
1081
|
-
console.warn(l);
|
|
1082
|
-
}
|
|
1083
|
-
});
|
|
1084
|
-
};
|
|
1085
|
-
return n(this._listenersCapture), n(this._listeners), !0;
|
|
1086
|
-
}
|
|
1087
|
-
removeEventListener(t, n, r) {
|
|
1088
|
-
const o = r?.capture ? this._listenersCapture : this._listeners, a = o.get(t);
|
|
1089
|
-
a && (a.delete(n), a.size === 0 && o.delete(t));
|
|
1090
|
-
}
|
|
1091
|
-
close() {
|
|
1092
|
-
globalThis.removeEventListener?.("focus", this._onFocus), globalThis.removeEventListener?.("blur", this._onBlur);
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
var Ce;
|
|
1096
|
-
(Ce = ot || (ot = {})).ErrorMessages = gt, Ce.Global = new Ce();
|
|
1097
|
-
const Wt = "__SHEETXL";
|
|
1098
|
-
let ee = null, se = null;
|
|
1099
|
-
async function Yt() {
|
|
1100
|
-
if (ee)
|
|
1101
|
-
return ee;
|
|
1102
|
-
if (se) {
|
|
1103
|
-
if (await se, !ee)
|
|
1104
|
-
throw new Error("ESBuild initialization promise resolved, but instance is not available.");
|
|
1105
|
-
return ee;
|
|
1106
|
-
}
|
|
1107
|
-
let e, t;
|
|
1108
|
-
se = new Promise((n, r) => {
|
|
1109
|
-
e = n, t = r;
|
|
1110
|
-
});
|
|
1111
|
-
try {
|
|
1112
|
-
const { initialize: n } = await Promise.resolve().then(function() {
|
|
1113
|
-
return ln;
|
|
1114
|
-
});
|
|
1115
|
-
return ee = await n(), e(), ee;
|
|
1116
|
-
} catch (n) {
|
|
1117
|
-
throw console.error("Failed to import or initialize esbuild:", n), se = null, t(n), n;
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
const Jt = {
|
|
1121
|
-
// ESBuild.TsconfigRaw =
|
|
1122
|
-
compilerOptions: {
|
|
1123
|
-
target: "esnext"
|
|
1124
|
-
}
|
|
1125
|
-
};
|
|
1126
|
-
async function Ht(e, t, n = "/script.js", r = Wt) {
|
|
1127
|
-
try {
|
|
1128
|
-
const o = await Yt(), a = "@sheetxl/primitives", i = \`
|
|
1129
|
-
export const FormulaContext = globalThis.\${r}?.FormulaContext;
|
|
1130
|
-
export const ScalarType = globalThis.\${r}?.ScalarType;
|
|
1131
|
-
export const Observable = globalThis.\${r}?.Observable;
|
|
1132
|
-
export const IRange = globalThis.\${r}?.IRange;
|
|
1133
|
-
export const FormulaError = globalThis.\${r}?.FormulaError;
|
|
1134
|
-
// Add more exports as needed
|
|
1135
|
-
\`, l = {
|
|
1136
|
-
// ESBuild.Plugin = {
|
|
1137
|
-
name: "sheetxl-esbuild-in-memory",
|
|
1138
|
-
setup(p) {
|
|
1139
|
-
const w = "sheetxl-" + (/* @__PURE__ */ new Date()).getTime();
|
|
1140
|
-
p.onResolve({ filter: new RegExp(\`^(\${n.replace("/", "\\\\/")}|\${a})$\`) }, (g) => ({
|
|
1141
|
-
path: g.path,
|
|
1142
|
-
namespace: w
|
|
1143
|
-
})), p.onResolve({ filter: /.*/ }, (g) => {
|
|
1144
|
-
if (g.namespace !== w)
|
|
1145
|
-
return console.warn(\`esbuild: Treating import "\${g.path}" as external.\`), { path: g.path, external: !0 };
|
|
1146
|
-
}), p.onLoad({ filter: /.*/, namespace: w }, (g) => {
|
|
1147
|
-
let f;
|
|
1148
|
-
if (g.path === n)
|
|
1149
|
-
f = t;
|
|
1150
|
-
else if (g.path === a)
|
|
1151
|
-
f = i;
|
|
1152
|
-
else
|
|
1153
|
-
return {
|
|
1154
|
-
errors: [{ text: \`Cannot load unknown path in \${w}: \${g.path}\` }]
|
|
1155
|
-
};
|
|
1156
|
-
return {
|
|
1157
|
-
contents: f,
|
|
1158
|
-
loader: "ts"
|
|
1159
|
-
// leave this as 'ts' so esbuild generates proper sourcemaps
|
|
1160
|
-
};
|
|
1161
|
-
});
|
|
1162
|
-
}
|
|
1163
|
-
}, s = await o.build({
|
|
1164
|
-
entryPoints: [n],
|
|
1165
|
-
// Use the virtual entry point
|
|
1166
|
-
bundle: !0,
|
|
1167
|
-
// IMPORTANT: Enable bundling
|
|
1168
|
-
write: !1,
|
|
1169
|
-
// IMPORTANT: Return result in memory
|
|
1170
|
-
format: "esm",
|
|
1171
|
-
// Output format
|
|
1172
|
-
plugins: [l],
|
|
1173
|
-
// TODO - later change to external and prepend when executing from ui
|
|
1174
|
-
sourcemap: "inline",
|
|
1175
|
-
// Generate separate source map string
|
|
1176
|
-
tsconfigRaw: Jt,
|
|
1177
|
-
// Pass the mapped options
|
|
1178
|
-
minify: !0,
|
|
1179
|
-
// sourcemap: 'external', // Generate separate source map string
|
|
1180
|
-
// Or use 'inline' if you prefer data URLs embedded in the code
|
|
1181
|
-
// To suppress warnings about dynamic import() if esbuild complains:
|
|
1182
|
-
// supported: { 'dynamic-import': true },
|
|
1183
|
-
platform: "neutral"
|
|
1184
|
-
// not really needed
|
|
1185
|
-
});
|
|
1186
|
-
if (s.outputFiles && s.outputFiles.length > 0)
|
|
1187
|
-
return s.outputFiles[0].text;
|
|
1188
|
-
throw s.errors && s.errors.length > 0 ? new Error(\`esbuild bundling failed: \${s.errors.map((p) => p.text).join(\`
|
|
1189
|
-
\`)}\`) : new Error("esbuild did not produce an output file.");
|
|
1190
|
-
} catch (o) {
|
|
1191
|
-
throw console.error("esbuild bundling process failed:", o), o;
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
const Xt = \`
|
|
1195
|
-
/**
|
|
1196
|
-
* Represents the completion of an asynchronous operation
|
|
1197
|
-
*/
|
|
1198
|
-
interface Promise<T> {
|
|
1199
|
-
/**
|
|
1200
|
-
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
1201
|
-
* resolved value cannot be modified from the callback.
|
|
1202
|
-
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
1203
|
-
* @returns A Promise for the completion of the callback.
|
|
1204
|
-
*/
|
|
1205
|
-
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
|
1206
|
-
}
|
|
1207
|
-
\`, Zt = \`
|
|
1208
|
-
interface FirstTest {
|
|
1209
|
-
isTrue?: boolean;
|
|
1210
|
-
}
|
|
1211
|
-
\`, Qt = async () => Zt, Et = /* @__PURE__ */ new Map([
|
|
1212
|
-
["IReferenceRange", "r"],
|
|
1213
|
-
["IRange", "l"]
|
|
1214
|
-
]), St = /* @__PURE__ */ new Map([
|
|
1215
|
-
["IWorkbook", "workbook"],
|
|
1216
|
-
["ISheet", "sheet"],
|
|
1217
|
-
["ICellRanges", "ranges"],
|
|
1218
|
-
["ICellRange", "range"],
|
|
1219
|
-
["IFormulaContext", "context"]
|
|
1220
|
-
]), Ne = (e, t) => {
|
|
1221
|
-
Array.from(t.keys()).forEach((r) => {
|
|
1222
|
-
const o = t.get(r);
|
|
1223
|
-
t.set(\`\${e}.\${r}\`, o);
|
|
1224
|
-
});
|
|
1225
|
-
}, en = /* @__PURE__ */ new Map([
|
|
1226
|
-
["Scalar", "*"],
|
|
1227
|
-
["FormulaError.Known", W.Error],
|
|
1228
|
-
["Date", "Date"],
|
|
1229
|
-
["JSON", "JSON"]
|
|
1230
|
-
]), tn = /* @__PURE__ */ new Map([
|
|
1231
|
-
// Repeating
|
|
1232
|
-
]), Re = "SheetXL";
|
|
1233
|
-
Ne(Re, Et);
|
|
1234
|
-
Ne(Re, St);
|
|
1235
|
-
Ne(Re, tn);
|
|
1236
|
-
const nn = /* @__PURE__ */ new Map([
|
|
1237
|
-
["Promise", () => ({ async: !0 })],
|
|
1238
|
-
// ['PromiseLike', (): Partial<IFunction.ReturnTypeJSON> => {
|
|
1239
|
-
// return { async: true };
|
|
1240
|
-
// }],
|
|
1241
|
-
["Observable", () => ({ stream: !0 })]
|
|
1242
|
-
]);
|
|
1243
|
-
let ce = null;
|
|
1244
|
-
async function rn() {
|
|
1245
|
-
if (ce)
|
|
1246
|
-
return ce;
|
|
1247
|
-
try {
|
|
1248
|
-
return await (await Promise.resolve().then(function() {
|
|
1249
|
-
return cn;
|
|
1250
|
-
})).initialize();
|
|
1251
|
-
} catch (e) {
|
|
1252
|
-
throw ce = null, e;
|
|
1253
|
-
} finally {
|
|
1254
|
-
ce = null;
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
async function on(e) {
|
|
1258
|
-
const t = e?.source ?? null;
|
|
1259
|
-
if (!t) return null;
|
|
1260
|
-
const n = (e.disableBundle || e.declarationsOnly) ?? !1, r = [
|
|
1261
|
-
Qt(),
|
|
1262
|
-
//import('typescript'), // when bundled, but node check causes issues. We could bundle replace isNode but felt hacky
|
|
1263
|
-
rn()
|
|
1264
|
-
], o = await Promise.all(r), a = o[0], i = o[1];
|
|
1265
|
-
let l = "", s = null;
|
|
1266
|
-
const p = [], w = {
|
|
1267
|
-
allowJs: !0,
|
|
1268
|
-
declaration: !1,
|
|
1269
|
-
sourceMap: !1,
|
|
1270
|
-
// was true but now bundler will do this
|
|
1271
|
-
inlineSourceMap: !1,
|
|
1272
|
-
inlineSources: !1,
|
|
1273
|
-
isolatedModules: !0,
|
|
1274
|
-
preserveConstEnums: !1,
|
|
1275
|
-
// types: ['WebWorker'],
|
|
1276
|
-
module: 99,
|
|
1277
|
-
//"esNext",
|
|
1278
|
-
noResolve: !0,
|
|
1279
|
-
emitDeclarationOnly: !1,
|
|
1280
|
-
target: i.ScriptTarget.ES2020
|
|
1281
|
-
// lib: ['webworker', 'es2020', 'esnext.asynciterable'], // Use the webworker lib instead of dom
|
|
1282
|
-
}, g = "script", f = \`\${g}.ts\`, y = "lib.d.ts", x = "global.d.ts", A = {
|
|
1283
|
-
[f]: t,
|
|
1284
|
-
[y]: Xt,
|
|
1285
|
-
[x]: a
|
|
1286
|
-
}, U = {
|
|
1287
|
-
getSourceFile: (c, m, L, F) => i.createSourceFile(c, A[c], i.ScriptTarget.Latest, !0),
|
|
1288
|
-
fileExists: (c) => A[c] !== void 0,
|
|
1289
|
-
readFile: (c) => A[c],
|
|
1290
|
-
writeFile: (c, m) => {
|
|
1291
|
-
A[c] = m;
|
|
1292
|
-
},
|
|
1293
|
-
// not used
|
|
1294
|
-
getCurrentDirectory: () => "./",
|
|
1295
|
-
getCanonicalFileName: (c) => c,
|
|
1296
|
-
useCaseSensitiveFileNames: () => !0,
|
|
1297
|
-
getDefaultLibFileName: (c) => y,
|
|
1298
|
-
getNewLine: () => \`
|
|
1299
|
-
\`
|
|
1300
|
-
}, B = i.createProgram([f, x], w, U), O = B.getTypeChecker(), J = B.getSourceFile(f), b = B.emit();
|
|
1301
|
-
b.diagnostics.length > 0 && console.warn(b.diagnostics), l = A[\`\${g}.js\`];
|
|
1302
|
-
const u = (c, m, L, F) => {
|
|
1303
|
-
if (!c) {
|
|
1304
|
-
z(c, new Error(\`Type is not defined for '\${m?.name ?? "return"}'.\`));
|
|
1305
|
-
return;
|
|
1306
|
-
}
|
|
1307
|
-
if (c.kind === i.SyntaxKind.NumberKeyword)
|
|
1308
|
-
m.scalar = W.Number;
|
|
1309
|
-
else if (c.kind === i.SyntaxKind.StringKeyword)
|
|
1310
|
-
m.scalar = W.String;
|
|
1311
|
-
else if (c.kind === i.SyntaxKind.BooleanKeyword)
|
|
1312
|
-
m.scalar = W.Boolean;
|
|
1313
|
-
else if (c.kind === i.SyntaxKind.UndefinedKeyword || c.kind === i.SyntaxKind.NullKeyword || c.kind === i.SyntaxKind.VoidKeyword) {
|
|
1314
|
-
if (F) {
|
|
1315
|
-
z(c, new Error(\`'undefined' is not a valid type for input: '\${c?.parent?.name?.escapedText}'.\`));
|
|
1316
|
-
return;
|
|
1317
|
-
}
|
|
1318
|
-
m.scalar = W.Null;
|
|
1319
|
-
} else if (c.kind === i.SyntaxKind.BigIntKeyword)
|
|
1320
|
-
m.scalar = W.Number;
|
|
1321
|
-
else if (c.kind === i.SyntaxKind.AnyKeyword)
|
|
1322
|
-
m.scalar = W.Null;
|
|
1323
|
-
else if (c.kind === i.SyntaxKind.ArrayType) {
|
|
1324
|
-
const M = c.elementType;
|
|
1325
|
-
if (!M) {
|
|
1326
|
-
z(c, new Error(\`'Array' must be typed: '\${c?.parent?.name?.escapedText}'.\`));
|
|
1327
|
-
return;
|
|
1328
|
-
}
|
|
1329
|
-
m.arrayDepth = (m.arrayDepth ?? 0) + 1, u(M, m, L, F);
|
|
1330
|
-
} else if (c.kind !== i.SyntaxKind.TupleType) {
|
|
1331
|
-
if (c.kind === i.SyntaxKind.TypeReference) {
|
|
1332
|
-
const M = c.typeName?.getText?.() ?? null, V = Et.get(M);
|
|
1333
|
-
let q = !1;
|
|
1334
|
-
V && (m.range = V, q = !0);
|
|
1335
|
-
const G = en.get(M);
|
|
1336
|
-
if (G && (m.scalar = G), G !== void 0 && (q = !0), F) {
|
|
1337
|
-
const N = St.get(M);
|
|
1338
|
-
if (N)
|
|
1339
|
-
return N;
|
|
1340
|
-
} else {
|
|
1341
|
-
const N = nn.get(M);
|
|
1342
|
-
if (N) {
|
|
1343
|
-
const E = { ...m, ...N() };
|
|
1344
|
-
let I = 0;
|
|
1345
|
-
if (E.async && I++, E.stream && I++, I > 1) {
|
|
1346
|
-
z(c, new Error(\`'\${M}' cannot have multiple modifiers: '\${c?.parent?.name?.escapedText}'.\`));
|
|
1347
|
-
return;
|
|
1348
|
-
}
|
|
1349
|
-
m = E, q = !0;
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
if (!q) {
|
|
1353
|
-
z("node", new Error(\`'\${M}' is not a valid type: '\${c?.parent?.name?.escapedText}'.\`));
|
|
1354
|
-
return;
|
|
1355
|
-
}
|
|
1356
|
-
const H = c.typeArguments;
|
|
1357
|
-
if (H) {
|
|
1358
|
-
if (H.length !== 1) {
|
|
1359
|
-
z(c, new Error(\`'\${M}' must be typed with exactly 1 type: '\${c?.parent?.name?.escapedText}'.\`));
|
|
1360
|
-
return;
|
|
1361
|
-
}
|
|
1362
|
-
u(H[0], m, L, F);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
}, h = (c) => (i.getCombinedModifierFlags(c) & i.ModifierFlags.Export) !== 0, pe = (c) => (i.getCombinedModifierFlags(c) & i.ModifierFlags.Default) !== 0, $ = [], z = (c, m) => {
|
|
1367
|
-
$.push(m);
|
|
1368
|
-
};
|
|
1369
|
-
if (i.forEachChild(J, (c) => {
|
|
1370
|
-
if (h(c) && i.isFunctionDeclaration(c)) {
|
|
1371
|
-
const m = {}, L = {
|
|
1372
|
-
parameters: {}
|
|
1373
|
-
}, F = c?.name?.getText();
|
|
1374
|
-
try {
|
|
1375
|
-
m.name = F;
|
|
1376
|
-
const V = O.getSymbolAtLocation(c.name).getDocumentationComment(O);
|
|
1377
|
-
if (V && V.length > 0 && V[0].text) {
|
|
1378
|
-
let N = V[0].text;
|
|
1379
|
-
N = N.replace(/[\\r\\n]+/g, "\\\\n").trim(), L.summary = N;
|
|
1380
|
-
}
|
|
1381
|
-
const q = {};
|
|
1382
|
-
u(c.type, q, m, !1), m.returnType = q;
|
|
1383
|
-
const G = {};
|
|
1384
|
-
pe(c) && (G.default = !0, s = F), Object.keys(G).length > 0 && (m.behavior = G), m.parameters = [];
|
|
1385
|
-
const H = /* @__PURE__ */ new Map();
|
|
1386
|
-
for (let N = 0; N < c.parameters.length; N++) {
|
|
1387
|
-
const E = c.parameters[N], I = {};
|
|
1388
|
-
I.name = E.name?.getText();
|
|
1389
|
-
const X = u(E.type, I, m, !0);
|
|
1390
|
-
if (X) {
|
|
1391
|
-
if (m.parameters.length !== 0) {
|
|
1392
|
-
const ie = c?.parent?.name?.getText();
|
|
1393
|
-
z(c, new Error(\`'\${m.name}' contexts must be the first parameter: '\${ie}'.\`));
|
|
1394
|
-
return;
|
|
1395
|
-
}
|
|
1396
|
-
m.context = X;
|
|
1397
|
-
continue;
|
|
1398
|
-
}
|
|
1399
|
-
const he = !((E.initializer === void 0 || E.initializer === null) && (E.questionToken === void 0 || E.questionToken === null));
|
|
1400
|
-
let j;
|
|
1401
|
-
if (he && (I.optional = !0, E.initializer))
|
|
1402
|
-
try {
|
|
1403
|
-
E.initializer.kind === i.SyntaxKind.StringLiteral ? j = E.initializer.text : E.initializer.kind === i.SyntaxKind.NumericLiteral ? j = parseFloat(E.initializer.text) : E.initializer.kind === i.SyntaxKind.TrueKeyword || E.initializer.kind === i.SyntaxKind.FalseKeyword ? j = E.initializer.kind === i.SyntaxKind.TrueKeyword : E.initializer.kind === i.SyntaxKind.NullKeyword ? j = null : E.initializer.kind === i.SyntaxKind.ObjectLiteralExpression || E.initializer.kind === i.SyntaxKind.ArrayLiteralExpression ? j = E.initializer.getText() : j = E.initializer.getText?.();
|
|
1404
|
-
} catch (C) {
|
|
1405
|
-
console.warn(\`Couldn't extract default value for parameter '\${I.name}'\`, C);
|
|
1406
|
-
}
|
|
1407
|
-
E.dotDotDotToken && (I.rest = !0), m.parameters.push(I);
|
|
1408
|
-
const D = { description: "" };
|
|
1409
|
-
L.parameters[I.name] = D;
|
|
1410
|
-
const _ = O.getSymbolAtLocation(E.name).getDocumentationComment(O);
|
|
1411
|
-
_ && _.length > 0 && _[0].text && (D.description = _[0].text), j !== void 0 && (D.defaultValue = j), H.set(I.name, I);
|
|
1412
|
-
}
|
|
1413
|
-
if (c.jsDoc && c.jsDoc.length > 0) {
|
|
1414
|
-
const N = c.jsDoc, E = N.length;
|
|
1415
|
-
for (let I = 0; I < E; I++) {
|
|
1416
|
-
const X = N[I]?.tags;
|
|
1417
|
-
if (!X) continue;
|
|
1418
|
-
const he = X.length;
|
|
1419
|
-
for (let j = 0; j < he; j++) {
|
|
1420
|
-
const D = X[j];
|
|
1421
|
-
let _ = D?.tagName?.text;
|
|
1422
|
-
if (!_) continue;
|
|
1423
|
-
_ = _.toLowerCase();
|
|
1424
|
-
let C = D.comment;
|
|
1425
|
-
const ie = _ === "hidden";
|
|
1426
|
-
if (!(typeof C != "string" && !ie) && (typeof C == "string" && (C = C.replace(/[\\r\\n]+/g, "\\\\n").trim()), !(!ie && C && (C = C.split(/\\\\n/)[0], !C || C.length === 0)))) {
|
|
1427
|
-
if (C && typeof C == "string") {
|
|
1428
|
-
const R = /\\{@link(code|plain)?\\s+([^}|]+)(?:\\s*\\|\\s*([^}]+))?\\}/g;
|
|
1429
|
-
let K, Z = C, te = [];
|
|
1430
|
-
for (; (K = R.exec(C)) !== null; ) {
|
|
1431
|
-
const [me, we, Ct, Le] = K, vt = [Ct.trim()];
|
|
1432
|
-
Le && vt.push(Le.trim());
|
|
1433
|
-
}
|
|
1434
|
-
C = Z, te.length > 0 && _ === "see" && (L.links || (L.links = []), L.links.push(...te));
|
|
1435
|
-
}
|
|
1436
|
-
if (_ === "name") {
|
|
1437
|
-
const R = C;
|
|
1438
|
-
R !== F && (L.name = R);
|
|
1439
|
-
} else if (_ === "description") {
|
|
1440
|
-
const R = C;
|
|
1441
|
-
} else if (_ === "summary") {
|
|
1442
|
-
const R = C;
|
|
1443
|
-
R && (L.summary = R);
|
|
1444
|
-
} else if (_ === "param") {
|
|
1445
|
-
const R = D.name?.text, K = H.get(R);
|
|
1446
|
-
if (!K) {
|
|
1447
|
-
$.push(new Error(\`Parameter '\${R}' not found in function '\${F}'.\`));
|
|
1448
|
-
continue;
|
|
1449
|
-
}
|
|
1450
|
-
if (D.typeExpression && D.typeExpression.type)
|
|
1451
|
-
try {
|
|
1452
|
-
const Z = D.typeExpression.type;
|
|
1453
|
-
if (Z.kind === i.SyntaxKind.UnionType) {
|
|
1454
|
-
const te = [];
|
|
1455
|
-
K.enums = te, Z.types.forEach((me) => {
|
|
1456
|
-
if (me.kind === i.SyntaxKind.LiteralType) {
|
|
1457
|
-
const we = me.literal.text;
|
|
1458
|
-
we && te.push(we);
|
|
1459
|
-
}
|
|
1460
|
-
});
|
|
1461
|
-
}
|
|
1462
|
-
} catch (Z) {
|
|
1463
|
-
console.warn("Error parsing JSDoc type expression:", Z);
|
|
1464
|
-
}
|
|
1465
|
-
} else if (_ === "returns" || _ === "return")
|
|
1466
|
-
m.returnType.description = C;
|
|
1467
|
-
else if (_ === "category")
|
|
1468
|
-
L.category = C;
|
|
1469
|
-
else if (_ === "hidden") {
|
|
1470
|
-
let R = !0;
|
|
1471
|
-
const K = C?.toLowerCase();
|
|
1472
|
-
K === "false" ? R = !1 : K !== "true" && (R = C), R !== !1 && (L.hidden = R ?? !0);
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
Object.keys(m.returnType).length === 0 && delete m.returnType, p.push([m, L]);
|
|
1479
|
-
} catch (M) {
|
|
1480
|
-
z(c, new Error(\`'\${F}': \${M.message}\`));
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
}), $.length > 0)
|
|
1484
|
-
throw console.warn($), new Error("There were compilation errors.", { cause: $ });
|
|
1485
|
-
if (p.length === 0)
|
|
1486
|
-
throw new Error("No exported functions.");
|
|
1487
|
-
const xt = \`\${Kt.uuidV4()}-script\`;
|
|
1488
|
-
try {
|
|
1489
|
-
!n && $.length === 0 && (l = await Ht(i, l, g));
|
|
1490
|
-
} catch {
|
|
1491
|
-
console.warn("Error bundling script");
|
|
1492
|
-
}
|
|
1493
|
-
const ke = {
|
|
1494
|
-
functions: p,
|
|
1495
|
-
commitId: xt,
|
|
1496
|
-
source: t,
|
|
1497
|
-
name: "Script",
|
|
1498
|
-
language: "typescript",
|
|
1499
|
-
// default
|
|
1500
|
-
compiled: l
|
|
1501
|
-
};
|
|
1502
|
-
return s && (ke.autoRun = s), ke;
|
|
1503
|
-
}
|
|
1504
|
-
self.addEventListener("message", async (e) => {
|
|
1505
|
-
const { id: t, params: n } = e.data;
|
|
1506
|
-
try {
|
|
1507
|
-
const r = await on(n);
|
|
1508
|
-
self.postMessage({ id: t, result: r, error: null });
|
|
1509
|
-
} catch (r) {
|
|
1510
|
-
self.postMessage({
|
|
1511
|
-
id: t,
|
|
1512
|
-
result: null,
|
|
1513
|
-
error: {
|
|
1514
|
-
message: r.message,
|
|
1515
|
-
stack: r.stack,
|
|
1516
|
-
cause: r.cause
|
|
1517
|
-
}
|
|
1518
|
-
});
|
|
1519
|
-
}
|
|
1520
|
-
});
|
|
1521
|
-
let ue = null;
|
|
1522
|
-
async function an() {
|
|
1523
|
-
return ue || (ue = new Promise(async (e, t) => {
|
|
1524
|
-
try {
|
|
1525
|
-
const n = "0.20.2", r = \`https://esm.sh/esbuild-wasm@\${n}\`, o = \`https://esm.sh/esbuild-wasm@\${n}/esbuild.wasm\`, i = (await import(
|
|
1526
|
-
/* webpackIgnore: true */
|
|
1527
|
-
/* @vite-ignore */
|
|
1528
|
-
r
|
|
1529
|
-
)).default;
|
|
1530
|
-
await i.initialize({
|
|
1531
|
-
wasmURL: o,
|
|
1532
|
-
// Provide the specific WASM URL
|
|
1533
|
-
worker: !1
|
|
1534
|
-
// Keep processing on the current thread
|
|
1535
|
-
}), e(i);
|
|
1536
|
-
} catch (n) {
|
|
1537
|
-
console.error("Error initializing esbuild:", n), t(n);
|
|
1538
|
-
}
|
|
1539
|
-
}), ue);
|
|
1540
|
-
}
|
|
1541
|
-
var ln = /* @__PURE__ */ Object.freeze({
|
|
1542
|
-
__proto__: null,
|
|
1543
|
-
initialize: an
|
|
1544
|
-
});
|
|
1545
|
-
let de = null;
|
|
1546
|
-
async function sn() {
|
|
1547
|
-
return de || (de = new Promise(async (e, t) => {
|
|
1548
|
-
let n = null;
|
|
1549
|
-
try {
|
|
1550
|
-
n = await import("https://esm.sh/typescript@5.7.2");
|
|
1551
|
-
} catch (r) {
|
|
1552
|
-
console.error("Error initializing Browser TypeScript module:", r);
|
|
1553
|
-
}
|
|
1554
|
-
n || console.log("use script fallback"), e(n);
|
|
1555
|
-
}), de);
|
|
1556
|
-
}
|
|
1557
|
-
var cn = /* @__PURE__ */ Object.freeze({
|
|
1558
|
-
__proto__: null,
|
|
1559
|
-
initialize: sn
|
|
1560
|
-
});
|
|
1561
|
-
`, i = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", s], { type: "text/javascript;charset=utf-8" });
|
|
1562
|
-
function d(e) {
|
|
1563
|
-
let n;
|
|
1564
|
-
try {
|
|
1565
|
-
if (n = i && (self.URL || self.webkitURL).createObjectURL(i), !n) throw "";
|
|
1566
|
-
const t = new Worker(n, { type: "module", name: e?.name });
|
|
1567
|
-
return t.addEventListener("error", () => {
|
|
1568
|
-
(self.URL || self.webkitURL).revokeObjectURL(n);
|
|
1569
|
-
}), t;
|
|
1570
|
-
} catch {
|
|
1571
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(s), { type: "module", name: e?.name });
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
async function p() {
|
|
1575
|
-
if (typeof process < "u" && process.versions?.node && typeof Worker > "u")
|
|
1576
|
-
return await l();
|
|
1577
|
-
if (typeof Worker < "u") {
|
|
1578
|
-
const e = new c(() => new d());
|
|
1579
|
-
try {
|
|
1580
|
-
return await e.start(), e;
|
|
1581
|
-
} catch (n) {
|
|
1582
|
-
console.error("Failed to start TypescriptCompiler worker reverting to fallback:", n);
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
return await l();
|
|
1586
|
-
}
|
|
1587
|
-
const l = async () => {
|
|
1588
|
-
const { compileModule: e } = await import("./C1nmZG6Nh598I5Cy.mjs"), n = new u((t) => e(t));
|
|
1589
|
-
return await n.start(), n;
|
|
1590
|
-
};
|
|
1591
|
-
export {
|
|
1592
|
-
p as createCompilerWorker
|
|
1593
|
-
};
|