cvm-server 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/main.cjs +783 -593
  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");
@@ -27,14 +27,14 @@ function _interopNamespaceDefault(e2) {
27
27
  return Object.freeze(n);
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) {
33
+ var o$1 = Object.defineProperty;
34
+ var I = (e2, t2, n) => t2 in e2 ? o$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: n }) : e2[t2] = n;
35
+ var _$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.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))(i$2 || {});
37
+ function A$1(e2) {
38
38
  const t2 = [], n = [];
39
39
  let r2 = false;
40
40
  const a2 = s__namespace.createSourceFile(
@@ -45,8 +45,8 @@ function A(e2) {
45
45
  );
46
46
  function m2(T) {
47
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;
49
- ["setTimeout", "fetch", "require", "import"].includes(c2) && t2.push(`Unsupported function: ${c2}`);
48
+ const l = T.expression.text;
49
+ ["setTimeout", "fetch", "require", "import"].includes(l) && t2.push(`Unsupported function: ${l}`);
50
50
  }
51
51
  s__namespace.forEachChild(T, m2);
52
52
  }
@@ -56,11 +56,11 @@ function A(e2) {
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
@@ -141,22 +141,22 @@ class P {
141
141
  return `__temp${this.tempVarCounter++}`;
142
142
  }
143
143
  }
144
- const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
144
+ const P = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
145
145
  n(e2.expression);
146
146
  const a2 = t2.emit(i$2.JUMP_IF_FALSE, -1), m2 = {
147
147
  type: "if",
148
148
  endTargets: []
149
149
  };
150
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);
151
+ const l = t2.emit(i$2.JUMP, -1);
152
+ m2.endTargets.push(l);
153
153
  const S = t2.currentAddress();
154
154
  t2.patchJump(a2, S), r2(e2.elseStatement);
155
155
  }
156
156
  const T = t2.popContext();
157
157
  if (T) {
158
- const c2 = t2.currentAddress();
159
- t2.patchJumps(T.endTargets, c2);
158
+ const l = t2.currentAddress();
159
+ t2.patchJumps(T.endTargets, l);
160
160
  }
161
161
  }, N = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
162
162
  const a2 = t2.currentAddress();
@@ -169,10 +169,10 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
169
169
  startAddress: a2
170
170
  };
171
171
  t2.pushContext(T), r2(e2.statement), t2.emit(i$2.JUMP, a2);
172
- const c2 = t2.popContext();
173
- if (c2) {
172
+ const l = t2.popContext();
173
+ if (l) {
174
174
  const S = t2.currentAddress();
175
- t2.patchJumps(c2.breakTargets || [], S);
175
+ t2.patchJumps(l.breakTargets || [], S);
176
176
  }
177
177
  }, h$1 = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
178
178
  const a2 = e2.initializer, m2 = e2.expression;
@@ -184,7 +184,7 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
184
184
  else
185
185
  throw new Error("Unsupported for-of variable declaration");
186
186
  n(m2), t2.emit(i$2.ITER_START);
187
- const c2 = t2.currentAddress();
187
+ const l = t2.currentAddress();
188
188
  t2.emit(i$2.ITER_NEXT);
189
189
  const S = t2.emit(i$2.JUMP_IF_FALSE, -1);
190
190
  t2.emit(i$2.STORE, T);
@@ -193,14 +193,14 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
193
193
  breakTargets: [S],
194
194
  continueTargets: [],
195
195
  endTargets: [],
196
- startAddress: c2,
196
+ startAddress: l,
197
197
  iterVariable: T
198
198
  };
199
- t2.pushContext(u2), r2(e2.statement), t2.emit(i$2.JUMP, c2);
200
- const l = t2.popContext();
201
- if (l) {
202
- const x2 = t2.currentAddress();
203
- t2.patchJumps(l.breakTargets || [], x2), t2.emit(i$2.ITER_END);
199
+ t2.pushContext(u2), r2(e2.statement), t2.emit(i$2.JUMP, l);
200
+ const c2 = t2.popContext();
201
+ if (c2) {
202
+ const R = t2.currentAddress();
203
+ t2.patchJumps(c2.breakTargets || [], R), t2.emit(i$2.ITER_END);
204
204
  }
205
205
  }, p$2 = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
206
206
  const a2 = e2.initializer, m2 = e2.expression;
@@ -212,7 +212,7 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
212
212
  else
213
213
  throw new Error("Unsupported for-in variable declaration");
214
214
  n(m2), t2.emit(i$2.OBJECT_ITER_START);
215
- const c2 = t2.currentAddress();
215
+ const l = t2.currentAddress();
216
216
  t2.emit(i$2.OBJECT_ITER_NEXT);
217
217
  const S = t2.emit(i$2.JUMP_IF_FALSE, -1);
218
218
  t2.emit(i$2.STORE, T);
@@ -221,14 +221,14 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
221
221
  breakTargets: [S],
222
222
  continueTargets: [],
223
223
  endTargets: [],
224
- startAddress: c2,
224
+ startAddress: l,
225
225
  iterVariable: T
226
226
  };
227
- t2.pushContext(u2), r2(e2.statement), t2.emit(i$2.JUMP, c2);
228
- const l = t2.popContext();
229
- if (l) {
230
- const x2 = t2.currentAddress();
231
- t2.patchJumps(l.breakTargets || [], x2), t2.emit(i$2.ITER_END);
227
+ t2.pushContext(u2), r2(e2.statement), t2.emit(i$2.JUMP, l);
228
+ const c2 = t2.popContext();
229
+ if (c2) {
230
+ const R = t2.currentAddress();
231
+ t2.patchJumps(c2.breakTargets || [], R), t2.emit(i$2.ITER_END);
232
232
  }
233
233
  }, U = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
234
234
  if (e2.initializer)
@@ -248,58 +248,58 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
248
248
  startAddress: a2
249
249
  };
250
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) {
251
+ const l = t2.popContext();
252
+ if (l) {
253
253
  const S = t2.currentAddress();
254
- t2.patchJumps(c2.breakTargets || [], S);
254
+ t2.patchJumps(l.breakTargets || [], S);
255
255
  }
256
256
  }, y$1 = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
257
257
  const a2 = t2.generateTempVar();
258
258
  n(e2.expression), t2.emit(i$2.STORE, a2);
259
259
  const m2 = [], T = [];
260
- let c2 = null;
261
- if (e2.caseBlock.clauses.forEach((l, x2) => {
262
- 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));
267
- }), c2 === null) {
268
- const l = t2.emit(i$2.JUMP, -1);
269
- m2.push(l);
260
+ let l = null;
261
+ if (e2.caseBlock.clauses.forEach((c2, R) => {
262
+ if (s__namespace.isCaseClause(c2)) {
263
+ t2.emit(i$2.LOAD, a2), n(c2.expression), t2.emit(i$2.EQ_STRICT);
264
+ const E2 = t2.emit(i$2.JUMP_IF_TRUE, -1);
265
+ T.push(E2);
266
+ } else s__namespace.isDefaultClause(c2) && (l = t2.emit(i$2.JUMP, -1));
267
+ }), l === null) {
268
+ const c2 = t2.emit(i$2.JUMP, -1);
269
+ m2.push(c2);
270
270
  }
271
271
  let S = 0;
272
- e2.caseBlock.clauses.forEach((l, x2) => {
273
- 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)) {
272
+ e2.caseBlock.clauses.forEach((c2, R) => {
273
+ if (s__namespace.isCaseClause(c2)) {
274
+ const E2 = t2.currentAddress();
275
+ t2.patchJumps([T[S]], E2), S++, c2.statements.forEach((x2) => {
276
+ if (s__namespace.isBreakStatement(x2)) {
277
277
  const f3 = t2.emit(i$2.JUMP, -1);
278
278
  m2.push(f3);
279
279
  } else
280
- r2(E2);
280
+ r2(x2);
281
281
  });
282
- } 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)) {
282
+ } else if (s__namespace.isDefaultClause(c2)) {
283
+ const E2 = t2.currentAddress();
284
+ l !== null && t2.patchJumps([l], E2), c2.statements.forEach((x2) => {
285
+ if (s__namespace.isBreakStatement(x2)) {
286
286
  const f3 = t2.emit(i$2.JUMP, -1);
287
287
  m2.push(f3);
288
288
  } else
289
- r2(E2);
289
+ r2(x2);
290
290
  });
291
291
  }
292
292
  });
293
293
  const u2 = t2.currentAddress();
294
294
  t2.patchJumps(m2, u2);
295
- }, L$1 = (e2, t2, { compileStatement: n }) => {
295
+ }, L = (e2, t2, { compileStatement: n }) => {
296
296
  e2.statements.forEach((r2) => {
297
297
  n(r2);
298
298
  });
299
299
  }, k = (e2, t2, { compileExpression: n }) => {
300
300
  const r2 = e2.declarationList.declarations[0];
301
301
  r2.initializer && (n(r2.initializer), t2.emit(i$2.STORE, r2.name.getText()));
302
- }, D = (e2, t2, { compileExpression: n }) => {
302
+ }, G = (e2, t2, { compileExpression: n }) => {
303
303
  const r2 = e2.expression;
304
304
  if (s__namespace.isBinaryExpression(r2)) {
305
305
  const a2 = r2.operatorToken.kind;
@@ -342,7 +342,7 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
342
342
  s__namespace.isCallExpression(r2) && s__namespace.isPropertyAccessExpression(r2.expression) && r2.expression.expression.getText() === "console" && r2.expression.name.getText() === "log" ? (r2.arguments.forEach((a2) => {
343
343
  n(a2);
344
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 }) => {
345
+ }, D = (e2, t2, { compileExpression: n }) => {
346
346
  e2.expression ? n(e2.expression) : t2.emit(i$2.PUSH, null), t2.emit(i$2.RETURN);
347
347
  }, F$1 = (e2, t2, n) => {
348
348
  const r2 = t2.findLoopContext();
@@ -360,40 +360,40 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
360
360
  } else
361
361
  n.reportError(e2, "continue statement not in loop");
362
362
  }, K = {
363
- [s__namespace.SyntaxKind.IfStatement]: g,
363
+ [s__namespace.SyntaxKind.IfStatement]: P,
364
364
  [s__namespace.SyntaxKind.WhileStatement]: N,
365
365
  [s__namespace.SyntaxKind.ForOfStatement]: h$1,
366
366
  [s__namespace.SyntaxKind.ForInStatement]: p$2,
367
367
  [s__namespace.SyntaxKind.ForStatement]: U,
368
368
  [s__namespace.SyntaxKind.SwitchStatement]: y$1,
369
- [s__namespace.SyntaxKind.Block]: L$1,
369
+ [s__namespace.SyntaxKind.Block]: L,
370
370
  [s__namespace.SyntaxKind.VariableStatement]: k,
371
- [s__namespace.SyntaxKind.ExpressionStatement]: D,
372
- [s__namespace.SyntaxKind.ReturnStatement]: G,
371
+ [s__namespace.SyntaxKind.ExpressionStatement]: G,
372
+ [s__namespace.SyntaxKind.ReturnStatement]: D,
373
373
  [s__namespace.SyntaxKind.BreakStatement]: F$1,
374
374
  [s__namespace.SyntaxKind.ContinueStatement]: b$1
375
- }, J = (e2, t2, n) => {
376
- t2.emit(i$2.PUSH, e2.text);
377
375
  }, H = (e2, t2, n) => {
376
+ t2.emit(i$2.PUSH, e2.text);
377
+ }, J = (e2, t2, n) => {
378
378
  t2.emit(i$2.PUSH, Number(e2.text));
379
- }, M$1 = (e2, t2, n) => {
379
+ }, M$2 = (e2, t2, n) => {
380
380
  t2.emit(i$2.PUSH, true);
381
381
  }, Y = (e2, t2, n) => {
382
382
  t2.emit(i$2.PUSH, false);
383
- }, B$1 = (e2, t2, n) => {
384
- t2.emit(i$2.PUSH, null);
385
383
  }, C$2 = (e2, t2, n) => {
384
+ t2.emit(i$2.PUSH, null);
385
+ }, B$1 = (e2, t2, n) => {
386
386
  const r2 = e2.text, a2 = r2.lastIndexOf("/"), m2 = r2.substring(1, a2), T = r2.substring(a2 + 1);
387
387
  t2.emit(i$2.LOAD_REGEX, { pattern: m2, flags: T });
388
- }, d$3 = (e2, t2, n) => {
388
+ }, w$1 = (e2, t2, n) => {
389
389
  e2.text === "undefined" ? t2.emit(i$2.PUSH_UNDEFINED) : t2.emit(i$2.LOAD, e2.text);
390
- }, w$1 = (e2, t2, { compileExpression: n }) => {
390
+ }, q = (e2, t2, { compileExpression: n }) => {
391
391
  t2.emit(i$2.ARRAY_NEW), e2.elements.forEach((r2) => {
392
392
  n(r2), t2.emit(i$2.ARRAY_PUSH);
393
393
  });
394
394
  }, O = (e2, t2, { compileExpression: n }) => {
395
395
  n(e2.expression);
396
- }, q = (e2, t2, { compileExpression: n }) => {
396
+ }, X = (e2, t2, { compileExpression: n }) => {
397
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
398
  }, V$1 = (e2, t2, { compileExpression: n, reportError: r2 }) => {
399
399
  n(e2.expression), e2.argumentExpression ? n(e2.argumentExpression) : r2(e2, "Element access requires an index expression"), t2.emit(i$2.ARRAY_GET);
@@ -415,7 +415,7 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
415
415
  s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.DEC, false));
416
416
  break;
417
417
  }
418
- }, j$2 = (e2, t2, { compileExpression: n }) => {
418
+ }, d$3 = (e2, t2, { compileExpression: n }) => {
419
419
  switch (e2.operator) {
420
420
  case s__namespace.SyntaxKind.PlusPlusToken:
421
421
  s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.INC, true));
@@ -424,7 +424,7 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
424
424
  s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.DEC, true));
425
425
  break;
426
426
  }
427
- }, X = (e2, t2, { compileExpression: n }) => {
427
+ }, j$1 = (e2, t2, { compileExpression: n }) => {
428
428
  const r2 = e2.operatorToken.kind;
429
429
  switch (n(e2.left), n(e2.right), r2) {
430
430
  case s__namespace.SyntaxKind.PlusToken:
@@ -473,7 +473,7 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
473
473
  t2.emit(i$2.OR);
474
474
  break;
475
475
  }
476
- }, v = (e2, t2, { compileExpression: n }) => {
476
+ }, v$1 = (e2, t2, { compileExpression: n }) => {
477
477
  n(e2.condition);
478
478
  const r2 = t2.emit(i$2.JUMP_IF_FALSE, -1);
479
479
  n(e2.whenTrue);
@@ -542,8 +542,18 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
542
542
  n(e2.expression.expression), t2.emit(i$2.STRING_TRIM_START);
543
543
  else if (a2 === "trimEnd")
544
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);
545
+ else if (a2 === "test")
546
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.REGEX_TEST);
547
+ else if (a2 === "match") {
548
+ if (n(e2.expression.expression), e2.arguments.length > 0)
549
+ n(e2.arguments[0]);
550
+ else {
551
+ r2(e2, "match() requires a regex argument");
552
+ return;
553
+ }
554
+ t2.emit(i$2.STRING_MATCH);
555
+ } else if (a2 === "replace")
556
+ 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, ""), e2.arguments.length > 0 && s__namespace.isRegularExpressionLiteral(e2.arguments[0]), t2.emit(i$2.STRING_REPLACE_REGEX);
547
557
  else if (a2 === "replaceAll")
548
558
  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);
549
559
  else if (a2 === "lastIndexOf")
@@ -578,27 +588,27 @@ const g = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
578
588
  } else
579
589
  throw new Error("Unsupported property type in object literal");
580
590
  }, Z$1 = {
581
- [s__namespace.SyntaxKind.StringLiteral]: J,
582
- [s__namespace.SyntaxKind.NumericLiteral]: H,
583
- [s__namespace.SyntaxKind.TrueKeyword]: M$1,
591
+ [s__namespace.SyntaxKind.StringLiteral]: H,
592
+ [s__namespace.SyntaxKind.NumericLiteral]: J,
593
+ [s__namespace.SyntaxKind.TrueKeyword]: M$2,
584
594
  [s__namespace.SyntaxKind.FalseKeyword]: Y,
585
- [s__namespace.SyntaxKind.NullKeyword]: B$1,
586
- [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,
595
+ [s__namespace.SyntaxKind.NullKeyword]: C$2,
596
+ [s__namespace.SyntaxKind.RegularExpressionLiteral]: B$1,
597
+ [s__namespace.SyntaxKind.Identifier]: w$1,
598
+ [s__namespace.SyntaxKind.ArrayLiteralExpression]: q,
599
+ [s__namespace.SyntaxKind.BinaryExpression]: j$1,
590
600
  [s__namespace.SyntaxKind.PrefixUnaryExpression]: W$1,
591
- [s__namespace.SyntaxKind.PostfixUnaryExpression]: j$2,
601
+ [s__namespace.SyntaxKind.PostfixUnaryExpression]: d$3,
592
602
  [s__namespace.SyntaxKind.CallExpression]: Q$1,
593
- [s__namespace.SyntaxKind.PropertyAccessExpression]: q,
603
+ [s__namespace.SyntaxKind.PropertyAccessExpression]: X,
594
604
  [s__namespace.SyntaxKind.ElementAccessExpression]: V$1,
595
- [s__namespace.SyntaxKind.ConditionalExpression]: v,
605
+ [s__namespace.SyntaxKind.ConditionalExpression]: v$1,
596
606
  [s__namespace.SyntaxKind.TypeOfExpression]: z,
597
607
  [s__namespace.SyntaxKind.ParenthesizedExpression]: O,
598
608
  [s__namespace.SyntaxKind.ObjectLiteralExpression]: $$1
599
609
  };
600
610
  function te$1(e2) {
601
- const t2 = [], n = A(e2);
611
+ const t2 = [], n = A$1(e2);
602
612
  if (n.errors.length > 0)
603
613
  return {
604
614
  success: false,
@@ -609,16 +619,16 @@ function te$1(e2) {
609
619
  character: 0
610
620
  }))
611
621
  };
612
- const r2 = new P(), a2 = s__namespace.createSourceFile("program.ts", e2, s__namespace.ScriptTarget.Latest, true), m2 = {
622
+ const r2 = new g(), a2 = s__namespace.createSourceFile("program.ts", e2, s__namespace.ScriptTarget.Latest, true), m2 = {
613
623
  compileStatement: T,
614
- compileExpression: c2,
624
+ compileExpression: l,
615
625
  reportError: (S, u2) => {
616
- const { line: l, character: x2 } = a2.getLineAndCharacterOfPosition(S.getStart());
626
+ const { line: c2, character: R } = a2.getLineAndCharacterOfPosition(S.getStart());
617
627
  throw t2.push({
618
628
  message: u2,
619
- line: l + 1,
629
+ line: c2 + 1,
620
630
  // TypeScript uses 0-based lines
621
- character: x2 + 1
631
+ character: R + 1
622
632
  // TypeScript uses 0-based columns
623
633
  }), new Error(u2);
624
634
  }
@@ -628,32 +638,32 @@ function te$1(e2) {
628
638
  if (u2)
629
639
  u2(S, r2, m2);
630
640
  else {
631
- const { line: l, character: x2 } = a2.getLineAndCharacterOfPosition(S.getStart());
641
+ const { line: c2, character: R } = a2.getLineAndCharacterOfPosition(S.getStart());
632
642
  t2.push({
633
643
  message: `Unsupported statement: ${s__namespace.SyntaxKind[S.kind]}`,
634
- line: l + 1,
635
- character: x2 + 1
644
+ line: c2 + 1,
645
+ character: R + 1
636
646
  });
637
647
  }
638
648
  }
639
- function c2(S) {
649
+ function l(S) {
640
650
  const u2 = Z$1[S.kind];
641
651
  if (u2)
642
652
  u2(S, r2, m2);
643
653
  else {
644
- const { line: l, character: x2 } = a2.getLineAndCharacterOfPosition(S.getStart());
654
+ const { line: c2, character: R } = a2.getLineAndCharacterOfPosition(S.getStart());
645
655
  t2.push({
646
656
  message: `Unsupported expression: ${s__namespace.SyntaxKind[S.kind]}`,
647
- line: l + 1,
648
- character: x2 + 1
657
+ line: c2 + 1,
658
+ character: R + 1
649
659
  });
650
660
  }
651
661
  }
652
662
  return a2.forEachChild((S) => {
653
663
  var u2;
654
- s__namespace.isFunctionDeclaration(S) && ((u2 = S.name) == null ? void 0 : u2.text) === "main" && S.body && S.body.statements.forEach((l) => {
664
+ s__namespace.isFunctionDeclaration(S) && ((u2 = S.name) == null ? void 0 : u2.text) === "main" && S.body && S.body.statements.forEach((c2) => {
655
665
  try {
656
- T(l);
666
+ T(c2);
657
667
  } catch {
658
668
  }
659
669
  });
@@ -693,7 +703,7 @@ function b(r2) {
693
703
  function p$1(r2) {
694
704
  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
705
  }
696
- function j$1(r2) {
706
+ function j(r2) {
697
707
  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
708
  }
699
709
  function d$2(r2) {
@@ -716,7 +726,7 @@ function s(r2 = [], n) {
716
726
  function C$1() {
717
727
  return { type: "undefined" };
718
728
  }
719
- function M(r2 = {}) {
729
+ function M$1(r2 = {}) {
720
730
  return { type: "object", properties: r2 };
721
731
  }
722
732
  var d$1 = Object.defineProperty;
@@ -734,7 +744,7 @@ class p {
734
744
  return r__namespace.join(this.dataDir, "metadata.json");
735
745
  }
736
746
  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;
747
+ 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
748
  }
739
749
  async disconnect() {
740
750
  this.connected = false;
@@ -745,13 +755,13 @@ class p {
745
755
  async saveProgram(t2) {
746
756
  if (!this.connected) throw new Error("Not connected");
747
757
  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");
758
+ await b$2.promises.writeFile(n, e2, "utf-8");
749
759
  }
750
760
  async getProgram(t2) {
751
761
  if (!this.connected) throw new Error("Not connected");
752
762
  const n = r__namespace.join(this.programsDir, `${t2}.json`);
753
763
  try {
754
- const e2 = await N$1.promises.readFile(n, "utf-8"), o2 = JSON.parse(e2);
764
+ const e2 = await b$2.promises.readFile(n, "utf-8"), o2 = JSON.parse(e2);
755
765
  return o2.created = new Date(o2.created), o2.updated && (o2.updated = new Date(o2.updated)), o2;
756
766
  } catch (e2) {
757
767
  if (e2.code === "ENOENT")
@@ -762,13 +772,13 @@ class p {
762
772
  async saveExecution(t2) {
763
773
  if (!this.connected) throw new Error("Not connected");
764
774
  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");
775
+ await b$2.promises.writeFile(n, e2, "utf-8");
766
776
  }
767
777
  async getExecution(t2) {
768
778
  if (!this.connected) throw new Error("Not connected");
769
779
  const n = r__namespace.join(this.executionsDir, `${t2}.json`);
770
780
  try {
771
- const e2 = await N$1.promises.readFile(n, "utf-8"), o2 = JSON.parse(e2);
781
+ const e2 = await b$2.promises.readFile(n, "utf-8"), o2 = JSON.parse(e2);
772
782
  return o2.created = new Date(o2.created), o2.updated && (o2.updated = new Date(o2.updated)), o2;
773
783
  } catch (e2) {
774
784
  if (e2.code === "ENOENT")
@@ -781,13 +791,13 @@ class p {
781
791
  const e2 = r__namespace.join(this.outputsDir, `${t2}.output`), o2 = n.join(`
782
792
  `) + `
783
793
  `;
784
- await N$1.promises.appendFile(e2, o2, "utf-8");
794
+ await b$2.promises.appendFile(e2, o2, "utf-8");
785
795
  }
786
796
  async getOutput(t2) {
787
797
  if (!this.connected) throw new Error("Not connected");
788
798
  const n = r__namespace.join(this.outputsDir, `${t2}.output`);
789
799
  try {
790
- return (await N$1.promises.readFile(n, "utf-8")).split(`
800
+ return (await b$2.promises.readFile(n, "utf-8")).split(`
791
801
  `).filter((o2) => o2.length > 0);
792
802
  } catch (e2) {
793
803
  if (e2.code === "ENOENT")
@@ -797,7 +807,7 @@ class p {
797
807
  }
798
808
  async listExecutions() {
799
809
  if (!this.connected) throw new Error("Not connected");
800
- const t2 = await N$1.promises.readdir(this.executionsDir), n = [];
810
+ const t2 = await b$2.promises.readdir(this.executionsDir), n = [];
801
811
  for (const e2 of t2)
802
812
  if (e2.endsWith(".json")) {
803
813
  const o2 = e2.slice(0, -5), i2 = await this.getExecution(o2);
@@ -808,7 +818,7 @@ class p {
808
818
  async getCurrentExecutionId() {
809
819
  if (!this.connected) throw new Error("Not connected");
810
820
  try {
811
- const t2 = await N$1.promises.readFile(this.metadataFile, "utf-8");
821
+ const t2 = await b$2.promises.readFile(this.metadataFile, "utf-8");
812
822
  return JSON.parse(t2).currentExecutionId || null;
813
823
  } catch (t2) {
814
824
  if (t2.code === "ENOENT")
@@ -819,19 +829,19 @@ class p {
819
829
  async setCurrentExecutionId(t2) {
820
830
  if (!this.connected) throw new Error("Not connected");
821
831
  const n = { currentExecutionId: t2 };
822
- await N$1.promises.writeFile(this.metadataFile, JSON.stringify(n, null, 2), "utf-8");
832
+ await b$2.promises.writeFile(this.metadataFile, JSON.stringify(n, null, 2), "utf-8");
823
833
  }
824
834
  async deleteExecution(t2) {
825
835
  if (!this.connected) throw new Error("Not connected");
826
836
  const n = r__namespace.join(this.executionsDir, `${t2}.json`);
827
837
  try {
828
- await N$1.promises.unlink(n);
838
+ await b$2.promises.unlink(n);
829
839
  } catch (i2) {
830
840
  if (i2.code !== "ENOENT") throw i2;
831
841
  }
832
842
  const e2 = r__namespace.join(this.outputsDir, `${t2}.output`);
833
843
  try {
834
- await N$1.promises.unlink(e2);
844
+ await b$2.promises.unlink(e2);
835
845
  } catch (i2) {
836
846
  if (i2.code !== "ENOENT") throw i2;
837
847
  }
@@ -839,7 +849,7 @@ class p {
839
849
  }
840
850
  async listPrograms() {
841
851
  if (!this.connected) throw new Error("Not connected");
842
- const t2 = await N$1.promises.readdir(this.programsDir), n = [];
852
+ const t2 = await b$2.promises.readdir(this.programsDir), n = [];
843
853
  for (const e2 of t2)
844
854
  if (e2.endsWith(".json")) {
845
855
  const o2 = e2.slice(0, -5), i2 = await this.getProgram(o2);
@@ -851,7 +861,7 @@ class p {
851
861
  if (!this.connected) throw new Error("Not connected");
852
862
  const n = r__namespace.join(this.programsDir, `${t2}.json`);
853
863
  try {
854
- await N$1.promises.unlink(n);
864
+ await b$2.promises.unlink(n);
855
865
  } catch (e2) {
856
866
  if (e2.code !== "ENOENT") throw e2;
857
867
  }
@@ -998,13 +1008,13 @@ const f2 = Q, Z = {
998
1008
  execute: (e2, t$1) => {
999
1009
  const r2 = d(e2, t$1.op);
1000
1010
  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));
1011
+ const o2 = d(e2, t$1.op);
1012
+ if (f2(o2)) return o2;
1013
+ if (t(o2) || t(r2))
1014
+ e2.stack.push(p$1(o2) + p$1(r2));
1005
1015
  else {
1006
- const o2 = m(s2), c2 = m(r2);
1007
- e2.stack.push(o2 + c2);
1016
+ const s2 = m(o2), c2 = m(r2);
1017
+ e2.stack.push(s2 + c2);
1008
1018
  }
1009
1019
  }
1010
1020
  },
@@ -1014,10 +1024,10 @@ const f2 = Q, Z = {
1014
1024
  execute: (e2, t2) => {
1015
1025
  const r2 = d(e2, t2.op);
1016
1026
  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);
1027
+ const o2 = d(e2, t2.op);
1028
+ if (f2(o2)) return o2;
1029
+ const s2 = m(o2), c2 = m(r2);
1030
+ e2.stack.push(s2 - c2);
1021
1031
  }
1022
1032
  },
1023
1033
  [i$2.MUL]: {
@@ -1026,10 +1036,10 @@ const f2 = Q, Z = {
1026
1036
  execute: (e2, t2) => {
1027
1037
  const r2 = d(e2, t2.op);
1028
1038
  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);
1039
+ const o2 = d(e2, t2.op);
1040
+ if (f2(o2)) return o2;
1041
+ const s2 = m(o2), c2 = m(r2);
1042
+ e2.stack.push(s2 * c2);
1033
1043
  }
1034
1044
  },
1035
1045
  [i$2.DIV]: {
@@ -1038,9 +1048,9 @@ const f2 = Q, Z = {
1038
1048
  execute: (e2, t2) => {
1039
1049
  const r2 = d(e2, t2.op);
1040
1050
  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);
1051
+ const o2 = d(e2, t2.op);
1052
+ if (f2(o2)) return o2;
1053
+ const s2 = m(o2), c2 = m(r2);
1044
1054
  if (c2 === 0)
1045
1055
  return {
1046
1056
  type: "DivisionByZero",
@@ -1048,7 +1058,7 @@ const f2 = Q, Z = {
1048
1058
  pc: e2.pc,
1049
1059
  opcode: t2.op
1050
1060
  };
1051
- e2.stack.push(o2 / c2);
1061
+ e2.stack.push(s2 / c2);
1052
1062
  }
1053
1063
  },
1054
1064
  [i$2.MOD]: {
@@ -1057,10 +1067,10 @@ const f2 = Q, Z = {
1057
1067
  execute: (e2, t2) => {
1058
1068
  const r2 = d(e2, t2.op);
1059
1069
  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);
1070
+ const o2 = d(e2, t2.op);
1071
+ if (f2(o2)) return o2;
1072
+ const s2 = m(o2), c2 = m(r2);
1073
+ e2.stack.push(s2 % c2);
1064
1074
  }
1065
1075
  },
1066
1076
  [i$2.UNARY_MINUS]: {
@@ -1069,8 +1079,8 @@ const f2 = Q, Z = {
1069
1079
  execute: (e2, t2) => {
1070
1080
  const r2 = d(e2, t2.op);
1071
1081
  if (f2(r2)) return r2;
1072
- const s2 = m(r2);
1073
- e2.stack.push(-s2);
1082
+ const o2 = m(r2);
1083
+ e2.stack.push(-o2);
1074
1084
  }
1075
1085
  },
1076
1086
  [i$2.UNARY_PLUS]: {
@@ -1079,8 +1089,8 @@ const f2 = Q, Z = {
1079
1089
  execute: (e2, t2) => {
1080
1090
  const r2 = d(e2, t2.op);
1081
1091
  if (f2(r2)) return r2;
1082
- const s2 = m(r2);
1083
- e2.stack.push(s2);
1092
+ const o2 = m(r2);
1093
+ e2.stack.push(o2);
1084
1094
  }
1085
1095
  }
1086
1096
  }, ee = {
@@ -1117,16 +1127,16 @@ const f2 = Q, Z = {
1117
1127
  stackIn: 2,
1118
1128
  stackOut: 2,
1119
1129
  execute: (e2, t2) => {
1120
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
1121
- e2.stack.push(r2), e2.stack.push(s2);
1130
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1131
+ e2.stack.push(r2), e2.stack.push(o2);
1122
1132
  }
1123
1133
  },
1124
1134
  [i$2.DUP2]: {
1125
1135
  stackIn: 2,
1126
1136
  stackOut: 4,
1127
1137
  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);
1138
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1139
+ e2.stack.push(o2), e2.stack.push(r2), e2.stack.push(o2), e2.stack.push(r2);
1130
1140
  }
1131
1141
  }
1132
1142
  }, re = {
@@ -1193,15 +1203,15 @@ const f2 = Q, Z = {
1193
1203
  pc: e2.pc,
1194
1204
  opcode: t2.op
1195
1205
  };
1196
- const s2 = t2.arg;
1197
- if (s2 < 0)
1206
+ const o2 = t2.arg;
1207
+ if (o2 < 0)
1198
1208
  return {
1199
1209
  type: "RuntimeError",
1200
- message: `Invalid jump target: ${s2}`,
1210
+ message: `Invalid jump target: ${o2}`,
1201
1211
  pc: e2.pc,
1202
1212
  opcode: t2.op
1203
1213
  };
1204
- j$1(r2) ? e2.pc++ : e2.pc = s2;
1214
+ j(r2) ? e2.pc++ : e2.pc = o2;
1205
1215
  }
1206
1216
  },
1207
1217
  [i$2.JUMP_IF]: {
@@ -1217,15 +1227,15 @@ const f2 = Q, Z = {
1217
1227
  pc: e2.pc,
1218
1228
  opcode: t2.op
1219
1229
  };
1220
- const s2 = t2.arg;
1221
- if (s2 < 0)
1230
+ const o2 = t2.arg;
1231
+ if (o2 < 0)
1222
1232
  return {
1223
1233
  type: "RuntimeError",
1224
- message: `Invalid jump target: ${s2}`,
1234
+ message: `Invalid jump target: ${o2}`,
1225
1235
  pc: e2.pc,
1226
1236
  opcode: t2.op
1227
1237
  };
1228
- j$1(r2) ? e2.pc = s2 : e2.pc++;
1238
+ j(r2) ? e2.pc = o2 : e2.pc++;
1229
1239
  }
1230
1240
  },
1231
1241
  [i$2.JUMP_IF_TRUE]: {
@@ -1241,15 +1251,15 @@ const f2 = Q, Z = {
1241
1251
  pc: e2.pc,
1242
1252
  opcode: t2.op
1243
1253
  };
1244
- const s2 = t2.arg;
1245
- if (s2 < 0)
1254
+ const o2 = t2.arg;
1255
+ if (o2 < 0)
1246
1256
  return {
1247
1257
  type: "RuntimeError",
1248
- message: `Invalid jump target: ${s2}`,
1258
+ message: `Invalid jump target: ${o2}`,
1249
1259
  pc: e2.pc,
1250
1260
  opcode: t2.op
1251
1261
  };
1252
- j$1(r2) ? e2.pc = s2 : e2.pc++;
1262
+ j(r2) ? e2.pc = o2 : e2.pc++;
1253
1263
  }
1254
1264
  },
1255
1265
  [i$2.CALL]: {
@@ -1263,7 +1273,7 @@ const f2 = Q, Z = {
1263
1273
  opcode: i$2.CALL
1264
1274
  })
1265
1275
  }
1266
- }, se = {
1276
+ }, oe = {
1267
1277
  [i$2.LOAD]: {
1268
1278
  stackIn: 0,
1269
1279
  stackOut: 1,
@@ -1280,7 +1290,7 @@ const f2 = Q, Z = {
1280
1290
  e2.variables.set(t2.arg, r2);
1281
1291
  }
1282
1292
  }
1283
- }, oe = {
1293
+ }, se = {
1284
1294
  [i$2.ITER_START]: {
1285
1295
  stackIn: 1,
1286
1296
  stackOut: 0,
@@ -1293,19 +1303,19 @@ const f2 = Q, Z = {
1293
1303
  pc: e2.pc,
1294
1304
  opcode: t2.op
1295
1305
  };
1296
- let s2;
1306
+ let o$12;
1297
1307
  if (u$1(r2)) {
1298
- const o2 = e2.heap.get(r2.id);
1299
- if (!o2 || o2.type !== "array")
1308
+ const s2 = e2.heap.get(r2.id);
1309
+ if (!s2 || s2.type !== "array")
1300
1310
  return {
1301
1311
  type: "RuntimeError",
1302
1312
  message: "Invalid array reference",
1303
1313
  pc: e2.pc,
1304
1314
  opcode: t2.op
1305
1315
  };
1306
- s2 = o2.data;
1316
+ o$12 = s2.data;
1307
1317
  } else if (o(r2))
1308
- s2 = r2;
1318
+ o$12 = r2;
1309
1319
  else
1310
1320
  return {
1311
1321
  type: "TypeError",
@@ -1321,9 +1331,9 @@ const f2 = Q, Z = {
1321
1331
  opcode: t2.op
1322
1332
  };
1323
1333
  e2.iterators.push({
1324
- array: s2,
1334
+ array: o$12,
1325
1335
  index: 0,
1326
- length: s2.elements.length
1336
+ length: o$12.elements.length
1327
1337
  });
1328
1338
  }
1329
1339
  },
@@ -1358,88 +1368,88 @@ const f2 = Q, Z = {
1358
1368
  }
1359
1369
  }
1360
1370
  };
1361
- function x$1(e2, t2, r2) {
1362
- const s2 = d(e2, t2.op);
1363
- if (f2(s2)) return s2;
1371
+ function v(e2, t2, r2) {
1364
1372
  const o2 = d(e2, t2.op);
1365
1373
  if (f2(o2)) return o2;
1366
- const c2 = r2(o2, s2);
1374
+ const s2 = d(e2, t2.op);
1375
+ if (f2(s2)) return s2;
1376
+ const c2 = r2(s2, o2);
1367
1377
  e2.stack.push(c2);
1368
1378
  }
1369
1379
  const ce = {
1370
1380
  [i$2.EQ]: {
1371
1381
  stackIn: 2,
1372
1382
  stackOut: 1,
1373
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1374
- if (f$2(r2) && c(s2) || c(r2) && f$2(s2))
1383
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1384
+ if (f$2(r2) && c(o2) || c(r2) && f$2(o2))
1375
1385
  return true;
1376
- if (c(r2) && c(s2))
1386
+ if (c(r2) && c(o2))
1377
1387
  return true;
1378
1388
  if (u$1(r2) || b(r2))
1379
- return u$1(r2) && u$1(s2) || b(r2) && b(s2) ? r2.id === s2.id : false;
1389
+ return u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id === o2.id : false;
1380
1390
  {
1381
- const o2 = m(r2), c2 = m(s2);
1382
- return !isNaN(o2) && !isNaN(c2) ? o2 === c2 : p$1(r2) === p$1(s2);
1391
+ const s2 = m(r2), c2 = m(o2);
1392
+ return !isNaN(s2) && !isNaN(c2) ? s2 === c2 : p$1(r2) === p$1(o2);
1383
1393
  }
1384
1394
  })
1385
1395
  },
1386
1396
  [i$2.NEQ]: {
1387
1397
  stackIn: 2,
1388
1398
  stackOut: 1,
1389
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1390
- if (f$2(r2) && c(s2) || c(r2) && f$2(s2))
1399
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1400
+ if (f$2(r2) && c(o2) || c(r2) && f$2(o2))
1391
1401
  return false;
1392
- if (c(r2) && c(s2))
1402
+ if (c(r2) && c(o2))
1393
1403
  return false;
1394
1404
  if (u$1(r2) || b(r2))
1395
- return u$1(r2) && u$1(s2) || b(r2) && b(s2) ? r2.id !== s2.id : true;
1405
+ return u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id !== o2.id : true;
1396
1406
  {
1397
- const o2 = m(r2), c2 = m(s2);
1398
- return !isNaN(o2) && !isNaN(c2) ? o2 !== c2 : p$1(r2) !== p$1(s2);
1407
+ const s2 = m(r2), c2 = m(o2);
1408
+ return !isNaN(s2) && !isNaN(c2) ? s2 !== c2 : p$1(r2) !== p$1(o2);
1399
1409
  }
1400
1410
  })
1401
1411
  },
1402
1412
  [i$2.LT]: {
1403
1413
  stackIn: 2,
1404
1414
  stackOut: 1,
1405
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1406
- const o2 = m(r2), c2 = m(s2);
1407
- return o2 < c2;
1415
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1416
+ const s2 = m(r2), c2 = m(o2);
1417
+ return s2 < c2;
1408
1418
  })
1409
1419
  },
1410
1420
  [i$2.GT]: {
1411
1421
  stackIn: 2,
1412
1422
  stackOut: 1,
1413
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1414
- const o2 = m(r2), c2 = m(s2);
1415
- return o2 > c2;
1423
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1424
+ const s2 = m(r2), c2 = m(o2);
1425
+ return s2 > c2;
1416
1426
  })
1417
1427
  },
1418
1428
  [i$2.LTE]: {
1419
1429
  stackIn: 2,
1420
1430
  stackOut: 1,
1421
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1422
- const o2 = m(r2), c2 = m(s2);
1423
- return o2 <= c2;
1431
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1432
+ const s2 = m(r2), c2 = m(o2);
1433
+ return s2 <= c2;
1424
1434
  })
1425
1435
  },
1426
1436
  [i$2.GTE]: {
1427
1437
  stackIn: 2,
1428
1438
  stackOut: 1,
1429
- execute: (e2, t2) => x$1(e2, t2, (r2, s2) => {
1430
- const o2 = m(r2), c2 = m(s2);
1431
- return o2 >= c2;
1439
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1440
+ const s2 = m(r2), c2 = m(o2);
1441
+ return s2 >= c2;
1432
1442
  })
1433
1443
  },
1434
1444
  [i$2.EQ_STRICT]: {
1435
1445
  stackIn: 2,
1436
1446
  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)
1447
+ 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
1448
  },
1439
1449
  [i$2.NEQ_STRICT]: {
1440
1450
  stackIn: 2,
1441
1451
  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)
1452
+ 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
1453
  }
1444
1454
  }, ne = {
1445
1455
  [i$2.AND]: {
@@ -1448,10 +1458,10 @@ const ce = {
1448
1458
  execute: (e2, t2) => {
1449
1459
  const r2 = d(e2, t2.op);
1450
1460
  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);
1461
+ const o2 = d(e2, t2.op);
1462
+ if (f2(o2)) return o2;
1463
+ const s2 = j(o2) ? r2 : o2;
1464
+ e2.stack.push(s2);
1455
1465
  }
1456
1466
  },
1457
1467
  [i$2.OR]: {
@@ -1460,10 +1470,10 @@ const ce = {
1460
1470
  execute: (e2, t2) => {
1461
1471
  const r2 = d(e2, t2.op);
1462
1472
  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);
1473
+ const o2 = d(e2, t2.op);
1474
+ if (f2(o2)) return o2;
1475
+ const s2 = j(o2) ? o2 : r2;
1476
+ e2.stack.push(s2);
1467
1477
  }
1468
1478
  },
1469
1479
  [i$2.NOT]: {
@@ -1472,8 +1482,8 @@ const ce = {
1472
1482
  execute: (e2, t2) => {
1473
1483
  const r2 = d(e2, t2.op);
1474
1484
  if (f2(r2)) return r2;
1475
- const s2 = !j$1(r2);
1476
- e2.stack.push(s2);
1485
+ const o2 = !j(r2);
1486
+ e2.stack.push(o2);
1477
1487
  }
1478
1488
  }
1479
1489
  }, pe = {
@@ -1485,8 +1495,8 @@ const ce = {
1485
1495
  stackIn: 0,
1486
1496
  stackOut: 1,
1487
1497
  execute: (e2, t2) => {
1488
- const r2 = s(), s$12 = e2.heap.allocate("array", r2);
1489
- e2.stack.push(s$12);
1498
+ const r2 = s(), o2 = e2.heap.allocate("array", r2);
1499
+ e2.stack.push(o2);
1490
1500
  }
1491
1501
  },
1492
1502
  /**
@@ -1497,10 +1507,10 @@ const ce = {
1497
1507
  stackIn: 2,
1498
1508
  stackOut: 1,
1499
1509
  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);
1510
+ const r2 = e2.stack.pop(), o$12 = e2.stack.pop();
1511
+ let s2;
1512
+ if (u$1(o$12)) {
1513
+ const c2 = e2.heap.get(o$12.id);
1504
1514
  if (!c2 || c2.type !== "array")
1505
1515
  return {
1506
1516
  type: "RuntimeError",
@@ -1508,9 +1518,9 @@ const ce = {
1508
1518
  pc: e2.pc,
1509
1519
  opcode: t2.op
1510
1520
  };
1511
- o$12 = c2.data;
1512
- } else if (o(s2))
1513
- o$12 = s2;
1521
+ s2 = c2.data;
1522
+ } else if (o(o$12))
1523
+ s2 = o$12;
1514
1524
  else
1515
1525
  return {
1516
1526
  type: "RuntimeError",
@@ -1518,7 +1528,7 @@ const ce = {
1518
1528
  pc: e2.pc,
1519
1529
  opcode: t2.op
1520
1530
  };
1521
- o$12.elements.push(r2), e2.stack.push(s2);
1531
+ s2.elements.push(r2), e2.stack.push(o$12);
1522
1532
  }
1523
1533
  },
1524
1534
  [i$2.ARRAY_GET]: {
@@ -1526,41 +1536,41 @@ const ce = {
1526
1536
  stackOut: 1,
1527
1537
  execute: (e2, t$1) => {
1528
1538
  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);
1533
- if (!i2 || i2.type !== "array")
1539
+ const r2 = e2.stack.pop(), o$12 = e2.stack.pop();
1540
+ let s2;
1541
+ if (u$1(o$12)) {
1542
+ const u2 = e2.heap.get(o$12.id);
1543
+ if (!u2 || u2.type !== "array")
1534
1544
  return {
1535
1545
  type: "RuntimeError",
1536
1546
  message: "Invalid array reference",
1537
1547
  pc: e2.pc,
1538
1548
  opcode: t$1.op
1539
1549
  };
1540
- o$12 = i2.data;
1541
- } else if (b(s2)) {
1542
- const i2 = e2.heap.get(s2.id);
1543
- if (!i2 || i2.type !== "object")
1550
+ s2 = u2.data;
1551
+ } else if (b(o$12)) {
1552
+ const u2 = e2.heap.get(o$12.id);
1553
+ if (!u2 || u2.type !== "object")
1544
1554
  return {
1545
1555
  type: "RuntimeError",
1546
1556
  message: "Invalid object reference",
1547
1557
  pc: e2.pc,
1548
1558
  opcode: t$1.op
1549
1559
  };
1550
- const u2 = i2.data, y2 = p$1(r2), E2 = u2.properties[y2] ?? C$1();
1560
+ const i2 = u2.data, y2 = p$1(r2), E2 = i2.properties[y2] ?? C$1();
1551
1561
  e2.stack.push(E2);
1552
1562
  return;
1553
- } else if (o(s2))
1554
- o$12 = s2;
1555
- else if (t(s2)) {
1556
- let i2;
1563
+ } else if (o(o$12))
1564
+ s2 = o$12;
1565
+ else if (t(o$12)) {
1566
+ let u2;
1557
1567
  if (i$1(r2))
1558
- i2 = r2;
1568
+ u2 = r2;
1559
1569
  else if (t(r2)) {
1560
- const u2 = parseInt(r2, 10);
1561
- !isNaN(u2) && u2.toString() === r2 && (i2 = u2);
1570
+ const i2 = parseInt(r2, 10);
1571
+ !isNaN(i2) && i2.toString() === r2 && (u2 = i2);
1562
1572
  }
1563
- i2 !== void 0 && i2 >= 0 && i2 < s2.length ? e2.stack.push(s2[i2]) : e2.stack.push(C$1());
1573
+ u2 !== void 0 && u2 >= 0 && u2 < o$12.length ? e2.stack.push(o$12[u2]) : e2.stack.push(C$1());
1564
1574
  return;
1565
1575
  } else
1566
1576
  return {
@@ -1573,12 +1583,12 @@ const ce = {
1573
1583
  if (i$1(r2))
1574
1584
  c2 = r2;
1575
1585
  else if (t(r2)) {
1576
- const i2 = parseInt(r2, 10);
1577
- if (!isNaN(i2) && i2.toString() === r2 && i2 >= 0)
1578
- c2 = i2;
1586
+ const u2 = parseInt(r2, 10);
1587
+ if (!isNaN(u2) && u2.toString() === r2 && u2 >= 0)
1588
+ c2 = u2;
1579
1589
  else {
1580
- const u2 = ((a2 = o$12.properties) == null ? void 0 : a2[r2]) ?? C$1();
1581
- e2.stack.push(u2);
1590
+ const i2 = ((a2 = s2.properties) == null ? void 0 : a2[r2]) ?? C$1();
1591
+ e2.stack.push(i2);
1582
1592
  return;
1583
1593
  }
1584
1594
  } else
@@ -1588,7 +1598,7 @@ const ce = {
1588
1598
  pc: e2.pc,
1589
1599
  opcode: t$1.op
1590
1600
  };
1591
- const p2 = o$12.elements[c2] ?? C$1();
1601
+ const p2 = s2.elements[c2] ?? C$1();
1592
1602
  e2.stack.push(p2);
1593
1603
  }
1594
1604
  },
@@ -1596,32 +1606,32 @@ const ce = {
1596
1606
  stackIn: 3,
1597
1607
  stackOut: 1,
1598
1608
  execute: (e2, t$1) => {
1599
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o$12 = e2.stack.pop();
1609
+ const r2 = e2.stack.pop(), o$12 = e2.stack.pop(), s2 = e2.stack.pop();
1600
1610
  let c2;
1601
- if (u$1(o$12)) {
1602
- const i2 = e2.heap.get(o$12.id);
1603
- if (!i2 || i2.type !== "array")
1611
+ if (u$1(s2)) {
1612
+ const u2 = e2.heap.get(s2.id);
1613
+ if (!u2 || u2.type !== "array")
1604
1614
  return {
1605
1615
  type: "RuntimeError",
1606
1616
  message: "Invalid array reference",
1607
1617
  pc: e2.pc,
1608
1618
  opcode: t$1.op
1609
1619
  };
1610
- c2 = i2.data;
1611
- } else if (b(o$12)) {
1612
- const i2 = e2.heap.get(o$12.id);
1613
- if (!i2 || i2.type !== "object")
1620
+ c2 = u2.data;
1621
+ } else if (b(s2)) {
1622
+ const u2 = e2.heap.get(s2.id);
1623
+ if (!u2 || u2.type !== "object")
1614
1624
  return {
1615
1625
  type: "RuntimeError",
1616
1626
  message: "Invalid object reference",
1617
1627
  pc: e2.pc,
1618
1628
  opcode: t$1.op
1619
1629
  };
1620
- const u2 = i2.data, y2 = p$1(s2);
1621
- u2.properties[y2] = r2, e2.stack.push(o$12);
1630
+ const i2 = u2.data, y2 = p$1(o$12);
1631
+ i2.properties[y2] = r2, e2.stack.push(s2);
1622
1632
  return;
1623
- } else if (o(o$12))
1624
- c2 = o$12;
1633
+ } else if (o(s2))
1634
+ c2 = s2;
1625
1635
  else
1626
1636
  return {
1627
1637
  type: "RuntimeError",
@@ -1630,14 +1640,14 @@ const ce = {
1630
1640
  opcode: t$1.op
1631
1641
  };
1632
1642
  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)
1638
- p2 = i2;
1643
+ if (i$1(o$12))
1644
+ p2 = o$12;
1645
+ else if (t(o$12)) {
1646
+ const u2 = parseInt(o$12, 10);
1647
+ if (!isNaN(u2) && u2.toString() === o$12 && u2 >= 0)
1648
+ p2 = u2;
1639
1649
  else {
1640
- c2.properties || (c2.properties = {}), c2.properties[s2] = r2, e2.stack.push(o$12);
1650
+ c2.properties || (c2.properties = {}), c2.properties[o$12] = r2, e2.stack.push(s2);
1641
1651
  return;
1642
1652
  }
1643
1653
  } else
@@ -1655,7 +1665,7 @@ const ce = {
1655
1665
  pc: e2.pc,
1656
1666
  opcode: t$1.op
1657
1667
  };
1658
- c2.elements[a2] = r2, e2.stack.push(o$12);
1668
+ c2.elements[a2] = r2, e2.stack.push(s2);
1659
1669
  }
1660
1670
  },
1661
1671
  [i$2.ARRAY_LEN]: {
@@ -1663,19 +1673,19 @@ const ce = {
1663
1673
  stackOut: 1,
1664
1674
  execute: (e2, t2) => {
1665
1675
  const r2 = e2.stack.pop();
1666
- let s2;
1676
+ let o$12;
1667
1677
  if (u$1(r2)) {
1668
- const o2 = e2.heap.get(r2.id);
1669
- if (!o2 || o2.type !== "array")
1678
+ const s2 = e2.heap.get(r2.id);
1679
+ if (!s2 || s2.type !== "array")
1670
1680
  return {
1671
1681
  type: "RuntimeError",
1672
1682
  message: "Invalid array reference",
1673
1683
  pc: e2.pc,
1674
1684
  opcode: t2.op
1675
1685
  };
1676
- s2 = o2.data;
1686
+ o$12 = s2.data;
1677
1687
  } else if (o(r2))
1678
- s2 = r2;
1688
+ o$12 = r2;
1679
1689
  else
1680
1690
  return {
1681
1691
  type: "RuntimeError",
@@ -1683,35 +1693,35 @@ const ce = {
1683
1693
  pc: e2.pc,
1684
1694
  opcode: t2.op
1685
1695
  };
1686
- e2.stack.push(s2.elements.length);
1696
+ e2.stack.push(o$12.elements.length);
1687
1697
  }
1688
1698
  },
1689
1699
  [i$2.ARRAY_MAP_PROP]: {
1690
1700
  stackIn: 2,
1691
1701
  stackOut: 1,
1692
1702
  execute: (e2, t2) => {
1693
- const r2 = e2.stack.pop(), s$12 = e2.stack.pop();
1694
- if (!u$1(s$12))
1703
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1704
+ if (!u$1(o2))
1695
1705
  return {
1696
1706
  type: "RuntimeError",
1697
1707
  message: "map() requires an array",
1698
1708
  pc: e2.pc,
1699
1709
  opcode: t2.op
1700
1710
  };
1701
- const o2 = e2.heap.get(s$12.id);
1702
- if (!o2 || o2.type !== "array")
1711
+ const s$12 = e2.heap.get(o2.id);
1712
+ if (!s$12 || s$12.type !== "array")
1703
1713
  return {
1704
1714
  type: "RuntimeError",
1705
1715
  message: "Invalid array reference",
1706
1716
  pc: e2.pc,
1707
1717
  opcode: t2.op
1708
1718
  };
1709
- const c2 = o2.data, p2 = s();
1710
- for (const i2 of c2.elements)
1711
- if (b(i2)) {
1712
- const u2 = e2.heap.get(i2.id);
1713
- if (u2 && u2.type === "object") {
1714
- const y2 = u2.data, E2 = p$1(r2);
1719
+ const c2 = s$12.data, p2 = s();
1720
+ for (const u2 of c2.elements)
1721
+ if (b(u2)) {
1722
+ const i2 = e2.heap.get(u2.id);
1723
+ if (i2 && i2.type === "object") {
1724
+ const y2 = i2.data, E2 = p$1(r2);
1715
1725
  p2.elements.push(y2.properties[E2] || null);
1716
1726
  } else
1717
1727
  p2.elements.push(null);
@@ -1725,29 +1735,29 @@ const ce = {
1725
1735
  stackIn: 2,
1726
1736
  stackOut: 1,
1727
1737
  execute: (e2, t2) => {
1728
- const r2 = e2.stack.pop(), s$12 = e2.stack.pop();
1729
- if (!u$1(s$12))
1738
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1739
+ if (!u$1(o2))
1730
1740
  return {
1731
1741
  type: "RuntimeError",
1732
1742
  message: "filter() requires an array",
1733
1743
  pc: e2.pc,
1734
1744
  opcode: t2.op
1735
1745
  };
1736
- const o2 = e2.heap.get(s$12.id);
1737
- if (!o2 || o2.type !== "array")
1746
+ const s$12 = e2.heap.get(o2.id);
1747
+ if (!s$12 || s$12.type !== "array")
1738
1748
  return {
1739
1749
  type: "RuntimeError",
1740
1750
  message: "Invalid array reference",
1741
1751
  pc: e2.pc,
1742
1752
  opcode: t2.op
1743
1753
  };
1744
- const c2 = o2.data, p2 = s();
1745
- for (const i2 of c2.elements)
1746
- if (b(i2)) {
1747
- const u2 = e2.heap.get(i2.id);
1748
- if (u2 && u2.type === "object") {
1749
- const y2 = u2.data, E2 = p$1(r2);
1750
- E2 in y2.properties && y2.properties[E2] && p2.elements.push(i2);
1754
+ const c2 = s$12.data, p2 = s();
1755
+ for (const u2 of c2.elements)
1756
+ if (b(u2)) {
1757
+ const i2 = e2.heap.get(u2.id);
1758
+ if (i2 && i2.type === "object") {
1759
+ const y2 = i2.data, E2 = p$1(r2);
1760
+ E2 in y2.properties && y2.properties[E2] && p2.elements.push(u2);
1751
1761
  }
1752
1762
  }
1753
1763
  const a2 = e2.heap.allocate("array", p2);
@@ -1759,20 +1769,20 @@ const ce = {
1759
1769
  // array, start, end
1760
1770
  stackOut: 1,
1761
1771
  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))
1772
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s$12 = e2.stack.pop();
1773
+ if (!((L2) => {
1774
+ if (!u$1(L2))
1765
1775
  return false;
1766
- const U2 = e2.heap.get(M2.id);
1776
+ const U2 = e2.heap.get(L2.id);
1767
1777
  return U2 !== void 0 && U2.type === "array";
1768
- })(o2))
1778
+ })(s$12))
1769
1779
  return {
1770
1780
  type: "RuntimeError",
1771
1781
  message: "ARRAY_SLICE requires an array",
1772
1782
  pc: e2.pc,
1773
1783
  opcode: t2.op
1774
1784
  };
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);
1785
+ const a2 = e2.heap.get(s$12.id).data, u2 = i$1(o2) ? o2 : 0, i2 = r2 === void 0 ? a2.elements.length : i$1(r2) ? r2 : a2.elements.length, y2 = u2 < 0 ? Math.max(0, a2.elements.length + u2) : u2, E2 = i2 < 0 ? Math.max(0, a2.elements.length + i2) : i2, J2 = a2.elements.slice(y2, E2), Y2 = s(J2), z2 = e2.heap.allocate("array", Y2);
1776
1786
  e2.stack.push(z2);
1777
1787
  }
1778
1788
  },
@@ -1782,21 +1792,21 @@ const ce = {
1782
1792
  stackOut: 1,
1783
1793
  // string
1784
1794
  execute: (e2, t$1) => {
1785
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
1795
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1786
1796
  if (!((y2) => {
1787
1797
  if (!u$1(y2))
1788
1798
  return false;
1789
1799
  const E2 = e2.heap.get(y2.id);
1790
1800
  return E2 !== void 0 && E2.type === "array";
1791
- })(s2))
1801
+ })(o2))
1792
1802
  return {
1793
1803
  type: "RuntimeError",
1794
1804
  message: "ARRAY_JOIN requires an array",
1795
1805
  pc: e2.pc,
1796
1806
  opcode: t$1.op
1797
1807
  };
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);
1799
- e2.stack.push(u2);
1808
+ const p2 = e2.heap.get(o2.id).data, a2 = t(r2) ? r2 : String(r2), i2 = p2.elements.map((y2) => y2 === null ? "null" : y2 === void 0 || c(y2) ? "undefined" : String(y2)).join(a2);
1809
+ e2.stack.push(i2);
1800
1810
  }
1801
1811
  },
1802
1812
  [i$2.ARRAY_INDEX_OF]: {
@@ -1805,20 +1815,20 @@ const ce = {
1805
1815
  stackOut: 1,
1806
1816
  // number (index or -1)
1807
1817
  execute: (e2, t2) => {
1808
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
1818
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1809
1819
  if (!((a2) => {
1810
1820
  if (!u$1(a2))
1811
1821
  return false;
1812
- const i2 = e2.heap.get(a2.id);
1813
- return i2 !== void 0 && i2.type === "array";
1814
- })(s2))
1822
+ const u2 = e2.heap.get(a2.id);
1823
+ return u2 !== void 0 && u2.type === "array";
1824
+ })(o2))
1815
1825
  return {
1816
1826
  type: "RuntimeError",
1817
1827
  message: "ARRAY_INDEX_OF requires an array",
1818
1828
  pc: e2.pc,
1819
1829
  opcode: t2.op
1820
1830
  };
1821
- const p2 = e2.heap.get(s2.id).data;
1831
+ const p2 = e2.heap.get(o2.id).data;
1822
1832
  for (let a2 = 0; a2 < p2.elements.length; a2++)
1823
1833
  if (p2.elements[a2] === r2) {
1824
1834
  e2.stack.push(a2);
@@ -1828,21 +1838,21 @@ const ce = {
1828
1838
  }
1829
1839
  }
1830
1840
  };
1831
- function L(e2, t2) {
1841
+ function M(e2, t2) {
1832
1842
  if (e2 === null) return null;
1833
1843
  if (e2 !== void 0) {
1834
1844
  if (typeof e2 == "string" || typeof e2 == "number" || typeof e2 == "boolean" || e2 && typeof e2 == "object" && e2.type === "array" && Array.isArray(e2.elements))
1835
1845
  return e2;
1836
1846
  if (Array.isArray(e2)) {
1837
1847
  const r2 = s();
1838
- return r2.elements = e2.map((s2) => L(s2, t2)), t2.allocate("array", r2);
1848
+ return r2.elements = e2.map((o2) => M(o2, t2)), t2.allocate("array", r2);
1839
1849
  }
1840
1850
  if (e2 && typeof e2 == "object" && e2.type === "object" && e2.properties)
1841
1851
  return e2;
1842
1852
  if (typeof e2 == "object") {
1843
- const r2 = M();
1844
- for (const [s2, o2] of Object.entries(e2))
1845
- r2.properties[s2] = L(o2, t2);
1853
+ const r2 = M$1();
1854
+ for (const [o2, s2] of Object.entries(e2))
1855
+ r2.properties[o2] = M(s2, t2);
1846
1856
  return t2.allocate("object", r2);
1847
1857
  }
1848
1858
  return null;
@@ -1855,9 +1865,9 @@ const ae = {
1855
1865
  execute: (e2, t2) => {
1856
1866
  const r2 = d(e2, t2.op);
1857
1867
  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));
1868
+ const o2 = d(e2, t2.op);
1869
+ if (f2(o2)) return o2;
1870
+ e2.stack.push(p$1(o2) + p$1(r2));
1861
1871
  }
1862
1872
  },
1863
1873
  [i$2.STRING_LEN]: {
@@ -1887,16 +1897,16 @@ const ae = {
1887
1897
  else if (o(r2))
1888
1898
  e2.stack.push(r2.elements.length);
1889
1899
  else if (u$1(r2)) {
1890
- const s2 = e2.heap.get(r2.id);
1891
- if (!s2 || s2.type !== "array")
1900
+ const o2 = e2.heap.get(r2.id);
1901
+ if (!o2 || o2.type !== "array")
1892
1902
  return {
1893
1903
  type: "RuntimeError",
1894
1904
  message: "Invalid array reference",
1895
1905
  pc: e2.pc,
1896
1906
  opcode: t$1.op
1897
1907
  };
1898
- const o2 = s2.data;
1899
- e2.stack.push(o2.elements.length);
1908
+ const s2 = o2.data;
1909
+ e2.stack.push(s2.elements.length);
1900
1910
  } else
1901
1911
  return {
1902
1912
  type: "RuntimeError",
@@ -1920,8 +1930,8 @@ const ae = {
1920
1930
  opcode: t$1.op
1921
1931
  };
1922
1932
  try {
1923
- const s2 = JSON.parse(r2);
1924
- e2.stack.push(L(s2, e2.heap));
1933
+ const o2 = JSON.parse(r2);
1934
+ e2.stack.push(M(o2, e2.heap));
1925
1935
  } catch {
1926
1936
  e2.stack.push(null);
1927
1937
  }
@@ -1936,7 +1946,7 @@ const ae = {
1936
1946
  e2.stack.push(d$2(r2));
1937
1947
  }
1938
1948
  }
1939
- }, ie = {
1949
+ }, ue = {
1940
1950
  [i$2.INC]: {
1941
1951
  stackIn: 1,
1942
1952
  stackOut: 1,
@@ -1949,10 +1959,10 @@ const ae = {
1949
1959
  pc: e2.pc,
1950
1960
  opcode: t2.op
1951
1961
  };
1952
- const s2 = e2.variables.get(r2) ?? 0, o2 = m(s2) + 1;
1953
- e2.variables.set(r2, o2);
1962
+ const o2 = e2.variables.get(r2) ?? 0, s2 = m(o2) + 1;
1963
+ e2.variables.set(r2, s2);
1954
1964
  const c2 = t2.arg === true;
1955
- e2.stack.push(c2 ? m(s2) : o2);
1965
+ e2.stack.push(c2 ? m(o2) : s2);
1956
1966
  }
1957
1967
  },
1958
1968
  [i$2.DEC]: {
@@ -1967,13 +1977,13 @@ const ae = {
1967
1977
  pc: e2.pc,
1968
1978
  opcode: t2.op
1969
1979
  };
1970
- const s2 = e2.variables.get(r2) ?? 0, o2 = m(s2) - 1;
1971
- e2.variables.set(r2, o2);
1980
+ const o2 = e2.variables.get(r2) ?? 0, s2 = m(o2) - 1;
1981
+ e2.variables.set(r2, s2);
1972
1982
  const c2 = t2.arg === true;
1973
- e2.stack.push(c2 ? m(s2) : o2);
1983
+ e2.stack.push(c2 ? m(o2) : s2);
1974
1984
  }
1975
1985
  }
1976
- }, ue = {
1986
+ }, ie = {
1977
1987
  [i$2.RETURN]: {
1978
1988
  stackIn: 0,
1979
1989
  stackOut: 0,
@@ -2041,9 +2051,9 @@ const ae = {
2041
2051
  pc: e2.pc,
2042
2052
  opcode: t$1.op
2043
2053
  };
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))
2054
+ let r2, o$12 = {};
2055
+ const s2 = e2.stack[e2.stack.length - 1];
2056
+ if (e2.stack.length >= 2 && typeof s2 == "object" && s2 !== null && !o(s2) && (o$12 = e2.stack.pop()), r2 = e2.stack.pop(), !t(r2))
2047
2057
  return {
2048
2058
  type: "RuntimeError",
2049
2059
  message: "FS_LIST_FILES requires a string path",
@@ -2057,7 +2067,7 @@ const ae = {
2057
2067
  pc: e2.pc,
2058
2068
  opcode: t$1.op
2059
2069
  };
2060
- const c2 = e2.fileSystem.listFiles(r2, s2);
2070
+ const c2 = e2.fileSystem.listFiles(r2, o$12);
2061
2071
  if (o(c2)) {
2062
2072
  const p2 = e2.heap.allocate("array", c2);
2063
2073
  e2.stack.push(p2);
@@ -2086,8 +2096,8 @@ const ae = {
2086
2096
  pc: e2.pc,
2087
2097
  opcode: t$1.op
2088
2098
  };
2089
- const s2 = e2.fileSystem.readFile(r2);
2090
- e2.stack.push(s2);
2099
+ const o2 = e2.fileSystem.readFile(r2);
2100
+ e2.stack.push(o2);
2091
2101
  }
2092
2102
  },
2093
2103
  [i$2.FS_WRITE_FILE]: {
@@ -2096,8 +2106,8 @@ const ae = {
2096
2106
  stackOut: 1,
2097
2107
  // Returns boolean
2098
2108
  execute: (e2, t$1) => {
2099
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2100
- if (!s2 || !t(s2))
2109
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2110
+ if (!o2 || !t(o2))
2101
2111
  return {
2102
2112
  type: "RuntimeError",
2103
2113
  message: "FS_WRITE_FILE requires a string path",
@@ -2118,7 +2128,7 @@ const ae = {
2118
2128
  pc: e2.pc,
2119
2129
  opcode: t$1.op
2120
2130
  };
2121
- const o2 = p$1(r2), c2 = e2.fileSystem.writeFile(s2, o2);
2131
+ const s2 = p$1(r2), c2 = e2.fileSystem.writeFile(o2, s2);
2122
2132
  e2.stack.push(c2);
2123
2133
  }
2124
2134
  },
@@ -2136,58 +2146,58 @@ const ae = {
2136
2146
  opcode: t$1.op
2137
2147
  };
2138
2148
  const r2 = e2.stack.length;
2139
- let s2, o2, c2;
2149
+ let o2, s2, c2;
2140
2150
  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))
2151
+ 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
2152
  return {
2143
2153
  type: "RuntimeError",
2144
2154
  message: "STRING_SUBSTRING requires a string",
2145
2155
  pc: e2.pc,
2146
2156
  opcode: t$1.op
2147
2157
  };
2148
- if (typeof o2 != "number")
2158
+ if (typeof s2 != "number")
2149
2159
  return {
2150
2160
  type: "RuntimeError",
2151
2161
  message: "STRING_SUBSTRING requires numeric start index",
2152
2162
  pc: e2.pc,
2153
2163
  opcode: t$1.op
2154
2164
  };
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);
2158
- e2.stack.push(u2);
2165
+ const u2 = o2.length;
2166
+ s2 < 0 && (s2 = Math.max(0, u2 + s2)), c2 !== void 0 && c2 < 0 && (c2 = Math.max(0, u2 + c2));
2167
+ const i2 = c2 !== void 0 ? o2.substring(s2, c2) : o2.substring(s2);
2168
+ e2.stack.push(i2);
2159
2169
  }
2160
2170
  },
2161
2171
  [i$2.STRING_INDEXOF]: {
2162
2172
  stackIn: 2,
2163
2173
  stackOut: 1,
2164
2174
  execute: (e2, t$1) => {
2165
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2166
- if (!t(s2) || !t(r2))
2175
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2176
+ if (!t(o2) || !t(r2))
2167
2177
  return {
2168
2178
  type: "RuntimeError",
2169
2179
  message: "STRING_INDEXOF requires string arguments",
2170
2180
  pc: e2.pc,
2171
2181
  opcode: t$1.op
2172
2182
  };
2173
- e2.stack.push(s2.indexOf(r2));
2183
+ e2.stack.push(o2.indexOf(r2));
2174
2184
  }
2175
2185
  },
2176
2186
  [i$2.STRING_SPLIT]: {
2177
2187
  stackIn: 2,
2178
2188
  stackOut: 1,
2179
2189
  execute: (e2, t$1) => {
2180
- const r2 = e2.stack.pop(), s$12 = e2.stack.pop();
2181
- if (!t(s$12) || !t(r2))
2190
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2191
+ if (!t(o2) || !t(r2))
2182
2192
  return {
2183
2193
  type: "RuntimeError",
2184
2194
  message: "STRING_SPLIT requires string arguments",
2185
2195
  pc: e2.pc,
2186
2196
  opcode: t$1.op
2187
2197
  };
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);
2198
+ let s$12;
2199
+ r2 === "" ? s$12 = o2.split("") : s$12 = o2.split(r2);
2200
+ const c2 = s(s$12), p2 = e2.heap.allocate("array", c2);
2191
2201
  e2.stack.push(p2);
2192
2202
  }
2193
2203
  },
@@ -2204,32 +2214,32 @@ const ae = {
2204
2214
  opcode: t$1.op
2205
2215
  };
2206
2216
  const r2 = e2.stack.length;
2207
- let s2, o2, c2;
2217
+ let o2, s2, c2;
2208
2218
  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))
2219
+ 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
2220
  return {
2211
2221
  type: "RuntimeError",
2212
2222
  message: "STRING_SLICE requires a string",
2213
2223
  pc: e2.pc,
2214
2224
  opcode: t$1.op
2215
2225
  };
2216
- if (typeof o2 != "number")
2226
+ if (typeof s2 != "number")
2217
2227
  return {
2218
2228
  type: "RuntimeError",
2219
2229
  message: "STRING_SLICE requires numeric start index",
2220
2230
  pc: e2.pc,
2221
2231
  opcode: t$1.op
2222
2232
  };
2223
- const i2 = c2 !== void 0 ? s2.slice(o2, c2) : s2.slice(o2);
2224
- e2.stack.push(i2);
2233
+ const u2 = c2 !== void 0 ? o2.slice(s2, c2) : o2.slice(s2);
2234
+ e2.stack.push(u2);
2225
2235
  }
2226
2236
  },
2227
2237
  [i$2.STRING_CHARAT]: {
2228
2238
  stackIn: 2,
2229
2239
  stackOut: 1,
2230
2240
  execute: (e2, t$1) => {
2231
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2232
- if (!t(s2))
2241
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2242
+ if (!t(o2))
2233
2243
  return {
2234
2244
  type: "RuntimeError",
2235
2245
  message: "STRING_CHARAT requires a string",
@@ -2243,8 +2253,8 @@ const ae = {
2243
2253
  pc: e2.pc,
2244
2254
  opcode: t$1.op
2245
2255
  };
2246
- const o2 = s2.charAt(r2);
2247
- e2.stack.push(o2);
2256
+ const s2 = o2.charAt(r2);
2257
+ e2.stack.push(s2);
2248
2258
  }
2249
2259
  },
2250
2260
  [i$2.STRING_TOUPPERCASE]: {
@@ -2289,8 +2299,8 @@ const ae = {
2289
2299
  pc: e2.pc,
2290
2300
  opcode: t2.op
2291
2301
  };
2292
- const s2 = p$1(r2);
2293
- e2.stack.push(s2);
2302
+ const o2 = p$1(r2);
2303
+ e2.stack.push(o2);
2294
2304
  }
2295
2305
  },
2296
2306
  [i$2.STRING_INCLUDES]: {
@@ -2299,48 +2309,48 @@ const ae = {
2299
2309
  stackOut: 1,
2300
2310
  // boolean
2301
2311
  execute: (e2, t$1) => {
2302
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2303
- if (!t(s2))
2312
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2313
+ if (!t(o2))
2304
2314
  return {
2305
2315
  type: "RuntimeError",
2306
2316
  message: "STRING_INCLUDES requires a string",
2307
2317
  pc: e2.pc,
2308
2318
  opcode: t$1.op
2309
2319
  };
2310
- const o2 = String(r2);
2311
- e2.stack.push(s2.includes(o2));
2320
+ const s2 = String(r2);
2321
+ e2.stack.push(o2.includes(s2));
2312
2322
  }
2313
2323
  },
2314
2324
  [i$2.STRING_ENDS_WITH]: {
2315
2325
  stackIn: 2,
2316
2326
  stackOut: 1,
2317
2327
  execute: (e2, t$1) => {
2318
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2319
- if (!t(s2))
2328
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2329
+ if (!t(o2))
2320
2330
  return {
2321
2331
  type: "RuntimeError",
2322
2332
  message: "STRING_ENDS_WITH requires a string",
2323
2333
  pc: e2.pc,
2324
2334
  opcode: t$1.op
2325
2335
  };
2326
- const o2 = String(r2);
2327
- e2.stack.push(s2.endsWith(o2));
2336
+ const s2 = String(r2);
2337
+ e2.stack.push(o2.endsWith(s2));
2328
2338
  }
2329
2339
  },
2330
2340
  [i$2.STRING_STARTS_WITH]: {
2331
2341
  stackIn: 2,
2332
2342
  stackOut: 1,
2333
2343
  execute: (e2, t$1) => {
2334
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2335
- if (!t(s2))
2344
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2345
+ if (!t(o2))
2336
2346
  return {
2337
2347
  type: "RuntimeError",
2338
2348
  message: "STRING_STARTS_WITH requires a string",
2339
2349
  pc: e2.pc,
2340
2350
  opcode: t$1.op
2341
2351
  };
2342
- const o2 = String(r2);
2343
- e2.stack.push(s2.startsWith(o2));
2352
+ const s2 = String(r2);
2353
+ e2.stack.push(o2.startsWith(s2));
2344
2354
  }
2345
2355
  },
2346
2356
  [i$2.STRING_TRIM]: {
@@ -2393,31 +2403,31 @@ const ae = {
2393
2403
  // string, search, replacement
2394
2404
  stackOut: 1,
2395
2405
  execute: (e2, t$1) => {
2396
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop();
2397
- if (!t(o2))
2406
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2407
+ if (!t(s2))
2398
2408
  return {
2399
2409
  type: "RuntimeError",
2400
2410
  message: "STRING_REPLACE requires a string",
2401
2411
  pc: e2.pc,
2402
2412
  opcode: t$1.op
2403
2413
  };
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);
2405
- e2.stack.push(i2);
2414
+ const c2 = String(o2), p2 = String(r2), a2 = s2.indexOf(c2), u2 = a2 === -1 ? s2 : s2.substring(0, a2) + p2 + s2.substring(a2 + c2.length);
2415
+ e2.stack.push(u2);
2406
2416
  }
2407
2417
  },
2408
2418
  [i$2.STRING_REPLACE_ALL]: {
2409
2419
  stackIn: 3,
2410
2420
  stackOut: 1,
2411
2421
  execute: (e2, t$1) => {
2412
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop();
2413
- if (!t(o2))
2422
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2423
+ if (!t(s2))
2414
2424
  return {
2415
2425
  type: "RuntimeError",
2416
2426
  message: "STRING_REPLACE_ALL requires a string",
2417
2427
  pc: e2.pc,
2418
2428
  opcode: t$1.op
2419
2429
  };
2420
- const c2 = String(s2), p2 = String(r2), a2 = o2.split(c2).join(p2);
2430
+ const c2 = String(o2), p2 = String(r2), a2 = s2.split(c2).join(p2);
2421
2431
  e2.stack.push(a2);
2422
2432
  }
2423
2433
  },
@@ -2425,24 +2435,24 @@ const ae = {
2425
2435
  stackIn: 2,
2426
2436
  stackOut: 1,
2427
2437
  execute: (e2, t$1) => {
2428
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2429
- if (!t(s2))
2438
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2439
+ if (!t(o2))
2430
2440
  return {
2431
2441
  type: "RuntimeError",
2432
2442
  message: "STRING_LAST_INDEX_OF requires a string",
2433
2443
  pc: e2.pc,
2434
2444
  opcode: t$1.op
2435
2445
  };
2436
- const o2 = String(r2);
2437
- e2.stack.push(s2.lastIndexOf(o2));
2446
+ const s2 = String(r2);
2447
+ e2.stack.push(o2.lastIndexOf(s2));
2438
2448
  }
2439
2449
  },
2440
2450
  [i$2.STRING_REPEAT]: {
2441
2451
  stackIn: 2,
2442
2452
  stackOut: 1,
2443
2453
  execute: (e2, t$1) => {
2444
- const r2 = e2.stack.pop(), s2 = e2.stack.pop();
2445
- if (!t(s2))
2454
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2455
+ if (!t(o2))
2446
2456
  return {
2447
2457
  type: "RuntimeError",
2448
2458
  message: "STRING_REPEAT requires a string",
@@ -2456,7 +2466,7 @@ const ae = {
2456
2466
  pc: e2.pc,
2457
2467
  opcode: t$1.op
2458
2468
  };
2459
- e2.stack.push(s2.repeat(Math.floor(r2)));
2469
+ e2.stack.push(o2.repeat(Math.floor(r2)));
2460
2470
  }
2461
2471
  },
2462
2472
  [i$2.STRING_PAD_START]: {
@@ -2464,15 +2474,15 @@ const ae = {
2464
2474
  // string, targetLength, padString
2465
2475
  stackOut: 1,
2466
2476
  execute: (e2, t$1) => {
2467
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop();
2468
- if (!t(o2))
2477
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2478
+ if (!t(s2))
2469
2479
  return {
2470
2480
  type: "RuntimeError",
2471
2481
  message: "STRING_PAD_START requires a string",
2472
2482
  pc: e2.pc,
2473
2483
  opcode: t$1.op
2474
2484
  };
2475
- if (!i$1(s2))
2485
+ if (!i$1(o2))
2476
2486
  return {
2477
2487
  type: "RuntimeError",
2478
2488
  message: "STRING_PAD_START requires number for length",
@@ -2480,22 +2490,22 @@ const ae = {
2480
2490
  opcode: t$1.op
2481
2491
  };
2482
2492
  const c2 = t(r2) ? r2 : String(r2);
2483
- e2.stack.push(o2.padStart(s2, c2 || " "));
2493
+ e2.stack.push(s2.padStart(o2, c2 || " "));
2484
2494
  }
2485
2495
  },
2486
2496
  [i$2.STRING_PAD_END]: {
2487
2497
  stackIn: 3,
2488
2498
  stackOut: 1,
2489
2499
  execute: (e2, t$1) => {
2490
- const r2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop();
2491
- if (!t(o2))
2500
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2501
+ if (!t(s2))
2492
2502
  return {
2493
2503
  type: "RuntimeError",
2494
2504
  message: "STRING_PAD_END requires a string",
2495
2505
  pc: e2.pc,
2496
2506
  opcode: t$1.op
2497
2507
  };
2498
- if (!i$1(s2))
2508
+ if (!i$1(o2))
2499
2509
  return {
2500
2510
  type: "RuntimeError",
2501
2511
  message: "STRING_PAD_END requires number for length",
@@ -2503,31 +2513,31 @@ const ae = {
2503
2513
  opcode: t$1.op
2504
2514
  };
2505
2515
  const c2 = t(r2) ? r2 : String(r2);
2506
- e2.stack.push(o2.padEnd(s2, c2 || " "));
2516
+ e2.stack.push(s2.padEnd(o2, c2 || " "));
2507
2517
  }
2508
2518
  }
2509
2519
  };
2510
- function j(e2, t2) {
2520
+ function A(e2, t2) {
2511
2521
  if (u$1(e2)) {
2512
2522
  const r2 = t2.get(e2.id);
2513
- return r2 && r2.type === "array" ? r2.data.elements.map((o2) => j(o2, t2)) : null;
2523
+ return r2 && r2.type === "array" ? r2.data.elements.map((s2) => A(s2, t2)) : null;
2514
2524
  }
2515
2525
  if (b(e2)) {
2516
2526
  const r2 = t2.get(e2.id);
2517
2527
  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;
2528
+ const o2 = r2.data, s2 = {};
2529
+ for (const [c2, p2] of Object.entries(o2.properties))
2530
+ s2[c2] = A(p2, t2);
2531
+ return s2;
2522
2532
  }
2523
2533
  return null;
2524
2534
  }
2525
2535
  if (o(e2))
2526
- return e2.elements.map((r2) => j(r2, t2));
2536
+ return e2.elements.map((r2) => A(r2, t2));
2527
2537
  if (y(e2)) {
2528
2538
  const r2 = {};
2529
- for (const [s2, o2] of Object.entries(e2.properties))
2530
- r2[s2] = j(o2, t2);
2539
+ for (const [o2, s2] of Object.entries(e2.properties))
2540
+ r2[o2] = A(s2, t2);
2531
2541
  return r2;
2532
2542
  }
2533
2543
  if (!c(e2))
@@ -2538,7 +2548,7 @@ const le = {
2538
2548
  stackIn: 0,
2539
2549
  stackOut: 1,
2540
2550
  execute: (e2) => {
2541
- const t2 = M(), r2 = e2.heap.allocate("object", t2);
2551
+ const t2 = M$1(), r2 = e2.heap.allocate("object", t2);
2542
2552
  e2.stack.push(r2);
2543
2553
  }
2544
2554
  },
@@ -2548,13 +2558,13 @@ const le = {
2548
2558
  execute: (e2, t2) => {
2549
2559
  const r2 = d(e2, t2.op);
2550
2560
  if (f2(r2)) return r2;
2551
- const s2 = d(e2, t2.op);
2552
- if (f2(s2)) return s2;
2553
2561
  const o2 = d(e2, t2.op);
2554
2562
  if (f2(o2)) return o2;
2563
+ const s2 = d(e2, t2.op);
2564
+ if (f2(s2)) return s2;
2555
2565
  let c2;
2556
- if (b(o2)) {
2557
- const a2 = e2.heap.get(o2.id);
2566
+ if (b(s2)) {
2567
+ const a2 = e2.heap.get(s2.id);
2558
2568
  if (!a2 || a2.type !== "object")
2559
2569
  return {
2560
2570
  type: "RuntimeError",
@@ -2563,17 +2573,17 @@ const le = {
2563
2573
  opcode: t2.op
2564
2574
  };
2565
2575
  c2 = a2.data;
2566
- } else if (y(o2))
2567
- c2 = o2;
2576
+ } else if (y(s2))
2577
+ c2 = s2;
2568
2578
  else
2569
2579
  return {
2570
2580
  type: "RuntimeError",
2571
- message: `Cannot set property '${s2}' on ${d$2(o2)}`,
2581
+ message: `Cannot set property '${o2}' on ${d$2(s2)}`,
2572
2582
  pc: e2.pc,
2573
2583
  opcode: t2.op
2574
2584
  };
2575
- const p2 = p$1(s2);
2576
- c2.properties[p2] = r2, e2.stack.push(o2);
2585
+ const p2 = p$1(o2);
2586
+ c2.properties[p2] = r2, e2.stack.push(s2);
2577
2587
  }
2578
2588
  },
2579
2589
  [i$2.PROPERTY_GET]: {
@@ -2582,18 +2592,18 @@ const le = {
2582
2592
  execute: (e2, t2) => {
2583
2593
  const r2 = d(e2, t2.op);
2584
2594
  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))
2595
+ const o2 = d(e2, t2.op);
2596
+ if (f2(o2)) return o2;
2597
+ if (f$2(o2) || c(o2))
2588
2598
  return {
2589
2599
  type: "RuntimeError",
2590
- message: `Cannot read property '${r2}' of ${d$2(s2)}`,
2600
+ message: `Cannot read property '${r2}' of ${d$2(o2)}`,
2591
2601
  pc: e2.pc,
2592
2602
  opcode: t2.op
2593
2603
  };
2594
- let o2 = null;
2595
- if (b(s2)) {
2596
- const p2 = e2.heap.get(s2.id);
2604
+ let s2 = null;
2605
+ if (b(o2)) {
2606
+ const p2 = e2.heap.get(o2.id);
2597
2607
  if (!p2 || p2.type !== "object")
2598
2608
  return {
2599
2609
  type: "RuntimeError",
@@ -2601,14 +2611,14 @@ const le = {
2601
2611
  pc: e2.pc,
2602
2612
  opcode: t2.op
2603
2613
  };
2604
- o2 = p2.data;
2605
- } else if (y(s2))
2606
- o2 = s2;
2614
+ s2 = p2.data;
2615
+ } else if (y(o2))
2616
+ s2 = o2;
2607
2617
  else {
2608
2618
  e2.stack.push(C$1());
2609
2619
  return;
2610
2620
  }
2611
- const c$1 = o2.properties[p$1(r2)];
2621
+ const c$1 = s2.properties[p$1(r2)];
2612
2622
  e2.stack.push(c$1 ?? C$1());
2613
2623
  }
2614
2624
  },
@@ -2618,8 +2628,8 @@ const le = {
2618
2628
  execute: (e2, t2) => {
2619
2629
  const r2 = d(e2, t2.op);
2620
2630
  if (f2(r2)) return r2;
2621
- const s2 = j(r2, e2.heap);
2622
- e2.stack.push(JSON.stringify(s2));
2631
+ const o2 = A(r2, e2.heap);
2632
+ e2.stack.push(JSON.stringify(o2));
2623
2633
  }
2624
2634
  },
2625
2635
  [i$2.OBJECT_KEYS]: {
@@ -2629,15 +2639,15 @@ const le = {
2629
2639
  const r2 = d(e2, t2.op);
2630
2640
  if (f2(r2)) return r2;
2631
2641
  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 });
2642
+ const o2 = e2.heap.get(r2.id);
2643
+ if (o2 && o2.type === "object") {
2644
+ const s2 = o2.data, c2 = Object.keys(s2.properties), p2 = e2.heap.allocate("array", { type: "array", elements: c2 });
2635
2645
  e2.stack.push(p2);
2636
2646
  } else
2637
2647
  e2.stack.push(null);
2638
2648
  } 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);
2649
+ const o2 = Object.keys(r2.properties), s2 = e2.heap.allocate("array", { type: "array", elements: o2 });
2650
+ e2.stack.push(s2);
2641
2651
  } else
2642
2652
  e2.stack.push(null);
2643
2653
  }
@@ -2650,9 +2660,9 @@ const le = {
2650
2660
  const r2 = d(e2, t2.op);
2651
2661
  if (f2(r2)) return r2;
2652
2662
  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);
2663
+ const o2 = e2.heap.get(r2.id);
2664
+ if (o2 && o2.type === "object") {
2665
+ const s2 = o2.data, c2 = Object.keys(s2.properties);
2656
2666
  e2.iterators.push({
2657
2667
  array: null,
2658
2668
  keys: c2,
@@ -2667,12 +2677,12 @@ const le = {
2667
2677
  length: 0
2668
2678
  });
2669
2679
  } else if (y(r2)) {
2670
- const s2 = Object.keys(r2.properties);
2680
+ const o2 = Object.keys(r2.properties);
2671
2681
  e2.iterators.push({
2672
2682
  array: null,
2673
- keys: s2,
2683
+ keys: o2,
2674
2684
  index: 0,
2675
- length: s2.length
2685
+ length: o2.length
2676
2686
  });
2677
2687
  } else
2678
2688
  e2.iterators.push({
@@ -2690,8 +2700,8 @@ const le = {
2690
2700
  execute: (e2, t2) => {
2691
2701
  const r2 = e2.iterators[e2.iterators.length - 1];
2692
2702
  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++;
2703
+ const o2 = r2.keys[r2.index];
2704
+ e2.stack.push(o2), e2.stack.push(true), r2.index++;
2695
2705
  } else
2696
2706
  e2.stack.push(null), e2.stack.push(false);
2697
2707
  }
@@ -2701,10 +2711,10 @@ const le = {
2701
2711
  stackIn: 2,
2702
2712
  stackOut: 1,
2703
2713
  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);
2714
+ var s2;
2715
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2716
+ if (u$1(o2)) {
2717
+ const c2 = e2.heap.get(o2.id);
2708
2718
  if (!c2 || c2.type !== "array")
2709
2719
  return {
2710
2720
  type: "RuntimeError",
@@ -2717,11 +2727,11 @@ const le = {
2717
2727
  if (i$1(r2))
2718
2728
  a2 = r2;
2719
2729
  else if (t(r2)) {
2720
- const u2 = parseInt(r2, 10);
2721
- if (!isNaN(u2) && u2.toString() === r2 && u2 >= 0)
2722
- a2 = u2;
2730
+ const i2 = parseInt(r2, 10);
2731
+ if (!isNaN(i2) && i2.toString() === r2 && i2 >= 0)
2732
+ a2 = i2;
2723
2733
  else {
2724
- const y2 = ((o2 = p2.properties) == null ? void 0 : o2[r2]) ?? C$1();
2734
+ const y2 = ((s2 = p2.properties) == null ? void 0 : s2[r2]) ?? C$1();
2725
2735
  e2.stack.push(y2);
2726
2736
  return;
2727
2737
  }
@@ -2732,11 +2742,11 @@ const le = {
2732
2742
  pc: e2.pc,
2733
2743
  opcode: t$1.op
2734
2744
  };
2735
- const i2 = p2.elements[a2] ?? C$1();
2736
- e2.stack.push(i2);
2745
+ const u2 = p2.elements[a2] ?? C$1();
2746
+ e2.stack.push(u2);
2737
2747
  return;
2738
- } else if (b(s2)) {
2739
- const c2 = e2.heap.get(s2.id);
2748
+ } else if (b(o2)) {
2749
+ const c2 = e2.heap.get(o2.id);
2740
2750
  if (!c2 || c2.type !== "object")
2741
2751
  return {
2742
2752
  type: "RuntimeError",
@@ -2744,10 +2754,10 @@ const le = {
2744
2754
  pc: e2.pc,
2745
2755
  opcode: t$1.op
2746
2756
  };
2747
- const p2 = c2.data, a2 = p$1(r2), i2 = p2.properties[a2] ?? C$1();
2748
- e2.stack.push(i2);
2757
+ const p2 = c2.data, a2 = p$1(r2), u2 = p2.properties[a2] ?? C$1();
2758
+ e2.stack.push(u2);
2749
2759
  return;
2750
- } else if (t(s2)) {
2760
+ } else if (t(o2)) {
2751
2761
  let c2;
2752
2762
  if (i$1(r2))
2753
2763
  c2 = r2;
@@ -2755,7 +2765,7 @@ const le = {
2755
2765
  const p2 = parseInt(r2, 10);
2756
2766
  !isNaN(p2) && p2.toString() === r2 && (c2 = p2);
2757
2767
  }
2758
- c2 !== void 0 && c2 >= 0 && c2 < s2.length ? e2.stack.push(s2[c2]) : e2.stack.push(C$1());
2768
+ c2 !== void 0 && c2 >= 0 && c2 < o2.length ? e2.stack.push(o2[c2]) : e2.stack.push(C$1());
2759
2769
  return;
2760
2770
  } else
2761
2771
  return {
@@ -2770,9 +2780,9 @@ const le = {
2770
2780
  stackIn: 3,
2771
2781
  stackOut: 1,
2772
2782
  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);
2783
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2784
+ if (u$1(s2)) {
2785
+ const c2 = e2.heap.get(s2.id);
2776
2786
  if (!c2 || c2.type !== "array")
2777
2787
  return {
2778
2788
  type: "RuntimeError",
@@ -2782,14 +2792,14 @@ const le = {
2782
2792
  };
2783
2793
  const p2 = c2.data;
2784
2794
  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)
2790
- a2 = u2;
2795
+ if (i$1(o2))
2796
+ a2 = o2;
2797
+ else if (t(o2)) {
2798
+ const i2 = parseInt(o2, 10);
2799
+ if (!isNaN(i2) && i2.toString() === o2 && i2 >= 0)
2800
+ a2 = i2;
2791
2801
  else {
2792
- p2.properties || (p2.properties = {}), p2.properties[s2] = r2, e2.stack.push(o2);
2802
+ p2.properties || (p2.properties = {}), p2.properties[o2] = r2, e2.stack.push(s2);
2793
2803
  return;
2794
2804
  }
2795
2805
  } else
@@ -2799,18 +2809,18 @@ const le = {
2799
2809
  pc: e2.pc,
2800
2810
  opcode: t$1.op
2801
2811
  };
2802
- const i2 = Math.floor(a2);
2803
- if (i2 < 0)
2812
+ const u2 = Math.floor(a2);
2813
+ if (u2 < 0)
2804
2814
  return {
2805
2815
  type: "RuntimeError",
2806
2816
  message: "SET: Negative index not allowed",
2807
2817
  pc: e2.pc,
2808
2818
  opcode: t$1.op
2809
2819
  };
2810
- p2.elements[i2] = r2, e2.stack.push(o2);
2820
+ p2.elements[u2] = r2, e2.stack.push(s2);
2811
2821
  return;
2812
- } else if (b(o2)) {
2813
- const c2 = e2.heap.get(o2.id);
2822
+ } else if (b(s2)) {
2823
+ const c2 = e2.heap.get(s2.id);
2814
2824
  if (!c2 || c2.type !== "object")
2815
2825
  return {
2816
2826
  type: "RuntimeError",
@@ -2818,8 +2828,8 @@ const le = {
2818
2828
  pc: e2.pc,
2819
2829
  opcode: t$1.op
2820
2830
  };
2821
- const p2 = c2.data, a2 = p$1(s2);
2822
- p2.properties[a2] = r2, e2.stack.push(o2);
2831
+ const p2 = c2.data, a2 = p$1(o2);
2832
+ p2.properties[a2] = r2, e2.stack.push(s2);
2823
2833
  return;
2824
2834
  } else
2825
2835
  return {
@@ -2830,7 +2840,7 @@ const le = {
2830
2840
  };
2831
2841
  }
2832
2842
  }
2833
- }, ke = {
2843
+ }, ge = {
2834
2844
  stackIn: 0,
2835
2845
  // Consumes no stack items
2836
2846
  stackOut: 1,
@@ -2845,46 +2855,226 @@ const le = {
2845
2855
  opcode: t2.op
2846
2856
  };
2847
2857
  try {
2848
- const s2 = new RegExp(r2.pattern, r2.flags), o2 = {
2858
+ const o2 = new RegExp(r2.pattern, r2.flags), s2 = {
2849
2859
  type: "object",
2850
2860
  properties: {
2851
- source: s2.source,
2852
- flags: s2.flags,
2853
- global: s2.global,
2854
- ignoreCase: s2.ignoreCase,
2855
- multiline: s2.multiline
2861
+ source: o2.source,
2862
+ flags: o2.flags,
2863
+ global: o2.global,
2864
+ ignoreCase: o2.ignoreCase,
2865
+ multiline: o2.multiline
2856
2866
  }
2857
- }, c2 = e2.heap.allocate("object", o2);
2867
+ }, c2 = e2.heap.allocate("object", s2);
2858
2868
  e2.stack.push(c2);
2859
2869
  return;
2860
- } catch (s2) {
2870
+ } catch (o2) {
2861
2871
  return {
2862
2872
  type: "SyntaxError",
2863
- message: `Invalid regular expression: ${s2.message}`,
2873
+ message: `Invalid regular expression: ${o2.message}`,
2864
2874
  pc: e2.pc,
2865
2875
  opcode: t2.op
2866
2876
  };
2867
2877
  }
2868
2878
  }
2869
2879
  }, me = {
2870
- [i$2.LOAD_REGEX]: ke
2880
+ stackIn: 2,
2881
+ // Consumes regex reference and string
2882
+ stackOut: 1,
2883
+ // Produces boolean result
2884
+ execute: (e2, t2) => {
2885
+ const r2 = d(e2, t2.op);
2886
+ if (f2(r2)) return r2;
2887
+ const o2 = d(e2, t2.op);
2888
+ if (f2(o2)) return o2;
2889
+ if (typeof r2 != "string")
2890
+ return {
2891
+ type: "TypeError",
2892
+ message: `Expected string argument for regex test, got ${typeof r2}`,
2893
+ pc: e2.pc,
2894
+ opcode: t2.op
2895
+ };
2896
+ if (!b(o2))
2897
+ return {
2898
+ type: "TypeError",
2899
+ message: "Expected regex object for regex test",
2900
+ pc: e2.pc,
2901
+ opcode: t2.op
2902
+ };
2903
+ const s2 = e2.heap.get(o2.id);
2904
+ if (!s2 || s2.type !== "object")
2905
+ return {
2906
+ type: "TypeError",
2907
+ message: "Invalid regex object reference",
2908
+ pc: e2.pc,
2909
+ opcode: t2.op
2910
+ };
2911
+ try {
2912
+ const c2 = s2.data, p2 = c2.properties.source, a2 = c2.properties.flags;
2913
+ if (typeof p2 != "string" || typeof a2 != "string")
2914
+ return {
2915
+ type: "TypeError",
2916
+ message: "Invalid regex object structure",
2917
+ pc: e2.pc,
2918
+ opcode: t2.op
2919
+ };
2920
+ const i2 = new RegExp(p2, a2).test(r2);
2921
+ e2.stack.push(i2);
2922
+ return;
2923
+ } catch (c2) {
2924
+ return {
2925
+ type: "RuntimeError",
2926
+ message: `Regex test failed: ${c2.message}`,
2927
+ pc: e2.pc,
2928
+ opcode: t2.op
2929
+ };
2930
+ }
2931
+ }
2932
+ }, ke = {
2933
+ stackIn: 2,
2934
+ // Consumes string and regex reference
2935
+ stackOut: 1,
2936
+ // Produces array reference or null
2937
+ execute: (e2, t2) => {
2938
+ const r2 = d(e2, t2.op);
2939
+ if (f2(r2)) return r2;
2940
+ const o2 = d(e2, t2.op);
2941
+ if (f2(o2)) return o2;
2942
+ if (typeof o2 != "string")
2943
+ return {
2944
+ type: "TypeError",
2945
+ message: `Expected string input for match, got ${typeof o2}`,
2946
+ pc: e2.pc,
2947
+ opcode: t2.op
2948
+ };
2949
+ if (!b(r2))
2950
+ return {
2951
+ type: "TypeError",
2952
+ message: "Expected regex object for match",
2953
+ pc: e2.pc,
2954
+ opcode: t2.op
2955
+ };
2956
+ const s2 = e2.heap.get(r2.id);
2957
+ if (!s2 || s2.type !== "object")
2958
+ return {
2959
+ type: "TypeError",
2960
+ message: "Invalid regex object reference",
2961
+ pc: e2.pc,
2962
+ opcode: t2.op
2963
+ };
2964
+ try {
2965
+ const c2 = s2.data, p2 = c2.properties.source, a2 = c2.properties.flags;
2966
+ if (typeof p2 != "string" || typeof a2 != "string")
2967
+ return {
2968
+ type: "TypeError",
2969
+ message: "Invalid regex object structure",
2970
+ pc: e2.pc,
2971
+ opcode: t2.op
2972
+ };
2973
+ const u2 = new RegExp(p2, a2), i2 = o2.match(u2);
2974
+ if (i2 === null)
2975
+ e2.stack.push(null);
2976
+ else {
2977
+ const y2 = {
2978
+ type: "array",
2979
+ elements: [...i2]
2980
+ // Copy all match results
2981
+ }, E2 = e2.heap.allocate("array", y2);
2982
+ e2.stack.push(E2);
2983
+ }
2984
+ return;
2985
+ } catch (c2) {
2986
+ return {
2987
+ type: "RuntimeError",
2988
+ message: `String match failed: ${c2.message}`,
2989
+ pc: e2.pc,
2990
+ opcode: t2.op
2991
+ };
2992
+ }
2993
+ }
2994
+ }, ye = {
2995
+ stackIn: 3,
2996
+ // Consumes string, regex reference, and replacement string
2997
+ stackOut: 1,
2998
+ // Produces new string
2999
+ execute: (e2, t2) => {
3000
+ const r2 = d(e2, t2.op);
3001
+ if (f2(r2)) return r2;
3002
+ const o2 = d(e2, t2.op);
3003
+ if (f2(o2)) return o2;
3004
+ const s2 = d(e2, t2.op);
3005
+ if (f2(s2)) return s2;
3006
+ if (typeof s2 != "string")
3007
+ return {
3008
+ type: "TypeError",
3009
+ message: `Expected string input for replace, got ${typeof s2}`,
3010
+ pc: e2.pc,
3011
+ opcode: t2.op
3012
+ };
3013
+ if (!b(o2))
3014
+ return {
3015
+ type: "TypeError",
3016
+ message: "Expected regex object for replace",
3017
+ pc: e2.pc,
3018
+ opcode: t2.op
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, u2 = p2.properties.flags;
3037
+ if (typeof a2 != "string" || typeof u2 != "string")
3038
+ return {
3039
+ type: "TypeError",
3040
+ message: "Invalid regex object structure",
3041
+ pc: e2.pc,
3042
+ opcode: t2.op
3043
+ };
3044
+ const i2 = new RegExp(a2, u2), y2 = s2.replace(i2, 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
+ [i$2.LOAD_REGEX]: ge,
3058
+ [i$2.REGEX_TEST]: me,
3059
+ [i$2.STRING_MATCH]: ke,
3060
+ [i$2.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,
2881
3071
  ...ae,
2882
- ...ie,
2883
3072
  ...ue,
3073
+ ...ie,
2884
3074
  ...le,
2885
3075
  ...de,
2886
3076
  ...fe,
2887
- ...me
3077
+ ...he
2888
3078
  };
2889
3079
  function w() {
2890
3080
  const e2 = /* @__PURE__ */ new Map();
@@ -2892,14 +3082,14 @@ function w() {
2892
3082
  return {
2893
3083
  objects: e2,
2894
3084
  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 };
3085
+ allocate(r2, o2) {
3086
+ const s2 = t2++, c2 = { id: s2, type: r2, data: o2 };
3087
+ return e2.set(s2, c2), r2 === "array" ? { type: "array-ref", id: s2 } : { type: "object-ref", id: s2 };
2898
3088
  },
2899
3089
  get(r2) {
2900
- const s2 = e2.get(r2);
2901
- if (s2)
2902
- return s2;
3090
+ const o2 = e2.get(r2);
3091
+ if (o2)
3092
+ return o2;
2903
3093
  }
2904
3094
  };
2905
3095
  }
@@ -2916,70 +3106,70 @@ class C {
2916
3106
  };
2917
3107
  }
2918
3108
  executeInstruction(t2, r2) {
2919
- const s2 = F[r2.op];
2920
- if (!s2)
3109
+ const o2 = F[r2.op];
3110
+ if (!o2)
2921
3111
  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;
3112
+ const s2 = this.validateStack(o2, r2, t2);
3113
+ if (s2) {
3114
+ t2.status = "error", t2.error = s2.message;
2925
3115
  return;
2926
3116
  }
2927
- s2.execute(t2, r2), t2.pc++;
3117
+ o2.execute(t2, r2), t2.pc++;
2928
3118
  }
2929
- validateStack(t2, r2, s2) {
2930
- if (s2.stack.length < t2.stackIn)
3119
+ validateStack(t2, r2, o2) {
3120
+ if (o2.stack.length < t2.stackIn)
2931
3121
  return {
2932
3122
  type: "StackUnderflow",
2933
3123
  message: `${i$2[r2.op]}: Stack underflow`,
2934
- pc: s2.pc,
3124
+ pc: o2.pc,
2935
3125
  opcode: r2.op
2936
3126
  };
2937
3127
  }
2938
- execute(t2, r2, s2) {
2939
- const o2 = {
3128
+ execute(t2, r2, o2) {
3129
+ const s2 = {
2940
3130
  pc: (r2 == null ? void 0 : r2.pc) ?? 0,
2941
3131
  stack: (r2 == null ? void 0 : r2.stack) ?? [],
2942
3132
  variables: (r2 == null ? void 0 : r2.variables) ?? /* @__PURE__ */ new Map(),
2943
3133
  status: "running",
2944
3134
  output: (r2 == null ? void 0 : r2.output) ?? [],
2945
3135
  iterators: (r2 == null ? void 0 : r2.iterators) ?? [],
2946
- fileSystem: s2,
3136
+ fileSystem: o2,
2947
3137
  heap: (r2 == null ? void 0 : r2.heap) ?? w(),
2948
3138
  ...r2
2949
3139
  };
2950
- for (; o2.status === "running" && o2.pc < t2.length; ) {
2951
- const c2 = t2[o2.pc], p2 = F[c2.op];
3140
+ for (; s2.status === "running" && s2.pc < t2.length; ) {
3141
+ const c2 = t2[s2.pc], p2 = F[c2.op];
2952
3142
  if (p2) {
2953
- const a2 = this.validateStack(p2, c2, o2);
3143
+ const a2 = this.validateStack(p2, c2, s2);
2954
3144
  if (a2) {
2955
- o2.status = "error", o2.error = a2.message;
3145
+ s2.status = "error", s2.error = a2.message;
2956
3146
  break;
2957
3147
  }
2958
3148
  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}`;
3149
+ s2.status = "error";
3150
+ const i2 = 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";
3151
+ s2.error = `Invalid ${i2} target: ${c2.arg}`;
2962
3152
  break;
2963
3153
  }
2964
- const i2 = p2.execute(o2, c2);
2965
- 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;
3154
+ const u2 = p2.execute(s2, c2);
3155
+ if (u2) {
3156
+ const i2 = s2.pc + 1;
3157
+ if (i2 < t2.length && t2[i2].op === i$2.CC) {
3158
+ s2.ccPrompt = `ERROR: ${u2.message}. How should I proceed?`, s2.status = "waiting_cc", s2.pc = i2;
2969
3159
  break;
2970
3160
  }
2971
- o2.status = "error", o2.error = i2.message;
3161
+ s2.status = "error", s2.error = u2.message;
2972
3162
  break;
2973
3163
  }
2974
- p2.controlsPC || o2.pc++;
3164
+ p2.controlsPC || s2.pc++;
2975
3165
  continue;
2976
3166
  }
2977
- o2.status = "error", o2.error = `Unknown opcode: ${i$2[c2.op]}`;
3167
+ s2.status = "error", s2.error = `Unknown opcode: ${i$2[c2.op]}`;
2978
3168
  break;
2979
3169
  }
2980
- return o2;
3170
+ return s2;
2981
3171
  }
2982
- resume(t2, r2, s2, o2) {
3172
+ resume(t2, r2, o2, s2) {
2983
3173
  if (t2.status !== "waiting_cc")
2984
3174
  throw new Error("Cannot resume: VM not waiting for CC");
2985
3175
  const c2 = {
@@ -2989,47 +3179,47 @@ class C {
2989
3179
  ccPrompt: void 0,
2990
3180
  pc: t2.pc + 1
2991
3181
  };
2992
- return this.execute(s2, c2, o2 || t2.fileSystem);
3182
+ return this.execute(o2, c2, s2 || t2.fileSystem);
2993
3183
  }
2994
3184
  }
2995
3185
  class V {
2996
3186
  constructor() {
2997
3187
  _(this, "sandboxPaths", []);
2998
3188
  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)]);
3189
+ t2 ? this.sandboxPaths = t2.split(",").map((o2) => r__namespace.resolve(o2.trim())) : r2 && (this.sandboxPaths = [r__namespace.resolve(r2)]);
3000
3190
  }
3001
3191
  isPathAllowed(t2) {
3002
3192
  const r2 = r__namespace.resolve(t2);
3003
3193
  return r2.includes("..") || this.sandboxPaths.length === 0 ? false : this.sandboxPaths.some(
3004
- (s2) => r2.startsWith(s2)
3194
+ (o2) => r2.startsWith(o2)
3005
3195
  );
3006
3196
  }
3007
3197
  listFiles(t2, r2 = {}) {
3008
- const s$12 = s();
3198
+ const o2 = s();
3009
3199
  if (!this.isPathAllowed(t2))
3010
- return s$12;
3200
+ return o2;
3011
3201
  try {
3012
- const o2 = r__namespace.resolve(t2);
3013
- this.listFilesRecursive(o2, o2, s$12.elements, r2);
3202
+ const s2 = r__namespace.resolve(t2);
3203
+ this.listFilesRecursive(s2, s2, o2.elements, r2);
3014
3204
  } catch {
3015
3205
  }
3016
- return s$12;
3206
+ return o2;
3017
3207
  }
3018
3208
  matchesPattern(t2, r2) {
3019
- let s2 = r2.replace(/\./g, "\\.").replace(/\*\*/g, "__DOUBLESTAR__").replace(/\*/g, "[^/]*").replace(/__DOUBLESTAR__/g, ".*").replace(/\?/g, ".");
3020
- s2 = "^" + s2 + "$";
3209
+ let o2 = r2.replace(/\./g, "\\.").replace(/\*\*/g, "__DOUBLESTAR__").replace(/\*/g, "[^/]*").replace(/__DOUBLESTAR__/g, ".*").replace(/\?/g, ".");
3210
+ o2 = "^" + o2 + "$";
3021
3211
  try {
3022
- return new RegExp(s2).test(t2);
3212
+ return new RegExp(o2).test(t2);
3023
3213
  } catch {
3024
3214
  return true;
3025
3215
  }
3026
3216
  }
3027
- listFilesRecursive(t2, r2, s2, o2, c2 = 0) {
3217
+ listFilesRecursive(t2, r2, o2, s2, c2 = 0) {
3028
3218
  try {
3029
- const p2 = N__namespace.readdirSync(r2, { withFileTypes: true });
3219
+ const p2 = b__namespace.readdirSync(r2, { withFileTypes: true });
3030
3220
  for (const a2 of p2) {
3031
- 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
+ const u2 = r__namespace.join(r2, a2.name), i2 = r__namespace.relative(t2, u2);
3222
+ a2.isSymbolicLink() || s2.filter && !this.matchesPattern(i2, s2.filter) || (o2.push(u2), a2.isDirectory() && s2.recursive && this.listFilesRecursive(t2, u2, o2, s2, c2 + 1));
3033
3223
  }
3034
3224
  } catch {
3035
3225
  }
@@ -3038,8 +3228,8 @@ class V {
3038
3228
  if (!this.isPathAllowed(t2))
3039
3229
  return null;
3040
3230
  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");
3231
+ const r2 = r__namespace.resolve(t2), o2 = b__namespace.lstatSync(r2);
3232
+ return o2.isSymbolicLink() || !o2.isFile() ? null : b__namespace.readFileSync(r2, "utf-8");
3043
3233
  } catch {
3044
3234
  return null;
3045
3235
  }
@@ -3048,24 +3238,24 @@ class V {
3048
3238
  if (!this.isPathAllowed(t2))
3049
3239
  return false;
3050
3240
  try {
3051
- const s2 = r__namespace.resolve(t2), o2 = r__namespace.dirname(s2);
3052
- if (!this.isPathAllowed(o2))
3241
+ const o2 = r__namespace.resolve(t2), s2 = r__namespace.dirname(o2);
3242
+ if (!this.isPathAllowed(s2))
3053
3243
  return false;
3054
3244
  try {
3055
- if (N__namespace.lstatSync(s2).isSymbolicLink())
3245
+ if (b__namespace.lstatSync(o2).isSymbolicLink())
3056
3246
  return false;
3057
3247
  } catch (c2) {
3058
3248
  if (c2.code !== "ENOENT")
3059
3249
  return false;
3060
3250
  }
3061
- return N__namespace.mkdirSync(o2, { recursive: true }), N__namespace.writeFileSync(s2, r2, "utf-8"), true;
3251
+ return b__namespace.mkdirSync(s2, { recursive: true }), b__namespace.writeFileSync(o2, r2, "utf-8"), true;
3062
3252
  } catch {
3063
3253
  return false;
3064
3254
  }
3065
3255
  }
3066
3256
  }
3067
3257
  new V();
3068
- class Ie {
3258
+ class Se {
3069
3259
  constructor(t2, r2) {
3070
3260
  _(this, "vms", /* @__PURE__ */ new Map());
3071
3261
  _(this, "storage");
@@ -3088,18 +3278,18 @@ class Ie {
3088
3278
  * Load and compile a program from source code
3089
3279
  */
3090
3280
  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 = {
3281
+ const o2 = te$1(r2);
3282
+ if (!o2.success)
3283
+ throw new Error(`Compilation failed: ${o2.errors.join(", ")}`);
3284
+ const s2 = {
3095
3285
  id: t2,
3096
3286
  name: t2,
3097
3287
  source: r2,
3098
- bytecode: s2.bytecode,
3288
+ bytecode: o2.bytecode,
3099
3289
  // VM decides internal format
3100
3290
  created: /* @__PURE__ */ new Date()
3101
3291
  };
3102
- await this.storage.saveProgram(o2);
3292
+ await this.storage.saveProgram(s2);
3103
3293
  }
3104
3294
  /**
3105
3295
  * Start execution of a loaded program
@@ -3107,7 +3297,7 @@ class Ie {
3107
3297
  async startExecution(t2, r2) {
3108
3298
  if (!await this.storage.getProgram(t2))
3109
3299
  throw new Error(`Program not found: ${t2}`);
3110
- const o2 = {
3300
+ const s2 = {
3111
3301
  id: r2,
3112
3302
  programId: t2,
3113
3303
  state: "READY",
@@ -3116,7 +3306,7 @@ class Ie {
3116
3306
  variables: {},
3117
3307
  created: /* @__PURE__ */ new Date()
3118
3308
  };
3119
- await this.storage.saveExecution(o2);
3309
+ await this.storage.saveExecution(s2);
3120
3310
  const c2 = new C();
3121
3311
  this.vms.set(r2, c2);
3122
3312
  }
@@ -3129,17 +3319,17 @@ class Ie {
3129
3319
  if (!r2)
3130
3320
  throw new Error(`Execution not found: ${t2}`);
3131
3321
  if (r2.state === "READY" || r2.state === "RUNNING") {
3132
- const s2 = await this.storage.getProgram(r2.programId);
3133
- if (!s2)
3322
+ const o2 = await this.storage.getProgram(r2.programId);
3323
+ if (!o2)
3134
3324
  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));
3325
+ let s2 = this.vms.get(t2);
3326
+ s2 || (s2 = new C(), this.vms.set(t2, s2));
3137
3327
  const c2 = r2.state === "READY" ? {
3138
3328
  pc: 0,
3139
3329
  stack: [],
3140
3330
  variables: /* @__PURE__ */ new Map(),
3141
3331
  output: []
3142
- } : this.deserializeVMState(r2), p2 = o2.execute(s2.bytecode, c2, this.fileSystem);
3332
+ } : this.deserializeVMState(r2), p2 = s2.execute(o2.bytecode, c2, this.fileSystem);
3143
3333
  p2.output.length > 0 && await this.storage.appendOutput(t2, p2.output);
3144
3334
  const a2 = this.serializeVMState(p2);
3145
3335
  if (Object.assign(r2, a2), p2.status === "complete")
@@ -3180,24 +3370,24 @@ class Ie {
3180
3370
  * Report result from cognitive operation and continue execution
3181
3371
  */
3182
3372
  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);
3373
+ const o2 = await this.storage.getExecution(t2);
3187
3374
  if (!o2)
3188
- throw new Error(`Program not found: ${s2.programId}`);
3375
+ throw new Error(`Execution not found: ${t2}`);
3376
+ const s2 = await this.storage.getProgram(o2.programId);
3377
+ if (!s2)
3378
+ throw new Error(`Program not found: ${o2.programId}`);
3189
3379
  let c2 = this.vms.get(t2);
3190
3380
  c2 || (c2 = new C(), this.vms.set(t2, c2));
3191
3381
  const p2 = {
3192
- ...this.deserializeVMState(s2),
3382
+ ...this.deserializeVMState(o2),
3193
3383
  status: "waiting_cc",
3194
3384
  output: [],
3195
3385
  // Start with empty output for resumed execution
3196
3386
  ccPrompt: void 0
3197
- }, a2 = c2.resume(p2, r2, o2.bytecode, this.fileSystem);
3387
+ }, a2 = c2.resume(p2, r2, s2.bytecode, this.fileSystem);
3198
3388
  a2.output.length > 0 && await this.storage.appendOutput(t2, a2.output);
3199
- 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);
3389
+ const u2 = this.serializeVMState(a2);
3390
+ Object.assign(o2, u2), 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
3391
  }
3202
3392
  /**
3203
3393
  * Get current execution status
@@ -3269,22 +3459,22 @@ class Ie {
3269
3459
  * Restart a program (create new execution and set as current)
3270
3460
  */
3271
3461
  async restartExecution(t2, r2) {
3272
- const s2 = r2 || `${t2}-${Date.now()}`;
3273
- return await this.startExecution(t2, s2), await this.setCurrentExecutionId(s2), s2;
3462
+ const o2 = r2 || `${t2}-${Date.now()}`;
3463
+ return await this.startExecution(t2, o2), await this.setCurrentExecutionId(o2), o2;
3274
3464
  }
3275
3465
  /**
3276
3466
  * Serialize heap to storage format
3277
3467
  */
3278
3468
  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,
3469
+ const r2 = (s2, c2) => u$1(c2) || b(c2) ? { $ref: c2.id } : c2, o2 = {};
3470
+ return t2.objects.forEach((s2, c2) => {
3471
+ o2[c2] = {
3472
+ type: s2.type,
3283
3473
  // Serialize each object's data individually with replacer
3284
- data: JSON.parse(JSON.stringify(o2.data, r2))
3474
+ data: JSON.parse(JSON.stringify(s2.data, r2))
3285
3475
  };
3286
3476
  }), {
3287
- objects: s2,
3477
+ objects: o2,
3288
3478
  nextId: t2.nextId
3289
3479
  };
3290
3480
  }
@@ -3294,17 +3484,17 @@ class Ie {
3294
3484
  deserializeHeap(t2) {
3295
3485
  const r2 = w();
3296
3486
  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,
3487
+ for (const o2 in t2.objects) {
3488
+ const s2 = parseInt(o2, 10), c2 = t2.objects[s2];
3489
+ r2.objects.set(s2, {
3490
+ id: s2,
3301
3491
  type: c2.type,
3302
3492
  data: c2.data
3303
3493
  // Still contains $ref stubs
3304
3494
  });
3305
3495
  }
3306
- return r2.objects.forEach((s2) => {
3307
- s2.data = this.restoreReferences(s2.data, r2);
3496
+ return r2.objects.forEach((o2) => {
3497
+ o2.data = this.restoreReferences(o2.data, r2);
3308
3498
  }), r2;
3309
3499
  }
3310
3500
  /**
@@ -3343,16 +3533,16 @@ class Ie {
3343
3533
  }
3344
3534
  restoreReferences(t2, r2) {
3345
3535
  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;
3536
+ const o2 = r2.objects.get(t2.$ref);
3537
+ 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
3538
  }
3349
3539
  if (Array.isArray(t2))
3350
- return t2.map((s2) => this.restoreReferences(s2, r2));
3540
+ return t2.map((o2) => this.restoreReferences(o2, r2));
3351
3541
  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;
3542
+ const o2 = {};
3543
+ for (const s2 in t2)
3544
+ o2[s2] = this.restoreReferences(t2[s2], r2);
3545
+ return o2;
3356
3546
  }
3357
3547
  return t2;
3358
3548
  }
@@ -3366,7 +3556,7 @@ class $ {
3366
3556
  i(this, "transport", null);
3367
3557
  i(this, "vmManager");
3368
3558
  i(this, "version");
3369
- this.version = e2, this.vmManager = new Ie(), this.server = new mcp_js.McpServer({
3559
+ this.version = e2, this.vmManager = new Se(), this.server = new mcp_js.McpServer({
3370
3560
  name: "cvm-server",
3371
3561
  version: this.version
3372
3562
  }), this.setupTools();
@@ -3844,7 +4034,7 @@ async function main() {
3844
4034
  ];
3845
4035
  for (const packageJsonPath of possiblePaths) {
3846
4036
  try {
3847
- const packageJson = JSON.parse(N$1.readFileSync(packageJsonPath, "utf-8"));
4037
+ const packageJson = JSON.parse(b$2.readFileSync(packageJsonPath, "utf-8"));
3848
4038
  if (packageJson.name === "cvm-server" && packageJson.version) {
3849
4039
  version = packageJson.version;
3850
4040
  break;