@suss/adapter-typescript 0.22.1 → 0.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -75,7 +75,7 @@ module.exports = __toCommonJS(index_exports);
75
75
  // src/adapter.ts
76
76
  var import_node_path10 = __toESM(require("path"), 1);
77
77
  var import_ts_morph66 = require("ts-morph");
78
- var import_behavioral_ir9 = require("@suss/behavioral-ir");
78
+ var import_behavioral_ir8 = require("@suss/behavioral-ir");
79
79
  var import_datalog6 = require("@suss/datalog");
80
80
  var import_extractor11 = require("@suss/extractor");
81
81
 
@@ -712,14 +712,14 @@ function parseConditionExpression(expr, depth = 0) {
712
712
  if (expr.getOperatorToken() !== import_ts_morph5.SyntaxKind.ExclamationToken) {
713
713
  return null;
714
714
  }
715
- const operand = expr.getOperand();
716
- const inner = parseConditionExpression(operand, depth);
715
+ const operand2 = expr.getOperand();
716
+ const inner = parseConditionExpression(operand2, depth);
717
717
  if (inner === null) {
718
718
  return {
719
719
  type: "negation",
720
720
  operand: {
721
721
  type: "opaque",
722
- sourceText: operand.getText(),
722
+ sourceText: operand2.getText(),
723
723
  reason: "complexExpression"
724
724
  }
725
725
  };
@@ -783,8 +783,8 @@ function parseConditionExpression(expr, depth = 0) {
783
783
  const rightIsNull = isNullOrUndefined(right);
784
784
  if (leftIsNull || rightIsNull) {
785
785
  const subject = resolveSubject(leftIsNull ? right : left);
786
- const negated = op === "neq";
787
- return { type: "nullCheck", subject, negated };
786
+ const negated2 = op === "neq";
787
+ return { type: "nullCheck", subject, negated: negated2 };
788
788
  }
789
789
  }
790
790
  if (import_ts_morph5.Node.isTypeOfExpression(left) && import_ts_morph5.Node.isStringLiteral(right) && (opText === "===" || opText === "==")) {
@@ -2599,7 +2599,7 @@ function isNotYetPlaceholder(value) {
2599
2599
  return value.getKind() === import_ts_morph14.SyntaxKind.NullKeyword || import_ts_morph14.Node.isIdentifier(value) && value.getText() === "undefined";
2600
2600
  }
2601
2601
  function isConstruction(value) {
2602
- return import_ts_morph14.Node.isCallExpression(value) || import_ts_morph14.Node.isNewExpression(value);
2602
+ return import_ts_morph14.Node.isCallExpression(value) || import_ts_morph14.Node.isNewExpression(value) || import_ts_morph14.Node.isObjectLiteralExpression(value) || import_ts_morph14.Node.isArrayLiteralExpression(value);
2603
2603
  }
2604
2604
  function sourceOf(node) {
2605
2605
  return node.getText().replace(/\s+/g, " ").trim();
@@ -3070,10 +3070,10 @@ function emitValue(db, table, value) {
3070
3070
  }
3071
3071
  return id;
3072
3072
  }
3073
- const fallback = asFallbackExpression(expression);
3074
- if (fallback !== null) {
3075
- fact(db, "fallbackBranch", id, emitValue(db, table, fallback.getLeft()));
3076
- fact(db, "fallbackBranch", id, emitValue(db, table, fallback.getRight()));
3073
+ const fallback2 = asFallbackExpression(expression);
3074
+ if (fallback2 !== null) {
3075
+ fact(db, "fallbackBranch", id, emitValue(db, table, fallback2.getLeft()));
3076
+ fact(db, "fallbackBranch", id, emitValue(db, table, fallback2.getRight()));
3077
3077
  return id;
3078
3078
  }
3079
3079
  if (import_ts_morph15.Node.isCallExpression(expression) || import_ts_morph15.Node.isNewExpression(expression)) {
@@ -3161,9 +3161,9 @@ function emitBindingElementFacts(db, table, element) {
3161
3161
  property.getText()
3162
3162
  );
3163
3163
  }
3164
- const fallback = element.getInitializer();
3165
- if (fallback !== void 0) {
3166
- fact(db, "binds", id, emitValue(db, table, fallback));
3164
+ const fallback2 = element.getInitializer();
3165
+ if (fallback2 !== void 0) {
3166
+ fact(db, "binds", id, emitValue(db, table, fallback2));
3167
3167
  }
3168
3168
  return id;
3169
3169
  }
@@ -4368,7 +4368,7 @@ function declarationOf(value) {
4368
4368
  }
4369
4369
 
4370
4370
  // src/discovery/clientCall.ts
4371
- var import_ts_morph19 = require("ts-morph");
4371
+ var import_ts_morph20 = require("ts-morph");
4372
4372
 
4373
4373
  // src/discovery/importScan.ts
4374
4374
  var import_node_path3 = __toESM(require("path"), 1);
@@ -4392,8 +4392,8 @@ function commonDirectoryOf(files) {
4392
4392
  }
4393
4393
  shared = shared.slice(0, i);
4394
4394
  }
4395
- const joined = shared.join(import_node_path2.default.sep);
4396
- return joined.length > 1 ? joined : void 0;
4395
+ const joined2 = shared.join(import_node_path2.default.sep);
4396
+ return joined2.length > 1 ? joined2 : void 0;
4397
4397
  }
4398
4398
  var DEFAULT_RESOLUTION = {
4399
4399
  moduleResolution: import_ts_morph17.ts.ModuleResolutionKind.Bundler,
@@ -4658,17 +4658,616 @@ function resolveImportedLocalName(sourceFile, importModule, importName) {
4658
4658
  }
4659
4659
  return null;
4660
4660
  }
4661
+ function importedReferenceSpellings(sourceFile, importModule, importName) {
4662
+ const spellings = [];
4663
+ const localName = resolveImportedLocalName(
4664
+ sourceFile,
4665
+ importModule,
4666
+ importName
4667
+ );
4668
+ if (localName !== null) {
4669
+ spellings.push(localName);
4670
+ }
4671
+ if (!sourceFile.getFullText().includes(`.${importName}`)) {
4672
+ return spellings;
4673
+ }
4674
+ for (const root of importedRootsOf(sourceFile, [importModule])) {
4675
+ if (root !== importName) {
4676
+ spellings.push(`${root}.${importName}`);
4677
+ }
4678
+ }
4679
+ return spellings;
4680
+ }
4661
4681
 
4662
4682
  // src/discovery/resolveValue.ts
4683
+ var import_ts_morph19 = require("ts-morph");
4684
+ var import_values3 = require("@suss/values");
4685
+
4686
+ // src/values/evaluator.ts
4687
+ var import_values2 = require("@suss/values");
4688
+
4689
+ // src/values/lowering.ts
4663
4690
  var import_ts_morph18 = require("ts-morph");
4691
+ var ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set([
4692
+ "=",
4693
+ "+=",
4694
+ "-=",
4695
+ "*=",
4696
+ "/=",
4697
+ "??=",
4698
+ "||=",
4699
+ "&&="
4700
+ ]);
4701
+ var MUTATING_METHODS = /* @__PURE__ */ new Set([
4702
+ "push",
4703
+ "pop",
4704
+ "shift",
4705
+ "unshift",
4706
+ "splice",
4707
+ "sort",
4708
+ "reverse",
4709
+ "fill",
4710
+ "copyWithin"
4711
+ ]);
4712
+ function typescriptLowering(options) {
4713
+ const { resolution, rows } = options;
4714
+ const rowModules = [
4715
+ ...new Set(
4716
+ rows.flatMap((row) => row.kind === "callee" ? [row.origin.module] : [])
4717
+ )
4718
+ ];
4719
+ const mutatedByRoot = /* @__PURE__ */ new Map();
4720
+ const originOf = (callee) => {
4721
+ const chain = memberChainOf(callee);
4722
+ if (chain === null) {
4723
+ return null;
4724
+ }
4725
+ const name = chain.names[chain.names.length - 1] ?? null;
4726
+ if (name === null) {
4727
+ return null;
4728
+ }
4729
+ const origins = resolution?.importOriginsOf(chain.root, rowModules) ?? [];
4730
+ const first = origins[0];
4731
+ if (first !== void 0) {
4732
+ return { module: first.module, name };
4733
+ }
4734
+ const local = resolution !== void 0 && resolution.resolveCallable(callee) !== null;
4735
+ if (chain.names.length > 1 || local) {
4736
+ return null;
4737
+ }
4738
+ return { module: "global", name };
4739
+ };
4740
+ return {
4741
+ expression: (node) => expressionOf(peelValue(node), originOf),
4742
+ statement: statementOf2,
4743
+ siteOf,
4744
+ functionOf,
4745
+ writtenTo: (node) => {
4746
+ if (resolution === void 0) {
4747
+ return null;
4748
+ }
4749
+ const target = peelValue(node);
4750
+ return resolution.resolveWrittenValue(target) ?? resolution.resolveObject(target);
4751
+ },
4752
+ callable: (node) => {
4753
+ const call = peelValue(node);
4754
+ if (resolution === void 0 || !import_ts_morph18.Node.isCallExpression(call) && !import_ts_morph18.Node.isNewExpression(call)) {
4755
+ return null;
4756
+ }
4757
+ const target = resolution.resolveCallable(call.getExpression());
4758
+ return target !== null && import_ts_morph18.Node.isFunctionLikeDeclaration(target) ? target : null;
4759
+ },
4760
+ mutatedInNestedFunction: (root, name) => {
4761
+ let mutated = mutatedByRoot.get(root);
4762
+ if (mutated === void 0) {
4763
+ mutated = namesMutatedInNestedFunctions(root);
4764
+ mutatedByRoot.set(root, mutated);
4765
+ }
4766
+ return mutated.has(name);
4767
+ },
4768
+ freeNamesOf,
4769
+ holeNameOf: placeholderName,
4770
+ rows
4771
+ };
4772
+ }
4773
+ function placeholderName(expr) {
4774
+ if (import_ts_morph18.Node.isIdentifier(expr)) {
4775
+ return expr.getText();
4776
+ }
4777
+ if (import_ts_morph18.Node.isPropertyAccessExpression(expr)) {
4778
+ return expr.getName();
4779
+ }
4780
+ return "param";
4781
+ }
4782
+ function expressionOf(node, originOf) {
4783
+ if (import_ts_morph18.Node.isStringLiteral(node) || import_ts_morph18.Node.isNoSubstitutionTemplateLiteral(node)) {
4784
+ return { kind: "literal", value: node.getLiteralValue() };
4785
+ }
4786
+ if (import_ts_morph18.Node.isNumericLiteral(node)) {
4787
+ return { kind: "literal", value: node.getLiteralValue() };
4788
+ }
4789
+ if (import_ts_morph18.Node.isTrueLiteral(node)) {
4790
+ return { kind: "literal", value: true };
4791
+ }
4792
+ if (import_ts_morph18.Node.isFalseLiteral(node)) {
4793
+ return { kind: "literal", value: false };
4794
+ }
4795
+ if (import_ts_morph18.Node.isNullLiteral(node)) {
4796
+ return { kind: "literal", value: null };
4797
+ }
4798
+ if (import_ts_morph18.Node.isIdentifier(node)) {
4799
+ return node.getText() === "undefined" ? { kind: "literal", value: void 0 } : { kind: "name", text: node.getText() };
4800
+ }
4801
+ if (import_ts_morph18.Node.isTemplateExpression(node)) {
4802
+ return {
4803
+ kind: "template",
4804
+ parts: [
4805
+ { text: node.getHead().getLiteralText() },
4806
+ ...node.getTemplateSpans().flatMap((span) => [
4807
+ { expression: span.getExpression() },
4808
+ { text: span.getLiteral().getLiteralText() }
4809
+ ])
4810
+ ]
4811
+ };
4812
+ }
4813
+ if (import_ts_morph18.Node.isPropertyAccessExpression(node)) {
4814
+ return {
4815
+ kind: "member",
4816
+ object: node.getExpression(),
4817
+ name: node.getName()
4818
+ };
4819
+ }
4820
+ if (import_ts_morph18.Node.isElementAccessExpression(node)) {
4821
+ const index = node.getArgumentExpression();
4822
+ return index === void 0 ? { kind: "opaque" } : { kind: "element", object: node.getExpression(), index };
4823
+ }
4824
+ if (import_ts_morph18.Node.isArrayLiteralExpression(node)) {
4825
+ return { kind: "array", items: node.getElements().map(elementOf) };
4826
+ }
4827
+ if (import_ts_morph18.Node.isObjectLiteralExpression(node)) {
4828
+ return { kind: "record", fields: node.getProperties().flatMap(fieldOf) };
4829
+ }
4830
+ if (import_ts_morph18.Node.isCallExpression(node) || import_ts_morph18.Node.isNewExpression(node)) {
4831
+ return {
4832
+ kind: "call",
4833
+ callee: calleeOf(node.getExpression(), originOf),
4834
+ args: node.getArguments().map(elementOf),
4835
+ constructs: import_ts_morph18.Node.isNewExpression(node)
4836
+ };
4837
+ }
4838
+ if (import_ts_morph18.Node.isBinaryExpression(node)) {
4839
+ const operator = node.getOperatorToken().getText();
4840
+ return ASSIGNMENT_OPERATORS.has(operator) ? { kind: "opaque" } : {
4841
+ kind: "operator",
4842
+ operator,
4843
+ operands: [node.getLeft(), node.getRight()]
4844
+ };
4845
+ }
4846
+ if (import_ts_morph18.Node.isPrefixUnaryExpression(node)) {
4847
+ const operator = node.getOperatorToken();
4848
+ return operator === import_ts_morph18.SyntaxKind.ExclamationToken ? { kind: "operator", operator: "!", operands: [node.getOperand()] } : { kind: "opaque" };
4849
+ }
4850
+ if (import_ts_morph18.Node.isConditionalExpression(node)) {
4851
+ return {
4852
+ kind: "conditional",
4853
+ condition: node.getCondition(),
4854
+ whenTrue: node.getWhenTrue(),
4855
+ whenFalse: node.getWhenFalse()
4856
+ };
4857
+ }
4858
+ if (import_ts_morph18.Node.isArrowFunction(node) || import_ts_morph18.Node.isFunctionExpression(node)) {
4859
+ return { kind: "function", node };
4860
+ }
4861
+ return { kind: "opaque" };
4862
+ }
4863
+ function elementOf(node) {
4864
+ return import_ts_morph18.Node.isSpreadElement(node) ? { kind: "spread", node: node.getExpression() } : { kind: "value", node };
4865
+ }
4866
+ function fieldOf(property) {
4867
+ if (import_ts_morph18.Node.isSpreadAssignment(property)) {
4868
+ return [{ kind: "spread", node: property.getExpression() }];
4869
+ }
4870
+ if (import_ts_morph18.Node.isShorthandPropertyAssignment(property)) {
4871
+ const nameNode2 = property.getNameNode();
4872
+ return [{ kind: "field", name: nameNode2.getText(), value: nameNode2 }];
4873
+ }
4874
+ if (!import_ts_morph18.Node.isPropertyAssignment(property)) {
4875
+ return [];
4876
+ }
4877
+ const value = property.getInitializer();
4878
+ if (value === void 0) {
4879
+ return [];
4880
+ }
4881
+ const nameNode = property.getNameNode();
4882
+ if (import_ts_morph18.Node.isComputedPropertyName(nameNode)) {
4883
+ return [{ kind: "computed", name: nameNode.getExpression(), value }];
4884
+ }
4885
+ const name = import_ts_morph18.Node.isStringLiteral(nameNode) || import_ts_morph18.Node.isNumericLiteral(nameNode) ? String(nameNode.getLiteralValue()) : nameNode.getText();
4886
+ return [{ kind: "field", name, value }];
4887
+ }
4888
+ function calleeOf(expression, originOf) {
4889
+ const callee = peelValue(expression);
4890
+ if (import_ts_morph18.Node.isPropertyAccessExpression(callee)) {
4891
+ return {
4892
+ receiver: callee.getExpression(),
4893
+ name: callee.getName(),
4894
+ origin: () => originOf(callee)
4895
+ };
4896
+ }
4897
+ if (import_ts_morph18.Node.isIdentifier(callee)) {
4898
+ return {
4899
+ receiver: null,
4900
+ name: callee.getText(),
4901
+ origin: () => originOf(callee)
4902
+ };
4903
+ }
4904
+ return { receiver: null, name: null, origin: () => null };
4905
+ }
4906
+ function memberChainOf(node) {
4907
+ const names = [];
4908
+ let current2 = peelValue(node);
4909
+ while (import_ts_morph18.Node.isPropertyAccessExpression(current2)) {
4910
+ names.unshift(current2.getName());
4911
+ current2 = peelValue(current2.getExpression());
4912
+ }
4913
+ if (!import_ts_morph18.Node.isIdentifier(current2)) {
4914
+ return null;
4915
+ }
4916
+ return { root: current2, names: [current2.getText(), ...names] };
4917
+ }
4918
+ function statementOf2(node) {
4919
+ if (import_ts_morph18.Node.isVariableStatement(node)) {
4920
+ return {
4921
+ kind: "declare",
4922
+ bindings: node.getDeclarationList().getDeclarations().flatMap(
4923
+ (declaration) => declarationsOf2(
4924
+ declaration.getNameNode(),
4925
+ declaration.getInitializer() ?? null
4926
+ )
4927
+ )
4928
+ };
4929
+ }
4930
+ if (import_ts_morph18.Node.isExpressionStatement(node)) {
4931
+ const expression = peelValue(node.getExpression());
4932
+ if (import_ts_morph18.Node.isBinaryExpression(expression)) {
4933
+ const operator = expression.getOperatorToken().getText();
4934
+ if (ASSIGNMENT_OPERATORS.has(operator)) {
4935
+ return {
4936
+ kind: "assign",
4937
+ target: expression.getLeft(),
4938
+ operator: operator === "=" ? null : operator.slice(0, -1),
4939
+ value: expression.getRight()
4940
+ };
4941
+ }
4942
+ }
4943
+ return { kind: "expression", value: node.getExpression() };
4944
+ }
4945
+ if (import_ts_morph18.Node.isIfStatement(node)) {
4946
+ const otherwise = node.getElseStatement();
4947
+ return {
4948
+ kind: "branch",
4949
+ condition: node.getExpression(),
4950
+ arms: [
4951
+ armOf(node.getThenStatement()),
4952
+ otherwise === void 0 ? [] : armOf(otherwise)
4953
+ ]
4954
+ };
4955
+ }
4956
+ if (import_ts_morph18.Node.isSwitchStatement(node)) {
4957
+ return {
4958
+ kind: "branch",
4959
+ condition: null,
4960
+ arms: node.getClauses().map((clause) => clause.getStatements())
4961
+ };
4962
+ }
4963
+ if (import_ts_morph18.Node.isIterationStatement(node)) {
4964
+ return { kind: "loop", body: armOf(node.getStatement()) };
4965
+ }
4966
+ if (import_ts_morph18.Node.isReturnStatement(node)) {
4967
+ return { kind: "return", value: node.getExpression() ?? null };
4968
+ }
4969
+ if (import_ts_morph18.Node.isBlock(node)) {
4970
+ return { kind: "block", body: node.getStatements() };
4971
+ }
4972
+ if (import_ts_morph18.Node.isTryStatement(node)) {
4973
+ return {
4974
+ kind: "block",
4975
+ body: [
4976
+ ...node.getTryBlock().getStatements(),
4977
+ ...node.getFinallyBlock()?.getStatements() ?? []
4978
+ ]
4979
+ };
4980
+ }
4981
+ return { kind: "opaque" };
4982
+ }
4983
+ function armOf(statement) {
4984
+ return import_ts_morph18.Node.isBlock(statement) ? statement.getStatements() : [statement];
4985
+ }
4986
+ function declarationsOf2(nameNode, value) {
4987
+ if (import_ts_morph18.Node.isIdentifier(nameNode)) {
4988
+ return [{ name: nameNode.getText(), value }];
4989
+ }
4990
+ if (import_ts_morph18.Node.isObjectBindingPattern(nameNode) || import_ts_morph18.Node.isArrayBindingPattern(nameNode)) {
4991
+ return nameNode.getElements().flatMap(
4992
+ (element) => import_ts_morph18.Node.isBindingElement(element) ? declarationsOf2(element.getNameNode(), null) : []
4993
+ );
4994
+ }
4995
+ return [];
4996
+ }
4997
+ function isRoot(node) {
4998
+ return import_ts_morph18.Node.isSourceFile(node) || import_ts_morph18.Node.isFunctionLikeDeclaration(node);
4999
+ }
5000
+ function isStandaloneBlock(node) {
5001
+ const parent = node.getParent();
5002
+ return parent !== void 0 && (import_ts_morph18.Node.isBlock(parent) || import_ts_morph18.Node.isSourceFile(parent) || import_ts_morph18.Node.isModuleBlock(parent) || import_ts_morph18.Node.isCaseClause(parent) || import_ts_morph18.Node.isDefaultClause(parent));
5003
+ }
5004
+ function isPathStatement(node) {
5005
+ if (import_ts_morph18.Node.isBlock(node)) {
5006
+ return isStandaloneBlock(node);
5007
+ }
5008
+ return import_ts_morph18.Node.isStatement(node) && !import_ts_morph18.Node.isFunctionDeclaration(node);
5009
+ }
5010
+ function siteOf(node) {
5011
+ const path14 = [];
5012
+ let current2 = node;
5013
+ for (; ; ) {
5014
+ const parent = current2.getParent();
5015
+ if (parent === void 0) {
5016
+ return null;
5017
+ }
5018
+ if (isPathStatement(current2)) {
5019
+ path14.unshift(current2);
5020
+ }
5021
+ if (isRoot(parent)) {
5022
+ return { root: parent, path: path14 };
5023
+ }
5024
+ current2 = parent;
5025
+ }
5026
+ }
5027
+ function functionOf(node) {
5028
+ if (import_ts_morph18.Node.isSourceFile(node)) {
5029
+ return { parameters: [], body: node.getStatements() };
5030
+ }
5031
+ if (!import_ts_morph18.Node.isFunctionLikeDeclaration(node)) {
5032
+ return null;
5033
+ }
5034
+ const parameters = node.getParameters().flatMap((parameter) => {
5035
+ const nameNode = parameter.getNameNode();
5036
+ return import_ts_morph18.Node.isIdentifier(nameNode) ? [
5037
+ {
5038
+ name: nameNode.getText(),
5039
+ default: parameter.getInitializer() ?? null
5040
+ }
5041
+ ] : [];
5042
+ });
5043
+ const body = import_ts_morph18.Node.isBodied(node) ? node.getBody() : import_ts_morph18.Node.isBodyable(node) ? node.getBody() : void 0;
5044
+ if (body === void 0) {
5045
+ return { parameters, body: [] };
5046
+ }
5047
+ return import_ts_morph18.Node.isBlock(body) ? { parameters, body: body.getStatements() } : { parameters, body: { expression: body } };
5048
+ }
5049
+ function namesMutatedInNestedFunctions(root) {
5050
+ const mutated = /* @__PURE__ */ new Set();
5051
+ root.forEachDescendant((descendant) => {
5052
+ const written = writtenNameOf(descendant);
5053
+ if (written !== null && enclosingRootOf(descendant) !== root) {
5054
+ mutated.add(written);
5055
+ }
5056
+ });
5057
+ return mutated;
5058
+ }
5059
+ function writtenNameOf(node) {
5060
+ if (import_ts_morph18.Node.isBinaryExpression(node)) {
5061
+ const target = peelValue(node.getLeft());
5062
+ return ASSIGNMENT_OPERATORS.has(node.getOperatorToken().getText()) && import_ts_morph18.Node.isIdentifier(target) ? target.getText() : null;
5063
+ }
5064
+ if (import_ts_morph18.Node.isPostfixUnaryExpression(node) || import_ts_morph18.Node.isPrefixUnaryExpression(node)) {
5065
+ const operand2 = peelValue(node.getOperand());
5066
+ return import_ts_morph18.Node.isIdentifier(operand2) ? operand2.getText() : null;
5067
+ }
5068
+ if (import_ts_morph18.Node.isCallExpression(node)) {
5069
+ const callee = peelValue(node.getExpression());
5070
+ if (!import_ts_morph18.Node.isPropertyAccessExpression(callee)) {
5071
+ return null;
5072
+ }
5073
+ const receiver = peelValue(callee.getExpression());
5074
+ return MUTATING_METHODS.has(callee.getName()) && import_ts_morph18.Node.isIdentifier(receiver) ? receiver.getText() : null;
5075
+ }
5076
+ return null;
5077
+ }
5078
+ function enclosingRootOf(node) {
5079
+ let current2 = node.getParent();
5080
+ while (current2 !== void 0 && !isRoot(current2)) {
5081
+ current2 = current2.getParent();
5082
+ }
5083
+ return current2;
5084
+ }
5085
+ function freeNamesOf(fn) {
5086
+ const declared = /* @__PURE__ */ new Set();
5087
+ const read2 = /* @__PURE__ */ new Set();
5088
+ fn.forEachDescendant((descendant) => {
5089
+ if (!import_ts_morph18.Node.isIdentifier(descendant)) {
5090
+ return;
5091
+ }
5092
+ const parent = descendant.getParent();
5093
+ if (import_ts_morph18.Node.isPropertyAccessExpression(parent) && parent.getNameNode() === descendant) {
5094
+ return;
5095
+ }
5096
+ if (import_ts_morph18.Node.isVariableDeclaration(parent) || import_ts_morph18.Node.isParameterDeclaration(parent) || import_ts_morph18.Node.isBindingElement(parent) || import_ts_morph18.Node.isFunctionDeclaration(parent)) {
5097
+ declared.add(descendant.getText());
5098
+ return;
5099
+ }
5100
+ if (import_ts_morph18.Node.isPropertyAssignment(parent) && parent.getNameNode() === descendant) {
5101
+ return;
5102
+ }
5103
+ read2.add(descendant.getText());
5104
+ });
5105
+ return [...read2].filter((name) => !declared.has(name));
5106
+ }
5107
+
5108
+ // src/values/rows.ts
5109
+ var import_values = require("@suss/values");
5110
+ var PATH_MODULES = ["path", "node:path", "path/posix", "node:path/posix"];
5111
+ var operatorRows = [
5112
+ {
5113
+ kind: "operator",
5114
+ operator: "+",
5115
+ arity: 2,
5116
+ apply: ([a, b]) => (0, import_values.plus)((0, import_values.operand)(a), (0, import_values.operand)(b))
5117
+ },
5118
+ {
5119
+ kind: "operator",
5120
+ operator: "===",
5121
+ arity: 2,
5122
+ apply: ([a, b]) => (0, import_values.equals)((0, import_values.operand)(a), (0, import_values.operand)(b))
5123
+ },
5124
+ {
5125
+ kind: "operator",
5126
+ operator: "==",
5127
+ arity: 2,
5128
+ apply: ([a, b]) => (0, import_values.equals)((0, import_values.operand)(a), (0, import_values.operand)(b))
5129
+ },
5130
+ {
5131
+ kind: "operator",
5132
+ operator: "!==",
5133
+ arity: 2,
5134
+ apply: ([a, b]) => (0, import_values.negated)((0, import_values.equals)((0, import_values.operand)(a), (0, import_values.operand)(b)))
5135
+ },
5136
+ {
5137
+ kind: "operator",
5138
+ operator: "!=",
5139
+ arity: 2,
5140
+ apply: ([a, b]) => (0, import_values.negated)((0, import_values.equals)((0, import_values.operand)(a), (0, import_values.operand)(b)))
5141
+ },
5142
+ {
5143
+ kind: "operator",
5144
+ operator: "!",
5145
+ arity: 1,
5146
+ apply: ([a]) => (0, import_values.negated)((0, import_values.operand)(a))
5147
+ },
5148
+ {
5149
+ kind: "operator",
5150
+ operator: "??",
5151
+ arity: 2,
5152
+ apply: ([a, b]) => (0, import_values.readableFallback)((0, import_values.operand)(a), (0, import_values.operand)(b), import_values.isPresent)
5153
+ },
5154
+ {
5155
+ kind: "operator",
5156
+ operator: "||",
5157
+ arity: 2,
5158
+ apply: ([a, b]) => (0, import_values.readableFallback)((0, import_values.operand)(a), (0, import_values.operand)(b), import_values.truthOf)
5159
+ },
5160
+ {
5161
+ kind: "operator",
5162
+ operator: "&&",
5163
+ arity: 2,
5164
+ apply: ([a, b]) => (0, import_values.fallback)((0, import_values.operand)(a), (0, import_values.operand)(b), (left) => {
5165
+ const truth = (0, import_values.truthOf)(left);
5166
+ return truth === null ? null : !truth;
5167
+ })
5168
+ }
5169
+ ];
5170
+ var stringRows = [
5171
+ {
5172
+ kind: "method",
5173
+ method: "toString",
5174
+ on: "string",
5175
+ apply: () => ({ result: "receiver" })
5176
+ },
5177
+ {
5178
+ kind: "method",
5179
+ method: "toString",
5180
+ on: "constant",
5181
+ apply: ({ receiver }) => ({ result: (0, import_values.concat)([(0, import_values.operand)(receiver)]) })
5182
+ },
5183
+ {
5184
+ kind: "method",
5185
+ method: "concat",
5186
+ on: "string",
5187
+ apply: ({ receiver, args }) => ({
5188
+ result: (0, import_values.concat)([(0, import_values.operand)(receiver), ...args])
5189
+ })
5190
+ }
5191
+ ];
5192
+ var sequenceRows = ["sequence", "unbounded"].flatMap((on) => [
5193
+ {
5194
+ kind: "method",
5195
+ method: "push",
5196
+ on,
5197
+ apply: ({ receiver, args }) => ({
5198
+ result: (0, import_values.constant)(0),
5199
+ receiver: (0, import_values.appended)((0, import_values.operand)(receiver), args)
5200
+ })
5201
+ },
5202
+ {
5203
+ kind: "method",
5204
+ method: "concat",
5205
+ on,
5206
+ apply: ({ receiver, args, contentOf }) => ({
5207
+ result: args.reduce(
5208
+ (sequence, other) => (0, import_values.extended)(sequence, contentOf(other)),
5209
+ (0, import_values.operand)(receiver)
5210
+ )
5211
+ })
5212
+ },
5213
+ {
5214
+ kind: "method",
5215
+ method: "join",
5216
+ on,
5217
+ apply: ({ receiver, args }) => ({
5218
+ result: (0, import_values.joined)((0, import_values.operand)(receiver), args[0])
5219
+ })
5220
+ }
5221
+ ]);
5222
+ var calleeRows = [
5223
+ {
5224
+ kind: "callee",
5225
+ origin: { module: "global", name: "String" },
5226
+ apply: ({ args }) => ({ result: (0, import_values.concat)([(0, import_values.operand)(args[0])]) })
5227
+ },
5228
+ ...PATH_MODULES.map(
5229
+ (module2) => ({
5230
+ kind: "callee",
5231
+ origin: { module: module2, name: "join" },
5232
+ apply: ({ args }) => ({ result: (0, import_values.joinedPath)(args) })
5233
+ })
5234
+ )
5235
+ ];
5236
+ var typescriptRows = [
5237
+ ...operatorRows,
5238
+ ...stringRows,
5239
+ ...sequenceRows,
5240
+ ...calleeRows
5241
+ ];
5242
+
5243
+ // src/values/evaluator.ts
5244
+ var evaluators = /* @__PURE__ */ new WeakMap();
5245
+ function evaluatorFor(node, resolution) {
5246
+ const key = resolution ?? node.getProject();
5247
+ let evaluator = evaluators.get(key);
5248
+ if (evaluator === void 0) {
5249
+ evaluator = new import_values2.Evaluator(
5250
+ typescriptLowering(
5251
+ resolution === void 0 ? { rows: typescriptRows } : { resolution, rows: typescriptRows }
5252
+ )
5253
+ );
5254
+ evaluators.set(key, evaluator);
5255
+ }
5256
+ return evaluator;
5257
+ }
5258
+ function evaluatedValue(node, resolution) {
5259
+ return (0, import_values2.force)(evaluatorFor(node, resolution).evaluate(node));
5260
+ }
5261
+
5262
+ // src/discovery/resolveValue.ts
4664
5263
  function couldNameAValue(value) {
4665
- return import_ts_morph18.Node.isIdentifier(value) || import_ts_morph18.Node.isPropertyAccessExpression(value) || import_ts_morph18.Node.isElementAccessExpression(value) || import_ts_morph18.Node.isCallExpression(value);
5264
+ return import_ts_morph19.Node.isIdentifier(value) || import_ts_morph19.Node.isPropertyAccessExpression(value) || import_ts_morph19.Node.isElementAccessExpression(value) || import_ts_morph19.Node.isCallExpression(value);
4666
5265
  }
4667
5266
  function propertyValueOf(property) {
4668
- if (import_ts_morph18.Node.isPropertyAssignment(property)) {
5267
+ if (import_ts_morph19.Node.isPropertyAssignment(property)) {
4669
5268
  return property.getInitializer() ?? null;
4670
5269
  }
4671
- if (import_ts_morph18.Node.isShorthandPropertyAssignment(property)) {
5270
+ if (import_ts_morph19.Node.isShorthandPropertyAssignment(property)) {
4672
5271
  return property.getNameNode();
4673
5272
  }
4674
5273
  return null;
@@ -4689,7 +5288,7 @@ function objectLiteralOf(value, resolution) {
4689
5288
  return literalValueOf(
4690
5289
  value,
4691
5290
  resolution,
4692
- (node) => import_ts_morph18.Node.isObjectLiteralExpression(node)
5291
+ (node) => import_ts_morph19.Node.isObjectLiteralExpression(node)
4693
5292
  );
4694
5293
  }
4695
5294
  function propertiesOf(object, resolution) {
@@ -4701,7 +5300,7 @@ function propertiesReached(object, resolution, seen) {
4701
5300
  }
4702
5301
  seen.add(object);
4703
5302
  return object.getProperties().flatMap((property) => {
4704
- if (!import_ts_morph18.Node.isSpreadAssignment(property)) {
5303
+ if (!import_ts_morph19.Node.isSpreadAssignment(property)) {
4705
5304
  return [property];
4706
5305
  }
4707
5306
  const spread = objectLiteralOf(property.getExpression(), resolution);
@@ -4710,17 +5309,17 @@ function propertiesReached(object, resolution, seen) {
4710
5309
  }
4711
5310
  function writtenNodeOf(value, resolution) {
4712
5311
  const written = factKeyOf(value);
4713
- if (import_ts_morph18.Node.isNewExpression(written)) {
5312
+ if (import_ts_morph19.Node.isNewExpression(written)) {
4714
5313
  return written;
4715
5314
  }
4716
- if (import_ts_morph18.Node.isCallExpression(written)) {
5315
+ if (import_ts_morph19.Node.isCallExpression(written)) {
4717
5316
  return writtenThroughCall(written, resolution);
4718
5317
  }
4719
5318
  if (resolution === void 0 || !couldNameAValue(written)) {
4720
5319
  return null;
4721
5320
  }
4722
5321
  const resolved = resolution.resolveWrittenValue(written);
4723
- return resolved !== null && import_ts_morph18.Node.isCallExpression(resolved) ? writtenThroughCall(resolved, resolution) : resolved;
5322
+ return resolved !== null && import_ts_morph19.Node.isCallExpression(resolved) ? writtenThroughCall(resolved, resolution) : resolved;
4724
5323
  }
4725
5324
  function writtenThroughCall(call, resolution) {
4726
5325
  if (resolution !== void 0 && resolution.resolveCallable(call.getExpression()) !== null) {
@@ -4732,24 +5331,21 @@ function writtenThroughCall(call, resolution) {
4732
5331
  return call;
4733
5332
  }
4734
5333
  function stringValueOf(value, resolution) {
4735
- const written = factKeyOf(value);
4736
- if (isStringNode(written)) {
4737
- return written.getLiteralValue();
4738
- }
4739
- if (resolution === void 0 || !couldNameAValue(written)) {
5334
+ return (0, import_values3.literalOf)(evaluatedValue(value, resolution));
5335
+ }
5336
+ function stringPropertyOf(object, name, resolution) {
5337
+ const record2 = evaluatedValue(object, resolution);
5338
+ if (record2.kind !== "record") {
4740
5339
  return null;
4741
5340
  }
4742
- const resolved = resolution.resolveWrittenValue(written);
4743
- return resolved !== null && isStringNode(resolved) ? resolved.getLiteralValue() : null;
4744
- }
4745
- function isStringNode(node) {
4746
- return import_ts_morph18.Node.isStringLiteral(node) || import_ts_morph18.Node.isNoSubstitutionTemplateLiteral(node);
5341
+ const field = record2.fields.get(name);
5342
+ return field === void 0 ? null : (0, import_values3.literalOf)((0, import_values3.force)(field.value));
4747
5343
  }
4748
5344
  function arrayLiteralOf(value, resolution) {
4749
5345
  return literalValueOf(
4750
5346
  value,
4751
5347
  resolution,
4752
- (node) => import_ts_morph18.Node.isArrayLiteralExpression(node)
5348
+ (node) => import_ts_morph19.Node.isArrayLiteralExpression(node)
4753
5349
  );
4754
5350
  }
4755
5351
  function literalValueOf(value, resolution, isWanted) {
@@ -4772,26 +5368,26 @@ function discoverClientCalls(sourceFile, match, kind, resolution) {
4772
5368
  if (!isGlobal) {
4773
5369
  for (const varDecl of sourceFile.getVariableDeclarations()) {
4774
5370
  const init = varDecl.getInitializer();
4775
- if (init !== void 0 && (import_ts_morph19.Node.isCallExpression(init) || import_ts_morph19.Node.isNewExpression(init)) && isCreationCall(init, match, resolution)) {
5371
+ if (init !== void 0 && (import_ts_morph20.Node.isCallExpression(init) || import_ts_morph20.Node.isNewExpression(init)) && isCreationCall(init, match, resolution)) {
4776
5372
  clientVarNames.add(varDecl.getName());
4777
5373
  }
4778
5374
  }
4779
5375
  }
4780
5376
  const methodFilter = match.methodFilter !== void 0 ? new Set(match.methodFilter) : null;
4781
5377
  sourceFile.forEachDescendant((node) => {
4782
- if (!import_ts_morph19.Node.isCallExpression(node)) {
5378
+ if (!import_ts_morph20.Node.isCallExpression(node)) {
4783
5379
  return;
4784
5380
  }
4785
5381
  const callee = node.getExpression();
4786
5382
  let methodName = null;
4787
5383
  let matched = false;
4788
- if (isGlobal && import_ts_morph19.Node.isIdentifier(callee)) {
5384
+ if (isGlobal && import_ts_morph20.Node.isIdentifier(callee)) {
4789
5385
  if (callee.getText() === match.importName) {
4790
5386
  matched = true;
4791
5387
  }
4792
- } else if (import_ts_morph19.Node.isPropertyAccessExpression(callee)) {
5388
+ } else if (import_ts_morph20.Node.isPropertyAccessExpression(callee)) {
4793
5389
  const subject = callee.getExpression();
4794
- if (import_ts_morph19.Node.isIdentifier(subject) && (isClientImport(subject, match, resolution, true) || clientVarNames.has(subject.getText())) || resolvesToKnownInstance(subject, match, resolution)) {
5390
+ if (import_ts_morph20.Node.isIdentifier(subject) && (isClientImport(subject, match, resolution, true) || clientVarNames.has(subject.getText())) || resolvesToKnownInstance(subject, match, resolution)) {
4795
5391
  methodName = callee.getName();
4796
5392
  if (methodFilter === null || methodFilter.has(methodName)) {
4797
5393
  matched = true;
@@ -4825,16 +5421,16 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
4825
5421
  );
4826
5422
  const constructedHere = /* @__PURE__ */ new Set();
4827
5423
  sourceFile.forEachDescendant((node) => {
4828
- if (import_ts_morph19.Node.isVariableDeclaration(node)) {
5424
+ if (import_ts_morph20.Node.isVariableDeclaration(node)) {
4829
5425
  const init = node.getInitializer();
4830
- if (init !== void 0 && (import_ts_morph19.Node.isCallExpression(init) || import_ts_morph19.Node.isNewExpression(init)) && isCreationCall(init, match, resolution) || localName !== null && typedAsClient(node.getTypeNode(), localName)) {
5426
+ if (init !== void 0 && (import_ts_morph20.Node.isCallExpression(init) || import_ts_morph20.Node.isNewExpression(init)) && isCreationCall(init, match, resolution) || localName !== null && typedAsClient(node.getTypeNode(), localName)) {
4831
5427
  constructedHere.add(node.getName());
4832
5428
  }
4833
5429
  return;
4834
5430
  }
4835
- if (import_ts_morph19.Node.isParameterDeclaration(node) && localName !== null && typedAsClient(node.getTypeNode(), localName)) {
5431
+ if (import_ts_morph20.Node.isParameterDeclaration(node) && localName !== null && typedAsClient(node.getTypeNode(), localName)) {
4836
5432
  const written = node.getNameNode();
4837
- if (import_ts_morph19.Node.isIdentifier(written)) {
5433
+ if (import_ts_morph20.Node.isIdentifier(written)) {
4838
5434
  constructedHere.add(written.getText());
4839
5435
  }
4840
5436
  }
@@ -4845,10 +5441,10 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
4845
5441
  importName: match.importName,
4846
5442
  ...match.factoryMethods === void 0 ? {} : { factoryMethods: match.factoryMethods }
4847
5443
  };
4848
- return (subject) => isClientImport(subject, match, resolution, true) || import_ts_morph19.Node.isIdentifier(subject) && constructedHere.has(subject.getText()) || resolvesToKnownInstance(subject, full, resolution);
5444
+ return (subject) => isClientImport(subject, match, resolution, true) || import_ts_morph20.Node.isIdentifier(subject) && constructedHere.has(subject.getText()) || resolvesToKnownInstance(subject, full, resolution);
4849
5445
  }
4850
5446
  function typedAsClient(typeNode, localName) {
4851
- if (typeNode === void 0 || !import_ts_morph19.Node.isTypeReference(typeNode)) {
5447
+ if (typeNode === void 0 || !import_ts_morph20.Node.isTypeReference(typeNode)) {
4852
5448
  return false;
4853
5449
  }
4854
5450
  return typeNode.getTypeName().getText() === localName;
@@ -4858,27 +5454,27 @@ function resolvesToKnownInstance(subject, match, resolution) {
4858
5454
  return false;
4859
5455
  }
4860
5456
  const written = writtenNodeOf(subject, resolution);
4861
- if (written === null || !import_ts_morph19.Node.isCallExpression(written) && !import_ts_morph19.Node.isNewExpression(written)) {
5457
+ if (written === null || !import_ts_morph20.Node.isCallExpression(written) && !import_ts_morph20.Node.isNewExpression(written)) {
4862
5458
  return false;
4863
5459
  }
4864
5460
  return isCreationCall(written, match, resolution);
4865
5461
  }
4866
5462
  function isCreationCall(call, match, resolution) {
4867
5463
  const callee = call.getExpression();
4868
- if (import_ts_morph19.Node.isIdentifier(callee)) {
5464
+ if (import_ts_morph20.Node.isIdentifier(callee)) {
4869
5465
  return isClientImport(callee, match, resolution, false);
4870
5466
  }
4871
- if (!import_ts_morph19.Node.isPropertyAccessExpression(callee)) {
5467
+ if (!import_ts_morph20.Node.isPropertyAccessExpression(callee)) {
4872
5468
  return false;
4873
5469
  }
4874
5470
  const base = callee.getExpression();
4875
- return import_ts_morph19.Node.isIdentifier(base) && (match.factoryMethods?.includes(callee.getName()) ?? false) && isClientImport(base, match, resolution, false);
5471
+ return import_ts_morph20.Node.isIdentifier(base) && (match.factoryMethods?.includes(callee.getName()) ?? false) && isClientImport(base, match, resolution, false);
4876
5472
  }
4877
5473
  function isPathShaped(specifier) {
4878
5474
  return specifier.startsWith(".") || specifier.startsWith("/");
4879
5475
  }
4880
5476
  function isClientImport(subject, match, resolution, strictDefaultName) {
4881
- if (!import_ts_morph19.Node.isIdentifier(subject)) {
5477
+ if (!import_ts_morph20.Node.isIdentifier(subject)) {
4882
5478
  return false;
4883
5479
  }
4884
5480
  if (resolution === void 0) {
@@ -4926,27 +5522,27 @@ function resolvedImportLocalName(sourceFile, importModule, importName, strictDef
4926
5522
  return null;
4927
5523
  }
4928
5524
  function clientUnitName(enclosingFunc, methodName) {
4929
- if (import_ts_morph19.Node.isFunctionDeclaration(enclosingFunc)) {
5525
+ if (import_ts_morph20.Node.isFunctionDeclaration(enclosingFunc)) {
4930
5526
  return enclosingFunc.getName() ?? methodName ?? "anonymous";
4931
5527
  }
4932
- if (import_ts_morph19.Node.isMethodDeclaration(enclosingFunc)) {
5528
+ if (import_ts_morph20.Node.isMethodDeclaration(enclosingFunc)) {
4933
5529
  return enclosingFunc.getName();
4934
5530
  }
4935
5531
  const parent = enclosingFunc.getParent();
4936
- if (parent !== void 0 && import_ts_morph19.Node.isVariableDeclaration(parent)) {
5532
+ if (parent !== void 0 && import_ts_morph20.Node.isVariableDeclaration(parent)) {
4937
5533
  return parent.getName();
4938
5534
  }
4939
- if (parent !== void 0 && import_ts_morph19.Node.isPropertyAssignment(parent)) {
5535
+ if (parent !== void 0 && import_ts_morph20.Node.isPropertyAssignment(parent)) {
4940
5536
  return parent.getName();
4941
5537
  }
4942
5538
  return methodName ?? "anonymous";
4943
5539
  }
4944
5540
 
4945
5541
  // src/discovery/decoratedMethod.ts
4946
- var import_ts_morph22 = require("ts-morph");
5542
+ var import_ts_morph23 = require("ts-morph");
4947
5543
 
4948
5544
  // src/discovery/decoratedMembers.ts
4949
- var import_ts_morph20 = require("ts-morph");
5545
+ var import_ts_morph21 = require("ts-morph");
4950
5546
  function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
4951
5547
  const localToCanonical = /* @__PURE__ */ new Map();
4952
5548
  for (const importDecl of sourceFile.getImportDeclarations()) {
@@ -4966,7 +5562,7 @@ function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
4966
5562
  function decoratedCallablesOf(cls, decoratorNames) {
4967
5563
  const callables = [];
4968
5564
  for (const member of cls.getMembers()) {
4969
- if (!import_ts_morph20.Node.isMethodDeclaration(member) && !import_ts_morph20.Node.isPropertyDeclaration(member)) {
5565
+ if (!import_ts_morph21.Node.isMethodDeclaration(member) && !import_ts_morph21.Node.isPropertyDeclaration(member)) {
4970
5566
  continue;
4971
5567
  }
4972
5568
  const func = callableOf(member);
@@ -4990,7 +5586,7 @@ function decoratedCallablesOf(cls, decoratorNames) {
4990
5586
  return callables;
4991
5587
  }
4992
5588
  function callableOf(member) {
4993
- if (import_ts_morph20.Node.isMethodDeclaration(member)) {
5589
+ if (import_ts_morph21.Node.isMethodDeclaration(member)) {
4994
5590
  return toFunctionRoot(member);
4995
5591
  }
4996
5592
  const held = member.getInitializer();
@@ -4998,7 +5594,7 @@ function callableOf(member) {
4998
5594
  }
4999
5595
 
5000
5596
  // src/discovery/decoratorComposition.ts
5001
- var import_ts_morph21 = require("ts-morph");
5597
+ var import_ts_morph22 = require("ts-morph");
5002
5598
  function classDecoratorStandingFor(cls, names, modules, resolution) {
5003
5599
  for (const candidate of names) {
5004
5600
  const decorator = cls.getDecorator(candidate);
@@ -5014,7 +5610,7 @@ function classDecoratorStandingFor(cls, names, modules, resolution) {
5014
5610
  return null;
5015
5611
  }
5016
5612
  for (const decorator of cls.getDecorators()) {
5017
- const applied = resolution.importedNamesOf(calleeOf(decorator), modules);
5613
+ const applied = resolution.importedNamesOf(calleeOf2(decorator), modules);
5018
5614
  const standsFor = names.find((name) => applied.includes(name));
5019
5615
  if (standsFor === void 0) {
5020
5616
  continue;
@@ -5032,11 +5628,11 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
5032
5628
  if (atClass.length > 0) {
5033
5629
  return atClass;
5034
5630
  }
5035
- const wrapper = resolution.resolveCallable(calleeOf(decorator));
5631
+ const wrapper = resolution.resolveCallable(calleeOf2(decorator));
5036
5632
  if (wrapper === null) {
5037
5633
  return atClass;
5038
5634
  }
5039
- for (const call of wrapper.getDescendantsOfKind(import_ts_morph21.SyntaxKind.CallExpression)) {
5635
+ for (const call of wrapper.getDescendantsOfKind(import_ts_morph22.SyntaxKind.CallExpression)) {
5040
5636
  const names = resolution.importedNamesOf(call.getExpression(), modules);
5041
5637
  if (!names.includes(standsFor)) {
5042
5638
  continue;
@@ -5047,17 +5643,17 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
5047
5643
  return atClass;
5048
5644
  }
5049
5645
  function statesAValue(arg, wrapper) {
5050
- const identifiers = import_ts_morph21.Node.isIdentifier(arg) ? [arg] : arg.getDescendantsOfKind(import_ts_morph21.SyntaxKind.Identifier);
5646
+ const identifiers = import_ts_morph22.Node.isIdentifier(arg) ? [arg] : arg.getDescendantsOfKind(import_ts_morph22.SyntaxKind.Identifier);
5051
5647
  return !identifiers.some(
5052
5648
  (identifier) => identifier.getSymbol()?.getDeclarations().some(
5053
- (declaration) => import_ts_morph21.Node.isParameterDeclaration(declaration) && isWithin(declaration, wrapper)
5649
+ (declaration) => import_ts_morph22.Node.isParameterDeclaration(declaration) && isWithin(declaration, wrapper)
5054
5650
  )
5055
5651
  );
5056
5652
  }
5057
5653
  function isWithin(node, container) {
5058
5654
  return node.getSourceFile() === container.getSourceFile() && node.getStart() >= container.getStart() && node.getEnd() <= container.getEnd();
5059
5655
  }
5060
- function calleeOf(decorator) {
5656
+ function calleeOf2(decorator) {
5061
5657
  const call = decorator.getCallExpression();
5062
5658
  if (call !== void 0) {
5063
5659
  return call.getExpression();
@@ -5070,39 +5666,39 @@ function resolverTypeName(args) {
5070
5666
  return args.typeMap[args.decoratorName] ?? args.classTypeName ?? null;
5071
5667
  }
5072
5668
  function resolveResolverClassTypeName(decoratorArg) {
5073
- if (import_ts_morph22.Node.isArrowFunction(decoratorArg)) {
5669
+ if (import_ts_morph23.Node.isArrowFunction(decoratorArg)) {
5074
5670
  const body = decoratorArg.getBody();
5075
- if (import_ts_morph22.Node.isIdentifier(body)) {
5671
+ if (import_ts_morph23.Node.isIdentifier(body)) {
5076
5672
  return body.getText();
5077
5673
  }
5078
5674
  return null;
5079
5675
  }
5080
- if (import_ts_morph22.Node.isStringLiteral(decoratorArg)) {
5676
+ if (import_ts_morph23.Node.isStringLiteral(decoratorArg)) {
5081
5677
  return decoratorArg.getLiteralValue();
5082
5678
  }
5083
- if (import_ts_morph22.Node.isIdentifier(decoratorArg)) {
5679
+ if (import_ts_morph23.Node.isIdentifier(decoratorArg)) {
5084
5680
  return decoratorArg.getText();
5085
5681
  }
5086
5682
  return null;
5087
5683
  }
5088
5684
  function resolveOperationNameOverride(decorator) {
5089
- if (!import_ts_morph22.Node.isDecorator(decorator)) {
5685
+ if (!import_ts_morph23.Node.isDecorator(decorator)) {
5090
5686
  return null;
5091
5687
  }
5092
5688
  const args = decorator.getArguments();
5093
5689
  for (const arg of args) {
5094
- if (!import_ts_morph22.Node.isObjectLiteralExpression(arg)) {
5690
+ if (!import_ts_morph23.Node.isObjectLiteralExpression(arg)) {
5095
5691
  continue;
5096
5692
  }
5097
5693
  const prop = arg.getProperty("name");
5098
- if (prop === void 0 || !import_ts_morph22.Node.isPropertyAssignment(prop)) {
5694
+ if (prop === void 0 || !import_ts_morph23.Node.isPropertyAssignment(prop)) {
5099
5695
  continue;
5100
5696
  }
5101
5697
  const init = prop.getInitializer();
5102
5698
  if (init === void 0) {
5103
5699
  continue;
5104
5700
  }
5105
- if (import_ts_morph22.Node.isStringLiteral(init) || import_ts_morph22.Node.isNoSubstitutionTemplateLiteral(init)) {
5701
+ if (import_ts_morph23.Node.isStringLiteral(init) || import_ts_morph23.Node.isNoSubstitutionTemplateLiteral(init)) {
5106
5702
  return init.getLiteralValue();
5107
5703
  }
5108
5704
  }
@@ -5155,9 +5751,9 @@ function discoverDecoratedMethods(sourceFile, match, kind, resolution) {
5155
5751
  }
5156
5752
 
5157
5753
  // src/discovery/decoratedRoute.ts
5158
- var import_ts_morph23 = require("ts-morph");
5754
+ var import_ts_morph24 = require("ts-morph");
5159
5755
  function resolveRoutePathArg(decorator, resolution) {
5160
- if (!import_ts_morph23.Node.isDecorator(decorator)) {
5756
+ if (!import_ts_morph24.Node.isDecorator(decorator)) {
5161
5757
  return "";
5162
5758
  }
5163
5759
  return routePathOf(decorator.getArguments(), resolution);
@@ -5185,7 +5781,7 @@ function declaredChannelOf(source, decorator, resolution) {
5185
5781
  if (source.from === "unstated") {
5186
5782
  return null;
5187
5783
  }
5188
- if (!import_ts_morph23.Node.isDecorator(decorator)) {
5784
+ if (!import_ts_morph24.Node.isDecorator(decorator)) {
5189
5785
  return null;
5190
5786
  }
5191
5787
  const arg = decorator.getArguments()[source.position];
@@ -5196,7 +5792,7 @@ function declaredChannelOf(source, decorator, resolution) {
5196
5792
  return text === null || text === "" ? null : text;
5197
5793
  }
5198
5794
  function literalStringOf(node, resolution) {
5199
- if (import_ts_morph23.Node.isStringLiteral(node) || import_ts_morph23.Node.isNoSubstitutionTemplateLiteral(node)) {
5795
+ if (import_ts_morph24.Node.isStringLiteral(node) || import_ts_morph24.Node.isNoSubstitutionTemplateLiteral(node)) {
5200
5796
  return node.getLiteralValue();
5201
5797
  }
5202
5798
  const written = resolution?.resolveWrittenValue(node) ?? null;
@@ -5266,31 +5862,31 @@ function discoverDecoratedRoutes(sourceFile, match, kind, resolution, binding) {
5266
5862
  var import_picomatch = __toESM(require("picomatch"), 1);
5267
5863
 
5268
5864
  // src/discovery/namedExport.ts
5269
- var import_ts_morph24 = require("ts-morph");
5865
+ var import_ts_morph25 = require("ts-morph");
5270
5866
  function nameWrittenAt(expression) {
5271
- if (import_ts_morph24.Node.isIdentifier(expression)) {
5867
+ if (import_ts_morph25.Node.isIdentifier(expression)) {
5272
5868
  return expression.getText();
5273
5869
  }
5274
- if (import_ts_morph24.Node.isPropertyAccessExpression(expression)) {
5870
+ if (import_ts_morph25.Node.isPropertyAccessExpression(expression)) {
5275
5871
  return expression.getName();
5276
5872
  }
5277
5873
  return null;
5278
5874
  }
5279
5875
  function resolveDefaultExportName(decl, fn) {
5280
- if (import_ts_morph24.Node.isFunctionDeclaration(fn) || import_ts_morph24.Node.isFunctionExpression(fn)) {
5876
+ if (import_ts_morph25.Node.isFunctionDeclaration(fn) || import_ts_morph25.Node.isFunctionExpression(fn)) {
5281
5877
  const n = fn.getName?.();
5282
5878
  if (typeof n === "string" && n.length > 0) {
5283
5879
  return n;
5284
5880
  }
5285
5881
  }
5286
- if (import_ts_morph24.Node.isVariableDeclaration(decl)) {
5882
+ if (import_ts_morph25.Node.isVariableDeclaration(decl)) {
5287
5883
  const name = decl.getName();
5288
5884
  if (name.length > 0) {
5289
5885
  return name;
5290
5886
  }
5291
5887
  }
5292
5888
  const binding = fn.getParent();
5293
- if (binding !== void 0 && import_ts_morph24.Node.isVariableDeclaration(binding)) {
5889
+ if (binding !== void 0 && import_ts_morph25.Node.isVariableDeclaration(binding)) {
5294
5890
  const name = binding.getName();
5295
5891
  if (name.length > 0) {
5296
5892
  return name;
@@ -5345,7 +5941,7 @@ function discoverNamedExports(sourceFile, match, kind, resolution) {
5345
5941
  }
5346
5942
  continue;
5347
5943
  }
5348
- if (import_ts_morph24.Node.isArrowFunction(init) || import_ts_morph24.Node.isFunctionExpression(init)) {
5944
+ if (import_ts_morph25.Node.isArrowFunction(init) || import_ts_morph25.Node.isFunctionExpression(init)) {
5349
5945
  results.push({
5350
5946
  func: init,
5351
5947
  kind,
@@ -5454,13 +6050,13 @@ function discoverFileConventions(sourceFile, match, kind, resolution) {
5454
6050
  }
5455
6051
 
5456
6052
  // src/discovery/graphqlHookCall.ts
5457
- var import_ts_morph27 = require("ts-morph");
6053
+ var import_ts_morph28 = require("ts-morph");
5458
6054
 
5459
6055
  // src/discovery/graphqlShared.ts
5460
6056
  var import_node_fs = __toESM(require("fs"), 1);
5461
6057
  var import_node_path4 = __toESM(require("path"), 1);
5462
6058
  var import_graphql = require("graphql");
5463
- var import_ts_morph25 = require("ts-morph");
6059
+ var import_ts_morph26 = require("ts-morph");
5464
6060
  var DOCUMENT_TAGS = /* @__PURE__ */ new Set(["gql", "graphql"]);
5465
6061
  var UNQUALIFIED_DOCUMENT_TAG = "gql";
5466
6062
  function parseGraphqlOperation(source) {
@@ -5526,10 +6122,10 @@ function startAssembly(resolution) {
5526
6122
  };
5527
6123
  }
5528
6124
  function assembledTemplateText(template, assembly) {
5529
- if (import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(template)) {
6125
+ if (import_ts_morph26.Node.isNoSubstitutionTemplateLiteral(template)) {
5530
6126
  return innerTemplateText(template);
5531
6127
  }
5532
- if (!import_ts_morph25.Node.isTemplateExpression(template)) {
6128
+ if (!import_ts_morph26.Node.isTemplateExpression(template)) {
5533
6129
  return null;
5534
6130
  }
5535
6131
  let text = template.getHead().getLiteralText();
@@ -5665,7 +6261,7 @@ function collectDanglingSpreads(selectionSet, defined, dangling) {
5665
6261
  }
5666
6262
  }
5667
6263
  function documentTextFromExpression(node, assembly) {
5668
- if (import_ts_morph25.Node.isTaggedTemplateExpression(node)) {
6264
+ if (import_ts_morph26.Node.isTaggedTemplateExpression(node)) {
5669
6265
  if (!isDocumentTag(node.getTag())) {
5670
6266
  return null;
5671
6267
  }
@@ -5675,7 +6271,7 @@ function documentTextFromExpression(node, assembly) {
5675
6271
  assembly.seen.add(node);
5676
6272
  return assembledTemplateText(node.getTemplate(), assembly);
5677
6273
  }
5678
- if (!import_ts_morph25.Node.isCallExpression(node)) {
6274
+ if (!import_ts_morph26.Node.isCallExpression(node)) {
5679
6275
  return null;
5680
6276
  }
5681
6277
  if (!isDocumentTag(node.getExpression())) {
@@ -5686,7 +6282,7 @@ function documentTextFromExpression(node, assembly) {
5686
6282
  return null;
5687
6283
  }
5688
6284
  const template = stripDocumentNodeCasts(first);
5689
- if (!import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(template) && !import_ts_morph25.Node.isTemplateExpression(template)) {
6285
+ if (!import_ts_morph26.Node.isNoSubstitutionTemplateLiteral(template) && !import_ts_morph26.Node.isTemplateExpression(template)) {
5690
6286
  return null;
5691
6287
  }
5692
6288
  if (assembly.seen.has(node)) {
@@ -5696,7 +6292,7 @@ function documentTextFromExpression(node, assembly) {
5696
6292
  return assembledTemplateText(template, assembly);
5697
6293
  }
5698
6294
  function isDocumentTag(tag) {
5699
- if (!import_ts_morph25.Node.isIdentifier(tag)) {
6295
+ if (!import_ts_morph26.Node.isIdentifier(tag)) {
5700
6296
  return false;
5701
6297
  }
5702
6298
  if (tag.getText() === UNQUALIFIED_DOCUMENT_TAG) {
@@ -5707,14 +6303,14 @@ function isDocumentTag(tag) {
5707
6303
  return false;
5708
6304
  }
5709
6305
  for (const declaration of symbol.getDeclarations()) {
5710
- if (import_ts_morph25.Node.isImportSpecifier(declaration) && DOCUMENT_TAGS.has(declaration.getName())) {
6306
+ if (import_ts_morph26.Node.isImportSpecifier(declaration) && DOCUMENT_TAGS.has(declaration.getName())) {
5711
6307
  return true;
5712
6308
  }
5713
6309
  }
5714
6310
  return false;
5715
6311
  }
5716
6312
  function resolveThroughFacts(arg, assembly) {
5717
- if (assembly.resolution === void 0 || !import_ts_morph25.Node.isIdentifier(arg)) {
6313
+ if (assembly.resolution === void 0 || !import_ts_morph26.Node.isIdentifier(arg)) {
5718
6314
  return null;
5719
6315
  }
5720
6316
  const written = assembly.resolution.resolveWrittenValue(arg);
@@ -5763,7 +6359,7 @@ function singleLine(text) {
5763
6359
  return collapsed.length > 80 ? `${collapsed.slice(0, 79)}\u2026` : collapsed;
5764
6360
  }
5765
6361
  function importedVariableInitializers(identifier) {
5766
- if (!import_ts_morph25.Node.isIdentifier(identifier)) {
6362
+ if (!import_ts_morph26.Node.isIdentifier(identifier)) {
5767
6363
  return [];
5768
6364
  }
5769
6365
  const symbol = identifier.getSymbol();
@@ -5773,7 +6369,7 @@ function importedVariableInitializers(identifier) {
5773
6369
  const resolved = resolveAliasedSymbol(symbol) ?? symbol;
5774
6370
  const inits = [];
5775
6371
  for (const decl of resolved.getDeclarations()) {
5776
- if (import_ts_morph25.Node.isVariableDeclaration(decl)) {
6372
+ if (import_ts_morph26.Node.isVariableDeclaration(decl)) {
5777
6373
  const init = decl.getInitializer();
5778
6374
  if (init !== void 0) {
5779
6375
  inits.push(init);
@@ -5787,7 +6383,7 @@ function resolveGqlTemplateText(arg, assembly) {
5787
6383
  if (direct !== null) {
5788
6384
  return direct;
5789
6385
  }
5790
- if (!import_ts_morph25.Node.isIdentifier(arg)) {
6386
+ if (!import_ts_morph26.Node.isIdentifier(arg)) {
5791
6387
  return null;
5792
6388
  }
5793
6389
  const symbol = arg.getSymbol();
@@ -5795,7 +6391,7 @@ function resolveGqlTemplateText(arg, assembly) {
5795
6391
  return null;
5796
6392
  }
5797
6393
  for (const decl of symbol.getDeclarations()) {
5798
- if (import_ts_morph25.Node.isImportClause(decl) || import_ts_morph25.Node.isImportSpecifier(decl)) {
6394
+ if (import_ts_morph26.Node.isImportClause(decl) || import_ts_morph26.Node.isImportSpecifier(decl)) {
5799
6395
  const fromGraphqlFile = resolveGraphqlFileImport(decl);
5800
6396
  if (fromGraphqlFile !== null) {
5801
6397
  return fromGraphqlFile;
@@ -5814,7 +6410,7 @@ function resolveGqlTemplateText(arg, assembly) {
5814
6410
  return null;
5815
6411
  }
5816
6412
  function resolveTypedDocumentSource(arg) {
5817
- if (!import_ts_morph25.Node.isIdentifier(arg)) {
6413
+ if (!import_ts_morph26.Node.isIdentifier(arg)) {
5818
6414
  return null;
5819
6415
  }
5820
6416
  for (const init of importedVariableInitializers(arg)) {
@@ -5827,7 +6423,7 @@ function resolveTypedDocumentSource(arg) {
5827
6423
  }
5828
6424
  function typedDocumentSourceOf(node) {
5829
6425
  const inner = stripDocumentNodeCasts(node);
5830
- if (!import_ts_morph25.Node.isObjectLiteralExpression(inner)) {
6426
+ if (!import_ts_morph26.Node.isObjectLiteralExpression(inner)) {
5831
6427
  return null;
5832
6428
  }
5833
6429
  const evaluated = evaluateObjectLiteralAsJson(inner);
@@ -5845,7 +6441,7 @@ function typedDocumentSourceOf(node) {
5845
6441
  }
5846
6442
  }
5847
6443
  function resolveTypedDocumentHeader(arg) {
5848
- if (!import_ts_morph25.Node.isIdentifier(arg)) {
6444
+ if (!import_ts_morph26.Node.isIdentifier(arg)) {
5849
6445
  return null;
5850
6446
  }
5851
6447
  const reference = arg.getText();
@@ -5855,7 +6451,7 @@ function resolveTypedDocumentHeader(arg) {
5855
6451
  }
5856
6452
  const resolved = resolveAliasedSymbol(symbol) ?? symbol;
5857
6453
  for (const decl of resolved.getDeclarations()) {
5858
- if (!import_ts_morph25.Node.isVariableDeclaration(decl)) {
6454
+ if (!import_ts_morph26.Node.isVariableDeclaration(decl)) {
5859
6455
  continue;
5860
6456
  }
5861
6457
  const init = decl.getInitializer();
@@ -5888,10 +6484,10 @@ function resolveTypedDocumentHeader(arg) {
5888
6484
  }
5889
6485
  function documentNodeCastTypeArgs(node) {
5890
6486
  let current2 = node;
5891
- while (import_ts_morph25.Node.isAsExpression(current2) || import_ts_morph25.Node.isParenthesizedExpression(current2)) {
5892
- if (import_ts_morph25.Node.isAsExpression(current2)) {
6487
+ while (import_ts_morph26.Node.isAsExpression(current2) || import_ts_morph26.Node.isParenthesizedExpression(current2)) {
6488
+ if (import_ts_morph26.Node.isAsExpression(current2)) {
5893
6489
  const typeNode = current2.getTypeNode();
5894
- if (typeNode !== void 0 && import_ts_morph25.Node.isTypeReference(typeNode)) {
6490
+ if (typeNode !== void 0 && import_ts_morph26.Node.isTypeReference(typeNode)) {
5895
6491
  const name = typeNode.getTypeName().getText();
5896
6492
  const simpleName = name.includes(".") ? name.split(".").pop() ?? name : name;
5897
6493
  if (simpleName === "TypedDocumentNode" || simpleName === "DocumentNode") {
@@ -5904,7 +6500,7 @@ function documentNodeCastTypeArgs(node) {
5904
6500
  return null;
5905
6501
  }
5906
6502
  function operationHeaderFromResultType(typeNode) {
5907
- if (typeNode === void 0 || !import_ts_morph25.Node.isTypeReference(typeNode)) {
6503
+ if (typeNode === void 0 || !import_ts_morph26.Node.isTypeReference(typeNode)) {
5908
6504
  return null;
5909
6505
  }
5910
6506
  const name = typeNode.getTypeName().getText();
@@ -5925,16 +6521,16 @@ function operationHeaderFromResultType(typeNode) {
5925
6521
  }
5926
6522
  function stripDocumentNodeCasts(node) {
5927
6523
  let current2 = node;
5928
- while (import_ts_morph25.Node.isAsExpression(current2) || import_ts_morph25.Node.isParenthesizedExpression(current2)) {
6524
+ while (import_ts_morph26.Node.isAsExpression(current2) || import_ts_morph26.Node.isParenthesizedExpression(current2)) {
5929
6525
  current2 = current2.getExpression();
5930
6526
  }
5931
6527
  return current2;
5932
6528
  }
5933
6529
  function evaluateObjectLiteralAsJson(node) {
5934
- if (import_ts_morph25.Node.isStringLiteral(node) || import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(node)) {
6530
+ if (import_ts_morph26.Node.isStringLiteral(node) || import_ts_morph26.Node.isNoSubstitutionTemplateLiteral(node)) {
5935
6531
  return node.getLiteralValue();
5936
6532
  }
5937
- if (import_ts_morph25.Node.isNumericLiteral(node)) {
6533
+ if (import_ts_morph26.Node.isNumericLiteral(node)) {
5938
6534
  return Number(node.getText());
5939
6535
  }
5940
6536
  const kind = node.getText();
@@ -5947,17 +6543,17 @@ function evaluateObjectLiteralAsJson(node) {
5947
6543
  if (kind === "null") {
5948
6544
  return null;
5949
6545
  }
5950
- if (import_ts_morph25.Node.isObjectLiteralExpression(node)) {
6546
+ if (import_ts_morph26.Node.isObjectLiteralExpression(node)) {
5951
6547
  const out = {};
5952
6548
  for (const prop of node.getProperties()) {
5953
- if (!import_ts_morph25.Node.isPropertyAssignment(prop)) {
6549
+ if (!import_ts_morph26.Node.isPropertyAssignment(prop)) {
5954
6550
  return null;
5955
6551
  }
5956
6552
  const nameNode = prop.getNameNode();
5957
6553
  let name;
5958
- if (import_ts_morph25.Node.isIdentifier(nameNode)) {
6554
+ if (import_ts_morph26.Node.isIdentifier(nameNode)) {
5959
6555
  name = nameNode.getText();
5960
- } else if (import_ts_morph25.Node.isStringLiteral(nameNode) || import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(nameNode)) {
6556
+ } else if (import_ts_morph26.Node.isStringLiteral(nameNode) || import_ts_morph26.Node.isNoSubstitutionTemplateLiteral(nameNode)) {
5961
6557
  name = nameNode.getLiteralValue();
5962
6558
  } else {
5963
6559
  return null;
@@ -5974,7 +6570,7 @@ function evaluateObjectLiteralAsJson(node) {
5974
6570
  }
5975
6571
  return out;
5976
6572
  }
5977
- if (import_ts_morph25.Node.isArrayLiteralExpression(node)) {
6573
+ if (import_ts_morph26.Node.isArrayLiteralExpression(node)) {
5978
6574
  const out = [];
5979
6575
  for (const el of node.getElements()) {
5980
6576
  const value = evaluateObjectLiteralAsJson(el);
@@ -5988,8 +6584,8 @@ function evaluateObjectLiteralAsJson(node) {
5988
6584
  return void 0;
5989
6585
  }
5990
6586
  function resolveGraphqlFileImport(decl) {
5991
- const importDecl = import_ts_morph25.Node.isImportSpecifier(decl) ? decl.getImportDeclaration() : import_ts_morph25.Node.isImportClause(decl) ? decl.getParent() : null;
5992
- if (importDecl === null || importDecl === void 0 || !import_ts_morph25.Node.isImportDeclaration(importDecl)) {
6587
+ const importDecl = import_ts_morph26.Node.isImportSpecifier(decl) ? decl.getImportDeclaration() : import_ts_morph26.Node.isImportClause(decl) ? decl.getParent() : null;
6588
+ if (importDecl === null || importDecl === void 0 || !import_ts_morph26.Node.isImportDeclaration(importDecl)) {
5993
6589
  return null;
5994
6590
  }
5995
6591
  const specifier = importDecl.getModuleSpecifierValue();
@@ -6008,7 +6604,7 @@ function resolveGraphqlFileImport(decl) {
6008
6604
  function enclosingFunctionRoot(node) {
6009
6605
  let current2 = node.getParent();
6010
6606
  while (current2 !== void 0) {
6011
- if (import_ts_morph25.Node.isFunctionDeclaration(current2) || import_ts_morph25.Node.isFunctionExpression(current2) || import_ts_morph25.Node.isArrowFunction(current2) || import_ts_morph25.Node.isMethodDeclaration(current2)) {
6607
+ if (import_ts_morph26.Node.isFunctionDeclaration(current2) || import_ts_morph26.Node.isFunctionExpression(current2) || import_ts_morph26.Node.isArrowFunction(current2) || import_ts_morph26.Node.isMethodDeclaration(current2)) {
6012
6608
  return current2;
6013
6609
  }
6014
6610
  current2 = current2.getParent();
@@ -6016,18 +6612,18 @@ function enclosingFunctionRoot(node) {
6016
6612
  return null;
6017
6613
  }
6018
6614
  function functionNameOrAnon(func) {
6019
- if (import_ts_morph25.Node.isFunctionDeclaration(func) || import_ts_morph25.Node.isMethodDeclaration(func)) {
6615
+ if (import_ts_morph26.Node.isFunctionDeclaration(func) || import_ts_morph26.Node.isMethodDeclaration(func)) {
6020
6616
  return func.getName() ?? "<anon>";
6021
6617
  }
6022
6618
  const parent = func.getParent();
6023
- if (parent !== void 0 && import_ts_morph25.Node.isVariableDeclaration(parent)) {
6619
+ if (parent !== void 0 && import_ts_morph26.Node.isVariableDeclaration(parent)) {
6024
6620
  return parent.getName();
6025
6621
  }
6026
6622
  return "<anon>";
6027
6623
  }
6028
6624
 
6029
6625
  // src/discovery/importedCalls.ts
6030
- var import_ts_morph26 = require("ts-morph");
6626
+ var import_ts_morph27 = require("ts-morph");
6031
6627
  function callsResolvingTo(sourceFile, resolution, spec) {
6032
6628
  return [
6033
6629
  ...callsByOriginName(
@@ -6041,11 +6637,11 @@ function callsResolvingTo(sourceFile, resolution, spec) {
6041
6637
  function callsByOriginName(sourceFile, resolution, module2, names) {
6042
6638
  const candidates = [];
6043
6639
  sourceFile.forEachDescendant((node) => {
6044
- if (!import_ts_morph26.Node.isCallExpression(node) && !import_ts_morph26.Node.isNewExpression(node)) {
6640
+ if (!import_ts_morph27.Node.isCallExpression(node) && !import_ts_morph27.Node.isNewExpression(node)) {
6045
6641
  return;
6046
6642
  }
6047
6643
  const callee = node.getExpression();
6048
- if (import_ts_morph26.Node.isIdentifier(callee) && !declaredLocally(callee)) {
6644
+ if (import_ts_morph27.Node.isIdentifier(callee) && !declaredLocally(callee)) {
6049
6645
  candidates.push(node);
6050
6646
  }
6051
6647
  });
@@ -6071,7 +6667,7 @@ function callsByOriginName(sourceFile, resolution, module2, names) {
6071
6667
  function declaredLocally(callee) {
6072
6668
  const declarations = callee.getSymbol()?.getDeclarations() ?? [];
6073
6669
  return declarations.length > 0 && declarations.every(
6074
- (declaration) => (import_ts_morph26.Node.isFunctionDeclaration(declaration) || import_ts_morph26.Node.isClassDeclaration(declaration)) && !declaration.getSourceFile().isInNodeModules()
6670
+ (declaration) => (import_ts_morph27.Node.isFunctionDeclaration(declaration) || import_ts_morph27.Node.isClassDeclaration(declaration)) && !declaration.getSourceFile().isInNodeModules()
6075
6671
  );
6076
6672
  }
6077
6673
 
@@ -6089,7 +6685,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
6089
6685
  );
6090
6686
  const results = [];
6091
6687
  for (const [node, canonical] of hookCalls) {
6092
- if (!import_ts_morph27.Node.isCallExpression(node)) {
6688
+ if (!import_ts_morph28.Node.isCallExpression(node)) {
6093
6689
  continue;
6094
6690
  }
6095
6691
  const operationType = operationTypeByHook.get(canonical);
@@ -6126,7 +6722,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
6126
6722
  }
6127
6723
 
6128
6724
  // src/discovery/graphqlImperativeCall.ts
6129
- var import_ts_morph28 = require("ts-morph");
6725
+ var import_ts_morph29 = require("ts-morph");
6130
6726
  function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
6131
6727
  const isTheClient = clientReceiverCheckFor(sourceFile, match, resolution);
6132
6728
  const methodSpec = /* @__PURE__ */ new Map();
@@ -6138,11 +6734,11 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
6138
6734
  }
6139
6735
  const results = [];
6140
6736
  sourceFile.forEachDescendant((node) => {
6141
- if (!import_ts_morph28.Node.isCallExpression(node)) {
6737
+ if (!import_ts_morph29.Node.isCallExpression(node)) {
6142
6738
  return;
6143
6739
  }
6144
6740
  const callee = node.getExpression();
6145
- if (!import_ts_morph28.Node.isPropertyAccessExpression(callee)) {
6741
+ if (!import_ts_morph29.Node.isPropertyAccessExpression(callee)) {
6146
6742
  return;
6147
6743
  }
6148
6744
  const methodName = callee.getName();
@@ -6154,7 +6750,7 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
6154
6750
  return;
6155
6751
  }
6156
6752
  const args = node.getArguments();
6157
- if (args.length === 0 || !import_ts_morph28.Node.isObjectLiteralExpression(args[0])) {
6753
+ if (args.length === 0 || !import_ts_morph29.Node.isObjectLiteralExpression(args[0])) {
6158
6754
  return;
6159
6755
  }
6160
6756
  const config = args[0];
@@ -6190,16 +6786,16 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
6190
6786
  return results;
6191
6787
  }
6192
6788
  function imperativeConfigValue(prop) {
6193
- if (import_ts_morph28.Node.isPropertyAssignment(prop)) {
6789
+ if (import_ts_morph29.Node.isPropertyAssignment(prop)) {
6194
6790
  return prop.getInitializer() ?? null;
6195
6791
  }
6196
- if (import_ts_morph28.Node.isShorthandPropertyAssignment(prop)) {
6792
+ if (import_ts_morph29.Node.isShorthandPropertyAssignment(prop)) {
6197
6793
  const valueSymbol = prop.getValueSymbol();
6198
6794
  if (valueSymbol === void 0) {
6199
6795
  return null;
6200
6796
  }
6201
6797
  for (const decl of valueSymbol.getDeclarations()) {
6202
- if (import_ts_morph28.Node.isVariableDeclaration(decl)) {
6798
+ if (import_ts_morph29.Node.isVariableDeclaration(decl)) {
6203
6799
  const init = decl.getInitializer();
6204
6800
  if (init !== void 0) {
6205
6801
  return init;
@@ -6212,7 +6808,7 @@ function imperativeConfigValue(prop) {
6212
6808
  }
6213
6809
 
6214
6810
  // src/discovery/jsxElementRoute.ts
6215
- var import_ts_morph29 = require("ts-morph");
6811
+ var import_ts_morph30 = require("ts-morph");
6216
6812
  var PATH_NOT_LITERAL = "The path this route declares is not written as a string literal, so no path is claimed and this route pairs with nothing";
6217
6813
  var ENCLOSING_PATH_NOT_LITERAL = "A route this one is nested under declares its path as something other than a string literal, so the full path is not claimed and this route pairs with nothing";
6218
6814
  var SPREAD_NOT_ENUMERATED = "A spread stands in for routes declared elsewhere in this array, and they are not read here, so no path is claimed for any of them";
@@ -6244,7 +6840,7 @@ function discoverJsxElementRoutes(sourceFile, match, kind, resolution) {
6244
6840
  }
6245
6841
  return;
6246
6842
  }
6247
- if (import_ts_morph29.Node.isCallExpression(node) && callsAFactory(node, factoryNames)) {
6843
+ if (import_ts_morph30.Node.isCallExpression(node) && callsAFactory(node, factoryNames)) {
6248
6844
  results.push(
6249
6845
  ...unitsForRouteArray(node, match, elementsNames, kind, resolution)
6250
6846
  );
@@ -6266,7 +6862,7 @@ function localNamesFor(sourceFile, match, exported) {
6266
6862
  return local;
6267
6863
  }
6268
6864
  function asRouteJsx(node, routeNames) {
6269
- if (!import_ts_morph29.Node.isJsxSelfClosingElement(node) && !import_ts_morph29.Node.isJsxElement(node)) {
6865
+ if (!import_ts_morph30.Node.isJsxSelfClosingElement(node) && !import_ts_morph30.Node.isJsxElement(node)) {
6270
6866
  return null;
6271
6867
  }
6272
6868
  return isRouteJsx(node, routeNames) ? node : null;
@@ -6276,15 +6872,15 @@ function isRouteJsx(node, routeNames) {
6276
6872
  return tag !== null && routeNames.has(tag.getText());
6277
6873
  }
6278
6874
  function tagNameOf(node) {
6279
- const tag = import_ts_morph29.Node.isJsxElement(node) ? node.getOpeningElement().getTagNameNode() : node.getTagNameNode();
6280
- return import_ts_morph29.Node.isIdentifier(tag) ? tag : null;
6875
+ const tag = import_ts_morph30.Node.isJsxElement(node) ? node.getOpeningElement().getTagNameNode() : node.getTagNameNode();
6876
+ return import_ts_morph30.Node.isIdentifier(tag) ? tag : null;
6281
6877
  }
6282
6878
  function attributesOf(node) {
6283
- return import_ts_morph29.Node.isJsxElement(node) ? node.getOpeningElement().getAttributes() : node.getAttributes();
6879
+ return import_ts_morph30.Node.isJsxElement(node) ? node.getOpeningElement().getAttributes() : node.getAttributes();
6284
6880
  }
6285
6881
  function attributeValueOf(node, name) {
6286
6882
  for (const attribute of attributesOf(node)) {
6287
- if (!import_ts_morph29.Node.isJsxAttribute(attribute)) {
6883
+ if (!import_ts_morph30.Node.isJsxAttribute(attribute)) {
6288
6884
  continue;
6289
6885
  }
6290
6886
  if (attribute.getNameNode().getText() !== name) {
@@ -6295,8 +6891,8 @@ function attributeValueOf(node, name) {
6295
6891
  return null;
6296
6892
  }
6297
6893
  function literalStringOf2(value) {
6298
- const unwrapped2 = import_ts_morph29.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
6299
- if (import_ts_morph29.Node.isStringLiteral(unwrapped2) || import_ts_morph29.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
6894
+ const unwrapped2 = import_ts_morph30.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
6895
+ if (import_ts_morph30.Node.isStringLiteral(unwrapped2) || import_ts_morph30.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
6300
6896
  return unwrapped2.getLiteralValue();
6301
6897
  }
6302
6898
  return null;
@@ -6316,8 +6912,8 @@ function elementTargetOfValue(value) {
6316
6912
  if (value === null) {
6317
6913
  return { kind: "absent" };
6318
6914
  }
6319
- const unwrapped2 = import_ts_morph29.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
6320
- if (!import_ts_morph29.Node.isJsxSelfClosingElement(unwrapped2) && !import_ts_morph29.Node.isJsxElement(unwrapped2)) {
6915
+ const unwrapped2 = import_ts_morph30.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
6916
+ if (!import_ts_morph30.Node.isJsxSelfClosingElement(unwrapped2) && !import_ts_morph30.Node.isJsxElement(unwrapped2)) {
6321
6917
  return { kind: "unreadable" };
6322
6918
  }
6323
6919
  const tag = tagNameOf(unwrapped2);
@@ -6329,7 +6925,7 @@ function elementTargetOfValue(value) {
6329
6925
  function composedPrefixOf(node, match, routeNames) {
6330
6926
  const enclosing = [];
6331
6927
  for (const ancestor of node.getAncestors()) {
6332
- if (import_ts_morph29.Node.isJsxElement(ancestor) && isRouteJsx(ancestor, routeNames)) {
6928
+ if (import_ts_morph30.Node.isJsxElement(ancestor) && isRouteJsx(ancestor, routeNames)) {
6333
6929
  enclosing.push(ancestor);
6334
6930
  }
6335
6931
  }
@@ -6445,14 +7041,14 @@ function abstention(at, kind, sentence, label) {
6445
7041
  }
6446
7042
  function callsAFactory(call, factoryNames) {
6447
7043
  const callee = call.getExpression();
6448
- return import_ts_morph29.Node.isIdentifier(callee) && factoryNames.has(callee.getText());
7044
+ return import_ts_morph30.Node.isIdentifier(callee) && factoryNames.has(callee.getText());
6449
7045
  }
6450
7046
  function unitsForRouteArray(call, match, elementsNames, kind, resolution) {
6451
7047
  const first = call.getArguments()[0];
6452
7048
  if (first === void 0) {
6453
7049
  return [];
6454
7050
  }
6455
- if (import_ts_morph29.Node.isJsxElement(first) || import_ts_morph29.Node.isJsxSelfClosingElement(first) || import_ts_morph29.Node.isCallExpression(first) && callsAFactory(first, elementsNames)) {
7051
+ if (import_ts_morph30.Node.isJsxElement(first) || import_ts_morph30.Node.isJsxSelfClosingElement(first) || import_ts_morph30.Node.isCallExpression(first) && callsAFactory(first, elementsNames)) {
6456
7052
  return [];
6457
7053
  }
6458
7054
  const array = arrayLiteralOf(first, resolution);
@@ -6477,7 +7073,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
6477
7073
  const nestedIn = new Set(ancestry).add(array);
6478
7074
  const results = [];
6479
7075
  for (const element of array.getElements()) {
6480
- if (import_ts_morph29.Node.isSpreadElement(element)) {
7076
+ if (import_ts_morph30.Node.isSpreadElement(element)) {
6481
7077
  results.push(
6482
7078
  abstention(
6483
7079
  element,
@@ -6488,7 +7084,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
6488
7084
  );
6489
7085
  continue;
6490
7086
  }
6491
- if (!import_ts_morph29.Node.isObjectLiteralExpression(element)) {
7087
+ if (!import_ts_morph30.Node.isObjectLiteralExpression(element)) {
6492
7088
  results.push(
6493
7089
  abstention(
6494
7090
  element,
@@ -6577,7 +7173,7 @@ function ownPathOfObject(object, match) {
6577
7173
  }
6578
7174
  if (match.indexAttribute !== void 0) {
6579
7175
  const indexValue = routePropertyOf(object, match.indexAttribute);
6580
- if (indexValue !== null && import_ts_morph29.Node.isTrueLiteral(indexValue)) {
7176
+ if (indexValue !== null && import_ts_morph30.Node.isTrueLiteral(indexValue)) {
6581
7177
  return { kind: "inherited" };
6582
7178
  }
6583
7179
  }
@@ -6591,17 +7187,17 @@ function objectLabelOf(target) {
6591
7187
  return target.kind === "named" ? target.identifier.getText() : "declaration";
6592
7188
  }
6593
7189
  function labelOfExpression(node) {
6594
- if (import_ts_morph29.Node.isIdentifier(node)) {
7190
+ if (import_ts_morph30.Node.isIdentifier(node)) {
6595
7191
  return node.getText();
6596
7192
  }
6597
- if (import_ts_morph29.Node.isCallExpression(node)) {
7193
+ if (import_ts_morph30.Node.isCallExpression(node)) {
6598
7194
  return node.getExpression().getText();
6599
7195
  }
6600
7196
  return node.getKindName();
6601
7197
  }
6602
7198
 
6603
7199
  // src/discovery/packageExports.ts
6604
- var import_ts_morph31 = require("ts-morph");
7200
+ var import_ts_morph32 = require("ts-morph");
6605
7201
 
6606
7202
  // src/packageExports.ts
6607
7203
  var import_node_fs2 = __toESM(require("fs"), 1);
@@ -6793,13 +7389,13 @@ function sameDeclaration(a, b) {
6793
7389
  }
6794
7390
 
6795
7391
  // src/discovery/factorySurface.ts
6796
- var import_ts_morph30 = require("ts-morph");
7392
+ var import_ts_morph31 = require("ts-morph");
6797
7393
  var MAX_BUILDER_HOPS = 2;
6798
7394
  function surfaceMethods(decl) {
6799
- if (import_ts_morph30.Node.isClassDeclaration(decl)) {
7395
+ if (import_ts_morph31.Node.isClassDeclaration(decl)) {
6800
7396
  return surfaceClassMethods(decl);
6801
7397
  }
6802
- if (import_ts_morph30.Node.isFunctionDeclaration(decl) || import_ts_morph30.Node.isFunctionExpression(decl) || import_ts_morph30.Node.isArrowFunction(decl) || import_ts_morph30.Node.isMethodDeclaration(decl)) {
7398
+ if (import_ts_morph31.Node.isFunctionDeclaration(decl) || import_ts_morph31.Node.isFunctionExpression(decl) || import_ts_morph31.Node.isArrowFunction(decl) || import_ts_morph31.Node.isMethodDeclaration(decl)) {
6803
7399
  return surfaceFactoryReturnMethods(decl);
6804
7400
  }
6805
7401
  return [];
@@ -6808,7 +7404,7 @@ function surfaceClassMethods(cls) {
6808
7404
  const out = [];
6809
7405
  const seen = /* @__PURE__ */ new Set();
6810
7406
  for (const method of cls.getInstanceMethods()) {
6811
- if (method.hasModifier(import_ts_morph30.SyntaxKind.PrivateKeyword)) {
7407
+ if (method.hasModifier(import_ts_morph31.SyntaxKind.PrivateKeyword)) {
6812
7408
  continue;
6813
7409
  }
6814
7410
  const name = method.getName();
@@ -6819,7 +7415,7 @@ function surfaceClassMethods(cls) {
6819
7415
  out.push({ func: method, name });
6820
7416
  }
6821
7417
  for (const method of cls.getStaticMethods()) {
6822
- if (method.hasModifier(import_ts_morph30.SyntaxKind.PrivateKeyword)) {
7418
+ if (method.hasModifier(import_ts_morph31.SyntaxKind.PrivateKeyword)) {
6823
7419
  continue;
6824
7420
  }
6825
7421
  const name = method.getName();
@@ -6838,9 +7434,9 @@ function surfaceFactoryReturnMethods(fn) {
6838
7434
  return out;
6839
7435
  }
6840
7436
  function collectFromFunctionReturns(fn, out, seen, depth) {
6841
- if (import_ts_morph30.Node.isArrowFunction(fn)) {
7437
+ if (import_ts_morph31.Node.isArrowFunction(fn)) {
6842
7438
  const body2 = fn.getBody();
6843
- if (import_ts_morph30.Node.isExpression(body2)) {
7439
+ if (import_ts_morph31.Node.isExpression(body2)) {
6844
7440
  collectFromReturnValue(body2, out, seen, depth);
6845
7441
  return;
6846
7442
  }
@@ -6851,11 +7447,11 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
6851
7447
  }
6852
7448
  const returns = [];
6853
7449
  body.forEachDescendant((node, traversal) => {
6854
- if (import_ts_morph30.Node.isFunctionDeclaration(node) || import_ts_morph30.Node.isFunctionExpression(node) || import_ts_morph30.Node.isArrowFunction(node) || import_ts_morph30.Node.isMethodDeclaration(node) || import_ts_morph30.Node.isConstructorDeclaration(node) || import_ts_morph30.Node.isGetAccessorDeclaration(node) || import_ts_morph30.Node.isSetAccessorDeclaration(node)) {
7450
+ if (import_ts_morph31.Node.isFunctionDeclaration(node) || import_ts_morph31.Node.isFunctionExpression(node) || import_ts_morph31.Node.isArrowFunction(node) || import_ts_morph31.Node.isMethodDeclaration(node) || import_ts_morph31.Node.isConstructorDeclaration(node) || import_ts_morph31.Node.isGetAccessorDeclaration(node) || import_ts_morph31.Node.isSetAccessorDeclaration(node)) {
6855
7451
  traversal.skip();
6856
7452
  return;
6857
7453
  }
6858
- if (import_ts_morph30.Node.isReturnStatement(node)) {
7454
+ if (import_ts_morph31.Node.isReturnStatement(node)) {
6859
7455
  returns.push(node);
6860
7456
  }
6861
7457
  });
@@ -6869,15 +7465,15 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
6869
7465
  }
6870
7466
  function collectFromReturnValue(node, out, seen, depth) {
6871
7467
  const expr = peelParens(node);
6872
- if (import_ts_morph30.Node.isObjectLiteralExpression(expr)) {
7468
+ if (import_ts_morph31.Node.isObjectLiteralExpression(expr)) {
6873
7469
  collectFromObjectLiteral(expr, out, seen);
6874
7470
  return;
6875
7471
  }
6876
- if (depth >= MAX_BUILDER_HOPS || !import_ts_morph30.Node.isCallExpression(expr)) {
7472
+ if (depth >= MAX_BUILDER_HOPS || !import_ts_morph31.Node.isCallExpression(expr)) {
6877
7473
  return;
6878
7474
  }
6879
7475
  const callee = expr.getExpression();
6880
- if (!import_ts_morph30.Node.isIdentifier(callee)) {
7476
+ if (!import_ts_morph31.Node.isIdentifier(callee)) {
6881
7477
  return;
6882
7478
  }
6883
7479
  const helper = sameFileFunctionBehind(callee);
@@ -6900,12 +7496,12 @@ function functionAmong(declarations, filePath) {
6900
7496
  if (decl.getSourceFile().getFilePath() !== filePath) {
6901
7497
  continue;
6902
7498
  }
6903
- if (import_ts_morph30.Node.isFunctionDeclaration(decl)) {
7499
+ if (import_ts_morph31.Node.isFunctionDeclaration(decl)) {
6904
7500
  return decl;
6905
7501
  }
6906
- if (import_ts_morph30.Node.isVariableDeclaration(decl)) {
7502
+ if (import_ts_morph31.Node.isVariableDeclaration(decl)) {
6907
7503
  const init = decl.getInitializer();
6908
- if (init !== void 0 && (import_ts_morph30.Node.isArrowFunction(init) || import_ts_morph30.Node.isFunctionExpression(init))) {
7504
+ if (init !== void 0 && (import_ts_morph31.Node.isArrowFunction(init) || import_ts_morph31.Node.isFunctionExpression(init))) {
6909
7505
  return init;
6910
7506
  }
6911
7507
  }
@@ -6914,11 +7510,11 @@ function functionAmong(declarations, filePath) {
6914
7510
  }
6915
7511
  function collectFromObjectLiteral(node, out, seen) {
6916
7512
  const e = peelParens(node);
6917
- if (!import_ts_morph30.Node.isObjectLiteralExpression(e)) {
7513
+ if (!import_ts_morph31.Node.isObjectLiteralExpression(e)) {
6918
7514
  return;
6919
7515
  }
6920
7516
  for (const prop of e.getProperties()) {
6921
- if (import_ts_morph30.Node.isMethodDeclaration(prop)) {
7517
+ if (import_ts_morph31.Node.isMethodDeclaration(prop)) {
6922
7518
  const name = prop.getName();
6923
7519
  if (seen.has(name)) {
6924
7520
  continue;
@@ -6927,16 +7523,16 @@ function collectFromObjectLiteral(node, out, seen) {
6927
7523
  out.push({ func: prop, name });
6928
7524
  continue;
6929
7525
  }
6930
- if (import_ts_morph30.Node.isPropertyAssignment(prop)) {
7526
+ if (import_ts_morph31.Node.isPropertyAssignment(prop)) {
6931
7527
  const init = prop.getInitializer();
6932
7528
  if (init === void 0) {
6933
7529
  continue;
6934
7530
  }
6935
7531
  let v3 = init;
6936
- while (import_ts_morph30.Node.isParenthesizedExpression(v3)) {
7532
+ while (import_ts_morph31.Node.isParenthesizedExpression(v3)) {
6937
7533
  v3 = v3.getExpression();
6938
7534
  }
6939
- if (import_ts_morph30.Node.isArrowFunction(v3) || import_ts_morph30.Node.isFunctionExpression(v3)) {
7535
+ if (import_ts_morph31.Node.isArrowFunction(v3) || import_ts_morph31.Node.isFunctionExpression(v3)) {
6940
7536
  const name = prop.getName();
6941
7537
  if (seen.has(name)) {
6942
7538
  continue;
@@ -6945,7 +7541,7 @@ function collectFromObjectLiteral(node, out, seen) {
6945
7541
  out.push({ func: v3, name });
6946
7542
  }
6947
7543
  }
6948
- if (import_ts_morph30.Node.isShorthandPropertyAssignment(prop)) {
7544
+ if (import_ts_morph31.Node.isShorthandPropertyAssignment(prop)) {
6949
7545
  collectShorthandFunction(prop, out, seen);
6950
7546
  }
6951
7547
  }
@@ -7008,9 +7604,9 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
7008
7604
  (decl) => sourceDeclarationsBehind(decl, resolution)
7009
7605
  );
7010
7606
  for (const decl of candidates) {
7011
- if (import_ts_morph31.Node.isVariableDeclaration(decl)) {
7607
+ if (import_ts_morph32.Node.isVariableDeclaration(decl)) {
7012
7608
  const init = decl.getInitializer();
7013
- if (init !== void 0 && (import_ts_morph31.Node.isArrowFunction(init) || import_ts_morph31.Node.isFunctionExpression(init))) {
7609
+ if (init !== void 0 && (import_ts_morph32.Node.isArrowFunction(init) || import_ts_morph32.Node.isFunctionExpression(init))) {
7014
7610
  results.push(buildUnit(init, kind, exportName, entry));
7015
7611
  for (const m of surfaceMethods(init)) {
7016
7612
  results.push(buildSurfacedUnit(m, kind, exportName, entry));
@@ -7020,7 +7616,7 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
7020
7616
  }
7021
7617
  continue;
7022
7618
  }
7023
- if (import_ts_morph31.Node.isClassDeclaration(decl)) {
7619
+ if (import_ts_morph32.Node.isClassDeclaration(decl)) {
7024
7620
  for (const m of surfaceMethods(decl)) {
7025
7621
  results.push(buildSurfacedUnit(m, kind, exportName, entry));
7026
7622
  }
@@ -7065,7 +7661,7 @@ function buildSurfacedUnit(m, kind, parentExportName, entry) {
7065
7661
  }
7066
7662
 
7067
7663
  // src/discovery/packageImport.ts
7068
- var import_ts_morph32 = require("ts-morph");
7664
+ var import_ts_morph33 = require("ts-morph");
7069
7665
  function isLanguageLib(file) {
7070
7666
  return /[\\/]typescript[\\/]lib[\\/]lib\..*\.d\.ts$/.test(file.getFilePath());
7071
7667
  }
@@ -7086,13 +7682,13 @@ function splitPackageSpec(spec) {
7086
7682
  };
7087
7683
  }
7088
7684
  function enclosingFunctionName(func) {
7089
- if (import_ts_morph32.Node.isFunctionDeclaration(func) || import_ts_morph32.Node.isMethodDeclaration(func)) {
7685
+ if (import_ts_morph33.Node.isFunctionDeclaration(func) || import_ts_morph33.Node.isMethodDeclaration(func)) {
7090
7686
  const n = func.getName?.();
7091
7687
  if (typeof n === "string" && n.length > 0) {
7092
7688
  return n;
7093
7689
  }
7094
7690
  }
7095
- if (import_ts_morph32.Node.isFunctionExpression(func)) {
7691
+ if (import_ts_morph33.Node.isFunctionExpression(func)) {
7096
7692
  const n = func.getName();
7097
7693
  if (typeof n === "string" && n.length > 0) {
7098
7694
  return n;
@@ -7100,10 +7696,10 @@ function enclosingFunctionName(func) {
7100
7696
  }
7101
7697
  const parent = func.getParent();
7102
7698
  if (parent !== void 0) {
7103
- if (import_ts_morph32.Node.isVariableDeclaration(parent)) {
7699
+ if (import_ts_morph33.Node.isVariableDeclaration(parent)) {
7104
7700
  return parent.getName();
7105
7701
  }
7106
- if (import_ts_morph32.Node.isPropertyAssignment(parent)) {
7702
+ if (import_ts_morph33.Node.isPropertyAssignment(parent)) {
7107
7703
  return parent.getName();
7108
7704
  }
7109
7705
  }
@@ -7122,7 +7718,7 @@ function attributedCalls(sourceFile, packages, resolution) {
7122
7718
  const calls = [];
7123
7719
  const candidates = /* @__PURE__ */ new Set();
7124
7720
  sourceFile.forEachDescendant((node) => {
7125
- if (!import_ts_morph32.Node.isCallExpression(node)) {
7721
+ if (!import_ts_morph33.Node.isCallExpression(node)) {
7126
7722
  return;
7127
7723
  }
7128
7724
  calls.push(node);
@@ -7130,7 +7726,7 @@ function attributedCalls(sourceFile, packages, resolution) {
7130
7726
  if (couldBePackageLinked(callee, packages)) {
7131
7727
  candidates.add(callee);
7132
7728
  }
7133
- if (import_ts_morph32.Node.isPropertyAccessExpression(callee) && couldBePackageLinked(callee.getExpression(), packages)) {
7729
+ if (import_ts_morph33.Node.isPropertyAccessExpression(callee) && couldBePackageLinked(callee.getExpression(), packages)) {
7134
7730
  candidates.add(callee.getExpression());
7135
7731
  }
7136
7732
  });
@@ -7152,7 +7748,7 @@ function attributedCalls(sourceFile, packages, resolution) {
7152
7748
  if (direct !== null) {
7153
7749
  return direct;
7154
7750
  }
7155
- if (!import_ts_morph32.Node.isPropertyAccessExpression(callee)) {
7751
+ if (!import_ts_morph33.Node.isPropertyAccessExpression(callee)) {
7156
7752
  return null;
7157
7753
  }
7158
7754
  const subject = originOf(callee.getExpression());
@@ -7177,7 +7773,7 @@ function attributedCalls(sourceFile, packages, resolution) {
7177
7773
  return results;
7178
7774
  }
7179
7775
  function couldBePackageLinked(value, packages) {
7180
- if (!import_ts_morph32.Node.isIdentifier(value)) {
7776
+ if (!import_ts_morph33.Node.isIdentifier(value)) {
7181
7777
  return true;
7182
7778
  }
7183
7779
  const declarations = value.getSymbol()?.getDeclarations() ?? [];
@@ -7185,7 +7781,7 @@ function couldBePackageLinked(value, packages) {
7185
7781
  return true;
7186
7782
  }
7187
7783
  return !declarations.every(
7188
- (declaration) => import_ts_morph32.Node.isFunctionDeclaration(declaration) || import_ts_morph32.Node.isMethodDeclaration(declaration) || import_ts_morph32.Node.isClassDeclaration(declaration) || import_ts_morph32.Node.isImportSpecifier(declaration) && importAimsElsewhere(declaration, packages)
7784
+ (declaration) => import_ts_morph33.Node.isFunctionDeclaration(declaration) || import_ts_morph33.Node.isMethodDeclaration(declaration) || import_ts_morph33.Node.isClassDeclaration(declaration) || import_ts_morph33.Node.isImportSpecifier(declaration) && importAimsElsewhere(declaration, packages)
7189
7785
  );
7190
7786
  }
7191
7787
  function importAimsElsewhere(declaration, packages) {
@@ -7242,156 +7838,9 @@ var import_ts_morph34 = require("ts-morph");
7242
7838
  var import_resolution3 = require("@suss/resolution");
7243
7839
 
7244
7840
  // src/resolve/routePath.ts
7245
- var import_ts_morph33 = require("ts-morph");
7246
- var import_behavioral_ir2 = require("@suss/behavioral-ir");
7247
- var URL_SCHEME = /^[a-zA-Z][a-zA-Z\d+.-]*:\/\//;
7248
- var URL_ORIGIN = /^[a-zA-Z][a-zA-Z\d+.-]*:\/\/[^/]*/;
7249
- var PROTOCOL_RELATIVE = /^\/\//;
7250
- var PROTOCOL_RELATIVE_ORIGIN = /^\/\/[^/]*/;
7251
- function isAbsoluteUrlLiteral(text) {
7252
- return URL_SCHEME.test(text) || PROTOCOL_RELATIVE.test(text);
7253
- }
7254
- function stripOriginManually(text) {
7255
- if (URL_SCHEME.test(text)) {
7256
- return text.replace(URL_ORIGIN, "");
7257
- }
7258
- if (PROTOCOL_RELATIVE.test(text)) {
7259
- return text.replace(PROTOCOL_RELATIVE_ORIGIN, "");
7260
- }
7261
- return text;
7262
- }
7263
- function stripQueryAndFragment(text) {
7264
- const idx = text.search(/[?#]/);
7265
- return idx === -1 ? text : text.slice(0, idx);
7266
- }
7267
- var SUBSTITUTION = "\uFFFF";
7268
- var AUTHORITY_OPENER = /^(?:[-+.\uFFFFa-zA-Z0-9]+:\/\/|\/\/)/;
7269
- function originEndOf(flattened) {
7270
- const opener = AUTHORITY_OPENER.exec(flattened);
7271
- if (opener === null) {
7272
- return 0;
7273
- }
7274
- const slash = flattened.indexOf("/", opener[0].length);
7275
- return slash === -1 ? flattened.length : slash;
7276
- }
7277
- function appendPathText(path14, text) {
7278
- const idx = text.search(/[?#]/);
7279
- if (idx === -1) {
7280
- return { path: path14 + text, stop: false };
7281
- }
7282
- return { path: path14 + text.slice(0, idx), stop: true };
7283
- }
7284
- function parseAbsoluteUrl(text) {
7285
- try {
7286
- return new URL(text);
7287
- } catch {
7288
- }
7289
- if (!PROTOCOL_RELATIVE.test(text)) {
7290
- return void 0;
7291
- }
7292
- try {
7293
- return new URL(`https:${text}`);
7294
- } catch {
7295
- return void 0;
7296
- }
7297
- }
7298
- function pathnameOfAbsoluteLiteral(text) {
7299
- const parsed = parseAbsoluteUrl(text);
7300
- if (parsed !== void 0) {
7301
- return parsed.pathname;
7302
- }
7303
- return stripQueryAndFragment(stripOriginManually(text));
7304
- }
7305
- function pathFromLiteralUrl(text) {
7306
- const path14 = isAbsoluteUrlLiteral(text) ? pathnameOfAbsoluteLiteral(text) : stripQueryAndFragment(text);
7307
- return path14 === "" ? void 0 : path14;
7308
- }
7309
- function pathFromTemplateUrl(arg, resolution) {
7310
- const headText = arg.getHead().getLiteralText();
7311
- const spans = arg.getTemplateSpans();
7312
- const tails = spans.map((span) => span.getLiteral().getLiteralText());
7313
- const originEnd = originEndOf([headText, ...tails].join(SUBSTITUTION));
7314
- const head = appendPathText("", headText.slice(originEnd));
7315
- let path14 = head.path;
7316
- let stop = head.stop;
7317
- let at = headText.length;
7318
- for (let i = 0; i < spans.length && !stop; i++) {
7319
- const span = spans[i];
7320
- const tailText = tails[i];
7321
- if (span === void 0 || tailText === void 0) {
7322
- continue;
7323
- }
7324
- if (at >= originEnd) {
7325
- path14 += holeText(span.getExpression(), resolution);
7326
- }
7327
- at += SUBSTITUTION.length;
7328
- const appended = appendPathText(
7329
- path14,
7330
- tailText.slice(Math.max(0, originEnd - at))
7331
- );
7332
- path14 = appended.path;
7333
- stop = appended.stop;
7334
- at += tailText.length;
7335
- }
7336
- return path14 === "" ? void 0 : path14;
7337
- }
7338
- function pathFromUrlNode(node, resolution) {
7339
- if (import_ts_morph33.Node.isStringLiteral(node)) {
7340
- return pathFromLiteralUrl(node.getLiteralValue());
7341
- }
7342
- if (import_ts_morph33.Node.isNoSubstitutionTemplateLiteral(node)) {
7343
- return pathFromLiteralUrl(node.getLiteralValue());
7344
- }
7345
- if (import_ts_morph33.Node.isTemplateExpression(node)) {
7346
- return pathFromTemplateUrl(node, resolution);
7347
- }
7348
- if (import_ts_morph33.Node.isBinaryExpression(node)) {
7349
- const joined = joinedStringOf(node, resolution);
7350
- return joined === void 0 ? void 0 : pathFromLiteralUrl(joined);
7351
- }
7352
- return void 0;
7353
- }
7354
- function joinedStringOf(node, resolution) {
7355
- if (import_ts_morph33.Node.isStringLiteral(node) || import_ts_morph33.Node.isNoSubstitutionTemplateLiteral(node)) {
7356
- return node.getLiteralValue();
7357
- }
7358
- if (import_ts_morph33.Node.isBinaryExpression(node) && node.getOperatorToken().getText() === "+") {
7359
- const left = joinedStringOf(node.getLeft(), resolution);
7360
- const right = joinedStringOf(node.getRight(), resolution);
7361
- return left === void 0 || right === void 0 ? void 0 : left + right;
7362
- }
7363
- const written = resolution?.resolveWrittenValue(node) ?? null;
7364
- return written === null || written === node ? void 0 : joinedStringOf(written, resolution);
7365
- }
7366
- function placeholderName(expr) {
7367
- if (import_ts_morph33.Node.isIdentifier(expr)) {
7368
- return expr.getText();
7369
- }
7370
- if (import_ts_morph33.Node.isPropertyAccessExpression(expr)) {
7371
- return expr.getName();
7372
- }
7373
- return "param";
7374
- }
7375
- function holeText(expr, resolution) {
7376
- const written = resolution?.resolveWrittenValue(expr) ?? null;
7377
- if (written === null) {
7378
- return (0, import_behavioral_ir2.patternHole)(placeholderName(expr));
7379
- }
7380
- if (emptyStringLiteral(written)) {
7381
- return "";
7382
- }
7383
- return pathFromUrlNode(written, resolution) ?? (0, import_behavioral_ir2.patternHole)(placeholderName(expr));
7384
- }
7385
- function emptyStringLiteral(node) {
7386
- return (import_ts_morph33.Node.isStringLiteral(node) || import_ts_morph33.Node.isNoSubstitutionTemplateLiteral(node)) && node.getLiteralValue() === "";
7387
- }
7841
+ var import_values4 = require("@suss/values");
7388
7842
  function pathFromArgument(arg, resolution) {
7389
- const written = pathFromUrlNode(arg, resolution);
7390
- if (written !== void 0) {
7391
- return written;
7392
- }
7393
- const resolved = resolution?.resolveWrittenValue(arg) ?? null;
7394
- return resolved !== null ? pathFromUrlNode(resolved, resolution) : void 0;
7843
+ return (0, import_values4.pathOf)(evaluatedValue(arg, resolution));
7395
7844
  }
7396
7845
 
7397
7846
  // src/discovery/registrationCall.ts
@@ -7652,13 +8101,13 @@ function collectMethodsCalledOnCallResults(sourceFile) {
7652
8101
  return called;
7653
8102
  }
7654
8103
  function registrationSubjectsOf(sourceFile, importModule, importName, resolution) {
7655
- const importedLocalName = resolveImportedLocalName(
8104
+ const spellings = importedReferenceSpellings(
7656
8105
  sourceFile,
7657
8106
  importModule,
7658
8107
  importName
7659
8108
  );
7660
8109
  const subjects = /* @__PURE__ */ new Map();
7661
- if (importedLocalName === null) {
8110
+ if (spellings.length === 0) {
7662
8111
  return subjects;
7663
8112
  }
7664
8113
  sourceFile.forEachDescendant((node) => {
@@ -7668,7 +8117,7 @@ function registrationSubjectsOf(sourceFile, importModule, importName, resolution
7668
8117
  return;
7669
8118
  }
7670
8119
  const calleeText = import_ts_morph34.Node.isCallExpression(init) || import_ts_morph34.Node.isNewExpression(init) ? init.getExpression().getText() : null;
7671
- if (calleeText === importedLocalName) {
8120
+ if (calleeText !== null && spellings.includes(calleeText)) {
7672
8121
  subjects.set(node.getName(), init);
7673
8122
  }
7674
8123
  return;
@@ -7681,7 +8130,9 @@ function registrationSubjectsOf(sourceFile, importModule, importName, resolution
7681
8130
  return;
7682
8131
  }
7683
8132
  const typeText = typeNode.getText();
7684
- if (typeText === importedLocalName || typeText.startsWith(`${importedLocalName}<`)) {
8133
+ if (spellings.some(
8134
+ (spelling) => typeText === spelling || typeText.startsWith(`${spelling}<`)
8135
+ )) {
7685
8136
  subjects.set(node.getName(), creationSiteBehind(node, resolution));
7686
8137
  }
7687
8138
  });
@@ -7725,17 +8176,17 @@ function registrationSubjectIdsOf(sourceFile, matches, resolution) {
7725
8176
  return ids;
7726
8177
  }
7727
8178
  function unboundConstructionsOf(sourceFile, importModule, importName) {
7728
- const importedLocalName = resolveImportedLocalName(
8179
+ const spellings = importedReferenceSpellings(
7729
8180
  sourceFile,
7730
8181
  importModule,
7731
8182
  importName
7732
8183
  );
7733
- if (importedLocalName === null) {
8184
+ if (spellings.length === 0) {
7734
8185
  return [];
7735
8186
  }
7736
8187
  const constructions = [];
7737
8188
  sourceFile.forEachDescendant((node) => {
7738
- if ((import_ts_morph34.Node.isCallExpression(node) || import_ts_morph34.Node.isNewExpression(node)) && node.getExpression().getText() === importedLocalName && !import_ts_morph34.Node.isVariableDeclaration(node.getParent())) {
8189
+ if ((import_ts_morph34.Node.isCallExpression(node) || import_ts_morph34.Node.isNewExpression(node)) && spellings.includes(node.getExpression().getText()) && !import_ts_morph34.Node.isVariableDeclaration(node.getParent())) {
7739
8190
  constructions.push(node);
7740
8191
  }
7741
8192
  });
@@ -7804,32 +8255,14 @@ function mountTargetsAmong(args, targetPosition, knownSubjectIds, resolution) {
7804
8255
  }
7805
8256
  return targets;
7806
8257
  }
7807
- function stringProperty(obj, name) {
7808
- if (!import_ts_morph34.Node.isObjectLiteralExpression(obj)) {
7809
- return null;
7810
- }
7811
- const property = obj.getProperty(name);
7812
- if (property === void 0 || !import_ts_morph34.Node.isPropertyAssignment(property)) {
7813
- return null;
7814
- }
7815
- const value = property.getInitializer();
7816
- if (value !== void 0 && (import_ts_morph34.Node.isStringLiteral(value) || import_ts_morph34.Node.isNoSubstitutionTemplateLiteral(value))) {
7817
- return value.getLiteralValue();
7818
- }
7819
- return null;
7820
- }
7821
8258
  function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
7822
8259
  if (binding.method.type === "fromArgumentProperty" && binding.path.type === "fromArgumentProperty" && binding.method.position === binding.path.position) {
7823
8260
  const arg = call.getArguments()[binding.method.position];
7824
8261
  if (arg === void 0) {
7825
8262
  return null;
7826
8263
  }
7827
- const routeObject = objectLiteralOf(arg, resolution);
7828
- if (routeObject === null) {
7829
- return null;
7830
- }
7831
- const method2 = stringProperty(routeObject, binding.method.property);
7832
- const path15 = stringProperty(routeObject, binding.path.property);
8264
+ const method2 = stringPropertyOf(arg, binding.method.property, resolution);
8265
+ const path15 = stringPropertyOf(arg, binding.path.property, resolution);
7833
8266
  if (method2 === null || path15 === null) {
7834
8267
  return null;
7835
8268
  }
@@ -8029,7 +8462,7 @@ var import_resolution4 = require("@suss/resolution");
8029
8462
 
8030
8463
  // src/resolve/unfollowedCall.ts
8031
8464
  var import_ts_morph36 = require("ts-morph");
8032
- var import_behavioral_ir3 = require("@suss/behavioral-ir");
8465
+ var import_behavioral_ir2 = require("@suss/behavioral-ir");
8033
8466
  function isInExternalCode(sourceFile) {
8034
8467
  if (sourceFile.isDeclarationFile()) {
8035
8468
  return true;
@@ -8684,7 +9117,7 @@ function parameterReads(func, parameterNames2, barriers = NO_BARRIERS) {
8684
9117
 
8685
9118
  // src/resolve/readName.ts
8686
9119
  var import_ts_morph41 = require("ts-morph");
8687
- var import_behavioral_ir4 = require("@suss/behavioral-ir");
9120
+ var import_behavioral_ir3 = require("@suss/behavioral-ir");
8688
9121
  var MAX_HELPER_HOPS = 2;
8689
9122
  var UNNAMED_HOLE = "param";
8690
9123
  function readName(expr, options = {}) {
@@ -8699,7 +9132,7 @@ function readName(expr, options = {}) {
8699
9132
  return name;
8700
9133
  }
8701
9134
  const reference = referenceIn(expr);
8702
- return reference === null ? null : (0, import_behavioral_ir4.referenceName)(reference);
9135
+ return reference === null ? null : (0, import_behavioral_ir3.referenceName)(reference);
8703
9136
  }
8704
9137
  function referenceIn(expr) {
8705
9138
  const fromParameter = parameterPath(expr);
@@ -8948,7 +9381,7 @@ function boundOnce(expr, ctx) {
8948
9381
  }
8949
9382
  function readOrHole(expr, ctx) {
8950
9383
  const name = read(expr, ctx);
8951
- return name ?? (0, import_behavioral_ir4.patternHole)(holeName(expr, ctx));
9384
+ return name ?? (0, import_behavioral_ir3.patternHole)(holeName(expr, ctx));
8952
9385
  }
8953
9386
  function holeName(expr, ctx) {
8954
9387
  const bound = boundOnce(expr, ctx);
@@ -9015,7 +9448,7 @@ function madeExpression(receiver) {
9015
9448
  }
9016
9449
  function callOpsFor(call, resolveWrittenValue, originatesFrom, anchorCallsOf) {
9017
9450
  const resolve2 = resolveWrittenValue ?? (() => null);
9018
- const expression = calleeOf2(call);
9451
+ const expression = calleeOf3(call);
9019
9452
  const callee = import_ts_morph42.Node.isPropertyAccessExpression(expression) ? expression : null;
9020
9453
  let args = null;
9021
9454
  const argumentsOf = () => {
@@ -9067,7 +9500,7 @@ function anchorCallBehind(subject, origin, resolve2, originatesFrom, anchorCalls
9067
9500
  if (!import_ts_morph42.Node.isCallExpression(candidate) && !import_ts_morph42.Node.isNewExpression(candidate)) {
9068
9501
  return false;
9069
9502
  }
9070
- const candidateCallee = calleeOf2(candidate);
9503
+ const candidateCallee = calleeOf3(candidate);
9071
9504
  if (origin.named !== void 0 && !origin.named.includes(constructorName(candidate))) {
9072
9505
  return false;
9073
9506
  }
@@ -9201,7 +9634,7 @@ function opsOverCall(value, resolve2) {
9201
9634
  function isCalled(value) {
9202
9635
  return import_ts_morph42.Node.isCallExpression(value) || import_ts_morph42.Node.isNewExpression(value) || import_ts_morph42.Node.isTaggedTemplateExpression(value);
9203
9636
  }
9204
- function calleeOf2(call) {
9637
+ function calleeOf3(call) {
9205
9638
  return import_ts_morph42.Node.isTaggedTemplateExpression(call) ? call.getTag() : call.getExpression();
9206
9639
  }
9207
9640
  function argumentsIn(call) {
@@ -9784,199 +10217,12 @@ function tryMatchParameterCall(node, func, pattern, match) {
9784
10217
  return { node, terminal };
9785
10218
  }
9786
10219
 
9787
- // src/terminals/jsx.ts
9788
- var import_ts_morph46 = require("ts-morph");
9789
- function tryMatchJsxReturn(node, pattern) {
9790
- let expr;
9791
- let source;
9792
- if (import_ts_morph46.Node.isReturnStatement(node)) {
9793
- expr = node.getExpression();
9794
- source = node;
9795
- } else if (import_ts_morph46.Node.isArrowFunction(node)) {
9796
- const body = node.getBody();
9797
- if (body !== void 0 && !import_ts_morph46.Node.isBlock(body)) {
9798
- expr = body;
9799
- source = body;
9800
- }
9801
- }
9802
- if (expr === void 0 || source === void 0) {
9803
- return null;
9804
- }
9805
- const tree = jsxToRenderNode(expr);
9806
- if (tree === null) {
9807
- return null;
9808
- }
9809
- const component = tree.type === "element" ? tree.tag : "Fragment";
9810
- const terminal = {
9811
- kind: pattern.kind,
9812
- statusCode: null,
9813
- body: null,
9814
- exceptionType: null,
9815
- message: null,
9816
- component,
9817
- delegateTarget: null,
9818
- emitEvent: null,
9819
- renderTree: tree,
9820
- location: {
9821
- start: startLineOf(node),
9822
- end: endLineOf(node)
9823
- }
9824
- };
9825
- return { node, source, terminal };
9826
- }
9827
- function componentTargetOf(tagNode) {
9828
- if (!import_ts_morph46.Node.isIdentifier(tagNode) || !/^[A-Z]/.test(tagNode.getText())) {
9829
- return null;
9830
- }
9831
- const target = functionTargetOf(tagNode);
9832
- return target === null ? null : { file: target.file, name: target.name };
9833
- }
9834
- function jsxToRenderNode(node) {
9835
- if (import_ts_morph46.Node.isJsxElement(node)) {
9836
- const opening = node.getOpeningElement();
9837
- const tag = opening.getTagNameNode().getText();
9838
- const attrs = collectJsxAttributes(opening);
9839
- const target = componentTargetOf(opening.getTagNameNode());
9840
- const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
9841
- return {
9842
- type: "element",
9843
- tag,
9844
- children,
9845
- ...attrs !== null ? { attrs } : {},
9846
- ...target !== null ? { target } : {}
9847
- };
9848
- }
9849
- if (import_ts_morph46.Node.isJsxSelfClosingElement(node)) {
9850
- const tag = node.getTagNameNode().getText();
9851
- const attrs = collectJsxAttributes(node);
9852
- const target = componentTargetOf(node.getTagNameNode());
9853
- return {
9854
- type: "element",
9855
- tag,
9856
- children: [],
9857
- ...attrs !== null ? { attrs } : {},
9858
- ...target !== null ? { target } : {}
9859
- };
9860
- }
9861
- if (import_ts_morph46.Node.isJsxFragment(node)) {
9862
- const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
9863
- return { type: "element", tag: "Fragment", children };
9864
- }
9865
- if (import_ts_morph46.Node.isParenthesizedExpression(node)) {
9866
- return jsxToRenderNode(node.getExpression());
9867
- }
9868
- return null;
9869
- }
9870
- function collectJsxAttributes(opening) {
9871
- const entries = {};
9872
- for (const attr of opening.getAttributes()) {
9873
- if (import_ts_morph46.Node.isJsxSpreadAttribute(attr)) {
9874
- const exprText = attr.getExpression().getText();
9875
- entries[`...${exprText}`] = exprText;
9876
- continue;
9877
- }
9878
- if (!import_ts_morph46.Node.isJsxAttribute(attr)) {
9879
- continue;
9880
- }
9881
- const name = attr.getNameNode().getText();
9882
- const initializer = attr.getInitializer();
9883
- if (initializer === void 0) {
9884
- entries[name] = "";
9885
- continue;
9886
- }
9887
- if (import_ts_morph46.Node.isJsxExpression(initializer)) {
9888
- const inner = initializer.getExpression();
9889
- entries[name] = inner !== void 0 ? inner.getText() : "";
9890
- continue;
9891
- }
9892
- entries[name] = initializer.getText();
9893
- }
9894
- return Object.keys(entries).length > 0 ? entries : null;
9895
- }
9896
- function jsxChildToRenderNode(child) {
9897
- if (import_ts_morph46.Node.isJsxText(child)) {
9898
- const text = child.getLiteralText().trim();
9899
- if (text.length === 0) {
9900
- return null;
9901
- }
9902
- return { type: "text", value: text };
9903
- }
9904
- if (import_ts_morph46.Node.isJsxExpression(child)) {
9905
- const inner = child.getExpression();
9906
- if (inner === void 0) {
9907
- return null;
9908
- }
9909
- return jsxExpressionToRenderNode(inner);
9910
- }
9911
- if (import_ts_morph46.Node.isJsxElement(child) || import_ts_morph46.Node.isJsxSelfClosingElement(child) || import_ts_morph46.Node.isJsxFragment(child)) {
9912
- return jsxToRenderNode(child);
9913
- }
9914
- return null;
9915
- }
9916
- function jsxExpressionToRenderNode(expr) {
9917
- if (import_ts_morph46.Node.isParenthesizedExpression(expr)) {
9918
- return jsxExpressionToRenderNode(expr.getExpression());
9919
- }
9920
- if (import_ts_morph46.Node.isBinaryExpression(expr)) {
9921
- const op = expr.getOperatorToken().getText();
9922
- if (op === "&&") {
9923
- const right = renderAlternative(peelParens(expr.getRight()));
9924
- if (right.kind === "jsx") {
9925
- return {
9926
- type: "conditional",
9927
- condition: expr.getLeft().getText(),
9928
- whenTrue: right.node,
9929
- whenFalse: null
9930
- };
9931
- }
9932
- }
9933
- }
9934
- if (import_ts_morph46.Node.isConditionalExpression(expr)) {
9935
- const truthy = renderAlternative(peelParens(expr.getWhenTrue()));
9936
- const falsy = renderAlternative(peelParens(expr.getWhenFalse()));
9937
- if (truthy.kind === "jsx") {
9938
- return {
9939
- type: "conditional",
9940
- condition: expr.getCondition().getText(),
9941
- whenTrue: truthy.node,
9942
- whenFalse: falsy.kind === "jsx" ? falsy.node : null
9943
- };
9944
- }
9945
- if (falsy.kind === "jsx") {
9946
- return {
9947
- type: "conditional",
9948
- condition: `!(${expr.getCondition().getText()})`,
9949
- whenTrue: falsy.node,
9950
- whenFalse: null
9951
- };
9952
- }
9953
- }
9954
- return { type: "expression", sourceText: expr.getText() };
9955
- }
9956
- function renderAlternative(node) {
9957
- if (import_ts_morph46.Node.isNullLiteral(node)) {
9958
- return { kind: "noRender" };
9959
- }
9960
- if (import_ts_morph46.Node.isFalseLiteral(node)) {
9961
- return { kind: "noRender" };
9962
- }
9963
- if (import_ts_morph46.Node.isIdentifier(node) && node.getText() === "undefined") {
9964
- return { kind: "noRender" };
9965
- }
9966
- if (import_ts_morph46.Node.isJsxElement(node) || import_ts_morph46.Node.isJsxSelfClosingElement(node) || import_ts_morph46.Node.isJsxFragment(node)) {
9967
- const tree = jsxToRenderNode(node);
9968
- if (tree !== null) {
9969
- return { kind: "jsx", node: tree };
9970
- }
9971
- }
9972
- return { kind: "notStatic" };
9973
- }
9974
-
9975
- // src/terminals/returns.ts
9976
- var import_ts_morph51 = require("ts-morph");
10220
+ // src/terminals/extract.ts
10221
+ var import_ts_morph47 = require("ts-morph");
10222
+ var import_values5 = require("@suss/values");
9977
10223
 
9978
10224
  // src/shapes/shapes.ts
9979
- var import_ts_morph47 = require("ts-morph");
10225
+ var import_ts_morph46 = require("ts-morph");
9980
10226
 
9981
10227
  // src/shapes/typeShapes.ts
9982
10228
  var import_node_crypto = require("crypto");
@@ -10435,60 +10681,60 @@ function extractShapeWithArguments(node, substitutions) {
10435
10681
  }
10436
10682
  function extractShapeInner(node) {
10437
10683
  const unwrapped2 = peelSyntax(node);
10438
- if (boundArguments !== null && import_ts_morph47.Node.isIdentifier(unwrapped2)) {
10684
+ if (boundArguments !== null && import_ts_morph46.Node.isIdentifier(unwrapped2)) {
10439
10685
  const argument = boundArguments.get(unwrapped2.getText());
10440
10686
  if (argument !== void 0 && argument !== unwrapped2) {
10441
10687
  return extractShape(argument);
10442
10688
  }
10443
10689
  }
10444
- if (import_ts_morph47.Node.isObjectLiteralExpression(unwrapped2)) {
10690
+ if (import_ts_morph46.Node.isObjectLiteralExpression(unwrapped2)) {
10445
10691
  return shapeFromObjectLiteral(unwrapped2);
10446
10692
  }
10447
- if (import_ts_morph47.Node.isArrayLiteralExpression(unwrapped2)) {
10693
+ if (import_ts_morph46.Node.isArrayLiteralExpression(unwrapped2)) {
10448
10694
  return shapeFromArrayLiteral(unwrapped2);
10449
10695
  }
10450
- if (import_ts_morph47.Node.isStringLiteral(unwrapped2) || import_ts_morph47.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
10696
+ if (import_ts_morph46.Node.isStringLiteral(unwrapped2) || import_ts_morph46.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
10451
10697
  return { type: "literal", value: unwrapped2.getLiteralValue() };
10452
10698
  }
10453
- if (import_ts_morph47.Node.isTemplateExpression(unwrapped2)) {
10699
+ if (import_ts_morph46.Node.isTemplateExpression(unwrapped2)) {
10454
10700
  return { type: "text" };
10455
10701
  }
10456
- if (import_ts_morph47.Node.isNumericLiteral(unwrapped2)) {
10702
+ if (import_ts_morph46.Node.isNumericLiteral(unwrapped2)) {
10457
10703
  return numericLiteralShape(
10458
10704
  unwrapped2.getLiteralValue(),
10459
10705
  unwrapped2.getText()
10460
10706
  );
10461
10707
  }
10462
- if (import_ts_morph47.Node.isPrefixUnaryExpression(unwrapped2)) {
10708
+ if (import_ts_morph46.Node.isPrefixUnaryExpression(unwrapped2)) {
10463
10709
  const op = unwrapped2.getOperatorToken();
10464
- if (op === import_ts_morph47.SyntaxKind.MinusToken || op === import_ts_morph47.SyntaxKind.PlusToken) {
10710
+ if (op === import_ts_morph46.SyntaxKind.MinusToken || op === import_ts_morph46.SyntaxKind.PlusToken) {
10465
10711
  const inner = unwrapped2.getOperand();
10466
- if (import_ts_morph47.Node.isNumericLiteral(inner)) {
10712
+ if (import_ts_morph46.Node.isNumericLiteral(inner)) {
10467
10713
  const v3 = inner.getLiteralValue();
10468
- const signed = op === import_ts_morph47.SyntaxKind.MinusToken ? -v3 : v3;
10714
+ const signed = op === import_ts_morph46.SyntaxKind.MinusToken ? -v3 : v3;
10469
10715
  const rawBody = inner.getText();
10470
- const raw = op === import_ts_morph47.SyntaxKind.MinusToken ? `-${rawBody}` : rawBody;
10716
+ const raw = op === import_ts_morph46.SyntaxKind.MinusToken ? `-${rawBody}` : rawBody;
10471
10717
  return numericLiteralShape(signed, raw);
10472
10718
  }
10473
10719
  }
10474
10720
  }
10475
- if (import_ts_morph47.Node.isBigIntLiteral(unwrapped2)) {
10721
+ if (import_ts_morph46.Node.isBigIntLiteral(unwrapped2)) {
10476
10722
  return { type: "ref", name: "bigint" };
10477
10723
  }
10478
10724
  const kind = unwrapped2.getKind();
10479
- if (kind === import_ts_morph47.SyntaxKind.TrueKeyword) {
10725
+ if (kind === import_ts_morph46.SyntaxKind.TrueKeyword) {
10480
10726
  return { type: "literal", value: true };
10481
10727
  }
10482
- if (kind === import_ts_morph47.SyntaxKind.FalseKeyword) {
10728
+ if (kind === import_ts_morph46.SyntaxKind.FalseKeyword) {
10483
10729
  return { type: "literal", value: false };
10484
10730
  }
10485
- if (kind === import_ts_morph47.SyntaxKind.NullKeyword) {
10731
+ if (kind === import_ts_morph46.SyntaxKind.NullKeyword) {
10486
10732
  return { type: "null" };
10487
10733
  }
10488
- if (import_ts_morph47.Node.isIdentifier(unwrapped2) && unwrapped2.getText() === "undefined") {
10734
+ if (import_ts_morph46.Node.isIdentifier(unwrapped2) && unwrapped2.getText() === "undefined") {
10489
10735
  return { type: "undefined" };
10490
10736
  }
10491
- if (import_ts_morph47.Node.isConditionalExpression(unwrapped2)) {
10737
+ if (import_ts_morph46.Node.isConditionalExpression(unwrapped2)) {
10492
10738
  const whenTrue = extractShape(unwrapped2.getWhenTrue());
10493
10739
  const whenFalse = extractShape(unwrapped2.getWhenFalse());
10494
10740
  const variants = [];
@@ -10519,7 +10765,7 @@ function shapeFromArrayLiteral(arr) {
10519
10765
  }
10520
10766
  const shapes = [];
10521
10767
  for (const el of elements) {
10522
- if (import_ts_morph47.Node.isSpreadElement(el)) {
10768
+ if (import_ts_morph46.Node.isSpreadElement(el)) {
10523
10769
  const inner = el.getExpression();
10524
10770
  const innerShape = extractShape(inner);
10525
10771
  if (innerShape?.type === "array") {
@@ -10538,7 +10784,7 @@ function shapeFromObjectLiteral(obj) {
10538
10784
  const properties = {};
10539
10785
  const unresolvedSpreads = [];
10540
10786
  for (const prop of obj.getProperties()) {
10541
- if (import_ts_morph47.Node.isPropertyAssignment(prop)) {
10787
+ if (import_ts_morph46.Node.isPropertyAssignment(prop)) {
10542
10788
  const name = propertyName2(prop);
10543
10789
  if (name === null) {
10544
10790
  continue;
@@ -10554,7 +10800,7 @@ function shapeFromObjectLiteral(obj) {
10554
10800
  };
10555
10801
  continue;
10556
10802
  }
10557
- if (import_ts_morph47.Node.isShorthandPropertyAssignment(prop)) {
10803
+ if (import_ts_morph46.Node.isShorthandPropertyAssignment(prop)) {
10558
10804
  const name = prop.getName();
10559
10805
  const valueExpr = prop.getNameNode();
10560
10806
  properties[name] = extractShape(valueExpr) ?? {
@@ -10563,7 +10809,7 @@ function shapeFromObjectLiteral(obj) {
10563
10809
  };
10564
10810
  continue;
10565
10811
  }
10566
- if (import_ts_morph47.Node.isSpreadAssignment(prop)) {
10812
+ if (import_ts_morph46.Node.isSpreadAssignment(prop)) {
10567
10813
  const expr = prop.getExpression();
10568
10814
  const spreadShape = extractShape(expr);
10569
10815
  if (spreadShape?.type === "record") {
@@ -10582,7 +10828,7 @@ function shapeFromObjectLiteral(obj) {
10582
10828
  }
10583
10829
  function propertyName2(prop) {
10584
10830
  const nameNode = prop.getNameNode();
10585
- if (import_ts_morph47.Node.isIdentifier(nameNode) || import_ts_morph47.Node.isStringLiteral(nameNode) || import_ts_morph47.Node.isNoSubstitutionTemplateLiteral(nameNode) || import_ts_morph47.Node.isNumericLiteral(nameNode)) {
10831
+ if (import_ts_morph46.Node.isIdentifier(nameNode) || import_ts_morph46.Node.isStringLiteral(nameNode) || import_ts_morph46.Node.isNoSubstitutionTemplateLiteral(nameNode) || import_ts_morph46.Node.isNumericLiteral(nameNode)) {
10586
10832
  return nameNode.getText().replace(/^["']|["']$/g, "");
10587
10833
  }
10588
10834
  return null;
@@ -10608,21 +10854,20 @@ function collapseVariants2(shapes) {
10608
10854
  }
10609
10855
 
10610
10856
  // src/terminals/extract.ts
10611
- var import_ts_morph48 = require("ts-morph");
10612
10857
  function unwrapAs(node) {
10613
10858
  return peelSyntax(node);
10614
10859
  }
10615
10860
  function unwrapJsonStringify(node) {
10616
10861
  const outer = unwrapAs(node);
10617
- if (!import_ts_morph48.Node.isCallExpression(outer)) {
10862
+ if (!import_ts_morph47.Node.isCallExpression(outer)) {
10618
10863
  return node;
10619
10864
  }
10620
10865
  const callee = outer.getExpression();
10621
- if (!import_ts_morph48.Node.isPropertyAccessExpression(callee) || callee.getName() !== "stringify") {
10866
+ if (!import_ts_morph47.Node.isPropertyAccessExpression(callee) || callee.getName() !== "stringify") {
10622
10867
  return node;
10623
10868
  }
10624
10869
  const receiver = callee.getExpression();
10625
- if (!import_ts_morph48.Node.isIdentifier(receiver) || receiver.getText() !== "JSON") {
10870
+ if (!import_ts_morph47.Node.isIdentifier(receiver) || receiver.getText() !== "JSON") {
10626
10871
  return node;
10627
10872
  }
10628
10873
  const args = outer.getArguments();
@@ -10632,7 +10877,7 @@ function unwrapJsonStringify(node) {
10632
10877
  return unwrapAs(args[0]);
10633
10878
  }
10634
10879
  function substituted(value, ctx) {
10635
- if (ctx.substitutions === void 0 || !import_ts_morph48.Node.isIdentifier(value)) {
10880
+ if (ctx.substitutions === void 0 || !import_ts_morph47.Node.isIdentifier(value)) {
10636
10881
  return value;
10637
10882
  }
10638
10883
  return ctx.substitutions.get(value.getText()) ?? value;
@@ -10645,10 +10890,10 @@ function extractStatusCode(ctx) {
10645
10890
  if (result !== null) {
10646
10891
  return result;
10647
10892
  }
10648
- if (ctx.extraction.defaultStatusCode !== void 0) {
10649
- return { type: "literal", value: ctx.extraction.defaultStatusCode };
10650
- }
10651
- return null;
10893
+ return declaredStatusCode(ctx.extraction);
10894
+ }
10895
+ function declaredStatusCode(extraction) {
10896
+ return extraction.defaultStatusCode !== void 0 ? { type: "literal", value: extraction.defaultStatusCode } : null;
10652
10897
  }
10653
10898
  function matchConstructorCode(ctorText, codes) {
10654
10899
  const fullMatch = codes[ctorText];
@@ -10665,25 +10910,21 @@ function matchConstructorCode(ctorText, codes) {
10665
10910
  return null;
10666
10911
  }
10667
10912
  function statusOf(value, ctx) {
10668
- const unwrapped2 = unwrapAs(value);
10669
- if (import_ts_morph48.Node.isNumericLiteral(unwrapped2)) {
10670
- return { type: "literal", value: Number(unwrapped2.getText()) };
10913
+ const status = (0, import_values5.constantOf)(evaluatedValue(value, ctx.resolution));
10914
+ if (typeof status === "number") {
10915
+ return { type: "literal", value: status };
10671
10916
  }
10672
- const resolved = ctx.resolveWrittenValue?.(unwrapped2) ?? null;
10673
- if (resolved !== null && import_ts_morph48.Node.isNumericLiteral(resolved)) {
10674
- return { type: "literal", value: Number(resolved.getText()) };
10675
- }
10676
- return { type: "dynamic", sourceText: unwrapped2.getText() };
10917
+ return { type: "dynamic", sourceText: unwrapAs(value).getText() };
10677
10918
  }
10678
10919
  function statusFromProperty(obj, name, ctx) {
10679
10920
  const prop = obj.getProperty(name);
10680
10921
  if (prop === void 0) {
10681
10922
  return null;
10682
10923
  }
10683
- if (import_ts_morph48.Node.isShorthandPropertyAssignment(prop)) {
10924
+ if (import_ts_morph47.Node.isShorthandPropertyAssignment(prop)) {
10684
10925
  return { type: "dynamic", sourceText: prop.getName() };
10685
10926
  }
10686
- if (!import_ts_morph48.Node.isPropertyAssignment(prop)) {
10927
+ if (!import_ts_morph47.Node.isPropertyAssignment(prop)) {
10687
10928
  return null;
10688
10929
  }
10689
10930
  const value = prop.getInitializer();
@@ -10706,7 +10947,7 @@ function extractStatusCodeFromRule(ctx) {
10706
10947
  return null;
10707
10948
  }
10708
10949
  const first = ctx.throwCallArgs?.[0];
10709
- if (first !== void 0 && import_ts_morph48.Node.isNumericLiteral(first)) {
10950
+ if (first !== void 0 && import_ts_morph47.Node.isNumericLiteral(first)) {
10710
10951
  const value = first.getLiteralValue();
10711
10952
  if (value >= 100 && value <= 599) {
10712
10953
  return { type: "literal", value };
@@ -10719,7 +10960,7 @@ function extractStatusCodeFromRule(ctx) {
10719
10960
  return null;
10720
10961
  }
10721
10962
  const arg = ctx.throwCallArgs[sc.position];
10722
- if (arg === void 0 || !import_ts_morph48.Node.isNewExpression(arg)) {
10963
+ if (arg === void 0 || !import_ts_morph47.Node.isNewExpression(arg)) {
10723
10964
  return null;
10724
10965
  }
10725
10966
  const ctorText = arg.getExpression().getText();
@@ -10728,7 +10969,7 @@ function extractStatusCodeFromRule(ctx) {
10728
10969
  if (sc.from === "argumentProperty") {
10729
10970
  const args = ctx.throwCallArgs ?? ctx.calls?.[0]?.getArguments();
10730
10971
  const arg = args?.[sc.position];
10731
- if (arg === void 0 || !import_ts_morph48.Node.isObjectLiteralExpression(arg)) {
10972
+ if (arg === void 0 || !import_ts_morph47.Node.isObjectLiteralExpression(arg)) {
10732
10973
  return null;
10733
10974
  }
10734
10975
  return statusFromProperty(arg, sc.name, ctx);
@@ -10738,8 +10979,8 @@ function extractStatusCodeFromRule(ctx) {
10738
10979
  return null;
10739
10980
  }
10740
10981
  for (const prop of ctx.returnedObj.getProperties()) {
10741
- if (!import_ts_morph48.Node.isPropertyAssignment(prop)) {
10742
- if (import_ts_morph48.Node.isShorthandPropertyAssignment(prop)) {
10982
+ if (!import_ts_morph47.Node.isPropertyAssignment(prop)) {
10983
+ if (import_ts_morph47.Node.isShorthandPropertyAssignment(prop)) {
10743
10984
  if (prop.getName() === sc.name) {
10744
10985
  const resolved = ctx.substitutions?.get(prop.getName());
10745
10986
  if (resolved !== void 0) {
@@ -10797,8 +11038,8 @@ function extractBody(ctx) {
10797
11038
  return null;
10798
11039
  }
10799
11040
  for (const prop of ctx.returnedObj.getProperties()) {
10800
- if (!import_ts_morph48.Node.isPropertyAssignment(prop)) {
10801
- if (import_ts_morph48.Node.isShorthandPropertyAssignment(prop)) {
11041
+ if (!import_ts_morph47.Node.isPropertyAssignment(prop)) {
11042
+ if (import_ts_morph47.Node.isShorthandPropertyAssignment(prop)) {
10802
11043
  if (prop.getName() === b.name) {
10803
11044
  const resolved = ctx.substitutions?.get(prop.getName());
10804
11045
  if (resolved !== void 0) {
@@ -10852,6 +11093,197 @@ function extractBody(ctx) {
10852
11093
  return null;
10853
11094
  }
10854
11095
 
11096
+ // src/terminals/jsx.ts
11097
+ var import_ts_morph48 = require("ts-morph");
11098
+ function tryMatchJsxReturn(node, pattern) {
11099
+ let expr;
11100
+ let source;
11101
+ if (import_ts_morph48.Node.isReturnStatement(node)) {
11102
+ expr = node.getExpression();
11103
+ source = node;
11104
+ } else if (import_ts_morph48.Node.isArrowFunction(node)) {
11105
+ const body = node.getBody();
11106
+ if (body !== void 0 && !import_ts_morph48.Node.isBlock(body)) {
11107
+ expr = body;
11108
+ source = body;
11109
+ }
11110
+ }
11111
+ if (expr === void 0 || source === void 0) {
11112
+ return null;
11113
+ }
11114
+ const tree = jsxToRenderNode(expr);
11115
+ if (tree === null) {
11116
+ return null;
11117
+ }
11118
+ const component = tree.type === "element" ? tree.tag : "Fragment";
11119
+ const terminal = {
11120
+ kind: pattern.kind,
11121
+ statusCode: null,
11122
+ body: null,
11123
+ exceptionType: null,
11124
+ message: null,
11125
+ component,
11126
+ delegateTarget: null,
11127
+ emitEvent: null,
11128
+ renderTree: tree,
11129
+ location: {
11130
+ start: startLineOf(node),
11131
+ end: endLineOf(node)
11132
+ }
11133
+ };
11134
+ return { node, source, terminal };
11135
+ }
11136
+ function componentTargetOf(tagNode) {
11137
+ if (!import_ts_morph48.Node.isIdentifier(tagNode) || !/^[A-Z]/.test(tagNode.getText())) {
11138
+ return null;
11139
+ }
11140
+ const target = functionTargetOf(tagNode);
11141
+ return target === null ? null : { file: target.file, name: target.name };
11142
+ }
11143
+ function jsxToRenderNode(node) {
11144
+ if (import_ts_morph48.Node.isJsxElement(node)) {
11145
+ const opening = node.getOpeningElement();
11146
+ const tag = opening.getTagNameNode().getText();
11147
+ const attrs = collectJsxAttributes(opening);
11148
+ const target = componentTargetOf(opening.getTagNameNode());
11149
+ const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
11150
+ return {
11151
+ type: "element",
11152
+ tag,
11153
+ children,
11154
+ ...attrs !== null ? { attrs } : {},
11155
+ ...target !== null ? { target } : {}
11156
+ };
11157
+ }
11158
+ if (import_ts_morph48.Node.isJsxSelfClosingElement(node)) {
11159
+ const tag = node.getTagNameNode().getText();
11160
+ const attrs = collectJsxAttributes(node);
11161
+ const target = componentTargetOf(node.getTagNameNode());
11162
+ return {
11163
+ type: "element",
11164
+ tag,
11165
+ children: [],
11166
+ ...attrs !== null ? { attrs } : {},
11167
+ ...target !== null ? { target } : {}
11168
+ };
11169
+ }
11170
+ if (import_ts_morph48.Node.isJsxFragment(node)) {
11171
+ const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
11172
+ return { type: "element", tag: "Fragment", children };
11173
+ }
11174
+ if (import_ts_morph48.Node.isParenthesizedExpression(node)) {
11175
+ return jsxToRenderNode(node.getExpression());
11176
+ }
11177
+ return null;
11178
+ }
11179
+ function collectJsxAttributes(opening) {
11180
+ const entries = {};
11181
+ for (const attr of opening.getAttributes()) {
11182
+ if (import_ts_morph48.Node.isJsxSpreadAttribute(attr)) {
11183
+ const exprText = attr.getExpression().getText();
11184
+ entries[`...${exprText}`] = exprText;
11185
+ continue;
11186
+ }
11187
+ if (!import_ts_morph48.Node.isJsxAttribute(attr)) {
11188
+ continue;
11189
+ }
11190
+ const name = attr.getNameNode().getText();
11191
+ const initializer = attr.getInitializer();
11192
+ if (initializer === void 0) {
11193
+ entries[name] = "";
11194
+ continue;
11195
+ }
11196
+ if (import_ts_morph48.Node.isJsxExpression(initializer)) {
11197
+ const inner = initializer.getExpression();
11198
+ entries[name] = inner !== void 0 ? inner.getText() : "";
11199
+ continue;
11200
+ }
11201
+ entries[name] = initializer.getText();
11202
+ }
11203
+ return Object.keys(entries).length > 0 ? entries : null;
11204
+ }
11205
+ function jsxChildToRenderNode(child) {
11206
+ if (import_ts_morph48.Node.isJsxText(child)) {
11207
+ const text = child.getLiteralText().trim();
11208
+ if (text.length === 0) {
11209
+ return null;
11210
+ }
11211
+ return { type: "text", value: text };
11212
+ }
11213
+ if (import_ts_morph48.Node.isJsxExpression(child)) {
11214
+ const inner = child.getExpression();
11215
+ if (inner === void 0) {
11216
+ return null;
11217
+ }
11218
+ return jsxExpressionToRenderNode(inner);
11219
+ }
11220
+ if (import_ts_morph48.Node.isJsxElement(child) || import_ts_morph48.Node.isJsxSelfClosingElement(child) || import_ts_morph48.Node.isJsxFragment(child)) {
11221
+ return jsxToRenderNode(child);
11222
+ }
11223
+ return null;
11224
+ }
11225
+ function jsxExpressionToRenderNode(expr) {
11226
+ if (import_ts_morph48.Node.isParenthesizedExpression(expr)) {
11227
+ return jsxExpressionToRenderNode(expr.getExpression());
11228
+ }
11229
+ if (import_ts_morph48.Node.isBinaryExpression(expr)) {
11230
+ const op = expr.getOperatorToken().getText();
11231
+ if (op === "&&") {
11232
+ const right = renderAlternative(peelParens(expr.getRight()));
11233
+ if (right.kind === "jsx") {
11234
+ return {
11235
+ type: "conditional",
11236
+ condition: expr.getLeft().getText(),
11237
+ whenTrue: right.node,
11238
+ whenFalse: null
11239
+ };
11240
+ }
11241
+ }
11242
+ }
11243
+ if (import_ts_morph48.Node.isConditionalExpression(expr)) {
11244
+ const truthy = renderAlternative(peelParens(expr.getWhenTrue()));
11245
+ const falsy = renderAlternative(peelParens(expr.getWhenFalse()));
11246
+ if (truthy.kind === "jsx") {
11247
+ return {
11248
+ type: "conditional",
11249
+ condition: expr.getCondition().getText(),
11250
+ whenTrue: truthy.node,
11251
+ whenFalse: falsy.kind === "jsx" ? falsy.node : null
11252
+ };
11253
+ }
11254
+ if (falsy.kind === "jsx") {
11255
+ return {
11256
+ type: "conditional",
11257
+ condition: `!(${expr.getCondition().getText()})`,
11258
+ whenTrue: falsy.node,
11259
+ whenFalse: null
11260
+ };
11261
+ }
11262
+ }
11263
+ return { type: "expression", sourceText: expr.getText() };
11264
+ }
11265
+ function renderAlternative(node) {
11266
+ if (import_ts_morph48.Node.isNullLiteral(node)) {
11267
+ return { kind: "noRender" };
11268
+ }
11269
+ if (import_ts_morph48.Node.isFalseLiteral(node)) {
11270
+ return { kind: "noRender" };
11271
+ }
11272
+ if (import_ts_morph48.Node.isIdentifier(node) && node.getText() === "undefined") {
11273
+ return { kind: "noRender" };
11274
+ }
11275
+ if (import_ts_morph48.Node.isJsxElement(node) || import_ts_morph48.Node.isJsxSelfClosingElement(node) || import_ts_morph48.Node.isJsxFragment(node)) {
11276
+ const tree = jsxToRenderNode(node);
11277
+ if (tree !== null) {
11278
+ return { kind: "jsx", node: tree };
11279
+ }
11280
+ }
11281
+ return { kind: "notStatic" };
11282
+ }
11283
+
11284
+ // src/terminals/returns.ts
11285
+ var import_ts_morph51 = require("ts-morph");
11286
+
10855
11287
  // src/terminals/helperResolution.ts
10856
11288
  var import_ts_morph49 = require("ts-morph");
10857
11289
  function resolveHelperReturn(call, resolveCallee2) {
@@ -11104,13 +11536,14 @@ function bindArguments(callArgs, params) {
11104
11536
 
11105
11537
  // src/terminals/statusBranches.ts
11106
11538
  var import_ts_morph50 = require("ts-morph");
11107
- function statusChoicesOf(argument) {
11539
+ var import_values6 = require("@suss/values");
11540
+ function statusChoicesOf(argument, resolution) {
11108
11541
  const chosen = asConditional(argument);
11109
11542
  if (chosen === null) {
11110
11543
  return null;
11111
11544
  }
11112
- const whenTrue = numberOf(chosen.getWhenTrue());
11113
- const whenFalse = numberOf(chosen.getWhenFalse());
11545
+ const whenTrue = numberOf(chosen.getWhenTrue(), resolution);
11546
+ const whenFalse = numberOf(chosen.getWhenFalse(), resolution);
11114
11547
  if (whenTrue === null || whenFalse === null) {
11115
11548
  return null;
11116
11549
  }
@@ -11141,20 +11574,14 @@ function asConditional(node) {
11141
11574
  return only === void 0 ? null : toConditional(only);
11142
11575
  }
11143
11576
  var toConditional = (node) => import_ts_morph50.Node.isConditionalExpression(node) ? node : null;
11144
- function numberOf(node) {
11145
- const inner = unwrap(node);
11146
- if (!import_ts_morph50.Node.isNumericLiteral(inner)) {
11147
- return null;
11148
- }
11149
- const value = Number(inner.getText());
11150
- return Number.isFinite(value) ? value : null;
11151
- }
11152
- function unwrap(node) {
11153
- return peelSyntax(node);
11577
+ function numberOf(node, resolution) {
11578
+ const value = (0, import_values6.constantOf)(evaluatedValue(node, resolution));
11579
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
11154
11580
  }
11155
11581
 
11156
11582
  // src/terminals/returns.ts
11157
- function unwrapMethodChain(call, methodChain, func, paramPos) {
11583
+ function unwrapMethodChain(call, match, func) {
11584
+ const { methodChain, parameterPosition: paramPos } = match;
11158
11585
  if (methodChain.length === 0) {
11159
11586
  return null;
11160
11587
  }
@@ -11170,7 +11597,10 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
11170
11597
  return null;
11171
11598
  }
11172
11599
  collected.unshift(current2);
11173
- const subject = callee.getExpression();
11600
+ const subject = withoutPassThroughCalls(
11601
+ callee.getExpression(),
11602
+ match.passThroughMethods ?? []
11603
+ );
11174
11604
  if (i === 0) {
11175
11605
  if (parameterPositionOf(subject, func) !== paramPos) {
11176
11606
  return null;
@@ -11184,11 +11614,22 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
11184
11614
  }
11185
11615
  return { calls: collected };
11186
11616
  }
11617
+ function withoutPassThroughCalls(subject, passThrough) {
11618
+ let current2 = subject;
11619
+ while (import_ts_morph51.Node.isCallExpression(current2)) {
11620
+ const callee = current2.getExpression();
11621
+ if (!import_ts_morph51.Node.isPropertyAccessExpression(callee) || !passThrough.includes(callee.getName())) {
11622
+ break;
11623
+ }
11624
+ current2 = callee.getExpression();
11625
+ }
11626
+ return current2;
11627
+ }
11187
11628
  function returnedValueOf(returnStatement) {
11188
11629
  const written = returnStatement.getExpression();
11189
11630
  return written === void 0 ? null : unwrapValue(written);
11190
11631
  }
11191
- function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveCallee2) {
11632
+ function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
11192
11633
  if (import_ts_morph51.Node.isObjectLiteralExpression(node)) {
11193
11634
  const source = returnPositionOf(node);
11194
11635
  if (source === null) {
@@ -11203,7 +11644,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
11203
11644
  pattern,
11204
11645
  match,
11205
11646
  void 0,
11206
- resolveWrittenValue
11647
+ resolution
11207
11648
  );
11208
11649
  return terminal === null ? [] : [{ ...terminal, source }];
11209
11650
  }
@@ -11221,7 +11662,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
11221
11662
  pattern,
11222
11663
  match,
11223
11664
  void 0,
11224
- resolveWrittenValue
11665
+ resolution
11225
11666
  );
11226
11667
  return terminal === null ? [] : [terminal];
11227
11668
  }
@@ -11249,7 +11690,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
11249
11690
  pattern,
11250
11691
  match,
11251
11692
  resolved.substitutions,
11252
- resolveWrittenValue
11693
+ resolution
11253
11694
  );
11254
11695
  if (terminal !== null) {
11255
11696
  terminals.push(terminal);
@@ -11257,7 +11698,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
11257
11698
  }
11258
11699
  return terminals;
11259
11700
  }
11260
- function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions, resolveWrittenValue) {
11701
+ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions, resolution) {
11261
11702
  const required = match.requiredProperties;
11262
11703
  if (required !== void 0 && required.length > 0) {
11263
11704
  const presentNames = /* @__PURE__ */ new Set();
@@ -11276,7 +11717,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
11276
11717
  extraction: pattern.extraction,
11277
11718
  returnedObj: obj,
11278
11719
  ...substitutions !== void 0 ? { substitutions } : {},
11279
- ...resolveWrittenValue !== void 0 ? { resolveWrittenValue } : {}
11720
+ ...resolution !== void 0 ? { resolution } : {}
11280
11721
  };
11281
11722
  const statusCode = extractStatusCode(ctx);
11282
11723
  let body = extractBody(ctx);
@@ -11306,16 +11747,11 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
11306
11747
  }
11307
11748
  };
11308
11749
  }
11309
- function tryMatchParameterMethodCall(node, func, pattern, match, resolveWrittenValue) {
11750
+ function tryMatchParameterMethodCall(node, func, pattern, match, resolution) {
11310
11751
  if (!import_ts_morph51.Node.isCallExpression(node)) {
11311
11752
  return [];
11312
11753
  }
11313
- const result = unwrapMethodChain(
11314
- node,
11315
- match.methodChain,
11316
- func,
11317
- match.parameterPosition
11318
- );
11754
+ const result = unwrapMethodChain(node, match, func);
11319
11755
  if (result === null) {
11320
11756
  return [];
11321
11757
  }
@@ -11324,7 +11760,7 @@ function tryMatchParameterMethodCall(node, func, pattern, match, resolveWrittenV
11324
11760
  const ctx = {
11325
11761
  extraction: pattern.extraction,
11326
11762
  calls,
11327
- ...resolveWrittenValue !== void 0 ? { resolveWrittenValue } : {}
11763
+ ...resolution !== void 0 ? { resolution } : {}
11328
11764
  };
11329
11765
  const statusCode = extractStatusCode(ctx);
11330
11766
  const body = extractBody(ctx);
@@ -11345,7 +11781,7 @@ function tryMatchParameterMethodCall(node, func, pattern, match, resolveWrittenV
11345
11781
  };
11346
11782
  const base = { node, ...source !== null ? { source } : {} };
11347
11783
  const argument = statusArgument(calls, pattern.extraction);
11348
- const choices = argument === null ? null : statusChoicesOf(argument);
11784
+ const choices = argument === null ? null : statusChoicesOf(argument, resolution);
11349
11785
  if (choices === null) {
11350
11786
  return [{ ...base, terminal }];
11351
11787
  }
@@ -11379,12 +11815,7 @@ function returnCoveredByParameterMethodCall(expr, func, patterns) {
11379
11815
  if (pattern.match.type !== "parameterMethodCall") {
11380
11816
  continue;
11381
11817
  }
11382
- const result = unwrapMethodChain(
11383
- current2,
11384
- pattern.match.methodChain,
11385
- func,
11386
- pattern.match.parameterPosition
11387
- );
11818
+ const result = unwrapMethodChain(current2, pattern.match, func);
11388
11819
  if (result !== null) {
11389
11820
  return true;
11390
11821
  }
@@ -11424,10 +11855,9 @@ function tryMatchReturnStatement(node, pattern, func, allPatterns) {
11424
11855
  return null;
11425
11856
  }
11426
11857
  function buildReturnTerminal(locationNode, pattern, body) {
11427
- const statusCode = pattern.extraction.defaultStatusCode !== void 0 ? { type: "literal", value: pattern.extraction.defaultStatusCode } : null;
11428
11858
  const terminal = {
11429
11859
  kind: pattern.kind,
11430
- statusCode,
11860
+ statusCode: declaredStatusCode(pattern.extraction),
11431
11861
  body,
11432
11862
  exceptionType: null,
11433
11863
  message: null,
@@ -11482,7 +11912,7 @@ function calleeSubject(callee) {
11482
11912
  }
11483
11913
  return null;
11484
11914
  }
11485
- function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue, originatesFrom) {
11915
+ function tryMatchFunctionCall(node, pattern, match, resolution, originatesFrom) {
11486
11916
  if (!import_ts_morph51.Node.isCallExpression(node) && !import_ts_morph51.Node.isNewExpression(node)) {
11487
11917
  return null;
11488
11918
  }
@@ -11501,7 +11931,7 @@ function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue, origina
11501
11931
  const ctx = {
11502
11932
  extraction: pattern.extraction,
11503
11933
  throwCallArgs: callArgs,
11504
- ...resolveWrittenValue !== void 0 ? { resolveWrittenValue } : {}
11934
+ ...resolution !== void 0 ? { resolution } : {}
11505
11935
  };
11506
11936
  const statusCode = extractStatusCode(ctx);
11507
11937
  const body = extractBody(ctx);
@@ -11526,7 +11956,7 @@ function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue, origina
11526
11956
 
11527
11957
  // src/terminals/throws.ts
11528
11958
  var import_ts_morph52 = require("ts-morph");
11529
- function tryMatchThrowExpression(node, pattern, match, resolveWrittenValue) {
11959
+ function tryMatchThrowExpression(node, pattern, match, resolution) {
11530
11960
  if (!import_ts_morph52.Node.isThrowStatement(node)) {
11531
11961
  return null;
11532
11962
  }
@@ -11541,7 +11971,7 @@ function tryMatchThrowExpression(node, pattern, match, resolveWrittenValue) {
11541
11971
  extraction: pattern.extraction,
11542
11972
  ...callArgs !== null ? { throwCallArgs: callArgs } : {},
11543
11973
  ...exceptionType !== null ? { exceptionType } : {},
11544
- ...resolveWrittenValue !== void 0 ? { resolveWrittenValue } : {}
11974
+ ...resolution !== void 0 ? { resolution } : {}
11545
11975
  };
11546
11976
  const statusCode = extractStatusCode(ctx);
11547
11977
  const body = extractBody(ctx);
@@ -11597,7 +12027,7 @@ function classifyThrownExpression(thrown, constructorPattern) {
11597
12027
 
11598
12028
  // src/terminals/index.ts
11599
12029
  var NESTED_ESCAPING_MATCH_TYPES = /* @__PURE__ */ new Set(["parameterMethodCall"]);
11600
- function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenValue, originatesFrom, resolveCallee2) {
12030
+ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolution, originatesFrom, resolveCallee2) {
11601
12031
  const results = [];
11602
12032
  func.forEachDescendant((node, traversal) => {
11603
12033
  if (isDescentStop(node, func, barriers)) {
@@ -11615,7 +12045,7 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
11615
12045
  node,
11616
12046
  pattern,
11617
12047
  pattern.match,
11618
- resolveWrittenValue,
12048
+ resolution,
11619
12049
  resolveCallee2
11620
12050
  );
11621
12051
  if (matches.length > 0) {
@@ -11630,7 +12060,7 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
11630
12060
  func,
11631
12061
  pattern,
11632
12062
  pattern.match,
11633
- resolveWrittenValue
12063
+ resolution
11634
12064
  );
11635
12065
  if (matches.length > 0) {
11636
12066
  results.push(...matches);
@@ -11647,14 +12077,14 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
11647
12077
  node,
11648
12078
  pattern,
11649
12079
  pattern.match,
11650
- resolveWrittenValue
12080
+ resolution
11651
12081
  );
11652
12082
  } else if (pattern.match.type === "functionCall") {
11653
12083
  found = tryMatchFunctionCall(
11654
12084
  node,
11655
12085
  pattern,
11656
12086
  pattern.match,
11657
- resolveWrittenValue,
12087
+ resolution,
11658
12088
  originatesFrom
11659
12089
  );
11660
12090
  } else if (pattern.match.type === "parameterCall") {
@@ -11716,15 +12146,15 @@ function functionMayFallThrough(func) {
11716
12146
  }
11717
12147
  return true;
11718
12148
  }
11719
- function makeFallthroughTerminal(func) {
12149
+ function makeFallthroughTerminal(func, pattern) {
11720
12150
  const body = func.getBody();
11721
12151
  const anchor = body ?? func;
11722
12152
  const line = endLineOf(anchor);
11723
12153
  return {
11724
12154
  node: anchor,
11725
12155
  terminal: {
11726
- kind: "return",
11727
- statusCode: null,
12156
+ kind: pattern.kind,
12157
+ statusCode: declaredStatusCode(pattern.extraction),
11728
12158
  body: null,
11729
12159
  exceptionType: null,
11730
12160
  message: null,
@@ -11810,15 +12240,16 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
11810
12240
  });
11811
12241
  return unmatched;
11812
12242
  }
11813
- function extractRawBranches(func, terminalPatterns, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolveWrittenValue, originatesFrom, anchorCallsOf, resolveCallee2) {
12243
+ function extractRawBranches(func, terminalPatterns, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolution, originatesFrom, anchorCallsOf, resolveCallee2) {
11814
12244
  const terminals = findTerminals(
11815
12245
  func,
11816
12246
  terminalPatterns,
11817
12247
  barriers,
11818
- resolveWrittenValue,
12248
+ resolution,
11819
12249
  originatesFrom,
11820
12250
  resolveCallee2
11821
12251
  );
12252
+ const resolveWrittenValue = resolution === void 0 ? void 0 : (value) => resolution.resolveWrittenValue(value);
11822
12253
  const invocations = extractInvocationEffects(func, barriers);
11823
12254
  const recognized = [
11824
12255
  ...runInvocationRecognizers(
@@ -11843,15 +12274,15 @@ function extractRawBranches(func, terminalPatterns, invocationRecognizers = [],
11843
12274
  terminals.map(({ node }) => node),
11844
12275
  barriers
11845
12276
  );
11846
- const wantsFallthrough = terminalPatterns.some(
12277
+ const fallthroughPattern = terminalPatterns.find(
11847
12278
  (p) => p.match.type === "functionFallthrough"
11848
12279
  );
11849
- if (wantsFallthrough && functionMayFallThrough(func)) {
12280
+ if (fallthroughPattern !== void 0 && functionMayFallThrough(func)) {
11850
12281
  const hasDefaultTerminal = terminals.some(
11851
12282
  ({ node }) => (byTerminal.get(node) ?? []).some(isDefaultConditionList)
11852
12283
  );
11853
12284
  if (!hasDefaultTerminal) {
11854
- const synthetic = makeFallthroughTerminal(func);
12285
+ const synthetic = makeFallthroughTerminal(func, fallthroughPattern);
11855
12286
  terminals.push(synthetic);
11856
12287
  const pathResult = computePathConditions(
11857
12288
  func,
@@ -11995,7 +12426,7 @@ function indexFunctions(sf) {
11995
12426
 
11996
12427
  // src/contract.ts
11997
12428
  var import_ts_morph56 = require("ts-morph");
11998
- var import_behavioral_ir5 = require("@suss/behavioral-ir");
12429
+ var import_behavioral_ir4 = require("@suss/behavioral-ir");
11999
12430
  function extractDeclaredBody(node) {
12000
12431
  if (node === void 0) {
12001
12432
  return null;
@@ -12174,7 +12605,7 @@ function extractEndpointContract(endpointNode, pattern, framework) {
12174
12605
  if (responses.length === 0) {
12175
12606
  return null;
12176
12607
  }
12177
- const boundaryBinding = method !== void 0 || path14 !== void 0 ? (0, import_behavioral_ir5.restBinding)({
12608
+ const boundaryBinding = method !== void 0 || path14 !== void 0 ? (0, import_behavioral_ir4.restBinding)({
12178
12609
  transport: "http",
12179
12610
  method: method ?? null,
12180
12611
  path: path14 ?? null,
@@ -12375,7 +12806,7 @@ function parameterName(segment, convention) {
12375
12806
  // src/discovery/graphqlClientConstruction.ts
12376
12807
  var import_picomatch2 = __toESM(require("picomatch"), 1);
12377
12808
  var import_ts_morph57 = require("ts-morph");
12378
- var import_behavioral_ir6 = require("@suss/behavioral-ir");
12809
+ var import_behavioral_ir5 = require("@suss/behavioral-ir");
12379
12810
  function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
12380
12811
  const scopes = compileOperationScopes(packs);
12381
12812
  const sole = soleGraphqlClientRef(
@@ -12385,10 +12816,10 @@ function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
12385
12816
  const soleClient = sole !== null ? workspace !== null ? { ...sole, workspace } : sole : null;
12386
12817
  let registry = null;
12387
12818
  for (const summary of summaries) {
12388
- if (!(0, import_behavioral_ir6.isGraphqlOperationBinding)(summary.identity.boundaryBinding)) {
12819
+ if (!(0, import_behavioral_ir5.isGraphqlOperationBinding)(summary.identity.boundaryBinding)) {
12389
12820
  continue;
12390
12821
  }
12391
- const existing = (0, import_behavioral_ir6.readGraphqlMetadata)(summary) ?? {};
12822
+ const existing = (0, import_behavioral_ir5.readGraphqlMetadata)(summary) ?? {};
12392
12823
  const scoped = scopedWorkspaceFor(summary.location.file, scopes);
12393
12824
  const client = scoped !== null ? { uri: null, uriRef: null, workspace: scoped } : soleClient;
12394
12825
  const dangling = (existing.unresolvedFragments?.length ?? 0) > 0;
@@ -12398,7 +12829,7 @@ function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
12398
12829
  if (dangling && registry === null) {
12399
12830
  registry = fragmentRegistryStatus(sourceFiles, packs);
12400
12831
  }
12401
- summary.metadata = (0, import_behavioral_ir6.withGraphqlMetadata)(summary.metadata, {
12832
+ summary.metadata = (0, import_behavioral_ir5.withGraphqlMetadata)(summary.metadata, {
12402
12833
  ...existing,
12403
12834
  ...client !== null ? { client } : {},
12404
12835
  ...dangling && registry !== null ? { fragmentRegistry: registry } : {}
@@ -13564,7 +13995,7 @@ function deriveBoundaryEffects(summaries, facts) {
13564
13995
 
13565
13996
  // src/resolve/reachableClosure.ts
13566
13997
  var import_ts_morph62 = require("ts-morph");
13567
- var import_behavioral_ir7 = require("@suss/behavioral-ir");
13998
+ var import_behavioral_ir6 = require("@suss/behavioral-ir");
13568
13999
  var import_datalog4 = require("@suss/datalog");
13569
14000
  var import_extractor7 = require("@suss/extractor");
13570
14001
  var reachablePack = {
@@ -13682,7 +14113,7 @@ function collectReachable(func, scan) {
13682
14113
  const inFunc = { ...scan, scanning: func };
13683
14114
  const candidates = [];
13684
14115
  const stops = [];
13685
- const placements = new import_behavioral_ir7.TargetPlacements();
14116
+ const placements = new import_behavioral_ir6.TargetPlacements();
13686
14117
  const parameterCalls = [];
13687
14118
  const passedPositions = /* @__PURE__ */ new Set();
13688
14119
  const seen = /* @__PURE__ */ new Set();
@@ -13690,7 +14121,7 @@ function collectReachable(func, scan) {
13690
14121
  const record2 = (outcome) => {
13691
14122
  if (outcome.kind === "stopped") {
13692
14123
  const stopKey = `${outcome.stop.reason}:${outcome.stop.callee}`;
13693
- if (!seen.has(stopKey) && (0, import_behavioral_ir3.worthRecording)(outcome.stop.reason)) {
14124
+ if (!seen.has(stopKey) && (0, import_behavioral_ir2.worthRecording)(outcome.stop.reason)) {
13694
14125
  seen.add(stopKey);
13695
14126
  stops.push(outcome.stop);
13696
14127
  }
@@ -13772,9 +14203,9 @@ function extractReachableSummary(candidate, options, recognizers) {
13772
14203
  recognizers.invocation,
13773
14204
  recognizers.access,
13774
14205
  void 0,
13775
- recognizers.resolveWrittenValue
14206
+ recognizers.resolution
13776
14207
  );
13777
- raw.boundaryBinding = (0, import_behavioral_ir7.functionCallBinding)({
14208
+ raw.boundaryBinding = (0, import_behavioral_ir6.functionCallBinding)({
13778
14209
  transport: "in-process",
13779
14210
  recognition: "reachable"
13780
14211
  });
@@ -13979,7 +14410,7 @@ function recordStops(stopsByKey, summariesByKey, options) {
13979
14410
  }
13980
14411
  for (const [key, stops] of stopsByKey) {
13981
14412
  for (const summary of summariesByKey.get(key) ?? []) {
13982
- summary.gaps.push(...stops.map(import_behavioral_ir3.unfollowedCallGap));
14413
+ summary.gaps.push(...stops.map(import_behavioral_ir2.unfollowedCallGap));
13983
14414
  }
13984
14415
  }
13985
14416
  }
@@ -14061,7 +14492,7 @@ function recordParameterGaps(parameterCallsByKey, summariesByKey, passedPosition
14061
14492
  for (const summary of summariesByKey.get(key) ?? []) {
14062
14493
  summary.gaps.push(
14063
14494
  ...unbound.map(
14064
- ({ callee }) => (0, import_behavioral_ir3.unfollowedCallGap)({ callee, reason: "unboundParameter" })
14495
+ ({ callee }) => (0, import_behavioral_ir2.unfollowedCallGap)({ callee, reason: "unboundParameter" })
14065
14496
  )
14066
14497
  );
14067
14498
  }
@@ -14375,7 +14806,7 @@ function prefixOfExpr(expr, responseCall, depth) {
14375
14806
  if (depth >= MAX_PREFIX_DEPTH) {
14376
14807
  return null;
14377
14808
  }
14378
- const node = unwrap2(expr);
14809
+ const node = unwrap(expr);
14379
14810
  if (node === responseCall) {
14380
14811
  return [];
14381
14812
  }
@@ -14428,7 +14859,7 @@ function firstCallbackParamName(callback) {
14428
14859
  const nameNode = param.getNameNode();
14429
14860
  return import_ts_morph64.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
14430
14861
  }
14431
- function unwrap2(expr) {
14862
+ function unwrap(expr) {
14432
14863
  let node = expr;
14433
14864
  while (import_ts_morph64.Node.isAwaitExpression(node) || import_ts_morph64.Node.isParenthesizedExpression(node) || import_ts_morph64.Node.isAsExpression(node)) {
14434
14865
  node = node.getExpression();
@@ -14443,7 +14874,7 @@ function chainRootedAt(expr, rootName) {
14443
14874
  return import_ts_morph64.Node.isIdentifier(chain.root) && chain.root.getText() === rootName ? chain.segments : null;
14444
14875
  }
14445
14876
  function memberChain(expr) {
14446
- let node = import_ts_morph64.Node.isExpression(expr) ? unwrap2(expr) : expr;
14877
+ let node = import_ts_morph64.Node.isExpression(expr) ? unwrap(expr) : expr;
14447
14878
  if (import_ts_morph64.Node.isCallExpression(node)) {
14448
14879
  node = node.getExpression();
14449
14880
  }
@@ -14799,7 +15230,7 @@ function readArrayLiteralText(node) {
14799
15230
 
14800
15231
  // src/summaryIdentity.ts
14801
15232
  var import_node_path8 = __toESM(require("path"), 1);
14802
- var import_behavioral_ir8 = require("@suss/behavioral-ir");
15233
+ var import_behavioral_ir7 = require("@suss/behavioral-ir");
14803
15234
  function workspaceRootFor(anchor) {
14804
15235
  return namedPackageDirAbove(anchor) ?? import_node_path8.default.resolve(anchor);
14805
15236
  }
@@ -14822,8 +15253,8 @@ function nameSummaries(summaries, args) {
14822
15253
  }
14823
15254
  summary.identity.id = idFor(args.workspace, file, summary);
14824
15255
  }
14825
- (0, import_behavioral_ir8.disambiguateSummaryIds)(summaries);
14826
- (0, import_behavioral_ir8.linkCallsToSummaries)(summaries);
15256
+ (0, import_behavioral_ir7.disambiguateSummaryIds)(summaries);
15257
+ (0, import_behavioral_ir7.linkCallsToSummaries)(summaries);
14827
15258
  }
14828
15259
  function relativeFile(file, projectRoot) {
14829
15260
  if (projectRoot === void 0 || !import_node_path8.default.isAbsolute(file)) {
@@ -14833,7 +15264,7 @@ function relativeFile(file, projectRoot) {
14833
15264
  return relative.startsWith("..") ? file : relative;
14834
15265
  }
14835
15266
  function idFor(workspace, file, summary) {
14836
- return (0, import_behavioral_ir8.summaryIdFromParts)({
15267
+ return (0, import_behavioral_ir7.summaryIdFromParts)({
14837
15268
  workspace: workspace ?? void 0,
14838
15269
  file,
14839
15270
  name: summary.identity.name,
@@ -15337,7 +15768,7 @@ function announcedBoundaryStructure(unit) {
15337
15768
  declaredContract: null
15338
15769
  };
15339
15770
  }
15340
- function extractCodeStructure(unit, pack, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolveWrittenValue, originatesFrom, anchorCallsOf, resolveCallee2) {
15771
+ function extractCodeStructure(unit, pack, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolution, originatesFrom, anchorCallsOf, resolveCallee2) {
15341
15772
  const read2 = withDefinitions(
15342
15773
  () => readCodeStructure(
15343
15774
  unit,
@@ -15345,7 +15776,7 @@ function extractCodeStructure(unit, pack, invocationRecognizers = [], accessReco
15345
15776
  invocationRecognizers,
15346
15777
  accessRecognizers,
15347
15778
  barriers,
15348
- resolveWrittenValue,
15779
+ resolution,
15349
15780
  originatesFrom,
15350
15781
  anchorCallsOf,
15351
15782
  resolveCallee2
@@ -15430,7 +15861,7 @@ function terminalsFor(unit, pack) {
15430
15861
  }
15431
15862
  return [...declared, FUNCTION_FALLTHROUGH_TERMINAL];
15432
15863
  }
15433
- function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers, barriers, resolveWrittenValue, originatesFrom, anchorCallsOf, resolveCallee2) {
15864
+ function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers, barriers, resolution, originatesFrom, anchorCallsOf, resolveCallee2) {
15434
15865
  const { func, kind, name } = unit;
15435
15866
  if (func === null) {
15436
15867
  return announcedBoundaryStructure(unit);
@@ -15445,7 +15876,7 @@ function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers,
15445
15876
  invocationRecognizers,
15446
15877
  accessRecognizers,
15447
15878
  barriers,
15448
- resolveWrittenValue,
15879
+ resolution,
15449
15880
  originatesFrom,
15450
15881
  anchorCallsOf,
15451
15882
  resolveCallee2
@@ -15526,7 +15957,7 @@ function extractConsumerBinding(unit, pattern, pack, resolution) {
15526
15957
  }
15527
15958
  const method = extractBindingMethod(binding, callSite, pack, resolution);
15528
15959
  const path14 = extractBindingPath(binding, callSite, pack, resolution);
15529
- return (0, import_behavioral_ir9.restBinding)({
15960
+ return (0, import_behavioral_ir8.restBinding)({
15530
15961
  transport: pack.protocol,
15531
15962
  method: method ?? null,
15532
15963
  path: path14 ?? null,
@@ -15545,7 +15976,7 @@ function fileRouteBinding(filePath, unit, binding, pack) {
15545
15976
  if (method === void 0) {
15546
15977
  return null;
15547
15978
  }
15548
- return (0, import_behavioral_ir9.restBinding)({
15979
+ return (0, import_behavioral_ir8.restBinding)({
15549
15980
  transport: pack.protocol,
15550
15981
  recognition: pack.name,
15551
15982
  method,
@@ -15567,21 +15998,9 @@ function extractBindingMethod(binding, callSite, pack, resolution) {
15567
15998
  return resolveContractField(callSite, pack, "method", resolution);
15568
15999
  }
15569
16000
  if (m.type === "fromArgumentProperty") {
15570
- const args = callSite.callExpression.getArguments();
15571
- const arg = args[m.position];
15572
- if (arg !== void 0 && import_ts_morph66.Node.isObjectLiteralExpression(arg)) {
15573
- const prop = arg.getProperty(m.property);
15574
- if (prop !== void 0 && import_ts_morph66.Node.isPropertyAssignment(prop)) {
15575
- const init = prop.getInitializer();
15576
- if (init !== void 0) {
15577
- const value = stringValueOf(init, resolution);
15578
- if (value !== null) {
15579
- return value;
15580
- }
15581
- }
15582
- }
15583
- }
15584
- return m.default;
16001
+ const arg = callSite.callExpression.getArguments()[m.position];
16002
+ const value = arg === void 0 ? null : stringPropertyOf(arg, m.property, resolution);
16003
+ return value ?? m.default;
15585
16004
  }
15586
16005
  if (m.type === "literal") {
15587
16006
  return m.value;
@@ -15784,7 +16203,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
15784
16203
  allInvocationRecognizers,
15785
16204
  allAccessRecognizers,
15786
16205
  barriers,
15787
- resolution === void 0 ? void 0 : (value) => resolution.resolveWrittenValue(value),
16206
+ resolution,
15788
16207
  resolution === void 0 ? void 0 : (value, module2) => resolution.importOriginsOf(value, [module2]).length > 0,
15789
16208
  resolution === void 0 ? void 0 : (value, matches) => resolution.anchorCallsOf(value, matches),
15790
16209
  resolution === void 0 ? void 0 : (value) => resolution.resolveCallable(value)
@@ -15798,7 +16217,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
15798
16217
  stampWrappers(raw, unit, wrappers);
15799
16218
  const matchedPattern = unit.pattern ?? pack.discovery.find((d) => d.kind === unit.kind);
15800
16219
  if (unit.resolverInfo !== void 0) {
15801
- raw.boundaryBinding = (0, import_behavioral_ir9.graphqlResolverBinding)({
16220
+ raw.boundaryBinding = (0, import_behavioral_ir8.graphqlResolverBinding)({
15802
16221
  transport: pack.protocol,
15803
16222
  recognition: pack.name,
15804
16223
  typeName: unit.resolverInfo.typeName,
@@ -15825,26 +16244,26 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
15825
16244
  }
15826
16245
  }
15827
16246
  } else if (unit.routeInfo !== void 0) {
15828
- raw.boundaryBinding = (0, import_behavioral_ir9.restBinding)({
16247
+ raw.boundaryBinding = (0, import_behavioral_ir8.restBinding)({
15829
16248
  transport: pack.protocol,
15830
16249
  recognition: pack.name,
15831
16250
  method: unit.routeInfo.method,
15832
16251
  path: unit.routeInfo.path
15833
16252
  });
15834
16253
  } else if (unit.channelInfo !== void 0) {
15835
- raw.boundaryBinding = (0, import_behavioral_ir9.messageBusBinding)({
16254
+ raw.boundaryBinding = (0, import_behavioral_ir8.messageBusBinding)({
15836
16255
  recognition: pack.name,
15837
16256
  messageBus: unit.channelInfo.messageBus,
15838
16257
  channel: unit.channelInfo.channel
15839
16258
  });
15840
16259
  } else if (unit.invocationInfo !== void 0) {
15841
- raw.boundaryBinding = (0, import_behavioral_ir9.unitInvocationBinding)({
16260
+ raw.boundaryBinding = (0, import_behavioral_ir8.unitInvocationBinding)({
15842
16261
  recognition: pack.name,
15843
16262
  deploymentTarget: unit.invocationInfo.deploymentTarget,
15844
16263
  instanceName: unit.invocationInfo.instanceName
15845
16264
  });
15846
16265
  } else if (unit.operationInfo !== void 0) {
15847
- raw.boundaryBinding = (0, import_behavioral_ir9.graphqlOperationBinding)({
16266
+ raw.boundaryBinding = (0, import_behavioral_ir8.graphqlOperationBinding)({
15848
16267
  transport: pack.protocol,
15849
16268
  recognition: pack.name,
15850
16269
  operationType: unit.operationInfo.operationType,
@@ -15933,14 +16352,14 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
15933
16352
  }
15934
16353
  if (raw.boundaryBinding === null) {
15935
16354
  if (unit.packageExportInfo !== void 0) {
15936
- raw.boundaryBinding = (0, import_behavioral_ir9.packageExportBinding)({
16355
+ raw.boundaryBinding = (0, import_behavioral_ir8.packageExportBinding)({
15937
16356
  transport: pack.protocol,
15938
16357
  recognition: pack.name,
15939
16358
  packageName: unit.packageExportInfo.packageName,
15940
16359
  exportPath: unit.packageExportInfo.exportPath
15941
16360
  });
15942
16361
  } else {
15943
- raw.boundaryBinding = (0, import_behavioral_ir9.functionCallBinding)({
16362
+ raw.boundaryBinding = (0, import_behavioral_ir8.functionCallBinding)({
15944
16363
  transport: pack.protocol,
15945
16364
  recognition: pack.name,
15946
16365
  ...unit.functionCallInfo !== void 0 ? {
@@ -15952,7 +16371,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
15952
16371
  }
15953
16372
  const summary = (0, import_extractor11.assembleSummary)(raw, options);
15954
16373
  if (unit.unfollowed !== void 0 && options?.gapHandling !== "silent") {
15955
- summary.gaps.push((0, import_behavioral_ir3.unfollowedCallGap)(unit.unfollowed));
16374
+ summary.gaps.push((0, import_behavioral_ir2.unfollowedCallGap)(unit.unfollowed));
15956
16375
  }
15957
16376
  if (unit.metadata !== void 0 && Object.keys(unit.metadata).length > 0) {
15958
16377
  summary.metadata = {
@@ -16032,14 +16451,14 @@ function fileImporting(project, modulePrefix) {
16032
16451
  function liftSchemasOntoDocuments(summaries) {
16033
16452
  const sdlByDocument = /* @__PURE__ */ new Map();
16034
16453
  for (const summary of summaries) {
16035
- const label = (0, import_behavioral_ir9.readSourceDocumentMetadata)(summary)?.label;
16036
- const graphql = (0, import_behavioral_ir9.readGraphqlMetadata)(summary);
16454
+ const label = (0, import_behavioral_ir8.readSourceDocumentMetadata)(summary)?.label;
16455
+ const graphql = (0, import_behavioral_ir8.readGraphqlMetadata)(summary);
16037
16456
  if (label === void 0 || graphql?.schemaSdl === void 0) {
16038
16457
  continue;
16039
16458
  }
16040
16459
  sdlByDocument.set(label, graphql.schemaSdl);
16041
16460
  const { schemaSdl: _movedToTheDocument, ...rest } = graphql;
16042
- summary.metadata = (0, import_behavioral_ir9.withGraphqlMetadata)(summary.metadata, rest);
16461
+ summary.metadata = (0, import_behavioral_ir8.withGraphqlMetadata)(summary.metadata, rest);
16043
16462
  }
16044
16463
  for (const [label, schemaSdl] of sdlByDocument) {
16045
16464
  summaries.push(schemaDocumentSummary(label, schemaSdl));
@@ -16054,8 +16473,8 @@ function schemaDocumentSummary(label, schemaSdl) {
16054
16473
  transitions: [],
16055
16474
  gaps: [],
16056
16475
  confidence: { source: "declared", level: "high" },
16057
- metadata: (0, import_behavioral_ir9.withGraphqlMetadata)(
16058
- (0, import_behavioral_ir9.withSourceDocumentMetadata)(void 0, { label }),
16476
+ metadata: (0, import_behavioral_ir8.withGraphqlMetadata)(
16477
+ (0, import_behavioral_ir8.withSourceDocumentMetadata)(void 0, { label }),
16059
16478
  { schemaSdl }
16060
16479
  )
16061
16480
  };
@@ -16067,7 +16486,7 @@ function libraryEnvReadMarker(pack, declared, importer) {
16067
16486
  identity: {
16068
16487
  name: `${declared.module} env reads`,
16069
16488
  exportPath: null,
16070
- boundaryBinding: (0, import_behavioral_ir9.functionCallBinding)({
16489
+ boundaryBinding: (0, import_behavioral_ir8.functionCallBinding)({
16071
16490
  transport: "in-process",
16072
16491
  recognition: pack.name
16073
16492
  })
@@ -16278,7 +16697,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path14, options) {
16278
16697
  }
16279
16698
  };
16280
16699
  const raw = extractCodeStructure(unit, syntheticPack);
16281
- raw.boundaryBinding = (0, import_behavioral_ir9.restBinding)({
16700
+ raw.boundaryBinding = (0, import_behavioral_ir8.restBinding)({
16282
16701
  transport: wrapperBinding?.transport ?? "http",
16283
16702
  method: wrapperRest?.method ?? null,
16284
16703
  path: path14,
@@ -16618,7 +17037,7 @@ function createTypeScriptAdapter(suppliedConfig) {
16618
17037
  ...projectHelpers.contributedRecognizers()
16619
17038
  ],
16620
17039
  access: collectAccessRecognizers(config.frameworks, tallies),
16621
- resolveWrittenValue: (value) => resolution.resolveWrittenValue(value),
17040
+ resolution,
16622
17041
  resolveCallableSources: (value, alsoFrom) => resolution.resolveCallableSources(value, alsoFrom),
16623
17042
  sourceDeclarationsBehind: (declaration) => sourceDeclarationsBehind(declaration, resolution)
16624
17043
  },
@@ -16851,10 +17270,10 @@ function mergeWithReused(reused, fresh, ownersBySummary) {
16851
17270
  return { summaries: [...reusedKept, ...fresh], reusedKept, reusedOwners };
16852
17271
  }
16853
17272
  function readsRunLevelJoins(summary) {
16854
- if ((0, import_behavioral_ir9.readSourceDocumentMetadata)(summary) !== void 0) {
17273
+ if ((0, import_behavioral_ir8.readSourceDocumentMetadata)(summary) !== void 0) {
16855
17274
  return true;
16856
17275
  }
16857
- if ((0, import_behavioral_ir9.readGraphqlMetadata)(summary)?.client !== void 0) {
17276
+ if ((0, import_behavioral_ir8.readGraphqlMetadata)(summary)?.client !== void 0) {
16858
17277
  return true;
16859
17278
  }
16860
17279
  const semantics = summary.identity.boundaryBinding?.semantics;