@barefootjs/cli 0.35.0 → 0.35.2

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
@@ -4606,7 +4606,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
4606
4606
  case "expression":
4607
4607
  case "template":
4608
4608
  case "spread": {
4609
- const expr = attrValueToString(p.value, { useTemplate: true }) ?? "undefined";
4609
+ const expr = wrapExpr(attrValueToString(p.value, { useTemplate: true }) ?? "undefined");
4610
4610
  return `${quotePropName(p.name)}: ${expr}`;
4611
4611
  }
4612
4612
  }
@@ -5975,8 +5975,152 @@ var init_strip_types = __esm({
5975
5975
  }
5976
5976
  });
5977
5977
 
5978
- // ../jsx/src/analyzer-context.ts
5978
+ // ../jsx/src/reactivity-checker.ts
5979
5979
  import ts9 from "typescript";
5980
+ function queryType(checker, node) {
5981
+ incrementCounter("typeCheckerQueries");
5982
+ return checker.getTypeAtLocation(node);
5983
+ }
5984
+ function isReactiveType(type2) {
5985
+ return type2.getProperty(REACTIVE_BRAND) !== void 0;
5986
+ }
5987
+ function safeGetText(node) {
5988
+ try {
5989
+ return node.getText();
5990
+ } catch {
5991
+ return "";
5992
+ }
5993
+ }
5994
+ function analyze(node, checker) {
5995
+ if (ts9.isPropertyAccessExpression(node)) {
5996
+ try {
5997
+ const type2 = queryType(checker, node);
5998
+ if (isReactiveType(type2)) {
5999
+ return {
6000
+ isReactive: true,
6001
+ reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
6002
+ };
6003
+ }
6004
+ } catch {
6005
+ }
6006
+ const sub2 = analyze(node.expression, checker);
6007
+ if (sub2.isReactive) {
6008
+ return {
6009
+ isReactive: true,
6010
+ reason: {
6011
+ kind: "child",
6012
+ via: "property-access-object",
6013
+ childText: safeGetText(node.expression),
6014
+ childReason: sub2.reason
6015
+ }
6016
+ };
6017
+ }
6018
+ return NOT_REACTIVE;
6019
+ }
6020
+ if (ts9.isIdentifier(node)) {
6021
+ try {
6022
+ const type2 = queryType(checker, node);
6023
+ if (isReactiveType(type2)) {
6024
+ return {
6025
+ isReactive: true,
6026
+ reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
6027
+ };
6028
+ }
6029
+ } catch {
6030
+ }
6031
+ return NOT_REACTIVE;
6032
+ }
6033
+ if (ts9.isCallExpression(node)) {
6034
+ try {
6035
+ const calleeType = queryType(checker, node.expression);
6036
+ if (isReactiveType(calleeType)) {
6037
+ return {
6038
+ isReactive: true,
6039
+ reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
6040
+ };
6041
+ }
6042
+ } catch {
6043
+ }
6044
+ }
6045
+ let foundChild;
6046
+ let foundChildText = "";
6047
+ ts9.forEachChild(node, (child) => {
6048
+ if (foundChild?.isReactive) return;
6049
+ const result2 = analyze(child, checker);
6050
+ if (result2.isReactive) {
6051
+ foundChild = result2;
6052
+ foundChildText = safeGetText(child);
6053
+ }
6054
+ });
6055
+ if (foundChild?.isReactive) {
6056
+ return {
6057
+ isReactive: true,
6058
+ reason: {
6059
+ kind: "child",
6060
+ via: "sub-expression",
6061
+ childText: foundChildText,
6062
+ childReason: foundChild.reason
6063
+ }
6064
+ };
6065
+ }
6066
+ return NOT_REACTIVE;
6067
+ }
6068
+ function containsReactiveExpression(node, checker) {
6069
+ incrementCounter("reactivityChecks");
6070
+ return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
6071
+ }
6072
+ function nodeContainsJsx(node) {
6073
+ if (ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node)) return true;
6074
+ return ts9.forEachChild(node, nodeContainsJsx) ?? false;
6075
+ }
6076
+ function collectReactiveBrandLeaves(node, checker) {
6077
+ const leaves = [];
6078
+ const visit3 = (n) => {
6079
+ if (ts9.isPropertyAccessExpression(n)) {
6080
+ try {
6081
+ if (isReactiveType(queryType(checker, n))) {
6082
+ leaves.push(n);
6083
+ return;
6084
+ }
6085
+ } catch {
6086
+ }
6087
+ visit3(n.expression);
6088
+ return;
6089
+ }
6090
+ if (ts9.isIdentifier(n)) {
6091
+ try {
6092
+ if (isReactiveType(queryType(checker, n))) leaves.push(n);
6093
+ } catch {
6094
+ }
6095
+ return;
6096
+ }
6097
+ if (ts9.isCallExpression(n)) {
6098
+ try {
6099
+ if (isReactiveType(queryType(checker, n.expression))) {
6100
+ leaves.push(nodeContainsJsx(n) ? n.expression : n);
6101
+ return;
6102
+ }
6103
+ } catch {
6104
+ }
6105
+ }
6106
+ ts9.forEachChild(n, visit3);
6107
+ };
6108
+ visit3(node);
6109
+ return leaves;
6110
+ }
6111
+ var REACTIVE_BRAND, NOT_REACTIVE, brandTypeReactivityAnalyzer;
6112
+ var init_reactivity_checker = __esm({
6113
+ "../jsx/src/reactivity-checker.ts"() {
6114
+ "use strict";
6115
+ init_instrumentation();
6116
+ REACTIVE_BRAND = "__reactive";
6117
+ NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
6118
+ brandTypeReactivityAnalyzer = { analyze };
6119
+ }
6120
+ });
6121
+
6122
+ // ../jsx/src/analyzer-context.ts
6123
+ import ts10 from "typescript";
5980
6124
  function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5981
6125
  return {
5982
6126
  sourceFile,
@@ -6027,7 +6171,7 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
6027
6171
  } catch {
6028
6172
  ownSourceFile = void 0;
6029
6173
  }
6030
- if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && this.errors.length === 0 && nodeContainsJsx(node)) {
6174
+ if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && !this.errors.some((e) => e.severity === "error") && nodeContainsJsx(node)) {
6031
6175
  throw new Error(
6032
6176
  "getJS() called on a JSX-bearing node \u2014 raw JSX must never be spliced into emitted output. Carry mixed content as structured segments (MapCallbackPreamble / FlatMapCallback) instead."
6033
6177
  );
@@ -6039,10 +6183,6 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
6039
6183
  }
6040
6184
  };
6041
6185
  }
6042
- function nodeContainsJsx(node) {
6043
- if (ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node)) return true;
6044
- return ts9.forEachChild(node, nodeContainsJsx) ?? false;
6045
- }
6046
6186
  function getSourceLocation(node, sourceFile, filePath) {
6047
6187
  const start2 = sourceFile.getLineAndCharacterOfPosition(node.getStart());
6048
6188
  const end2 = sourceFile.getLineAndCharacterOfPosition(node.getEnd());
@@ -6060,7 +6200,7 @@ function getSourceLocation(node, sourceFile, filePath) {
6060
6200
  };
6061
6201
  }
6062
6202
  function membersToProperties(members, sourceFile) {
6063
- return members.filter(ts9.isPropertySignature).map((member) => ({
6203
+ return members.filter(ts10.isPropertySignature).map((member) => ({
6064
6204
  name: propertyNameText(member.name, sourceFile),
6065
6205
  type: typeNodeToTypeInfo(member.type, sourceFile) ?? {
6066
6206
  kind: "unknown",
@@ -6068,13 +6208,13 @@ function membersToProperties(members, sourceFile) {
6068
6208
  },
6069
6209
  optional: !!member.questionToken,
6070
6210
  readonly: !!member.modifiers?.some(
6071
- (m) => m.kind === ts9.SyntaxKind.ReadonlyKeyword
6211
+ (m) => m.kind === ts10.SyntaxKind.ReadonlyKeyword
6072
6212
  )
6073
6213
  }));
6074
6214
  }
6075
6215
  function propertyNameText(name2, sourceFile) {
6076
6216
  if (!name2) return "";
6077
- if (ts9.isStringLiteral(name2) || ts9.isNumericLiteral(name2)) return name2.text;
6217
+ if (ts10.isStringLiteral(name2) || ts10.isNumericLiteral(name2)) return name2.text;
6078
6218
  return name2.getText(sourceFile);
6079
6219
  }
6080
6220
  function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
@@ -6083,48 +6223,48 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
6083
6223
  const raw = rawOf ? rawOf(typeNode) : typeNode.getText(sourceFile);
6084
6224
  const recurse = (n) => typeNodeToTypeInfo(n, sourceFile, rawOf) ?? { kind: "unknown", raw: "unknown" };
6085
6225
  switch (typeNode.kind) {
6086
- case ts9.SyntaxKind.StringKeyword:
6226
+ case ts10.SyntaxKind.StringKeyword:
6087
6227
  return { kind: "primitive", raw, primitive: "string" };
6088
- case ts9.SyntaxKind.NumberKeyword:
6228
+ case ts10.SyntaxKind.NumberKeyword:
6089
6229
  return { kind: "primitive", raw, primitive: "number" };
6090
- case ts9.SyntaxKind.BooleanKeyword:
6230
+ case ts10.SyntaxKind.BooleanKeyword:
6091
6231
  return { kind: "primitive", raw, primitive: "boolean" };
6092
- case ts9.SyntaxKind.NullKeyword:
6232
+ case ts10.SyntaxKind.NullKeyword:
6093
6233
  return { kind: "primitive", raw, primitive: "null" };
6094
- case ts9.SyntaxKind.UndefinedKeyword:
6234
+ case ts10.SyntaxKind.UndefinedKeyword:
6095
6235
  return { kind: "primitive", raw, primitive: "undefined" };
6096
6236
  }
6097
- if (ts9.isArrayTypeNode(typeNode)) {
6237
+ if (ts10.isArrayTypeNode(typeNode)) {
6098
6238
  return { kind: "array", raw, elementType: recurse(typeNode.elementType) };
6099
6239
  }
6100
- if (ts9.isLiteralTypeNode(typeNode)) {
6240
+ if (ts10.isLiteralTypeNode(typeNode)) {
6101
6241
  const lit = typeNode.literal;
6102
- if (ts9.isStringLiteral(lit) || ts9.isNoSubstitutionTemplateLiteral(lit)) {
6242
+ if (ts10.isStringLiteral(lit) || ts10.isNoSubstitutionTemplateLiteral(lit)) {
6103
6243
  return { kind: "primitive", raw, primitive: "string", literalValue: lit.text };
6104
6244
  }
6105
- if (ts9.isNumericLiteral(lit)) {
6245
+ if (ts10.isNumericLiteral(lit)) {
6106
6246
  return { kind: "primitive", raw, primitive: "number", literalValue: lit.text };
6107
6247
  }
6108
- if (ts9.isPrefixUnaryExpression(lit) && lit.operator === ts9.SyntaxKind.MinusToken && ts9.isNumericLiteral(lit.operand)) {
6248
+ if (ts10.isPrefixUnaryExpression(lit) && lit.operator === ts10.SyntaxKind.MinusToken && ts10.isNumericLiteral(lit.operand)) {
6109
6249
  return { kind: "primitive", raw, primitive: "number", literalValue: `-${lit.operand.text}` };
6110
6250
  }
6111
- if (lit.kind === ts9.SyntaxKind.TrueKeyword || lit.kind === ts9.SyntaxKind.FalseKeyword) {
6251
+ if (lit.kind === ts10.SyntaxKind.TrueKeyword || lit.kind === ts10.SyntaxKind.FalseKeyword) {
6112
6252
  return {
6113
6253
  kind: "primitive",
6114
6254
  raw,
6115
6255
  primitive: "boolean",
6116
- literalValue: lit.kind === ts9.SyntaxKind.TrueKeyword ? "true" : "false"
6256
+ literalValue: lit.kind === ts10.SyntaxKind.TrueKeyword ? "true" : "false"
6117
6257
  };
6118
6258
  }
6119
- if (lit.kind === ts9.SyntaxKind.NullKeyword) {
6259
+ if (lit.kind === ts10.SyntaxKind.NullKeyword) {
6120
6260
  return { kind: "primitive", raw, primitive: "null" };
6121
6261
  }
6122
6262
  return { kind: "unknown", raw };
6123
6263
  }
6124
- if (ts9.isUnionTypeNode(typeNode)) {
6264
+ if (ts10.isUnionTypeNode(typeNode)) {
6125
6265
  return { kind: "union", raw, unionTypes: typeNode.types.map(recurse) };
6126
6266
  }
6127
- if (ts9.isTypeLiteralNode(typeNode)) {
6267
+ if (ts10.isTypeLiteralNode(typeNode)) {
6128
6268
  return {
6129
6269
  kind: "object",
6130
6270
  raw,
@@ -6133,8 +6273,8 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
6133
6273
  ...synthetic ? {} : { properties: membersToProperties(typeNode.members, sourceFile) }
6134
6274
  };
6135
6275
  }
6136
- if (ts9.isTypeReferenceNode(typeNode)) {
6137
- const refName = ts9.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
6276
+ if (ts10.isTypeReferenceNode(typeNode)) {
6277
+ const refName = ts10.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
6138
6278
  if ((refName === "Array" || refName === "ReadonlyArray") && typeNode.typeArguments?.length === 1) {
6139
6279
  return { kind: "array", raw, elementType: recurse(typeNode.typeArguments[0]) };
6140
6280
  }
@@ -6143,7 +6283,7 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
6143
6283
  raw
6144
6284
  };
6145
6285
  }
6146
- if (ts9.isFunctionTypeNode(typeNode)) {
6286
+ if (ts10.isFunctionTypeNode(typeNode)) {
6147
6287
  if (synthetic) return { kind: "function", raw };
6148
6288
  return {
6149
6289
  kind: "function",
@@ -6163,11 +6303,11 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
6163
6303
  return { kind: "unknown", raw };
6164
6304
  }
6165
6305
  function tsTypeToTypeInfo(type2, checker) {
6166
- const node = checker.typeToTypeNode(type2, void 0, ts9.NodeBuilderFlags.NoTruncation);
6306
+ const node = checker.typeToTypeNode(type2, void 0, ts10.NodeBuilderFlags.NoTruncation);
6167
6307
  if (!node) return null;
6168
6308
  const rawOf = (n) => {
6169
6309
  try {
6170
- return _typePrinter.printNode(ts9.EmitHint.Unspecified, n, _blankTypeSourceFile);
6310
+ return _typePrinter.printNode(ts10.EmitHint.Unspecified, n, _blankTypeSourceFile);
6171
6311
  } catch {
6172
6312
  return "unknown";
6173
6313
  }
@@ -6178,13 +6318,13 @@ function isPascalCase(name2) {
6178
6318
  return /^[A-Z][a-zA-Z0-9]*$/.test(name2);
6179
6319
  }
6180
6320
  function isComponentFunction(node) {
6181
- return ts9.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
6321
+ return ts10.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
6182
6322
  }
6183
6323
  function isArrowComponentFunction(node) {
6184
- if (!ts9.isVariableDeclaration(node)) return false;
6185
- if (!ts9.isIdentifier(node.name)) return false;
6324
+ if (!ts10.isVariableDeclaration(node)) return false;
6325
+ if (!ts10.isIdentifier(node.name)) return false;
6186
6326
  if (!isPascalCase(node.name.text)) return false;
6187
- if (!node.initializer || !ts9.isArrowFunction(node.initializer)) return false;
6327
+ if (!node.initializer || !ts10.isArrowFunction(node.initializer)) return false;
6188
6328
  return true;
6189
6329
  }
6190
6330
  function collectReactiveGetterNames(signals, memos) {
@@ -6198,8 +6338,9 @@ var init_analyzer_context = __esm({
6198
6338
  "../jsx/src/analyzer-context.ts"() {
6199
6339
  "use strict";
6200
6340
  init_strip_types();
6201
- _typePrinter = ts9.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
6202
- _blankTypeSourceFile = ts9.createSourceFile("__bf_types__.ts", "", ts9.ScriptTarget.Latest);
6341
+ init_reactivity_checker();
6342
+ _typePrinter = ts10.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
6343
+ _blankTypeSourceFile = ts10.createSourceFile("__bf_types__.ts", "", ts10.ScriptTarget.Latest);
6203
6344
  }
6204
6345
  });
6205
6346
 
@@ -6596,7 +6737,7 @@ var init_date_lowering = __esm({
6596
6737
  });
6597
6738
 
6598
6739
  // ../jsx/src/analyzer.ts
6599
- import ts10 from "typescript";
6740
+ import ts11 from "typescript";
6600
6741
  import path5 from "node:path";
6601
6742
  import fs from "node:fs";
6602
6743
  function needsTypeBasedDetection(source) {
@@ -6607,8 +6748,8 @@ function needsTypeBasedDetection(source) {
6607
6748
  }
6608
6749
  function findBrandPackageImportLoc(sourceFile, filePath) {
6609
6750
  for (const stmt of sourceFile.statements) {
6610
- if (!ts10.isImportDeclaration(stmt)) continue;
6611
- if (!ts10.isStringLiteral(stmt.moduleSpecifier)) continue;
6751
+ if (!ts11.isImportDeclaration(stmt)) continue;
6752
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier)) continue;
6612
6753
  if (!REACTIVE_BRAND_PACKAGES.includes(stmt.moduleSpecifier.text)) continue;
6613
6754
  const start2 = sourceFile.getLineAndCharacterOfPosition(stmt.getStart(sourceFile));
6614
6755
  const end2 = sourceFile.getLineAndCharacterOfPosition(stmt.getEnd());
@@ -6625,21 +6766,21 @@ function createProgramForFile(source, filePath) {
6625
6766
  try {
6626
6767
  const normalizedPath = path5.resolve(filePath);
6627
6768
  const compilerOptions = {
6628
- target: ts10.ScriptTarget.Latest,
6629
- module: ts10.ModuleKind.ESNext,
6630
- moduleResolution: ts10.ModuleResolutionKind.Bundler,
6631
- jsx: ts10.JsxEmit.ReactJSX,
6769
+ target: ts11.ScriptTarget.Latest,
6770
+ module: ts11.ModuleKind.ESNext,
6771
+ moduleResolution: ts11.ModuleResolutionKind.Bundler,
6772
+ jsx: ts11.JsxEmit.ReactJSX,
6632
6773
  strict: true,
6633
6774
  skipLibCheck: true,
6634
6775
  noEmit: true,
6635
6776
  baseUrl: path5.dirname(normalizedPath)
6636
6777
  };
6637
- const defaultHost = ts10.createCompilerHost(compilerOptions);
6778
+ const defaultHost = ts11.createCompilerHost(compilerOptions);
6638
6779
  const virtualHost = {
6639
6780
  ...defaultHost,
6640
6781
  getSourceFile(fileName, languageVersion) {
6641
6782
  if (path5.resolve(fileName) === normalizedPath) {
6642
- return ts10.createSourceFile(fileName, source, languageVersion, true, ts10.ScriptKind.TSX);
6783
+ return ts11.createSourceFile(fileName, source, languageVersion, true, ts11.ScriptKind.TSX);
6643
6784
  }
6644
6785
  return defaultHost.getSourceFile(fileName, languageVersion);
6645
6786
  },
@@ -6652,7 +6793,7 @@ function createProgramForFile(source, filePath) {
6652
6793
  return defaultHost.readFile(fileName);
6653
6794
  }
6654
6795
  };
6655
- const program = ts10.createProgram([normalizedPath], compilerOptions, virtualHost);
6796
+ const program = ts11.createProgram([normalizedPath], compilerOptions, virtualHost);
6656
6797
  const sourceFile = program.getSourceFile(normalizedPath);
6657
6798
  if (!sourceFile) return null;
6658
6799
  return { program, sourceFile, checker: program.getTypeChecker() };
@@ -6684,12 +6825,12 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
6684
6825
  }
6685
6826
  }
6686
6827
  if (!sourceFile) {
6687
- sourceFile = ts10.createSourceFile(
6828
+ sourceFile = ts11.createSourceFile(
6688
6829
  filePath,
6689
6830
  source,
6690
- ts10.ScriptTarget.Latest,
6831
+ ts11.ScriptTarget.Latest,
6691
6832
  true,
6692
- ts10.ScriptKind.TSX
6833
+ ts11.ScriptKind.TSX
6693
6834
  );
6694
6835
  }
6695
6836
  if (!checker && needsTypeBasedDetection(source)) {
@@ -6735,23 +6876,23 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
6735
6876
  function findDefaultExportedComponent(sourceFile) {
6736
6877
  let defaultExportName;
6737
6878
  function findDefaultExport(node) {
6738
- if (ts10.isExportAssignment(node) && !node.isExportEquals) {
6739
- if (ts10.isIdentifier(node.expression)) {
6879
+ if (ts11.isExportAssignment(node) && !node.isExportEquals) {
6880
+ if (ts11.isIdentifier(node.expression)) {
6740
6881
  defaultExportName = node.expression.text;
6741
6882
  }
6742
6883
  }
6743
- if (ts10.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword)) {
6884
+ if (ts11.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword)) {
6744
6885
  defaultExportName = node.name.text;
6745
6886
  }
6746
- ts10.forEachChild(node, findDefaultExport);
6887
+ ts11.forEachChild(node, findDefaultExport);
6747
6888
  }
6748
- ts10.forEachChild(sourceFile, findDefaultExport);
6889
+ ts11.forEachChild(sourceFile, findDefaultExport);
6749
6890
  return defaultExportName;
6750
6891
  }
6751
6892
  function collectNamedExports(sourceFile) {
6752
6893
  const exported = /* @__PURE__ */ new Set();
6753
6894
  for (const stmt of sourceFile.statements) {
6754
- if (ts10.isExportDeclaration(stmt) && stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
6895
+ if (ts11.isExportDeclaration(stmt) && stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
6755
6896
  for (const spec of stmt.exportClause.elements) {
6756
6897
  const local = (spec.propertyName ?? spec.name).text;
6757
6898
  exported.add(local);
@@ -6761,22 +6902,22 @@ function collectNamedExports(sourceFile) {
6761
6902
  return exported;
6762
6903
  }
6763
6904
  function visit(node, ctx2, targetComponentName, namedExports) {
6764
- if (ts10.isExpressionStatement(node) && ts10.isStringLiteral(node.expression)) {
6905
+ if (ts11.isExpressionStatement(node) && ts11.isStringLiteral(node.expression)) {
6765
6906
  if (node.expression.text === "use client" || node.expression.text === "'use client'") {
6766
6907
  ctx2.hasUseClientDirective = true;
6767
6908
  }
6768
6909
  }
6769
- if (ts10.isImportDeclaration(node)) {
6910
+ if (ts11.isImportDeclaration(node)) {
6770
6911
  collectImport(node, ctx2);
6771
6912
  }
6772
- if (ts10.isInterfaceDeclaration(node)) {
6913
+ if (ts11.isInterfaceDeclaration(node)) {
6773
6914
  collectInterfaceDefinition(node, ctx2);
6774
6915
  }
6775
- if (ts10.isTypeAliasDeclaration(node)) {
6916
+ if (ts11.isTypeAliasDeclaration(node)) {
6776
6917
  collectTypeAliasDefinition(node, ctx2);
6777
6918
  }
6778
- if (!ctx2.hasUseClientDirective && ts10.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
6779
- const hasInlineExport = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6919
+ if (!ctx2.hasUseClientDirective && ts11.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
6920
+ const hasInlineExport = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6780
6921
  const hasNamedExport = namedExports?.has(node.name.text) ?? false;
6781
6922
  if (!hasInlineExport && !hasNamedExport) {
6782
6923
  collectFunction(node, ctx2, true, false);
@@ -6790,9 +6931,9 @@ function visit(node, ctx2, targetComponentName, namedExports) {
6790
6931
  if (!ctx2.componentName) {
6791
6932
  ctx2.componentName = node.name.text;
6792
6933
  ctx2.componentNode = node;
6793
- ctx2.isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6934
+ ctx2.isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6794
6935
  analyzeComponentBody(node, ctx2);
6795
- if (node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword)) {
6936
+ if (node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword)) {
6796
6937
  ctx2.hasDefaultExport = true;
6797
6938
  }
6798
6939
  }
@@ -6806,10 +6947,10 @@ function visit(node, ctx2, targetComponentName, namedExports) {
6806
6947
  ctx2.componentName = node.name.text;
6807
6948
  ctx2.componentNode = node.initializer;
6808
6949
  const parentStatement = node.parent;
6809
- if (ts10.isVariableDeclarationList(parentStatement)) {
6950
+ if (ts11.isVariableDeclarationList(parentStatement)) {
6810
6951
  const varStatement = parentStatement.parent;
6811
- if (ts10.isVariableStatement(varStatement)) {
6812
- ctx2.isExported = varStatement.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6952
+ if (ts11.isVariableStatement(varStatement)) {
6953
+ ctx2.isExported = varStatement.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6813
6954
  }
6814
6955
  }
6815
6956
  analyzeComponentBody(node.initializer, ctx2);
@@ -6821,10 +6962,10 @@ function visit(node, ctx2, targetComponentName, namedExports) {
6821
6962
  if (!ctx2.componentNode) {
6822
6963
  collectAmbientGlobals(node, ctx2);
6823
6964
  }
6824
- const isDeclareStatement = ts10.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false);
6825
- if (ts10.isVariableStatement(node) && !ctx2.componentNode && !isDeclareStatement) {
6826
- const isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6827
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6965
+ const isDeclareStatement = ts11.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false);
6966
+ if (ts11.isVariableStatement(node) && !ctx2.componentNode && !isDeclareStatement) {
6967
+ const isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6968
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
6828
6969
  const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx2.sourceFile);
6829
6970
  for (const decl of node.declarationList.declarations) {
6830
6971
  if (declarationIsReactiveFactoryCall(decl, ctx2)) {
@@ -6838,19 +6979,19 @@ function visit(node, ctx2, targetComponentName, namedExports) {
6838
6979
  }
6839
6980
  continue;
6840
6981
  }
6841
- if (ts10.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
6982
+ if (ts11.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
6842
6983
  collectConstant(decl, ctx2, true, isLet ? "let" : "const", isExported);
6843
6984
  }
6844
6985
  }
6845
6986
  }
6846
- if (ts10.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
6847
- const isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6987
+ if (ts11.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
6988
+ const isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6848
6989
  collectFunction(node, ctx2, true, isExported);
6849
6990
  return;
6850
6991
  }
6851
- if (ts10.isExportDeclaration(node) && node.exportClause && ts10.isNamedExports(node.exportClause)) {
6992
+ if (ts11.isExportDeclaration(node) && node.exportClause && ts11.isNamedExports(node.exportClause)) {
6852
6993
  const isFromReexport = !!node.moduleSpecifier;
6853
- const sourceSpec = node.moduleSpecifier && ts10.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
6994
+ const sourceSpec = node.moduleSpecifier && ts11.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
6854
6995
  const exportSpecifiers = node.exportClause.elements.map((spec) => ({
6855
6996
  name: (spec.propertyName ?? spec.name).text,
6856
6997
  alias: spec.propertyName ? spec.name.text : null,
@@ -6876,24 +7017,24 @@ function visit(node, ctx2, targetComponentName, namedExports) {
6876
7017
  }
6877
7018
  }
6878
7019
  }
6879
- if (ts10.isExportAssignment(node) && !node.isExportEquals) {
7020
+ if (ts11.isExportAssignment(node) && !node.isExportEquals) {
6880
7021
  const expr = node.expression;
6881
- if (ts10.isIdentifier(expr)) {
7022
+ if (ts11.isIdentifier(expr)) {
6882
7023
  if (ctx2.componentName && expr.text === ctx2.componentName) {
6883
7024
  ctx2.hasDefaultExport = true;
6884
7025
  ctx2.isExported = true;
6885
7026
  }
6886
7027
  }
6887
7028
  }
6888
- ts10.forEachChild(node, (child) => visit(child, ctx2, targetComponentName, namedExports));
7029
+ ts11.forEachChild(node, (child) => visit(child, ctx2, targetComponentName, namedExports));
6889
7030
  }
6890
7031
  function analyzeComponentBody(node, ctx2) {
6891
7032
  if (node.parameters.length > 0) {
6892
7033
  extractProps(node.parameters[0], ctx2);
6893
7034
  }
6894
- const body2 = ts10.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
7035
+ const body2 = ts11.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
6895
7036
  if (body2) {
6896
- ctx2.componentBodyBlock = ts10.isBlock(body2) ? body2 : null;
7037
+ ctx2.componentBodyBlock = ts11.isBlock(body2) ? body2 : null;
6897
7038
  if (!ctx2.componentBodyBlock) {
6898
7039
  ctx2.jsxReturn = unwrapJsxTransparent(body2);
6899
7040
  }
@@ -6903,14 +7044,14 @@ function analyzeComponentBody(node, ctx2) {
6903
7044
  }
6904
7045
  }
6905
7046
  function getArrowFunctionBody(node) {
6906
- if (ts10.isBlock(node.body)) {
7047
+ if (ts11.isBlock(node.body)) {
6907
7048
  return node.body;
6908
7049
  }
6909
7050
  return node.body;
6910
7051
  }
6911
7052
  function visitComponentBody(node, ctx2) {
6912
7053
  const isTopLevel = ctx2.componentBodyBlock !== null && node.parent === ctx2.componentBodyBlock;
6913
- if (ts10.isVariableStatement(node)) {
7054
+ if (ts11.isVariableStatement(node)) {
6914
7055
  for (const decl of node.declarationList.declarations) {
6915
7056
  if (isSignalDeclaration(decl, ctx2)) {
6916
7057
  collectSignal(decl, ctx2);
@@ -6933,16 +7074,16 @@ function visitComponentBody(node, ctx2) {
6933
7074
  collectEffect(decl.initializer, ctx2, decl.name.text);
6934
7075
  continue;
6935
7076
  }
6936
- if (ts10.isIdentifier(decl.name)) {
6937
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
7077
+ if (ts11.isIdentifier(decl.name)) {
7078
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
6938
7079
  collectConstant(decl, ctx2, false, isLet ? "let" : "const");
6939
- } else if (ts10.isObjectBindingPattern(decl.name) && decl.initializer && ts10.isIdentifier(decl.initializer) && ctx2.propsObjectName === decl.initializer.text) {
6940
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
7080
+ } else if (ts11.isObjectBindingPattern(decl.name) && decl.initializer && ts11.isIdentifier(decl.initializer) && ctx2.propsObjectName === decl.initializer.text) {
7081
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
6941
7082
  collectConstant(decl, ctx2, false, isLet ? "let" : "const");
6942
7083
  }
6943
7084
  }
6944
7085
  }
6945
- if (ts10.isExpressionStatement(node)) {
7086
+ if (ts11.isExpressionStatement(node)) {
6946
7087
  if (isEffectCall(node.expression, ctx2)) {
6947
7088
  collectEffect(node.expression, ctx2);
6948
7089
  return;
@@ -6956,10 +7097,10 @@ function visitComponentBody(node, ctx2) {
6956
7097
  return;
6957
7098
  }
6958
7099
  }
6959
- if (ts10.isFunctionDeclaration(node) && node.name) {
7100
+ if (ts11.isFunctionDeclaration(node) && node.name) {
6960
7101
  collectFunction(node, ctx2, false);
6961
7102
  }
6962
- if (ts10.isIfStatement(node)) {
7103
+ if (ts11.isIfStatement(node)) {
6963
7104
  const jsxReturn = findJsxReturnInBlock(node.thenStatement);
6964
7105
  if (jsxReturn) {
6965
7106
  const scopeVars = collectScopeVariables(node.thenStatement, ctx2);
@@ -6978,8 +7119,8 @@ function visitComponentBody(node, ctx2) {
6978
7119
  return;
6979
7120
  }
6980
7121
  }
6981
- if (isTopLevel && (ts10.isTryStatement(node) || ts10.isSwitchStatement(node) || ts10.isForStatement(node) || ts10.isForInStatement(node) || ts10.isForOfStatement(node) || ts10.isWhileStatement(node) || ts10.isDoStatement(node) || ts10.isThrowStatement(node) || ts10.isBlock(node) && node.parent === ctx2.componentBodyBlock)) {
6982
- if (ts10.isBlock(node)) {
7122
+ if (isTopLevel && (ts11.isTryStatement(node) || ts11.isSwitchStatement(node) || ts11.isForStatement(node) || ts11.isForInStatement(node) || ts11.isForOfStatement(node) || ts11.isWhileStatement(node) || ts11.isDoStatement(node) || ts11.isThrowStatement(node) || ts11.isBlock(node) && node.parent === ctx2.componentBodyBlock)) {
7123
+ if (ts11.isBlock(node)) {
6983
7124
  const returnedLocal = findBlockBodyReturnedJsxLocalName(node);
6984
7125
  if (returnedLocal) {
6985
7126
  ctx2.errors.push(createError(
@@ -6994,33 +7135,33 @@ function visitComponentBody(node, ctx2) {
6994
7135
  collectInitStatement(node, ctx2);
6995
7136
  return;
6996
7137
  }
6997
- if (ts10.isReturnStatement(node) && node.expression) {
7138
+ if (ts11.isReturnStatement(node) && node.expression) {
6998
7139
  ctx2.jsxReturn = unwrapJsxTransparent(node.expression);
6999
7140
  }
7000
- ts10.forEachChild(node, (child) => {
7001
- if (ts10.isArrowFunction(child) || ts10.isFunctionExpression(child) || ts10.isFunctionDeclaration(child)) {
7141
+ ts11.forEachChild(node, (child) => {
7142
+ if (ts11.isArrowFunction(child) || ts11.isFunctionExpression(child) || ts11.isFunctionDeclaration(child)) {
7002
7143
  return;
7003
7144
  }
7004
7145
  visitComponentBody(child, ctx2);
7005
7146
  });
7006
7147
  }
7007
7148
  function findJsxReturnInBlock(node) {
7008
- if (ts10.isBlock(node)) {
7149
+ if (ts11.isBlock(node)) {
7009
7150
  for (const stmt of node.statements) {
7010
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7151
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7011
7152
  const jsx = extractJsxFromExpression(stmt.expression);
7012
7153
  if (jsx) return jsx;
7013
7154
  }
7014
7155
  }
7015
7156
  }
7016
- if (ts10.isReturnStatement(node) && node.expression) {
7157
+ if (ts11.isReturnStatement(node) && node.expression) {
7017
7158
  return extractJsxFromExpression(node.expression);
7018
7159
  }
7019
7160
  return null;
7020
7161
  }
7021
7162
  function unwrapJsxTransparent(expr) {
7022
7163
  let current = expr;
7023
- while (ts10.isParenthesizedExpression(current) || ts10.isAsExpression(current) || ts10.isSatisfiesExpression(current) || ts10.isNonNullExpression(current) || ts10.isTypeAssertionExpression(current) || current.kind === ts10.SyntaxKind.PartiallyEmittedExpression) {
7164
+ while (ts11.isParenthesizedExpression(current) || ts11.isAsExpression(current) || ts11.isSatisfiesExpression(current) || ts11.isNonNullExpression(current) || ts11.isTypeAssertionExpression(current) || current.kind === ts11.SyntaxKind.PartiallyEmittedExpression) {
7024
7165
  current = current.expression;
7025
7166
  }
7026
7167
  return current;
@@ -7028,17 +7169,17 @@ function unwrapJsxTransparent(expr) {
7028
7169
  function findBlockBodyReturnedJsxLocalName(block) {
7029
7170
  const stmts = block.statements;
7030
7171
  const last = stmts[stmts.length - 1];
7031
- if (!last || !ts10.isReturnStatement(last) || !last.expression) return null;
7172
+ if (!last || !ts11.isReturnStatement(last) || !last.expression) return null;
7032
7173
  const returned = unwrapJsxTransparent(last.expression);
7033
- if (!ts10.isIdentifier(returned)) return null;
7174
+ if (!ts11.isIdentifier(returned)) return null;
7034
7175
  const name2 = returned.text;
7035
7176
  for (const stmt of stmts) {
7036
- if (!ts10.isVariableStatement(stmt)) continue;
7177
+ if (!ts11.isVariableStatement(stmt)) continue;
7037
7178
  for (const decl of stmt.declarationList.declarations) {
7038
- if (!ts10.isIdentifier(decl.name) || decl.name.text !== name2 || !decl.initializer) continue;
7179
+ if (!ts11.isIdentifier(decl.name) || decl.name.text !== name2 || !decl.initializer) continue;
7039
7180
  let init = decl.initializer;
7040
- while (ts10.isParenthesizedExpression(init)) init = init.expression;
7041
- if (ts10.isJsxElement(init) || ts10.isJsxSelfClosingElement(init) || ts10.isJsxFragment(init) || initializerShapeContainsJsx(init) || // `initializerShapeContainsJsx` deliberately stops at arrow
7181
+ while (ts11.isParenthesizedExpression(init)) init = init.expression;
7182
+ if (ts11.isJsxElement(init) || ts11.isJsxSelfClosingElement(init) || ts11.isJsxFragment(init) || initializerShapeContainsJsx(init) || // `initializerShapeContainsJsx` deliberately stops at arrow
7042
7183
  // boundaries, so a `.map()`/`.flatMap()` whose CALLBACK returns JSX
7043
7184
  // needs the same dedicated check `collectConstant` uses to admit
7044
7185
  // that shape into `inlineableJsxConsts` (#1554) — without it,
@@ -7054,16 +7195,16 @@ function findBlockBodyReturnedJsxLocalName(block) {
7054
7195
  }
7055
7196
  function extractJsxFromExpression(expr) {
7056
7197
  const inner = unwrapJsxTransparent(expr);
7057
- if (ts10.isJsxElement(inner) || ts10.isJsxFragment(inner) || ts10.isJsxSelfClosingElement(inner)) {
7198
+ if (ts11.isJsxElement(inner) || ts11.isJsxFragment(inner) || ts11.isJsxSelfClosingElement(inner)) {
7058
7199
  return inner;
7059
7200
  }
7060
7201
  return null;
7061
7202
  }
7062
7203
  function collectScopeVariables(node, ctx2) {
7063
7204
  const variables = [];
7064
- if (ts10.isBlock(node)) {
7205
+ if (ts11.isBlock(node)) {
7065
7206
  for (const stmt of node.statements) {
7066
- if (ts10.isVariableStatement(stmt)) {
7207
+ if (ts11.isVariableStatement(stmt)) {
7067
7208
  for (const decl of stmt.declarationList.declarations) {
7068
7209
  variables.push(decl);
7069
7210
  }
@@ -7075,13 +7216,13 @@ function collectScopeVariables(node, ctx2) {
7075
7216
  function collectParamBindingNames(params) {
7076
7217
  const out = /* @__PURE__ */ new Set();
7077
7218
  const addBindingNames2 = (name2) => {
7078
- if (ts10.isIdentifier(name2)) {
7219
+ if (ts11.isIdentifier(name2)) {
7079
7220
  out.add(name2.text);
7080
- } else if (ts10.isObjectBindingPattern(name2)) {
7221
+ } else if (ts11.isObjectBindingPattern(name2)) {
7081
7222
  name2.elements.forEach((e) => addBindingNames2(e.name));
7082
- } else if (ts10.isArrayBindingPattern(name2)) {
7223
+ } else if (ts11.isArrayBindingPattern(name2)) {
7083
7224
  name2.elements.forEach((e) => {
7084
- if (!ts10.isOmittedExpression(e)) addBindingNames2(e.name);
7225
+ if (!ts11.isOmittedExpression(e)) addBindingNames2(e.name);
7085
7226
  });
7086
7227
  }
7087
7228
  };
@@ -7095,7 +7236,7 @@ function collectEnclosingBranchVars(node, ctx2) {
7095
7236
  for (const cr of ctx2.conditionalReturns) {
7096
7237
  if (cr.ifStatement.thenStatement !== current) continue;
7097
7238
  for (const decl of cr.scopeVariables) {
7098
- if (!ts10.isIdentifier(decl.name) || !decl.initializer) continue;
7239
+ if (!ts11.isIdentifier(decl.name) || !decl.initializer) continue;
7099
7240
  const varName = decl.name.text;
7100
7241
  if (result2.has(varName)) continue;
7101
7242
  if (initializerShapeContainsJsx(decl.initializer)) continue;
@@ -7107,9 +7248,9 @@ function collectEnclosingBranchVars(node, ctx2) {
7107
7248
  return result2;
7108
7249
  }
7109
7250
  function collectBranchSignals(thenStatement, ctx2, branchCondition) {
7110
- if (!ts10.isBlock(thenStatement)) return;
7251
+ if (!ts11.isBlock(thenStatement)) return;
7111
7252
  for (const stmt of thenStatement.statements) {
7112
- if (!ts10.isVariableStatement(stmt)) continue;
7253
+ if (!ts11.isVariableStatement(stmt)) continue;
7113
7254
  for (const decl of stmt.declarationList.declarations) {
7114
7255
  if (!isSignalDeclaration(decl, ctx2)) continue;
7115
7256
  const before = ctx2.signals.length;
@@ -7122,12 +7263,12 @@ function collectBranchSignals(thenStatement, ctx2, branchCondition) {
7122
7263
  }
7123
7264
  }
7124
7265
  function resolvePrimitiveKind(callExpr, ctx2) {
7125
- if (ts10.isIdentifier(callExpr.expression)) {
7266
+ if (ts11.isIdentifier(callExpr.expression)) {
7126
7267
  const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
7127
7268
  if (hit) return hit;
7128
7269
  return resolveCalleeViaChecker(callExpr.expression, ctx2);
7129
7270
  }
7130
- if (ts10.isPropertyAccessExpression(callExpr.expression)) {
7271
+ if (ts11.isPropertyAccessExpression(callExpr.expression)) {
7131
7272
  const propName = callExpr.expression.name.text;
7132
7273
  const hit = PRIMITIVE_CANONICAL_NAMES[propName];
7133
7274
  if (!hit) return null;
@@ -7151,7 +7292,7 @@ function resolveCanonicalClientExportName(ident, ctx2) {
7151
7292
  }
7152
7293
  if (!symbol) return null;
7153
7294
  let target2 = symbol;
7154
- if (symbol.flags & ts10.SymbolFlags.Alias) {
7295
+ if (symbol.flags & ts11.SymbolFlags.Alias) {
7155
7296
  try {
7156
7297
  target2 = ctx2.checker.getAliasedSymbol(symbol);
7157
7298
  } catch {
@@ -7167,20 +7308,20 @@ function resolveCanonicalClientExportName(ident, ctx2) {
7167
7308
  return null;
7168
7309
  }
7169
7310
  function resolveEnvSignalKey(callExpr, ctx2) {
7170
- if (ts10.isIdentifier(callExpr.expression)) {
7311
+ if (ts11.isIdentifier(callExpr.expression)) {
7171
7312
  const key = ENV_SIGNAL_FACTORIES[callExpr.expression.text];
7172
7313
  if (key) return key;
7173
7314
  const canonical = resolveCanonicalClientExportName(callExpr.expression, ctx2);
7174
7315
  return canonical ? ENV_SIGNAL_FACTORIES[canonical] ?? null : null;
7175
7316
  }
7176
- if (ts10.isPropertyAccessExpression(callExpr.expression)) {
7317
+ if (ts11.isPropertyAccessExpression(callExpr.expression)) {
7177
7318
  const key = ENV_SIGNAL_FACTORIES[callExpr.expression.name.text];
7178
7319
  if (key && isBarefootClientNamespace(callExpr.expression.expression, ctx2)) return key;
7179
7320
  }
7180
7321
  return null;
7181
7322
  }
7182
7323
  function isBarefootClientNamespace(expr, ctx2) {
7183
- if (!ts10.isIdentifier(expr)) return false;
7324
+ if (!ts11.isIdentifier(expr)) return false;
7184
7325
  if (!ctx2.checker) return false;
7185
7326
  let symbol;
7186
7327
  try {
@@ -7190,33 +7331,33 @@ function isBarefootClientNamespace(expr, ctx2) {
7190
7331
  }
7191
7332
  if (!symbol) return false;
7192
7333
  for (const decl of symbol.declarations ?? []) {
7193
- if (!ts10.isNamespaceImport(decl)) continue;
7334
+ if (!ts11.isNamespaceImport(decl)) continue;
7194
7335
  const importDecl = decl.parent.parent;
7195
- if (!ts10.isImportDeclaration(importDecl)) continue;
7336
+ if (!ts11.isImportDeclaration(importDecl)) continue;
7196
7337
  const mod = importDecl.moduleSpecifier;
7197
- if (ts10.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
7338
+ if (ts11.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
7198
7339
  return true;
7199
7340
  }
7200
7341
  }
7201
7342
  return false;
7202
7343
  }
7203
7344
  function isSignalDeclaration(node, ctx2) {
7204
- if (!ts10.isArrayBindingPattern(node.name)) return false;
7205
- if (!node.initializer || !ts10.isCallExpression(node.initializer)) return false;
7345
+ if (!ts11.isArrayBindingPattern(node.name)) return false;
7346
+ if (!node.initializer || !ts11.isCallExpression(node.initializer)) return false;
7206
7347
  return resolvePrimitiveKind(node.initializer, ctx2) === "signal";
7207
7348
  }
7208
7349
  function collectSignal(node, ctx2) {
7209
7350
  const pattern = node.name;
7210
7351
  const callExpr = node.initializer;
7211
7352
  const elements2 = pattern.elements;
7212
- const getterElided = elements2.length === 2 && ts10.isOmittedExpression(elements2[0]);
7213
- if (elements2.length < 1 || elements2.length > 2 || !getterElided && (!ts10.isBindingElement(elements2[0]) || !ts10.isIdentifier(elements2[0].name))) {
7353
+ const getterElided = elements2.length === 2 && ts11.isOmittedExpression(elements2[0]);
7354
+ if (elements2.length < 1 || elements2.length > 2 || !getterElided && (!ts11.isBindingElement(elements2[0]) || !ts11.isIdentifier(elements2[0].name))) {
7214
7355
  return;
7215
7356
  }
7216
- if (elements2.length === 2 && (!ts10.isBindingElement(elements2[1]) || !ts10.isIdentifier(elements2[1].name))) {
7357
+ if (elements2.length === 2 && (!ts11.isBindingElement(elements2[1]) || !ts11.isIdentifier(elements2[1].name))) {
7217
7358
  return;
7218
7359
  }
7219
- const setter = elements2.length === 2 && ts10.isBindingElement(elements2[1]) && ts10.isIdentifier(elements2[1].name) ? elements2[1].name.text : null;
7360
+ const setter = elements2.length === 2 && ts11.isBindingElement(elements2[1]) && ts11.isIdentifier(elements2[1].name) ? elements2[1].name.text : null;
7220
7361
  if (getterElided && !setter) return;
7221
7362
  const getter = getterElided ? `__bfGet_${setter}` : elements2[0].name.text;
7222
7363
  const initialValue = callExpr.arguments[0] ? ctx2.getJS(callExpr.arguments[0]) : "";
@@ -7252,27 +7393,27 @@ function collectSignal(node, ctx2) {
7252
7393
  });
7253
7394
  }
7254
7395
  function isSignalTupleDeclaration(node) {
7255
- if (!ts10.isIdentifier(node.name)) return false;
7256
- if (!node.initializer || !ts10.isCallExpression(node.initializer)) return false;
7396
+ if (!ts11.isIdentifier(node.name)) return false;
7397
+ if (!node.initializer || !ts11.isCallExpression(node.initializer)) return false;
7257
7398
  const callExpr = node.initializer;
7258
- return ts10.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
7399
+ return ts11.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
7259
7400
  }
7260
7401
  function isSignalIndexAccess(node, ctx2) {
7261
- if (!ts10.isIdentifier(node.name)) return null;
7262
- if (!node.initializer || !ts10.isElementAccessExpression(node.initializer)) return null;
7402
+ if (!ts11.isIdentifier(node.name)) return null;
7403
+ if (!node.initializer || !ts11.isElementAccessExpression(node.initializer)) return null;
7263
7404
  const access2 = node.initializer;
7264
- if (!ts10.isNumericLiteral(access2.argumentExpression)) return null;
7405
+ if (!ts11.isNumericLiteral(access2.argumentExpression)) return null;
7265
7406
  const indexValue = Number(access2.argumentExpression.text);
7266
7407
  if (indexValue !== 0 && indexValue !== 1) return null;
7267
7408
  const index = indexValue;
7268
- if (ts10.isCallExpression(access2.expression)) {
7409
+ if (ts11.isCallExpression(access2.expression)) {
7269
7410
  const call = access2.expression;
7270
- if (ts10.isIdentifier(call.expression) && call.expression.text === "createSignal") {
7411
+ if (ts11.isIdentifier(call.expression) && call.expression.text === "createSignal") {
7271
7412
  return { kind: "direct", index, callExpr: call };
7272
7413
  }
7273
7414
  return null;
7274
7415
  }
7275
- if (ts10.isIdentifier(access2.expression)) {
7416
+ if (ts11.isIdentifier(access2.expression)) {
7276
7417
  const tupleName = access2.expression.text;
7277
7418
  if (ctx2.signalTupleRefs.has(tupleName)) {
7278
7419
  return { kind: "tupleRef", index, tupleName };
@@ -7363,23 +7504,23 @@ function flushPendingSignalTuples(ctx2) {
7363
7504
  ctx2.signalTupleRefs.clear();
7364
7505
  }
7365
7506
  function isMemoDeclaration(node, ctx2) {
7366
- if (!ts10.isIdentifier(node.name)) return false;
7367
- if (!node.initializer || !ts10.isCallExpression(node.initializer)) return false;
7507
+ if (!ts11.isIdentifier(node.name)) return false;
7508
+ if (!node.initializer || !ts11.isCallExpression(node.initializer)) return false;
7368
7509
  return resolvePrimitiveKind(node.initializer, ctx2) === "memo";
7369
7510
  }
7370
7511
  function memoBodyIsTemplateLiteral(memoArrow) {
7371
7512
  let node = memoArrow;
7372
- while (node && ts10.isParenthesizedExpression(node)) node = node.expression;
7373
- if (!node || !ts10.isArrowFunction(node)) return false;
7513
+ while (node && ts11.isParenthesizedExpression(node)) node = node.expression;
7514
+ if (!node || !ts11.isArrowFunction(node)) return false;
7374
7515
  let body2 = node.body;
7375
- while (ts10.isParenthesizedExpression(body2)) body2 = body2.expression;
7376
- if (ts10.isBlock(body2)) {
7377
- const ret = body2.statements.find(ts10.isReturnStatement);
7516
+ while (ts11.isParenthesizedExpression(body2)) body2 = body2.expression;
7517
+ if (ts11.isBlock(body2)) {
7518
+ const ret = body2.statements.find(ts11.isReturnStatement);
7378
7519
  if (!ret || !ret.expression) return false;
7379
7520
  body2 = ret.expression;
7380
- while (ts10.isParenthesizedExpression(body2)) body2 = body2.expression;
7521
+ while (ts11.isParenthesizedExpression(body2)) body2 = body2.expression;
7381
7522
  }
7382
- return ts10.isTemplateExpression(body2) || ts10.isNoSubstitutionTemplateLiteral(body2);
7523
+ return ts11.isTemplateExpression(body2) || ts11.isNoSubstitutionTemplateLiteral(body2);
7383
7524
  }
7384
7525
  function collectMemo(node, ctx2) {
7385
7526
  const name2 = node.name.text;
@@ -7396,7 +7537,7 @@ function collectMemo(node, ctx2) {
7396
7537
  type2 = inferTypeFromValue(arrowBody);
7397
7538
  }
7398
7539
  }
7399
- if (ctx2.checker && (type2.kind === "unknown" || type2.kind === "object") && callExpr.arguments[0] && (ts10.isArrowFunction(callExpr.arguments[0]) || ts10.isFunctionExpression(callExpr.arguments[0]))) {
7540
+ if (ctx2.checker && (type2.kind === "unknown" || type2.kind === "object") && callExpr.arguments[0] && (ts11.isArrowFunction(callExpr.arguments[0]) || ts11.isFunctionExpression(callExpr.arguments[0]))) {
7400
7541
  const fnType = ctx2.checker.getTypeAtLocation(callExpr.arguments[0]);
7401
7542
  const sig = fnType.getCallSignatures()[0];
7402
7543
  if (sig) {
@@ -7405,11 +7546,11 @@ function collectMemo(node, ctx2) {
7405
7546
  }
7406
7547
  }
7407
7548
  const memoArrow = callExpr.arguments[0];
7408
- const parsedBody = memoArrow && ts10.isArrowFunction(memoArrow) && !ts10.isBlock(memoArrow.body) ? parseExpression(ctx2.getJS(memoArrow.body)) : void 0;
7549
+ const parsedBody = memoArrow && ts11.isArrowFunction(memoArrow) && !ts11.isBlock(memoArrow.body) ? parseExpression(ctx2.getJS(memoArrow.body)) : void 0;
7409
7550
  const parsed = parsedBody && parsedBody.kind !== "unsupported" && parsedBody.kind !== "object-literal" ? parsedBody : void 0;
7410
7551
  let arrowNode = memoArrow;
7411
- while (arrowNode && ts10.isParenthesizedExpression(arrowNode)) arrowNode = arrowNode.expression;
7412
- const blockBody = arrowNode && ts10.isArrowFunction(arrowNode) && ts10.isBlock(arrowNode.body) ? arrowNode.body : void 0;
7552
+ while (arrowNode && ts11.isParenthesizedExpression(arrowNode)) arrowNode = arrowNode.expression;
7553
+ const blockBody = arrowNode && ts11.isArrowFunction(arrowNode) && ts11.isBlock(arrowNode.body) ? arrowNode.body : void 0;
7413
7554
  const parsedBlock = blockBody ? parseBlockBodyTolerant(blockBody, ctx2.sourceFile, (node2) => ctx2.getJS(node2)) : void 0;
7414
7555
  const parsedBlockComplete = parsedBlock && blockBody ? parsedBlock.length === blockBody.statements.length : void 0;
7415
7556
  let templateComputation;
@@ -7436,12 +7577,12 @@ function collectMemo(node, ctx2) {
7436
7577
  });
7437
7578
  }
7438
7579
  function isEffectCall(node, ctx2) {
7439
- if (!ts10.isCallExpression(node)) return false;
7580
+ if (!ts11.isCallExpression(node)) return false;
7440
7581
  return resolvePrimitiveKind(node, ctx2) === "effect";
7441
7582
  }
7442
7583
  function isEffectDisposerCapture(node, ctx2) {
7443
- if (!ts10.isIdentifier(node.name)) return false;
7444
- if (!node.initializer || !ts10.isCallExpression(node.initializer)) return false;
7584
+ if (!ts11.isIdentifier(node.name)) return false;
7585
+ if (!node.initializer || !ts11.isCallExpression(node.initializer)) return false;
7445
7586
  return resolvePrimitiveKind(node.initializer, ctx2) === "effect";
7446
7587
  }
7447
7588
  function collectEffect(node, ctx2, captureName) {
@@ -7455,7 +7596,7 @@ function collectEffect(node, ctx2, captureName) {
7455
7596
  });
7456
7597
  }
7457
7598
  function isOnMountCall(node, ctx2) {
7458
- if (!ts10.isCallExpression(node)) return false;
7599
+ if (!ts11.isCallExpression(node)) return false;
7459
7600
  return resolvePrimitiveKind(node, ctx2) === "onMount";
7460
7601
  }
7461
7602
  function collectOnMount(node, ctx2) {
@@ -7494,18 +7635,18 @@ function leadsWithAsiHazard(body2) {
7494
7635
  function extractAssignedIdentifiersFromNode(node) {
7495
7636
  const ids = /* @__PURE__ */ new Set();
7496
7637
  function addFromTarget(target2) {
7497
- if (ts10.isIdentifier(target2)) {
7638
+ if (ts11.isIdentifier(target2)) {
7498
7639
  ids.add(target2.text);
7499
7640
  return;
7500
7641
  }
7501
- if (ts10.isParenthesizedExpression(target2)) {
7642
+ if (ts11.isParenthesizedExpression(target2)) {
7502
7643
  addFromTarget(target2.expression);
7503
7644
  return;
7504
7645
  }
7505
- if (ts10.isArrayLiteralExpression(target2)) {
7646
+ if (ts11.isArrayLiteralExpression(target2)) {
7506
7647
  for (const el of target2.elements) {
7507
- if (ts10.isOmittedExpression(el)) continue;
7508
- if (ts10.isSpreadElement(el)) {
7648
+ if (ts11.isOmittedExpression(el)) continue;
7649
+ if (ts11.isSpreadElement(el)) {
7509
7650
  addFromTarget(el.expression);
7510
7651
  continue;
7511
7652
  }
@@ -7513,17 +7654,17 @@ function extractAssignedIdentifiersFromNode(node) {
7513
7654
  }
7514
7655
  return;
7515
7656
  }
7516
- if (ts10.isObjectLiteralExpression(target2)) {
7657
+ if (ts11.isObjectLiteralExpression(target2)) {
7517
7658
  for (const prop of target2.properties) {
7518
- if (ts10.isShorthandPropertyAssignment(prop)) {
7659
+ if (ts11.isShorthandPropertyAssignment(prop)) {
7519
7660
  ids.add(prop.name.text);
7520
7661
  continue;
7521
7662
  }
7522
- if (ts10.isPropertyAssignment(prop)) {
7663
+ if (ts11.isPropertyAssignment(prop)) {
7523
7664
  addFromTarget(prop.initializer);
7524
7665
  continue;
7525
7666
  }
7526
- if (ts10.isSpreadAssignment(prop)) {
7667
+ if (ts11.isSpreadAssignment(prop)) {
7527
7668
  addFromTarget(prop.expression);
7528
7669
  continue;
7529
7670
  }
@@ -7532,21 +7673,21 @@ function extractAssignedIdentifiersFromNode(node) {
7532
7673
  }
7533
7674
  }
7534
7675
  function visit3(n) {
7535
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n) || ts10.isFunctionDeclaration(n) || ts10.isMethodDeclaration(n) || ts10.isGetAccessorDeclaration(n) || ts10.isSetAccessorDeclaration(n) || ts10.isConstructorDeclaration(n)) {
7676
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n) || ts11.isMethodDeclaration(n) || ts11.isGetAccessorDeclaration(n) || ts11.isSetAccessorDeclaration(n) || ts11.isConstructorDeclaration(n)) {
7536
7677
  return;
7537
7678
  }
7538
- if (ts10.isBinaryExpression(n)) {
7679
+ if (ts11.isBinaryExpression(n)) {
7539
7680
  const op = n.operatorToken.kind;
7540
- if (op === ts10.SyntaxKind.EqualsToken || op === ts10.SyntaxKind.PlusEqualsToken || op === ts10.SyntaxKind.MinusEqualsToken || op === ts10.SyntaxKind.AsteriskEqualsToken || op === ts10.SyntaxKind.SlashEqualsToken || op === ts10.SyntaxKind.PercentEqualsToken || op === ts10.SyntaxKind.AsteriskAsteriskEqualsToken || op === ts10.SyntaxKind.AmpersandEqualsToken || op === ts10.SyntaxKind.BarEqualsToken || op === ts10.SyntaxKind.CaretEqualsToken || op === ts10.SyntaxKind.LessThanLessThanEqualsToken || op === ts10.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === ts10.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === ts10.SyntaxKind.AmpersandAmpersandEqualsToken || op === ts10.SyntaxKind.BarBarEqualsToken || op === ts10.SyntaxKind.QuestionQuestionEqualsToken) {
7681
+ if (op === ts11.SyntaxKind.EqualsToken || op === ts11.SyntaxKind.PlusEqualsToken || op === ts11.SyntaxKind.MinusEqualsToken || op === ts11.SyntaxKind.AsteriskEqualsToken || op === ts11.SyntaxKind.SlashEqualsToken || op === ts11.SyntaxKind.PercentEqualsToken || op === ts11.SyntaxKind.AsteriskAsteriskEqualsToken || op === ts11.SyntaxKind.AmpersandEqualsToken || op === ts11.SyntaxKind.BarEqualsToken || op === ts11.SyntaxKind.CaretEqualsToken || op === ts11.SyntaxKind.LessThanLessThanEqualsToken || op === ts11.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === ts11.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === ts11.SyntaxKind.AmpersandAmpersandEqualsToken || op === ts11.SyntaxKind.BarBarEqualsToken || op === ts11.SyntaxKind.QuestionQuestionEqualsToken) {
7541
7682
  addFromTarget(n.left);
7542
7683
  }
7543
7684
  }
7544
- if (ts10.isPrefixUnaryExpression(n) || ts10.isPostfixUnaryExpression(n)) {
7545
- if (n.operator === ts10.SyntaxKind.PlusPlusToken || n.operator === ts10.SyntaxKind.MinusMinusToken) {
7685
+ if (ts11.isPrefixUnaryExpression(n) || ts11.isPostfixUnaryExpression(n)) {
7686
+ if (n.operator === ts11.SyntaxKind.PlusPlusToken || n.operator === ts11.SyntaxKind.MinusMinusToken) {
7546
7687
  addFromTarget(n.operand);
7547
7688
  }
7548
7689
  }
7549
- ts10.forEachChild(n, visit3);
7690
+ ts11.forEachChild(n, visit3);
7550
7691
  }
7551
7692
  visit3(node);
7552
7693
  const localDecls = collectLocalDeclarations(node);
@@ -7556,56 +7697,56 @@ function extractAssignedIdentifiersFromNode(node) {
7556
7697
  function collectLocalDeclarations(root2) {
7557
7698
  const names = /* @__PURE__ */ new Set();
7558
7699
  function addBindingName(name2) {
7559
- if (ts10.isIdentifier(name2)) {
7700
+ if (ts11.isIdentifier(name2)) {
7560
7701
  names.add(name2.text);
7561
7702
  return;
7562
7703
  }
7563
- if (ts10.isArrayBindingPattern(name2)) {
7704
+ if (ts11.isArrayBindingPattern(name2)) {
7564
7705
  for (const el of name2.elements) {
7565
- if (ts10.isBindingElement(el)) addBindingName(el.name);
7706
+ if (ts11.isBindingElement(el)) addBindingName(el.name);
7566
7707
  }
7567
7708
  return;
7568
7709
  }
7569
- if (ts10.isObjectBindingPattern(name2)) {
7710
+ if (ts11.isObjectBindingPattern(name2)) {
7570
7711
  for (const el of name2.elements) {
7571
7712
  addBindingName(el.name);
7572
7713
  }
7573
7714
  }
7574
7715
  }
7575
7716
  function visit3(n) {
7576
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n) || ts10.isFunctionDeclaration(n)) return;
7577
- if (ts10.isVariableDeclaration(n)) {
7717
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n)) return;
7718
+ if (ts11.isVariableDeclaration(n)) {
7578
7719
  addBindingName(n.name);
7579
7720
  }
7580
- ts10.forEachChild(n, visit3);
7721
+ ts11.forEachChild(n, visit3);
7581
7722
  }
7582
7723
  visit3(root2);
7583
7724
  return names;
7584
7725
  }
7585
7726
  function collectAmbientGlobals(node, ctx2) {
7586
- if (ts10.isVariableStatement(node)) {
7587
- const isDeclare = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false;
7727
+ if (ts11.isVariableStatement(node)) {
7728
+ const isDeclare = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false;
7588
7729
  if (!isDeclare) return;
7589
7730
  for (const decl of node.declarationList.declarations) {
7590
- if (ts10.isIdentifier(decl.name)) ctx2.ambientGlobals.add(decl.name.text);
7731
+ if (ts11.isIdentifier(decl.name)) ctx2.ambientGlobals.add(decl.name.text);
7591
7732
  }
7592
7733
  return;
7593
7734
  }
7594
- if (ts10.isFunctionDeclaration(node) && node.name) {
7595
- const isDeclare = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false;
7735
+ if (ts11.isFunctionDeclaration(node) && node.name) {
7736
+ const isDeclare = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false;
7596
7737
  if (isDeclare) ctx2.ambientGlobals.add(node.name.text);
7597
7738
  return;
7598
7739
  }
7599
- if (ts10.isModuleDeclaration(node)) {
7600
- const isGlobalAugmentation = (node.flags & ts10.NodeFlags.GlobalAugmentation) !== 0;
7740
+ if (ts11.isModuleDeclaration(node)) {
7741
+ const isGlobalAugmentation = (node.flags & ts11.NodeFlags.GlobalAugmentation) !== 0;
7601
7742
  if (!isGlobalAugmentation) return;
7602
- if (!node.body || !ts10.isModuleBlock(node.body)) return;
7743
+ if (!node.body || !ts11.isModuleBlock(node.body)) return;
7603
7744
  for (const inner of node.body.statements) {
7604
- if (ts10.isVariableStatement(inner)) {
7745
+ if (ts11.isVariableStatement(inner)) {
7605
7746
  for (const decl of inner.declarationList.declarations) {
7606
- if (ts10.isIdentifier(decl.name)) ctx2.ambientGlobals.add(decl.name.text);
7747
+ if (ts11.isIdentifier(decl.name)) ctx2.ambientGlobals.add(decl.name.text);
7607
7748
  }
7608
- } else if (ts10.isFunctionDeclaration(inner) && inner.name) {
7749
+ } else if (ts11.isFunctionDeclaration(inner) && inner.name) {
7609
7750
  ctx2.ambientGlobals.add(inner.name.text);
7610
7751
  }
7611
7752
  }
@@ -7616,7 +7757,7 @@ function collectImport(node, ctx2) {
7616
7757
  const specifiers = [];
7617
7758
  const isTypeOnly = !!node.importClause?.isTypeOnly;
7618
7759
  const loc = getSourceLocation(node, ctx2.sourceFile, ctx2.filePath);
7619
- if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && ts10.isNamedImports(node.importClause.namedBindings)) {
7760
+ if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && ts11.isNamedImports(node.importClause.namedBindings)) {
7620
7761
  const wrongImports = [];
7621
7762
  for (const element2 of node.importClause.namedBindings.elements) {
7622
7763
  const name2 = element2.propertyName?.text ?? element2.name.text;
@@ -7644,7 +7785,7 @@ function collectImport(node, ctx2) {
7644
7785
  });
7645
7786
  }
7646
7787
  if (node.importClause.namedBindings) {
7647
- if (ts10.isNamedImports(node.importClause.namedBindings)) {
7788
+ if (ts11.isNamedImports(node.importClause.namedBindings)) {
7648
7789
  for (const element2 of node.importClause.namedBindings.elements) {
7649
7790
  specifiers.push({
7650
7791
  name: element2.propertyName?.text ?? element2.name.text,
@@ -7656,7 +7797,7 @@ function collectImport(node, ctx2) {
7656
7797
  });
7657
7798
  }
7658
7799
  }
7659
- if (ts10.isNamespaceImport(node.importClause.namedBindings)) {
7800
+ if (ts11.isNamespaceImport(node.importClause.namedBindings)) {
7660
7801
  specifiers.push({
7661
7802
  name: node.importClause.namedBindings.name.text,
7662
7803
  alias: null,
@@ -7683,7 +7824,7 @@ function collectInterfaceDefinition(node, ctx2) {
7683
7824
  });
7684
7825
  }
7685
7826
  function collectTypeAliasDefinition(node, ctx2) {
7686
- const properties = ts10.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx2.sourceFile) : void 0;
7827
+ const properties = ts11.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx2.sourceFile) : void 0;
7687
7828
  ctx2.typeDefinitions.push({
7688
7829
  kind: "type",
7689
7830
  name: node.name.text,
@@ -7696,19 +7837,19 @@ function extractSingleJsxReturn(body2) {
7696
7837
  let jsxReturn = null;
7697
7838
  let returnCount = 0;
7698
7839
  function visit3(node) {
7699
- if (ts10.isFunctionDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node)) return;
7700
- if (ts10.isReturnStatement(node)) {
7840
+ if (ts11.isFunctionDeclaration(node) || ts11.isFunctionExpression(node) || ts11.isArrowFunction(node)) return;
7841
+ if (ts11.isReturnStatement(node)) {
7701
7842
  returnCount++;
7702
7843
  if (node.expression) {
7703
7844
  const expr = unwrapJsxTransparent(node.expression);
7704
- if (ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr)) {
7845
+ if (ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr)) {
7705
7846
  jsxReturn = expr;
7706
7847
  }
7707
7848
  }
7708
7849
  }
7709
- ts10.forEachChild(node, visit3);
7850
+ ts11.forEachChild(node, visit3);
7710
7851
  }
7711
- ts10.forEachChild(body2, visit3);
7852
+ ts11.forEachChild(body2, visit3);
7712
7853
  if (returnCount !== 1) return null;
7713
7854
  return jsxReturn;
7714
7855
  }
@@ -7723,9 +7864,9 @@ function extractMultiReturnJsxBranches(body2, allowPreamble = false) {
7723
7864
  const stmts = body2.statements;
7724
7865
  for (let i = 0; i < stmts.length; i++) {
7725
7866
  const stmt = stmts[i];
7726
- if (ts10.isIfStatement(stmt)) {
7867
+ if (ts11.isIfStatement(stmt)) {
7727
7868
  let current = stmt;
7728
- while (ts10.isIfStatement(current)) {
7869
+ while (ts11.isIfStatement(current)) {
7729
7870
  const ifStmt = current;
7730
7871
  if (!isDirectReturnBlock(ifStmt.thenStatement)) return null;
7731
7872
  const jsxReturn = findJsxReturnInBlock(ifStmt.thenStatement);
@@ -7733,7 +7874,7 @@ function extractMultiReturnJsxBranches(body2, allowPreamble = false) {
7733
7874
  if (!jsxReturn && !nullReturn) return null;
7734
7875
  branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
7735
7876
  if (ifStmt.elseStatement) {
7736
- if (ts10.isIfStatement(ifStmt.elseStatement)) {
7877
+ if (ts11.isIfStatement(ifStmt.elseStatement)) {
7737
7878
  current = ifStmt.elseStatement;
7738
7879
  continue;
7739
7880
  }
@@ -7752,16 +7893,16 @@ function extractMultiReturnJsxBranches(body2, allowPreamble = false) {
7752
7893
  }
7753
7894
  continue;
7754
7895
  }
7755
- if (ts10.isSwitchStatement(stmt)) {
7896
+ if (ts11.isSwitchStatement(stmt)) {
7756
7897
  if (branches.length > 0) return null;
7757
- if (!ts10.isIdentifier(stmt.expression) && !ts10.isPropertyAccessExpression(stmt.expression)) {
7898
+ if (!ts11.isIdentifier(stmt.expression) && !ts11.isPropertyAccessExpression(stmt.expression)) {
7758
7899
  return null;
7759
7900
  }
7760
- const hasDefault = stmt.caseBlock.clauses.some((c) => ts10.isDefaultClause(c));
7901
+ const hasDefault = stmt.caseBlock.clauses.some((c) => ts11.isDefaultClause(c));
7761
7902
  if (!hasDefault) return null;
7762
7903
  let pendingCases = [];
7763
7904
  for (const clause of stmt.caseBlock.clauses) {
7764
- if (ts10.isCaseClause(clause) && clause.statements.length === 0) {
7905
+ if (ts11.isCaseClause(clause) && clause.statements.length === 0) {
7765
7906
  pendingCases.push(clause.expression);
7766
7907
  continue;
7767
7908
  }
@@ -7769,7 +7910,7 @@ function extractMultiReturnJsxBranches(body2, allowPreamble = false) {
7769
7910
  const nullReturn = findNullReturnInCaseClause(clause);
7770
7911
  if (!jsxReturn && !nullReturn) return null;
7771
7912
  if (!caseClauseIsDirectReturn(clause)) return null;
7772
- if (ts10.isCaseClause(clause)) {
7913
+ if (ts11.isCaseClause(clause)) {
7773
7914
  branches.push({
7774
7915
  condition: clause.expression,
7775
7916
  jsxReturn: jsxReturn ?? null,
@@ -7786,19 +7927,19 @@ function extractMultiReturnJsxBranches(body2, allowPreamble = false) {
7786
7927
  if (preambleUnsafe(preamble, branches, fallback)) return null;
7787
7928
  return { branches, fallback, switchDiscriminant: stmt.expression, preamble };
7788
7929
  }
7789
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7930
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7790
7931
  const expr = unwrapJsxTransparent(stmt.expression);
7791
- if (ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr)) {
7932
+ if (ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr)) {
7792
7933
  fallback = expr;
7793
- } else if (expr.kind === ts10.SyntaxKind.NullKeyword) {
7934
+ } else if (expr.kind === ts11.SyntaxKind.NullKeyword) {
7794
7935
  } else {
7795
7936
  return null;
7796
7937
  }
7797
7938
  continue;
7798
7939
  }
7799
- if (ts10.isVariableStatement(stmt)) {
7940
+ if (ts11.isVariableStatement(stmt)) {
7800
7941
  const declFlags = stmt.declarationList.flags;
7801
- const isConstOrLet = (declFlags & ts10.NodeFlags.Const) !== 0 || (declFlags & ts10.NodeFlags.Let) !== 0;
7942
+ const isConstOrLet = (declFlags & ts11.NodeFlags.Const) !== 0 || (declFlags & ts11.NodeFlags.Let) !== 0;
7802
7943
  if (allowPreamble && isConstOrLet && branches.length === 0 && fallback === null) {
7803
7944
  preamble.push(stmt);
7804
7945
  continue;
@@ -7812,11 +7953,11 @@ function extractMultiReturnJsxBranches(body2, allowPreamble = false) {
7812
7953
  return { branches, fallback, preamble };
7813
7954
  }
7814
7955
  function isDirectReturnBlock(node) {
7815
- if (ts10.isReturnStatement(node)) return true;
7816
- if (ts10.isBlock(node)) {
7956
+ if (ts11.isReturnStatement(node)) return true;
7957
+ if (ts11.isBlock(node)) {
7817
7958
  let returnCount = 0;
7818
7959
  for (const stmt of node.statements) {
7819
- if (ts10.isReturnStatement(stmt)) {
7960
+ if (ts11.isReturnStatement(stmt)) {
7820
7961
  returnCount++;
7821
7962
  continue;
7822
7963
  }
@@ -7827,23 +7968,23 @@ function isDirectReturnBlock(node) {
7827
7968
  return false;
7828
7969
  }
7829
7970
  function findNullReturnInBlock(node) {
7830
- if (ts10.isBlock(node)) {
7971
+ if (ts11.isBlock(node)) {
7831
7972
  for (const stmt of node.statements) {
7832
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7973
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7833
7974
  const expr = unwrapJsxTransparent(stmt.expression);
7834
- if (expr.kind === ts10.SyntaxKind.NullKeyword) return true;
7975
+ if (expr.kind === ts11.SyntaxKind.NullKeyword) return true;
7835
7976
  }
7836
7977
  }
7837
7978
  }
7838
- if (ts10.isReturnStatement(node) && node.expression) {
7979
+ if (ts11.isReturnStatement(node) && node.expression) {
7839
7980
  const expr = unwrapJsxTransparent(node.expression);
7840
- if (expr.kind === ts10.SyntaxKind.NullKeyword) return true;
7981
+ if (expr.kind === ts11.SyntaxKind.NullKeyword) return true;
7841
7982
  }
7842
7983
  return false;
7843
7984
  }
7844
7985
  function findJsxReturnInCaseClause(clause) {
7845
7986
  for (const stmt of clause.statements) {
7846
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7987
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7847
7988
  return extractJsxFromExpression(stmt.expression);
7848
7989
  }
7849
7990
  }
@@ -7853,12 +7994,12 @@ function caseClauseIsDirectReturn(clause) {
7853
7994
  let returnCount = 0;
7854
7995
  let seenReturn = false;
7855
7996
  for (const stmt of clause.statements) {
7856
- if (ts10.isReturnStatement(stmt)) {
7997
+ if (ts11.isReturnStatement(stmt)) {
7857
7998
  returnCount++;
7858
7999
  seenReturn = true;
7859
8000
  continue;
7860
8001
  }
7861
- if (ts10.isBreakStatement(stmt)) {
8002
+ if (ts11.isBreakStatement(stmt)) {
7862
8003
  if (!seenReturn) return false;
7863
8004
  continue;
7864
8005
  }
@@ -7868,9 +8009,9 @@ function caseClauseIsDirectReturn(clause) {
7868
8009
  }
7869
8010
  function findNullReturnInCaseClause(clause) {
7870
8011
  for (const stmt of clause.statements) {
7871
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
8012
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7872
8013
  const expr = unwrapJsxTransparent(stmt.expression);
7873
- if (expr.kind === ts10.SyntaxKind.NullKeyword) return true;
8014
+ if (expr.kind === ts11.SyntaxKind.NullKeyword) return true;
7874
8015
  }
7875
8016
  }
7876
8017
  return false;
@@ -7880,23 +8021,23 @@ function isMultiReturnJsxFunctionBody(body2) {
7880
8021
  let hasJsxReturn = false;
7881
8022
  let allReturnsAreJsxOrNull = true;
7882
8023
  function visit3(node) {
7883
- if (ts10.isFunctionDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node)) return;
7884
- if (ts10.isReturnStatement(node)) {
8024
+ if (ts11.isFunctionDeclaration(node) || ts11.isFunctionExpression(node) || ts11.isArrowFunction(node)) return;
8025
+ if (ts11.isReturnStatement(node)) {
7885
8026
  returnCount++;
7886
8027
  if (!node.expression) {
7887
8028
  allReturnsAreJsxOrNull = false;
7888
8029
  return;
7889
8030
  }
7890
8031
  const expr = unwrapJsxTransparent(node.expression);
7891
- const isJsx = ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr);
7892
- const isNull = expr.kind === ts10.SyntaxKind.NullKeyword;
8032
+ const isJsx = ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr);
8033
+ const isNull = expr.kind === ts11.SyntaxKind.NullKeyword;
7893
8034
  if (isJsx) hasJsxReturn = true;
7894
8035
  if (!isJsx && !isNull) allReturnsAreJsxOrNull = false;
7895
8036
  return;
7896
8037
  }
7897
- ts10.forEachChild(node, visit3);
8038
+ ts11.forEachChild(node, visit3);
7898
8039
  }
7899
- ts10.forEachChild(body2, visit3);
8040
+ ts11.forEachChild(body2, visit3);
7900
8041
  return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
7901
8042
  }
7902
8043
  function collectFunction(node, ctx2, _isModule, isExported = false) {
@@ -7962,7 +8103,7 @@ function collectFunction(node, ctx2, _isModule, isExported = false) {
7962
8103
  }
7963
8104
  }
7964
8105
  }
7965
- const isAsync = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.AsyncKeyword) ?? false;
8106
+ const isAsync = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.AsyncKeyword) ?? false;
7966
8107
  const isGenerator = !!node.asteriskToken;
7967
8108
  ctx2.localFunctions.push({
7968
8109
  name: name2,
@@ -7983,10 +8124,10 @@ function collectFunction(node, ctx2, _isModule, isExported = false) {
7983
8124
  });
7984
8125
  }
7985
8126
  function extractValueBranches(node, ctx2) {
7986
- if (ts10.isParenthesizedExpression(node)) {
8127
+ if (ts11.isParenthesizedExpression(node)) {
7987
8128
  return extractValueBranches(node.expression, ctx2);
7988
8129
  }
7989
- if (ts10.isConditionalExpression(node)) {
8130
+ if (ts11.isConditionalExpression(node)) {
7990
8131
  return [
7991
8132
  ...extractValueBranches(node.whenTrue, ctx2),
7992
8133
  ...extractValueBranches(node.whenFalse, ctx2)
@@ -7998,33 +8139,33 @@ function extractFreeIdentifiersFromNode(node) {
7998
8139
  const ids = /* @__PURE__ */ new Set();
7999
8140
  const boundNames = /* @__PURE__ */ new Set();
8000
8141
  function addBindingNames2(name2, out) {
8001
- if (ts10.isIdentifier(name2)) out.push(name2.text);
8002
- else if (ts10.isObjectBindingPattern(name2)) name2.elements.forEach((e) => addBindingNames2(e.name, out));
8003
- else if (ts10.isArrayBindingPattern(name2)) name2.elements.forEach((e) => {
8004
- if (!ts10.isOmittedExpression(e)) addBindingNames2(e.name, out);
8142
+ if (ts11.isIdentifier(name2)) out.push(name2.text);
8143
+ else if (ts11.isObjectBindingPattern(name2)) name2.elements.forEach((e) => addBindingNames2(e.name, out));
8144
+ else if (ts11.isArrayBindingPattern(name2)) name2.elements.forEach((e) => {
8145
+ if (!ts11.isOmittedExpression(e)) addBindingNames2(e.name, out);
8005
8146
  });
8006
8147
  }
8007
8148
  function visit3(n) {
8008
- if (ts10.isTypeNode(n)) return;
8009
- if (ts10.isIdentifier(n)) {
8149
+ if (ts11.isTypeNode(n)) return;
8150
+ if (ts11.isIdentifier(n)) {
8010
8151
  const parent2 = n.parent;
8011
- if (parent2 && ts10.isPropertyAccessExpression(parent2) && parent2.name === n) return;
8012
- if (parent2 && ts10.isPropertyAssignment(parent2) && parent2.name === n) return;
8013
- if (parent2 && ts10.isParameter(parent2) && parent2.name === n) return;
8014
- if (parent2 && ts10.isVariableDeclaration(parent2) && parent2.name === n) return;
8152
+ if (parent2 && ts11.isPropertyAccessExpression(parent2) && parent2.name === n) return;
8153
+ if (parent2 && ts11.isPropertyAssignment(parent2) && parent2.name === n) return;
8154
+ if (parent2 && ts11.isParameter(parent2) && parent2.name === n) return;
8155
+ if (parent2 && ts11.isVariableDeclaration(parent2) && parent2.name === n) return;
8015
8156
  if (boundNames.has(n.text)) return;
8016
8157
  ids.add(n.text);
8017
8158
  return;
8018
8159
  }
8019
- if (ts10.isArrowFunction(n)) {
8160
+ if (ts11.isArrowFunction(n)) {
8020
8161
  const params = [];
8021
8162
  for (const p of n.parameters) addBindingNames2(p.name, params);
8022
8163
  for (const name2 of params) boundNames.add(name2);
8023
- ts10.forEachChild(n, visit3);
8164
+ ts11.forEachChild(n, visit3);
8024
8165
  for (const name2 of params) boundNames.delete(name2);
8025
8166
  return;
8026
8167
  }
8027
- ts10.forEachChild(n, visit3);
8168
+ ts11.forEachChild(n, visit3);
8028
8169
  }
8029
8170
  visit3(node);
8030
8171
  return ids;
@@ -8033,25 +8174,25 @@ function extractFreeTypeIdentifiersFromNode(node) {
8033
8174
  const ids = /* @__PURE__ */ new Set();
8034
8175
  const boundTypeParams = /* @__PURE__ */ new Set();
8035
8176
  function rootName(name2) {
8036
- return ts10.isQualifiedName(name2) ? rootName(name2.left) : name2;
8177
+ return ts11.isQualifiedName(name2) ? rootName(name2.left) : name2;
8037
8178
  }
8038
8179
  function visit3(n) {
8039
- if (ts10.isTypeReferenceNode(n)) {
8180
+ if (ts11.isTypeReferenceNode(n)) {
8040
8181
  const name2 = rootName(n.typeName).text;
8041
8182
  if (!boundTypeParams.has(name2)) ids.add(name2);
8042
8183
  }
8043
- if (ts10.isTypeQueryNode(n)) {
8184
+ if (ts11.isTypeQueryNode(n)) {
8044
8185
  const name2 = rootName(n.exprName).text;
8045
8186
  if (!boundTypeParams.has(name2)) ids.add(name2);
8046
8187
  }
8047
- if (ts10.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
8188
+ if (ts11.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
8048
8189
  const names = n.typeParameters.map((p) => p.name.text);
8049
8190
  for (const p of names) boundTypeParams.add(p);
8050
- ts10.forEachChild(n, visit3);
8191
+ ts11.forEachChild(n, visit3);
8051
8192
  for (const p of names) boundTypeParams.delete(p);
8052
8193
  return;
8053
8194
  }
8054
- ts10.forEachChild(n, visit3);
8195
+ ts11.forEachChild(n, visit3);
8055
8196
  }
8056
8197
  visit3(node);
8057
8198
  return ids;
@@ -8060,30 +8201,30 @@ function initializerShapeContainsJsx(node) {
8060
8201
  let found = false;
8061
8202
  function visit3(n) {
8062
8203
  if (found) return;
8063
- if (ts10.isJsxElement(n) || ts10.isJsxSelfClosingElement(n) || ts10.isJsxFragment(n)) {
8204
+ if (ts11.isJsxElement(n) || ts11.isJsxSelfClosingElement(n) || ts11.isJsxFragment(n)) {
8064
8205
  found = true;
8065
8206
  return;
8066
8207
  }
8067
- if (ts10.isFunctionDeclaration(n) || ts10.isFunctionExpression(n) || ts10.isArrowFunction(n)) {
8208
+ if (ts11.isFunctionDeclaration(n) || ts11.isFunctionExpression(n) || ts11.isArrowFunction(n)) {
8068
8209
  return;
8069
8210
  }
8070
- ts10.forEachChild(n, visit3);
8211
+ ts11.forEachChild(n, visit3);
8071
8212
  }
8072
8213
  visit3(node);
8073
8214
  return found;
8074
8215
  }
8075
8216
  function isMapLikeCallWithJsx(node) {
8076
- if (!ts10.isCallExpression(node)) return false;
8077
- if (!ts10.isPropertyAccessExpression(node.expression)) return false;
8217
+ if (!ts11.isCallExpression(node)) return false;
8218
+ if (!ts11.isPropertyAccessExpression(node.expression)) return false;
8078
8219
  const method2 = node.expression.name.text;
8079
8220
  if (method2 !== "map" && method2 !== "flatMap") return false;
8080
8221
  const callback = node.arguments[0];
8081
8222
  if (!callback) return false;
8082
- if (!ts10.isArrowFunction(callback) && !ts10.isFunctionExpression(callback)) return false;
8223
+ if (!ts11.isArrowFunction(callback) && !ts11.isFunctionExpression(callback)) return false;
8083
8224
  return containsJsxDeep(callback.body);
8084
8225
  }
8085
8226
  function containsJsxDeep(node) {
8086
- if (ts10.isJsxElement(node) || ts10.isJsxSelfClosingElement(node) || ts10.isJsxFragment(node)) return true;
8227
+ if (ts11.isJsxElement(node) || ts11.isJsxSelfClosingElement(node) || ts11.isJsxFragment(node)) return true;
8087
8228
  let found = false;
8088
8229
  node.forEachChild((child) => {
8089
8230
  if (!found) found = containsJsxDeep(child);
@@ -8094,11 +8235,11 @@ function nodeContainsArrow(node) {
8094
8235
  let found = false;
8095
8236
  function visit3(n) {
8096
8237
  if (found) return;
8097
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n)) {
8238
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n)) {
8098
8239
  found = true;
8099
8240
  return;
8100
8241
  }
8101
- ts10.forEachChild(n, visit3);
8242
+ ts11.forEachChild(n, visit3);
8102
8243
  }
8103
8244
  visit3(node);
8104
8245
  return found;
@@ -8143,17 +8284,17 @@ function collectModuleScopeReactive(decl, ctx2, isExported) {
8143
8284
  ));
8144
8285
  }
8145
8286
  function getSystemConstructKind(node) {
8146
- if (ts10.isCallExpression(node) && ts10.isIdentifier(node.expression) && node.expression.text === "createContext") return "createContext";
8147
- if (ts10.isNewExpression(node) && ts10.isIdentifier(node.expression) && node.expression.text === "WeakMap") return "weakMap";
8287
+ if (ts11.isCallExpression(node) && ts11.isIdentifier(node.expression) && node.expression.text === "createContext") return "createContext";
8288
+ if (ts11.isNewExpression(node) && ts11.isIdentifier(node.expression) && node.expression.text === "WeakMap") return "weakMap";
8148
8289
  return void 0;
8149
8290
  }
8150
8291
  function collectConstant(node, ctx2, _isModule, declarationKind = "const", isExported = false) {
8151
- if (!_isModule && ts10.isObjectBindingPattern(node.name) && node.initializer && ts10.isIdentifier(node.initializer) && ctx2.propsObjectName === node.initializer.text) {
8292
+ if (!_isModule && ts11.isObjectBindingPattern(node.name) && node.initializer && ts11.isIdentifier(node.initializer) && ctx2.propsObjectName === node.initializer.text) {
8152
8293
  const propsName = node.initializer.text;
8153
8294
  for (const el of node.name.elements) {
8154
- if (!ts10.isBindingElement(el) || !ts10.isIdentifier(el.name) || el.dotDotDotToken) continue;
8295
+ if (!ts11.isBindingElement(el) || !ts11.isIdentifier(el.name) || el.dotDotDotToken) continue;
8155
8296
  const localName2 = el.name.text;
8156
- const sourceKey = el.propertyName && ts10.isIdentifier(el.propertyName) ? el.propertyName.text : localName2;
8297
+ const sourceKey = el.propertyName && ts11.isIdentifier(el.propertyName) ? el.propertyName.text : localName2;
8157
8298
  const defaultValueExpr = el.initializer ? ctx2.getJS(el.initializer) : void 0;
8158
8299
  const baseValue = `${propsName}.${sourceKey}`;
8159
8300
  const value3 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
@@ -8177,7 +8318,7 @@ function collectConstant(node, ctx2, _isModule, declarationKind = "const", isExp
8177
8318
  }
8178
8319
  return;
8179
8320
  }
8180
- if (!ts10.isIdentifier(node.name)) return;
8321
+ if (!ts11.isIdentifier(node.name)) return;
8181
8322
  if (isSignalDeclaration(node, ctx2) || isMemoDeclaration(node, ctx2)) return;
8182
8323
  if (isSignalTupleDeclaration(node)) return;
8183
8324
  if (isSignalIndexAccess(node, ctx2) !== null) return;
@@ -8190,8 +8331,8 @@ function collectConstant(node, ctx2, _isModule, declarationKind = "const", isExp
8190
8331
  let isJsxFunction = false;
8191
8332
  if (node.initializer) {
8192
8333
  let init = node.initializer;
8193
- while (ts10.isParenthesizedExpression(init)) init = init.expression;
8194
- if (ts10.isJsxElement(init) || ts10.isJsxSelfClosingElement(init) || ts10.isJsxFragment(init)) {
8334
+ while (ts11.isParenthesizedExpression(init)) init = init.expression;
8335
+ if (ts11.isJsxElement(init) || ts11.isJsxSelfClosingElement(init) || ts11.isJsxFragment(init)) {
8195
8336
  isJsx = true;
8196
8337
  ctx2.jsxConstants.set(name2, init);
8197
8338
  } else if (initializerShapeContainsJsx(init)) {
@@ -8199,9 +8340,9 @@ function collectConstant(node, ctx2, _isModule, declarationKind = "const", isExp
8199
8340
  } else if (isMapLikeCallWithJsx(init)) {
8200
8341
  ctx2.inlineableJsxConsts.set(name2, init);
8201
8342
  }
8202
- if (ts10.isArrowFunction(init)) {
8343
+ if (ts11.isArrowFunction(init)) {
8203
8344
  const arrowBody = init.body;
8204
- if (ts10.isBlock(arrowBody)) {
8345
+ if (ts11.isBlock(arrowBody)) {
8205
8346
  const jsxReturn = extractSingleJsxReturn(arrowBody);
8206
8347
  if (jsxReturn) {
8207
8348
  isJsxFunction = true;
@@ -8221,8 +8362,8 @@ function collectConstant(node, ctx2, _isModule, declarationKind = "const", isExp
8221
8362
  }
8222
8363
  } else {
8223
8364
  let body2 = arrowBody;
8224
- while (ts10.isParenthesizedExpression(body2)) body2 = body2.expression;
8225
- if (ts10.isJsxElement(body2) || ts10.isJsxSelfClosingElement(body2) || ts10.isJsxFragment(body2)) {
8365
+ while (ts11.isParenthesizedExpression(body2)) body2 = body2.expression;
8366
+ if (ts11.isJsxElement(body2) || ts11.isJsxSelfClosingElement(body2) || ts11.isJsxFragment(body2)) {
8226
8367
  isJsxFunction = true;
8227
8368
  ctx2.jsxFunctions.set(name2, {
8228
8369
  jsxReturn: body2,
@@ -8235,8 +8376,8 @@ function collectConstant(node, ctx2, _isModule, declarationKind = "const", isExp
8235
8376
  let valueBranches;
8236
8377
  if (node.initializer) {
8237
8378
  let inner = node.initializer;
8238
- while (ts10.isParenthesizedExpression(inner)) inner = inner.expression;
8239
- if (ts10.isConditionalExpression(inner)) {
8379
+ while (ts11.isParenthesizedExpression(inner)) inner = inner.expression;
8380
+ if (ts11.isConditionalExpression(inner)) {
8240
8381
  valueBranches = extractValueBranches(node.initializer, ctx2);
8241
8382
  }
8242
8383
  }
@@ -8312,7 +8453,7 @@ function collectConstant(node, ctx2, _isModule, declarationKind = "const", isExp
8312
8453
  function hasIgnoreDirective(node, sourceFile, ruleId) {
8313
8454
  const checkComments = (targetNode) => {
8314
8455
  const fullStart = targetNode.getFullStart();
8315
- const leadingComments = ts10.getLeadingCommentRanges(
8456
+ const leadingComments = ts11.getLeadingCommentRanges(
8316
8457
  sourceFile.getFullText(),
8317
8458
  fullStart
8318
8459
  );
@@ -8326,10 +8467,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
8326
8467
  return false;
8327
8468
  };
8328
8469
  if (checkComments(node)) return true;
8329
- if (ts10.isArrowFunction(node)) {
8470
+ if (ts11.isArrowFunction(node)) {
8330
8471
  let current = node.parent;
8331
8472
  while (current) {
8332
- if (ts10.isVariableStatement(current)) {
8473
+ if (ts11.isVariableStatement(current)) {
8333
8474
  if (checkComments(current)) return true;
8334
8475
  break;
8335
8476
  }
@@ -8339,7 +8480,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
8339
8480
  return false;
8340
8481
  }
8341
8482
  function extractProps(param, ctx2) {
8342
- if (ts10.isObjectBindingPattern(param.name)) {
8483
+ if (ts11.isObjectBindingPattern(param.name)) {
8343
8484
  const componentNode = ctx2.componentNode;
8344
8485
  const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx2.sourceFile, "props-destructuring"));
8345
8486
  ctx2.propsDestructuring = {
@@ -8348,14 +8489,14 @@ function extractProps(param, ctx2) {
8348
8489
  };
8349
8490
  const memberTypes = param.type ? collectMemberTypes(param.type, ctx2) : null;
8350
8491
  for (const element2 of param.name.elements) {
8351
- if (ts10.isBindingElement(element2) && ts10.isIdentifier(element2.name)) {
8492
+ if (ts11.isBindingElement(element2) && ts11.isIdentifier(element2.name)) {
8352
8493
  const localName2 = element2.name.text;
8353
8494
  const defaultValue2 = element2.initializer ? ctx2.getJS(element2.initializer) : void 0;
8354
8495
  if (element2.dotDotDotToken) {
8355
8496
  ctx2.restPropsName = localName2;
8356
8497
  continue;
8357
8498
  }
8358
- const sourcePropName = element2.propertyName && ts10.isIdentifier(element2.propertyName) ? element2.propertyName.text : localName2;
8499
+ const sourcePropName = element2.propertyName && ts11.isIdentifier(element2.propertyName) ? element2.propertyName.text : localName2;
8359
8500
  const member = memberTypes?.get(sourcePropName);
8360
8501
  const resolvedType = member?.type ?? { kind: "unknown", raw: "unknown" };
8361
8502
  const defaultContainsArrow = element2.initializer ? nodeContainsArrow(element2.initializer) : false;
@@ -8382,7 +8523,7 @@ function extractProps(param, ctx2) {
8382
8523
  }
8383
8524
  }
8384
8525
  }
8385
- if (ts10.isIdentifier(param.name)) {
8526
+ if (ts11.isIdentifier(param.name)) {
8386
8527
  ctx2.propsObjectName = param.name.text;
8387
8528
  if (param.type) {
8388
8529
  extractPropsFromType(param.type, ctx2);
@@ -8393,22 +8534,22 @@ function extractProps(param, ctx2) {
8393
8534
  }
8394
8535
  }
8395
8536
  function collectTypeKeys(typeNode, ctx2) {
8396
- if (ts10.isTypeLiteralNode(typeNode)) {
8537
+ if (ts11.isTypeLiteralNode(typeNode)) {
8397
8538
  return collectKeysFromMembers(typeNode.members, ctx2);
8398
8539
  }
8399
- if (ts10.isTypeReferenceNode(typeNode)) {
8540
+ if (ts11.isTypeReferenceNode(typeNode)) {
8400
8541
  const typeName = typeNode.typeName.getText(ctx2.sourceFile);
8401
8542
  const typeDecl = findTypeDeclaration(typeName, ctx2.sourceFile);
8402
8543
  if (!typeDecl) return null;
8403
- if (ts10.isInterfaceDeclaration(typeDecl)) {
8544
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
8404
8545
  if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0) return null;
8405
8546
  return collectKeysFromMembers(typeDecl.members, ctx2);
8406
8547
  }
8407
- if (ts10.isTypeAliasDeclaration(typeDecl)) {
8408
- if (ts10.isTypeLiteralNode(typeDecl.type)) {
8548
+ if (ts11.isTypeAliasDeclaration(typeDecl)) {
8549
+ if (ts11.isTypeLiteralNode(typeDecl.type)) {
8409
8550
  return collectKeysFromMembers(typeDecl.type.members, ctx2);
8410
8551
  }
8411
- if (ts10.isIntersectionTypeNode(typeDecl.type)) {
8552
+ if (ts11.isIntersectionTypeNode(typeDecl.type)) {
8412
8553
  return null;
8413
8554
  }
8414
8555
  }
@@ -8418,8 +8559,8 @@ function collectTypeKeys(typeNode, ctx2) {
8418
8559
  function collectKeysFromMembers(members, ctx2) {
8419
8560
  const keys = [];
8420
8561
  for (const member of members) {
8421
- if (ts10.isIndexSignatureDeclaration(member)) return null;
8422
- if (ts10.isPropertySignature(member) && member.name) {
8562
+ if (ts11.isIndexSignatureDeclaration(member)) return null;
8563
+ if (ts11.isPropertySignature(member) && member.name) {
8423
8564
  keys.push(member.name.getText(ctx2.sourceFile));
8424
8565
  }
8425
8566
  }
@@ -8444,7 +8585,7 @@ function collectMemberTypes(typeNode, ctx2) {
8444
8585
  const fromMembers = (members) => {
8445
8586
  const map = /* @__PURE__ */ new Map();
8446
8587
  for (const member of members) {
8447
- if (ts10.isPropertySignature(member) && member.name) {
8588
+ if (ts11.isPropertySignature(member) && member.name) {
8448
8589
  const info = member.type ? typeNodeToTypeInfo(member.type, ctx2.sourceFile) : null;
8449
8590
  map.set(member.name.getText(ctx2.sourceFile), {
8450
8591
  type: info && isResolvableMemberType(info) ? info : null,
@@ -8454,34 +8595,34 @@ function collectMemberTypes(typeNode, ctx2) {
8454
8595
  }
8455
8596
  return map;
8456
8597
  };
8457
- if (ts10.isTypeLiteralNode(typeNode)) {
8598
+ if (ts11.isTypeLiteralNode(typeNode)) {
8458
8599
  return fromMembers(typeNode.members);
8459
8600
  }
8460
- if (ts10.isTypeReferenceNode(typeNode)) {
8601
+ if (ts11.isTypeReferenceNode(typeNode)) {
8461
8602
  const typeName = typeNode.typeName.getText(ctx2.sourceFile);
8462
8603
  const typeDecl = findTypeDeclaration(typeName, ctx2.sourceFile);
8463
8604
  if (!typeDecl) return null;
8464
- if (ts10.isInterfaceDeclaration(typeDecl)) {
8605
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
8465
8606
  return fromMembers(typeDecl.members);
8466
8607
  }
8467
- if (ts10.isTypeAliasDeclaration(typeDecl) && ts10.isTypeLiteralNode(typeDecl.type)) {
8608
+ if (ts11.isTypeAliasDeclaration(typeDecl) && ts11.isTypeLiteralNode(typeDecl.type)) {
8468
8609
  return fromMembers(typeDecl.type.members);
8469
8610
  }
8470
8611
  }
8471
8612
  return null;
8472
8613
  }
8473
8614
  function extractPropsFromType(typeNode, ctx2) {
8474
- if (ts10.isTypeLiteralNode(typeNode)) {
8615
+ if (ts11.isTypeLiteralNode(typeNode)) {
8475
8616
  extractPropsFromTypeMembers(typeNode.members, ctx2);
8476
8617
  return;
8477
8618
  }
8478
- if (ts10.isTypeReferenceNode(typeNode)) {
8619
+ if (ts11.isTypeReferenceNode(typeNode)) {
8479
8620
  const typeName = typeNode.typeName.getText(ctx2.sourceFile);
8480
8621
  const typeDecl = findTypeDeclaration(typeName, ctx2.sourceFile);
8481
8622
  if (typeDecl) {
8482
- if (ts10.isInterfaceDeclaration(typeDecl)) {
8623
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
8483
8624
  extractPropsFromTypeMembers(typeDecl.members, ctx2);
8484
- } else if (ts10.isTypeAliasDeclaration(typeDecl) && ts10.isTypeLiteralNode(typeDecl.type)) {
8625
+ } else if (ts11.isTypeAliasDeclaration(typeDecl) && ts11.isTypeLiteralNode(typeDecl.type)) {
8485
8626
  extractPropsFromTypeMembers(typeDecl.type.members, ctx2);
8486
8627
  }
8487
8628
  }
@@ -8489,7 +8630,7 @@ function extractPropsFromType(typeNode, ctx2) {
8489
8630
  }
8490
8631
  function extractPropsFromTypeMembers(members, ctx2) {
8491
8632
  for (const member of members) {
8492
- if (ts10.isPropertySignature(member) && member.name) {
8633
+ if (ts11.isPropertySignature(member) && member.name) {
8493
8634
  const propName = member.name.getText(ctx2.sourceFile);
8494
8635
  const isOptional = !!member.questionToken;
8495
8636
  const propType = member.type ? typeNodeToTypeInfo(member.type, ctx2.sourceFile) : { kind: "unknown", raw: "unknown" };
@@ -8505,17 +8646,17 @@ function extractPropsFromTypeMembers(members, ctx2) {
8505
8646
  function findTypeDeclaration(typeName, sourceFile) {
8506
8647
  let result2;
8507
8648
  function visit3(node) {
8508
- if (ts10.isInterfaceDeclaration(node) && node.name.text === typeName) {
8649
+ if (ts11.isInterfaceDeclaration(node) && node.name.text === typeName) {
8509
8650
  result2 = node;
8510
8651
  return;
8511
8652
  }
8512
- if (ts10.isTypeAliasDeclaration(node) && node.name.text === typeName) {
8653
+ if (ts11.isTypeAliasDeclaration(node) && node.name.text === typeName) {
8513
8654
  result2 = node;
8514
8655
  return;
8515
8656
  }
8516
- ts10.forEachChild(node, visit3);
8657
+ ts11.forEachChild(node, visit3);
8517
8658
  }
8518
- ts10.forEachChild(sourceFile, visit3);
8659
+ ts11.forEachChild(sourceFile, visit3);
8519
8660
  return result2;
8520
8661
  }
8521
8662
  function inferTypeFromValue(value2) {
@@ -8561,12 +8702,12 @@ function inferTypeFromValue(value2) {
8561
8702
  }
8562
8703
  function collectCalledIdentifiers(code) {
8563
8704
  const called = /* @__PURE__ */ new Set();
8564
- const sf = ts10.createSourceFile("__deps__.tsx", code, ts10.ScriptTarget.Latest, false, ts10.ScriptKind.TSX);
8705
+ const sf = ts11.createSourceFile("__deps__.tsx", code, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
8565
8706
  const visit3 = (node) => {
8566
- if (ts10.isCallExpression(node) && ts10.isIdentifier(node.expression)) {
8707
+ if (ts11.isCallExpression(node) && ts11.isIdentifier(node.expression)) {
8567
8708
  called.add(node.expression.text);
8568
8709
  }
8569
- ts10.forEachChild(node, visit3);
8710
+ ts11.forEachChild(node, visit3);
8570
8711
  };
8571
8712
  visit3(sf);
8572
8713
  return called;
@@ -8659,16 +8800,16 @@ function isResolvableComponentSource(source) {
8659
8800
  function collectJsxComponentTags(sourceFile) {
8660
8801
  const tags = /* @__PURE__ */ new Set();
8661
8802
  function visit3(node) {
8662
- if (ts10.isJsxOpeningElement(node) || ts10.isJsxSelfClosingElement(node)) {
8803
+ if (ts11.isJsxOpeningElement(node) || ts11.isJsxSelfClosingElement(node)) {
8663
8804
  const tagName2 = node.tagName;
8664
- if (ts10.isIdentifier(tagName2)) {
8805
+ if (ts11.isIdentifier(tagName2)) {
8665
8806
  const first = tagName2.text.charAt(0);
8666
8807
  if (first >= "A" && first <= "Z") {
8667
8808
  tags.add(tagName2.text);
8668
8809
  }
8669
8810
  }
8670
8811
  }
8671
- ts10.forEachChild(node, visit3);
8812
+ ts11.forEachChild(node, visit3);
8672
8813
  }
8673
8814
  visit3(sourceFile);
8674
8815
  return tags;
@@ -8737,23 +8878,23 @@ function fileHasUseClientDirective(filePath) {
8737
8878
  } catch {
8738
8879
  return true;
8739
8880
  }
8740
- const sf = ts10.createSourceFile(
8881
+ const sf = ts11.createSourceFile(
8741
8882
  filePath,
8742
8883
  content2,
8743
- ts10.ScriptTarget.Latest,
8884
+ ts11.ScriptTarget.Latest,
8744
8885
  false,
8745
- ts10.ScriptKind.TSX
8886
+ ts11.ScriptKind.TSX
8746
8887
  );
8747
8888
  let found = false;
8748
8889
  function visit3(node) {
8749
8890
  if (found) return;
8750
- if (ts10.isExpressionStatement(node) && ts10.isStringLiteral(node.expression)) {
8891
+ if (ts11.isExpressionStatement(node) && ts11.isStringLiteral(node.expression)) {
8751
8892
  if (node.expression.text === "use client") {
8752
8893
  found = true;
8753
8894
  return;
8754
8895
  }
8755
8896
  }
8756
- ts10.forEachChild(node, visit3);
8897
+ ts11.forEachChild(node, visit3);
8757
8898
  }
8758
8899
  visit3(sf);
8759
8900
  return found;
@@ -8809,22 +8950,22 @@ function importsBrowserOnlyClientApi(ctx2) {
8809
8950
  return false;
8810
8951
  }
8811
8952
  function listComponentFunctions(source, filePath) {
8812
- const sourceFile = ts10.createSourceFile(
8953
+ const sourceFile = ts11.createSourceFile(
8813
8954
  filePath,
8814
8955
  source,
8815
- ts10.ScriptTarget.Latest,
8956
+ ts11.ScriptTarget.Latest,
8816
8957
  true,
8817
- ts10.ScriptKind.TSX
8958
+ ts11.ScriptKind.TSX
8818
8959
  );
8819
8960
  return listComponentFunctionsFromSourceFile(sourceFile);
8820
8961
  }
8821
8962
  function scanComponentFile(source, filePath) {
8822
- const sourceFile = ts10.createSourceFile(
8963
+ const sourceFile = ts11.createSourceFile(
8823
8964
  filePath,
8824
8965
  source,
8825
- ts10.ScriptTarget.Latest,
8966
+ ts11.ScriptTarget.Latest,
8826
8967
  true,
8827
- ts10.ScriptKind.TSX
8968
+ ts11.ScriptKind.TSX
8828
8969
  );
8829
8970
  return {
8830
8971
  exports: listComponentFunctionsFromSourceFile(sourceFile),
@@ -8834,12 +8975,12 @@ function scanComponentFile(source, filePath) {
8834
8975
  function listComponentFunctionsFromSourceFile(sourceFile) {
8835
8976
  const componentNames = [];
8836
8977
  const hasUseClient = sourceFile.statements.some(
8837
- (stmt) => ts10.isExpressionStatement(stmt) && ts10.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'")
8978
+ (stmt) => ts11.isExpressionStatement(stmt) && ts11.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'")
8838
8979
  );
8839
8980
  const namedExports = collectNamedExports(sourceFile);
8840
8981
  function collectComponents(node) {
8841
8982
  if (isComponentFunction(node)) {
8842
- const hasInlineExport = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
8983
+ const hasInlineExport = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
8843
8984
  const hasNamedExport = namedExports.has(node.name.text);
8844
8985
  const isExported = hasInlineExport || hasNamedExport;
8845
8986
  if (!hasUseClient && !isExported && node.body && isMultiReturnJsxFunctionBody(node.body)) {
@@ -8850,25 +8991,25 @@ function listComponentFunctionsFromSourceFile(sourceFile) {
8850
8991
  if (isArrowComponentFunction(node)) {
8851
8992
  componentNames.push(node.name.text);
8852
8993
  }
8853
- ts10.forEachChild(node, collectComponents);
8994
+ ts11.forEachChild(node, collectComponents);
8854
8995
  }
8855
- ts10.forEachChild(sourceFile, collectComponents);
8996
+ ts11.forEachChild(sourceFile, collectComponents);
8856
8997
  return componentNames;
8857
8998
  }
8858
8999
  function prescanReactiveFactoriesInSource(source, filePath) {
8859
- const sourceFile = ts10.createSourceFile(
9000
+ const sourceFile = ts11.createSourceFile(
8860
9001
  filePath + ".prescan",
8861
9002
  source,
8862
- ts10.ScriptTarget.Latest,
9003
+ ts11.ScriptTarget.Latest,
8863
9004
  true,
8864
- ts10.ScriptKind.TSX
9005
+ ts11.ScriptKind.TSX
8865
9006
  );
8866
9007
  const factories = /* @__PURE__ */ new Map();
8867
9008
  const declined = /* @__PURE__ */ new Map();
8868
9009
  const reactiveShaped = /* @__PURE__ */ new Set();
8869
9010
  const cleanFactoryImports = /* @__PURE__ */ new Set();
8870
9011
  function visitTop(node) {
8871
- if (ts10.isFunctionDeclaration(node) && node.name && node.body) {
9012
+ if (ts11.isFunctionDeclaration(node) && node.name && node.body) {
8872
9013
  const det = detectReactiveFactory(node, sourceFile, filePath);
8873
9014
  if (!det) return;
8874
9015
  switch (det.kind) {
@@ -8884,7 +9025,7 @@ function prescanReactiveFactoriesInSource(source, filePath) {
8884
9025
  }
8885
9026
  }
8886
9027
  }
8887
- ts10.forEachChild(sourceFile, visitTop);
9028
+ ts11.forEachChild(sourceFile, visitTop);
8888
9029
  const result2 = { factories, declined, reactiveShaped, cleanFactoryImports, sourceFile };
8889
9030
  prescanImportedReactiveFactories(sourceFile, filePath, result2);
8890
9031
  return result2;
@@ -8899,13 +9040,13 @@ function toComponentRelativeSpecifier(resolvedAbs, componentFilePath) {
8899
9040
  function buildEntryImportIndex(sf, filePath) {
8900
9041
  const index = /* @__PURE__ */ new Map();
8901
9042
  for (const stmt of sf.statements) {
8902
- if (!ts10.isImportDeclaration(stmt)) continue;
8903
- if (!ts10.isStringLiteral(stmt.moduleSpecifier)) continue;
9043
+ if (!ts11.isImportDeclaration(stmt)) continue;
9044
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier)) continue;
8904
9045
  const src = stmt.moduleSpecifier.text;
8905
9046
  const targetKey = src.startsWith("./") || src.startsWith("../") ? resolveRelativeImportToFile(src, filePath) ?? "unresolved:" + src : src;
8906
9047
  const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
8907
9048
  const namedBindings = stmt.importClause?.namedBindings;
8908
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
9049
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8909
9050
  for (const el of namedBindings.elements) {
8910
9051
  index.set(el.name.text, {
8911
9052
  targetKey,
@@ -8920,35 +9061,35 @@ function buildEntryImportIndex(sf, filePath) {
8920
9061
  function collectEntryBindingNames(sf) {
8921
9062
  const names = /* @__PURE__ */ new Set();
8922
9063
  function visit3(node) {
8923
- if (ts10.isImportDeclaration(node) && node.importClause) {
9064
+ if (ts11.isImportDeclaration(node) && node.importClause) {
8924
9065
  if (node.importClause.name) names.add(node.importClause.name.text);
8925
9066
  const namedBindings = node.importClause.namedBindings;
8926
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
9067
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8927
9068
  for (const el of namedBindings.elements) names.add(el.name.text);
8928
9069
  }
8929
- if (namedBindings && ts10.isNamespaceImport(namedBindings)) {
9070
+ if (namedBindings && ts11.isNamespaceImport(namedBindings)) {
8930
9071
  names.add(namedBindings.name.text);
8931
9072
  }
8932
9073
  }
8933
- if (ts10.isVariableDeclaration(node)) {
9074
+ if (ts11.isVariableDeclaration(node)) {
8934
9075
  const out = [];
8935
9076
  addBindingNames(node.name, out);
8936
9077
  for (const n of out) names.add(n);
8937
9078
  }
8938
- if ((ts10.isFunctionDeclaration(node) || ts10.isClassDeclaration(node) || ts10.isEnumDeclaration(node)) && node.name) {
9079
+ if ((ts11.isFunctionDeclaration(node) || ts11.isClassDeclaration(node) || ts11.isEnumDeclaration(node)) && node.name) {
8939
9080
  names.add(node.name.text);
8940
9081
  }
8941
- if ((ts10.isTypeAliasDeclaration(node) || ts10.isInterfaceDeclaration(node)) && node.name) {
9082
+ if ((ts11.isTypeAliasDeclaration(node) || ts11.isInterfaceDeclaration(node)) && node.name) {
8942
9083
  names.add(node.name.text);
8943
9084
  }
8944
- if (ts10.isFunctionLike(node)) {
9085
+ if (ts11.isFunctionLike(node)) {
8945
9086
  for (const p of node.parameters) {
8946
9087
  const out = [];
8947
9088
  addBindingNames(p.name, out);
8948
9089
  for (const n of out) names.add(n);
8949
9090
  }
8950
9091
  }
8951
- ts10.forEachChild(node, visit3);
9092
+ ts11.forEachChild(node, visit3);
8952
9093
  }
8953
9094
  visit3(sf);
8954
9095
  return names;
@@ -8956,22 +9097,22 @@ function collectEntryBindingNames(sf) {
8956
9097
  function prescanImportedReactiveFactories(entrySourceFile, filePath, result2) {
8957
9098
  const candidateCallees = /* @__PURE__ */ new Set();
8958
9099
  function collectCandidates(node) {
8959
- if (ts10.isVariableDeclaration(node) && (ts10.isArrayBindingPattern(node.name) || ts10.isObjectBindingPattern(node.name)) && node.initializer && ts10.isCallExpression(node.initializer) && ts10.isIdentifier(node.initializer.expression)) {
9100
+ if (ts11.isVariableDeclaration(node) && (ts11.isArrayBindingPattern(node.name) || ts11.isObjectBindingPattern(node.name)) && node.initializer && ts11.isCallExpression(node.initializer) && ts11.isIdentifier(node.initializer.expression)) {
8960
9101
  candidateCallees.add(node.initializer.expression.text);
8961
9102
  }
8962
- ts10.forEachChild(node, collectCandidates);
9103
+ ts11.forEachChild(node, collectCandidates);
8963
9104
  }
8964
9105
  collectCandidates(entrySourceFile);
8965
9106
  if (candidateCallees.size === 0) return;
8966
9107
  const importsToCheck = [];
8967
9108
  for (const stmt of entrySourceFile.statements) {
8968
- if (!ts10.isImportDeclaration(stmt)) continue;
8969
- if (!ts10.isStringLiteral(stmt.moduleSpecifier)) continue;
9109
+ if (!ts11.isImportDeclaration(stmt)) continue;
9110
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier)) continue;
8970
9111
  const src = stmt.moduleSpecifier.text;
8971
9112
  if (!src.startsWith("./") && !src.startsWith("../")) continue;
8972
9113
  if (stmt.importClause?.isTypeOnly) continue;
8973
9114
  const namedBindings = stmt.importClause?.namedBindings;
8974
- if (!namedBindings || !ts10.isNamedImports(namedBindings)) continue;
9115
+ if (!namedBindings || !ts11.isNamedImports(namedBindings)) continue;
8975
9116
  const specs = [];
8976
9117
  for (const el of namedBindings.elements) {
8977
9118
  if (el.isTypeOnly) continue;
@@ -9003,14 +9144,14 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result2) {
9003
9144
  helperCache.set(abs, "clean");
9004
9145
  return "clean";
9005
9146
  }
9006
- const sf = ts10.createSourceFile(abs + ".prescan", content2, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
9147
+ const sf = ts11.createSourceFile(abs + ".prescan", content2, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
9007
9148
  const localFns = /* @__PURE__ */ new Map();
9008
9149
  const exportedFns = /* @__PURE__ */ new Map();
9009
9150
  for (const stmt of sf.statements) {
9010
- if (ts10.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
9151
+ if (ts11.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
9011
9152
  localFns.set(stmt.name.text, stmt);
9012
- const hasExportModifier = stmt.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
9013
- const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword) ?? false;
9153
+ const hasExportModifier = stmt.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
9154
+ const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword) ?? false;
9014
9155
  if (hasExportModifier && !hasDefaultModifier) {
9015
9156
  exportedFns.set(stmt.name.text, stmt);
9016
9157
  }
@@ -9019,9 +9160,9 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result2) {
9019
9160
  const reexports = /* @__PURE__ */ new Map();
9020
9161
  let hasStarReexport = false;
9021
9162
  for (const stmt of sf.statements) {
9022
- if (!ts10.isExportDeclaration(stmt) || stmt.isTypeOnly) continue;
9163
+ if (!ts11.isExportDeclaration(stmt) || stmt.isTypeOnly) continue;
9023
9164
  if (!stmt.moduleSpecifier) {
9024
- if (stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
9165
+ if (stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
9025
9166
  for (const el of stmt.exportClause.elements) {
9026
9167
  if (el.isTypeOnly) continue;
9027
9168
  const fn = localFns.get((el.propertyName ?? el.name).text);
@@ -9030,8 +9171,8 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result2) {
9030
9171
  }
9031
9172
  continue;
9032
9173
  }
9033
- if (!ts10.isStringLiteral(stmt.moduleSpecifier)) continue;
9034
- if (stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
9174
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier)) continue;
9175
+ if (stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
9035
9176
  for (const el of stmt.exportClause.elements) {
9036
9177
  if (el.isTypeOnly) continue;
9037
9178
  reexports.set(el.name.text, {
@@ -9167,7 +9308,7 @@ function collectHelperModuleValueBindings(sf) {
9167
9308
  const importedTypes = /* @__PURE__ */ new Map();
9168
9309
  const imported = /* @__PURE__ */ new Map();
9169
9310
  for (const stmt of sf.statements) {
9170
- if (ts10.isVariableStatement(stmt)) {
9311
+ if (ts11.isVariableStatement(stmt)) {
9171
9312
  const out = [];
9172
9313
  for (const decl of stmt.declarationList.declarations) {
9173
9314
  addBindingNames(decl.name, out);
@@ -9175,29 +9316,29 @@ function collectHelperModuleValueBindings(sf) {
9175
9316
  for (const n of out) local.add(n);
9176
9317
  continue;
9177
9318
  }
9178
- if ((ts10.isFunctionDeclaration(stmt) || ts10.isClassDeclaration(stmt) || ts10.isEnumDeclaration(stmt)) && stmt.name) {
9319
+ if ((ts11.isFunctionDeclaration(stmt) || ts11.isClassDeclaration(stmt) || ts11.isEnumDeclaration(stmt)) && stmt.name) {
9179
9320
  local.add(stmt.name.text);
9180
9321
  continue;
9181
9322
  }
9182
- if ((ts10.isTypeAliasDeclaration(stmt) || ts10.isInterfaceDeclaration(stmt)) && stmt.name) {
9323
+ if ((ts11.isTypeAliasDeclaration(stmt) || ts11.isInterfaceDeclaration(stmt)) && stmt.name) {
9183
9324
  localTypes.add(stmt.name.text);
9184
9325
  continue;
9185
9326
  }
9186
- if (ts10.isImportDeclaration(stmt)) {
9187
- if (!ts10.isStringLiteral(stmt.moduleSpecifier)) continue;
9327
+ if (ts11.isImportDeclaration(stmt)) {
9328
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier)) continue;
9188
9329
  const src = stmt.moduleSpecifier.text;
9189
9330
  if (src === "@barefootjs/client" || src === "@barefootjs/client/runtime") continue;
9190
9331
  const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
9191
9332
  if (stmt.importClause?.name) (wholeTypeOnly ? localTypes : local).add(stmt.importClause.name.text);
9192
9333
  const namedBindings = stmt.importClause?.namedBindings;
9193
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
9334
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
9194
9335
  for (const el of namedBindings.elements) {
9195
9336
  const entry = { source: src, exportedName: (el.propertyName ?? el.name).text };
9196
9337
  if (wholeTypeOnly || el.isTypeOnly) importedTypes.set(el.name.text, entry);
9197
9338
  else imported.set(el.name.text, entry);
9198
9339
  }
9199
9340
  }
9200
- if (namedBindings && ts10.isNamespaceImport(namedBindings)) {
9341
+ if (namedBindings && ts11.isNamespaceImport(namedBindings)) {
9201
9342
  (wholeTypeOnly ? localTypes : local).add(namedBindings.name.text);
9202
9343
  }
9203
9344
  }
@@ -9251,50 +9392,50 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9251
9392
  let hasReactiveCall = false;
9252
9393
  function checkForReactive(n) {
9253
9394
  if (hasReactiveCall) return;
9254
- if (ts10.isCallExpression(n) && ts10.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
9395
+ if (ts11.isCallExpression(n) && ts11.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
9255
9396
  hasReactiveCall = true;
9256
9397
  return;
9257
9398
  }
9258
- ts10.forEachChild(n, checkForReactive);
9399
+ ts11.forEachChild(n, checkForReactive);
9259
9400
  }
9260
9401
  checkForReactive(node.body);
9261
9402
  if (!hasReactiveCall) return null;
9262
9403
  const loc = getSourceLocation(node, sourceFile, filePath);
9263
9404
  let totalReturnCount = 0;
9264
9405
  function countReturns(n) {
9265
- if (ts10.isFunctionLike(n)) return;
9266
- if (ts10.isReturnStatement(n)) {
9406
+ if (ts11.isFunctionLike(n)) return;
9407
+ if (ts11.isReturnStatement(n)) {
9267
9408
  totalReturnCount++;
9268
9409
  return;
9269
9410
  }
9270
- ts10.forEachChild(n, countReturns);
9411
+ ts11.forEachChild(n, countReturns);
9271
9412
  }
9272
- ts10.forEachChild(node.body, countReturns);
9413
+ ts11.forEachChild(node.body, countReturns);
9273
9414
  let returnExpr = null;
9274
9415
  let returnCount = 0;
9275
9416
  for (const stmt of node.body.statements) {
9276
- if (!ts10.isReturnStatement(stmt)) continue;
9417
+ if (!ts11.isReturnStatement(stmt)) continue;
9277
9418
  returnCount++;
9278
9419
  if (!stmt.expression) return { kind: "reactive-shaped" };
9279
9420
  let expr = stmt.expression;
9280
- while (ts10.isParenthesizedExpression(expr)) expr = expr.expression;
9281
- if (ts10.isAsExpression(expr)) expr = expr.expression;
9282
- if (ts10.isTypeAssertionExpression(expr)) expr = expr.expression;
9421
+ while (ts11.isParenthesizedExpression(expr)) expr = expr.expression;
9422
+ if (ts11.isAsExpression(expr)) expr = expr.expression;
9423
+ if (ts11.isTypeAssertionExpression(expr)) expr = expr.expression;
9283
9424
  returnExpr = expr;
9284
9425
  }
9285
9426
  if (totalReturnCount !== 1 || returnCount !== 1 || !returnExpr) return { kind: "reactive-shaped" };
9286
9427
  const returnTupleIdentifiers = [];
9287
9428
  let returnKind;
9288
- if (ts10.isArrayLiteralExpression(returnExpr)) {
9429
+ if (ts11.isArrayLiteralExpression(returnExpr)) {
9289
9430
  returnKind = "tuple";
9290
9431
  for (const el of returnExpr.elements) {
9291
- if (!ts10.isIdentifier(el)) return { kind: "reactive-shaped" };
9432
+ if (!ts11.isIdentifier(el)) return { kind: "reactive-shaped" };
9292
9433
  returnTupleIdentifiers.push(el.text);
9293
9434
  }
9294
9435
  if (returnTupleIdentifiers.length === 0) return { kind: "reactive-shaped" };
9295
- } else if (ts10.isObjectLiteralExpression(returnExpr)) {
9436
+ } else if (ts11.isObjectLiteralExpression(returnExpr)) {
9296
9437
  returnKind = "object";
9297
- const hasNonShorthand = returnExpr.properties.some((p) => !ts10.isShorthandPropertyAssignment(p));
9438
+ const hasNonShorthand = returnExpr.properties.some((p) => !ts11.isShorthandPropertyAssignment(p));
9298
9439
  if (hasNonShorthand) {
9299
9440
  return {
9300
9441
  kind: "declined",
@@ -9314,7 +9455,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9314
9455
  }
9315
9456
  const params = [];
9316
9457
  for (const p of node.parameters) {
9317
- if (ts10.isIdentifier(p.name)) {
9458
+ if (ts11.isIdentifier(p.name)) {
9318
9459
  params.push(p.name.text);
9319
9460
  continue;
9320
9461
  }
@@ -9322,11 +9463,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9322
9463
  }
9323
9464
  const localBindings = [];
9324
9465
  for (const stmt of node.body.statements) {
9325
- if (ts10.isVariableStatement(stmt)) {
9466
+ if (ts11.isVariableStatement(stmt)) {
9326
9467
  for (const decl of stmt.declarationList.declarations) {
9327
9468
  addBindingNames(decl.name, localBindings);
9328
9469
  }
9329
- } else if (ts10.isFunctionDeclaration(stmt) && stmt.name) {
9470
+ } else if (ts11.isFunctionDeclaration(stmt) && stmt.name) {
9330
9471
  localBindings.push(stmt.name.text);
9331
9472
  }
9332
9473
  }
@@ -9345,37 +9486,37 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9345
9486
  function classify3(id2) {
9346
9487
  if (!relevantNames.has(id2.text)) return;
9347
9488
  const p = id2.parent;
9348
- if (ts10.isPropertyAccessExpression(p) && p.name === id2) return;
9349
- if (ts10.isPropertyAssignment(p) && p.name === id2) return;
9350
- if (ts10.isBindingElement(p) && p.propertyName === id2) return;
9351
- if ((ts10.isMethodDeclaration(p) || ts10.isGetAccessorDeclaration(p) || ts10.isSetAccessorDeclaration(p) || ts10.isPropertyDeclaration(p) || ts10.isEnumMember(p)) && p.name === id2) return;
9352
- if (ts10.isJsxAttribute(p) && p.name === id2) return;
9353
- if (ts10.isLabeledStatement(p) && p.label === id2 || (ts10.isBreakStatement(p) || ts10.isContinueStatement(p)) && p.label === id2) return;
9354
- if ((ts10.isJsxOpeningElement(p) || ts10.isJsxSelfClosingElement(p) || ts10.isJsxClosingElement(p)) && p.tagName === id2 && /^[a-z]/.test(id2.text)) return;
9355
- if (ts10.isShorthandPropertyAssignment(p) && p.name === id2) {
9489
+ if (ts11.isPropertyAccessExpression(p) && p.name === id2) return;
9490
+ if (ts11.isPropertyAssignment(p) && p.name === id2) return;
9491
+ if (ts11.isBindingElement(p) && p.propertyName === id2) return;
9492
+ if ((ts11.isMethodDeclaration(p) || ts11.isGetAccessorDeclaration(p) || ts11.isSetAccessorDeclaration(p) || ts11.isPropertyDeclaration(p) || ts11.isEnumMember(p)) && p.name === id2) return;
9493
+ if (ts11.isJsxAttribute(p) && p.name === id2) return;
9494
+ if (ts11.isLabeledStatement(p) && p.label === id2 || (ts11.isBreakStatement(p) || ts11.isContinueStatement(p)) && p.label === id2) return;
9495
+ if ((ts11.isJsxOpeningElement(p) || ts11.isJsxSelfClosingElement(p) || ts11.isJsxClosingElement(p)) && p.tagName === id2 && /^[a-z]/.test(id2.text)) return;
9496
+ if (ts11.isShorthandPropertyAssignment(p) && p.name === id2) {
9356
9497
  push(id2, "shorthand");
9357
9498
  return;
9358
9499
  }
9359
- if (ts10.isBindingElement(p) && p.name === id2 && !p.propertyName && ts10.isObjectBindingPattern(p.parent)) {
9500
+ if (ts11.isBindingElement(p) && p.name === id2 && !p.propertyName && ts11.isObjectBindingPattern(p.parent)) {
9360
9501
  if (params.includes(id2.text)) shadowedParam = id2.text;
9361
9502
  push(id2, "shorthand");
9362
9503
  return;
9363
9504
  }
9364
- const isDecl = (ts10.isVariableDeclaration(p) || ts10.isParameter(p) || ts10.isBindingElement(p) || ts10.isFunctionDeclaration(p) || ts10.isFunctionExpression(p) || ts10.isClassDeclaration(p) || ts10.isClassExpression(p)) && p.name === id2;
9505
+ const isDecl = (ts11.isVariableDeclaration(p) || ts11.isParameter(p) || ts11.isBindingElement(p) || ts11.isFunctionDeclaration(p) || ts11.isFunctionExpression(p) || ts11.isClassDeclaration(p) || ts11.isClassExpression(p)) && p.name === id2;
9365
9506
  if (isDecl && params.includes(id2.text)) shadowedParam = id2.text;
9366
9507
  push(id2, "plain");
9367
9508
  }
9368
9509
  function visit3(n) {
9369
- if (ts10.isTypeNode(n) || ts10.isTypeParameterDeclaration(n) || ts10.isTypeAliasDeclaration(n) || ts10.isInterfaceDeclaration(n)) return;
9370
- if (ts10.isIdentifier(n)) {
9510
+ if (ts11.isTypeNode(n) || ts11.isTypeParameterDeclaration(n) || ts11.isTypeAliasDeclaration(n) || ts11.isInterfaceDeclaration(n)) return;
9511
+ if (ts11.isIdentifier(n)) {
9371
9512
  classify3(n);
9372
9513
  return;
9373
9514
  }
9374
- ts10.forEachChild(n, visit3);
9515
+ ts11.forEachChild(n, visit3);
9375
9516
  }
9376
9517
  visit3(root2);
9377
9518
  }
9378
- const keptStatements = node.body.statements.filter((s) => !ts10.isReturnStatement(s));
9519
+ const keptStatements = node.body.statements.filter((s) => !ts11.isReturnStatement(s));
9379
9520
  const pieces = [];
9380
9521
  let base = 0;
9381
9522
  for (const stmt of keptStatements) {
@@ -9422,17 +9563,17 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9422
9563
  };
9423
9564
  }
9424
9565
  function addBindingNames(name2, out) {
9425
- if (ts10.isIdentifier(name2)) {
9566
+ if (ts11.isIdentifier(name2)) {
9426
9567
  out.push(name2.text);
9427
9568
  return;
9428
9569
  }
9429
- if (ts10.isObjectBindingPattern(name2)) {
9570
+ if (ts11.isObjectBindingPattern(name2)) {
9430
9571
  for (const el of name2.elements) addBindingNames(el.name, out);
9431
9572
  return;
9432
9573
  }
9433
- if (ts10.isArrayBindingPattern(name2)) {
9574
+ if (ts11.isArrayBindingPattern(name2)) {
9434
9575
  for (const el of name2.elements) {
9435
- if (ts10.isOmittedExpression(el)) continue;
9576
+ if (ts11.isOmittedExpression(el)) continue;
9436
9577
  addBindingNames(el.name, out);
9437
9578
  }
9438
9579
  }
@@ -9443,28 +9584,28 @@ function rewriteFactoryCallsInSource(source, prescan) {
9443
9584
  let callSiteIndex = 0;
9444
9585
  const inlinedFactories = /* @__PURE__ */ new Set();
9445
9586
  function visitStmt(node, inComponent) {
9446
- if (ts10.isVariableStatement(node) && inComponent) {
9587
+ if (ts11.isVariableStatement(node) && inComponent) {
9447
9588
  for (const decl of node.declarationList.declarations) {
9448
9589
  maybeRewriteDecl(node, decl);
9449
9590
  }
9450
9591
  }
9451
- ts10.forEachChild(node, (child) => {
9452
- if (ts10.isFunctionDeclaration(child) && child.name && factories.has(child.name.text)) return;
9592
+ ts11.forEachChild(node, (child) => {
9593
+ if (ts11.isFunctionDeclaration(child) && child.name && factories.has(child.name.text)) return;
9453
9594
  visitStmt(child, inComponent || isPascalCaseComponentFn(child));
9454
9595
  });
9455
9596
  }
9456
9597
  function maybeRewriteDecl(stmt, decl) {
9457
- if (!decl.initializer || !ts10.isCallExpression(decl.initializer)) return;
9458
- if (!ts10.isIdentifier(decl.initializer.expression)) return;
9598
+ if (!decl.initializer || !ts11.isCallExpression(decl.initializer)) return;
9599
+ if (!ts11.isIdentifier(decl.initializer.expression)) return;
9459
9600
  const factoryName = decl.initializer.expression.text;
9460
9601
  const factory = factories.get(factoryName);
9461
9602
  if (!factory) return;
9462
- if (ts10.isArrayBindingPattern(decl.name)) {
9603
+ if (ts11.isArrayBindingPattern(decl.name)) {
9463
9604
  if (factory.returnKind !== "tuple") return;
9464
9605
  rewriteTupleDecl(stmt, decl.name, decl.initializer, factory);
9465
9606
  return;
9466
9607
  }
9467
- if (ts10.isObjectBindingPattern(decl.name)) {
9608
+ if (ts11.isObjectBindingPattern(decl.name)) {
9468
9609
  if (factory.returnKind !== "object") return;
9469
9610
  rewriteObjectDecl(stmt, decl.name, decl.initializer, factory);
9470
9611
  return;
@@ -9475,7 +9616,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
9475
9616
  if (elements2.length !== factory.returnTupleIdentifiers.length) return;
9476
9617
  const callerNames = [];
9477
9618
  for (const el of elements2) {
9478
- if (ts10.isOmittedExpression(el) || !ts10.isIdentifier(el.name)) return;
9619
+ if (ts11.isOmittedExpression(el) || !ts11.isIdentifier(el.name)) return;
9479
9620
  callerNames.push(el.name.text);
9480
9621
  }
9481
9622
  const excludeFromSuffixRename = new Set(factory.params);
@@ -9492,7 +9633,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
9492
9633
  if (el.dotDotDotToken) return;
9493
9634
  if (el.propertyName) return;
9494
9635
  if (el.initializer) return;
9495
- if (!ts10.isIdentifier(el.name)) return;
9636
+ if (!ts11.isIdentifier(el.name)) return;
9496
9637
  if (!factory.returnTupleIdentifiers.includes(el.name.text)) return;
9497
9638
  destructured.add(el.name.text);
9498
9639
  }
@@ -9585,21 +9726,21 @@ function factoryImportInsertionOffset(sf) {
9585
9726
  let lastImportEnd = -1;
9586
9727
  let directiveEnd = -1;
9587
9728
  for (const stmt of sf.statements) {
9588
- if (ts10.isImportDeclaration(stmt)) {
9729
+ if (ts11.isImportDeclaration(stmt)) {
9589
9730
  lastImportEnd = stmt.getEnd();
9590
9731
  continue;
9591
9732
  }
9592
- if (directiveEnd === -1 && ts10.isExpressionStatement(stmt) && ts10.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
9733
+ if (directiveEnd === -1 && ts11.isExpressionStatement(stmt) && ts11.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
9593
9734
  directiveEnd = stmt.getEnd();
9594
9735
  }
9595
9736
  }
9596
9737
  return lastImportEnd >= 0 ? lastImportEnd : directiveEnd >= 0 ? directiveEnd : 0;
9597
9738
  }
9598
9739
  function isPascalCaseComponentFn(node) {
9599
- if (ts10.isFunctionDeclaration(node) && node.name) {
9740
+ if (ts11.isFunctionDeclaration(node) && node.name) {
9600
9741
  return /^[A-Z]/.test(node.name.text);
9601
9742
  }
9602
- if (ts10.isVariableDeclaration(node) && ts10.isIdentifier(node.name) && node.initializer && ts10.isArrowFunction(node.initializer)) {
9743
+ if (ts11.isVariableDeclaration(node) && ts11.isIdentifier(node.name) && node.initializer && ts11.isArrowFunction(node.initializer)) {
9603
9744
  return /^[A-Z]/.test(node.name.text);
9604
9745
  }
9605
9746
  return false;
@@ -9627,16 +9768,16 @@ function declinedFactoryErrorCode(code) {
9627
9768
  }
9628
9769
  function validateReactiveFactoryCalls(ctx2) {
9629
9770
  if (!ctx2.componentNode) return;
9630
- const body2 = ts10.isFunctionDeclaration(ctx2.componentNode) ? ctx2.componentNode.body : ts10.isBlock(ctx2.componentNode.body) ? ctx2.componentNode.body : null;
9771
+ const body2 = ts11.isFunctionDeclaration(ctx2.componentNode) ? ctx2.componentNode.body : ts11.isBlock(ctx2.componentNode.body) ? ctx2.componentNode.body : null;
9631
9772
  if (!body2) return;
9632
9773
  for (const stmt of body2.statements) {
9633
- if (!ts10.isVariableStatement(stmt)) continue;
9774
+ if (!ts11.isVariableStatement(stmt)) continue;
9634
9775
  for (const decl of stmt.declarationList.declarations) {
9635
- if (!decl.initializer || !ts10.isCallExpression(decl.initializer)) continue;
9636
- if (!ts10.isIdentifier(decl.initializer.expression)) continue;
9776
+ if (!decl.initializer || !ts11.isCallExpression(decl.initializer)) continue;
9777
+ if (!ts11.isIdentifier(decl.initializer.expression)) continue;
9637
9778
  const callee = decl.initializer.expression.text;
9638
9779
  const loc = getSourceLocation(stmt, ctx2.sourceFile, ctx2.filePath);
9639
- if (ts10.isArrayBindingPattern(decl.name)) {
9780
+ if (ts11.isArrayBindingPattern(decl.name)) {
9640
9781
  if (callee === "createSignal" || callee === "createMemo") continue;
9641
9782
  if (resolveEnvSignalKey(decl.initializer, ctx2)) continue;
9642
9783
  const declinedEntry = ctx2.declinedReactiveFactories.get(callee);
@@ -9671,7 +9812,7 @@ function validateReactiveFactoryCalls(ctx2) {
9671
9812
  );
9672
9813
  continue;
9673
9814
  }
9674
- if (ts10.isObjectBindingPattern(decl.name)) {
9815
+ if (ts11.isObjectBindingPattern(decl.name)) {
9675
9816
  validateObjectFactoryDestructure(ctx2, decl.name, callee, loc);
9676
9817
  }
9677
9818
  }
@@ -9679,22 +9820,22 @@ function validateReactiveFactoryCalls(ctx2) {
9679
9820
  }
9680
9821
  function validateNamespaceQualifiedPrimitives(ctx2) {
9681
9822
  if (!ctx2.componentNode) return;
9682
- const body2 = ts10.isFunctionDeclaration(ctx2.componentNode) ? ctx2.componentNode.body : ts10.isBlock(ctx2.componentNode.body) ? ctx2.componentNode.body : null;
9823
+ const body2 = ts11.isFunctionDeclaration(ctx2.componentNode) ? ctx2.componentNode.body : ts11.isBlock(ctx2.componentNode.body) ? ctx2.componentNode.body : null;
9683
9824
  if (!body2) return;
9684
9825
  for (const stmt of body2.statements) {
9685
9826
  const calls = [];
9686
- if (ts10.isVariableStatement(stmt)) {
9827
+ if (ts11.isVariableStatement(stmt)) {
9687
9828
  for (const decl of stmt.declarationList.declarations) {
9688
9829
  let init = decl.initializer;
9689
- if (init && ts10.isElementAccessExpression(init)) init = init.expression;
9690
- if (init && ts10.isCallExpression(init)) calls.push(init);
9830
+ if (init && ts11.isElementAccessExpression(init)) init = init.expression;
9831
+ if (init && ts11.isCallExpression(init)) calls.push(init);
9691
9832
  }
9692
- } else if (ts10.isExpressionStatement(stmt) && ts10.isCallExpression(stmt.expression)) {
9833
+ } else if (ts11.isExpressionStatement(stmt) && ts11.isCallExpression(stmt.expression)) {
9693
9834
  calls.push(stmt.expression);
9694
9835
  }
9695
9836
  for (const call of calls) {
9696
9837
  const callee = call.expression;
9697
- if (!ts10.isPropertyAccessExpression(callee) || !ts10.isIdentifier(callee.expression)) continue;
9838
+ if (!ts11.isPropertyAccessExpression(callee) || !ts11.isIdentifier(callee.expression)) continue;
9698
9839
  const primitive = callee.name.text;
9699
9840
  if (!(primitive in PRIMITIVE_CANONICAL_NAMES)) continue;
9700
9841
  if (resolvePrimitiveKind(call, ctx2) !== null) continue;
@@ -9724,10 +9865,10 @@ function isNamespaceNameShadowedAtComponentTopLevel(name2, body2, ctx2) {
9724
9865
  if (ctx2.propsObjectName === name2) return true;
9725
9866
  if (ctx2.propsParams.some((p) => p.name === name2)) return true;
9726
9867
  for (const stmt of body2.statements) {
9727
- if (ts10.isFunctionDeclaration(stmt) && stmt.name?.text === name2) return true;
9728
- if (ts10.isVariableStatement(stmt)) {
9868
+ if (ts11.isFunctionDeclaration(stmt) && stmt.name?.text === name2) return true;
9869
+ if (ts11.isVariableStatement(stmt)) {
9729
9870
  for (const decl of stmt.declarationList.declarations) {
9730
- if (ts10.isIdentifier(decl.name) && decl.name.text === name2) return true;
9871
+ if (ts11.isIdentifier(decl.name) && decl.name.text === name2) return true;
9731
9872
  }
9732
9873
  }
9733
9874
  }
@@ -9744,7 +9885,7 @@ function validateObjectFactoryDestructure(ctx2, pattern, callee, loc) {
9744
9885
  return;
9745
9886
  }
9746
9887
  const hasUnsupportedElement = pattern.elements.some(
9747
- (el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !ts10.isIdentifier(el.name)
9888
+ (el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !ts11.isIdentifier(el.name)
9748
9889
  );
9749
9890
  if (hasUnsupportedElement) {
9750
9891
  ctx2.errors.push(createError(ErrorCodes.REACTIVE_FACTORY_RENAME_UNSUPPORTED, loc, {
@@ -9753,7 +9894,7 @@ function validateObjectFactoryDestructure(ctx2, pattern, callee, loc) {
9753
9894
  }));
9754
9895
  return;
9755
9896
  }
9756
- const unknown = pattern.elements.map((el) => ts10.isIdentifier(el.name) ? el.name.text : "").filter((name2) => name2 && !factory.returnTupleIdentifiers.includes(name2));
9897
+ const unknown = pattern.elements.map((el) => ts11.isIdentifier(el.name) ? el.name.text : "").filter((name2) => name2 && !factory.returnTupleIdentifiers.includes(name2));
9757
9898
  if (unknown.length > 0) {
9758
9899
  const label2 = unknown.length === 1 ? "property" : "properties";
9759
9900
  ctx2.errors.push(createError(ErrorCodes.UNRECOGNIZED_REACTIVE_FACTORY, loc, {
@@ -10013,7 +10154,7 @@ var init_types = __esm({
10013
10154
  });
10014
10155
 
10015
10156
  // ../jsx/src/module-exports.ts
10016
- import ts11 from "typescript";
10157
+ import ts12 from "typescript";
10017
10158
  function generateModuleExports(ir, extraInlineExported = /* @__PURE__ */ new Set(), rewriteRelativeImport, options2) {
10018
10159
  const lines = [];
10019
10160
  for (const constant of options2?.skipValueDeclarations ? [] : ir.metadata.localConstants) {
@@ -10104,28 +10245,28 @@ function findReachableNames(primaryRefs, declarations) {
10104
10245
  function findAssignedNames(bodyText, candidates) {
10105
10246
  const assigned = /* @__PURE__ */ new Set();
10106
10247
  if (candidates.size === 0) return assigned;
10107
- const sf = ts11.createSourceFile(
10248
+ const sf = ts12.createSourceFile(
10108
10249
  "bf-assignment-scan.tsx",
10109
10250
  bodyText,
10110
- ts11.ScriptTarget.Latest,
10251
+ ts12.ScriptTarget.Latest,
10111
10252
  /* setParentNodes */
10112
10253
  false,
10113
- ts11.ScriptKind.TSX
10254
+ ts12.ScriptKind.TSX
10114
10255
  );
10115
10256
  const record = (target2) => {
10116
- if (ts11.isIdentifier(target2) && candidates.has(target2.text)) {
10257
+ if (ts12.isIdentifier(target2) && candidates.has(target2.text)) {
10117
10258
  assigned.add(target2.text);
10118
10259
  }
10119
10260
  };
10120
10261
  const visit3 = (node) => {
10121
- if (ts11.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
10262
+ if (ts12.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
10122
10263
  record(node.left);
10123
- } else if ((ts11.isPrefixUnaryExpression(node) || ts11.isPostfixUnaryExpression(node)) && (node.operator === ts11.SyntaxKind.PlusPlusToken || node.operator === ts11.SyntaxKind.MinusMinusToken)) {
10264
+ } else if ((ts12.isPrefixUnaryExpression(node) || ts12.isPostfixUnaryExpression(node)) && (node.operator === ts12.SyntaxKind.PlusPlusToken || node.operator === ts12.SyntaxKind.MinusMinusToken)) {
10124
10265
  record(node.operand);
10125
10266
  }
10126
- ts11.forEachChild(node, visit3);
10267
+ ts12.forEachChild(node, visit3);
10127
10268
  };
10128
- ts11.forEachChild(sf, visit3);
10269
+ ts12.forEachChild(sf, visit3);
10129
10270
  return assigned;
10130
10271
  }
10131
10272
  function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
@@ -10145,7 +10286,7 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
10145
10286
  return reachable;
10146
10287
  }
10147
10288
  function isAssignmentOperator(kind2) {
10148
- return kind2 >= ts11.SyntaxKind.FirstAssignment && kind2 <= ts11.SyntaxKind.LastAssignment;
10289
+ return kind2 >= ts12.SyntaxKind.FirstAssignment && kind2 <= ts12.SyntaxKind.LastAssignment;
10149
10290
  }
10150
10291
  function extractFunctionParams(value2) {
10151
10292
  const arrowMatch = value2.match(/^(?:async\s*)?\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/);
@@ -10198,111 +10339,6 @@ var init_builtins = __esm({
10198
10339
  }
10199
10340
  });
10200
10341
 
10201
- // ../jsx/src/reactivity-checker.ts
10202
- import ts12 from "typescript";
10203
- function queryType(checker, node) {
10204
- incrementCounter("typeCheckerQueries");
10205
- return checker.getTypeAtLocation(node);
10206
- }
10207
- function isReactiveType(type2) {
10208
- return type2.getProperty(REACTIVE_BRAND) !== void 0;
10209
- }
10210
- function safeGetText(node) {
10211
- try {
10212
- return node.getText();
10213
- } catch {
10214
- return "";
10215
- }
10216
- }
10217
- function analyze(node, checker) {
10218
- if (ts12.isPropertyAccessExpression(node)) {
10219
- try {
10220
- const type2 = queryType(checker, node);
10221
- if (isReactiveType(type2)) {
10222
- return {
10223
- isReactive: true,
10224
- reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
10225
- };
10226
- }
10227
- } catch {
10228
- }
10229
- const sub2 = analyze(node.expression, checker);
10230
- if (sub2.isReactive) {
10231
- return {
10232
- isReactive: true,
10233
- reason: {
10234
- kind: "child",
10235
- via: "property-access-object",
10236
- childText: safeGetText(node.expression),
10237
- childReason: sub2.reason
10238
- }
10239
- };
10240
- }
10241
- return NOT_REACTIVE;
10242
- }
10243
- if (ts12.isIdentifier(node)) {
10244
- try {
10245
- const type2 = queryType(checker, node);
10246
- if (isReactiveType(type2)) {
10247
- return {
10248
- isReactive: true,
10249
- reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
10250
- };
10251
- }
10252
- } catch {
10253
- }
10254
- return NOT_REACTIVE;
10255
- }
10256
- if (ts12.isCallExpression(node)) {
10257
- try {
10258
- const calleeType = queryType(checker, node.expression);
10259
- if (isReactiveType(calleeType)) {
10260
- return {
10261
- isReactive: true,
10262
- reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
10263
- };
10264
- }
10265
- } catch {
10266
- }
10267
- }
10268
- let foundChild;
10269
- let foundChildText = "";
10270
- ts12.forEachChild(node, (child) => {
10271
- if (foundChild?.isReactive) return;
10272
- const result2 = analyze(child, checker);
10273
- if (result2.isReactive) {
10274
- foundChild = result2;
10275
- foundChildText = safeGetText(child);
10276
- }
10277
- });
10278
- if (foundChild?.isReactive) {
10279
- return {
10280
- isReactive: true,
10281
- reason: {
10282
- kind: "child",
10283
- via: "sub-expression",
10284
- childText: foundChildText,
10285
- childReason: foundChild.reason
10286
- }
10287
- };
10288
- }
10289
- return NOT_REACTIVE;
10290
- }
10291
- function containsReactiveExpression(node, checker) {
10292
- incrementCounter("reactivityChecks");
10293
- return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
10294
- }
10295
- var REACTIVE_BRAND, NOT_REACTIVE, brandTypeReactivityAnalyzer;
10296
- var init_reactivity_checker = __esm({
10297
- "../jsx/src/reactivity-checker.ts"() {
10298
- "use strict";
10299
- init_instrumentation();
10300
- REACTIVE_BRAND = "__reactive";
10301
- NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
10302
- brandTypeReactivityAnalyzer = { analyze };
10303
- }
10304
- });
10305
-
10306
10342
  // ../jsx/src/free-refs.ts
10307
10343
  import ts13 from "typescript";
10308
10344
  function buildBindingMap(env) {
@@ -11932,7 +11968,7 @@ function transformExpressionInner(expr, ctx2, node, isClientOnly) {
11932
11968
  }
11933
11969
  const ir = transformJsxExpression(expr, ctx2, isClientOnly);
11934
11970
  if (ir !== null) {
11935
- if ((isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx2)) && ir.type === "conditional") {
11971
+ if (ir.type === "conditional" && (isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx2))) {
11936
11972
  ir.clientOnly = true;
11937
11973
  if (!ir.slotId) {
11938
11974
  ir.slotId = generateSlotId(ctx2);
@@ -14858,8 +14894,9 @@ function isReactiveExpression(expr, ctx2, astNode) {
14858
14894
  function shouldAutoDeferReactiveBrand(expr, ctx2) {
14859
14895
  const checker = ctx2.analyzer.checker;
14860
14896
  if (!checker) return false;
14861
- if (!containsReactiveExpression(expr, checker)) return false;
14862
- if (isSignalOrMemoReference(ctx2.getJS(expr), ctx2)) return false;
14897
+ const leaves = collectReactiveBrandLeaves(expr, checker);
14898
+ if (leaves.length === 0) return false;
14899
+ if (leaves.some((leaf) => isSignalOrMemoReference(ctx2.getJS(leaf), ctx2))) return false;
14863
14900
  return true;
14864
14901
  }
14865
14902
  function isSignalOrMemoReference(expr, ctx2, visited) {
@@ -15250,9 +15287,9 @@ var init_prop_handling = __esm({
15250
15287
  });
15251
15288
 
15252
15289
  // ../jsx/src/ir-to-client-js/reactivity.ts
15253
- function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex) {
15290
+ function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope) {
15254
15291
  if (!loopParam) return void 0;
15255
- return BindingScope.EMPTY.enterLoopRow({
15292
+ return (parentScope ?? BindingScope.EMPTY).enterLoopRow({
15256
15293
  param: loopParam,
15257
15294
  paramBindings: loopParamBindings,
15258
15295
  index: loopIndex,
@@ -15314,16 +15351,20 @@ function needsEffectWrapperCore(expr, ctx2, freeIdentifiers2, visitedConstants)
15314
15351
  }
15315
15352
  return false;
15316
15353
  }
15317
- function classifyReactivity(expr, ctx2, loopParam, loopParamBindings, freeIdentifiers2) {
15354
+ function classifyReactivity(expr, ctx2, scope, freeIdentifiers2) {
15318
15355
  const has = (name2) => freeIdentifiers2 ? freeIdentifiers2.has(name2) : tokenContainsIdent(expr, name2);
15319
- if (loopParamBindings && loopParamBindings.length > 0) {
15320
- for (const b of loopParamBindings) {
15321
- if (has(b.name)) {
15322
- return { kind: "loop-param", param: loopParam ?? b.name };
15356
+ if (scope) {
15357
+ let indexHit;
15358
+ for (const name2 of scope.valueBoundNames()) {
15359
+ if (!has(name2)) continue;
15360
+ const source = scope.lookup(name2)?.binding.source;
15361
+ if (source === "index") {
15362
+ indexHit ??= name2;
15363
+ continue;
15323
15364
  }
15365
+ return { kind: "loop-param", param: name2 };
15324
15366
  }
15325
- } else if (loopParam && has(loopParam)) {
15326
- return { kind: "loop-param", param: loopParam };
15367
+ if (indexHit) return { kind: "loop-index", param: indexHit };
15327
15368
  }
15328
15369
  if (needsEffectWrapper(expr, ctx2, freeIdentifiers2)) {
15329
15370
  return { kind: "signal-or-memo-or-prop" };
@@ -15494,9 +15535,9 @@ function traverseForComponents(node, components, skipConditionals = false) {
15494
15535
  }
15495
15536
  });
15496
15537
  }
15497
- function collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
15538
+ function collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex, parentScope) {
15498
15539
  const texts = [];
15499
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
15540
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
15500
15541
  walkIR(node, false, {
15501
15542
  // Skip loop/async/if-statement subtrees — the original walker omitted
15502
15543
  // them; they have their own scopes (inner-loop reconciliation, async
@@ -15507,7 +15548,7 @@ function collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings,
15507
15548
  if (n.preambleRegion) return;
15508
15549
  const originFreeIds = freeIdsFromRefs(n.origin?.freeRefs);
15509
15550
  const expanded = expandConstantForReactivity(n.expr, ctx2, originFreeIds, scope);
15510
- const reactive = classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
15551
+ const reactive = classifyReactivity(expanded.expr, ctx2, scope, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
15511
15552
  if (!reactive) return;
15512
15553
  texts.push({
15513
15554
  slotId: n.slotId,
@@ -15526,9 +15567,9 @@ function anyNameIn(names, set) {
15526
15567
  for (const n of names) if (set.has(n)) return true;
15527
15568
  return false;
15528
15569
  }
15529
- function collectLoopChildReactiveAttrs(node, ctx2, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
15570
+ function collectLoopChildReactiveAttrs(node, ctx2, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex, parentScope) {
15530
15571
  const attrs = [];
15531
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
15572
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
15532
15573
  traverseElements(node, (el) => {
15533
15574
  if (el.slotId) {
15534
15575
  for (const attr of el.attrs) {
@@ -15539,7 +15580,7 @@ function collectLoopChildReactiveAttrs(node, ctx2, loopParam, loopParamBindings,
15539
15580
  if (!valueStr) continue;
15540
15581
  const expanded = expandConstantForReactivity(valueStr, ctx2, attr.freeIdentifiers, scope);
15541
15582
  const readsPreamble = preambleNames !== void 0 && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
15542
- const reactive = classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
15583
+ const reactive = classifyReactivity(expanded.expr, ctx2, scope, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
15543
15584
  if (!attr.clientOnly && !reactive) continue;
15544
15585
  attrs.push({
15545
15586
  childSlotId: el.slotId,
@@ -15871,7 +15912,9 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx2, options2
15871
15912
  const flat = options2?.flatBranchMode === true;
15872
15913
  const fixedDepth = options2?.templateDepth;
15873
15914
  const collectBindings = options2?.collectItemBindings === true;
15874
- const initialScope = { parentSlotId: null, depth: 0, insideCond: false };
15915
+ const outerSpec = typeof outerLoopParam === "string" ? { param: outerLoopParam } : outerLoopParam;
15916
+ const outerScope = buildLoopRowScope(outerSpec?.param, outerSpec?.bindings, void 0, outerSpec?.index);
15917
+ const initialScope = { parentSlotId: null, depth: 0, insideCond: false, bindingScope: outerScope };
15875
15918
  for (const root2 of nodes) {
15876
15919
  walkIR(root2, initialScope, {
15877
15920
  element: ({ node: el, scope, descend }) => {
@@ -15886,15 +15929,14 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx2, options2
15886
15929
  },
15887
15930
  loop: ({ node: n, scope, descend }) => {
15888
15931
  const emitDepth = fixedDepth ?? scope.depth + 1;
15889
- const loopParamsForTemplate = outerLoopParam ? [outerLoopParam, { param: n.param, bindings: n.paramBindings, index: n.index }] : void 0;
15932
+ const loopParamsForTemplate = outerSpec ? [outerSpec, { param: n.param, bindings: n.paramBindings, index: n.index }] : void 0;
15890
15933
  const template = n.children.map((c) => irToPlaceholderTemplate(c, void 0, emitDepth, loopParamsForTemplate)).join("");
15891
- const refsOuter = outerLoopParam ? identifierPattern(outerLoopParam).test(n.array) : false;
15892
15934
  const bindings = emptyLoopChildBindings();
15893
15935
  const innerPreambleNames = preambleNamesOf(n);
15894
15936
  if (ctx2) {
15895
15937
  for (const child of n.children) {
15896
- bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx2, n.param, n.paramBindings, true, innerPreambleNames, n.index));
15897
- bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx2, n.param, n.paramBindings, true, innerPreambleNames, n.index));
15938
+ bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx2, n.param, n.paramBindings, true, innerPreambleNames, n.index, scope.bindingScope));
15939
+ bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx2, n.param, n.paramBindings, true, innerPreambleNames, n.index, scope.bindingScope));
15898
15940
  bindings.refs.push(...collectLoopChildRefs(child));
15899
15941
  }
15900
15942
  bindings.conditionals.push(...collectLoopChildConditionals(
@@ -15904,7 +15946,13 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx2, options2
15904
15946
  n.param,
15905
15947
  n.paramBindings,
15906
15948
  innerPreambleNames,
15907
- n.index
15949
+ n.index,
15950
+ // Render a branch's HTML against the FULL ancestor chain (outer
15951
+ // loop(s) + this loop's own param), not just this loop's own
15952
+ // param — an inner-loop conditional arm can read an outer
15953
+ // loop's item/index too (#2868).
15954
+ loopParamsForTemplate,
15955
+ scope.bindingScope
15908
15956
  ));
15909
15957
  }
15910
15958
  let childComponents;
@@ -15947,14 +15995,17 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx2, options2
15947
15995
  containerSlotId: scope.parentSlotId,
15948
15996
  template,
15949
15997
  preamble: n.preamble,
15950
- refsOuterParam: refsOuter,
15951
15998
  childComponents,
15952
15999
  insideConditional: !flat && scope.insideCond ? true : void 0,
15953
16000
  offset: flat ? void 0 : resolveLoopOffset(siblingOffsets.get(n)),
15954
16001
  bindings
15955
16002
  });
15956
16003
  if (!flat) {
15957
- descend({ ...scope, depth: scope.depth + 1 });
16004
+ descend({
16005
+ ...scope,
16006
+ depth: scope.depth + 1,
16007
+ bindingScope: buildLoopRowScope(n.param, n.paramBindings, innerPreambleNames, n.index, scope.bindingScope)
16008
+ });
15958
16009
  }
15959
16010
  }
15960
16011
  // fragment / provider / async auto-descend with the same scope.
@@ -15964,7 +16015,12 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx2, options2
15964
16015
  }
15965
16016
  function decideLoopRendering(loop, siblingOffsets, ctx2) {
15966
16017
  const hasNestedComps = (loop.nestedComponents?.length ?? 0) > 0;
15967
- const innerLoops = collectInnerLoops(loop.children, siblingOffsets, loop.param, ctx2);
16018
+ const innerLoops = collectInnerLoops(
16019
+ loop.children,
16020
+ siblingOffsets,
16021
+ { param: loop.param, bindings: loop.paramBindings, index: loop.index },
16022
+ ctx2
16023
+ );
15968
16024
  const hasInnerLoops = (innerLoops?.length ?? 0) > 0;
15969
16025
  const useElementReconciliation = !loop.childComponent && !loop.isStaticArray && (hasNestedComps || hasInnerLoops);
15970
16026
  return { useElementReconciliation, innerLoops };
@@ -16117,6 +16173,7 @@ function collectElements(node, ctx2, siblingOffsets, insideConditional = false)
16117
16173
  }
16118
16174
  const { useElementReconciliation, innerLoops } = projectionInner ? { useElementReconciliation: false, innerLoops: void 0 } : decideLoopRendering(l, siblingOffsets, ctx2);
16119
16175
  let template = "";
16176
+ let templateIndexed;
16120
16177
  let staticItemTemplate;
16121
16178
  let skeletonTemplate;
16122
16179
  let skeletonPaths;
@@ -16128,6 +16185,10 @@ function collectElements(node, ctx2, siblingOffsets, insideConditional = false)
16128
16185
  } else if (l.children[0] && !projectionInner) {
16129
16186
  const loopParamSpec = [{ param: l.param, bindings: l.paramBindings }];
16130
16187
  template = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx2), 0, loopParamSpec) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx2), 0, loopParamSpec);
16188
+ if (l.index) {
16189
+ const loopParamSpecIndexed = [{ param: l.param, bindings: l.paramBindings, index: l.index }];
16190
+ templateIndexed = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx2), 0, loopParamSpecIndexed) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx2), 0, loopParamSpecIndexed);
16191
+ }
16131
16192
  if (l.isStaticArray) {
16132
16193
  staticItemTemplate = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx2), 0) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx2), 0);
16133
16194
  } else if (!useElementReconciliation && !l.bodyIsMultiRoot && !l.bodyIsItemConditional) {
@@ -16156,6 +16217,7 @@ function collectElements(node, ctx2, siblingOffsets, insideConditional = false)
16156
16217
  iterationShape: l.iterationShape,
16157
16218
  objectIteration: l.objectIteration,
16158
16219
  template,
16220
+ templateIndexed,
16159
16221
  staticItemTemplate,
16160
16222
  skeletonTemplate,
16161
16223
  skeletonPaths,
@@ -16344,6 +16406,7 @@ function collectBranchLoops(node, ctx2, siblingOffsets) {
16344
16406
  const projectionInner = n.method === "flatMap" && n.children.length === 1 && n.children[0].type === "loop" ? n.children[0] : void 0;
16345
16407
  const { useElementReconciliation, innerLoops: innerLoopsCollected } = projectionInner ? { useElementReconciliation: false, innerLoops: void 0 } : decideLoopRendering(n, siblingOffsets, void 0);
16346
16408
  let childTemplate;
16409
+ let childTemplateIndexed;
16347
16410
  const branchLoopParamSpec = [{ param: n.param, bindings: n.paramBindings }];
16348
16411
  if (projectionInner) {
16349
16412
  childTemplate = "";
@@ -16352,6 +16415,10 @@ function collectBranchLoops(node, ctx2, siblingOffsets) {
16352
16415
  } else {
16353
16416
  childTemplate = n.children.map((c) => irToHtmlTemplate(c, void 0, 0, branchLoopParamSpec)).join("");
16354
16417
  }
16418
+ if (n.index && !projectionInner) {
16419
+ const branchLoopParamSpecIndexed = [{ param: n.param, bindings: n.paramBindings, index: n.index }];
16420
+ childTemplateIndexed = useElementReconciliation && n.children[0] ? irToPlaceholderTemplate(n.children[0], restNames, 0, branchLoopParamSpecIndexed) : n.children.map((c) => irToHtmlTemplate(c, void 0, 0, branchLoopParamSpecIndexed)).join("");
16421
+ }
16355
16422
  const branchBindings = ctx2 && !projectionInner ? collectLoopChildBindings(n.children, ctx2, siblingOffsets, n.param, n.paramBindings, preambleNamesOf(n), n.index) : emptyLoopChildBindings();
16356
16423
  loops.push({
16357
16424
  kind: "branch",
@@ -16367,6 +16434,7 @@ function collectBranchLoops(node, ctx2, siblingOffsets) {
16367
16434
  iterationShape: n.iterationShape,
16368
16435
  objectIteration: n.objectIteration,
16369
16436
  template: childTemplate,
16437
+ templateIndexed: childTemplateIndexed,
16370
16438
  containerSlotId: containerSlot,
16371
16439
  preamble: n.preamble,
16372
16440
  preambleRegions: n.preambleRegions,
@@ -16449,18 +16517,10 @@ function collectLoopChildBindings(children2, ctx2, siblingOffsets, loopParam, lo
16449
16517
  }
16450
16518
  return bindings;
16451
16519
  }
16452
- function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
16520
+ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex, loopParams, parentScope) {
16453
16521
  const conditionals = [];
16454
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
16455
- const refsAnyBindingViaFreeIds = (freeIds) => {
16456
- if (loopParamBindings && loopParamBindings.length > 0) {
16457
- for (const b of loopParamBindings) {
16458
- if (freeIds.has(b.name)) return true;
16459
- }
16460
- return false;
16461
- }
16462
- return loopParam ? freeIds.has(loopParam) : false;
16463
- };
16522
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
16523
+ const refsAnyBindingViaFreeIds = (freeIds) => scope !== void 0 && anyNameIn(scope.valueBoundNames(), freeIds);
16464
16524
  walkIR(node, null, {
16465
16525
  // element / fragment / component / provider auto-descend with same scope.
16466
16526
  // loop / async / if-statement skipped — nested loops have their own
@@ -16473,8 +16533,8 @@ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loo
16473
16533
  if (!n.reactive && !refsLoopParamInSource) return;
16474
16534
  const expanded = expandConstantForReactivity(n.condition, ctx2, sourceFreeIds, scope);
16475
16535
  const readsPreamble = preambleNames !== void 0 && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
16476
- if (!readsPreamble && classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind === "none") return;
16477
- const loopParamsForCond = loopParam ? [{ param: loopParam, bindings: loopParamBindings, index: loopIndex }] : void 0;
16536
+ if (!readsPreamble && classifyReactivity(expanded.expr, ctx2, scope, expanded.freeIds).kind === "none") return;
16537
+ const loopParamsForCond = loopParams ?? (loopParam ? [{ param: loopParam, bindings: loopParamBindings, index: loopIndex }] : void 0);
16478
16538
  const whenTrueHtml = irToHtmlTemplate(n.whenTrue, void 0, 0, loopParamsForCond, "__slots");
16479
16539
  const whenFalseHtml = irToHtmlTemplate(n.whenFalse, void 0, 0, loopParamsForCond, "__slots");
16480
16540
  conditionals.push({
@@ -16492,7 +16552,13 @@ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loo
16492
16552
  return conditionals;
16493
16553
  }
16494
16554
  function summarizeLoopChildBranch(node, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
16495
- const inner = collectInnerLoops([node], siblingOffsets, loopParam, ctx2, branchInnerLoopOptions);
16555
+ const inner = collectInnerLoops(
16556
+ [node],
16557
+ siblingOffsets,
16558
+ loopParam ? { param: loopParam, bindings: loopParamBindings, index: loopIndex } : void 0,
16559
+ ctx2,
16560
+ branchInnerLoopOptions
16561
+ );
16496
16562
  return {
16497
16563
  childComponents: collectConditionalBranchChildComponents(node),
16498
16564
  innerLoops: inner.length > 0 ? inner : void 0,
@@ -16567,7 +16633,6 @@ var init_collect_elements = __esm({
16567
16633
  init_csr_substitute();
16568
16634
  init_walker();
16569
16635
  init_loop_chain();
16570
- init_identifier_pattern();
16571
16636
  init_src();
16572
16637
  EMPTY_RENDER_EXPRS = /* @__PURE__ */ new Set(["null", "undefined", "false", "''", '""', "``"]);
16573
16638
  branchInnerLoopOptions = {
@@ -19825,13 +19890,14 @@ function buildBranchInnerLoopsPlan(args2) {
19825
19890
  condSlotId,
19826
19891
  outerLoopParam,
19827
19892
  outerLoopParamBindings,
19893
+ outerLoopIndex,
19828
19894
  wrapOuter
19829
19895
  } = args2;
19830
19896
  if (!innerLoops || innerLoops.length === 0) return [];
19831
19897
  const plan = [];
19832
19898
  for (let i = 0; i < innerLoops.length; i++) {
19833
19899
  const inner = innerLoops[i];
19834
- if (!inner.refsOuterParam || !inner.template) continue;
19900
+ if (!inner.template) continue;
19835
19901
  const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
19836
19902
  const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings, inner.index);
19837
19903
  const csl = inner.containerSlotId;
@@ -19901,18 +19967,20 @@ function buildBranchInnerLoopsPlan(args2) {
19901
19967
  scopeVar: `__belbr_${i}`,
19902
19968
  wrap: wrapBoth,
19903
19969
  loopParam: inner.param,
19904
- loopParamBindings: inner.paramBindings
19970
+ loopParamBindings: inner.paramBindings,
19971
+ loopIndex: inner.index
19905
19972
  }),
19906
19973
  innerLoopParam: inner.param,
19907
19974
  innerLoopParamBindings: inner.paramBindings,
19908
19975
  outerLoopParam,
19909
- outerLoopParamBindings
19976
+ outerLoopParamBindings,
19977
+ outerLoopIndex
19910
19978
  });
19911
19979
  }
19912
19980
  return plan;
19913
19981
  }
19914
19982
  function buildLoopChildConditionalsPlan(args2) {
19915
- const { conditionals, scopeVar, wrap, loopParam, loopParamBindings } = args2;
19983
+ const { conditionals, scopeVar, wrap, loopParam, loopParamBindings, loopIndex } = args2;
19916
19984
  if (!conditionals || conditionals.length === 0) return [];
19917
19985
  const plans = [];
19918
19986
  for (const cond of conditionals) {
@@ -19920,13 +19988,20 @@ function buildLoopChildConditionalsPlan(args2) {
19920
19988
  slotId: cond.slotId,
19921
19989
  scopeVar,
19922
19990
  wrappedCondition: wrap(cond.condition),
19923
- whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
19924
- whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
19991
+ // whenTrueHtml/whenFalseHtml are already loop-param-wrapped for the
19992
+ // full ancestor chain at IR render time (`irToHtmlTemplate`'s
19993
+ // `loopParams`, collect-elements.ts) — do NOT re-wrap the rendered
19994
+ // HTML string here (#2868: a word-boundary regex over assembled
19995
+ // markup can match a bare tag name colliding with the param/index
19996
+ // identifier, e.g. `<i>` -> `<i()>`).
19997
+ whenTrueTemplateHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
19998
+ whenFalseTemplateHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId),
19925
19999
  whenTrueArm: buildLoopChildArmPlan({
19926
20000
  branch: cond.whenTrue,
19927
20001
  wrap,
19928
20002
  loopParam,
19929
20003
  loopParamBindings,
20004
+ loopIndex,
19930
20005
  condId: cond.slotId
19931
20006
  }),
19932
20007
  whenFalseArm: buildLoopChildArmPlan({
@@ -19934,8 +20009,10 @@ function buildLoopChildConditionalsPlan(args2) {
19934
20009
  wrap,
19935
20010
  loopParam,
19936
20011
  loopParamBindings,
20012
+ loopIndex,
19937
20013
  condId: cond.slotId
19938
- })
20014
+ }),
20015
+ ...cond.readsPreamble && { readsPreamble: true }
19939
20016
  });
19940
20017
  }
19941
20018
  return plans;
@@ -19958,7 +20035,8 @@ function buildArmAttrsPlan(attrs, wrap) {
19958
20035
  attrs: slotAttrs.map((attr) => ({
19959
20036
  attrName: attr.attrName,
19960
20037
  wrappedExpression: wrap(attr.expression),
19961
- meta: pickAttrMeta(attr)
20038
+ meta: pickAttrMeta(attr),
20039
+ ...attr.readsPreamble && { readsPreamble: true }
19962
20040
  }))
19963
20041
  });
19964
20042
  }
@@ -19972,7 +20050,7 @@ function buildArmTextsPlan(texts, wrap) {
19972
20050
  }));
19973
20051
  }
19974
20052
  function buildLoopChildArmPlan(args2) {
19975
- const { branch, wrap, loopParam, loopParamBindings, condId } = args2;
20053
+ const { branch, wrap, loopParam, loopParamBindings, loopIndex, condId } = args2;
19976
20054
  return {
19977
20055
  events: buildBranchEventBindingsPlan({
19978
20056
  events: branch.events,
@@ -19988,6 +20066,7 @@ function buildLoopChildArmPlan(args2) {
19988
20066
  condSlotId: condId,
19989
20067
  outerLoopParam: loopParam,
19990
20068
  outerLoopParamBindings: loopParamBindings,
20069
+ outerLoopIndex: loopIndex,
19991
20070
  wrapOuter: wrap
19992
20071
  }),
19993
20072
  nestedConditionals: buildLoopChildConditionalsPlan({
@@ -19995,7 +20074,8 @@ function buildLoopChildArmPlan(args2) {
19995
20074
  scopeVar: "__branchScope",
19996
20075
  wrap,
19997
20076
  loopParam,
19998
- loopParamBindings
20077
+ loopParamBindings,
20078
+ loopIndex
19999
20079
  }),
20000
20080
  attrs: buildArmAttrsPlan(branch.reactiveAttrs, wrap),
20001
20081
  texts: buildArmTextsPlan(branch.reactiveTexts, wrap)
@@ -20047,10 +20127,17 @@ function buildReactiveEffectsPlan(args2) {
20047
20127
  conditionalPlans.push({
20048
20128
  slotId: cond.slotId,
20049
20129
  wrappedCondition: wrap(cond.condition),
20050
- whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
20051
- whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
20052
- whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, cond.slotId, profileComponentName),
20053
- whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, cond.slotId, profileComponentName),
20130
+ // whenTrueHtml/whenFalseHtml are already loop-param-wrapped at IR
20131
+ // render time (`irToHtmlTemplate`'s `loopParams`, collect-elements.ts)
20132
+ // do NOT re-wrap the rendered HTML string here. A word-boundary
20133
+ // regex over already-assembled markup matches a bare tag name that
20134
+ // collides with the param/index identifier (`<i>` -> `<i()>`) just
20135
+ // as readily as a real reference, since `<`/`>` are non-word
20136
+ // characters (#2868).
20137
+ whenTrueTemplateHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
20138
+ whenFalseTemplateHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId),
20139
+ whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, loopIndex, cond.slotId, profileComponentName),
20140
+ whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, loopIndex, cond.slotId, profileComponentName),
20054
20141
  ...cond.readsPreamble && { readsPreamble: true }
20055
20142
  });
20056
20143
  }
@@ -20062,7 +20149,7 @@ function buildReactiveEffectsPlan(args2) {
20062
20149
  profileComponentName
20063
20150
  };
20064
20151
  }
20065
- function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, profileComponentName) {
20152
+ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, loopIndex, condSlotId, profileComponentName) {
20066
20153
  return {
20067
20154
  events: buildBranchEventBindingsPlan({
20068
20155
  events: branch.events,
@@ -20079,6 +20166,7 @@ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, p
20079
20166
  condSlotId,
20080
20167
  outerLoopParam: loopParam,
20081
20168
  outerLoopParamBindings: loopParamBindings,
20169
+ outerLoopIndex: loopIndex,
20082
20170
  wrapOuter: wrap
20083
20171
  }),
20084
20172
  nestedConditionals: buildLoopChildConditionalsPlan({
@@ -20086,7 +20174,8 @@ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, p
20086
20174
  scopeVar: "__branchScope",
20087
20175
  wrap,
20088
20176
  loopParam,
20089
- loopParamBindings
20177
+ loopParamBindings,
20178
+ loopIndex
20090
20179
  }),
20091
20180
  attrs: buildArmAttrsPlan(branch.reactiveAttrs, wrap),
20092
20181
  texts: buildArmTextsPlan(branch.reactiveTexts, wrap)
@@ -20135,8 +20224,8 @@ function wrapAttrValueExpression2(value2, wrap) {
20135
20224
  }
20136
20225
  }
20137
20226
  function buildInnerLoopsPlan(args2) {
20138
- const { levels, parentElVar, outerLoopParam, outerLoopParamBindings } = args2;
20139
- const wrapOuter = outerLoopParam ? (expr) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings) : (expr) => expr;
20227
+ const { levels, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex } = args2;
20228
+ const wrapOuter = outerLoopParam ? (expr) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings, outerLoopIndex) : (expr) => expr;
20140
20229
  const plan = [];
20141
20230
  let i = 0;
20142
20231
  while (i < levels.length) {
@@ -20158,15 +20247,14 @@ function buildInnerLoopsPlan(args2) {
20158
20247
  }
20159
20248
  const uidSuffix = `${inner.depth}_${i}`;
20160
20249
  const containerExpr = inner.containerSlotId ? `qsa(${parentElVar}, '[bf="${inner.containerSlotId}"]')` : parentElVar;
20161
- const refsParent = !!outerLoopParam && (inner.arrayFreeIdentifiers?.has(outerLoopParam) ?? false);
20162
- const useReactive = refsParent && !!inner.template;
20163
- const emit = useReactive ? buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings) : buildStaticEmit(inner, level, uidSuffix);
20164
- const arrayExpr = useReactive ? wrapOuter(inner.array) : inner.array;
20250
+ const emit = buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex);
20251
+ const arrayExpr = wrapOuter(inner.array);
20165
20252
  const childLevelsPlan = childLevels.length > 0 ? buildInnerLoopsPlan({
20166
20253
  levels: childLevels,
20167
20254
  parentElVar: `__innerEl${uidSuffix}`,
20168
20255
  outerLoopParam: inner.param,
20169
- outerLoopParamBindings: inner.paramBindings
20256
+ outerLoopParamBindings: inner.paramBindings,
20257
+ outerLoopIndex: inner.index
20170
20258
  }) : [];
20171
20259
  plan.push({
20172
20260
  uidSuffix,
@@ -20181,13 +20269,14 @@ function buildInnerLoopsPlan(args2) {
20181
20269
  emit,
20182
20270
  childLevels: childLevelsPlan,
20183
20271
  outerLoopParam,
20184
- outerLoopParamBindings
20272
+ outerLoopParamBindings,
20273
+ outerLoopIndex
20185
20274
  });
20186
20275
  i = j;
20187
20276
  }
20188
20277
  return plan;
20189
20278
  }
20190
- function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings) {
20279
+ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex) {
20191
20280
  const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
20192
20281
  const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings, inner.index);
20193
20282
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(inner.param, inner.paramBindings);
@@ -20240,7 +20329,7 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
20240
20329
  if (paramUnwrap) preludeStatements.push(paramUnwrap);
20241
20330
  if (inner.preamble) {
20242
20331
  const leafLoopParams = outerLoopParam ? [
20243
- { param: outerLoopParam, bindings: outerLoopParamBindings },
20332
+ { param: outerLoopParam, bindings: outerLoopParamBindings, index: outerLoopIndex },
20244
20333
  { param: inner.param, bindings: inner.paramBindings, index: inner.index }
20245
20334
  ] : [{ param: inner.param, bindings: inner.paramBindings, index: inner.index }];
20246
20335
  preludeStatements.push(renderPreamble(inner.preamble, {
@@ -20254,7 +20343,8 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
20254
20343
  scopeVar: `__innerEl${uidSuffix}`,
20255
20344
  wrap: wrapBoth,
20256
20345
  loopParam: inner.param,
20257
- loopParamBindings: inner.paramBindings
20346
+ loopParamBindings: inner.paramBindings,
20347
+ loopIndex: inner.index
20258
20348
  });
20259
20349
  return {
20260
20350
  mode: "reactive",
@@ -20272,24 +20362,6 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
20272
20362
  childRefs
20273
20363
  };
20274
20364
  }
20275
- function buildStaticEmit(inner, level, uidSuffix) {
20276
- const preludeStatements = [];
20277
- const indexAlias = nestedLoopIndexAlias(inner, `__innerIdx${uidSuffix}`, inner.param, level.comps, level.events);
20278
- if (indexAlias) preludeStatements.push(indexAlias);
20279
- if (inner.preamble) {
20280
- preludeStatements.push(renderPreamble(inner.preamble, {
20281
- renderLeaf: (ir) => irToHtmlTemplate(ir, void 0, 1, void 0, void 0)
20282
- }));
20283
- }
20284
- return {
20285
- mode: "static",
20286
- rawKey: inner.key ?? null,
20287
- preludeStatements,
20288
- components: level.comps,
20289
- events: level.events,
20290
- childRefs: buildStaticChildRefBindings(inner.bindings.refs)
20291
- };
20292
- }
20293
20365
  var init_build_inner_loop = __esm({
20294
20366
  "../jsx/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts"() {
20295
20367
  "use strict";
@@ -20331,7 +20403,8 @@ function buildTopLevelCompositePlan(elem, profileComponentName) {
20331
20403
  levels: depthLevels,
20332
20404
  parentElVar: "__el",
20333
20405
  outerLoopParam: elem.param,
20334
- outerLoopParamBindings: elem.paramBindings
20406
+ outerLoopParamBindings: elem.paramBindings,
20407
+ outerLoopIndex: elem.index
20335
20408
  }),
20336
20409
  loopParam: elem.param,
20337
20410
  loopParamBindings: elem.paramBindings,
@@ -20386,7 +20459,8 @@ function buildBranchCompositePlan(loop, cv, profileComponentName) {
20386
20459
  levels: depthLevels,
20387
20460
  parentElVar: "__el",
20388
20461
  outerLoopParam: loop.param,
20389
- outerLoopParamBindings: loop.paramBindings
20462
+ outerLoopParamBindings: loop.paramBindings,
20463
+ outerLoopIndex: loop.index
20390
20464
  }),
20391
20465
  loopParam: loop.param,
20392
20466
  loopParamBindings: loop.paramBindings,
@@ -20924,8 +20998,8 @@ function decideLazyRow(args2) {
20924
20998
  let conditionalRefusal = null;
20925
20999
  for (const cond of rawConditionals) {
20926
21000
  const verdict = analyzeLazyConditional(cond, {
20927
- whenTrueHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
20928
- whenFalseHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId)
21001
+ whenTrueHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
21002
+ whenFalseHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId)
20929
21003
  });
20930
21004
  if (!verdict.lazySafe) {
20931
21005
  conditionalRefusal = verdict.reason;
@@ -21162,7 +21236,7 @@ function buildPlainRowCore(inputs) {
21162
21236
  scope
21163
21237
  }) ?? void 0;
21164
21238
  const mapPreambleWrappedFinal = !lazyRow && loop.index ? wrapIndexParamAsAccessor(mapPreambleWrapped, loop.index) : mapPreambleWrapped;
21165
- const templateFinal = !lazyRow && loop.index ? wrapIndexParamAsAccessor(loop.template, loop.index) : loop.template;
21239
+ const templateFinal = !lazyRow && loop.index ? loop.templateIndexed ?? loop.template : loop.template;
21166
21240
  return {
21167
21241
  indexParam,
21168
21242
  paramHead,
@@ -21396,6 +21470,22 @@ function emitAttrUpdate(target2, attrName, expression, meta) {
21396
21470
  `{ const __v = ${expression}; if (__v != null) ${target2}.setAttribute('${htmlName}', String(__v)); else ${target2}.removeAttribute('${htmlName}') }`
21397
21471
  ];
21398
21472
  }
21473
+ function dedupGuard(ordinal) {
21474
+ return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
21475
+ }
21476
+ function emitDedupedAttrUpdate(target2, attrName, expression, meta, ordinal, guard = dedupGuard(ordinal)) {
21477
+ const write = emitAttrUpdate(target2, attrName, "__x", meta);
21478
+ const lines = [`{ const __x = ${expression}`];
21479
+ if (guard) {
21480
+ lines.push(`if (${guard}) {`);
21481
+ for (const stmt of write) lines.push(` ${stmt}`);
21482
+ lines.push(`}`);
21483
+ } else {
21484
+ lines.push(...write);
21485
+ }
21486
+ lines.push(`__l[${ordinal}] = __x }`);
21487
+ return lines;
21488
+ }
21399
21489
  function rewriteDestructuredPropsInExpr(expr, ctx2) {
21400
21490
  if (ctx2.propsObjectName) return expr;
21401
21491
  const propNames = /* @__PURE__ */ new Set();
@@ -21598,16 +21688,18 @@ function emitReactiveAttributeUpdates(lines, ctx2) {
21598
21688
  }
21599
21689
  for (const [slotId, attrs] of attrsBySlot) {
21600
21690
  const v = varSlotId(slotId);
21691
+ lines.push(` { ${DEDUP_STORE_DECL}`);
21601
21692
  lines.push(` createEffect(() => {`);
21602
21693
  lines.push(` if (_${v}) {`);
21694
+ let ordinal = 0;
21603
21695
  for (const attr of attrs) {
21604
21696
  const expression = rewriteDestructuredPropsInExpr(lower(attr.expression), ctx2);
21605
- for (const stmt of emitAttrUpdate(`_${v}`, attr.attrName, expression, attr)) {
21697
+ for (const stmt of emitDedupedAttrUpdate(`_${v}`, attr.attrName, expression, attr, ordinal++)) {
21606
21698
  lines.push(` ${stmt}`);
21607
21699
  }
21608
21700
  }
21609
21701
  lines.push(` }`);
21610
- lines.push(` }${bindingIdArg(ctx2, slotId)})`);
21702
+ lines.push(` }${bindingIdArg(ctx2, slotId)}) }`);
21611
21703
  lines.push("");
21612
21704
  }
21613
21705
  }
@@ -21659,6 +21751,7 @@ function emitReactiveChildProps(lines, ctx2) {
21659
21751
  if (ctx2.reactiveChildProps.length > 0) {
21660
21752
  lines.push("");
21661
21753
  lines.push(` // Reactive child component props`);
21754
+ lines.push(` { ${DEDUP_STORE_DECL}`);
21662
21755
  lines.push(` createEffect(() => {`);
21663
21756
  const propsByComponent = /* @__PURE__ */ new Map();
21664
21757
  for (const prop of ctx2.reactiveChildProps) {
@@ -21668,6 +21761,7 @@ function emitReactiveChildProps(lines, ctx2) {
21668
21761
  }
21669
21762
  propsByComponent.get(key).push(prop);
21670
21763
  }
21764
+ let ordinal = 0;
21671
21765
  for (const [, props] of propsByComponent) {
21672
21766
  const first = props[0];
21673
21767
  const isCommentRoot = first.slotId !== null && first.slotId === ctx2.commentScopeRootSlotId;
@@ -21679,16 +21773,17 @@ function emitReactiveChildProps(lines, ctx2) {
21679
21773
  }
21680
21774
  lines.push(` if (${varName}) {`);
21681
21775
  for (const prop of props) {
21682
- const stmts = toHTMLAttrName(prop.attrName) === "value" ? emitChildValueMirrorStatements(varName, prop.expression) : emitAttrUpdate(varName, prop.attrName, prop.expression, prop);
21776
+ const stmts = toHTMLAttrName(prop.attrName) === "value" ? emitChildValueMirrorStatements(varName, prop.expression) : emitDedupedAttrUpdate(varName, prop.attrName, prop.expression, prop, ordinal++);
21683
21777
  for (const stmt of stmts) {
21684
21778
  lines.push(` ${stmt}`);
21685
21779
  }
21686
21780
  }
21687
21781
  lines.push(` }`);
21688
21782
  }
21689
- lines.push(` }${bindingIdArg(ctx2, ctx2.reactiveChildProps[0]?.slotId ?? void 0)})`);
21783
+ lines.push(` }${bindingIdArg(ctx2, ctx2.reactiveChildProps[0]?.slotId ?? void 0)}) }`);
21690
21784
  }
21691
21785
  }
21786
+ var DEDUP_STORE_DECL;
21692
21787
  var init_emit_reactive = __esm({
21693
21788
  "../jsx/src/ir-to-client-js/emit-reactive.ts"() {
21694
21789
  "use strict";
@@ -21701,18 +21796,24 @@ var init_emit_reactive = __esm({
21701
21796
  init_to_locale_date_lowering();
21702
21797
  init_expression_parser();
21703
21798
  init_prop_rewrite();
21799
+ DEDUP_STORE_DECL = "const __l = []";
21704
21800
  }
21705
21801
  });
21706
21802
 
21707
21803
  // ../jsx/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts
21708
- function stringifyBranchReactiveAttrs(lines, plan, indent, pc) {
21804
+ function stringifyBranchReactiveAttrs(lines, plan, indent, pc, mapPreambleWrapped) {
21709
21805
  for (const slot of plan) {
21710
21806
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21711
21807
  lines.push(`${indent}{ const ${varName} = qsa(__branchScope, '[bf="${slot.slotId}"]')`);
21808
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
21712
21809
  lines.push(`${indent}if (${varName}) {`);
21810
+ let ordinal = 0;
21713
21811
  for (const attr of slot.attrs) {
21714
21812
  lines.push(`${indent} __disposers.push(createDisposableEffect(() => {`);
21715
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
21813
+ if (attr.readsPreamble && mapPreambleWrapped) {
21814
+ lines.push(`${indent} ${mapPreambleWrapped}`);
21815
+ }
21816
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
21716
21817
  lines.push(`${indent} ${stmt}`);
21717
21818
  }
21718
21819
  lines.push(`${indent} }${profileBindingId(pc, slot.slotId)}))`);
@@ -21762,7 +21863,9 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
21762
21863
  [...inner.legacyComponents],
21763
21864
  [...inner.legacyEvents],
21764
21865
  inner.outerLoopParam,
21765
- inner.outerLoopParamBindings
21866
+ inner.outerLoopParamBindings,
21867
+ false,
21868
+ inner.outerLoopIndex
21766
21869
  );
21767
21870
  }
21768
21871
  const conditionalTexts = inner.reactiveTexts.filter((t) => t.insideConditional);
@@ -21780,42 +21883,45 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
21780
21883
  }
21781
21884
  }
21782
21885
  if (inner.nestedConditionals.length > 0) {
21783
- stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc);
21886
+ stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc, void 0);
21784
21887
  }
21785
21888
  lines.push(`${indent} return __bel${uid}`);
21786
21889
  lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!inner.wrappedKey, inner.keyDepth)}) }`);
21787
21890
  }
21788
21891
  }
21789
- function stringifyLoopChildConditionals(lines, conditionals, indent, pc) {
21892
+ function stringifyLoopChildConditionals(lines, conditionals, indent, pc, mapPreambleWrapped) {
21790
21893
  for (const cond of conditionals) {
21791
- stringifyLoopChildConditional(lines, cond, indent, pc);
21894
+ stringifyLoopChildConditional(lines, cond, indent, pc, mapPreambleWrapped);
21792
21895
  }
21793
21896
  }
21794
- function stringifyLoopChildConditional(lines, cond, indent, pc) {
21897
+ function conditionGetterExpr(wrappedCondition, readsPreamble, mapPreambleWrapped) {
21898
+ return readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${wrappedCondition}) }` : `() => ${wrappedCondition}`;
21899
+ }
21900
+ function stringifyLoopChildConditional(lines, cond, indent, pc, mapPreambleWrapped) {
21795
21901
  const armIndent = `${indent} `;
21796
- lines.push(`${indent}insert(${cond.scopeVar}, '${cond.slotId}', () => ${cond.wrappedCondition}, {`);
21902
+ lines.push(`${indent}insert(${cond.scopeVar}, '${cond.slotId}', ${conditionGetterExpr(cond.wrappedCondition, cond.readsPreamble, mapPreambleWrapped)}, {`);
21797
21903
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
21798
21904
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21799
- stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
21905
+ stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc, mapPreambleWrapped);
21800
21906
  lines.push(`${indent} }`);
21801
21907
  lines.push(`${indent}}, {`);
21802
21908
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenFalseTemplateHtml}\`, slots: __slots } },`);
21803
21909
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21804
- stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc);
21910
+ stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc, mapPreambleWrapped);
21805
21911
  lines.push(`${indent} }`);
21806
21912
  lines.push(`${indent}}${profileBindingId(pc, cond.slotId)})`);
21807
21913
  }
21808
- function stringifyLoopChildArm(lines, arm, armIndent, pc) {
21914
+ function stringifyLoopChildArm(lines, arm, armIndent, pc, mapPreambleWrapped) {
21809
21915
  stringifyBranchEventBindings(lines, arm.events, armIndent);
21810
21916
  stringifyBranchChildComponentInits(lines, arm.childComponents, armIndent);
21811
21917
  stringifyBranchInnerLoops(lines, arm.innerLoops, armIndent, pc);
21812
21918
  const hasDisposables = arm.attrs.length > 0 || arm.texts.length > 0 || arm.nestedConditionals.length > 0;
21813
21919
  if (!hasDisposables) return;
21814
21920
  lines.push(`${armIndent}const __disposers = []`);
21815
- stringifyBranchReactiveAttrs(lines, arm.attrs, armIndent, pc);
21921
+ stringifyBranchReactiveAttrs(lines, arm.attrs, armIndent, pc, mapPreambleWrapped);
21816
21922
  for (const cond of arm.nestedConditionals) {
21817
21923
  lines.push(`${armIndent}__disposers.push(createDisposableEffect(() => {`);
21818
- stringifyLoopChildConditional(lines, cond, `${armIndent} `, pc);
21924
+ stringifyLoopChildConditional(lines, cond, `${armIndent} `, pc, mapPreambleWrapped);
21819
21925
  lines.push(`${armIndent}}))`);
21820
21926
  }
21821
21927
  if (arm.texts.length > 0) {
@@ -21877,13 +21983,15 @@ function emitAttrSlotsGranular(lines, indent, elVar, lookup, attrSlots, elementI
21877
21983
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21878
21984
  const lookupExpr = attrLookupExpr(slot.slotId, varName, elVar, lookup, elementIndexBySlot);
21879
21985
  lines.push(`${indent}{ const ${varName} = ${lookupExpr}`);
21986
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
21880
21987
  lines.push(`${indent}if (${varName}) {`);
21988
+ let ordinal = 0;
21881
21989
  for (const attr of slot.attrs) {
21882
21990
  lines.push(`${indent} createEffect(() => {`);
21883
21991
  if (attr.readsPreamble && mapPreambleWrapped) {
21884
21992
  lines.push(`${indent} ${mapPreambleWrapped}`);
21885
21993
  }
21886
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
21994
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
21887
21995
  lines.push(`${indent} ${stmt}`);
21888
21996
  }
21889
21997
  lines.push(`${indent} }${bindingBfId(slot.slotId)})`);
@@ -21916,6 +22024,7 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
21916
22024
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21917
22025
  lines.push(`${indent}const ${varName} = ${attrLookupExpr(slot.slotId, varName, elVar, lookup, elementIndexBySlot)}`);
21918
22026
  }
22027
+ if (attrSlots.length > 0) lines.push(`${indent}${DEDUP_STORE_DECL}`);
21919
22028
  const claimSlots = [
21920
22029
  ...outerTexts.map((t) => ({ id: t.slotId, kind: "text", path: [], pathExpr: textClaimPathExprs?.get(t.slotId) })),
21921
22030
  ...preambleRegions.map((r2) => ({ id: r2.slotId, kind: "markup", path: [] }))
@@ -21933,15 +22042,14 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
21933
22042
  if (mapPreambleWrapped && (preambleRegions.length > 0 || attrsReadPreamble(attrSlots))) {
21934
22043
  lines.push(`${indent} ${mapPreambleWrapped}`);
21935
22044
  }
22045
+ let ordinal = 0;
21936
22046
  for (const slot of attrSlots) {
21937
22047
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21938
22048
  lines.push(`${indent} if (${varName}) {`);
21939
22049
  for (const attr of slot.attrs) {
21940
- lines.push(`${indent} {`);
21941
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
21942
- lines.push(`${indent} ${stmt}`);
22050
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
22051
+ lines.push(`${indent} ${stmt}`);
21943
22052
  }
21944
- lines.push(`${indent} }`);
21945
22053
  }
21946
22054
  lines.push(`${indent} }`);
21947
22055
  }
@@ -21969,16 +22077,16 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
21969
22077
  }
21970
22078
  function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
21971
22079
  const armIndent = `${indent} `;
21972
- const conditionGetter = cond.readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${cond.wrappedCondition}) }` : `() => ${cond.wrappedCondition}`;
22080
+ const conditionGetter = conditionGetterExpr(cond.wrappedCondition, cond.readsPreamble, mapPreambleWrapped);
21973
22081
  lines.push(`${indent}insert(${elVar}, '${cond.slotId}', ${conditionGetter}, {`);
21974
22082
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
21975
22083
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21976
- stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
22084
+ stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc, mapPreambleWrapped);
21977
22085
  lines.push(`${indent} }`);
21978
22086
  lines.push(`${indent}}, {`);
21979
22087
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenFalseTemplateHtml}\`, slots: __slots } },`);
21980
22088
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21981
- stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc);
22089
+ stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc, mapPreambleWrapped);
21982
22090
  lines.push(`${indent} }`);
21983
22091
  lines.push(`${indent}}${profileBindingId(pc, cond.slotId)})`);
21984
22092
  }
@@ -22244,22 +22352,14 @@ function emitConditional(lines, ind, mid, c, mode2) {
22244
22352
  lines.push(`${ind} __l[${c.ordinal}] = __x`);
22245
22353
  lines.push(`${ind}} }`);
22246
22354
  }
22247
- function dedupGuard(ordinal) {
22248
- return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
22249
- }
22250
22355
  function emitAttrBinding(lines, ind, a, mode2) {
22251
22356
  const target2 = mode2 === "create" ? `__r[${a.refIndex}]` : elementAccess(a);
22357
+ const guard = mode2 === "create" ? null : mode2 === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
22252
22358
  lines.push(`${ind}{ const __t = ${target2}`);
22253
22359
  lines.push(`${ind}if (__t) {`);
22254
- lines.push(`${ind} const __x = ${a.wrappedExpression}`);
22255
- const guard = mode2 === "create" ? null : mode2 === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
22256
- const writeIndent = guard ? `${ind} ` : `${ind} `;
22257
- if (guard) lines.push(`${ind} if (${guard}) {`);
22258
- for (const stmt of emitAttrUpdate("__t", a.attrName, "__x", a.meta)) {
22259
- lines.push(`${writeIndent}${stmt}`);
22360
+ for (const stmt of emitDedupedAttrUpdate("__t", a.attrName, a.wrappedExpression, a.meta, a.ordinal, guard)) {
22361
+ lines.push(`${ind} ${stmt}`);
22260
22362
  }
22261
- if (guard) lines.push(`${ind} }`);
22262
- lines.push(`${ind} __l[${a.ordinal}] = __x`);
22263
22363
  lines.push(`${ind}} }`);
22264
22364
  }
22265
22365
  function emitTextBinding(lines, ind, t, doorExpr, mode2, rwDoor) {
@@ -22546,13 +22646,15 @@ function stringifyStaticLoop(lines, plan) {
22546
22646
  lines.push(` }`);
22547
22647
  }
22548
22648
  lines.push(` if (__iterEl) {`);
22649
+ if (attrsBySlot.length > 0) lines.push(` ${DEDUP_STORE_DECL}`);
22650
+ let ordinal = 0;
22549
22651
  for (const [slotId, attrs] of attrsBySlot) {
22550
22652
  const varName = `__t_${varSlotId(slotId)}`;
22551
22653
  lines.push(` const ${varName} = qsa(__iterEl, '[bf="${slotId}"]')`);
22552
22654
  lines.push(` if (${varName}) {`);
22553
22655
  for (const attr of attrs) {
22554
22656
  lines.push(` createEffect(() => {`);
22555
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.expression, attr)) {
22657
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.expression, attr, ordinal++)) {
22556
22658
  lines.push(` ${stmt}`);
22557
22659
  }
22558
22660
  lines.push(` }${profileBindingId(pc, slotId)})`);
@@ -22591,17 +22693,12 @@ var init_loop = __esm({
22591
22693
  // ../jsx/src/ir-to-client-js/control-flow/stringify/inner-loop.ts
22592
22694
  function stringifyInnerLoops(lines, plan, indent, pc) {
22593
22695
  for (const inner of plan) {
22594
- if (inner.emit.mode === "reactive") {
22595
- emitReactive(lines, inner, indent, pc);
22596
- } else {
22597
- emitStatic(lines, inner, indent, pc);
22598
- }
22696
+ emitReactive(lines, inner, indent, pc);
22599
22697
  }
22600
22698
  }
22601
22699
  function emitReactive(lines, inner, indent, pc) {
22602
22700
  const uid = inner.uidSuffix;
22603
22701
  const emit = inner.emit;
22604
- if (emit.mode !== "reactive") return;
22605
22702
  lines.push(`${indent}// Reactive inner loop: ${inner.arraySrc}`);
22606
22703
  lines.push(`${indent}{ const __ic${uid} = ${inner.containerExpr}`);
22607
22704
  lines.push(`${indent}if (__ic${uid}) mapArray(() => ${inner.arrayExpr} || [], __ic${uid}, ${emit.keyFn}, (${emit.paramHead}, __innerIdx${uid}, __existing) => {`);
@@ -22633,7 +22730,9 @@ function emitReactive(lines, inner, indent, pc) {
22633
22730
  [...emit.components],
22634
22731
  [...emit.events],
22635
22732
  inner.outerLoopParam,
22636
- inner.outerLoopParamBindings
22733
+ inner.outerLoopParamBindings,
22734
+ false,
22735
+ inner.outerLoopIndex
22637
22736
  );
22638
22737
  }
22639
22738
  if (inner.childLevels.length > 0) {
@@ -22653,17 +22752,19 @@ function emitReactive(lines, inner, indent, pc) {
22653
22752
  lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${profileBindingId(pc, text.slotId)})`);
22654
22753
  }
22655
22754
  }
22755
+ if (emit.reactiveAttrs.length > 0) lines.push(`${indent} ${DEDUP_STORE_DECL}`);
22756
+ let attrOrdinal = 0;
22656
22757
  for (const attr of emit.reactiveAttrs) {
22657
22758
  const targetVar = `__ta_${attr.slotId.replace(/[^a-zA-Z0-9]/g, "_")}`;
22658
22759
  lines.push(`${indent} { const ${targetVar} = qsa(__innerEl${uid}, '[bf="${attr.slotId}"]')`);
22659
22760
  lines.push(`${indent} if (${targetVar}) createEffect(() => {`);
22660
- for (const stmt of emitAttrUpdate(targetVar, attr.attrName, attr.wrappedExpression, attr.meta)) {
22761
+ for (const stmt of emitDedupedAttrUpdate(targetVar, attr.attrName, attr.wrappedExpression, attr.meta, attrOrdinal++)) {
22661
22762
  lines.push(`${indent} ${stmt}`);
22662
22763
  }
22663
22764
  lines.push(`${indent} }${profileBindingId(pc, attr.slotId)}) }`);
22664
22765
  }
22665
22766
  if (emit.conditionals.length > 0) {
22666
- stringifyLoopChildConditionals(lines, emit.conditionals, `${indent} `, pc);
22767
+ stringifyLoopChildConditionals(lines, emit.conditionals, `${indent} `, pc, void 0);
22667
22768
  }
22668
22769
  emitLoopChildRefs(lines, emit.childRefs, {
22669
22770
  indent: `${indent} `,
@@ -22673,40 +22774,6 @@ function emitReactive(lines, inner, indent, pc) {
22673
22774
  lines.push(`${indent} return __innerEl${uid}`);
22674
22775
  lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!emit.wrappedKey, inner.keyDepth)}) }`);
22675
22776
  }
22676
- function emitStatic(lines, inner, indent, pc) {
22677
- const uid = inner.uidSuffix;
22678
- const emit = inner.emit;
22679
- if (emit.mode !== "static") return;
22680
- lines.push(`${indent}// Initialize ${inner.arraySrc} loop components and events`);
22681
- lines.push(`${indent}{ const __ic${uid} = ${inner.containerExpr}`);
22682
- lines.push(`${indent}if (__ic${uid} && ${inner.arrayExpr}) ${inner.arrayExpr}.forEach((${inner.param}, __innerIdx${uid}) => {`);
22683
- lines.push(`${indent} const __innerEl${uid} = __ic${uid}.children[__innerIdx${uid}]`);
22684
- lines.push(`${indent} if (!__innerEl${uid}) return`);
22685
- for (const stmt of emit.preludeStatements) {
22686
- lines.push(`${indent} ${stmt}`);
22687
- }
22688
- if (emit.rawKey) {
22689
- lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName2(inner.keyDepth)}', String(${emit.rawKey}))`);
22690
- }
22691
- emitComponentAndEventSetup(
22692
- lines,
22693
- `${indent} `,
22694
- `__innerEl${uid}`,
22695
- [...emit.components],
22696
- [...emit.events],
22697
- inner.outerLoopParam,
22698
- inner.outerLoopParamBindings
22699
- );
22700
- if (inner.childLevels.length > 0) {
22701
- stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc);
22702
- }
22703
- emitLoopChildRefs(lines, emit.childRefs, {
22704
- indent: `${indent} `,
22705
- elVar: `__innerEl${uid}`,
22706
- bodyIsMultiRoot: false
22707
- });
22708
- lines.push(`${indent}}) }`);
22709
- }
22710
22777
  var init_inner_loop = __esm({
22711
22778
  "../jsx/src/ir-to-client-js/control-flow/stringify/inner-loop.ts"() {
22712
22779
  "use strict";
@@ -23156,10 +23223,12 @@ function emitArmBody(lines, body2, mode2, indent, profileComponentName) {
23156
23223
  const v = varSlotId(slotId);
23157
23224
  const elVar = `__ra_${v}`;
23158
23225
  lines.push(`${indent}{ const ${elVar} = qsa(__branchScope, '[bf="${slotId}"]')`);
23226
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
23159
23227
  lines.push(`${indent}if (${elVar}) {`);
23228
+ let ordinal = 0;
23160
23229
  for (const attr of attrs) {
23161
23230
  lines.push(`${indent} __disposers.push(createDisposableEffect(() => {`);
23162
- for (const stmt of emitAttrUpdate(elVar, attr.attrName, attr.expression, attr)) {
23231
+ for (const stmt of emitDedupedAttrUpdate(elVar, attr.attrName, attr.expression, attr, ordinal++)) {
23163
23232
  lines.push(`${indent} ${stmt}`);
23164
23233
  }
23165
23234
  lines.push(`${indent} }${bindingBfId(slotId)}))`);