@weapp-sqlite/sqljs 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lite.mjs CHANGED
@@ -1,2393 +1,8 @@
1
- import { createRequire } from "node:module";
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
21
- value: mod,
22
- enumerable: true
23
- }) : target, mod));
24
- var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
25
- const initSqlJsLite = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
26
- var initSqlJsPromise = void 0;
27
- var initSqlJs = function(moduleConfig) {
28
- if (initSqlJsPromise) return initSqlJsPromise;
29
- initSqlJsPromise = new Promise(function(resolveModule, reject) {
30
- var Module = typeof moduleConfig !== "undefined" ? moduleConfig : {};
31
- var originalOnAbortFunction = Module["onAbort"];
32
- Module["onAbort"] = function(errorThatCausedAbort) {
33
- reject(new Error(errorThatCausedAbort));
34
- if (originalOnAbortFunction) originalOnAbortFunction(errorThatCausedAbort);
35
- };
36
- Module["postRun"] = Module["postRun"] || [];
37
- Module["postRun"].push(function() {
38
- resolveModule(Module);
39
- });
40
- module = void 0;
41
- var k;
42
- k ||= typeof Module != "undefined" ? Module : {};
43
- var aa = !!globalThis.window, ba = !!globalThis.WorkerGlobalScope, ca = globalThis.process?.versions?.node && "renderer" != globalThis.process?.type;
44
- k.onRuntimeInitialized = function() {
45
- function a(f, l) {
46
- switch (typeof l) {
47
- case "boolean":
48
- cc(f, l ? 1 : 0);
49
- break;
50
- case "number":
51
- dc(f, l);
52
- break;
53
- case "string":
54
- ec(f, l, -1, -1);
55
- break;
56
- case "object":
57
- if (null === l) lb(f);
58
- else if (null != l.length) {
59
- var n = da(l.length);
60
- m.set(l, n);
61
- fc(f, n, l.length, -1);
62
- ea(n);
63
- } else va(f, "Wrong API use : tried to return a value of an unknown type (" + l + ").", -1);
64
- break;
65
- default: lb(f);
66
- }
67
- }
68
- function b(f, l) {
69
- for (var n = [], p = 0; p < f; p += 1) {
70
- var r = t(l + 4 * p, "i32"), w = gc(r);
71
- if (1 === w || 2 === w) r = hc(r);
72
- else if (3 === w) r = ic(r);
73
- else if (4 === w) {
74
- w = r;
75
- r = jc(w);
76
- w = kc(w);
77
- for (var J = new Uint8Array(r), I = 0; I < r; I += 1) J[I] = m[w + I];
78
- r = J;
79
- } else r = null;
80
- n.push(r);
81
- }
82
- return n;
83
- }
84
- function c(f, l) {
85
- this.Na = f;
86
- this.db = l;
87
- this.La = 1;
88
- this.jb = [];
89
- }
90
- function d(f, l) {
91
- this.db = l;
92
- this.bb = fa(f);
93
- if (null === this.bb) throw Error("Unable to allocate memory for the SQL string");
94
- this.ib = this.bb;
95
- this.Xa = this.pb = null;
96
- }
97
- function e(f) {
98
- this.filename = "dbfile_" + (4294967295 * Math.random() >>> 0);
99
- if (null != f) {
100
- var l = this.filename, n = "/", p = l;
101
- n && (n = "string" == typeof n ? n : ha(n), p = l ? ia(n + "/" + l) : n);
102
- l = ja(!0, !0);
103
- p = la(p, l);
104
- if (f) {
105
- if ("string" == typeof f) {
106
- n = Array(f.length);
107
- for (var r = 0, w = f.length; r < w; ++r) n[r] = f.charCodeAt(r);
108
- f = n;
109
- }
110
- ma(p, l | 146);
111
- n = na(p, 577);
112
- oa(n, f, 0, f.length, 0);
113
- pa(n);
114
- ma(p, l);
115
- }
116
- }
117
- this.handleError(q(this.filename, g));
118
- this.db = t(g, "i32");
119
- this.cb = {};
120
- this.Pa = {};
121
- }
122
- var g = y(4), h = k.cwrap, q = h("sqlite3_open", "number", ["string", "number"]), v = h("sqlite3_close_v2", "number", ["number"]), u = h("sqlite3_exec", "number", [
123
- "number",
124
- "string",
125
- "number",
126
- "number",
127
- "number"
128
- ]), x = h("sqlite3_changes", "number", ["number"]), C = h("sqlite3_prepare_v2", "number", [
129
- "number",
130
- "string",
131
- "number",
132
- "number",
133
- "number"
134
- ]), ob = h("sqlite3_sql", "string", ["number"]), pb = h("sqlite3_prepare_v2", "number", [
135
- "number",
136
- "number",
137
- "number",
138
- "number",
139
- "number"
140
- ]), mc = h("sqlite3_bind_text", "number", [
141
- "number",
142
- "number",
143
- "number",
144
- "number",
145
- "number"
146
- ]), qb = h("sqlite3_bind_blob", "number", [
147
- "number",
148
- "number",
149
- "number",
150
- "number",
151
- "number"
152
- ]), nc = h("sqlite3_bind_double", "number", [
153
- "number",
154
- "number",
155
- "number"
156
- ]), oc = h("sqlite3_bind_int", "number", [
157
- "number",
158
- "number",
159
- "number"
160
- ]), pc = h("sqlite3_bind_parameter_index", "number", ["number", "string"]), qc = h("sqlite3_step", "number", ["number"]), rc = h("sqlite3_errmsg", "string", ["number"]), sc = h("sqlite3_column_count", "number", ["number"]), tc = h("sqlite3_data_count", "number", ["number"]), uc = h("sqlite3_column_double", "number", ["number", "number"]), rb = h("sqlite3_column_text", "string", ["number", "number"]), vc = h("sqlite3_column_blob", "number", ["number", "number"]), wc = h("sqlite3_column_bytes", "number", ["number", "number"]), xc = h("sqlite3_column_type", "number", ["number", "number"]), yc = h("sqlite3_column_name", "string", ["number", "number"]), zc = h("sqlite3_reset", "number", ["number"]), Ac = h("sqlite3_clear_bindings", "number", ["number"]), Bc = h("sqlite3_finalize", "number", ["number"]), sb = h("sqlite3_create_function_v2", "number", "number string number number number number number number number".split(" ")), gc = h("sqlite3_value_type", "number", ["number"]), jc = h("sqlite3_value_bytes", "number", ["number"]), ic = h("sqlite3_value_text", "string", ["number"]), kc = h("sqlite3_value_blob", "number", ["number"]), hc = h("sqlite3_value_double", "number", ["number"]), dc = h("sqlite3_result_double", "", ["number", "number"]), lb = h("sqlite3_result_null", "", ["number"]), ec = h("sqlite3_result_text", "", [
161
- "number",
162
- "string",
163
- "number",
164
- "number"
165
- ]), fc = h("sqlite3_result_blob", "", [
166
- "number",
167
- "number",
168
- "number",
169
- "number"
170
- ]), cc = h("sqlite3_result_int", "", ["number", "number"]), va = h("sqlite3_result_error", "", [
171
- "number",
172
- "string",
173
- "number"
174
- ]), tb = h("sqlite3_aggregate_context", "number", ["number", "number"]), ub = h("sqlite3_update_hook", "number", [
175
- "number",
176
- "number",
177
- "number"
178
- ]);
179
- c.prototype.bind = function(f) {
180
- if (!this.Na) throw "Statement closed";
181
- this.reset();
182
- return Array.isArray(f) ? this.Db(f) : null != f && "object" === typeof f ? this.Eb(f) : !0;
183
- };
184
- c.prototype.step = function() {
185
- if (!this.Na) throw "Statement closed";
186
- this.La = 1;
187
- var f = qc(this.Na);
188
- switch (f) {
189
- case 100: return !0;
190
- case 101: return !1;
191
- default: throw this.db.handleError(f);
192
- }
193
- };
194
- c.prototype.xb = function(f) {
195
- f ?? (f = this.La, this.La += 1);
196
- return uc(this.Na, f);
197
- };
198
- c.prototype.Lb = function(f) {
199
- f ?? (f = this.La, this.La += 1);
200
- f = rb(this.Na, f);
201
- if ("function" !== typeof BigInt) throw Error("BigInt is not supported");
202
- return BigInt(f);
203
- };
204
- c.prototype.Pb = function(f) {
205
- f ?? (f = this.La, this.La += 1);
206
- return rb(this.Na, f);
207
- };
208
- c.prototype.getBlob = function(f) {
209
- f ?? (f = this.La, this.La += 1);
210
- var l = wc(this.Na, f);
211
- f = vc(this.Na, f);
212
- for (var n = new Uint8Array(l), p = 0; p < l; p += 1) n[p] = m[f + p];
213
- return n;
214
- };
215
- c.prototype.get = function(f, l) {
216
- l = l || {};
217
- null != f && this.bind(f) && this.step();
218
- f = [];
219
- for (var n = tc(this.Na), p = 0; p < n; p += 1) switch (xc(this.Na, p)) {
220
- case 1:
221
- var r = l.useBigInt ? this.Lb(p) : this.xb(p);
222
- f.push(r);
223
- break;
224
- case 2:
225
- f.push(this.xb(p));
226
- break;
227
- case 3:
228
- f.push(this.Pb(p));
229
- break;
230
- case 4:
231
- f.push(this.getBlob(p));
232
- break;
233
- default: f.push(null);
234
- }
235
- return f;
236
- };
237
- c.prototype.nb = function() {
238
- for (var f = [], l = sc(this.Na), n = 0; n < l; n += 1) f.push(yc(this.Na, n));
239
- return f;
240
- };
241
- c.prototype.wb = function(f, l) {
242
- f = this.get(f, l);
243
- l = this.nb();
244
- for (var n = {}, p = 0; p < l.length; p += 1) n[l[p]] = f[p];
245
- return n;
246
- };
247
- c.prototype.Ob = function() {
248
- return ob(this.Na);
249
- };
250
- c.prototype.run = function(f) {
251
- null != f && this.bind(f);
252
- this.step();
253
- return this.reset();
254
- };
255
- c.prototype.tb = function(f, l) {
256
- l ?? (l = this.La, this.La += 1);
257
- f = fa(f);
258
- this.jb.push(f);
259
- this.db.handleError(mc(this.Na, l, f, -1, 0));
260
- };
261
- c.prototype.Cb = function(f, l) {
262
- l ?? (l = this.La, this.La += 1);
263
- var n = da(f.length);
264
- m.set(f, n);
265
- this.jb.push(n);
266
- this.db.handleError(qb(this.Na, l, n, f.length, 0));
267
- };
268
- c.prototype.sb = function(f, l) {
269
- l ?? (l = this.La, this.La += 1);
270
- this.db.handleError((f === (f | 0) ? oc : nc)(this.Na, l, f));
271
- };
272
- c.prototype.Fb = function(f) {
273
- f ?? (f = this.La, this.La += 1);
274
- qb(this.Na, f, 0, 0, 0);
275
- };
276
- c.prototype.ub = function(f, l) {
277
- l ?? (l = this.La, this.La += 1);
278
- switch (typeof f) {
279
- case "string":
280
- this.tb(f, l);
281
- return;
282
- case "number":
283
- this.sb(f, l);
284
- return;
285
- case "bigint":
286
- this.tb(f.toString(), l);
287
- return;
288
- case "boolean":
289
- this.sb(f + 0, l);
290
- return;
291
- case "object":
292
- if (null === f) {
293
- this.Fb(l);
294
- return;
295
- }
296
- if (null != f.length) {
297
- this.Cb(f, l);
298
- return;
299
- }
300
- }
301
- throw "Wrong API use : tried to bind a value of an unknown type (" + f + ").";
302
- };
303
- c.prototype.Eb = function(f) {
304
- var l = this;
305
- Object.keys(f).forEach(function(n) {
306
- var p = pc(l.Na, n);
307
- 0 !== p && l.ub(f[n], p);
308
- });
309
- return !0;
310
- };
311
- c.prototype.Db = function(f) {
312
- for (var l = 0; l < f.length; l += 1) this.ub(f[l], l + 1);
313
- return !0;
314
- };
315
- c.prototype.reset = function() {
316
- this.freemem();
317
- return 0 === Ac(this.Na) && 0 === zc(this.Na);
318
- };
319
- c.prototype.freemem = function() {
320
- for (var f; void 0 !== (f = this.jb.pop());) ea(f);
321
- };
322
- c.prototype.Va = function() {
323
- this.freemem();
324
- var f = 0 === Bc(this.Na);
325
- delete this.db.cb[this.Na];
326
- this.Na = 0;
327
- return f;
328
- };
329
- d.prototype.next = function() {
330
- if (null === this.bb) return { done: !0 };
331
- null !== this.Xa && (this.Xa.Va(), this.Xa = null);
332
- if (!this.db.db) throw this.lb(), Error("Database closed");
333
- var f = qa(), l = y(4);
334
- ra(g);
335
- ra(l);
336
- try {
337
- this.db.handleError(pb(this.db.db, this.ib, -1, g, l));
338
- this.ib = t(l, "i32");
339
- var n = t(g, "i32");
340
- if (0 === n) return this.lb(), { done: !0 };
341
- this.Xa = new c(n, this.db);
342
- this.db.cb[n] = this.Xa;
343
- return {
344
- value: this.Xa,
345
- done: !1
346
- };
347
- } catch (p) {
348
- throw this.pb = z(this.ib), this.lb(), p;
349
- } finally {
350
- sa(f);
351
- }
352
- };
353
- d.prototype.lb = function() {
354
- ea(this.bb);
355
- this.bb = null;
356
- };
357
- d.prototype.Mb = function() {
358
- return null !== this.pb ? this.pb : z(this.ib);
359
- };
360
- "function" === typeof Symbol && "symbol" === typeof Symbol.iterator && (d.prototype[Symbol.iterator] = function() {
361
- return this;
362
- });
363
- e.prototype.run = function(f, l) {
364
- if (!this.db) throw "Database closed";
365
- if (l) {
366
- f = this.qb(f, l);
367
- try {
368
- f.step();
369
- } finally {
370
- f.Va();
371
- }
372
- } else this.handleError(u(this.db, f, 0, 0, g));
373
- return this;
374
- };
375
- e.prototype.exec = function(f, l, n) {
376
- if (!this.db) throw "Database closed";
377
- var p = qa(), r = null, w = null, J = null;
378
- try {
379
- J = w = fa(f);
380
- var I = y(4);
381
- for (f = []; 0 !== t(J, "i8");) {
382
- ra(g);
383
- ra(I);
384
- this.handleError(pb(this.db, J, -1, g, I));
385
- var L = t(g, "i32");
386
- J = t(I, "i32");
387
- if (0 !== L) {
388
- var G = null;
389
- r = new c(L, this);
390
- for (null != l && r.bind(l); r.step();) null === G && (G = {
391
- columns: r.nb(),
392
- values: []
393
- }, f.push(G)), G.values.push(r.get(null, n));
394
- r.Va();
395
- }
396
- }
397
- return f;
398
- } catch (ka) {
399
- throw r && r.Va(), ka;
400
- } finally {
401
- w && ea(w), sa(p);
402
- }
403
- };
404
- e.prototype.Jb = function(f, l, n, p, r) {
405
- "function" === typeof l && (p = n, n = l, l = void 0);
406
- f = this.qb(f, l);
407
- try {
408
- for (; f.step();) n(f.wb(null, r));
409
- } finally {
410
- f.Va();
411
- }
412
- if ("function" === typeof p) return p();
413
- };
414
- e.prototype.qb = function(f, l) {
415
- ra(g);
416
- this.handleError(C(this.db, f, -1, g, 0));
417
- f = t(g, "i32");
418
- if (0 === f) throw "Nothing to prepare";
419
- var n = new c(f, this);
420
- null != l && n.bind(l);
421
- return this.cb[f] = n;
422
- };
423
- e.prototype.Qb = function(f) {
424
- return new d(f, this);
425
- };
426
- e.prototype.Kb = function() {
427
- Object.values(this.cb).forEach(function(l) {
428
- l.Va();
429
- });
430
- Object.values(this.Pa).forEach(A);
431
- this.Pa = {};
432
- this.handleError(v(this.db));
433
- var f = ta(this.filename);
434
- this.handleError(q(this.filename, g));
435
- this.db = t(g, "i32");
436
- return f;
437
- };
438
- e.prototype.close = function() {
439
- null !== this.db && (Object.values(this.cb).forEach(function(f) {
440
- f.Va();
441
- }), Object.values(this.Pa).forEach(A), this.Pa = {}, this.Wa && (A(this.Wa), this.Wa = void 0), this.handleError(v(this.db)), ua("/" + this.filename), this.db = null);
442
- };
443
- e.prototype.handleError = function(f) {
444
- if (0 === f) return null;
445
- f = rc(this.db);
446
- throw Error(f);
447
- };
448
- e.prototype.Nb = function() {
449
- return x(this.db);
450
- };
451
- e.prototype.Hb = function(f, l) {
452
- Object.prototype.hasOwnProperty.call(this.Pa, f) && (A(this.Pa[f]), delete this.Pa[f]);
453
- var n = wa(function(p, r, w) {
454
- r = b(r, w);
455
- try {
456
- var J = l.apply(null, r);
457
- } catch (I) {
458
- va(p, I, -1);
459
- return;
460
- }
461
- a(p, J);
462
- }, "viii");
463
- this.Pa[f] = n;
464
- this.handleError(sb(this.db, f, l.length, 1, 0, n, 0, 0, 0));
465
- return this;
466
- };
467
- e.prototype.Gb = function(f, l) {
468
- var n = l.init || function() {
469
- return null;
470
- }, p = l.finalize || function(L) {
471
- return L;
472
- }, r = l.step;
473
- if (!r) throw "An aggregate function must have a step function in " + f;
474
- var w = {};
475
- Object.hasOwnProperty.call(this.Pa, f) && (A(this.Pa[f]), delete this.Pa[f]);
476
- l = f + "__finalize";
477
- Object.hasOwnProperty.call(this.Pa, l) && (A(this.Pa[l]), delete this.Pa[l]);
478
- var J = wa(function(L, G, ka) {
479
- var V = tb(L, 1);
480
- Object.hasOwnProperty.call(w, V) || (w[V] = n());
481
- G = b(G, ka);
482
- G = [w[V]].concat(G);
483
- try {
484
- w[V] = r.apply(null, G);
485
- } catch (Dc) {
486
- delete w[V], va(L, Dc, -1);
487
- }
488
- }, "viii"), I = wa(function(L) {
489
- var G = tb(L, 1);
490
- try {
491
- var ka = p(w[G]);
492
- } catch (V) {
493
- delete w[G];
494
- va(L, V, -1);
495
- return;
496
- }
497
- a(L, ka);
498
- delete w[G];
499
- }, "vi");
500
- this.Pa[f] = J;
501
- this.Pa[l] = I;
502
- this.handleError(sb(this.db, f, r.length - 1, 1, 0, 0, J, I, 0));
503
- return this;
504
- };
505
- e.prototype.Vb = function(f) {
506
- this.Wa && (ub(this.db, 0, 0), A(this.Wa), this.Wa = void 0);
507
- if (!f) return this;
508
- this.Wa = wa(function(l, n, p, r, w) {
509
- switch (n) {
510
- case 18:
511
- l = "insert";
512
- break;
513
- case 23:
514
- l = "update";
515
- break;
516
- case 9:
517
- l = "delete";
518
- break;
519
- default: throw "unknown operationCode in updateHook callback: " + n;
520
- }
521
- p = z(p);
522
- r = z(r);
523
- if (w > Number.MAX_SAFE_INTEGER) throw "rowId too big to fit inside a Number";
524
- f(l, p, r, Number(w));
525
- }, "viiiij");
526
- ub(this.db, this.Wa, 0);
527
- return this;
528
- };
529
- c.prototype.bind = c.prototype.bind;
530
- c.prototype.step = c.prototype.step;
531
- c.prototype.get = c.prototype.get;
532
- c.prototype.getColumnNames = c.prototype.nb;
533
- c.prototype.getAsObject = c.prototype.wb;
534
- c.prototype.getSQL = c.prototype.Ob;
535
- c.prototype.getNormalizedSQL = c.prototype.cc;
536
- c.prototype.run = c.prototype.run;
537
- c.prototype.reset = c.prototype.reset;
538
- c.prototype.freemem = c.prototype.freemem;
539
- c.prototype.free = c.prototype.Va;
540
- d.prototype.next = d.prototype.next;
541
- d.prototype.getRemainingSQL = d.prototype.Mb;
542
- e.prototype.run = e.prototype.run;
543
- e.prototype.exec = e.prototype.exec;
544
- e.prototype.each = e.prototype.Jb;
545
- e.prototype.prepare = e.prototype.qb;
546
- e.prototype.iterateStatements = e.prototype.Qb;
547
- e.prototype["export"] = e.prototype.Kb;
548
- e.prototype.close = e.prototype.close;
549
- e.prototype.handleError = e.prototype.handleError;
550
- e.prototype.getRowsModified = e.prototype.Nb;
551
- e.prototype.create_function = e.prototype.Hb;
552
- e.prototype.create_aggregate = e.prototype.Gb;
553
- e.prototype.updateHook = e.prototype.Vb;
554
- k.Database = e;
555
- };
556
- var xa = "./this.program", ya = (a, b) => {
557
- throw b;
558
- }, za = globalThis.document?.currentScript?.src;
559
- "undefined" != typeof __filename ? za = __filename : ba && (za = self.location.href);
560
- var Aa = "", Ba, Ca;
561
- if (ca) {
562
- var fs = __require("node:fs");
563
- Aa = __dirname + "/";
564
- Ca = (a) => {
565
- a = Da(a) ? new URL(a) : a;
566
- return fs.readFileSync(a);
567
- };
568
- Ba = async (a) => {
569
- a = Da(a) ? new URL(a) : a;
570
- return fs.readFileSync(a, void 0);
571
- };
572
- 1 < process.argv.length && (xa = process.argv[1].replace(/\\/g, "/"));
573
- process.argv.slice(2);
574
- "undefined" != typeof module && (module.exports = k);
575
- ya = (a, b) => {
576
- process.exitCode = a;
577
- throw b;
578
- };
579
- } else if (aa || ba) {
580
- try {
581
- Aa = new URL(".", za).href;
582
- } catch {}
583
- ba && (Ca = (a) => {
584
- var b = new XMLHttpRequest();
585
- b.open("GET", a, !1);
586
- b.responseType = "arraybuffer";
587
- b.send(null);
588
- return new Uint8Array(b.response);
589
- });
590
- Ba = async (a) => {
591
- if (Da(a)) return new Promise((c, d) => {
592
- var e = new XMLHttpRequest();
593
- e.open("GET", a, !0);
594
- e.responseType = "arraybuffer";
595
- e.onload = () => {
596
- 200 == e.status || 0 == e.status && e.response ? c(e.response) : d(e.status);
597
- };
598
- e.onerror = d;
599
- e.send(null);
600
- });
601
- var b = await fetch(a, { credentials: "same-origin" });
602
- if (b.ok) return b.arrayBuffer();
603
- throw Error(b.status + " : " + b.url);
604
- };
605
- }
606
- var Ea = console.log.bind(console), B = console.error.bind(console), Fa, Ga = !1, Ha, Da = (a) => a.startsWith("file://"), m, D, Ia, E, F, Ja, Ka, H;
607
- function La() {
608
- var a = Ma.buffer;
609
- m = new Int8Array(a);
610
- Ia = new Int16Array(a);
611
- D = new Uint8Array(a);
612
- new Uint16Array(a);
613
- E = new Int32Array(a);
614
- F = new Uint32Array(a);
615
- Ja = new Float32Array(a);
616
- Ka = new Float64Array(a);
617
- H = new BigInt64Array(a);
618
- new BigUint64Array(a);
619
- }
620
- function Na(a) {
621
- k.onAbort?.(a);
622
- a = "Aborted(" + a + ")";
623
- B(a);
624
- Ga = !0;
625
- throw new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
626
- }
627
- var Oa;
628
- async function Pa(a) {
629
- if (!Fa) try {
630
- var b = await Ba(a);
631
- return new Uint8Array(b);
632
- } catch {}
633
- if (a == Oa && Fa) a = new Uint8Array(Fa);
634
- else if (Ca) a = Ca(a);
635
- else throw "both async and sync fetching of the wasm failed";
636
- return a;
637
- }
638
- async function Qa(a, b) {
639
- try {
640
- var c = await Pa(a);
641
- return await WebAssembly.instantiate(c, b);
642
- } catch (d) {
643
- B(`failed to asynchronously prepare wasm: ${d}`), Na(d);
644
- }
645
- }
646
- async function Ra(a) {
647
- var b = Oa;
648
- if (!Fa && !Da(b) && !ca) try {
649
- var c = fetch(b, { credentials: "same-origin" });
650
- return await WebAssembly.instantiateStreaming(c, a);
651
- } catch (d) {
652
- B(`wasm streaming compile failed: ${d}`), B("falling back to ArrayBuffer instantiation");
653
- }
654
- return Qa(b, a);
655
- }
656
- class Sa {
657
- name = "ExitStatus";
658
- constructor(a) {
659
- this.message = `Program terminated with exit(${a})`;
660
- this.status = a;
661
- }
662
- }
663
- var Ta = (a) => {
664
- for (; 0 < a.length;) a.shift()(k);
665
- }, Ua = [], Va = [], Wa = () => {
666
- var a = k.preRun.shift();
667
- Va.push(a);
668
- }, K = 0, Xa = null;
669
- function t(a, b = "i8") {
670
- b.endsWith("*") && (b = "*");
671
- switch (b) {
672
- case "i1": return m[a];
673
- case "i8": return m[a];
674
- case "i16": return Ia[a >> 1];
675
- case "i32": return E[a >> 2];
676
- case "i64": return H[a >> 3];
677
- case "float": return Ja[a >> 2];
678
- case "double": return Ka[a >> 3];
679
- case "*": return F[a >> 2];
680
- default: Na(`invalid type for getValue: ${b}`);
681
- }
682
- }
683
- var Ya = !0;
684
- function ra(a) {
685
- var b = "i32";
686
- b.endsWith("*") && (b = "*");
687
- switch (b) {
688
- case "i1":
689
- m[a] = 0;
690
- break;
691
- case "i8":
692
- m[a] = 0;
693
- break;
694
- case "i16":
695
- Ia[a >> 1] = 0;
696
- break;
697
- case "i32":
698
- E[a >> 2] = 0;
699
- break;
700
- case "i64":
701
- H[a >> 3] = BigInt(0);
702
- break;
703
- case "float":
704
- Ja[a >> 2] = 0;
705
- break;
706
- case "double":
707
- Ka[a >> 3] = 0;
708
- break;
709
- case "*":
710
- F[a >> 2] = 0;
711
- break;
712
- default: Na(`invalid type for setValue: ${b}`);
713
- }
714
- }
715
- var Za = (a, b) => {
716
- for (var c = 0, d = a.length - 1; 0 <= d; d--) {
717
- var e = a[d];
718
- "." === e ? a.splice(d, 1) : ".." === e ? (a.splice(d, 1), c++) : c && (a.splice(d, 1), c--);
719
- }
720
- if (b) for (; c; c--) a.unshift("..");
721
- return a;
722
- }, ia = (a) => {
723
- var b = "/" === a.charAt(0), c = "/" === a.slice(-1);
724
- (a = Za(a.split("/").filter((d) => !!d), !b).join("/")) || b || (a = ".");
725
- a && c && (a += "/");
726
- return (b ? "/" : "") + a;
727
- }, $a = (a) => {
728
- var b = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);
729
- a = b[0];
730
- b = b[1];
731
- if (!a && !b) return ".";
732
- b &&= b.slice(0, -1);
733
- return a + b;
734
- }, ab = (a) => a && a.match(/([^\/]+|\/)\/*$/)[1], bb = () => {
735
- if (ca) {
736
- var a = __require("node:crypto");
737
- return (b) => a.randomFillSync(b);
738
- }
739
- return (b) => crypto.getRandomValues(b);
740
- }, cb = (a) => {
741
- (cb = bb())(a);
742
- }, db = (...a) => {
743
- for (var b = "", c = !1, d = a.length - 1; -1 <= d && !c; d--) {
744
- c = 0 <= d ? a[d] : "/";
745
- if ("string" != typeof c) throw new TypeError("Arguments to path.resolve must be strings");
746
- if (!c) return "";
747
- b = c + "/" + b;
748
- c = "/" === c.charAt(0);
749
- }
750
- b = Za(b.split("/").filter((e) => !!e), !c).join("/");
751
- return (c ? "/" : "") + b || ".";
752
- }, eb = new TextDecoder(), fb = (a, b, c, d) => {
753
- c = b + c;
754
- if (d) return c;
755
- for (; a[b] && !(b >= c);) ++b;
756
- return b;
757
- }, gb = (a) => {
758
- var b = fb(a, 0);
759
- return eb.decode(a.buffer ? a.subarray(0, b) : new Uint8Array(a.slice(0, b)));
760
- }, hb = [], ib = (a) => {
761
- for (var b = 0, c = 0; c < a.length; ++c) {
762
- var d = a.charCodeAt(c);
763
- 127 >= d ? b++ : 2047 >= d ? b += 2 : 55296 <= d && 57343 >= d ? (b += 4, ++c) : b += 3;
764
- }
765
- return b;
766
- }, M = (a, b, c, d) => {
767
- if (!(0 < d)) return 0;
768
- var e = c;
769
- d = c + d - 1;
770
- for (var g = 0; g < a.length; ++g) {
771
- var h = a.codePointAt(g);
772
- if (127 >= h) {
773
- if (c >= d) break;
774
- b[c++] = h;
775
- } else if (2047 >= h) {
776
- if (c + 1 >= d) break;
777
- b[c++] = 192 | h >> 6;
778
- b[c++] = 128 | h & 63;
779
- } else if (65535 >= h) {
780
- if (c + 2 >= d) break;
781
- b[c++] = 224 | h >> 12;
782
- b[c++] = 128 | h >> 6 & 63;
783
- b[c++] = 128 | h & 63;
784
- } else {
785
- if (c + 3 >= d) break;
786
- b[c++] = 240 | h >> 18;
787
- b[c++] = 128 | h >> 12 & 63;
788
- b[c++] = 128 | h >> 6 & 63;
789
- b[c++] = 128 | h & 63;
790
- g++;
791
- }
792
- }
793
- b[c] = 0;
794
- return c - e;
795
- }, jb = [];
796
- function kb(a, b) {
797
- jb[a] = {
798
- input: [],
799
- output: [],
800
- ab: b
801
- };
802
- mb(a, nb);
803
- }
804
- var nb = {
805
- open(a) {
806
- var b = jb[a.node.rdev];
807
- if (!b) throw new N(43);
808
- a.tty = b;
809
- a.seekable = !1;
810
- },
811
- close(a) {
812
- a.tty.ab.fsync(a.tty);
813
- },
814
- fsync(a) {
815
- a.tty.ab.fsync(a.tty);
816
- },
817
- read(a, b, c, d) {
818
- if (!a.tty || !a.tty.ab.yb) throw new N(60);
819
- for (var e = 0, g = 0; g < d; g++) {
820
- try {
821
- var h = a.tty.ab.yb(a.tty);
822
- } catch (q) {
823
- throw new N(29);
824
- }
825
- if (void 0 === h && 0 === e) throw new N(6);
826
- if (null === h || void 0 === h) break;
827
- e++;
828
- b[c + g] = h;
829
- }
830
- e && (a.node.atime = Date.now());
831
- return e;
832
- },
833
- write(a, b, c, d) {
834
- if (!a.tty || !a.tty.ab.rb) throw new N(60);
835
- try {
836
- for (var e = 0; e < d; e++) a.tty.ab.rb(a.tty, b[c + e]);
837
- } catch (g) {
838
- throw new N(29);
839
- }
840
- d && (a.node.mtime = a.node.ctime = Date.now());
841
- return e;
842
- }
843
- }, vb = {
844
- yb() {
845
- a: {
846
- if (!hb.length) {
847
- var a = null;
848
- if (ca) {
849
- var b = Buffer.alloc(256), c = 0, d = process.stdin.fd;
850
- try {
851
- c = fs.readSync(d, b, 0, 256);
852
- } catch (e) {
853
- if (e.toString().includes("EOF")) c = 0;
854
- else throw e;
855
- }
856
- 0 < c && (a = b.slice(0, c).toString("utf-8"));
857
- } else globalThis.window?.prompt && (a = window.prompt("Input: "), null !== a && (a += "\n"));
858
- if (!a) {
859
- a = null;
860
- break a;
861
- }
862
- b = Array(ib(a) + 1);
863
- a = M(a, b, 0, b.length);
864
- b.length = a;
865
- hb = b;
866
- }
867
- a = hb.shift();
868
- }
869
- return a;
870
- },
871
- rb(a, b) {
872
- null === b || 10 === b ? (Ea(gb(a.output)), a.output = []) : 0 != b && a.output.push(b);
873
- },
874
- fsync(a) {
875
- 0 < a.output?.length && (Ea(gb(a.output)), a.output = []);
876
- },
877
- dc() {
878
- return {
879
- Yb: 25856,
880
- $b: 5,
881
- Xb: 191,
882
- Zb: 35387,
883
- Wb: [
884
- 3,
885
- 28,
886
- 127,
887
- 21,
888
- 4,
889
- 0,
890
- 1,
891
- 0,
892
- 17,
893
- 19,
894
- 26,
895
- 0,
896
- 18,
897
- 15,
898
- 23,
899
- 22,
900
- 0,
901
- 0,
902
- 0,
903
- 0,
904
- 0,
905
- 0,
906
- 0,
907
- 0,
908
- 0,
909
- 0,
910
- 0,
911
- 0,
912
- 0,
913
- 0,
914
- 0,
915
- 0
916
- ]
917
- };
918
- },
919
- ec() {
920
- return 0;
921
- },
922
- fc() {
923
- return [24, 80];
924
- }
925
- }, wb = {
926
- rb(a, b) {
927
- null === b || 10 === b ? (B(gb(a.output)), a.output = []) : 0 != b && a.output.push(b);
928
- },
929
- fsync(a) {
930
- 0 < a.output?.length && (B(gb(a.output)), a.output = []);
931
- }
932
- }, O = {
933
- Ta: null,
934
- Ua() {
935
- return O.createNode(null, "/", 16895, 0);
936
- },
937
- createNode(a, b, c, d) {
938
- if (24576 === (c & 61440) || 4096 === (c & 61440)) throw new N(63);
939
- O.Ta || (O.Ta = {
940
- dir: {
941
- node: {
942
- Qa: O.Ia.Qa,
943
- Ra: O.Ia.Ra,
944
- lookup: O.Ia.lookup,
945
- fb: O.Ia.fb,
946
- rename: O.Ia.rename,
947
- unlink: O.Ia.unlink,
948
- rmdir: O.Ia.rmdir,
949
- readdir: O.Ia.readdir,
950
- symlink: O.Ia.symlink
951
- },
952
- stream: { Sa: O.Ja.Sa }
953
- },
954
- file: {
955
- node: {
956
- Qa: O.Ia.Qa,
957
- Ra: O.Ia.Ra
958
- },
959
- stream: {
960
- Sa: O.Ja.Sa,
961
- read: O.Ja.read,
962
- write: O.Ja.write,
963
- gb: O.Ja.gb,
964
- hb: O.Ja.hb
965
- }
966
- },
967
- link: {
968
- node: {
969
- Qa: O.Ia.Qa,
970
- Ra: O.Ia.Ra,
971
- readlink: O.Ia.readlink
972
- },
973
- stream: {}
974
- },
975
- vb: {
976
- node: {
977
- Qa: O.Ia.Qa,
978
- Ra: O.Ia.Ra
979
- },
980
- stream: xb
981
- }
982
- });
983
- c = yb(a, b, c, d);
984
- P(c.mode) ? (c.Ia = O.Ta.dir.node, c.Ja = O.Ta.dir.stream, c.Ka = {}) : 32768 === (c.mode & 61440) ? (c.Ia = O.Ta.file.node, c.Ja = O.Ta.file.stream, c.Oa = 0, c.Ka = null) : 40960 === (c.mode & 61440) ? (c.Ia = O.Ta.link.node, c.Ja = O.Ta.link.stream) : 8192 === (c.mode & 61440) && (c.Ia = O.Ta.vb.node, c.Ja = O.Ta.vb.stream);
985
- c.atime = c.mtime = c.ctime = Date.now();
986
- a && (a.Ka[b] = c, a.atime = a.mtime = a.ctime = c.atime);
987
- return c;
988
- },
989
- bc(a) {
990
- return a.Ka ? a.Ka.subarray ? a.Ka.subarray(0, a.Oa) : new Uint8Array(a.Ka) : /* @__PURE__ */ new Uint8Array(0);
991
- },
992
- Ia: {
993
- Qa(a) {
994
- var b = {};
995
- b.dev = 8192 === (a.mode & 61440) ? a.id : 1;
996
- b.ino = a.id;
997
- b.mode = a.mode;
998
- b.nlink = 1;
999
- b.uid = 0;
1000
- b.gid = 0;
1001
- b.rdev = a.rdev;
1002
- P(a.mode) ? b.size = 4096 : 32768 === (a.mode & 61440) ? b.size = a.Oa : 40960 === (a.mode & 61440) ? b.size = a.link.length : b.size = 0;
1003
- b.atime = new Date(a.atime);
1004
- b.mtime = new Date(a.mtime);
1005
- b.ctime = new Date(a.ctime);
1006
- b.blksize = 4096;
1007
- b.blocks = Math.ceil(b.size / b.blksize);
1008
- return b;
1009
- },
1010
- Ra(a, b) {
1011
- for (var c of [
1012
- "mode",
1013
- "atime",
1014
- "mtime",
1015
- "ctime"
1016
- ]) null != b[c] && (a[c] = b[c]);
1017
- void 0 !== b.size && (b = b.size, a.Oa != b && (0 == b ? (a.Ka = null, a.Oa = 0) : (c = a.Ka, a.Ka = new Uint8Array(b), c && a.Ka.set(c.subarray(0, Math.min(b, a.Oa))), a.Oa = b)));
1018
- },
1019
- lookup() {
1020
- O.kb || (O.kb = new N(44), O.kb.stack = "<generic error, no stack>");
1021
- throw O.kb;
1022
- },
1023
- fb(a, b, c, d) {
1024
- return O.createNode(a, b, c, d);
1025
- },
1026
- rename(a, b, c) {
1027
- try {
1028
- var d = Q(b, c);
1029
- } catch (g) {}
1030
- if (d) {
1031
- if (P(a.mode)) for (var e in d.Ka) throw new N(55);
1032
- zb(d);
1033
- }
1034
- delete a.parent.Ka[a.name];
1035
- b.Ka[c] = a;
1036
- a.name = c;
1037
- b.ctime = b.mtime = a.parent.ctime = a.parent.mtime = Date.now();
1038
- },
1039
- unlink(a, b) {
1040
- delete a.Ka[b];
1041
- a.ctime = a.mtime = Date.now();
1042
- },
1043
- rmdir(a, b) {
1044
- var c = Q(a, b), d;
1045
- for (d in c.Ka) throw new N(55);
1046
- delete a.Ka[b];
1047
- a.ctime = a.mtime = Date.now();
1048
- },
1049
- readdir(a) {
1050
- return [
1051
- ".",
1052
- "..",
1053
- ...Object.keys(a.Ka)
1054
- ];
1055
- },
1056
- symlink(a, b, c) {
1057
- a = O.createNode(a, b, 41471, 0);
1058
- a.link = c;
1059
- return a;
1060
- },
1061
- readlink(a) {
1062
- if (40960 !== (a.mode & 61440)) throw new N(28);
1063
- return a.link;
1064
- }
1065
- },
1066
- Ja: {
1067
- read(a, b, c, d, e) {
1068
- var g = a.node.Ka;
1069
- if (e >= a.node.Oa) return 0;
1070
- a = Math.min(a.node.Oa - e, d);
1071
- if (8 < a && g.subarray) b.set(g.subarray(e, e + a), c);
1072
- else for (d = 0; d < a; d++) b[c + d] = g[e + d];
1073
- return a;
1074
- },
1075
- write(a, b, c, d, e, g) {
1076
- b.buffer === m.buffer && (g = !1);
1077
- if (!d) return 0;
1078
- a = a.node;
1079
- a.mtime = a.ctime = Date.now();
1080
- if (b.subarray && (!a.Ka || a.Ka.subarray)) {
1081
- if (g) return a.Ka = b.subarray(c, c + d), a.Oa = d;
1082
- if (0 === a.Oa && 0 === e) return a.Ka = b.slice(c, c + d), a.Oa = d;
1083
- if (e + d <= a.Oa) return a.Ka.set(b.subarray(c, c + d), e), d;
1084
- }
1085
- g = e + d;
1086
- var h = a.Ka ? a.Ka.length : 0;
1087
- h >= g || (g = Math.max(g, h * (1048576 > h ? 2 : 1.125) >>> 0), 0 != h && (g = Math.max(g, 256)), h = a.Ka, a.Ka = new Uint8Array(g), 0 < a.Oa && a.Ka.set(h.subarray(0, a.Oa), 0));
1088
- if (a.Ka.subarray && b.subarray) a.Ka.set(b.subarray(c, c + d), e);
1089
- else for (g = 0; g < d; g++) a.Ka[e + g] = b[c + g];
1090
- a.Oa = Math.max(a.Oa, e + d);
1091
- return d;
1092
- },
1093
- Sa(a, b, c) {
1094
- 1 === c ? b += a.position : 2 === c && 32768 === (a.node.mode & 61440) && (b += a.node.Oa);
1095
- if (0 > b) throw new N(28);
1096
- return b;
1097
- },
1098
- gb(a, b, c, d, e) {
1099
- if (32768 !== (a.node.mode & 61440)) throw new N(43);
1100
- a = a.node.Ka;
1101
- if (e & 2 || !a || a.buffer !== m.buffer) {
1102
- e = !0;
1103
- d = 65536 * Math.ceil(b / 65536);
1104
- var g = Ab(65536, d);
1105
- g && D.fill(0, g, g + d);
1106
- d = g;
1107
- if (!d) throw new N(48);
1108
- if (a) {
1109
- if (0 < c || c + b < a.length) a.subarray ? a = a.subarray(c, c + b) : a = Array.prototype.slice.call(a, c, c + b);
1110
- m.set(a, d);
1111
- }
1112
- } else e = !1, d = a.byteOffset;
1113
- return {
1114
- Tb: d,
1115
- Bb: e
1116
- };
1117
- },
1118
- hb(a, b, c, d) {
1119
- O.Ja.write(a, b, 0, d, c, !1);
1120
- return 0;
1121
- }
1122
- }
1123
- }, ja = (a, b) => {
1124
- var c = 0;
1125
- a && (c |= 365);
1126
- b && (c |= 146);
1127
- return c;
1128
- }, Bb = null, Cb = {}, Db = [], Eb = 1, R = null, Fb = !1, Gb = !0, Hb = {}, N = class {
1129
- name = "ErrnoError";
1130
- constructor(a) {
1131
- this.Ma = a;
1132
- }
1133
- }, Ib = class {
1134
- eb = {};
1135
- node = null;
1136
- get flags() {
1137
- return this.eb.flags;
1138
- }
1139
- set flags(a) {
1140
- this.eb.flags = a;
1141
- }
1142
- get position() {
1143
- return this.eb.position;
1144
- }
1145
- set position(a) {
1146
- this.eb.position = a;
1147
- }
1148
- }, Jb = class {
1149
- Ia = {};
1150
- Ja = {};
1151
- Za = null;
1152
- constructor(a, b, c, d) {
1153
- a ||= this;
1154
- this.parent = a;
1155
- this.Ua = a.Ua;
1156
- this.id = Eb++;
1157
- this.name = b;
1158
- this.mode = c;
1159
- this.rdev = d;
1160
- this.atime = this.mtime = this.ctime = Date.now();
1161
- }
1162
- get read() {
1163
- return 365 === (this.mode & 365);
1164
- }
1165
- set read(a) {
1166
- a ? this.mode |= 365 : this.mode &= -366;
1167
- }
1168
- get write() {
1169
- return 146 === (this.mode & 146);
1170
- }
1171
- set write(a) {
1172
- a ? this.mode |= 146 : this.mode &= -147;
1173
- }
1174
- };
1175
- function S(a, b = {}) {
1176
- if (!a) throw new N(44);
1177
- b.mb ?? (b.mb = !0);
1178
- "/" === a.charAt(0) || (a = "//" + a);
1179
- var c = 0;
1180
- a: for (; 40 > c; c++) {
1181
- a = a.split("/").filter((q) => !!q);
1182
- for (var d = Bb, e = "/", g = 0; g < a.length; g++) {
1183
- var h = g === a.length - 1;
1184
- if (h && b.parent) break;
1185
- if ("." !== a[g]) if (".." === a[g]) if (e = $a(e), d === d.parent) {
1186
- a = e + "/" + a.slice(g + 1).join("/");
1187
- c--;
1188
- continue a;
1189
- } else d = d.parent;
1190
- else {
1191
- e = ia(e + "/" + a[g]);
1192
- try {
1193
- d = Q(d, a[g]);
1194
- } catch (q) {
1195
- if (44 === q?.Ma && h && b.Sb) return { path: e };
1196
- throw q;
1197
- }
1198
- !d.Za || h && !b.mb || (d = d.Za.root);
1199
- if (40960 === (d.mode & 61440) && (!h || b.Ya)) {
1200
- if (!d.Ia.readlink) throw new N(52);
1201
- d = d.Ia.readlink(d);
1202
- "/" === d.charAt(0) || (d = $a(e) + "/" + d);
1203
- a = d + "/" + a.slice(g + 1).join("/");
1204
- continue a;
1205
- }
1206
- }
1207
- }
1208
- return {
1209
- path: e,
1210
- node: d
1211
- };
1212
- }
1213
- throw new N(32);
1214
- }
1215
- function ha(a) {
1216
- for (var b;;) {
1217
- if (a === a.parent) return a = a.Ua.Ab, b ? "/" !== a[a.length - 1] ? `${a}/${b}` : a + b : a;
1218
- b = b ? `${a.name}/${b}` : a.name;
1219
- a = a.parent;
1220
- }
1221
- }
1222
- function Kb(a, b) {
1223
- for (var c = 0, d = 0; d < b.length; d++) c = (c << 5) - c + b.charCodeAt(d) | 0;
1224
- return (a + c >>> 0) % R.length;
1225
- }
1226
- function zb(a) {
1227
- var b = Kb(a.parent.id, a.name);
1228
- if (R[b] === a) R[b] = a.$a;
1229
- else for (b = R[b]; b;) {
1230
- if (b.$a === a) {
1231
- b.$a = a.$a;
1232
- break;
1233
- }
1234
- b = b.$a;
1235
- }
1236
- }
1237
- function Q(a, b) {
1238
- var c = P(a.mode) ? (c = Lb(a, "x")) ? c : a.Ia.lookup ? 0 : 2 : 54;
1239
- if (c) throw new N(c);
1240
- for (c = R[Kb(a.id, b)]; c; c = c.$a) {
1241
- var d = c.name;
1242
- if (c.parent.id === a.id && d === b) return c;
1243
- }
1244
- return a.Ia.lookup(a, b);
1245
- }
1246
- function yb(a, b, c, d) {
1247
- a = new Jb(a, b, c, d);
1248
- b = Kb(a.parent.id, a.name);
1249
- a.$a = R[b];
1250
- return R[b] = a;
1251
- }
1252
- function P(a) {
1253
- return 16384 === (a & 61440);
1254
- }
1255
- function Mb(a) {
1256
- var b = [
1257
- "r",
1258
- "w",
1259
- "rw"
1260
- ][a & 3];
1261
- a & 512 && (b += "w");
1262
- return b;
1263
- }
1264
- function Lb(a, b) {
1265
- if (Gb) return 0;
1266
- if (!b.includes("r") || a.mode & 292) {
1267
- if (b.includes("w") && !(a.mode & 146) || b.includes("x") && !(a.mode & 73)) return 2;
1268
- } else return 2;
1269
- return 0;
1270
- }
1271
- function Nb(a, b) {
1272
- if (!P(a.mode)) return 54;
1273
- try {
1274
- return Q(a, b), 20;
1275
- } catch (c) {}
1276
- return Lb(a, "wx");
1277
- }
1278
- function Ob(a, b, c) {
1279
- try {
1280
- var d = Q(a, b);
1281
- } catch (e) {
1282
- return e.Ma;
1283
- }
1284
- if (a = Lb(a, "wx")) return a;
1285
- if (c) {
1286
- if (!P(d.mode)) return 54;
1287
- if (d === d.parent || "/" === ha(d)) return 10;
1288
- } else if (P(d.mode)) return 31;
1289
- return 0;
1290
- }
1291
- function Pb(a) {
1292
- if (!a) throw new N(63);
1293
- return a;
1294
- }
1295
- function T(a) {
1296
- a = Db[a];
1297
- if (!a) throw new N(8);
1298
- return a;
1299
- }
1300
- function Qb(a, b = -1) {
1301
- a = Object.assign(new Ib(), a);
1302
- if (-1 == b) a: {
1303
- for (b = 0; 4096 >= b; b++) if (!Db[b]) break a;
1304
- throw new N(33);
1305
- }
1306
- a.fd = b;
1307
- return Db[b] = a;
1308
- }
1309
- function Rb(a, b = -1) {
1310
- a = Qb(a, b);
1311
- a.Ja?.ac?.(a);
1312
- return a;
1313
- }
1314
- function Sb(a, b, c) {
1315
- var d = a?.Ja.Ra;
1316
- a = d ? a : b;
1317
- d ??= b.Ia.Ra;
1318
- Pb(d);
1319
- d(a, c);
1320
- }
1321
- var xb = {
1322
- open(a) {
1323
- a.Ja = Cb[a.node.rdev].Ja;
1324
- a.Ja.open?.(a);
1325
- },
1326
- Sa() {
1327
- throw new N(70);
1328
- }
1329
- };
1330
- function mb(a, b) {
1331
- Cb[a] = { Ja: b };
1332
- }
1333
- function Tb(a, b) {
1334
- var c = "/" === b;
1335
- if (c && Bb) throw new N(10);
1336
- if (!c && b) {
1337
- var d = S(b, { mb: !1 });
1338
- b = d.path;
1339
- d = d.node;
1340
- if (d.Za) throw new N(10);
1341
- if (!P(d.mode)) throw new N(54);
1342
- }
1343
- b = {
1344
- type: a,
1345
- hc: {},
1346
- Ab: b,
1347
- Rb: []
1348
- };
1349
- a = a.Ua(b);
1350
- a.Ua = b;
1351
- b.root = a;
1352
- c ? Bb = a : d && (d.Za = b, d.Ua && d.Ua.Rb.push(b));
1353
- }
1354
- function Ub(a, b, c) {
1355
- var d = S(a, { parent: !0 }).node;
1356
- a = ab(a);
1357
- if (!a) throw new N(28);
1358
- if ("." === a || ".." === a) throw new N(20);
1359
- var e = Nb(d, a);
1360
- if (e) throw new N(e);
1361
- if (!d.Ia.fb) throw new N(63);
1362
- return d.Ia.fb(d, a, b, c);
1363
- }
1364
- function la(a, b = 438) {
1365
- return Ub(a, b & 4095 | 32768, 0);
1366
- }
1367
- function U(a, b = 511) {
1368
- return Ub(a, b & 1023 | 16384, 0);
1369
- }
1370
- function Vb(a, b, c) {
1371
- "undefined" == typeof c && (c = b, b = 438);
1372
- Ub(a, b | 8192, c);
1373
- }
1374
- function Wb(a, b) {
1375
- if (!db(a)) throw new N(44);
1376
- var c = S(b, { parent: !0 }).node;
1377
- if (!c) throw new N(44);
1378
- b = ab(b);
1379
- var d = Nb(c, b);
1380
- if (d) throw new N(d);
1381
- if (!c.Ia.symlink) throw new N(63);
1382
- c.Ia.symlink(c, b, a);
1383
- }
1384
- function Xb(a) {
1385
- var b = S(a, { parent: !0 }).node;
1386
- a = ab(a);
1387
- var c = Q(b, a), d = Ob(b, a, !0);
1388
- if (d) throw new N(d);
1389
- if (!b.Ia.rmdir) throw new N(63);
1390
- if (c.Za) throw new N(10);
1391
- b.Ia.rmdir(b, a);
1392
- zb(c);
1393
- }
1394
- function ua(a) {
1395
- var b = S(a, { parent: !0 }).node;
1396
- if (!b) throw new N(44);
1397
- a = ab(a);
1398
- var c = Q(b, a), d = Ob(b, a, !1);
1399
- if (d) throw new N(d);
1400
- if (!b.Ia.unlink) throw new N(63);
1401
- if (c.Za) throw new N(10);
1402
- b.Ia.unlink(b, a);
1403
- zb(c);
1404
- }
1405
- function Yb(a, b) {
1406
- a = S(a, { Ya: !b }).node;
1407
- return Pb(a.Ia.Qa)(a);
1408
- }
1409
- function Zb(a, b, c, d) {
1410
- Sb(a, b, {
1411
- mode: c & 4095 | b.mode & -4096,
1412
- ctime: Date.now(),
1413
- Ib: d
1414
- });
1415
- }
1416
- function ma(a, b) {
1417
- a = "string" == typeof a ? S(a, { Ya: !0 }).node : a;
1418
- Zb(null, a, b);
1419
- }
1420
- function $b(a, b, c) {
1421
- if (P(b.mode)) throw new N(31);
1422
- if (32768 !== (b.mode & 61440)) throw new N(28);
1423
- var d = Lb(b, "w");
1424
- if (d) throw new N(d);
1425
- Sb(a, b, {
1426
- size: c,
1427
- timestamp: Date.now()
1428
- });
1429
- }
1430
- function na(a, b, c = 438) {
1431
- if ("" === a) throw new N(44);
1432
- if ("string" == typeof b) {
1433
- var d = {
1434
- r: 0,
1435
- "r+": 2,
1436
- w: 577,
1437
- "w+": 578,
1438
- a: 1089,
1439
- "a+": 1090
1440
- }[b];
1441
- if ("undefined" == typeof d) throw Error(`Unknown file open mode: ${b}`);
1442
- b = d;
1443
- }
1444
- c = b & 64 ? c & 4095 | 32768 : 0;
1445
- if ("object" == typeof a) d = a;
1446
- else {
1447
- var e = a.endsWith("/");
1448
- a = S(a, {
1449
- Ya: !(b & 131072),
1450
- Sb: !0
1451
- });
1452
- d = a.node;
1453
- a = a.path;
1454
- }
1455
- var g = !1;
1456
- if (b & 64) if (d) {
1457
- if (b & 128) throw new N(20);
1458
- } else {
1459
- if (e) throw new N(31);
1460
- d = Ub(a, c | 511, 0);
1461
- g = !0;
1462
- }
1463
- if (!d) throw new N(44);
1464
- 8192 === (d.mode & 61440) && (b &= -513);
1465
- if (b & 65536 && !P(d.mode)) throw new N(54);
1466
- if (!g && (e = d ? 40960 === (d.mode & 61440) ? 32 : P(d.mode) && ("r" !== Mb(b) || b & 576) ? 31 : Lb(d, Mb(b)) : 44)) throw new N(e);
1467
- b & 512 && !g && (e = d, e = "string" == typeof e ? S(e, { Ya: !0 }).node : e, $b(null, e, 0));
1468
- b &= -131713;
1469
- e = Qb({
1470
- node: d,
1471
- path: ha(d),
1472
- flags: b,
1473
- seekable: !0,
1474
- position: 0,
1475
- Ja: d.Ja,
1476
- Ub: [],
1477
- error: !1
1478
- });
1479
- e.Ja.open && e.Ja.open(e);
1480
- g && ma(d, c & 511);
1481
- !k.logReadFiles || b & 1 || a in Hb || (Hb[a] = 1);
1482
- return e;
1483
- }
1484
- function pa(a) {
1485
- if (null === a.fd) throw new N(8);
1486
- a.ob && (a.ob = null);
1487
- try {
1488
- a.Ja.close && a.Ja.close(a);
1489
- } catch (b) {
1490
- throw b;
1491
- } finally {
1492
- Db[a.fd] = null;
1493
- }
1494
- a.fd = null;
1495
- }
1496
- function ac(a, b, c) {
1497
- if (null === a.fd) throw new N(8);
1498
- if (!a.seekable || !a.Ja.Sa) throw new N(70);
1499
- if (0 != c && 1 != c && 2 != c) throw new N(28);
1500
- a.position = a.Ja.Sa(a, b, c);
1501
- a.Ub = [];
1502
- }
1503
- function bc(a, b, c, d, e) {
1504
- if (0 > d || 0 > e) throw new N(28);
1505
- if (null === a.fd) throw new N(8);
1506
- if (1 === (a.flags & 2097155)) throw new N(8);
1507
- if (P(a.node.mode)) throw new N(31);
1508
- if (!a.Ja.read) throw new N(28);
1509
- var g = "undefined" != typeof e;
1510
- if (!g) e = a.position;
1511
- else if (!a.seekable) throw new N(70);
1512
- b = a.Ja.read(a, b, c, d, e);
1513
- g || (a.position += b);
1514
- return b;
1515
- }
1516
- function oa(a, b, c, d, e) {
1517
- if (0 > d || 0 > e) throw new N(28);
1518
- if (null === a.fd) throw new N(8);
1519
- if (0 === (a.flags & 2097155)) throw new N(8);
1520
- if (P(a.node.mode)) throw new N(31);
1521
- if (!a.Ja.write) throw new N(28);
1522
- a.seekable && a.flags & 1024 && ac(a, 0, 2);
1523
- var g = "undefined" != typeof e;
1524
- if (!g) e = a.position;
1525
- else if (!a.seekable) throw new N(70);
1526
- b = a.Ja.write(a, b, c, d, e, void 0);
1527
- g || (a.position += b);
1528
- return b;
1529
- }
1530
- function ta(a) {
1531
- var b = b || 0;
1532
- var c = "binary";
1533
- "utf8" !== c && "binary" !== c && Na(`Invalid encoding type "${c}"`);
1534
- b = na(a, b);
1535
- a = Yb(a).size;
1536
- var d = new Uint8Array(a);
1537
- bc(b, d, 0, a, 0);
1538
- "utf8" === c && (d = gb(d));
1539
- pa(b);
1540
- return d;
1541
- }
1542
- function W(a, b, c) {
1543
- a = ia("/dev/" + a);
1544
- var d = ja(!!b, !!c);
1545
- W.zb ?? (W.zb = 64);
1546
- var e = W.zb++ << 8 | 0;
1547
- mb(e, {
1548
- open(g) {
1549
- g.seekable = !1;
1550
- },
1551
- close() {
1552
- c?.buffer?.length && c(10);
1553
- },
1554
- read(g, h, q, v) {
1555
- for (var u = 0, x = 0; x < v; x++) {
1556
- try {
1557
- var C = b();
1558
- } catch (ob) {
1559
- throw new N(29);
1560
- }
1561
- if (void 0 === C && 0 === u) throw new N(6);
1562
- if (null === C || void 0 === C) break;
1563
- u++;
1564
- h[q + x] = C;
1565
- }
1566
- u && (g.node.atime = Date.now());
1567
- return u;
1568
- },
1569
- write(g, h, q, v) {
1570
- for (var u = 0; u < v; u++) try {
1571
- c(h[q + u]);
1572
- } catch (x) {
1573
- throw new N(29);
1574
- }
1575
- v && (g.node.mtime = g.node.ctime = Date.now());
1576
- return u;
1577
- }
1578
- });
1579
- Vb(a, d, e);
1580
- }
1581
- var X = {}, z = (a, b, c) => a ? eb.decode(D.subarray(a, fb(D, a, b, c))) : "";
1582
- function Y(a, b, c) {
1583
- if ("/" === b.charAt(0)) return b;
1584
- a = -100 === a ? "/" : T(a).path;
1585
- if (0 == b.length) {
1586
- if (!c) throw new N(44);
1587
- return a;
1588
- }
1589
- return a + "/" + b;
1590
- }
1591
- function lc(a, b) {
1592
- F[a >> 2] = b.dev;
1593
- F[a + 4 >> 2] = b.mode;
1594
- F[a + 8 >> 2] = b.nlink;
1595
- F[a + 12 >> 2] = b.uid;
1596
- F[a + 16 >> 2] = b.gid;
1597
- F[a + 20 >> 2] = b.rdev;
1598
- H[a + 24 >> 3] = BigInt(b.size);
1599
- E[a + 32 >> 2] = 4096;
1600
- E[a + 36 >> 2] = b.blocks;
1601
- var c = b.atime.getTime(), d = b.mtime.getTime(), e = b.ctime.getTime();
1602
- H[a + 40 >> 3] = BigInt(Math.floor(c / 1e3));
1603
- F[a + 48 >> 2] = c % 1e3 * 1e6;
1604
- H[a + 56 >> 3] = BigInt(Math.floor(d / 1e3));
1605
- F[a + 64 >> 2] = d % 1e3 * 1e6;
1606
- H[a + 72 >> 3] = BigInt(Math.floor(e / 1e3));
1607
- F[a + 80 >> 2] = e % 1e3 * 1e6;
1608
- H[a + 88 >> 3] = BigInt(b.ino);
1609
- return 0;
1610
- }
1611
- var Cc = void 0, Ec = () => {
1612
- var a = E[+Cc >> 2];
1613
- Cc += 4;
1614
- return a;
1615
- }, Fc = 0, Gc = [
1616
- 0,
1617
- 31,
1618
- 60,
1619
- 91,
1620
- 121,
1621
- 152,
1622
- 182,
1623
- 213,
1624
- 244,
1625
- 274,
1626
- 305,
1627
- 335
1628
- ], Hc = [
1629
- 0,
1630
- 31,
1631
- 59,
1632
- 90,
1633
- 120,
1634
- 151,
1635
- 181,
1636
- 212,
1637
- 243,
1638
- 273,
1639
- 304,
1640
- 334
1641
- ], Ic = {}, Jc = (a) => {
1642
- Ha = a;
1643
- Ya || 0 < Fc || (k.onExit?.(a), Ga = !0);
1644
- ya(a, new Sa(a));
1645
- }, Kc = (a) => {
1646
- if (!Ga) try {
1647
- a();
1648
- } catch (b) {
1649
- b instanceof Sa || "unwind" == b || ya(1, b);
1650
- } finally {
1651
- if (!(Ya || 0 < Fc)) try {
1652
- Ha = a = Ha, Jc(a);
1653
- } catch (b) {
1654
- b instanceof Sa || "unwind" == b || ya(1, b);
1655
- }
1656
- }
1657
- }, Lc = {}, Nc = () => {
1658
- if (!Mc) {
1659
- var a = {
1660
- USER: "web_user",
1661
- LOGNAME: "web_user",
1662
- PATH: "/",
1663
- PWD: "/",
1664
- HOME: "/home/web_user",
1665
- LANG: (globalThis.navigator?.language ?? "C").replace("-", "_") + ".UTF-8",
1666
- _: xa || "./this.program"
1667
- }, b;
1668
- for (b in Lc) void 0 === Lc[b] ? delete a[b] : a[b] = Lc[b];
1669
- var c = [];
1670
- for (b in a) c.push(`${b}=${a[b]}`);
1671
- Mc = c;
1672
- }
1673
- return Mc;
1674
- }, Mc, Oc = (a, b, c, d) => {
1675
- var e = {
1676
- string: (u) => {
1677
- var x = 0;
1678
- if (null !== u && void 0 !== u && 0 !== u) {
1679
- x = ib(u) + 1;
1680
- var C = y(x);
1681
- M(u, D, C, x);
1682
- x = C;
1683
- }
1684
- return x;
1685
- },
1686
- array: (u) => {
1687
- var x = y(u.length);
1688
- m.set(u, x);
1689
- return x;
1690
- }
1691
- };
1692
- a = k["_" + a];
1693
- var g = [], h = 0;
1694
- if (d) for (var q = 0; q < d.length; q++) {
1695
- var v = e[c[q]];
1696
- v ? (0 === h && (h = qa()), g[q] = v(d[q])) : g[q] = d[q];
1697
- }
1698
- c = a(...g);
1699
- return c = function(u) {
1700
- 0 !== h && sa(h);
1701
- return "string" === b ? z(u) : "boolean" === b ? !!u : u;
1702
- }(c);
1703
- }, fa = (a) => {
1704
- var b = ib(a) + 1, c = da(b);
1705
- c && M(a, D, c, b);
1706
- return c;
1707
- }, Pc, Qc = [], A = (a) => {
1708
- Pc.delete(Z.get(a));
1709
- Z.set(a, null);
1710
- Qc.push(a);
1711
- }, Rc = (a) => {
1712
- const b = a.length;
1713
- return [
1714
- b % 128 | 128,
1715
- b >> 7,
1716
- ...a
1717
- ];
1718
- }, Sc = {
1719
- i: 127,
1720
- p: 127,
1721
- j: 126,
1722
- f: 125,
1723
- d: 124,
1724
- e: 111
1725
- }, Tc = (a) => Rc(Array.from(a, (b) => Sc[b])), wa = (a, b) => {
1726
- if (!Pc) {
1727
- Pc = /* @__PURE__ */ new WeakMap();
1728
- var c = Z.length;
1729
- if (Pc) for (var d = 0; d < 0 + c; d++) {
1730
- var e = Z.get(d);
1731
- e && Pc.set(e, d);
1732
- }
1733
- }
1734
- if (c = Pc.get(a) || 0) return c;
1735
- c = Qc.length ? Qc.pop() : Z.grow(1);
1736
- try {
1737
- Z.set(c, a);
1738
- } catch (g) {
1739
- if (!(g instanceof TypeError)) throw g;
1740
- b = Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0, 1, ...Rc([
1741
- 1,
1742
- 96,
1743
- ...Tc(b.slice(1)),
1744
- ...Tc("v" === b[0] ? "" : b[0])
1745
- ]), 2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
1746
- b = new WebAssembly.Module(b);
1747
- b = new WebAssembly.Instance(b, { e: { f: a } }).exports.f;
1748
- Z.set(c, b);
1749
- }
1750
- Pc.set(a, c);
1751
- return c;
1752
- };
1753
- R = Array(4096);
1754
- Tb(O, "/");
1755
- U("/tmp");
1756
- U("/home");
1757
- U("/home/web_user");
1758
- (function() {
1759
- U("/dev");
1760
- mb(259, {
1761
- read: () => 0,
1762
- write: (d, e, g, h) => h,
1763
- Sa: () => 0
1764
- });
1765
- Vb("/dev/null", 259);
1766
- kb(1280, vb);
1767
- kb(1536, wb);
1768
- Vb("/dev/tty", 1280);
1769
- Vb("/dev/tty1", 1536);
1770
- var a = /* @__PURE__ */ new Uint8Array(1024), b = 0, c = () => {
1771
- 0 === b && (cb(a), b = a.byteLength);
1772
- return a[--b];
1773
- };
1774
- W("random", c);
1775
- W("urandom", c);
1776
- U("/dev/shm");
1777
- U("/dev/shm/tmp");
1778
- })();
1779
- (function() {
1780
- U("/proc");
1781
- var a = U("/proc/self");
1782
- U("/proc/self/fd");
1783
- Tb({ Ua() {
1784
- var b = yb(a, "fd", 16895, 73);
1785
- b.Ja = { Sa: O.Ja.Sa };
1786
- b.Ia = {
1787
- lookup(c, d) {
1788
- c = +d;
1789
- var e = T(c);
1790
- c = {
1791
- parent: null,
1792
- Ua: { Ab: "fake" },
1793
- Ia: { readlink: () => e.path },
1794
- id: c + 1
1795
- };
1796
- return c.parent = c;
1797
- },
1798
- readdir() {
1799
- return Array.from(Db.entries()).filter(([, c]) => c).map(([c]) => c.toString());
1800
- }
1801
- };
1802
- return b;
1803
- } }, "/proc/self/fd");
1804
- })();
1805
- k.noExitRuntime && (Ya = k.noExitRuntime);
1806
- k.print && (Ea = k.print);
1807
- k.printErr && (B = k.printErr);
1808
- k.wasmBinary && (Fa = k.wasmBinary);
1809
- k.thisProgram && (xa = k.thisProgram);
1810
- if (k.preInit) for ("function" == typeof k.preInit && (k.preInit = [k.preInit]); 0 < k.preInit.length;) k.preInit.shift()();
1811
- k.stackSave = () => qa();
1812
- k.stackRestore = (a) => sa(a);
1813
- k.stackAlloc = (a) => y(a);
1814
- k.cwrap = (a, b, c, d) => {
1815
- var e = !c || c.every((g) => "number" === g || "boolean" === g);
1816
- return "string" !== b && e && !d ? k["_" + a] : (...g) => Oc(a, b, c, g);
1817
- };
1818
- k.addFunction = wa;
1819
- k.removeFunction = A;
1820
- k.UTF8ToString = z;
1821
- k.stringToNewUTF8 = fa;
1822
- k.writeArrayToMemory = (a, b) => {
1823
- m.set(a, b);
1824
- };
1825
- var da, ea, Ab, Uc, sa, y, qa, Ma, Z, Vc = {
1826
- i: function(a, b) {
1827
- try {
1828
- return a = z(a), ma(a, b), 0;
1829
- } catch (c) {
1830
- if ("undefined" == typeof X || "ErrnoError" !== c.name) throw c;
1831
- return -c.Ma;
1832
- }
1833
- },
1834
- K: function(a, b, c) {
1835
- try {
1836
- b = z(b);
1837
- b = Y(a, b);
1838
- if (c & -8) return -28;
1839
- var d = S(b, { Ya: !0 }).node;
1840
- if (!d) return -44;
1841
- a = "";
1842
- c & 4 && (a += "r");
1843
- c & 2 && (a += "w");
1844
- c & 1 && (a += "x");
1845
- return a && Lb(d, a) ? -2 : 0;
1846
- } catch (e) {
1847
- if ("undefined" == typeof X || "ErrnoError" !== e.name) throw e;
1848
- return -e.Ma;
1849
- }
1850
- },
1851
- q: function(a, b) {
1852
- try {
1853
- var c = T(a);
1854
- Zb(c, c.node, b, !1);
1855
- return 0;
1856
- } catch (d) {
1857
- if ("undefined" == typeof X || "ErrnoError" !== d.name) throw d;
1858
- return -d.Ma;
1859
- }
1860
- },
1861
- h: function(a) {
1862
- try {
1863
- var b = T(a);
1864
- Sb(b, b.node, {
1865
- timestamp: Date.now(),
1866
- Ib: !1
1867
- });
1868
- return 0;
1869
- } catch (c) {
1870
- if ("undefined" == typeof X || "ErrnoError" !== c.name) throw c;
1871
- return -c.Ma;
1872
- }
1873
- },
1874
- a: function(a, b, c) {
1875
- Cc = c;
1876
- try {
1877
- var d = T(a);
1878
- switch (b) {
1879
- case 0:
1880
- var e = Ec();
1881
- if (0 > e) break;
1882
- for (; Db[e];) e++;
1883
- return Rb(d, e).fd;
1884
- case 1:
1885
- case 2: return 0;
1886
- case 3: return d.flags;
1887
- case 4: return e = Ec(), d.flags |= e, 0;
1888
- case 12: return e = Ec(), Ia[e + 0 >> 1] = 2, 0;
1889
- case 13:
1890
- case 14: return 0;
1891
- }
1892
- return -28;
1893
- } catch (g) {
1894
- if ("undefined" == typeof X || "ErrnoError" !== g.name) throw g;
1895
- return -g.Ma;
1896
- }
1897
- },
1898
- g: function(a, b) {
1899
- try {
1900
- var c = T(a), d = c.node, e = c.Ja.Qa;
1901
- a = e ? c : d;
1902
- e ??= d.Ia.Qa;
1903
- Pb(e);
1904
- return lc(b, e(a));
1905
- } catch (h) {
1906
- if ("undefined" == typeof X || "ErrnoError" !== h.name) throw h;
1907
- return -h.Ma;
1908
- }
1909
- },
1910
- H: function(a, b) {
1911
- b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
1912
- try {
1913
- if (isNaN(b)) return -61;
1914
- var c = T(a);
1915
- if (0 > b || 0 === (c.flags & 2097155)) throw new N(28);
1916
- $b(c, c.node, b);
1917
- return 0;
1918
- } catch (d) {
1919
- if ("undefined" == typeof X || "ErrnoError" !== d.name) throw d;
1920
- return -d.Ma;
1921
- }
1922
- },
1923
- G: function(a, b) {
1924
- try {
1925
- if (0 === b) return -28;
1926
- var c = ib("/") + 1;
1927
- if (b < c) return -68;
1928
- M("/", D, a, b);
1929
- return c;
1930
- } catch (d) {
1931
- if ("undefined" == typeof X || "ErrnoError" !== d.name) throw d;
1932
- return -d.Ma;
1933
- }
1934
- },
1935
- e: function(a, b) {
1936
- try {
1937
- return a = z(a), lc(b, Yb(a, !0));
1938
- } catch (c) {
1939
- if ("undefined" == typeof X || "ErrnoError" !== c.name) throw c;
1940
- return -c.Ma;
1941
- }
1942
- },
1943
- C: function(a, b, c) {
1944
- try {
1945
- return b = z(b), b = Y(a, b), U(b, c), 0;
1946
- } catch (d) {
1947
- if ("undefined" == typeof X || "ErrnoError" !== d.name) throw d;
1948
- return -d.Ma;
1949
- }
1950
- },
1951
- J: function(a, b, c, d) {
1952
- try {
1953
- b = z(b);
1954
- var e = d & 256;
1955
- b = Y(a, b, d & 4096);
1956
- return lc(c, e ? Yb(b, !0) : Yb(b));
1957
- } catch (g) {
1958
- if ("undefined" == typeof X || "ErrnoError" !== g.name) throw g;
1959
- return -g.Ma;
1960
- }
1961
- },
1962
- x: function(a, b, c, d) {
1963
- Cc = d;
1964
- try {
1965
- b = z(b);
1966
- b = Y(a, b);
1967
- var e = d ? Ec() : 0;
1968
- return na(b, c, e).fd;
1969
- } catch (g) {
1970
- if ("undefined" == typeof X || "ErrnoError" !== g.name) throw g;
1971
- return -g.Ma;
1972
- }
1973
- },
1974
- v: function(a, b, c, d) {
1975
- try {
1976
- b = z(b);
1977
- b = Y(a, b);
1978
- if (0 >= d) return -28;
1979
- var e = S(b).node;
1980
- if (!e) throw new N(44);
1981
- if (!e.Ia.readlink) throw new N(28);
1982
- var g = e.Ia.readlink(e);
1983
- var h = Math.min(d, ib(g)), q = m[c + h];
1984
- M(g, D, c, d + 1);
1985
- m[c + h] = q;
1986
- return h;
1987
- } catch (v) {
1988
- if ("undefined" == typeof X || "ErrnoError" !== v.name) throw v;
1989
- return -v.Ma;
1990
- }
1991
- },
1992
- u: function(a) {
1993
- try {
1994
- return a = z(a), Xb(a), 0;
1995
- } catch (b) {
1996
- if ("undefined" == typeof X || "ErrnoError" !== b.name) throw b;
1997
- return -b.Ma;
1998
- }
1999
- },
2000
- f: function(a, b) {
2001
- try {
2002
- return a = z(a), lc(b, Yb(a));
2003
- } catch (c) {
2004
- if ("undefined" == typeof X || "ErrnoError" !== c.name) throw c;
2005
- return -c.Ma;
2006
- }
2007
- },
2008
- s: function(a, b, c) {
2009
- try {
2010
- b = z(b);
2011
- b = Y(a, b);
2012
- if (c) if (512 === c) Xb(b);
2013
- else return -28;
2014
- else ua(b);
2015
- return 0;
2016
- } catch (d) {
2017
- if ("undefined" == typeof X || "ErrnoError" !== d.name) throw d;
2018
- return -d.Ma;
2019
- }
2020
- },
2021
- r: function(a, b, c) {
2022
- try {
2023
- b = z(b);
2024
- b = Y(a, b, !0);
2025
- var d = Date.now(), e, g;
2026
- if (c) {
2027
- var h = F[c >> 2] + 4294967296 * E[c + 4 >> 2], q = E[c + 8 >> 2];
2028
- 1073741823 == q ? e = d : 1073741822 == q ? e = null : e = 1e3 * h + q / 1e6;
2029
- c += 16;
2030
- h = F[c >> 2] + 4294967296 * E[c + 4 >> 2];
2031
- q = E[c + 8 >> 2];
2032
- 1073741823 == q ? g = d : 1073741822 == q ? g = null : g = 1e3 * h + q / 1e6;
2033
- } else g = e = d;
2034
- if (null !== (g ?? e)) {
2035
- a = e;
2036
- var v = S(b, { Ya: !0 }).node;
2037
- Pb(v.Ia.Ra)(v, {
2038
- atime: a,
2039
- mtime: g
2040
- });
2041
- }
2042
- return 0;
2043
- } catch (u) {
2044
- if ("undefined" == typeof X || "ErrnoError" !== u.name) throw u;
2045
- return -u.Ma;
2046
- }
2047
- },
2048
- l: () => Na(""),
2049
- k: () => {
2050
- Ya = !1;
2051
- Fc = 0;
2052
- },
2053
- A: function(a, b) {
2054
- a = -9007199254740992 > a || 9007199254740992 < a ? NaN : Number(a);
2055
- a = /* @__PURE__ */ new Date(1e3 * a);
2056
- E[b >> 2] = a.getSeconds();
2057
- E[b + 4 >> 2] = a.getMinutes();
2058
- E[b + 8 >> 2] = a.getHours();
2059
- E[b + 12 >> 2] = a.getDate();
2060
- E[b + 16 >> 2] = a.getMonth();
2061
- E[b + 20 >> 2] = a.getFullYear() - 1900;
2062
- E[b + 24 >> 2] = a.getDay();
2063
- var c = a.getFullYear();
2064
- E[b + 28 >> 2] = (0 !== c % 4 || 0 === c % 100 && 0 !== c % 400 ? Hc : Gc)[a.getMonth()] + a.getDate() - 1 | 0;
2065
- E[b + 36 >> 2] = -(60 * a.getTimezoneOffset());
2066
- c = new Date(a.getFullYear(), 6, 1).getTimezoneOffset();
2067
- var d = new Date(a.getFullYear(), 0, 1).getTimezoneOffset();
2068
- E[b + 32 >> 2] = (c != d && a.getTimezoneOffset() == Math.min(d, c)) | 0;
2069
- },
2070
- y: function(a, b, c, d, e, g, h) {
2071
- e = -9007199254740992 > e || 9007199254740992 < e ? NaN : Number(e);
2072
- try {
2073
- var q = T(d);
2074
- if (0 !== (b & 2) && 0 === (c & 2) && 2 !== (q.flags & 2097155)) throw new N(2);
2075
- if (1 === (q.flags & 2097155)) throw new N(2);
2076
- if (!q.Ja.gb) throw new N(43);
2077
- if (!a) throw new N(28);
2078
- var v = q.Ja.gb(q, a, e, b, c);
2079
- var u = v.Tb;
2080
- E[g >> 2] = v.Bb;
2081
- F[h >> 2] = u;
2082
- return 0;
2083
- } catch (x) {
2084
- if ("undefined" == typeof X || "ErrnoError" !== x.name) throw x;
2085
- return -x.Ma;
2086
- }
2087
- },
2088
- z: function(a, b, c, d, e, g) {
2089
- g = -9007199254740992 > g || 9007199254740992 < g ? NaN : Number(g);
2090
- try {
2091
- var h = T(e);
2092
- if (c & 2) {
2093
- c = g;
2094
- if (32768 !== (h.node.mode & 61440)) throw new N(43);
2095
- if (!(d & 2)) {
2096
- var q = D.slice(a, a + b);
2097
- h.Ja.hb && h.Ja.hb(h, q, c, b, d);
2098
- }
2099
- }
2100
- } catch (v) {
2101
- if ("undefined" == typeof X || "ErrnoError" !== v.name) throw v;
2102
- return -v.Ma;
2103
- }
2104
- },
2105
- m: (a, b) => {
2106
- Ic[a] && (clearTimeout(Ic[a].id), delete Ic[a]);
2107
- if (!b) return 0;
2108
- Ic[a] = {
2109
- id: setTimeout(() => {
2110
- delete Ic[a];
2111
- Kc(() => Uc(a, performance.now()));
2112
- }, b),
2113
- ic: b
2114
- };
2115
- return 0;
2116
- },
2117
- B: (a, b, c, d) => {
2118
- var e = (/* @__PURE__ */ new Date()).getFullYear(), g = new Date(e, 0, 1).getTimezoneOffset();
2119
- e = new Date(e, 6, 1).getTimezoneOffset();
2120
- F[a >> 2] = 60 * Math.max(g, e);
2121
- E[b >> 2] = Number(g != e);
2122
- b = (h) => {
2123
- var q = Math.abs(h);
2124
- return `UTC${0 <= h ? "-" : "+"}${String(Math.floor(q / 60)).padStart(2, "0")}${String(q % 60).padStart(2, "0")}`;
2125
- };
2126
- a = b(g);
2127
- b = b(e);
2128
- e < g ? (M(a, D, c, 17), M(b, D, d, 17)) : (M(a, D, d, 17), M(b, D, c, 17));
2129
- },
2130
- c: () => Date.now(),
2131
- t: () => 2147483648,
2132
- b: () => performance.now(),
2133
- n: (a) => {
2134
- var b = D.length;
2135
- a >>>= 0;
2136
- if (2147483648 < a) return !1;
2137
- for (var c = 1; 4 >= c; c *= 2) {
2138
- var d = b * (1 + .2 / c);
2139
- d = Math.min(d, a + 100663296);
2140
- a: {
2141
- d = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, d) / 65536)) - Ma.buffer.byteLength + 65535) / 65536 | 0;
2142
- try {
2143
- Ma.grow(d);
2144
- La();
2145
- var e = 1;
2146
- break a;
2147
- } catch (g) {}
2148
- e = void 0;
2149
- }
2150
- if (e) return !0;
2151
- }
2152
- return !1;
2153
- },
2154
- E: (a, b) => {
2155
- var c = 0, d = 0, e;
2156
- for (e of Nc()) {
2157
- var g = b + c;
2158
- F[a + d >> 2] = g;
2159
- c += M(e, D, g, Infinity) + 1;
2160
- d += 4;
2161
- }
2162
- return 0;
2163
- },
2164
- F: (a, b) => {
2165
- var c = Nc();
2166
- F[a >> 2] = c.length;
2167
- a = 0;
2168
- for (var d of c) a += ib(d) + 1;
2169
- F[b >> 2] = a;
2170
- return 0;
2171
- },
2172
- d: function(a) {
2173
- try {
2174
- pa(T(a));
2175
- return 0;
2176
- } catch (c) {
2177
- if ("undefined" == typeof X || "ErrnoError" !== c.name) throw c;
2178
- return c.Ma;
2179
- }
2180
- },
2181
- p: function(a, b) {
2182
- try {
2183
- var c = T(a);
2184
- m[b] = c.tty ? 2 : P(c.mode) ? 3 : 40960 === (c.mode & 61440) ? 7 : 4;
2185
- Ia[b + 2 >> 1] = 0;
2186
- H[b + 8 >> 3] = BigInt(0);
2187
- H[b + 16 >> 3] = BigInt(0);
2188
- return 0;
2189
- } catch (d) {
2190
- if ("undefined" == typeof X || "ErrnoError" !== d.name) throw d;
2191
- return d.Ma;
2192
- }
2193
- },
2194
- w: function(a, b, c, d) {
2195
- try {
2196
- a: {
2197
- var e = T(a);
2198
- a = b;
2199
- for (var g, h = b = 0; h < c; h++) {
2200
- var q = F[a >> 2], v = F[a + 4 >> 2];
2201
- a += 8;
2202
- var u = bc(e, m, q, v, g);
2203
- if (0 > u) {
2204
- var x = -1;
2205
- break a;
2206
- }
2207
- b += u;
2208
- if (u < v) break;
2209
- "undefined" != typeof g && (g += u);
2210
- }
2211
- x = b;
2212
- }
2213
- F[d >> 2] = x;
2214
- return 0;
2215
- } catch (C) {
2216
- if ("undefined" == typeof X || "ErrnoError" !== C.name) throw C;
2217
- return C.Ma;
2218
- }
2219
- },
2220
- D: function(a, b, c, d) {
2221
- b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
2222
- try {
2223
- if (isNaN(b)) return 61;
2224
- var e = T(a);
2225
- ac(e, b, c);
2226
- H[d >> 3] = BigInt(e.position);
2227
- e.ob && 0 === b && 0 === c && (e.ob = null);
2228
- return 0;
2229
- } catch (g) {
2230
- if ("undefined" == typeof X || "ErrnoError" !== g.name) throw g;
2231
- return g.Ma;
2232
- }
2233
- },
2234
- I: function(a) {
2235
- try {
2236
- var b = T(a);
2237
- return b.Ja?.fsync?.(b);
2238
- } catch (c) {
2239
- if ("undefined" == typeof X || "ErrnoError" !== c.name) throw c;
2240
- return c.Ma;
2241
- }
2242
- },
2243
- o: function(a, b, c, d) {
2244
- try {
2245
- a: {
2246
- var e = T(a);
2247
- a = b;
2248
- for (var g, h = b = 0; h < c; h++) {
2249
- var q = F[a >> 2], v = F[a + 4 >> 2];
2250
- a += 8;
2251
- var u = oa(e, m, q, v, g);
2252
- if (0 > u) {
2253
- var x = -1;
2254
- break a;
2255
- }
2256
- b += u;
2257
- if (u < v) break;
2258
- "undefined" != typeof g && (g += u);
2259
- }
2260
- x = b;
2261
- }
2262
- F[d >> 2] = x;
2263
- return 0;
2264
- } catch (C) {
2265
- if ("undefined" == typeof X || "ErrnoError" !== C.name) throw C;
2266
- return C.Ma;
2267
- }
2268
- },
2269
- j: Jc
2270
- };
2271
- function Wc() {
2272
- function a() {
2273
- k.calledRun = !0;
2274
- if (!Ga) {
2275
- if (!k.noFSInit && !Fb) {
2276
- var b, c;
2277
- Fb = !0;
2278
- b ??= k.stdin;
2279
- c ??= k.stdout;
2280
- d ??= k.stderr;
2281
- b ? W("stdin", b) : Wb("/dev/tty", "/dev/stdin");
2282
- c ? W("stdout", null, c) : Wb("/dev/tty", "/dev/stdout");
2283
- d ? W("stderr", null, d) : Wb("/dev/tty1", "/dev/stderr");
2284
- na("/dev/stdin", 0);
2285
- na("/dev/stdout", 1);
2286
- na("/dev/stderr", 1);
2287
- }
2288
- Xc.M();
2289
- Gb = !1;
2290
- k.onRuntimeInitialized?.();
2291
- if (k.postRun) for ("function" == typeof k.postRun && (k.postRun = [k.postRun]); k.postRun.length;) {
2292
- var d = k.postRun.shift();
2293
- Ua.push(d);
2294
- }
2295
- Ta(Ua);
2296
- }
2297
- }
2298
- if (0 < K) Xa = Wc;
2299
- else {
2300
- if (k.preRun) for ("function" == typeof k.preRun && (k.preRun = [k.preRun]); k.preRun.length;) Wa();
2301
- Ta(Va);
2302
- 0 < K ? Xa = Wc : k.setStatus ? (k.setStatus("Running..."), setTimeout(() => {
2303
- setTimeout(() => k.setStatus(""), 1);
2304
- a();
2305
- }, 1)) : a();
2306
- }
2307
- }
2308
- var Xc;
2309
- (async function() {
2310
- function a(c) {
2311
- c = Xc = c.exports;
2312
- k._sqlite3_free = c.O;
2313
- k._sqlite3_value_text = c.P;
2314
- k._sqlite3_prepare_v2 = c.Q;
2315
- k._sqlite3_step = c.R;
2316
- k._sqlite3_reset = c.S;
2317
- k._sqlite3_exec = c.T;
2318
- k._sqlite3_finalize = c.U;
2319
- k._sqlite3_column_name = c.V;
2320
- k._sqlite3_column_text = c.W;
2321
- k._sqlite3_column_type = c.X;
2322
- k._sqlite3_errmsg = c.Y;
2323
- k._sqlite3_clear_bindings = c.Z;
2324
- k._sqlite3_value_blob = c._;
2325
- k._sqlite3_value_bytes = c.$;
2326
- k._sqlite3_value_double = c.aa;
2327
- k._sqlite3_value_int = c.ba;
2328
- k._sqlite3_value_type = c.ca;
2329
- k._sqlite3_result_blob = c.da;
2330
- k._sqlite3_result_double = c.ea;
2331
- k._sqlite3_result_error = c.fa;
2332
- k._sqlite3_result_int = c.ga;
2333
- k._sqlite3_result_int64 = c.ha;
2334
- k._sqlite3_result_null = c.ia;
2335
- k._sqlite3_result_text = c.ja;
2336
- k._sqlite3_aggregate_context = c.ka;
2337
- k._sqlite3_column_count = c.la;
2338
- k._sqlite3_data_count = c.ma;
2339
- k._sqlite3_column_blob = c.na;
2340
- k._sqlite3_column_bytes = c.oa;
2341
- k._sqlite3_column_double = c.pa;
2342
- k._sqlite3_bind_blob = c.qa;
2343
- k._sqlite3_bind_double = c.ra;
2344
- k._sqlite3_bind_int = c.sa;
2345
- k._sqlite3_bind_text = c.ta;
2346
- k._sqlite3_bind_parameter_index = c.ua;
2347
- k._sqlite3_sql = c.va;
2348
- k._sqlite3_changes = c.wa;
2349
- k._sqlite3_close_v2 = c.xa;
2350
- k._sqlite3_create_function_v2 = c.ya;
2351
- k._sqlite3_update_hook = c.za;
2352
- k._sqlite3_open = c.Aa;
2353
- da = k._malloc = c.Ba;
2354
- ea = k._free = c.Ca;
2355
- Ab = c.Da;
2356
- Uc = c.Ea;
2357
- sa = c.Fa;
2358
- y = c.Ga;
2359
- qa = c.Ha;
2360
- Ma = c.L;
2361
- Z = c.N;
2362
- La();
2363
- K--;
2364
- k.monitorRunDependencies?.(K);
2365
- 0 == K && Xa && (c = Xa, Xa = null, c());
2366
- return Xc;
2367
- }
2368
- K++;
2369
- k.monitorRunDependencies?.(K);
2370
- var b = { a: Vc };
2371
- if (k.instantiateWasm) return new Promise((c) => {
2372
- k.instantiateWasm(b, (d, e) => {
2373
- c(a(d, e));
2374
- });
2375
- });
2376
- Oa ??= k.locateFile ? k.locateFile("sql-wasm.wasm", Aa) : Aa + "sql-wasm.wasm";
2377
- return a((await Ra(b)).instance);
2378
- })();
2379
- Wc();
2380
- return Module;
2381
- });
2382
- return initSqlJsPromise;
2383
- };
2384
- if (typeof exports === "object" && typeof module === "object") {
2385
- module.exports = initSqlJs;
2386
- module.exports.default = initSqlJs;
2387
- } else if (typeof define === "function" && define["amd"]) define([], function() {
2388
- return initSqlJs;
2389
- });
2390
- else if (typeof exports === "object") exports["Module"] = initSqlJs;
2391
- })))(), 1)).default;
1
+ import initializeSqlJs from "./vendor/sql-wasm-lite.js";
2
+ //#region src/lite.ts
3
+ const initSqlJsLite = (options) => initializeSqlJs({
4
+ ...options,
5
+ locateFile: options?.locateFile ?? ((file, prefix = "") => `${prefix}../assets/${file === "sql-wasm.wasm" ? "sql-wasm-lite.wasm" : file}`)
6
+ });
2392
7
  //#endregion
2393
8
  export { initSqlJsLite as default, initSqlJsLite };