brsh 3.7.0 → 3.8.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/dist/shell.es.js CHANGED
@@ -96,7 +96,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
96
96
  if (typeof e == "string") return g(e, t);
97
97
  if (o.isView(e)) return y(e);
98
98
  if (e == null) throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e);
99
- if (X(e, o) || e && X(e.buffer, o) || s !== void 0 && (X(e, s) || e && X(e.buffer, s))) return b(e, t, n);
99
+ if (fe(e, o) || e && fe(e.buffer, o) || s !== void 0 && (fe(e, s) || e && fe(e.buffer, s))) return b(e, t, n);
100
100
  if (typeof e == "number") throw TypeError("The \"value\" argument must not be of type number. Received type number");
101
101
  let r = e.valueOf && e.valueOf();
102
102
  if (r != null && r !== e) return u.from(r, t, n);
@@ -137,7 +137,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
137
137
  return n;
138
138
  }
139
139
  function y(e) {
140
- if (X(e, a)) {
140
+ if (fe(e, a)) {
141
141
  let t = new a(e);
142
142
  return b(t.buffer, t.byteOffset, t.byteLength);
143
143
  }
@@ -167,7 +167,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
167
167
  u.isBuffer = function(e) {
168
168
  return e != null && e._isBuffer === !0 && e !== u.prototype;
169
169
  }, u.compare = function(e, t) {
170
- if (X(e, a) && (e = u.from(e, e.offset, e.byteLength)), X(t, a) && (t = u.from(t, t.offset, t.byteLength)), !u.isBuffer(e) || !u.isBuffer(t)) throw TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");
170
+ if (fe(e, a) && (e = u.from(e, e.offset, e.byteLength)), fe(t, a) && (t = u.from(t, t.offset, t.byteLength)), !u.isBuffer(e) || !u.isBuffer(t)) throw TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");
171
171
  if (e === t) return 0;
172
172
  let n = e.length, r = t.length;
173
173
  for (let i = 0, a = Math.min(n, r); i < a; ++i) if (e[i] !== t[i]) {
@@ -198,7 +198,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
198
198
  let r = u.allocUnsafe(t), i = 0;
199
199
  for (n = 0; n < e.length; ++n) {
200
200
  let t = e[n];
201
- if (X(t, a)) i + t.length > r.length ? (u.isBuffer(t) || (t = u.from(t)), t.copy(r, i)) : a.prototype.set.call(r, t, i);
201
+ if (fe(t, a)) i + t.length > r.length ? (u.isBuffer(t) || (t = u.from(t)), t.copy(r, i)) : a.prototype.set.call(r, t, i);
202
202
  else if (u.isBuffer(t)) t.copy(r, i);
203
203
  else throw TypeError("\"list\" argument must be an Array of Buffers");
204
204
  i += t.length;
@@ -207,7 +207,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
207
207
  };
208
208
  function w(e, t) {
209
209
  if (u.isBuffer(e)) return e.length;
210
- if (o.isView(e) || X(e, o)) return e.byteLength;
210
+ if (o.isView(e) || fe(e, o)) return e.byteLength;
211
211
  if (typeof e != "string") throw TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type " + typeof e);
212
212
  let n = e.length, r = arguments.length > 2 && arguments[2] === !0;
213
213
  if (!r && n === 0) return 0;
@@ -217,15 +217,15 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
217
217
  case "latin1":
218
218
  case "binary": return n;
219
219
  case "utf8":
220
- case "utf-8": return ce(e).length;
220
+ case "utf-8": return se(e).length;
221
221
  case "ucs2":
222
222
  case "ucs-2":
223
223
  case "utf16le":
224
224
  case "utf-16le": return n * 2;
225
225
  case "hex": return n >>> 1;
226
- case "base64": return de(e).length;
226
+ case "base64": return ue(e).length;
227
227
  default:
228
- if (i) return r ? -1 : ce(e).length;
228
+ if (i) return r ? -1 : se(e).length;
229
229
  t = ("" + t).toLowerCase(), i = !0;
230
230
  }
231
231
  }
@@ -280,7 +280,7 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
280
280
  let t = "", n = e.INSPECT_MAX_BYTES;
281
281
  return t = this.toString("hex", 0, n).replace(/(.{2})/g, "$1 ").trim(), this.length > n && (t += " ... "), "<Buffer " + t + ">";
282
282
  }, r && (u.prototype[r] = u.prototype.inspect), u.prototype.compare = function(e, t, n, r, i) {
283
- if (X(e, a) && (e = u.from(e, e.offset, e.byteLength)), !u.isBuffer(e)) throw TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type " + typeof e);
283
+ if (fe(e, a) && (e = u.from(e, e.offset, e.byteLength)), !u.isBuffer(e)) throw TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type " + typeof e);
284
284
  if (t === void 0 && (t = 0), n === void 0 && (n = e ? e.length : 0), r === void 0 && (r = 0), i === void 0 && (i = this.length), t < 0 || n > e.length || r < 0 || i > this.length) throw RangeError("out of range index");
285
285
  if (r >= i && t >= n) return 0;
286
286
  if (r >= i) return -1;
@@ -351,16 +351,16 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
351
351
  return o;
352
352
  }
353
353
  function A(e, t, n, r) {
354
- return fe(ce(t, e.length - n), e, n, r);
354
+ return de(se(t, e.length - n), e, n, r);
355
355
  }
356
356
  function j(e, t, n, r) {
357
- return fe(le(t), e, n, r);
357
+ return de(ce(t), e, n, r);
358
358
  }
359
359
  function M(e, t, n, r) {
360
- return fe(de(t), e, n, r);
360
+ return de(ue(t), e, n, r);
361
361
  }
362
362
  function N(e, t, n, r) {
363
- return fe(ue(t, e.length - n), e, n, r);
363
+ return de(le(t, e.length - n), e, n, r);
364
364
  }
365
365
  u.prototype.write = function(e, t, n, r) {
366
366
  if (t === void 0) r = "utf8", n = this.length, t = 0;
@@ -483,15 +483,15 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
483
483
  }, u.prototype.readUint32BE = u.prototype.readUInt32BE = function(e, t) {
484
484
  return e >>>= 0, t || V(e, 4, this.length), this[e] * 16777216 + (this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3]);
485
485
  }, u.prototype.readBigUInt64LE = Z(function(e) {
486
- e >>>= 0, Y(e, "offset");
486
+ e >>>= 0, X(e, "offset");
487
487
  let t = this[e], n = this[e + 7];
488
- (t === void 0 || n === void 0) && ae(e, this.length - 8);
488
+ (t === void 0 || n === void 0) && ie(e, this.length - 8);
489
489
  let r = t + this[++e] * 2 ** 8 + this[++e] * 2 ** 16 + this[++e] * 2 ** 24, i = this[++e] + this[++e] * 2 ** 8 + this[++e] * 2 ** 16 + n * 2 ** 24;
490
490
  return BigInt(r) + (BigInt(i) << BigInt(32));
491
491
  }), u.prototype.readBigUInt64BE = Z(function(e) {
492
- e >>>= 0, Y(e, "offset");
492
+ e >>>= 0, X(e, "offset");
493
493
  let t = this[e], n = this[e + 7];
494
- (t === void 0 || n === void 0) && ae(e, this.length - 8);
494
+ (t === void 0 || n === void 0) && ie(e, this.length - 8);
495
495
  let r = t * 2 ** 24 + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + this[++e], i = this[++e] * 2 ** 24 + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + n;
496
496
  return (BigInt(r) << BigInt(32)) + BigInt(i);
497
497
  }), u.prototype.readIntLE = function(e, t, n) {
@@ -519,15 +519,15 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
519
519
  }, u.prototype.readInt32BE = function(e, t) {
520
520
  return e >>>= 0, t || V(e, 4, this.length), this[e] << 24 | this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3];
521
521
  }, u.prototype.readBigInt64LE = Z(function(e) {
522
- e >>>= 0, Y(e, "offset");
522
+ e >>>= 0, X(e, "offset");
523
523
  let t = this[e], n = this[e + 7];
524
- (t === void 0 || n === void 0) && ae(e, this.length - 8);
524
+ (t === void 0 || n === void 0) && ie(e, this.length - 8);
525
525
  let r = this[e + 4] + this[e + 5] * 2 ** 8 + this[e + 6] * 2 ** 16 + (n << 24);
526
526
  return (BigInt(r) << BigInt(32)) + BigInt(t + this[++e] * 2 ** 8 + this[++e] * 2 ** 16 + this[++e] * 2 ** 24);
527
527
  }), u.prototype.readBigInt64BE = Z(function(e) {
528
- e >>>= 0, Y(e, "offset");
528
+ e >>>= 0, X(e, "offset");
529
529
  let t = this[e], n = this[e + 7];
530
- (t === void 0 || n === void 0) && ae(e, this.length - 8);
530
+ (t === void 0 || n === void 0) && ie(e, this.length - 8);
531
531
  let r = (t << 24) + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + this[++e];
532
532
  return (BigInt(r) << BigInt(32)) + BigInt(this[++e] * 2 ** 24 + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + n);
533
533
  }), u.prototype.readFloatLE = function(e, t) {
@@ -572,14 +572,14 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
572
572
  return e = +e, t >>>= 0, n || H(this, e, t, 4, 4294967295, 0), this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255, t + 4;
573
573
  };
574
574
  function U(e, t, n, r, i) {
575
- J(t, r, i, e, n, 7);
575
+ re(t, r, i, e, n, 7);
576
576
  let a = Number(t & BigInt(4294967295));
577
577
  e[n++] = a, a >>= 8, e[n++] = a, a >>= 8, e[n++] = a, a >>= 8, e[n++] = a;
578
578
  let o = Number(t >> BigInt(32) & BigInt(4294967295));
579
579
  return e[n++] = o, o >>= 8, e[n++] = o, o >>= 8, e[n++] = o, o >>= 8, e[n++] = o, n;
580
580
  }
581
581
  function te(e, t, n, r, i) {
582
- J(t, r, i, e, n, 7);
582
+ re(t, r, i, e, n, 7);
583
583
  let a = Number(t & BigInt(4294967295));
584
584
  e[n + 7] = a, a >>= 8, e[n + 6] = a, a >>= 8, e[n + 5] = a, a >>= 8, e[n + 4] = a;
585
585
  let o = Number(t >> BigInt(32) & BigInt(4294967295));
@@ -631,13 +631,13 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
631
631
  }, u.prototype.writeFloatBE = function(e, t, n) {
632
632
  return ne(this, e, t, !1, n);
633
633
  };
634
- function re(e, t, r, i, a) {
634
+ function G(e, t, r, i, a) {
635
635
  return t = +t, r >>>= 0, a || W(e, t, r, 8), n.write(e, t, r, i, 52, 8), r + 8;
636
636
  }
637
637
  u.prototype.writeDoubleLE = function(e, t, n) {
638
- return re(this, e, t, !0, n);
638
+ return G(this, e, t, !0, n);
639
639
  }, u.prototype.writeDoubleBE = function(e, t, n) {
640
- return re(this, e, t, !1, n);
640
+ return G(this, e, t, !1, n);
641
641
  }, u.prototype.copy = function(e, t, n, r) {
642
642
  if (!u.isBuffer(e)) throw TypeError("argument should be a Buffer");
643
643
  if (n ||= 0, !r && r !== 0 && (r = this.length), t >= e.length && (t = e.length), t ||= 0, r > 0 && r < n && (r = n), r === n || e.length === 0 || this.length === 0) return 0;
@@ -668,9 +668,9 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
668
668
  }
669
669
  return this;
670
670
  };
671
- let G = {};
672
- function K(e, t, n) {
673
- G[e] = class extends n {
671
+ let K = {};
672
+ function q(e, t, n) {
673
+ K[e] = class extends n {
674
674
  constructor() {
675
675
  super(), Object.defineProperty(this, "message", {
676
676
  value: t.apply(this, arguments),
@@ -694,42 +694,42 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
694
694
  }
695
695
  };
696
696
  }
697
- K("ERR_BUFFER_OUT_OF_BOUNDS", function(e) {
697
+ q("ERR_BUFFER_OUT_OF_BOUNDS", function(e) {
698
698
  return e ? `${e} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
699
- }, RangeError), K("ERR_INVALID_ARG_TYPE", function(e, t) {
699
+ }, RangeError), q("ERR_INVALID_ARG_TYPE", function(e, t) {
700
700
  return `The "${e}" argument must be of type number. Received type ${typeof t}`;
701
- }, TypeError), K("ERR_OUT_OF_RANGE", function(e, t, n) {
701
+ }, TypeError), q("ERR_OUT_OF_RANGE", function(e, t, n) {
702
702
  let r = `The value of "${e}" is out of range.`, i = n;
703
- return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i = ie(String(n)) : typeof n == "bigint" && (i = String(n), (n > BigInt(2) ** BigInt(32) || n < -(BigInt(2) ** BigInt(32))) && (i = ie(i)), i += "n"), r += ` It must be ${t}. Received ${i}`, r;
703
+ return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i = J(String(n)) : typeof n == "bigint" && (i = String(n), (n > BigInt(2) ** BigInt(32) || n < -(BigInt(2) ** BigInt(32))) && (i = J(i)), i += "n"), r += ` It must be ${t}. Received ${i}`, r;
704
704
  }, RangeError);
705
- function ie(e) {
705
+ function J(e) {
706
706
  let t = "", n = e.length, r = +(e[0] === "-");
707
707
  for (; n >= r + 4; n -= 3) t = `_${e.slice(n - 3, n)}${t}`;
708
708
  return `${e.slice(0, n)}${t}`;
709
709
  }
710
- function q(e, t, n) {
711
- Y(t, "offset"), (e[t] === void 0 || e[t + n] === void 0) && ae(t, e.length - (n + 1));
710
+ function Y(e, t, n) {
711
+ X(t, "offset"), (e[t] === void 0 || e[t + n] === void 0) && ie(t, e.length - (n + 1));
712
712
  }
713
- function J(e, t, n, r, i, a) {
713
+ function re(e, t, n, r, i, a) {
714
714
  if (e > n || e < t) {
715
715
  let r = typeof t == "bigint" ? "n" : "", i;
716
- throw i = a > 3 ? t === 0 || t === BigInt(0) ? `>= 0${r} and < 2${r} ** ${(a + 1) * 8}${r}` : `>= -(2${r} ** ${(a + 1) * 8 - 1}${r}) and < 2 ** ${(a + 1) * 8 - 1}${r}` : `>= ${t}${r} and <= ${n}${r}`, new G.ERR_OUT_OF_RANGE("value", i, e);
716
+ throw i = a > 3 ? t === 0 || t === BigInt(0) ? `>= 0${r} and < 2${r} ** ${(a + 1) * 8}${r}` : `>= -(2${r} ** ${(a + 1) * 8 - 1}${r}) and < 2 ** ${(a + 1) * 8 - 1}${r}` : `>= ${t}${r} and <= ${n}${r}`, new K.ERR_OUT_OF_RANGE("value", i, e);
717
717
  }
718
- q(r, i, a);
718
+ Y(r, i, a);
719
719
  }
720
- function Y(e, t) {
721
- if (typeof e != "number") throw new G.ERR_INVALID_ARG_TYPE(t, "number", e);
720
+ function X(e, t) {
721
+ if (typeof e != "number") throw new K.ERR_INVALID_ARG_TYPE(t, "number", e);
722
722
  }
723
- function ae(e, t, n) {
724
- throw Math.floor(e) === e ? t < 0 ? new G.ERR_BUFFER_OUT_OF_BOUNDS() : new G.ERR_OUT_OF_RANGE(n || "offset", `>= ${+!!n} and <= ${t}`, e) : (Y(e, n), new G.ERR_OUT_OF_RANGE(n || "offset", "an integer", e));
723
+ function ie(e, t, n) {
724
+ throw Math.floor(e) === e ? t < 0 ? new K.ERR_BUFFER_OUT_OF_BOUNDS() : new K.ERR_OUT_OF_RANGE(n || "offset", `>= ${+!!n} and <= ${t}`, e) : (X(e, n), new K.ERR_OUT_OF_RANGE(n || "offset", "an integer", e));
725
725
  }
726
- let oe = /[^+/0-9A-Za-z-_]/g;
727
- function se(e) {
728
- if (e = e.split("=")[0], e = e.trim().replace(oe, ""), e.length < 2) return "";
726
+ let ae = /[^+/0-9A-Za-z-_]/g;
727
+ function oe(e) {
728
+ if (e = e.split("=")[0], e = e.trim().replace(ae, ""), e.length < 2) return "";
729
729
  for (; e.length % 4 != 0;) e += "=";
730
730
  return e;
731
731
  }
732
- function ce(e, t) {
732
+ function se(e, t) {
733
733
  t ||= Infinity;
734
734
  let n, r = e.length, i = null, a = [];
735
735
  for (let o = 0; o < r; ++o) {
@@ -767,25 +767,25 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
767
767
  }
768
768
  return a;
769
769
  }
770
- function le(e) {
770
+ function ce(e) {
771
771
  let t = [];
772
772
  for (let n = 0; n < e.length; ++n) t.push(e.charCodeAt(n) & 255);
773
773
  return t;
774
774
  }
775
- function ue(e, t) {
775
+ function le(e, t) {
776
776
  let n, r, i, a = [];
777
777
  for (let o = 0; o < e.length && !((t -= 2) < 0); ++o) n = e.charCodeAt(o), r = n >> 8, i = n % 256, a.push(i), a.push(r);
778
778
  return a;
779
779
  }
780
- function de(e) {
781
- return t.toByteArray(se(e));
780
+ function ue(e) {
781
+ return t.toByteArray(oe(e));
782
782
  }
783
- function fe(e, t, n, r) {
783
+ function de(e, t, n, r) {
784
784
  let i;
785
785
  for (i = 0; i < r && !(i + n >= t.length || i >= e.length); ++i) t[i + n] = e[i];
786
786
  return i;
787
787
  }
788
- function X(e, t) {
788
+ function fe(e, t) {
789
789
  return e instanceof t || e != null && e.constructor != null && e.constructor.name != null && e.constructor.name === t.name;
790
790
  }
791
791
  function pe(e) {
@@ -1240,10 +1240,24 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
1240
1240
  super(), this.isTTY = e.isTTY !== !1, this.readable = !0, this.writable = !0, this.columns = e.columns || 80, this.rows = e.rows || 24, this.isRaw = !1, this._encoding = null, this._onWrite = e.onWrite || null;
1241
1241
  }
1242
1242
  write(e, t, n) {
1243
- return e == null ? !0 : (typeof this._onWrite == "function" && this._onWrite(e), this.emit("data", this._formatChunk(e)), typeof t == "function" ? t() : typeof n == "function" && n(), !0);
1243
+ if (e == null) return !0;
1244
+ typeof this._onWrite == "function" && this._onWrite(e), this._isPushing = !0;
1245
+ try {
1246
+ this.emit("data", this._formatChunk(e));
1247
+ } finally {
1248
+ this._isPushing = !1;
1249
+ }
1250
+ return typeof t == "function" ? t() : typeof n == "function" && n(), !0;
1244
1251
  }
1245
1252
  pushData(e) {
1246
- e != null && this.emit("data", this._formatChunk(e));
1253
+ if (e != null) {
1254
+ this._isPushing = !0;
1255
+ try {
1256
+ this.emit("data", this._formatChunk(e));
1257
+ } finally {
1258
+ this._isPushing = !1;
1259
+ }
1260
+ }
1247
1261
  }
1248
1262
  _formatChunk(e) {
1249
1263
  return this._encoding ? typeof e == "string" ? e : e instanceof Uint8Array || y !== void 0 && y.isBuffer(e) ? new TextDecoder().decode(e) : String(e) : e;
@@ -1304,11 +1318,11 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
1304
1318
  columns: n,
1305
1319
  rows: o,
1306
1320
  onWrite: (e) => this.emit("stderr", e)
1307
- }), this.stdinStream.on("data", (e) => {
1321
+ }), this._onStdinStreamData = (e) => {
1308
1322
  if (!this.captureInput) return;
1309
1323
  let t = a(e);
1310
1324
  for (let e of t) !this.interactive && !this.stdinStream.isRaw && (e === "Enter" ? this.stdout.write("\r\n") : e === "Backspace" ? this.stdout.write("\b \b") : e.length === 1 && this.stdout.write(e)), this.onInput(e);
1311
- });
1325
+ }, this.stdinStream.on("data", this._onStdinStreamData);
1312
1326
  }
1313
1327
  get name() {
1314
1328
  return "unnamed";
@@ -1366,7 +1380,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
1366
1380
  });
1367
1381
  }
1368
1382
  };
1369
- })), re = /* @__PURE__ */ t(((e, t) => {
1383
+ })), G = /* @__PURE__ */ t(((e, t) => {
1370
1384
  b(), B();
1371
1385
  var { BinaryFile: n, SymlinkRef: r } = x(), i = new Uint8Array([
1372
1386
  66,
@@ -1637,7 +1651,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
1637
1651
  }
1638
1652
  }
1639
1653
  };
1640
- })), G = /* @__PURE__ */ t(((e, t) => {
1654
+ })), K = /* @__PURE__ */ t(((e, t) => {
1641
1655
  b();
1642
1656
  var n = x(), { BinaryFile: r, SymlinkRef: i } = n;
1643
1657
  function a(e) {
@@ -1662,20 +1676,20 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
1662
1676
  t.exports = class extends n {
1663
1677
  constructor(e = "/", t = {}, n = {}, r = null) {
1664
1678
  if (super(), t instanceof Uint8Array || t instanceof ArrayBuffer) {
1665
- let { deserializeBinaryFilesystem: e } = re(), r = e(t);
1679
+ let { deserializeBinaryFilesystem: e } = G(), r = e(t);
1666
1680
  t = r.filesystem, n = Object.assign({}, r.permissions, n);
1667
1681
  } else if (t && typeof t == "object" && t.filesystem && (t.filesystem instanceof Uint8Array || typeof t.filesystem == "object") && (n = Object.assign({}, t.permissions || {}, n), t = t.filesystem, t instanceof Uint8Array || t instanceof ArrayBuffer)) {
1668
- let { deserializeBinaryFilesystem: e } = re(), r = e(t);
1682
+ let { deserializeBinaryFilesystem: e } = G(), r = e(t);
1669
1683
  t = r.filesystem, n = Object.assign({}, r.permissions, n);
1670
1684
  }
1671
1685
  a(t), this.fileSystem = t, this.permissions = Object.assign({}, n), this.cwd = e.endsWith("/") ? e : e + "/", this._onChange = r, this._changeScheduled = !1;
1672
1686
  }
1673
1687
  toBinaryContainer(e = {}) {
1674
- let { serializeBinaryFilesystem: t } = re();
1688
+ let { serializeBinaryFilesystem: t } = G();
1675
1689
  return t(this.fileSystem, this.permissions, e);
1676
1690
  }
1677
1691
  static fromBinaryContainer(e, t = {}) {
1678
- let { deserializeBinaryFilesystem: n } = re();
1692
+ let { deserializeBinaryFilesystem: n } = G();
1679
1693
  return n(e, t);
1680
1694
  }
1681
1695
  getFileByPath(e) {
@@ -1853,9 +1867,9 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
1853
1867
  return null;
1854
1868
  }
1855
1869
  }, t.exports.BinaryFile = r, t.exports.SymlinkRef = i;
1856
- })), K = /* @__PURE__ */ t(((e, t) => {
1870
+ })), q = /* @__PURE__ */ t(((e, t) => {
1857
1871
  t.exports = null;
1858
- })), ie = /* @__PURE__ */ t(((e, t) => {
1872
+ })), J = /* @__PURE__ */ t(((e, t) => {
1859
1873
  B();
1860
1874
  function n(e) {
1861
1875
  if (typeof e != "string") throw TypeError("Path must be a string. Received " + JSON.stringify(e));
@@ -2023,9 +2037,9 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2023
2037
  posix: null
2024
2038
  };
2025
2039
  a.posix = a, t.exports = a;
2026
- })), q = /* @__PURE__ */ t(((e, t) => {
2040
+ })), Y = /* @__PURE__ */ t(((e, t) => {
2027
2041
  B();
2028
- var n = K(), r = ie(), i = x();
2042
+ var n = q(), r = J(), i = x();
2029
2043
  t.exports = class extends i {
2030
2044
  constructor(e, t = null) {
2031
2045
  super(), this._onChange = t, this._changeScheduled = !1, this._virtualFiles = {}, this.cwd = this._normalizeCwd(e || z.cwd());
@@ -2232,8 +2246,8 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2232
2246
  }
2233
2247
  }
2234
2248
  };
2235
- })), J = /* @__PURE__ */ t(((e, t) => {
2236
- var n = G();
2249
+ })), re = /* @__PURE__ */ t(((e, t) => {
2250
+ var n = K();
2237
2251
  t.exports = class {
2238
2252
  constructor(e) {
2239
2253
  this.options = e;
@@ -2267,7 +2281,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2267
2281
  return this.fs._getFileRaw(t) || null;
2268
2282
  }
2269
2283
  setNodeFilesystem(e) {
2270
- let t = q(), n = this.fs._onChange;
2284
+ let t = Y(), n = this.fs._onChange;
2271
2285
  this.fs = new t(e, n);
2272
2286
  }
2273
2287
  setFilesystem(e, t = {}) {
@@ -2287,15 +2301,15 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2287
2301
  typeof this._destroyFn == "function" && this._destroyFn(e);
2288
2302
  }
2289
2303
  };
2290
- })), Y = /* @__PURE__ */ t(((e, t) => {
2304
+ })), X = /* @__PURE__ */ t(((e, t) => {
2291
2305
  var n = W();
2292
2306
  t.exports = class extends n {
2293
2307
  constructor(e, t) {
2294
2308
  super(e, t);
2295
2309
  }
2296
2310
  };
2297
- })), ae = /* @__PURE__ */ t(((e, t) => {
2298
- var n = Y();
2311
+ })), ie = /* @__PURE__ */ t(((e, t) => {
2312
+ var n = X();
2299
2313
  function r(e) {
2300
2314
  return /^#!\/(sh\.js|bin\/(sh|brsh))/.test(e);
2301
2315
  }
@@ -2487,7 +2501,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2487
2501
  }
2488
2502
  _executeNode(e) {
2489
2503
  if (e.type === "function") {
2490
- let t = e.name, n = e.bodyLines, r = this, i = Y(), a = class extends i {
2504
+ let t = e.name, n = e.bodyLines, r = this, i = X(), a = class extends i {
2491
2505
  static get name() {
2492
2506
  return t;
2493
2507
  }
@@ -2687,9 +2701,9 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2687
2701
  }
2688
2702
  }
2689
2703
  }, t.exports.isKnownInterpreter = r;
2690
- })), oe = /* @__PURE__ */ t(((e, t) => {
2704
+ })), ae = /* @__PURE__ */ t(((e, t) => {
2691
2705
  b();
2692
- var n = ae(), { BinaryFile: r } = G(), i = 0, a = 8, o = 20, s = 28, c = 31, l = 44, u = 54, d = 70, f = 0, p = 2, m = 3, h = 4, g = 1, _ = 2, v = 4, x = 8, S = 1, C = class extends n {
2706
+ var n = ie(), { BinaryFile: r } = K(), i = 0, a = 6, o = 8, s = 20, c = 28, l = 31, u = 44, d = 54, f = 70, p = 0, m = 2, h = 3, g = 4, _ = 1, v = 2, x = 4, S = 8, C = 1, w = 4, T = class extends n {
2693
2707
  get name() {
2694
2708
  return "wasm";
2695
2709
  }
@@ -2740,7 +2754,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2740
2754
  return n[e] ? new TextEncoder().encode(n[e]) : new TextEncoder().encode(e);
2741
2755
  }
2742
2756
  onInput(e) {
2743
- if (!this._handlingStreamData) {
2757
+ if (!this._handlingStreamData && !(this.stdinStream && this.stdinStream._isPushing)) {
2744
2758
  if (typeof this._externalKeyHandler == "function") {
2745
2759
  this._externalKeyHandler(e);
2746
2760
  return;
@@ -2756,7 +2770,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2756
2770
  run() {
2757
2771
  let e = this.script, t = (() => {
2758
2772
  try {
2759
- return K();
2773
+ return q();
2760
2774
  } catch {
2761
2775
  return null;
2762
2776
  }
@@ -2824,8 +2838,10 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2824
2838
  let t = {
2825
2839
  1: "",
2826
2840
  2: ""
2827
- }, n = new TextDecoder(), b = new TextEncoder(), C = null, w = null, T = !1, E = 0, D = null, O = null, j = null, M = null, N = !!(this.interactive && (this.stdin === void 0 || this.stdin === null || this.stdin === this.stdinStream || this.stdin && this.stdin.isTTY)), P = (e, n) => {
2828
- if (N && (e === 1 || e === 2)) {
2841
+ }, n = new TextDecoder(), b = new TextEncoder(), T = null, E = null, D = !1, O = 0, k = null, A = null, N = null, P = null, F = this.stdin === void 0 || this.stdin === null || this.stdin === this.stdinStream || this.stdin && this.stdin.isTTY, I = !!(this.interactive && F), L = () => {
2842
+ I || !F || (I = !0, this._isInteractive = !0, t[1] &&= (this.stdout && typeof this.stdout.write == "function" && this.stdout.write(t[1]), ""), t[2] &&= (this.stderr && typeof this.stderr.write == "function" && this.stderr.write(t[2]), ""), this.stdinStream && typeof this.stdinStream.setRawMode == "function" && this.stdinStream.setRawMode(!0));
2843
+ }, R = (e, n) => {
2844
+ if (I && (e === 1 || e === 2)) {
2829
2845
  if (e === 1 && this.stdout) {
2830
2846
  this.stdout.write(n);
2831
2847
  return;
@@ -2839,57 +2855,61 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2839
2855
  let r = t[e].split("\n");
2840
2856
  t[e] = r.pop();
2841
2857
  for (let t of r) e === 1 ? this.stdOut = t : this.stdErr = t;
2842
- }, F = () => {
2843
- t[1] &&= (N && this.stdout ? this.stdout.write(t[1]) : this.stdOut = t[1], ""), t[2] &&= (N && this.stderr ? this.stderr.write(t[2]) : this.stdErr = t[2], "");
2844
- }, I = [], L = (e) => {
2858
+ }, ee = () => {
2859
+ t[1] &&= (I && this.stdout ? this.stdout.write(t[1]) : this.stdOut = t[1], ""), t[2] &&= (I && this.stderr ? this.stderr.write(t[2]) : this.stdErr = t[2], "");
2860
+ }, z = [], B = (e) => {
2845
2861
  if (!(!e || e.length === 0)) {
2846
- for (let t = 0; t < e.length; t++) I.push(e[t]);
2847
- if (O) {
2848
- let e = O;
2849
- O = null, e();
2862
+ for (let t = 0; t < e.length; t++) z.push(e[t]);
2863
+ if (A) {
2864
+ let e = A;
2865
+ A = null, e();
2850
2866
  }
2851
2867
  }
2852
2868
  };
2853
- M = (e) => {
2869
+ P = (e) => {
2854
2870
  this._handlingStreamData = !0;
2855
2871
  try {
2856
- L(typeof e == "string" ? b.encode(e) : e instanceof Uint8Array ? e : y !== void 0 && y.isBuffer(e) ? new Uint8Array(e) : b.encode(String(e ?? "")));
2872
+ B(typeof e == "string" ? b.encode(e) : e instanceof Uint8Array ? e : y !== void 0 && y.isBuffer(e) ? new Uint8Array(e) : b.encode(String(e ?? "")));
2857
2873
  } finally {
2858
2874
  this._handlingStreamData = !1;
2859
2875
  }
2860
2876
  }, this._externalKeyHandler = (e) => {
2861
2877
  if (this._handlingStreamData) return;
2862
2878
  let t = this._keyToBytes(e);
2863
- t && L(t);
2864
- }, N && this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("data", M), N && this.stdin && this.stdin !== this.stdinStream && typeof this.stdin.on == "function" && this.stdin.on("data", M);
2865
- let R = !N && typeof this.stdin == "string" ? b.encode(this.stdin) : !N && this.stdin instanceof Uint8Array ? this.stdin : !N && y !== void 0 && y.isBuffer(this.stdin) ? new Uint8Array(this.stdin) : new Uint8Array(), ee = 0, z = this.context && this.context.fs ? this.context.fs : this.fs, B = this.context && this.context.fs && this.context.fs.cwd || this.fs && this.fs.cwd || this.context && typeof this.context.getVar == "function" && this.context.getVar("PWD") || z && z.cwd || "/", V = B.length > 1 && B.endsWith("/") ? B.slice(0, -1) : B, H = 5, U = new Map([[3, {
2879
+ t && B(t);
2880
+ }, this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", this._onStdinStreamData), F && this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("data", P), F && this.stdin && this.stdin !== this.stdinStream && typeof this.stdin.on == "function" && this.stdin.on("data", P);
2881
+ let V = !F && typeof this.stdin == "string" ? b.encode(this.stdin) : !F && this.stdin instanceof Uint8Array ? this.stdin : !F && y !== void 0 && y.isBuffer(this.stdin) ? new Uint8Array(this.stdin) : new Uint8Array(), H = 0, U = this.context && this.context.fs ? this.context.fs : this.fs, te = this.context && this.context.fs && this.context.fs.cwd || this.fs && this.fs.cwd || this.context && typeof this.context.getVar == "function" && this.context.getVar("PWD") || U && U.cwd || "/", W = te.length > 1 && te.endsWith("/") ? te.slice(0, -1) : te, ne = 5, G = new Map([[3, {
2866
2882
  type: "preopen",
2867
2883
  path: "/",
2868
2884
  guestName: "/"
2869
2885
  }], [4, {
2870
2886
  type: "preopen",
2871
- path: V,
2887
+ path: W,
2872
2888
  guestName: "."
2873
- }]]), te = (e) => {
2889
+ }]]), K = new Map([
2890
+ [0, 0],
2891
+ [1, 0],
2892
+ [2, 0]
2893
+ ]), q = (e) => {
2874
2894
  let t = e.split("/").filter(Boolean);
2875
2895
  return t.pop(), "/" + t.join("/");
2876
- }, W = (e, t) => {
2877
- let n = U.get(e);
2896
+ }, J = (e, t) => {
2897
+ let n = G.get(e);
2878
2898
  if (!n || n.type !== "preopen" && n.type !== "dir") return null;
2879
- if (t.startsWith("/")) return z.absolutePath(t);
2880
- if (!t || t === ".") return z.absolutePath(n.path);
2881
- let r = n.path.endsWith("/") ? n.path : n.path + "/", i = z.absolutePath(r + t), a = z.absolutePath("/" + t);
2899
+ if (t.startsWith("/")) return U.absolutePath(t);
2900
+ if (!t || t === ".") return U.absolutePath(n.path);
2901
+ let r = n.path.endsWith("/") ? n.path : n.path + "/", i = U.absolutePath(r + t), a = U.absolutePath("/" + t);
2882
2902
  if (n.path !== "/") {
2883
- if (z.exists(i)) return i;
2884
- if (z.exists(a)) return a;
2885
- let e = z.exists(te(i));
2886
- return z.exists(te(a)) && !e ? a : i;
2887
- }
2888
- if (z.exists(i)) return i;
2889
- let o = z.absolutePath(t);
2890
- return z.exists(o) ? o : i;
2891
- }, ne = (e) => {
2892
- if (!(!e || e.type !== "file" || !e.dirty || !z)) try {
2903
+ if (U.exists(i)) return i;
2904
+ if (U.exists(a)) return a;
2905
+ let e = U.exists(q(i));
2906
+ return U.exists(q(a)) && !e ? a : i;
2907
+ }
2908
+ if (U.exists(i)) return i;
2909
+ let o = U.absolutePath(t);
2910
+ return U.exists(o) ? o : i;
2911
+ }, Y = (e) => {
2912
+ if (!(!e || e.type !== "file" || !e.dirty || !U)) try {
2893
2913
  let t = !0;
2894
2914
  for (let n = 0; n < e.bytes.length; n++) if (e.bytes[n] === 0) {
2895
2915
  t = !1;
@@ -2897,10 +2917,10 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2897
2917
  }
2898
2918
  if (t) {
2899
2919
  let t = n.decode(e.bytes);
2900
- z.setFileByPath(e.path, t, !0);
2920
+ U.setFileByPath(e.path, t, !0);
2901
2921
  } else {
2902
2922
  let t = new Uint8Array(e.bytes.length);
2903
- t.set(e.bytes), z.setFileByPath(e.path, new r(t.buffer, "application/octet-stream"), !0);
2923
+ t.set(e.bytes), U.setFileByPath(e.path, new r(t.buffer, "application/octet-stream"), !0);
2904
2924
  }
2905
2925
  e.dirty = !1;
2906
2926
  } catch {}
@@ -2910,25 +2930,39 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2910
2930
  COLUMNS: String(this.stdout && this.stdout.columns || this.context && typeof this.context.getVar == "function" && this.context.getVar("COLUMNS") || 80),
2911
2931
  LINES: String(this.stdout && this.stdout.rows || this.context && typeof this.context.getVar == "function" && this.context.getVar("LINES") || 24),
2912
2932
  ...this.context && this.context.vars || {}
2913
- }, G = Object.entries(re).map(([e, t]) => `${e}=${t}`), K = new Proxy({
2914
- fd_write: (e, t, r, o) => {
2915
- if (!C) return a;
2916
- let s = new DataView(C.buffer);
2933
+ }, X = Object.entries(re).map(([e, t]) => `${e}=${t}`), ie = new Proxy({
2934
+ fd_write: (e, t, r, a) => {
2935
+ if (!T) return o;
2936
+ let s = new DataView(T.buffer);
2917
2937
  if (e === 1 || e === 2) {
2918
- let a = 0;
2938
+ let o = 0;
2939
+ for (let i = 0; i < r; i++) {
2940
+ let r = s.getUint32(t + i * 8, !0), a = s.getUint32(t + i * 8 + 4, !0);
2941
+ a > 0 && R(e, n.decode(new Uint8Array(T.buffer, r, a))), o += a;
2942
+ }
2943
+ return s.setUint32(a, o, !0), i;
2944
+ }
2945
+ let c = G.get(e);
2946
+ if (!c) return o;
2947
+ if (c.type === "dev_null" || c.type === "dev_zero") {
2948
+ let e = 0;
2949
+ for (let n = 0; n < r; n++) e += s.getUint32(t + n * 8 + 4, !0);
2950
+ return s.setUint32(a, e, !0), i;
2951
+ }
2952
+ if (c.type === "dev_tty") {
2953
+ let e = 0;
2919
2954
  for (let i = 0; i < r; i++) {
2920
- let r = s.getUint32(t + i * 8, !0), o = s.getUint32(t + i * 8 + 4, !0);
2921
- o > 0 && P(e, n.decode(new Uint8Array(C.buffer, r, o))), a += o;
2955
+ let r = s.getUint32(t + i * 8, !0), a = s.getUint32(t + i * 8 + 4, !0);
2956
+ a > 0 && R(1, n.decode(new Uint8Array(T.buffer, r, a))), e += a;
2922
2957
  }
2923
- return s.setUint32(o, a, !0), i;
2958
+ return s.setUint32(a, e, !0), i;
2924
2959
  }
2925
- let c = U.get(e);
2926
- if (!c || c.type !== "file") return a;
2960
+ if (c.type !== "file") return o;
2927
2961
  let l = 0;
2928
2962
  for (let e = 0; e < r; e++) {
2929
2963
  let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0);
2930
2964
  if (r > 0) {
2931
- let e = new Uint8Array(C.buffer, n, r), t = c.append ? c.bytes.length : c.pos, i = t + r;
2965
+ let e = new Uint8Array(T.buffer, n, r), t = c.append ? c.bytes.length : c.pos, i = t + r;
2932
2966
  if (i > c.bytes.length) {
2933
2967
  let e = new Uint8Array(i);
2934
2968
  e.set(c.bytes), c.bytes = e;
@@ -2936,202 +2970,277 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
2936
2970
  c.bytes.set(e, t), c.pos = t + r, c.dirty = !0, l += r;
2937
2971
  }
2938
2972
  }
2939
- return s.setUint32(o, l, !0), i;
2973
+ return s.setUint32(a, l, !0), i;
2940
2974
  },
2941
2975
  fd_read: (e, t, n, r) => {
2942
- if (!C) return a;
2943
- let o = new DataView(C.buffer);
2944
- if (e === 0) {
2945
- if (N && T) {
2946
- if ((typeof w?.exports?.asyncify_get_state == "function" ? w.exports.asyncify_get_state() : 0) === 2) {
2947
- w.exports.asyncify_stop_rewind();
2976
+ if (!T) return o;
2977
+ let s = new DataView(T.buffer), c = G.get(e), l = !!(c && c.type === "dev_tty");
2978
+ if (e === 0 || I && e === 2 || l) {
2979
+ (l || e === 2) && L();
2980
+ let o = !!((K.get(e) || 0) & w);
2981
+ if (D) {
2982
+ if ((typeof E?.exports?.asyncify_get_state == "function" ? E.exports.asyncify_get_state() : 0) === 2) {
2983
+ E.exports.asyncify_stop_rewind();
2948
2984
  let e = 0;
2949
- for (let r = 0; r < n && I.length > 0; r++) {
2950
- let n = o.getUint32(t + r * 8, !0), i = o.getUint32(t + r * 8 + 4, !0), a = Math.min(i, I.length), s = I.splice(0, a);
2951
- new Uint8Array(C.buffer).set(s, n), e += a;
2985
+ for (let r = 0; r < n && z.length > 0; r++) {
2986
+ let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = Math.min(i, z.length), o = z.splice(0, a);
2987
+ new Uint8Array(T.buffer).set(o, n), e += a;
2952
2988
  }
2953
- return o.setUint32(r, e, !0), i;
2989
+ return s.setUint32(r, e, !0), i;
2954
2990
  }
2955
- if (I.length > 0) {
2991
+ if (z.length > 0) {
2956
2992
  let e = 0;
2957
- for (let r = 0; r < n && I.length > 0; r++) {
2958
- let n = o.getUint32(t + r * 8, !0), i = o.getUint32(t + r * 8 + 4, !0), a = Math.min(i, I.length), s = I.splice(0, a);
2959
- new Uint8Array(C.buffer).set(s, n), e += a;
2993
+ for (let r = 0; r < n && z.length > 0; r++) {
2994
+ let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = Math.min(i, z.length), o = z.splice(0, a);
2995
+ new Uint8Array(T.buffer).set(o, n), e += a;
2960
2996
  }
2961
- return o.setUint32(r, e, !0), i;
2997
+ return s.setUint32(r, e, !0), i;
2998
+ }
2999
+ return o ? (s.setUint32(r, 0, !0), a) : (E.exports.asyncify_start_unwind(O), k = new Promise((e) => {
3000
+ A = e;
3001
+ }), s.setUint32(r, 0, !0), i);
3002
+ }
3003
+ if (z.length > 0) {
3004
+ let e = 0;
3005
+ for (let r = 0; r < n && z.length > 0; r++) {
3006
+ let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = Math.min(i, z.length), o = z.splice(0, a);
3007
+ new Uint8Array(T.buffer).set(o, n), e += a;
2962
3008
  }
2963
- return w.exports.asyncify_start_unwind(E), D = new Promise((e) => {
2964
- O = e;
2965
- }), o.setUint32(r, 0, !0), i;
3009
+ return s.setUint32(r, e, !0), i;
3010
+ }
3011
+ let c = 0;
3012
+ for (let e = 0; e < n && H < V.length; e++) {
3013
+ let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0), i = Math.min(r, V.length - H);
3014
+ new Uint8Array(T.buffer).set(V.slice(H, H + i), n), H += i, c += i;
3015
+ }
3016
+ return c === 0 && o && H >= V.length ? (s.setUint32(r, 0, !0), a) : (s.setUint32(r, c, !0), i);
3017
+ }
3018
+ if (!c) return o;
3019
+ if (c.type === "dev_null") return s.setUint32(r, 0, !0), i;
3020
+ if (c.type === "dev_zero") {
3021
+ let e = 0;
3022
+ for (let r = 0; r < n; r++) {
3023
+ let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0);
3024
+ new Uint8Array(T.buffer, n, i).fill(0), e += i;
2966
3025
  }
3026
+ return s.setUint32(r, e, !0), i;
3027
+ }
3028
+ if (c.type === "dev_urandom") {
2967
3029
  let e = 0;
2968
- for (let r = 0; r < n && ee < R.length; r++) {
2969
- let n = o.getUint32(t + r * 8, !0), i = o.getUint32(t + r * 8 + 4, !0), a = Math.min(i, R.length - ee);
2970
- new Uint8Array(C.buffer).set(R.slice(ee, ee + a), n), ee += a, e += a;
3030
+ for (let r = 0; r < n; r++) {
3031
+ let n = s.getUint32(t + r * 8, !0), i = s.getUint32(t + r * 8 + 4, !0), a = new Uint8Array(T.buffer, n, i);
3032
+ if (typeof crypto < "u" && crypto.getRandomValues) crypto.getRandomValues(a);
3033
+ else for (let e = 0; e < i; e++) a[e] = Math.floor(Math.random() * 256);
3034
+ e += i;
2971
3035
  }
2972
- return o.setUint32(r, e, !0), i;
3036
+ return s.setUint32(r, e, !0), i;
2973
3037
  }
2974
- let s = U.get(e);
2975
- if (!s || s.type !== "file") return a;
2976
- let c = 0;
2977
- for (let e = 0; e < n && s.pos < s.bytes.length; e++) {
2978
- let n = o.getUint32(t + e * 8, !0), r = o.getUint32(t + e * 8 + 4, !0), i = Math.min(r, s.bytes.length - s.pos);
2979
- new Uint8Array(C.buffer).set(s.bytes.subarray(s.pos, s.pos + i), n), s.pos += i, c += i;
3038
+ if (c.type !== "file") return o;
3039
+ let u = 0;
3040
+ for (let e = 0; e < n && c.pos < c.bytes.length; e++) {
3041
+ let n = s.getUint32(t + e * 8, !0), r = s.getUint32(t + e * 8 + 4, !0), i = Math.min(r, c.bytes.length - c.pos);
3042
+ new Uint8Array(T.buffer).set(c.bytes.subarray(c.pos, c.pos + i), n), c.pos += i, u += i;
2980
3043
  }
2981
- return o.setUint32(r, c, !0), i;
3044
+ return s.setUint32(r, u, !0), i;
2982
3045
  },
2983
- fd_seek: (e, t, n, r, o) => {
2984
- if (!C) return a;
2985
- if (e <= 2) return d;
2986
- let c = U.get(e);
2987
- if (!c || c.type !== "file") return a;
2988
- let l, u, f;
2989
- typeof t == "bigint" ? (l = Number(t), u = n, f = r) : (l = t, u = r, f = o);
2990
- let p = c.pos;
3046
+ fd_seek: (e, t, n, r, a) => {
3047
+ if (!T) return o;
3048
+ if (e <= 2) return f;
3049
+ let s = G.get(e);
3050
+ if (!s) return o;
3051
+ if (s.type === "dev_tty" || s.type === "dev_null" || s.type === "dev_zero" || s.type === "dev_urandom") return f;
3052
+ if (s.type !== "file") return o;
3053
+ let l, u, d;
3054
+ typeof t == "bigint" ? (l = Number(t), u = n, d = r) : (l = t, u = r, d = a);
3055
+ let p = s.pos;
2991
3056
  if (u === 0) p = l;
2992
- else if (u === 1) p = c.pos + l;
2993
- else if (u === 2) p = c.bytes.length + l;
2994
- else return s;
2995
- return p < 0 ? s : (c.pos = p, f && new DataView(C.buffer).setBigUint64(f, BigInt(c.pos), !0), i);
3057
+ else if (u === 1) p = s.pos + l;
3058
+ else if (u === 2) p = s.bytes.length + l;
3059
+ else return c;
3060
+ return p < 0 ? c : (s.pos = p, d && new DataView(T.buffer).setBigUint64(d, BigInt(s.pos), !0), i);
2996
3061
  },
2997
3062
  fd_tell: (e, t) => {
2998
- if (!C) return a;
2999
- let n = U.get(e);
3000
- return !n || n.type !== "file" ? a : (new DataView(C.buffer).setBigUint64(t, BigInt(n.pos), !0), i);
3063
+ if (!T) return o;
3064
+ let n = G.get(e);
3065
+ return !n || n.type !== "file" ? o : (new DataView(T.buffer).setBigUint64(t, BigInt(n.pos), !0), i);
3001
3066
  },
3002
3067
  fd_close: (e) => {
3003
3068
  if (e <= 2) return i;
3004
- let t = U.get(e);
3005
- return t ? (ne(t), U.delete(e), i) : a;
3069
+ let t = G.get(e);
3070
+ return t ? (t.type === "file" && Y(t), G.delete(e), K.delete(e), i) : o;
3006
3071
  },
3007
3072
  fd_sync: (e) => {
3008
- let t = U.get(e);
3009
- return t && ne(t), i;
3073
+ let t = G.get(e);
3074
+ return t && Y(t), i;
3010
3075
  },
3011
3076
  fd_datasync: (e) => {
3012
- let t = U.get(e);
3013
- return t && ne(t), i;
3077
+ let t = G.get(e);
3078
+ return t && Y(t), i;
3014
3079
  },
3015
3080
  fd_prestat_get: (e, t) => {
3016
- if (!C) return a;
3017
- let n = U.get(e);
3018
- if (!n || n.type !== "preopen") return a;
3019
- let r = new DataView(C.buffer), o = b.encode(n.guestName);
3020
- return r.setUint8(t, 0), r.setUint32(t + 4, o.length, !0), i;
3081
+ if (!T) return o;
3082
+ let n = G.get(e);
3083
+ if (!n || n.type !== "preopen") return o;
3084
+ let r = new DataView(T.buffer), a = b.encode(n.guestName);
3085
+ return r.setUint8(t, 0), r.setUint32(t + 4, a.length, !0), i;
3021
3086
  },
3022
3087
  fd_prestat_dir_name: (e, t, n) => {
3023
- if (!C) return a;
3024
- let r = U.get(e);
3025
- if (!r || r.type !== "preopen") return a;
3026
- let o = b.encode(r.guestName);
3027
- return new Uint8Array(C.buffer, t, Math.min(n, o.length)).set(o.subarray(0, n)), i;
3088
+ if (!T) return o;
3089
+ let r = G.get(e);
3090
+ if (!r || r.type !== "preopen") return o;
3091
+ let a = b.encode(r.guestName);
3092
+ return new Uint8Array(T.buffer, t, Math.min(n, a.length)).set(a.subarray(0, n)), i;
3028
3093
  },
3029
3094
  fd_fdstat_get: (e, t) => {
3030
- if (!C) return a;
3031
- let n = new DataView(C.buffer), r = f;
3032
- if (e <= 2) r = p;
3095
+ if (!T) return o;
3096
+ let n = new DataView(T.buffer), r = p;
3097
+ if (e <= 2) r = m;
3033
3098
  else {
3034
- let t = U.get(e);
3035
- if (!t) return a;
3036
- r = t.type === "preopen" || t.type === "dir" ? m : h;
3099
+ let t = G.get(e);
3100
+ if (!t) return o;
3101
+ r = t.type === "dev_null" || t.type === "dev_zero" || t.type === "dev_urandom" || t.type === "dev_tty" ? m : t.type === "preopen" || t.type === "dir" ? h : g;
3037
3102
  }
3038
3103
  for (let e = 0; e < 24; e++) n.setUint8(t + e, 0);
3039
- return n.setUint8(t, r), n.setBigUint64(t + 8, 18446744073709551615n, !0), n.setBigUint64(t + 16, 18446744073709551615n, !0), i;
3104
+ n.setUint8(t, r);
3105
+ let a = K.get(e) || (G.get(e)?.append ? C : 0);
3106
+ return n.setUint16(t + 2, a, !0), n.setBigUint64(t + 8, 18446744073709551615n, !0), n.setBigUint64(t + 16, 18446744073709551615n, !0), i;
3107
+ },
3108
+ fd_fdstat_set_flags: (e, t) => {
3109
+ if (!T || e > 2 && !G.has(e)) return o;
3110
+ K.set(e, t);
3111
+ let n = G.get(e);
3112
+ return n && (n.append = !!(t & C)), (e === 0 || e === 2 || n && n.type === "dev_tty") && t & w && L(), i;
3040
3113
  },
3041
- fd_fdstat_set_flags: () => i,
3042
3114
  fd_filestat_get: (e, t) => {
3043
- if (!C) return a;
3044
- let n = new DataView(C.buffer);
3115
+ if (!T) return o;
3116
+ let n = new DataView(T.buffer);
3045
3117
  for (let e = 0; e < 64; e++) n.setUint8(t + e, 0);
3046
- if (e <= 2) return n.setUint8(t + 16, p), i;
3047
- let r = U.get(e);
3048
- if (!r) return a;
3049
- let o = r.type === "preopen" || r.type === "dir";
3050
- return n.setUint8(t + 16, o ? m : h), n.setBigUint64(t + 24, 1n, !0), n.setBigUint64(t + 32, BigInt(r.bytes ? r.bytes.length : 0), !0), i;
3118
+ if (e <= 2) return n.setUint8(t + 16, m), i;
3119
+ let r = G.get(e);
3120
+ if (!r) return o;
3121
+ if (r.type === "dev_null" || r.type === "dev_zero" || r.type === "dev_urandom" || r.type === "dev_tty") return n.setUint8(t + 16, m), n.setBigUint64(t + 24, 1n, !0), i;
3122
+ let a = r.type === "preopen" || r.type === "dir";
3123
+ return n.setUint8(t + 16, a ? h : g), n.setBigUint64(t + 24, 1n, !0), n.setBigUint64(t + 32, BigInt(r.bytes ? r.bytes.length : 0), !0), i;
3051
3124
  },
3052
- path_open: (e, t, r, s, d, f, p, m, h) => {
3053
- if (!C || !z) return a;
3054
- let y = W(e, n.decode(new Uint8Array(C.buffer, r, s)));
3055
- if (!y) return a;
3056
- let w = z.stat(y), T = w !== null;
3057
- if (d & v && d & g && T) return o;
3058
- if (d & _) {
3059
- if (!T) return l;
3060
- if (!w.isDirectory) return u;
3061
- let e = H++;
3062
- return U.set(e, {
3063
- type: "dir",
3125
+ path_open: (e, t, r, a, c, f, p, m, h) => {
3126
+ if (!T || !U) return o;
3127
+ let g = J(e, n.decode(new Uint8Array(T.buffer, r, a)));
3128
+ if (!g) return o;
3129
+ let y = g.replace(/\/+/g, "/").replace(/\/$/, "") || "/";
3130
+ if (y === "/dev/null") {
3131
+ let e = ne++;
3132
+ return G.set(e, {
3133
+ type: "dev_null",
3134
+ path: "/dev/null"
3135
+ }), new DataView(T.buffer).setUint32(h, e, !0), i;
3136
+ }
3137
+ if (y === "/dev/zero") {
3138
+ let e = ne++;
3139
+ return G.set(e, {
3140
+ type: "dev_zero",
3141
+ path: "/dev/zero"
3142
+ }), new DataView(T.buffer).setUint32(h, e, !0), i;
3143
+ }
3144
+ if (y === "/dev/urandom" || y === "/dev/random") {
3145
+ let e = ne++;
3146
+ return G.set(e, {
3147
+ type: "dev_urandom",
3064
3148
  path: y
3065
- }), new DataView(C.buffer).setUint32(h, e, !0), i;
3149
+ }), new DataView(T.buffer).setUint32(h, e, !0), i;
3150
+ }
3151
+ if (y === "/dev/tty") {
3152
+ L();
3153
+ let e = ne++;
3154
+ return G.set(e, {
3155
+ type: "dev_tty",
3156
+ path: "/dev/tty"
3157
+ }), new DataView(T.buffer).setUint32(h, e, !0), i;
3066
3158
  }
3067
- if (T && w.isDirectory) return c;
3068
- if (!T && !(d & g)) return l;
3069
- let E = new Uint8Array(), D = !1;
3070
- if (T && !(d & x)) {
3071
- let e = z.getFileByPath(y);
3072
- e != null && (E = typeof e == "string" ? b.encode(e) : new Uint8Array(this._contentToBytes(e)));
3073
- } else D = !0;
3074
- let O = H++;
3075
- return U.set(O, {
3159
+ let w = U.stat(g), E = w !== null;
3160
+ if (c & x && c & _ && E) return s;
3161
+ if (c & v) {
3162
+ if (!E) return u;
3163
+ if (!w.isDirectory) return d;
3164
+ let e = ne++;
3165
+ return G.set(e, {
3166
+ type: "dir",
3167
+ path: g
3168
+ }), new DataView(T.buffer).setUint32(h, e, !0), i;
3169
+ }
3170
+ if (E && w.isDirectory) return l;
3171
+ if (!E && !(c & _)) return u;
3172
+ let D = new Uint8Array(), O = !1;
3173
+ if (E && !(c & S)) {
3174
+ let e = U.getFileByPath(g);
3175
+ e != null && (D = typeof e == "string" ? b.encode(e) : new Uint8Array(this._contentToBytes(e)));
3176
+ } else O = !0;
3177
+ let k = ne++;
3178
+ return G.set(k, {
3076
3179
  type: "file",
3077
- path: y,
3078
- bytes: E,
3079
- pos: m & S ? E.length : 0,
3080
- append: !!(m & S),
3081
- dirty: D
3082
- }), new DataView(C.buffer).setUint32(h, O, !0), i;
3180
+ path: g,
3181
+ bytes: D,
3182
+ pos: m & C ? D.length : 0,
3183
+ append: !!(m & C),
3184
+ dirty: O
3185
+ }), new DataView(T.buffer).setUint32(h, k, !0), i;
3083
3186
  },
3084
- path_filestat_get: (e, t, r, o, s) => {
3085
- if (!C || !z) return a;
3086
- let c = W(e, n.decode(new Uint8Array(C.buffer, r, o)));
3087
- if (!c) return a;
3088
- let u = z.stat(c);
3089
- if (!u) return l;
3090
- let d = new DataView(C.buffer);
3091
- for (let e = 0; e < 64; e++) d.setUint8(s + e, 0);
3092
- return d.setUint8(s + 16, u.isDirectory ? m : h), d.setBigUint64(s + 24, 1n, !0), d.setBigUint64(s + 32, BigInt(z.getSize(c) || 0), !0), i;
3187
+ path_filestat_get: (e, t, r, a, s) => {
3188
+ if (!T || !U) return o;
3189
+ let c = J(e, n.decode(new Uint8Array(T.buffer, r, a)));
3190
+ if (!c) return o;
3191
+ let l = c.replace(/\/+/g, "/").replace(/\/$/, "") || "/";
3192
+ if (l === "/dev/null" || l === "/dev/zero" || l === "/dev/urandom" || l === "/dev/random" || l === "/dev/tty") {
3193
+ let e = new DataView(T.buffer);
3194
+ for (let t = 0; t < 64; t++) e.setUint8(s + t, 0);
3195
+ return e.setUint8(s + 16, m), e.setBigUint64(s + 24, 1n, !0), i;
3196
+ }
3197
+ let d = U.stat(c);
3198
+ if (!d) return u;
3199
+ let f = new DataView(T.buffer);
3200
+ for (let e = 0; e < 64; e++) f.setUint8(s + e, 0);
3201
+ return f.setUint8(s + 16, d.isDirectory ? h : g), f.setBigUint64(s + 24, 1n, !0), f.setBigUint64(s + 32, BigInt(U.getSize(c) || 0), !0), i;
3093
3202
  },
3094
3203
  path_create_directory: (e, t, r) => {
3095
- if (!C || !z) return a;
3096
- let o = W(e, n.decode(new Uint8Array(C.buffer, t, r)));
3097
- if (!o) return a;
3204
+ if (!T || !U) return o;
3205
+ let a = J(e, n.decode(new Uint8Array(T.buffer, t, r)));
3206
+ if (!a) return o;
3098
3207
  try {
3099
- return z.setFileByPath(o, {}, !0), i;
3208
+ return U.setFileByPath(a, {}, !0), i;
3100
3209
  } catch {
3101
- return s;
3210
+ return c;
3102
3211
  }
3103
3212
  },
3104
3213
  path_unlink_file: (e, t, r) => {
3105
- if (!C || !z) return a;
3106
- let o = W(e, n.decode(new Uint8Array(C.buffer, t, r)));
3107
- if (!o || !z.exists(o)) return l;
3214
+ if (!T || !U) return o;
3215
+ let a = J(e, n.decode(new Uint8Array(T.buffer, t, r)));
3216
+ if (!a || !U.exists(a)) return u;
3108
3217
  try {
3109
- return z.deleteFileByPath(o), i;
3218
+ return U.deleteFileByPath(a), i;
3110
3219
  } catch {
3111
- return s;
3220
+ return c;
3112
3221
  }
3113
3222
  },
3114
3223
  path_remove_directory: (e, t, r) => {
3115
- if (!C || !z) return a;
3116
- let o = W(e, n.decode(new Uint8Array(C.buffer, t, r)));
3117
- if (!o || !z.exists(o)) return l;
3224
+ if (!T || !U) return o;
3225
+ let a = J(e, n.decode(new Uint8Array(T.buffer, t, r)));
3226
+ if (!a || !U.exists(a)) return u;
3118
3227
  try {
3119
- return z.deleteFileByPath(o), i;
3228
+ return U.deleteFileByPath(a), i;
3120
3229
  } catch {
3121
- return s;
3230
+ return c;
3122
3231
  }
3123
3232
  },
3124
- path_rename: (e, t, r, o, c, u) => {
3125
- if (!C || !z) return a;
3126
- let d = n.decode(new Uint8Array(C.buffer, t, r)), f = n.decode(new Uint8Array(C.buffer, c, u)), p = W(e, d), m = W(o, f);
3127
- if (!p || !m) return a;
3128
- if (!z.exists(p)) return l;
3129
- for (let e of U.values()) e.path === p && (ne(e), e.path = m);
3233
+ path_rename: (e, t, r, a, s, l) => {
3234
+ if (!T || !U) return o;
3235
+ let d = n.decode(new Uint8Array(T.buffer, t, r)), f = n.decode(new Uint8Array(T.buffer, s, l)), p = J(e, d), m = J(a, f);
3236
+ if (!p || !m) return o;
3237
+ if (!U.exists(p)) return u;
3238
+ for (let e of G.values()) e.path === p && (Y(e), e.path = m);
3130
3239
  try {
3131
- let e = z.getFileByPath(p);
3132
- return z.setFileByPath(m, e, !0), z.deleteFileByPath(p), i;
3240
+ let e = U.getFileByPath(p);
3241
+ return U.setFileByPath(m, e, !0), U.deleteFileByPath(p), i;
3133
3242
  } catch {
3134
- return s;
3243
+ return c;
3135
3244
  }
3136
3245
  },
3137
3246
  proc_exit: (e) => {
@@ -3141,88 +3250,156 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3141
3250
  };
3142
3251
  },
3143
3252
  args_sizes_get: (e, t) => {
3144
- if (!C) return s;
3145
- let n = [this.script, ...this.arguments || []], r = new DataView(C.buffer);
3253
+ if (!T) return c;
3254
+ let n = [this.script, ...this.arguments || []], r = new DataView(T.buffer);
3146
3255
  return r.setUint32(e, n.length, !0), r.setUint32(t, n.reduce((e, t) => e + b.encode(t).length + 1, 0), !0), i;
3147
3256
  },
3148
3257
  args_get: (e, t) => {
3149
- if (!C) return s;
3150
- let n = [this.script, ...this.arguments || []], r = new DataView(C.buffer), a = t;
3258
+ if (!T) return c;
3259
+ let n = [this.script, ...this.arguments || []], r = new DataView(T.buffer), a = t;
3151
3260
  for (let t = 0; t < n.length; t++) {
3152
3261
  r.setUint32(e + t * 4, a, !0);
3153
3262
  let i = b.encode(n[t] + "\0");
3154
- new Uint8Array(C.buffer).set(i, a), a += i.length;
3263
+ new Uint8Array(T.buffer).set(i, a), a += i.length;
3155
3264
  }
3156
3265
  return i;
3157
3266
  },
3158
3267
  environ_sizes_get: (e, t) => {
3159
- if (!C) return s;
3160
- let n = new DataView(C.buffer);
3161
- n.setUint32(e, G.length, !0);
3162
- let r = G.reduce((e, t) => e + b.encode(t).length + 1, 0);
3268
+ if (!T) return c;
3269
+ let n = new DataView(T.buffer);
3270
+ n.setUint32(e, X.length, !0);
3271
+ let r = X.reduce((e, t) => e + b.encode(t).length + 1, 0);
3163
3272
  return n.setUint32(t, r, !0), i;
3164
3273
  },
3165
3274
  environ_get: (e, t) => {
3166
- if (!C) return s;
3167
- let n = new DataView(C.buffer), r = t;
3168
- for (let t = 0; t < G.length; t++) {
3275
+ if (!T) return c;
3276
+ let n = new DataView(T.buffer), r = t;
3277
+ for (let t = 0; t < X.length; t++) {
3169
3278
  n.setUint32(e + t * 4, r, !0);
3170
- let i = b.encode(G[t] + "\0");
3171
- new Uint8Array(C.buffer).set(i, r), r += i.length;
3279
+ let i = b.encode(X[t] + "\0");
3280
+ new Uint8Array(T.buffer).set(i, r), r += i.length;
3172
3281
  }
3173
3282
  return i;
3174
3283
  },
3175
3284
  clock_time_get: (e, t, n) => {
3176
- if (C) {
3285
+ if (T) {
3177
3286
  let e = BigInt(Date.now()) * 1000000n;
3178
- new DataView(C.buffer).setBigUint64(n, e, !0);
3287
+ new DataView(T.buffer).setBigUint64(n, e, !0);
3179
3288
  }
3180
3289
  return i;
3181
3290
  },
3182
3291
  random_get: (e, t) => {
3183
- if (C) {
3184
- let n = new Uint8Array(C.buffer, e, t);
3292
+ if (T) {
3293
+ let n = new Uint8Array(T.buffer, e, t);
3185
3294
  for (let e = 0; e < t; e++) n[e] = Math.random() * 256 | 0;
3186
3295
  }
3187
3296
  return i;
3297
+ },
3298
+ clock_nanosleep: (e, t, n, r, a) => {
3299
+ if (!T) return o;
3300
+ let s = new DataView(T.buffer).getBigUint64(n, !0), c = 0;
3301
+ if (t & 1) {
3302
+ let e = BigInt(Date.now()) * 1000000n;
3303
+ c = s > e ? Number((s - e) / 1000000n) : 0;
3304
+ } else c = Number(s / 1000000n);
3305
+ return D && c > 0 ? (typeof E?.exports?.asyncify_get_state == "function" ? E.exports.asyncify_get_state() : 0) === 2 ? (E.exports.asyncify_stop_rewind(), i) : (E.exports.asyncify_start_unwind(O), k = new Promise((e) => setTimeout(e, Math.max(1, c))), i) : i;
3306
+ },
3307
+ poll_oneoff: (e, t, n, r) => {
3308
+ if (!T) return o;
3309
+ let a = new DataView(T.buffer);
3310
+ if (D) {
3311
+ if ((typeof E?.exports?.asyncify_get_state == "function" ? E.exports.asyncify_get_state() : 0) === 2) {
3312
+ E.exports.asyncify_stop_rewind();
3313
+ let o = 0;
3314
+ for (let r = 0; r < n; r++) {
3315
+ let n = e + r * 48, s = a.getBigUint64(n, !0), c = a.getUint8(n + 8), l = t + o * 32;
3316
+ a.setBigUint64(l, s, !0), a.setUint16(l + 8, i, !0), a.setUint8(l + 10, c);
3317
+ for (let e = 11; e < 32; e++) a.setUint8(l + e, 0);
3318
+ c === 1 && a.setBigUint64(l + 16, BigInt(z.length), !0), o++;
3319
+ }
3320
+ return a.setUint32(r, o, !0), i;
3321
+ }
3322
+ let o = 0, s = Infinity;
3323
+ for (let t = 0; t < n; t++) {
3324
+ let n = e + t * 48, r = a.getUint8(n + 8);
3325
+ if (r === 0) {
3326
+ let e = a.getBigUint64(n + 24, !0), t = a.getUint16(n + 40, !0), r = 0;
3327
+ if (t & 1) {
3328
+ let t = BigInt(Date.now()) * 1000000n;
3329
+ r = e > t ? Number((e - t) / 1000000n) : 0;
3330
+ } else r = Number(e / 1000000n);
3331
+ r < s && (s = r);
3332
+ } else if (r === 1) {
3333
+ let e = a.getUint32(n + 16, !0), t = G.get(e), r = !!(t && t.type === "dev_tty");
3334
+ (e === 0 || e === 2 || r) && L(), (e === 0 || I && e === 2 || r) && z.length > 0 && o++;
3335
+ } else r === 2 && o++;
3336
+ }
3337
+ if (o > 0 || s === 0) {
3338
+ let o = 0;
3339
+ for (let r = 0; r < n; r++) {
3340
+ let n = e + r * 48, c = a.getBigUint64(n, !0), l = a.getUint8(n + 8), u = !1;
3341
+ if (l === 0 && s === 0) u = !0;
3342
+ else if (l === 1) {
3343
+ let e = a.getUint32(n + 16, !0), t = G.get(e), r = !!(t && t.type === "dev_tty");
3344
+ (e === 0 || I && e === 2 || r) && z.length > 0 && (u = !0);
3345
+ } else l === 2 && (u = !0);
3346
+ if (u) {
3347
+ let e = t + o * 32;
3348
+ a.setBigUint64(e, c, !0), a.setUint16(e + 8, i, !0), a.setUint8(e + 10, l);
3349
+ for (let t = 11; t < 32; t++) a.setUint8(e + t, 0);
3350
+ l === 1 && a.setBigUint64(e + 16, BigInt(z.length), !0), o++;
3351
+ }
3352
+ }
3353
+ return a.setUint32(r, o, !0), i;
3354
+ }
3355
+ return E.exports.asyncify_start_unwind(O), k = new Promise((e) => {
3356
+ let t = null;
3357
+ A = () => {
3358
+ t && clearTimeout(t), A = null, e();
3359
+ }, s !== Infinity && (t = setTimeout(() => {
3360
+ A = null, e();
3361
+ }, Math.max(1, s)));
3362
+ }), a.setUint32(r, 0, !0), i;
3363
+ }
3364
+ return a.setUint32(r, 0, !0), i;
3188
3365
  }
3189
3366
  }, { get(e, t) {
3190
3367
  return t in e ? e[t] : () => 0;
3191
- } }), ie = (e) => {
3192
- if (!C || !e) return "";
3368
+ } }), ae = (e) => {
3369
+ if (!T || !e) return "";
3193
3370
  try {
3194
- let t = new DataView(C.buffer).getUint32(e - 4, !0), n = new Uint16Array(C.buffer, e, t >>> 1);
3371
+ let t = new DataView(T.buffer).getUint32(e - 4, !0), n = new Uint16Array(T.buffer, e, t >>> 1);
3195
3372
  return String.fromCharCode(...n);
3196
3373
  } catch {
3197
3374
  return "";
3198
3375
  }
3199
- }, q = {
3200
- wasi_snapshot_preview1: K,
3201
- wasi_unstable: K,
3376
+ }, oe = {
3377
+ wasi_snapshot_preview1: ie,
3378
+ wasi_unstable: ie,
3202
3379
  env: new Proxy({
3203
3380
  print: (e, t) => {
3204
- C && P(1, n.decode(new Uint8Array(C.buffer, e, t)));
3381
+ T && R(1, n.decode(new Uint8Array(T.buffer, e, t)));
3205
3382
  },
3206
3383
  eprint: (e, t) => {
3207
- C && P(2, n.decode(new Uint8Array(C.buffer, e, t)));
3384
+ T && R(2, n.decode(new Uint8Array(T.buffer, e, t)));
3208
3385
  },
3209
3386
  log: (e) => {
3210
- P(1, ie(e) + "\n");
3387
+ R(1, ae(e) + "\n");
3211
3388
  },
3212
3389
  logi: (e) => {
3213
- P(1, String(e) + "\n");
3390
+ R(1, String(e) + "\n");
3214
3391
  },
3215
3392
  logf: (e) => {
3216
- P(1, String(e) + "\n");
3393
+ R(1, String(e) + "\n");
3217
3394
  },
3218
3395
  trace: (e, t, ...n) => {
3219
3396
  let r = t > 0 ? " " + n.slice(0, t).join(", ") : "";
3220
- P(1, `trace: ${ie(e)}${r}\n`);
3397
+ R(1, `trace: ${ae(e)}${r}\n`);
3221
3398
  },
3222
3399
  seed: () => Date.now() * Math.random(),
3223
3400
  abort: (e, t, n, r) => {
3224
- let i = ie(e), a = ie(t);
3225
- throw (i || a) && P(2, `abort: ${i || "aborted"} at ${a || this.script}:${n || 0}:${r || 0}\n`), this.exitCode = 134, {
3401
+ let i = ae(e), a = ae(t);
3402
+ throw (i || a) && R(2, `abort: ${i || "aborted"} at ${a || this.script}:${n || 0}:${r || 0}\n`), this.exitCode = 134, {
3226
3403
  _wasmExit: !0,
3227
3404
  code: 134
3228
3405
  };
@@ -3238,66 +3415,64 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3238
3415
  initial: 1,
3239
3416
  maximum: 256
3240
3417
  });
3241
- C = t, q[e.module] || (q[e.module] = {}), q[e.module][e.name] = t;
3418
+ T = t, oe[e.module] || (oe[e.module] = {}), oe[e.module][e.name] = t;
3242
3419
  }
3243
- if (w = await WebAssembly.instantiate(t, q), w.exports.memory && (C = w.exports.memory), T = !!(w.exports.asyncify_start_unwind && w.exports.asyncify_stop_unwind), T && C) {
3420
+ if (E = await WebAssembly.instantiate(t, oe), E.exports.memory && (T = E.exports.memory), D = !!(E.exports.asyncify_start_unwind && E.exports.asyncify_stop_unwind), D && T) {
3244
3421
  try {
3245
- E = C.grow(1) * 65536;
3422
+ O = T.grow(1) * 65536;
3246
3423
  } catch {
3247
- E = 16;
3424
+ O = 16;
3248
3425
  }
3249
- let e = E + 8, t = E + 65536 - 8;
3250
- new Int32Array(C.buffer, E, 2).set([e, t]);
3426
+ let e = O + 8, t = O + 65536 - 8;
3427
+ new Int32Array(T.buffer, O, 2).set([e, t]);
3251
3428
  }
3252
- if (N) {
3253
- this._enterAltScreen();
3429
+ typeof E.exports.set_terminal_size == "function" && L(), I && this._enterAltScreen();
3430
+ let n = this.stdout && this.stdout.columns || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, r = this.stdout && this.stdout.rows || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24;
3431
+ if (typeof E.exports.set_terminal_size == "function") try {
3432
+ E.exports.set_terminal_size(n, r);
3433
+ } catch {}
3434
+ N = () => {
3254
3435
  let e = this.stdout && this.stdout.columns || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("COLUMNS"), 10) || 80, t = this.stdout && this.stdout.rows || this.context && typeof this.context.getVar == "function" && parseInt(this.context.getVar("LINES"), 10) || 24;
3255
- if (typeof w.exports.set_terminal_size == "function") try {
3256
- w.exports.set_terminal_size(e, t);
3436
+ if (typeof E?.exports?.set_terminal_size == "function") try {
3437
+ E.exports.set_terminal_size(e, t);
3257
3438
  } catch {}
3258
- j = () => {
3259
- let e = this.stdout && this.stdout.columns || 80, t = this.stdout && this.stdout.rows || 24;
3260
- if (typeof w?.exports?.set_terminal_size == "function") try {
3261
- w.exports.set_terminal_size(e, t);
3262
- } catch {}
3263
- }, this.stdout && typeof this.stdout.on == "function" && this.stdout.on("resize", j), this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("resize", j);
3264
- }
3265
- let n = w.exports._start || w.exports.__wasi_command || w.exports.main || w.exports.run;
3266
- if (n) try {
3267
- let e = n();
3268
- for (e && typeof e.then == "function" && (e = await e); T && typeof w.exports.asyncify_get_state == "function" && w.exports.asyncify_get_state() === 1;) w.exports.asyncify_stop_unwind(), D &&= (await D, null), w.exports.asyncify_start_rewind(E), e = n(), e && typeof e.then == "function" && (e = await e);
3439
+ }, this.stdout && typeof this.stdout.on == "function" && this.stdout.on("resize", N), this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("resize", N);
3440
+ let i = E.exports._start || E.exports.__wasi_command || E.exports.main || E.exports.run;
3441
+ if (i) try {
3442
+ let e = i();
3443
+ for (e && typeof e.then == "function" && (e = await e); D && typeof E.exports.asyncify_get_state == "function" && E.exports.asyncify_get_state() === 1;) E.exports.asyncify_stop_unwind(), k &&= (await k, null), E.exports.asyncify_start_rewind(O), e = i(), e && typeof e.then == "function" && (e = await e);
3269
3444
  } catch (e) {
3270
3445
  (!e || !e._wasmExit) && (this.stdErr = `${this.script}: runtime error: ${e?.message || String(e)}`, this.exitCode = 1);
3271
3446
  }
3272
3447
  else {
3273
- let e = Object.entries(w.exports).filter(([, e]) => typeof e == "function").map(([e]) => e), t = e.length > 0 ? ` (module is a library exporting: ${e.join(", ")})` : "";
3448
+ let e = Object.entries(E.exports).filter(([, e]) => typeof e == "function").map(([e]) => e), t = e.length > 0 ? ` (module is a library exporting: ${e.join(", ")})` : "";
3274
3449
  this.stdErr = `${this.script}: no CLI entry point found (expected _start, main, or run)${t}`, this.exitCode = 1;
3275
3450
  }
3276
3451
  } catch (e) {
3277
3452
  (!e || !e._wasmExit) && (this.stdErr = `${this.script}: ${e?.message || String(e)}`, this.exitCode = 1);
3278
3453
  } finally {
3279
- N && this._exitAltScreen(), N && M && (this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", M), this.stdin && typeof this.stdin.off == "function" && this.stdin.off("data", M)), j && (this.stdout && typeof this.stdout.off == "function" && this.stdout.off("resize", j), this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("resize", j)), this._externalKeyHandler = null;
3280
- for (let e of U.values()) ne(e);
3454
+ I && this._exitAltScreen(), P && (this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("data", P), this.stdin && typeof this.stdin.off == "function" && this.stdin.off("data", P)), this._onStdinStreamData && this.stdinStream && typeof this.stdinStream.on == "function" && this.stdinStream.on("data", this._onStdinStreamData), N && (this.stdout && typeof this.stdout.off == "function" && this.stdout.off("resize", N), this.stdinStream && typeof this.stdinStream.off == "function" && this.stdinStream.off("resize", N)), this._externalKeyHandler = null;
3455
+ for (let e of G.values()) Y(e);
3281
3456
  }
3282
- F();
3283
- let J = this.arguments || [];
3457
+ ee();
3458
+ let se = this.arguments || [];
3284
3459
  if (!(this.result && this.result.getStdOutput && this.result.getStdOutput().length > 0) && (this.exitCode === 0 || this.exitCode === void 0)) {
3285
3460
  let t = (this.script || "wasm").split("/").pop(), n = Object.assign({
3286
3461
  name: t,
3287
3462
  version: "wasi",
3288
3463
  description: `WebAssembly WASI binary (${this.script})`
3289
3464
  }, this._pkgMeta || {});
3290
- if (J.includes("--help") || J.includes("-h")) {
3291
- let r = k(e);
3292
- for (let e of A(t, n, r)) this.stdOut = e;
3293
- } else (J.includes("--version") || J.includes("-V") || J.includes("-v")) && (this.stdOut = `${t} (${n.name} ${n.version} wasm)`);
3465
+ if (se.includes("--help") || se.includes("-h")) {
3466
+ let r = j(e);
3467
+ for (let e of M(t, n, r)) this.stdOut = e;
3468
+ } else (se.includes("--version") || se.includes("-V") || se.includes("-v")) && (this.stdOut = `${t} (${n.name} ${n.version} wasm)`);
3294
3469
  }
3295
3470
  }
3296
- }, w = /* @__PURE__ */ new Map();
3297
- function T(e, t) {
3471
+ }, E = /* @__PURE__ */ new Map();
3472
+ function D(e, t) {
3298
3473
  if (!e || !e.exists(t)) return null;
3299
3474
  if (e.isRealFilesystem) try {
3300
- let n = K();
3475
+ let n = q();
3301
3476
  return new Uint8Array(n.readFileSync(e.absolutePath(t)));
3302
3477
  } catch {}
3303
3478
  let n = e.getFileByPath(t);
@@ -3321,12 +3496,12 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3321
3496
  }
3322
3497
  return null;
3323
3498
  }
3324
- function E(e, t, n, i = "application/octet-stream") {
3499
+ function O(e, t, n, i = "application/octet-stream") {
3325
3500
  let a = n instanceof Uint8Array ? n : new Uint8Array(n), o = new Uint8Array(a.byteLength);
3326
3501
  o.set(a);
3327
3502
  let s = new r(o.buffer, i);
3328
3503
  if (e.isRealFilesystem) try {
3329
- let n = K(), r = ie(), i = e.absolutePath(t);
3504
+ let n = q(), r = J(), i = e.absolutePath(t);
3330
3505
  n.mkdirSync(r.dirname(i), { recursive: !0 }), n.writeFileSync(i, y.from(a.buffer, a.byteOffset, a.byteLength));
3331
3506
  return;
3332
3507
  } catch {
@@ -3341,7 +3516,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3341
3516
  }
3342
3517
  e.setFileByPath(t, s, !0);
3343
3518
  }
3344
- async function D(e, t, n = null) {
3519
+ async function k(e, t, n = null) {
3345
3520
  if (typeof n == "function") {
3346
3521
  let r = await n(e, t);
3347
3522
  if (r) return r;
@@ -3369,7 +3544,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3369
3544
  }
3370
3545
  throw Error(`Package '${e}' could not be loaded`);
3371
3546
  }
3372
- function O(e, t = !1) {
3547
+ function A(e, t = !1) {
3373
3548
  let n = {
3374
3549
  usage: null,
3375
3550
  options: []
@@ -3386,7 +3561,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3386
3561
  }
3387
3562
  return n;
3388
3563
  }
3389
- function k(e) {
3564
+ function j(e) {
3390
3565
  let t = {
3391
3566
  usage: null,
3392
3567
  options: [],
@@ -3407,12 +3582,12 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3407
3582
  i >= 32 && i <= 126 || i === 9 || i === 10 ? r += String.fromCharCode(i) : (r.length >= 4 && n.push(r), r = "");
3408
3583
  }
3409
3584
  r.length >= 4 && n.push(r);
3410
- let i = O(n.join("\n"), !0);
3585
+ let i = A(n.join("\n"), !0);
3411
3586
  t.usage = i.usage, t.options = i.options;
3412
3587
  } catch {}
3413
3588
  return t;
3414
3589
  }
3415
- function A(e, t = {}, n = null) {
3590
+ function M(e, t = {}, n = null) {
3416
3591
  let r = t.name || e, i = t.version || "wasm", a = t.description || "WebAssembly binary", o = t && typeof t.repl == "object" ? t.repl : t.repl ? {} : null, s = n && n.usage || t.usage, c = s ? s.replace(/%s/g, e) : null, l = o ? `${e} [options] ${o.evalFlag ? `[${o.evalFlag} <code>] ` : ""}[file] [args...]` : `${e} [options] [args...]`, u = [`${e} (${r} ${i} wasm) — ${a}`, `Usage: ${c || l}`];
3417
3592
  t.details && u.push("", t.details), u.push("", "Options:");
3418
3593
  let d = n && n.options && n.options.length > 0 ? n.options : Array.isArray(t.options) ? t.options : [];
@@ -3420,8 +3595,8 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3420
3595
  else o && (o.evalFlag && u.push(` ${o.evalFlag.padEnd(20)}Evaluate inline code and print result`), u.push(` (no arguments) Start interactive ${e} REPL shell`));
3421
3596
  return u.push(" -h, --help Show this help message and exit"), u.push(" -V, --version Show WebAssembly binary version and exit"), n && n.exports && n.exports.length > 0 && u.push("", `WASM Exports: ${n.exports.join(", ")}`), Array.isArray(t.aliases) && t.aliases.length > 0 && u.push("", `Aliases: ${t.aliases.join(", ")}`), (t.homepage || t.cdnUrl || t.wasmUrl) && u.push(`Source: ${t.homepage || t.cdnUrl || t.wasmUrl}`), u;
3422
3597
  }
3423
- function j(e, t = {}, n = null) {
3424
- let r = Y(), i = (n || e.bin || e.name).toLowerCase();
3598
+ function N(e, t = {}, n = null) {
3599
+ let r = X(), i = (n || e.bin || e.name).toLowerCase();
3425
3600
  class a extends r {
3426
3601
  static get name() {
3427
3602
  return i;
@@ -3434,7 +3609,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3434
3609
  }
3435
3610
  async run() {
3436
3611
  let n = [...this.arguments || []], r = n.includes("--help") || n.includes("-h"), a = !r && (n.includes("--version") || n.includes("-V") || n.includes("-v"));
3437
- this._inspectedWasm = null, this._persistedWasmBytes = e.wasmPath ? T(this.context && this.context.fs || this.fs, e.wasmPath) : null, r && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && (this._inspectedWasm = k(this._persistedWasmBytes));
3612
+ this._inspectedWasm = null, this._persistedWasmBytes = e.wasmPath ? D(this.context && this.context.fs || this.fs, e.wasmPath) : null, r && this._persistedWasmBytes && this._persistedWasmBytes.byteLength > 0 && (this._inspectedWasm = j(this._persistedWasmBytes));
3438
3613
  try {
3439
3614
  if ((e.type === "wasm" || e.type === "custom-wasm") && (this._persistedWasmBytes || e.wasmUrl)) {
3440
3615
  let i = this._persistedWasmBytes;
@@ -3443,7 +3618,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3443
3618
  n instanceof Uint8Array || n instanceof ArrayBuffer ? i = n instanceof Uint8Array ? n : new Uint8Array(n) : n && (n.wasmBytes || n.wasm || n.wasmBinary) && (i = n.wasmBytes || n.wasm || n.wasmBinary);
3444
3619
  } catch {}
3445
3620
  if (!i && e.wasmUrl && (i = await this._fetchWasmBytes(e.wasmUrl)), i) {
3446
- r && (this._inspectedWasm = k(i)), await this._runRawWasmBytes(i, n);
3621
+ r && (this._inspectedWasm = j(i)), await this._runRawWasmBytes(i, n);
3447
3622
  return;
3448
3623
  }
3449
3624
  } else {
@@ -3460,19 +3635,19 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3460
3635
  }
3461
3636
  let c, l;
3462
3637
  try {
3463
- c = await D(e.name, o, t.moduleLoader), l = c && c.default !== void 0 ? c.default : c, l && typeof l.then == "function" && (l = await l);
3638
+ c = await k(e.name, o, t.moduleLoader), l = c && c.default !== void 0 ? c.default : c, l && typeof l.then == "function" && (l = await l);
3464
3639
  } finally {
3465
3640
  s && (globalThis.fetch = s);
3466
3641
  }
3467
3642
  if (l instanceof Uint8Array || l instanceof ArrayBuffer) {
3468
3643
  let e = l instanceof Uint8Array ? l : new Uint8Array(l);
3469
- r && (this._inspectedWasm = k(e)), await this._runRawWasmBytes(e, n);
3644
+ r && (this._inspectedWasm = j(e)), await this._runRawWasmBytes(e, n);
3470
3645
  } else if (l && (l.wasmBytes instanceof Uint8Array || l.wasm instanceof Uint8Array)) {
3471
3646
  let e = l.wasmBytes || l.wasm;
3472
- r && (this._inspectedWasm = k(e)), await this._runRawWasmBytes(e, n);
3647
+ r && (this._inspectedWasm = j(e)), await this._runRawWasmBytes(e, n);
3473
3648
  } else if (typeof l == "function") await this._runFunctionOrEmscripten(l, n, r);
3474
3649
  else if (l && typeof l == "object") {
3475
- l.ready && await l.ready, r && (l.HEAPU8 instanceof Uint8Array || l.wasmBinary instanceof Uint8Array) && (this._inspectedWasm = k(l.wasmBinary || l.HEAPU8));
3650
+ l.ready && await l.ready, r && (l.HEAPU8 instanceof Uint8Array || l.wasmBinary instanceof Uint8Array) && (this._inspectedWasm = j(l.wasmBinary || l.HEAPU8));
3476
3651
  let t = l.main || l.run || l.callMain || l.exec;
3477
3652
  if (typeof t == "function") await this._invokeCliFunction(t.bind(l), n);
3478
3653
  else if (l.promised || typeof l.raw == "function" || typeof l.json == "function") {
@@ -3500,29 +3675,29 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3500
3675
  }
3501
3676
  }
3502
3677
  if (r || a) {
3503
- let t = this.result && this.result.getStdOutput ? this.result.getStdOutput() : [], n = t.map((e) => e.string).join("\n"), o = r ? O(n) : null, s = r && !!(o && (o.usage || o.options.length > 0) || t.some((e) => /\b(usage|options):/i.test(e.string))), c = t.filter((e) => e.type === "out").map((e) => e.string), l = a && c.length > 0 && (this.exitCode === 0 || this.exitCode === void 0);
3678
+ let t = this.result && this.result.getStdOutput ? this.result.getStdOutput() : [], n = t.map((e) => e.string).join("\n"), o = r ? A(n) : null, s = r && !!(o && (o.usage || o.options.length > 0) || t.some((e) => /\b(usage|options):/i.test(e.string))), c = t.filter((e) => e.type === "out").map((e) => e.string), l = a && c.length > 0 && (this.exitCode === 0 || this.exitCode === void 0);
3504
3679
  if (r) if (s) {
3505
3680
  let e = t.map((e) => e.string);
3506
3681
  this.result && Array.isArray(this.result.std) && (this.result.std.length = 0), this.exitCode = 0;
3507
3682
  for (let t of e) this.stdOut = t;
3508
3683
  } else {
3509
3684
  this.result && Array.isArray(this.result.std) && (this.result.std.length = 0), this.exitCode = 0;
3510
- for (let t of A(i, e, this._inspectedWasm)) this.stdOut = t;
3685
+ for (let t of M(i, e, this._inspectedWasm)) this.stdOut = t;
3511
3686
  }
3512
3687
  else a && !l ? (this.result && Array.isArray(this.result.std) && (this.result.std.length = 0), this.exitCode = 0, this.stdOut = `${i} (${e.name} ${e.version || "wasm"} wasm)`) : this.exitCode = 0;
3513
3688
  }
3514
3689
  }
3515
3690
  async _fetchWasmBytes(e) {
3516
- if (w.has(e)) return w.get(e);
3691
+ if (E.has(e)) return E.get(e);
3517
3692
  let n = t.fetch || (typeof fetch == "function" ? fetch : null);
3518
3693
  if (!n) throw Error("fetch is not available in this environment");
3519
3694
  let r = await n(e);
3520
3695
  if (!r || !r.ok) throw Error(`HTTP ${r ? r.status : "error"} fetching ${e}`);
3521
3696
  let i = new Uint8Array(await r.arrayBuffer());
3522
- return w.set(e, i), i;
3697
+ return E.set(e, i), i;
3523
3698
  }
3524
3699
  async _runRawWasmBytes(t, n) {
3525
- let r = new C(i, n, this.context);
3700
+ let r = new T(i, n, this.context);
3526
3701
  r.script = i, r.arguments = n, r.context = this.context, r.fs = this.fs, r._pkgMeta = e, this.stdin !== void 0 && (r.stdin = this.stdin), await r._runWasm(t);
3527
3702
  for (let e of r.result.getStdOutput()) e.type === "out" ? this.stdOut = e.string : e.type === "err" && (this.stdErr = e.string);
3528
3703
  this.exitCode = r.result.getExitCode();
@@ -3546,13 +3721,13 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3546
3721
  let n = t && t !== "." && !e.startsWith("/") ? `${t.replace(/\/+$/, "")}/${e}` : e, r = this.fs.getFileByPath(n) ?? this.fs.getFileByPath(e);
3547
3722
  return r == null ? null : typeof r == "string" ? r : new TextDecoder().decode(r);
3548
3723
  },
3549
- readBytes: (e) => T(this.fs, e),
3724
+ readBytes: (e) => D(this.fs, e),
3550
3725
  writeFile: (e, t, n) => {
3551
3726
  if (!this.fs) return;
3552
3727
  let r = n && n !== "." && !e.startsWith("/") ? `${n.replace(/\/+$/, "")}/${e}` : e;
3553
3728
  if (t instanceof Uint8Array || ArrayBuffer.isView(t)) {
3554
3729
  let e = r.endsWith(".wasm") ? "application/wasm" : "application/octet-stream";
3555
- E(this.fs, r, t, e);
3730
+ O(this.fs, r, t, e);
3556
3731
  } else this.fs.setFileByPath(r, String(t), !0);
3557
3732
  if (r.endsWith(".wasm") || r.endsWith(".wat")) try {
3558
3733
  this.context && this.context.fs ? this.context.fs.setMode(r, 493) : this.fs.setMode(r, 493);
@@ -3588,7 +3763,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3588
3763
  if (e && typeof e.status == "number") this.exitCode = e.status;
3589
3764
  else throw e;
3590
3765
  }
3591
- if (d && typeof d == "object") if (r && (d.wasmBinary instanceof Uint8Array || d.HEAPU8 instanceof Uint8Array) && (this._inspectedWasm = k(d.wasmBinary || d.HEAPU8)), typeof d.callMain == "function") {
3766
+ if (d && typeof d == "object") if (r && (d.wasmBinary instanceof Uint8Array || d.HEAPU8 instanceof Uint8Array) && (this._inspectedWasm = j(d.wasmBinary || d.HEAPU8)), typeof d.callMain == "function") {
3592
3767
  d.FS && c.size === 0 && (c = this._syncBrshToEmscriptenFs(d.FS, n));
3593
3768
  try {
3594
3769
  let e = await d.callMain(n);
@@ -3651,14 +3826,14 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3651
3826
  }), !t.loaded && typeof t.load == "function" && await t.load(e.coreUrl ? { coreURL: e.coreUrl } : void 0);
3652
3827
  let a = /* @__PURE__ */ new Set(), o = [];
3653
3828
  for (let e of n) if (!e.startsWith("-") && (o.push(e), this.fs.exists(e))) {
3654
- let n = T(this.fs, e);
3829
+ let n = D(this.fs, e);
3655
3830
  n && (await t.writeFile(e, n), a.add(e));
3656
3831
  }
3657
3832
  let s = await t.exec(n);
3658
3833
  for (let e of o) if (!a.has(e)) try {
3659
3834
  if (typeof t.readFile == "function") {
3660
3835
  let n = await t.readFile(e);
3661
- n && E(this.fs, e, n);
3836
+ n && O(this.fs, e, n);
3662
3837
  }
3663
3838
  } catch {}
3664
3839
  typeof s == "number" && s !== 0 && (this.exitCode = s, i.length === 0 && r.length > 0 && i.push(...r.splice(0, r.length)));
@@ -3675,7 +3850,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3675
3850
  let n = /* @__PURE__ */ new Set();
3676
3851
  if (!this.fs || !e || typeof e.writeFile != "function") return n;
3677
3852
  for (let r of t) if (!r.startsWith("-") && this.fs.exists(r)) {
3678
- let t = T(this.fs, r);
3853
+ let t = D(this.fs, r);
3679
3854
  if (t) try {
3680
3855
  e.writeFile(r, t), n.add(r);
3681
3856
  } catch {}
@@ -3688,7 +3863,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3688
3863
  let t = e.readFile(r);
3689
3864
  if (t) {
3690
3865
  let e = r.endsWith(".wasm") ? "application/wasm" : "application/octet-stream";
3691
- if (E(this.fs, r, t, e), r.endsWith(".wasm") || r.endsWith(".wat")) try {
3866
+ if (O(this.fs, r, t, e), r.endsWith(".wasm") || r.endsWith(".wat")) try {
3692
3867
  this.context && this.context.fs ? this.context.fs.setMode(r, 493) : this.fs.setMode(r, 493);
3693
3868
  } catch {}
3694
3869
  }
@@ -3698,8 +3873,8 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3698
3873
  }
3699
3874
  return a;
3700
3875
  }
3701
- C.readBytesFromFs = T, C.writeBytesToFs = E, C.loadModule = D, C.extractHelpFromText = O, C.inspectWasmBytes = k, C.formatWasmHelp = A, C.createGenericWasmCommand = j, C.createCommand = j, t.exports = C;
3702
- })), se = /* @__PURE__ */ t(((e, t) => {
3876
+ T.readBytesFromFs = D, T.writeBytesToFs = O, T.loadModule = k, T.extractHelpFromText = A, T.inspectWasmBytes = j, T.formatWasmHelp = M, T.createGenericWasmCommand = N, T.createCommand = N, t.exports = T;
3877
+ })), oe = /* @__PURE__ */ t(((e, t) => {
3703
3878
  var n = W(), r = class extends n {
3704
3879
  static get name() {
3705
3880
  return "test";
@@ -3784,7 +3959,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3784
3959
  }
3785
3960
  }
3786
3961
  };
3787
- })), ce = /* @__PURE__ */ t(((e, t) => {
3962
+ })), se = /* @__PURE__ */ t(((e, t) => {
3788
3963
  var n = W();
3789
3964
  t.exports = class extends n {
3790
3965
  static get name() {
@@ -3825,7 +4000,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3825
4000
  return o.forEach((e) => this.stdOut = e), Promise.resolve();
3826
4001
  }
3827
4002
  };
3828
- })), le = /* @__PURE__ */ t(((e, t) => {
4003
+ })), ce = /* @__PURE__ */ t(((e, t) => {
3829
4004
  function n(e) {
3830
4005
  return typeof e == "object" && !!e;
3831
4006
  }
@@ -3836,7 +4011,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3836
4011
  return Array.isArray(e) ? e : e === void 0 ? [] : r(e) || e instanceof Set ? Array.from(e) : [e];
3837
4012
  }
3838
4013
  t.exports = i;
3839
- })), ue = /* @__PURE__ */ t(((e, t) => {
4014
+ })), le = /* @__PURE__ */ t(((e, t) => {
3840
4015
  function n(e, t, ...n) {
3841
4016
  let r = [];
3842
4017
  if (!Array.isArray(e)) throw Error("Input must be an array");
@@ -3856,7 +4031,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3856
4031
  return e;
3857
4032
  }
3858
4033
  t.exports = n;
3859
- })), de = /* @__PURE__ */ t(((e) => {
4034
+ })), ue = /* @__PURE__ */ t(((e) => {
3860
4035
  Object.defineProperty(e, "__esModule", { value: !0 });
3861
4036
  function t(e) {
3862
4037
  return !isNaN(parseFloat(e));
@@ -3935,10 +4110,10 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3935
4110
  isFunction: h,
3936
4111
  isAsyncFunction: g
3937
4112
  }, e.isArrayLike = i, e.isAsyncFunction = g, e.isClass = u, e.isDefined = o, e.isDefinedValue = l, e.isFiniteNumber = n, e.isFunction = h, e.isIterable = p, e.isNull = c, e.isNumber = t, e.isObject = a, e.isPlainObject = r, e.isPrimitive = d, e.isPromise = f, e.isString = m, e.isUndefined = s;
3938
- })), fe, X = e((() => {
3939
- fe = globalThis || self;
4113
+ })), de, fe = e((() => {
4114
+ de = globalThis || self;
3940
4115
  })), pe = /* @__PURE__ */ t(((e, t) => {
3941
- X();
4116
+ fe();
3942
4117
  var n = Infinity, r = "[object Symbol]", i = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, a = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, o = "\\ud800-\\udfff", s = "\\u0300-\\u036f\\ufe20-\\ufe23", c = "\\u20d0-\\u20f0", l = "\\u2700-\\u27bf", u = "a-z\\xdf-\\xf6\\xf8-\\xff", d = "\\xac\\xb1\\xd7\\xf7", f = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", p = "\\u2000-\\u206f", m = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", h = "A-Z\\xc0-\\xd6\\xd8-\\xde", g = "\\ufe0e\\ufe0f", _ = d + f + p + m, v = "['’]", y = "[" + o + "]", b = "[" + _ + "]", x = "[" + s + c + "]", S = "\\d+", C = "[" + l + "]", w = "[" + u + "]", T = "[^" + o + _ + S + l + u + h + "]", E = "\\ud83c[\\udffb-\\udfff]", D = "(?:" + x + "|" + E + ")", O = "[^" + o + "]", k = "(?:\\ud83c[\\udde6-\\uddff]){2}", A = "[\\ud800-\\udbff][\\udc00-\\udfff]", j = "[" + h + "]", M = "\\u200d", N = "(?:" + w + "|" + T + ")", P = "(?:" + j + "|" + T + ")", F = "(?:" + v + "(?:d|ll|m|re|s|t|ve))?", I = "(?:" + v + "(?:D|LL|M|RE|S|T|VE))?", L = D + "?", R = "[" + g + "]?", ee = "(?:" + M + "(?:" + [
3943
4118
  O,
3944
4119
  k,
@@ -3968,7 +4143,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
3968
4143
  j + "+" + I,
3969
4144
  S,
3970
4145
  B
3971
- ].join("|"), "g"), ne = RegExp("[" + M + o + s + c + g + "]"), re = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/, G = {
4146
+ ].join("|"), "g"), ne = RegExp("[" + M + o + s + c + g + "]"), G = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/, K = {
3972
4147
  À: "A",
3973
4148
  Á: "A",
3974
4149
  Â: "A",
@@ -4159,40 +4334,40 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
4159
4334
  œ: "oe",
4160
4335
  ʼn: "'n",
4161
4336
  ſ: "ss"
4162
- }, K = typeof fe == "object" && fe && fe.Object === Object && fe, ie = typeof self == "object" && self && self.Object === Object && self, q = K || ie || Function("return this")();
4163
- function J(e, t, n, r) {
4337
+ }, q = typeof de == "object" && de && de.Object === Object && de, J = typeof self == "object" && self && self.Object === Object && self, Y = q || J || Function("return this")();
4338
+ function re(e, t, n, r) {
4164
4339
  var i = -1, a = e ? e.length : 0;
4165
4340
  for (r && a && (n = e[++i]); ++i < a;) n = t(n, e[i], i, e);
4166
4341
  return n;
4167
4342
  }
4168
- function Y(e) {
4343
+ function X(e) {
4169
4344
  return e.split("");
4170
4345
  }
4171
- function ae(e) {
4346
+ function ie(e) {
4172
4347
  return e.match(i) || [];
4173
4348
  }
4174
- function oe(e) {
4349
+ function ae(e) {
4175
4350
  return function(t) {
4176
4351
  return e?.[t];
4177
4352
  };
4178
4353
  }
4179
- var se = oe(G);
4180
- function ce(e) {
4354
+ var oe = ae(K);
4355
+ function se(e) {
4181
4356
  return ne.test(e);
4182
4357
  }
4358
+ function ce(e) {
4359
+ return G.test(e);
4360
+ }
4183
4361
  function le(e) {
4184
- return re.test(e);
4362
+ return se(e) ? ue(e) : X(e);
4185
4363
  }
4186
4364
  function ue(e) {
4187
- return ce(e) ? de(e) : Y(e);
4188
- }
4189
- function de(e) {
4190
4365
  return e.match(te) || [];
4191
4366
  }
4192
4367
  function pe(e) {
4193
4368
  return e.match(W) || [];
4194
4369
  }
4195
- var me = Object.prototype.toString, Z = q.Symbol, he = Z ? Z.prototype : void 0, ge = he ? he.toString : void 0;
4370
+ var me = Object.prototype.toString, Z = Y.Symbol, he = Z ? Z.prototype : void 0, ge = he ? he.toString : void 0;
4196
4371
  function _e(e, t, n) {
4197
4372
  var r = -1, i = e.length;
4198
4373
  t < 0 && (t = -t > i ? 0 : i + t), n = n > i ? i : n, n < 0 && (n += i), i = t > n ? 0 : n - t >>> 0, t >>>= 0;
@@ -4212,13 +4387,13 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
4212
4387
  function be(e) {
4213
4388
  return function(t) {
4214
4389
  t = we(t);
4215
- var n = ce(t) ? ue(t) : void 0, r = n ? n[0] : t.charAt(0), i = n ? ye(n, 1).join("") : t.slice(1);
4390
+ var n = se(t) ? le(t) : void 0, r = n ? n[0] : t.charAt(0), i = n ? ye(n, 1).join("") : t.slice(1);
4216
4391
  return r[e]() + i;
4217
4392
  };
4218
4393
  }
4219
4394
  function xe(e) {
4220
4395
  return function(t) {
4221
- return J(ke(De(t).replace(H, "")), e, "");
4396
+ return re(ke(De(t).replace(H, "")), e, "");
4222
4397
  };
4223
4398
  }
4224
4399
  function Se(e) {
@@ -4237,16 +4412,16 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
4237
4412
  return Oe(we(e).toLowerCase());
4238
4413
  }
4239
4414
  function De(e) {
4240
- return e = we(e), e && e.replace(a, se).replace(U, "");
4415
+ return e = we(e), e && e.replace(a, oe).replace(U, "");
4241
4416
  }
4242
4417
  var Oe = be("toUpperCase");
4243
4418
  function ke(e, t, n) {
4244
- return e = we(e), t = n ? void 0 : t, t === void 0 ? le(e) ? pe(e) : ae(e) : e.match(t) || [];
4419
+ return e = we(e), t = n ? void 0 : t, t === void 0 ? ce(e) ? pe(e) : ie(e) : e.match(t) || [];
4245
4420
  }
4246
4421
  t.exports = Te;
4247
4422
  })), me = /* @__PURE__ */ t(((e, t) => {
4248
4423
  B();
4249
- var n = le(), r = ue(), i = de(), a = pe(), o = {
4424
+ var n = ce(), r = le(), i = ue(), a = pe(), o = {
4250
4425
  short: /^-([^\d-])$/,
4251
4426
  long: /^--(\S+)/,
4252
4427
  combinedShort: /^-[^\d-]{2,}$/,
@@ -4866,9 +5041,9 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
4866
5041
  }
4867
5042
  };
4868
5043
  })), be = /* @__PURE__ */ t(((e, t) => {
4869
- var { Test: n, TestBracket: r } = se();
5044
+ var { Test: n, TestBracket: r } = oe();
4870
5045
  t.exports = [
4871
- ce(),
5046
+ se(),
4872
5047
  Z(),
4873
5048
  he(),
4874
5049
  ge(),
@@ -4879,7 +5054,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
4879
5054
  r
4880
5055
  ];
4881
5056
  })), xe = /* @__PURE__ */ t(((e, t) => {
4882
- var n = Y();
5057
+ var n = X();
4883
5058
  t.exports = class extends n {
4884
5059
  static get name() {
4885
5060
  return "alias";
@@ -4891,7 +5066,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
4891
5066
  }
4892
5067
  };
4893
5068
  })), Se = /* @__PURE__ */ t(((e, t) => {
4894
- var n = Y();
5069
+ var n = X();
4895
5070
  t.exports = class extends n {
4896
5071
  static get name() {
4897
5072
  return "export";
@@ -4903,7 +5078,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
4903
5078
  }
4904
5079
  };
4905
5080
  })), Ce = /* @__PURE__ */ t(((e, t) => {
4906
- var n = Y();
5081
+ var n = X();
4907
5082
  t.exports = class extends n {
4908
5083
  static get name() {
4909
5084
  return "cd";
@@ -4915,7 +5090,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
4915
5090
  }
4916
5091
  };
4917
5092
  })), we = /* @__PURE__ */ t(((e, t) => {
4918
- var n = Y();
5093
+ var n = X();
4919
5094
  t.exports = class extends n {
4920
5095
  static get name() {
4921
5096
  return "chmod";
@@ -4971,7 +5146,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
4971
5146
  }
4972
5147
  };
4973
5148
  })), Te = /* @__PURE__ */ t(((e, t) => {
4974
- var n = Y(), r = K();
5149
+ var n = X(), r = q();
4975
5150
  t.exports = class extends n {
4976
5151
  static get name() {
4977
5152
  return "cp";
@@ -5067,9 +5242,9 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5067
5242
  }
5068
5243
  };
5069
5244
  })), Ee = /* @__PURE__ */ t(((e, t) => {
5070
- var n = Y(), r = (() => {
5245
+ var n = X(), r = (() => {
5071
5246
  try {
5072
- return K();
5247
+ return q();
5073
5248
  } catch {
5074
5249
  return null;
5075
5250
  }
@@ -5140,7 +5315,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5140
5315
  }
5141
5316
  };
5142
5317
  })), De = /* @__PURE__ */ t(((e, t) => {
5143
- var n = Y();
5318
+ var n = X();
5144
5319
  t.exports = class extends n {
5145
5320
  static get name() {
5146
5321
  return "mkdir";
@@ -5167,7 +5342,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5167
5342
  }
5168
5343
  };
5169
5344
  })), Oe = /* @__PURE__ */ t(((e, t) => {
5170
- var n = Y(), r = K();
5345
+ var n = X(), r = q();
5171
5346
  t.exports = class extends n {
5172
5347
  static get name() {
5173
5348
  return "mv";
@@ -5211,7 +5386,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5211
5386
  continue;
5212
5387
  }
5213
5388
  try {
5214
- let e = ie();
5389
+ let e = J();
5215
5390
  r.mkdirSync(e.dirname(i), { recursive: !0 }), r.renameSync(n, i);
5216
5391
  } catch (n) {
5217
5392
  this.stdErr = `mv: cannot move '${e}' to '${t}': ${n.message}`, this.exitCode = 1;
@@ -5240,7 +5415,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5240
5415
  }
5241
5416
  };
5242
5417
  })), ke = /* @__PURE__ */ t(((e, t) => {
5243
- var n = Y();
5418
+ var n = X();
5244
5419
  t.exports = class extends n {
5245
5420
  static get name() {
5246
5421
  return "pwd";
@@ -5251,7 +5426,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5251
5426
  }
5252
5427
  };
5253
5428
  })), Ae = /* @__PURE__ */ t(((e, t) => {
5254
- var n = Y(), r = K();
5429
+ var n = X(), r = q();
5255
5430
  t.exports = class extends n {
5256
5431
  static get name() {
5257
5432
  return "rm";
@@ -5296,9 +5471,9 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5296
5471
  }
5297
5472
  };
5298
5473
  })), je = /* @__PURE__ */ t(((e, t) => {
5299
- var n = Y(), r = (() => {
5474
+ var n = X(), r = (() => {
5300
5475
  try {
5301
- return K();
5476
+ return q();
5302
5477
  } catch {
5303
5478
  return null;
5304
5479
  }
@@ -5365,9 +5540,9 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5365
5540
  }
5366
5541
  };
5367
5542
  })), Me = /* @__PURE__ */ t(((e, t) => {
5368
- var n = Y(), r = (() => {
5543
+ var n = X(), r = (() => {
5369
5544
  try {
5370
- return K();
5545
+ return q();
5371
5546
  } catch {
5372
5547
  return null;
5373
5548
  }
@@ -5406,7 +5581,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5406
5581
  }
5407
5582
  };
5408
5583
  })), Ne = /* @__PURE__ */ t(((e, t) => {
5409
- var n = Y();
5584
+ var n = X();
5410
5585
  t.exports = class extends n {
5411
5586
  static get name() {
5412
5587
  return "which";
@@ -5418,7 +5593,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5418
5593
  }
5419
5594
  };
5420
5595
  })), Pe = /* @__PURE__ */ t(((e, t) => {
5421
- var n = ae(), r = Y();
5596
+ var n = ie(), r = X();
5422
5597
  t.exports = class extends r {
5423
5598
  static get name() {
5424
5599
  return "source";
@@ -5447,7 +5622,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5447
5622
  }
5448
5623
  };
5449
5624
  })), Fe = /* @__PURE__ */ t(((e, t) => {
5450
- var n = Y();
5625
+ var n = X();
5451
5626
  t.exports = class extends n {
5452
5627
  static get name() {
5453
5628
  return "clear";
@@ -5457,7 +5632,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5457
5632
  }
5458
5633
  };
5459
5634
  })), Ie = /* @__PURE__ */ t(((e, t) => {
5460
- var n = Y();
5635
+ var n = X();
5461
5636
  t.exports = class extends n {
5462
5637
  static get name() {
5463
5638
  return "exit";
@@ -5468,7 +5643,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5468
5643
  }
5469
5644
  };
5470
5645
  })), Le = /* @__PURE__ */ t(((e, t) => {
5471
- var n = Y(), r = me();
5646
+ var n = X(), r = me();
5472
5647
  t.exports = class extends n {
5473
5648
  static get name() {
5474
5649
  return "read";
@@ -5542,7 +5717,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5542
5717
  }
5543
5718
  };
5544
5719
  })), Re = /* @__PURE__ */ t(((e, t) => {
5545
- var n = Y(), r = W();
5720
+ var n = X(), r = W();
5546
5721
  t.exports = class extends n {
5547
5722
  static get name() {
5548
5723
  return "jsfunction";
@@ -5578,7 +5753,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5578
5753
  }
5579
5754
  };
5580
5755
  })), ze = /* @__PURE__ */ t(((e, t) => {
5581
- var n = Y();
5756
+ var n = X();
5582
5757
  function r(e) {
5583
5758
  return e >= 1048576 ? (e / 1048576).toFixed(1) + " MB" : e >= 1024 ? (e / 1024).toFixed(1) + " KB" : e + " B";
5584
5759
  }
@@ -5676,7 +5851,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5676
5851
  let e = new TextDecoder().decode(t);
5677
5852
  this.fs.setFileByPath(s, e, !0);
5678
5853
  } else {
5679
- let { BinaryFile: e } = G(), r = e ? new e(t.buffer, n || "application/octet-stream") : t;
5854
+ let { BinaryFile: e } = K(), r = e ? new e(t.buffer, n || "application/octet-stream") : t;
5680
5855
  this.fs.setFileByPath(s, r, !0);
5681
5856
  }
5682
5857
  } catch (e) {
@@ -5699,7 +5874,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
5699
5874
  }
5700
5875
  };
5701
5876
  })), Be = /* @__PURE__ */ t(((e, t) => {
5702
- var n = Y(), r = {
5877
+ var n = X(), r = {
5703
5878
  errexit: "e",
5704
5879
  xtrace: "x",
5705
5880
  nounset: "u",
@@ -6370,7 +6545,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6370
6545
  })), Pt = /* @__PURE__ */ t(((e, t) => {
6371
6546
  t.exports = {};
6372
6547
  })), Ft = /* @__PURE__ */ t(((e, t) => {
6373
- X();
6548
+ fe();
6374
6549
  var n = typeof Map == "function" && Map.prototype, r = Object.getOwnPropertyDescriptor && n ? Object.getOwnPropertyDescriptor(Map.prototype, "size") : null, i = n && r && typeof r.get == "function" ? r.get : null, a = n && Map.prototype.forEach, o = typeof Set == "function" && Set.prototype, s = Object.getOwnPropertyDescriptor && o ? Object.getOwnPropertyDescriptor(Set.prototype, "size") : null, c = o && s && typeof s.get == "function" ? s.get : null, l = o && Set.prototype.forEach, u = typeof WeakMap == "function" && WeakMap.prototype ? WeakMap.prototype.has : null, d = typeof WeakSet == "function" && WeakSet.prototype ? WeakSet.prototype.has : null, f = typeof WeakRef == "function" && WeakRef.prototype ? WeakRef.prototype.deref : null, p = Boolean.prototype.valueOf, m = Object.prototype.toString, h = Function.prototype.toString, g = String.prototype.match, _ = String.prototype.slice, v = String.prototype.replace, y = String.prototype.toUpperCase, b = String.prototype.toLowerCase, x = RegExp.prototype.test, S = Array.prototype.concat, C = Array.prototype.join, w = Array.prototype.slice, T = Math.floor, E = typeof BigInt == "function" ? BigInt.prototype.valueOf : null, D = Object.getOwnPropertySymbols, O = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? Symbol.prototype.toString : null, k = typeof Symbol == "function" && typeof Symbol.iterator == "object", A = typeof Symbol == "function" && Symbol.toStringTag ? Symbol.toStringTag : null, j = Object.prototype.propertyIsEnumerable, M = (typeof Reflect == "function" ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function(e) {
6375
6550
  return e.__proto__;
6376
6551
  } : null);
@@ -6386,7 +6561,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6386
6561
  }
6387
6562
  return v.call(t, n, "$&_");
6388
6563
  }
6389
- var P = Pt(), F = P.custom, I = G(F) ? F : null, L = {
6564
+ var P = Pt(), F = P.custom, I = K(F) ? F : null, L = {
6390
6565
  __proto__: null,
6391
6566
  double: "\"",
6392
6567
  single: "'"
@@ -6397,12 +6572,12 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6397
6572
  };
6398
6573
  t.exports = function e(t, n, r, o) {
6399
6574
  var s = n || {};
6400
- if (q(s, "quoteStyle") && !q(L, s.quoteStyle)) throw TypeError("option \"quoteStyle\" must be \"single\" or \"double\"");
6401
- if (q(s, "maxStringLength") && (typeof s.maxStringLength == "number" ? s.maxStringLength < 0 && s.maxStringLength !== Infinity : s.maxStringLength !== null)) throw TypeError("option \"maxStringLength\", if provided, must be a positive integer, Infinity, or `null`");
6402
- var u = q(s, "customInspect") ? s.customInspect : !0;
6575
+ if (Y(s, "quoteStyle") && !Y(L, s.quoteStyle)) throw TypeError("option \"quoteStyle\" must be \"single\" or \"double\"");
6576
+ if (Y(s, "maxStringLength") && (typeof s.maxStringLength == "number" ? s.maxStringLength < 0 && s.maxStringLength !== Infinity : s.maxStringLength !== null)) throw TypeError("option \"maxStringLength\", if provided, must be a positive integer, Infinity, or `null`");
6577
+ var u = Y(s, "customInspect") ? s.customInspect : !0;
6403
6578
  if (typeof u != "boolean" && u !== "symbol") throw TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");
6404
- if (q(s, "indent") && s.indent !== null && s.indent !== " " && !(parseInt(s.indent, 10) === s.indent && s.indent > 0)) throw TypeError("option \"indent\" must be \"\\t\", an integer > 0, or `null`");
6405
- if (q(s, "numericSeparator") && typeof s.numericSeparator != "boolean") throw TypeError("option \"numericSeparator\", if provided, must be `true` or `false`");
6579
+ if (Y(s, "indent") && s.indent !== null && s.indent !== " " && !(parseInt(s.indent, 10) === s.indent && s.indent > 0)) throw TypeError("option \"indent\" must be \"\\t\", an integer > 0, or `null`");
6580
+ if (Y(s, "numericSeparator") && typeof s.numericSeparator != "boolean") throw TypeError("option \"numericSeparator\", if provided, must be `true` or `false`");
6406
6581
  var d = s.numericSeparator;
6407
6582
  if (t === void 0) return "undefined";
6408
6583
  if (t === null) return "null";
@@ -6421,62 +6596,62 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6421
6596
  if (r === void 0 && (r = 0), r >= h && h > 0 && typeof t == "object") return V(t) ? "[Array]" : "[Object]";
6422
6597
  var g = ve(s, r);
6423
6598
  if (o === void 0) o = [];
6424
- else if (ae(o, t) >= 0) return "[Circular]";
6599
+ else if (ie(o, t) >= 0) return "[Circular]";
6425
6600
  function y(t, n, i) {
6426
6601
  if (n && (o = w.call(o), o.push(n)), i) {
6427
6602
  var a = { depth: s.depth };
6428
- return q(s, "quoteStyle") && (a.quoteStyle = s.quoteStyle), e(t, a, r + 1, o);
6603
+ return Y(s, "quoteStyle") && (a.quoteStyle = s.quoteStyle), e(t, a, r + 1, o);
6429
6604
  }
6430
6605
  return e(t, s, r + 1, o);
6431
6606
  }
6432
6607
  if (typeof t == "function" && !U(t)) {
6433
- var x = Y(t), T = be(t, y);
6608
+ var x = X(t), T = be(t, y);
6434
6609
  return "[Function" + (x ? ": " + x : " (anonymous)") + "]" + (T.length > 0 ? " { " + C.call(T, ", ") + " }" : "");
6435
6610
  }
6436
- if (G(t)) {
6611
+ if (K(t)) {
6437
6612
  var D = k ? v.call(String(t), /^(Symbol\(.*\))_[^)]*$/, "$1") : O.call(t);
6438
6613
  return typeof t == "object" && !k ? Z(D) : D;
6439
6614
  }
6440
- if (de(t)) {
6615
+ if (ue(t)) {
6441
6616
  for (var F = "<" + b.call(String(t.nodeName)), R = t.attributes || [], B = 0; B < R.length; B++) F += " " + R[B].name + "=" + ee(z(R[B].value), "double", s);
6442
6617
  return F += ">", t.childNodes && t.childNodes.length && (F += "..."), F += "</" + b.call(String(t.nodeName)) + ">", F;
6443
6618
  }
6444
6619
  if (V(t)) {
6445
6620
  if (t.length === 0) return "[]";
6446
- var ie = be(t, y);
6447
- return g && !_e(ie) ? "[" + ye(ie, g) + "]" : "[ " + C.call(ie, ", ") + " ]";
6621
+ var J = be(t, y);
6622
+ return g && !_e(J) ? "[" + ye(J, g) + "]" : "[ " + C.call(J, ", ") + " ]";
6448
6623
  }
6449
6624
  if (te(t)) {
6450
- var X = be(t, y);
6451
- return !("cause" in Error.prototype) && "cause" in t && !j.call(t, "cause") ? "{ [" + String(t) + "] " + C.call(S.call("[cause]: " + y(t.cause), X), ", ") + " }" : X.length === 0 ? "[" + String(t) + "]" : "{ [" + String(t) + "] " + C.call(X, ", ") + " }";
6625
+ var fe = be(t, y);
6626
+ return !("cause" in Error.prototype) && "cause" in t && !j.call(t, "cause") ? "{ [" + String(t) + "] " + C.call(S.call("[cause]: " + y(t.cause), fe), ", ") + " }" : fe.length === 0 ? "[" + String(t) + "]" : "{ [" + String(t) + "] " + C.call(fe, ", ") + " }";
6452
6627
  }
6453
6628
  if (typeof t == "object" && u) {
6454
6629
  if (I && typeof t[I] == "function" && P) return P(t, { depth: h - r });
6455
6630
  if (u !== "symbol" && typeof t.inspect == "function") return t.inspect();
6456
6631
  }
6457
- if (oe(t)) {
6632
+ if (ae(t)) {
6458
6633
  var me = [];
6459
6634
  return a && a.call(t, function(e, n) {
6460
6635
  me.push(y(n, t, !0) + " => " + y(e, t));
6461
6636
  }), ge("Map", i.call(t), me, g);
6462
6637
  }
6463
- if (le(t)) {
6638
+ if (ce(t)) {
6464
6639
  var xe = [];
6465
6640
  return l && l.call(t, function(e) {
6466
6641
  xe.push(y(e, t));
6467
6642
  }), ge("Set", c.call(t), xe, g);
6468
6643
  }
6469
- if (se(t)) return he("WeakMap");
6470
- if (ue(t)) return he("WeakSet");
6471
- if (ce(t)) return he("WeakRef");
6644
+ if (oe(t)) return he("WeakMap");
6645
+ if (le(t)) return he("WeakSet");
6646
+ if (se(t)) return he("WeakRef");
6472
6647
  if (ne(t)) return Z(y(Number(t)));
6473
- if (K(t)) return Z(y(E.call(t)));
6474
- if (re(t)) return Z(p.call(t));
6648
+ if (q(t)) return Z(y(E.call(t)));
6649
+ if (G(t)) return Z(p.call(t));
6475
6650
  if (W(t)) return Z(y(String(t)));
6476
6651
  if (typeof window < "u" && t === window) return "{ [object Window] }";
6477
- if (typeof globalThis < "u" && t === globalThis || fe !== void 0 && t === fe) return "{ [object globalThis] }";
6652
+ if (typeof globalThis < "u" && t === globalThis || de !== void 0 && t === de) return "{ [object globalThis] }";
6478
6653
  if (!H(t) && !U(t)) {
6479
- var Se = be(t, y), Ce = M ? M(t) === Object.prototype : t instanceof Object || t.constructor === Object, we = t instanceof Object ? "" : "null prototype", Te = !Ce && A && Object(t) === t && A in t ? _.call(J(t), 8, -1) : we ? "Object" : "", Ee = (Ce || typeof t.constructor != "function" ? "" : t.constructor.name ? t.constructor.name + " " : "") + (Te || we ? "[" + C.call(S.call([], Te || [], we || []), ": ") + "] " : "");
6654
+ var Se = be(t, y), Ce = M ? M(t) === Object.prototype : t instanceof Object || t.constructor === Object, we = t instanceof Object ? "" : "null prototype", Te = !Ce && A && Object(t) === t && A in t ? _.call(re(t), 8, -1) : we ? "Object" : "", Ee = (Ce || typeof t.constructor != "function" ? "" : t.constructor.name ? t.constructor.name + " " : "") + (Te || we ? "[" + C.call(S.call([], Te || [], we || []), ": ") + "] " : "");
6480
6655
  return Se.length === 0 ? Ee + "{}" : g ? Ee + "{" + ye(Se, g) + "}" : Ee + "{ " + C.call(Se, ", ") + " }";
6481
6656
  }
6482
6657
  return String(t);
@@ -6492,27 +6667,27 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6492
6667
  return !A || !(typeof e == "object" && (A in e || e[A] !== void 0));
6493
6668
  }
6494
6669
  function V(e) {
6495
- return J(e) === "[object Array]" && B(e);
6670
+ return re(e) === "[object Array]" && B(e);
6496
6671
  }
6497
6672
  function H(e) {
6498
- return J(e) === "[object Date]" && B(e);
6673
+ return re(e) === "[object Date]" && B(e);
6499
6674
  }
6500
6675
  function U(e) {
6501
- return J(e) === "[object RegExp]" && B(e);
6676
+ return re(e) === "[object RegExp]" && B(e);
6502
6677
  }
6503
6678
  function te(e) {
6504
- return J(e) === "[object Error]" && B(e);
6679
+ return re(e) === "[object Error]" && B(e);
6505
6680
  }
6506
6681
  function W(e) {
6507
- return J(e) === "[object String]" && B(e);
6682
+ return re(e) === "[object String]" && B(e);
6508
6683
  }
6509
6684
  function ne(e) {
6510
- return J(e) === "[object Number]" && B(e);
6511
- }
6512
- function re(e) {
6513
- return J(e) === "[object Boolean]" && B(e);
6685
+ return re(e) === "[object Number]" && B(e);
6514
6686
  }
6515
6687
  function G(e) {
6688
+ return re(e) === "[object Boolean]" && B(e);
6689
+ }
6690
+ function K(e) {
6516
6691
  if (k) return e && typeof e == "object" && e instanceof Symbol;
6517
6692
  if (typeof e == "symbol") return !0;
6518
6693
  if (!e || typeof e != "object" || !O) return !1;
@@ -6521,33 +6696,33 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6521
6696
  } catch {}
6522
6697
  return !1;
6523
6698
  }
6524
- function K(e) {
6699
+ function q(e) {
6525
6700
  if (!e || typeof e != "object" || !E) return !1;
6526
6701
  try {
6527
6702
  return E.call(e), !0;
6528
6703
  } catch {}
6529
6704
  return !1;
6530
6705
  }
6531
- var ie = Object.prototype.hasOwnProperty || function(e) {
6706
+ var J = Object.prototype.hasOwnProperty || function(e) {
6532
6707
  return e in this;
6533
6708
  };
6534
- function q(e, t) {
6535
- return ie.call(e, t);
6709
+ function Y(e, t) {
6710
+ return J.call(e, t);
6536
6711
  }
6537
- function J(e) {
6712
+ function re(e) {
6538
6713
  return m.call(e);
6539
6714
  }
6540
- function Y(e) {
6715
+ function X(e) {
6541
6716
  if (e.name) return e.name;
6542
6717
  var t = g.call(h.call(e), /^function\s*([\w$]+)/);
6543
6718
  return t ? t[1] : null;
6544
6719
  }
6545
- function ae(e, t) {
6720
+ function ie(e, t) {
6546
6721
  if (e.indexOf) return e.indexOf(t);
6547
6722
  for (var n = 0, r = e.length; n < r; n++) if (e[n] === t) return n;
6548
6723
  return -1;
6549
6724
  }
6550
- function oe(e) {
6725
+ function ae(e) {
6551
6726
  if (!i || !e || typeof e != "object") return !1;
6552
6727
  try {
6553
6728
  i.call(e);
@@ -6560,7 +6735,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6560
6735
  } catch {}
6561
6736
  return !1;
6562
6737
  }
6563
- function se(e) {
6738
+ function oe(e) {
6564
6739
  if (!u || !e || typeof e != "object") return !1;
6565
6740
  try {
6566
6741
  u.call(e, u);
@@ -6573,14 +6748,14 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6573
6748
  } catch {}
6574
6749
  return !1;
6575
6750
  }
6576
- function ce(e) {
6751
+ function se(e) {
6577
6752
  if (!f || !e || typeof e != "object") return !1;
6578
6753
  try {
6579
6754
  return f.call(e), !0;
6580
6755
  } catch {}
6581
6756
  return !1;
6582
6757
  }
6583
- function le(e) {
6758
+ function ce(e) {
6584
6759
  if (!c || !e || typeof e != "object") return !1;
6585
6760
  try {
6586
6761
  c.call(e);
@@ -6593,7 +6768,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6593
6768
  } catch {}
6594
6769
  return !1;
6595
6770
  }
6596
- function ue(e) {
6771
+ function le(e) {
6597
6772
  if (!d || !e || typeof e != "object") return !1;
6598
6773
  try {
6599
6774
  d.call(e, d);
@@ -6606,7 +6781,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6606
6781
  } catch {}
6607
6782
  return !1;
6608
6783
  }
6609
- function de(e) {
6784
+ function ue(e) {
6610
6785
  return !e || typeof e != "object" ? !1 : typeof HTMLElement < "u" && e instanceof HTMLElement ? !0 : typeof e.nodeName == "string" && typeof e.getAttribute == "function";
6611
6786
  }
6612
6787
  function pe(e, t) {
@@ -6638,7 +6813,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6638
6813
  return e + " (" + t + ") {" + i + "}";
6639
6814
  }
6640
6815
  function _e(e) {
6641
- for (var t = 0; t < e.length; t++) if (ae(e[t], "\n") >= 0) return !1;
6816
+ for (var t = 0; t < e.length; t++) if (ie(e[t], "\n") >= 0) return !1;
6642
6817
  return !0;
6643
6818
  }
6644
6819
  function ve(e, t) {
@@ -6660,14 +6835,14 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
6660
6835
  var n = V(e), r = [];
6661
6836
  if (n) {
6662
6837
  r.length = e.length;
6663
- for (var i = 0; i < e.length; i++) r[i] = q(e, i) ? t(e[i], e) : "";
6838
+ for (var i = 0; i < e.length; i++) r[i] = Y(e, i) ? t(e[i], e) : "";
6664
6839
  }
6665
6840
  var a = typeof D == "function" ? D(e) : [], o;
6666
6841
  if (k) {
6667
6842
  o = {};
6668
6843
  for (var s = 0; s < a.length; s++) o["$" + a[s]] = a[s];
6669
6844
  }
6670
- for (var c in e) q(e, c) && (n && String(Number(c)) === c && c < e.length || k && o["$" + c] instanceof Symbol || (x.call(/[^\w$]/, c) ? r.push(t(c, e) + ": " + t(e[c], e)) : r.push(c + ": " + t(e[c], e))));
6845
+ for (var c in e) Y(e, c) && (n && String(Number(c)) === c && c < e.length || k && o["$" + c] instanceof Symbol || (x.call(/[^\w$]/, c) ? r.push(t(c, e) + ": " + t(e[c], e)) : r.push(c + ": " + t(e[c], e))));
6671
6846
  if (typeof D == "function") for (var l = 0; l < a.length; l++) j.call(e, a[l]) && r.push("[" + t(a[l]) + "]: " + t(e[a[l]], e));
6672
6847
  return r;
6673
6848
  }
@@ -7580,7 +7755,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
7580
7755
  shim: o
7581
7756
  }), t.exports = s;
7582
7757
  })), sr = /* @__PURE__ */ t(((e, t) => {
7583
- var n = ne(), { createGenericWasmCommand: r } = oe(), i = "\x1B[2J\x1B[H", a = "\x1B[0m", o = "\x1B[7m", s = "\x1B[1m", c = "\x1B[2m", l = "\x1B[36m", u = "\x1B[31m", d = "\x1B[32m", f = class extends n {
7758
+ var n = ne(), { createGenericWasmCommand: r } = ae(), i = "\x1B[2J\x1B[H", a = "\x1B[0m", o = "\x1B[7m", s = "\x1B[1m", c = "\x1B[2m", l = "\x1B[36m", u = "\x1B[31m", d = "\x1B[32m", f = class extends n {
7584
7759
  get requiresFilesystem() {
7585
7760
  return !0;
7586
7761
  }
@@ -7851,7 +8026,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
7851
8026
  f.createReplWasmCommand = p, f.createCommand = p, t.exports = f;
7852
8027
  })), cr = /* @__PURE__ */ t(((e, t) => {
7853
8028
  b();
7854
- var r = J(), i = Y(), a = ae(), o = oe(), s = W(), c = ne(), { TtyStream: l } = te(), u = "/.brsh_history", d = be(), f = He(), p = V(), m = x(), { isAsyncFilesystemSource: h, resolveFilesystemSource: g } = re(), _ = /\$(?:\{([\w\d?#@*-]+)\}|([\w\d]+|[?#@*-]))/g, v = p.EventEmitter || p.default || p;
8029
+ var r = re(), i = X(), a = ie(), o = ae(), s = W(), c = ne(), { TtyStream: l } = te(), u = "/.brsh_history", d = be(), f = He(), p = V(), m = x(), { isAsyncFilesystemSource: h, resolveFilesystemSource: g } = G(), _ = /\$(?:\{([\w\d?#@*-]+)\}|([\w\d]+|[?#@*-]))/g, v = p.EventEmitter || p.default || p;
7855
8030
  String.prototype.regexIndexOf = function(e, t) {
7856
8031
  let n = this.substring(t || 0).search(e);
7857
8032
  return n >= 0 ? n + (t || 0) : n;
@@ -8764,7 +8939,7 @@ var j, M, N, P, F, I, L, R, ee, z, B = e((() => {
8764
8939
  return e.create(Object.assign({}, n, { filesystem: t }));
8765
8940
  }
8766
8941
  };
8767
- S.STATUS_READY = "READY", S.STATUS_WORKING = "WORKING", S.STATUS_DESTROYED = "DESTROYED", S.Command = s, S.InteractiveCommand = c, S.WasmCommand = o, S.createWasmCommand = o.createGenericWasmCommand || o.createCommand, S.ReplCommand = sr(), S.FS = m, S.BinaryContainer = re(), S.Storage = S.BinaryContainer.FilesystemStorage, globalThis.shell = S, globalThis.Shell = S, t.exports = S;
8942
+ S.STATUS_READY = "READY", S.STATUS_WORKING = "WORKING", S.STATUS_DESTROYED = "DESTROYED", S.Command = s, S.InteractiveCommand = c, S.WasmCommand = o, S.createWasmCommand = o.createGenericWasmCommand || o.createCommand, S.ReplCommand = sr(), S.FS = m, S.BinaryContainer = G(), S.Storage = S.BinaryContainer.FilesystemStorage, globalThis.shell = S, globalThis.Shell = S, t.exports = S;
8768
8943
  }));
8769
8944
  //#endregion
8770
8945
  export default cr();