cvm-server 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/main.cjs +1067 -874
  2. package/package.json +1 -1
package/main.cjs CHANGED
@@ -3,7 +3,7 @@ const mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
3
3
  const stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
4
4
  const zod = require("zod");
5
5
  const s$1 = require("typescript");
6
- const N$1 = require("fs");
6
+ const b$2 = require("fs");
7
7
  const r = require("path");
8
8
  const mongodb = require("mongodb");
9
9
  const promises = require("fs/promises");
@@ -11,31 +11,31 @@ const dotenv = require("dotenv");
11
11
  const url = require("url");
12
12
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
13
13
  function _interopNamespaceDefault(e2) {
14
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
14
+ const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
15
15
  if (e2) {
16
16
  for (const k2 in e2) {
17
17
  if (k2 !== "default") {
18
18
  const d2 = Object.getOwnPropertyDescriptor(e2, k2);
19
- Object.defineProperty(n, k2, d2.get ? d2 : {
19
+ Object.defineProperty(n2, k2, d2.get ? d2 : {
20
20
  enumerable: true,
21
21
  get: () => e2[k2]
22
22
  });
23
23
  }
24
24
  }
25
25
  }
26
- n.default = e2;
27
- return Object.freeze(n);
26
+ n2.default = e2;
27
+ return Object.freeze(n2);
28
28
  }
29
29
  const s__namespace = /* @__PURE__ */ _interopNamespaceDefault(s$1);
30
- const N__namespace = /* @__PURE__ */ _interopNamespaceDefault(N$1);
30
+ const b__namespace = /* @__PURE__ */ _interopNamespaceDefault(b$2);
31
31
  const r__namespace = /* @__PURE__ */ _interopNamespaceDefault(r);
32
32
  const dotenv__namespace = /* @__PURE__ */ _interopNamespaceDefault(dotenv);
33
- var _$1 = Object.defineProperty;
34
- var I = (e2, t2, n) => t2 in e2 ? _$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: n }) : e2[t2] = n;
35
- var o$1 = (e2, t2, n) => I(e2, typeof t2 != "symbol" ? t2 + "" : t2, n);
36
- var i$2 = /* @__PURE__ */ ((e2) => (e2.PUSH = "PUSH", e2.PUSH_UNDEFINED = "PUSH_UNDEFINED", e2.POP = "POP", e2.DUP = "DUP", e2.DUP2 = "DUP2", e2.SWAP = "SWAP", e2.LOAD = "LOAD", e2.STORE = "STORE", e2.CONCAT = "CONCAT", e2.ARRAY_NEW = "ARRAY_NEW", e2.ARRAY_PUSH = "ARRAY_PUSH", e2.ARRAY_GET = "ARRAY_GET", e2.ARRAY_SET = "ARRAY_SET", e2.ARRAY_LEN = "ARRAY_LEN", e2.ARRAY_MAP_PROP = "ARRAY_MAP_PROP", e2.ARRAY_FILTER_PROP = "ARRAY_FILTER_PROP", e2.ARRAY_SLICE = "ARRAY_SLICE", e2.ARRAY_JOIN = "ARRAY_JOIN", e2.ARRAY_INDEX_OF = "ARRAY_INDEX_OF", e2.STRING_LEN = "STRING_LEN", e2.STRING_SUBSTRING = "STRING_SUBSTRING", e2.STRING_INDEXOF = "STRING_INDEXOF", e2.STRING_SPLIT = "STRING_SPLIT", e2.STRING_SLICE = "STRING_SLICE", e2.STRING_CHARAT = "STRING_CHARAT", e2.STRING_TOUPPERCASE = "STRING_TOUPPERCASE", e2.STRING_TOLOWERCASE = "STRING_TOLOWERCASE", e2.STRING_INCLUDES = "STRING_INCLUDES", e2.STRING_ENDS_WITH = "STRING_ENDS_WITH", e2.STRING_STARTS_WITH = "STRING_STARTS_WITH", e2.STRING_TRIM = "STRING_TRIM", e2.STRING_TRIM_START = "STRING_TRIM_START", e2.STRING_TRIM_END = "STRING_TRIM_END", e2.STRING_REPLACE = "STRING_REPLACE", e2.STRING_REPLACE_ALL = "STRING_REPLACE_ALL", e2.STRING_LAST_INDEX_OF = "STRING_LAST_INDEX_OF", e2.STRING_REPEAT = "STRING_REPEAT", e2.STRING_PAD_START = "STRING_PAD_START", e2.STRING_PAD_END = "STRING_PAD_END", e2.LOAD_REGEX = "LOAD_REGEX", e2.LENGTH = "LENGTH", e2.TO_STRING = "TO_STRING", e2.JSON_PARSE = "JSON_PARSE", e2.TYPEOF = "TYPEOF", e2.ADD = "ADD", e2.SUB = "SUB", e2.MUL = "MUL", e2.DIV = "DIV", e2.MOD = "MOD", e2.UNARY_MINUS = "UNARY_MINUS", e2.UNARY_PLUS = "UNARY_PLUS", e2.INC = "INC", e2.DEC = "DEC", e2.EQ = "EQ", e2.NEQ = "NEQ", e2.LT = "LT", e2.GT = "GT", e2.LTE = "LTE", e2.GTE = "GTE", e2.EQ_STRICT = "EQ_STRICT", e2.NEQ_STRICT = "NEQ_STRICT", e2.JUMP = "JUMP", e2.JUMP_IF = "JUMP_IF", e2.JUMP_IF_FALSE = "JUMP_IF_FALSE", e2.JUMP_IF_TRUE = "JUMP_IF_TRUE", e2.CALL = "CALL", e2.RETURN = "RETURN", e2.AND = "AND", e2.OR = "OR", e2.NOT = "NOT", e2.BREAK = "BREAK", e2.CONTINUE = "CONTINUE", e2.ITER_START = "ITER_START", e2.ITER_NEXT = "ITER_NEXT", e2.ITER_END = "ITER_END", e2.OBJECT_ITER_START = "OBJECT_ITER_START", e2.OBJECT_ITER_NEXT = "OBJECT_ITER_NEXT", e2.FS_LIST_FILES = "FS_LIST_FILES", e2.FS_READ_FILE = "FS_READ_FILE", e2.FS_WRITE_FILE = "FS_WRITE_FILE", e2.OBJECT_CREATE = "OBJECT_CREATE", e2.PROPERTY_GET = "PROPERTY_GET", e2.PROPERTY_SET = "PROPERTY_SET", e2.OBJECT_KEYS = "OBJECT_KEYS", e2.JSON_STRINGIFY = "JSON_STRINGIFY", e2.GET = "GET", e2.SET = "SET", e2.CC = "CC", e2.PRINT = "PRINT", e2.HALT = "HALT", e2))(i$2 || {});
37
- function A(e2) {
38
- const t2 = [], n = [];
33
+ var f$3 = Object.defineProperty;
34
+ var I = (e2, t2, i2) => t2 in e2 ? f$3(e2, t2, { enumerable: true, configurable: true, writable: true, value: i2 }) : e2[t2] = i2;
35
+ var _$1 = (e2, t2, i2) => I(e2, typeof t2 != "symbol" ? t2 + "" : t2, i2);
36
+ var n = /* @__PURE__ */ ((e2) => (e2.PUSH = "PUSH", e2.PUSH_UNDEFINED = "PUSH_UNDEFINED", e2.POP = "POP", e2.DUP = "DUP", e2.DUP2 = "DUP2", e2.SWAP = "SWAP", e2.LOAD = "LOAD", e2.STORE = "STORE", e2.CONCAT = "CONCAT", e2.ARRAY_NEW = "ARRAY_NEW", e2.ARRAY_PUSH = "ARRAY_PUSH", e2.ARRAY_GET = "ARRAY_GET", e2.ARRAY_SET = "ARRAY_SET", e2.ARRAY_LEN = "ARRAY_LEN", e2.ARRAY_MAP_PROP = "ARRAY_MAP_PROP", e2.ARRAY_FILTER_PROP = "ARRAY_FILTER_PROP", e2.ARRAY_SLICE = "ARRAY_SLICE", e2.ARRAY_JOIN = "ARRAY_JOIN", e2.ARRAY_INDEX_OF = "ARRAY_INDEX_OF", e2.STRING_LEN = "STRING_LEN", e2.STRING_SUBSTRING = "STRING_SUBSTRING", e2.STRING_INDEXOF = "STRING_INDEXOF", e2.STRING_SPLIT = "STRING_SPLIT", e2.STRING_SLICE = "STRING_SLICE", e2.STRING_CHARAT = "STRING_CHARAT", e2.STRING_TOUPPERCASE = "STRING_TOUPPERCASE", e2.STRING_TOLOWERCASE = "STRING_TOLOWERCASE", e2.STRING_INCLUDES = "STRING_INCLUDES", e2.STRING_ENDS_WITH = "STRING_ENDS_WITH", e2.STRING_STARTS_WITH = "STRING_STARTS_WITH", e2.STRING_TRIM = "STRING_TRIM", e2.STRING_TRIM_START = "STRING_TRIM_START", e2.STRING_TRIM_END = "STRING_TRIM_END", e2.STRING_REPLACE = "STRING_REPLACE", e2.STRING_REPLACE_ALL = "STRING_REPLACE_ALL", e2.STRING_LAST_INDEX_OF = "STRING_LAST_INDEX_OF", e2.STRING_REPEAT = "STRING_REPEAT", e2.STRING_PAD_START = "STRING_PAD_START", e2.STRING_PAD_END = "STRING_PAD_END", e2.LOAD_REGEX = "LOAD_REGEX", e2.REGEX_TEST = "REGEX_TEST", e2.STRING_MATCH = "STRING_MATCH", e2.STRING_REPLACE_REGEX = "STRING_REPLACE_REGEX", e2.LENGTH = "LENGTH", e2.TO_STRING = "TO_STRING", e2.JSON_PARSE = "JSON_PARSE", e2.TYPEOF = "TYPEOF", e2.ADD = "ADD", e2.SUB = "SUB", e2.MUL = "MUL", e2.DIV = "DIV", e2.MOD = "MOD", e2.UNARY_MINUS = "UNARY_MINUS", e2.UNARY_PLUS = "UNARY_PLUS", e2.INC = "INC", e2.DEC = "DEC", e2.EQ = "EQ", e2.NEQ = "NEQ", e2.LT = "LT", e2.GT = "GT", e2.LTE = "LTE", e2.GTE = "GTE", e2.EQ_STRICT = "EQ_STRICT", e2.NEQ_STRICT = "NEQ_STRICT", e2.JUMP = "JUMP", e2.JUMP_IF = "JUMP_IF", e2.JUMP_IF_FALSE = "JUMP_IF_FALSE", e2.JUMP_IF_TRUE = "JUMP_IF_TRUE", e2.CALL = "CALL", e2.RETURN = "RETURN", e2.AND = "AND", e2.OR = "OR", e2.NOT = "NOT", e2.BREAK = "BREAK", e2.CONTINUE = "CONTINUE", e2.ITER_START = "ITER_START", e2.ITER_NEXT = "ITER_NEXT", e2.ITER_END = "ITER_END", e2.OBJECT_ITER_START = "OBJECT_ITER_START", e2.OBJECT_ITER_NEXT = "OBJECT_ITER_NEXT", e2.FS_LIST_FILES = "FS_LIST_FILES", e2.FS_READ_FILE = "FS_READ_FILE", e2.FS_WRITE_FILE = "FS_WRITE_FILE", e2.OBJECT_CREATE = "OBJECT_CREATE", e2.PROPERTY_GET = "PROPERTY_GET", e2.PROPERTY_SET = "PROPERTY_SET", e2.OBJECT_KEYS = "OBJECT_KEYS", e2.JSON_STRINGIFY = "JSON_STRINGIFY", e2.GET = "GET", e2.SET = "SET", e2.CC = "CC", e2.PRINT = "PRINT", e2.HALT = "HALT", e2))(n || {});
37
+ function A$1(e2) {
38
+ const t2 = [], i2 = [];
39
39
  let r2 = false;
40
40
  const a2 = s__namespace.createSourceFile(
41
41
  "program.ts",
@@ -43,31 +43,31 @@ function A(e2) {
43
43
  s__namespace.ScriptTarget.Latest,
44
44
  true
45
45
  );
46
- function m2(T) {
47
- if (s__namespace.isFunctionDeclaration(T) && T.name && T.name.text === "main" && (r2 = true, T.parameters.length > 0 && t2.push("main() must not have parameters")), s__namespace.isCallExpression(T) && s__namespace.isIdentifier(T.expression)) {
48
- const c2 = T.expression.text;
46
+ function T(S) {
47
+ if (s__namespace.isFunctionDeclaration(S) && S.name && S.name.text === "main" && (r2 = true, S.parameters.length > 0 && t2.push("main() must not have parameters")), s__namespace.isCallExpression(S) && s__namespace.isIdentifier(S.expression)) {
48
+ const c2 = S.expression.text;
49
49
  ["setTimeout", "fetch", "require", "import"].includes(c2) && t2.push(`Unsupported function: ${c2}`);
50
50
  }
51
- s__namespace.forEachChild(T, m2);
51
+ s__namespace.forEachChild(S, T);
52
52
  }
53
- return m2(a2), r2 || t2.push("Program must have a main() function"), t2.length === 0 && n.push({ op: i$2.HALT }), {
54
- bytecode: n,
53
+ return T(a2), r2 || t2.push("Program must have a main() function"), t2.length === 0 && i2.push({ op: n.HALT }), {
54
+ bytecode: i2,
55
55
  errors: t2,
56
56
  hasMain: r2
57
57
  };
58
58
  }
59
- class P {
59
+ class g {
60
60
  constructor() {
61
- o$1(this, "bytecode", []);
62
- o$1(this, "contextStack", []);
63
- o$1(this, "tempVarCounter", 0);
61
+ _$1(this, "bytecode", []);
62
+ _$1(this, "contextStack", []);
63
+ _$1(this, "tempVarCounter", 0);
64
64
  }
65
65
  /**
66
66
  * Emit an instruction and return its index
67
67
  */
68
- emit(t2, n) {
68
+ emit(t2, i2) {
69
69
  const r2 = this.bytecode.length;
70
- return this.bytecode.push({ op: t2, arg: n }), r2;
70
+ return this.bytecode.push({ op: t2, arg: i2 }), r2;
71
71
  }
72
72
  /**
73
73
  * Get the current address (next instruction index)
@@ -78,14 +78,14 @@ class P {
78
78
  /**
79
79
  * Patch a jump instruction with the target address
80
80
  */
81
- patchJump(t2, n) {
82
- t2 >= 0 && t2 < this.bytecode.length && (this.bytecode[t2].arg = n);
81
+ patchJump(t2, i2) {
82
+ t2 >= 0 && t2 < this.bytecode.length && (this.bytecode[t2].arg = i2);
83
83
  }
84
84
  /**
85
85
  * Patch multiple jump instructions with the same target
86
86
  */
87
- patchJumps(t2, n) {
88
- t2.forEach((r2) => this.patchJump(r2, n));
87
+ patchJumps(t2, i2) {
88
+ t2.forEach((r2) => this.patchJump(r2, i2));
89
89
  }
90
90
  /**
91
91
  * Push a new jump context onto the stack
@@ -110,9 +110,9 @@ class P {
110
110
  */
111
111
  findLoopContext() {
112
112
  for (let t2 = this.contextStack.length - 1; t2 >= 0; t2--) {
113
- const n = this.contextStack[t2];
114
- if (n.type === "loop" || n.type === "foreach")
115
- return n;
113
+ const i2 = this.contextStack[t2];
114
+ if (i2.type === "loop" || i2.type === "foreach")
115
+ return i2;
116
116
  }
117
117
  return null;
118
118
  }
@@ -141,427 +141,439 @@ class P {
141
141
  return `__temp${this.tempVarCounter++}`;
142
142
  }
143
143
  }
144
- const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
145
- n(e2.expression);
146
- const a2 = t2.emit(i$2.JUMP_IF_FALSE, -1), m2 = {
144
+ const P = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
145
+ i2(e2.expression);
146
+ const a2 = t2.emit(n.JUMP_IF_FALSE, -1), T = {
147
147
  type: "if",
148
148
  endTargets: []
149
149
  };
150
- if (e2.elseStatement ? m2.elseTarget = a2 : m2.endTargets.push(a2), t2.pushContext(m2), r2(e2.thenStatement), e2.elseStatement) {
151
- const c2 = t2.emit(i$2.JUMP, -1);
152
- m2.endTargets.push(c2);
153
- const S = t2.currentAddress();
154
- t2.patchJump(a2, S), r2(e2.elseStatement);
155
- }
156
- const T = t2.popContext();
157
- if (T) {
150
+ if (e2.elseStatement ? T.elseTarget = a2 : T.endTargets.push(a2), t2.pushContext(T), r2(e2.thenStatement), e2.elseStatement) {
151
+ const c2 = t2.emit(n.JUMP, -1);
152
+ T.endTargets.push(c2);
153
+ const m2 = t2.currentAddress();
154
+ t2.patchJump(a2, m2), r2(e2.elseStatement);
155
+ }
156
+ const S = t2.popContext();
157
+ if (S) {
158
158
  const c2 = t2.currentAddress();
159
- t2.patchJumps(T.endTargets, c2);
159
+ t2.patchJumps(S.endTargets, c2);
160
160
  }
161
- }, N = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
161
+ }, N = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
162
162
  const a2 = t2.currentAddress();
163
- n(e2.expression);
164
- const T = {
163
+ i2(e2.expression);
164
+ const S = {
165
165
  type: "loop",
166
- breakTargets: [t2.emit(i$2.JUMP_IF_FALSE, -1)],
166
+ breakTargets: [t2.emit(n.JUMP_IF_FALSE, -1)],
167
167
  continueTargets: [],
168
168
  endTargets: [],
169
169
  startAddress: a2
170
170
  };
171
- t2.pushContext(T), r2(e2.statement), t2.emit(i$2.JUMP, a2);
171
+ t2.pushContext(S), r2(e2.statement), t2.emit(n.JUMP, a2);
172
172
  const c2 = t2.popContext();
173
173
  if (c2) {
174
- const S = t2.currentAddress();
175
- t2.patchJumps(c2.breakTargets || [], S);
174
+ const m2 = t2.currentAddress();
175
+ t2.patchJumps(c2.breakTargets || [], m2), t2.patchJumps(c2.continueTargets || [], a2);
176
176
  }
177
- }, h$1 = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
178
- const a2 = e2.initializer, m2 = e2.expression;
179
- let T;
177
+ }, h$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
178
+ const a2 = e2.initializer, T = e2.expression;
179
+ let S;
180
180
  if (s__namespace.isVariableDeclarationList(a2))
181
- T = a2.declarations[0].name.getText();
181
+ S = a2.declarations[0].name.getText();
182
182
  else if (s__namespace.isIdentifier(a2))
183
- T = a2.text;
183
+ S = a2.text;
184
184
  else
185
185
  throw new Error("Unsupported for-of variable declaration");
186
- n(m2), t2.emit(i$2.ITER_START);
186
+ i2(T), t2.emit(n.ITER_START);
187
187
  const c2 = t2.currentAddress();
188
- t2.emit(i$2.ITER_NEXT);
189
- const S = t2.emit(i$2.JUMP_IF_FALSE, -1);
190
- t2.emit(i$2.STORE, T);
188
+ t2.emit(n.ITER_NEXT);
189
+ const m2 = t2.emit(n.JUMP_IF_FALSE, -1);
190
+ t2.emit(n.STORE, S);
191
191
  const u2 = {
192
192
  type: "foreach",
193
- breakTargets: [S],
193
+ breakTargets: [m2],
194
194
  continueTargets: [],
195
195
  endTargets: [],
196
196
  startAddress: c2,
197
- iterVariable: T
197
+ iterVariable: S
198
198
  };
199
- t2.pushContext(u2), r2(e2.statement), t2.emit(i$2.JUMP, c2);
199
+ t2.pushContext(u2), r2(e2.statement), t2.emit(n.JUMP, c2);
200
200
  const l = t2.popContext();
201
201
  if (l) {
202
- const x2 = t2.currentAddress();
203
- t2.patchJumps(l.breakTargets || [], x2), t2.emit(i$2.ITER_END);
202
+ const R = t2.currentAddress();
203
+ t2.patchJumps(l.breakTargets || [], R), t2.patchJumps(l.continueTargets || [], c2), t2.emit(n.ITER_END);
204
204
  }
205
- }, p$2 = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
206
- const a2 = e2.initializer, m2 = e2.expression;
207
- let T;
205
+ }, p$2 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
206
+ const a2 = e2.initializer, T = e2.expression;
207
+ let S;
208
208
  if (s__namespace.isVariableDeclarationList(a2))
209
- T = a2.declarations[0].name.getText();
209
+ S = a2.declarations[0].name.getText();
210
210
  else if (s__namespace.isIdentifier(a2))
211
- T = a2.text;
211
+ S = a2.text;
212
212
  else
213
213
  throw new Error("Unsupported for-in variable declaration");
214
- n(m2), t2.emit(i$2.OBJECT_ITER_START);
214
+ i2(T), t2.emit(n.OBJECT_ITER_START);
215
215
  const c2 = t2.currentAddress();
216
- t2.emit(i$2.OBJECT_ITER_NEXT);
217
- const S = t2.emit(i$2.JUMP_IF_FALSE, -1);
218
- t2.emit(i$2.STORE, T);
216
+ t2.emit(n.OBJECT_ITER_NEXT);
217
+ const m2 = t2.emit(n.JUMP_IF_FALSE, -1);
218
+ t2.emit(n.STORE, S);
219
219
  const u2 = {
220
220
  type: "foreach",
221
- breakTargets: [S],
221
+ breakTargets: [m2],
222
222
  continueTargets: [],
223
223
  endTargets: [],
224
224
  startAddress: c2,
225
- iterVariable: T
225
+ iterVariable: S
226
226
  };
227
- t2.pushContext(u2), r2(e2.statement), t2.emit(i$2.JUMP, c2);
227
+ t2.pushContext(u2), r2(e2.statement), t2.emit(n.JUMP, c2);
228
228
  const l = t2.popContext();
229
229
  if (l) {
230
- const x2 = t2.currentAddress();
231
- t2.patchJumps(l.breakTargets || [], x2), t2.emit(i$2.ITER_END);
230
+ const R = t2.currentAddress();
231
+ t2.patchJumps(l.breakTargets || [], R), t2.patchJumps(l.continueTargets || [], c2), t2.emit(n.ITER_END);
232
232
  }
233
- }, U = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
233
+ }, U = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
234
234
  if (e2.initializer)
235
235
  if (s__namespace.isVariableDeclarationList(e2.initializer))
236
- for (const S of e2.initializer.declarations)
237
- S.initializer && (n(S.initializer), t2.emit(i$2.STORE, S.name.getText()));
236
+ for (const u2 of e2.initializer.declarations)
237
+ u2.initializer && (i2(u2.initializer), t2.emit(n.STORE, u2.name.getText()));
238
238
  else
239
- n(e2.initializer), t2.emit(i$2.POP);
239
+ i2(e2.initializer), t2.emit(n.POP);
240
240
  const a2 = t2.currentAddress();
241
- let m2;
242
- e2.condition && (n(e2.condition), m2 = t2.emit(i$2.JUMP_IF_FALSE, -1));
243
- const T = {
241
+ let T;
242
+ e2.condition && (i2(e2.condition), T = t2.emit(n.JUMP_IF_FALSE, -1));
243
+ const S = {
244
244
  type: "loop",
245
- breakTargets: m2 ? [m2] : [],
245
+ breakTargets: T ? [T] : [],
246
246
  continueTargets: [],
247
247
  endTargets: [],
248
248
  startAddress: a2
249
249
  };
250
- t2.pushContext(T), r2(e2.statement), e2.incrementor && (n(e2.incrementor), t2.emit(i$2.POP)), t2.emit(i$2.JUMP, a2);
251
- const c2 = t2.popContext();
252
- if (c2) {
253
- const S = t2.currentAddress();
254
- t2.patchJumps(c2.breakTargets || [], S);
250
+ t2.pushContext(S), r2(e2.statement);
251
+ const c2 = t2.currentAddress();
252
+ e2.incrementor && (i2(e2.incrementor), t2.emit(n.POP)), t2.emit(n.JUMP, a2);
253
+ const m2 = t2.popContext();
254
+ if (m2) {
255
+ const u2 = t2.currentAddress();
256
+ t2.patchJumps(m2.breakTargets || [], u2), t2.patchJumps(m2.continueTargets || [], c2);
255
257
  }
256
- }, y$1 = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
258
+ }, y$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
257
259
  const a2 = t2.generateTempVar();
258
- n(e2.expression), t2.emit(i$2.STORE, a2);
259
- const m2 = [], T = [];
260
+ i2(e2.expression), t2.emit(n.STORE, a2);
261
+ const T = [], S = [];
260
262
  let c2 = null;
261
- if (e2.caseBlock.clauses.forEach((l, x2) => {
263
+ if (e2.caseBlock.clauses.forEach((l, R) => {
262
264
  if (s__namespace.isCaseClause(l)) {
263
- t2.emit(i$2.LOAD, a2), n(l.expression), t2.emit(i$2.EQ_STRICT);
264
- const R = t2.emit(i$2.JUMP_IF_TRUE, -1);
265
- T.push(R);
266
- } else s__namespace.isDefaultClause(l) && (c2 = t2.emit(i$2.JUMP, -1));
265
+ t2.emit(n.LOAD, a2), i2(l.expression), t2.emit(n.EQ_STRICT);
266
+ const E2 = t2.emit(n.JUMP_IF_TRUE, -1);
267
+ S.push(E2);
268
+ } else s__namespace.isDefaultClause(l) && (c2 = t2.emit(n.JUMP, -1));
267
269
  }), c2 === null) {
268
- const l = t2.emit(i$2.JUMP, -1);
269
- m2.push(l);
270
+ const l = t2.emit(n.JUMP, -1);
271
+ T.push(l);
270
272
  }
271
- let S = 0;
272
- e2.caseBlock.clauses.forEach((l, x2) => {
273
+ let m2 = 0;
274
+ e2.caseBlock.clauses.forEach((l, R) => {
273
275
  if (s__namespace.isCaseClause(l)) {
274
- const R = t2.currentAddress();
275
- t2.patchJumps([T[S]], R), S++, l.statements.forEach((E2) => {
276
- if (s__namespace.isBreakStatement(E2)) {
277
- const f3 = t2.emit(i$2.JUMP, -1);
278
- m2.push(f3);
276
+ const E2 = t2.currentAddress();
277
+ t2.patchJumps([S[m2]], E2), m2++, l.statements.forEach((x2) => {
278
+ if (s__namespace.isBreakStatement(x2)) {
279
+ const o2 = t2.emit(n.JUMP, -1);
280
+ T.push(o2);
279
281
  } else
280
- r2(E2);
282
+ r2(x2);
281
283
  });
282
284
  } else if (s__namespace.isDefaultClause(l)) {
283
- const R = t2.currentAddress();
284
- c2 !== null && t2.patchJumps([c2], R), l.statements.forEach((E2) => {
285
- if (s__namespace.isBreakStatement(E2)) {
286
- const f3 = t2.emit(i$2.JUMP, -1);
287
- m2.push(f3);
285
+ const E2 = t2.currentAddress();
286
+ c2 !== null && t2.patchJumps([c2], E2), l.statements.forEach((x2) => {
287
+ if (s__namespace.isBreakStatement(x2)) {
288
+ const o2 = t2.emit(n.JUMP, -1);
289
+ T.push(o2);
288
290
  } else
289
- r2(E2);
291
+ r2(x2);
290
292
  });
291
293
  }
292
294
  });
293
295
  const u2 = t2.currentAddress();
294
- t2.patchJumps(m2, u2);
295
- }, L$1 = (e2, t2, { compileStatement: n }) => {
296
+ t2.patchJumps(T, u2);
297
+ }, L = (e2, t2, { compileStatement: i2 }) => {
296
298
  e2.statements.forEach((r2) => {
297
- n(r2);
299
+ i2(r2);
298
300
  });
299
- }, k = (e2, t2, { compileExpression: n }) => {
301
+ }, k = (e2, t2, { compileExpression: i2 }) => {
300
302
  const r2 = e2.declarationList.declarations[0];
301
- r2.initializer && (n(r2.initializer), t2.emit(i$2.STORE, r2.name.getText()));
302
- }, D = (e2, t2, { compileExpression: n }) => {
303
+ r2.initializer && (i2(r2.initializer), t2.emit(n.STORE, r2.name.getText()));
304
+ }, G = (e2, t2, { compileExpression: i2 }) => {
303
305
  const r2 = e2.expression;
304
306
  if (s__namespace.isBinaryExpression(r2)) {
305
307
  const a2 = r2.operatorToken.kind;
306
308
  if (a2 === s__namespace.SyntaxKind.PlusEqualsToken || a2 === s__namespace.SyntaxKind.MinusEqualsToken || a2 === s__namespace.SyntaxKind.AsteriskEqualsToken || a2 === s__namespace.SyntaxKind.SlashEqualsToken || a2 === s__namespace.SyntaxKind.PercentEqualsToken) {
307
309
  if (s__namespace.isIdentifier(r2.left)) {
308
- switch (t2.emit(i$2.LOAD, r2.left.text), n(r2.right), a2) {
310
+ switch (t2.emit(n.LOAD, r2.left.text), i2(r2.right), a2) {
309
311
  case s__namespace.SyntaxKind.PlusEqualsToken:
310
- t2.emit(i$2.ADD);
312
+ t2.emit(n.ADD);
311
313
  break;
312
314
  case s__namespace.SyntaxKind.MinusEqualsToken:
313
- t2.emit(i$2.SUB);
315
+ t2.emit(n.SUB);
314
316
  break;
315
317
  case s__namespace.SyntaxKind.AsteriskEqualsToken:
316
- t2.emit(i$2.MUL);
318
+ t2.emit(n.MUL);
317
319
  break;
318
320
  case s__namespace.SyntaxKind.SlashEqualsToken:
319
- t2.emit(i$2.DIV);
321
+ t2.emit(n.DIV);
320
322
  break;
321
323
  case s__namespace.SyntaxKind.PercentEqualsToken:
322
- t2.emit(i$2.MOD);
324
+ t2.emit(n.MOD);
323
325
  break;
324
326
  }
325
- t2.emit(i$2.STORE, r2.left.text);
327
+ t2.emit(n.STORE, r2.left.text);
326
328
  } else if (s__namespace.isElementAccessExpression(r2.left))
327
329
  throw new Error("Compound assignment to array elements not yet supported");
328
330
  return;
329
331
  } else if (a2 === s__namespace.SyntaxKind.EqualsToken) {
330
- if (n(r2.right), s__namespace.isIdentifier(r2.left))
331
- t2.emit(i$2.STORE, r2.left.text);
332
+ if (i2(r2.right), s__namespace.isIdentifier(r2.left))
333
+ t2.emit(n.STORE, r2.left.text);
332
334
  else if (s__namespace.isElementAccessExpression(r2.left)) {
333
- const m2 = `__temp_${t2.getBytecode().length}`;
334
- t2.emit(i$2.STORE, m2), n(r2.left.expression), n(r2.left.argumentExpression), t2.emit(i$2.LOAD, m2), t2.emit(i$2.ARRAY_SET), t2.emit(i$2.POP);
335
+ const T = `__temp_${t2.getBytecode().length}`;
336
+ t2.emit(n.STORE, T), i2(r2.left.expression), i2(r2.left.argumentExpression), t2.emit(n.LOAD, T), t2.emit(n.ARRAY_SET), t2.emit(n.POP);
335
337
  } else if (s__namespace.isPropertyAccessExpression(r2.left)) {
336
- const m2 = `__temp_${t2.getBytecode().length}`;
337
- t2.emit(i$2.STORE, m2), n(r2.left.expression), t2.emit(i$2.PUSH, r2.left.name.text), t2.emit(i$2.LOAD, m2), t2.emit(i$2.PROPERTY_SET), t2.emit(i$2.POP);
338
+ const T = `__temp_${t2.getBytecode().length}`;
339
+ t2.emit(n.STORE, T), i2(r2.left.expression), t2.emit(n.PUSH, r2.left.name.text), t2.emit(n.LOAD, T), t2.emit(n.PROPERTY_SET), t2.emit(n.POP);
338
340
  }
339
341
  return;
340
342
  }
341
343
  }
342
344
  s__namespace.isCallExpression(r2) && s__namespace.isPropertyAccessExpression(r2.expression) && r2.expression.expression.getText() === "console" && r2.expression.name.getText() === "log" ? (r2.arguments.forEach((a2) => {
343
- n(a2);
344
- }), t2.emit(i$2.PRINT)) : s__namespace.isCallExpression(r2) && s__namespace.isIdentifier(r2.expression) && r2.expression.text === "CC" ? (r2.arguments.length > 0 && n(r2.arguments[0]), t2.emit(i$2.CC), t2.emit(i$2.POP)) : s__namespace.isCallExpression(r2) && s__namespace.isPropertyAccessExpression(r2.expression) && r2.expression.name.getText() === "push" ? (n(r2.expression.expression), r2.arguments.length > 0 && n(r2.arguments[0]), t2.emit(i$2.ARRAY_PUSH)) : (s__namespace.isPostfixUnaryExpression(r2) || s__namespace.isPrefixUnaryExpression(r2), n(r2), t2.emit(i$2.POP));
345
- }, G = (e2, t2, { compileExpression: n }) => {
346
- e2.expression ? n(e2.expression) : t2.emit(i$2.PUSH, null), t2.emit(i$2.RETURN);
347
- }, F$1 = (e2, t2, n) => {
345
+ i2(a2);
346
+ }), t2.emit(n.PRINT)) : s__namespace.isCallExpression(r2) && s__namespace.isIdentifier(r2.expression) && r2.expression.text === "CC" ? (r2.arguments.length > 0 && i2(r2.arguments[0]), t2.emit(n.CC), t2.emit(n.POP)) : s__namespace.isCallExpression(r2) && s__namespace.isPropertyAccessExpression(r2.expression) && r2.expression.name.getText() === "push" ? (i2(r2.expression.expression), r2.arguments.length > 0 && i2(r2.arguments[0]), t2.emit(n.ARRAY_PUSH)) : (s__namespace.isPostfixUnaryExpression(r2) || s__namespace.isPrefixUnaryExpression(r2), i2(r2), t2.emit(n.POP));
347
+ }, D = (e2, t2, { compileExpression: i2 }) => {
348
+ e2.expression ? i2(e2.expression) : t2.emit(n.PUSH, null), t2.emit(n.RETURN);
349
+ }, F$1 = (e2, t2, i2) => {
348
350
  const r2 = t2.findLoopContext();
349
351
  if (r2) {
350
- r2.type === "foreach" && t2.emit(i$2.ITER_END);
351
- const a2 = t2.emit(i$2.BREAK, -1);
352
+ r2.type === "foreach" && t2.emit(n.ITER_END);
353
+ const a2 = t2.emit(n.BREAK, -1);
352
354
  r2.breakTargets = r2.breakTargets || [], r2.breakTargets.push(a2);
353
355
  } else
354
- n.reportError(e2, "break statement not in loop");
355
- }, b$1 = (e2, t2, n) => {
356
+ i2.reportError(e2, "break statement not in loop");
357
+ }, b$1 = (e2, t2, i2) => {
356
358
  const r2 = t2.findLoopContext();
357
359
  if (r2 && r2.startAddress !== void 0) {
358
- const a2 = t2.emit(i$2.CONTINUE, r2.startAddress);
360
+ const a2 = t2.emit(n.CONTINUE, -1);
359
361
  r2.continueTargets = r2.continueTargets || [], r2.continueTargets.push(a2);
360
362
  } else
361
- n.reportError(e2, "continue statement not in loop");
363
+ i2.reportError(e2, "continue statement not in loop");
362
364
  }, K = {
363
- [s__namespace.SyntaxKind.IfStatement]: g,
365
+ [s__namespace.SyntaxKind.IfStatement]: P,
364
366
  [s__namespace.SyntaxKind.WhileStatement]: N,
365
367
  [s__namespace.SyntaxKind.ForOfStatement]: h$1,
366
368
  [s__namespace.SyntaxKind.ForInStatement]: p$2,
367
369
  [s__namespace.SyntaxKind.ForStatement]: U,
368
370
  [s__namespace.SyntaxKind.SwitchStatement]: y$1,
369
- [s__namespace.SyntaxKind.Block]: L$1,
371
+ [s__namespace.SyntaxKind.Block]: L,
370
372
  [s__namespace.SyntaxKind.VariableStatement]: k,
371
- [s__namespace.SyntaxKind.ExpressionStatement]: D,
372
- [s__namespace.SyntaxKind.ReturnStatement]: G,
373
+ [s__namespace.SyntaxKind.ExpressionStatement]: G,
374
+ [s__namespace.SyntaxKind.ReturnStatement]: D,
373
375
  [s__namespace.SyntaxKind.BreakStatement]: F$1,
374
376
  [s__namespace.SyntaxKind.ContinueStatement]: b$1
375
- }, J = (e2, t2, n) => {
376
- t2.emit(i$2.PUSH, e2.text);
377
- }, H = (e2, t2, n) => {
378
- t2.emit(i$2.PUSH, Number(e2.text));
379
- }, M$1 = (e2, t2, n) => {
380
- t2.emit(i$2.PUSH, true);
381
- }, Y = (e2, t2, n) => {
382
- t2.emit(i$2.PUSH, false);
383
- }, B$1 = (e2, t2, n) => {
384
- t2.emit(i$2.PUSH, null);
385
- }, C$2 = (e2, t2, n) => {
386
- const r2 = e2.text, a2 = r2.lastIndexOf("/"), m2 = r2.substring(1, a2), T = r2.substring(a2 + 1);
387
- t2.emit(i$2.LOAD_REGEX, { pattern: m2, flags: T });
388
- }, d$3 = (e2, t2, n) => {
389
- e2.text === "undefined" ? t2.emit(i$2.PUSH_UNDEFINED) : t2.emit(i$2.LOAD, e2.text);
390
- }, w$1 = (e2, t2, { compileExpression: n }) => {
391
- t2.emit(i$2.ARRAY_NEW), e2.elements.forEach((r2) => {
392
- n(r2), t2.emit(i$2.ARRAY_PUSH);
377
+ }, J = (e2, t2, i2) => {
378
+ t2.emit(n.PUSH, e2.text);
379
+ }, H = (e2, t2, i2) => {
380
+ t2.emit(n.PUSH, Number(e2.text));
381
+ }, M$2 = (e2, t2, i2) => {
382
+ t2.emit(n.PUSH, true);
383
+ }, Y = (e2, t2, i2) => {
384
+ t2.emit(n.PUSH, false);
385
+ }, B$1 = (e2, t2, i2) => {
386
+ t2.emit(n.PUSH, null);
387
+ }, C$2 = (e2, t2, i2) => {
388
+ const r2 = e2.text, a2 = r2.lastIndexOf("/"), T = r2.substring(1, a2), S = r2.substring(a2 + 1);
389
+ t2.emit(n.LOAD_REGEX, { pattern: T, flags: S });
390
+ }, w$1 = (e2, t2, i2) => {
391
+ e2.text === "undefined" ? t2.emit(n.PUSH_UNDEFINED) : t2.emit(n.LOAD, e2.text);
392
+ }, q = (e2, t2, { compileExpression: i2 }) => {
393
+ t2.emit(n.ARRAY_NEW), e2.elements.forEach((r2) => {
394
+ i2(r2), t2.emit(n.ARRAY_PUSH);
393
395
  });
394
- }, O = (e2, t2, { compileExpression: n }) => {
395
- n(e2.expression);
396
- }, q = (e2, t2, { compileExpression: n }) => {
397
- e2.name.text === "length" ? (n(e2.expression), t2.emit(i$2.LENGTH)) : (n(e2.expression), t2.emit(i$2.PUSH, e2.name.text), t2.emit(i$2.PROPERTY_GET));
398
- }, V$1 = (e2, t2, { compileExpression: n, reportError: r2 }) => {
399
- n(e2.expression), e2.argumentExpression ? n(e2.argumentExpression) : r2(e2, "Element access requires an index expression"), t2.emit(i$2.ARRAY_GET);
400
- }, W$1 = (e2, t2, { compileExpression: n }) => {
396
+ }, O = (e2, t2, { compileExpression: i2 }) => {
397
+ i2(e2.expression);
398
+ }, d$3 = (e2, t2, { compileExpression: i2 }) => {
399
+ e2.name.text === "length" ? (i2(e2.expression), t2.emit(n.LENGTH)) : (i2(e2.expression), t2.emit(n.PUSH, e2.name.text), t2.emit(n.PROPERTY_GET));
400
+ }, X = (e2, t2, { compileExpression: i2, reportError: r2 }) => {
401
+ i2(e2.expression), e2.argumentExpression ? i2(e2.argumentExpression) : r2(e2, "Element access requires an index expression"), t2.emit(n.ARRAY_GET);
402
+ }, V$1 = (e2, t2, { compileExpression: i2 }) => {
401
403
  switch (e2.operator) {
402
404
  case s__namespace.SyntaxKind.ExclamationToken:
403
- n(e2.operand), t2.emit(i$2.NOT);
405
+ i2(e2.operand), t2.emit(n.NOT);
404
406
  break;
405
407
  case s__namespace.SyntaxKind.MinusToken:
406
- n(e2.operand), t2.emit(i$2.UNARY_MINUS);
408
+ i2(e2.operand), t2.emit(n.UNARY_MINUS);
407
409
  break;
408
410
  case s__namespace.SyntaxKind.PlusToken:
409
- n(e2.operand), t2.emit(i$2.UNARY_PLUS);
411
+ i2(e2.operand), t2.emit(n.UNARY_PLUS);
410
412
  break;
411
413
  case s__namespace.SyntaxKind.PlusPlusToken:
412
- s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.INC, false));
414
+ s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.INC, false));
413
415
  break;
414
416
  case s__namespace.SyntaxKind.MinusMinusToken:
415
- s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.DEC, false));
417
+ s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.DEC, false));
416
418
  break;
417
419
  }
418
- }, j$2 = (e2, t2, { compileExpression: n }) => {
420
+ }, W$1 = (e2, t2, { compileExpression: i2 }) => {
419
421
  switch (e2.operator) {
420
422
  case s__namespace.SyntaxKind.PlusPlusToken:
421
- s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.INC, true));
423
+ s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.INC, true));
422
424
  break;
423
425
  case s__namespace.SyntaxKind.MinusMinusToken:
424
- s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.DEC, true));
426
+ s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.DEC, true));
425
427
  break;
426
428
  }
427
- }, X = (e2, t2, { compileExpression: n }) => {
429
+ }, j$1 = (e2, t2, { compileExpression: i2 }) => {
428
430
  const r2 = e2.operatorToken.kind;
429
- switch (n(e2.left), n(e2.right), r2) {
431
+ switch (i2(e2.left), i2(e2.right), r2) {
430
432
  case s__namespace.SyntaxKind.PlusToken:
431
- t2.emit(i$2.ADD);
433
+ t2.emit(n.ADD);
432
434
  break;
433
435
  case s__namespace.SyntaxKind.MinusToken:
434
- t2.emit(i$2.SUB);
436
+ t2.emit(n.SUB);
435
437
  break;
436
438
  case s__namespace.SyntaxKind.AsteriskToken:
437
- t2.emit(i$2.MUL);
439
+ t2.emit(n.MUL);
438
440
  break;
439
441
  case s__namespace.SyntaxKind.SlashToken:
440
- t2.emit(i$2.DIV);
442
+ t2.emit(n.DIV);
441
443
  break;
442
444
  case s__namespace.SyntaxKind.PercentToken:
443
- t2.emit(i$2.MOD);
445
+ t2.emit(n.MOD);
444
446
  break;
445
447
  case s__namespace.SyntaxKind.EqualsEqualsToken:
446
- t2.emit(i$2.EQ);
448
+ t2.emit(n.EQ);
447
449
  break;
448
450
  case s__namespace.SyntaxKind.ExclamationEqualsToken:
449
- t2.emit(i$2.NEQ);
451
+ t2.emit(n.NEQ);
450
452
  break;
451
453
  case s__namespace.SyntaxKind.LessThanToken:
452
- t2.emit(i$2.LT);
454
+ t2.emit(n.LT);
453
455
  break;
454
456
  case s__namespace.SyntaxKind.GreaterThanToken:
455
- t2.emit(i$2.GT);
457
+ t2.emit(n.GT);
456
458
  break;
457
459
  case s__namespace.SyntaxKind.LessThanEqualsToken:
458
- t2.emit(i$2.LTE);
460
+ t2.emit(n.LTE);
459
461
  break;
460
462
  case s__namespace.SyntaxKind.GreaterThanEqualsToken:
461
- t2.emit(i$2.GTE);
463
+ t2.emit(n.GTE);
462
464
  break;
463
465
  case s__namespace.SyntaxKind.EqualsEqualsEqualsToken:
464
- t2.emit(i$2.EQ_STRICT);
466
+ t2.emit(n.EQ_STRICT);
465
467
  break;
466
468
  case s__namespace.SyntaxKind.ExclamationEqualsEqualsToken:
467
- t2.emit(i$2.NEQ_STRICT);
469
+ t2.emit(n.NEQ_STRICT);
468
470
  break;
469
471
  case s__namespace.SyntaxKind.AmpersandAmpersandToken:
470
- t2.emit(i$2.AND);
472
+ t2.emit(n.AND);
471
473
  break;
472
474
  case s__namespace.SyntaxKind.BarBarToken:
473
- t2.emit(i$2.OR);
475
+ t2.emit(n.OR);
474
476
  break;
475
477
  }
476
- }, v = (e2, t2, { compileExpression: n }) => {
477
- n(e2.condition);
478
- const r2 = t2.emit(i$2.JUMP_IF_FALSE, -1);
479
- n(e2.whenTrue);
480
- const a2 = t2.emit(i$2.JUMP, -1), m2 = t2.currentAddress();
481
- t2.patchJump(r2, m2), n(e2.whenFalse);
482
- const T = t2.currentAddress();
483
- t2.patchJump(a2, T);
484
- }, z = (e2, t2, { compileExpression: n }) => {
485
- n(e2.expression), t2.emit(i$2.TYPEOF);
486
- }, Q$1 = (e2, t2, { compileExpression: n, reportError: r2 }) => {
478
+ }, v$1 = (e2, t2, { compileExpression: i2 }) => {
479
+ i2(e2.condition);
480
+ const r2 = t2.emit(n.JUMP_IF_FALSE, -1);
481
+ i2(e2.whenTrue);
482
+ const a2 = t2.emit(n.JUMP, -1), T = t2.currentAddress();
483
+ t2.patchJump(r2, T), i2(e2.whenFalse);
484
+ const S = t2.currentAddress();
485
+ t2.patchJump(a2, S);
486
+ }, z = (e2, t2, { compileExpression: i2 }) => {
487
+ i2(e2.expression), t2.emit(n.TYPEOF);
488
+ }, Q$1 = (e2, t2, { compileExpression: i2, reportError: r2 }) => {
487
489
  if (s__namespace.isPropertyAccessExpression(e2.expression) && s__namespace.isIdentifier(e2.expression.expression) && e2.expression.expression.text === "fs") {
488
490
  const a2 = e2.expression.name.text;
489
491
  if (a2 === "listFiles")
490
- e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, "."), e2.arguments.length > 1 && n(e2.arguments[1]), t2.emit(i$2.FS_LIST_FILES);
492
+ e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, "."), e2.arguments.length > 1 && i2(e2.arguments[1]), t2.emit(n.FS_LIST_FILES);
491
493
  else if (a2 === "readFile")
492
- e2.arguments.length > 0 ? (n(e2.arguments[0]), t2.emit(i$2.FS_READ_FILE)) : r2(e2, "fs.readFile() requires a path argument");
494
+ e2.arguments.length > 0 ? (i2(e2.arguments[0]), t2.emit(n.FS_READ_FILE)) : r2(e2, "fs.readFile() requires a path argument");
493
495
  else if (a2 === "writeFile") {
494
496
  if (e2.arguments.length < 2) {
495
497
  r2(e2, "fs.writeFile() requires path and content arguments");
496
498
  return;
497
499
  }
498
- n(e2.arguments[0]), n(e2.arguments[1]), t2.emit(i$2.FS_WRITE_FILE);
500
+ i2(e2.arguments[0]), i2(e2.arguments[1]), t2.emit(n.FS_WRITE_FILE);
499
501
  } else
500
502
  r2(e2, `Unsupported fs method: ${a2}`);
501
503
  } else if (s__namespace.isPropertyAccessExpression(e2.expression) && s__namespace.isIdentifier(e2.expression.expression) && e2.expression.expression.text === "JSON" && e2.expression.name.text === "parse")
502
- e2.arguments.length > 0 && n(e2.arguments[0]), t2.emit(i$2.JSON_PARSE);
504
+ e2.arguments.length > 0 && i2(e2.arguments[0]), t2.emit(n.JSON_PARSE);
503
505
  else if (s__namespace.isPropertyAccessExpression(e2.expression) && s__namespace.isIdentifier(e2.expression.expression) && e2.expression.expression.text === "JSON" && e2.expression.name.text === "stringify")
504
- e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH_UNDEFINED), t2.emit(i$2.JSON_STRINGIFY);
506
+ e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH_UNDEFINED), t2.emit(n.JSON_STRINGIFY);
505
507
  else if (s__namespace.isPropertyAccessExpression(e2.expression) && s__namespace.isIdentifier(e2.expression.expression) && e2.expression.expression.text === "Object" && e2.expression.name.text === "keys") {
506
508
  if (e2.arguments.length !== 1) {
507
509
  r2(e2, "Object.keys() requires exactly one argument");
508
510
  return;
509
511
  }
510
- n(e2.arguments[0]), t2.emit(i$2.OBJECT_KEYS);
512
+ i2(e2.arguments[0]), t2.emit(n.OBJECT_KEYS);
511
513
  } else if (s__namespace.isIdentifier(e2.expression) && e2.expression.text === "CC")
512
- e2.arguments.length > 0 && n(e2.arguments[0]), t2.emit(i$2.CC);
514
+ e2.arguments.length > 0 && i2(e2.arguments[0]), t2.emit(n.CC);
513
515
  else if (s__namespace.isPropertyAccessExpression(e2.expression)) {
514
516
  const a2 = e2.expression.name.text;
515
517
  if (a2 === "substring")
516
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), e2.arguments.length > 1 && n(e2.arguments[1]), t2.emit(i$2.STRING_SUBSTRING);
518
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 && i2(e2.arguments[1]), t2.emit(n.STRING_SUBSTRING);
517
519
  else if (a2 === "indexOf")
518
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_INDEXOF);
520
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_INDEXOF);
519
521
  else if (a2 === "split")
520
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_SPLIT);
522
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_SPLIT);
521
523
  else if (a2 === "slice")
522
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH_UNDEFINED), t2.emit(i$2.STRING_SLICE);
524
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH_UNDEFINED), t2.emit(n.STRING_SLICE);
523
525
  else if (a2 === "join")
524
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ","), t2.emit(i$2.ARRAY_JOIN);
526
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ","), t2.emit(n.ARRAY_JOIN);
525
527
  else if (a2 === "charAt")
526
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), t2.emit(i$2.STRING_CHARAT);
528
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), t2.emit(n.STRING_CHARAT);
527
529
  else if (a2 === "toUpperCase")
528
- n(e2.expression.expression), t2.emit(i$2.STRING_TOUPPERCASE);
530
+ i2(e2.expression.expression), t2.emit(n.STRING_TOUPPERCASE);
529
531
  else if (a2 === "toLowerCase")
530
- n(e2.expression.expression), t2.emit(i$2.STRING_TOLOWERCASE);
532
+ i2(e2.expression.expression), t2.emit(n.STRING_TOLOWERCASE);
531
533
  else if (a2 === "toString")
532
- n(e2.expression.expression), t2.emit(i$2.TO_STRING);
534
+ i2(e2.expression.expression), t2.emit(n.TO_STRING);
533
535
  else if (a2 === "includes")
534
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_INCLUDES);
536
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_INCLUDES);
535
537
  else if (a2 === "endsWith")
536
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_ENDS_WITH);
538
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_ENDS_WITH);
537
539
  else if (a2 === "startsWith")
538
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_STARTS_WITH);
540
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_STARTS_WITH);
539
541
  else if (a2 === "trim")
540
- n(e2.expression.expression), t2.emit(i$2.STRING_TRIM);
542
+ i2(e2.expression.expression), t2.emit(n.STRING_TRIM);
541
543
  else if (a2 === "trimStart")
542
- n(e2.expression.expression), t2.emit(i$2.STRING_TRIM_START);
544
+ i2(e2.expression.expression), t2.emit(n.STRING_TRIM_START);
543
545
  else if (a2 === "trimEnd")
544
- n(e2.expression.expression), t2.emit(i$2.STRING_TRIM_END);
545
- else if (a2 === "replace")
546
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_REPLACE);
546
+ i2(e2.expression.expression), t2.emit(n.STRING_TRIM_END);
547
+ else if (a2 === "test")
548
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.REGEX_TEST);
549
+ else if (a2 === "match") {
550
+ if (i2(e2.expression.expression), e2.arguments.length > 0)
551
+ i2(e2.arguments[0]);
552
+ else {
553
+ r2(e2, "match() requires a regex argument");
554
+ return;
555
+ }
556
+ t2.emit(n.STRING_MATCH);
557
+ } else if (a2 === "replace")
558
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_REPLACE_REGEX);
547
559
  else if (a2 === "replaceAll")
548
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_REPLACE_ALL);
560
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_REPLACE_ALL);
549
561
  else if (a2 === "lastIndexOf")
550
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_LAST_INDEX_OF);
562
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_LAST_INDEX_OF);
551
563
  else if (a2 === "repeat")
552
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), t2.emit(i$2.STRING_REPEAT);
564
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), t2.emit(n.STRING_REPEAT);
553
565
  else if (a2 === "padStart")
554
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH, " "), t2.emit(i$2.STRING_PAD_START);
566
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, " "), t2.emit(n.STRING_PAD_START);
555
567
  else if (a2 === "padEnd")
556
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH, " "), t2.emit(i$2.STRING_PAD_END);
568
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, " "), t2.emit(n.STRING_PAD_END);
557
569
  else if (a2 === "push")
558
- n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH_UNDEFINED), t2.emit(i$2.ARRAY_PUSH);
570
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH_UNDEFINED), t2.emit(n.ARRAY_PUSH);
559
571
  else
560
572
  throw new Error(`Method call '${a2}' is not supported`);
561
573
  } else
562
574
  throw new Error("Unsupported call expression");
563
- }, $$1 = (e2, t2, { compileExpression: n }) => {
564
- t2.emit(i$2.OBJECT_CREATE);
575
+ }, $$1 = (e2, t2, { compileExpression: i2 }) => {
576
+ t2.emit(n.OBJECT_CREATE);
565
577
  for (const r2 of e2.properties)
566
578
  if (s__namespace.isPropertyAssignment(r2)) {
567
579
  let a2;
@@ -571,93 +583,93 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
571
583
  a2 = r2.name.text;
572
584
  else
573
585
  throw new Error("Computed property names are not supported");
574
- t2.emit(i$2.PUSH, a2), n(r2.initializer), t2.emit(i$2.PROPERTY_SET);
586
+ t2.emit(n.PUSH, a2), i2(r2.initializer), t2.emit(n.PROPERTY_SET);
575
587
  } else if (s__namespace.isShorthandPropertyAssignment(r2)) {
576
588
  const a2 = r2.name.text;
577
- t2.emit(i$2.PUSH, a2), t2.emit(i$2.LOAD, a2), t2.emit(i$2.PROPERTY_SET);
589
+ t2.emit(n.PUSH, a2), t2.emit(n.LOAD, a2), t2.emit(n.PROPERTY_SET);
578
590
  } else
579
591
  throw new Error("Unsupported property type in object literal");
580
592
  }, Z$1 = {
581
593
  [s__namespace.SyntaxKind.StringLiteral]: J,
582
594
  [s__namespace.SyntaxKind.NumericLiteral]: H,
583
- [s__namespace.SyntaxKind.TrueKeyword]: M$1,
595
+ [s__namespace.SyntaxKind.TrueKeyword]: M$2,
584
596
  [s__namespace.SyntaxKind.FalseKeyword]: Y,
585
597
  [s__namespace.SyntaxKind.NullKeyword]: B$1,
586
598
  [s__namespace.SyntaxKind.RegularExpressionLiteral]: C$2,
587
- [s__namespace.SyntaxKind.Identifier]: d$3,
588
- [s__namespace.SyntaxKind.ArrayLiteralExpression]: w$1,
589
- [s__namespace.SyntaxKind.BinaryExpression]: X,
590
- [s__namespace.SyntaxKind.PrefixUnaryExpression]: W$1,
591
- [s__namespace.SyntaxKind.PostfixUnaryExpression]: j$2,
599
+ [s__namespace.SyntaxKind.Identifier]: w$1,
600
+ [s__namespace.SyntaxKind.ArrayLiteralExpression]: q,
601
+ [s__namespace.SyntaxKind.BinaryExpression]: j$1,
602
+ [s__namespace.SyntaxKind.PrefixUnaryExpression]: V$1,
603
+ [s__namespace.SyntaxKind.PostfixUnaryExpression]: W$1,
592
604
  [s__namespace.SyntaxKind.CallExpression]: Q$1,
593
- [s__namespace.SyntaxKind.PropertyAccessExpression]: q,
594
- [s__namespace.SyntaxKind.ElementAccessExpression]: V$1,
595
- [s__namespace.SyntaxKind.ConditionalExpression]: v,
605
+ [s__namespace.SyntaxKind.PropertyAccessExpression]: d$3,
606
+ [s__namespace.SyntaxKind.ElementAccessExpression]: X,
607
+ [s__namespace.SyntaxKind.ConditionalExpression]: v$1,
596
608
  [s__namespace.SyntaxKind.TypeOfExpression]: z,
597
609
  [s__namespace.SyntaxKind.ParenthesizedExpression]: O,
598
610
  [s__namespace.SyntaxKind.ObjectLiteralExpression]: $$1
599
611
  };
600
612
  function te$1(e2) {
601
- const t2 = [], n = A(e2);
602
- if (n.errors.length > 0)
613
+ const t2 = [], i2 = A$1(e2);
614
+ if (i2.errors.length > 0)
603
615
  return {
604
616
  success: false,
605
617
  bytecode: [],
606
- errors: n.errors.map((S) => ({
607
- message: S,
618
+ errors: i2.errors.map((m2) => ({
619
+ message: m2,
608
620
  line: 0,
609
621
  character: 0
610
622
  }))
611
623
  };
612
- const r2 = new P(), a2 = s__namespace.createSourceFile("program.ts", e2, s__namespace.ScriptTarget.Latest, true), m2 = {
613
- compileStatement: T,
624
+ const r2 = new g(), a2 = s__namespace.createSourceFile("program.ts", e2, s__namespace.ScriptTarget.Latest, true), T = {
625
+ compileStatement: S,
614
626
  compileExpression: c2,
615
- reportError: (S, u2) => {
616
- const { line: l, character: x2 } = a2.getLineAndCharacterOfPosition(S.getStart());
627
+ reportError: (m2, u2) => {
628
+ const { line: l, character: R } = a2.getLineAndCharacterOfPosition(m2.getStart());
617
629
  throw t2.push({
618
630
  message: u2,
619
631
  line: l + 1,
620
632
  // TypeScript uses 0-based lines
621
- character: x2 + 1
633
+ character: R + 1
622
634
  // TypeScript uses 0-based columns
623
635
  }), new Error(u2);
624
636
  }
625
637
  };
626
- function T(S) {
627
- const u2 = K[S.kind];
638
+ function S(m2) {
639
+ const u2 = K[m2.kind];
628
640
  if (u2)
629
- u2(S, r2, m2);
641
+ u2(m2, r2, T);
630
642
  else {
631
- const { line: l, character: x2 } = a2.getLineAndCharacterOfPosition(S.getStart());
643
+ const { line: l, character: R } = a2.getLineAndCharacterOfPosition(m2.getStart());
632
644
  t2.push({
633
- message: `Unsupported statement: ${s__namespace.SyntaxKind[S.kind]}`,
645
+ message: `Unsupported statement: ${s__namespace.SyntaxKind[m2.kind]}`,
634
646
  line: l + 1,
635
- character: x2 + 1
647
+ character: R + 1
636
648
  });
637
649
  }
638
650
  }
639
- function c2(S) {
640
- const u2 = Z$1[S.kind];
651
+ function c2(m2) {
652
+ const u2 = Z$1[m2.kind];
641
653
  if (u2)
642
- u2(S, r2, m2);
654
+ u2(m2, r2, T);
643
655
  else {
644
- const { line: l, character: x2 } = a2.getLineAndCharacterOfPosition(S.getStart());
656
+ const { line: l, character: R } = a2.getLineAndCharacterOfPosition(m2.getStart());
645
657
  t2.push({
646
- message: `Unsupported expression: ${s__namespace.SyntaxKind[S.kind]}`,
658
+ message: `Unsupported expression: ${s__namespace.SyntaxKind[m2.kind]}`,
647
659
  line: l + 1,
648
- character: x2 + 1
660
+ character: R + 1
649
661
  });
650
662
  }
651
663
  }
652
- return a2.forEachChild((S) => {
664
+ return a2.forEachChild((m2) => {
653
665
  var u2;
654
- s__namespace.isFunctionDeclaration(S) && ((u2 = S.name) == null ? void 0 : u2.text) === "main" && S.body && S.body.statements.forEach((l) => {
666
+ s__namespace.isFunctionDeclaration(m2) && ((u2 = m2.name) == null ? void 0 : u2.text) === "main" && m2.body && m2.body.statements.forEach((l) => {
655
667
  try {
656
- T(l);
668
+ S(l);
657
669
  } catch {
658
670
  }
659
671
  });
660
- }), r2.emit(i$2.HALT), {
672
+ }), r2.emit(n.HALT), {
661
673
  success: t2.length === 0,
662
674
  bytecode: r2.getBytecode(),
663
675
  errors: t2
@@ -693,7 +705,7 @@ function b(r2) {
693
705
  function p$1(r2) {
694
706
  return t(r2) ? r2 : i$1(r2) || e(r2) ? r2.toString() : f$2(r2) ? "null" : c(r2) ? "undefined" : o(r2) ? `[array:${r2.elements.length}]` : y(r2) ? "[object Object]" : String(r2);
695
707
  }
696
- function j$1(r2) {
708
+ function j(r2) {
697
709
  return e(r2) ? r2 : f$2(r2) || c(r2) ? false : i$1(r2) ? r2 !== 0 : t(r2) ? r2 !== "" : o(r2) || y(r2) ? true : !!r2;
698
710
  }
699
711
  function d$2(r2) {
@@ -705,23 +717,23 @@ function m(r2) {
705
717
  if (f$2(r2)) return 0;
706
718
  if (c(r2)) return NaN;
707
719
  if (t(r2)) {
708
- const n = r2.trim();
709
- return n === "" ? 0 : Number(n);
720
+ const n2 = r2.trim();
721
+ return n2 === "" ? 0 : Number(n2);
710
722
  }
711
723
  return o(r2) ? NaN : Number(r2);
712
724
  }
713
- function s(r2 = [], n) {
714
- return n ? { type: "array", elements: r2, properties: n } : { type: "array", elements: r2 };
725
+ function s(r2 = [], n2) {
726
+ return n2 ? { type: "array", elements: r2, properties: n2 } : { type: "array", elements: r2 };
715
727
  }
716
728
  function C$1() {
717
729
  return { type: "undefined" };
718
730
  }
719
- function M(r2 = {}) {
731
+ function M$1(r2 = {}) {
720
732
  return { type: "object", properties: r2 };
721
733
  }
722
734
  var d$1 = Object.defineProperty;
723
- var h = (s2, t2, n) => t2 in s2 ? d$1(s2, t2, { enumerable: true, configurable: true, writable: true, value: n }) : s2[t2] = n;
724
- var a = (s2, t2, n) => h(s2, typeof t2 != "symbol" ? t2 + "" : t2, n);
735
+ var h = (s2, t2, n2) => t2 in s2 ? d$1(s2, t2, { enumerable: true, configurable: true, writable: true, value: n2 }) : s2[t2] = n2;
736
+ var a = (s2, t2, n2) => h(s2, typeof t2 != "symbol" ? t2 + "" : t2, n2);
725
737
  class p {
726
738
  constructor(t2) {
727
739
  a(this, "connected", false);
@@ -734,7 +746,7 @@ class p {
734
746
  return r__namespace.join(this.dataDir, "metadata.json");
735
747
  }
736
748
  async connect() {
737
- await N$1.promises.mkdir(this.dataDir, { recursive: true }), await N$1.promises.mkdir(this.programsDir, { recursive: true }), await N$1.promises.mkdir(this.executionsDir, { recursive: true }), await N$1.promises.mkdir(this.outputsDir, { recursive: true }), this.connected = true;
749
+ await b$2.promises.mkdir(this.dataDir, { recursive: true }), await b$2.promises.mkdir(this.programsDir, { recursive: true }), await b$2.promises.mkdir(this.executionsDir, { recursive: true }), await b$2.promises.mkdir(this.outputsDir, { recursive: true }), this.connected = true;
738
750
  }
739
751
  async disconnect() {
740
752
  this.connected = false;
@@ -744,14 +756,14 @@ class p {
744
756
  }
745
757
  async saveProgram(t2) {
746
758
  if (!this.connected) throw new Error("Not connected");
747
- const n = r__namespace.join(this.programsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
748
- await N$1.promises.writeFile(n, e2, "utf-8");
759
+ const n2 = r__namespace.join(this.programsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
760
+ await b$2.promises.writeFile(n2, e2, "utf-8");
749
761
  }
750
762
  async getProgram(t2) {
751
763
  if (!this.connected) throw new Error("Not connected");
752
- const n = r__namespace.join(this.programsDir, `${t2}.json`);
764
+ const n2 = r__namespace.join(this.programsDir, `${t2}.json`);
753
765
  try {
754
- const e2 = await N$1.promises.readFile(n, "utf-8"), o2 = JSON.parse(e2);
766
+ const e2 = await b$2.promises.readFile(n2, "utf-8"), o2 = JSON.parse(e2);
755
767
  return o2.created = new Date(o2.created), o2.updated && (o2.updated = new Date(o2.updated)), o2;
756
768
  } catch (e2) {
757
769
  if (e2.code === "ENOENT")
@@ -761,14 +773,14 @@ class p {
761
773
  }
762
774
  async saveExecution(t2) {
763
775
  if (!this.connected) throw new Error("Not connected");
764
- const n = r__namespace.join(this.executionsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
765
- await N$1.promises.writeFile(n, e2, "utf-8");
776
+ const n2 = r__namespace.join(this.executionsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
777
+ await b$2.promises.writeFile(n2, e2, "utf-8");
766
778
  }
767
779
  async getExecution(t2) {
768
780
  if (!this.connected) throw new Error("Not connected");
769
- const n = r__namespace.join(this.executionsDir, `${t2}.json`);
781
+ const n2 = r__namespace.join(this.executionsDir, `${t2}.json`);
770
782
  try {
771
- const e2 = await N$1.promises.readFile(n, "utf-8"), o2 = JSON.parse(e2);
783
+ const e2 = await b$2.promises.readFile(n2, "utf-8"), o2 = JSON.parse(e2);
772
784
  return o2.created = new Date(o2.created), o2.updated && (o2.updated = new Date(o2.updated)), o2;
773
785
  } catch (e2) {
774
786
  if (e2.code === "ENOENT")
@@ -776,18 +788,18 @@ class p {
776
788
  throw e2;
777
789
  }
778
790
  }
779
- async appendOutput(t2, n) {
791
+ async appendOutput(t2, n2) {
780
792
  if (!this.connected) throw new Error("Not connected");
781
- const e2 = r__namespace.join(this.outputsDir, `${t2}.output`), o2 = n.join(`
793
+ const e2 = r__namespace.join(this.outputsDir, `${t2}.output`), o2 = n2.join(`
782
794
  `) + `
783
795
  `;
784
- await N$1.promises.appendFile(e2, o2, "utf-8");
796
+ await b$2.promises.appendFile(e2, o2, "utf-8");
785
797
  }
786
798
  async getOutput(t2) {
787
799
  if (!this.connected) throw new Error("Not connected");
788
- const n = r__namespace.join(this.outputsDir, `${t2}.output`);
800
+ const n2 = r__namespace.join(this.outputsDir, `${t2}.output`);
789
801
  try {
790
- return (await N$1.promises.readFile(n, "utf-8")).split(`
802
+ return (await b$2.promises.readFile(n2, "utf-8")).split(`
791
803
  `).filter((o2) => o2.length > 0);
792
804
  } catch (e2) {
793
805
  if (e2.code === "ENOENT")
@@ -797,18 +809,18 @@ class p {
797
809
  }
798
810
  async listExecutions() {
799
811
  if (!this.connected) throw new Error("Not connected");
800
- const t2 = await N$1.promises.readdir(this.executionsDir), n = [];
812
+ const t2 = await b$2.promises.readdir(this.executionsDir), n2 = [];
801
813
  for (const e2 of t2)
802
814
  if (e2.endsWith(".json")) {
803
815
  const o2 = e2.slice(0, -5), i2 = await this.getExecution(o2);
804
- i2 && n.push(i2);
816
+ i2 && n2.push(i2);
805
817
  }
806
- return n;
818
+ return n2;
807
819
  }
808
820
  async getCurrentExecutionId() {
809
821
  if (!this.connected) throw new Error("Not connected");
810
822
  try {
811
- const t2 = await N$1.promises.readFile(this.metadataFile, "utf-8");
823
+ const t2 = await b$2.promises.readFile(this.metadataFile, "utf-8");
812
824
  return JSON.parse(t2).currentExecutionId || null;
813
825
  } catch (t2) {
814
826
  if (t2.code === "ENOENT")
@@ -818,20 +830,20 @@ class p {
818
830
  }
819
831
  async setCurrentExecutionId(t2) {
820
832
  if (!this.connected) throw new Error("Not connected");
821
- const n = { currentExecutionId: t2 };
822
- await N$1.promises.writeFile(this.metadataFile, JSON.stringify(n, null, 2), "utf-8");
833
+ const n2 = { currentExecutionId: t2 };
834
+ await b$2.promises.writeFile(this.metadataFile, JSON.stringify(n2, null, 2), "utf-8");
823
835
  }
824
836
  async deleteExecution(t2) {
825
837
  if (!this.connected) throw new Error("Not connected");
826
- const n = r__namespace.join(this.executionsDir, `${t2}.json`);
838
+ const n2 = r__namespace.join(this.executionsDir, `${t2}.json`);
827
839
  try {
828
- await N$1.promises.unlink(n);
840
+ await b$2.promises.unlink(n2);
829
841
  } catch (i2) {
830
842
  if (i2.code !== "ENOENT") throw i2;
831
843
  }
832
844
  const e2 = r__namespace.join(this.outputsDir, `${t2}.output`);
833
845
  try {
834
- await N$1.promises.unlink(e2);
846
+ await b$2.promises.unlink(e2);
835
847
  } catch (i2) {
836
848
  if (i2.code !== "ENOENT") throw i2;
837
849
  }
@@ -839,19 +851,19 @@ class p {
839
851
  }
840
852
  async listPrograms() {
841
853
  if (!this.connected) throw new Error("Not connected");
842
- const t2 = await N$1.promises.readdir(this.programsDir), n = [];
854
+ const t2 = await b$2.promises.readdir(this.programsDir), n2 = [];
843
855
  for (const e2 of t2)
844
856
  if (e2.endsWith(".json")) {
845
857
  const o2 = e2.slice(0, -5), i2 = await this.getProgram(o2);
846
- i2 && n.push(i2);
858
+ i2 && n2.push(i2);
847
859
  }
848
- return n;
860
+ return n2;
849
861
  }
850
862
  async deleteProgram(t2) {
851
863
  if (!this.connected) throw new Error("Not connected");
852
- const n = r__namespace.join(this.programsDir, `${t2}.json`);
864
+ const n2 = r__namespace.join(this.programsDir, `${t2}.json`);
853
865
  try {
854
- await N$1.promises.unlink(n);
866
+ await b$2.promises.unlink(n2);
855
867
  } catch (e2) {
856
868
  if (e2.code !== "ENOENT") throw e2;
857
869
  }
@@ -880,7 +892,7 @@ let f$1 = class f {
880
892
  }
881
893
  async getCollections() {
882
894
  if (!this.db) throw new Error("Not connected to database");
883
- return (await this.db.listCollections().toArray()).map((n) => n.name);
895
+ return (await this.db.listCollections().toArray()).map((n2) => n2.name);
884
896
  }
885
897
  getCollection(t2) {
886
898
  if (!this.db) throw new Error("Not connected to database");
@@ -906,12 +918,12 @@ let f$1 = class f {
906
918
  async getExecution(t2) {
907
919
  return await this.getCollection("executions").findOne({ id: t2 });
908
920
  }
909
- async appendOutput(t2, n) {
921
+ async appendOutput(t2, n2) {
910
922
  const e2 = this.getCollection("outputs");
911
923
  await e2.findOne({ executionId: t2 }) ? await e2.updateOne(
912
924
  { executionId: t2 },
913
- { $push: { lines: { $each: n } } }
914
- ) : await e2.insertOne({ executionId: t2, lines: n });
925
+ { $push: { lines: { $each: n2 } } }
926
+ ) : await e2.insertOne({ executionId: t2, lines: n2 });
915
927
  }
916
928
  async getOutput(t2) {
917
929
  const e2 = await this.getCollection("outputs").findOne({ executionId: t2 });
@@ -921,8 +933,8 @@ let f$1 = class f {
921
933
  return await this.getCollection("executions").find({}).toArray();
922
934
  }
923
935
  async getCurrentExecutionId() {
924
- const n = await this.getCollection("metadata").findOne({ _id: "current" });
925
- return (n == null ? void 0 : n.currentExecutionId) || null;
936
+ const n2 = await this.getCollection("metadata").findOne({ _id: "current" });
937
+ return (n2 == null ? void 0 : n2.currentExecutionId) || null;
926
938
  }
927
939
  async setCurrentExecutionId(t2) {
928
940
  await this.getCollection("metadata").replaceOne(
@@ -933,7 +945,7 @@ let f$1 = class f {
933
945
  }
934
946
  async deleteExecution(t2) {
935
947
  var o2;
936
- let n = true;
948
+ let n2 = true;
937
949
  const e2 = this.client.startSession();
938
950
  try {
939
951
  await e2.withTransaction(async () => {
@@ -945,13 +957,13 @@ let f$1 = class f {
945
957
  });
946
958
  } catch (i2) {
947
959
  if ((o2 = i2 == null ? void 0 : i2.message) != null && o2.includes("Transaction numbers are only allowed"))
948
- n = false;
960
+ n2 = false;
949
961
  else
950
962
  throw i2;
951
963
  } finally {
952
964
  await e2.endSession();
953
965
  }
954
- n || (await this.getCollection("executions").deleteOne({ id: t2 }), await this.getCollection("outputs").deleteMany({ executionId: t2 }), await this.getCurrentExecutionId() === t2 && await this.setCurrentExecutionId(null));
966
+ n2 || (await this.getCollection("executions").deleteOne({ id: t2 }), await this.getCollection("outputs").deleteMany({ executionId: t2 }), await this.getCurrentExecutionId() === t2 && await this.setCurrentExecutionId(null));
955
967
  }
956
968
  async listPrograms() {
957
969
  return await this.getCollection("programs").find({}).toArray();
@@ -962,8 +974,8 @@ let f$1 = class f {
962
974
  };
963
975
  class E {
964
976
  static create(t2) {
965
- const n = (t2 == null ? void 0 : t2.type) || process.env.CVM_STORAGE_TYPE || "file";
966
- switch (n) {
977
+ const n2 = (t2 == null ? void 0 : t2.type) || process.env.CVM_STORAGE_TYPE || "file";
978
+ switch (n2) {
967
979
  case "file": {
968
980
  const e2 = (t2 == null ? void 0 : t2.dataDir) || process.env.CVM_DATA_DIR || ".cvm";
969
981
  return new p(e2);
@@ -973,7 +985,7 @@ class E {
973
985
  return new f$1(e2);
974
986
  }
975
987
  default:
976
- throw new Error(`Unsupported storage type: ${n}`);
988
+ throw new Error(`Unsupported storage type: ${n2}`);
977
989
  }
978
990
  }
979
991
  }
@@ -988,59 +1000,59 @@ function d(e2, t2) {
988
1000
  type: "RuntimeError",
989
1001
  message: "Stack underflow",
990
1002
  pc: e2.pc,
991
- opcode: t2 || i$2.POP
1003
+ opcode: t2 || n.POP
992
1004
  } : e2.stack.pop();
993
1005
  }
994
1006
  const f2 = Q, Z = {
995
- [i$2.ADD]: {
1007
+ [n.ADD]: {
996
1008
  stackIn: 2,
997
1009
  stackOut: 1,
998
1010
  execute: (e2, t$1) => {
999
1011
  const r2 = d(e2, t$1.op);
1000
1012
  if (f2(r2)) return r2;
1001
- const s2 = d(e2, t$1.op);
1002
- if (f2(s2)) return s2;
1003
- if (t(s2) || t(r2))
1004
- e2.stack.push(p$1(s2) + p$1(r2));
1013
+ const o2 = d(e2, t$1.op);
1014
+ if (f2(o2)) return o2;
1015
+ if (t(o2) || t(r2))
1016
+ e2.stack.push(p$1(o2) + p$1(r2));
1005
1017
  else {
1006
- const o2 = m(s2), c2 = m(r2);
1007
- e2.stack.push(o2 + c2);
1018
+ const s2 = m(o2), c2 = m(r2);
1019
+ e2.stack.push(s2 + c2);
1008
1020
  }
1009
1021
  }
1010
1022
  },
1011
- [i$2.SUB]: {
1023
+ [n.SUB]: {
1012
1024
  stackIn: 2,
1013
1025
  stackOut: 1,
1014
1026
  execute: (e2, t2) => {
1015
1027
  const r2 = d(e2, t2.op);
1016
1028
  if (f2(r2)) return r2;
1017
- const s2 = d(e2, t2.op);
1018
- if (f2(s2)) return s2;
1019
- const o2 = m(s2), c2 = m(r2);
1020
- e2.stack.push(o2 - c2);
1029
+ const o2 = d(e2, t2.op);
1030
+ if (f2(o2)) return o2;
1031
+ const s2 = m(o2), c2 = m(r2);
1032
+ e2.stack.push(s2 - c2);
1021
1033
  }
1022
1034
  },
1023
- [i$2.MUL]: {
1035
+ [n.MUL]: {
1024
1036
  stackIn: 2,
1025
1037
  stackOut: 1,
1026
1038
  execute: (e2, t2) => {
1027
1039
  const r2 = d(e2, t2.op);
1028
1040
  if (f2(r2)) return r2;
1029
- const s2 = d(e2, t2.op);
1030
- if (f2(s2)) return s2;
1031
- const o2 = m(s2), c2 = m(r2);
1032
- e2.stack.push(o2 * c2);
1041
+ const o2 = d(e2, t2.op);
1042
+ if (f2(o2)) return o2;
1043
+ const s2 = m(o2), c2 = m(r2);
1044
+ e2.stack.push(s2 * c2);
1033
1045
  }
1034
1046
  },
1035
- [i$2.DIV]: {
1047
+ [n.DIV]: {
1036
1048
  stackIn: 2,
1037
1049
  stackOut: 1,
1038
1050
  execute: (e2, t2) => {
1039
1051
  const r2 = d(e2, t2.op);
1040
1052
  if (f2(r2)) return r2;
1041
- const s2 = d(e2, t2.op);
1042
- if (f2(s2)) return s2;
1043
- const o2 = m(s2), c2 = m(r2);
1053
+ const o2 = d(e2, t2.op);
1054
+ if (f2(o2)) return o2;
1055
+ const s2 = m(o2), c2 = m(r2);
1044
1056
  if (c2 === 0)
1045
1057
  return {
1046
1058
  type: "DivisionByZero",
@@ -1048,64 +1060,64 @@ const f2 = Q, Z = {
1048
1060
  pc: e2.pc,
1049
1061
  opcode: t2.op
1050
1062
  };
1051
- e2.stack.push(o2 / c2);
1063
+ e2.stack.push(s2 / c2);
1052
1064
  }
1053
1065
  },
1054
- [i$2.MOD]: {
1066
+ [n.MOD]: {
1055
1067
  stackIn: 2,
1056
1068
  stackOut: 1,
1057
1069
  execute: (e2, t2) => {
1058
1070
  const r2 = d(e2, t2.op);
1059
1071
  if (f2(r2)) return r2;
1060
- const s2 = d(e2, t2.op);
1061
- if (f2(s2)) return s2;
1062
- const o2 = m(s2), c2 = m(r2);
1063
- e2.stack.push(o2 % c2);
1072
+ const o2 = d(e2, t2.op);
1073
+ if (f2(o2)) return o2;
1074
+ const s2 = m(o2), c2 = m(r2);
1075
+ e2.stack.push(s2 % c2);
1064
1076
  }
1065
1077
  },
1066
- [i$2.UNARY_MINUS]: {
1078
+ [n.UNARY_MINUS]: {
1067
1079
  stackIn: 1,
1068
1080
  stackOut: 1,
1069
1081
  execute: (e2, t2) => {
1070
1082
  const r2 = d(e2, t2.op);
1071
1083
  if (f2(r2)) return r2;
1072
- const s2 = m(r2);
1073
- e2.stack.push(-s2);
1084
+ const o2 = m(r2);
1085
+ e2.stack.push(-o2);
1074
1086
  }
1075
1087
  },
1076
- [i$2.UNARY_PLUS]: {
1088
+ [n.UNARY_PLUS]: {
1077
1089
  stackIn: 1,
1078
1090
  stackOut: 1,
1079
1091
  execute: (e2, t2) => {
1080
1092
  const r2 = d(e2, t2.op);
1081
1093
  if (f2(r2)) return r2;
1082
- const s2 = m(r2);
1083
- e2.stack.push(s2);
1094
+ const o2 = m(r2);
1095
+ e2.stack.push(o2);
1084
1096
  }
1085
1097
  }
1086
1098
  }, ee = {
1087
- [i$2.PUSH]: {
1099
+ [n.PUSH]: {
1088
1100
  stackIn: 0,
1089
1101
  stackOut: 1,
1090
1102
  execute: (e2, t2) => {
1091
1103
  e2.stack.push(t2.arg);
1092
1104
  }
1093
1105
  },
1094
- [i$2.PUSH_UNDEFINED]: {
1106
+ [n.PUSH_UNDEFINED]: {
1095
1107
  stackIn: 0,
1096
1108
  stackOut: 1,
1097
1109
  execute: (e2) => {
1098
1110
  e2.stack.push(C$1());
1099
1111
  }
1100
1112
  },
1101
- [i$2.POP]: {
1113
+ [n.POP]: {
1102
1114
  stackIn: 1,
1103
1115
  stackOut: 0,
1104
1116
  execute: (e2) => {
1105
1117
  e2.stack.pop();
1106
1118
  }
1107
1119
  },
1108
- [i$2.DUP]: {
1120
+ [n.DUP]: {
1109
1121
  stackIn: 1,
1110
1122
  stackOut: 2,
1111
1123
  execute: (e2, t2) => {
@@ -1113,24 +1125,24 @@ const f2 = Q, Z = {
1113
1125
  e2.stack.push(r2), e2.stack.push(r2);
1114
1126
  }
1115
1127
  },
1116
- [i$2.SWAP]: {
1128
+ [n.SWAP]: {
1117
1129
  stackIn: 2,
1118
1130
  stackOut: 2,
1119
1131
  execute: (e2, t2) => {
1120
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
1121
- e2.stack.push(r2), e2.stack.push(s2);
1132
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1133
+ e2.stack.push(r2), e2.stack.push(o2);
1122
1134
  }
1123
1135
  },
1124
- [i$2.DUP2]: {
1136
+ [n.DUP2]: {
1125
1137
  stackIn: 2,
1126
1138
  stackOut: 4,
1127
1139
  execute: (e2, t2) => {
1128
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
1129
- e2.stack.push(s2), e2.stack.push(r2), e2.stack.push(s2), e2.stack.push(r2);
1140
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1141
+ e2.stack.push(o2), e2.stack.push(r2), e2.stack.push(o2), e2.stack.push(r2);
1130
1142
  }
1131
1143
  }
1132
1144
  }, re = {
1133
- [i$2.PRINT]: {
1145
+ [n.PRINT]: {
1134
1146
  stackIn: 1,
1135
1147
  stackOut: 0,
1136
1148
  execute: (e2) => {
@@ -1138,7 +1150,7 @@ const f2 = Q, Z = {
1138
1150
  t2 !== void 0 && e2.output.push(p$1(t2));
1139
1151
  }
1140
1152
  },
1141
- [i$2.CC]: {
1153
+ [n.CC]: {
1142
1154
  stackIn: 1,
1143
1155
  stackOut: 0,
1144
1156
  controlsPC: true,
@@ -1149,7 +1161,7 @@ const f2 = Q, Z = {
1149
1161
  }
1150
1162
  }
1151
1163
  }, te = {
1152
- [i$2.HALT]: {
1164
+ [n.HALT]: {
1153
1165
  stackIn: 0,
1154
1166
  stackOut: 0,
1155
1167
  controlsPC: true,
@@ -1157,7 +1169,7 @@ const f2 = Q, Z = {
1157
1169
  e2.status = "complete";
1158
1170
  }
1159
1171
  },
1160
- [i$2.JUMP]: {
1172
+ [n.JUMP]: {
1161
1173
  stackIn: 0,
1162
1174
  stackOut: 0,
1163
1175
  controlsPC: true,
@@ -1180,7 +1192,7 @@ const f2 = Q, Z = {
1180
1192
  e2.pc = r2;
1181
1193
  }
1182
1194
  },
1183
- [i$2.JUMP_IF_FALSE]: {
1195
+ [n.JUMP_IF_FALSE]: {
1184
1196
  stackIn: 1,
1185
1197
  stackOut: 0,
1186
1198
  controlsPC: true,
@@ -1193,18 +1205,18 @@ const f2 = Q, Z = {
1193
1205
  pc: e2.pc,
1194
1206
  opcode: t2.op
1195
1207
  };
1196
- const s2 = t2.arg;
1197
- if (s2 < 0)
1208
+ const o2 = t2.arg;
1209
+ if (o2 < 0)
1198
1210
  return {
1199
1211
  type: "RuntimeError",
1200
- message: `Invalid jump target: ${s2}`,
1212
+ message: `Invalid jump target: ${o2}`,
1201
1213
  pc: e2.pc,
1202
1214
  opcode: t2.op
1203
1215
  };
1204
- j$1(r2) ? e2.pc++ : e2.pc = s2;
1216
+ j(r2) ? e2.pc++ : e2.pc = o2;
1205
1217
  }
1206
1218
  },
1207
- [i$2.JUMP_IF]: {
1219
+ [n.JUMP_IF]: {
1208
1220
  stackIn: 1,
1209
1221
  stackOut: 0,
1210
1222
  controlsPC: true,
@@ -1217,18 +1229,18 @@ const f2 = Q, Z = {
1217
1229
  pc: e2.pc,
1218
1230
  opcode: t2.op
1219
1231
  };
1220
- const s2 = t2.arg;
1221
- if (s2 < 0)
1232
+ const o2 = t2.arg;
1233
+ if (o2 < 0)
1222
1234
  return {
1223
1235
  type: "RuntimeError",
1224
- message: `Invalid jump target: ${s2}`,
1236
+ message: `Invalid jump target: ${o2}`,
1225
1237
  pc: e2.pc,
1226
1238
  opcode: t2.op
1227
1239
  };
1228
- j$1(r2) ? e2.pc = s2 : e2.pc++;
1240
+ j(r2) ? e2.pc = o2 : e2.pc++;
1229
1241
  }
1230
1242
  },
1231
- [i$2.JUMP_IF_TRUE]: {
1243
+ [n.JUMP_IF_TRUE]: {
1232
1244
  stackIn: 1,
1233
1245
  stackOut: 0,
1234
1246
  controlsPC: true,
@@ -1241,18 +1253,18 @@ const f2 = Q, Z = {
1241
1253
  pc: e2.pc,
1242
1254
  opcode: t2.op
1243
1255
  };
1244
- const s2 = t2.arg;
1245
- if (s2 < 0)
1256
+ const o2 = t2.arg;
1257
+ if (o2 < 0)
1246
1258
  return {
1247
1259
  type: "RuntimeError",
1248
- message: `Invalid jump target: ${s2}`,
1260
+ message: `Invalid jump target: ${o2}`,
1249
1261
  pc: e2.pc,
1250
1262
  opcode: t2.op
1251
1263
  };
1252
- j$1(r2) ? e2.pc = s2 : e2.pc++;
1264
+ j(r2) ? e2.pc = o2 : e2.pc++;
1253
1265
  }
1254
1266
  },
1255
- [i$2.CALL]: {
1267
+ [n.CALL]: {
1256
1268
  stackIn: 1,
1257
1269
  stackOut: 0,
1258
1270
  controlsPC: false,
@@ -1260,11 +1272,11 @@ const f2 = Q, Z = {
1260
1272
  type: "RuntimeError",
1261
1273
  message: "Functions not implemented",
1262
1274
  pc: e2.pc,
1263
- opcode: i$2.CALL
1275
+ opcode: n.CALL
1264
1276
  })
1265
1277
  }
1266
- }, se = {
1267
- [i$2.LOAD]: {
1278
+ }, oe = {
1279
+ [n.LOAD]: {
1268
1280
  stackIn: 0,
1269
1281
  stackOut: 1,
1270
1282
  execute: (e2, t2) => {
@@ -1272,7 +1284,7 @@ const f2 = Q, Z = {
1272
1284
  e2.variables.has(r2) ? e2.stack.push(e2.variables.get(r2)) : e2.stack.push(C$1());
1273
1285
  }
1274
1286
  },
1275
- [i$2.STORE]: {
1287
+ [n.STORE]: {
1276
1288
  stackIn: 1,
1277
1289
  stackOut: 0,
1278
1290
  execute: (e2, t2) => {
@@ -1280,8 +1292,8 @@ const f2 = Q, Z = {
1280
1292
  e2.variables.set(t2.arg, r2);
1281
1293
  }
1282
1294
  }
1283
- }, oe = {
1284
- [i$2.ITER_START]: {
1295
+ }, se = {
1296
+ [n.ITER_START]: {
1285
1297
  stackIn: 1,
1286
1298
  stackOut: 0,
1287
1299
  execute: (e2, t2) => {
@@ -1293,19 +1305,19 @@ const f2 = Q, Z = {
1293
1305
  pc: e2.pc,
1294
1306
  opcode: t2.op
1295
1307
  };
1296
- let s2;
1308
+ let o$1;
1297
1309
  if (u$1(r2)) {
1298
- const o2 = e2.heap.get(r2.id);
1299
- if (!o2 || o2.type !== "array")
1310
+ const s2 = e2.heap.get(r2.id);
1311
+ if (!s2 || s2.type !== "array")
1300
1312
  return {
1301
1313
  type: "RuntimeError",
1302
1314
  message: "Invalid array reference",
1303
1315
  pc: e2.pc,
1304
1316
  opcode: t2.op
1305
1317
  };
1306
- s2 = o2.data;
1318
+ o$1 = s2.data;
1307
1319
  } else if (o(r2))
1308
- s2 = r2;
1320
+ o$1 = r2;
1309
1321
  else
1310
1322
  return {
1311
1323
  type: "TypeError",
@@ -1321,13 +1333,13 @@ const f2 = Q, Z = {
1321
1333
  opcode: t2.op
1322
1334
  };
1323
1335
  e2.iterators.push({
1324
- array: s2,
1336
+ array: o$1,
1325
1337
  index: 0,
1326
- length: s2.elements.length
1338
+ length: o$1.elements.length
1327
1339
  });
1328
1340
  }
1329
1341
  },
1330
- [i$2.ITER_NEXT]: {
1342
+ [n.ITER_NEXT]: {
1331
1343
  stackIn: 0,
1332
1344
  stackOut: 2,
1333
1345
  // Pushes element and hasMore flag
@@ -1343,7 +1355,7 @@ const f2 = Q, Z = {
1343
1355
  r2.index < r2.length ? (r2.array && r2.index < r2.array.elements.length ? e2.stack.push(r2.array.elements[r2.index]) : e2.stack.push(C$1()), e2.stack.push(true), r2.index++) : (e2.stack.push(null), e2.stack.push(false));
1344
1356
  }
1345
1357
  },
1346
- [i$2.ITER_END]: {
1358
+ [n.ITER_END]: {
1347
1359
  stackIn: 0,
1348
1360
  stackOut: 0,
1349
1361
  execute: (e2, t2) => {
@@ -1358,122 +1370,122 @@ const f2 = Q, Z = {
1358
1370
  }
1359
1371
  }
1360
1372
  };
1361
- function x$1(e2, t2, r2) {
1362
- const s2 = d(e2, t2.op);
1363
- if (f2(s2)) return s2;
1373
+ function v(e2, t2, r2) {
1364
1374
  const o2 = d(e2, t2.op);
1365
1375
  if (f2(o2)) return o2;
1366
- const c2 = r2(o2, s2);
1376
+ const s2 = d(e2, t2.op);
1377
+ if (f2(s2)) return s2;
1378
+ const c2 = r2(s2, o2);
1367
1379
  e2.stack.push(c2);
1368
1380
  }
1369
1381
  const ce = {
1370
- [i$2.EQ]: {
1382
+ [n.EQ]: {
1371
1383
  stackIn: 2,
1372
1384
  stackOut: 1,
1373
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1374
- if (f$2(r2) && c(s2) || c(r2) && f$2(s2))
1385
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1386
+ if (f$2(r2) && c(o2) || c(r2) && f$2(o2))
1375
1387
  return true;
1376
- if (c(r2) && c(s2))
1388
+ if (c(r2) && c(o2))
1377
1389
  return true;
1378
1390
  if (u$1(r2) || b(r2))
1379
- return u$1(r2) && u$1(s2) || b(r2) && b(s2) ? r2.id === s2.id : false;
1391
+ return u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id === o2.id : false;
1380
1392
  {
1381
- const o2 = m(r2), c2 = m(s2);
1382
- return !isNaN(o2) && !isNaN(c2) ? o2 === c2 : p$1(r2) === p$1(s2);
1393
+ const s2 = m(r2), c2 = m(o2);
1394
+ return !isNaN(s2) && !isNaN(c2) ? s2 === c2 : p$1(r2) === p$1(o2);
1383
1395
  }
1384
1396
  })
1385
1397
  },
1386
- [i$2.NEQ]: {
1398
+ [n.NEQ]: {
1387
1399
  stackIn: 2,
1388
1400
  stackOut: 1,
1389
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1390
- if (f$2(r2) && c(s2) || c(r2) && f$2(s2))
1401
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1402
+ if (f$2(r2) && c(o2) || c(r2) && f$2(o2))
1391
1403
  return false;
1392
- if (c(r2) && c(s2))
1404
+ if (c(r2) && c(o2))
1393
1405
  return false;
1394
1406
  if (u$1(r2) || b(r2))
1395
- return u$1(r2) && u$1(s2) || b(r2) && b(s2) ? r2.id !== s2.id : true;
1407
+ return u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id !== o2.id : true;
1396
1408
  {
1397
- const o2 = m(r2), c2 = m(s2);
1398
- return !isNaN(o2) && !isNaN(c2) ? o2 !== c2 : p$1(r2) !== p$1(s2);
1409
+ const s2 = m(r2), c2 = m(o2);
1410
+ return !isNaN(s2) && !isNaN(c2) ? s2 !== c2 : p$1(r2) !== p$1(o2);
1399
1411
  }
1400
1412
  })
1401
1413
  },
1402
- [i$2.LT]: {
1414
+ [n.LT]: {
1403
1415
  stackIn: 2,
1404
1416
  stackOut: 1,
1405
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1406
- const o2 = m(r2), c2 = m(s2);
1407
- return o2 < c2;
1417
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1418
+ const s2 = m(r2), c2 = m(o2);
1419
+ return s2 < c2;
1408
1420
  })
1409
1421
  },
1410
- [i$2.GT]: {
1422
+ [n.GT]: {
1411
1423
  stackIn: 2,
1412
1424
  stackOut: 1,
1413
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1414
- const o2 = m(r2), c2 = m(s2);
1415
- return o2 > c2;
1425
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1426
+ const s2 = m(r2), c2 = m(o2);
1427
+ return s2 > c2;
1416
1428
  })
1417
1429
  },
1418
- [i$2.LTE]: {
1430
+ [n.LTE]: {
1419
1431
  stackIn: 2,
1420
1432
  stackOut: 1,
1421
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1422
- const o2 = m(r2), c2 = m(s2);
1423
- return o2 <= c2;
1433
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1434
+ const s2 = m(r2), c2 = m(o2);
1435
+ return s2 <= c2;
1424
1436
  })
1425
1437
  },
1426
- [i$2.GTE]: {
1438
+ [n.GTE]: {
1427
1439
  stackIn: 2,
1428
1440
  stackOut: 1,
1429
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1430
- const o2 = m(r2), c2 = m(s2);
1431
- return o2 >= c2;
1441
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1442
+ const s2 = m(r2), c2 = m(o2);
1443
+ return s2 >= c2;
1432
1444
  })
1433
1445
  },
1434
- [i$2.EQ_STRICT]: {
1446
+ [n.EQ_STRICT]: {
1435
1447
  stackIn: 2,
1436
1448
  stackOut: 1,
1437
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => u$1(r2) && u$1(s2) || b(r2) && b(s2) ? r2.id === s2.id : r2 === s2)
1449
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id === o2.id : r2 === o2)
1438
1450
  },
1439
- [i$2.NEQ_STRICT]: {
1451
+ [n.NEQ_STRICT]: {
1440
1452
  stackIn: 2,
1441
1453
  stackOut: 1,
1442
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => u$1(r2) && u$1(s2) || b(r2) && b(s2) ? r2.id !== s2.id : r2 !== s2)
1454
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id !== o2.id : r2 !== o2)
1443
1455
  }
1444
1456
  }, ne = {
1445
- [i$2.AND]: {
1457
+ [n.AND]: {
1446
1458
  stackIn: 2,
1447
1459
  stackOut: 1,
1448
1460
  execute: (e2, t2) => {
1449
1461
  const r2 = d(e2, t2.op);
1450
1462
  if (f2(r2)) return r2;
1451
- const s2 = d(e2, t2.op);
1452
- if (f2(s2)) return s2;
1453
- const o2 = j$1(s2) ? r2 : s2;
1454
- e2.stack.push(o2);
1463
+ const o2 = d(e2, t2.op);
1464
+ if (f2(o2)) return o2;
1465
+ const s2 = j(o2) ? r2 : o2;
1466
+ e2.stack.push(s2);
1455
1467
  }
1456
1468
  },
1457
- [i$2.OR]: {
1469
+ [n.OR]: {
1458
1470
  stackIn: 2,
1459
1471
  stackOut: 1,
1460
1472
  execute: (e2, t2) => {
1461
1473
  const r2 = d(e2, t2.op);
1462
1474
  if (f2(r2)) return r2;
1463
- const s2 = d(e2, t2.op);
1464
- if (f2(s2)) return s2;
1465
- const o2 = j$1(s2) ? s2 : r2;
1466
- e2.stack.push(o2);
1475
+ const o2 = d(e2, t2.op);
1476
+ if (f2(o2)) return o2;
1477
+ const s2 = j(o2) ? o2 : r2;
1478
+ e2.stack.push(s2);
1467
1479
  }
1468
1480
  },
1469
- [i$2.NOT]: {
1481
+ [n.NOT]: {
1470
1482
  stackIn: 1,
1471
1483
  stackOut: 1,
1472
1484
  execute: (e2, t2) => {
1473
1485
  const r2 = d(e2, t2.op);
1474
1486
  if (f2(r2)) return r2;
1475
- const s2 = !j$1(r2);
1476
- e2.stack.push(s2);
1487
+ const o2 = !j(r2);
1488
+ e2.stack.push(o2);
1477
1489
  }
1478
1490
  }
1479
1491
  }, pe = {
@@ -1481,26 +1493,26 @@ const ce = {
1481
1493
  * ARRAY_NEW: Creates a new empty array on the heap
1482
1494
  * Stack: [] -> [array-ref]
1483
1495
  */
1484
- [i$2.ARRAY_NEW]: {
1496
+ [n.ARRAY_NEW]: {
1485
1497
  stackIn: 0,
1486
1498
  stackOut: 1,
1487
1499
  execute: (e2, t2) => {
1488
- const r2 = s(), s$12 = e2.heap.allocate("array", r2);
1489
- e2.stack.push(s$12);
1500
+ const r2 = s(), o2 = e2.heap.allocate("array", r2);
1501
+ e2.stack.push(o2);
1490
1502
  }
1491
1503
  },
1492
1504
  /**
1493
1505
  * ARRAY_PUSH: Pushes a value to the end of an array
1494
1506
  * Stack: [array-ref, value] -> [array-ref]
1495
1507
  */
1496
- [i$2.ARRAY_PUSH]: {
1508
+ [n.ARRAY_PUSH]: {
1497
1509
  stackIn: 2,
1498
1510
  stackOut: 1,
1499
1511
  execute: (e2, t2) => {
1500
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
1501
- let o$12;
1502
- if (u$1(s2)) {
1503
- const c2 = e2.heap.get(s2.id);
1512
+ const r2 = e2.stack.pop(), o$1 = e2.stack.pop();
1513
+ let s2;
1514
+ if (u$1(o$1)) {
1515
+ const c2 = e2.heap.get(o$1.id);
1504
1516
  if (!c2 || c2.type !== "array")
1505
1517
  return {
1506
1518
  type: "RuntimeError",
@@ -1508,9 +1520,9 @@ const ce = {
1508
1520
  pc: e2.pc,
1509
1521
  opcode: t2.op
1510
1522
  };
1511
- o$12 = c2.data;
1512
- } else if (o(s2))
1513
- o$12 = s2;
1523
+ s2 = c2.data;
1524
+ } else if (o(o$1))
1525
+ s2 = o$1;
1514
1526
  else
1515
1527
  return {
1516
1528
  type: "RuntimeError",
@@ -1518,18 +1530,18 @@ const ce = {
1518
1530
  pc: e2.pc,
1519
1531
  opcode: t2.op
1520
1532
  };
1521
- o$12.elements.push(r2), e2.stack.push(s2);
1533
+ s2.elements.push(r2), e2.stack.push(o$1);
1522
1534
  }
1523
1535
  },
1524
- [i$2.ARRAY_GET]: {
1536
+ [n.ARRAY_GET]: {
1525
1537
  stackIn: 2,
1526
1538
  stackOut: 1,
1527
1539
  execute: (e2, t$1) => {
1528
1540
  var a2;
1529
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
1530
- let o$12;
1531
- if (u$1(s2)) {
1532
- const i2 = e2.heap.get(s2.id);
1541
+ const r2 = e2.stack.pop(), o$1 = e2.stack.pop();
1542
+ let s2;
1543
+ if (u$1(o$1)) {
1544
+ const i2 = e2.heap.get(o$1.id);
1533
1545
  if (!i2 || i2.type !== "array")
1534
1546
  return {
1535
1547
  type: "RuntimeError",
@@ -1537,9 +1549,9 @@ const ce = {
1537
1549
  pc: e2.pc,
1538
1550
  opcode: t$1.op
1539
1551
  };
1540
- o$12 = i2.data;
1541
- } else if (b(s2)) {
1542
- const i2 = e2.heap.get(s2.id);
1552
+ s2 = i2.data;
1553
+ } else if (b(o$1)) {
1554
+ const i2 = e2.heap.get(o$1.id);
1543
1555
  if (!i2 || i2.type !== "object")
1544
1556
  return {
1545
1557
  type: "RuntimeError",
@@ -1550,9 +1562,9 @@ const ce = {
1550
1562
  const u2 = i2.data, y2 = p$1(r2), E2 = u2.properties[y2] ?? C$1();
1551
1563
  e2.stack.push(E2);
1552
1564
  return;
1553
- } else if (o(s2))
1554
- o$12 = s2;
1555
- else if (t(s2)) {
1565
+ } else if (o(o$1))
1566
+ s2 = o$1;
1567
+ else if (t(o$1)) {
1556
1568
  let i2;
1557
1569
  if (i$1(r2))
1558
1570
  i2 = r2;
@@ -1560,7 +1572,7 @@ const ce = {
1560
1572
  const u2 = parseInt(r2, 10);
1561
1573
  !isNaN(u2) && u2.toString() === r2 && (i2 = u2);
1562
1574
  }
1563
- i2 !== void 0 && i2 >= 0 && i2 < s2.length ? e2.stack.push(s2[i2]) : e2.stack.push(C$1());
1575
+ i2 !== void 0 && i2 >= 0 && i2 < o$1.length ? e2.stack.push(o$1[i2]) : e2.stack.push(C$1());
1564
1576
  return;
1565
1577
  } else
1566
1578
  return {
@@ -1577,7 +1589,7 @@ const ce = {
1577
1589
  if (!isNaN(i2) && i2.toString() === r2 && i2 >= 0)
1578
1590
  c2 = i2;
1579
1591
  else {
1580
- const u2 = ((a2 = o$12.properties) == null ? void 0 : a2[r2]) ?? C$1();
1592
+ const u2 = ((a2 = s2.properties) == null ? void 0 : a2[r2]) ?? C$1();
1581
1593
  e2.stack.push(u2);
1582
1594
  return;
1583
1595
  }
@@ -1588,18 +1600,18 @@ const ce = {
1588
1600
  pc: e2.pc,
1589
1601
  opcode: t$1.op
1590
1602
  };
1591
- const p2 = o$12.elements[c2] ?? C$1();
1603
+ const p2 = s2.elements[c2] ?? C$1();
1592
1604
  e2.stack.push(p2);
1593
1605
  }
1594
1606
  },
1595
- [i$2.ARRAY_SET]: {
1607
+ [n.ARRAY_SET]: {
1596
1608
  stackIn: 3,
1597
1609
  stackOut: 1,
1598
1610
  execute: (e2, t$1) => {
1599
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o$12 = e2.stack.pop();
1611
+ const r2 = e2.stack.pop(), o$1 = e2.stack.pop(), s2 = e2.stack.pop();
1600
1612
  let c2;
1601
- if (u$1(o$12)) {
1602
- const i2 = e2.heap.get(o$12.id);
1613
+ if (u$1(s2)) {
1614
+ const i2 = e2.heap.get(s2.id);
1603
1615
  if (!i2 || i2.type !== "array")
1604
1616
  return {
1605
1617
  type: "RuntimeError",
@@ -1608,8 +1620,8 @@ const ce = {
1608
1620
  opcode: t$1.op
1609
1621
  };
1610
1622
  c2 = i2.data;
1611
- } else if (b(o$12)) {
1612
- const i2 = e2.heap.get(o$12.id);
1623
+ } else if (b(s2)) {
1624
+ const i2 = e2.heap.get(s2.id);
1613
1625
  if (!i2 || i2.type !== "object")
1614
1626
  return {
1615
1627
  type: "RuntimeError",
@@ -1617,11 +1629,11 @@ const ce = {
1617
1629
  pc: e2.pc,
1618
1630
  opcode: t$1.op
1619
1631
  };
1620
- const u2 = i2.data, y2 = p$1(s2);
1621
- u2.properties[y2] = r2, e2.stack.push(o$12);
1632
+ const u2 = i2.data, y2 = p$1(o$1);
1633
+ u2.properties[y2] = r2, e2.stack.push(s2);
1622
1634
  return;
1623
- } else if (o(o$12))
1624
- c2 = o$12;
1635
+ } else if (o(s2))
1636
+ c2 = s2;
1625
1637
  else
1626
1638
  return {
1627
1639
  type: "RuntimeError",
@@ -1630,14 +1642,14 @@ const ce = {
1630
1642
  opcode: t$1.op
1631
1643
  };
1632
1644
  let p2;
1633
- if (i$1(s2))
1634
- p2 = s2;
1635
- else if (t(s2)) {
1636
- const i2 = parseInt(s2, 10);
1637
- if (!isNaN(i2) && i2.toString() === s2 && i2 >= 0)
1645
+ if (i$1(o$1))
1646
+ p2 = o$1;
1647
+ else if (t(o$1)) {
1648
+ const i2 = parseInt(o$1, 10);
1649
+ if (!isNaN(i2) && i2.toString() === o$1 && i2 >= 0)
1638
1650
  p2 = i2;
1639
1651
  else {
1640
- c2.properties || (c2.properties = {}), c2.properties[s2] = r2, e2.stack.push(o$12);
1652
+ c2.properties || (c2.properties = {}), c2.properties[o$1] = r2, e2.stack.push(s2);
1641
1653
  return;
1642
1654
  }
1643
1655
  } else
@@ -1655,27 +1667,27 @@ const ce = {
1655
1667
  pc: e2.pc,
1656
1668
  opcode: t$1.op
1657
1669
  };
1658
- c2.elements[a2] = r2, e2.stack.push(o$12);
1670
+ c2.elements[a2] = r2, e2.stack.push(s2);
1659
1671
  }
1660
1672
  },
1661
- [i$2.ARRAY_LEN]: {
1673
+ [n.ARRAY_LEN]: {
1662
1674
  stackIn: 1,
1663
1675
  stackOut: 1,
1664
1676
  execute: (e2, t2) => {
1665
1677
  const r2 = e2.stack.pop();
1666
- let s2;
1678
+ let o$1;
1667
1679
  if (u$1(r2)) {
1668
- const o2 = e2.heap.get(r2.id);
1669
- if (!o2 || o2.type !== "array")
1680
+ const s2 = e2.heap.get(r2.id);
1681
+ if (!s2 || s2.type !== "array")
1670
1682
  return {
1671
1683
  type: "RuntimeError",
1672
1684
  message: "Invalid array reference",
1673
1685
  pc: e2.pc,
1674
1686
  opcode: t2.op
1675
1687
  };
1676
- s2 = o2.data;
1688
+ o$1 = s2.data;
1677
1689
  } else if (o(r2))
1678
- s2 = r2;
1690
+ o$1 = r2;
1679
1691
  else
1680
1692
  return {
1681
1693
  type: "RuntimeError",
@@ -1683,30 +1695,30 @@ const ce = {
1683
1695
  pc: e2.pc,
1684
1696
  opcode: t2.op
1685
1697
  };
1686
- e2.stack.push(s2.elements.length);
1698
+ e2.stack.push(o$1.elements.length);
1687
1699
  }
1688
1700
  },
1689
- [i$2.ARRAY_MAP_PROP]: {
1701
+ [n.ARRAY_MAP_PROP]: {
1690
1702
  stackIn: 2,
1691
1703
  stackOut: 1,
1692
1704
  execute: (e2, t2) => {
1693
- const r2 = e2.stack.pop(), s$12 = e2.stack.pop();
1694
- if (!u$1(s$12))
1705
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1706
+ if (!u$1(o2))
1695
1707
  return {
1696
1708
  type: "RuntimeError",
1697
1709
  message: "map() requires an array",
1698
1710
  pc: e2.pc,
1699
1711
  opcode: t2.op
1700
1712
  };
1701
- const o2 = e2.heap.get(s$12.id);
1702
- if (!o2 || o2.type !== "array")
1713
+ const s$12 = e2.heap.get(o2.id);
1714
+ if (!s$12 || s$12.type !== "array")
1703
1715
  return {
1704
1716
  type: "RuntimeError",
1705
1717
  message: "Invalid array reference",
1706
1718
  pc: e2.pc,
1707
1719
  opcode: t2.op
1708
1720
  };
1709
- const c2 = o2.data, p2 = s();
1721
+ const c2 = s$12.data, p2 = s();
1710
1722
  for (const i2 of c2.elements)
1711
1723
  if (b(i2)) {
1712
1724
  const u2 = e2.heap.get(i2.id);
@@ -1721,27 +1733,27 @@ const ce = {
1721
1733
  e2.stack.push(a2);
1722
1734
  }
1723
1735
  },
1724
- [i$2.ARRAY_FILTER_PROP]: {
1736
+ [n.ARRAY_FILTER_PROP]: {
1725
1737
  stackIn: 2,
1726
1738
  stackOut: 1,
1727
1739
  execute: (e2, t2) => {
1728
- const r2 = e2.stack.pop(), s$12 = e2.stack.pop();
1729
- if (!u$1(s$12))
1740
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1741
+ if (!u$1(o2))
1730
1742
  return {
1731
1743
  type: "RuntimeError",
1732
1744
  message: "filter() requires an array",
1733
1745
  pc: e2.pc,
1734
1746
  opcode: t2.op
1735
1747
  };
1736
- const o2 = e2.heap.get(s$12.id);
1737
- if (!o2 || o2.type !== "array")
1748
+ const s$12 = e2.heap.get(o2.id);
1749
+ if (!s$12 || s$12.type !== "array")
1738
1750
  return {
1739
1751
  type: "RuntimeError",
1740
1752
  message: "Invalid array reference",
1741
1753
  pc: e2.pc,
1742
1754
  opcode: t2.op
1743
1755
  };
1744
- const c2 = o2.data, p2 = s();
1756
+ const c2 = s$12.data, p2 = s();
1745
1757
  for (const i2 of c2.elements)
1746
1758
  if (b(i2)) {
1747
1759
  const u2 = e2.heap.get(i2.id);
@@ -1754,71 +1766,71 @@ const ce = {
1754
1766
  e2.stack.push(a2);
1755
1767
  }
1756
1768
  },
1757
- [i$2.ARRAY_SLICE]: {
1769
+ [n.ARRAY_SLICE]: {
1758
1770
  stackIn: 3,
1759
1771
  // array, start, end
1760
1772
  stackOut: 1,
1761
1773
  execute: (e2, t2) => {
1762
- const r2 = e2.stack.pop(), s$12 = e2.stack.pop(), o2 = e2.stack.pop();
1763
- if (!((M2) => {
1764
- if (!u$1(M2))
1774
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s$12 = e2.stack.pop();
1775
+ if (!((L2) => {
1776
+ if (!u$1(L2))
1765
1777
  return false;
1766
- const U2 = e2.heap.get(M2.id);
1778
+ const U2 = e2.heap.get(L2.id);
1767
1779
  return U2 !== void 0 && U2.type === "array";
1768
- })(o2))
1780
+ })(s$12))
1769
1781
  return {
1770
1782
  type: "RuntimeError",
1771
1783
  message: "ARRAY_SLICE requires an array",
1772
1784
  pc: e2.pc,
1773
1785
  opcode: t2.op
1774
1786
  };
1775
- const a2 = e2.heap.get(o2.id).data, i2 = i$1(s$12) ? s$12 : 0, u2 = r2 === void 0 ? a2.elements.length : i$1(r2) ? r2 : a2.elements.length, y2 = i2 < 0 ? Math.max(0, a2.elements.length + i2) : i2, E2 = u2 < 0 ? Math.max(0, a2.elements.length + u2) : u2, J2 = a2.elements.slice(y2, E2), Y2 = s(J2), z2 = e2.heap.allocate("array", Y2);
1787
+ const a2 = e2.heap.get(s$12.id).data, i2 = i$1(o2) ? o2 : 0, u2 = r2 === void 0 ? a2.elements.length : i$1(r2) ? r2 : a2.elements.length, y2 = i2 < 0 ? Math.max(0, a2.elements.length + i2) : i2, E2 = u2 < 0 ? Math.max(0, a2.elements.length + u2) : u2, J2 = a2.elements.slice(y2, E2), Y2 = s(J2), z2 = e2.heap.allocate("array", Y2);
1776
1788
  e2.stack.push(z2);
1777
1789
  }
1778
1790
  },
1779
- [i$2.ARRAY_JOIN]: {
1791
+ [n.ARRAY_JOIN]: {
1780
1792
  stackIn: 2,
1781
1793
  // array, separator
1782
1794
  stackOut: 1,
1783
1795
  // string
1784
1796
  execute: (e2, t$1) => {
1785
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
1797
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1786
1798
  if (!((y2) => {
1787
1799
  if (!u$1(y2))
1788
1800
  return false;
1789
1801
  const E2 = e2.heap.get(y2.id);
1790
1802
  return E2 !== void 0 && E2.type === "array";
1791
- })(s2))
1803
+ })(o2))
1792
1804
  return {
1793
1805
  type: "RuntimeError",
1794
1806
  message: "ARRAY_JOIN requires an array",
1795
1807
  pc: e2.pc,
1796
1808
  opcode: t$1.op
1797
1809
  };
1798
- const p2 = e2.heap.get(s2.id).data, a2 = t(r2) ? r2 : String(r2), u2 = p2.elements.map((y2) => y2 === null ? "null" : y2 === void 0 || c(y2) ? "undefined" : String(y2)).join(a2);
1810
+ const p2 = e2.heap.get(o2.id).data, a2 = t(r2) ? r2 : String(r2), u2 = p2.elements.map((y2) => y2 === null ? "null" : y2 === void 0 || c(y2) ? "undefined" : String(y2)).join(a2);
1799
1811
  e2.stack.push(u2);
1800
1812
  }
1801
1813
  },
1802
- [i$2.ARRAY_INDEX_OF]: {
1814
+ [n.ARRAY_INDEX_OF]: {
1803
1815
  stackIn: 2,
1804
1816
  // array, searchElement
1805
1817
  stackOut: 1,
1806
1818
  // number (index or -1)
1807
1819
  execute: (e2, t2) => {
1808
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
1820
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1809
1821
  if (!((a2) => {
1810
1822
  if (!u$1(a2))
1811
1823
  return false;
1812
1824
  const i2 = e2.heap.get(a2.id);
1813
1825
  return i2 !== void 0 && i2.type === "array";
1814
- })(s2))
1826
+ })(o2))
1815
1827
  return {
1816
1828
  type: "RuntimeError",
1817
1829
  message: "ARRAY_INDEX_OF requires an array",
1818
1830
  pc: e2.pc,
1819
1831
  opcode: t2.op
1820
1832
  };
1821
- const p2 = e2.heap.get(s2.id).data;
1833
+ const p2 = e2.heap.get(o2.id).data;
1822
1834
  for (let a2 = 0; a2 < p2.elements.length; a2++)
1823
1835
  if (p2.elements[a2] === r2) {
1824
1836
  e2.stack.push(a2);
@@ -1828,39 +1840,39 @@ const ce = {
1828
1840
  }
1829
1841
  }
1830
1842
  };
1831
- function L(e2, t2) {
1843
+ function M(e2, t2) {
1832
1844
  if (e2 === null) return null;
1833
1845
  if (e2 !== void 0) {
1834
1846
  if (typeof e2 == "string" || typeof e2 == "number" || typeof e2 == "boolean" || e2 && typeof e2 == "object" && e2.type === "array" && Array.isArray(e2.elements))
1835
1847
  return e2;
1836
1848
  if (Array.isArray(e2)) {
1837
1849
  const r2 = s();
1838
- return r2.elements = e2.map((s2) => L(s2, t2)), t2.allocate("array", r2);
1850
+ return r2.elements = e2.map((o2) => M(o2, t2)), t2.allocate("array", r2);
1839
1851
  }
1840
1852
  if (e2 && typeof e2 == "object" && e2.type === "object" && e2.properties)
1841
1853
  return e2;
1842
1854
  if (typeof e2 == "object") {
1843
- const r2 = M();
1844
- for (const [s2, o2] of Object.entries(e2))
1845
- r2.properties[s2] = L(o2, t2);
1855
+ const r2 = M$1();
1856
+ for (const [o2, s2] of Object.entries(e2))
1857
+ r2.properties[o2] = M(s2, t2);
1846
1858
  return t2.allocate("object", r2);
1847
1859
  }
1848
1860
  return null;
1849
1861
  }
1850
1862
  }
1851
1863
  const ae = {
1852
- [i$2.CONCAT]: {
1864
+ [n.CONCAT]: {
1853
1865
  stackIn: 2,
1854
1866
  stackOut: 1,
1855
1867
  execute: (e2, t2) => {
1856
1868
  const r2 = d(e2, t2.op);
1857
1869
  if (f2(r2)) return r2;
1858
- const s2 = d(e2, t2.op);
1859
- if (f2(s2)) return s2;
1860
- e2.stack.push(p$1(s2) + p$1(r2));
1870
+ const o2 = d(e2, t2.op);
1871
+ if (f2(o2)) return o2;
1872
+ e2.stack.push(p$1(o2) + p$1(r2));
1861
1873
  }
1862
1874
  },
1863
- [i$2.STRING_LEN]: {
1875
+ [n.STRING_LEN]: {
1864
1876
  stackIn: 1,
1865
1877
  stackOut: 1,
1866
1878
  execute: (e2, t$1) => {
@@ -1876,7 +1888,7 @@ const ae = {
1876
1888
  e2.stack.push(r2.length);
1877
1889
  }
1878
1890
  },
1879
- [i$2.LENGTH]: {
1891
+ [n.LENGTH]: {
1880
1892
  stackIn: 1,
1881
1893
  stackOut: 1,
1882
1894
  execute: (e2, t$1) => {
@@ -1887,16 +1899,16 @@ const ae = {
1887
1899
  else if (o(r2))
1888
1900
  e2.stack.push(r2.elements.length);
1889
1901
  else if (u$1(r2)) {
1890
- const s2 = e2.heap.get(r2.id);
1891
- if (!s2 || s2.type !== "array")
1902
+ const o2 = e2.heap.get(r2.id);
1903
+ if (!o2 || o2.type !== "array")
1892
1904
  return {
1893
1905
  type: "RuntimeError",
1894
1906
  message: "Invalid array reference",
1895
1907
  pc: e2.pc,
1896
1908
  opcode: t$1.op
1897
1909
  };
1898
- const o2 = s2.data;
1899
- e2.stack.push(o2.elements.length);
1910
+ const s2 = o2.data;
1911
+ e2.stack.push(s2.elements.length);
1900
1912
  } else
1901
1913
  return {
1902
1914
  type: "RuntimeError",
@@ -1906,7 +1918,7 @@ const ae = {
1906
1918
  };
1907
1919
  }
1908
1920
  },
1909
- [i$2.JSON_PARSE]: {
1921
+ [n.JSON_PARSE]: {
1910
1922
  stackIn: 1,
1911
1923
  stackOut: 1,
1912
1924
  execute: (e2, t$1) => {
@@ -1920,14 +1932,14 @@ const ae = {
1920
1932
  opcode: t$1.op
1921
1933
  };
1922
1934
  try {
1923
- const s2 = JSON.parse(r2);
1924
- e2.stack.push(L(s2, e2.heap));
1935
+ const o2 = JSON.parse(r2);
1936
+ e2.stack.push(M(o2, e2.heap));
1925
1937
  } catch {
1926
1938
  e2.stack.push(null);
1927
1939
  }
1928
1940
  }
1929
1941
  },
1930
- [i$2.TYPEOF]: {
1942
+ [n.TYPEOF]: {
1931
1943
  stackIn: 1,
1932
1944
  stackOut: 1,
1933
1945
  execute: (e2, t2) => {
@@ -1937,7 +1949,7 @@ const ae = {
1937
1949
  }
1938
1950
  }
1939
1951
  }, ie = {
1940
- [i$2.INC]: {
1952
+ [n.INC]: {
1941
1953
  stackIn: 1,
1942
1954
  stackOut: 1,
1943
1955
  execute: (e2, t2) => {
@@ -1949,13 +1961,13 @@ const ae = {
1949
1961
  pc: e2.pc,
1950
1962
  opcode: t2.op
1951
1963
  };
1952
- const s2 = e2.variables.get(r2) ?? 0, o2 = m(s2) + 1;
1953
- e2.variables.set(r2, o2);
1964
+ const o2 = e2.variables.get(r2) ?? 0, s2 = m(o2) + 1;
1965
+ e2.variables.set(r2, s2);
1954
1966
  const c2 = t2.arg === true;
1955
- e2.stack.push(c2 ? m(s2) : o2);
1967
+ e2.stack.push(c2 ? m(o2) : s2);
1956
1968
  }
1957
1969
  },
1958
- [i$2.DEC]: {
1970
+ [n.DEC]: {
1959
1971
  stackIn: 1,
1960
1972
  stackOut: 1,
1961
1973
  execute: (e2, t2) => {
@@ -1967,14 +1979,14 @@ const ae = {
1967
1979
  pc: e2.pc,
1968
1980
  opcode: t2.op
1969
1981
  };
1970
- const s2 = e2.variables.get(r2) ?? 0, o2 = m(s2) - 1;
1971
- e2.variables.set(r2, o2);
1982
+ const o2 = e2.variables.get(r2) ?? 0, s2 = m(o2) - 1;
1983
+ e2.variables.set(r2, s2);
1972
1984
  const c2 = t2.arg === true;
1973
- e2.stack.push(c2 ? m(s2) : o2);
1985
+ e2.stack.push(c2 ? m(o2) : s2);
1974
1986
  }
1975
1987
  }
1976
1988
  }, ue = {
1977
- [i$2.RETURN]: {
1989
+ [n.RETURN]: {
1978
1990
  stackIn: 0,
1979
1991
  stackOut: 0,
1980
1992
  controlsPC: true,
@@ -1983,7 +1995,7 @@ const ae = {
1983
1995
  e2.returnValue = r2, e2.status = "complete";
1984
1996
  }
1985
1997
  },
1986
- [i$2.BREAK]: {
1998
+ [n.BREAK]: {
1987
1999
  stackIn: 0,
1988
2000
  stackOut: 0,
1989
2001
  controlsPC: true,
@@ -2006,7 +2018,7 @@ const ae = {
2006
2018
  e2.pc = r2;
2007
2019
  }
2008
2020
  },
2009
- [i$2.CONTINUE]: {
2021
+ [n.CONTINUE]: {
2010
2022
  stackIn: 0,
2011
2023
  stackOut: 0,
2012
2024
  controlsPC: true,
@@ -2019,17 +2031,17 @@ const ae = {
2019
2031
  opcode: t2.op
2020
2032
  };
2021
2033
  const r2 = t2.arg;
2022
- if (r2 < 0)
2034
+ if (r2 < 0 || r2 === -1)
2023
2035
  return {
2024
2036
  type: "RuntimeError",
2025
- message: `Invalid continue target: ${r2}`,
2037
+ message: `Invalid continue target: ${r2} (not patched properly during compilation)`,
2026
2038
  pc: e2.pc,
2027
2039
  opcode: t2.op
2028
2040
  };
2029
2041
  e2.pc = r2;
2030
2042
  }
2031
2043
  },
2032
- [i$2.FS_LIST_FILES]: {
2044
+ [n.FS_LIST_FILES]: {
2033
2045
  stackIn: 1,
2034
2046
  // Minimum 1 argument (path), optionally 2 (path + options)
2035
2047
  stackOut: 1,
@@ -2041,9 +2053,9 @@ const ae = {
2041
2053
  pc: e2.pc,
2042
2054
  opcode: t$1.op
2043
2055
  };
2044
- let r2, s2 = {};
2045
- const o$12 = e2.stack[e2.stack.length - 1];
2046
- if (e2.stack.length >= 2 && typeof o$12 == "object" && o$12 !== null && !o(o$12) && (s2 = e2.stack.pop()), r2 = e2.stack.pop(), !t(r2))
2056
+ let r2, o$1 = {};
2057
+ const s2 = e2.stack[e2.stack.length - 1];
2058
+ if (e2.stack.length >= 2 && typeof s2 == "object" && s2 !== null && !o(s2) && (o$1 = e2.stack.pop()), r2 = e2.stack.pop(), !t(r2))
2047
2059
  return {
2048
2060
  type: "RuntimeError",
2049
2061
  message: "FS_LIST_FILES requires a string path",
@@ -2057,7 +2069,7 @@ const ae = {
2057
2069
  pc: e2.pc,
2058
2070
  opcode: t$1.op
2059
2071
  };
2060
- const c2 = e2.fileSystem.listFiles(r2, s2);
2072
+ const c2 = e2.fileSystem.listFiles(r2, o$1);
2061
2073
  if (o(c2)) {
2062
2074
  const p2 = e2.heap.allocate("array", c2);
2063
2075
  e2.stack.push(p2);
@@ -2065,7 +2077,7 @@ const ae = {
2065
2077
  e2.stack.push(c2);
2066
2078
  }
2067
2079
  },
2068
- [i$2.FS_READ_FILE]: {
2080
+ [n.FS_READ_FILE]: {
2069
2081
  stackIn: 1,
2070
2082
  // path
2071
2083
  stackOut: 1,
@@ -2086,18 +2098,18 @@ const ae = {
2086
2098
  pc: e2.pc,
2087
2099
  opcode: t$1.op
2088
2100
  };
2089
- const s2 = e2.fileSystem.readFile(r2);
2090
- e2.stack.push(s2);
2101
+ const o2 = e2.fileSystem.readFile(r2);
2102
+ e2.stack.push(o2);
2091
2103
  }
2092
2104
  },
2093
- [i$2.FS_WRITE_FILE]: {
2105
+ [n.FS_WRITE_FILE]: {
2094
2106
  stackIn: 2,
2095
2107
  // path, content
2096
2108
  stackOut: 1,
2097
2109
  // Returns boolean
2098
2110
  execute: (e2, t$1) => {
2099
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2100
- if (!s2 || !t(s2))
2111
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2112
+ if (!o2 || !t(o2))
2101
2113
  return {
2102
2114
  type: "RuntimeError",
2103
2115
  message: "FS_WRITE_FILE requires a string path",
@@ -2118,12 +2130,12 @@ const ae = {
2118
2130
  pc: e2.pc,
2119
2131
  opcode: t$1.op
2120
2132
  };
2121
- const o2 = p$1(r2), c2 = e2.fileSystem.writeFile(s2, o2);
2133
+ const s2 = p$1(r2), c2 = e2.fileSystem.writeFile(o2, s2);
2122
2134
  e2.stack.push(c2);
2123
2135
  }
2124
2136
  },
2125
2137
  // String method handlers
2126
- [i$2.STRING_SUBSTRING]: {
2138
+ [n.STRING_SUBSTRING]: {
2127
2139
  stackIn: 2,
2128
2140
  // Minimum 2 (string, start), optionally 3 (string, start, end)
2129
2141
  stackOut: 1,
@@ -2136,62 +2148,62 @@ const ae = {
2136
2148
  opcode: t$1.op
2137
2149
  };
2138
2150
  const r2 = e2.stack.length;
2139
- let s2, o2, c2;
2151
+ let o2, s2, c2;
2140
2152
  const p2 = e2.stack[r2 - 1], a2 = e2.stack[r2 - 2];
2141
- if (r2 >= 3 && typeof p2 == "number" && typeof a2 == "number" ? (c2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop()) : (o2 = e2.stack.pop(), s2 = e2.stack.pop(), c2 = void 0), !t(s2))
2153
+ if (r2 >= 3 && typeof p2 == "number" && typeof a2 == "number" ? (c2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop()) : (s2 = e2.stack.pop(), o2 = e2.stack.pop(), c2 = void 0), !t(o2))
2142
2154
  return {
2143
2155
  type: "RuntimeError",
2144
2156
  message: "STRING_SUBSTRING requires a string",
2145
2157
  pc: e2.pc,
2146
2158
  opcode: t$1.op
2147
2159
  };
2148
- if (typeof o2 != "number")
2160
+ if (typeof s2 != "number")
2149
2161
  return {
2150
2162
  type: "RuntimeError",
2151
2163
  message: "STRING_SUBSTRING requires numeric start index",
2152
2164
  pc: e2.pc,
2153
2165
  opcode: t$1.op
2154
2166
  };
2155
- const i2 = s2.length;
2156
- o2 < 0 && (o2 = Math.max(0, i2 + o2)), c2 !== void 0 && c2 < 0 && (c2 = Math.max(0, i2 + c2));
2157
- const u2 = c2 !== void 0 ? s2.substring(o2, c2) : s2.substring(o2);
2167
+ const i2 = o2.length;
2168
+ s2 < 0 && (s2 = Math.max(0, i2 + s2)), c2 !== void 0 && c2 < 0 && (c2 = Math.max(0, i2 + c2));
2169
+ const u2 = c2 !== void 0 ? o2.substring(s2, c2) : o2.substring(s2);
2158
2170
  e2.stack.push(u2);
2159
2171
  }
2160
2172
  },
2161
- [i$2.STRING_INDEXOF]: {
2173
+ [n.STRING_INDEXOF]: {
2162
2174
  stackIn: 2,
2163
2175
  stackOut: 1,
2164
2176
  execute: (e2, t$1) => {
2165
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2166
- if (!t(s2) || !t(r2))
2177
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2178
+ if (!t(o2) || !t(r2))
2167
2179
  return {
2168
2180
  type: "RuntimeError",
2169
2181
  message: "STRING_INDEXOF requires string arguments",
2170
2182
  pc: e2.pc,
2171
2183
  opcode: t$1.op
2172
2184
  };
2173
- e2.stack.push(s2.indexOf(r2));
2185
+ e2.stack.push(o2.indexOf(r2));
2174
2186
  }
2175
2187
  },
2176
- [i$2.STRING_SPLIT]: {
2188
+ [n.STRING_SPLIT]: {
2177
2189
  stackIn: 2,
2178
2190
  stackOut: 1,
2179
2191
  execute: (e2, t$1) => {
2180
- const r2 = e2.stack.pop(), s$12 = e2.stack.pop();
2181
- if (!t(s$12) || !t(r2))
2192
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2193
+ if (!t(o2) || !t(r2))
2182
2194
  return {
2183
2195
  type: "RuntimeError",
2184
2196
  message: "STRING_SPLIT requires string arguments",
2185
2197
  pc: e2.pc,
2186
2198
  opcode: t$1.op
2187
2199
  };
2188
- let o2;
2189
- r2 === "" ? o2 = s$12.split("") : o2 = s$12.split(r2);
2190
- const c2 = s(o2), p2 = e2.heap.allocate("array", c2);
2200
+ let s$12;
2201
+ r2 === "" ? s$12 = o2.split("") : s$12 = o2.split(r2);
2202
+ const c2 = s(s$12), p2 = e2.heap.allocate("array", c2);
2191
2203
  e2.stack.push(p2);
2192
2204
  }
2193
2205
  },
2194
- [i$2.STRING_SLICE]: {
2206
+ [n.STRING_SLICE]: {
2195
2207
  stackIn: 2,
2196
2208
  // Minimum 2 (string, start), optionally 3 (string, start, end)
2197
2209
  stackOut: 1,
@@ -2204,32 +2216,32 @@ const ae = {
2204
2216
  opcode: t$1.op
2205
2217
  };
2206
2218
  const r2 = e2.stack.length;
2207
- let s2, o2, c2;
2219
+ let o2, s2, c2;
2208
2220
  const p2 = e2.stack.length >= 1 ? e2.stack[r2 - 1] : void 0, a2 = e2.stack.length >= 2 ? e2.stack[r2 - 2] : void 0;
2209
- if (r2 >= 3 && typeof p2 == "number" && typeof a2 == "number" ? (c2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop()) : (o2 = e2.stack.pop(), s2 = e2.stack.pop(), c2 = void 0), !t(s2))
2221
+ if (r2 >= 3 && typeof p2 == "number" && typeof a2 == "number" ? (c2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop()) : (s2 = e2.stack.pop(), o2 = e2.stack.pop(), c2 = void 0), !t(o2))
2210
2222
  return {
2211
2223
  type: "RuntimeError",
2212
2224
  message: "STRING_SLICE requires a string",
2213
2225
  pc: e2.pc,
2214
2226
  opcode: t$1.op
2215
2227
  };
2216
- if (typeof o2 != "number")
2228
+ if (typeof s2 != "number")
2217
2229
  return {
2218
2230
  type: "RuntimeError",
2219
2231
  message: "STRING_SLICE requires numeric start index",
2220
2232
  pc: e2.pc,
2221
2233
  opcode: t$1.op
2222
2234
  };
2223
- const i2 = c2 !== void 0 ? s2.slice(o2, c2) : s2.slice(o2);
2235
+ const i2 = c2 !== void 0 ? o2.slice(s2, c2) : o2.slice(s2);
2224
2236
  e2.stack.push(i2);
2225
2237
  }
2226
2238
  },
2227
- [i$2.STRING_CHARAT]: {
2239
+ [n.STRING_CHARAT]: {
2228
2240
  stackIn: 2,
2229
2241
  stackOut: 1,
2230
2242
  execute: (e2, t$1) => {
2231
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2232
- if (!t(s2))
2243
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2244
+ if (!t(o2))
2233
2245
  return {
2234
2246
  type: "RuntimeError",
2235
2247
  message: "STRING_CHARAT requires a string",
@@ -2243,11 +2255,11 @@ const ae = {
2243
2255
  pc: e2.pc,
2244
2256
  opcode: t$1.op
2245
2257
  };
2246
- const o2 = s2.charAt(r2);
2247
- e2.stack.push(o2);
2258
+ const s2 = o2.charAt(r2);
2259
+ e2.stack.push(s2);
2248
2260
  }
2249
2261
  },
2250
- [i$2.STRING_TOUPPERCASE]: {
2262
+ [n.STRING_TOUPPERCASE]: {
2251
2263
  stackIn: 1,
2252
2264
  stackOut: 1,
2253
2265
  execute: (e2, t$1) => {
@@ -2262,7 +2274,7 @@ const ae = {
2262
2274
  e2.stack.push(r2.toUpperCase());
2263
2275
  }
2264
2276
  },
2265
- [i$2.STRING_TOLOWERCASE]: {
2277
+ [n.STRING_TOLOWERCASE]: {
2266
2278
  stackIn: 1,
2267
2279
  stackOut: 1,
2268
2280
  execute: (e2, t$1) => {
@@ -2277,7 +2289,7 @@ const ae = {
2277
2289
  e2.stack.push(r2.toLowerCase());
2278
2290
  }
2279
2291
  },
2280
- [i$2.TO_STRING]: {
2292
+ [n.TO_STRING]: {
2281
2293
  stackIn: 1,
2282
2294
  stackOut: 1,
2283
2295
  execute: (e2, t2) => {
@@ -2289,61 +2301,61 @@ const ae = {
2289
2301
  pc: e2.pc,
2290
2302
  opcode: t2.op
2291
2303
  };
2292
- const s2 = p$1(r2);
2293
- e2.stack.push(s2);
2304
+ const o2 = p$1(r2);
2305
+ e2.stack.push(o2);
2294
2306
  }
2295
2307
  },
2296
- [i$2.STRING_INCLUDES]: {
2308
+ [n.STRING_INCLUDES]: {
2297
2309
  stackIn: 2,
2298
2310
  // string, searchString
2299
2311
  stackOut: 1,
2300
2312
  // boolean
2301
2313
  execute: (e2, t$1) => {
2302
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2303
- if (!t(s2))
2314
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2315
+ if (!t(o2))
2304
2316
  return {
2305
2317
  type: "RuntimeError",
2306
2318
  message: "STRING_INCLUDES requires a string",
2307
2319
  pc: e2.pc,
2308
2320
  opcode: t$1.op
2309
2321
  };
2310
- const o2 = String(r2);
2311
- e2.stack.push(s2.includes(o2));
2322
+ const s2 = String(r2);
2323
+ e2.stack.push(o2.includes(s2));
2312
2324
  }
2313
2325
  },
2314
- [i$2.STRING_ENDS_WITH]: {
2326
+ [n.STRING_ENDS_WITH]: {
2315
2327
  stackIn: 2,
2316
2328
  stackOut: 1,
2317
2329
  execute: (e2, t$1) => {
2318
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2319
- if (!t(s2))
2330
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2331
+ if (!t(o2))
2320
2332
  return {
2321
2333
  type: "RuntimeError",
2322
2334
  message: "STRING_ENDS_WITH requires a string",
2323
2335
  pc: e2.pc,
2324
2336
  opcode: t$1.op
2325
2337
  };
2326
- const o2 = String(r2);
2327
- e2.stack.push(s2.endsWith(o2));
2338
+ const s2 = String(r2);
2339
+ e2.stack.push(o2.endsWith(s2));
2328
2340
  }
2329
2341
  },
2330
- [i$2.STRING_STARTS_WITH]: {
2342
+ [n.STRING_STARTS_WITH]: {
2331
2343
  stackIn: 2,
2332
2344
  stackOut: 1,
2333
2345
  execute: (e2, t$1) => {
2334
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2335
- if (!t(s2))
2346
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2347
+ if (!t(o2))
2336
2348
  return {
2337
2349
  type: "RuntimeError",
2338
2350
  message: "STRING_STARTS_WITH requires a string",
2339
2351
  pc: e2.pc,
2340
2352
  opcode: t$1.op
2341
2353
  };
2342
- const o2 = String(r2);
2343
- e2.stack.push(s2.startsWith(o2));
2354
+ const s2 = String(r2);
2355
+ e2.stack.push(o2.startsWith(s2));
2344
2356
  }
2345
2357
  },
2346
- [i$2.STRING_TRIM]: {
2358
+ [n.STRING_TRIM]: {
2347
2359
  stackIn: 1,
2348
2360
  stackOut: 1,
2349
2361
  execute: (e2, t$1) => {
@@ -2358,7 +2370,7 @@ const ae = {
2358
2370
  e2.stack.push(r2.trim());
2359
2371
  }
2360
2372
  },
2361
- [i$2.STRING_TRIM_START]: {
2373
+ [n.STRING_TRIM_START]: {
2362
2374
  stackIn: 1,
2363
2375
  stackOut: 1,
2364
2376
  execute: (e2, t$1) => {
@@ -2373,7 +2385,7 @@ const ae = {
2373
2385
  e2.stack.push(r2.trimStart());
2374
2386
  }
2375
2387
  },
2376
- [i$2.STRING_TRIM_END]: {
2388
+ [n.STRING_TRIM_END]: {
2377
2389
  stackIn: 1,
2378
2390
  stackOut: 1,
2379
2391
  execute: (e2, t$1) => {
@@ -2388,61 +2400,61 @@ const ae = {
2388
2400
  e2.stack.push(r2.trimEnd());
2389
2401
  }
2390
2402
  },
2391
- [i$2.STRING_REPLACE]: {
2403
+ [n.STRING_REPLACE]: {
2392
2404
  stackIn: 3,
2393
2405
  // string, search, replacement
2394
2406
  stackOut: 1,
2395
2407
  execute: (e2, t$1) => {
2396
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop();
2397
- if (!t(o2))
2408
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2409
+ if (!t(s2))
2398
2410
  return {
2399
2411
  type: "RuntimeError",
2400
2412
  message: "STRING_REPLACE requires a string",
2401
2413
  pc: e2.pc,
2402
2414
  opcode: t$1.op
2403
2415
  };
2404
- const c2 = String(s2), p2 = String(r2), a2 = o2.indexOf(c2), i2 = a2 === -1 ? o2 : o2.substring(0, a2) + p2 + o2.substring(a2 + c2.length);
2416
+ const c2 = String(r2), p2 = String(o2), a2 = s2.indexOf(p2), i2 = a2 === -1 ? s2 : s2.substring(0, a2) + c2 + s2.substring(a2 + p2.length);
2405
2417
  e2.stack.push(i2);
2406
2418
  }
2407
2419
  },
2408
- [i$2.STRING_REPLACE_ALL]: {
2420
+ [n.STRING_REPLACE_ALL]: {
2409
2421
  stackIn: 3,
2410
2422
  stackOut: 1,
2411
2423
  execute: (e2, t$1) => {
2412
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop();
2413
- if (!t(o2))
2424
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2425
+ if (!t(s2))
2414
2426
  return {
2415
2427
  type: "RuntimeError",
2416
2428
  message: "STRING_REPLACE_ALL requires a string",
2417
2429
  pc: e2.pc,
2418
2430
  opcode: t$1.op
2419
2431
  };
2420
- const c2 = String(s2), p2 = String(r2), a2 = o2.split(c2).join(p2);
2432
+ const c2 = String(o2), p2 = String(r2), a2 = s2.split(c2).join(p2);
2421
2433
  e2.stack.push(a2);
2422
2434
  }
2423
2435
  },
2424
- [i$2.STRING_LAST_INDEX_OF]: {
2436
+ [n.STRING_LAST_INDEX_OF]: {
2425
2437
  stackIn: 2,
2426
2438
  stackOut: 1,
2427
2439
  execute: (e2, t$1) => {
2428
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2429
- if (!t(s2))
2440
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2441
+ if (!t(o2))
2430
2442
  return {
2431
2443
  type: "RuntimeError",
2432
2444
  message: "STRING_LAST_INDEX_OF requires a string",
2433
2445
  pc: e2.pc,
2434
2446
  opcode: t$1.op
2435
2447
  };
2436
- const o2 = String(r2);
2437
- e2.stack.push(s2.lastIndexOf(o2));
2448
+ const s2 = String(r2);
2449
+ e2.stack.push(o2.lastIndexOf(s2));
2438
2450
  }
2439
2451
  },
2440
- [i$2.STRING_REPEAT]: {
2452
+ [n.STRING_REPEAT]: {
2441
2453
  stackIn: 2,
2442
2454
  stackOut: 1,
2443
2455
  execute: (e2, t$1) => {
2444
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2445
- if (!t(s2))
2456
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2457
+ if (!t(o2))
2446
2458
  return {
2447
2459
  type: "RuntimeError",
2448
2460
  message: "STRING_REPEAT requires a string",
@@ -2456,23 +2468,23 @@ const ae = {
2456
2468
  pc: e2.pc,
2457
2469
  opcode: t$1.op
2458
2470
  };
2459
- e2.stack.push(s2.repeat(Math.floor(r2)));
2471
+ e2.stack.push(o2.repeat(Math.floor(r2)));
2460
2472
  }
2461
2473
  },
2462
- [i$2.STRING_PAD_START]: {
2474
+ [n.STRING_PAD_START]: {
2463
2475
  stackIn: 3,
2464
2476
  // string, targetLength, padString
2465
2477
  stackOut: 1,
2466
2478
  execute: (e2, t$1) => {
2467
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop();
2468
- if (!t(o2))
2479
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2480
+ if (!t(s2))
2469
2481
  return {
2470
2482
  type: "RuntimeError",
2471
2483
  message: "STRING_PAD_START requires a string",
2472
2484
  pc: e2.pc,
2473
2485
  opcode: t$1.op
2474
2486
  };
2475
- if (!i$1(s2))
2487
+ if (!i$1(o2))
2476
2488
  return {
2477
2489
  type: "RuntimeError",
2478
2490
  message: "STRING_PAD_START requires number for length",
@@ -2480,22 +2492,22 @@ const ae = {
2480
2492
  opcode: t$1.op
2481
2493
  };
2482
2494
  const c2 = t(r2) ? r2 : String(r2);
2483
- e2.stack.push(o2.padStart(s2, c2 || " "));
2495
+ e2.stack.push(s2.padStart(o2, c2 || " "));
2484
2496
  }
2485
2497
  },
2486
- [i$2.STRING_PAD_END]: {
2498
+ [n.STRING_PAD_END]: {
2487
2499
  stackIn: 3,
2488
2500
  stackOut: 1,
2489
2501
  execute: (e2, t$1) => {
2490
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop();
2491
- if (!t(o2))
2502
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2503
+ if (!t(s2))
2492
2504
  return {
2493
2505
  type: "RuntimeError",
2494
2506
  message: "STRING_PAD_END requires a string",
2495
2507
  pc: e2.pc,
2496
2508
  opcode: t$1.op
2497
2509
  };
2498
- if (!i$1(s2))
2510
+ if (!i$1(o2))
2499
2511
  return {
2500
2512
  type: "RuntimeError",
2501
2513
  message: "STRING_PAD_END requires number for length",
@@ -2503,58 +2515,58 @@ const ae = {
2503
2515
  opcode: t$1.op
2504
2516
  };
2505
2517
  const c2 = t(r2) ? r2 : String(r2);
2506
- e2.stack.push(o2.padEnd(s2, c2 || " "));
2518
+ e2.stack.push(s2.padEnd(o2, c2 || " "));
2507
2519
  }
2508
2520
  }
2509
2521
  };
2510
- function j(e2, t2) {
2522
+ function A(e2, t2) {
2511
2523
  if (u$1(e2)) {
2512
2524
  const r2 = t2.get(e2.id);
2513
- return r2 && r2.type === "array" ? r2.data.elements.map((o2) => j(o2, t2)) : null;
2525
+ return r2 && r2.type === "array" ? r2.data.elements.map((s2) => A(s2, t2)) : null;
2514
2526
  }
2515
2527
  if (b(e2)) {
2516
2528
  const r2 = t2.get(e2.id);
2517
2529
  if (r2 && r2.type === "object") {
2518
- const s2 = r2.data, o2 = {};
2519
- for (const [c2, p2] of Object.entries(s2.properties))
2520
- o2[c2] = j(p2, t2);
2521
- return o2;
2530
+ const o2 = r2.data, s2 = {};
2531
+ for (const [c2, p2] of Object.entries(o2.properties))
2532
+ s2[c2] = A(p2, t2);
2533
+ return s2;
2522
2534
  }
2523
2535
  return null;
2524
2536
  }
2525
2537
  if (o(e2))
2526
- return e2.elements.map((r2) => j(r2, t2));
2538
+ return e2.elements.map((r2) => A(r2, t2));
2527
2539
  if (y(e2)) {
2528
2540
  const r2 = {};
2529
- for (const [s2, o2] of Object.entries(e2.properties))
2530
- r2[s2] = j(o2, t2);
2541
+ for (const [o2, s2] of Object.entries(e2.properties))
2542
+ r2[o2] = A(s2, t2);
2531
2543
  return r2;
2532
2544
  }
2533
2545
  if (!c(e2))
2534
2546
  return e2;
2535
2547
  }
2536
2548
  const le = {
2537
- [i$2.OBJECT_CREATE]: {
2549
+ [n.OBJECT_CREATE]: {
2538
2550
  stackIn: 0,
2539
2551
  stackOut: 1,
2540
2552
  execute: (e2) => {
2541
- const t2 = M(), r2 = e2.heap.allocate("object", t2);
2553
+ const t2 = M$1(), r2 = e2.heap.allocate("object", t2);
2542
2554
  e2.stack.push(r2);
2543
2555
  }
2544
2556
  },
2545
- [i$2.PROPERTY_SET]: {
2557
+ [n.PROPERTY_SET]: {
2546
2558
  stackIn: 3,
2547
2559
  stackOut: 1,
2548
2560
  execute: (e2, t2) => {
2549
2561
  const r2 = d(e2, t2.op);
2550
2562
  if (f2(r2)) return r2;
2551
- const s2 = d(e2, t2.op);
2552
- if (f2(s2)) return s2;
2553
2563
  const o2 = d(e2, t2.op);
2554
2564
  if (f2(o2)) return o2;
2565
+ const s2 = d(e2, t2.op);
2566
+ if (f2(s2)) return s2;
2555
2567
  let c2;
2556
- if (b(o2)) {
2557
- const a2 = e2.heap.get(o2.id);
2568
+ if (b(s2)) {
2569
+ const a2 = e2.heap.get(s2.id);
2558
2570
  if (!a2 || a2.type !== "object")
2559
2571
  return {
2560
2572
  type: "RuntimeError",
@@ -2563,37 +2575,37 @@ const le = {
2563
2575
  opcode: t2.op
2564
2576
  };
2565
2577
  c2 = a2.data;
2566
- } else if (y(o2))
2567
- c2 = o2;
2578
+ } else if (y(s2))
2579
+ c2 = s2;
2568
2580
  else
2569
2581
  return {
2570
2582
  type: "RuntimeError",
2571
- message: `Cannot set property '${s2}' on ${d$2(o2)}`,
2583
+ message: `Cannot set property '${o2}' on ${d$2(s2)}`,
2572
2584
  pc: e2.pc,
2573
2585
  opcode: t2.op
2574
2586
  };
2575
- const p2 = p$1(s2);
2576
- c2.properties[p2] = r2, e2.stack.push(o2);
2587
+ const p2 = p$1(o2);
2588
+ c2.properties[p2] = r2, e2.stack.push(s2);
2577
2589
  }
2578
2590
  },
2579
- [i$2.PROPERTY_GET]: {
2591
+ [n.PROPERTY_GET]: {
2580
2592
  stackIn: 2,
2581
2593
  stackOut: 1,
2582
2594
  execute: (e2, t2) => {
2583
2595
  const r2 = d(e2, t2.op);
2584
2596
  if (f2(r2)) return r2;
2585
- const s2 = d(e2, t2.op);
2586
- if (f2(s2)) return s2;
2587
- if (f$2(s2) || c(s2))
2597
+ const o2 = d(e2, t2.op);
2598
+ if (f2(o2)) return o2;
2599
+ if (f$2(o2) || c(o2))
2588
2600
  return {
2589
2601
  type: "RuntimeError",
2590
- message: `Cannot read property '${r2}' of ${d$2(s2)}`,
2602
+ message: `Cannot read property '${r2}' of ${d$2(o2)}`,
2591
2603
  pc: e2.pc,
2592
2604
  opcode: t2.op
2593
2605
  };
2594
- let o2 = null;
2595
- if (b(s2)) {
2596
- const p2 = e2.heap.get(s2.id);
2606
+ let s2 = null;
2607
+ if (b(o2)) {
2608
+ const p2 = e2.heap.get(o2.id);
2597
2609
  if (!p2 || p2.type !== "object")
2598
2610
  return {
2599
2611
  type: "RuntimeError",
@@ -2601,58 +2613,58 @@ const le = {
2601
2613
  pc: e2.pc,
2602
2614
  opcode: t2.op
2603
2615
  };
2604
- o2 = p2.data;
2605
- } else if (y(s2))
2606
- o2 = s2;
2616
+ s2 = p2.data;
2617
+ } else if (y(o2))
2618
+ s2 = o2;
2607
2619
  else {
2608
2620
  e2.stack.push(C$1());
2609
2621
  return;
2610
2622
  }
2611
- const c$1 = o2.properties[p$1(r2)];
2623
+ const c$1 = s2.properties[p$1(r2)];
2612
2624
  e2.stack.push(c$1 ?? C$1());
2613
2625
  }
2614
2626
  },
2615
- [i$2.JSON_STRINGIFY]: {
2627
+ [n.JSON_STRINGIFY]: {
2616
2628
  stackIn: 1,
2617
2629
  stackOut: 1,
2618
2630
  execute: (e2, t2) => {
2619
2631
  const r2 = d(e2, t2.op);
2620
2632
  if (f2(r2)) return r2;
2621
- const s2 = j(r2, e2.heap);
2622
- e2.stack.push(JSON.stringify(s2));
2633
+ const o2 = A(r2, e2.heap);
2634
+ e2.stack.push(JSON.stringify(o2));
2623
2635
  }
2624
2636
  },
2625
- [i$2.OBJECT_KEYS]: {
2637
+ [n.OBJECT_KEYS]: {
2626
2638
  stackIn: 1,
2627
2639
  stackOut: 1,
2628
2640
  execute: (e2, t2) => {
2629
2641
  const r2 = d(e2, t2.op);
2630
2642
  if (f2(r2)) return r2;
2631
2643
  if (b(r2)) {
2632
- const s2 = e2.heap.get(r2.id);
2633
- if (s2 && s2.type === "object") {
2634
- const o2 = s2.data, c2 = Object.keys(o2.properties), p2 = e2.heap.allocate("array", { type: "array", elements: c2 });
2644
+ const o2 = e2.heap.get(r2.id);
2645
+ if (o2 && o2.type === "object") {
2646
+ const s2 = o2.data, c2 = Object.keys(s2.properties), p2 = e2.heap.allocate("array", { type: "array", elements: c2 });
2635
2647
  e2.stack.push(p2);
2636
2648
  } else
2637
2649
  e2.stack.push(null);
2638
2650
  } else if (y(r2)) {
2639
- const s2 = Object.keys(r2.properties), o2 = e2.heap.allocate("array", { type: "array", elements: s2 });
2640
- e2.stack.push(o2);
2651
+ const o2 = Object.keys(r2.properties), s2 = e2.heap.allocate("array", { type: "array", elements: o2 });
2652
+ e2.stack.push(s2);
2641
2653
  } else
2642
2654
  e2.stack.push(null);
2643
2655
  }
2644
2656
  }
2645
2657
  }, de = {
2646
- [i$2.OBJECT_ITER_START]: {
2658
+ [n.OBJECT_ITER_START]: {
2647
2659
  stackIn: 1,
2648
2660
  stackOut: 0,
2649
2661
  execute: (e2, t2) => {
2650
2662
  const r2 = d(e2, t2.op);
2651
2663
  if (f2(r2)) return r2;
2652
2664
  if (b(r2)) {
2653
- const s2 = e2.heap.get(r2.id);
2654
- if (s2 && s2.type === "object") {
2655
- const o2 = s2.data, c2 = Object.keys(o2.properties);
2665
+ const o2 = e2.heap.get(r2.id);
2666
+ if (o2 && o2.type === "object") {
2667
+ const s2 = o2.data, c2 = Object.keys(s2.properties);
2656
2668
  e2.iterators.push({
2657
2669
  array: null,
2658
2670
  keys: c2,
@@ -2667,12 +2679,12 @@ const le = {
2667
2679
  length: 0
2668
2680
  });
2669
2681
  } else if (y(r2)) {
2670
- const s2 = Object.keys(r2.properties);
2682
+ const o2 = Object.keys(r2.properties);
2671
2683
  e2.iterators.push({
2672
2684
  array: null,
2673
- keys: s2,
2685
+ keys: o2,
2674
2686
  index: 0,
2675
- length: s2.length
2687
+ length: o2.length
2676
2688
  });
2677
2689
  } else
2678
2690
  e2.iterators.push({
@@ -2683,28 +2695,28 @@ const le = {
2683
2695
  });
2684
2696
  }
2685
2697
  },
2686
- [i$2.OBJECT_ITER_NEXT]: {
2698
+ [n.OBJECT_ITER_NEXT]: {
2687
2699
  stackIn: 0,
2688
2700
  stackOut: 2,
2689
2701
  // Push key and hasNext
2690
2702
  execute: (e2, t2) => {
2691
2703
  const r2 = e2.iterators[e2.iterators.length - 1];
2692
2704
  if (r2 && r2.index < r2.length && r2.keys) {
2693
- const s2 = r2.keys[r2.index];
2694
- e2.stack.push(s2), e2.stack.push(true), r2.index++;
2705
+ const o2 = r2.keys[r2.index];
2706
+ e2.stack.push(o2), e2.stack.push(true), r2.index++;
2695
2707
  } else
2696
2708
  e2.stack.push(null), e2.stack.push(false);
2697
2709
  }
2698
2710
  }
2699
2711
  }, fe = {
2700
- [i$2.GET]: {
2712
+ [n.GET]: {
2701
2713
  stackIn: 2,
2702
2714
  stackOut: 1,
2703
2715
  execute: (e2, t$1) => {
2704
- var o2;
2705
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2706
- if (u$1(s2)) {
2707
- const c2 = e2.heap.get(s2.id);
2716
+ var s2;
2717
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2718
+ if (u$1(o2)) {
2719
+ const c2 = e2.heap.get(o2.id);
2708
2720
  if (!c2 || c2.type !== "array")
2709
2721
  return {
2710
2722
  type: "RuntimeError",
@@ -2721,7 +2733,7 @@ const le = {
2721
2733
  if (!isNaN(u2) && u2.toString() === r2 && u2 >= 0)
2722
2734
  a2 = u2;
2723
2735
  else {
2724
- const y2 = ((o2 = p2.properties) == null ? void 0 : o2[r2]) ?? C$1();
2736
+ const y2 = ((s2 = p2.properties) == null ? void 0 : s2[r2]) ?? C$1();
2725
2737
  e2.stack.push(y2);
2726
2738
  return;
2727
2739
  }
@@ -2735,8 +2747,8 @@ const le = {
2735
2747
  const i2 = p2.elements[a2] ?? C$1();
2736
2748
  e2.stack.push(i2);
2737
2749
  return;
2738
- } else if (b(s2)) {
2739
- const c2 = e2.heap.get(s2.id);
2750
+ } else if (b(o2)) {
2751
+ const c2 = e2.heap.get(o2.id);
2740
2752
  if (!c2 || c2.type !== "object")
2741
2753
  return {
2742
2754
  type: "RuntimeError",
@@ -2747,7 +2759,7 @@ const le = {
2747
2759
  const p2 = c2.data, a2 = p$1(r2), i2 = p2.properties[a2] ?? C$1();
2748
2760
  e2.stack.push(i2);
2749
2761
  return;
2750
- } else if (t(s2)) {
2762
+ } else if (t(o2)) {
2751
2763
  let c2;
2752
2764
  if (i$1(r2))
2753
2765
  c2 = r2;
@@ -2755,7 +2767,7 @@ const le = {
2755
2767
  const p2 = parseInt(r2, 10);
2756
2768
  !isNaN(p2) && p2.toString() === r2 && (c2 = p2);
2757
2769
  }
2758
- c2 !== void 0 && c2 >= 0 && c2 < s2.length ? e2.stack.push(s2[c2]) : e2.stack.push(C$1());
2770
+ c2 !== void 0 && c2 >= 0 && c2 < o2.length ? e2.stack.push(o2[c2]) : e2.stack.push(C$1());
2759
2771
  return;
2760
2772
  } else
2761
2773
  return {
@@ -2766,13 +2778,13 @@ const le = {
2766
2778
  };
2767
2779
  }
2768
2780
  },
2769
- [i$2.SET]: {
2781
+ [n.SET]: {
2770
2782
  stackIn: 3,
2771
2783
  stackOut: 1,
2772
2784
  execute: (e2, t$1) => {
2773
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop();
2774
- if (u$1(o2)) {
2775
- const c2 = e2.heap.get(o2.id);
2785
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2786
+ if (u$1(s2)) {
2787
+ const c2 = e2.heap.get(s2.id);
2776
2788
  if (!c2 || c2.type !== "array")
2777
2789
  return {
2778
2790
  type: "RuntimeError",
@@ -2782,14 +2794,14 @@ const le = {
2782
2794
  };
2783
2795
  const p2 = c2.data;
2784
2796
  let a2;
2785
- if (i$1(s2))
2786
- a2 = s2;
2787
- else if (t(s2)) {
2788
- const u2 = parseInt(s2, 10);
2789
- if (!isNaN(u2) && u2.toString() === s2 && u2 >= 0)
2797
+ if (i$1(o2))
2798
+ a2 = o2;
2799
+ else if (t(o2)) {
2800
+ const u2 = parseInt(o2, 10);
2801
+ if (!isNaN(u2) && u2.toString() === o2 && u2 >= 0)
2790
2802
  a2 = u2;
2791
2803
  else {
2792
- p2.properties || (p2.properties = {}), p2.properties[s2] = r2, e2.stack.push(o2);
2804
+ p2.properties || (p2.properties = {}), p2.properties[o2] = r2, e2.stack.push(s2);
2793
2805
  return;
2794
2806
  }
2795
2807
  } else
@@ -2807,10 +2819,10 @@ const le = {
2807
2819
  pc: e2.pc,
2808
2820
  opcode: t$1.op
2809
2821
  };
2810
- p2.elements[i2] = r2, e2.stack.push(o2);
2822
+ p2.elements[i2] = r2, e2.stack.push(s2);
2811
2823
  return;
2812
- } else if (b(o2)) {
2813
- const c2 = e2.heap.get(o2.id);
2824
+ } else if (b(s2)) {
2825
+ const c2 = e2.heap.get(s2.id);
2814
2826
  if (!c2 || c2.type !== "object")
2815
2827
  return {
2816
2828
  type: "RuntimeError",
@@ -2818,8 +2830,8 @@ const le = {
2818
2830
  pc: e2.pc,
2819
2831
  opcode: t$1.op
2820
2832
  };
2821
- const p2 = c2.data, a2 = p$1(s2);
2822
- p2.properties[a2] = r2, e2.stack.push(o2);
2833
+ const p2 = c2.data, a2 = p$1(o2);
2834
+ p2.properties[a2] = r2, e2.stack.push(s2);
2823
2835
  return;
2824
2836
  } else
2825
2837
  return {
@@ -2830,7 +2842,7 @@ const le = {
2830
2842
  };
2831
2843
  }
2832
2844
  }
2833
- }, ke = {
2845
+ }, ge = {
2834
2846
  stackIn: 0,
2835
2847
  // Consumes no stack items
2836
2848
  stackOut: 1,
@@ -2845,36 +2857,214 @@ const le = {
2845
2857
  opcode: t2.op
2846
2858
  };
2847
2859
  try {
2848
- const s2 = new RegExp(r2.pattern, r2.flags), o2 = {
2860
+ const o2 = new RegExp(r2.pattern, r2.flags), s2 = {
2849
2861
  type: "object",
2850
2862
  properties: {
2851
- source: s2.source,
2852
- flags: s2.flags,
2853
- global: s2.global,
2854
- ignoreCase: s2.ignoreCase,
2855
- multiline: s2.multiline
2863
+ source: o2.source,
2864
+ flags: o2.flags,
2865
+ global: o2.global,
2866
+ ignoreCase: o2.ignoreCase,
2867
+ multiline: o2.multiline
2856
2868
  }
2857
- }, c2 = e2.heap.allocate("object", o2);
2869
+ }, c2 = e2.heap.allocate("object", s2);
2858
2870
  e2.stack.push(c2);
2859
2871
  return;
2860
- } catch (s2) {
2872
+ } catch (o2) {
2861
2873
  return {
2862
2874
  type: "SyntaxError",
2863
- message: `Invalid regular expression: ${s2.message}`,
2875
+ message: `Invalid regular expression: ${o2.message}`,
2864
2876
  pc: e2.pc,
2865
2877
  opcode: t2.op
2866
2878
  };
2867
2879
  }
2868
2880
  }
2869
2881
  }, me = {
2870
- [i$2.LOAD_REGEX]: ke
2882
+ stackIn: 2,
2883
+ // Consumes regex reference and string
2884
+ stackOut: 1,
2885
+ // Produces boolean result
2886
+ execute: (e2, t2) => {
2887
+ const r2 = d(e2, t2.op);
2888
+ if (f2(r2)) return r2;
2889
+ const o2 = d(e2, t2.op);
2890
+ if (f2(o2)) return o2;
2891
+ if (typeof r2 != "string")
2892
+ return {
2893
+ type: "TypeError",
2894
+ message: `Expected string argument for regex test, got ${typeof r2}`,
2895
+ pc: e2.pc,
2896
+ opcode: t2.op
2897
+ };
2898
+ if (!b(o2))
2899
+ return {
2900
+ type: "TypeError",
2901
+ message: "Expected regex object for regex test",
2902
+ pc: e2.pc,
2903
+ opcode: t2.op
2904
+ };
2905
+ const s2 = e2.heap.get(o2.id);
2906
+ if (!s2 || s2.type !== "object")
2907
+ return {
2908
+ type: "TypeError",
2909
+ message: "Invalid regex object reference",
2910
+ pc: e2.pc,
2911
+ opcode: t2.op
2912
+ };
2913
+ try {
2914
+ const c2 = s2.data, p2 = c2.properties.source, a2 = c2.properties.flags;
2915
+ if (typeof p2 != "string" || typeof a2 != "string")
2916
+ return {
2917
+ type: "TypeError",
2918
+ message: "Invalid regex object structure",
2919
+ pc: e2.pc,
2920
+ opcode: t2.op
2921
+ };
2922
+ const u2 = new RegExp(p2, a2).test(r2);
2923
+ e2.stack.push(u2);
2924
+ return;
2925
+ } catch (c2) {
2926
+ return {
2927
+ type: "RuntimeError",
2928
+ message: `Regex test failed: ${c2.message}`,
2929
+ pc: e2.pc,
2930
+ opcode: t2.op
2931
+ };
2932
+ }
2933
+ }
2934
+ }, ke = {
2935
+ stackIn: 2,
2936
+ // Consumes string and regex reference
2937
+ stackOut: 1,
2938
+ // Produces array reference or null
2939
+ execute: (e2, t2) => {
2940
+ const r2 = d(e2, t2.op);
2941
+ if (f2(r2)) return r2;
2942
+ const o2 = d(e2, t2.op);
2943
+ if (f2(o2)) return o2;
2944
+ if (typeof o2 != "string")
2945
+ return {
2946
+ type: "TypeError",
2947
+ message: `Expected string input for match, got ${typeof o2}`,
2948
+ pc: e2.pc,
2949
+ opcode: t2.op
2950
+ };
2951
+ if (!b(r2))
2952
+ return {
2953
+ type: "TypeError",
2954
+ message: "Expected regex object for match",
2955
+ pc: e2.pc,
2956
+ opcode: t2.op
2957
+ };
2958
+ const s2 = e2.heap.get(r2.id);
2959
+ if (!s2 || s2.type !== "object")
2960
+ return {
2961
+ type: "TypeError",
2962
+ message: "Invalid regex object reference",
2963
+ pc: e2.pc,
2964
+ opcode: t2.op
2965
+ };
2966
+ try {
2967
+ const c2 = s2.data, p2 = c2.properties.source, a2 = c2.properties.flags;
2968
+ if (typeof p2 != "string" || typeof a2 != "string")
2969
+ return {
2970
+ type: "TypeError",
2971
+ message: "Invalid regex object structure",
2972
+ pc: e2.pc,
2973
+ opcode: t2.op
2974
+ };
2975
+ const i2 = new RegExp(p2, a2), u2 = o2.match(i2);
2976
+ if (u2 === null)
2977
+ e2.stack.push(null);
2978
+ else {
2979
+ const y2 = {
2980
+ type: "array",
2981
+ elements: [...u2]
2982
+ // Copy all match results
2983
+ }, E2 = e2.heap.allocate("array", y2);
2984
+ e2.stack.push(E2);
2985
+ }
2986
+ return;
2987
+ } catch (c2) {
2988
+ return {
2989
+ type: "RuntimeError",
2990
+ message: `String match failed: ${c2.message}`,
2991
+ pc: e2.pc,
2992
+ opcode: t2.op
2993
+ };
2994
+ }
2995
+ }
2996
+ }, ye = {
2997
+ stackIn: 3,
2998
+ // Consumes string, regex reference, and replacement string
2999
+ stackOut: 1,
3000
+ // Produces new string
3001
+ execute: (e2, t2) => {
3002
+ const r2 = d(e2, t2.op);
3003
+ if (f2(r2)) return r2;
3004
+ const o2 = d(e2, t2.op);
3005
+ if (f2(o2)) return o2;
3006
+ const s2 = d(e2, t2.op);
3007
+ if (f2(s2)) return s2;
3008
+ if (typeof s2 != "string")
3009
+ return {
3010
+ type: "TypeError",
3011
+ message: `Expected string input for replace, got ${typeof s2}`,
3012
+ pc: e2.pc,
3013
+ opcode: t2.op
3014
+ };
3015
+ if (!b(o2)) {
3016
+ const p2 = String(o2), a2 = String(r2), i2 = s2.indexOf(p2), u2 = i2 === -1 ? s2 : s2.substring(0, i2) + a2 + s2.substring(i2 + p2.length);
3017
+ e2.stack.push(u2);
3018
+ return;
3019
+ }
3020
+ if (typeof r2 != "string")
3021
+ return {
3022
+ type: "TypeError",
3023
+ message: `Expected string replacement, got ${typeof r2}`,
3024
+ pc: e2.pc,
3025
+ opcode: t2.op
3026
+ };
3027
+ const c2 = e2.heap.get(o2.id);
3028
+ if (!c2 || c2.type !== "object")
3029
+ return {
3030
+ type: "TypeError",
3031
+ message: "Invalid regex object reference",
3032
+ pc: e2.pc,
3033
+ opcode: t2.op
3034
+ };
3035
+ try {
3036
+ const p2 = c2.data, a2 = p2.properties.source, i2 = p2.properties.flags;
3037
+ if (typeof a2 != "string" || typeof i2 != "string")
3038
+ return {
3039
+ type: "TypeError",
3040
+ message: "Invalid regex object structure",
3041
+ pc: e2.pc,
3042
+ opcode: t2.op
3043
+ };
3044
+ const u2 = new RegExp(a2, i2), y2 = s2.replace(u2, r2);
3045
+ e2.stack.push(y2);
3046
+ return;
3047
+ } catch (p2) {
3048
+ return {
3049
+ type: "RuntimeError",
3050
+ message: `String replace failed: ${p2.message}`,
3051
+ pc: e2.pc,
3052
+ opcode: t2.op
3053
+ };
3054
+ }
3055
+ }
3056
+ }, he = {
3057
+ [n.LOAD_REGEX]: ge,
3058
+ [n.REGEX_TEST]: me,
3059
+ [n.STRING_MATCH]: ke,
3060
+ [n.STRING_REPLACE_REGEX]: ye
2871
3061
  }, F = {
2872
3062
  ...Z,
2873
3063
  ...ee,
2874
3064
  ...re,
2875
3065
  ...te,
2876
- ...se,
2877
3066
  ...oe,
3067
+ ...se,
2878
3068
  ...ce,
2879
3069
  ...ne,
2880
3070
  ...pe,
@@ -2884,24 +3074,23 @@ const le = {
2884
3074
  ...le,
2885
3075
  ...de,
2886
3076
  ...fe,
2887
- ...me
3077
+ ...he
2888
3078
  };
2889
3079
  function w() {
2890
- const e2 = /* @__PURE__ */ new Map();
2891
- let t2 = 1;
2892
- return {
3080
+ const e2 = /* @__PURE__ */ new Map(), t2 = {
2893
3081
  objects: e2,
2894
- nextId: t2,
2895
- allocate(r2, s2) {
2896
- const o2 = t2++, c2 = { id: o2, type: r2, data: s2 };
2897
- return e2.set(o2, c2), r2 === "array" ? { type: "array-ref", id: o2 } : { type: "object-ref", id: o2 };
3082
+ nextId: 1,
3083
+ allocate(r2, o2) {
3084
+ const s2 = t2.nextId++, c2 = { id: s2, type: r2, data: o2 };
3085
+ return e2.set(s2, c2), r2 === "array" ? { type: "array-ref", id: s2 } : { type: "object-ref", id: s2 };
2898
3086
  },
2899
3087
  get(r2) {
2900
- const s2 = e2.get(r2);
2901
- if (s2)
2902
- return s2;
3088
+ const o2 = e2.get(r2);
3089
+ if (o2)
3090
+ return o2;
2903
3091
  }
2904
3092
  };
3093
+ return t2;
2905
3094
  }
2906
3095
  class C {
2907
3096
  createInitialState() {
@@ -2916,70 +3105,70 @@ class C {
2916
3105
  };
2917
3106
  }
2918
3107
  executeInstruction(t2, r2) {
2919
- const s2 = F[r2.op];
2920
- if (!s2)
3108
+ const o2 = F[r2.op];
3109
+ if (!o2)
2921
3110
  throw new Error(`Unknown opcode: ${r2.op}`);
2922
- const o2 = this.validateStack(s2, r2, t2);
2923
- if (o2) {
2924
- t2.status = "error", t2.error = o2.message;
3111
+ const s2 = this.validateStack(o2, r2, t2);
3112
+ if (s2) {
3113
+ t2.status = "error", t2.error = s2.message;
2925
3114
  return;
2926
3115
  }
2927
- s2.execute(t2, r2), t2.pc++;
3116
+ o2.execute(t2, r2), t2.pc++;
2928
3117
  }
2929
- validateStack(t2, r2, s2) {
2930
- if (s2.stack.length < t2.stackIn)
3118
+ validateStack(t2, r2, o2) {
3119
+ if (o2.stack.length < t2.stackIn)
2931
3120
  return {
2932
3121
  type: "StackUnderflow",
2933
- message: `${i$2[r2.op]}: Stack underflow`,
2934
- pc: s2.pc,
3122
+ message: `${n[r2.op]}: Stack underflow`,
3123
+ pc: o2.pc,
2935
3124
  opcode: r2.op
2936
3125
  };
2937
3126
  }
2938
- execute(t2, r2, s2) {
2939
- const o2 = {
3127
+ execute(t2, r2, o2) {
3128
+ const s2 = {
2940
3129
  pc: (r2 == null ? void 0 : r2.pc) ?? 0,
2941
3130
  stack: (r2 == null ? void 0 : r2.stack) ?? [],
2942
3131
  variables: (r2 == null ? void 0 : r2.variables) ?? /* @__PURE__ */ new Map(),
2943
3132
  status: "running",
2944
3133
  output: (r2 == null ? void 0 : r2.output) ?? [],
2945
3134
  iterators: (r2 == null ? void 0 : r2.iterators) ?? [],
2946
- fileSystem: s2,
3135
+ fileSystem: o2,
2947
3136
  heap: (r2 == null ? void 0 : r2.heap) ?? w(),
2948
3137
  ...r2
2949
3138
  };
2950
- for (; o2.status === "running" && o2.pc < t2.length; ) {
2951
- const c2 = t2[o2.pc], p2 = F[c2.op];
3139
+ for (; s2.status === "running" && s2.pc < t2.length; ) {
3140
+ const c2 = t2[s2.pc], p2 = F[c2.op];
2952
3141
  if (p2) {
2953
- const a2 = this.validateStack(p2, c2, o2);
3142
+ const a2 = this.validateStack(p2, c2, s2);
2954
3143
  if (a2) {
2955
- o2.status = "error", o2.error = a2.message;
3144
+ s2.status = "error", s2.error = a2.message;
2956
3145
  break;
2957
3146
  }
2958
- if ((c2.op === i$2.JUMP || c2.op === i$2.JUMP_IF_FALSE || c2.op === i$2.JUMP_IF || c2.op === i$2.JUMP_IF_TRUE || c2.op === i$2.BREAK || c2.op === i$2.CONTINUE) && c2.arg !== void 0 && c2.arg >= t2.length) {
2959
- o2.status = "error";
2960
- const u2 = c2.op === i$2.JUMP || c2.op === i$2.JUMP_IF_FALSE || c2.op === i$2.JUMP_IF || c2.op === i$2.JUMP_IF_TRUE ? "jump" : c2.op === i$2.BREAK ? "break" : "continue";
2961
- o2.error = `Invalid ${u2} target: ${c2.arg}`;
3147
+ if ((c2.op === n.JUMP || c2.op === n.JUMP_IF_FALSE || c2.op === n.JUMP_IF || c2.op === n.JUMP_IF_TRUE || c2.op === n.BREAK || c2.op === n.CONTINUE) && c2.arg !== void 0 && c2.arg >= t2.length) {
3148
+ s2.status = "error";
3149
+ const u2 = c2.op === n.JUMP || c2.op === n.JUMP_IF_FALSE || c2.op === n.JUMP_IF || c2.op === n.JUMP_IF_TRUE ? "jump" : c2.op === n.BREAK ? "break" : "continue";
3150
+ s2.error = `Invalid ${u2} target: ${c2.arg}`;
2962
3151
  break;
2963
3152
  }
2964
- const i2 = p2.execute(o2, c2);
3153
+ const i2 = p2.execute(s2, c2);
2965
3154
  if (i2) {
2966
- const u2 = o2.pc + 1;
2967
- if (u2 < t2.length && t2[u2].op === i$2.CC) {
2968
- o2.ccPrompt = `ERROR: ${i2.message}. How should I proceed?`, o2.status = "waiting_cc", o2.pc = u2;
3155
+ const u2 = s2.pc + 1;
3156
+ if (u2 < t2.length && t2[u2].op === n.CC) {
3157
+ s2.ccPrompt = `ERROR: ${i2.message}. How should I proceed?`, s2.status = "waiting_cc", s2.pc = u2;
2969
3158
  break;
2970
3159
  }
2971
- o2.status = "error", o2.error = i2.message;
3160
+ s2.status = "error", s2.error = i2.message;
2972
3161
  break;
2973
3162
  }
2974
- p2.controlsPC || o2.pc++;
3163
+ p2.controlsPC || s2.pc++;
2975
3164
  continue;
2976
3165
  }
2977
- o2.status = "error", o2.error = `Unknown opcode: ${i$2[c2.op]}`;
3166
+ s2.status = "error", s2.error = `Unknown opcode: ${n[c2.op]}`;
2978
3167
  break;
2979
3168
  }
2980
- return o2;
3169
+ return s2;
2981
3170
  }
2982
- resume(t2, r2, s2, o2) {
3171
+ resume(t2, r2, o2, s2) {
2983
3172
  if (t2.status !== "waiting_cc")
2984
3173
  throw new Error("Cannot resume: VM not waiting for CC");
2985
3174
  const c2 = {
@@ -2989,47 +3178,47 @@ class C {
2989
3178
  ccPrompt: void 0,
2990
3179
  pc: t2.pc + 1
2991
3180
  };
2992
- return this.execute(s2, c2, o2 || t2.fileSystem);
3181
+ return this.execute(o2, c2, s2 || t2.fileSystem);
2993
3182
  }
2994
3183
  }
2995
3184
  class V {
2996
3185
  constructor() {
2997
3186
  _(this, "sandboxPaths", []);
2998
3187
  const t2 = process.env.CVM_SANDBOX_PATHS, r2 = process.env.CVM_SANDBOX_ROOT;
2999
- t2 ? this.sandboxPaths = t2.split(",").map((s2) => r__namespace.resolve(s2.trim())) : r2 && (this.sandboxPaths = [r__namespace.resolve(r2)]);
3188
+ t2 ? this.sandboxPaths = t2.split(",").map((o2) => r__namespace.resolve(o2.trim())) : r2 && (this.sandboxPaths = [r__namespace.resolve(r2)]);
3000
3189
  }
3001
3190
  isPathAllowed(t2) {
3002
3191
  const r2 = r__namespace.resolve(t2);
3003
3192
  return r2.includes("..") || this.sandboxPaths.length === 0 ? false : this.sandboxPaths.some(
3004
- (s2) => r2.startsWith(s2)
3193
+ (o2) => r2.startsWith(o2)
3005
3194
  );
3006
3195
  }
3007
3196
  listFiles(t2, r2 = {}) {
3008
- const s$12 = s();
3197
+ const o2 = s();
3009
3198
  if (!this.isPathAllowed(t2))
3010
- return s$12;
3199
+ return o2;
3011
3200
  try {
3012
- const o2 = r__namespace.resolve(t2);
3013
- this.listFilesRecursive(o2, o2, s$12.elements, r2);
3201
+ const s2 = r__namespace.resolve(t2);
3202
+ this.listFilesRecursive(s2, s2, o2.elements, r2);
3014
3203
  } catch {
3015
3204
  }
3016
- return s$12;
3205
+ return o2;
3017
3206
  }
3018
3207
  matchesPattern(t2, r2) {
3019
- let s2 = r2.replace(/\./g, "\\.").replace(/\*\*/g, "__DOUBLESTAR__").replace(/\*/g, "[^/]*").replace(/__DOUBLESTAR__/g, ".*").replace(/\?/g, ".");
3020
- s2 = "^" + s2 + "$";
3208
+ let o2 = r2.replace(/\./g, "\\.").replace(/\*\*/g, "__DOUBLESTAR__").replace(/\*/g, "[^/]*").replace(/__DOUBLESTAR__/g, ".*").replace(/\?/g, ".");
3209
+ o2 = "^" + o2 + "$";
3021
3210
  try {
3022
- return new RegExp(s2).test(t2);
3211
+ return new RegExp(o2).test(t2);
3023
3212
  } catch {
3024
3213
  return true;
3025
3214
  }
3026
3215
  }
3027
- listFilesRecursive(t2, r2, s2, o2, c2 = 0) {
3216
+ listFilesRecursive(t2, r2, o2, s2, c2 = 0) {
3028
3217
  try {
3029
- const p2 = N__namespace.readdirSync(r2, { withFileTypes: true });
3218
+ const p2 = b__namespace.readdirSync(r2, { withFileTypes: true });
3030
3219
  for (const a2 of p2) {
3031
3220
  const i2 = r__namespace.join(r2, a2.name), u2 = r__namespace.relative(t2, i2);
3032
- a2.isSymbolicLink() || o2.filter && !this.matchesPattern(u2, o2.filter) || (s2.push(i2), a2.isDirectory() && o2.recursive && this.listFilesRecursive(t2, i2, s2, o2, c2 + 1));
3221
+ a2.isSymbolicLink() || s2.filter && !this.matchesPattern(u2, s2.filter) || (o2.push(i2), a2.isDirectory() && s2.recursive && this.listFilesRecursive(t2, i2, o2, s2, c2 + 1));
3033
3222
  }
3034
3223
  } catch {
3035
3224
  }
@@ -3038,8 +3227,8 @@ class V {
3038
3227
  if (!this.isPathAllowed(t2))
3039
3228
  return null;
3040
3229
  try {
3041
- const r2 = r__namespace.resolve(t2), s2 = N__namespace.lstatSync(r2);
3042
- return s2.isSymbolicLink() || !s2.isFile() ? null : N__namespace.readFileSync(r2, "utf-8");
3230
+ const r2 = r__namespace.resolve(t2), o2 = b__namespace.lstatSync(r2);
3231
+ return o2.isSymbolicLink() || !o2.isFile() ? null : b__namespace.readFileSync(r2, "utf-8");
3043
3232
  } catch {
3044
3233
  return null;
3045
3234
  }
@@ -3048,24 +3237,24 @@ class V {
3048
3237
  if (!this.isPathAllowed(t2))
3049
3238
  return false;
3050
3239
  try {
3051
- const s2 = r__namespace.resolve(t2), o2 = r__namespace.dirname(s2);
3052
- if (!this.isPathAllowed(o2))
3240
+ const o2 = r__namespace.resolve(t2), s2 = r__namespace.dirname(o2);
3241
+ if (!this.isPathAllowed(s2))
3053
3242
  return false;
3054
3243
  try {
3055
- if (N__namespace.lstatSync(s2).isSymbolicLink())
3244
+ if (b__namespace.lstatSync(o2).isSymbolicLink())
3056
3245
  return false;
3057
3246
  } catch (c2) {
3058
3247
  if (c2.code !== "ENOENT")
3059
3248
  return false;
3060
3249
  }
3061
- return N__namespace.mkdirSync(o2, { recursive: true }), N__namespace.writeFileSync(s2, r2, "utf-8"), true;
3250
+ return b__namespace.mkdirSync(s2, { recursive: true }), b__namespace.writeFileSync(o2, r2, "utf-8"), true;
3062
3251
  } catch {
3063
3252
  return false;
3064
3253
  }
3065
3254
  }
3066
3255
  }
3067
3256
  new V();
3068
- class Ie {
3257
+ class Se {
3069
3258
  constructor(t2, r2) {
3070
3259
  _(this, "vms", /* @__PURE__ */ new Map());
3071
3260
  _(this, "storage");
@@ -3088,18 +3277,22 @@ class Ie {
3088
3277
  * Load and compile a program from source code
3089
3278
  */
3090
3279
  async loadProgram(t2, r2) {
3091
- const s2 = te$1(r2);
3092
- if (!s2.success)
3093
- throw new Error(`Compilation failed: ${s2.errors.join(", ")}`);
3094
- const o2 = {
3280
+ const o2 = te$1(r2);
3281
+ if (!o2.success) {
3282
+ const c2 = o2.errors.map(
3283
+ (p2) => `${p2.message} at line ${p2.line}, column ${p2.character}`
3284
+ );
3285
+ throw new Error(`Compilation failed: ${c2.join("; ")}`);
3286
+ }
3287
+ const s2 = {
3095
3288
  id: t2,
3096
3289
  name: t2,
3097
3290
  source: r2,
3098
- bytecode: s2.bytecode,
3291
+ bytecode: o2.bytecode,
3099
3292
  // VM decides internal format
3100
3293
  created: /* @__PURE__ */ new Date()
3101
3294
  };
3102
- await this.storage.saveProgram(o2);
3295
+ await this.storage.saveProgram(s2);
3103
3296
  }
3104
3297
  /**
3105
3298
  * Start execution of a loaded program
@@ -3107,7 +3300,7 @@ class Ie {
3107
3300
  async startExecution(t2, r2) {
3108
3301
  if (!await this.storage.getProgram(t2))
3109
3302
  throw new Error(`Program not found: ${t2}`);
3110
- const o2 = {
3303
+ const s2 = {
3111
3304
  id: r2,
3112
3305
  programId: t2,
3113
3306
  state: "READY",
@@ -3116,7 +3309,7 @@ class Ie {
3116
3309
  variables: {},
3117
3310
  created: /* @__PURE__ */ new Date()
3118
3311
  };
3119
- await this.storage.saveExecution(o2);
3312
+ await this.storage.saveExecution(s2);
3120
3313
  const c2 = new C();
3121
3314
  this.vms.set(r2, c2);
3122
3315
  }
@@ -3129,17 +3322,17 @@ class Ie {
3129
3322
  if (!r2)
3130
3323
  throw new Error(`Execution not found: ${t2}`);
3131
3324
  if (r2.state === "READY" || r2.state === "RUNNING") {
3132
- const s2 = await this.storage.getProgram(r2.programId);
3133
- if (!s2)
3325
+ const o2 = await this.storage.getProgram(r2.programId);
3326
+ if (!o2)
3134
3327
  throw new Error(`Program not found: ${r2.programId}`);
3135
- let o2 = this.vms.get(t2);
3136
- o2 || (o2 = new C(), this.vms.set(t2, o2));
3328
+ let s2 = this.vms.get(t2);
3329
+ s2 || (s2 = new C(), this.vms.set(t2, s2));
3137
3330
  const c2 = r2.state === "READY" ? {
3138
3331
  pc: 0,
3139
3332
  stack: [],
3140
3333
  variables: /* @__PURE__ */ new Map(),
3141
3334
  output: []
3142
- } : this.deserializeVMState(r2), p2 = o2.execute(s2.bytecode, c2, this.fileSystem);
3335
+ } : this.deserializeVMState(r2), p2 = s2.execute(o2.bytecode, c2, this.fileSystem);
3143
3336
  p2.output.length > 0 && await this.storage.appendOutput(t2, p2.output);
3144
3337
  const a2 = this.serializeVMState(p2);
3145
3338
  if (Object.assign(r2, a2), p2.status === "complete")
@@ -3180,24 +3373,24 @@ class Ie {
3180
3373
  * Report result from cognitive operation and continue execution
3181
3374
  */
3182
3375
  async reportCCResult(t2, r2) {
3183
- const s2 = await this.storage.getExecution(t2);
3184
- if (!s2)
3185
- throw new Error(`Execution not found: ${t2}`);
3186
- const o2 = await this.storage.getProgram(s2.programId);
3376
+ const o2 = await this.storage.getExecution(t2);
3187
3377
  if (!o2)
3188
- throw new Error(`Program not found: ${s2.programId}`);
3378
+ throw new Error(`Execution not found: ${t2}`);
3379
+ const s2 = await this.storage.getProgram(o2.programId);
3380
+ if (!s2)
3381
+ throw new Error(`Program not found: ${o2.programId}`);
3189
3382
  let c2 = this.vms.get(t2);
3190
3383
  c2 || (c2 = new C(), this.vms.set(t2, c2));
3191
3384
  const p2 = {
3192
- ...this.deserializeVMState(s2),
3385
+ ...this.deserializeVMState(o2),
3193
3386
  status: "waiting_cc",
3194
3387
  output: [],
3195
3388
  // Start with empty output for resumed execution
3196
3389
  ccPrompt: void 0
3197
- }, a2 = c2.resume(p2, r2, o2.bytecode, this.fileSystem);
3390
+ }, a2 = c2.resume(p2, r2, s2.bytecode, this.fileSystem);
3198
3391
  a2.output.length > 0 && await this.storage.appendOutput(t2, a2.output);
3199
3392
  const i2 = this.serializeVMState(a2);
3200
- Object.assign(s2, i2), a2.status === "complete" ? (s2.state = "COMPLETED", a2.returnValue !== void 0 && (s2.returnValue = a2.returnValue), this.vms.delete(t2)) : a2.status === "error" ? (s2.state = "ERROR", s2.error = a2.error, this.vms.delete(t2)) : a2.status === "waiting_cc" ? (s2.state = "AWAITING_COGNITIVE_RESULT", s2.ccPrompt = a2.ccPrompt) : s2.state = "RUNNING", await this.storage.saveExecution(s2);
3393
+ Object.assign(o2, i2), a2.status === "complete" ? (o2.state = "COMPLETED", a2.returnValue !== void 0 && (o2.returnValue = a2.returnValue), this.vms.delete(t2)) : a2.status === "error" ? (o2.state = "ERROR", o2.error = a2.error, this.vms.delete(t2)) : a2.status === "waiting_cc" ? (o2.state = "AWAITING_COGNITIVE_RESULT", o2.ccPrompt = a2.ccPrompt) : o2.state = "RUNNING", await this.storage.saveExecution(o2);
3201
3394
  }
3202
3395
  /**
3203
3396
  * Get current execution status
@@ -3269,22 +3462,22 @@ class Ie {
3269
3462
  * Restart a program (create new execution and set as current)
3270
3463
  */
3271
3464
  async restartExecution(t2, r2) {
3272
- const s2 = r2 || `${t2}-${Date.now()}`;
3273
- return await this.startExecution(t2, s2), await this.setCurrentExecutionId(s2), s2;
3465
+ const o2 = r2 || `${t2}-${Date.now()}`;
3466
+ return await this.startExecution(t2, o2), await this.setCurrentExecutionId(o2), o2;
3274
3467
  }
3275
3468
  /**
3276
3469
  * Serialize heap to storage format
3277
3470
  */
3278
3471
  serializeHeap(t2) {
3279
- const r2 = (o2, c2) => u$1(c2) || b(c2) ? { $ref: c2.id } : c2, s2 = {};
3280
- return t2.objects.forEach((o2, c2) => {
3281
- s2[c2] = {
3282
- type: o2.type,
3472
+ const r2 = (s2, c2) => u$1(c2) || b(c2) ? { $ref: c2.id } : c2, o2 = {};
3473
+ return t2.objects.forEach((s2, c2) => {
3474
+ o2[c2] = {
3475
+ type: s2.type,
3283
3476
  // Serialize each object's data individually with replacer
3284
- data: JSON.parse(JSON.stringify(o2.data, r2))
3477
+ data: JSON.parse(JSON.stringify(s2.data, r2))
3285
3478
  };
3286
3479
  }), {
3287
- objects: s2,
3480
+ objects: o2,
3288
3481
  nextId: t2.nextId
3289
3482
  };
3290
3483
  }
@@ -3294,17 +3487,17 @@ class Ie {
3294
3487
  deserializeHeap(t2) {
3295
3488
  const r2 = w();
3296
3489
  r2.nextId = t2.nextId;
3297
- for (const s2 in t2.objects) {
3298
- const o2 = parseInt(s2, 10), c2 = t2.objects[o2];
3299
- r2.objects.set(o2, {
3300
- id: o2,
3490
+ for (const o2 in t2.objects) {
3491
+ const s2 = parseInt(o2, 10), c2 = t2.objects[s2];
3492
+ r2.objects.set(s2, {
3493
+ id: s2,
3301
3494
  type: c2.type,
3302
3495
  data: c2.data
3303
3496
  // Still contains $ref stubs
3304
3497
  });
3305
3498
  }
3306
- return r2.objects.forEach((s2) => {
3307
- s2.data = this.restoreReferences(s2.data, r2);
3499
+ return r2.objects.forEach((o2) => {
3500
+ o2.data = this.restoreReferences(o2.data, r2);
3308
3501
  }), r2;
3309
3502
  }
3310
3503
  /**
@@ -3343,16 +3536,16 @@ class Ie {
3343
3536
  }
3344
3537
  restoreReferences(t2, r2) {
3345
3538
  if (t2 && typeof t2 == "object" && t2.$ref !== void 0) {
3346
- const s2 = r2.objects.get(t2.$ref);
3347
- return (s2 == null ? void 0 : s2.type) === "array" ? { type: "array-ref", id: t2.$ref } : (s2 == null ? void 0 : s2.type) === "object" ? { type: "object-ref", id: t2.$ref } : t2;
3539
+ const o2 = r2.objects.get(t2.$ref);
3540
+ return (o2 == null ? void 0 : o2.type) === "array" ? { type: "array-ref", id: t2.$ref } : (o2 == null ? void 0 : o2.type) === "object" ? { type: "object-ref", id: t2.$ref } : t2;
3348
3541
  }
3349
3542
  if (Array.isArray(t2))
3350
- return t2.map((s2) => this.restoreReferences(s2, r2));
3543
+ return t2.map((o2) => this.restoreReferences(o2, r2));
3351
3544
  if (t2 && typeof t2 == "object") {
3352
- const s2 = {};
3353
- for (const o2 in t2)
3354
- s2[o2] = this.restoreReferences(t2[o2], r2);
3355
- return s2;
3545
+ const o2 = {};
3546
+ for (const s2 in t2)
3547
+ o2[s2] = this.restoreReferences(t2[s2], r2);
3548
+ return o2;
3356
3549
  }
3357
3550
  return t2;
3358
3551
  }
@@ -3366,7 +3559,7 @@ class $ {
3366
3559
  i(this, "transport", null);
3367
3560
  i(this, "vmManager");
3368
3561
  i(this, "version");
3369
- this.version = e2, this.vmManager = new Ie(), this.server = new mcp_js.McpServer({
3562
+ this.version = e2, this.vmManager = new Se(), this.server = new mcp_js.McpServer({
3370
3563
  name: "cvm-server",
3371
3564
  version: this.version
3372
3565
  }), this.setupTools();
@@ -3404,19 +3597,19 @@ class $ {
3404
3597
  },
3405
3598
  async ({ programId: e2, filePath: r$1 }) => {
3406
3599
  try {
3407
- const t2 = r.resolve(r$1), n = await promises.readFile(t2, "utf-8");
3408
- return await this.vmManager.loadProgram(e2, n), {
3600
+ const t2 = r.resolve(r$1), n2 = await promises.readFile(t2, "utf-8");
3601
+ return await this.vmManager.loadProgram(e2, n2), {
3409
3602
  content: [{ type: "text", text: `Program loaded successfully from ${r$1}: ${e2}` }]
3410
3603
  };
3411
3604
  } catch (t2) {
3412
3605
  if (t2 instanceof Error) {
3413
- const n = t2;
3414
- if (n.code === "ENOENT")
3606
+ const n2 = t2;
3607
+ if (n2.code === "ENOENT")
3415
3608
  return {
3416
3609
  content: [{ type: "text", text: `Error: File not found: ${r$1}` }],
3417
3610
  isError: true
3418
3611
  };
3419
- if (n.code === "EACCES")
3612
+ if (n2.code === "EACCES")
3420
3613
  return {
3421
3614
  content: [{ type: "text", text: `Error: Permission denied: ${r$1}` }],
3422
3615
  isError: true
@@ -3440,9 +3633,9 @@ class $ {
3440
3633
  return await this.vmManager.startExecution(e2, r2), t2 && await this.vmManager.setCurrentExecutionId(r2), {
3441
3634
  content: [{ type: "text", text: `Execution started: ${r2}${t2 ? " (set as current)" : ""}` }]
3442
3635
  };
3443
- } catch (n) {
3636
+ } catch (n2) {
3444
3637
  return {
3445
- content: [{ type: "text", text: `Error: ${n instanceof Error ? n.message : "Unknown error"}` }],
3638
+ content: [{ type: "text", text: `Error: ${n2 instanceof Error ? n2.message : "Unknown error"}` }],
3446
3639
  isError: true
3447
3640
  };
3448
3641
  }
@@ -3456,12 +3649,12 @@ class $ {
3456
3649
  try {
3457
3650
  let r2 = e2;
3458
3651
  if (!r2) {
3459
- const n = await this.vmManager.getCurrentExecutionId();
3460
- if (!n)
3652
+ const n2 = await this.vmManager.getCurrentExecutionId();
3653
+ if (!n2)
3461
3654
  return {
3462
3655
  content: [{ type: "text", text: "No current execution set. Use list_executions to see available executions." }]
3463
3656
  };
3464
- r2 = n;
3657
+ r2 = n2;
3465
3658
  }
3466
3659
  const t2 = await this.vmManager.getNext(r2);
3467
3660
  return t2.type === "completed" ? {
@@ -3492,13 +3685,13 @@ class $ {
3492
3685
  try {
3493
3686
  let t2 = e2;
3494
3687
  if (!t2) {
3495
- const n = await this.vmManager.getCurrentExecutionId();
3496
- if (!n)
3688
+ const n2 = await this.vmManager.getCurrentExecutionId();
3689
+ if (!n2)
3497
3690
  return {
3498
3691
  content: [{ type: "text", text: "Error: No current execution set" }],
3499
3692
  isError: true
3500
3693
  };
3501
- t2 = n;
3694
+ t2 = n2;
3502
3695
  }
3503
3696
  return await this.vmManager.reportCCResult(t2, r2), {
3504
3697
  content: [{ type: "text", text: "Execution resumed" }]
@@ -3519,13 +3712,13 @@ class $ {
3519
3712
  try {
3520
3713
  let r2 = e2;
3521
3714
  if (!r2) {
3522
- const n = await this.vmManager.getCurrentExecutionId();
3523
- if (!n)
3715
+ const n2 = await this.vmManager.getCurrentExecutionId();
3716
+ if (!n2)
3524
3717
  return {
3525
3718
  content: [{ type: "text", text: "Error: No current execution set" }],
3526
3719
  isError: true
3527
3720
  };
3528
- r2 = n;
3721
+ r2 = n2;
3529
3722
  }
3530
3723
  const t2 = await this.vmManager.getExecutionStatus(r2);
3531
3724
  return {
@@ -3543,14 +3736,14 @@ class $ {
3543
3736
  {},
3544
3737
  async () => {
3545
3738
  try {
3546
- const e2 = await this.vmManager.listExecutions(), r2 = await this.vmManager.getCurrentExecutionId(), t2 = e2.map((n) => ({
3547
- executionId: n.id,
3548
- programId: n.programId,
3549
- state: n.state,
3550
- created: n.created,
3551
- isCurrent: n.id === r2,
3739
+ const e2 = await this.vmManager.listExecutions(), r2 = await this.vmManager.getCurrentExecutionId(), t2 = e2.map((n2) => ({
3740
+ executionId: n2.id,
3741
+ programId: n2.programId,
3742
+ state: n2.state,
3743
+ created: n2.created,
3744
+ isCurrent: n2.id === r2,
3552
3745
  summary: {
3553
- currentPrompt: n.state === "AWAITING_COGNITIVE_RESULT" ? n.ccPrompt : void 0,
3746
+ currentPrompt: n2.state === "AWAITING_COGNITIVE_RESULT" ? n2.ccPrompt : void 0,
3554
3747
  tasksCompleted: 0
3555
3748
  // TODO: Track this in future
3556
3749
  }
@@ -3582,12 +3775,12 @@ class $ {
3582
3775
  };
3583
3776
  r2 = a2;
3584
3777
  }
3585
- const t2 = await this.vmManager.getExecutionWithAttempts(r2), n = await this.vmManager.getCurrentExecutionId(), c2 = {
3778
+ const t2 = await this.vmManager.getExecutionWithAttempts(r2), n2 = await this.vmManager.getCurrentExecutionId(), c2 = {
3586
3779
  executionId: t2.id,
3587
3780
  programId: t2.programId,
3588
3781
  state: t2.state,
3589
3782
  created: t2.created,
3590
- isCurrent: t2.id === n,
3783
+ isCurrent: t2.id === n2,
3591
3784
  currentTask: t2.state === "AWAITING_COGNITIVE_RESULT" ? {
3592
3785
  prompt: t2.ccPrompt,
3593
3786
  attempts: t2.attempts || 1,
@@ -3844,7 +4037,7 @@ async function main() {
3844
4037
  ];
3845
4038
  for (const packageJsonPath of possiblePaths) {
3846
4039
  try {
3847
- const packageJson = JSON.parse(N$1.readFileSync(packageJsonPath, "utf-8"));
4040
+ const packageJson = JSON.parse(b$2.readFileSync(packageJsonPath, "utf-8"));
3848
4041
  if (packageJson.name === "cvm-server" && packageJson.version) {
3849
4042
  version = packageJson.version;
3850
4043
  break;