@barefootjs/cli 0.31.4 → 0.31.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3739,7 +3739,7 @@ var init_binding_scope = __esm({
3739
3739
  * qualifies, including a preamble local shadowing a module const.
3740
3740
  * These call `isBound` / `boundNames()`.
3741
3741
  * - REACTIVITY / SLOT-ID CLASSIFIERS (`referencesLoopParam`,
3742
- * `hasReactiveAttributes`, and the `BindingEnvironment.loopParams`
3742
+ * `hasReactiveAttributes`, and the `BindingEnvironment.loopValueBoundNames`
3743
3743
  * feed built from `makeBindingEnv`, all in `jsx-to-ir.ts`) ask
3744
3744
  * "does this expression read a value that changes per row and so
3745
3745
  * needs its own patchable slot" — a preamble local already gets
@@ -4963,6 +4963,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4963
4963
  case "expression":
4964
4964
  if (node.expr === "null" || node.expr === "undefined") return "";
4965
4965
  if (node.clientOnly && node.slotId) {
4966
+ if (node.markerless) return "";
4966
4967
  return `<!--bf:${node.slotId}--><!--/-->`;
4967
4968
  }
4968
4969
  {
@@ -9328,7 +9329,7 @@ function pickAttrMetaFromIR(src) {
9328
9329
  ...src.freeIdentifiers !== void 0 && { freeIdentifiers: src.freeIdentifiers }
9329
9330
  };
9330
9331
  }
9331
- var SCOPE_FORBIDDEN, REACTIVE_BINDING_KINDS, AttrValueOf;
9332
+ var SCOPE_FORBIDDEN, REACTIVE_BINDING_KINDS, AttrValueOf, ESCAPE_SSR_COST;
9332
9333
  var init_types = __esm({
9333
9334
  "../jsx/src/types.ts"() {
9334
9335
  "use strict";
@@ -9400,10 +9401,19 @@ var init_types = __esm({
9400
9401
  return { kind: "jsx-children", children: children2 };
9401
9402
  }
9402
9403
  };
9404
+ ESCAPE_SSR_COST = {
9405
+ // `/* @client */` — compiles and hydrates correctly, renders nothing at SSR.
9406
+ "client-directive": "client-render",
9407
+ // The refused computation moves to an already-computed prop.
9408
+ "prop-precompute": "none",
9409
+ // The source is restructured into an equivalent in-subset shape.
9410
+ rewrite: "none"
9411
+ };
9403
9412
  }
9404
9413
  });
9405
9414
 
9406
9415
  // ../jsx/src/module-exports.ts
9416
+ import ts10 from "typescript";
9407
9417
  function generateModuleExports(ir, extraInlineExported = /* @__PURE__ */ new Set(), rewriteRelativeImport, options2) {
9408
9418
  const lines = [];
9409
9419
  for (const constant of options2?.skipValueDeclarations ? [] : ir.metadata.localConstants) {
@@ -9491,6 +9501,52 @@ function findReachableNames(primaryRefs, declarations) {
9491
9501
  }
9492
9502
  return reachable;
9493
9503
  }
9504
+ function findAssignedNames(bodyText, candidates) {
9505
+ const assigned = /* @__PURE__ */ new Set();
9506
+ if (candidates.size === 0) return assigned;
9507
+ const sf = ts10.createSourceFile(
9508
+ "bf-assignment-scan.tsx",
9509
+ bodyText,
9510
+ ts10.ScriptTarget.Latest,
9511
+ /* setParentNodes */
9512
+ false,
9513
+ ts10.ScriptKind.TSX
9514
+ );
9515
+ const record = (target2) => {
9516
+ if (ts10.isIdentifier(target2) && candidates.has(target2.text)) {
9517
+ assigned.add(target2.text);
9518
+ }
9519
+ };
9520
+ const visit3 = (node) => {
9521
+ if (ts10.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
9522
+ record(node.left);
9523
+ } else if ((ts10.isPrefixUnaryExpression(node) || ts10.isPostfixUnaryExpression(node)) && (node.operator === ts10.SyntaxKind.PlusPlusToken || node.operator === ts10.SyntaxKind.MinusMinusToken)) {
9524
+ record(node.operand);
9525
+ }
9526
+ ts10.forEachChild(node, visit3);
9527
+ };
9528
+ ts10.forEachChild(sf, visit3);
9529
+ return assigned;
9530
+ }
9531
+ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
9532
+ let reachable = findReachableNames(primaryRefs, declarations);
9533
+ if (mutableNames.size === 0) return reachable;
9534
+ let seedText = primaryRefs;
9535
+ for (let round = 0; round <= declarations.length; round++) {
9536
+ const survivingMutables = new Set(
9537
+ [...reachable].filter((name2) => mutableNames.has(name2))
9538
+ );
9539
+ if (survivingMutables.size === 0) return reachable;
9540
+ const added = declarations.filter((d) => !reachable.has(d.name)).filter((d) => findAssignedNames(d.body, survivingMutables).size > 0).map((d) => d.name);
9541
+ if (added.length === 0) return reachable;
9542
+ seedText += "\n" + added.join("\n");
9543
+ reachable = findReachableNames(seedText, declarations);
9544
+ }
9545
+ return reachable;
9546
+ }
9547
+ function isAssignmentOperator(kind2) {
9548
+ return kind2 >= ts10.SyntaxKind.FirstAssignment && kind2 <= ts10.SyntaxKind.LastAssignment;
9549
+ }
9494
9550
  function extractFunctionParams(value2) {
9495
9551
  const arrowMatch = value2.match(/^(?:async\s*)?\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/);
9496
9552
  if (arrowMatch) {
@@ -9543,7 +9599,7 @@ var init_builtins = __esm({
9543
9599
  });
9544
9600
 
9545
9601
  // ../jsx/src/reactivity-checker.ts
9546
- import ts10 from "typescript";
9602
+ import ts11 from "typescript";
9547
9603
  function queryType(checker, node) {
9548
9604
  incrementCounter("typeCheckerQueries");
9549
9605
  return checker.getTypeAtLocation(node);
@@ -9559,7 +9615,7 @@ function safeGetText(node) {
9559
9615
  }
9560
9616
  }
9561
9617
  function analyze(node, checker) {
9562
- if (ts10.isPropertyAccessExpression(node)) {
9618
+ if (ts11.isPropertyAccessExpression(node)) {
9563
9619
  try {
9564
9620
  const type2 = queryType(checker, node);
9565
9621
  if (isReactiveType(type2)) {
@@ -9584,7 +9640,7 @@ function analyze(node, checker) {
9584
9640
  }
9585
9641
  return NOT_REACTIVE;
9586
9642
  }
9587
- if (ts10.isIdentifier(node)) {
9643
+ if (ts11.isIdentifier(node)) {
9588
9644
  try {
9589
9645
  const type2 = queryType(checker, node);
9590
9646
  if (isReactiveType(type2)) {
@@ -9597,7 +9653,7 @@ function analyze(node, checker) {
9597
9653
  }
9598
9654
  return NOT_REACTIVE;
9599
9655
  }
9600
- if (ts10.isCallExpression(node)) {
9656
+ if (ts11.isCallExpression(node)) {
9601
9657
  try {
9602
9658
  const calleeType = queryType(checker, node.expression);
9603
9659
  if (isReactiveType(calleeType)) {
@@ -9611,7 +9667,7 @@ function analyze(node, checker) {
9611
9667
  }
9612
9668
  let foundChild;
9613
9669
  let foundChildText = "";
9614
- ts10.forEachChild(node, (child) => {
9670
+ ts11.forEachChild(node, (child) => {
9615
9671
  if (foundChild?.isReactive) return;
9616
9672
  const result2 = analyze(child, checker);
9617
9673
  if (result2.isReactive) {
@@ -9648,7 +9704,7 @@ var init_reactivity_checker = __esm({
9648
9704
  });
9649
9705
 
9650
9706
  // ../jsx/src/free-refs.ts
9651
- import ts11 from "typescript";
9707
+ import ts12 from "typescript";
9652
9708
  function buildBindingMap(env) {
9653
9709
  const cached = _bindingMapCache.get(env);
9654
9710
  if (cached) return cached;
@@ -9682,8 +9738,8 @@ function buildBindingMap(env) {
9682
9738
  for (const m of env.memos) {
9683
9739
  map.set(m.name, "memo-getter");
9684
9740
  }
9685
- if (env.loopParams) {
9686
- for (const name2 of env.loopParams) map.set(name2, "render-item");
9741
+ if (env.loopValueBoundNames) {
9742
+ for (const name2 of env.loopValueBoundNames) map.set(name2, "render-item");
9687
9743
  }
9688
9744
  _bindingMapCache.set(env, map);
9689
9745
  return map;
@@ -9712,17 +9768,17 @@ function defaultBindingScope(kind2) {
9712
9768
  function collectIdentifiers2(node) {
9713
9769
  const out = [];
9714
9770
  const visit3 = (n, parent2) => {
9715
- if (ts11.isIdentifier(n)) {
9716
- if (parent2 && ts11.isPropertyAccessExpression(parent2) && parent2.name === n) return;
9717
- if (parent2 && ts11.isPropertyAssignment(parent2) && parent2.name === n) return;
9718
- if (parent2 && (ts11.isJsxOpeningElement(parent2) || ts11.isJsxClosingElement(parent2) || ts11.isJsxSelfClosingElement(parent2)) && parent2.tagName === n) {
9771
+ if (ts12.isIdentifier(n)) {
9772
+ if (parent2 && ts12.isPropertyAccessExpression(parent2) && parent2.name === n) return;
9773
+ if (parent2 && ts12.isPropertyAssignment(parent2) && parent2.name === n) return;
9774
+ if (parent2 && (ts12.isJsxOpeningElement(parent2) || ts12.isJsxClosingElement(parent2) || ts12.isJsxSelfClosingElement(parent2)) && parent2.tagName === n) {
9719
9775
  return;
9720
9776
  }
9721
- if (parent2 && ts11.isJsxAttribute(parent2) && parent2.name === n) return;
9777
+ if (parent2 && ts12.isJsxAttribute(parent2) && parent2.name === n) return;
9722
9778
  out.push(n);
9723
9779
  return;
9724
9780
  }
9725
- ts11.forEachChild(n, (child) => visit3(child, n));
9781
+ ts12.forEachChild(n, (child) => visit3(child, n));
9726
9782
  };
9727
9783
  visit3(node);
9728
9784
  return out;
@@ -9731,7 +9787,7 @@ function collectReactiveBrandRefs(node, checker) {
9731
9787
  const out = [];
9732
9788
  const seen = /* @__PURE__ */ new Set();
9733
9789
  const visit3 = (n) => {
9734
- if (ts11.isPropertyAccessExpression(n)) {
9790
+ if (ts12.isPropertyAccessExpression(n)) {
9735
9791
  try {
9736
9792
  const type2 = checker.getTypeAtLocation(n);
9737
9793
  if (isReactiveType(type2)) {
@@ -9749,7 +9805,7 @@ function collectReactiveBrandRefs(node, checker) {
9749
9805
  incrementCounter("freeRefsTypeLookupFailures");
9750
9806
  }
9751
9807
  }
9752
- ts11.forEachChild(n, visit3);
9808
+ ts12.forEachChild(n, visit3);
9753
9809
  };
9754
9810
  visit3(node);
9755
9811
  return out;
@@ -9757,17 +9813,17 @@ function collectReactiveBrandRefs(node, checker) {
9757
9813
  function resolveConstantInitializerRefs(c, env, visited) {
9758
9814
  if (c.value === void 0) return [];
9759
9815
  if (c.containsArrow) return [];
9760
- const sf = ts11.createSourceFile(
9816
+ const sf = ts12.createSourceFile(
9761
9817
  "__const_init.ts",
9762
9818
  `const __probe = (${c.value});`,
9763
- ts11.ScriptTarget.Latest,
9819
+ ts12.ScriptTarget.Latest,
9764
9820
  true
9765
9821
  );
9766
9822
  const stmt = sf.statements[0];
9767
- if (!stmt || !ts11.isVariableStatement(stmt)) return [];
9823
+ if (!stmt || !ts12.isVariableStatement(stmt)) return [];
9768
9824
  const decl = stmt.declarationList.declarations[0];
9769
9825
  if (!decl || !decl.initializer) return [];
9770
- const expr = ts11.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9826
+ const expr = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9771
9827
  return resolveFreeRefsInternal(expr, env, visited);
9772
9828
  }
9773
9829
  function resolveFreeRefsInternal(node, env, visited) {
@@ -9779,7 +9835,7 @@ function resolveFreeRefsInternal(node, env, visited) {
9779
9835
  const name2 = ident.text;
9780
9836
  if (env.propsObjectName === name2) {
9781
9837
  const parent2 = ident.parent;
9782
- if (parent2 && ts11.isPropertyAccessExpression(parent2) && parent2.expression === ident && parent2.name.text === "children") {
9838
+ if (parent2 && ts12.isPropertyAccessExpression(parent2) && parent2.expression === ident && parent2.name.text === "children") {
9783
9839
  continue;
9784
9840
  }
9785
9841
  }
@@ -10174,7 +10230,7 @@ var init_to_locale_date_lowering = __esm({
10174
10230
  });
10175
10231
 
10176
10232
  // ../jsx/src/jsx-to-ir.ts
10177
- import ts12 from "typescript";
10233
+ import ts13 from "typescript";
10178
10234
  function hasLeadingClientDirective(expr, sourceFile) {
10179
10235
  const trivia = sourceFile.text.slice(expr.pos, expr.getStart(sourceFile));
10180
10236
  BLOCK_COMMENT_RE2.lastIndex = 0;
@@ -10195,13 +10251,13 @@ function exprCallsReactiveGetters(expr, ctx2) {
10195
10251
  let found = false;
10196
10252
  function visit3(n) {
10197
10253
  if (found) return;
10198
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
10254
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
10199
10255
  if (names.has(n.expression.text)) {
10200
10256
  found = true;
10201
10257
  return;
10202
10258
  }
10203
10259
  }
10204
- ts12.forEachChild(n, visit3);
10260
+ ts13.forEachChild(n, visit3);
10205
10261
  }
10206
10262
  visit3(expr);
10207
10263
  return found;
@@ -10224,11 +10280,11 @@ function exprReferencesModuleClientSignal(expr, ctx2) {
10224
10280
  let found = false;
10225
10281
  function visit3(n) {
10226
10282
  if (found) return;
10227
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression) && names.has(n.expression.text)) {
10283
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression) && names.has(n.expression.text)) {
10228
10284
  found = true;
10229
10285
  return;
10230
10286
  }
10231
- ts12.forEachChild(n, visit3);
10287
+ ts13.forEachChild(n, visit3);
10232
10288
  }
10233
10289
  visit3(expr);
10234
10290
  return found;
@@ -10237,11 +10293,11 @@ function exprHasFunctionCalls(expr) {
10237
10293
  let found = false;
10238
10294
  function visit3(n) {
10239
10295
  if (found) return;
10240
- if (ts12.isCallExpression(n)) {
10296
+ if (ts13.isCallExpression(n)) {
10241
10297
  found = true;
10242
10298
  return;
10243
10299
  }
10244
- ts12.forEachChild(n, visit3);
10300
+ ts13.forEachChild(n, visit3);
10245
10301
  }
10246
10302
  visit3(expr);
10247
10303
  return found;
@@ -10277,10 +10333,10 @@ function lowerDateCalls(text, expr, ctx2) {
10277
10333
  if (!matcher) return text;
10278
10334
  const candidates = [];
10279
10335
  function visit3(n) {
10280
- if (ts12.isCallExpression(n) && n.arguments.length === 0 && ts12.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
10336
+ if (ts13.isCallExpression(n) && n.arguments.length === 0 && ts13.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
10281
10337
  candidates.push(n);
10282
10338
  }
10283
- ts12.forEachChild(n, visit3);
10339
+ ts13.forEachChild(n, visit3);
10284
10340
  }
10285
10341
  visit3(expr);
10286
10342
  if (candidates.length === 0) return text;
@@ -10302,10 +10358,10 @@ function lowerToLocaleDateCalls(text, expr, ctx2) {
10302
10358
  if (!matcher) return text;
10303
10359
  const candidates = [];
10304
10360
  function visit3(n) {
10305
- if (ts12.isCallExpression(n) && n.arguments.length === 2 && ts12.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
10361
+ if (ts13.isCallExpression(n) && n.arguments.length === 2 && ts13.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
10306
10362
  candidates.push(n);
10307
10363
  }
10308
- ts12.forEachChild(n, visit3);
10364
+ ts13.forEachChild(n, visit3);
10309
10365
  }
10310
10366
  visit3(expr);
10311
10367
  if (candidates.length === 0) return text;
@@ -10358,10 +10414,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx2) {
10358
10414
  if (!propDepsMap || !branchVars || propDepsMap.size === 0) return void 0;
10359
10415
  let acc;
10360
10416
  function visit3(n, parent2) {
10361
- if (ts12.isIdentifier(n) && propDepsMap.has(n.text)) {
10362
- const isObjectKey = parent2 && ts12.isPropertyAssignment(parent2) && parent2.name === n;
10363
- const isShorthand = parent2 && ts12.isShorthandPropertyAssignment(parent2) && parent2.name === n;
10364
- const isAccessName = parent2 && ts12.isPropertyAccessExpression(parent2) && parent2.name === n;
10417
+ if (ts13.isIdentifier(n) && propDepsMap.has(n.text)) {
10418
+ const isObjectKey = parent2 && ts13.isPropertyAssignment(parent2) && parent2.name === n;
10419
+ const isShorthand = parent2 && ts13.isShorthandPropertyAssignment(parent2) && parent2.name === n;
10420
+ const isAccessName = parent2 && ts13.isPropertyAccessExpression(parent2) && parent2.name === n;
10365
10421
  if (!isObjectKey && !isShorthand && !isAccessName) {
10366
10422
  const deps = propDepsMap.get(n.text);
10367
10423
  if (deps && deps.size > 0) {
@@ -10370,7 +10426,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx2) {
10370
10426
  }
10371
10427
  }
10372
10428
  }
10373
- ts12.forEachChild(n, (child) => visit3(child, n));
10429
+ ts13.forEachChild(n, (child) => visit3(child, n));
10374
10430
  }
10375
10431
  visit3(node);
10376
10432
  return acc;
@@ -10442,17 +10498,17 @@ function createTransformContext(analyzer) {
10442
10498
  function buildComponentNamespaces(ctx2) {
10443
10499
  const result2 = /* @__PURE__ */ new Map();
10444
10500
  for (const stmt of ctx2.sourceFile.statements) {
10445
- if (!ts12.isVariableStatement(stmt)) continue;
10501
+ if (!ts13.isVariableStatement(stmt)) continue;
10446
10502
  for (const decl of stmt.declarationList.declarations) {
10447
- if (!decl.initializer || !ts12.isIdentifier(decl.name)) continue;
10503
+ if (!decl.initializer || !ts13.isIdentifier(decl.name)) continue;
10448
10504
  let init = decl.initializer;
10449
- while (ts12.isParenthesizedExpression(init)) init = init.expression;
10450
- if (!ts12.isObjectLiteralExpression(init)) continue;
10505
+ while (ts13.isParenthesizedExpression(init)) init = init.expression;
10506
+ if (!ts13.isObjectLiteralExpression(init)) continue;
10451
10507
  const members = /* @__PURE__ */ new Map();
10452
10508
  for (const prop of init.properties) {
10453
- if (ts12.isShorthandPropertyAssignment(prop)) {
10509
+ if (ts13.isShorthandPropertyAssignment(prop)) {
10454
10510
  members.set(prop.name.text, prop.name.text);
10455
- } else if (ts12.isPropertyAssignment(prop) && (ts12.isIdentifier(prop.name) || ts12.isStringLiteral(prop.name)) && ts12.isIdentifier(prop.initializer)) {
10511
+ } else if (ts13.isPropertyAssignment(prop) && (ts13.isIdentifier(prop.name) || ts13.isStringLiteral(prop.name)) && ts13.isIdentifier(prop.initializer)) {
10456
10512
  members.set(prop.name.text, prop.initializer.text);
10457
10513
  }
10458
10514
  }
@@ -10464,9 +10520,9 @@ function buildComponentNamespaces(ctx2) {
10464
10520
  return result2;
10465
10521
  }
10466
10522
  function resolveMemberExpressionTag(tagNode, ctx2) {
10467
- if (!ts12.isPropertyAccessExpression(tagNode)) return null;
10468
- if (!ts12.isIdentifier(tagNode.expression)) return null;
10469
- if (!ts12.isIdentifier(tagNode.name)) return null;
10523
+ if (!ts13.isPropertyAccessExpression(tagNode)) return null;
10524
+ if (!ts13.isIdentifier(tagNode.expression)) return null;
10525
+ if (!ts13.isIdentifier(tagNode.name)) return null;
10470
10526
  if (!ctx2._componentNamespaces) {
10471
10527
  ctx2._componentNamespaces = buildComponentNamespaces(ctx2);
10472
10528
  }
@@ -10501,7 +10557,7 @@ function makeBindingEnv(ctx2) {
10501
10557
  // mutated (cached on the immutable `BindingScope`) — a stable
10502
10558
  // snapshot even if `ctx.scope` is later reassigned by an enclosing
10503
10559
  // visitor frame, which swaps the instance rather than mutating it.
10504
- loopParams: boundNames,
10560
+ loopValueBoundNames: boundNames,
10505
10561
  checker: a.checker
10506
10562
  };
10507
10563
  ctx2._bindingEnv = env;
@@ -10607,7 +10663,7 @@ function buildIRRoot(analyzer) {
10607
10663
  if (!analyzer.jsxReturn) return null;
10608
10664
  const ctx2 = createTransformContext(analyzer);
10609
10665
  const jsxReturn = analyzer.jsxReturn;
10610
- if (ts12.isJsxElement(jsxReturn) || ts12.isJsxSelfClosingElement(jsxReturn) || ts12.isJsxFragment(jsxReturn)) {
10666
+ if (ts13.isJsxElement(jsxReturn) || ts13.isJsxSelfClosingElement(jsxReturn) || ts13.isJsxFragment(jsxReturn)) {
10611
10667
  const ir2 = transformNode(jsxReturn, ctx2);
10612
10668
  if (ir2 && needsScopeWrapper(ir2)) {
10613
10669
  return wrapInScopeElement(ir2);
@@ -10660,22 +10716,22 @@ function wrapInScopeElement(node) {
10660
10716
  };
10661
10717
  }
10662
10718
  function transformNode(node, ctx2) {
10663
- if (ts12.isJsxElement(node)) {
10719
+ if (ts13.isJsxElement(node)) {
10664
10720
  return transformJsxElement(node, ctx2);
10665
10721
  }
10666
- if (ts12.isJsxSelfClosingElement(node)) {
10722
+ if (ts13.isJsxSelfClosingElement(node)) {
10667
10723
  return transformSelfClosingElement(node, ctx2);
10668
10724
  }
10669
- if (ts12.isJsxFragment(node)) {
10725
+ if (ts13.isJsxFragment(node)) {
10670
10726
  return transformFragment(node, ctx2);
10671
10727
  }
10672
- if (ts12.isJsxText(node)) {
10728
+ if (ts13.isJsxText(node)) {
10673
10729
  return transformText(node, ctx2);
10674
10730
  }
10675
- if (ts12.isJsxExpression(node)) {
10731
+ if (ts13.isJsxExpression(node)) {
10676
10732
  return transformExpression(node, ctx2);
10677
10733
  }
10678
- if (ts12.isConditionalExpression(node)) {
10734
+ if (ts13.isConditionalExpression(node)) {
10679
10735
  return transformConditional(node, ctx2);
10680
10736
  }
10681
10737
  return null;
@@ -11054,14 +11110,14 @@ function transformSelfClosingComponent(node, ctx2, name2) {
11054
11110
  }
11055
11111
  function isTransparentFragment(node, ctx2) {
11056
11112
  const children2 = node.children.filter((child2) => {
11057
- if (ts12.isJsxText(child2)) {
11113
+ if (ts13.isJsxText(child2)) {
11058
11114
  return child2.text.trim() !== "";
11059
11115
  }
11060
11116
  return true;
11061
11117
  });
11062
11118
  if (children2.length !== 1) return false;
11063
11119
  const child = children2[0];
11064
- if (!ts12.isJsxExpression(child)) return false;
11120
+ if (!ts13.isJsxExpression(child)) return false;
11065
11121
  if (!child.expression) return false;
11066
11122
  const exprText = child.expression.getText(ctx2.sourceFile);
11067
11123
  if (exprText === "children") return true;
@@ -11100,7 +11156,7 @@ function transformChildren(children2, ctx2) {
11100
11156
  const result2 = [];
11101
11157
  for (let i = 0; i < children2.length; i++) {
11102
11158
  const child = children2[i];
11103
- if (ts12.isJsxExpression(child) && !child.expression) {
11159
+ if (ts13.isJsxExpression(child) && !child.expression) {
11104
11160
  continue;
11105
11161
  }
11106
11162
  const transformed = transformNode(child, ctx2);
@@ -11115,10 +11171,10 @@ function transformChildren(children2, ctx2) {
11115
11171
  }
11116
11172
  function isRenderNothingLiteral(expr, ctx2) {
11117
11173
  let e = expr;
11118
- while (ts12.isParenthesizedExpression(e) || ts12.isAsExpression(e) || ts12.isSatisfiesExpression(e) || ts12.isNonNullExpression(e)) {
11174
+ while (ts13.isParenthesizedExpression(e) || ts13.isAsExpression(e) || ts13.isSatisfiesExpression(e) || ts13.isNonNullExpression(e)) {
11119
11175
  e = e.expression;
11120
11176
  }
11121
- return e.kind === ts12.SyntaxKind.NullKeyword || e.kind === ts12.SyntaxKind.TrueKeyword || e.kind === ts12.SyntaxKind.FalseKeyword || ts12.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx2));
11177
+ return e.kind === ts13.SyntaxKind.NullKeyword || e.kind === ts13.SyntaxKind.TrueKeyword || e.kind === ts13.SyntaxKind.FalseKeyword || ts13.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx2));
11122
11178
  }
11123
11179
  function transformText(node, ctx2) {
11124
11180
  const text = node.text.replace(/\s+/g, " ");
@@ -11148,7 +11204,7 @@ function transformExpressionInner(expr, ctx2, node, isClientOnly) {
11148
11204
  return null;
11149
11205
  }
11150
11206
  checkBareSignalOrMemoIdentifier(expr, ctx2);
11151
- if (ts12.isIdentifier(expr)) {
11207
+ if (ts13.isIdentifier(expr)) {
11152
11208
  const jsxNode = ctx2.analyzer.jsxConstants.get(expr.text);
11153
11209
  if (jsxNode) {
11154
11210
  return transformNode(jsxNode, ctx2);
@@ -11436,35 +11492,35 @@ function transformLogicalAnd(node, ctx2) {
11436
11492
  };
11437
11493
  }
11438
11494
  function containsJsxInExpression(node) {
11439
- if (ts12.isJsxElement(node) || ts12.isJsxSelfClosingElement(node) || ts12.isJsxFragment(node)) {
11495
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node)) {
11440
11496
  return true;
11441
11497
  }
11442
- return ts12.forEachChild(node, containsJsxInExpression) ?? false;
11498
+ return ts13.forEachChild(node, containsJsxInExpression) ?? false;
11443
11499
  }
11444
11500
  function callsJsxHelper(node, ctx2) {
11445
11501
  let found = false;
11446
11502
  const visit3 = (n) => {
11447
11503
  if (found) return;
11448
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
11504
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
11449
11505
  const name2 = n.expression.text;
11450
11506
  if (ctx2.analyzer.jsxFunctions.has(name2) || ctx2.analyzer.jsxMultiReturnFunctions.has(name2)) {
11451
11507
  found = true;
11452
11508
  return;
11453
11509
  }
11454
11510
  }
11455
- ts12.forEachChild(n, visit3);
11511
+ ts13.forEachChild(n, visit3);
11456
11512
  };
11457
11513
  visit3(node);
11458
11514
  return found;
11459
11515
  }
11460
11516
  function containsAwaitExpression(node) {
11461
- if (ts12.isAwaitExpression(node)) return true;
11462
- if (ts12.isFunctionDeclaration(node) || ts12.isFunctionExpression(node) || ts12.isArrowFunction(node)) return false;
11463
- return ts12.forEachChild(node, containsAwaitExpression) ?? false;
11517
+ if (ts13.isAwaitExpression(node)) return true;
11518
+ if (ts13.isFunctionDeclaration(node) || ts13.isFunctionExpression(node) || ts13.isArrowFunction(node)) return false;
11519
+ return ts13.forEachChild(node, containsAwaitExpression) ?? false;
11464
11520
  }
11465
11521
  function transformNullishCoalescing(node, ctx2) {
11466
11522
  const leftText = ctx2.getJS(node.left);
11467
- const isNullish = node.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken;
11523
+ const isNullish = node.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken;
11468
11524
  const condition = isNullish ? `${leftText} != null` : leftText;
11469
11525
  const leftOrigin = {
11470
11526
  phase: "tick",
@@ -11511,46 +11567,46 @@ function transformNullishCoalescing(node, ctx2) {
11511
11567
  function assertNever2(expr) {
11512
11568
  const kind2 = expr?.kind;
11513
11569
  throw new Error(
11514
- `transformJsxExpression: unhandled ts.SyntaxKind ${kind2 !== void 0 ? ts12.SyntaxKind[kind2] : "unknown"} (kind=${kind2}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`
11570
+ `transformJsxExpression: unhandled ts.SyntaxKind ${kind2 !== void 0 ? ts13.SyntaxKind[kind2] : "unknown"} (kind=${kind2}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`
11515
11571
  );
11516
11572
  }
11517
11573
  function transformJsxExpression(expr, ctx2, isClientOnly = false) {
11518
11574
  const node = expr;
11519
11575
  switch (node.kind) {
11520
11576
  // --- Transparent: unwrap and recurse ---
11521
- case ts12.SyntaxKind.ParenthesizedExpression:
11522
- case ts12.SyntaxKind.AsExpression:
11523
- case ts12.SyntaxKind.SatisfiesExpression:
11524
- case ts12.SyntaxKind.NonNullExpression:
11525
- case ts12.SyntaxKind.TypeAssertionExpression:
11526
- case ts12.SyntaxKind.PartiallyEmittedExpression:
11577
+ case ts13.SyntaxKind.ParenthesizedExpression:
11578
+ case ts13.SyntaxKind.AsExpression:
11579
+ case ts13.SyntaxKind.SatisfiesExpression:
11580
+ case ts13.SyntaxKind.NonNullExpression:
11581
+ case ts13.SyntaxKind.TypeAssertionExpression:
11582
+ case ts13.SyntaxKind.PartiallyEmittedExpression:
11527
11583
  return transformJsxExpression(node.expression, ctx2, isClientOnly);
11528
11584
  // --- JSX-structural: delegate to shape transformer ---
11529
- case ts12.SyntaxKind.JsxElement:
11585
+ case ts13.SyntaxKind.JsxElement:
11530
11586
  return transformJsxElement(node, ctx2);
11531
- case ts12.SyntaxKind.JsxFragment:
11587
+ case ts13.SyntaxKind.JsxFragment:
11532
11588
  return transformFragment(node, ctx2);
11533
- case ts12.SyntaxKind.JsxSelfClosingElement:
11589
+ case ts13.SyntaxKind.JsxSelfClosingElement:
11534
11590
  return transformSelfClosingElement(node, ctx2);
11535
- case ts12.SyntaxKind.ConditionalExpression:
11591
+ case ts13.SyntaxKind.ConditionalExpression:
11536
11592
  return transformConditional(node, ctx2);
11537
- case ts12.SyntaxKind.BinaryExpression: {
11538
- if (node.operatorToken.kind === ts12.SyntaxKind.AmpersandAmpersandToken) {
11593
+ case ts13.SyntaxKind.BinaryExpression: {
11594
+ if (node.operatorToken.kind === ts13.SyntaxKind.AmpersandAmpersandToken) {
11539
11595
  return transformLogicalAnd(node, ctx2);
11540
11596
  }
11541
- if ((node.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === ts12.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx2))) {
11597
+ if ((node.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === ts13.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx2))) {
11542
11598
  return transformNullishCoalescing(node, ctx2);
11543
11599
  }
11544
11600
  return null;
11545
11601
  }
11546
- case ts12.SyntaxKind.CallExpression: {
11602
+ case ts13.SyntaxKind.CallExpression: {
11547
11603
  const mapMethod = getMapLikeMethod(node);
11548
11604
  if (mapMethod) {
11549
11605
  const mapResult = transformMapCall(node, ctx2, isClientOnly, mapMethod);
11550
11606
  if (mapResult) return mapResult;
11551
11607
  }
11552
11608
  const callee = node.expression;
11553
- if (ts12.isIdentifier(callee)) {
11609
+ if (ts13.isIdentifier(callee)) {
11554
11610
  const jsxFunc = ctx2.analyzer.jsxFunctions.get(callee.text);
11555
11611
  if (jsxFunc) {
11556
11612
  return transformJsxFunctionCall(node, jsxFunc, ctx2, isClientOnly);
@@ -11563,40 +11619,40 @@ function transformJsxExpression(expr, ctx2, isClientOnly = false) {
11563
11619
  return null;
11564
11620
  }
11565
11621
  // --- Scalar leaf: caller emits IRExpression ---
11566
- case ts12.SyntaxKind.Identifier:
11567
- case ts12.SyntaxKind.StringLiteral:
11568
- case ts12.SyntaxKind.NumericLiteral:
11569
- case ts12.SyntaxKind.BigIntLiteral:
11570
- case ts12.SyntaxKind.RegularExpressionLiteral:
11571
- case ts12.SyntaxKind.NoSubstitutionTemplateLiteral:
11572
- case ts12.SyntaxKind.TemplateExpression:
11573
- case ts12.SyntaxKind.TaggedTemplateExpression:
11574
- case ts12.SyntaxKind.TrueKeyword:
11575
- case ts12.SyntaxKind.FalseKeyword:
11576
- case ts12.SyntaxKind.NullKeyword:
11577
- case ts12.SyntaxKind.ThisKeyword:
11578
- case ts12.SyntaxKind.SuperKeyword:
11579
- case ts12.SyntaxKind.ImportKeyword:
11580
- case ts12.SyntaxKind.PropertyAccessExpression:
11581
- case ts12.SyntaxKind.ElementAccessExpression:
11582
- case ts12.SyntaxKind.PrefixUnaryExpression:
11583
- case ts12.SyntaxKind.PostfixUnaryExpression:
11584
- case ts12.SyntaxKind.TypeOfExpression:
11585
- case ts12.SyntaxKind.VoidExpression:
11586
- case ts12.SyntaxKind.DeleteExpression:
11587
- case ts12.SyntaxKind.NewExpression:
11588
- case ts12.SyntaxKind.ObjectLiteralExpression:
11589
- case ts12.SyntaxKind.ArrowFunction:
11590
- case ts12.SyntaxKind.FunctionExpression:
11591
- case ts12.SyntaxKind.ClassExpression:
11592
- case ts12.SyntaxKind.MetaProperty:
11593
- case ts12.SyntaxKind.ExpressionWithTypeArguments:
11594
- case ts12.SyntaxKind.CommaListExpression:
11595
- case ts12.SyntaxKind.SyntheticExpression:
11596
- case ts12.SyntaxKind.ArrayLiteralExpression:
11622
+ case ts13.SyntaxKind.Identifier:
11623
+ case ts13.SyntaxKind.StringLiteral:
11624
+ case ts13.SyntaxKind.NumericLiteral:
11625
+ case ts13.SyntaxKind.BigIntLiteral:
11626
+ case ts13.SyntaxKind.RegularExpressionLiteral:
11627
+ case ts13.SyntaxKind.NoSubstitutionTemplateLiteral:
11628
+ case ts13.SyntaxKind.TemplateExpression:
11629
+ case ts13.SyntaxKind.TaggedTemplateExpression:
11630
+ case ts13.SyntaxKind.TrueKeyword:
11631
+ case ts13.SyntaxKind.FalseKeyword:
11632
+ case ts13.SyntaxKind.NullKeyword:
11633
+ case ts13.SyntaxKind.ThisKeyword:
11634
+ case ts13.SyntaxKind.SuperKeyword:
11635
+ case ts13.SyntaxKind.ImportKeyword:
11636
+ case ts13.SyntaxKind.PropertyAccessExpression:
11637
+ case ts13.SyntaxKind.ElementAccessExpression:
11638
+ case ts13.SyntaxKind.PrefixUnaryExpression:
11639
+ case ts13.SyntaxKind.PostfixUnaryExpression:
11640
+ case ts13.SyntaxKind.TypeOfExpression:
11641
+ case ts13.SyntaxKind.VoidExpression:
11642
+ case ts13.SyntaxKind.DeleteExpression:
11643
+ case ts13.SyntaxKind.NewExpression:
11644
+ case ts13.SyntaxKind.ObjectLiteralExpression:
11645
+ case ts13.SyntaxKind.ArrowFunction:
11646
+ case ts13.SyntaxKind.FunctionExpression:
11647
+ case ts13.SyntaxKind.ClassExpression:
11648
+ case ts13.SyntaxKind.MetaProperty:
11649
+ case ts13.SyntaxKind.ExpressionWithTypeArguments:
11650
+ case ts13.SyntaxKind.CommaListExpression:
11651
+ case ts13.SyntaxKind.SyntheticExpression:
11652
+ case ts13.SyntaxKind.ArrayLiteralExpression:
11597
11653
  return null;
11598
11654
  // --- Forbidden in render position ---
11599
- case ts12.SyntaxKind.AwaitExpression:
11655
+ case ts13.SyntaxKind.AwaitExpression:
11600
11656
  ctx2.analyzer.errors.push(
11601
11657
  createError(
11602
11658
  ErrorCodes.STAGE_AWAIT_IN_TEMPLATE,
@@ -11612,20 +11668,20 @@ function transformJsxExpression(expr, ctx2, isClientOnly = false) {
11612
11668
  loc: getSourceLocation(node, ctx2.sourceFile, ctx2.filePath),
11613
11669
  origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
11614
11670
  };
11615
- case ts12.SyntaxKind.YieldExpression:
11671
+ case ts13.SyntaxKind.YieldExpression:
11616
11672
  return null;
11617
11673
  // --- Unreachable at render position ---
11618
11674
  // Parser prevents these in well-formed sources; listed for exhaustiveness
11619
11675
  // so an upstream TypeScript change that repurposes one of these kinds
11620
11676
  // surfaces as a compile error here instead of silently drifting.
11621
- case ts12.SyntaxKind.SpreadElement:
11622
- case ts12.SyntaxKind.OmittedExpression:
11623
- case ts12.SyntaxKind.JsxExpression:
11624
- case ts12.SyntaxKind.JsxOpeningElement:
11625
- case ts12.SyntaxKind.JsxOpeningFragment:
11626
- case ts12.SyntaxKind.JsxClosingFragment:
11627
- case ts12.SyntaxKind.JsxAttributes:
11628
- case ts12.SyntaxKind.MissingDeclaration:
11677
+ case ts13.SyntaxKind.SpreadElement:
11678
+ case ts13.SyntaxKind.OmittedExpression:
11679
+ case ts13.SyntaxKind.JsxExpression:
11680
+ case ts13.SyntaxKind.JsxOpeningElement:
11681
+ case ts13.SyntaxKind.JsxOpeningFragment:
11682
+ case ts13.SyntaxKind.JsxClosingFragment:
11683
+ case ts13.SyntaxKind.JsxAttributes:
11684
+ case ts13.SyntaxKind.MissingDeclaration:
11629
11685
  return null;
11630
11686
  default:
11631
11687
  return assertNever2(node);
@@ -11661,15 +11717,15 @@ function transformConditionalBranch(node, ctx2) {
11661
11717
  };
11662
11718
  }
11663
11719
  function getMapLikeMethod(node) {
11664
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11720
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11665
11721
  const name2 = node.expression.name.text;
11666
11722
  if (name2 === "map") return "map";
11667
11723
  if (name2 === "flatMap") return "flatMap";
11668
11724
  return null;
11669
11725
  }
11670
11726
  function isFilterCall(node) {
11671
- if (!ts12.isCallExpression(node)) return null;
11672
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11727
+ if (!ts13.isCallExpression(node)) return null;
11728
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11673
11729
  if (node.expression.name.text !== "filter") return null;
11674
11730
  if (node.arguments.length !== 1) return null;
11675
11731
  return {
@@ -11678,8 +11734,8 @@ function isFilterCall(node) {
11678
11734
  };
11679
11735
  }
11680
11736
  function isSortCall(node) {
11681
- if (!ts12.isCallExpression(node)) return null;
11682
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11737
+ if (!ts13.isCallExpression(node)) return null;
11738
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11683
11739
  const methodName = node.expression.name.text;
11684
11740
  if (methodName !== "sort" && methodName !== "toSorted") return null;
11685
11741
  if (node.arguments.length !== 1) return null;
@@ -11690,17 +11746,17 @@ function isSortCall(node) {
11690
11746
  };
11691
11747
  }
11692
11748
  function isIteratorShapeCall(node) {
11693
- if (!ts12.isCallExpression(node)) return null;
11694
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11749
+ if (!ts13.isCallExpression(node)) return null;
11750
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11695
11751
  if (node.arguments.length !== 0) return null;
11696
11752
  const name2 = node.expression.name.text;
11697
11753
  if (name2 !== "entries" && name2 !== "keys" && name2 !== "values") return null;
11698
11754
  return { array: node.expression.expression, shape: name2 };
11699
11755
  }
11700
11756
  function isObjectIteratorCall(node) {
11701
- if (!ts12.isCallExpression(node)) return null;
11702
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11703
- if (!ts12.isIdentifier(node.expression.expression)) return null;
11757
+ if (!ts13.isCallExpression(node)) return null;
11758
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11759
+ if (!ts13.isIdentifier(node.expression.expression)) return null;
11704
11760
  if (node.expression.expression.text !== "Object") return null;
11705
11761
  if (node.arguments.length !== 1) return null;
11706
11762
  const name2 = node.expression.name.text;
@@ -11721,7 +11777,7 @@ function extractSortComparator(callback, _method, ctx2) {
11721
11777
  (reverse the operands for descending order).`
11722
11778
  });
11723
11779
  let resolvedNode = callback;
11724
- if (ts12.isIdentifier(callback)) {
11780
+ if (ts13.isIdentifier(callback)) {
11725
11781
  const resolved = resolveSortComparatorIdentifier(callback.text, ctx2);
11726
11782
  if (!resolved) {
11727
11783
  return {
@@ -11731,7 +11787,7 @@ function extractSortComparator(callback, _method, ctx2) {
11731
11787
  }
11732
11788
  resolvedNode = resolved;
11733
11789
  }
11734
- if (!ts12.isArrowFunction(resolvedNode) && !ts12.isFunctionExpression(resolvedNode)) {
11790
+ if (!ts13.isArrowFunction(resolvedNode) && !ts13.isFunctionExpression(resolvedNode)) {
11735
11791
  return {
11736
11792
  result: null,
11737
11793
  unsupportedReason: "Sort comparator must be an arrow function or function expression"
@@ -11755,11 +11811,11 @@ function resolveSortComparatorIdentifier(name2, ctx2) {
11755
11811
  if (constInfo && fnInfo) return null;
11756
11812
  if (constInfo) {
11757
11813
  const ast = parseConstInitializer(constInfo);
11758
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11814
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11759
11815
  }
11760
11816
  if (fnInfo) {
11761
11817
  const ast = parseFunctionInfoAsExpr(fnInfo);
11762
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11818
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11763
11819
  }
11764
11820
  return null;
11765
11821
  }
@@ -11769,11 +11825,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name2, analyzer) {
11769
11825
  if (constInfo && fnInfo) return null;
11770
11826
  if (constInfo) {
11771
11827
  const ast = parseConstInitializer(constInfo);
11772
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11828
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11773
11829
  }
11774
11830
  if (fnInfo) {
11775
11831
  const ast = parseFunctionInfoAsExpr(fnInfo);
11776
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11832
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11777
11833
  }
11778
11834
  return null;
11779
11835
  }
@@ -11828,11 +11884,11 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
11828
11884
  return visit3(expr, bound);
11829
11885
  }
11830
11886
  function extractFilterPredicate(callback, ctx2) {
11831
- if (!ts12.isArrowFunction(callback)) return { result: null };
11887
+ if (!ts13.isArrowFunction(callback)) return { result: null };
11832
11888
  if (callback.parameters.length < 1) return { result: null };
11833
11889
  const firstParam = callback.parameters[0];
11834
- if (!ts12.isIdentifier(firstParam.name)) {
11835
- if (ts12.isBlock(callback.body)) {
11890
+ if (!ts13.isIdentifier(firstParam.name)) {
11891
+ if (ts13.isBlock(callback.body)) {
11836
11892
  return {
11837
11893
  result: null,
11838
11894
  unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
@@ -11852,7 +11908,7 @@ function extractFilterPredicate(callback, ctx2) {
11852
11908
  return { result: null };
11853
11909
  }
11854
11910
  const param = firstParam.name.getText(ctx2.sourceFile);
11855
- if (ts12.isBlock(callback.body)) {
11911
+ if (ts13.isBlock(callback.body)) {
11856
11912
  const raw2 = ctx2.getJS(callback.body);
11857
11913
  const statements = parseBlockBody(callback.body, ctx2.sourceFile, (n) => ctx2.getJS(n));
11858
11914
  if (!statements) {
@@ -11878,14 +11934,14 @@ function extractFilterPredicate(callback, ctx2) {
11878
11934
  return { result: { param, predicate, raw } };
11879
11935
  }
11880
11936
  function extractLoopParamBindings(pattern) {
11881
- if (ts12.isIdentifier(pattern)) return null;
11937
+ if (ts13.isIdentifier(pattern)) return null;
11882
11938
  const bindings = [];
11883
11939
  let unsupported = false;
11884
11940
  const isIdent = (key) => {
11885
11941
  if (key.length === 0) return false;
11886
11942
  for (let i = 0; i < key.length; ) {
11887
11943
  const cp = key.codePointAt(i);
11888
- const ok = i === 0 ? ts12.isIdentifierStart(cp, ts12.ScriptTarget.Latest) : ts12.isIdentifierPart(cp, ts12.ScriptTarget.Latest);
11944
+ const ok = i === 0 ? ts13.isIdentifierStart(cp, ts13.ScriptTarget.Latest) : ts13.isIdentifierPart(cp, ts13.ScriptTarget.Latest);
11889
11945
  if (!ok) return false;
11890
11946
  i += cp > 65535 ? 2 : 1;
11891
11947
  }
@@ -11896,19 +11952,19 @@ function extractLoopParamBindings(pattern) {
11896
11952
  };
11897
11953
  const walk = (p, prefix2, segments) => {
11898
11954
  if (unsupported) return;
11899
- if (ts12.isArrayBindingPattern(p)) {
11955
+ if (ts13.isArrayBindingPattern(p)) {
11900
11956
  const elements3 = p.elements;
11901
11957
  for (let index = 0; index < elements3.length; index++) {
11902
11958
  if (unsupported) return;
11903
11959
  const el = elements3[index];
11904
- if (ts12.isOmittedExpression(el)) continue;
11960
+ if (ts13.isOmittedExpression(el)) continue;
11905
11961
  if (el.dotDotDotToken) {
11906
11962
  internalInvariant(
11907
11963
  index === elements3.length - 1,
11908
11964
  "extractLoopParamBindings: array rest token in non-final position (parser should reject)"
11909
11965
  );
11910
11966
  internalInvariant(
11911
- ts12.isIdentifier(el.name),
11967
+ ts13.isIdentifier(el.name),
11912
11968
  "extractLoopParamBindings: array rest target is not an identifier (parser should reject)"
11913
11969
  );
11914
11970
  bindings.push({
@@ -11921,7 +11977,7 @@ function extractLoopParamBindings(pattern) {
11921
11977
  }
11922
11978
  const path25 = `${prefix2}[${index}]`;
11923
11979
  const nextSegments = [...segments, { kind: "index", index }];
11924
- if (ts12.isIdentifier(el.name)) {
11980
+ if (ts13.isIdentifier(el.name)) {
11925
11981
  bindings.push({ name: el.name.text, path: path25, segments: nextSegments });
11926
11982
  } else {
11927
11983
  walk(el.name, path25, nextSegments);
@@ -11940,7 +11996,7 @@ function extractLoopParamBindings(pattern) {
11940
11996
  "extractLoopParamBindings: object rest token in non-final position (parser should reject)"
11941
11997
  );
11942
11998
  internalInvariant(
11943
- ts12.isIdentifier(el.name),
11999
+ ts13.isIdentifier(el.name),
11944
12000
  "extractLoopParamBindings: object rest target is not an identifier (parser should reject)"
11945
12001
  );
11946
12002
  bindings.push({
@@ -11954,14 +12010,14 @@ function extractLoopParamBindings(pattern) {
11954
12010
  let keyText2 = null;
11955
12011
  if (el.propertyName) {
11956
12012
  const pn = el.propertyName;
11957
- if (ts12.isIdentifier(pn)) keyText2 = pn.text;
11958
- else if (ts12.isStringLiteral(pn)) keyText2 = pn.text;
11959
- else if (ts12.isNumericLiteral(pn)) keyText2 = pn.text;
12013
+ if (ts13.isIdentifier(pn)) keyText2 = pn.text;
12014
+ else if (ts13.isStringLiteral(pn)) keyText2 = pn.text;
12015
+ else if (ts13.isNumericLiteral(pn)) keyText2 = pn.text;
11960
12016
  else {
11961
12017
  unsupported = true;
11962
12018
  return;
11963
12019
  }
11964
- } else if (ts12.isIdentifier(el.name)) {
12020
+ } else if (ts13.isIdentifier(el.name)) {
11965
12021
  keyText2 = el.name.text;
11966
12022
  } else {
11967
12023
  unsupported = true;
@@ -11971,14 +12027,14 @@ function extractLoopParamBindings(pattern) {
11971
12027
  collectedKeys.push({ key: keyText2, isIdent: keyIsIdent });
11972
12028
  const path25 = appendDotAccess(prefix2, keyText2);
11973
12029
  const nextSegments = [...segments, { kind: "field", key: keyText2, isIdent: keyIsIdent }];
11974
- if (ts12.isIdentifier(el.name)) {
12030
+ if (ts13.isIdentifier(el.name)) {
11975
12031
  bindings.push({ name: el.name.text, path: path25, segments: nextSegments });
11976
12032
  } else {
11977
12033
  walk(el.name, path25, nextSegments);
11978
12034
  }
11979
12035
  }
11980
12036
  };
11981
- if (ts12.isArrayBindingPattern(pattern) || ts12.isObjectBindingPattern(pattern)) {
12037
+ if (ts13.isArrayBindingPattern(pattern) || ts13.isObjectBindingPattern(pattern)) {
11982
12038
  walk(pattern, "", []);
11983
12039
  if (unsupported) return { unsupported: true };
11984
12040
  return bindings;
@@ -11987,7 +12043,7 @@ function extractLoopParamBindings(pattern) {
11987
12043
  }
11988
12044
  function findKeyJsxAttribute(opening) {
11989
12045
  for (const prop of opening.attributes.properties) {
11990
- if (ts12.isJsxAttribute(prop) && prop.name.getText() === "key") {
12046
+ if (ts13.isJsxAttribute(prop) && prop.name.getText() === "key") {
11991
12047
  return prop;
11992
12048
  }
11993
12049
  }
@@ -12028,7 +12084,7 @@ function keyAttrValueToExpr(v) {
12028
12084
  function normalizeKeyExpr(expr) {
12029
12085
  let out = "";
12030
12086
  for (const tok of iterateJsTokens(expr)) {
12031
- if (tok.kind === ts12.SyntaxKind.WhitespaceTrivia || tok.kind === ts12.SyntaxKind.NewLineTrivia) {
12087
+ if (tok.kind === ts13.SyntaxKind.WhitespaceTrivia || tok.kind === ts13.SyntaxKind.NewLineTrivia) {
12032
12088
  continue;
12033
12089
  }
12034
12090
  out += expr.slice(tok.pos, tok.end);
@@ -12040,33 +12096,33 @@ function conditionalHasExplicitNullishBranch(cond) {
12040
12096
  }
12041
12097
  function branchHasExplicitNullish(branch) {
12042
12098
  let b = branch;
12043
- while (ts12.isParenthesizedExpression(b)) b = b.expression;
12044
- if (b.kind === ts12.SyntaxKind.NullKeyword) return true;
12045
- if (ts12.isIdentifier(b) && b.text === "undefined") return true;
12046
- if (ts12.isConditionalExpression(b)) return conditionalHasExplicitNullishBranch(b);
12099
+ while (ts13.isParenthesizedExpression(b)) b = b.expression;
12100
+ if (b.kind === ts13.SyntaxKind.NullKeyword) return true;
12101
+ if (ts13.isIdentifier(b) && b.text === "undefined") return true;
12102
+ if (ts13.isConditionalExpression(b)) return conditionalHasExplicitNullishBranch(b);
12047
12103
  return false;
12048
12104
  }
12049
12105
  function classifyKeyProblem(keyAttr, checker) {
12050
12106
  if (!keyAttr) return "missing";
12051
12107
  if (!keyAttr.initializer) return "missing";
12052
- if (ts12.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
12108
+ if (ts13.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
12053
12109
  return "missing";
12054
12110
  }
12055
12111
  let expr;
12056
- if (ts12.isStringLiteral(keyAttr.initializer)) {
12112
+ if (ts13.isStringLiteral(keyAttr.initializer)) {
12057
12113
  return null;
12058
- } else if (ts12.isJsxExpression(keyAttr.initializer)) {
12114
+ } else if (ts13.isJsxExpression(keyAttr.initializer)) {
12059
12115
  expr = keyAttr.initializer.expression;
12060
12116
  }
12061
12117
  if (!expr) return null;
12062
- if (expr.kind === ts12.SyntaxKind.NullKeyword) return null;
12063
- if (ts12.isIdentifier(expr) && expr.text === "undefined") return null;
12064
- if (ts12.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr)) return null;
12118
+ if (expr.kind === ts13.SyntaxKind.NullKeyword) return null;
12119
+ if (ts13.isIdentifier(expr) && expr.text === "undefined") return null;
12120
+ if (ts13.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr)) return null;
12065
12121
  if (checker) {
12066
12122
  const type2 = checker.getTypeAtLocation(expr);
12067
12123
  const isNullable = type2.isUnion() ? type2.types.some(
12068
- (t) => (t.flags & (ts12.TypeFlags.Null | ts12.TypeFlags.Undefined | ts12.TypeFlags.Void)) !== 0
12069
- ) : (type2.flags & (ts12.TypeFlags.Null | ts12.TypeFlags.Undefined | ts12.TypeFlags.Void)) !== 0;
12124
+ (t) => (t.flags & (ts13.TypeFlags.Null | ts13.TypeFlags.Undefined | ts13.TypeFlags.Void)) !== 0
12125
+ ) : (type2.flags & (ts13.TypeFlags.Null | ts13.TypeFlags.Undefined | ts13.TypeFlags.Void)) !== 0;
12070
12126
  if (isNullable) return "nullable-type";
12071
12127
  }
12072
12128
  return null;
@@ -12095,70 +12151,70 @@ function checkLoopKey(callback, ctx2, isNested) {
12095
12151
  );
12096
12152
  }
12097
12153
  let body2 = callback.body;
12098
- if (ts12.isBlock(body2)) {
12154
+ if (ts13.isBlock(body2)) {
12099
12155
  const ret = body2.statements.find(
12100
- (s) => ts12.isReturnStatement(s) && s.expression != null
12156
+ (s) => ts13.isReturnStatement(s) && s.expression != null
12101
12157
  );
12102
12158
  if (!ret?.expression) return;
12103
12159
  body2 = ret.expression;
12104
12160
  }
12105
- while (ts12.isParenthesizedExpression(body2)) body2 = body2.expression;
12161
+ while (ts13.isParenthesizedExpression(body2)) body2 = body2.expression;
12106
12162
  function checkJsxOperand(node) {
12107
12163
  let n = node;
12108
- while (ts12.isParenthesizedExpression(n)) n = n.expression;
12109
- if (ts12.isJsxElement(n)) checkOpening(n.openingElement);
12110
- else if (ts12.isJsxSelfClosingElement(n)) checkOpening(n);
12164
+ while (ts13.isParenthesizedExpression(n)) n = n.expression;
12165
+ if (ts13.isJsxElement(n)) checkOpening(n.openingElement);
12166
+ else if (ts13.isJsxSelfClosingElement(n)) checkOpening(n);
12111
12167
  }
12112
- if (ts12.isConditionalExpression(body2)) {
12168
+ if (ts13.isConditionalExpression(body2)) {
12113
12169
  checkJsxOperand(body2.whenTrue);
12114
12170
  checkJsxOperand(body2.whenFalse);
12115
12171
  return;
12116
12172
  }
12117
- if (ts12.isBinaryExpression(body2) && (body2.operatorToken.kind === ts12.SyntaxKind.AmpersandAmpersandToken || body2.operatorToken.kind === ts12.SyntaxKind.BarBarToken || body2.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken)) {
12173
+ if (ts13.isBinaryExpression(body2) && (body2.operatorToken.kind === ts13.SyntaxKind.AmpersandAmpersandToken || body2.operatorToken.kind === ts13.SyntaxKind.BarBarToken || body2.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken)) {
12118
12174
  checkJsxOperand(body2.left);
12119
12175
  checkJsxOperand(body2.right);
12120
12176
  return;
12121
12177
  }
12122
- if (ts12.isJsxElement(body2)) {
12178
+ if (ts13.isJsxElement(body2)) {
12123
12179
  checkOpening(body2.openingElement);
12124
12180
  return;
12125
12181
  }
12126
- if (ts12.isJsxSelfClosingElement(body2)) {
12182
+ if (ts13.isJsxSelfClosingElement(body2)) {
12127
12183
  checkOpening(body2);
12128
12184
  return;
12129
12185
  }
12130
12186
  }
12131
12187
  function flatMapProjectionCall(body2) {
12132
12188
  let expr;
12133
- if (ts12.isBlock(body2)) {
12189
+ if (ts13.isBlock(body2)) {
12134
12190
  const real = body2.statements;
12135
- if (real.length !== 1 || !ts12.isReturnStatement(real[0]) || !real[0].expression) return null;
12191
+ if (real.length !== 1 || !ts13.isReturnStatement(real[0]) || !real[0].expression) return null;
12136
12192
  expr = real[0].expression;
12137
12193
  } else {
12138
12194
  expr = body2;
12139
12195
  }
12140
- while (ts12.isParenthesizedExpression(expr)) expr = expr.expression;
12141
- if (!ts12.isCallExpression(expr)) return null;
12196
+ while (ts13.isParenthesizedExpression(expr)) expr = expr.expression;
12197
+ if (!ts13.isCallExpression(expr)) return null;
12142
12198
  if (!getMapLikeMethod(expr)) return null;
12143
12199
  const cb = expr.arguments[0];
12144
- if (!cb || !ts12.isArrowFunction(cb) && !ts12.isFunctionExpression(cb)) return null;
12200
+ if (!cb || !ts13.isArrowFunction(cb) && !ts13.isFunctionExpression(cb)) return null;
12145
12201
  for (const p of cb.parameters) {
12146
- if (!ts12.isIdentifier(p.name)) return null;
12202
+ if (!ts13.isIdentifier(p.name)) return null;
12147
12203
  }
12148
12204
  let innerBody = cb.body;
12149
- if (ts12.isBlock(innerBody)) {
12205
+ if (ts13.isBlock(innerBody)) {
12150
12206
  const ret = innerBody.statements.find(
12151
- (s) => ts12.isReturnStatement(s) && s.expression != null
12207
+ (s) => ts13.isReturnStatement(s) && s.expression != null
12152
12208
  );
12153
12209
  if (innerBody.statements.length !== 1 || !ret?.expression) return null;
12154
12210
  innerBody = ret.expression;
12155
12211
  }
12156
- while (ts12.isParenthesizedExpression(innerBody)) innerBody = innerBody.expression;
12212
+ while (ts13.isParenthesizedExpression(innerBody)) innerBody = innerBody.expression;
12157
12213
  const isElementish = (n) => {
12158
12214
  let m = n;
12159
- while (ts12.isParenthesizedExpression(m)) m = m.expression;
12160
- if (ts12.isJsxElement(m) || ts12.isJsxSelfClosingElement(m)) return leafIsWirelessElement(m);
12161
- if (ts12.isConditionalExpression(m)) return isElementish(m.whenTrue) && isElementish(m.whenFalse);
12215
+ while (ts13.isParenthesizedExpression(m)) m = m.expression;
12216
+ if (ts13.isJsxElement(m) || ts13.isJsxSelfClosingElement(m)) return leafIsWirelessElement(m);
12217
+ if (ts13.isConditionalExpression(m)) return isElementish(m.whenTrue) && isElementish(m.whenFalse);
12162
12218
  return false;
12163
12219
  };
12164
12220
  if (!isElementish(innerBody)) return null;
@@ -12168,19 +12224,19 @@ function leafIsWirelessElement(el) {
12168
12224
  let ok = true;
12169
12225
  const visit3 = (n) => {
12170
12226
  if (!ok) return;
12171
- if (ts12.isJsxOpeningElement(n) || ts12.isJsxSelfClosingElement(n)) {
12227
+ if (ts13.isJsxOpeningElement(n) || ts13.isJsxSelfClosingElement(n)) {
12172
12228
  const tagNode = n.tagName;
12173
- const isIntrinsic = ts12.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : ts12.isJsxNamespacedName(tagNode);
12229
+ const isIntrinsic = ts13.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : ts13.isJsxNamespacedName(tagNode);
12174
12230
  if (!isIntrinsic) {
12175
12231
  ok = false;
12176
12232
  return;
12177
12233
  }
12178
12234
  for (const attr of n.attributes.properties) {
12179
- if (ts12.isJsxSpreadAttribute(attr)) {
12235
+ if (ts13.isJsxSpreadAttribute(attr)) {
12180
12236
  ok = false;
12181
12237
  return;
12182
12238
  }
12183
- if (ts12.isJsxAttribute(attr)) {
12239
+ if (ts13.isJsxAttribute(attr)) {
12184
12240
  const name2 = attr.name.getText();
12185
12241
  if (/^on[A-Z]/.test(name2)) {
12186
12242
  ok = false;
@@ -12189,11 +12245,11 @@ function leafIsWirelessElement(el) {
12189
12245
  }
12190
12246
  }
12191
12247
  }
12192
- if (ts12.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
12248
+ if (ts13.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
12193
12249
  ok = false;
12194
12250
  return;
12195
12251
  }
12196
- ts12.forEachChild(n, visit3);
12252
+ ts13.forEachChild(n, visit3);
12197
12253
  };
12198
12254
  visit3(el);
12199
12255
  return ok;
@@ -12397,7 +12453,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12397
12453
  let children2 = [];
12398
12454
  let paramBindings;
12399
12455
  let flatMapCallback;
12400
- if (ts12.isArrowFunction(callback)) {
12456
+ if (ts13.isArrowFunction(callback)) {
12401
12457
  if (callback.parameters.length > 0) {
12402
12458
  const firstParam = callback.parameters[0];
12403
12459
  param = firstParam.name.getText(ctx2.sourceFile);
@@ -12405,11 +12461,11 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12405
12461
  paramType = firstParam.type.getText(ctx2.sourceFile);
12406
12462
  }
12407
12463
  const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
12408
- if (isEntriesShape && ts12.isArrayBindingPattern(firstParam.name)) {
12464
+ if (isEntriesShape && ts13.isArrayBindingPattern(firstParam.name)) {
12409
12465
  const elements2 = firstParam.name.elements.filter(
12410
- (el) => !ts12.isOmittedExpression(el)
12466
+ (el) => !ts13.isOmittedExpression(el)
12411
12467
  );
12412
- if (elements2.length === 2 && ts12.isBindingElement(elements2[0]) && ts12.isIdentifier(elements2[0].name) && ts12.isBindingElement(elements2[1]) && ts12.isIdentifier(elements2[1].name)) {
12468
+ if (elements2.length === 2 && ts13.isBindingElement(elements2[0]) && ts13.isIdentifier(elements2[0].name) && ts13.isBindingElement(elements2[1]) && ts13.isIdentifier(elements2[1].name)) {
12413
12469
  index = elements2[0].name.text;
12414
12470
  param = elements2[1].name.text;
12415
12471
  } else {
@@ -12450,9 +12506,9 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12450
12506
  ctx2.scope = ctx2.scope.enterLoopRow({ param, index, paramBindings });
12451
12507
  ctx2.loopDepth++;
12452
12508
  const tryTransformRenderableBody = (expr) => {
12453
- if (!ts12.isBinaryExpression(expr)) return;
12509
+ if (!ts13.isBinaryExpression(expr)) return;
12454
12510
  const op = expr.operatorToken.kind;
12455
- if (op !== ts12.SyntaxKind.AmpersandAmpersandToken && op !== ts12.SyntaxKind.BarBarToken && op !== ts12.SyntaxKind.QuestionQuestionToken) {
12511
+ if (op !== ts13.SyntaxKind.AmpersandAmpersandToken && op !== ts13.SyntaxKind.BarBarToken && op !== ts13.SyntaxKind.QuestionQuestionToken) {
12456
12512
  return;
12457
12513
  }
12458
12514
  if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx2)) return;
@@ -12460,33 +12516,33 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12460
12516
  if (transformed) children2 = [transformed];
12461
12517
  };
12462
12518
  const body2 = callback.body;
12463
- if (ts12.isJsxElement(body2) || ts12.isJsxSelfClosingElement(body2) || ts12.isJsxFragment(body2)) {
12519
+ if (ts13.isJsxElement(body2) || ts13.isJsxSelfClosingElement(body2) || ts13.isJsxFragment(body2)) {
12464
12520
  const transformed = transformNode(body2, ctx2);
12465
12521
  if (transformed) {
12466
12522
  children2 = [transformed];
12467
12523
  }
12468
- } else if (ts12.isConditionalExpression(body2)) {
12524
+ } else if (ts13.isConditionalExpression(body2)) {
12469
12525
  children2 = [transformConditional(body2, ctx2)];
12470
- } else if (ts12.isParenthesizedExpression(body2)) {
12526
+ } else if (ts13.isParenthesizedExpression(body2)) {
12471
12527
  let inner = body2.expression;
12472
- while (ts12.isParenthesizedExpression(inner)) {
12528
+ while (ts13.isParenthesizedExpression(inner)) {
12473
12529
  inner = inner.expression;
12474
12530
  }
12475
- if (ts12.isJsxElement(inner) || ts12.isJsxSelfClosingElement(inner) || ts12.isJsxFragment(inner)) {
12531
+ if (ts13.isJsxElement(inner) || ts13.isJsxSelfClosingElement(inner) || ts13.isJsxFragment(inner)) {
12476
12532
  const transformed = transformNode(inner, ctx2);
12477
12533
  if (transformed) {
12478
12534
  children2 = [transformed];
12479
12535
  }
12480
- } else if (ts12.isConditionalExpression(inner)) {
12536
+ } else if (ts13.isConditionalExpression(inner)) {
12481
12537
  children2 = [transformConditional(inner, ctx2)];
12482
- } else if (method2 === "flatMap" && ts12.isArrayLiteralExpression(inner)) {
12538
+ } else if (method2 === "flatMap" && ts13.isArrayLiteralExpression(inner)) {
12483
12539
  children2 = transformArrayLiteralChildren(inner, ctx2);
12484
12540
  } else {
12485
12541
  tryTransformRenderableBody(inner);
12486
12542
  }
12487
- } else if (method2 === "flatMap" && ts12.isArrayLiteralExpression(body2)) {
12543
+ } else if (method2 === "flatMap" && ts13.isArrayLiteralExpression(body2)) {
12488
12544
  children2 = transformArrayLiteralChildren(body2, ctx2);
12489
- } else if (ts12.isBlock(body2)) {
12545
+ } else if (ts13.isBlock(body2)) {
12490
12546
  const multiReturn = method2 !== "flatMap" ? extractMultiReturnJsxBranches(body2, true) : null;
12491
12547
  if (multiReturn && multiReturn.branches.length > 0) {
12492
12548
  const loc = getSourceLocation(body2, ctx2.sourceFile, ctx2.filePath);
@@ -12507,7 +12563,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12507
12563
  }
12508
12564
  }
12509
12565
  const returnStmt = children2.length === 0 ? body2.statements.find(
12510
- (s) => ts12.isReturnStatement(s) && s.expression != null
12566
+ (s) => ts13.isReturnStatement(s) && s.expression != null
12511
12567
  ) : void 0;
12512
12568
  let rowScopeBeforePreamble = null;
12513
12569
  if (returnStmt) {
@@ -12528,10 +12584,10 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12528
12584
  }
12529
12585
  if (returnStmt && returnStmt.expression) {
12530
12586
  let returnExpr = returnStmt.expression;
12531
- while (ts12.isParenthesizedExpression(returnExpr)) {
12587
+ while (ts13.isParenthesizedExpression(returnExpr)) {
12532
12588
  returnExpr = returnExpr.expression;
12533
12589
  }
12534
- if (ts12.isJsxElement(returnExpr) || ts12.isJsxSelfClosingElement(returnExpr) || ts12.isJsxFragment(returnExpr)) {
12590
+ if (ts13.isJsxElement(returnExpr) || ts13.isJsxSelfClosingElement(returnExpr) || ts13.isJsxFragment(returnExpr)) {
12535
12591
  const transformed = transformNode(returnExpr, ctx2);
12536
12592
  if (transformed) {
12537
12593
  children2 = [transformed];
@@ -12635,7 +12691,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12635
12691
  }
12636
12692
  }
12637
12693
  }
12638
- if (method2 === "flatMap" && children2.length === 0 && !flatMapCallback && !ts12.isBlock(body2)) {
12694
+ if (method2 === "flatMap" && children2.length === 0 && !flatMapCallback && !ts13.isBlock(body2)) {
12639
12695
  flatMapCallback = buildFlatMapCallback(callback, body2, ctx2);
12640
12696
  }
12641
12697
  if (flatMapCallback) preamble = void 0;
@@ -12658,7 +12714,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12658
12714
  }
12659
12715
  if (children2.length === 0 && !flatMapCallback) {
12660
12716
  const cb = node.arguments[0];
12661
- const cbBody = cb && (ts12.isArrowFunction(cb) || ts12.isFunctionExpression(cb)) ? cb.body : void 0;
12717
+ const cbBody = cb && (ts13.isArrowFunction(cb) || ts13.isFunctionExpression(cb)) ? cb.body : void 0;
12662
12718
  if (cbBody && containsJsxInExpression(cbBody) && ctx2.analyzer.errors.length === diagCountAtEntry) {
12663
12719
  ctx2.analyzer.errors.push(
12664
12720
  createError(
@@ -12675,7 +12731,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12675
12731
  }
12676
12732
  return null;
12677
12733
  }
12678
- if (ts12.isArrowFunction(node.arguments[0]) && children2.length > 0) {
12734
+ if (ts13.isArrowFunction(node.arguments[0]) && children2.length > 0) {
12679
12735
  checkLoopKey(node.arguments[0], ctx2, isNested);
12680
12736
  }
12681
12737
  const itemConditional = children2.length > 0 ? loopBodyItemConditional(children2) : null;
@@ -12733,6 +12789,9 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12733
12789
  const preambleRegions = preamble && !isStaticArray ? collectPreambleRegions(children2, new Set(preamble.declaredNames), ctx2) : void 0;
12734
12790
  if (preamble && !isStaticArray) {
12735
12791
  markPreambleAttrSlots(children2, new Set(preamble.declaredNames), ctx2);
12792
+ if (preamble.reactiveNames && preamble.reactiveNames.length > 0) {
12793
+ markPreambleConditionalReactivity(children2, new Set(preamble.reactiveNames), ctx2);
12794
+ }
12736
12795
  }
12737
12796
  const nestedComponents = collectNestedComponents(children2).filter((c) => c.name !== childComponent?.name);
12738
12797
  return {
@@ -12783,10 +12842,10 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12783
12842
  function transformArrayLiteralChildren(arrayLiteral, ctx2) {
12784
12843
  const children2 = [];
12785
12844
  for (const element of arrayLiteral.elements) {
12786
- if (ts12.isSpreadElement(element)) continue;
12845
+ if (ts13.isSpreadElement(element)) continue;
12787
12846
  let inner = element;
12788
- while (ts12.isParenthesizedExpression(inner)) inner = inner.expression;
12789
- if (ts12.isJsxElement(inner) || ts12.isJsxSelfClosingElement(inner) || ts12.isJsxFragment(inner)) {
12847
+ while (ts13.isParenthesizedExpression(inner)) inner = inner.expression;
12848
+ if (ts13.isJsxElement(inner) || ts13.isJsxSelfClosingElement(inner) || ts13.isJsxFragment(inner)) {
12790
12849
  const transformed = transformNode(inner, ctx2);
12791
12850
  if (transformed) children2.push(transformed);
12792
12851
  }
@@ -12794,7 +12853,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx2) {
12794
12853
  return children2;
12795
12854
  }
12796
12855
  function containsJsx(node) {
12797
- if (ts12.isJsxElement(node) || ts12.isJsxSelfClosingElement(node) || ts12.isJsxFragment(node)) return true;
12856
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node)) return true;
12798
12857
  let found = false;
12799
12858
  node.forEachChild((child) => {
12800
12859
  if (!found) found = containsJsx(child);
@@ -12807,14 +12866,14 @@ function buildFlatMapCallback(callback, body2, ctx2) {
12807
12866
  const leafIrs = [];
12808
12867
  let refusalNode;
12809
12868
  const collectJsx = (n, underTemplate) => {
12810
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
12869
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
12811
12870
  if (underTemplate) refusalNode ??= n;
12812
12871
  leafSpans.push({ start: n.getStart(ctx2.sourceFile), end: n.getEnd() });
12813
12872
  const ir = transformNode(n, ctx2);
12814
12873
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx2.sourceFile, ctx2.filePath) });
12815
12874
  return;
12816
12875
  }
12817
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
12876
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
12818
12877
  n.forEachChild((c) => collectJsx(c, inTemplate));
12819
12878
  };
12820
12879
  collectJsx(body2, false);
@@ -12999,6 +13058,31 @@ function markPreambleAttrSlots(nodes, declared, ctx2) {
12999
13058
  };
13000
13059
  visit3(nodes);
13001
13060
  }
13061
+ function markPreambleConditionalReactivity(nodes, reactiveNames, ctx2) {
13062
+ if (reactiveNames.size === 0) return;
13063
+ const visit3 = (list) => {
13064
+ for (const node of list) {
13065
+ switch (node.type) {
13066
+ case "element":
13067
+ case "fragment":
13068
+ visit3(node.children);
13069
+ break;
13070
+ case "conditional": {
13071
+ if (!node.reactive) {
13072
+ const refs = extractFreeIdentifiersFromText(node.condition);
13073
+ if ([...refs].some((r2) => reactiveNames.has(r2))) {
13074
+ node.reactive = true;
13075
+ if (!node.slotId) node.slotId = generateSlotId(ctx2);
13076
+ }
13077
+ }
13078
+ visit3([node.whenTrue, ...node.whenFalse ? [node.whenFalse] : []]);
13079
+ break;
13080
+ }
13081
+ }
13082
+ }
13083
+ };
13084
+ visit3(nodes);
13085
+ }
13002
13086
  function attrValueText(value2) {
13003
13087
  if (value2.kind === "expression") return value2.expr;
13004
13088
  if (value2.kind !== "template") return "";
@@ -13010,23 +13094,42 @@ function attrValueText(value2) {
13010
13094
  return out.join(" ");
13011
13095
  }
13012
13096
  function collectBindingNames2(name2, out) {
13013
- if (ts12.isIdentifier(name2)) {
13097
+ if (ts13.isIdentifier(name2)) {
13014
13098
  out.add(name2.text);
13015
13099
  return;
13016
13100
  }
13017
13101
  for (const el of name2.elements) {
13018
- if (ts12.isBindingElement(el)) collectBindingNames2(el.name, out);
13102
+ if (ts13.isBindingElement(el)) collectBindingNames2(el.name, out);
13019
13103
  }
13020
13104
  }
13021
13105
  function collectPreambleDeclaredNames(stmt, out) {
13022
- if (ts12.isVariableStatement(stmt)) {
13106
+ if (ts13.isVariableStatement(stmt)) {
13023
13107
  for (const decl of stmt.declarationList.declarations) {
13024
13108
  collectBindingNames2(decl.name, out);
13025
13109
  }
13026
- } else if (ts12.isFunctionDeclaration(stmt) && stmt.name) {
13110
+ } else if (ts13.isFunctionDeclaration(stmt) && stmt.name) {
13027
13111
  out.add(stmt.name.text);
13028
13112
  }
13029
13113
  }
13114
+ function computePreambleReactiveNames(statements, ctx2) {
13115
+ const reactiveNames = /* @__PURE__ */ new Set();
13116
+ for (const stmt of statements) {
13117
+ if (!ts13.isVariableStatement(stmt)) continue;
13118
+ for (const decl of stmt.declarationList.declarations) {
13119
+ if (!decl.initializer) continue;
13120
+ const boundNames = /* @__PURE__ */ new Set();
13121
+ collectBindingNames2(decl.name, boundNames);
13122
+ const initText = ctx2.getJS(decl.initializer);
13123
+ const initFreeRefs = extractFreeIdentifiersFromNode(decl.initializer);
13124
+ const readsEarlierReactive = [...initFreeRefs].some((r2) => reactiveNames.has(r2));
13125
+ const isReactive = readsEarlierReactive || isReactiveExpression(initText, ctx2, decl.initializer);
13126
+ if (isReactive) {
13127
+ for (const n of boundNames) reactiveNames.add(n);
13128
+ }
13129
+ }
13130
+ }
13131
+ return reactiveNames;
13132
+ }
13030
13133
  function preambleFromValueStatements(statements, ctx2) {
13031
13134
  const segments = [];
13032
13135
  const typedParts = [];
@@ -13041,21 +13144,23 @@ function preambleFromValueStatements(statements, ctx2) {
13041
13144
  typedParts.push(raw0.endsWith(";") ? raw0 : raw0 + ";");
13042
13145
  segments.push(tjs !== js ? { kind: "js", text: js, templateText: tjs } : { kind: "js", text: js });
13043
13146
  }
13147
+ const reactiveNames = computePreambleReactiveNames(statements, ctx2);
13044
13148
  return {
13045
13149
  segments: trimPreambleSegments(segments),
13046
13150
  ssrText: tsxSourceText(typedParts.join(" ")),
13047
13151
  declaredNames: [...declared],
13048
13152
  // Value-only preambles accumulate no JSX, so no child needs the array join.
13049
13153
  builderNames: [],
13050
- declarations: neutralPreambleDeclarations(statements, ctx2) ?? void 0
13154
+ declarations: neutralPreambleDeclarations(statements, ctx2) ?? void 0,
13155
+ reactiveNames: reactiveNames.size > 0 ? [...reactiveNames] : void 0
13051
13156
  };
13052
13157
  }
13053
13158
  function neutralPreambleDeclarations(statements, ctx2) {
13054
13159
  const out = [];
13055
13160
  for (const stmt of statements) {
13056
- if (!ts12.isVariableStatement(stmt)) return null;
13161
+ if (!ts13.isVariableStatement(stmt)) return null;
13057
13162
  for (const decl of stmt.declarationList.declarations) {
13058
- if (!ts12.isIdentifier(decl.name)) return null;
13163
+ if (!ts13.isIdentifier(decl.name)) return null;
13059
13164
  if (!decl.initializer) return null;
13060
13165
  const valueParsed = tsNodeToParsedExpr(decl.initializer);
13061
13166
  if (!isSupported(valueParsed).supported) return null;
@@ -13085,11 +13190,11 @@ function buildPreambleSegments(statements, returnStmt, ctx2) {
13085
13190
  let refusalNode;
13086
13191
  const recordBuilderTarget = (leaf, stmt) => {
13087
13192
  for (let n = leaf.parent; n && n !== stmt.parent; n = n.parent) {
13088
- if (ts12.isCallExpression(n) && ts12.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && ts12.isIdentifier(n.expression.expression)) {
13193
+ if (ts13.isCallExpression(n) && ts13.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && ts13.isIdentifier(n.expression.expression)) {
13089
13194
  builders.add(n.expression.expression.text);
13090
13195
  return;
13091
13196
  }
13092
- if (ts12.isVariableDeclaration(n) && ts12.isIdentifier(n.name)) {
13197
+ if (ts13.isVariableDeclaration(n) && ts13.isIdentifier(n.name)) {
13093
13198
  builders.add(n.name.text);
13094
13199
  return;
13095
13200
  }
@@ -13101,7 +13206,7 @@ function buildPreambleSegments(statements, returnStmt, ctx2) {
13101
13206
  const leafSpans = [];
13102
13207
  const leafIrs = [];
13103
13208
  const collect = (n, underTemplate) => {
13104
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
13209
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
13105
13210
  if (underTemplate) refusalNode ??= n;
13106
13211
  recordBuilderTarget(n, stmt);
13107
13212
  leafSpans.push({ start: n.getStart(ctx2.sourceFile), end: n.getEnd() });
@@ -13110,7 +13215,7 @@ function buildPreambleSegments(statements, returnStmt, ctx2) {
13110
13215
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx2.sourceFile, ctx2.filePath) });
13111
13216
  return;
13112
13217
  }
13113
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
13218
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
13114
13219
  n.forEachChild((c) => collect(c, inTemplate));
13115
13220
  };
13116
13221
  collect(stmt, false);
@@ -13214,13 +13319,13 @@ function expandSpreadAttribute(attr, ctx2) {
13214
13319
  }];
13215
13320
  }
13216
13321
  function attrFreeIdentifiers(attr) {
13217
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13322
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13218
13323
  return void 0;
13219
13324
  }
13220
13325
  return extractFreeIdentifiersFromNode(attr.initializer.expression);
13221
13326
  }
13222
13327
  function computeReactivityFlags(attr, ctx2) {
13223
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13328
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13224
13329
  return {};
13225
13330
  }
13226
13331
  const expr = attr.initializer.expression;
@@ -13251,21 +13356,21 @@ function processAttributes(attributes2, ctx2) {
13251
13356
  const events = [];
13252
13357
  let ref = null;
13253
13358
  for (const attr of attributes2.properties) {
13254
- if (ts12.isJsxSpreadAttribute(attr)) {
13359
+ if (ts13.isJsxSpreadAttribute(attr)) {
13255
13360
  attrs.push(...expandSpreadAttribute(attr, ctx2));
13256
13361
  continue;
13257
13362
  }
13258
- if (!ts12.isJsxAttribute(attr)) continue;
13363
+ if (!ts13.isJsxAttribute(attr)) continue;
13259
13364
  const rawName = attr.name.getText(ctx2.sourceFile);
13260
13365
  if (rawName === "ref") {
13261
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13366
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13262
13367
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx2);
13263
13368
  ref = ctx2.getJS(attr.initializer.expression);
13264
13369
  }
13265
13370
  continue;
13266
13371
  }
13267
13372
  if (/^on[A-Z]/.test(rawName)) {
13268
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13373
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13269
13374
  const eventName = rawName.slice(2).toLowerCase();
13270
13375
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx2);
13271
13376
  events.push({
@@ -13280,7 +13385,7 @@ function processAttributes(attributes2, ctx2) {
13280
13385
  const name2 = toHTMLAttrName(rawName);
13281
13386
  let value2 = getAttributeValue(attr, ctx2);
13282
13387
  let clientOnly;
13283
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13388
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13284
13389
  if (value2.kind === "expression" && value2.templateExpr === void 0) {
13285
13390
  const rewritten = rewriteBarePropRefs2(value2.expr, attr.initializer.expression, ctx2);
13286
13391
  if (rewritten !== value2.expr) {
@@ -13307,19 +13412,19 @@ function getAttributeValue(attr, ctx2) {
13307
13412
  if (!attr.initializer) {
13308
13413
  return AttrValueOf.booleanAttr();
13309
13414
  }
13310
- if (ts12.isStringLiteral(attr.initializer)) {
13415
+ if (ts13.isStringLiteral(attr.initializer)) {
13311
13416
  return AttrValueOf.literal(decodeEntities(attr.initializer.text));
13312
13417
  }
13313
- if (ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13418
+ if (ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13314
13419
  let expr = attr.initializer.expression;
13315
- if (ts12.isIdentifier(expr)) {
13420
+ if (ts13.isIdentifier(expr)) {
13316
13421
  const branchInit = ctx2._branchScopeVars?.get(expr.text);
13317
13422
  if (branchInit && !initializerShapeContainsJsx(branchInit)) {
13318
13423
  expr = branchInit;
13319
13424
  }
13320
13425
  }
13321
13426
  expr = tryDesugarInterleaveTaggedTemplate(expr, ctx2);
13322
- if (ts12.isAwaitExpression(expr)) {
13427
+ if (ts13.isAwaitExpression(expr)) {
13323
13428
  ctx2.analyzer.errors.push(
13324
13429
  createError(
13325
13430
  ErrorCodes.STAGE_AWAIT_IN_TEMPLATE,
@@ -13329,38 +13434,38 @@ function getAttributeValue(attr, ctx2) {
13329
13434
  return AttrValueOf.expression("undefined");
13330
13435
  }
13331
13436
  checkBareSignalOrMemoIdentifier(expr, ctx2);
13332
- if (attr.name.getText(ctx2.sourceFile) === "style" && ts12.isObjectLiteralExpression(expr)) {
13437
+ if (attr.name.getText(ctx2.sourceFile) === "style" && ts13.isObjectLiteralExpression(expr)) {
13333
13438
  const cssString = tryStaticStyleObjectToCss(expr);
13334
13439
  if (cssString !== null) {
13335
13440
  return AttrValueOf.literal(cssString);
13336
13441
  }
13337
13442
  }
13338
- if (ts12.isTemplateExpression(expr)) {
13443
+ if (ts13.isTemplateExpression(expr)) {
13339
13444
  const parts = parseTemplateLiteral(expr, ctx2);
13340
13445
  if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
13341
13446
  return AttrValueOf.template(parts);
13342
13447
  }
13343
13448
  }
13344
- if (ts12.isElementAccessExpression(expr) && !ts12.isStringLiteralLike(expr.argumentExpression) && !ts12.isNumericLiteral(expr.argumentExpression)) {
13449
+ if (ts13.isElementAccessExpression(expr) && !ts13.isStringLiteralLike(expr.argumentExpression) && !ts13.isNumericLiteral(expr.argumentExpression)) {
13345
13450
  const parts = tryResolveTemplateSpanFromConst(expr, ctx2);
13346
13451
  if (parts) {
13347
13452
  return AttrValueOf.template(parts);
13348
13453
  }
13349
13454
  }
13350
- if (ts12.isIdentifier(expr)) {
13455
+ if (ts13.isIdentifier(expr)) {
13351
13456
  const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx2);
13352
13457
  if (resolved) {
13353
13458
  return AttrValueOf.template(resolved);
13354
13459
  }
13355
13460
  }
13356
- if (ts12.isConditionalExpression(expr)) {
13461
+ if (ts13.isConditionalExpression(expr)) {
13357
13462
  const ternary = parseTernary(expr, ctx2);
13358
13463
  if (ternary) {
13359
13464
  return AttrValueOf.template([ternary]);
13360
13465
  }
13361
13466
  }
13362
- if (ts12.isBinaryExpression(expr) && expr.operatorToken.kind === ts12.SyntaxKind.BarBarToken) {
13363
- if (ts12.isIdentifier(expr.right) && expr.right.text === "undefined") {
13467
+ if (ts13.isBinaryExpression(expr) && expr.operatorToken.kind === ts13.SyntaxKind.BarBarToken) {
13468
+ if (ts13.isIdentifier(expr.right) && expr.right.text === "undefined") {
13364
13469
  const baseExpr = ctx2.getJS(expr.left);
13365
13470
  return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
13366
13471
  }
@@ -13373,9 +13478,9 @@ function getAttributeValue(attr, ctx2) {
13373
13478
  function tryStaticStyleObjectToCss(expr) {
13374
13479
  const parts = [];
13375
13480
  for (const prop of expr.properties) {
13376
- if (!ts12.isPropertyAssignment(prop)) return null;
13377
- if (!ts12.isIdentifier(prop.name) && !ts12.isStringLiteral(prop.name)) return null;
13378
- if (!ts12.isStringLiteral(prop.initializer)) return null;
13481
+ if (!ts13.isPropertyAssignment(prop)) return null;
13482
+ if (!ts13.isIdentifier(prop.name) && !ts13.isStringLiteral(prop.name)) return null;
13483
+ if (!ts13.isStringLiteral(prop.initializer)) return null;
13379
13484
  const key = cssKebabCase(prop.name.text);
13380
13485
  parts.push(`${key}:${prop.initializer.text}`);
13381
13486
  }
@@ -13387,7 +13492,7 @@ function parseTemplateLiteral(expr, ctx2) {
13387
13492
  parts.push({ type: "string", value: expr.head.text });
13388
13493
  }
13389
13494
  for (const span of expr.templateSpans) {
13390
- if (ts12.isConditionalExpression(span.expression)) {
13495
+ if (ts13.isConditionalExpression(span.expression)) {
13391
13496
  const ternary = parseTernary(span.expression, ctx2);
13392
13497
  if (ternary) {
13393
13498
  parts.push(ternary);
@@ -13413,31 +13518,31 @@ function parseTemplateLiteral(expr, ctx2) {
13413
13518
  return parts;
13414
13519
  }
13415
13520
  function tryResolveTemplateSpanFromConst(expr, ctx2) {
13416
- if (ts12.isIdentifier(expr)) {
13521
+ if (ts13.isIdentifier(expr)) {
13417
13522
  if (ctx2.scope.isBound(expr.text)) return null;
13418
13523
  const constInfo = findLocalConst(expr.text, ctx2.analyzer);
13419
13524
  if (!constInfo) return null;
13420
13525
  const ast = parseConstInitializer(constInfo);
13421
13526
  if (!ast) return null;
13422
- if (ts12.isStringLiteral(ast) || ts12.isNoSubstitutionTemplateLiteral(ast)) {
13527
+ if (ts13.isStringLiteral(ast) || ts13.isNoSubstitutionTemplateLiteral(ast)) {
13423
13528
  return [{ type: "string", value: ast.text }];
13424
13529
  }
13425
13530
  return null;
13426
13531
  }
13427
- if (ts12.isElementAccessExpression(expr)) {
13428
- if (!ts12.isIdentifier(expr.expression)) return null;
13532
+ if (ts13.isElementAccessExpression(expr)) {
13533
+ if (!ts13.isIdentifier(expr.expression)) return null;
13429
13534
  if (ctx2.scope.isBound(expr.expression.text)) return null;
13430
13535
  const constInfo = findLocalConst(expr.expression.text, ctx2.analyzer);
13431
13536
  if (!constInfo) return null;
13432
13537
  const ast = parseConstInitializer(constInfo);
13433
- if (!ast || !ts12.isObjectLiteralExpression(ast)) return null;
13538
+ if (!ast || !ts13.isObjectLiteralExpression(ast)) return null;
13434
13539
  const cases = {};
13435
13540
  for (const prop of ast.properties) {
13436
- if (!ts12.isPropertyAssignment(prop)) return null;
13437
- const keyName = prop.name && (ts12.isStringLiteral(prop.name) || ts12.isIdentifier(prop.name)) ? prop.name.text : null;
13541
+ if (!ts13.isPropertyAssignment(prop)) return null;
13542
+ const keyName = prop.name && (ts13.isStringLiteral(prop.name) || ts13.isIdentifier(prop.name)) ? prop.name.text : null;
13438
13543
  if (!keyName) return null;
13439
13544
  const value2 = prop.initializer;
13440
- if (ts12.isStringLiteral(value2) || ts12.isNoSubstitutionTemplateLiteral(value2)) {
13545
+ if (ts13.isStringLiteral(value2) || ts13.isNoSubstitutionTemplateLiteral(value2)) {
13441
13546
  cases[keyName] = value2.text;
13442
13547
  } else {
13443
13548
  return null;
@@ -13476,17 +13581,17 @@ function hasDynamicTagBinding(name2, sourceFile) {
13476
13581
  let found = false;
13477
13582
  const visit3 = (node) => {
13478
13583
  if (found) return;
13479
- if (ts12.isVariableDeclaration(node) && ts12.isIdentifier(node.name) && node.name.text === name2 && node.initializer) {
13584
+ if (ts13.isVariableDeclaration(node) && ts13.isIdentifier(node.name) && node.name.text === name2 && node.initializer) {
13480
13585
  let init = node.initializer;
13481
- while (ts12.isAsExpression(init) || ts12.isSatisfiesExpression(init) || ts12.isParenthesizedExpression(init) || ts12.isNonNullExpression(init)) {
13586
+ while (ts13.isAsExpression(init) || ts13.isSatisfiesExpression(init) || ts13.isParenthesizedExpression(init) || ts13.isNonNullExpression(init)) {
13482
13587
  init = init.expression;
13483
13588
  }
13484
- if (ts12.isPropertyAccessExpression(init) && init.name.text === "tag") {
13589
+ if (ts13.isPropertyAccessExpression(init) && init.name.text === "tag") {
13485
13590
  found = true;
13486
13591
  return;
13487
13592
  }
13488
13593
  }
13489
- ts12.forEachChild(node, visit3);
13594
+ ts13.forEachChild(node, visit3);
13490
13595
  };
13491
13596
  visit3(sourceFile);
13492
13597
  return found;
@@ -13497,13 +13602,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx2) {
13497
13602
  if (!constInfo) return null;
13498
13603
  const ast = parseConstInitializer(constInfo);
13499
13604
  if (!ast) return null;
13500
- if (ts12.isNoSubstitutionTemplateLiteral(ast) || ts12.isStringLiteral(ast)) {
13605
+ if (ts13.isNoSubstitutionTemplateLiteral(ast) || ts13.isStringLiteral(ast)) {
13501
13606
  return [{ type: "string", value: ast.text }];
13502
13607
  }
13503
- if (ts12.isElementAccessExpression(ast) && !ts12.isStringLiteralLike(ast.argumentExpression) && !ts12.isNumericLiteral(ast.argumentExpression)) {
13608
+ if (ts13.isElementAccessExpression(ast) && !ts13.isStringLiteralLike(ast.argumentExpression) && !ts13.isNumericLiteral(ast.argumentExpression)) {
13504
13609
  return tryResolveTemplateSpanFromConst(ast, ctx2);
13505
13610
  }
13506
- if (!ts12.isTemplateExpression(ast)) return null;
13611
+ if (!ts13.isTemplateExpression(ast)) return null;
13507
13612
  let resolvedAny = false;
13508
13613
  const parts = [];
13509
13614
  if (ast.head.text) parts.push({ type: "string", value: ast.head.text });
@@ -13535,19 +13640,19 @@ function parseConstInitializer(c) {
13535
13640
  function parseConstInitializerImpl(c) {
13536
13641
  if (!c.value) return null;
13537
13642
  const wrapped = `const __bf_resolve__ = (${c.value})`;
13538
- const sf = ts12.createSourceFile(
13643
+ const sf = ts13.createSourceFile(
13539
13644
  "__bf_resolve.ts",
13540
13645
  wrapped,
13541
- ts12.ScriptTarget.Latest,
13646
+ ts13.ScriptTarget.Latest,
13542
13647
  /* setParentNodes */
13543
13648
  true,
13544
- ts12.ScriptKind.TS
13649
+ ts13.ScriptKind.TS
13545
13650
  );
13546
13651
  const stmt = sf.statements[0];
13547
- if (!stmt || !ts12.isVariableStatement(stmt)) return null;
13652
+ if (!stmt || !ts13.isVariableStatement(stmt)) return null;
13548
13653
  const decl = stmt.declarationList.declarations[0];
13549
13654
  if (!decl?.initializer) return null;
13550
- return ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13655
+ return ts13.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13551
13656
  }
13552
13657
  function astText(node) {
13553
13658
  return node.getText(node.getSourceFile());
@@ -13564,23 +13669,23 @@ function parseFunctionInfoAsExprImpl(fn) {
13564
13669
  const params = fn.typedParams !== void 0 ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
13565
13670
  const body2 = fn.typedBody ?? fn.body;
13566
13671
  const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body2}`;
13567
- const sf = ts12.createSourceFile(
13672
+ const sf = ts13.createSourceFile(
13568
13673
  "__bf_resolve_fn.ts",
13569
13674
  wrapped,
13570
- ts12.ScriptTarget.Latest,
13675
+ ts13.ScriptTarget.Latest,
13571
13676
  /* setParentNodes */
13572
13677
  true,
13573
- ts12.ScriptKind.TS
13678
+ ts13.ScriptKind.TS
13574
13679
  );
13575
13680
  const stmt = sf.statements[0];
13576
- if (!stmt || !ts12.isVariableStatement(stmt)) return null;
13681
+ if (!stmt || !ts13.isVariableStatement(stmt)) return null;
13577
13682
  const decl = stmt.declarationList.declarations[0];
13578
13683
  if (!decl?.initializer) return null;
13579
13684
  return decl.initializer;
13580
13685
  }
13581
13686
  function tryDesugarInterleaveTaggedTemplate(expr, ctx2) {
13582
- if (!ts12.isTaggedTemplateExpression(expr)) return expr;
13583
- if (!ts12.isIdentifier(expr.tag)) return expr;
13687
+ if (!ts13.isTaggedTemplateExpression(expr)) return expr;
13688
+ if (!ts13.isIdentifier(expr.tag)) return expr;
13584
13689
  const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx2);
13585
13690
  if (!resolvedTag) return expr;
13586
13691
  if (!isInterleaveTagFunction(resolvedTag)) return expr;
@@ -13593,20 +13698,20 @@ function resolveInterleaveTagIdentifier(name2, ctx2) {
13593
13698
  if (constInfo && fnInfo) return null;
13594
13699
  if (constInfo) {
13595
13700
  const ast = parseConstInitializer(constInfo);
13596
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13701
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
13597
13702
  }
13598
13703
  if (fnInfo) {
13599
13704
  const ast = parseFunctionInfoAsExpr(fnInfo);
13600
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13705
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
13601
13706
  }
13602
13707
  return null;
13603
13708
  }
13604
13709
  function isInterleaveTagFunction(fn) {
13605
- if (!ts12.isArrowFunction(fn) && !ts12.isFunctionExpression(fn)) return false;
13710
+ if (!ts13.isArrowFunction(fn) && !ts13.isFunctionExpression(fn)) return false;
13606
13711
  if (fn.parameters.length !== 2) return false;
13607
13712
  const [partsParam, argsParam] = fn.parameters;
13608
- if (!ts12.isIdentifier(partsParam.name) || partsParam.dotDotDotToken) return false;
13609
- if (!ts12.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken) return false;
13713
+ if (!ts13.isIdentifier(partsParam.name) || partsParam.dotDotDotToken) return false;
13714
+ if (!ts13.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken) return false;
13610
13715
  const parsed = tsNodeToParsedExpr(fn);
13611
13716
  if (parsed.kind !== "arrow") return false;
13612
13717
  return isInterleaveReduceCall(parsed.body, partsParam.name.text, argsParam.name.text);
@@ -13648,7 +13753,7 @@ function isInterleaveSpanExpr(expr, i, argsName) {
13648
13753
  function buildUntaggedTemplateLiteral(node, ctx2) {
13649
13754
  const template = node.template;
13650
13755
  let text;
13651
- if (ts12.isNoSubstitutionTemplateLiteral(template)) {
13756
+ if (ts13.isNoSubstitutionTemplateLiteral(template)) {
13652
13757
  text = "`" + (template.rawText ?? template.text) + "`";
13653
13758
  } else {
13654
13759
  let body2 = template.head.rawText ?? template.head.text;
@@ -13660,20 +13765,20 @@ function buildUntaggedTemplateLiteral(node, ctx2) {
13660
13765
  text = "`" + body2 + "`";
13661
13766
  }
13662
13767
  const wrapped = `const __bf_resolve_tagged__ = (${text})`;
13663
- const sf = ts12.createSourceFile(
13768
+ const sf = ts13.createSourceFile(
13664
13769
  "__bf_resolve_tagged.tsx",
13665
13770
  wrapped,
13666
- ts12.ScriptTarget.Latest,
13771
+ ts13.ScriptTarget.Latest,
13667
13772
  /* setParentNodes */
13668
13773
  true,
13669
- ts12.ScriptKind.TSX
13774
+ ts13.ScriptKind.TSX
13670
13775
  );
13671
13776
  const stmt = sf.statements[0];
13672
- if (!stmt || !ts12.isVariableStatement(stmt)) return null;
13777
+ if (!stmt || !ts13.isVariableStatement(stmt)) return null;
13673
13778
  const decl = stmt.declarationList.declarations[0];
13674
13779
  if (!decl?.initializer) return null;
13675
- const result2 = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13676
- if (!ts12.isTemplateExpression(result2) && !ts12.isNoSubstitutionTemplateLiteral(result2)) return null;
13780
+ const result2 = ts13.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13781
+ if (!ts13.isTemplateExpression(result2) && !ts13.isNoSubstitutionTemplateLiteral(result2)) return null;
13677
13782
  return result2;
13678
13783
  }
13679
13784
  function parseTernary(expr, ctx2) {
@@ -13692,10 +13797,10 @@ function parseTernary(expr, ctx2) {
13692
13797
  return null;
13693
13798
  }
13694
13799
  function getStringValue(node) {
13695
- if (ts12.isStringLiteral(node)) {
13800
+ if (ts13.isStringLiteral(node)) {
13696
13801
  return node.text;
13697
13802
  }
13698
- if (ts12.isNoSubstitutionTemplateLiteral(node)) {
13803
+ if (ts13.isNoSubstitutionTemplateLiteral(node)) {
13699
13804
  return node.text;
13700
13805
  }
13701
13806
  return null;
@@ -13703,18 +13808,18 @@ function getStringValue(node) {
13703
13808
  function processComponentProps(attributes2, ctx2) {
13704
13809
  const props = [];
13705
13810
  for (const attr of attributes2.properties) {
13706
- if (ts12.isJsxSpreadAttribute(attr)) {
13811
+ if (ts13.isJsxSpreadAttribute(attr)) {
13707
13812
  props.push(...expandSpreadAttribute(attr, ctx2));
13708
13813
  continue;
13709
13814
  }
13710
- if (!ts12.isJsxAttribute(attr)) continue;
13815
+ if (!ts13.isJsxAttribute(attr)) continue;
13711
13816
  const name2 = attr.name.getText(ctx2.sourceFile);
13712
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13817
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13713
13818
  let jsxExpr = attr.initializer.expression;
13714
- while (ts12.isParenthesizedExpression(jsxExpr)) {
13819
+ while (ts13.isParenthesizedExpression(jsxExpr)) {
13715
13820
  jsxExpr = jsxExpr.expression;
13716
13821
  }
13717
- if (ts12.isJsxElement(jsxExpr) || ts12.isJsxSelfClosingElement(jsxExpr) || ts12.isJsxFragment(jsxExpr)) {
13822
+ if (ts13.isJsxElement(jsxExpr) || ts13.isJsxSelfClosingElement(jsxExpr) || ts13.isJsxFragment(jsxExpr)) {
13718
13823
  const prevInsideComponentChildren = ctx2.insideComponentChildren;
13719
13824
  ctx2.insideComponentChildren = true;
13720
13825
  const irNode = transformNode(jsxExpr, ctx2);
@@ -13741,7 +13846,7 @@ function processComponentProps(attributes2, ctx2) {
13741
13846
  value2 = AttrValueOf.booleanShorthand();
13742
13847
  }
13743
13848
  let clientOnly;
13744
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13849
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13745
13850
  if (value2.kind === "expression" && value2.templateExpr === void 0) {
13746
13851
  const rewritten = rewriteBarePropRefs2(value2.expr, attr.initializer.expression, ctx2);
13747
13852
  if (rewritten !== value2.expr) {
@@ -13765,7 +13870,7 @@ function processComponentProps(attributes2, ctx2) {
13765
13870
  return props;
13766
13871
  }
13767
13872
  function checkBareSignalOrMemoIdentifier(expr, ctx2) {
13768
- if (!ts12.isIdentifier(expr)) return;
13873
+ if (!ts13.isIdentifier(expr)) return;
13769
13874
  const name2 = expr.text;
13770
13875
  for (const signal2 of ctx2.analyzer.signals) {
13771
13876
  if (signal2.getter === name2) {
@@ -13807,12 +13912,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx2) {
13807
13912
  function isArrayExprDirectPropRef(arrayExpr, ctx2) {
13808
13913
  const propNames = new Set(ctx2.patterns.props.map((p) => p.name));
13809
13914
  const propsObjName = ctx2.analyzer.propsObjectName;
13810
- if (ts12.isIdentifier(arrayExpr)) {
13915
+ if (ts13.isIdentifier(arrayExpr)) {
13811
13916
  return propNames.has(arrayExpr.text);
13812
13917
  }
13813
- if (ts12.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13918
+ if (ts13.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13814
13919
  const obj = arrayExpr.expression;
13815
- if (ts12.isIdentifier(obj) && obj.text === propsObjName) {
13920
+ if (ts13.isIdentifier(obj) && obj.text === propsObjName) {
13816
13921
  return true;
13817
13922
  }
13818
13923
  }
@@ -13984,7 +14089,7 @@ function buildIfStatementChain(analyzer, ctx2, opts) {
13984
14089
  for (const n of prevJsxBranchLocalNames) jsxBranchLocalNames.add(n);
13985
14090
  }
13986
14091
  for (const decl of condReturn.scopeVariables) {
13987
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
14092
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
13988
14093
  branchScopeVars.set(decl.name.text, decl.initializer);
13989
14094
  if (initializerShapeContainsJsx(decl.initializer)) {
13990
14095
  jsxBranchLocalNames.add(decl.name.text);
@@ -14048,7 +14153,7 @@ function buildIfStatementChain(analyzer, ctx2, opts) {
14048
14153
  }
14049
14154
  const scopeVariables = [];
14050
14155
  for (const decl of condReturn.scopeVariables) {
14051
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
14156
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
14052
14157
  const init = ctx2.getJS(decl.initializer);
14053
14158
  const typedInit = decl.initializer.getText(ctx2.sourceFile);
14054
14159
  scopeVariables.push({
@@ -15353,7 +15458,8 @@ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loo
15353
15458
  const refsLoopParamInSource = refsAnyBindingViaFreeIds(sourceFreeIds);
15354
15459
  if (!n.reactive && !refsLoopParamInSource) return;
15355
15460
  const expanded = expandConstantForReactivity(n.condition, ctx2, sourceFreeIds, scope);
15356
- if (classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind === "none") return;
15461
+ const readsPreamble = preambleNames !== void 0 && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
15462
+ if (!readsPreamble && classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind === "none") return;
15357
15463
  const loopParamsForCond = loopParam ? [{ param: loopParam, bindings: loopParamBindings }] : void 0;
15358
15464
  const whenTrueHtml = irToHtmlTemplate(n.whenTrue, void 0, 0, loopParamsForCond, "__slots");
15359
15465
  const whenFalseHtml = irToHtmlTemplate(n.whenFalse, void 0, 0, loopParamsForCond, "__slots");
@@ -15364,7 +15470,8 @@ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loo
15364
15470
  whenFalseHtml,
15365
15471
  whenTrue: summarizeLoopChildBranch(n.whenTrue, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15366
15472
  whenFalse: summarizeLoopChildBranch(n.whenFalse, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15367
- ...expanded.freeIds !== void 0 && { conditionFreeIdentifiers: expanded.freeIds }
15473
+ ...expanded.freeIds !== void 0 && { conditionFreeIdentifiers: expanded.freeIds },
15474
+ ...readsPreamble && { readsPreamble: true }
15368
15475
  });
15369
15476
  }
15370
15477
  });
@@ -15443,6 +15550,7 @@ var init_collect_elements = __esm({
15443
15550
  init_html_template();
15444
15551
  init_template_parse();
15445
15552
  init_prop_handling();
15553
+ init_csr_substitute();
15446
15554
  init_walker();
15447
15555
  init_loop_chain();
15448
15556
  init_identifier_pattern();
@@ -15800,7 +15908,7 @@ var init_build_references = __esm({
15800
15908
  });
15801
15909
 
15802
15910
  // ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
15803
- import ts13 from "typescript";
15911
+ import ts14 from "typescript";
15804
15912
  function collectPropAccesses(source, propNames, out) {
15805
15913
  if (propNames.size === 0) return;
15806
15914
  let anyMentioned = false;
@@ -15812,13 +15920,13 @@ function collectPropAccesses(source, propNames, out) {
15812
15920
  }
15813
15921
  if (!anyMentioned) return;
15814
15922
  for (const expr of normaliseExpressionParts(source)) {
15815
- const sourceFile = ts13.createSourceFile(
15923
+ const sourceFile = ts14.createSourceFile(
15816
15924
  "p.ts",
15817
15925
  expr,
15818
- ts13.ScriptTarget.Latest,
15926
+ ts14.ScriptTarget.Latest,
15819
15927
  /*setParentNodes*/
15820
15928
  false,
15821
- ts13.ScriptKind.TS
15929
+ ts14.ScriptKind.TS
15822
15930
  );
15823
15931
  visit2(sourceFile, propNames, out);
15824
15932
  }
@@ -15828,15 +15936,15 @@ function normaliseExpressionParts(source) {
15828
15936
  return extractTemplateExpressions(source);
15829
15937
  }
15830
15938
  function visit2(node, propNames, out) {
15831
- if (ts13.isPropertyAccessExpression(node)) {
15939
+ if (ts14.isPropertyAccessExpression(node)) {
15832
15940
  recordIfPropAccess(node.expression, "property", propNames, out);
15833
- } else if (ts13.isElementAccessExpression(node)) {
15941
+ } else if (ts14.isElementAccessExpression(node)) {
15834
15942
  recordIfPropAccess(node.expression, "index", propNames, out);
15835
15943
  }
15836
- ts13.forEachChild(node, (child) => visit2(child, propNames, out));
15944
+ ts14.forEachChild(node, (child) => visit2(child, propNames, out));
15837
15945
  }
15838
15946
  function recordIfPropAccess(receiver, kind2, propNames, out) {
15839
- if (!ts13.isIdentifier(receiver)) return;
15947
+ if (!ts14.isIdentifier(receiver)) return;
15840
15948
  const name2 = receiver.text;
15841
15949
  if (!propNames.has(name2)) return;
15842
15950
  let kinds = out.get(name2);
@@ -15897,43 +16005,43 @@ var init_compute_prop_usage = __esm({
15897
16005
  });
15898
16006
 
15899
16007
  // ../jsx/src/value-references.ts
15900
- import ts14 from "typescript";
16008
+ import ts15 from "typescript";
15901
16009
  function isValueReferenceIdentifier(id2) {
15902
16010
  const parent2 = id2.parent;
15903
16011
  if (!parent2) return false;
15904
- if (ts14.isPropertyAccessExpression(parent2) && parent2.name === id2) return false;
15905
- if (ts14.isPropertyAssignment(parent2) && parent2.name === id2) return false;
15906
- if ((ts14.isMethodDeclaration(parent2) || ts14.isGetAccessorDeclaration(parent2) || ts14.isSetAccessorDeclaration(parent2)) && parent2.name === id2) {
16012
+ if (ts15.isPropertyAccessExpression(parent2) && parent2.name === id2) return false;
16013
+ if (ts15.isPropertyAssignment(parent2) && parent2.name === id2) return false;
16014
+ if ((ts15.isMethodDeclaration(parent2) || ts15.isGetAccessorDeclaration(parent2) || ts15.isSetAccessorDeclaration(parent2)) && parent2.name === id2) {
15907
16015
  return false;
15908
16016
  }
15909
- if (ts14.isPropertyDeclaration(parent2) && parent2.name === id2) return false;
15910
- if (ts14.isMetaProperty(parent2) && parent2.name === id2) return false;
15911
- if (ts14.isVariableDeclaration(parent2) && parent2.name === id2) return false;
15912
- if (ts14.isFunctionDeclaration(parent2) && parent2.name === id2) return false;
15913
- if (ts14.isFunctionExpression(parent2) && parent2.name === id2) return false;
15914
- if (ts14.isClassDeclaration(parent2) && parent2.name === id2) return false;
15915
- if (ts14.isClassExpression(parent2) && parent2.name === id2) return false;
15916
- if (ts14.isParameter(parent2) && parent2.name === id2) return false;
15917
- if (ts14.isBindingElement(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15918
- if (ts14.isLabeledStatement(parent2) && parent2.label === id2) return false;
15919
- if (ts14.isBreakOrContinueStatement(parent2) && parent2.label === id2) return false;
15920
- if (ts14.isImportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15921
- if (ts14.isExportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15922
- if (ts14.isImportClause(parent2) && parent2.name === id2) return false;
15923
- if (ts14.isNamespaceImport(parent2) && parent2.name === id2) return false;
15924
- if (ts14.isQualifiedName(parent2) && parent2.right === id2) return false;
16017
+ if (ts15.isPropertyDeclaration(parent2) && parent2.name === id2) return false;
16018
+ if (ts15.isMetaProperty(parent2) && parent2.name === id2) return false;
16019
+ if (ts15.isVariableDeclaration(parent2) && parent2.name === id2) return false;
16020
+ if (ts15.isFunctionDeclaration(parent2) && parent2.name === id2) return false;
16021
+ if (ts15.isFunctionExpression(parent2) && parent2.name === id2) return false;
16022
+ if (ts15.isClassDeclaration(parent2) && parent2.name === id2) return false;
16023
+ if (ts15.isClassExpression(parent2) && parent2.name === id2) return false;
16024
+ if (ts15.isParameter(parent2) && parent2.name === id2) return false;
16025
+ if (ts15.isBindingElement(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
16026
+ if (ts15.isLabeledStatement(parent2) && parent2.label === id2) return false;
16027
+ if (ts15.isBreakOrContinueStatement(parent2) && parent2.label === id2) return false;
16028
+ if (ts15.isImportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
16029
+ if (ts15.isExportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
16030
+ if (ts15.isImportClause(parent2) && parent2.name === id2) return false;
16031
+ if (ts15.isNamespaceImport(parent2) && parent2.name === id2) return false;
16032
+ if (ts15.isQualifiedName(parent2) && parent2.right === id2) return false;
15925
16033
  return true;
15926
16034
  }
15927
16035
  function collectValueReferencedNames(code) {
15928
16036
  let sourceFile;
15929
16037
  try {
15930
- sourceFile = ts14.createSourceFile(
16038
+ sourceFile = ts15.createSourceFile(
15931
16039
  "generated.js",
15932
16040
  code,
15933
- ts14.ScriptTarget.Latest,
16041
+ ts15.ScriptTarget.Latest,
15934
16042
  /*setParentNodes*/
15935
16043
  true,
15936
- ts14.ScriptKind.JS
16044
+ ts15.ScriptKind.JS
15937
16045
  );
15938
16046
  } catch {
15939
16047
  return null;
@@ -15942,10 +16050,10 @@ function collectValueReferencedNames(code) {
15942
16050
  if (diagnostics && diagnostics.length > 0) return null;
15943
16051
  const names = /* @__PURE__ */ new Set();
15944
16052
  function visit3(node) {
15945
- if (ts14.isIdentifier(node) && isValueReferenceIdentifier(node)) {
16053
+ if (ts15.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15946
16054
  names.add(node.text);
15947
16055
  }
15948
- ts14.forEachChild(node, visit3);
16056
+ ts15.forEachChild(node, visit3);
15949
16057
  }
15950
16058
  visit3(sourceFile);
15951
16059
  return names;
@@ -16178,23 +16286,23 @@ var init_lowering_registry = __esm({
16178
16286
  });
16179
16287
 
16180
16288
  // ../jsx/src/relocate.ts
16181
- import ts15 from "typescript";
16289
+ import ts16 from "typescript";
16182
16290
  function classify(name2, env) {
16183
16291
  return env.bindings.get(name2) ?? "global";
16184
16292
  }
16185
16293
  function collectFreeRefs(node) {
16186
16294
  const refs = /* @__PURE__ */ new Map();
16187
16295
  function visit3(n, parent2) {
16188
- if (ts15.isIdentifier(n)) {
16189
- if (parent2 && ts15.isPropertyAccessExpression(parent2) && parent2.name === n) return;
16190
- if (parent2 && ts15.isPropertyAssignment(parent2) && parent2.name === n) return;
16191
- if (parent2 && ts15.isShorthandPropertyAssignment(parent2) && parent2.name === n) return;
16296
+ if (ts16.isIdentifier(n)) {
16297
+ if (parent2 && ts16.isPropertyAccessExpression(parent2) && parent2.name === n) return;
16298
+ if (parent2 && ts16.isPropertyAssignment(parent2) && parent2.name === n) return;
16299
+ if (parent2 && ts16.isShorthandPropertyAssignment(parent2) && parent2.name === n) return;
16192
16300
  const list = refs.get(n.text) ?? [];
16193
16301
  list.push(n);
16194
16302
  refs.set(n.text, list);
16195
16303
  return;
16196
16304
  }
16197
- ts15.forEachChild(n, (child) => visit3(child, n));
16305
+ ts16.forEachChild(n, (child) => visit3(child, n));
16198
16306
  }
16199
16307
  visit3(node);
16200
16308
  return refs;
@@ -16296,9 +16404,9 @@ function isInlinableInTemplate(value2, env) {
16296
16404
  return { ok: true, rewrittenValue: r2.text, decisions: r2.decisions };
16297
16405
  }
16298
16406
  function getCalleeIdentifierPath(callee) {
16299
- if (ts15.isParenthesizedExpression(callee)) return getCalleeIdentifierPath(callee.expression);
16300
- if (ts15.isIdentifier(callee)) return callee.text;
16301
- if (ts15.isPropertyAccessExpression(callee)) {
16407
+ if (ts16.isParenthesizedExpression(callee)) return getCalleeIdentifierPath(callee.expression);
16408
+ if (ts16.isIdentifier(callee)) return callee.text;
16409
+ if (ts16.isPropertyAccessExpression(callee)) {
16302
16410
  const left = getCalleeIdentifierPath(callee.expression);
16303
16411
  if (left === null) return null;
16304
16412
  return `${left}.${callee.name.text}`;
@@ -16306,9 +16414,9 @@ function getCalleeIdentifierPath(callee) {
16306
16414
  return null;
16307
16415
  }
16308
16416
  function getCalleeLeftmostIdentifier(callee) {
16309
- if (ts15.isParenthesizedExpression(callee)) return getCalleeLeftmostIdentifier(callee.expression);
16310
- if (ts15.isIdentifier(callee)) return callee.text;
16311
- if (ts15.isPropertyAccessExpression(callee)) {
16417
+ if (ts16.isParenthesizedExpression(callee)) return getCalleeLeftmostIdentifier(callee.expression);
16418
+ if (ts16.isIdentifier(callee)) return callee.text;
16419
+ if (ts16.isPropertyAccessExpression(callee)) {
16312
16420
  return getCalleeLeftmostIdentifier(callee.expression);
16313
16421
  }
16314
16422
  return null;
@@ -16347,17 +16455,17 @@ function isCallAcceptedByAdapter(call, env) {
16347
16455
  }
16348
16456
  function parseExpressionNode(text) {
16349
16457
  try {
16350
- const sf = ts15.createSourceFile(
16458
+ const sf = ts16.createSourceFile(
16351
16459
  "__inline_check__.ts",
16352
16460
  `(${text});`,
16353
- ts15.ScriptTarget.Latest,
16461
+ ts16.ScriptTarget.Latest,
16354
16462
  false,
16355
- ts15.ScriptKind.TS
16463
+ ts16.ScriptKind.TS
16356
16464
  );
16357
16465
  const stmt = sf.statements[0];
16358
- if (!stmt || !ts15.isExpressionStatement(stmt)) return null;
16466
+ if (!stmt || !ts16.isExpressionStatement(stmt)) return null;
16359
16467
  const inner = stmt.expression;
16360
- return ts15.isParenthesizedExpression(inner) ? inner.expression : inner;
16468
+ return ts16.isParenthesizedExpression(inner) ? inner.expression : inner;
16361
16469
  } catch {
16362
16470
  return null;
16363
16471
  }
@@ -16371,8 +16479,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
16371
16479
  let found = false;
16372
16480
  function visit3(n) {
16373
16481
  if (found) return;
16374
- if (ts15.isCallExpression(n) || ts15.isNewExpression(n)) {
16375
- const accepted = ts15.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
16482
+ if (ts16.isCallExpression(n) || ts16.isNewExpression(n)) {
16483
+ const accepted = ts16.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
16376
16484
  if (!accepted) {
16377
16485
  const args2 = n.arguments;
16378
16486
  if (args2) {
@@ -16385,7 +16493,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
16385
16493
  }
16386
16494
  }
16387
16495
  }
16388
- ts15.forEachChild(n, visit3);
16496
+ ts16.forEachChild(n, visit3);
16389
16497
  }
16390
16498
  visit3(node);
16391
16499
  return found;
@@ -16394,13 +16502,13 @@ function hasZeroArgCall(node, env) {
16394
16502
  let found = false;
16395
16503
  function visit3(n) {
16396
16504
  if (found) return;
16397
- if (ts15.isCallExpression(n) && n.arguments.length === 0) {
16505
+ if (ts16.isCallExpression(n) && n.arguments.length === 0) {
16398
16506
  if (!isCallAcceptedByAdapter(n, env)) {
16399
16507
  found = true;
16400
16508
  return;
16401
16509
  }
16402
16510
  }
16403
- ts15.forEachChild(n, visit3);
16511
+ ts16.forEachChild(n, visit3);
16404
16512
  }
16405
16513
  visit3(node);
16406
16514
  return found;
@@ -16409,25 +16517,25 @@ function containsAnyIdentifier(node, names) {
16409
16517
  let found = false;
16410
16518
  function visit3(n) {
16411
16519
  if (found) return;
16412
- if (ts15.isPropertyAccessExpression(n)) {
16520
+ if (ts16.isPropertyAccessExpression(n)) {
16413
16521
  visit3(n.expression);
16414
16522
  return;
16415
16523
  }
16416
- if (ts15.isPropertyAssignment(n)) {
16524
+ if (ts16.isPropertyAssignment(n)) {
16417
16525
  visit3(n.initializer);
16418
16526
  return;
16419
16527
  }
16420
- if (ts15.isShorthandPropertyAssignment(n)) {
16421
- if (ts15.isIdentifier(n.name) && names.has(n.name.text)) {
16528
+ if (ts16.isShorthandPropertyAssignment(n)) {
16529
+ if (ts16.isIdentifier(n.name) && names.has(n.name.text)) {
16422
16530
  found = true;
16423
16531
  }
16424
16532
  return;
16425
16533
  }
16426
- if (ts15.isIdentifier(n) && names.has(n.text)) {
16534
+ if (ts16.isIdentifier(n) && names.has(n.text)) {
16427
16535
  found = true;
16428
16536
  return;
16429
16537
  }
16430
- ts15.forEachChild(n, visit3);
16538
+ ts16.forEachChild(n, visit3);
16431
16539
  }
16432
16540
  visit3(node);
16433
16541
  return found;
@@ -17757,19 +17865,19 @@ var init_emit_module_level = __esm({
17757
17865
  });
17758
17866
 
17759
17867
  // ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
17760
- import ts16 from "typescript";
17868
+ import ts17 from "typescript";
17761
17869
  function propExtractionName(stmt) {
17762
- if (!ts16.isVariableStatement(stmt)) return null;
17870
+ if (!ts17.isVariableStatement(stmt)) return null;
17763
17871
  const decls = stmt.declarationList.declarations;
17764
17872
  if (decls.length !== 1) return null;
17765
17873
  const decl = decls[0];
17766
- if (!ts16.isIdentifier(decl.name) || !decl.initializer) return null;
17874
+ if (!ts17.isIdentifier(decl.name) || !decl.initializer) return null;
17767
17875
  let core = decl.initializer;
17768
- if (ts16.isBinaryExpression(core) && core.operatorToken.kind === ts16.SyntaxKind.QuestionQuestionToken) {
17876
+ if (ts17.isBinaryExpression(core) && core.operatorToken.kind === ts17.SyntaxKind.QuestionQuestionToken) {
17769
17877
  core = core.left;
17770
17878
  }
17771
- if (!ts16.isPropertyAccessExpression(core)) return null;
17772
- if (!ts16.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM) return null;
17879
+ if (!ts17.isPropertyAccessExpression(core)) return null;
17880
+ if (!ts17.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM) return null;
17773
17881
  if (core.name.text !== decl.name.text) return null;
17774
17882
  return decl.name.text;
17775
17883
  }
@@ -17780,17 +17888,17 @@ function pruneUnusedPropExtractions(code) {
17780
17888
  console.warn("[barefootjs] pruneUnusedPropExtractions: generated code did not parse; skipping prune");
17781
17889
  return code;
17782
17890
  }
17783
- const sourceFile = ts16.createSourceFile(
17891
+ const sourceFile = ts17.createSourceFile(
17784
17892
  "generated.js",
17785
17893
  code,
17786
- ts16.ScriptTarget.Latest,
17894
+ ts17.ScriptTarget.Latest,
17787
17895
  /*setParentNodes*/
17788
17896
  false,
17789
- ts16.ScriptKind.JS
17897
+ ts17.ScriptKind.JS
17790
17898
  );
17791
17899
  const spans = [];
17792
17900
  for (const stmt of sourceFile.statements) {
17793
- if (!ts16.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body) continue;
17901
+ if (!ts17.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body) continue;
17794
17902
  for (const inner of stmt.body.statements) {
17795
17903
  const name2 = propExtractionName(inner);
17796
17904
  if (name2 !== null && !referenced.has(name2)) {
@@ -18835,7 +18943,8 @@ function buildReactiveEffectsPlan(args2) {
18835
18943
  whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
18836
18944
  whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
18837
18945
  whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, profileComponentName),
18838
- whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName)
18946
+ whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName),
18947
+ ...cond.readsPreamble && { readsPreamble: true }
18839
18948
  });
18840
18949
  }
18841
18950
  }
@@ -19369,7 +19478,7 @@ var init_lazy_conditional = __esm({
19369
19478
  });
19370
19479
 
19371
19480
  // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
19372
- import ts17 from "typescript";
19481
+ import ts18 from "typescript";
19373
19482
  function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19374
19483
  if (!preamble) return NO_PREAMBLE;
19375
19484
  if (preamble.builderNames.length > 0) {
@@ -19381,19 +19490,19 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19381
19490
  const text = preambleAnalysisText(preamble);
19382
19491
  if (text.trim().length === 0) return NO_PREAMBLE;
19383
19492
  const declaredNames = /* @__PURE__ */ new Set();
19384
- const sf = ts17.createSourceFile(
19493
+ const sf = ts18.createSourceFile(
19385
19494
  "__lazy_preamble__.ts",
19386
19495
  text,
19387
- ts17.ScriptTarget.Latest,
19496
+ ts18.ScriptTarget.Latest,
19388
19497
  /* setParentNodes */
19389
19498
  true,
19390
- ts17.ScriptKind.TS
19499
+ ts18.ScriptKind.TS
19391
19500
  );
19392
19501
  for (const stmt of sf.statements) {
19393
- if (!ts17.isVariableStatement(stmt)) {
19394
- return NO2(`map-callback preamble has a non-declaration statement (${ts17.SyntaxKind[stmt.kind]})`);
19502
+ if (!ts18.isVariableStatement(stmt)) {
19503
+ return NO2(`map-callback preamble has a non-declaration statement (${ts18.SyntaxKind[stmt.kind]})`);
19395
19504
  }
19396
- const isConst = (stmt.declarationList.flags & ts17.NodeFlags.Const) !== 0;
19505
+ const isConst = (stmt.declarationList.flags & ts18.NodeFlags.Const) !== 0;
19397
19506
  if (!isConst) return NO2("map-callback preamble declares a mutable binding (let/var)");
19398
19507
  for (const decl of stmt.declarationList.declarations) {
19399
19508
  collectBindingNames3(decl.name, declaredNames);
@@ -19420,12 +19529,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19420
19529
  return { lazySafe: true, facts: { declaredNames, freeNames } };
19421
19530
  }
19422
19531
  function collectBindingNames3(name2, out) {
19423
- if (ts17.isIdentifier(name2)) {
19532
+ if (ts18.isIdentifier(name2)) {
19424
19533
  out.add(name2.text);
19425
19534
  return;
19426
19535
  }
19427
19536
  for (const element of name2.elements) {
19428
- if (ts17.isOmittedExpression(element)) continue;
19537
+ if (ts18.isOmittedExpression(element)) continue;
19429
19538
  collectBindingNames3(element.name, out);
19430
19539
  }
19431
19540
  }
@@ -19433,56 +19542,56 @@ function findImpureNode(root2, primableNames) {
19433
19542
  let found = null;
19434
19543
  const visit3 = (node) => {
19435
19544
  if (found) return;
19436
- if (ts17.isCallExpression(node)) {
19545
+ if (ts18.isCallExpression(node)) {
19437
19546
  const callee = node.expression;
19438
- const isSignalRead = ts17.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === void 0;
19547
+ const isSignalRead = ts18.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === void 0;
19439
19548
  if (!isSignalRead) {
19440
19549
  found = `call to ${callee.getText(callee.getSourceFile())}`;
19441
19550
  return;
19442
19551
  }
19443
19552
  }
19444
- if (ts17.isNewExpression(node)) {
19553
+ if (ts18.isNewExpression(node)) {
19445
19554
  found = "new expression";
19446
19555
  return;
19447
19556
  }
19448
- if (ts17.isTaggedTemplateExpression(node)) {
19557
+ if (ts18.isTaggedTemplateExpression(node)) {
19449
19558
  found = "tagged template";
19450
19559
  return;
19451
19560
  }
19452
- if (ts17.isAwaitExpression(node)) {
19561
+ if (ts18.isAwaitExpression(node)) {
19453
19562
  found = "await";
19454
19563
  return;
19455
19564
  }
19456
- if (ts17.isYieldExpression(node)) {
19565
+ if (ts18.isYieldExpression(node)) {
19457
19566
  found = "yield";
19458
19567
  return;
19459
19568
  }
19460
- if (ts17.isPrefixUnaryExpression(node) || ts17.isPostfixUnaryExpression(node)) {
19569
+ if (ts18.isPrefixUnaryExpression(node) || ts18.isPostfixUnaryExpression(node)) {
19461
19570
  const op = node.operator;
19462
- if (op === ts17.SyntaxKind.PlusPlusToken || op === ts17.SyntaxKind.MinusMinusToken) {
19571
+ if (op === ts18.SyntaxKind.PlusPlusToken || op === ts18.SyntaxKind.MinusMinusToken) {
19463
19572
  found = "increment/decrement";
19464
19573
  return;
19465
19574
  }
19466
19575
  }
19467
- if (ts17.isDeleteExpression(node)) {
19576
+ if (ts18.isDeleteExpression(node)) {
19468
19577
  found = "delete";
19469
19578
  return;
19470
19579
  }
19471
- if (ts17.isFunctionExpression(node) || ts17.isArrowFunction(node) || ts17.isClassExpression(node)) {
19580
+ if (ts18.isFunctionExpression(node) || ts18.isArrowFunction(node) || ts18.isClassExpression(node)) {
19472
19581
  found = "function or class expression";
19473
19582
  return;
19474
19583
  }
19475
- if (ts17.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
19584
+ if (ts18.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
19476
19585
  found = "assignment";
19477
19586
  return;
19478
19587
  }
19479
- ts17.forEachChild(node, visit3);
19588
+ ts18.forEachChild(node, visit3);
19480
19589
  };
19481
19590
  visit3(root2);
19482
19591
  return found;
19483
19592
  }
19484
- function isAssignmentOperator(kind2) {
19485
- return kind2 >= ts17.SyntaxKind.FirstAssignment && kind2 <= ts17.SyntaxKind.LastAssignment;
19593
+ function isAssignmentOperator2(kind2) {
19594
+ return kind2 >= ts18.SyntaxKind.FirstAssignment && kind2 <= ts18.SyntaxKind.LastAssignment;
19486
19595
  }
19487
19596
  var NO_PREAMBLE, NO2;
19488
19597
  var init_lazy_preamble = __esm({
@@ -20080,7 +20189,7 @@ var init_claim_plan = __esm({
20080
20189
  });
20081
20190
 
20082
20191
  // ../jsx/src/ir-to-client-js/emit-reactive.ts
20083
- import ts18 from "typescript";
20192
+ import ts19 from "typescript";
20084
20193
  function bindingIdArg(ctx2, slotId) {
20085
20194
  if (!ctx2.profile || !slotId) return "";
20086
20195
  return `, ${JSON.stringify(`${ctx2.componentName}#binding:${slotId}`)}`;
@@ -20161,19 +20270,19 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
20161
20270
  if (!matcher) return expr;
20162
20271
  let sourceFile;
20163
20272
  try {
20164
- sourceFile = ts18.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
20273
+ sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
20165
20274
  } catch {
20166
20275
  return expr;
20167
20276
  }
20168
20277
  const stmt = sourceFile.statements[0];
20169
- if (!stmt || !ts18.isExpressionStatement(stmt)) return expr;
20170
- const root2 = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20278
+ if (!stmt || !ts19.isExpressionStatement(stmt)) return expr;
20279
+ const root2 = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20171
20280
  const candidates = [];
20172
20281
  const visit3 = (n) => {
20173
- if (ts18.isCallExpression(n) && n.arguments.length === 2 && ts18.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
20282
+ if (ts19.isCallExpression(n) && n.arguments.length === 2 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
20174
20283
  candidates.push(n);
20175
20284
  }
20176
- ts18.forEachChild(n, visit3);
20285
+ ts19.forEachChild(n, visit3);
20177
20286
  };
20178
20287
  visit3(root2);
20179
20288
  if (candidates.length === 0) return expr;
@@ -20210,19 +20319,19 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
20210
20319
  if (!matcher) return expr;
20211
20320
  let sourceFile;
20212
20321
  try {
20213
- sourceFile = ts18.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
20322
+ sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
20214
20323
  } catch {
20215
20324
  return expr;
20216
20325
  }
20217
20326
  const stmt = sourceFile.statements[0];
20218
- if (!stmt || !ts18.isExpressionStatement(stmt)) return expr;
20219
- const root2 = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20327
+ if (!stmt || !ts19.isExpressionStatement(stmt)) return expr;
20328
+ const root2 = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20220
20329
  const candidates = [];
20221
20330
  const visit3 = (n) => {
20222
- if (ts18.isCallExpression(n) && n.arguments.length === 0 && ts18.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
20331
+ if (ts19.isCallExpression(n) && n.arguments.length === 0 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
20223
20332
  candidates.push(n);
20224
20333
  }
20225
- ts18.forEachChild(n, visit3);
20334
+ ts19.forEachChild(n, visit3);
20226
20335
  };
20227
20336
  visit3(root2);
20228
20337
  if (candidates.length === 0) return expr;
@@ -20580,7 +20689,7 @@ function stringifyReactiveEffects(lines, plan, opts) {
20580
20689
  );
20581
20690
  }
20582
20691
  for (const cond of conditionals) {
20583
- emitOuterConditional(lines, indent, elVar, cond, pc);
20692
+ emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped);
20584
20693
  }
20585
20694
  }
20586
20695
  function emitAttrSlotsGranular(lines, indent, elVar, lookup, attrSlots, elementIndexBySlot, bindingBfId, mapPreambleWrapped) {
@@ -20678,9 +20787,10 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
20678
20787
  lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${bindingBfId(text.slotId)})`);
20679
20788
  }
20680
20789
  }
20681
- function emitOuterConditional(lines, indent, elVar, cond, pc) {
20790
+ function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
20682
20791
  const armIndent = `${indent} `;
20683
- lines.push(`${indent}insert(${elVar}, '${cond.slotId}', () => ${cond.wrappedCondition}, {`);
20792
+ const conditionGetter = cond.readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${cond.wrappedCondition}) }` : `() => ${cond.wrappedCondition}`;
20793
+ lines.push(`${indent}insert(${elVar}, '${cond.slotId}', ${conditionGetter}, {`);
20684
20794
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
20685
20795
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
20686
20796
  stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
@@ -22406,25 +22516,25 @@ var init_phases = __esm({
22406
22516
  });
22407
22517
 
22408
22518
  // ../jsx/src/ir-to-client-js/rewrite-props-object.ts
22409
- import ts19 from "typescript";
22519
+ import ts20 from "typescript";
22410
22520
  function rewritePropsObjectRef(code, propsObjectName) {
22411
22521
  const srcPropsName = propsObjectName ?? "props";
22412
22522
  if (srcPropsName === PROPS_PARAM) return code;
22413
22523
  if (!identifierPattern(srcPropsName).test(code)) return code;
22414
- const sourceFile = ts19.createSourceFile(
22524
+ const sourceFile = ts20.createSourceFile(
22415
22525
  "init-body.ts",
22416
22526
  code,
22417
- ts19.ScriptTarget.Latest,
22527
+ ts20.ScriptTarget.Latest,
22418
22528
  /*setParentNodes*/
22419
22529
  true,
22420
- ts19.ScriptKind.TS
22530
+ ts20.ScriptKind.TS
22421
22531
  );
22422
22532
  const spans = [];
22423
22533
  function visit3(node) {
22424
- if (ts19.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22534
+ if (ts20.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22425
22535
  spans.push([node.getStart(sourceFile), node.getEnd()]);
22426
22536
  }
22427
- ts19.forEachChild(node, visit3);
22537
+ ts20.forEachChild(node, visit3);
22428
22538
  }
22429
22539
  visit3(sourceFile);
22430
22540
  if (spans.length === 0) return code;
@@ -22438,12 +22548,12 @@ function rewritePropsObjectRef(code, propsObjectName) {
22438
22548
  function shouldRewrite(node) {
22439
22549
  const parent2 = node.parent;
22440
22550
  if (!parent2) return true;
22441
- if (ts19.isPropertyAccessExpression(parent2) && parent2.name === node) return false;
22442
- if (ts19.isPropertyAssignment(parent2) && parent2.name === node) return false;
22443
- if (ts19.isShorthandPropertyAssignment(parent2) && parent2.name === node) return false;
22444
- if (ts19.isPropertySignature(parent2) && parent2.name === node) return false;
22445
- if (ts19.isPropertyDeclaration(parent2) && parent2.name === node) return false;
22446
- if (ts19.isBindingElement(parent2) && parent2.name === node) return false;
22551
+ if (ts20.isPropertyAccessExpression(parent2) && parent2.name === node) return false;
22552
+ if (ts20.isPropertyAssignment(parent2) && parent2.name === node) return false;
22553
+ if (ts20.isShorthandPropertyAssignment(parent2) && parent2.name === node) return false;
22554
+ if (ts20.isPropertySignature(parent2) && parent2.name === node) return false;
22555
+ if (ts20.isPropertyDeclaration(parent2) && parent2.name === node) return false;
22556
+ if (ts20.isBindingElement(parent2) && parent2.name === node) return false;
22447
22557
  return true;
22448
22558
  }
22449
22559
  var init_rewrite_props_object = __esm({
@@ -23150,7 +23260,7 @@ var init_css_layer_prefixer = __esm({
23150
23260
  });
23151
23261
 
23152
23262
  // ../jsx/src/preprocess-inline-jsx-callbacks.ts
23153
- import ts20 from "typescript";
23263
+ import ts21 from "typescript";
23154
23264
  function preprocessInlineJsxCallbacks(source, filePath) {
23155
23265
  const errors = [];
23156
23266
  const syntheticNames = [];
@@ -23170,15 +23280,15 @@ function preprocessInlineJsxCallbacks(source, filePath) {
23170
23280
  return { source: current, errors, syntheticNames };
23171
23281
  }
23172
23282
  function runSinglePass(source, filePath, startingCounter) {
23173
- const sourceFile = ts20.createSourceFile(
23283
+ const sourceFile = ts21.createSourceFile(
23174
23284
  filePath,
23175
23285
  source,
23176
- ts20.ScriptTarget.Latest,
23286
+ ts21.ScriptTarget.Latest,
23177
23287
  true,
23178
- ts20.ScriptKind.TSX
23288
+ ts21.ScriptKind.TSX
23179
23289
  );
23180
23290
  const hasUseClient = sourceFile.statements.some(
23181
- (stmt) => ts20.isExpressionStatement(stmt) && ts20.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'")
23291
+ (stmt) => ts21.isExpressionStatement(stmt) && ts21.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'")
23182
23292
  );
23183
23293
  if (!hasUseClient) {
23184
23294
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
@@ -23201,20 +23311,20 @@ function runSinglePass(source, filePath, startingCounter) {
23201
23311
  }
23202
23312
  }
23203
23313
  function visit3(node) {
23204
- if (ts20.isJsxAttribute(node) && node.initializer && ts20.isJsxExpression(node.initializer) && node.initializer.expression) {
23314
+ if (ts21.isJsxAttribute(node) && node.initializer && ts21.isJsxExpression(node.initializer) && node.initializer.expression) {
23205
23315
  if (tryHandleArrowValue(node.initializer.expression)) {
23206
23316
  return;
23207
23317
  }
23208
23318
  }
23209
- if (ts20.isPropertyAssignment(node) && node.initializer) {
23319
+ if (ts21.isPropertyAssignment(node) && node.initializer) {
23210
23320
  if (tryHandleArrowValue(node.initializer)) return;
23211
23321
  }
23212
- ts20.forEachChild(node, visit3);
23322
+ ts21.forEachChild(node, visit3);
23213
23323
  }
23214
23324
  function tryHandleArrowValue(initializer) {
23215
23325
  let expr = initializer;
23216
- while (ts20.isParenthesizedExpression(expr)) expr = expr.expression;
23217
- if (ts20.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23326
+ while (ts21.isParenthesizedExpression(expr)) expr = expr.expression;
23327
+ if (ts21.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23218
23328
  return handleInlineArrow(expr);
23219
23329
  }
23220
23330
  return false;
@@ -23249,7 +23359,7 @@ function runSinglePass(source, filePath, startingCounter) {
23249
23359
  replacements.push({ start: arrowStart, end: arrowEnd, text: name2 });
23250
23360
  return true;
23251
23361
  }
23252
- ts20.forEachChild(sourceFile, visit3);
23362
+ ts21.forEachChild(sourceFile, visit3);
23253
23363
  if (replacements.length === 0) {
23254
23364
  return { source, errors, syntheticNames, counterAfter: counter };
23255
23365
  }
@@ -23268,33 +23378,33 @@ function errorMessageForCapture(captures) {
23268
23378
  return `Inline JSX-returning arrow function captures non-module identifier(s): ${captures.sort().join(", ")}. Extract the callback into a top-level '\\'use client\\'' component (e.g. \`function MyNode(n) { return <div/> }\` then \`renderNode={MyNode}\`) or pass captured values via component props.`;
23269
23379
  }
23270
23380
  function arrowBodyContainsJsx(arrow) {
23271
- if (ts20.isBlock(arrow.body)) {
23381
+ if (ts21.isBlock(arrow.body)) {
23272
23382
  return blockReturnsJsx(arrow.body);
23273
23383
  }
23274
23384
  let body2 = arrow.body;
23275
- while (ts20.isParenthesizedExpression(body2)) body2 = body2.expression;
23385
+ while (ts21.isParenthesizedExpression(body2)) body2 = body2.expression;
23276
23386
  return isJsxLike(body2);
23277
23387
  }
23278
23388
  function blockReturnsJsx(block) {
23279
23389
  let found = false;
23280
23390
  function visit3(n) {
23281
23391
  if (found) return;
23282
- if (ts20.isReturnStatement(n) && n.expression) {
23392
+ if (ts21.isReturnStatement(n) && n.expression) {
23283
23393
  let e = n.expression;
23284
- while (ts20.isParenthesizedExpression(e)) e = e.expression;
23394
+ while (ts21.isParenthesizedExpression(e)) e = e.expression;
23285
23395
  if (isJsxLike(e)) {
23286
23396
  found = true;
23287
23397
  return;
23288
23398
  }
23289
23399
  }
23290
- if (ts20.isArrowFunction(n) || ts20.isFunctionDeclaration(n) || ts20.isFunctionExpression(n)) return;
23291
- ts20.forEachChild(n, visit3);
23400
+ if (ts21.isArrowFunction(n) || ts21.isFunctionDeclaration(n) || ts21.isFunctionExpression(n)) return;
23401
+ ts21.forEachChild(n, visit3);
23292
23402
  }
23293
- ts20.forEachChild(block, visit3);
23403
+ ts21.forEachChild(block, visit3);
23294
23404
  return found;
23295
23405
  }
23296
23406
  function isJsxLike(expr) {
23297
- return ts20.isJsxElement(expr) || ts20.isJsxSelfClosingElement(expr) || ts20.isJsxFragment(expr);
23407
+ return ts21.isJsxElement(expr) || ts21.isJsxSelfClosingElement(expr) || ts21.isJsxFragment(expr);
23298
23408
  }
23299
23409
  function collectArrowParamNames(arrow) {
23300
23410
  const names = /* @__PURE__ */ new Set();
@@ -23303,13 +23413,13 @@ function collectArrowParamNames(arrow) {
23303
23413
  }
23304
23414
  function collectBindingNames4(name2, out) {
23305
23415
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
23306
- if (ts20.isIdentifier(name2)) {
23416
+ if (ts21.isIdentifier(name2)) {
23307
23417
  push(name2.text);
23308
- } else if (ts20.isObjectBindingPattern(name2)) {
23418
+ } else if (ts21.isObjectBindingPattern(name2)) {
23309
23419
  name2.elements.forEach((el) => collectBindingNames4(el.name, out));
23310
- } else if (ts20.isArrayBindingPattern(name2)) {
23420
+ } else if (ts21.isArrayBindingPattern(name2)) {
23311
23421
  name2.elements.forEach((el) => {
23312
- if (!ts20.isOmittedExpression(el)) collectBindingNames4(el.name, out);
23422
+ if (!ts21.isOmittedExpression(el)) collectBindingNames4(el.name, out);
23313
23423
  });
23314
23424
  }
23315
23425
  }
@@ -23334,71 +23444,71 @@ function collectFreeIdentifiers(arrow) {
23334
23444
  return bound.includes(name2);
23335
23445
  }
23336
23446
  function visit3(node) {
23337
- if (ts20.isIdentifier(node)) {
23447
+ if (ts21.isIdentifier(node)) {
23338
23448
  const parent2 = node.parent;
23339
- if (parent2 && ts20.isPropertyAccessExpression(parent2) && parent2.name === node) return;
23340
- if (parent2 && ts20.isPropertyAssignment(parent2) && parent2.name === node) return;
23341
- if (parent2 && ts20.isPropertySignature(parent2) && parent2.name === node) return;
23342
- if (parent2 && ts20.isPropertyDeclaration(parent2) && parent2.name === node) return;
23343
- if (parent2 && ts20.isMethodDeclaration(parent2) && parent2.name === node) return;
23344
- if (parent2 && ts20.isMethodSignature(parent2) && parent2.name === node) return;
23345
- if (parent2 && ts20.isGetAccessorDeclaration(parent2) && parent2.name === node) return;
23346
- if (parent2 && ts20.isSetAccessorDeclaration(parent2) && parent2.name === node) return;
23347
- if (parent2 && ts20.isEnumMember(parent2) && parent2.name === node) return;
23348
- if (parent2 && ts20.isBindingElement(parent2) && parent2.propertyName === node) return;
23349
- if (parent2 && ts20.isShorthandPropertyAssignment(parent2) && parent2.name === node) {
23449
+ if (parent2 && ts21.isPropertyAccessExpression(parent2) && parent2.name === node) return;
23450
+ if (parent2 && ts21.isPropertyAssignment(parent2) && parent2.name === node) return;
23451
+ if (parent2 && ts21.isPropertySignature(parent2) && parent2.name === node) return;
23452
+ if (parent2 && ts21.isPropertyDeclaration(parent2) && parent2.name === node) return;
23453
+ if (parent2 && ts21.isMethodDeclaration(parent2) && parent2.name === node) return;
23454
+ if (parent2 && ts21.isMethodSignature(parent2) && parent2.name === node) return;
23455
+ if (parent2 && ts21.isGetAccessorDeclaration(parent2) && parent2.name === node) return;
23456
+ if (parent2 && ts21.isSetAccessorDeclaration(parent2) && parent2.name === node) return;
23457
+ if (parent2 && ts21.isEnumMember(parent2) && parent2.name === node) return;
23458
+ if (parent2 && ts21.isBindingElement(parent2) && parent2.propertyName === node) return;
23459
+ if (parent2 && ts21.isShorthandPropertyAssignment(parent2) && parent2.name === node) {
23350
23460
  if (!isBound(node.text)) ids.add(node.text);
23351
23461
  return;
23352
23462
  }
23353
- if (parent2 && ts20.isParameter(parent2) && parent2.name === node) return;
23354
- if (parent2 && ts20.isVariableDeclaration(parent2) && parent2.name === node) return;
23355
- if (parent2 && ts20.isFunctionDeclaration(parent2) && parent2.name === node) return;
23356
- if (parent2 && ts20.isClassDeclaration(parent2) && parent2.name === node) return;
23357
- if (parent2 && ts20.isJsxAttribute(parent2) && parent2.name === node) return;
23358
- if (parent2 && ts20.isJsxOpeningElement(parent2) && parent2.tagName === node) {
23463
+ if (parent2 && ts21.isParameter(parent2) && parent2.name === node) return;
23464
+ if (parent2 && ts21.isVariableDeclaration(parent2) && parent2.name === node) return;
23465
+ if (parent2 && ts21.isFunctionDeclaration(parent2) && parent2.name === node) return;
23466
+ if (parent2 && ts21.isClassDeclaration(parent2) && parent2.name === node) return;
23467
+ if (parent2 && ts21.isJsxAttribute(parent2) && parent2.name === node) return;
23468
+ if (parent2 && ts21.isJsxOpeningElement(parent2) && parent2.tagName === node) {
23359
23469
  if (/^[a-z]/.test(node.text)) return;
23360
23470
  }
23361
- if (parent2 && ts20.isJsxClosingElement(parent2) && parent2.tagName === node) {
23471
+ if (parent2 && ts21.isJsxClosingElement(parent2) && parent2.tagName === node) {
23362
23472
  if (/^[a-z]/.test(node.text)) return;
23363
23473
  }
23364
23474
  if (isBound(node.text)) return;
23365
23475
  ids.add(node.text);
23366
23476
  return;
23367
23477
  }
23368
- if (ts20.isVariableDeclaration(node)) {
23478
+ if (ts21.isVariableDeclaration(node)) {
23369
23479
  const declared = pushBindings(node.name);
23370
23480
  if (node.initializer) visit3(node.initializer);
23371
23481
  declared;
23372
23482
  return;
23373
23483
  }
23374
- if (ts20.isFunctionDeclaration(node)) {
23484
+ if (ts21.isFunctionDeclaration(node)) {
23375
23485
  if (node.name) bound.push(node.name.text);
23376
23486
  visitInsideNewScope(node);
23377
23487
  return;
23378
23488
  }
23379
- if (ts20.isClassDeclaration(node)) {
23489
+ if (ts21.isClassDeclaration(node)) {
23380
23490
  if (node.name) bound.push(node.name.text);
23381
- ts20.forEachChild(node, visit3);
23491
+ ts21.forEachChild(node, visit3);
23382
23492
  return;
23383
23493
  }
23384
- if (ts20.isArrowFunction(node) || ts20.isFunctionExpression(node)) {
23494
+ if (ts21.isArrowFunction(node) || ts21.isFunctionExpression(node)) {
23385
23495
  visitInsideNewScope(node);
23386
23496
  return;
23387
23497
  }
23388
- if (ts20.isCatchClause(node)) {
23498
+ if (ts21.isCatchClause(node)) {
23389
23499
  const before = bound.length;
23390
23500
  if (node.variableDeclaration) pushBindings(node.variableDeclaration.name);
23391
- ts20.forEachChild(node, visit3);
23501
+ ts21.forEachChild(node, visit3);
23392
23502
  popN(bound.length - before);
23393
23503
  return;
23394
23504
  }
23395
- if (ts20.isBlock(node)) {
23505
+ if (ts21.isBlock(node)) {
23396
23506
  const before = bound.length;
23397
- ts20.forEachChild(node, visit3);
23507
+ ts21.forEachChild(node, visit3);
23398
23508
  popN(bound.length - before);
23399
23509
  return;
23400
23510
  }
23401
- ts20.forEachChild(node, visit3);
23511
+ ts21.forEachChild(node, visit3);
23402
23512
  }
23403
23513
  function visitInsideNewScope(fn) {
23404
23514
  const before = bound.length;
@@ -23418,27 +23528,27 @@ function collectFreeIdentifiers(arrow) {
23418
23528
  function collectModuleScopeNames(sourceFile) {
23419
23529
  const names = /* @__PURE__ */ new Set();
23420
23530
  for (const stmt of sourceFile.statements) {
23421
- if (ts20.isFunctionDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23422
- else if (ts20.isClassDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23423
- else if (ts20.isVariableStatement(stmt)) {
23531
+ if (ts21.isFunctionDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23532
+ else if (ts21.isClassDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23533
+ else if (ts21.isVariableStatement(stmt)) {
23424
23534
  for (const decl of stmt.declarationList.declarations) collectBindingNames4(decl.name, names);
23425
- } else if (ts20.isImportDeclaration(stmt) && stmt.importClause) {
23535
+ } else if (ts21.isImportDeclaration(stmt) && stmt.importClause) {
23426
23536
  const ic = stmt.importClause;
23427
23537
  if (ic.name) names.add(ic.name.text);
23428
23538
  if (ic.namedBindings) {
23429
- if (ts20.isNamespaceImport(ic.namedBindings)) names.add(ic.namedBindings.name.text);
23539
+ if (ts21.isNamespaceImport(ic.namedBindings)) names.add(ic.namedBindings.name.text);
23430
23540
  else for (const e of ic.namedBindings.elements) names.add(e.name.text);
23431
23541
  }
23432
- } else if (ts20.isTypeAliasDeclaration(stmt)) names.add(stmt.name.text);
23433
- else if (ts20.isInterfaceDeclaration(stmt)) names.add(stmt.name.text);
23434
- else if (ts20.isEnumDeclaration(stmt)) names.add(stmt.name.text);
23542
+ } else if (ts21.isTypeAliasDeclaration(stmt)) names.add(stmt.name.text);
23543
+ else if (ts21.isInterfaceDeclaration(stmt)) names.add(stmt.name.text);
23544
+ else if (ts21.isEnumDeclaration(stmt)) names.add(stmt.name.text);
23435
23545
  }
23436
23546
  return names;
23437
23547
  }
23438
23548
  function buildSyntheticDeclaration(name2, arrow, sourceFile) {
23439
23549
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
23440
23550
  let bodyText;
23441
- if (ts20.isBlock(arrow.body)) {
23551
+ if (ts21.isBlock(arrow.body)) {
23442
23552
  bodyText = arrow.body.getText(sourceFile);
23443
23553
  } else {
23444
23554
  const expr = arrow.body.getText(sourceFile);
@@ -23457,7 +23567,7 @@ var init_preprocess_inline_jsx_callbacks = __esm({
23457
23567
  });
23458
23568
 
23459
23569
  // ../jsx/src/ssr-defaults.ts
23460
- import ts21 from "typescript";
23570
+ import ts22 from "typescript";
23461
23571
  function deriveStashFromDefaults(defaults, props) {
23462
23572
  const extra = {};
23463
23573
  for (const [name2, d] of Object.entries(defaults)) {
@@ -23537,11 +23647,11 @@ function collectPropRefs(expr, propsObjectName, out) {
23537
23647
  const node = parseExpression2(expr);
23538
23648
  if (!node) return;
23539
23649
  const visit3 = (n) => {
23540
- if (ts21.isPropertyAccessExpression(n) && ts21.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts21.isIdentifier(n.name)) {
23650
+ if (ts22.isPropertyAccessExpression(n) && ts22.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts22.isIdentifier(n.name)) {
23541
23651
  out.add(n.name.text);
23542
23652
  return;
23543
23653
  }
23544
- ts21.forEachChild(n, visit3);
23654
+ ts22.forEachChild(n, visit3);
23545
23655
  };
23546
23656
  visit3(node);
23547
23657
  }
@@ -23558,21 +23668,21 @@ function tryStaticEval(expr, ctx2) {
23558
23668
  }
23559
23669
  function evalStatementsForReturn(statements, ctx2) {
23560
23670
  for (const stmt of statements) {
23561
- if (ts21.isVariableStatement(stmt)) {
23671
+ if (ts22.isVariableStatement(stmt)) {
23562
23672
  for (const d of stmt.declarationList.declarations) {
23563
- if (!ts21.isIdentifier(d.name) || !d.initializer) continue;
23673
+ if (!ts22.isIdentifier(d.name) || !d.initializer) continue;
23564
23674
  const v = evalNode(d.initializer, ctx2);
23565
23675
  if (v !== UNRESOLVED) ctx2.bindings[d.name.text] = v;
23566
23676
  }
23567
- } else if (ts21.isReturnStatement(stmt)) {
23677
+ } else if (ts22.isReturnStatement(stmt)) {
23568
23678
  return stmt.expression ? evalNode(stmt.expression, ctx2) : UNRESOLVED;
23569
- } else if (ts21.isIfStatement(stmt)) {
23679
+ } else if (ts22.isIfStatement(stmt)) {
23570
23680
  const cond = evalNode(stmt.expression, ctx2);
23571
23681
  if (cond === UNRESOLVED) return UNRESOLVED;
23572
23682
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
23573
23683
  if (branch) {
23574
23684
  const taken = evalStatementsForReturn(
23575
- ts21.isBlock(branch) ? branch.statements : [branch],
23685
+ ts22.isBlock(branch) ? branch.statements : [branch],
23576
23686
  ctx2
23577
23687
  );
23578
23688
  if (taken !== NO_RETURN) return taken;
@@ -23584,64 +23694,64 @@ function evalStatementsForReturn(statements, ctx2) {
23584
23694
  return NO_RETURN;
23585
23695
  }
23586
23696
  function parseExpression2(expr) {
23587
- const sf = ts21.createSourceFile(
23697
+ const sf = ts22.createSourceFile(
23588
23698
  "__ssr_default__.ts",
23589
23699
  `(${expr})`,
23590
- ts21.ScriptTarget.Latest,
23700
+ ts22.ScriptTarget.Latest,
23591
23701
  false,
23592
- ts21.ScriptKind.TS
23702
+ ts22.ScriptKind.TS
23593
23703
  );
23594
23704
  const stmt = sf.statements[0];
23595
- if (!stmt || !ts21.isExpressionStatement(stmt)) return null;
23596
- const inner = ts21.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23705
+ if (!stmt || !ts22.isExpressionStatement(stmt)) return null;
23706
+ const inner = ts22.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23597
23707
  return inner;
23598
23708
  }
23599
23709
  function evalNode(node, ctx2) {
23600
- if (ts21.isParenthesizedExpression(node)) return evalNode(node.expression, ctx2);
23601
- if (ts21.isAsExpression(node)) return evalNode(node.expression, ctx2);
23602
- if (ts21.isSatisfiesExpression(node)) return evalNode(node.expression, ctx2);
23603
- if (ts21.isTypeAssertionExpression(node)) return evalNode(node.expression, ctx2);
23604
- if (ts21.isNonNullExpression(node)) return evalNode(node.expression, ctx2);
23605
- if (ts21.isArrowFunction(node)) {
23710
+ if (ts22.isParenthesizedExpression(node)) return evalNode(node.expression, ctx2);
23711
+ if (ts22.isAsExpression(node)) return evalNode(node.expression, ctx2);
23712
+ if (ts22.isSatisfiesExpression(node)) return evalNode(node.expression, ctx2);
23713
+ if (ts22.isTypeAssertionExpression(node)) return evalNode(node.expression, ctx2);
23714
+ if (ts22.isNonNullExpression(node)) return evalNode(node.expression, ctx2);
23715
+ if (ts22.isArrowFunction(node)) {
23606
23716
  if (node.parameters.length !== 0) return UNRESOLVED;
23607
- if (!ts21.isBlock(node.body)) return evalNode(node.body, ctx2);
23717
+ if (!ts22.isBlock(node.body)) return evalNode(node.body, ctx2);
23608
23718
  const localBindings = { ...ctx2.bindings };
23609
23719
  const localCtx = { ...ctx2, bindings: localBindings };
23610
23720
  const result2 = evalStatementsForReturn(node.body.statements, localCtx);
23611
23721
  return result2 === NO_RETURN ? UNRESOLVED : result2;
23612
23722
  }
23613
- if (ts21.isNumericLiteral(node)) return Number(node.text);
23614
- if (ts21.isStringLiteralLike(node)) return node.text;
23615
- if (node.kind === ts21.SyntaxKind.TrueKeyword) return true;
23616
- if (node.kind === ts21.SyntaxKind.FalseKeyword) return false;
23617
- if (node.kind === ts21.SyntaxKind.NullKeyword) return null;
23618
- if (ts21.isIdentifier(node)) {
23723
+ if (ts22.isNumericLiteral(node)) return Number(node.text);
23724
+ if (ts22.isStringLiteralLike(node)) return node.text;
23725
+ if (node.kind === ts22.SyntaxKind.TrueKeyword) return true;
23726
+ if (node.kind === ts22.SyntaxKind.FalseKeyword) return false;
23727
+ if (node.kind === ts22.SyntaxKind.NullKeyword) return null;
23728
+ if (ts22.isIdentifier(node)) {
23619
23729
  if (node.text === "undefined") return void 0;
23620
23730
  if (node.text in ctx2.bindings) return ctx2.bindings[node.text];
23621
23731
  if (ctx2.propsLike.has(node.text)) return void 0;
23622
23732
  return UNRESOLVED;
23623
23733
  }
23624
- if (ts21.isPrefixUnaryExpression(node)) {
23734
+ if (ts22.isPrefixUnaryExpression(node)) {
23625
23735
  const arg = evalNode(node.operand, ctx2);
23626
23736
  if (arg === UNRESOLVED) return UNRESOLVED;
23627
23737
  switch (node.operator) {
23628
- case ts21.SyntaxKind.MinusToken:
23738
+ case ts22.SyntaxKind.MinusToken:
23629
23739
  return typeof arg === "number" ? -arg : UNRESOLVED;
23630
- case ts21.SyntaxKind.PlusToken:
23740
+ case ts22.SyntaxKind.PlusToken:
23631
23741
  return typeof arg === "number" ? +arg : UNRESOLVED;
23632
- case ts21.SyntaxKind.ExclamationToken:
23742
+ case ts22.SyntaxKind.ExclamationToken:
23633
23743
  return !arg;
23634
23744
  }
23635
23745
  return UNRESOLVED;
23636
23746
  }
23637
- if (ts21.isObjectLiteralExpression(node)) {
23747
+ if (ts22.isObjectLiteralExpression(node)) {
23638
23748
  const obj = {};
23639
23749
  for (const prop of node.properties) {
23640
- if (!ts21.isPropertyAssignment(prop)) return UNRESOLVED;
23750
+ if (!ts22.isPropertyAssignment(prop)) return UNRESOLVED;
23641
23751
  let key;
23642
- if (ts21.isIdentifier(prop.name) || ts21.isStringLiteralLike(prop.name)) {
23752
+ if (ts22.isIdentifier(prop.name) || ts22.isStringLiteralLike(prop.name)) {
23643
23753
  key = prop.name.text;
23644
- } else if (ts21.isNumericLiteral(prop.name)) {
23754
+ } else if (ts22.isNumericLiteral(prop.name)) {
23645
23755
  key = prop.name.text;
23646
23756
  } else {
23647
23757
  return UNRESOLVED;
@@ -23652,17 +23762,17 @@ function evalNode(node, ctx2) {
23652
23762
  }
23653
23763
  return obj;
23654
23764
  }
23655
- if (ts21.isArrayLiteralExpression(node)) {
23765
+ if (ts22.isArrayLiteralExpression(node)) {
23656
23766
  const arr = [];
23657
23767
  for (const elem of node.elements) {
23658
- if (ts21.isOmittedExpression(elem)) return UNRESOLVED;
23768
+ if (ts22.isOmittedExpression(elem)) return UNRESOLVED;
23659
23769
  const v = evalNode(elem, ctx2);
23660
23770
  if (v === UNRESOLVED) return UNRESOLVED;
23661
23771
  arr.push(v === void 0 ? null : v);
23662
23772
  }
23663
23773
  return arr;
23664
23774
  }
23665
- if (ts21.isElementAccessExpression(node)) {
23775
+ if (ts22.isElementAccessExpression(node)) {
23666
23776
  const base = evalNode(node.expression, ctx2);
23667
23777
  if (base === void 0) return void 0;
23668
23778
  if (base === UNRESOLVED || base === null || typeof base !== "object") return UNRESOLVED;
@@ -23672,16 +23782,16 @@ function evalNode(node, ctx2) {
23672
23782
  const k = String(key);
23673
23783
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : void 0;
23674
23784
  }
23675
- if (ts21.isPropertyAccessExpression(node)) {
23785
+ if (ts22.isPropertyAccessExpression(node)) {
23676
23786
  const baseResult = evalNode(node.expression, ctx2);
23677
23787
  if (baseResult === void 0) return void 0;
23678
23788
  return UNRESOLVED;
23679
23789
  }
23680
- if (ts21.isCallExpression(node)) {
23681
- if (node.arguments.length === 0 && ts21.isIdentifier(node.expression) && node.expression.text in ctx2.bindings) {
23790
+ if (ts22.isCallExpression(node)) {
23791
+ if (node.arguments.length === 0 && ts22.isIdentifier(node.expression) && node.expression.text in ctx2.bindings) {
23682
23792
  return ctx2.bindings[node.expression.text];
23683
23793
  }
23684
- if (ts21.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23794
+ if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23685
23795
  const recv = evalNode(node.expression.expression, ctx2);
23686
23796
  if (Array.isArray(recv)) {
23687
23797
  let sep = ",";
@@ -23696,24 +23806,24 @@ function evalNode(node, ctx2) {
23696
23806
  }
23697
23807
  return UNRESOLVED;
23698
23808
  }
23699
- if (ts21.isConditionalExpression(node)) {
23809
+ if (ts22.isConditionalExpression(node)) {
23700
23810
  const cond = evalNode(node.condition, ctx2);
23701
23811
  if (cond === UNRESOLVED) return UNRESOLVED;
23702
23812
  return cond ? evalNode(node.whenTrue, ctx2) : evalNode(node.whenFalse, ctx2);
23703
23813
  }
23704
- if (ts21.isBinaryExpression(node)) {
23814
+ if (ts22.isBinaryExpression(node)) {
23705
23815
  const op = node.operatorToken.kind;
23706
- if (op === ts21.SyntaxKind.QuestionQuestionToken) {
23816
+ if (op === ts22.SyntaxKind.QuestionQuestionToken) {
23707
23817
  const l2 = evalNode(node.left, ctx2);
23708
23818
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== void 0) return l2;
23709
23819
  return evalNode(node.right, ctx2);
23710
23820
  }
23711
- if (op === ts21.SyntaxKind.BarBarToken) {
23821
+ if (op === ts22.SyntaxKind.BarBarToken) {
23712
23822
  const l2 = evalNode(node.left, ctx2);
23713
23823
  if (l2 !== UNRESOLVED && l2) return l2;
23714
23824
  return evalNode(node.right, ctx2);
23715
23825
  }
23716
- if (op === ts21.SyntaxKind.AmpersandAmpersandToken) {
23826
+ if (op === ts22.SyntaxKind.AmpersandAmpersandToken) {
23717
23827
  const l2 = evalNode(node.left, ctx2);
23718
23828
  if (l2 === UNRESOLVED) return UNRESOLVED;
23719
23829
  if (!l2) return l2;
@@ -23723,28 +23833,28 @@ function evalNode(node, ctx2) {
23723
23833
  const r2 = evalNode(node.right, ctx2);
23724
23834
  if (l === UNRESOLVED || r2 === UNRESOLVED) return UNRESOLVED;
23725
23835
  switch (op) {
23726
- case ts21.SyntaxKind.PlusToken:
23836
+ case ts22.SyntaxKind.PlusToken:
23727
23837
  if (typeof l === "string" || typeof r2 === "string") return `${l}${r2}`;
23728
23838
  if (typeof l === "number" && typeof r2 === "number") return l + r2;
23729
23839
  return UNRESOLVED;
23730
- case ts21.SyntaxKind.MinusToken:
23840
+ case ts22.SyntaxKind.MinusToken:
23731
23841
  return typeof l === "number" && typeof r2 === "number" ? l - r2 : UNRESOLVED;
23732
- case ts21.SyntaxKind.AsteriskToken:
23842
+ case ts22.SyntaxKind.AsteriskToken:
23733
23843
  return typeof l === "number" && typeof r2 === "number" ? l * r2 : UNRESOLVED;
23734
- case ts21.SyntaxKind.SlashToken:
23844
+ case ts22.SyntaxKind.SlashToken:
23735
23845
  return typeof l === "number" && typeof r2 === "number" && r2 !== 0 ? l / r2 : UNRESOLVED;
23736
- case ts21.SyntaxKind.PercentToken:
23846
+ case ts22.SyntaxKind.PercentToken:
23737
23847
  return typeof l === "number" && typeof r2 === "number" && r2 !== 0 ? l % r2 : UNRESOLVED;
23738
- case ts21.SyntaxKind.EqualsEqualsEqualsToken:
23739
- case ts21.SyntaxKind.EqualsEqualsToken:
23848
+ case ts22.SyntaxKind.EqualsEqualsEqualsToken:
23849
+ case ts22.SyntaxKind.EqualsEqualsToken:
23740
23850
  return l === r2;
23741
- case ts21.SyntaxKind.ExclamationEqualsEqualsToken:
23742
- case ts21.SyntaxKind.ExclamationEqualsToken:
23851
+ case ts22.SyntaxKind.ExclamationEqualsEqualsToken:
23852
+ case ts22.SyntaxKind.ExclamationEqualsToken:
23743
23853
  return l !== r2;
23744
23854
  }
23745
23855
  return UNRESOLVED;
23746
23856
  }
23747
- if (ts21.isTemplateExpression(node)) {
23857
+ if (ts22.isTemplateExpression(node)) {
23748
23858
  if (node.templateSpans.length === 0) return node.head.text;
23749
23859
  let acc = node.head.text;
23750
23860
  for (const span of node.templateSpans) {
@@ -23754,7 +23864,7 @@ function evalNode(node, ctx2) {
23754
23864
  }
23755
23865
  return acc;
23756
23866
  }
23757
- if (ts21.isNoSubstitutionTemplateLiteral(node)) return node.text;
23867
+ if (ts22.isNoSubstitutionTemplateLiteral(node)) return node.text;
23758
23868
  return UNRESOLVED;
23759
23869
  }
23760
23870
  var UNRESOLVED, NO_RETURN;
@@ -23767,7 +23877,7 @@ var init_ssr_defaults = __esm({
23767
23877
  });
23768
23878
 
23769
23879
  // ../jsx/src/augment-inherited-props.ts
23770
- import ts22 from "typescript";
23880
+ import ts23 from "typescript";
23771
23881
  function collectContextConsumers(metadata) {
23772
23882
  const constants = metadata.localConstants ?? [];
23773
23883
  const contextDefaults = /* @__PURE__ */ new Map();
@@ -23794,35 +23904,35 @@ function collectContextConsumers(metadata) {
23794
23904
  }
23795
23905
  function parseUseContextArg(source) {
23796
23906
  const expr = parseSingleExpression(source);
23797
- if (!expr || !ts22.isCallExpression(expr)) return null;
23798
- if (!ts22.isIdentifier(expr.expression) || expr.expression.text !== "useContext") return null;
23907
+ if (!expr || !ts23.isCallExpression(expr)) return null;
23908
+ if (!ts23.isIdentifier(expr.expression) || expr.expression.text !== "useContext") return null;
23799
23909
  if (expr.arguments.length !== 1) return null;
23800
23910
  const arg = expr.arguments[0];
23801
- return ts22.isIdentifier(arg) ? arg.text : null;
23911
+ return ts23.isIdentifier(arg) ? arg.text : null;
23802
23912
  }
23803
23913
  function parseCreateContextDefault(source) {
23804
23914
  const expr = parseSingleExpression(source);
23805
- if (!expr || !ts22.isCallExpression(expr)) return null;
23915
+ if (!expr || !ts23.isCallExpression(expr)) return null;
23806
23916
  if (expr.arguments.length === 0) return null;
23807
23917
  const arg = expr.arguments[0];
23808
- if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg)) return arg.text;
23809
- if (ts22.isNumericLiteral(arg)) return Number(arg.text);
23810
- if (arg.kind === ts22.SyntaxKind.TrueKeyword) return true;
23811
- if (arg.kind === ts22.SyntaxKind.FalseKeyword) return false;
23918
+ if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg)) return arg.text;
23919
+ if (ts23.isNumericLiteral(arg)) return Number(arg.text);
23920
+ if (arg.kind === ts23.SyntaxKind.TrueKeyword) return true;
23921
+ if (arg.kind === ts23.SyntaxKind.FalseKeyword) return false;
23812
23922
  return null;
23813
23923
  }
23814
23924
  function isObjectLiteralCreateContextDefault(source) {
23815
23925
  const expr = parseSingleExpression(source);
23816
- if (!expr || !ts22.isCallExpression(expr)) return false;
23926
+ if (!expr || !ts23.isCallExpression(expr)) return false;
23817
23927
  if (expr.arguments.length === 0) return false;
23818
- return ts22.isObjectLiteralExpression(expr.arguments[0]);
23928
+ return ts23.isObjectLiteralExpression(expr.arguments[0]);
23819
23929
  }
23820
23930
  function parseSingleExpression(source) {
23821
- const sf = ts22.createSourceFile("__ctx.ts", `(${source})`, ts22.ScriptTarget.Latest, false);
23931
+ const sf = ts23.createSourceFile("__ctx.ts", `(${source})`, ts23.ScriptTarget.Latest, false);
23822
23932
  const stmt = sf.statements[0];
23823
- if (!stmt || !ts22.isExpressionStatement(stmt)) return null;
23933
+ if (!stmt || !ts23.isExpressionStatement(stmt)) return null;
23824
23934
  let e = stmt.expression;
23825
- while (ts22.isParenthesizedExpression(e)) e = e.expression;
23935
+ while (ts23.isParenthesizedExpression(e)) e = e.expression;
23826
23936
  return e;
23827
23937
  }
23828
23938
  function augmentInheritedPropAccesses(ir) {
@@ -23843,21 +23953,21 @@ function augmentInheritedPropAccesses(ir) {
23843
23953
  const coalesceLiteralTypes = /* @__PURE__ */ new Map();
23844
23954
  const pinCoalesceLiterals = (s) => {
23845
23955
  if (!s || !s.includes(propsObj)) return;
23846
- const sf = ts22.createSourceFile("__aug.ts", `(${s})`, ts22.ScriptTarget.Latest, false);
23956
+ const sf = ts23.createSourceFile("__aug.ts", `(${s})`, ts23.ScriptTarget.Latest, false);
23847
23957
  const visit3 = (n) => {
23848
- if (ts22.isBinaryExpression(n) && (n.operatorToken.kind === ts22.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts22.SyntaxKind.BarBarToken)) {
23958
+ if (ts23.isBinaryExpression(n) && (n.operatorToken.kind === ts23.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts23.SyntaxKind.BarBarToken)) {
23849
23959
  let left = n.left;
23850
- while (ts22.isParenthesizedExpression(left)) left = left.expression;
23851
- if (ts22.isPropertyAccessExpression(left) && ts22.isIdentifier(left.expression) && left.expression.text === propsObj) {
23960
+ while (ts23.isParenthesizedExpression(left)) left = left.expression;
23961
+ if (ts23.isPropertyAccessExpression(left) && ts23.isIdentifier(left.expression) && left.expression.text === propsObj) {
23852
23962
  const name2 = left.name.text;
23853
23963
  let right = n.right;
23854
- while (ts22.isParenthesizedExpression(right)) right = right.expression;
23855
- if (ts22.isPrefixUnaryExpression(right)) right = right.operand;
23856
- const kind2 = ts22.isNumericLiteral(right) ? "number" : right.kind === ts22.SyntaxKind.TrueKeyword || right.kind === ts22.SyntaxKind.FalseKeyword ? "boolean" : ts22.isStringLiteralLike(right) ? "string" : null;
23964
+ while (ts23.isParenthesizedExpression(right)) right = right.expression;
23965
+ if (ts23.isPrefixUnaryExpression(right)) right = right.operand;
23966
+ const kind2 = ts23.isNumericLiteral(right) ? "number" : right.kind === ts23.SyntaxKind.TrueKeyword || right.kind === ts23.SyntaxKind.FalseKeyword ? "boolean" : ts23.isStringLiteralLike(right) ? "string" : null;
23857
23967
  if (kind2 && !coalesceLiteralTypes.has(name2)) coalesceLiteralTypes.set(name2, kind2);
23858
23968
  }
23859
23969
  }
23860
- ts22.forEachChild(n, visit3);
23970
+ ts23.forEachChild(n, visit3);
23861
23971
  };
23862
23972
  visit3(sf);
23863
23973
  };
@@ -23953,39 +24063,39 @@ function augmentInheritedPropAccesses(ir) {
23953
24063
  }
23954
24064
  }
23955
24065
  function parseStaticStringConst(source) {
23956
- const sf = ts22.createSourceFile(
24066
+ const sf = ts23.createSourceFile(
23957
24067
  "__const.ts",
23958
24068
  `const __x = (${source});`,
23959
- ts22.ScriptTarget.Latest,
24069
+ ts23.ScriptTarget.Latest,
23960
24070
  /*setParentNodes*/
23961
24071
  false
23962
24072
  );
23963
24073
  const stmt = sf.statements[0];
23964
- if (!stmt || !ts22.isVariableStatement(stmt)) return null;
24074
+ if (!stmt || !ts23.isVariableStatement(stmt)) return null;
23965
24075
  let init = stmt.declarationList.declarations[0]?.initializer;
23966
- while (init && ts22.isParenthesizedExpression(init)) init = init.expression;
24076
+ while (init && ts23.isParenthesizedExpression(init)) init = init.expression;
23967
24077
  if (!init) return null;
23968
- if (ts22.isStringLiteral(init) || ts22.isNoSubstitutionTemplateLiteral(init)) {
24078
+ if (ts23.isStringLiteral(init) || ts23.isNoSubstitutionTemplateLiteral(init)) {
23969
24079
  return init.text;
23970
24080
  }
23971
24081
  return evalStringArrayJoin(source);
23972
24082
  }
23973
24083
  function evalTemplateOfStringConsts(source, resolved) {
23974
- const sf = ts22.createSourceFile(
24084
+ const sf = ts23.createSourceFile(
23975
24085
  "__const.ts",
23976
24086
  `const __x = (${source});`,
23977
- ts22.ScriptTarget.Latest,
24087
+ ts23.ScriptTarget.Latest,
23978
24088
  /*setParentNodes*/
23979
24089
  false
23980
24090
  );
23981
24091
  const stmt = sf.statements[0];
23982
- if (!stmt || !ts22.isVariableStatement(stmt)) return null;
24092
+ if (!stmt || !ts23.isVariableStatement(stmt)) return null;
23983
24093
  let init = stmt.declarationList.declarations[0]?.initializer;
23984
- while (init && ts22.isParenthesizedExpression(init)) init = init.expression;
23985
- if (!init || !ts22.isTemplateExpression(init)) return null;
24094
+ while (init && ts23.isParenthesizedExpression(init)) init = init.expression;
24095
+ if (!init || !ts23.isTemplateExpression(init)) return null;
23986
24096
  let out = init.head.text;
23987
24097
  for (const span of init.templateSpans) {
23988
- if (!ts22.isIdentifier(span.expression)) return null;
24098
+ if (!ts23.isIdentifier(span.expression)) return null;
23989
24099
  const value2 = resolved.get(span.expression.text);
23990
24100
  if (value2 === void 0) return null;
23991
24101
  out += value2 + span.literal.text;
@@ -24011,31 +24121,32 @@ function collectModuleStringConsts(constants) {
24011
24121
  }
24012
24122
  return map;
24013
24123
  }
24014
- function lookupStaticRecordLiteral(objectName, key, constants) {
24124
+ function lookupStaticRecordLiteral(objectName, key, constants, isShadowed) {
24125
+ if (isShadowed(objectName)) return null;
24015
24126
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
24016
24127
  if (constInfo?.value === void 0) return null;
24017
- const sf = ts22.createSourceFile(
24128
+ const sf = ts23.createSourceFile(
24018
24129
  "__rec.ts",
24019
24130
  `(${constInfo.value})`,
24020
- ts22.ScriptTarget.Latest,
24131
+ ts23.ScriptTarget.Latest,
24021
24132
  /*setParentNodes*/
24022
24133
  true
24023
24134
  );
24024
24135
  if (sf.statements.length !== 1) return null;
24025
24136
  const stmt = sf.statements[0];
24026
- if (!ts22.isExpressionStatement(stmt)) return null;
24137
+ if (!ts23.isExpressionStatement(stmt)) return null;
24027
24138
  let parsed = stmt.expression;
24028
- while (ts22.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24029
- if (!ts22.isObjectLiteralExpression(parsed)) return null;
24139
+ while (ts23.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24140
+ if (!ts23.isObjectLiteralExpression(parsed)) return null;
24030
24141
  for (const prop of parsed.properties) {
24031
- if (!ts22.isPropertyAssignment(prop)) continue;
24142
+ if (!ts23.isPropertyAssignment(prop)) continue;
24032
24143
  const name2 = prop.name;
24033
- const propKey = ts22.isIdentifier(name2) || ts22.isStringLiteral(name2) || ts22.isNoSubstitutionTemplateLiteral(name2) ? name2.text : null;
24144
+ const propKey = ts23.isIdentifier(name2) || ts23.isStringLiteral(name2) || ts23.isNoSubstitutionTemplateLiteral(name2) ? name2.text : null;
24034
24145
  if (propKey !== key) continue;
24035
24146
  let v = prop.initializer;
24036
- while (ts22.isParenthesizedExpression(v)) v = v.expression;
24037
- if (ts22.isNumericLiteral(v)) return { kind: "number", text: v.text };
24038
- if (ts22.isStringLiteral(v) || ts22.isNoSubstitutionTemplateLiteral(v)) {
24147
+ while (ts23.isParenthesizedExpression(v)) v = v.expression;
24148
+ if (ts23.isNumericLiteral(v)) return { kind: "number", text: v.text };
24149
+ if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
24039
24150
  return { kind: "string", text: v.text };
24040
24151
  }
24041
24152
  return null;
@@ -24043,27 +24154,27 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
24043
24154
  return null;
24044
24155
  }
24045
24156
  function evalStringArrayJoin(source) {
24046
- const sf = ts22.createSourceFile(
24157
+ const sf = ts23.createSourceFile(
24047
24158
  "__join.ts",
24048
24159
  `const __x = (${source});`,
24049
- ts22.ScriptTarget.Latest,
24160
+ ts23.ScriptTarget.Latest,
24050
24161
  /*setParentNodes*/
24051
24162
  false
24052
24163
  );
24053
24164
  const stmt = sf.statements[0];
24054
- if (!stmt || !ts22.isVariableStatement(stmt)) return null;
24165
+ if (!stmt || !ts23.isVariableStatement(stmt)) return null;
24055
24166
  let node = stmt.declarationList.declarations[0]?.initializer;
24056
- while (node && ts22.isParenthesizedExpression(node)) node = node.expression;
24057
- if (!node || !ts22.isCallExpression(node)) return null;
24167
+ while (node && ts23.isParenthesizedExpression(node)) node = node.expression;
24168
+ if (!node || !ts23.isCallExpression(node)) return null;
24058
24169
  const callee = node.expression;
24059
- if (!ts22.isPropertyAccessExpression(callee)) return null;
24170
+ if (!ts23.isPropertyAccessExpression(callee)) return null;
24060
24171
  if (callee.name.text !== "join") return null;
24061
24172
  let recv = callee.expression;
24062
- while (ts22.isParenthesizedExpression(recv)) recv = recv.expression;
24063
- if (!ts22.isArrayLiteralExpression(recv)) return null;
24173
+ while (ts23.isParenthesizedExpression(recv)) recv = recv.expression;
24174
+ if (!ts23.isArrayLiteralExpression(recv)) return null;
24064
24175
  const parts = [];
24065
24176
  for (const el of recv.elements) {
24066
- if (ts22.isStringLiteral(el) || ts22.isNoSubstitutionTemplateLiteral(el)) {
24177
+ if (ts23.isStringLiteral(el) || ts23.isNoSubstitutionTemplateLiteral(el)) {
24067
24178
  parts.push(el.text);
24068
24179
  } else {
24069
24180
  return null;
@@ -24072,16 +24183,16 @@ function evalStringArrayJoin(source) {
24072
24183
  let sep = ",";
24073
24184
  if (node.arguments.length >= 1) {
24074
24185
  const arg = node.arguments[0];
24075
- if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg)) sep = arg.text;
24186
+ if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg)) sep = arg.text;
24076
24187
  else return null;
24077
24188
  }
24078
24189
  return parts.join(sep);
24079
24190
  }
24080
24191
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24081
- if (!ts22.isElementAccessExpression(val)) return null;
24192
+ if (!ts23.isElementAccessExpression(val)) return null;
24082
24193
  const obj = val.expression;
24083
24194
  const arg = val.argumentExpression;
24084
- if (!ts22.isIdentifier(obj) || !ts22.isIdentifier(arg)) return null;
24195
+ if (!ts23.isIdentifier(obj) || !ts23.isIdentifier(arg)) return null;
24085
24196
  let indexPropName;
24086
24197
  let defaultKey;
24087
24198
  const resolved = resolveKey?.(arg.text);
@@ -24095,35 +24206,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24095
24206
  }
24096
24207
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
24097
24208
  if (constInfo?.value === void 0) return null;
24098
- const sf = ts22.createSourceFile(
24209
+ const sf = ts23.createSourceFile(
24099
24210
  "__rec.ts",
24100
24211
  `(${constInfo.value})`,
24101
- ts22.ScriptTarget.Latest,
24212
+ ts23.ScriptTarget.Latest,
24102
24213
  /* setParentNodes */
24103
24214
  true
24104
24215
  );
24105
24216
  if (sf.statements.length !== 1) return null;
24106
24217
  const stmt = sf.statements[0];
24107
- if (!ts22.isExpressionStatement(stmt)) return null;
24218
+ if (!ts23.isExpressionStatement(stmt)) return null;
24108
24219
  let parsed = stmt.expression;
24109
- while (ts22.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24110
- if (!ts22.isObjectLiteralExpression(parsed)) return null;
24220
+ while (ts23.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24221
+ if (!ts23.isObjectLiteralExpression(parsed)) return null;
24111
24222
  const entries2 = [];
24112
24223
  for (const prop of parsed.properties) {
24113
- if (!ts22.isPropertyAssignment(prop)) return null;
24224
+ if (!ts23.isPropertyAssignment(prop)) return null;
24114
24225
  let key;
24115
- if (ts22.isIdentifier(prop.name)) {
24226
+ if (ts23.isIdentifier(prop.name)) {
24116
24227
  key = prop.name.text;
24117
- } else if (ts22.isStringLiteral(prop.name) || ts22.isNoSubstitutionTemplateLiteral(prop.name)) {
24228
+ } else if (ts23.isStringLiteral(prop.name) || ts23.isNoSubstitutionTemplateLiteral(prop.name)) {
24118
24229
  key = prop.name.text;
24119
24230
  } else {
24120
24231
  return null;
24121
24232
  }
24122
24233
  let v = prop.initializer;
24123
- while (ts22.isParenthesizedExpression(v)) v = v.expression;
24124
- if (ts22.isNumericLiteral(v)) {
24234
+ while (ts23.isParenthesizedExpression(v)) v = v.expression;
24235
+ if (ts23.isNumericLiteral(v)) {
24125
24236
  entries2.push({ key, value: { kind: "number", text: v.text } });
24126
- } else if (ts22.isStringLiteral(v) || ts22.isNoSubstitutionTemplateLiteral(v)) {
24237
+ } else if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
24127
24238
  entries2.push({ key, value: { kind: "string", text: v.text } });
24128
24239
  } else {
24129
24240
  return null;
@@ -24395,7 +24506,7 @@ var init_rich_type_refusal = __esm({
24395
24506
  });
24396
24507
 
24397
24508
  // ../jsx/src/compiler.ts
24398
- import ts23 from "typescript";
24509
+ import ts24 from "typescript";
24399
24510
  function mergeTemplateImports(lines) {
24400
24511
  const result2 = [];
24401
24512
  const valueIdx = /* @__PURE__ */ new Map();
@@ -24460,12 +24571,12 @@ function compileMultipleComponents(source, filePath, componentNames, options2) {
24460
24571
  if (entries2.some((e) => e.componentIR.metadata.isClientComponent)) {
24461
24572
  const topLevelNames = /* @__PURE__ */ new Set();
24462
24573
  {
24463
- const sf = ts23.createSourceFile(filePath, source, ts23.ScriptTarget.Latest, true, ts23.ScriptKind.TSX);
24574
+ const sf = ts24.createSourceFile(filePath, source, ts24.ScriptTarget.Latest, true, ts24.ScriptKind.TSX);
24464
24575
  for (const stmt of sf.statements) {
24465
- if (ts23.isFunctionDeclaration(stmt) && stmt.name) topLevelNames.add(stmt.name.text);
24466
- else if (ts23.isVariableStatement(stmt)) {
24576
+ if (ts24.isFunctionDeclaration(stmt) && stmt.name) topLevelNames.add(stmt.name.text);
24577
+ else if (ts24.isVariableStatement(stmt)) {
24467
24578
  for (const d of stmt.declarationList.declarations) {
24468
- if (ts23.isIdentifier(d.name)) topLevelNames.add(d.name.text);
24579
+ if (ts24.isIdentifier(d.name)) topLevelNames.add(d.name.text);
24469
24580
  }
24470
24581
  }
24471
24582
  }
@@ -24526,13 +24637,13 @@ function compileMultipleComponents(source, filePath, componentNames, options2) {
24526
24637
  const moduleStatementSeen = /* @__PURE__ */ new Set();
24527
24638
  const moduleStatementsOrdered = [];
24528
24639
  const collectModuleStatements = (block) => {
24529
- const sf = ts23.createSourceFile(
24640
+ const sf = ts24.createSourceFile(
24530
24641
  "__bf_module_decls.tsx",
24531
24642
  block,
24532
- ts23.ScriptTarget.Latest,
24643
+ ts24.ScriptTarget.Latest,
24533
24644
  /* setParentNodes */
24534
24645
  false,
24535
- ts23.ScriptKind.TSX
24646
+ ts24.ScriptKind.TSX
24536
24647
  );
24537
24648
  for (const stmt of sf.statements) {
24538
24649
  const text = stmt.getText(sf);
@@ -24764,6 +24875,11 @@ function compileMultipleComponents(source, filePath, componentNames, options2) {
24764
24875
  }
24765
24876
  return { files: files2, errors };
24766
24877
  }
24878
+ function componentTypeParametersText(componentNode, sourceFile) {
24879
+ const typeParameters = componentNode?.typeParameters;
24880
+ if (!typeParameters || typeParameters.length === 0) return null;
24881
+ return `<${typeParameters.map((p) => p.getText(sourceFile)).join(", ")}>`;
24882
+ }
24767
24883
  function buildMetadata(ctx2) {
24768
24884
  const metadata = {
24769
24885
  componentName: ctx2.componentName || "Unknown",
@@ -24772,6 +24888,7 @@ function buildMetadata(ctx2) {
24772
24888
  isClientComponent: ctx2.hasUseClientDirective,
24773
24889
  typeDefinitions: ctx2.typeDefinitions,
24774
24890
  propsType: ctx2.propsType,
24891
+ typeParameters: componentTypeParametersText(ctx2.componentNode, ctx2.sourceFile),
24775
24892
  propsParams: ctx2.propsParams,
24776
24893
  propsObjectName: ctx2.propsObjectName,
24777
24894
  restPropsName: ctx2.restPropsName,
@@ -24997,7 +25114,7 @@ var init_compiler = __esm({
24997
25114
  });
24998
25115
 
24999
25116
  // ../jsx/src/shared-program.ts
25000
- import ts24 from "typescript";
25117
+ import ts25 from "typescript";
25001
25118
  import path6 from "node:path";
25002
25119
  function commonParent(paths) {
25003
25120
  if (paths.length === 0) return process.cwd();
@@ -25015,10 +25132,10 @@ function commonParent(paths) {
25015
25132
  function createProgramForCorpus(files2, options2 = {}) {
25016
25133
  const baseUrl = options2.baseUrl ?? commonParent(files2);
25017
25134
  const compilerOptions = {
25018
- target: ts24.ScriptTarget.Latest,
25019
- module: ts24.ModuleKind.ESNext,
25020
- moduleResolution: ts24.ModuleResolutionKind.Bundler,
25021
- jsx: ts24.JsxEmit.ReactJSX,
25135
+ target: ts25.ScriptTarget.Latest,
25136
+ module: ts25.ModuleKind.ESNext,
25137
+ moduleResolution: ts25.ModuleResolutionKind.Bundler,
25138
+ jsx: ts25.JsxEmit.ReactJSX,
25022
25139
  strict: true,
25023
25140
  skipLibCheck: true,
25024
25141
  noEmit: true,
@@ -25028,7 +25145,7 @@ function createProgramForCorpus(files2, options2 = {}) {
25028
25145
  ...options2.compilerOptions
25029
25146
  };
25030
25147
  const absolute = files2.map((f) => path6.resolve(f));
25031
- return ts24.createProgram(absolute, compilerOptions, void 0, options2.oldProgram);
25148
+ return ts25.createProgram(absolute, compilerOptions, void 0, options2.oldProgram);
25032
25149
  }
25033
25150
  var init_shared_program = __esm({
25034
25151
  "../jsx/src/shared-program.ts"() {
@@ -25128,7 +25245,13 @@ var init_jsx_adapter = __esm({
25128
25245
  ...localFunctions.map((f) => ({ name: f.name, body: f.body })),
25129
25246
  ...localConstants.map((c) => ({ name: c.name, body: c.value }))
25130
25247
  ];
25131
- const reachable = findReachableNames(primaryRefText, declarations);
25248
+ const reachable = closeOverWritersOfMutableBindings(
25249
+ primaryRefText,
25250
+ declarations,
25251
+ new Set(
25252
+ ir.metadata.localConstants.filter((c) => (c.declarationKind ?? "const") !== "const").map((c) => c.name)
25253
+ )
25254
+ );
25132
25255
  const reachableBodies = [...reachable].map((name2) => {
25133
25256
  const func = localFunctions.find((f) => f.name === name2);
25134
25257
  if (func) return func.body;
@@ -25158,7 +25281,10 @@ var init_jsx_adapter = __esm({
25158
25281
  if (signal2.setter) {
25159
25282
  const setterUsed = identifierPattern(signal2.setter).test(setterRefText);
25160
25283
  if (setterUsed) {
25161
- lines.push(` const ${signal2.setter} = (..._args: any[]) => {}`);
25284
+ const setterType = preserveTypes && signal2.type.kind !== "unknown" ? `(valueOrFn: ${signal2.type.raw} | ((prev: ${signal2.type.raw}) => ${signal2.type.raw})) => void` : null;
25285
+ lines.push(
25286
+ setterType ? ` const ${signal2.setter}: ${setterType} = () => {}` : ` const ${signal2.setter} = (..._args: any[]) => {}`
25287
+ );
25162
25288
  }
25163
25289
  }
25164
25290
  }
@@ -25425,7 +25551,7 @@ var init_jsx_adapter = __esm({
25425
25551
  });
25426
25552
 
25427
25553
  // ../jsx/src/adapters/template-imports.ts
25428
- import ts25 from "typescript";
25554
+ import ts26 from "typescript";
25429
25555
  function rewriteImportsForTemplate(imports, shimSource, rewriteRelative) {
25430
25556
  const remap = (imp) => {
25431
25557
  if (!rewriteRelative || !imp.source.startsWith(".")) return imp;
@@ -25469,24 +25595,24 @@ function specKey(s) {
25469
25595
  }
25470
25596
  function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25471
25597
  if (!sourceText.includes("import")) return sourceText;
25472
- const sf = ts25.createSourceFile(
25598
+ const sf = ts26.createSourceFile(
25473
25599
  "bf-template-fragment.tsx",
25474
25600
  sourceText,
25475
- ts25.ScriptTarget.Latest,
25601
+ ts26.ScriptTarget.Latest,
25476
25602
  /* setParentNodes */
25477
25603
  false,
25478
- ts25.ScriptKind.TSX
25604
+ ts26.ScriptKind.TSX
25479
25605
  );
25480
25606
  const edits = [];
25481
25607
  const visit3 = (node) => {
25482
- if (ts25.isCallExpression(node) && node.expression.kind === ts25.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts25.isStringLiteralLike(node.arguments[0])) {
25608
+ if (ts26.isCallExpression(node) && node.expression.kind === ts26.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts26.isStringLiteralLike(node.arguments[0])) {
25483
25609
  collect(node.arguments[0]);
25484
25610
  }
25485
- if (ts25.isImportTypeNode(node) && ts25.isLiteralTypeNode(node.argument)) {
25611
+ if (ts26.isImportTypeNode(node) && ts26.isLiteralTypeNode(node.argument)) {
25486
25612
  const literal = node.argument.literal;
25487
- if (ts25.isStringLiteralLike(literal)) collect(literal);
25613
+ if (ts26.isStringLiteralLike(literal)) collect(literal);
25488
25614
  }
25489
- ts25.forEachChild(node, visit3);
25615
+ ts26.forEachChild(node, visit3);
25490
25616
  };
25491
25617
  const collect = (literal) => {
25492
25618
  const specifier = literal.text;
@@ -25501,7 +25627,7 @@ function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25501
25627
  text: `'${next}'`
25502
25628
  });
25503
25629
  };
25504
- ts25.forEachChild(sf, visit3);
25630
+ ts26.forEachChild(sf, visit3);
25505
25631
  if (edits.length === 0) return sourceText;
25506
25632
  let out = sourceText;
25507
25633
  for (const edit of edits.sort((a, b) => b.start - a.start)) {
@@ -25618,7 +25744,8 @@ export default ${this.componentName}` : "";
25618
25744
  const noArgDefault = hasRequiredProps ? "" : ` = {} as ${propsTypeExpr}`;
25619
25745
  const lines = [];
25620
25746
  const exportPrefix = ir.metadata.isExported === false ? "" : "export ";
25621
- lines.push(`${exportPrefix}function ${name2}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
25747
+ const typeParameters = ir.metadata.typeParameters ?? "";
25748
+ lines.push(`${exportPrefix}function ${name2}${typeParameters}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
25622
25749
  if (hasClientInteractivity) {
25623
25750
  lines.push(` const __scopeId = (/_s\\d/.test(__bfScope || '') ? __bfScope : null) || __instanceId || \`${name2}_\${Math.random().toString(36).slice(2, 8)}\``);
25624
25751
  } else {
@@ -26347,7 +26474,7 @@ var init_dangerous_inner_html = __esm({
26347
26474
  });
26348
26475
 
26349
26476
  // ../jsx/src/combine-client-js.ts
26350
- import ts26 from "typescript";
26477
+ import ts27 from "typescript";
26351
26478
  function combineParentChildClientJs(files2) {
26352
26479
  const result2 = /* @__PURE__ */ new Map();
26353
26480
  const lookup = /* @__PURE__ */ new Map();
@@ -26404,17 +26531,17 @@ function combineParentChildClientJs(files2) {
26404
26531
  return result2;
26405
26532
  }
26406
26533
  function parseAndMerge(content2, importsBySource, otherImports, codeSections) {
26407
- const sourceFile = ts26.createSourceFile(
26534
+ const sourceFile = ts27.createSourceFile(
26408
26535
  "combine.js",
26409
26536
  content2,
26410
- ts26.ScriptTarget.Latest,
26537
+ ts27.ScriptTarget.Latest,
26411
26538
  /*setParentNodes*/
26412
26539
  false,
26413
- ts26.ScriptKind.JS
26540
+ ts27.ScriptKind.JS
26414
26541
  );
26415
26542
  const importSpans = [];
26416
26543
  for (const stmt of sourceFile.statements) {
26417
- if (!ts26.isImportDeclaration(stmt)) continue;
26544
+ if (!ts27.isImportDeclaration(stmt)) continue;
26418
26545
  const start2 = stmt.getStart(sourceFile);
26419
26546
  const end2 = stmt.getEnd();
26420
26547
  importSpans.push([start2, end2]);
@@ -26422,8 +26549,8 @@ function parseAndMerge(content2, importsBySource, otherImports, codeSections) {
26422
26549
  if (stmtText.includes("@bf-child:")) continue;
26423
26550
  const clause = stmt.importClause;
26424
26551
  const bindings = clause?.namedBindings;
26425
- const specifier = ts26.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
26426
- if (clause && !clause.name && bindings && ts26.isNamedImports(bindings)) {
26552
+ const specifier = ts27.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
26553
+ if (clause && !clause.name && bindings && ts27.isNamedImports(bindings)) {
26427
26554
  if (!importsBySource.has(specifier)) {
26428
26555
  importsBySource.set(specifier, /* @__PURE__ */ new Set());
26429
26556
  }
@@ -26598,7 +26725,7 @@ var init_loop_destructure = __esm({
26598
26725
  });
26599
26726
 
26600
26727
  // ../jsx/src/debug.ts
26601
- import ts27 from "typescript";
26728
+ import ts28 from "typescript";
26602
26729
  function buildComponentGraph(source, filePath, componentName) {
26603
26730
  const ctx2 = analyzeComponent(source, filePath, componentName);
26604
26731
  if (!ctx2.jsxReturn) {
@@ -26671,7 +26798,7 @@ function buildGraphFromIR(ir) {
26671
26798
  return propsObjectName ? exprReadsPropMember(expr, propsObjectName) : false;
26672
26799
  };
26673
26800
  const domBindings = [];
26674
- collectDomBindings(ir.root, domBindings, signalGetters, memoNames, void 0, /* @__PURE__ */ new Set(), exprReadsProp);
26801
+ collectDomBindings(ir.root, domBindings, signalGetters, memoNames, void 0, BindingScope.EMPTY, exprReadsProp);
26675
26802
  const signalConsumers = /* @__PURE__ */ new Map();
26676
26803
  for (const s of meta.signals) signalConsumers.set(s.getter, []);
26677
26804
  for (const memo of meta.memos) {
@@ -27638,14 +27765,19 @@ function inferWrapReasonForAttrLike(hasStringReactive, hasPropsRef, flags) {
27638
27765
  const decision = decideWrapFromAstFlags(flags);
27639
27766
  return decision.wrap ? decision.reason : void 0;
27640
27767
  }
27641
- function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag, loopParams = /* @__PURE__ */ new Set(), readsProp = () => false) {
27642
- const exprReadsLoopParam = (n) => loopParams.size > 0 && (n.origin?.freeRefs?.some((r2) => loopParams.has(r2.name)) ?? false);
27643
- const attrReadsLoopParam = (free) => loopParams.size > 0 && free !== void 0 && [...loopParams].some((p) => free.has(p));
27768
+ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag, scope = BindingScope.EMPTY, readsProp = () => false) {
27769
+ const boundNames = scope.valueBoundNames();
27770
+ const setSomeIn = (names, other) => {
27771
+ for (const n of names) if (other.has(n)) return true;
27772
+ return false;
27773
+ };
27774
+ const exprReadsLoopParam = (n) => boundNames.size > 0 && (n.origin?.freeRefs?.some((r2) => boundNames.has(r2.name)) ?? false);
27775
+ const attrReadsLoopParam = (free) => boundNames.size > 0 && free !== void 0 && setSomeIn(boundNames, free);
27644
27776
  switch (node.type) {
27645
27777
  case "element": {
27646
27778
  for (const attr of node.attrs) {
27647
27779
  if (attr.value.kind !== "expression" && attr.value.kind !== "template" && attr.value.kind !== "spread") continue;
27648
- if (attr.name === "key" && loopParams.size > 0) continue;
27780
+ if (attr.name === "key" && boundNames.size > 0) continue;
27649
27781
  const expr = attrValueToString2(attr.value);
27650
27782
  if (!expr) continue;
27651
27783
  const deps = extractReactiveDeps(expr, signalGetters, memoNames);
@@ -27680,7 +27812,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27680
27812
  });
27681
27813
  }
27682
27814
  for (const child of node.children) {
27683
- collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, loopParams, readsProp);
27815
+ collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, scope, readsProp);
27684
27816
  }
27685
27817
  break;
27686
27818
  }
@@ -27707,7 +27839,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27707
27839
  }
27708
27840
  case "conditional": {
27709
27841
  const decision = decideWrapFromAstFlags(node);
27710
- const loopReactive = loopParams.size > 0 && (node.origin?.freeRefs?.some((r2) => loopParams.has(r2.name)) ?? false);
27842
+ const loopReactive = boundNames.size > 0 && (node.origin?.freeRefs?.some((r2) => boundNames.has(r2.name)) ?? false);
27711
27843
  if ((decision.wrap || loopReactive) && node.slotId) {
27712
27844
  const deps = extractReactiveDeps(node.condition, signalGetters, memoNames);
27713
27845
  bindings.push({
@@ -27723,14 +27855,14 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27723
27855
  jsxPreview: `{${truncateExpr(node.condition)} ? ... : ...}`
27724
27856
  });
27725
27857
  }
27726
- collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27727
- collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27858
+ collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27859
+ collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27728
27860
  break;
27729
27861
  }
27730
27862
  case "loop": {
27731
27863
  if (node.slotId) {
27732
27864
  const deps = extractReactiveDeps(node.array, signalGetters, memoNames);
27733
- const loopReactive = loopParams.size > 0 && node.arrayFreeIdentifiers !== void 0 && [...loopParams].some((p) => node.arrayFreeIdentifiers.has(p));
27865
+ const loopReactive = boundNames.size > 0 && node.arrayFreeIdentifiers !== void 0 && setSomeIn(boundNames, node.arrayFreeIdentifiers);
27734
27866
  const isReactive = deps.length > 0 || node.callsReactiveGetters === true || loopReactive;
27735
27867
  const isFallback = !isReactive && node.hasFunctionCalls === true;
27736
27868
  if (isReactive || isFallback) {
@@ -27749,11 +27881,9 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27749
27881
  });
27750
27882
  }
27751
27883
  }
27752
- const childLoopParams = new Set(loopParams);
27753
- for (const p of extractLoopParamNames(node.param, node)) childLoopParams.add(p);
27754
- if (node.index) childLoopParams.add(node.index);
27884
+ const childScope = scope.enterLoopRow(node);
27755
27885
  for (const child of node.children) {
27756
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childLoopParams, readsProp);
27886
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childScope, readsProp);
27757
27887
  }
27758
27888
  break;
27759
27889
  }
@@ -27783,21 +27913,21 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27783
27913
  }
27784
27914
  }
27785
27915
  for (const child of node.children) {
27786
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27916
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27787
27917
  }
27788
27918
  break;
27789
27919
  }
27790
27920
  case "fragment":
27791
27921
  case "provider": {
27792
27922
  for (const child of node.children) {
27793
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27923
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27794
27924
  }
27795
27925
  break;
27796
27926
  }
27797
27927
  case "if-statement": {
27798
- collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27928
+ collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27799
27929
  if (node.alternate) {
27800
- collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27930
+ collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27801
27931
  }
27802
27932
  break;
27803
27933
  }
@@ -27810,18 +27940,18 @@ function truncateExpr(expr, max = 40) {
27810
27940
  function exprReadsPropMember(expr, propsObjectName) {
27811
27941
  let sf;
27812
27942
  try {
27813
- sf = ts27.createSourceFile("__attr.tsx", `(${expr})`, ts27.ScriptTarget.Latest, true, ts27.ScriptKind.TSX);
27943
+ sf = ts28.createSourceFile("__attr.tsx", `(${expr})`, ts28.ScriptTarget.Latest, true, ts28.ScriptKind.TSX);
27814
27944
  } catch {
27815
27945
  return false;
27816
27946
  }
27817
27947
  let found = false;
27818
27948
  const visit3 = (n) => {
27819
27949
  if (found) return;
27820
- if (ts27.isPropertyAccessExpression(n) && ts27.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
27950
+ if (ts28.isPropertyAccessExpression(n) && ts28.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
27821
27951
  found = true;
27822
27952
  return;
27823
27953
  }
27824
- ts27.forEachChild(n, visit3);
27954
+ ts28.forEachChild(n, visit3);
27825
27955
  };
27826
27956
  visit3(sf);
27827
27957
  return found;
@@ -27895,11 +28025,12 @@ var init_debug = __esm({
27895
28025
  init_reactivity();
27896
28026
  init_utils();
27897
28027
  init_identifier_pattern();
28028
+ init_binding_scope();
27898
28029
  }
27899
28030
  });
27900
28031
 
27901
28032
  // ../jsx/src/profiler.ts
27902
- import ts28 from "typescript";
28033
+ import ts29 from "typescript";
27903
28034
  function buildStaticBudget(source, filePath, componentName, options2 = {}) {
27904
28035
  const threshold = options2.fanOutThreshold ?? DEFAULT_FANOUT_THRESHOLD;
27905
28036
  const program = createProgramForFile(source, filePath)?.program;
@@ -28154,14 +28285,14 @@ function joinProfilerEvents(events, index) {
28154
28285
  return { joined, unattributed, diagnostics };
28155
28286
  }
28156
28287
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
28157
- const sf = ts28.createSourceFile(filePath, source, ts28.ScriptTarget.Latest, true, ts28.ScriptKind.TSX);
28288
+ const sf = ts29.createSourceFile(filePath, source, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TSX);
28158
28289
  const out = [];
28159
28290
  const visit3 = (node) => {
28160
- if (ts28.isCallExpression(node) && ts28.isIdentifier(node.expression) && node.expression.text === "createEffect") {
28291
+ if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression) && node.expression.text === "createEffect") {
28161
28292
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
28162
28293
  if (!instrumentedLines.has(line)) out.push({ file: filePath, line });
28163
28294
  }
28164
- ts28.forEachChild(node, visit3);
28295
+ ts29.forEachChild(node, visit3);
28165
28296
  };
28166
28297
  visit3(sf);
28167
28298
  out.sort((a, b) => a.line - b.line);
@@ -28447,19 +28578,19 @@ function assessBatchSafety(args2) {
28447
28578
  const signalGetters = new Set(args2.graph.signals.map((s) => s.name));
28448
28579
  let sf;
28449
28580
  try {
28450
- sf = ts28.createSourceFile("__h.ts", `const __h = ${args2.handler}`, ts28.ScriptTarget.Latest, true);
28581
+ sf = ts29.createSourceFile("__h.ts", `const __h = ${args2.handler}`, ts29.ScriptTarget.Latest, true);
28451
28582
  } catch {
28452
28583
  return "unverified";
28453
28584
  }
28454
28585
  const calls = [];
28455
28586
  const visit3 = (node) => {
28456
- if (ts28.isCallExpression(node) && ts28.isIdentifier(node.expression)) {
28587
+ if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression)) {
28457
28588
  const name2 = node.expression.text;
28458
28589
  if (setters.has(name2)) calls.push({ pos: node.getStart(sf), kind: "write" });
28459
28590
  else if (D.has(name2) && node.arguments.length === 0) calls.push({ pos: node.getStart(sf), kind: "memoRead" });
28460
28591
  else if (!signalGetters.has(name2) && !memoNames.has(name2)) calls.push({ pos: node.getStart(sf), kind: "risky" });
28461
28592
  }
28462
- ts28.forEachChild(node, visit3);
28593
+ ts29.forEachChild(node, visit3);
28463
28594
  };
28464
28595
  visit3(sf);
28465
28596
  calls.sort((a, b) => a.pos - b.pos);
@@ -29118,6 +29249,7 @@ __export(src_exports, {
29118
29249
  BindingScope: () => BindingScope,
29119
29250
  CALLBACK_METHODS: () => CALLBACK_METHODS,
29120
29251
  ENV_SIGNAL_READERS: () => ENV_SIGNAL_READERS,
29252
+ ESCAPE_SSR_COST: () => ESCAPE_SSR_COST,
29121
29253
  ErrorCodes: () => ErrorCodes,
29122
29254
  JsxAdapter: () => JsxAdapter,
29123
29255
  PARSED_EXPR_KINDS: () => PARSED_EXPR_KINDS,
@@ -29308,6 +29440,7 @@ var init_src2 = __esm({
29308
29440
  init_source_map();
29309
29441
  init_combine_client_js();
29310
29442
  init_types();
29443
+ init_types();
29311
29444
  init_css_layer_prefixer();
29312
29445
  init_instrumentation();
29313
29446
  init_errors();
@@ -110123,7 +110256,7 @@ __export(scenario_driver_exports, {
110123
110256
  import { writeFileSync as writeFileSync9, mkdtempSync, rmSync, readFileSync as readFileSync19, existsSync as existsSync23, statSync as statSync3 } from "node:fs";
110124
110257
  import { join as join2, dirname as dirname4, resolve as resolve6 } from "node:path";
110125
110258
  import { tmpdir } from "node:os";
110126
- import ts29 from "typescript";
110259
+ import ts30 from "typescript";
110127
110260
  function externalRuntimeImport(clientJs) {
110128
110261
  const chunks = Array.isArray(clientJs) ? clientJs : [clientJs];
110129
110262
  for (const chunk of chunks) {
@@ -110193,11 +110326,11 @@ function resolveLocalFile(spec) {
110193
110326
  }
110194
110327
  function rewriteLocalImports(js, chunkPath, inlined) {
110195
110328
  const chunkDir = dirname4(chunkPath);
110196
- const sf = ts29.createSourceFile("chunk.mjs", js, ts29.ScriptTarget.Latest, false, ts29.ScriptKind.JS);
110329
+ const sf = ts30.createSourceFile("chunk.mjs", js, ts30.ScriptTarget.Latest, false, ts30.ScriptKind.JS);
110197
110330
  const edits = [];
110198
110331
  for (const stmt of sf.statements) {
110199
- if (!ts29.isImportDeclaration(stmt)) continue;
110200
- if (!ts29.isStringLiteral(stmt.moduleSpecifier)) continue;
110332
+ if (!ts30.isImportDeclaration(stmt)) continue;
110333
+ if (!ts30.isStringLiteral(stmt.moduleSpecifier)) continue;
110201
110334
  const spec = stmt.moduleSpecifier.text;
110202
110335
  if (!spec.startsWith(".")) continue;
110203
110336
  const resolved = resolveLocalFile(join2(chunkDir, spec.replace(/\.client\.js$/, "")));
@@ -110209,13 +110342,13 @@ function rewriteLocalImports(js, chunkPath, inlined) {
110209
110342
  const abs = resolve6(resolved);
110210
110343
  if (inlined.has(abs)) {
110211
110344
  const clause = stmt.importClause;
110212
- if (clause && (clause.name || clause.namedBindings && ts29.isNamespaceImport(clause.namedBindings))) {
110345
+ if (clause && (clause.name || clause.namedBindings && ts30.isNamespaceImport(clause.namedBindings))) {
110213
110346
  throw new Error(
110214
110347
  `"${spec}" (imported by ${chunkPath}) uses a default or namespace import of a sibling client file, which the dynamic scenario runner cannot bind after inlining that file into the run. Import its exports by name, or use the static budget (\`bf debug profile <component>\`), which needs no run.`
110215
110348
  );
110216
110349
  }
110217
110350
  const shims = [];
110218
- if (clause?.namedBindings && ts29.isNamedImports(clause.namedBindings)) {
110351
+ if (clause?.namedBindings && ts30.isNamedImports(clause.namedBindings)) {
110219
110352
  for (const el of clause.namedBindings.elements) {
110220
110353
  if (el.propertyName) shims.push(`var ${el.name.text} = ${el.propertyName.text}`);
110221
110354
  }