@nudojs/lsp 1.1.1 → 1.1.3

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 (3) hide show
  1. package/dist/index.js +435 -177
  2. package/dist/server.js +447 -182
  3. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -213867,7 +213867,12 @@ var app = (fn2, args) => ({ op: "app", fn: fn2, args });
213867
213867
  function termEquals(a, b) {
213868
213868
  if (a === b) return true;
213869
213869
  if (a.op !== b.op) return false;
213870
- if (a.op === "lit" && b.op === "lit") return a.value === b.value;
213870
+ if (a.op === "lit" && b.op === "lit") {
213871
+ if (typeof a.value === "number" && typeof b.value === "number" && Number.isNaN(a.value) && Number.isNaN(b.value)) {
213872
+ return true;
213873
+ }
213874
+ return a.value === b.value;
213875
+ }
213871
213876
  if (a.op === "var" && b.op === "var") return a.id === b.id;
213872
213877
  if (a.op === "app" && b.op === "app") {
213873
213878
  return a.fn === b.fn && a.args.length === b.args.length && a.args.every((x, i) => termEquals(x, b.args[i]));
@@ -213906,18 +213911,10 @@ function simplifyTerm(t) {
213906
213911
  const folded = foldLiterals(fn2, xs);
213907
213912
  if (folded !== void 0) return lit(folded);
213908
213913
  }
213909
- if (fn2 === "+" && args.length === 2) {
213910
- const [a, b] = args;
213911
- if (a.op === "lit" && a.value === 0) return b;
213912
- if (b.op === "lit" && b.value === 0) return a;
213913
- }
213914
213914
  if (fn2 === "*" && args.length === 2) {
213915
213915
  const [a, b] = args;
213916
213916
  if (a.op === "lit" && a.value === 1) return b;
213917
213917
  if (b.op === "lit" && b.value === 1) return a;
213918
- if (a.op === "lit" && a.value === 0 || b.op === "lit" && b.value === 0) {
213919
- return lit(0);
213920
- }
213921
213918
  }
213922
213919
  if (fn2 === "-" && args.length === 2) {
213923
213920
  const [a, b] = args;
@@ -230402,7 +230399,7 @@ function coercibleLit(v2) {
230402
230399
  return v2 !== void 0 && (typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null);
230403
230400
  }
230404
230401
  function toNumberResult(a, b, op) {
230405
- const term = a.term && b.term ? simplifyTerm(app(op, [a.term, b.term])) : void 0;
230402
+ const term = a.term && b.term ? app(op, [a.term, b.term]) : void 0;
230406
230403
  return abs(
230407
230404
  { k: "prim", type: "number" },
230408
230405
  term,
@@ -230569,9 +230566,6 @@ function mul(a, b, phi2 = pTrue) {
230569
230566
  }
230570
230567
  if (isNumericLike(a) && isNumericLike(b) && a.term && b.term) {
230571
230568
  const term = simplifyTerm(app("*", [a.term, b.term]));
230572
- if (b.term.op === "lit" && b.term.value === 0 || a.term.op === "lit" && a.term.value === 0) {
230573
- return numLit(0);
230574
- }
230575
230569
  let k;
230576
230570
  let base;
230577
230571
  if (b.term.op === "lit" && typeof b.term.value === "number") {
@@ -230683,9 +230677,6 @@ function mod(a, b, phi2 = pTrue) {
230683
230677
  return abs({ k: "prim", type: "bigint" }, void 0, void 0, confJoin(a.conf, b.conf));
230684
230678
  }
230685
230679
  if (typeof va === "number" && typeof vb === "number") {
230686
- if (vb === 0) {
230687
- return abs(num().shape, void 0, void 0, "path");
230688
- }
230689
230680
  return numLit(va % vb);
230690
230681
  }
230691
230682
  if (coercibleLit(va) && coercibleLit(vb)) {
@@ -230693,14 +230684,24 @@ function mod(a, b, phi2 = pTrue) {
230693
230684
  }
230694
230685
  if (isNumericLike(a) && isNumericLike(b) && a.term && b.term) {
230695
230686
  const term = simplifyTerm(app("%", [a.term, b.term]));
230696
- if (b.term.op === "lit" && typeof b.term.value === "number" && b.term.value !== 0) {
230687
+ if (b.term.op === "lit") {
230688
+ const bv = b.term.value;
230689
+ if (typeof bv === "number" && (bv === 0 || Number.isNaN(bv))) {
230690
+ return numLit(NaN);
230691
+ }
230692
+ }
230693
+ if (b.term.op === "lit" && typeof b.term.value === "number" && Number.isFinite(b.term.value) && b.term.value !== 0) {
230697
230694
  const k = Math.abs(b.term.value);
230698
- return abs(
230699
- num().shape,
230700
- term,
230701
- and(gt(term, lit(-k)), lt(term, lit(k))),
230702
- confJoin(confJoin(a.conf, b.conf), "path")
230703
- );
230695
+ const ab = numericBounds(a, phi2);
230696
+ const finiteDividend = ab?.lo !== void 0 && ab?.hi !== void 0 && Number.isFinite(ab.lo.value) && Number.isFinite(ab.hi.value);
230697
+ if (finiteDividend) {
230698
+ return abs(
230699
+ num().shape,
230700
+ term,
230701
+ and(gt(term, lit(-k)), lt(term, lit(k))),
230702
+ confJoin(confJoin(a.conf, b.conf), "path")
230703
+ );
230704
+ }
230704
230705
  }
230705
230706
  return abs(num().shape, term, void 0, confJoin(confJoin(a.conf, b.conf), "path"));
230706
230707
  }
@@ -230713,11 +230714,18 @@ function mod(a, b, phi2 = pTrue) {
230713
230714
  return abs({ k: "unknown" }, void 0, void 0, "partial");
230714
230715
  }
230715
230716
  function cmp(op, a, b, phi2 = pTrue) {
230716
- const va = litValue(a);
230717
- const vb = litValue(b);
230718
- if (va !== void 0 && vb !== void 0) {
230719
- const result = compareLits(op, va, vb);
230717
+ const ta = a.term;
230718
+ const tb = b.term;
230719
+ if (ta?.op === "lit" && tb?.op === "lit") {
230720
+ const result = compareLits(op, ta.value, tb.value);
230720
230721
  if (result !== void 0) return boolLit(result);
230722
+ } else {
230723
+ const va = litValue(a);
230724
+ const vb = litValue(b);
230725
+ if (va !== void 0 && vb !== void 0) {
230726
+ const result = compareLits(op, va, vb);
230727
+ if (result !== void 0) return boolLit(result);
230728
+ }
230721
230729
  }
230722
230730
  if (a.term && b.term) {
230723
230731
  const pred = op === "lt" ? lt(a.term, b.term) : op === "le" ? le(a.term, b.term) : op === "gt" ? gt(a.term, b.term) : op === "ge" ? ge(a.term, b.term) : op === "eq" ? { op: "eq", a: a.term, b: b.term } : { op: "ne", a: a.term, b: b.term };
@@ -230880,54 +230888,36 @@ function isPrimLike(a) {
230880
230888
  }
230881
230889
 
230882
230890
  // ../core/src/algebra/builtins/math.ts
230891
+ function coerceMathArg(a) {
230892
+ if (!a || a.term?.op !== "lit") return void 0;
230893
+ const v2 = a.term.value;
230894
+ if (typeof v2 === "number") return v2;
230895
+ if (typeof v2 === "string") return Number(v2);
230896
+ if (typeof v2 === "boolean") return v2 ? 1 : 0;
230897
+ if (v2 === null) return 0;
230898
+ if (v2 === void 0) return void 0;
230899
+ return "throw";
230900
+ }
230901
+ function mathMethod(name) {
230902
+ if (!Object.hasOwn(Math, name)) return void 0;
230903
+ const impl = Math[name];
230904
+ return typeof impl === "function" ? impl : void 0;
230905
+ }
230883
230906
  function evalMathMethod(name, args) {
230884
- const a0 = args[0] ? litValue(args[0]) : void 0;
230885
- const a1 = args[1] ? litValue(args[1]) : void 0;
230886
- switch (name) {
230887
- case "abs":
230888
- if (typeof a0 === "number") return numLit(Math.abs(a0));
230889
- return numPrim();
230890
- case "floor":
230891
- if (typeof a0 === "number") return numLit(Math.floor(a0));
230892
- return numPrim();
230893
- case "ceil":
230894
- if (typeof a0 === "number") return numLit(Math.ceil(a0));
230895
- return numPrim();
230896
- case "round":
230897
- if (typeof a0 === "number") return numLit(Math.round(a0));
230898
- return numPrim();
230899
- case "random":
230900
- return numPrim("path");
230901
- case "sqrt":
230902
- if (typeof a0 === "number") return numLit(Math.sqrt(a0));
230903
- return numPrim();
230904
- case "min": {
230905
- const lits = args.map(litValue);
230906
- if (lits.length > 0 && lits.every((x) => typeof x === "number")) {
230907
- return numLit(Math.min(...lits));
230908
- }
230909
- return numPrim();
230910
- }
230911
- case "max": {
230912
- const lits = args.map(litValue);
230913
- if (lits.length > 0 && lits.every((x) => typeof x === "number")) {
230914
- return numLit(Math.max(...lits));
230915
- }
230916
- return numPrim();
230917
- }
230918
- case "pow":
230919
- if (typeof a0 === "number" && typeof a1 === "number") return numLit(Math.pow(a0, a1));
230920
- return numPrim();
230921
- case "sign":
230922
- if (typeof a0 === "number") return numLit(Math.sign(a0));
230923
- return numPrim();
230924
- case "atan2":
230925
- if (typeof a0 === "number" && typeof a1 === "number") {
230926
- return numLit(Math.atan2(a0, a1));
230927
- }
230928
- return numPrim();
230929
- default:
230930
- return void 0;
230907
+ if (name === "random") return numPrim("path");
230908
+ const impl = mathMethod(name);
230909
+ if (!impl) return void 0;
230910
+ const nums = [];
230911
+ for (const a of args) {
230912
+ const n = coerceMathArg(a);
230913
+ if (n === void 0) return numPrim();
230914
+ if (n === "throw") throw new NudoThrow(errorTypeAbs("TypeError"));
230915
+ nums.push(n);
230916
+ }
230917
+ try {
230918
+ return numLit(impl(...nums));
230919
+ } catch {
230920
+ return numPrim();
230931
230921
  }
230932
230922
  }
230933
230923
 
@@ -231537,6 +231527,11 @@ function jsonValueToAbs(v2) {
231537
231527
  }
231538
231528
  return abs({ k: "obj", slots }, void 0, void 0, "exact");
231539
231529
  }
231530
+ function isNonJsonTopLevel(a) {
231531
+ if (a.shape.k === "fn") return true;
231532
+ if (a.shape.k === "prim" && a.shape.type === "symbol") return true;
231533
+ return false;
231534
+ }
231540
231535
  function evalJsonMethod(name, args) {
231541
231536
  if (name === "parse") {
231542
231537
  const a0Abs = args[0];
@@ -231559,7 +231554,10 @@ function evalJsonMethod(name, args) {
231559
231554
  const a0Abs = args[0];
231560
231555
  if (!a0Abs) return undefAbs();
231561
231556
  const v2 = absToJsonNative(a0Abs, /* @__PURE__ */ new Set());
231562
- if (v2 === NOT_LITERAL) return str2("partial");
231557
+ if (v2 === NOT_LITERAL) {
231558
+ if (isNonJsonTopLevel(a0Abs)) return undefAbs();
231559
+ return str2("partial");
231560
+ }
231563
231561
  const replacerArg = args[1];
231564
231562
  let replacer;
231565
231563
  if (replacerArg) {
@@ -231601,34 +231599,60 @@ function evalJsonMethod(name, args) {
231601
231599
  function foldParseInt(s, radix) {
231602
231600
  const str6 = String(s);
231603
231601
  if (radix === void 0) return numLit(parseInt(str6));
231604
- const r = radix | 0;
231602
+ const r = Number(radix) | 0;
231605
231603
  if (r === 0) return numLit(parseInt(str6));
231606
231604
  if (r < 2 || r > 36) return numLit(NaN);
231607
231605
  return numLit(parseInt(str6, r));
231608
231606
  }
231607
+ function foldParseFloat(s) {
231608
+ return numLit(parseFloat(String(s)));
231609
+ }
231610
+ function toStringLitArg(a) {
231611
+ if (!a) return { lit: true, v: void 0 };
231612
+ if (a.term?.op !== "lit") return { lit: false };
231613
+ const v2 = a.term.value;
231614
+ if (typeof v2 === "symbol") throw new NudoThrow(errorTypeAbs("TypeError"));
231615
+ return { lit: true, v: v2 };
231616
+ }
231617
+ function radixLitArg(a) {
231618
+ if (!a) return { ok: true, v: void 0 };
231619
+ if (a.term?.op !== "lit") return { ok: false };
231620
+ const v2 = a.term.value;
231621
+ if (typeof v2 === "symbol") throw new NudoThrow(errorTypeAbs("TypeError"));
231622
+ if (v2 === void 0) return { ok: true, v: void 0 };
231623
+ if (typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null) {
231624
+ return { ok: true, v: v2 };
231625
+ }
231626
+ return { ok: false };
231627
+ }
231609
231628
  function evalNumberStatic(name, args) {
231610
- const a0 = args[0] ? litValue(args[0]) : void 0;
231629
+ const a0Arg = args[0];
231630
+ const a0 = a0Arg ? litValue(a0Arg) : void 0;
231631
+ const foldStrictNumberPred = (pred) => {
231632
+ if (!a0Arg) return boolLit(false);
231633
+ if (a0Arg.term?.op !== "lit") return void 0;
231634
+ const v2 = a0Arg.term.value;
231635
+ return boolLit(typeof v2 === "number" && pred(v2));
231636
+ };
231611
231637
  switch (name) {
231612
231638
  case "isInteger":
231613
- if (typeof a0 === "number") return boolLit(Number.isInteger(a0));
231614
- return boolPrim();
231639
+ return foldStrictNumberPred(Number.isInteger) ?? boolPrim();
231615
231640
  case "isNaN":
231616
- if (typeof a0 === "number") return boolLit(Number.isNaN(a0));
231617
- return boolPrim();
231641
+ return foldStrictNumberPred(Number.isNaN) ?? boolPrim();
231618
231642
  case "isFinite":
231619
- if (typeof a0 === "number") return boolLit(Number.isFinite(a0));
231620
- return boolPrim();
231621
- case "parseInt":
231622
- if (typeof a0 === "string" || typeof a0 === "number") {
231623
- const radix = args[1] ? litValue(args[1]) : void 0;
231624
- if (radix === void 0) return foldParseInt(a0, void 0);
231625
- if (typeof radix === "number") return foldParseInt(a0, radix);
231626
- return numPrim();
231627
- }
231628
- return numPrim();
231629
- case "parseFloat":
231630
- if (typeof a0 === "string" || typeof a0 === "number") return numLit(parseFloat(String(a0)));
231631
- return numPrim();
231643
+ return foldStrictNumberPred(Number.isFinite) ?? boolPrim();
231644
+ case "parseInt": {
231645
+ const s = toStringLitArg(a0Arg);
231646
+ if (!s.lit) return numPrim();
231647
+ const radix = radixLitArg(args[1]);
231648
+ if (!radix.ok) return numPrim();
231649
+ return foldParseInt(s.v, radix.v);
231650
+ }
231651
+ case "parseFloat": {
231652
+ const s = toStringLitArg(a0Arg);
231653
+ if (!s.lit) return numPrim();
231654
+ return foldParseFloat(s.v);
231655
+ }
231632
231656
  case "MAX_SAFE_INTEGER":
231633
231657
  return numLit(Number.MAX_SAFE_INTEGER);
231634
231658
  default:
@@ -232416,29 +232440,59 @@ function arrayMethodAbs(name) {
232416
232440
  }
232417
232441
 
232418
232442
  // ../core/src/algebra/builtins/global.ts
232443
+ function litTermOf(a) {
232444
+ return a?.term?.op === "lit" ? a.term : void 0;
232445
+ }
232419
232446
  function evalGlobalFn(name, args) {
232420
232447
  const a0 = args[0] ? litValue(args[0]) : void 0;
232448
+ const a0Lit = litTermOf(args[0]);
232421
232449
  switch (name) {
232422
232450
  case "eval":
232423
232451
  return unknown;
232424
232452
  case "Array":
232425
232453
  return makeArrayCtorAbs(args);
232426
- case "parseInt":
232427
- if (typeof a0 === "string" || typeof a0 === "number") {
232428
- const radix = args[1] ? litValue(args[1]) : void 0;
232429
- if (radix === void 0) return foldParseInt(a0, void 0);
232430
- if (typeof radix === "number") return foldParseInt(a0, radix);
232454
+ case "parseInt": {
232455
+ const sVal = a0Lit ? a0Lit.value : void 0;
232456
+ if (a0Lit && typeof sVal === "symbol") throw new NudoThrow(errorTypeAbs("TypeError"));
232457
+ if (!a0Lit && args[0] && args[0].term?.op !== "lit") return numPrim();
232458
+ const rAbs = args[1];
232459
+ let radix;
232460
+ if (!rAbs) {
232461
+ radix = void 0;
232462
+ } else if (rAbs.term?.op !== "lit") {
232431
232463
  return numPrim();
232464
+ } else if (typeof rAbs.term.value === "symbol") {
232465
+ throw new NudoThrow(errorTypeAbs("TypeError"));
232466
+ } else {
232467
+ const rv = rAbs.term.value;
232468
+ radix = rv === void 0 ? void 0 : rv;
232469
+ if (rv !== void 0 && typeof rv !== "number" && typeof rv !== "string" && typeof rv !== "boolean" && rv !== null) {
232470
+ return numPrim();
232471
+ }
232472
+ }
232473
+ return foldParseInt(sVal, radix);
232474
+ }
232475
+ case "parseFloat": {
232476
+ if (!a0Lit && args[0] && args[0].term?.op !== "lit") return numPrim();
232477
+ if (a0Lit && typeof a0Lit.value === "symbol") throw new NudoThrow(errorTypeAbs("TypeError"));
232478
+ return foldParseFloat(a0Lit ? a0Lit.value : void 0);
232479
+ }
232480
+ case "isNaN": {
232481
+ if (args[0] && isSymbolAbs2(args[0])) throw new NudoThrow(errorTypeAbs("TypeError"));
232482
+ if (!args[0] || args[0].term?.op === "lit" && args[0].term.value === void 0) {
232483
+ return boolLit(true);
232432
232484
  }
232433
- return numPrim();
232434
- case "parseFloat":
232435
- if (typeof a0 === "string" || typeof a0 === "number") return numLit(parseFloat(String(a0)));
232436
- return numPrim();
232437
- case "isNaN":
232438
232485
  if (typeof a0 === "number") return boolLit(Number.isNaN(a0));
232486
+ if (typeof a0 === "boolean" || a0 === null) return boolLit(false);
232487
+ if (typeof a0 === "string") return boolLit(Number.isNaN(Number(a0)));
232488
+ if (typeof a0 === "bigint") throw new NudoThrow(errorTypeAbs("TypeError"));
232439
232489
  return boolPrim();
232490
+ }
232440
232491
  case "isFinite": {
232441
- if (a0 === void 0 && args.length === 0) return boolLit(false);
232492
+ if (args[0] && isSymbolAbs2(args[0])) throw new NudoThrow(errorTypeAbs("TypeError"));
232493
+ if (!args[0] || args[0].term?.op === "lit" && args[0].term.value === void 0) {
232494
+ return boolLit(false);
232495
+ }
232442
232496
  if (typeof a0 === "number") return boolLit(Number.isFinite(a0));
232443
232497
  if (typeof a0 === "boolean") return boolLit(true);
232444
232498
  if (typeof a0 === "string") return boolLit(Number.isFinite(Number(a0)));
@@ -232447,18 +232501,24 @@ function evalGlobalFn(name, args) {
232447
232501
  }
232448
232502
  case "Number":
232449
232503
  if (args[0] && isSymbolAbs2(args[0])) throw new NudoThrow(errorTypeAbs("TypeError"));
232504
+ if (!args[0]) return numLit(0);
232505
+ if (a0Lit && a0Lit.value === void 0) return numLit(NaN);
232450
232506
  if (typeof a0 === "number") return numLit(a0);
232451
232507
  if (typeof a0 === "string") return numLit(Number(a0));
232452
232508
  if (typeof a0 === "boolean") return numLit(a0 ? 1 : 0);
232509
+ if (a0 === null) return numLit(0);
232510
+ if (typeof a0 === "bigint") return numLit(Number(a0));
232453
232511
  return numPrim();
232454
232512
  case "String":
232455
232513
  if (args[0] && isSymbolAbs2(args[0])) return stringOfSymbol(args[0]);
232456
- if (a0 !== void 0) return strLit(String(a0));
232514
+ if (!args[0]) return strLit("");
232515
+ if (a0Lit) return strLit(String(a0Lit.value));
232457
232516
  return str2();
232458
232517
  case "Symbol":
232459
232518
  return makeSymbolAbs(args[0]);
232460
232519
  case "Boolean":
232461
- if (a0 !== void 0) return boolLit(Boolean(a0));
232520
+ if (!args[0]) return boolLit(false);
232521
+ if (a0Lit) return boolLit(Boolean(a0Lit.value));
232462
232522
  return boolPrim();
232463
232523
  case "Object": {
232464
232524
  const arg = args[0];
@@ -233291,6 +233351,12 @@ function negAbs(a, _phi = pTrue) {
233291
233351
  const v2 = litValue(a);
233292
233352
  if (typeof v2 === "number") return numLitAbs(-v2);
233293
233353
  if (typeof v2 === "bigint") return bigintLit(-v2);
233354
+ if (a.term?.op === "lit") {
233355
+ const tv = a.term.value;
233356
+ if (typeof tv === "string" || typeof tv === "boolean" || tv === null) {
233357
+ return numLitAbs(-Number(tv));
233358
+ }
233359
+ }
233294
233360
  if (a.shape.k === "prim" && a.shape.type === "number") {
233295
233361
  if (!a.term) {
233296
233362
  return abs(num().shape, void 0, void 0, confJoin(a.conf, "widened"));
@@ -233357,7 +233423,7 @@ function isDefinitelyTruthyShape(s) {
233357
233423
  case "eff":
233358
233424
  return true;
233359
233425
  case "prim":
233360
- return s.type === "symbol" || s.type === "bigint";
233426
+ return s.type === "symbol";
233361
233427
  default:
233362
233428
  return false;
233363
233429
  }
@@ -233424,7 +233490,12 @@ function strictEqAbs(a, b) {
233424
233490
  if (bNullish && definitelyNotNullishShape(a.shape)) return false;
233425
233491
  if (aNullish && definitelyNotNullishShape(b.shape)) return false;
233426
233492
  if (a.term && b.term && a.term.op === "var" && b.term.op === "var" && a.term.id === b.term.id) {
233427
- return true;
233493
+ const k = a.shape.k;
233494
+ if (k === "obj" || k === "arr" || k === "tuple" || k === "fn" || k === "brand" || k === "eff") {
233495
+ return true;
233496
+ }
233497
+ if (k === "prim" && a.shape.type !== "number") return true;
233498
+ return void 0;
233428
233499
  }
233429
233500
  return void 0;
233430
233501
  }
@@ -233488,9 +233559,26 @@ function callbackEnv() {
233488
233559
  function isStrRecv(recv) {
233489
233560
  return isTemplateLike(recv) || recv.shape.k === "prim" && recv.shape.type === "string" || recv.term?.op === "lit" && typeof recv.term.value === "string";
233490
233561
  }
233562
+ function isFoldableIndexArg(x) {
233563
+ if (x === void 0) return true;
233564
+ if (x.term?.op !== "lit") return false;
233565
+ const v2 = x.term.value;
233566
+ return v2 === void 0 || typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null;
233567
+ }
233568
+ function toStringArg(x) {
233569
+ if (x === void 0) return "undefined";
233570
+ if (x.term?.op !== "lit") return void 0;
233571
+ const v2 = x.term.value;
233572
+ if (typeof v2 === "symbol") return void 0;
233573
+ return String(v2);
233574
+ }
233575
+ function isUndefinedArg(x) {
233576
+ return x === void 0 || x.term?.op === "lit" && x.term.value === void 0;
233577
+ }
233491
233578
  function callAbsMethod(recv, name, args) {
233492
233579
  if (!isStrRecv(recv)) return void 0;
233493
233580
  const a0 = args[0] ? litValue(args[0]) : void 0;
233581
+ const a0Str = toStringArg(args[0]);
233494
233582
  const lit3 = recv.term?.op === "lit" && typeof recv.term.value === "string" ? recv.term.value : void 0;
233495
233583
  if (isTemplateLike(recv)) {
233496
233584
  const views = absTemplateViews(templatePartsOf(recv));
@@ -233499,20 +233587,20 @@ function callAbsMethod(recv, name, args) {
233499
233587
  switch (name) {
233500
233588
  case "startsWith": {
233501
233589
  if (args[1] && litValue(args[1]) !== void 0) return boolPrim5();
233502
- if (typeof a0 !== "string") return boolPrim5();
233503
- const d = decideStartsWith(prefix2, a0);
233590
+ if (a0Str === void 0) return boolPrim5();
233591
+ const d = decideStartsWith(prefix2, a0Str);
233504
233592
  return d === "unknown" ? boolPrim5() : boolLit(d);
233505
233593
  }
233506
233594
  case "endsWith": {
233507
233595
  if (args[1] && litValue(args[1]) !== void 0) return boolPrim5();
233508
- if (typeof a0 !== "string") return boolPrim5();
233509
- const d = decideEndsWith(suffix, a0);
233596
+ if (a0Str === void 0) return boolPrim5();
233597
+ const d = decideEndsWith(suffix, a0Str);
233510
233598
  return d === "unknown" ? boolPrim5() : boolLit(d);
233511
233599
  }
233512
233600
  case "includes": {
233513
233601
  if (args[1] && litValue(args[1]) !== void 0) return boolPrim5();
233514
- if (typeof a0 !== "string") return boolPrim5();
233515
- const d = decideIncludes(allFixedTextOfViews(views), a0);
233602
+ if (a0Str === void 0) return boolPrim5();
233603
+ const d = decideIncludes(allFixedTextOfViews(views), a0Str);
233516
233604
  return d === "unknown" ? boolPrim5() : boolLit(d);
233517
233605
  }
233518
233606
  case "toUpperCase":
@@ -233538,10 +233626,10 @@ function callAbsMethod(recv, name, args) {
233538
233626
  const a1 = a1Abs ? litValue(a1Abs) : void 0;
233539
233627
  const a1Unknown = a1Abs !== void 0 && a1Abs.term?.op !== "lit";
233540
233628
  if (a1Unknown) return boolPrim5();
233541
- if (lit3 !== void 0 && typeof a0 === "string") {
233542
- if (name === "startsWith") return boolLit(lit3.startsWith(a0, a1));
233543
- if (name === "endsWith") return boolLit(lit3.endsWith(a0, a1));
233544
- return boolLit(lit3.includes(a0, a1));
233629
+ if (lit3 !== void 0 && a0Str !== void 0) {
233630
+ if (name === "startsWith") return boolLit(lit3.startsWith(a0Str, a1));
233631
+ if (name === "endsWith") return boolLit(lit3.endsWith(a0Str, a1));
233632
+ return boolLit(lit3.includes(a0Str, a1));
233545
233633
  }
233546
233634
  return boolPrim5();
233547
233635
  }
@@ -233554,8 +233642,7 @@ function callAbsMethod(recv, name, args) {
233554
233642
  case "slice":
233555
233643
  case "substring":
233556
233644
  if (lit3 !== void 0) {
233557
- const numOrMissing = (x) => x === void 0 || x.term?.op === "lit" && (x.term.value === void 0 || typeof x.term.value === "number");
233558
- if (!numOrMissing(args[0]) || !numOrMissing(args[1])) return strPrim("path");
233645
+ if (!isFoldableIndexArg(args[0]) || !isFoldableIndexArg(args[1])) return strPrim("path");
233559
233646
  const a1 = args[1] ? litValue(args[1]) : void 0;
233560
233647
  if (name === "slice") {
233561
233648
  return strLit(lit3.slice(a0, a1));
@@ -233563,8 +233650,11 @@ function callAbsMethod(recv, name, args) {
233563
233650
  return strLit(lit3.substring(Number(a0 ?? 0), Number(a1 ?? lit3.length)));
233564
233651
  }
233565
233652
  return strPrim("path");
233566
- case "charAt":
233567
- return lit3 !== void 0 && typeof a0 === "number" ? strLit(lit3.charAt(a0)) : strPrim("path");
233653
+ case "charAt": {
233654
+ if (lit3 === void 0) return strPrim("path");
233655
+ if (!isFoldableIndexArg(args[0])) return strPrim("path");
233656
+ return strLit(lit3.charAt(Number(a0 ?? 0)));
233657
+ }
233568
233658
  case "toString":
233569
233659
  case "valueOf":
233570
233660
  return lit3 !== void 0 ? strLit(lit3) : strPrim("path");
@@ -233580,17 +233670,36 @@ function callAbsMethod(recv, name, args) {
233580
233670
  return strPrim("path");
233581
233671
  }
233582
233672
  case "indexOf":
233583
- case "lastIndexOf":
233584
- case "charCodeAt":
233585
- return numPrim5("path");
233673
+ case "lastIndexOf": {
233674
+ if (lit3 === void 0) return numPrim5("path");
233675
+ const search = toStringArg(args[0]);
233676
+ if (search === void 0) return numPrim5("path");
233677
+ if (!isFoldableIndexArg(args[1])) return numPrim5("path");
233678
+ const from = args[1] ? litValue(args[1]) : void 0;
233679
+ return numLit(
233680
+ name === "indexOf" ? lit3.indexOf(search, from) : lit3.lastIndexOf(search, from)
233681
+ );
233682
+ }
233683
+ case "charCodeAt": {
233684
+ if (lit3 === void 0) return numPrim5("path");
233685
+ if (!isFoldableIndexArg(args[0])) return numPrim5("path");
233686
+ return numLit(lit3.charCodeAt(Number(a0 ?? 0)));
233687
+ }
233586
233688
  case "split": {
233587
233689
  if (lit3 !== void 0) {
233588
- const sep3 = typeof a0 === "string" ? a0 : void 0;
233589
- const a1Abs = args[1];
233590
- const a1 = a1Abs ? litValue(a1Abs) : void 0;
233591
- if (a1Abs !== void 0 && a1Abs.term?.op !== "lit") return strArr("path");
233690
+ const limAbs = args[1];
233691
+ const lim = limAbs ? litValue(limAbs) : void 0;
233692
+ if (limAbs !== void 0 && limAbs.term?.op !== "lit") return strArr("path");
233693
+ if (isUndefinedArg(args[0])) {
233694
+ const one = abs({ k: "tuple", elements: [strLit(lit3)] }, void 0, void 0, "exact");
233695
+ if (lim === void 0) return one;
233696
+ const n = Number(lim);
233697
+ if (!(n > 0)) return abs({ k: "tuple", elements: [] }, void 0, void 0, "exact");
233698
+ return one;
233699
+ }
233700
+ const sep3 = toStringArg(args[0]);
233592
233701
  if (sep3 !== void 0) {
233593
- const parts = lit3.split(sep3, a1).map((s) => strLit(s));
233702
+ const parts = lit3.split(sep3, lim).map((s) => strLit(s));
233594
233703
  return abs({ k: "tuple", elements: parts }, void 0, void 0, "exact");
233595
233704
  }
233596
233705
  return strArr("path");
@@ -233602,12 +233711,16 @@ function callAbsMethod(recv, name, args) {
233602
233711
  if (lit3 !== void 0) {
233603
233712
  const patAbs = args[0];
233604
233713
  const repAbs = args[1];
233605
- if (patAbs && repAbs) {
233714
+ {
233606
233715
  let patSrc;
233607
233716
  let patRe;
233608
- const pv = patAbs.term?.op === "lit" ? patAbs.term.value : void 0;
233609
- if (typeof pv === "string") {
233717
+ const pv = patAbs?.term?.op === "lit" ? patAbs.term.value : void 0;
233718
+ if (patAbs === void 0) {
233719
+ patSrc = "undefined";
233720
+ } else if (typeof pv === "string") {
233610
233721
  patSrc = pv;
233722
+ } else if (patAbs.term?.op === "lit" && typeof pv !== "symbol") {
233723
+ patSrc = String(pv);
233611
233724
  } else if (patAbs.shape.k === "brand" && patAbs.shape.name === "RegExp") {
233612
233725
  const inner = patAbs.shape.shape;
233613
233726
  const slots = inner.shape.k === "obj" ? inner.shape.slots : void 0;
@@ -233626,11 +233739,12 @@ function callAbsMethod(recv, name, args) {
233626
233739
  throw new NudoThrow(errorTypeAbs("TypeError"));
233627
233740
  }
233628
233741
  const pat = patSrc ?? patRe;
233629
- const rv = repAbs.term?.op === "lit" ? repAbs.term.value : void 0;
233630
- if (typeof rv === "string") {
233742
+ const rvLit = repAbs?.term?.op === "lit" ? repAbs.term.value : void 0;
233743
+ const rv = repAbs === void 0 ? "undefined" : typeof rvLit === "string" ? rvLit : repAbs.term?.op === "lit" && typeof rvLit !== "symbol" ? String(rvLit) : void 0;
233744
+ if (rv !== void 0) {
233631
233745
  return strLit(name === "replaceAll" ? lit3.replaceAll(pat, rv) : lit3.replace(pat, rv));
233632
233746
  }
233633
- if (repAbs.shape.k === "fn") {
233747
+ if (repAbs && repAbs.shape.k === "fn") {
233634
233748
  let anyUnknown = false;
233635
233749
  const replWrapper = (...caps) => {
233636
233750
  const last = caps[caps.length - 1];
@@ -233731,8 +233845,9 @@ function leqWithPred(src, tgt, phi2, env, depth) {
233731
233845
  if (src.shape.k === "any") return ok();
233732
233846
  const sv = litValue(src);
233733
233847
  const tv = litValue(tgt);
233848
+ const sameLit = sv === tv || typeof sv === "number" && typeof tv === "number" && Number.isNaN(sv) && Number.isNaN(tv);
233734
233849
  if (sv !== void 0 && tv !== void 0) {
233735
- if (sv === tv) return ok();
233850
+ if (sameLit) return ok();
233736
233851
  if (tgt.shape.k === "prim") {
233737
233852
  return fail(`lit ${String(sv)} \u22AD lit ${String(tv)}`);
233738
233853
  }
@@ -236693,7 +236808,7 @@ function litTruth(a) {
236693
236808
  case "eff":
236694
236809
  return true;
236695
236810
  case "prim":
236696
- return a.shape.type === "symbol" || a.shape.type === "bigint" ? true : void 0;
236811
+ return a.shape.type === "symbol" ? true : void 0;
236697
236812
  case "never":
236698
236813
  return false;
236699
236814
  default:
@@ -237778,7 +237893,7 @@ function emitArrMutatorRebinds(expr, opts, pad) {
237778
237893
  if (node.type === "CallExpression" && node.callee?.type === "MemberExpression" && node.callee.computed !== true && node.callee.property?.type === "Identifier" && ARR_MUTATOR_NAMES.has(node.callee.property.name)) {
237779
237894
  const methodName = node.callee.property.name;
237780
237895
  const argSrcs = (node.arguments ?? []).map(
237781
- (a) => a.type === "SpreadElement" ? "$lit(undefined)" : isExpression(a) ? emitTranspileExpression(a, opts) : "$lit(undefined)"
237896
+ (a) => a.type === "SpreadElement" ? "$unknown()" : isExpression(a) ? emitTranspileExpression(a, opts) : "$unknown()"
237782
237897
  ).join(", ");
237783
237898
  const objNode = node.callee.object;
237784
237899
  if (objNode.type === "Identifier") {
@@ -237800,7 +237915,7 @@ function emitArrMutatorRebinds(expr, opts, pad) {
237800
237915
  }
237801
237916
  if (node.type === "CallExpression" && node.callee?.type === "MemberExpression" && node.callee.computed !== true && node.callee.object?.type === "Identifier" && node.callee.object.name === "Object" && node.callee.property?.type === "Identifier" && node.callee.property.name === "defineProperty" && node.arguments?.[0] && node.arguments[0].type === "Identifier") {
237802
237917
  const argSrcs = node.arguments.map(
237803
- (a) => a.type === "SpreadElement" ? "$lit(undefined)" : emitTranspileExpression(a, opts)
237918
+ (a) => a.type === "SpreadElement" ? "$unknown()" : emitTranspileExpression(a, opts)
237804
237919
  ).join(", ");
237805
237920
  const targetName = node.arguments[0].name;
237806
237921
  lines.push(
@@ -238438,7 +238553,7 @@ ${pad}export default ${name};`;
238438
238553
  const methodName = expr.callee.property.name;
238439
238554
  if (["push", "unshift", "splice", "pop", "shift", "reverse", "sort"].includes(methodName)) {
238440
238555
  const argSrcs = expr.arguments.map(
238441
- (a) => a.type === "SpreadElement" ? "$lit(undefined)" : emitTranspileExpression(a, opts)
238556
+ (a) => a.type === "SpreadElement" ? "$unknown()" : emitTranspileExpression(a, opts)
238442
238557
  ).join(", ");
238443
238558
  const objNode = expr.callee.object;
238444
238559
  if (objNode.type === "Identifier") {
@@ -239324,7 +239439,7 @@ function transpileExpression(expr, opts = {}) {
239324
239439
  case "NewExpression": {
239325
239440
  const callee = expr.callee;
239326
239441
  const cname = callee.type === "Identifier" ? callee.name : isExpression(callee) ? transpileExpression(callee, opts) : "$lit(undefined)";
239327
- const args = expr.arguments.map((a) => a.type === "SpreadElement" ? "$lit(undefined)" : transpileExpression(a, opts)).join(", ");
239442
+ const args = expr.arguments.map((a) => a.type === "SpreadElement" ? "$unknown()" : transpileExpression(a, opts)).join(", ");
239328
239443
  return `$new(${cname}, [${args}])`;
239329
239444
  }
239330
239445
  case "LogicalExpression": {
@@ -239760,11 +239875,11 @@ ${mBodyInner}
239760
239875
  const optionalCall = exprAny.type === "OptionalCallExpression" || exprAny.optional === true;
239761
239876
  const callee = expr.callee;
239762
239877
  if (callee.type === "Super" && opts.thisParam && opts.className) {
239763
- const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$lit(undefined)" : transpileExpression(a, opts)).join(", ");
239878
+ const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$unknown()" : transpileExpression(a, opts)).join(", ");
239764
239879
  return `${opts.thisParam} = $super(${opts.thisParam}, ${JSON.stringify(opts.className)}, [${args2}])`;
239765
239880
  }
239766
239881
  if (callee.type === "MemberExpression" && !callee.computed && callee.object.type === "Super" && callee.property.type === "Identifier" && opts.thisParam && opts.className) {
239767
- const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$lit(undefined)" : transpileExpression(a, opts)).join(", ");
239882
+ const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$unknown()" : transpileExpression(a, opts)).join(", ");
239768
239883
  return `$invokeSuper(${opts.thisParam}, ${JSON.stringify(opts.className)}, ${JSON.stringify(callee.property.name)}, [${args2}])`;
239769
239884
  }
239770
239885
  if (callee.type === "MemberExpression" && !callee.computed && callee.object.type === "Identifier" && callee.object.name === "require" && callee.property.type === "Identifier" && callee.property.name === "resolve") {
@@ -239779,7 +239894,7 @@ ${mBodyInner}
239779
239894
  }
239780
239895
  if ((callee.type === "MemberExpression" || callee.type === "OptionalMemberExpression") && !callee.computed && callee.property.type === "Identifier") {
239781
239896
  const recv = transpileExpression(callee.object, opts);
239782
- const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$lit(undefined)" : transpileExpression(a, opts)).join(", ");
239897
+ const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$unknown()" : transpileExpression(a, opts)).join(", ");
239783
239898
  const name = JSON.stringify(callee.property.name);
239784
239899
  const opt = optionalCall || callee.optional === true;
239785
239900
  const loc = expr.loc;
@@ -239795,7 +239910,7 @@ ${mBodyInner}
239795
239910
  const argLocSrcs = [];
239796
239911
  for (const a of expr.arguments) {
239797
239912
  if (a.type === "SpreadElement") {
239798
- argSrcs.push("$lit(undefined)");
239913
+ argSrcs.push("$unknown()");
239799
239914
  argLocSrcs.push("null");
239800
239915
  } else {
239801
239916
  argSrcs.push(transpileExpression(a, opts));
@@ -240925,16 +241040,21 @@ function $arrMutContainer(arr, method, args) {
240925
241040
  function $idx(a, i) {
240926
241041
  if (a?.shape?.k === "any") return anyMemberResult();
240927
241042
  const iv = litValue(i);
241043
+ const idx = iv !== void 0 ? canonicalArrayIndex(iv) : void 0;
240928
241044
  if (a.shape.k === "tuple") {
240929
241045
  const els = a.shape.elements;
240930
- if (typeof iv === "number" && Number.isInteger(iv)) {
240931
- if (iv >= 0 && iv < els.length) return els[iv];
241046
+ if (iv !== void 0 && idx === void 0) return undef();
241047
+ if (idx !== void 0) {
241048
+ if (idx < els.length) return els[idx];
240932
241049
  return undef();
240933
241050
  }
240934
241051
  if (els.length === 0) return undef();
240935
241052
  return els.reduce((x, y) => joinAbs(x, y));
240936
241053
  }
240937
- if (a.shape.k === "arr") return a.shape.element;
241054
+ if (a.shape.k === "arr") {
241055
+ if (iv !== void 0 && idx === void 0) return undef();
241056
+ return a.shape.element;
241057
+ }
240938
241058
  if (a.shape.k === "sum") {
240939
241059
  return a.shape.members.map((m) => $idx(m, i)).reduce((x, y) => joinAbs(x, y));
240940
241060
  }
@@ -241323,6 +241443,46 @@ function namespaceNameOf(v2) {
241323
241443
  function $regex(pattern, flags = "") {
241324
241444
  return regexBrandAbsFrom(pattern, flags);
241325
241445
  }
241446
+ var ARRAY_PROTO_METHOD_NAMES = /* @__PURE__ */ new Set([
241447
+ "at",
241448
+ "concat",
241449
+ "copyWithin",
241450
+ "entries",
241451
+ "every",
241452
+ "fill",
241453
+ "filter",
241454
+ "find",
241455
+ "findIndex",
241456
+ "findLast",
241457
+ "findLastIndex",
241458
+ "flat",
241459
+ "flatMap",
241460
+ "forEach",
241461
+ "includes",
241462
+ "indexOf",
241463
+ "join",
241464
+ "keys",
241465
+ "lastIndexOf",
241466
+ "map",
241467
+ "pop",
241468
+ "push",
241469
+ "reduce",
241470
+ "reduceRight",
241471
+ "reverse",
241472
+ "shift",
241473
+ "slice",
241474
+ "some",
241475
+ "sort",
241476
+ "splice",
241477
+ "toLocaleString",
241478
+ "toString",
241479
+ "unshift",
241480
+ "values",
241481
+ "@@iterator"
241482
+ ]);
241483
+ function isPossiblyProtoMemberKey(key) {
241484
+ return OBJECT_PROTO_METHOD_NAMES.has(key) || ARRAY_PROTO_METHOD_NAMES.has(key) || key === "constructor" || key.startsWith("@@");
241485
+ }
241326
241486
  function $get(o, key, opts) {
241327
241487
  if (!o || typeof o !== "object" || !("shape" in o)) {
241328
241488
  if (o === Object.prototype) {
@@ -241414,10 +241574,19 @@ function $get(o, key, opts) {
241414
241574
  if ((o.shape.k === "tuple" || o.shape.k === "arr") && key === "length") {
241415
241575
  return $len(o);
241416
241576
  }
241417
- if ((o.shape.k === "tuple" || o.shape.k === "arr" || o.shape.k === "prim") && OBJECT_PROTO_METHOD_NAMES.has(key) && !(o.shape.k === "prim" && o.shape.type === "string" && key === "toString")) {
241577
+ if (o.shape.k === "tuple") {
241578
+ const idx = canonicalArrayIndex(key);
241579
+ const els = o.shape.elements;
241580
+ if (idx !== void 0) return idx < els.length ? els[idx] : undef();
241581
+ if (!isPossiblyProtoMemberKey(key)) return undef();
241582
+ }
241583
+ if ((o.shape.k === "tuple" || o.shape.k === "arr" || o.shape.k === "prim") && (OBJECT_PROTO_METHOD_NAMES.has(key) || o.shape.k !== "prim" && ARRAY_PROTO_METHOD_NAMES.has(key)) && !(o.shape.k === "prim" && o.shape.type === "string" && key === "toString")) {
241418
241584
  if ((o.shape.k === "tuple" || o.shape.k === "arr") && (key === "toString" || key === "toLocaleString" || key === "join")) {
241419
241585
  return arrayMethodAbs(key === "join" ? "join" : key);
241420
241586
  }
241587
+ if (o.shape.k !== "prim" && (ARRAY_PROTO_METHOD_NAMES.has(key) || key === "@@iterator")) {
241588
+ return absFunction([], { body: noBody2 });
241589
+ }
241421
241590
  return objectProtoMethodAbs(key);
241422
241591
  }
241423
241592
  if (noteNullishMemberThrows(o, key, "property")) {
@@ -242131,7 +242300,9 @@ __export(calls_exports, {
242131
242300
  $recordBinding: () => $recordBinding,
242132
242301
  MAX_B_CALL_DEPTH: () => MAX_B_CALL_DEPTH,
242133
242302
  MAX_B_TOTAL_CALLS: () => MAX_B_TOTAL_CALLS,
242303
+ blockHostSideEffect: () => blockHostSideEffect,
242134
242304
  getBCallCollector: () => getBCallCollector,
242305
+ neverExecHostName: () => neverExecHostName,
242135
242306
  noteBCallRecord: () => noteBCallRecord,
242136
242307
  resetBCallBudget: () => resetBCallBudget,
242137
242308
  setBAssignCollector: () => setBAssignCollector,
@@ -242200,6 +242371,12 @@ function neverExecHostName(fn2) {
242200
242371
  }
242201
242372
  return null;
242202
242373
  }
242374
+ function blockHostSideEffect(fn2) {
242375
+ const hostName = neverExecHostName(fn2);
242376
+ if (hostName === null) return null;
242377
+ noteHostEffectBlocked(hostName);
242378
+ return abs({ k: "unknown" }, void 0, void 0, "opaque");
242379
+ }
242203
242380
  function noteBCallRecord(r) {
242204
242381
  if (!bCallCollector) return;
242205
242382
  try {
@@ -242281,12 +242458,11 @@ function $callNamed(name, fn2, args, loc, argLocs) {
242281
242458
  try {
242282
242459
  if (typeof fn2 === "function") {
242283
242460
  const g = GLOBAL_FNS.has(name) && fn2 === globalThis[name] ? evalGlobalFn(name, args) : void 0;
242284
- const blockedHost = g === void 0 ? neverExecHostName(fn2) : null;
242461
+ const blockedHost = g === void 0 ? blockHostSideEffect(fn2) : null;
242285
242462
  if (g !== void 0) {
242286
242463
  result = g;
242287
242464
  } else if (blockedHost !== null) {
242288
- noteHostEffectBlocked(blockedHost);
242289
- result = bTruncatedAbs();
242465
+ result = blockedHost;
242290
242466
  } else {
242291
242467
  const entered = bEnterCall(name, fn2, args);
242292
242468
  if (!entered.ok) {
@@ -242557,6 +242733,8 @@ function $new(cls, args) {
242557
242733
  }
242558
242734
  }
242559
242735
  if (typeof cls === "function") {
242736
+ const blockedHost = blockHostSideEffect(cls);
242737
+ if (blockedHost) return blockedHost;
242560
242738
  if (cls === Array) {
242561
242739
  return makeArrayCtorAbs(args);
242562
242740
  }
@@ -242851,13 +243029,11 @@ function $invoke(thisVal, method, args, loc) {
242851
243029
  }
242852
243030
  const brandName = thisVal.shape.k === "brand" ? thisVal.shape.name : void 0;
242853
243031
  if (brandName) {
242854
- if (brandName === "Map" || brandName === "Set") {
242855
- const viaCol = evalBuiltinInstanceMethod(brandName, method, thisVal, args);
242856
- if (viaCol !== void 0) return viaCol;
242857
- if (method === "forEach") {
242858
- const r = $collectionForEach(thisVal, args[0]);
242859
- if (r !== void 0) return r;
242860
- }
243032
+ const viaBuiltin = evalBuiltinInstanceMethod(brandName, method, thisVal, args);
243033
+ if (viaBuiltin !== void 0) return viaBuiltin;
243034
+ if ((brandName === "Map" || brandName === "Set") && method === "forEach") {
243035
+ const r = $collectionForEach(thisVal, args[0]);
243036
+ if (r !== void 0) return r;
242861
243037
  }
242862
243038
  const m = findMethod(brandName, method);
242863
243039
  if (m) {
@@ -244856,37 +245032,105 @@ function parseObjectLiteral(content) {
244856
245032
  }
244857
245033
  return absExact({ k: "obj", slots });
244858
245034
  }
245035
+ function scanWithStrings(s, onChar, onStructural) {
245036
+ let depth = 0;
245037
+ let inString = null;
245038
+ for (let i = 0; i < s.length; i++) {
245039
+ const ch = s[i];
245040
+ if (inString) {
245041
+ onChar(ch, i);
245042
+ if (ch === "\\") {
245043
+ i++;
245044
+ if (i < s.length) onChar(s[i], i);
245045
+ continue;
245046
+ }
245047
+ if (ch === inString) inString = null;
245048
+ continue;
245049
+ }
245050
+ if (ch === '"' || ch === "'") {
245051
+ inString = ch;
245052
+ onChar(ch, i);
245053
+ continue;
245054
+ }
245055
+ if (ch === "(" || ch === "[" || ch === "{") {
245056
+ depth++;
245057
+ onChar(ch, i);
245058
+ onStructural(ch, i, depth);
245059
+ continue;
245060
+ }
245061
+ if (ch === ")" || ch === "]" || ch === "}") {
245062
+ depth--;
245063
+ onChar(ch, i);
245064
+ onStructural(ch, i, depth);
245065
+ continue;
245066
+ }
245067
+ onChar(ch, i);
245068
+ onStructural(ch, i, depth);
245069
+ }
245070
+ }
244859
245071
  function splitTopLevelArgs(s) {
244860
245072
  const result = [];
244861
- let depth = 0;
244862
245073
  let current = "";
244863
- for (const ch of s) {
245074
+ let depth = 0;
245075
+ let inString = null;
245076
+ for (let i = 0; i < s.length; i++) {
245077
+ const ch = s[i];
245078
+ if (inString) {
245079
+ current += ch;
245080
+ if (ch === "\\") {
245081
+ i++;
245082
+ if (i < s.length) current += s[i];
245083
+ continue;
245084
+ }
245085
+ if (ch === inString) inString = null;
245086
+ continue;
245087
+ }
245088
+ if (ch === '"' || ch === "'") {
245089
+ inString = ch;
245090
+ current += ch;
245091
+ continue;
245092
+ }
244864
245093
  if (ch === "(" || ch === "[" || ch === "{") depth++;
244865
245094
  if (ch === ")" || ch === "]" || ch === "}") depth--;
244866
245095
  if (ch === "," && depth === 0) {
244867
245096
  result.push(current.trim());
244868
245097
  current = "";
244869
- } else {
244870
- current += ch;
245098
+ continue;
244871
245099
  }
245100
+ current += ch;
244872
245101
  }
244873
245102
  if (current.trim()) result.push(current.trim());
244874
245103
  return result;
244875
245104
  }
244876
245105
  function findTopLevelColon(s) {
244877
- let depth = 0;
244878
- for (let i = 0; i < s.length; i++) {
244879
- const ch = s[i];
244880
- if (ch === "(" || ch === "[" || ch === "{") depth++;
244881
- if (ch === ")" || ch === "]" || ch === "}") depth--;
244882
- if (ch === ":" && depth === 0) return i;
244883
- }
244884
- return -1;
245106
+ let found = -1;
245107
+ scanWithStrings(
245108
+ s,
245109
+ () => {
245110
+ },
245111
+ (ch, i, depth) => {
245112
+ if (found === -1 && ch === ":" && depth === 0) found = i;
245113
+ }
245114
+ );
245115
+ return found;
244885
245116
  }
244886
245117
  function findTopLevelArrow(s) {
244887
245118
  let depth = 0;
245119
+ let inString = null;
244888
245120
  for (let i = 0; i < s.length - 1; i++) {
244889
245121
  const ch = s[i];
245122
+ if (inString) {
245123
+ if (ch === "\\") {
245124
+ i++;
245125
+ continue;
245126
+ }
245127
+ if (ch === inString) inString = null;
245128
+ continue;
245129
+ }
245130
+ if (ch === '"' || ch === "'") {
245131
+ inString = ch;
245132
+ continue;
245133
+ }
244890
245134
  if (ch === "(" || ch === "[" || ch === "{") depth++;
244891
245135
  else if (ch === ")" || ch === "]" || ch === "}") depth--;
244892
245136
  else if (depth === 0 && ch === "=" && s[i + 1] === ">") return i;
@@ -244896,9 +245140,23 @@ function findTopLevelArrow(s) {
244896
245140
  function extractBalancedParens(text, startIdx) {
244897
245141
  if (text[startIdx] !== "(") return null;
244898
245142
  let depth = 0;
245143
+ let inString = null;
244899
245144
  for (let i = startIdx; i < text.length; i++) {
244900
- if (text[i] === "(") depth++;
244901
- if (text[i] === ")") depth--;
245145
+ const ch = text[i];
245146
+ if (inString) {
245147
+ if (ch === "\\") {
245148
+ i++;
245149
+ continue;
245150
+ }
245151
+ if (ch === inString) inString = null;
245152
+ continue;
245153
+ }
245154
+ if (ch === '"' || ch === "'") {
245155
+ inString = ch;
245156
+ continue;
245157
+ }
245158
+ if (ch === "(") depth++;
245159
+ if (ch === ")") depth--;
244902
245160
  if (depth === 0) return text.slice(startIdx + 1, i);
244903
245161
  }
244904
245162
  return null;
@@ -245255,7 +245513,7 @@ function extractFileDirectives(ast) {
245255
245513
  return results;
245256
245514
  }
245257
245515
 
245258
- // ../service/dist/chunk-ZXVAX7DE.js
245516
+ // ../service/dist/chunk-COMUCF3K.js
245259
245517
  import { readFileSync, existsSync, statSync, mkdirSync, writeFileSync } from "fs";
245260
245518
  import { resolve as resolvePath, join as joinPath } from "path";
245261
245519
  import { pathToFileURL } from "url";
@@ -247128,7 +247386,7 @@ function defineEnv3() {
247128
247386
  };
247129
247387
  }
247130
247388
 
247131
- // ../service/dist/chunk-ZXVAX7DE.js
247389
+ // ../service/dist/chunk-COMUCF3K.js
247132
247390
  function hasOwnProp(props, name) {
247133
247391
  return Object.prototype.hasOwnProperty.call(props, name);
247134
247392
  }