@lifo-sh/core 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +65 -0
  2. package/dist/{archive-D220So0m.js → archive-nRHWNwjH.js} +1 -1
  3. package/dist/{awk-rMPdpM91.js → awk-CchAsBzt.js} +1 -1
  4. package/dist/{basename-C33A_Zse.js → basename-C2v8jn7p.js} +1 -1
  5. package/dist/{cat-Crmqa4-2.js → cat-B2exoWlk.js} +1 -1
  6. package/dist/{chmod-CcGyvoCX.js → chmod-CQS63aP7.js} +1 -1
  7. package/dist/{chown-CErsnGQX.js → chown-rgGwZwu9.js} +1 -1
  8. package/dist/{cp-CpjwiLUF.js → cp-C8mNek36.js} +1 -1
  9. package/dist/{cut-GfN8py4j.js → cut-BZez9bS1.js} +1 -1
  10. package/dist/{diff-2wbVWmCT.js → diff-tWPvmikU.js} +1 -1
  11. package/dist/{dirname-C5L53RA2.js → dirname-BY_Gu5i2.js} +1 -1
  12. package/dist/{du-B0shJpEL.js → du-D25egSeK.js} +1 -1
  13. package/dist/{file-C2epVYvH.js → file-BPs1dqg5.js} +1 -1
  14. package/dist/{find-DA-rpvsC.js → find-CRUAXbhO.js} +1 -1
  15. package/dist/{grep-Bynq2w2E.js → grep-B9pTCSNY.js} +1 -1
  16. package/dist/{gunzip-B9b1Vph1.js → gunzip-BYlJhPf7.js} +2 -2
  17. package/dist/{gzip-CkXnPp5J.js → gzip-DgE-9PzE.js} +2 -2
  18. package/dist/{head-DZJVLF1k.js → head-DzP_T5Wx.js} +1 -1
  19. package/dist/{index-Be1wosKt.js → index-DccAPaZF.js} +861 -879
  20. package/dist/index.d.ts +2 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +12 -12
  23. package/dist/{ls-CSeazevv.js → ls-BiT10kLm.js} +1 -1
  24. package/dist/{mkdir-B7p8krsP.js → mkdir-DgzJ2JLj.js} +1 -1
  25. package/dist/{mktemp-88Nhvd7h.js → mktemp-Sh5DWxvc.js} +1 -1
  26. package/dist/{mv-DRVvz9oK.js → mv-Kp6DjQ8n.js} +1 -1
  27. package/dist/{nl-G2vK3rR3.js → nl-DBLFdpfC.js} +1 -1
  28. package/dist/{realpath-C-kisl-F.js → realpath-BOeYN6nD.js} +1 -1
  29. package/dist/{rev-9puwegeh.js → rev-CWRUIXWp.js} +1 -1
  30. package/dist/{rm-BXSq9iqP.js → rm-DA2w3xTR.js} +1 -1
  31. package/dist/{rmdir-CWgZ6q8D.js → rmdir-BiGbNDOT.js} +1 -1
  32. package/dist/sandbox/HeadlessTerminal.d.ts +2 -1
  33. package/dist/sandbox/HeadlessTerminal.d.ts.map +1 -1
  34. package/dist/sandbox/Sandbox.d.ts.map +1 -1
  35. package/dist/sandbox/types.d.ts +3 -2
  36. package/dist/sandbox/types.d.ts.map +1 -1
  37. package/dist/{sed-BRxd2DlZ.js → sed-ClWZ06zX.js} +1 -1
  38. package/dist/shell/Shell.d.ts +2 -2
  39. package/dist/shell/Shell.d.ts.map +1 -1
  40. package/dist/{sort-B7K83hAD.js → sort-CSzSGTdB.js} +1 -1
  41. package/dist/{stat-C0qs7xMV.js → stat-D0i1gTKB.js} +1 -1
  42. package/dist/{tail-CYBTYnn3.js → tail-tcIJLQnB.js} +1 -1
  43. package/dist/{tar-mMS7gfb-.js → tar-DkyzTzmT.js} +2 -2
  44. package/dist/{tee-B8bXFHbI.js → tee-RqoZ3qG-.js} +1 -1
  45. package/dist/terminal/ITerminal.d.ts +10 -0
  46. package/dist/terminal/ITerminal.d.ts.map +1 -0
  47. package/dist/{touch-CdAHKfLv.js → touch-k2NomRzL.js} +1 -1
  48. package/dist/{tree-BiWLXiUu.js → tree-B_j2_PsZ.js} +1 -1
  49. package/dist/{uniq-BZMOwoCc.js → uniq-hzJnHQOm.js} +1 -1
  50. package/dist/{unzip-DP4I991d.js → unzip-FwYCTDEZ.js} +2 -2
  51. package/dist/{wc-CpE5K4ZI.js → wc-Jp7nOops.js} +1 -1
  52. package/dist/{wget-DIPI0-I3.js → wget-2NAABIHc.js} +1 -1
  53. package/dist/{zip-B_gQ6LXC.js → zip--0ncHv0q.js} +2 -2
  54. package/package.json +35 -11
  55. package/dist/terminal/Terminal.d.ts +0 -13
  56. package/dist/terminal/Terminal.d.ts.map +0 -1
@@ -1,9 +1,6 @@
1
- var Ct = Object.defineProperty;
2
- var Lt = (r, e, t) => e in r ? Ct(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var h = (r, e, t) => Lt(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { Terminal as Pt } from "@xterm/xterm";
5
- import { FitAddon as Tt } from "@xterm/addon-fit";
6
- import { WebglAddon as At } from "@xterm/addon-webgl";
1
+ var Lt = Object.defineProperty;
2
+ var Pt = (r, e, t) => e in r ? Lt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var u = (r, e, t) => Pt(r, typeof e != "symbol" ? e + "" : e, t);
7
4
  function W(r) {
8
5
  if (r === "") return ".";
9
6
  const e = r.startsWith("/"), t = r.split("/"), s = [];
@@ -37,14 +34,14 @@ function Q(r) {
37
34
  const e = K(r), t = e.lastIndexOf(".");
38
35
  return t <= 0 ? "" : e.slice(t);
39
36
  }
40
- const _t = new TextEncoder(), Rt = new TextDecoder();
37
+ const Tt = new TextEncoder(), _t = new TextDecoder();
41
38
  function ee(r) {
42
- return _t.encode(r);
39
+ return Tt.encode(r);
43
40
  }
44
- function Ft(r) {
45
- return Rt.decode(r);
41
+ function Rt(r) {
42
+ return _t.decode(r);
46
43
  }
47
- function _r(...r) {
44
+ function xr(...r) {
48
45
  const e = r.reduce((i, n) => i + n.length, 0), t = new Uint8Array(e);
49
46
  let s = 0;
50
47
  for (const i of r)
@@ -62,15 +59,15 @@ const C = {
62
59
  class k extends Error {
63
60
  constructor(t, s) {
64
61
  super(`${t}: ${s}`);
65
- h(this, "code");
62
+ u(this, "code");
66
63
  this.code = t, this.name = "VFSError";
67
64
  }
68
65
  }
69
- class It {
66
+ class At {
70
67
  constructor() {
71
- h(this, "root");
72
- h(this, "virtualProviders", /* @__PURE__ */ new Map());
73
- h(this, "onChange");
68
+ u(this, "root");
69
+ u(this, "virtualProviders", /* @__PURE__ */ new Map());
70
+ u(this, "onChange");
74
71
  this.root = this.createNode("directory", "");
75
72
  }
76
73
  registerProvider(e, t) {
@@ -139,7 +136,7 @@ class It {
139
136
  }
140
137
  readFileString(e) {
141
138
  const t = this.getProvider(e);
142
- return t ? t.provider.readFileString(t.subpath) : Ft(this.readFile(e));
139
+ return t ? t.provider.readFileString(t.subpath) : Rt(this.readFile(e));
143
140
  }
144
141
  writeFile(e, t) {
145
142
  var c;
@@ -241,13 +238,13 @@ class It {
241
238
  if (t != null && t.recursive) {
242
239
  const l = this.toAbsolute(e).split("/").filter(Boolean);
243
240
  let f = this.root;
244
- for (const u of l) {
245
- let m = f.children.get(u);
246
- if (!m)
247
- m = this.createNode("directory", u), f.children.set(u, m);
248
- else if (m.type !== "directory")
249
- throw new k(C.ENOTDIR, `'${u}': not a directory`);
250
- f = m;
241
+ for (const h of l) {
242
+ let p = f.children.get(h);
243
+ if (!p)
244
+ p = this.createNode("directory", h), f.children.set(h, p);
245
+ else if (p.type !== "directory")
246
+ throw new k(C.ENOTDIR, `'${h}': not a directory`);
247
+ f = p;
251
248
  }
252
249
  (o = this.onChange) == null || o.call(this);
253
250
  return;
@@ -320,9 +317,9 @@ class It {
320
317
  this.rmdir(s);
321
318
  }
322
319
  }
323
- class Nt {
320
+ class Ft {
324
321
  constructor() {
325
- h(this, "generators", /* @__PURE__ */ new Map());
322
+ u(this, "generators", /* @__PURE__ */ new Map());
326
323
  this.generators.set("cpuinfo", () => {
327
324
  const e = typeof navigator < "u" ? navigator.hardwareConcurrency ?? 1 : 1, t = [];
328
325
  for (let s = 0; s < e; s++)
@@ -415,9 +412,9 @@ class Nt {
415
412
  }
416
413
  }
417
414
  const re = ["null", "zero", "random", "urandom", "clipboard"];
418
- class Bt {
415
+ class It {
419
416
  constructor() {
420
- h(this, "clipboardCache", "");
417
+ u(this, "clipboardCache", "");
421
418
  }
422
419
  readFile(e) {
423
420
  switch (e.startsWith("/") ? e.slice(1) : e) {
@@ -484,23 +481,23 @@ class Bt {
484
481
  throw new k(C.ENOTDIR, `'/dev${e}': not a directory`);
485
482
  }
486
483
  }
487
- const zt = ["proc", "dev"];
488
- function jt(r) {
484
+ const Nt = ["proc", "dev"];
485
+ function Bt(r) {
489
486
  let e = "";
490
487
  for (let t = 0; t < r.length; t++)
491
488
  e += String.fromCharCode(r[t]);
492
489
  return btoa(e);
493
490
  }
494
- function Dt(r) {
491
+ function zt(r) {
495
492
  const e = atob(r), t = new Uint8Array(e.length);
496
493
  for (let s = 0; s < e.length; s++)
497
494
  t[s] = e.charCodeAt(s);
498
495
  return t;
499
496
  }
500
- function Ot(r) {
501
- return He(r, !0);
497
+ function jt(r) {
498
+ return Ue(r, !0);
502
499
  }
503
- function He(r, e) {
500
+ function Ue(r, e) {
504
501
  if (r.type === "file") {
505
502
  const i = {
506
503
  t: "f",
@@ -509,11 +506,11 @@ function He(r, e) {
509
506
  mt: r.mtime,
510
507
  m: r.mode
511
508
  };
512
- return r.data.length > 0 && (i.d = jt(r.data)), i;
509
+ return r.data.length > 0 && (i.d = Bt(r.data)), i;
513
510
  }
514
511
  const t = [];
515
512
  for (const [i, n] of r.children)
516
- e && zt.includes(i) || t.push(He(n, !1));
513
+ e && Nt.includes(i) || t.push(Ue(n, !1));
517
514
  const s = {
518
515
  t: "d",
519
516
  n: r.name,
@@ -523,36 +520,36 @@ function He(r, e) {
523
520
  };
524
521
  return t.length > 0 && (s.c = t), s;
525
522
  }
526
- function Mt(r) {
527
- return Ve(r);
523
+ function Dt(r) {
524
+ return He(r);
528
525
  }
529
- function Ve(r) {
526
+ function He(r) {
530
527
  const e = /* @__PURE__ */ new Map();
531
528
  if (r.t === "d" && r.c)
532
529
  for (const t of r.c) {
533
- const s = Ve(t);
530
+ const s = He(t);
534
531
  e.set(s.name, s);
535
532
  }
536
533
  return {
537
534
  type: r.t === "f" ? "file" : "directory",
538
535
  name: r.n,
539
- data: r.d ? Dt(r.d) : new Uint8Array(0),
536
+ data: r.d ? zt(r.d) : new Uint8Array(0),
540
537
  children: e,
541
538
  ctime: r.ct,
542
539
  mtime: r.mt,
543
540
  mode: r.m
544
541
  };
545
542
  }
546
- const Wt = "lifo", V = "filesystem", $e = "root", qt = 1e3;
547
- class Ut {
543
+ const Ot = "lifo", V = "filesystem", $e = "root", Mt = 1e3;
544
+ class Wt {
548
545
  constructor() {
549
- h(this, "db", null);
550
- h(this, "timer", null);
546
+ u(this, "db", null);
547
+ u(this, "timer", null);
551
548
  }
552
549
  async open() {
553
550
  if (!(typeof indexedDB > "u"))
554
551
  return new Promise((e) => {
555
- const t = indexedDB.open(Wt, 1);
552
+ const t = indexedDB.open(Ot, 1);
556
553
  t.onupgradeneeded = () => {
557
554
  const s = t.result;
558
555
  s.objectStoreNames.contains(V) || s.createObjectStore(V);
@@ -570,7 +567,7 @@ class Ut {
570
567
  i.onsuccess = () => {
571
568
  if (i.result)
572
569
  try {
573
- const n = Mt(i.result);
570
+ const n = Dt(i.result);
574
571
  e(n);
575
572
  } catch {
576
573
  e(null);
@@ -585,7 +582,7 @@ class Ut {
585
582
  }
586
583
  async save(e) {
587
584
  if (!this.db) return;
588
- const t = Ot(e);
585
+ const t = jt(e);
589
586
  return new Promise((s) => {
590
587
  try {
591
588
  const i = this.db.transaction(V, "readwrite");
@@ -599,10 +596,10 @@ class Ut {
599
596
  this.timer && clearTimeout(this.timer), this.timer = setTimeout(() => {
600
597
  this.save(e).catch(() => {
601
598
  }), this.timer = null;
602
- }, qt);
599
+ }, Mt);
603
600
  }
604
601
  }
605
- function Ht(r) {
602
+ function qt(r) {
606
603
  const e = "/home/user/examples", t = [
607
604
  e,
608
605
  `${e}/scripts`,
@@ -614,10 +611,10 @@ function Ht(r) {
614
611
  r.mkdir(s, { recursive: !0 });
615
612
  } catch {
616
613
  }
617
- for (const [s, i] of Object.entries(Vt))
614
+ for (const [s, i] of Object.entries(Ut))
618
615
  r.exists(`${e}/${s}`) || r.writeFile(`${e}/${s}`, i);
619
616
  }
620
- const Vt = {
617
+ const Ut = {
621
618
  // ─── README ───
622
619
  "README.txt": `Lifo Examples
623
620
  ==================
@@ -1270,6 +1267,63 @@ console.log("\\nAdmin users:");
1270
1267
  for (const user of data.users.filter(u => u.role === "admin")) {
1271
1268
  console.log(\` \${user.name} (active: \${user.active})\`);
1272
1269
  }
1270
+ `,
1271
+ "node/http-server.js": `// Run with: node examples/node/http-server.js
1272
+ // Then in another terminal: curl localhost:3000
1273
+ // Or run: node examples/node/http-client.js
1274
+
1275
+ const http = require("http");
1276
+
1277
+ const server = http.createServer((req, res) => {
1278
+ const body = JSON.stringify({
1279
+ message: "Hello from Lifo!",
1280
+ method: req.method,
1281
+ url: req.url,
1282
+ time: new Date().toISOString(),
1283
+ }, null, 2);
1284
+
1285
+ res.writeHead(200, {
1286
+ "Content-Type": "application/json",
1287
+ "Content-Length": Buffer.byteLength(body),
1288
+ });
1289
+ res.end(body);
1290
+ });
1291
+
1292
+ server.listen(3000, () => {
1293
+ console.log("Server running on http://localhost:3000");
1294
+ console.log("Try: curl localhost:3000");
1295
+ console.log("Press Ctrl+C to stop");
1296
+ });
1297
+ `,
1298
+ "node/http-client.js": `// Run with: node examples/node/http-client.js
1299
+ // Make sure http-server.js is running first!
1300
+
1301
+ const http = require("http");
1302
+
1303
+ function request(path) {
1304
+ return new Promise((resolve, reject) => {
1305
+ http.get("http://localhost:3000" + path, (res) => {
1306
+ let data = "";
1307
+ res.on("data", (chunk) => data += chunk);
1308
+ res.on("end", () => {
1309
+ console.log("GET " + path);
1310
+ console.log("Status:", res.statusCode);
1311
+ console.log("Response:", data);
1312
+ console.log();
1313
+ resolve(data);
1314
+ });
1315
+ });
1316
+ });
1317
+ }
1318
+
1319
+ async function main() {
1320
+ await request("/");
1321
+ await request("/api/users");
1322
+ await request("/health");
1323
+ console.log("Done!");
1324
+ }
1325
+
1326
+ main();
1273
1327
  `,
1274
1328
  // ─── Text processing cheatsheet ───
1275
1329
  "scripts/11-text-processing.sh": `#!/bin/sh
@@ -1377,7 +1431,7 @@ tree /home/user -L 2
1377
1431
 
1378
1432
  echo "Done."
1379
1433
  `
1380
- }, Gt = `\x1B[1;36m
1434
+ }, Ht = `\x1B[1;36m
1381
1435
  _ _ __
1382
1436
  | | (_)/ _| ___
1383
1437
  | | | | |_ / _ \\
@@ -1387,9 +1441,9 @@ echo "Done."
1387
1441
  \x1B[2mA Linux-like OS running natively in your browser.\x1B[0m
1388
1442
  \x1B[2mType 'help' or try: ls, cd, cat, mkdir, touch\x1B[0m
1389
1443
  \x1B[2mExplore examples: ls ~/examples/scripts\x1B[0m
1390
- `, Zt = `export PATH=/usr/bin:/bin
1444
+ `, Vt = `export PATH=/usr/bin:/bin
1391
1445
  export EDITOR=nano
1392
- `, Jt = `# Aliases
1446
+ `, Gt = `# Aliases
1393
1447
  alias ll='ls -la'
1394
1448
  alias la='ls -a'
1395
1449
  alias l='ls -1'
@@ -1397,12 +1451,12 @@ alias ..='cd ..'
1397
1451
  alias cls='clear'
1398
1452
  alias h='history'
1399
1453
  `;
1400
- class Yt {
1454
+ class Zt {
1401
1455
  constructor() {
1402
- h(this, "vfs");
1403
- h(this, "portRegistry", /* @__PURE__ */ new Map());
1404
- h(this, "persistence");
1405
- this.vfs = new It(), this.persistence = new Ut();
1456
+ u(this, "vfs");
1457
+ u(this, "portRegistry", /* @__PURE__ */ new Map());
1458
+ u(this, "persistence");
1459
+ this.vfs = new At(), this.persistence = new Wt();
1406
1460
  }
1407
1461
  async boot(e) {
1408
1462
  const t = (e == null ? void 0 : e.persist) ?? !0;
@@ -1411,7 +1465,7 @@ class Yt {
1411
1465
  const s = await this.persistence.load();
1412
1466
  s && this.vfs.loadFromSerialized(s);
1413
1467
  }
1414
- this.initFilesystem(), this.vfs.registerProvider("/proc", new Nt()), this.vfs.registerProvider("/dev", new Bt()), t && (this.vfs.onChange = () => {
1468
+ this.initFilesystem(), this.vfs.registerProvider("/proc", new Ft()), this.vfs.registerProvider("/dev", new It()), t && (this.vfs.onChange = () => {
1415
1469
  this.persistence.scheduleSave(this.vfs.getRoot());
1416
1470
  });
1417
1471
  }
@@ -1435,8 +1489,8 @@ class Yt {
1435
1489
  this.vfs.mkdir(t, { recursive: !0 });
1436
1490
  } catch {
1437
1491
  }
1438
- this.vfs.writeFile("/etc/motd", Gt), this.vfs.writeFile("/etc/hostname", `lifo
1439
- `), this.vfs.exists("/etc/profile") || this.vfs.writeFile("/etc/profile", Zt), this.vfs.exists("/home/user/.bashrc") || this.vfs.writeFile("/home/user/.bashrc", Jt), Ht(this.vfs);
1492
+ this.vfs.writeFile("/etc/motd", Ht), this.vfs.writeFile("/etc/hostname", `lifo
1493
+ `), this.vfs.exists("/etc/profile") || this.vfs.writeFile("/etc/profile", Vt), this.vfs.exists("/home/user/.bashrc") || this.vfs.writeFile("/home/user/.bashrc", Gt), qt(this.vfs);
1440
1494
  }
1441
1495
  getDefaultEnv() {
1442
1496
  return {
@@ -1450,30 +1504,30 @@ class Yt {
1450
1504
  };
1451
1505
  }
1452
1506
  }
1453
- const z = "\x1B[0m", Y = "\x1B[1m", Xt = "\x1B[2m", Rr = "\x1B[3m", Fr = "\x1B[4m", Qt = "\x1B[31m", oe = "\x1B[32m", Kt = "\x1B[33m", ae = "\x1B[34m", es = "\x1B[35m", ts = "\x1B[36m", Ir = "\x1B[37m", Nr = "\x1B[91m", Br = "\x1B[92m", zr = "\x1B[93m", jr = "\x1B[94m", Dr = "\x1B[95m", Or = "\x1B[96m";
1454
- function Mr(r) {
1455
- return Qt + r + z;
1507
+ const z = "\x1B[0m", Y = "\x1B[1m", Jt = "\x1B[2m", Sr = "\x1B[3m", kr = "\x1B[4m", Yt = "\x1B[31m", oe = "\x1B[32m", Xt = "\x1B[33m", ae = "\x1B[34m", Qt = "\x1B[35m", Kt = "\x1B[36m", Er = "\x1B[37m", Cr = "\x1B[91m", Lr = "\x1B[92m", Pr = "\x1B[93m", Tr = "\x1B[94m", _r = "\x1B[95m", Rr = "\x1B[96m";
1508
+ function Ar(r) {
1509
+ return Yt + r + z;
1456
1510
  }
1457
- function Wr(r) {
1511
+ function Fr(r) {
1458
1512
  return oe + r + z;
1459
1513
  }
1460
- function qr(r) {
1461
- return Kt + r + z;
1514
+ function Ir(r) {
1515
+ return Xt + r + z;
1462
1516
  }
1463
- function Ur(r) {
1517
+ function Nr(r) {
1464
1518
  return ae + r + z;
1465
1519
  }
1466
- function Hr(r) {
1467
- return es + r + z;
1520
+ function Br(r) {
1521
+ return Qt + r + z;
1468
1522
  }
1469
- function Vr(r) {
1470
- return ts + r + z;
1523
+ function zr(r) {
1524
+ return Kt + r + z;
1471
1525
  }
1472
- function Gr(r) {
1526
+ function jr(r) {
1473
1527
  return Y + r + z;
1474
1528
  }
1475
- function Zr(r) {
1476
- return Xt + r + z;
1529
+ function Dr(r) {
1530
+ return Jt + r + z;
1477
1531
  }
1478
1532
  var g = /* @__PURE__ */ ((r) => (r[r.Word = 0] = "Word", r[r.Pipe = 1] = "Pipe", r[r.And = 2] = "And", r[r.Or = 3] = "Or", r[r.Semi = 4] = "Semi", r[r.Amp = 5] = "Amp", r[r.RedirectOut = 6] = "RedirectOut", r[r.RedirectAppend = 7] = "RedirectAppend", r[r.RedirectIn = 8] = "RedirectIn", r[r.RedirectErr = 9] = "RedirectErr", r[r.RedirectErrAppend = 10] = "RedirectErrAppend", r[r.RedirectAll = 11] = "RedirectAll", r[r.DoubleSemi = 12] = "DoubleSemi", r[r.LParen = 13] = "LParen", r[r.RParen = 14] = "RParen", r[r.Newline = 15] = "Newline", r[r.EOF = 16] = "EOF", r))(g || {});
1479
1533
  function xe(r) {
@@ -1496,12 +1550,12 @@ function xe(r) {
1496
1550
  t++;
1497
1551
  continue;
1498
1552
  }
1499
- const s = ss(r, t);
1553
+ const s = es(r, t);
1500
1554
  if (s) {
1501
1555
  e.push(s.token), t = s.end;
1502
1556
  continue;
1503
1557
  }
1504
- const i = ns(r, t);
1558
+ const i = rs(r, t);
1505
1559
  if (i) {
1506
1560
  e.push(i.token), t = i.end;
1507
1561
  continue;
@@ -1510,19 +1564,19 @@ function xe(r) {
1510
1564
  }
1511
1565
  return e.push({ kind: g.EOF, value: "", pos: t }), e;
1512
1566
  }
1513
- function ss(r, e) {
1567
+ function es(r, e) {
1514
1568
  const t = r[e], s = r[e + 1];
1515
- return t === "&" && s === ">" ? { token: { kind: g.RedirectAll, value: "&>", pos: e }, end: e + 2 } : t === "&" && s === "&" ? { token: { kind: g.And, value: "&&", pos: e }, end: e + 2 } : t === "&" ? { token: { kind: g.Amp, value: "&", pos: e }, end: e + 1 } : t === "|" && s === "|" ? { token: { kind: g.Or, value: "||", pos: e }, end: e + 2 } : t === "|" ? { token: { kind: g.Pipe, value: "|", pos: e }, end: e + 1 } : t === "2" && s === ">" && r[e + 2] === ">" ? { token: { kind: g.RedirectErrAppend, value: "2>>", pos: e }, end: e + 3 } : t === "2" && s === ">" ? e > 0 && !rs(r[e - 1]) ? null : { token: { kind: g.RedirectErr, value: "2>", pos: e }, end: e + 2 } : t === ">" && s === ">" ? { token: { kind: g.RedirectAppend, value: ">>", pos: e }, end: e + 2 } : t === ">" ? { token: { kind: g.RedirectOut, value: ">", pos: e }, end: e + 1 } : t === "<" ? { token: { kind: g.RedirectIn, value: "<", pos: e }, end: e + 1 } : t === ";" && s === ";" ? { token: { kind: g.DoubleSemi, value: ";;", pos: e }, end: e + 2 } : t === ";" ? { token: { kind: g.Semi, value: ";", pos: e }, end: e + 1 } : t === "(" ? { token: { kind: g.LParen, value: "(", pos: e }, end: e + 1 } : t === ")" ? { token: { kind: g.RParen, value: ")", pos: e }, end: e + 1 } : null;
1569
+ return t === "&" && s === ">" ? { token: { kind: g.RedirectAll, value: "&>", pos: e }, end: e + 2 } : t === "&" && s === "&" ? { token: { kind: g.And, value: "&&", pos: e }, end: e + 2 } : t === "&" ? { token: { kind: g.Amp, value: "&", pos: e }, end: e + 1 } : t === "|" && s === "|" ? { token: { kind: g.Or, value: "||", pos: e }, end: e + 2 } : t === "|" ? { token: { kind: g.Pipe, value: "|", pos: e }, end: e + 1 } : t === "2" && s === ">" && r[e + 2] === ">" ? { token: { kind: g.RedirectErrAppend, value: "2>>", pos: e }, end: e + 3 } : t === "2" && s === ">" ? e > 0 && !ts(r[e - 1]) ? null : { token: { kind: g.RedirectErr, value: "2>", pos: e }, end: e + 2 } : t === ">" && s === ">" ? { token: { kind: g.RedirectAppend, value: ">>", pos: e }, end: e + 2 } : t === ">" ? { token: { kind: g.RedirectOut, value: ">", pos: e }, end: e + 1 } : t === "<" ? { token: { kind: g.RedirectIn, value: "<", pos: e }, end: e + 1 } : t === ";" && s === ";" ? { token: { kind: g.DoubleSemi, value: ";;", pos: e }, end: e + 2 } : t === ";" ? { token: { kind: g.Semi, value: ";", pos: e }, end: e + 1 } : t === "(" ? { token: { kind: g.LParen, value: "(", pos: e }, end: e + 1 } : t === ")" ? { token: { kind: g.RParen, value: ")", pos: e }, end: e + 1 } : null;
1516
1570
  }
1517
- function rs(r) {
1571
+ function ts(r) {
1518
1572
  return r === " " || r === " " || r === "|" || r === "&" || r === ";" || r === ">" || r === "<" || r === `
1519
1573
  ` || r === "(" || r === ")";
1520
1574
  }
1521
- function is(r) {
1575
+ function ss(r) {
1522
1576
  return r === " " || r === " " || r === "|" || r === "&" || r === ";" || r === ">" || r === "<" || r === "#" || r === `
1523
1577
  ` || r === "(" || r === ")";
1524
1578
  }
1525
- function ns(r, e) {
1579
+ function rs(r, e) {
1526
1580
  const t = [];
1527
1581
  let s = e, i = "", n = !1;
1528
1582
  for (; s < r.length; ) {
@@ -1574,7 +1628,7 @@ function ns(r, e) {
1574
1628
  continue;
1575
1629
  }
1576
1630
  }
1577
- if (is(a) || a === ">" || a === "<")
1631
+ if (ss(a) || a === ">" || a === "<")
1578
1632
  break;
1579
1633
  i += a, s++, n = !0;
1580
1634
  }
@@ -1623,9 +1677,9 @@ class ke extends Error {
1623
1677
  }
1624
1678
  }
1625
1679
  function Ee(r) {
1626
- return new as(r).parseScript();
1680
+ return new ns(r).parseScript();
1627
1681
  }
1628
- const os = /* @__PURE__ */ new Set([
1682
+ const is = /* @__PURE__ */ new Set([
1629
1683
  "if",
1630
1684
  "then",
1631
1685
  "else",
@@ -1640,10 +1694,10 @@ const os = /* @__PURE__ */ new Set([
1640
1694
  "case",
1641
1695
  "esac"
1642
1696
  ]);
1643
- class as {
1697
+ class ns {
1644
1698
  constructor(e) {
1645
- h(this, "tokens");
1646
- h(this, "pos", 0);
1699
+ u(this, "tokens");
1700
+ u(this, "pos", 0);
1647
1701
  this.tokens = e;
1648
1702
  }
1649
1703
  peek() {
@@ -1731,7 +1785,7 @@ class as {
1731
1785
  }
1732
1786
  if (this.peekAt(1).kind === g.LParen && this.peekAt(2).kind === g.RParen) {
1733
1787
  const t = e.value;
1734
- if (!os.has(t))
1788
+ if (!is.has(t))
1735
1789
  return this.parseFunctionDef();
1736
1790
  }
1737
1791
  }
@@ -1869,13 +1923,13 @@ class as {
1869
1923
  const a = i.value.slice(0, o), c = i.value.slice(o + 1), l = [];
1870
1924
  if (i.parts) {
1871
1925
  let f = 0;
1872
- for (const u of i.parts) {
1873
- const m = f + u.text.length;
1874
- if (m <= o + 1) {
1875
- f = m;
1926
+ for (const h of i.parts) {
1927
+ const p = f + h.text.length;
1928
+ if (p <= o + 1) {
1929
+ f = p;
1876
1930
  continue;
1877
1931
  }
1878
- f < o + 1 ? l.push({ text: u.text.slice(o + 1 - f), quoted: u.quoted }) : l.push(u), f = m;
1932
+ f < o + 1 ? l.push({ text: h.text.slice(o + 1 - f), quoted: h.quoted }) : l.push(h), f = p;
1879
1933
  }
1880
1934
  }
1881
1935
  l.length === 0 && l.push({ text: c, quoted: "none" }), e.push({ name: a, value: l });
@@ -1899,7 +1953,7 @@ function M(r, e) {
1899
1953
  let t = 0, s = 0, i = -1, n = -1;
1900
1954
  for (; s < e.length; ) {
1901
1955
  if (t < r.length && r[t] === "[") {
1902
- const o = cs(r, t, e[s]);
1956
+ const o = os(r, t, e[s]);
1903
1957
  if (o.matched) {
1904
1958
  t = o.end, s++;
1905
1959
  continue;
@@ -1932,7 +1986,7 @@ function M(r, e) {
1932
1986
  t++;
1933
1987
  return t === r.length;
1934
1988
  }
1935
- function cs(r, e, t) {
1989
+ function os(r, e, t) {
1936
1990
  let s = e + 1, i = !1;
1937
1991
  s < r.length && (r[s] === "!" || r[s] === "^") && (i = !0, s++);
1938
1992
  let n = !1;
@@ -1941,7 +1995,7 @@ function cs(r, e, t) {
1941
1995
  s + 2 < r.length && r[s + 1] === "-" && r[s + 2] !== "]" ? (t >= r[s] && t <= r[s + 2] && (n = !0), s += 3) : (t === r[s] && (n = !0), s++);
1942
1996
  return s < r.length && r[s] === "]" && s++, { matched: i ? !n : n, end: s };
1943
1997
  }
1944
- function ls(r, e, t) {
1998
+ function as(r, e, t) {
1945
1999
  if (!Ce(r))
1946
2000
  return [r];
1947
2001
  const i = (r.startsWith("/") ? r : I(e, r)).split("/").filter(Boolean), n = r.startsWith("/");
@@ -1951,18 +2005,18 @@ function ls(r, e, t) {
1951
2005
  if (Ce(c))
1952
2006
  for (const f of o)
1953
2007
  try {
1954
- const u = t.readdir(f);
1955
- for (const m of u)
1956
- if (M(c, m.name)) {
1957
- const y = f === "/" ? `/${m.name}` : `${f}/${m.name}`;
2008
+ const h = t.readdir(f);
2009
+ for (const p of h)
2010
+ if (M(c, p.name)) {
2011
+ const y = f === "/" ? `/${p.name}` : `${f}/${p.name}`;
1958
2012
  l.push(y);
1959
2013
  }
1960
2014
  } catch {
1961
2015
  }
1962
2016
  else
1963
2017
  for (const f of o) {
1964
- const u = f === "/" ? `/${c}` : `${f}/${c}`;
1965
- t.exists(u) && l.push(u);
2018
+ const h = f === "/" ? `/${c}` : `${f}/${c}`;
2019
+ t.exists(h) && l.push(h);
1966
2020
  }
1967
2021
  o = l;
1968
2022
  }
@@ -1983,9 +2037,9 @@ function Ce(r) {
1983
2037
  async function Le(r, e) {
1984
2038
  const t = [];
1985
2039
  for (const s of r) {
1986
- const i = await Ge(s, e);
1987
- if (ms(s)) {
1988
- const n = ls(i, e.cwd, e.vfs);
2040
+ const i = await Ve(s, e);
2041
+ if (ds(s)) {
2042
+ const n = as(i, e.cwd, e.vfs);
1989
2043
  t.push(...n);
1990
2044
  } else
1991
2045
  t.push(i);
@@ -1993,9 +2047,9 @@ async function Le(r, e) {
1993
2047
  return t;
1994
2048
  }
1995
2049
  async function J(r, e) {
1996
- return Ge(r, e);
2050
+ return Ve(r, e);
1997
2051
  }
1998
- async function Ge(r, e) {
2052
+ async function Ve(r, e) {
1999
2053
  let t = "";
2000
2054
  for (const s of r)
2001
2055
  switch (s.quoted) {
@@ -2021,13 +2075,13 @@ async function Pe(r, e) {
2021
2075
  let t = "", s = 0;
2022
2076
  for (; s < r.length; )
2023
2077
  if (r[s] === "$") {
2024
- const i = await hs(r, s, e);
2078
+ const i = await cs(r, s, e);
2025
2079
  t += i.value, s = i.end;
2026
2080
  } else
2027
2081
  t += r[s], s++;
2028
2082
  return t;
2029
2083
  }
2030
- async function hs(r, e, t) {
2084
+ async function cs(r, e, t) {
2031
2085
  const s = r[e + 1];
2032
2086
  if (s === void 0)
2033
2087
  return { value: "$", end: e + 1 };
@@ -2050,7 +2104,7 @@ async function hs(r, e, t) {
2050
2104
  n += 2;
2051
2105
  } else
2052
2106
  n++;
2053
- const o = r.slice(e + 3, n - 2), a = ps(o, t.env);
2107
+ const o = r.slice(e + 3, n - 2), a = fs(o, t.env);
2054
2108
  return { value: String(a), end: n };
2055
2109
  }
2056
2110
  if (s === "(") {
@@ -2066,7 +2120,7 @@ async function hs(r, e, t) {
2066
2120
  for (; i < r.length && n > 0; )
2067
2121
  r[i] === "{" ? n++ : r[i] === "}" && n--, i++;
2068
2122
  const o = r.slice(e + 2, i - 1);
2069
- return { value: us(o, t), end: i };
2123
+ return { value: ls(o, t), end: i };
2070
2124
  }
2071
2125
  if (/[0-9]/.test(s))
2072
2126
  return { value: t.env[s] ?? "", end: e + 2 };
@@ -2079,7 +2133,7 @@ async function hs(r, e, t) {
2079
2133
  }
2080
2134
  return { value: "$", end: e + 1 };
2081
2135
  }
2082
- function us(r, e) {
2136
+ function ls(r, e) {
2083
2137
  if (r.startsWith("#") && /^#[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)) {
2084
2138
  const t = r.slice(1), s = e.env[t] ?? "";
2085
2139
  return String(s.length);
@@ -2129,14 +2183,14 @@ function us(r, e) {
2129
2183
  const t = r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\/\/([^/]*)\/(.*)$/s);
2130
2184
  if (t) {
2131
2185
  const s = e.env[t[1]] ?? "", i = t[2], n = t[3];
2132
- return fs(s, i, n);
2186
+ return us(s, i, n);
2133
2187
  }
2134
2188
  }
2135
2189
  {
2136
2190
  const t = r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\/([^/]*)\/(.*)$/s);
2137
2191
  if (t) {
2138
2192
  const s = e.env[t[1]] ?? "", i = t[2], n = t[3];
2139
- return ds(s, i, n);
2193
+ return hs(s, i, n);
2140
2194
  }
2141
2195
  }
2142
2196
  {
@@ -2181,14 +2235,14 @@ function us(r, e) {
2181
2235
  }
2182
2236
  return e.env[r] ?? "";
2183
2237
  }
2184
- function ds(r, e, t) {
2238
+ function hs(r, e, t) {
2185
2239
  for (let s = 0; s < r.length; s++)
2186
2240
  for (let i = s + 1; i <= r.length; i++)
2187
2241
  if (M(e, r.slice(s, i)))
2188
2242
  return r.slice(0, s) + t + r.slice(i);
2189
2243
  return r;
2190
2244
  }
2191
- function fs(r, e, t) {
2245
+ function us(r, e, t) {
2192
2246
  let s = "", i = 0;
2193
2247
  for (; i < r.length; ) {
2194
2248
  let n = !1;
@@ -2201,20 +2255,20 @@ function fs(r, e, t) {
2201
2255
  }
2202
2256
  return s;
2203
2257
  }
2204
- function ms(r, e) {
2258
+ function ds(r, e) {
2205
2259
  for (const t of r)
2206
2260
  if (t.quoted === "none" && (t.text.includes("*") || t.text.includes("?") || t.text.includes("[")))
2207
2261
  return !0;
2208
2262
  return !1;
2209
2263
  }
2210
- function ps(r, e) {
2211
- return new gs(r.trim(), e).parseExpression();
2264
+ function fs(r, e) {
2265
+ return new ms(r.trim(), e).parseExpression();
2212
2266
  }
2213
- class gs {
2267
+ class ms {
2214
2268
  constructor(e, t) {
2215
- h(this, "expr");
2216
- h(this, "pos", 0);
2217
- h(this, "env");
2269
+ u(this, "expr");
2270
+ u(this, "pos", 0);
2271
+ u(this, "env");
2218
2272
  this.expr = e, this.env = t;
2219
2273
  }
2220
2274
  skipSpaces() {
@@ -2477,12 +2531,12 @@ class gs {
2477
2531
  return isNaN(s) ? 0 : s;
2478
2532
  }
2479
2533
  }
2480
- class ws {
2534
+ class ps {
2481
2535
  constructor() {
2482
- h(this, "buffer", []);
2483
- h(this, "closed", !1);
2484
- h(this, "waiting", null);
2485
- h(this, "writer", {
2536
+ u(this, "buffer", []);
2537
+ u(this, "closed", !1);
2538
+ u(this, "waiting", null);
2539
+ u(this, "writer", {
2486
2540
  write: (e) => {
2487
2541
  if (this.waiting) {
2488
2542
  const t = this.waiting;
@@ -2491,7 +2545,7 @@ class ws {
2491
2545
  this.buffer.push(e);
2492
2546
  }
2493
2547
  });
2494
- h(this, "reader", {
2548
+ u(this, "reader", {
2495
2549
  read: () => this.read(),
2496
2550
  readAll: () => this.readAll()
2497
2551
  });
@@ -2532,11 +2586,11 @@ class ie {
2532
2586
  this.exitCode = e;
2533
2587
  }
2534
2588
  }
2535
- class ys {
2589
+ class gs {
2536
2590
  constructor(e) {
2537
- h(this, "config");
2538
- h(this, "lastExitCode", 0);
2539
- h(this, "functions", /* @__PURE__ */ new Map());
2591
+ u(this, "config");
2592
+ u(this, "lastExitCode", 0);
2593
+ u(this, "functions", /* @__PURE__ */ new Map());
2540
2594
  this.config = e;
2541
2595
  }
2542
2596
  getLastExitCode() {
@@ -2592,11 +2646,11 @@ class ys {
2592
2646
  const a = o > 0 ? s[o - 1].reader : void 0;
2593
2647
  let c;
2594
2648
  if (o < e.length - 1) {
2595
- const m = new ws();
2596
- s.push(m), c = m.writer;
2649
+ const p = new ps();
2650
+ s.push(p), c = p.writer;
2597
2651
  }
2598
- const l = e[o], f = o === 0 ? t : void 0, u = this.executeCommand(l, a, c, f).then((m) => (o < e.length - 1 && s[o].close(), m));
2599
- i.push(u);
2652
+ const l = e[o], f = o === 0 ? t : void 0, h = this.executeCommand(l, a, c, f).then((p) => (o < e.length - 1 && s[o].close(), p));
2653
+ i.push(h);
2600
2654
  }
2601
2655
  const n = await Promise.all(i);
2602
2656
  return n[n.length - 1];
@@ -2716,7 +2770,7 @@ class ys {
2716
2770
  return s;
2717
2771
  }
2718
2772
  async executeSimpleCommand(e, t, s, i) {
2719
- var A, P;
2773
+ var _, L;
2720
2774
  const n = this.createExpandContext(), o = await Le(e.words, n);
2721
2775
  if (o.length === 0 && e.assignments.length > 0) {
2722
2776
  for (const S of e.assignments) {
@@ -2740,31 +2794,31 @@ class ys {
2740
2794
  const w = await J(S.value, n);
2741
2795
  f[S.name] = this.config.env[S.name], this.config.env[S.name] = w;
2742
2796
  }
2743
- let u = s ?? this.config.defaultStdout ?? {
2797
+ let h = s ?? this.config.defaultStdout ?? {
2744
2798
  write: (S) => this.config.writeToTerminal(S)
2745
- }, m = this.config.defaultStderr ?? {
2799
+ }, p = this.config.defaultStderr ?? {
2746
2800
  write: (S) => this.config.writeToTerminal(S)
2747
2801
  }, y = t;
2748
2802
  for (const S of e.redirections) {
2749
2803
  const w = await J(S.target, n), $ = I(this.config.getCwd(), w);
2750
2804
  switch (S.operator) {
2751
2805
  case ">":
2752
- this.config.vfs.writeFile($, ""), u = this.createFileWriter($);
2806
+ this.config.vfs.writeFile($, ""), h = this.createFileWriter($);
2753
2807
  break;
2754
2808
  case ">>":
2755
- this.config.vfs.exists($) || this.config.vfs.writeFile($, ""), u = this.createFileAppender($);
2809
+ this.config.vfs.exists($) || this.config.vfs.writeFile($, ""), h = this.createFileAppender($);
2756
2810
  break;
2757
2811
  case "<":
2758
2812
  y = this.createFileReader($);
2759
2813
  break;
2760
2814
  case "2>":
2761
- this.config.vfs.writeFile($, ""), m = this.createFileWriter($);
2815
+ this.config.vfs.writeFile($, ""), p = this.createFileWriter($);
2762
2816
  break;
2763
2817
  case "2>>":
2764
- this.config.vfs.exists($) || this.config.vfs.writeFile($, ""), m = this.createFileAppender($);
2818
+ this.config.vfs.exists($) || this.config.vfs.writeFile($, ""), p = this.createFileAppender($);
2765
2819
  break;
2766
2820
  case "&>":
2767
- this.config.vfs.writeFile($, ""), u = this.createFileWriter($), m = u;
2821
+ this.config.vfs.writeFile($, ""), h = this.createFileWriter($), p = h;
2768
2822
  break;
2769
2823
  }
2770
2824
  }
@@ -2789,27 +2843,27 @@ class ys {
2789
2843
  else {
2790
2844
  const w = this.config.builtins.get(a);
2791
2845
  if (w)
2792
- E = await w(c, u, m, y);
2846
+ E = await w(c, h, p, y);
2793
2847
  else {
2794
2848
  const $ = await this.config.registry.resolve(a);
2795
2849
  if (!$)
2796
2850
  this.config.writeToTerminal(`${a}: command not found
2797
2851
  `), E = 127;
2798
2852
  else {
2799
- const x = ((P = (A = this.config).getAbortSignal) == null ? void 0 : P.call(A)) ?? new AbortController().signal, _ = {
2853
+ const x = ((L = (_ = this.config).getAbortSignal) == null ? void 0 : L.call(_)) ?? new AbortController().signal, R = {
2800
2854
  args: c,
2801
2855
  env: { ...this.config.env },
2802
2856
  cwd: this.config.getCwd(),
2803
2857
  vfs: this.config.vfs,
2804
- stdout: u,
2805
- stderr: m,
2858
+ stdout: h,
2859
+ stderr: p,
2806
2860
  signal: x,
2807
2861
  stdin: y
2808
2862
  };
2809
2863
  try {
2810
- E = await $(_);
2811
- } catch (L) {
2812
- L instanceof Error && L.name === "AbortError" ? E = 130 : (m.write(`${a}: ${L instanceof Error ? L.message : String(L)}
2864
+ E = await $(R);
2865
+ } catch (P) {
2866
+ P instanceof Error && P.name === "AbortError" ? E = 130 : (p.write(`${a}: ${P instanceof Error ? P.message : String(P)}
2813
2867
  `), E = 1);
2814
2868
  }
2815
2869
  }
@@ -2889,11 +2943,11 @@ class ys {
2889
2943
  };
2890
2944
  }
2891
2945
  }
2892
- const Te = "/home/user/.bash_history", Ae = 1e3;
2893
- class vs {
2946
+ const Te = "/home/user/.bash_history", _e = 1e3;
2947
+ class ws {
2894
2948
  constructor(e) {
2895
- h(this, "entries", []);
2896
- h(this, "vfs");
2949
+ u(this, "entries", []);
2950
+ u(this, "vfs");
2897
2951
  this.vfs = e;
2898
2952
  }
2899
2953
  load() {
@@ -2915,7 +2969,7 @@ class vs {
2915
2969
  }
2916
2970
  add(e) {
2917
2971
  const t = e.trim();
2918
- t && (this.entries.length > 0 && this.entries[this.entries.length - 1] === t || (this.entries.push(t), this.entries.length > Ae && (this.entries = this.entries.slice(-Ae)), this.save()));
2972
+ t && (this.entries.length > 0 && this.entries[this.entries.length - 1] === t || (this.entries.push(t), this.entries.length > _e && (this.entries = this.entries.slice(-_e)), this.save()));
2919
2973
  }
2920
2974
  /**
2921
2975
  * Expand history references:
@@ -2959,10 +3013,10 @@ class vs {
2959
3013
  return this.entries.length;
2960
3014
  }
2961
3015
  }
2962
- class bs {
3016
+ class ys {
2963
3017
  constructor() {
2964
- h(this, "jobs", /* @__PURE__ */ new Map());
2965
- h(this, "nextId", 1);
3018
+ u(this, "jobs", /* @__PURE__ */ new Map());
3019
+ u(this, "nextId", 1);
2966
3020
  }
2967
3021
  add(e, t, s) {
2968
3022
  const i = this.nextId++, n = {
@@ -3000,25 +3054,25 @@ class bs {
3000
3054
  return e;
3001
3055
  }
3002
3056
  }
3003
- function $s(r) {
3004
- const { line: e, cursorPos: t } = r, s = e.slice(0, t), { word: i, start: n } = xs(s), o = Ss(s, i);
3057
+ function vs(r) {
3058
+ const { line: e, cursorPos: t } = r, s = e.slice(0, t), { word: i, start: n } = bs(s), o = $s(s, i);
3005
3059
  let a;
3006
3060
  switch (o) {
3007
3061
  case "command":
3008
- a = ks(i, r);
3062
+ a = xs(i, r);
3009
3063
  break;
3010
3064
  case "directory":
3011
- a = Cs(i, r);
3065
+ a = ks(i, r);
3012
3066
  break;
3013
3067
  case "variable":
3014
- a = Ls(i.slice(1), r);
3068
+ a = Es(i.slice(1), r);
3015
3069
  break;
3016
3070
  case "file":
3017
3071
  default:
3018
- a = Es(i, r);
3072
+ a = Ss(i, r);
3019
3073
  break;
3020
3074
  }
3021
- const c = Ps(a);
3075
+ const c = Cs(a);
3022
3076
  return {
3023
3077
  replacementStart: n,
3024
3078
  replacementEnd: t,
@@ -3026,14 +3080,14 @@ function $s(r) {
3026
3080
  commonPrefix: c
3027
3081
  };
3028
3082
  }
3029
- function xs(r) {
3083
+ function bs(r) {
3030
3084
  let e = r.length - 1;
3031
3085
  for (; e >= 0 && r[e] !== " " && r[e] !== " " && r[e] !== "|" && r[e] !== ";" && r[e] !== "&" && r[e] !== ">" && r[e] !== "<"; )
3032
3086
  e--;
3033
3087
  const t = e + 1;
3034
3088
  return { word: r.slice(t), start: t };
3035
3089
  }
3036
- function Ss(r, e) {
3090
+ function $s(r, e) {
3037
3091
  if (e.startsWith("$"))
3038
3092
  return "variable";
3039
3093
  const t = r.slice(0, r.length - e.length).trimEnd();
@@ -3042,23 +3096,23 @@ function Ss(r, e) {
3042
3096
  if (t === "" || t.endsWith("|") || t.endsWith("&&") || t.endsWith("||") || t.endsWith(";"))
3043
3097
  return "command";
3044
3098
  const s = t.split(/\s+/).filter(Boolean);
3045
- return s.length > 0 && s[s.length - 1] === "cd" && _e(t) === "cd" || _e(t) === "cd" ? "directory" : "file";
3099
+ return s.length > 0 && s[s.length - 1] === "cd" && Re(t) === "cd" || Re(t) === "cd" ? "directory" : "file";
3046
3100
  }
3047
- function _e(r) {
3101
+ function Re(r) {
3048
3102
  const e = r.split(/\|{1,2}|&&|;/), s = e[e.length - 1].trim().split(/\s+/).filter(Boolean);
3049
3103
  return s.length > 0 ? s[0] : null;
3050
3104
  }
3051
- function ks(r, e) {
3105
+ function xs(r, e) {
3052
3106
  const t = [...e.builtinNames, ...e.registry.list()], s = [...new Set(t)].sort();
3053
3107
  return r ? s.filter((i) => i.startsWith(r)) : s;
3054
3108
  }
3055
- function Es(r, e) {
3056
- return Ze(r, e, !1);
3109
+ function Ss(r, e) {
3110
+ return Ge(r, e, !1);
3057
3111
  }
3058
- function Cs(r, e) {
3059
- return Ze(r, e, !0);
3112
+ function ks(r, e) {
3113
+ return Ge(r, e, !0);
3060
3114
  }
3061
- function Ze(r, e, t) {
3115
+ function Ge(r, e, t) {
3062
3116
  let s = r, i = "";
3063
3117
  r.startsWith("~/") ? (s = (e.env.HOME ?? "/home/user") + r.slice(1), i = "~/") : r === "~" && (s = e.env.HOME ?? "/home/user", i = "~");
3064
3118
  let n, o;
@@ -3070,17 +3124,17 @@ function Ze(r, e, t) {
3070
3124
  try {
3071
3125
  let c = e.vfs.readdir(n).filter((l) => l.name.startsWith(o) && (o.startsWith(".") || !l.name.startsWith(".")));
3072
3126
  return t && (c = c.filter((l) => l.type === "directory")), c.map((l) => {
3073
- const f = r.includes("/") ? r.slice(0, r.lastIndexOf("/") + 1) : "", u = l.type === "directory" ? "/" : "";
3074
- return i && f.startsWith(i), f + l.name + u;
3127
+ const f = r.includes("/") ? r.slice(0, r.lastIndexOf("/") + 1) : "", h = l.type === "directory" ? "/" : "";
3128
+ return i && f.startsWith(i), f + l.name + h;
3075
3129
  }).sort();
3076
3130
  } catch {
3077
3131
  return [];
3078
3132
  }
3079
3133
  }
3080
- function Ls(r, e) {
3134
+ function Es(r, e) {
3081
3135
  return Object.keys(e.env).filter((t) => t.startsWith(r)).map((t) => "$" + t).sort();
3082
3136
  }
3083
- function Ps(r) {
3137
+ function Cs(r) {
3084
3138
  if (r.length === 0) return "";
3085
3139
  if (r.length === 1) return r[0];
3086
3140
  let e = r[0];
@@ -3092,11 +3146,11 @@ function Ps(r) {
3092
3146
  }
3093
3147
  return e;
3094
3148
  }
3095
- function Re(r, e, t) {
3149
+ function Ae(r, e, t) {
3096
3150
  if (r.length > 0 && r[r.length - 1] === "]" && (r = r.slice(0, -1)), r.length === 0)
3097
3151
  return 1;
3098
3152
  try {
3099
- const s = Je(r, 0, e);
3153
+ const s = Ze(r, 0, e);
3100
3154
  return s.pos !== r.length ? (t.write(`test: too many arguments
3101
3155
  `), 2) : s.value ? 0 : 1;
3102
3156
  } catch (s) {
@@ -3104,10 +3158,10 @@ function Re(r, e, t) {
3104
3158
  `), 2;
3105
3159
  }
3106
3160
  }
3107
- function Je(r, e, t) {
3108
- return Ts(r, e, t);
3161
+ function Ze(r, e, t) {
3162
+ return Ls(r, e, t);
3109
3163
  }
3110
- function Ts(r, e, t) {
3164
+ function Ls(r, e, t) {
3111
3165
  let s = Fe(r, e, t);
3112
3166
  for (; s.pos < r.length && r[s.pos] === "-o"; ) {
3113
3167
  const i = Fe(r, s.pos + 1, t);
@@ -3132,7 +3186,7 @@ function ce(r, e, t) {
3132
3186
  return { value: !i.value, pos: i.pos };
3133
3187
  }
3134
3188
  if (s === "(") {
3135
- const i = Je(r, e + 1, t);
3189
+ const i = Ze(r, e + 1, t);
3136
3190
  if (i.pos >= r.length || r[i.pos] !== ")")
3137
3191
  throw new Error("missing )");
3138
3192
  return { value: i.value, pos: i.pos + 1 };
@@ -3142,7 +3196,7 @@ function ce(r, e, t) {
3142
3196
  if (s === "-n" && e + 1 < r.length)
3143
3197
  return { value: r[e + 1].length > 0, pos: e + 2 };
3144
3198
  if (s.startsWith("-") && s.length === 2 && e + 1 < r.length) {
3145
- const i = s[1], n = r[e + 1], o = As(i, n, t);
3199
+ const i = s[1], n = r[e + 1], o = Ps(i, n, t);
3146
3200
  if (o !== null)
3147
3201
  return { value: o, pos: e + 2 };
3148
3202
  }
@@ -3173,7 +3227,7 @@ function ce(r, e, t) {
3173
3227
  }
3174
3228
  return { value: s.length > 0, pos: e + 1 };
3175
3229
  }
3176
- function As(r, e, t) {
3230
+ function Ps(r, e, t) {
3177
3231
  switch (r) {
3178
3232
  case "e":
3179
3233
  return t.exists(e);
@@ -3216,10 +3270,10 @@ function N(r) {
3216
3270
  }
3217
3271
  class Ie {
3218
3272
  constructor() {
3219
- h(this, "buffer", []);
3220
- h(this, "closed", !1);
3221
- h(this, "resolver", null);
3222
- h(this, "_waiting", !1);
3273
+ u(this, "buffer", []);
3274
+ u(this, "closed", !1);
3275
+ u(this, "resolver", null);
3276
+ u(this, "_waiting", !1);
3223
3277
  }
3224
3278
  /** True when a command has called read() and is waiting for input. */
3225
3279
  get isWaiting() {
@@ -3258,37 +3312,37 @@ class Ie {
3258
3312
  return e.join("");
3259
3313
  }
3260
3314
  }
3261
- class _s {
3315
+ class Ts {
3262
3316
  constructor(e, t, s, i) {
3263
- h(this, "terminal");
3264
- h(this, "vfs");
3265
- h(this, "registry");
3266
- h(this, "cwd");
3267
- h(this, "env");
3317
+ u(this, "terminal");
3318
+ u(this, "vfs");
3319
+ u(this, "registry");
3320
+ u(this, "cwd");
3321
+ u(this, "env");
3268
3322
  // Alias map
3269
- h(this, "aliases", /* @__PURE__ */ new Map());
3323
+ u(this, "aliases", /* @__PURE__ */ new Map());
3270
3324
  // Line editing state
3271
- h(this, "lineBuffer", "");
3272
- h(this, "cursorPos", 0);
3325
+ u(this, "lineBuffer", "");
3326
+ u(this, "cursorPos", 0);
3273
3327
  // History (legacy array kept for backward compat with tests)
3274
- h(this, "history", []);
3275
- h(this, "historyIndex", -1);
3276
- h(this, "savedLine", "");
3328
+ u(this, "history", []);
3329
+ u(this, "historyIndex", -1);
3330
+ u(this, "savedLine", "");
3277
3331
  // Running command
3278
- h(this, "running", !1);
3279
- h(this, "abortController", null);
3280
- h(this, "terminalStdin", null);
3281
- h(this, "stdinLineBuffer", "");
3282
- h(this, "stdinCursorPos", 0);
3332
+ u(this, "running", !1);
3333
+ u(this, "abortController", null);
3334
+ u(this, "terminalStdin", null);
3335
+ u(this, "stdinLineBuffer", "");
3336
+ u(this, "stdinCursorPos", 0);
3283
3337
  // New Sprint 2 components
3284
- h(this, "interpreter");
3285
- h(this, "interpreterConfig");
3286
- h(this, "historyManager");
3287
- h(this, "jobTable");
3288
- h(this, "builtins");
3338
+ u(this, "interpreter");
3339
+ u(this, "interpreterConfig");
3340
+ u(this, "historyManager");
3341
+ u(this, "jobTable");
3342
+ u(this, "builtins");
3289
3343
  // Tab completion state
3290
- h(this, "tabCount", 0);
3291
- this.terminal = e, this.vfs = t, this.registry = s, this.cwd = i.HOME ?? "/home/user", this.env = { ...i }, this.builtins = /* @__PURE__ */ new Map(), this.registerBuiltins(), this.jobTable = new bs(), this.historyManager = new vs(t), this.historyManager.load(), this.interpreterConfig = {
3344
+ u(this, "tabCount", 0);
3345
+ this.terminal = e, this.vfs = t, this.registry = s, this.cwd = i.HOME ?? "/home/user", this.env = { ...i }, this.builtins = /* @__PURE__ */ new Map(), this.registerBuiltins(), this.jobTable = new ys(), this.historyManager = new ws(t), this.historyManager.load(), this.interpreterConfig = {
3292
3346
  env: this.env,
3293
3347
  getCwd: () => this.cwd,
3294
3348
  setCwd: (n) => {
@@ -3304,10 +3358,10 @@ class _s {
3304
3358
  var n;
3305
3359
  return ((n = this.abortController) == null ? void 0 : n.signal) ?? new AbortController().signal;
3306
3360
  }
3307
- }, this.interpreter = new ys(this.interpreterConfig);
3361
+ }, this.interpreter = new gs(this.interpreterConfig);
3308
3362
  }
3309
3363
  registerBuiltins() {
3310
- this.builtins.set("cd", (e, t, s) => this.builtinCd(e, s)), this.builtins.set("pwd", (e, t) => this.builtinPwd(t)), this.builtins.set("echo", (e, t) => this.builtinEcho(e, t)), this.builtins.set("clear", () => this.builtinClear()), this.builtins.set("export", (e) => this.builtinExport(e)), this.builtins.set("exit", (e, t) => this.builtinExit(t)), this.builtins.set("true", () => Promise.resolve(0)), this.builtins.set("false", () => Promise.resolve(1)), this.builtins.set("jobs", (e, t) => this.builtinJobs(t)), this.builtins.set("fg", (e, t, s) => this.builtinFg(e, t, s)), this.builtins.set("bg", (e, t, s) => this.builtinBg(e, t, s)), this.builtins.set("history", (e, t) => this.builtinHistory(t)), this.builtins.set("source", (e, t, s) => this.builtinSource(e, s)), this.builtins.set(".", (e, t, s) => this.builtinSource(e, s)), this.builtins.set("alias", (e, t) => this.builtinAlias(e, t)), this.builtins.set("unalias", (e, t, s) => this.builtinUnalias(e, s)), this.builtins.set("test", (e, t, s) => Promise.resolve(Re(e, this.vfs, s))), this.builtins.set("[", (e, t, s) => Promise.resolve(Re(e, this.vfs, s)));
3364
+ this.builtins.set("cd", (e, t, s) => this.builtinCd(e, s)), this.builtins.set("pwd", (e, t) => this.builtinPwd(t)), this.builtins.set("echo", (e, t) => this.builtinEcho(e, t)), this.builtins.set("clear", () => this.builtinClear()), this.builtins.set("export", (e) => this.builtinExport(e)), this.builtins.set("exit", (e, t) => this.builtinExit(t)), this.builtins.set("true", () => Promise.resolve(0)), this.builtins.set("false", () => Promise.resolve(1)), this.builtins.set("jobs", (e, t) => this.builtinJobs(t)), this.builtins.set("fg", (e, t, s) => this.builtinFg(e, t, s)), this.builtins.set("bg", (e, t, s) => this.builtinBg(e, t, s)), this.builtins.set("history", (e, t) => this.builtinHistory(t)), this.builtins.set("source", (e, t, s) => this.builtinSource(e, s)), this.builtins.set(".", (e, t, s) => this.builtinSource(e, s)), this.builtins.set("alias", (e, t) => this.builtinAlias(e, t)), this.builtins.set("unalias", (e, t, s) => this.builtinUnalias(e, s)), this.builtins.set("test", (e, t, s) => Promise.resolve(Ae(e, this.vfs, s))), this.builtins.set("[", (e, t, s) => Promise.resolve(Ae(e, this.vfs, s)));
3311
3365
  }
3312
3366
  getJobTable() {
3313
3367
  return this.jobTable;
@@ -3334,27 +3388,27 @@ class _s {
3334
3388
  async execute(e, t) {
3335
3389
  let s = "", i = "";
3336
3390
  const n = {
3337
- write: (m) => {
3391
+ write: (p) => {
3338
3392
  var y;
3339
- s += m, (y = t == null ? void 0 : t.onStdout) == null || y.call(t, m);
3393
+ s += p, (y = t == null ? void 0 : t.onStdout) == null || y.call(t, p);
3340
3394
  }
3341
3395
  }, o = {
3342
- write: (m) => {
3396
+ write: (p) => {
3343
3397
  var y;
3344
- i += m, (y = t == null ? void 0 : t.onStderr) == null || y.call(t, m);
3398
+ i += p, (y = t == null ? void 0 : t.onStderr) == null || y.call(t, p);
3345
3399
  }
3346
3400
  }, a = this.interpreterConfig.defaultStdout, c = this.interpreterConfig.defaultStderr, l = this.interpreterConfig.writeToTerminal, f = t != null && t.cwd ? this.cwd : void 0;
3347
- this.interpreterConfig.defaultStdout = n, this.interpreterConfig.defaultStderr = o, this.interpreterConfig.writeToTerminal = (m) => {
3401
+ this.interpreterConfig.defaultStdout = n, this.interpreterConfig.defaultStderr = o, this.interpreterConfig.writeToTerminal = (p) => {
3348
3402
  var y;
3349
- i += m, (y = t == null ? void 0 : t.onStderr) == null || y.call(t, m);
3403
+ i += p, (y = t == null ? void 0 : t.onStderr) == null || y.call(t, p);
3350
3404
  }, t != null && t.cwd && (this.cwd = t.cwd), t != null && t.env && Object.assign(this.env, t.env);
3351
- let u;
3352
- (t == null ? void 0 : t.stdin) !== void 0 && (u = new Ie(), u.feed(t.stdin), u.close());
3405
+ let h;
3406
+ (t == null ? void 0 : t.stdin) !== void 0 && (h = new Ie(), h.feed(t.stdin), h.close());
3353
3407
  try {
3354
- const m = await this.interpreter.executeLine(e, u);
3355
- return { stdout: s, stderr: i, exitCode: m };
3356
- } catch (m) {
3357
- const y = m instanceof Error ? m.message : String(m);
3408
+ const p = await this.interpreter.executeLine(e, h);
3409
+ return { stdout: s, stderr: i, exitCode: p };
3410
+ } catch (p) {
3411
+ const y = p instanceof Error ? p.message : String(p);
3358
3412
  return i += y + `
3359
3413
  `, { stdout: s, stderr: i, exitCode: 1 };
3360
3414
  } finally {
@@ -3466,7 +3520,7 @@ class _s {
3466
3520
  vfs: this.vfs,
3467
3521
  registry: this.registry,
3468
3522
  builtinNames: [...this.builtins.keys()]
3469
- }, t = $s(e), s = this.lineBuffer.slice(t.replacementStart, t.replacementEnd);
3523
+ }, t = vs(e), s = this.lineBuffer.slice(t.replacementStart, t.replacementEnd);
3470
3524
  if (t.completions.length === 0) {
3471
3525
  this.terminal.write("\x07");
3472
3526
  return;
@@ -3759,10 +3813,10 @@ class _s {
3759
3813
  return s.length > 0 && t.push(s), t;
3760
3814
  }
3761
3815
  }
3762
- class Rs {
3816
+ class _s {
3763
3817
  constructor() {
3764
- h(this, "commands", /* @__PURE__ */ new Map());
3765
- h(this, "lazy", /* @__PURE__ */ new Map());
3818
+ u(this, "commands", /* @__PURE__ */ new Map());
3819
+ u(this, "lazy", /* @__PURE__ */ new Map());
3766
3820
  }
3767
3821
  register(e, t) {
3768
3822
  this.commands.set(e, t);
@@ -3783,12 +3837,12 @@ class Rs {
3783
3837
  return [.../* @__PURE__ */ new Set([...this.commands.keys(), ...this.lazy.keys()])].sort();
3784
3838
  }
3785
3839
  }
3786
- function Fs() {
3787
- const r = new Rs();
3788
- return r.registerLazy("ls", () => import("./ls-CSeazevv.js")), r.registerLazy("cat", () => import("./cat-Crmqa4-2.js")), r.registerLazy("mkdir", () => import("./mkdir-B7p8krsP.js")), r.registerLazy("rm", () => import("./rm-BXSq9iqP.js")), r.registerLazy("cp", () => import("./cp-CpjwiLUF.js")), r.registerLazy("mv", () => import("./mv-DRVvz9oK.js")), r.registerLazy("touch", () => import("./touch-CdAHKfLv.js")), r.registerLazy("find", () => import("./find-DA-rpvsC.js")), r.registerLazy("tree", () => import("./tree-BiWLXiUu.js")), r.registerLazy("stat", () => import("./stat-C0qs7xMV.js")), r.registerLazy("ln", () => import("./ln-Bf3f3jVA.js")), r.registerLazy("du", () => import("./du-B0shJpEL.js")), r.registerLazy("df", () => import("./df-CeZb4WOr.js")), r.registerLazy("chmod", () => import("./chmod-CcGyvoCX.js")), r.registerLazy("file", () => import("./file-C2epVYvH.js")), r.registerLazy("grep", () => import("./grep-Bynq2w2E.js")), r.registerLazy("head", () => import("./head-DZJVLF1k.js")), r.registerLazy("tail", () => import("./tail-CYBTYnn3.js")), r.registerLazy("wc", () => import("./wc-CpE5K4ZI.js")), r.registerLazy("sort", () => import("./sort-B7K83hAD.js")), r.registerLazy("uniq", () => import("./uniq-BZMOwoCc.js")), r.registerLazy("cut", () => import("./cut-GfN8py4j.js")), r.registerLazy("tr", () => import("./tr-DsCiwSIu.js")), r.registerLazy("sed", () => import("./sed-BRxd2DlZ.js")), r.registerLazy("awk", () => import("./awk-rMPdpM91.js")), r.registerLazy("tee", () => import("./tee-B8bXFHbI.js")), r.registerLazy("xargs", () => import("./xargs-DfbCRFFd.js")), r.registerLazy("yes", () => import("./yes-DXEyHHD2.js")), r.registerLazy("printf", () => import("./printf-Cc2o7KZx.js")), r.registerLazy("env", () => import("./env-DXzvDKsN.js")), r.registerLazy("uname", () => import("./uname-BCn8HlJD.js")), r.registerLazy("date", () => import("./date-C8NB8v8G.js")), r.registerLazy("sleep", () => import("./sleep-B4C3fZiR.js")), r.registerLazy("uptime", () => import("./uptime-CgBJegqU.js")), r.registerLazy("whoami", () => import("./whoami-B1237V5e.js")), r.registerLazy("hostname", () => import("./hostname-BxU2S3nT.js")), r.registerLazy("free", () => import("./free-DAxE4b2U.js")), r.registerLazy("which", () => import("./which-D3u0cwyh.js")), r.registerLazy("curl", () => Promise.resolve().then(() => kr)), r.registerLazy("wget", () => import("./wget-DIPI0-I3.js")), r.registerLazy("ping", () => import("./ping-DtVEwwda.js")), r.registerLazy("dig", () => import("./dig-BEJ8Ky96.js")), r.registerLazy("tar", () => import("./tar-mMS7gfb-.js")), r.registerLazy("gzip", () => import("./gzip-CkXnPp5J.js")), r.registerLazy("gunzip", () => import("./gunzip-B9b1Vph1.js")), r.registerLazy("zip", () => import("./zip-B_gQ6LXC.js")), r.registerLazy("unzip", () => import("./unzip-DP4I991d.js")), r.registerLazy("node", () => Promise.resolve().then(() => ge)), r.registerLazy("rmdir", () => import("./rmdir-CWgZ6q8D.js")), r.registerLazy("realpath", () => import("./realpath-C-kisl-F.js")), r.registerLazy("basename", () => import("./basename-C33A_Zse.js")), r.registerLazy("dirname", () => import("./dirname-C5L53RA2.js")), r.registerLazy("mktemp", () => import("./mktemp-88Nhvd7h.js")), r.registerLazy("chown", () => import("./chown-CErsnGQX.js")), r.registerLazy("diff", () => import("./diff-2wbVWmCT.js")), r.registerLazy("nl", () => import("./nl-G2vK3rR3.js")), r.registerLazy("rev", () => import("./rev-9puwegeh.js")), r.registerLazy("cal", () => import("./cal-DPULSAhj.js")), r.registerLazy("bc", () => import("./bc-BYiKVTNg.js")), r.registerLazy("man", () => import("./man-CJ5pI0_W.js")), r;
3840
+ function Rs() {
3841
+ const r = new _s();
3842
+ return r.registerLazy("ls", () => import("./ls-BiT10kLm.js")), r.registerLazy("cat", () => import("./cat-B2exoWlk.js")), r.registerLazy("mkdir", () => import("./mkdir-DgzJ2JLj.js")), r.registerLazy("rm", () => import("./rm-DA2w3xTR.js")), r.registerLazy("cp", () => import("./cp-C8mNek36.js")), r.registerLazy("mv", () => import("./mv-Kp6DjQ8n.js")), r.registerLazy("touch", () => import("./touch-k2NomRzL.js")), r.registerLazy("find", () => import("./find-CRUAXbhO.js")), r.registerLazy("tree", () => import("./tree-B_j2_PsZ.js")), r.registerLazy("stat", () => import("./stat-D0i1gTKB.js")), r.registerLazy("ln", () => import("./ln-Bf3f3jVA.js")), r.registerLazy("du", () => import("./du-D25egSeK.js")), r.registerLazy("df", () => import("./df-CeZb4WOr.js")), r.registerLazy("chmod", () => import("./chmod-CQS63aP7.js")), r.registerLazy("file", () => import("./file-BPs1dqg5.js")), r.registerLazy("grep", () => import("./grep-B9pTCSNY.js")), r.registerLazy("head", () => import("./head-DzP_T5Wx.js")), r.registerLazy("tail", () => import("./tail-tcIJLQnB.js")), r.registerLazy("wc", () => import("./wc-Jp7nOops.js")), r.registerLazy("sort", () => import("./sort-CSzSGTdB.js")), r.registerLazy("uniq", () => import("./uniq-hzJnHQOm.js")), r.registerLazy("cut", () => import("./cut-BZez9bS1.js")), r.registerLazy("tr", () => import("./tr-DsCiwSIu.js")), r.registerLazy("sed", () => import("./sed-ClWZ06zX.js")), r.registerLazy("awk", () => import("./awk-CchAsBzt.js")), r.registerLazy("tee", () => import("./tee-RqoZ3qG-.js")), r.registerLazy("xargs", () => import("./xargs-DfbCRFFd.js")), r.registerLazy("yes", () => import("./yes-DXEyHHD2.js")), r.registerLazy("printf", () => import("./printf-Cc2o7KZx.js")), r.registerLazy("env", () => import("./env-DXzvDKsN.js")), r.registerLazy("uname", () => import("./uname-BCn8HlJD.js")), r.registerLazy("date", () => import("./date-C8NB8v8G.js")), r.registerLazy("sleep", () => import("./sleep-B4C3fZiR.js")), r.registerLazy("uptime", () => import("./uptime-CgBJegqU.js")), r.registerLazy("whoami", () => import("./whoami-B1237V5e.js")), r.registerLazy("hostname", () => import("./hostname-BxU2S3nT.js")), r.registerLazy("free", () => import("./free-DAxE4b2U.js")), r.registerLazy("which", () => import("./which-D3u0cwyh.js")), r.registerLazy("curl", () => Promise.resolve().then(() => dr)), r.registerLazy("wget", () => import("./wget-2NAABIHc.js")), r.registerLazy("ping", () => import("./ping-DtVEwwda.js")), r.registerLazy("dig", () => import("./dig-BEJ8Ky96.js")), r.registerLazy("tar", () => import("./tar-DkyzTzmT.js")), r.registerLazy("gzip", () => import("./gzip-DgE-9PzE.js")), r.registerLazy("gunzip", () => import("./gunzip-BYlJhPf7.js")), r.registerLazy("zip", () => import("./zip--0ncHv0q.js")), r.registerLazy("unzip", () => import("./unzip-FwYCTDEZ.js")), r.registerLazy("node", () => Promise.resolve().then(() => ge)), r.registerLazy("rmdir", () => import("./rmdir-BiGbNDOT.js")), r.registerLazy("realpath", () => import("./realpath-BOeYN6nD.js")), r.registerLazy("basename", () => import("./basename-C2v8jn7p.js")), r.registerLazy("dirname", () => import("./dirname-BY_Gu5i2.js")), r.registerLazy("mktemp", () => import("./mktemp-Sh5DWxvc.js")), r.registerLazy("chown", () => import("./chown-rgGwZwu9.js")), r.registerLazy("diff", () => import("./diff-tWPvmikU.js")), r.registerLazy("nl", () => import("./nl-DBLFdpfC.js")), r.registerLazy("rev", () => import("./rev-CWRUIXWp.js")), r.registerLazy("cal", () => import("./cal-DPULSAhj.js")), r.registerLazy("bc", () => import("./bc-BYiKVTNg.js")), r.registerLazy("man", () => import("./man-CJ5pI0_W.js")), r;
3789
3843
  }
3790
- const Is = "/usr/share/pkg", ne = "/usr/share/pkg/node_modules", Ne = "/usr/share/pkg/packages.json";
3791
- class Ns {
3844
+ const As = "/usr/share/pkg", ne = "/usr/share/pkg/node_modules", Ne = "/usr/share/pkg/packages.json";
3845
+ class Fs {
3792
3846
  constructor(e) {
3793
3847
  this.vfs = e;
3794
3848
  }
@@ -3806,7 +3860,7 @@ class Ns {
3806
3860
  }
3807
3861
  ensureDirs() {
3808
3862
  try {
3809
- this.vfs.mkdir(Is, { recursive: !0 });
3863
+ this.vfs.mkdir(As, { recursive: !0 });
3810
3864
  } catch {
3811
3865
  }
3812
3866
  try {
@@ -3861,9 +3915,9 @@ class Ns {
3861
3915
  return this.readMetadata().packages[e] || null;
3862
3916
  }
3863
3917
  }
3864
- function Bs(r) {
3918
+ function Is(r) {
3865
3919
  return async (t) => {
3866
- const s = t.args[0], i = new Ns(t.vfs);
3920
+ const s = t.args[0], i = new Fs(t.vfs);
3867
3921
  if (!s || s === "--help")
3868
3922
  return t.stdout.write(`Usage: pkg <command> [args]
3869
3923
 
@@ -3885,7 +3939,7 @@ function Bs(r) {
3885
3939
  `);
3886
3940
  const a = await i.install(n, o);
3887
3941
  t.stdout.write(`Installed ${a.name} (${a.size} bytes)
3888
- `), zs(r, t, a.name), t.stdout.write(`Command '${a.name}' is now available
3942
+ `), Ns(r, t, a.name), t.stdout.write(`Command '${a.name}' is now available
3889
3943
  `);
3890
3944
  } catch (a) {
3891
3945
  return t.stderr.write(`pkg: install failed: ${a instanceof Error ? a.message : String(a)}
@@ -3938,7 +3992,7 @@ function Bs(r) {
3938
3992
  }
3939
3993
  };
3940
3994
  }
3941
- function zs(r, e, t) {
3995
+ function Ns(r, e, t) {
3942
3996
  const s = `/usr/share/pkg/node_modules/${t}/index.js`;
3943
3997
  r.registerLazy(
3944
3998
  t,
@@ -3950,7 +4004,7 @@ function zs(r, e, t) {
3950
4004
  }))
3951
4005
  );
3952
4006
  }
3953
- function js(r) {
4007
+ function Bs(r) {
3954
4008
  return async (e) => {
3955
4009
  e.stdout.write(` PID TTY TIME CMD
3956
4010
  `), e.stdout.write(` 1 tty1 00:00:00 sh
@@ -3966,13 +4020,13 @@ function js(r) {
3966
4020
  `), 0;
3967
4021
  };
3968
4022
  }
3969
- function Ds(r) {
4023
+ function zs(r) {
3970
4024
  return async (e) => {
3971
- const t = /* @__PURE__ */ new Date(), s = String(t.getHours()).padStart(2, "0"), i = String(t.getMinutes()).padStart(2, "0"), n = String(t.getSeconds()).padStart(2, "0"), o = typeof performance < "u" ? performance.now() : 0, a = Math.floor(o / 6e4), c = typeof navigator < "u" && navigator.hardwareConcurrency || 1, l = typeof performance < "u" ? performance.memory : void 0, f = l ? Math.round(l.jsHeapSizeLimit / (1024 * 1024)) : 256, u = l ? Math.round(l.usedJSHeapSize / (1024 * 1024)) : 16, m = f - u, y = r.list(), E = y.filter((w) => w.status === "running").length, A = y.filter((w) => w.status === "stopped").length, P = y.length + 2;
4025
+ const t = /* @__PURE__ */ new Date(), s = String(t.getHours()).padStart(2, "0"), i = String(t.getMinutes()).padStart(2, "0"), n = String(t.getSeconds()).padStart(2, "0"), o = typeof performance < "u" ? performance.now() : 0, a = Math.floor(o / 6e4), c = typeof navigator < "u" && navigator.hardwareConcurrency || 1, l = typeof performance < "u" ? performance.memory : void 0, f = l ? Math.round(l.jsHeapSizeLimit / (1024 * 1024)) : 256, h = l ? Math.round(l.usedJSHeapSize / (1024 * 1024)) : 16, p = f - h, y = r.list(), E = y.filter((w) => w.status === "running").length, _ = y.filter((w) => w.status === "stopped").length, L = y.length + 2;
3972
4026
  e.stdout.write(`top - ${s}:${i}:${n} up ${a} min, 1 user
3973
- `), e.stdout.write(`Tasks: ${String(P).padStart(3, " ")} total, ${String(E + 2).padStart(3, " ")} running, ${String(A).padStart(3, " ")} stopped
4027
+ `), e.stdout.write(`Tasks: ${String(L).padStart(3, " ")} total, ${String(E + 2).padStart(3, " ")} running, ${String(_).padStart(3, " ")} stopped
3974
4028
  `), e.stdout.write(`%Cpu(s): ${c} cores
3975
- `), e.stdout.write(`MiB Mem: ${String(f).padStart(7, " ")} total ${String(u).padStart(7, " ")} used ${String(m).padStart(7, " ")} free
4029
+ `), e.stdout.write(`MiB Mem: ${String(f).padStart(7, " ")} total ${String(h).padStart(7, " ")} used ${String(p).padStart(7, " ")} free
3976
4030
  `), e.stdout.write(`
3977
4031
  `), e.stdout.write(` PID CMD STATUS
3978
4032
  `), e.stdout.write(` 1 sh running
@@ -3987,7 +4041,7 @@ function Ds(r) {
3987
4041
  `), 0;
3988
4042
  };
3989
4043
  }
3990
- const Os = {
4044
+ const js = {
3991
4045
  HUP: 1,
3992
4046
  INT: 2,
3993
4047
  QUIT: 3,
@@ -4011,7 +4065,7 @@ const Os = {
4011
4065
  19: "STOP",
4012
4066
  18: "CONT"
4013
4067
  };
4014
- function Ms(r) {
4068
+ function Ds(r) {
4015
4069
  return async (e) => {
4016
4070
  const t = e.args;
4017
4071
  if (t.length === 0)
@@ -4029,7 +4083,7 @@ function Ms(r) {
4029
4083
  s = 1;
4030
4084
  const o = parseInt(n, 10);
4031
4085
  if (!(!isNaN(o) && Be[o])) {
4032
- if (Os[n.toUpperCase()] === void 0) return e.stderr.write(`kill: invalid signal: ${n}
4086
+ if (js[n.toUpperCase()] === void 0) return e.stderr.write(`kill: invalid signal: ${n}
4033
4087
  `), 1;
4034
4088
  }
4035
4089
  }
@@ -4071,7 +4125,7 @@ function Ms(r) {
4071
4125
  return i;
4072
4126
  };
4073
4127
  }
4074
- function Ws(r) {
4128
+ function Os(r) {
4075
4129
  return async (e) => {
4076
4130
  let t = 2, s = 0;
4077
4131
  if (e.args[0] === "-n" && e.args.length > 1) {
@@ -4090,8 +4144,8 @@ function Ws(r) {
4090
4144
 
4091
4145
  `);
4092
4146
  const l = [], f = {
4093
- write(u) {
4094
- l.push(u);
4147
+ write(h) {
4148
+ l.push(h);
4095
4149
  }
4096
4150
  };
4097
4151
  await a({
@@ -4118,7 +4172,7 @@ function Ws(r) {
4118
4172
  });
4119
4173
  };
4120
4174
  }
4121
- const qs = [
4175
+ const Ms = [
4122
4176
  "cd",
4123
4177
  "pwd",
4124
4178
  "echo",
@@ -4135,8 +4189,8 @@ const qs = [
4135
4189
  ".",
4136
4190
  "alias",
4137
4191
  "unalias"
4138
- ], Us = {
4139
- "Shell builtins": qs,
4192
+ ], Ws = {
4193
+ "Shell builtins": Ms,
4140
4194
  "File system": [
4141
4195
  "ls",
4142
4196
  "cat",
@@ -4199,13 +4253,13 @@ const qs = [
4199
4253
  Archive: ["tar", "gzip", "gunzip", "zip", "unzip"],
4200
4254
  "Node.js": ["node", "pkg"]
4201
4255
  };
4202
- function Hs(r) {
4256
+ function qs(r) {
4203
4257
  return async (e) => {
4204
4258
  e.stdout.write(`Lifo Commands
4205
4259
  `), e.stdout.write(`==================
4206
4260
 
4207
4261
  `);
4208
- for (const [t, s] of Object.entries(Us)) {
4262
+ for (const [t, s] of Object.entries(Ws)) {
4209
4263
  e.stdout.write(`${t}:
4210
4264
  `);
4211
4265
  const i = 6;
@@ -4221,233 +4275,7 @@ function Hs(r) {
4221
4275
  `), 0;
4222
4276
  };
4223
4277
  }
4224
- const Vs = "/usr/share/pkg/packages.json", Gs = "/usr/share/pkg/node_modules";
4225
- function Zs(r, e) {
4226
- let t;
4227
- try {
4228
- const s = r.readFileString(Vs);
4229
- t = JSON.parse(s);
4230
- } catch {
4231
- return;
4232
- }
4233
- for (const s of Object.keys(t.packages)) {
4234
- const i = `${Gs}/${s}/index.js`;
4235
- r.exists(i) && e.registerLazy(
4236
- s,
4237
- () => Promise.resolve().then(() => ge).then((n) => ({
4238
- default: ((o) => n.default({
4239
- ...o,
4240
- args: [i, ...o.args]
4241
- }))
4242
- }))
4243
- );
4244
- }
4245
- }
4246
- class Js {
4247
- constructor(e, t) {
4248
- this.vfs = e, this.getCwd = t;
4249
- }
4250
- resolvePath(e) {
4251
- return I(this.getCwd(), e);
4252
- }
4253
- readFile(e, t) {
4254
- const s = this.resolvePath(e);
4255
- return t === null ? Promise.resolve(this.vfs.readFile(s)) : Promise.resolve(this.vfs.readFileString(s));
4256
- }
4257
- async writeFile(e, t) {
4258
- const s = this.resolvePath(e);
4259
- this.vfs.writeFile(s, t);
4260
- }
4261
- async readdir(e) {
4262
- const t = this.resolvePath(e);
4263
- return this.vfs.readdir(t);
4264
- }
4265
- async stat(e) {
4266
- const t = this.resolvePath(e), s = this.vfs.stat(t);
4267
- return { type: s.type, size: s.size, mtime: s.mtime };
4268
- }
4269
- async mkdir(e, t) {
4270
- const s = this.resolvePath(e);
4271
- this.vfs.mkdir(s, t);
4272
- }
4273
- async rm(e, t) {
4274
- const s = this.resolvePath(e);
4275
- this.vfs.stat(s).type === "directory" ? t != null && t.recursive ? this.vfs.rmdirRecursive(s) : this.vfs.rmdir(s) : this.vfs.unlink(s);
4276
- }
4277
- async exists(e) {
4278
- const t = this.resolvePath(e);
4279
- return this.vfs.exists(t);
4280
- }
4281
- async rename(e, t) {
4282
- const s = this.resolvePath(e), i = this.resolvePath(t);
4283
- this.vfs.rename(s, i);
4284
- }
4285
- async cp(e, t) {
4286
- const s = this.resolvePath(e), i = this.resolvePath(t);
4287
- this.vfs.copyFile(s, i);
4288
- }
4289
- async writeFiles(e) {
4290
- for (const { path: t, content: s } of e)
4291
- await this.writeFile(t, s);
4292
- }
4293
- }
4294
- class Ys {
4295
- constructor(e, t) {
4296
- h(this, "queue", Promise.resolve());
4297
- this.shell = e, this.registry = t;
4298
- }
4299
- run(e, t) {
4300
- return new Promise((i, n) => {
4301
- this.queue = this.queue.then(async () => {
4302
- try {
4303
- const o = await this.executeWithOptions(e, t);
4304
- i(o);
4305
- } catch (o) {
4306
- n(o);
4307
- }
4308
- });
4309
- });
4310
- }
4311
- register(e, t) {
4312
- this.registry.register(e, t);
4313
- }
4314
- async executeWithOptions(e, t) {
4315
- let s, i;
4316
- if (t != null && t.timeout || t != null && t.signal) {
4317
- if (s = new AbortController(), t.signal) {
4318
- if (t.signal.aborted)
4319
- return { stdout: "", stderr: "", exitCode: 130 };
4320
- t.signal.addEventListener("abort", () => s.abort(), { once: !0 });
4321
- }
4322
- t.timeout && (i = setTimeout(() => s.abort(), t.timeout));
4323
- }
4324
- try {
4325
- return await this.shell.execute(e, {
4326
- cwd: t == null ? void 0 : t.cwd,
4327
- env: t == null ? void 0 : t.env,
4328
- onStdout: t == null ? void 0 : t.onStdout,
4329
- onStderr: t == null ? void 0 : t.onStderr,
4330
- stdin: t == null ? void 0 : t.stdin
4331
- });
4332
- } finally {
4333
- i !== void 0 && clearTimeout(i);
4334
- }
4335
- }
4336
- }
4337
- class Xs {
4338
- constructor() {
4339
- h(this, "dataCallback", null);
4340
- }
4341
- write(e) {
4342
- }
4343
- writeln(e) {
4344
- }
4345
- onData(e) {
4346
- this.dataCallback = e;
4347
- }
4348
- get cols() {
4349
- return 80;
4350
- }
4351
- get rows() {
4352
- return 24;
4353
- }
4354
- focus() {
4355
- }
4356
- clear() {
4357
- }
4358
- /** Send data as if typed on keyboard (used internally for stdin) */
4359
- sendData(e) {
4360
- var t;
4361
- (t = this.dataCallback) == null || t.call(this, e);
4362
- }
4363
- }
4364
- class Ye {
4365
- constructor(e, t, s, i, n) {
4366
- /** Programmatic command execution */
4367
- h(this, "commands");
4368
- /** Filesystem operations */
4369
- h(this, "fs");
4370
- /** Environment variables */
4371
- h(this, "env");
4372
- // Power-user escape hatches
4373
- h(this, "kernel");
4374
- h(this, "shell");
4375
- h(this, "_destroyed", !1);
4376
- this.kernel = e, this.shell = t, this.commands = s, this.fs = i, this.env = n;
4377
- }
4378
- /** Current working directory */
4379
- get cwd() {
4380
- return this.shell.getCwd();
4381
- }
4382
- set cwd(e) {
4383
- this.shell.setCwd(e);
4384
- }
4385
- /**
4386
- * Create a new Sandbox instance.
4387
- * Orchestrates all boot steps: Kernel, VFS, Registry, Shell, config sourcing.
4388
- */
4389
- static async create(e) {
4390
- const t = new Yt();
4391
- await t.boot({ persist: (e == null ? void 0 : e.persist) ?? !1 });
4392
- const s = Fs();
4393
- if (s.register("pkg", Bs(s)), Zs(t.vfs, s), e != null && e.files)
4394
- for (const [m, y] of Object.entries(e.files))
4395
- Ks(t.vfs, m), t.vfs.writeFile(m, y);
4396
- const n = { ...t.getDefaultEnv(), ...e == null ? void 0 : e.env };
4397
- e != null && e.cwd && (n.PWD = e.cwd);
4398
- let o;
4399
- if (e != null && e.terminal) {
4400
- const { Terminal: m } = await Promise.resolve().then(() => Ue), y = Qs(e.terminal), E = new m(y);
4401
- o = E;
4402
- const A = t.vfs.readFileString("/etc/motd");
4403
- E.write(A.replace(/\r\n/g, `
4404
- `).replace(/\n/g, `\r
4405
- `));
4406
- } else
4407
- o = new Xs();
4408
- const a = new _s(o, t.vfs, s, n), c = a.getJobTable();
4409
- s.register("ps", js(c)), s.register("top", Ds(c)), s.register("kill", Ms(c)), s.register("watch", Ws(s)), s.register("help", Hs()), await a.sourceFile("/etc/profile"), await a.sourceFile(n.HOME + "/.bashrc"), e != null && e.cwd && a.setCwd(e.cwd), e != null && e.terminal && (a.start(), o.focus());
4410
- const l = () => a.getCwd(), f = new Js(t.vfs, l), u = new Ys(a, s);
4411
- return new Ye(t, a, u, f, n);
4412
- }
4413
- /**
4414
- * Attach a headless sandbox to a DOM element, enabling visual mode.
4415
- */
4416
- async attach(e) {
4417
- if (this._destroyed) throw new Error("Sandbox is destroyed");
4418
- const { Terminal: t } = await Promise.resolve().then(() => Ue), s = new t(e), i = this.kernel.vfs.readFileString("/etc/motd");
4419
- s.write(i.replace(/\r\n/g, `
4420
- `).replace(/\n/g, `\r
4421
- `)), s.focus();
4422
- }
4423
- /**
4424
- * Detach from visual mode.
4425
- */
4426
- detach() {
4427
- }
4428
- /**
4429
- * Destroy the sandbox, releasing all resources.
4430
- */
4431
- destroy() {
4432
- this._destroyed = !0;
4433
- }
4434
- }
4435
- function Qs(r) {
4436
- if (typeof r == "string") {
4437
- const e = document.querySelector(r);
4438
- if (!e) throw new Error(`Sandbox: element not found: ${r}`);
4439
- return e;
4440
- }
4441
- return r;
4442
- }
4443
- function Ks(r, e) {
4444
- const t = e.split("/").filter(Boolean);
4445
- t.pop();
4446
- let s = "";
4447
- for (const i of t)
4448
- s += "/" + i, r.exists(s) || r.mkdir(s, { recursive: !0 });
4449
- }
4450
- function er(r) {
4278
+ function Us(r) {
4451
4279
  const e = r.type === "file", t = r.type === "directory";
4452
4280
  return {
4453
4281
  dev: 0,
@@ -4477,7 +4305,7 @@ function er(r) {
4477
4305
  isSocket: () => !1
4478
4306
  };
4479
4307
  }
4480
- function tr(r, e, t) {
4308
+ function Hs(r, e, t) {
4481
4309
  const s = new Error(r.message);
4482
4310
  return s.code = r.code, s.errno = -2, s.syscall = e, s.path = t, s.name = "Error", s;
4483
4311
  }
@@ -4486,105 +4314,105 @@ function F(r, e) {
4486
4314
  return I(r, t);
4487
4315
  }
4488
4316
  function ze(r, e) {
4489
- function t(p, d) {
4490
- const v = typeof d == "string" ? d : d == null ? void 0 : d.encoding, b = F(e, p);
4317
+ function t(m, d) {
4318
+ const v = typeof d == "string" ? d : d == null ? void 0 : d.encoding, b = F(e, m);
4491
4319
  return v ? r.readFileString(b) : r.readFile(b);
4492
4320
  }
4493
- function s(p, d, v) {
4494
- const b = F(e, p);
4321
+ function s(m, d, v) {
4322
+ const b = F(e, m);
4495
4323
  r.writeFile(b, d);
4496
4324
  }
4497
- function i(p, d) {
4498
- const v = F(e, p);
4325
+ function i(m, d) {
4326
+ const v = F(e, m);
4499
4327
  r.appendFile(v, d);
4500
4328
  }
4501
- function n(p) {
4502
- const d = F(e, p);
4329
+ function n(m) {
4330
+ const d = F(e, m);
4503
4331
  return r.exists(d);
4504
4332
  }
4505
- function o(p) {
4506
- const d = F(e, p);
4507
- return er(r.stat(d));
4333
+ function o(m) {
4334
+ const d = F(e, m);
4335
+ return Us(r.stat(d));
4508
4336
  }
4509
- function a(p) {
4510
- return o(p);
4337
+ function a(m) {
4338
+ return o(m);
4511
4339
  }
4512
- function c(p, d) {
4513
- const v = F(e, p), b = typeof d == "number" ? {} : d;
4340
+ function c(m, d) {
4341
+ const v = F(e, m), b = typeof d == "number" ? {} : d;
4514
4342
  r.mkdir(v, { recursive: b == null ? void 0 : b.recursive });
4515
4343
  }
4516
- function l(p, d) {
4517
- const v = F(e, p);
4344
+ function l(m, d) {
4345
+ const v = F(e, m);
4518
4346
  return r.readdir(v).map((T) => T.name);
4519
4347
  }
4520
- function f(p) {
4521
- const d = F(e, p);
4348
+ function f(m) {
4349
+ const d = F(e, m);
4522
4350
  r.unlink(d);
4523
4351
  }
4524
- function u(p, d) {
4525
- const v = F(e, p);
4352
+ function h(m, d) {
4353
+ const v = F(e, m);
4526
4354
  d != null && d.recursive ? r.rmdirRecursive(v) : r.rmdir(v);
4527
4355
  }
4528
- function m(p, d) {
4529
- const v = F(e, p), b = F(e, d);
4356
+ function p(m, d) {
4357
+ const v = F(e, m), b = F(e, d);
4530
4358
  r.rename(v, b);
4531
4359
  }
4532
- function y(p, d) {
4533
- const v = F(e, p), b = F(e, d);
4360
+ function y(m, d) {
4361
+ const v = F(e, m), b = F(e, d);
4534
4362
  r.copyFile(v, b);
4535
4363
  }
4536
- function E(p, d) {
4364
+ function E(m, d) {
4537
4365
  }
4538
- function A(p, d) {
4539
- const v = F(e, p);
4366
+ function _(m, d) {
4367
+ const v = F(e, m);
4540
4368
  if (!r.exists(v)) {
4541
4369
  const b = new Error(`ENOENT: no such file or directory, access '${v}'`);
4542
4370
  throw b.code = "ENOENT", b.errno = -2, b.syscall = "access", b.path = v, b;
4543
4371
  }
4544
4372
  }
4545
- function P(p, d) {
4373
+ function L(m, d) {
4546
4374
  queueMicrotask(() => {
4547
4375
  try {
4548
- const v = p();
4376
+ const v = m();
4549
4377
  d(null, v);
4550
4378
  } catch (v) {
4551
4379
  if (v instanceof k)
4552
- d(tr(v, "", ""));
4380
+ d(Hs(v, "", ""));
4553
4381
  else
4554
4382
  throw v;
4555
4383
  }
4556
4384
  });
4557
4385
  }
4558
- function S(p, d, v) {
4386
+ function S(m, d, v) {
4559
4387
  const b = typeof d == "function" ? d : v, T = typeof d == "function" ? void 0 : d;
4560
- P(() => t(p, T), b);
4388
+ L(() => t(m, T), b);
4561
4389
  }
4562
- function w(p, d, v, b) {
4563
- P(() => s(p, d), typeof v == "function" ? v : b);
4390
+ function w(m, d, v, b) {
4391
+ L(() => s(m, d), typeof v == "function" ? v : b);
4564
4392
  }
4565
- function $(p, d) {
4566
- P(() => o(p), d);
4393
+ function $(m, d) {
4394
+ L(() => o(m), d);
4567
4395
  }
4568
- function x(p, d, v) {
4396
+ function x(m, d, v) {
4569
4397
  const b = typeof d == "function" ? d : v, T = typeof d == "function" ? void 0 : d;
4570
- P(() => c(p, T), b);
4398
+ L(() => c(m, T), b);
4571
4399
  }
4572
- function _(p, d, v) {
4573
- P(() => l(p), typeof d == "function" ? d : v);
4400
+ function R(m, d, v) {
4401
+ L(() => l(m), typeof d == "function" ? d : v);
4574
4402
  }
4575
- function L(p, d) {
4576
- P(() => f(p), d);
4403
+ function P(m, d) {
4404
+ L(() => f(m), d);
4577
4405
  }
4578
- function j(p, d, v) {
4579
- P(() => m(p, d), v);
4406
+ function j(m, d, v) {
4407
+ L(() => p(m, d), v);
4580
4408
  }
4581
- function U(p, d, v) {
4409
+ function U(m, d, v) {
4582
4410
  const b = typeof d == "function" ? d : v, T = typeof d == "function" ? void 0 : d;
4583
- P(() => A(p, T), b);
4411
+ L(() => _(m, T), b);
4584
4412
  }
4585
- function H(p, d) {
4413
+ function H(m, d) {
4586
4414
  queueMicrotask(() => {
4587
- d(n(p));
4415
+ d(n(m));
4588
4416
  });
4589
4417
  }
4590
4418
  return {
@@ -4598,39 +4426,39 @@ function ze(r, e) {
4598
4426
  mkdirSync: c,
4599
4427
  readdirSync: l,
4600
4428
  unlinkSync: f,
4601
- rmdirSync: u,
4602
- renameSync: m,
4429
+ rmdirSync: h,
4430
+ renameSync: p,
4603
4431
  copyFileSync: y,
4604
4432
  chmodSync: E,
4605
- accessSync: A,
4433
+ accessSync: _,
4606
4434
  // Callback
4607
4435
  readFile: S,
4608
4436
  writeFile: w,
4609
4437
  stat: $,
4610
4438
  mkdir: x,
4611
- readdir: _,
4612
- unlink: L,
4439
+ readdir: R,
4440
+ unlink: P,
4613
4441
  rename: j,
4614
4442
  access: U,
4615
4443
  exists: H,
4616
4444
  // Promises
4617
4445
  promises: {
4618
- readFile: async (p, d) => t(p, d),
4619
- writeFile: async (p, d) => s(p, d),
4620
- appendFile: async (p, d) => i(p, d),
4621
- stat: async (p) => o(p),
4622
- lstat: async (p) => a(p),
4623
- mkdir: async (p, d) => {
4624
- c(p, d);
4446
+ readFile: async (m, d) => t(m, d),
4447
+ writeFile: async (m, d) => s(m, d),
4448
+ appendFile: async (m, d) => i(m, d),
4449
+ stat: async (m) => o(m),
4450
+ lstat: async (m) => a(m),
4451
+ mkdir: async (m, d) => {
4452
+ c(m, d);
4625
4453
  },
4626
- readdir: async (p) => l(p),
4627
- unlink: async (p) => f(p),
4628
- rmdir: async (p, d) => u(p, d),
4629
- rename: async (p, d) => m(p, d),
4630
- copyFile: async (p, d) => y(p, d),
4631
- access: async (p, d) => A(p),
4632
- rm: async (p, d) => {
4633
- const v = F(e, p);
4454
+ readdir: async (m) => l(m),
4455
+ unlink: async (m) => f(m),
4456
+ rmdir: async (m, d) => h(m, d),
4457
+ rename: async (m, d) => p(m, d),
4458
+ copyFile: async (m, d) => y(m, d),
4459
+ access: async (m, d) => _(m),
4460
+ rm: async (m, d) => {
4461
+ const v = F(e, m);
4634
4462
  try {
4635
4463
  r.stat(v).type === "directory" ? d != null && d.recursive ? r.rmdirRecursive(v) : r.rmdir(v) : r.unlink(v);
4636
4464
  } catch (b) {
@@ -4648,7 +4476,7 @@ function ze(r, e) {
4648
4476
  }
4649
4477
  };
4650
4478
  }
4651
- function Xe(r, e) {
4479
+ function Je(r, e) {
4652
4480
  const t = W(r).split("/").filter(Boolean), s = W(e).split("/").filter(Boolean);
4653
4481
  let i = 0;
4654
4482
  for (; i < t.length && i < s.length && t[i] === s[i]; )
@@ -4656,15 +4484,15 @@ function Xe(r, e) {
4656
4484
  const n = t.length - i, o = s.slice(i);
4657
4485
  return [...Array(n).fill(".."), ...o].join("/") || ".";
4658
4486
  }
4659
- function Qe(r) {
4487
+ function Ye(r) {
4660
4488
  const e = se(r) ? "/" : "", t = G(r), s = K(r), i = Q(r), n = i ? s.slice(0, -i.length) : s;
4661
4489
  return { root: e, dir: t, base: s, ext: i, name: n };
4662
4490
  }
4663
- function Ke(r) {
4491
+ function Xe(r) {
4664
4492
  const e = r.dir || r.root || "", t = r.base || (r.name || "") + (r.ext || "");
4665
4493
  return e ? e.endsWith("/") ? e + t : e + "/" + t : t;
4666
4494
  }
4667
- const et = "/", tt = ":", sr = {
4495
+ const Qe = "/", Ke = ":", Vs = {
4668
4496
  normalize: W,
4669
4497
  isAbsolute: se,
4670
4498
  join: ue,
@@ -4672,12 +4500,12 @@ const et = "/", tt = ":", sr = {
4672
4500
  dirname: G,
4673
4501
  basename: K,
4674
4502
  extname: Q,
4675
- relative: Xe,
4676
- parse: Qe,
4677
- format: Ke,
4678
- sep: et,
4679
- delimiter: tt
4680
- }, rr = {
4503
+ relative: Je,
4504
+ parse: Ye,
4505
+ format: Xe,
4506
+ sep: Qe,
4507
+ delimiter: Ke
4508
+ }, Gs = {
4681
4509
  normalize: W,
4682
4510
  isAbsolute: se,
4683
4511
  join: ue,
@@ -4685,14 +4513,14 @@ const et = "/", tt = ":", sr = {
4685
4513
  dirname: G,
4686
4514
  basename: K,
4687
4515
  extname: Q,
4688
- relative: Xe,
4689
- parse: Qe,
4690
- format: Ke,
4691
- sep: et,
4692
- delimiter: tt,
4693
- posix: sr
4516
+ relative: Je,
4517
+ parse: Ye,
4518
+ format: Xe,
4519
+ sep: Qe,
4520
+ delimiter: Ke,
4521
+ posix: Vs
4694
4522
  };
4695
- function ir(r) {
4523
+ function Zs(r) {
4696
4524
  return {
4697
4525
  arch: () => "wasm",
4698
4526
  platform: () => "lifo",
@@ -4736,10 +4564,10 @@ function ir(r) {
4736
4564
  }
4737
4565
  };
4738
4566
  }
4739
- class st extends Error {
4567
+ class et extends Error {
4740
4568
  constructor(t) {
4741
4569
  super(`process.exit(${t})`);
4742
- h(this, "exitCode");
4570
+ u(this, "exitCode");
4743
4571
  this.name = "ProcessExitError", this.exitCode = t;
4744
4572
  }
4745
4573
  }
@@ -4754,7 +4582,7 @@ function le(r) {
4754
4582
  throw new Error("process.chdir() is not supported in Lifo");
4755
4583
  },
4756
4584
  exit: (t = 0) => {
4757
- throw new st(t);
4585
+ throw new et(t);
4758
4586
  },
4759
4587
  stdout: {
4760
4588
  write: (t) => (r.stdout.write(t), !0),
@@ -4815,8 +4643,8 @@ function le(r) {
4815
4643
  }
4816
4644
  class q {
4817
4645
  constructor() {
4818
- h(this, "_events", /* @__PURE__ */ new Map());
4819
- h(this, "_maxListeners", 10);
4646
+ u(this, "_events", /* @__PURE__ */ new Map());
4647
+ u(this, "_maxListeners", 10);
4820
4648
  }
4821
4649
  on(e, t) {
4822
4650
  let s = this._events.get(e);
@@ -4874,47 +4702,47 @@ class q {
4874
4702
  return s || (s = [], this._events.set(e, s)), s.unshift(t), this;
4875
4703
  }
4876
4704
  }
4877
- const je = new TextEncoder(), nr = new TextDecoder();
4878
- class R extends Uint8Array {
4705
+ const je = new TextEncoder(), Js = new TextDecoder();
4706
+ class A extends Uint8Array {
4879
4707
  // Use overloaded signatures to satisfy Uint8Array's static from
4880
4708
  static from(e, t, s) {
4881
4709
  if (typeof e == "string") {
4882
4710
  const o = t;
4883
4711
  if (o === "base64") {
4884
- const l = atob(e), f = new R(l.length);
4885
- for (let u = 0; u < l.length; u++) f[u] = l.charCodeAt(u);
4712
+ const l = atob(e), f = new A(l.length);
4713
+ for (let h = 0; h < l.length; h++) f[h] = l.charCodeAt(h);
4886
4714
  return f;
4887
4715
  }
4888
4716
  if (o === "hex") {
4889
- const l = new R(e.length / 2);
4717
+ const l = new A(e.length / 2);
4890
4718
  for (let f = 0; f < e.length; f += 2)
4891
4719
  l[f / 2] = parseInt(e.substring(f, f + 2), 16);
4892
4720
  return l;
4893
4721
  }
4894
- const a = je.encode(e), c = new R(a.length);
4722
+ const a = je.encode(e), c = new A(a.length);
4895
4723
  return c.set(a), c;
4896
4724
  }
4897
4725
  if (e instanceof ArrayBuffer) {
4898
- const o = new R(e.byteLength);
4726
+ const o = new A(e.byteLength);
4899
4727
  return o.set(new Uint8Array(e)), o;
4900
4728
  }
4901
4729
  if (e instanceof Uint8Array) {
4902
- const o = new R(e.length);
4730
+ const o = new A(e.length);
4903
4731
  return o.set(e), o;
4904
4732
  }
4905
- const i = e, n = new R(i.length);
4733
+ const i = e, n = new A(i.length);
4906
4734
  for (let o = 0; o < i.length; o++) n[o] = i[o];
4907
4735
  return n;
4908
4736
  }
4909
4737
  static alloc(e, t) {
4910
- const s = new R(e);
4738
+ const s = new A(e);
4911
4739
  return t !== void 0 && s.fill(t), s;
4912
4740
  }
4913
4741
  static isBuffer(e) {
4914
- return e instanceof R;
4742
+ return e instanceof A;
4915
4743
  }
4916
4744
  static concat(e, t) {
4917
- const s = t ?? e.reduce((o, a) => o + a.length, 0), i = R.alloc(s);
4745
+ const s = t ?? e.reduce((o, a) => o + a.length, 0), i = A.alloc(s);
4918
4746
  let n = 0;
4919
4747
  for (const o of e) {
4920
4748
  const a = o.subarray(0, Math.min(o.length, s - n));
@@ -4933,7 +4761,7 @@ class R extends Uint8Array {
4933
4761
  for (let s = 0; s < this.length; s++) t += this[s].toString(16).padStart(2, "0");
4934
4762
  return t;
4935
4763
  }
4936
- return nr.decode(this);
4764
+ return Js.decode(this);
4937
4765
  }
4938
4766
  write(e, t, s, i) {
4939
4767
  const n = je.encode(e), o = t ?? 0, a = s ?? this.length - o, c = Math.min(n.length, a);
@@ -4954,7 +4782,7 @@ class R extends Uint8Array {
4954
4782
  }
4955
4783
  slice(e, t) {
4956
4784
  const s = super.slice(e, t);
4957
- return R.from(s);
4785
+ return A.from(s);
4958
4786
  }
4959
4787
  }
4960
4788
  function B(r, ...e) {
@@ -5012,45 +4840,45 @@ function he(r, e) {
5012
4840
  }
5013
4841
  return String(r);
5014
4842
  }
5015
- function rt(r) {
4843
+ function tt(r) {
5016
4844
  return (...e) => new Promise((t, s) => {
5017
4845
  r(...e, (i, n) => {
5018
4846
  i ? s(i) : t(n);
5019
4847
  });
5020
4848
  });
5021
4849
  }
5022
- function it(r, e) {
4850
+ function st(r, e) {
5023
4851
  Object.setPrototypeOf(r.prototype, e.prototype);
5024
4852
  }
5025
- function nt(r, e) {
4853
+ function rt(r, e) {
5026
4854
  let t = !1;
5027
4855
  return ((...s) => (t || (console.warn(`DeprecationWarning: ${e}`), t = !0), r(...s)));
5028
4856
  }
5029
- function ot() {
4857
+ function it() {
5030
4858
  return {
5031
4859
  isDate: (r) => r instanceof Date,
5032
4860
  isRegExp: (r) => r instanceof RegExp,
5033
4861
  isArray: Array.isArray
5034
4862
  };
5035
4863
  }
5036
- const or = { format: B, inspect: X, promisify: rt, inherits: it, deprecate: nt, types: ot }, ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4864
+ const Ys = { format: B, inspect: X, promisify: tt, inherits: st, deprecate: rt, types: it }, Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5037
4865
  __proto__: null,
5038
- default: or,
5039
- deprecate: nt,
4866
+ default: Ys,
4867
+ deprecate: rt,
5040
4868
  format: B,
5041
- inherits: it,
4869
+ inherits: st,
5042
4870
  inspect: X,
5043
- promisify: rt,
5044
- types: ot
4871
+ promisify: tt,
4872
+ types: it
5045
4873
  }, Symbol.toStringTag, { value: "Module" }));
5046
4874
  class te extends q {
5047
4875
  constructor(t, s, i) {
5048
4876
  super();
5049
- h(this, "statusCode");
5050
- h(this, "statusMessage");
5051
- h(this, "headers");
5052
- h(this, "method");
5053
- h(this, "url");
4877
+ u(this, "statusCode");
4878
+ u(this, "statusMessage");
4879
+ u(this, "headers");
4880
+ u(this, "method");
4881
+ u(this, "url");
5054
4882
  this.statusCode = t, this.statusMessage = s, this.headers = i;
5055
4883
  }
5056
4884
  setEncoding(t) {
@@ -5060,10 +4888,10 @@ class te extends q {
5060
4888
  class De extends q {
5061
4889
  constructor(t, s, i) {
5062
4890
  super();
5063
- h(this, "options");
5064
- h(this, "body", "");
5065
- h(this, "aborted", !1);
5066
- h(this, "portRegistry");
4891
+ u(this, "options");
4892
+ u(this, "body", "");
4893
+ u(this, "aborted", !1);
4894
+ u(this, "portRegistry");
5067
4895
  this.options = t, this.portRegistry = i, s && this.on("response", s), queueMicrotask(() => this.execute());
5068
4896
  }
5069
4897
  write(t) {
@@ -5093,12 +4921,12 @@ class De extends q {
5093
4921
  };
5094
4922
  try {
5095
4923
  c(l, f);
5096
- const u = new te(f.statusCode, "OK", f.headers);
5097
- this.emit("response", u), queueMicrotask(() => {
5098
- u.emit("data", f.body), u.emit("end");
4924
+ const h = new te(f.statusCode, "OK", f.headers);
4925
+ this.emit("response", h), queueMicrotask(() => {
4926
+ h.emit("data", f.body), h.emit("end");
5099
4927
  });
5100
- } catch (u) {
5101
- this.emit("error", u);
4928
+ } catch (h) {
4929
+ this.emit("error", h);
5102
4930
  }
5103
4931
  return;
5104
4932
  }
@@ -5110,13 +4938,13 @@ class De extends q {
5110
4938
  headers: this.options.headers,
5111
4939
  body: this.options.method !== "GET" && this.body ? this.body : void 0
5112
4940
  }), l = {};
5113
- c.headers.forEach((m, y) => {
5114
- l[y] = m;
4941
+ c.headers.forEach((p, y) => {
4942
+ l[y] = p;
5115
4943
  });
5116
4944
  const f = new te(c.status, c.statusText, l);
5117
4945
  this.emit("response", f);
5118
- const u = await c.text();
5119
- f.emit("data", u), f.emit("end");
4946
+ const h = await c.text();
4947
+ f.emit("data", h), f.emit("end");
5120
4948
  } catch (c) {
5121
4949
  this.emit("error", c);
5122
4950
  }
@@ -5125,12 +4953,12 @@ class De extends q {
5125
4953
  return s && this.on("timeout", s), this;
5126
4954
  }
5127
4955
  }
5128
- class at {
4956
+ class nt {
5129
4957
  constructor(e) {
5130
- h(this, "statusCode", 200);
5131
- h(this, "_headers", {});
5132
- h(this, "_body", "");
5133
- h(this, "_vRes");
4958
+ u(this, "statusCode", 200);
4959
+ u(this, "_headers", {});
4960
+ u(this, "_body", "");
4961
+ u(this, "_vRes");
5134
4962
  this._vRes = e;
5135
4963
  }
5136
4964
  writeHead(e, t) {
@@ -5149,15 +4977,15 @@ class at {
5149
4977
  e && (this._body += e), this._vRes.statusCode = this.statusCode, this._vRes.headers = { ...this._headers }, this._vRes.body = this._body;
5150
4978
  }
5151
4979
  }
5152
- const ct = Symbol.for("lifo.http.activeServers");
4980
+ const ot = Symbol.for("lifo.http.activeServers");
5153
4981
  class Oe extends q {
5154
4982
  constructor(t, s, i) {
5155
4983
  super();
5156
- h(this, "portRegistry");
5157
- h(this, "_port", null);
5158
- h(this, "_closeResolve", null);
5159
- h(this, "_promise", null);
5160
- h(this, "_activeServers");
4984
+ u(this, "portRegistry");
4985
+ u(this, "_port", null);
4986
+ u(this, "_closeResolve", null);
4987
+ u(this, "_promise", null);
4988
+ u(this, "_activeServers");
5161
4989
  this.portRegistry = t, this._activeServers = s, i && this.on("request", i);
5162
4990
  }
5163
4991
  listen(t, ...s) {
@@ -5173,7 +5001,7 @@ class Oe extends q {
5173
5001
  const n = (o, a) => {
5174
5002
  const c = new te(0, "", o.headers);
5175
5003
  c.method = o.method, c.url = o.url;
5176
- const l = new at(a);
5004
+ const l = new nt(a);
5177
5005
  this.emit("request", c, l);
5178
5006
  };
5179
5007
  return this.portRegistry.set(t, n), this._activeServers.push(this), i && queueMicrotask(i), this;
@@ -5195,11 +5023,11 @@ function Me(r) {
5195
5023
  function t(o, a, c) {
5196
5024
  let l, f;
5197
5025
  if (typeof o == "string") {
5198
- const u = new URL(o);
5026
+ const h = new URL(o);
5199
5027
  l = {
5200
- hostname: u.hostname,
5201
- port: u.port,
5202
- path: u.pathname + u.search,
5028
+ hostname: h.hostname,
5029
+ port: h.port,
5030
+ path: h.pathname + h.search,
5203
5031
  method: "GET"
5204
5032
  }, typeof a == "function" ? f = a : (l = { ...l, ...a }, f = c);
5205
5033
  } else
@@ -5222,26 +5050,26 @@ function Me(r) {
5222
5050
  IncomingMessage: te,
5223
5051
  ClientRequest: De,
5224
5052
  Server: Oe,
5225
- ServerResponse: at,
5226
- [ct]: e
5053
+ ServerResponse: nt,
5054
+ [ot]: e
5227
5055
  };
5228
5056
  }
5229
- function cr(r) {
5057
+ function Qs(r) {
5230
5058
  function e(n, o, a) {
5231
5059
  const c = typeof o == "function" ? o : a, l = new q();
5232
5060
  if (!r)
5233
5061
  return queueMicrotask(() => {
5234
- const u = new Error("child_process.exec() requires shell interpreter");
5235
- c && c(u, "", ""), l.emit("error", u);
5062
+ const h = new Error("child_process.exec() requires shell interpreter");
5063
+ c && c(h, "", ""), l.emit("error", h);
5236
5064
  }), l;
5237
5065
  const f = r;
5238
5066
  return queueMicrotask(async () => {
5239
5067
  try {
5240
- const u = await f(n);
5241
- c && c(null, u, ""), l.emit("close", 0);
5242
- } catch (u) {
5243
- const m = u instanceof Error ? u : new Error(String(u));
5244
- c && c(m, "", m.message), l.emit("close", 1);
5068
+ const h = await f(n);
5069
+ c && c(null, h, ""), l.emit("close", 0);
5070
+ } catch (h) {
5071
+ const p = h instanceof Error ? h : new Error(String(h));
5072
+ c && c(p, "", p.message), l.emit("close", 1);
5245
5073
  }
5246
5074
  }), l;
5247
5075
  }
@@ -5259,9 +5087,9 @@ function cr(r) {
5259
5087
  class de extends q {
5260
5088
  constructor() {
5261
5089
  super(...arguments);
5262
- h(this, "_buffer", []);
5263
- h(this, "_ended", !1);
5264
- h(this, "readable", !0);
5090
+ u(this, "_buffer", []);
5091
+ u(this, "_ended", !1);
5092
+ u(this, "readable", !0);
5265
5093
  }
5266
5094
  push(t) {
5267
5095
  t === null ? (this._ended = !0, this.readable = !1, this.emit("end")) : (this._buffer.push(t), this.emit("data", t));
@@ -5285,11 +5113,11 @@ class de extends q {
5285
5113
  return this;
5286
5114
  }
5287
5115
  }
5288
- class lt extends q {
5116
+ class at extends q {
5289
5117
  constructor() {
5290
5118
  super(...arguments);
5291
- h(this, "_ended", !1);
5292
- h(this, "writable", !0);
5119
+ u(this, "_ended", !1);
5120
+ u(this, "writable", !0);
5293
5121
  }
5294
5122
  write(t, s, i) {
5295
5123
  return this._ended ? !1 : (this.emit("data", t), i && i(), !0);
@@ -5304,8 +5132,8 @@ class lt extends q {
5304
5132
  class fe extends de {
5305
5133
  constructor() {
5306
5134
  super(...arguments);
5307
- h(this, "writable", !0);
5308
- h(this, "_writableEnded", !1);
5135
+ u(this, "writable", !0);
5136
+ u(this, "_writableEnded", !1);
5309
5137
  }
5310
5138
  write(t, s, i) {
5311
5139
  return this._writableEnded ? !1 : (this.emit("data", t), i && i(), !0);
@@ -5314,17 +5142,17 @@ class fe extends de {
5314
5142
  t && this.write(t), this._writableEnded = !0, this.writable = !1, this.emit("finish");
5315
5143
  }
5316
5144
  }
5317
- class ht extends fe {
5145
+ class ct extends fe {
5318
5146
  }
5319
- const lr = { Readable: de, Writable: lt, Duplex: fe, PassThrough: ht }, hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5147
+ const Ks = { Readable: de, Writable: at, Duplex: fe, PassThrough: ct }, er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5320
5148
  __proto__: null,
5321
5149
  Duplex: fe,
5322
- PassThrough: ht,
5150
+ PassThrough: ct,
5323
5151
  Readable: de,
5324
- Writable: lt,
5325
- default: lr
5326
- }, Symbol.toStringTag, { value: "Module" })), ur = globalThis.URL, dr = globalThis.URLSearchParams;
5327
- function ut(r) {
5152
+ Writable: at,
5153
+ default: Ks
5154
+ }, Symbol.toStringTag, { value: "Module" })), tr = globalThis.URL, sr = globalThis.URLSearchParams;
5155
+ function lt(r) {
5328
5156
  try {
5329
5157
  const e = new URL(r);
5330
5158
  return {
@@ -5354,53 +5182,53 @@ function ut(r) {
5354
5182
  };
5355
5183
  }
5356
5184
  }
5357
- function dt(r) {
5185
+ function ht(r) {
5358
5186
  let e = "";
5359
5187
  return r.protocol && (e += r.protocol + "//"), r.hostname && (e += r.hostname), r.port && (e += ":" + r.port), r.pathname && (e += r.pathname), r.search && (e += r.search), r.hash && (e += r.hash), e;
5360
5188
  }
5361
- function ft(r, e) {
5189
+ function ut(r, e) {
5362
5190
  return new URL(e, r).href;
5363
5191
  }
5364
- const fr = { URL, URLSearchParams, parse: ut, format: dt, resolve: ft }, mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5192
+ const rr = { URL, URLSearchParams, parse: lt, format: ht, resolve: ut }, ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5365
5193
  __proto__: null,
5366
- URL: ur,
5367
- URLSearchParams: dr,
5368
- default: fr,
5369
- format: dt,
5370
- parse: ut,
5371
- resolve: ft
5372
- }, Symbol.toStringTag, { value: "Module" })), me = globalThis.setTimeout, mt = globalThis.setInterval, pe = globalThis.clearTimeout, pt = globalThis.clearInterval;
5373
- function gt(r, ...e) {
5194
+ URL: tr,
5195
+ URLSearchParams: sr,
5196
+ default: rr,
5197
+ format: ht,
5198
+ parse: lt,
5199
+ resolve: ut
5200
+ }, Symbol.toStringTag, { value: "Module" })), me = globalThis.setTimeout, dt = globalThis.setInterval, pe = globalThis.clearTimeout, ft = globalThis.clearInterval;
5201
+ function mt(r, ...e) {
5374
5202
  return me(() => r(...e), 0);
5375
5203
  }
5376
- function wt(r) {
5204
+ function pt(r) {
5377
5205
  pe(r);
5378
5206
  }
5379
- const pr = {
5207
+ const nr = {
5380
5208
  setTimeout: me,
5381
- setInterval: mt,
5209
+ setInterval: dt,
5382
5210
  clearTimeout: pe,
5383
- clearInterval: pt,
5384
- setImmediate: gt,
5385
- clearImmediate: wt
5386
- }, gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5211
+ clearInterval: ft,
5212
+ setImmediate: mt,
5213
+ clearImmediate: pt
5214
+ }, or = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5387
5215
  __proto__: null,
5388
- _clearInterval: pt,
5216
+ _clearInterval: ft,
5389
5217
  _clearTimeout: pe,
5390
- _setInterval: mt,
5218
+ _setInterval: dt,
5391
5219
  _setTimeout: me,
5392
- clearImmediate: wt,
5393
- default: pr,
5394
- setImmediate: gt
5220
+ clearImmediate: pt,
5221
+ default: nr,
5222
+ setImmediate: mt
5395
5223
  }, Symbol.toStringTag, { value: "Module" }));
5396
- function yt(r) {
5397
- const e = R.alloc(r);
5224
+ function gt(r) {
5225
+ const e = A.alloc(r);
5398
5226
  return crypto.getRandomValues(e), e;
5399
5227
  }
5400
- function vt() {
5228
+ function wt() {
5401
5229
  return crypto.randomUUID();
5402
5230
  }
5403
- function bt(r) {
5231
+ function yt(r) {
5404
5232
  const t = {
5405
5233
  sha1: "SHA-1",
5406
5234
  "sha-1": "SHA-1",
@@ -5425,30 +5253,30 @@ function bt(r) {
5425
5253
  let a = 0;
5426
5254
  for (const f of s)
5427
5255
  o.set(f, a), a += f.length;
5428
- const c = await crypto.subtle.digest(t, o), l = R.from(c);
5256
+ const c = await crypto.subtle.digest(t, o), l = A.from(c);
5429
5257
  return i === "hex" ? l.toString("hex") : i === "base64" ? l.toString("base64") : l;
5430
5258
  }
5431
5259
  };
5432
5260
  }
5433
- function $t(r, e) {
5261
+ function vt(r, e) {
5434
5262
  e === void 0 && (e = r, r = 0);
5435
5263
  const t = e - r, s = new Uint32Array(1);
5436
5264
  return crypto.getRandomValues(s), r + s[0] % t;
5437
5265
  }
5438
- const wr = { randomBytes: yt, randomUUID: vt, createHash: bt, randomInt: $t }, yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5266
+ const ar = { randomBytes: gt, randomUUID: wt, createHash: yt, randomInt: vt }, cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5439
5267
  __proto__: null,
5440
- createHash: bt,
5441
- default: wr,
5442
- randomBytes: yt,
5443
- randomInt: $t,
5444
- randomUUID: vt
5268
+ createHash: yt,
5269
+ default: ar,
5270
+ randomBytes: gt,
5271
+ randomInt: vt,
5272
+ randomUUID: wt
5445
5273
  }, Symbol.toStringTag, { value: "Module" }));
5446
5274
  function We(r) {
5447
5275
  return {
5448
5276
  fs: () => ze(r.vfs, r.cwd),
5449
5277
  "fs/promises": () => ze(r.vfs, r.cwd).promises,
5450
- path: () => rr,
5451
- os: () => ir(r.env),
5278
+ path: () => Gs,
5279
+ os: () => Zs(r.env),
5452
5280
  process: () => le({
5453
5281
  argv: r.argv,
5454
5282
  env: r.env,
@@ -5457,15 +5285,15 @@ function We(r) {
5457
5285
  stderr: r.stderr
5458
5286
  }),
5459
5287
  events: () => ({ EventEmitter: q, default: q }),
5460
- buffer: () => ({ Buffer: R }),
5461
- util: () => ar,
5288
+ buffer: () => ({ Buffer: A }),
5289
+ util: () => Xs,
5462
5290
  http: () => Me(r.portRegistry),
5463
5291
  https: () => Me(r.portRegistry),
5464
- child_process: () => cr(r.executeCapture),
5465
- stream: () => hr,
5466
- url: () => mr,
5467
- timers: () => gr,
5468
- crypto: () => yr,
5292
+ child_process: () => Qs(r.executeCapture),
5293
+ stream: () => er,
5294
+ url: () => ir,
5295
+ timers: () => or,
5296
+ crypto: () => cr,
5469
5297
  querystring: () => ({
5470
5298
  parse: (e) => Object.fromEntries(new URLSearchParams(e)),
5471
5299
  stringify: (e) => new URLSearchParams(e).toString(),
@@ -5574,11 +5402,11 @@ function qe(r, e) {
5574
5402
  }
5575
5403
  };
5576
5404
  }
5577
- const vr = "v20.0.0";
5578
- function xt(r) {
5405
+ const lr = "v20.0.0";
5406
+ function bt(r) {
5579
5407
  return async (e) => {
5580
5408
  if (e.args.length > 0 && (e.args[0] === "-v" || e.args[0] === "--version"))
5581
- return e.stdout.write(vr + `
5409
+ return e.stdout.write(lr + `
5582
5410
  `), 0;
5583
5411
  if (e.args.length > 0 && e.args[0] === "--help")
5584
5412
  return e.stdout.write(`Usage: node [-e code] [script.js] [args...]
@@ -5635,13 +5463,13 @@ function xt(r) {
5635
5463
  if (w.startsWith("./") || w.startsWith("../") || w.startsWith("/")) {
5636
5464
  const x = f(w, n);
5637
5465
  if (x) {
5638
- const _ = c.get(x.path);
5639
- if (_) return _;
5466
+ const R = c.get(x.path);
5467
+ if (R) return R;
5640
5468
  if (x.path.endsWith(".json")) {
5641
5469
  const U = e.vfs.readFileString(x.path), H = JSON.parse(U);
5642
5470
  return c.set(x.path, H), H;
5643
5471
  }
5644
- const L = e.vfs.readFileString(x.path), j = u(L, x.path);
5472
+ const P = e.vfs.readFileString(x.path), j = h(P, x.path);
5645
5473
  return c.set(x.path, j), j;
5646
5474
  }
5647
5475
  throw new Error(`Cannot find module '${w}'`);
@@ -5650,8 +5478,8 @@ function xt(r) {
5650
5478
  if (e.vfs.exists($)) {
5651
5479
  const x = c.get($);
5652
5480
  if (x) return x;
5653
- const _ = e.vfs.readFileString($), L = u(_, $);
5654
- return c.set($, L), L;
5481
+ const R = e.vfs.readFileString($), P = h(R, $);
5482
+ return c.set($, P), P;
5655
5483
  }
5656
5484
  throw new Error(`Cannot find module '${w}'`);
5657
5485
  }
@@ -5660,14 +5488,14 @@ function xt(r) {
5660
5488
  if (e.vfs.exists(x))
5661
5489
  try {
5662
5490
  if (e.vfs.stat(x).type === "file") return { path: x };
5663
- const L = ue(x, "index.js");
5664
- if (e.vfs.exists(L)) return { path: L };
5491
+ const P = ue(x, "index.js");
5492
+ if (e.vfs.exists(P)) return { path: P };
5665
5493
  } catch {
5666
5494
  }
5667
5495
  return !Q(x) && e.vfs.exists(x + ".js") ? { path: x + ".js" } : !Q(x) && e.vfs.exists(x + ".json") ? { path: x + ".json" } : null;
5668
5496
  }
5669
- function u(w, $) {
5670
- const x = G($), _ = { exports: {} }, L = _.exports, j = { ...o }, U = We(j), H = le({
5497
+ function h(w, $) {
5498
+ const x = G($), R = { exports: {} }, P = R.exports, j = { ...o }, U = We(j), H = le({
5671
5499
  argv: o.argv,
5672
5500
  env: o.env,
5673
5501
  cwd: o.cwd,
@@ -5687,65 +5515,65 @@ function xt(r) {
5687
5515
  const Z = c.get(T.path);
5688
5516
  if (Z) return Z;
5689
5517
  if (T.path.endsWith(".json")) {
5690
- const Et = e.vfs.readFileString(T.path), be = JSON.parse(Et);
5518
+ const Ct = e.vfs.readFileString(T.path), be = JSON.parse(Ct);
5691
5519
  return c.set(T.path, be), be;
5692
5520
  }
5693
- const kt = e.vfs.readFileString(T.path), ve = u(kt, T.path);
5521
+ const Et = e.vfs.readFileString(T.path), ve = h(Et, T.path);
5694
5522
  return c.set(T.path, ve), ve;
5695
5523
  }
5696
5524
  throw new Error(`Cannot find module '${b}'`);
5697
5525
  }
5698
5526
  return l(b);
5699
5527
  }
5700
- const p = `(function(exports, require, module, __filename, __dirname, console, process, Buffer, setTimeout, setInterval, clearTimeout, clearInterval, global) {
5528
+ const m = `(function(exports, require, module, __filename, __dirname, console, process, Buffer, setTimeout, setInterval, clearTimeout, clearInterval, global) {
5701
5529
  ${w}
5702
- })`, d = new Function("return " + p)(), v = {};
5530
+ })`, d = new Function("return " + m)(), v = {};
5703
5531
  return d(
5704
- L,
5532
+ P,
5705
5533
  ye,
5706
- _,
5534
+ R,
5707
5535
  $,
5708
5536
  x,
5709
5537
  we,
5710
5538
  H,
5711
- R,
5539
+ A,
5712
5540
  globalThis.setTimeout,
5713
5541
  globalThis.setInterval,
5714
5542
  globalThis.clearTimeout,
5715
5543
  globalThis.clearInterval,
5716
5544
  v
5717
- ), _.exports;
5545
+ ), R.exports;
5718
5546
  }
5719
- const m = le({
5547
+ const p = le({
5720
5548
  argv: o.argv,
5721
5549
  env: o.env,
5722
5550
  cwd: o.cwd,
5723
5551
  stdout: e.stdout,
5724
5552
  stderr: e.stderr
5725
- }), y = qe(e.stdout, e.stderr), E = { exports: {} }, A = E.exports, P = {}, S = `(function(exports, require, module, __filename, __dirname, console, process, Buffer, setTimeout, setInterval, clearTimeout, clearInterval, global) {
5553
+ }), y = qe(e.stdout, e.stderr), E = { exports: {} }, _ = E.exports, L = {}, S = `(function(exports, require, module, __filename, __dirname, console, process, Buffer, setTimeout, setInterval, clearTimeout, clearInterval, global) {
5726
5554
  ${t}
5727
5555
  })`;
5728
5556
  try {
5729
5557
  new Function("return " + S)()(
5730
- A,
5558
+ _,
5731
5559
  l,
5732
5560
  E,
5733
5561
  s,
5734
5562
  n,
5735
5563
  y,
5736
- m,
5737
- R,
5564
+ p,
5565
+ A,
5738
5566
  globalThis.setTimeout,
5739
5567
  globalThis.setInterval,
5740
5568
  globalThis.clearTimeout,
5741
5569
  globalThis.clearInterval,
5742
- P
5570
+ L
5743
5571
  );
5744
- const $ = c.get("http"), x = $ == null ? void 0 : $[ct];
5572
+ const $ = c.get("http"), x = $ == null ? void 0 : $[ot];
5745
5573
  if (x && x.length > 0) {
5746
- const _ = x.map((L) => L.getPromise()).filter((L) => L !== null);
5747
- if (_.length > 0) {
5748
- const L = new Promise((j) => {
5574
+ const R = x.map((P) => P.getPromise()).filter((P) => P !== null);
5575
+ if (R.length > 0) {
5576
+ const P = new Promise((j) => {
5749
5577
  if (e.signal.aborted) {
5750
5578
  j();
5751
5579
  return;
@@ -5753,8 +5581,8 @@ ${t}
5753
5581
  e.signal.addEventListener("abort", () => j(), { once: !0 });
5754
5582
  });
5755
5583
  if (await Promise.race([
5756
- Promise.all(_),
5757
- L
5584
+ Promise.all(R),
5585
+ P
5758
5586
  ]), e.signal.aborted)
5759
5587
  for (const j of [...x])
5760
5588
  j.close();
@@ -5762,42 +5590,42 @@ ${t}
5762
5590
  }
5763
5591
  return 0;
5764
5592
  } catch (w) {
5765
- return w instanceof st ? w.exitCode : (w instanceof Error ? e.stderr.write(`${w.stack || w.message}
5593
+ return w instanceof et ? w.exitCode : (w instanceof Error ? e.stderr.write(`${w.stack || w.message}
5766
5594
  `) : e.stderr.write(`${String(w)}
5767
5595
  `), 1);
5768
5596
  }
5769
5597
  };
5770
5598
  }
5771
- function br(r) {
5772
- return xt(r);
5599
+ function $t(r) {
5600
+ return bt(r);
5773
5601
  }
5774
- const $r = xt(), ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5602
+ const hr = bt(), ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5775
5603
  __proto__: null,
5776
- createNodeCommand: br,
5777
- default: $r
5604
+ createNodeCommand: $t,
5605
+ default: hr
5778
5606
  }, Symbol.toStringTag, { value: "Module" }));
5779
- function St(r) {
5607
+ function xt(r) {
5780
5608
  return async (e) => {
5781
5609
  let t = "GET";
5782
5610
  const s = {};
5783
5611
  let i, n, o = !1, a = !1, c = !1, l;
5784
5612
  const f = e.args;
5785
- for (let u = 0; u < f.length; u++) {
5786
- const m = f[u];
5787
- switch (m) {
5613
+ for (let h = 0; h < f.length; h++) {
5614
+ const p = f[h];
5615
+ switch (p) {
5788
5616
  case "-X":
5789
- t = f[++u] ?? "GET";
5617
+ t = f[++h] ?? "GET";
5790
5618
  break;
5791
5619
  case "-H": {
5792
- const y = f[++u] ?? "", E = y.indexOf(":");
5620
+ const y = f[++h] ?? "", E = y.indexOf(":");
5793
5621
  E !== -1 && (s[y.slice(0, E).trim()] = y.slice(E + 1).trim());
5794
5622
  break;
5795
5623
  }
5796
5624
  case "-d":
5797
- i = f[++u] ?? "", t === "GET" && (t = "POST");
5625
+ i = f[++h] ?? "", t === "GET" && (t = "POST");
5798
5626
  break;
5799
5627
  case "-o":
5800
- n = f[++u] ?? "";
5628
+ n = f[++h] ?? "";
5801
5629
  break;
5802
5630
  case "-s":
5803
5631
  case "--silent":
@@ -5812,7 +5640,7 @@ function St(r) {
5812
5640
  c = !0, t = "HEAD";
5813
5641
  break;
5814
5642
  default:
5815
- m.startsWith("-") || (l = m);
5643
+ p.startsWith("-") || (l = p);
5816
5644
  break;
5817
5645
  }
5818
5646
  }
@@ -5822,27 +5650,27 @@ function St(r) {
5822
5650
  `), 1;
5823
5651
  if (!l.startsWith("http://") && !l.startsWith("https://") && (l = "https://" + l), r)
5824
5652
  try {
5825
- const u = new URL(l), m = u.hostname, y = u.port ? Number(u.port) : u.protocol === "http:" ? 80 : 443;
5826
- if ((m === "localhost" || m === "127.0.0.1") && r.has(y)) {
5827
- const E = r.get(y), A = {
5653
+ const h = new URL(l), p = h.hostname, y = h.port ? Number(h.port) : h.protocol === "http:" ? 80 : 443;
5654
+ if ((p === "localhost" || p === "127.0.0.1") && r.has(y)) {
5655
+ const E = r.get(y), _ = {
5828
5656
  method: t,
5829
- url: u.pathname + u.search,
5657
+ url: h.pathname + h.search,
5830
5658
  headers: s,
5831
5659
  body: i || ""
5832
- }, P = {
5660
+ }, L = {
5833
5661
  statusCode: 200,
5834
5662
  headers: {},
5835
5663
  body: ""
5836
5664
  };
5837
- if (E(A, P), c) {
5838
- e.stdout.write(`HTTP/${P.statusCode} OK
5665
+ if (E(_, L), c) {
5666
+ e.stdout.write(`HTTP/${L.statusCode} OK
5839
5667
  `);
5840
- for (const [w, $] of Object.entries(P.headers))
5668
+ for (const [w, $] of Object.entries(L.headers))
5841
5669
  e.stdout.write(`${w}: ${$}
5842
5670
  `);
5843
5671
  return 0;
5844
5672
  }
5845
- const S = P.body;
5673
+ const S = L.body;
5846
5674
  if (n) {
5847
5675
  const w = I(e.cwd, n);
5848
5676
  e.vfs.writeFile(w, S), o || (e.stderr.write(` % Total % Received
@@ -5852,25 +5680,25 @@ function St(r) {
5852
5680
  e.stdout.write(S), S.endsWith(`
5853
5681
  `) || e.stdout.write(`
5854
5682
  `);
5855
- return P.statusCode >= 200 && P.statusCode < 400 ? 0 : 22;
5683
+ return L.statusCode >= 200 && L.statusCode < 400 ? 0 : 22;
5856
5684
  }
5857
5685
  } catch {
5858
5686
  }
5859
5687
  try {
5860
- const u = {
5688
+ const h = {
5861
5689
  method: t,
5862
5690
  headers: Object.keys(s).length > 0 ? s : void 0,
5863
5691
  body: i,
5864
5692
  redirect: a ? "follow" : "manual",
5865
5693
  signal: e.signal
5866
- }, m = await fetch(l, u);
5694
+ }, p = await fetch(l, h);
5867
5695
  if (c)
5868
- return e.stdout.write(`HTTP/${m.status} ${m.statusText}
5869
- `), m.headers.forEach((E, A) => {
5870
- e.stdout.write(`${A}: ${E}
5696
+ return e.stdout.write(`HTTP/${p.status} ${p.statusText}
5697
+ `), p.headers.forEach((E, _) => {
5698
+ e.stdout.write(`${_}: ${E}
5871
5699
  `);
5872
5700
  }), 0;
5873
- const y = await m.text();
5701
+ const y = await p.text();
5874
5702
  if (n) {
5875
5703
  const E = I(e.cwd, n);
5876
5704
  e.vfs.writeFile(E, y), o || (e.stderr.write(` % Total % Received
@@ -5880,149 +5708,303 @@ function St(r) {
5880
5708
  e.stdout.write(y), y.endsWith(`
5881
5709
  `) || e.stdout.write(`
5882
5710
  `);
5883
- return m.ok ? 0 : 22;
5884
- } catch (u) {
5885
- const m = u instanceof Error ? u.message : String(u);
5886
- return m.includes("Failed to fetch") || m.includes("NetworkError") || m.includes("CORS") ? (e.stderr.write(`curl: (7) Failed to connect to ${l}
5711
+ return p.ok ? 0 : 22;
5712
+ } catch (h) {
5713
+ const p = h instanceof Error ? h.message : String(h);
5714
+ return p.includes("Failed to fetch") || p.includes("NetworkError") || p.includes("CORS") ? (e.stderr.write(`curl: (7) Failed to connect to ${l}
5887
5715
  `), e.stderr.write(`Note: This may be a CORS restriction. The target server must allow cross-origin requests.
5888
- `)) : e.stderr.write(`curl: ${m}
5716
+ `)) : e.stderr.write(`curl: ${p}
5889
5717
  `), 7;
5890
5718
  }
5891
5719
  };
5892
5720
  }
5893
- function xr(r) {
5894
- return St(r);
5721
+ function St(r) {
5722
+ return xt(r);
5895
5723
  }
5896
- const Sr = St(), kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5724
+ const ur = xt(), dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5897
5725
  __proto__: null,
5898
- createCurlCommand: xr,
5899
- default: Sr
5900
- }, Symbol.toStringTag, { value: "Module" })), Er = {
5901
- background: "#1a1b26",
5902
- foreground: "#a9b1d6",
5903
- cursor: "#c0caf5",
5904
- cursorAccent: "#1a1b26",
5905
- selectionBackground: "#33467c",
5906
- black: "#15161e",
5907
- red: "#f7768e",
5908
- green: "#9ece6a",
5909
- yellow: "#e0af68",
5910
- blue: "#7aa2f7",
5911
- magenta: "#bb9af7",
5912
- cyan: "#7dcfff",
5913
- white: "#a9b1d6",
5914
- brightBlack: "#414868",
5915
- brightRed: "#f7768e",
5916
- brightGreen: "#9ece6a",
5917
- brightYellow: "#e0af68",
5918
- brightBlue: "#7aa2f7",
5919
- brightMagenta: "#bb9af7",
5920
- brightCyan: "#7dcfff",
5921
- brightWhite: "#c0caf5"
5922
- };
5923
- class Cr {
5924
- constructor(e) {
5925
- h(this, "xterm");
5926
- h(this, "fitAddon");
5927
- this.xterm = new Pt({
5928
- theme: Er,
5929
- fontFamily: '"Cascadia Code", "Fira Code", "JetBrains Mono", Menlo, monospace',
5930
- fontSize: 14,
5931
- lineHeight: 1.2,
5932
- cursorBlink: !0,
5933
- cursorStyle: "block",
5934
- allowProposedApi: !0
5935
- }), this.fitAddon = new Tt(), this.xterm.loadAddon(this.fitAddon), this.xterm.open(e);
5726
+ createCurlCommand: St,
5727
+ default: ur
5728
+ }, Symbol.toStringTag, { value: "Module" })), fr = "/usr/share/pkg/packages.json", mr = "/usr/share/pkg/node_modules";
5729
+ function pr(r, e) {
5730
+ let t;
5731
+ try {
5732
+ const s = r.readFileString(fr);
5733
+ t = JSON.parse(s);
5734
+ } catch {
5735
+ return;
5736
+ }
5737
+ for (const s of Object.keys(t.packages)) {
5738
+ const i = `${mr}/${s}/index.js`;
5739
+ r.exists(i) && e.registerLazy(
5740
+ s,
5741
+ () => Promise.resolve().then(() => ge).then((n) => ({
5742
+ default: ((o) => n.default({
5743
+ ...o,
5744
+ args: [i, ...o.args]
5745
+ }))
5746
+ }))
5747
+ );
5748
+ }
5749
+ }
5750
+ class gr {
5751
+ constructor(e, t) {
5752
+ this.vfs = e, this.getCwd = t;
5753
+ }
5754
+ resolvePath(e) {
5755
+ return I(this.getCwd(), e);
5756
+ }
5757
+ readFile(e, t) {
5758
+ const s = this.resolvePath(e);
5759
+ return t === null ? Promise.resolve(this.vfs.readFile(s)) : Promise.resolve(this.vfs.readFileString(s));
5760
+ }
5761
+ async writeFile(e, t) {
5762
+ const s = this.resolvePath(e);
5763
+ this.vfs.writeFile(s, t);
5764
+ }
5765
+ async readdir(e) {
5766
+ const t = this.resolvePath(e);
5767
+ return this.vfs.readdir(t);
5768
+ }
5769
+ async stat(e) {
5770
+ const t = this.resolvePath(e), s = this.vfs.stat(t);
5771
+ return { type: s.type, size: s.size, mtime: s.mtime };
5772
+ }
5773
+ async mkdir(e, t) {
5774
+ const s = this.resolvePath(e);
5775
+ this.vfs.mkdir(s, t);
5776
+ }
5777
+ async rm(e, t) {
5778
+ const s = this.resolvePath(e);
5779
+ this.vfs.stat(s).type === "directory" ? t != null && t.recursive ? this.vfs.rmdirRecursive(s) : this.vfs.rmdir(s) : this.vfs.unlink(s);
5780
+ }
5781
+ async exists(e) {
5782
+ const t = this.resolvePath(e);
5783
+ return this.vfs.exists(t);
5784
+ }
5785
+ async rename(e, t) {
5786
+ const s = this.resolvePath(e), i = this.resolvePath(t);
5787
+ this.vfs.rename(s, i);
5788
+ }
5789
+ async cp(e, t) {
5790
+ const s = this.resolvePath(e), i = this.resolvePath(t);
5791
+ this.vfs.copyFile(s, i);
5792
+ }
5793
+ async writeFiles(e) {
5794
+ for (const { path: t, content: s } of e)
5795
+ await this.writeFile(t, s);
5796
+ }
5797
+ }
5798
+ class wr {
5799
+ constructor(e, t) {
5800
+ u(this, "queue", Promise.resolve());
5801
+ this.shell = e, this.registry = t;
5802
+ }
5803
+ run(e, t) {
5804
+ return new Promise((i, n) => {
5805
+ this.queue = this.queue.then(async () => {
5806
+ try {
5807
+ const o = await this.executeWithOptions(e, t);
5808
+ i(o);
5809
+ } catch (o) {
5810
+ n(o);
5811
+ }
5812
+ });
5813
+ });
5814
+ }
5815
+ register(e, t) {
5816
+ this.registry.register(e, t);
5817
+ }
5818
+ async executeWithOptions(e, t) {
5819
+ let s, i;
5820
+ if (t != null && t.timeout || t != null && t.signal) {
5821
+ if (s = new AbortController(), t.signal) {
5822
+ if (t.signal.aborted)
5823
+ return { stdout: "", stderr: "", exitCode: 130 };
5824
+ t.signal.addEventListener("abort", () => s.abort(), { once: !0 });
5825
+ }
5826
+ t.timeout && (i = setTimeout(() => s.abort(), t.timeout));
5827
+ }
5936
5828
  try {
5937
- const s = new At();
5938
- s.onContextLoss(() => s.dispose()), this.xterm.loadAddon(s);
5939
- } catch {
5829
+ return await this.shell.execute(e, {
5830
+ cwd: t == null ? void 0 : t.cwd,
5831
+ env: t == null ? void 0 : t.env,
5832
+ onStdout: t == null ? void 0 : t.onStdout,
5833
+ onStderr: t == null ? void 0 : t.onStderr,
5834
+ stdin: t == null ? void 0 : t.stdin
5835
+ });
5836
+ } finally {
5837
+ i !== void 0 && clearTimeout(i);
5940
5838
  }
5941
- this.fitAddon.fit(), new ResizeObserver(() => {
5942
- this.fitAddon.fit();
5943
- }).observe(e);
5839
+ }
5840
+ }
5841
+ class yr {
5842
+ constructor() {
5843
+ u(this, "dataCallback", null);
5944
5844
  }
5945
5845
  write(e) {
5946
- this.xterm.write(e);
5947
5846
  }
5948
5847
  writeln(e) {
5949
- this.xterm.writeln(e);
5950
5848
  }
5951
5849
  onData(e) {
5952
- this.xterm.onData(e);
5850
+ this.dataCallback = e;
5953
5851
  }
5954
5852
  get cols() {
5955
- return this.xterm.cols;
5853
+ return 80;
5956
5854
  }
5957
5855
  get rows() {
5958
- return this.xterm.rows;
5856
+ return 24;
5959
5857
  }
5960
5858
  focus() {
5961
- this.xterm.focus();
5962
5859
  }
5963
5860
  clear() {
5964
- this.xterm.clear();
5861
+ }
5862
+ /** Send data as if typed on keyboard (used internally for stdin) */
5863
+ sendData(e) {
5864
+ var t;
5865
+ (t = this.dataCallback) == null || t.call(this, e);
5965
5866
  }
5966
5867
  }
5967
- const Ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5968
- __proto__: null,
5969
- Terminal: Cr
5970
- }, Symbol.toStringTag, { value: "Module" }));
5868
+ class kt {
5869
+ constructor(e, t, s, i, n) {
5870
+ /** Programmatic command execution */
5871
+ u(this, "commands");
5872
+ /** Filesystem operations */
5873
+ u(this, "fs");
5874
+ /** Environment variables */
5875
+ u(this, "env");
5876
+ // Power-user escape hatches
5877
+ u(this, "kernel");
5878
+ u(this, "shell");
5879
+ u(this, "_destroyed", !1);
5880
+ this.kernel = e, this.shell = t, this.commands = s, this.fs = i, this.env = n;
5881
+ }
5882
+ /** Current working directory */
5883
+ get cwd() {
5884
+ return this.shell.getCwd();
5885
+ }
5886
+ set cwd(e) {
5887
+ this.shell.setCwd(e);
5888
+ }
5889
+ /**
5890
+ * Create a new Sandbox instance.
5891
+ * Orchestrates all boot steps: Kernel, VFS, Registry, Shell, config sourcing.
5892
+ */
5893
+ static async create(e) {
5894
+ const t = new Zt();
5895
+ await t.boot({ persist: (e == null ? void 0 : e.persist) ?? !1 });
5896
+ const s = Rs();
5897
+ if (s.register("pkg", Is(s)), pr(t.vfs, s), e != null && e.files)
5898
+ for (const [y, E] of Object.entries(e.files))
5899
+ br(t.vfs, y), t.vfs.writeFile(y, E);
5900
+ const n = { ...t.getDefaultEnv(), ...e == null ? void 0 : e.env };
5901
+ e != null && e.cwd && (n.PWD = e.cwd);
5902
+ let o, a = !1;
5903
+ if (typeof (e == null ? void 0 : e.terminal) == "string" || typeof HTMLElement < "u" && (e == null ? void 0 : e.terminal) instanceof HTMLElement) {
5904
+ const { Terminal: y } = await import("@lifo-sh/ui"), E = vr(e.terminal), _ = new y(E);
5905
+ o = _, a = !0;
5906
+ const L = t.vfs.readFileString("/etc/motd");
5907
+ _.write(L.replace(/\r\n/g, `
5908
+ `).replace(/\n/g, `\r
5909
+ `));
5910
+ } else e != null && e.terminal && typeof e.terminal == "object" ? (o = e.terminal, a = !0) : o = new yr();
5911
+ const c = new Ts(o, t.vfs, s, n), l = c.getJobTable();
5912
+ s.register("ps", Bs(l)), s.register("top", zs(l)), s.register("kill", Ds(l)), s.register("watch", Os(s)), s.register("help", qs()), s.register("node", $t(t.portRegistry)), s.register("curl", St(t.portRegistry)), await c.sourceFile("/etc/profile"), await c.sourceFile(n.HOME + "/.bashrc"), e != null && e.cwd && c.setCwd(e.cwd), a && (c.start(), o.focus());
5913
+ const f = () => c.getCwd(), h = new gr(t.vfs, f), p = new wr(c, s);
5914
+ return new kt(t, c, p, h, n);
5915
+ }
5916
+ /**
5917
+ * Attach a headless sandbox to a DOM element, enabling visual mode.
5918
+ */
5919
+ async attach(e) {
5920
+ if (this._destroyed) throw new Error("Sandbox is destroyed");
5921
+ const { Terminal: t } = await import("@lifo-sh/ui"), s = new t(e), i = this.kernel.vfs.readFileString("/etc/motd");
5922
+ s.write(i.replace(/\r\n/g, `
5923
+ `).replace(/\n/g, `\r
5924
+ `)), s.focus();
5925
+ }
5926
+ /**
5927
+ * Detach from visual mode.
5928
+ */
5929
+ detach() {
5930
+ }
5931
+ /**
5932
+ * Destroy the sandbox, releasing all resources.
5933
+ */
5934
+ destroy() {
5935
+ this._destroyed = !0;
5936
+ }
5937
+ }
5938
+ function vr(r) {
5939
+ if (typeof r == "string") {
5940
+ const e = document.querySelector(r);
5941
+ if (!e) throw new Error(`Sandbox: element not found: ${r}`);
5942
+ return e;
5943
+ }
5944
+ return r;
5945
+ }
5946
+ function br(r, e) {
5947
+ const t = e.split("/").filter(Boolean);
5948
+ t.pop();
5949
+ let s = "";
5950
+ for (const i of t)
5951
+ s += "/" + i, r.exists(s) || r.mkdir(s, { recursive: !0 });
5952
+ }
5971
5953
  export {
5972
- Hr as $,
5954
+ Br as $,
5973
5955
  We as A,
5974
5956
  Y as B,
5975
- ts as C,
5976
- Xt as D,
5957
+ Kt as C,
5958
+ Jt as D,
5977
5959
  C as E,
5978
- br as F,
5960
+ $t as F,
5979
5961
  oe as G,
5980
- Bs as H,
5981
- Rr as I,
5982
- bs as J,
5983
- Yt as K,
5984
- js as L,
5985
- es as M,
5986
- Ds as N,
5987
- Ws as O,
5988
- Ns as P,
5989
- Vr as Q,
5962
+ yr as H,
5963
+ Sr as I,
5964
+ ys as J,
5965
+ Zt as K,
5966
+ Is as L,
5967
+ Qt as M,
5968
+ Bs as N,
5969
+ zs as O,
5970
+ Fs as P,
5971
+ Os as Q,
5990
5972
  z as R,
5991
- Ye as S,
5992
- Cr as T,
5993
- Fr as U,
5973
+ kt as S,
5974
+ zr as T,
5975
+ kr as U,
5994
5976
  k as V,
5995
- Ir as W,
5996
- Zr as X,
5997
- Kt as Y,
5998
- Wr as Z,
5999
- Zs as _,
5977
+ Er as W,
5978
+ Dr as X,
5979
+ Xt as Y,
5980
+ Fr as Z,
5981
+ pr as _,
6000
5982
  ae as a,
6001
- Mr as a0,
6002
- qr as a1,
5983
+ Ar as a0,
5984
+ Ir as a1,
6003
5985
  K as b,
6004
- _r as c,
5986
+ xr as c,
6005
5987
  G as d,
6006
5988
  Q as e,
6007
5989
  ee as f,
6008
5990
  M as g,
6009
- Ft as h,
6010
- jr as i,
6011
- Or as j,
6012
- Br as k,
6013
- Dr as l,
6014
- Nr as m,
6015
- zr as n,
6016
- Rs as o,
6017
- st as p,
6018
- Qt as q,
5991
+ Rt as h,
5992
+ Tr as i,
5993
+ Rr as j,
5994
+ Lr as k,
5995
+ _r as l,
5996
+ Cr as m,
5997
+ Pr as n,
5998
+ _s as o,
5999
+ et as p,
6000
+ Yt as q,
6019
6001
  I as r,
6020
- _s as s,
6021
- It as t,
6022
- Ur as u,
6023
- Gr as v,
6024
- xr as w,
6025
- Fs as x,
6026
- Hs as y,
6027
- Ms as z
6002
+ Ts as s,
6003
+ At as t,
6004
+ Nr as u,
6005
+ jr as v,
6006
+ St as w,
6007
+ Rs as x,
6008
+ qs as y,
6009
+ Ds as z
6028
6010
  };