codebaseiq 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (402) hide show
  1. package/CHANGELOG.md +44 -2
  2. package/README.md +1 -1
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/{chunk-2DMVFAY7.js → chunk-23C5AD3B.js} +2 -2
  5. package/dist/{chunk-WH5SYOMD.js → chunk-2E6OUPCF.js} +2 -2
  6. package/dist/{chunk-RWKEXCHU.js → chunk-2EDX3JT5.js} +2 -2
  7. package/dist/chunk-2I2UHZET.js +2 -0
  8. package/dist/{chunk-CSZOQ7YO.js → chunk-2OMXFE64.js} +2 -2
  9. package/dist/{chunk-EXMVF3JR.js → chunk-2PRONPAS.js} +3 -3
  10. package/dist/{chunk-5WXOEJ4G.js → chunk-356EZBIP.js} +2 -2
  11. package/dist/{chunk-A7XQT7MH.js → chunk-36JC5BG2.js} +2 -2
  12. package/dist/{chunk-RRPK327J.js → chunk-3RR2K7EZ.js} +2 -2
  13. package/dist/{chunk-3NUZVLR7.js → chunk-3RSBGWGL.js} +2 -2
  14. package/dist/{chunk-MTMF4N7F.js → chunk-3VJ3OCRE.js} +2 -2
  15. package/dist/{chunk-IBM3F2BJ.js → chunk-4LK5OIPW.js} +2 -2
  16. package/dist/{chunk-FQA3KIFX.js → chunk-5DSL3NT2.js} +2 -2
  17. package/dist/{chunk-IYBIBMPF.js → chunk-5FWR5HLG.js} +2 -2
  18. package/dist/{chunk-CIVYHK7U.js → chunk-5IC2WZAL.js} +2 -2
  19. package/dist/{chunk-PARCKE3Q.js → chunk-5IZRKWTZ.js} +2 -2
  20. package/dist/{chunk-HHBBGWES.js → chunk-5LL4KEHO.js} +2 -2
  21. package/dist/chunk-5T44HG5Y.js +88 -0
  22. package/dist/{chunk-YFQPWKHR.js → chunk-5ZI2PPI7.js} +2 -2
  23. package/dist/{chunk-T3YFIJ5P.js → chunk-67VJAYVR.js} +2 -2
  24. package/dist/{chunk-DKJXK3HA.js → chunk-6BF3VYEF.js} +2 -2
  25. package/dist/chunk-6JMAVFL4.js +3 -0
  26. package/dist/chunk-6O3KXIDL.js +2 -0
  27. package/dist/{chunk-OJFLPVBP.js → chunk-6VREELBC.js} +2 -2
  28. package/dist/chunk-6WAPPQ5F.js +82 -0
  29. package/dist/{chunk-QLTFXVUI.js → chunk-75KJGYX7.js} +2 -2
  30. package/dist/{chunk-PLZXWZHY.js → chunk-7GAK2F3H.js} +2 -2
  31. package/dist/{chunk-X5I2BQGX.js → chunk-7JELP5YE.js} +2 -2
  32. package/dist/{chunk-W3FK73MD.js → chunk-7UCDGXRW.js} +2 -2
  33. package/dist/{chunk-CMXW7MFV.js → chunk-AEXQYQD7.js} +2 -2
  34. package/dist/{chunk-PHPQ24UG.js → chunk-AQI4N64O.js} +2 -2
  35. package/dist/{chunk-XUJM6474.js → chunk-AURCQHSG.js} +2 -2
  36. package/dist/{chunk-EM5UHLAM.js → chunk-BBP7HVBJ.js} +2 -2
  37. package/dist/{chunk-57KFVPVZ.js → chunk-BFBIMTCJ.js} +2 -2
  38. package/dist/{chunk-VVCBMH5O.js → chunk-BGGB5N53.js} +2 -2
  39. package/dist/{chunk-ZOEDRCR4.js → chunk-BRQL7AFJ.js} +2 -2
  40. package/dist/{chunk-KDYQQJ6X.js → chunk-BWL3PMPT.js} +2 -2
  41. package/dist/{chunk-M7LAIM77.js → chunk-C6WKPKCF.js} +2 -2
  42. package/dist/{chunk-2F5ERMNI.js → chunk-C7OUW52M.js} +2 -2
  43. package/dist/{chunk-N3Q3AWGW.js → chunk-C7QWUBR2.js} +96 -96
  44. package/dist/{chunk-BX2U3QQV.js → chunk-CCIYWXX6.js} +2 -2
  45. package/dist/{chunk-3AC56WAR.js → chunk-CIYA2KZN.js} +2 -2
  46. package/dist/{chunk-35YYZD3D.js → chunk-CR3OG6SQ.js} +2 -2
  47. package/dist/{chunk-VYZQZ4ZN.js → chunk-CVHOQONG.js} +2 -2
  48. package/dist/{chunk-4IFISPQW.js → chunk-CW6AXOLR.js} +2 -2
  49. package/dist/{chunk-NDGTJHQN.js → chunk-D53LWANR.js} +2 -2
  50. package/dist/{chunk-VCWAJPXQ.js → chunk-D7AZAOZX.js} +2 -2
  51. package/dist/{chunk-ACZDU5GK.js → chunk-D7DOB27N.js} +7 -7
  52. package/dist/{chunk-CDWSLAPN.js → chunk-DAKIGMIK.js} +2 -2
  53. package/dist/chunk-DDN2F6GB.js +2 -0
  54. package/dist/{chunk-L3YSDLNB.js → chunk-DVWO7RBC.js} +2 -2
  55. package/dist/{chunk-KNV5VFDV.js → chunk-E52K4L2W.js} +2 -2
  56. package/dist/chunk-EIBGSU2R.js +2 -0
  57. package/dist/chunk-EQNMD62X.js +51 -0
  58. package/dist/{chunk-LY2NB5XR.js → chunk-EXZ7VLRY.js} +2 -2
  59. package/dist/{chunk-YIOQJ45A.js → chunk-F3QSL4W2.js} +2 -2
  60. package/dist/{chunk-JOALNFY3.js → chunk-F74LZWCE.js} +2 -2
  61. package/dist/{chunk-ZB3V5QM7.js → chunk-FEIZXBLH.js} +2 -2
  62. package/dist/{chunk-NJA4MMBD.js → chunk-FH5WG4LE.js} +2 -2
  63. package/dist/{chunk-MRGTCMDK.js → chunk-FOZ74V56.js} +2 -2
  64. package/dist/{chunk-S5SKXCND.js → chunk-FQTIFWLR.js} +2 -2
  65. package/dist/chunk-FTTV7IRX.js +355 -0
  66. package/dist/chunk-FWQGH2N2.js +2 -0
  67. package/dist/{chunk-PFPHS4NO.js → chunk-GDHWOA57.js} +2 -2
  68. package/dist/{chunk-H3CKAL6P.js → chunk-GIDCP7KV.js} +2 -2
  69. package/dist/{chunk-6SDEQTVY.js → chunk-GL6UTNUB.js} +2 -2
  70. package/dist/{chunk-37TKC6MB.js → chunk-GP7C5VAE.js} +2 -2
  71. package/dist/{chunk-U24M5RQM.js → chunk-GQLDYCWS.js} +2 -2
  72. package/dist/{chunk-I5FCDTK2.js → chunk-GQXXOS55.js} +2 -2
  73. package/dist/{chunk-NTRW52UR.js → chunk-GUFPEFBG.js} +2 -2
  74. package/dist/{chunk-B2E3HZ2A.js → chunk-GV2CEZCW.js} +2 -2
  75. package/dist/{chunk-AM5SUGHF.js → chunk-GVAF222T.js} +2 -2
  76. package/dist/{chunk-TAJ6UGCO.js → chunk-GWYZVVKY.js} +3 -3
  77. package/dist/{chunk-NK76RSB6.js → chunk-HENP2O4A.js} +2 -2
  78. package/dist/{chunk-VG55NFXF.js → chunk-HINZQKSY.js} +2 -2
  79. package/dist/{chunk-6OVNYYY4.js → chunk-HQA7EBSK.js} +2 -2
  80. package/dist/{chunk-DLC6JDN7.js → chunk-HVFB3PME.js} +2 -2
  81. package/dist/{chunk-FY5V4V4F.js → chunk-I22IZYDI.js} +2 -2
  82. package/dist/{chunk-RVYLJDXC.js → chunk-ICUL7XRT.js} +2 -2
  83. package/dist/{chunk-QVHZB75Z.js → chunk-IHSLIIL3.js} +2 -2
  84. package/dist/{chunk-PNVZIJ57.js → chunk-ITSJMNUD.js} +2 -2
  85. package/dist/{chunk-XNUWRTYM.js → chunk-IZDPGOZR.js} +2 -2
  86. package/dist/chunk-J3GLP7Q5.js +3 -0
  87. package/dist/{chunk-BH5CE4LN.js → chunk-J7AMBVWF.js} +2 -2
  88. package/dist/{chunk-YXJ4IAHH.js → chunk-JCMFBF4Z.js} +2 -2
  89. package/dist/{chunk-ZJZQ7Q2Q.js → chunk-JFIA2JI3.js} +2 -2
  90. package/dist/{chunk-FIXYHQ3W.js → chunk-JLZLLLW5.js} +2 -2
  91. package/dist/{chunk-2E6BTWER.js → chunk-JSNTHRLQ.js} +2 -2
  92. package/dist/{chunk-77GHPR2R.js → chunk-JX6ZWDOS.js} +2 -2
  93. package/dist/{chunk-SRY26ITJ.js → chunk-JYI7CV25.js} +2 -2
  94. package/dist/chunk-K7JLSGCJ.js +8 -0
  95. package/dist/{chunk-DFPAZXLU.js → chunk-KPZGTB2O.js} +2 -2
  96. package/dist/{chunk-7Z7HCZ7J.js → chunk-LKUTSP4G.js} +2 -2
  97. package/dist/{chunk-HIEXRDJF.js → chunk-LMTSB3TB.js} +2 -2
  98. package/dist/{chunk-BLKYYQ7C.js → chunk-LONKINMJ.js} +95 -95
  99. package/dist/{chunk-SF34QLK2.js → chunk-LQHYYIOB.js} +2 -2
  100. package/dist/{chunk-HBQGKMM3.js → chunk-LZSQ6X7E.js} +2 -2
  101. package/dist/{chunk-RCPZOPV6.js → chunk-M2Y6PCFE.js} +2 -2
  102. package/dist/{chunk-WJOQC4P7.js → chunk-MEUHIDI3.js} +2 -2
  103. package/dist/{chunk-MT5W4DUG.js → chunk-MHWMEZDA.js} +2 -2
  104. package/dist/{chunk-FLLXYUOL.js → chunk-MQW6SJ4P.js} +2 -2
  105. package/dist/{chunk-57KEZDPT.js → chunk-MSI3K7PJ.js} +2 -2
  106. package/dist/chunk-MVRGB4KJ.js +278 -0
  107. package/dist/{chunk-27PHVDKL.js → chunk-MZNMASFM.js} +2 -2
  108. package/dist/{chunk-DVYG3JTA.js → chunk-NBCQZSGR.js} +2 -2
  109. package/dist/{chunk-NIO346UL.js → chunk-NBZKSTXP.js} +2 -2
  110. package/dist/{chunk-UWB5WMC2.js → chunk-NCJILOAK.js} +2 -2
  111. package/dist/{chunk-JN5LIBT3.js → chunk-NDKOVQFG.js} +2 -2
  112. package/dist/{chunk-W6C6QTXJ.js → chunk-NEWHKGVD.js} +2 -2
  113. package/dist/{chunk-HBXZAGY6.js → chunk-O2M3VNDY.js} +2 -2
  114. package/dist/chunk-OFGOOL6U.js +3 -0
  115. package/dist/{chunk-FEBLLMTL.js → chunk-OQUCBKOI.js} +2 -2
  116. package/dist/{chunk-5IO2APSS.js → chunk-P4NVCOM7.js} +2 -2
  117. package/dist/{chunk-SJZQ2PTZ.js → chunk-PFC44E6D.js} +2 -2
  118. package/dist/{chunk-LAGDJXFY.js → chunk-PHNCEUXX.js} +2 -2
  119. package/dist/{chunk-HYKSLTAR.js → chunk-PTQPPPG2.js} +2 -2
  120. package/dist/{chunk-5XEVXVTK.js → chunk-PUVNH4PO.js} +2 -2
  121. package/dist/chunk-Q23IMHXS.js +343 -0
  122. package/dist/{chunk-YYFV32WR.js → chunk-Q3ZCQY2Y.js} +2 -2
  123. package/dist/{chunk-OMBRP7BB.js → chunk-Q4XEU3UH.js} +2 -2
  124. package/dist/{chunk-I645ZF75.js → chunk-QEOWONKY.js} +2 -2
  125. package/dist/{chunk-JXHLB7TP.js → chunk-QMOZZ2VX.js} +2 -2
  126. package/dist/{chunk-2VKB5CMA.js → chunk-RCIGX23V.js} +2 -2
  127. package/dist/{chunk-J24VICI5.js → chunk-RIYJ4L33.js} +2 -2
  128. package/dist/{chunk-M4EVGA5S.js → chunk-RJVAPMHF.js} +3 -3
  129. package/dist/chunk-SB7NASHU.js +2 -0
  130. package/dist/{chunk-3XFJUWJE.js → chunk-SGMNWYTH.js} +2 -2
  131. package/dist/chunk-SMDIEDM4.js +27 -0
  132. package/dist/{chunk-IOVPAZWP.js → chunk-SX72EVMY.js} +2 -2
  133. package/dist/{chunk-WO47BIPY.js → chunk-T5X7DK6C.js} +2 -2
  134. package/dist/{chunk-CZEIHYMP.js → chunk-T6MQNNAC.js} +2 -2
  135. package/dist/chunk-T75DS2E6.js +21 -0
  136. package/dist/{chunk-57GCCPLS.js → chunk-TEANKHUU.js} +2 -2
  137. package/dist/{chunk-T55YPJGB.js → chunk-TJBOJUVN.js} +2 -2
  138. package/dist/{chunk-I2KP4AGR.js → chunk-TJWVT4DO.js} +2 -2
  139. package/dist/{chunk-KM4QRWI5.js → chunk-TNJGTQWO.js} +2 -2
  140. package/dist/{chunk-EFFMFK7C.js → chunk-TOTWJZIX.js} +2 -2
  141. package/dist/{chunk-QMGWSEPL.js → chunk-TPO7XC5Z.js} +2 -2
  142. package/dist/{chunk-54K6556S.js → chunk-U33PMPNW.js} +2 -2
  143. package/dist/{chunk-GXVDTHFC.js → chunk-U7NUXDQO.js} +2 -2
  144. package/dist/chunk-UC2FD2PS.js +4 -0
  145. package/dist/{chunk-TUTSO7UZ.js → chunk-UQE4XFSA.js} +2 -2
  146. package/dist/{chunk-4O52YNKL.js → chunk-UQYQBLJX.js} +2 -2
  147. package/dist/{chunk-FPDL2TUB.js → chunk-USOAJHY7.js} +2 -2
  148. package/dist/{chunk-JUO3Z644.js → chunk-UW6KD57C.js} +2 -2
  149. package/dist/{chunk-VLTUX4IF.js → chunk-VGWZ4MOY.js} +2 -2
  150. package/dist/{chunk-U2XX3BT4.js → chunk-VWYGCMV5.js} +2 -2
  151. package/dist/{chunk-IWAMYGPN.js → chunk-W7YLRXZE.js} +2 -2
  152. package/dist/{chunk-QKVTWODE.js → chunk-WK2IQJPK.js} +2 -2
  153. package/dist/{chunk-S64NCE2Z.js → chunk-WWCV4E6J.js} +2 -2
  154. package/dist/{chunk-IVJJNVSX.js → chunk-XMJ53WG4.js} +2 -2
  155. package/dist/{chunk-IGYAZPRX.js → chunk-XN3EKMLI.js} +2 -2
  156. package/dist/{chunk-FWY2PRIF.js → chunk-XQAVQVIL.js} +2 -2
  157. package/dist/{chunk-JYX5UZSZ.js → chunk-XQPPURLQ.js} +2 -2
  158. package/dist/{chunk-4AOOSCZ7.js → chunk-YHPG3S2U.js} +2 -2
  159. package/dist/{chunk-5BDK6QC3.js → chunk-YRKP7PM7.js} +2 -2
  160. package/dist/{chunk-4NHWNAWQ.js → chunk-YT4DVWUV.js} +2 -2
  161. package/dist/{chunk-5NJPH3QZ.js → chunk-YTJHCGYB.js} +2 -2
  162. package/dist/chunk-Z35GOVEH.js +2 -0
  163. package/dist/{chunk-K5G7SPAG.js → chunk-Z6RL7XOE.js} +4 -4
  164. package/dist/{chunk-OVKZM2XI.js → chunk-ZAFGY22Q.js} +2 -2
  165. package/dist/{chunk-A67HT5FR.js → chunk-ZB4C5TTR.js} +2 -2
  166. package/dist/{chunk-CWMHWD56.js → chunk-ZNH33XIB.js} +2 -2
  167. package/dist/{chunk-ZNQCR656.js → chunk-ZQ62NNKN.js} +2 -2
  168. package/dist/{cli-context-XEPPF4RX.js → cli-context-FJL2JHOE.js} +2 -2
  169. package/dist/{cli-context-TSADTXLB.js → cli-context-PQNWHMCQ.js} +2 -2
  170. package/dist/{cli-program-KJGQEM72.js → cli-program-UO7PZD6V.js} +2 -2
  171. package/dist/cli.js +1 -1
  172. package/dist/{code-CDe-mIjx.d.ts → code-DfX3xeWy.d.ts} +1 -1
  173. package/dist/{code-viewer-YGDON6SY.js → code-viewer-KIXEYQNJ.js} +2 -2
  174. package/dist/{code-viewer-ZCTHXQ5C.js → code-viewer-VHLBLIUM.js} +2 -2
  175. package/dist/{command-descriptors-5VAB2MZX.js → command-descriptors-F5P2V3NW.js} +129 -129
  176. package/dist/{command-descriptors-EAHKIRAG.js → command-descriptors-YCLATF5I.js} +130 -130
  177. package/dist/{db-DmRNdCtm.d.ts → db-BoG_PWYH.d.ts} +1 -1
  178. package/dist/direct-navigation-4XJTXIDT.js +2 -0
  179. package/dist/direct-navigation-J5MVYYAD.js +3 -0
  180. package/dist/{graph-evidence-Bs54NWws.d.ts → graph-evidence-D1jx1Cql.d.ts} +1 -1
  181. package/dist/{health-BnzbSLCE.d.ts → health-DkYBS5BI.d.ts} +1 -1
  182. package/dist/index.d.ts +1 -1
  183. package/dist/index.js +1 -1
  184. package/dist/invocation-command-descriptors-RWV4VAI4.js +2 -0
  185. package/dist/invocation-command-descriptors-U76PN7IY.js +3 -0
  186. package/dist/{scip-cli-BRFKkHQn.d.ts → maintenance-types-CdL5eQii.d.ts} +1 -20
  187. package/dist/output-continuation-command-BL25S26S.js +3 -0
  188. package/dist/output-continuation-command-BTETTXEC.js +2 -0
  189. package/dist/postinstall.js +1 -1
  190. package/dist/project-reindex-CRJU3IFG.js +2 -0
  191. package/dist/project-reindex-TQFCOA2O.js +3 -0
  192. package/dist/queries/affected.d.ts +1 -1
  193. package/dist/queries/affected.js +1 -1
  194. package/dist/queries/anchors.d.ts +1 -1
  195. package/dist/queries/anchors.js +1 -1
  196. package/dist/queries/architecture.d.ts +1 -1
  197. package/dist/queries/architecture.js +1 -1
  198. package/dist/queries/bottlenecks.d.ts +1 -1
  199. package/dist/queries/bottlenecks.js +1 -1
  200. package/dist/queries/by-kind.d.ts +1 -1
  201. package/dist/queries/by-kind.js +1 -1
  202. package/dist/queries/call-graph.d.ts +1 -1
  203. package/dist/queries/call-graph.js +1 -1
  204. package/dist/queries/change-surface.d.ts +1 -1
  205. package/dist/queries/change-surface.js +1 -1
  206. package/dist/queries/cleanup-plan.d.ts +1 -1
  207. package/dist/queries/cleanup-plan.js +1 -1
  208. package/dist/queries/co-change.d.ts +1 -1
  209. package/dist/queries/co-change.js +1 -1
  210. package/dist/queries/code.d.ts +2 -2
  211. package/dist/queries/code.js +1 -1
  212. package/dist/queries/complexity-hotspots.d.ts +1 -1
  213. package/dist/queries/complexity-hotspots.js +1 -1
  214. package/dist/queries/complexity.d.ts +1 -1
  215. package/dist/queries/complexity.js +1 -1
  216. package/dist/queries/context.d.ts +1 -1
  217. package/dist/queries/context.js +1 -1
  218. package/dist/queries/convergence.d.ts +1 -1
  219. package/dist/queries/convergence.js +1 -1
  220. package/dist/queries/coupling.d.ts +1 -1
  221. package/dist/queries/coupling.js +1 -1
  222. package/dist/queries/cycles.d.ts +1 -1
  223. package/dist/queries/cycles.js +1 -1
  224. package/dist/queries/dataflow.d.ts +1 -1
  225. package/dist/queries/dataflow.js +1 -1
  226. package/dist/queries/dead.d.ts +1 -1
  227. package/dist/queries/dead.js +1 -1
  228. package/dist/queries/decorative-checkers.d.ts +1 -1
  229. package/dist/queries/decorative-checkers.js +1 -1
  230. package/dist/queries/deep-chains.d.ts +1 -1
  231. package/dist/queries/deep-chains.js +1 -1
  232. package/dist/queries/dependence-slice.d.ts +2 -2
  233. package/dist/queries/dependence-slice.js +1 -1
  234. package/dist/queries/dependency-depth.d.ts +1 -1
  235. package/dist/queries/dependency-depth.js +1 -1
  236. package/dist/queries/deps.d.ts +1 -1
  237. package/dist/queries/deps.js +1 -1
  238. package/dist/queries/diff-impact.d.ts +1 -1
  239. package/dist/queries/diff-impact.js +1 -1
  240. package/dist/queries/doc-drift.d.ts +1 -1
  241. package/dist/queries/doc-drift.js +1 -1
  242. package/dist/queries/drift.d.ts +1 -1
  243. package/dist/queries/drift.js +1 -1
  244. package/dist/queries/duplicate-bodies.d.ts +1 -1
  245. package/dist/queries/duplicate-bodies.js +1 -1
  246. package/dist/queries/entry-map.d.ts +1 -1
  247. package/dist/queries/entry-map.js +1 -1
  248. package/dist/queries/evidence.d.ts +2 -2
  249. package/dist/queries/evidence.js +1 -1
  250. package/dist/queries/extract-candidates.d.ts +1 -1
  251. package/dist/queries/extract-candidates.js +1 -1
  252. package/dist/queries/fan.d.ts +1 -1
  253. package/dist/queries/fan.js +1 -1
  254. package/dist/queries/files.d.ts +1 -1
  255. package/dist/queries/files.js +1 -1
  256. package/dist/queries/health.d.ts +2 -2
  257. package/dist/queries/health.js +1 -1
  258. package/dist/queries/hierarchy.d.ts +1 -1
  259. package/dist/queries/hierarchy.js +1 -1
  260. package/dist/queries/hotspots.d.ts +1 -1
  261. package/dist/queries/hotspots.js +1 -1
  262. package/dist/queries/imports.d.ts +1 -1
  263. package/dist/queries/imports.js +1 -1
  264. package/dist/queries/incomplete-migration.d.ts +1 -1
  265. package/dist/queries/incomplete-migration.js +1 -1
  266. package/dist/queries/index.d.ts +4 -4
  267. package/dist/queries/index.js +1 -1
  268. package/dist/queries/isolated.d.ts +1 -1
  269. package/dist/queries/isolated.js +1 -1
  270. package/dist/queries/locality-candidates.d.ts +1 -1
  271. package/dist/queries/locality-candidates.js +1 -1
  272. package/dist/queries/members.d.ts +1 -1
  273. package/dist/queries/members.js +1 -1
  274. package/dist/queries/methods.d.ts +1 -1
  275. package/dist/queries/methods.js +1 -1
  276. package/dist/queries/not-implemented.d.ts +1 -1
  277. package/dist/queries/not-implemented.js +1 -1
  278. package/dist/queries/outline.d.ts +1 -1
  279. package/dist/queries/outline.js +1 -1
  280. package/dist/queries/passthrough-candidates.d.ts +1 -1
  281. package/dist/queries/passthrough-candidates.js +1 -1
  282. package/dist/queries/plan-context.d.ts +1 -1
  283. package/dist/queries/plan-context.js +1 -1
  284. package/dist/queries/react-component-duplicates.d.ts +1 -1
  285. package/dist/queries/react-component-duplicates.js +1 -1
  286. package/dist/queries/react-hook-candidates.d.ts +1 -1
  287. package/dist/queries/react-hook-candidates.js +1 -1
  288. package/dist/queries/react-large-component-pressure.d.ts +1 -1
  289. package/dist/queries/react-large-component-pressure.js +1 -1
  290. package/dist/queries/recent-duplicates.d.ts +1 -1
  291. package/dist/queries/recent-duplicates.js +1 -1
  292. package/dist/queries/redundant-reexports.d.ts +1 -1
  293. package/dist/queries/redundant-reexports.js +1 -1
  294. package/dist/queries/reference-neighborhood.d.ts +1 -1
  295. package/dist/queries/reference-neighborhood.js +1 -1
  296. package/dist/queries/reference-reachability.d.ts +1 -1
  297. package/dist/queries/reference-reachability.js +1 -1
  298. package/dist/queries/refs.d.ts +1 -1
  299. package/dist/queries/refs.js +1 -1
  300. package/dist/queries/self-audit.d.ts +1 -1
  301. package/dist/queries/self-audit.js +1 -1
  302. package/dist/queries/similar-chains.d.ts +1 -1
  303. package/dist/queries/similar-chains.js +1 -1
  304. package/dist/queries/similar-files.d.ts +1 -1
  305. package/dist/queries/similar-files.js +1 -1
  306. package/dist/queries/similar-signatures.d.ts +1 -1
  307. package/dist/queries/similar-signatures.js +1 -1
  308. package/dist/queries/similar.d.ts +1 -1
  309. package/dist/queries/similar.js +1 -1
  310. package/dist/queries/slice.d.ts +1 -1
  311. package/dist/queries/slice.js +1 -1
  312. package/dist/queries/source-inspection.d.ts +3 -3
  313. package/dist/queries/source-inspection.js +1 -1
  314. package/dist/queries/source-search.d.ts +1 -1
  315. package/dist/queries/source-search.js +1 -1
  316. package/dist/queries/stale-abstractions.d.ts +1 -1
  317. package/dist/queries/stale-abstractions.js +1 -1
  318. package/dist/queries/stats.d.ts +1 -1
  319. package/dist/queries/surface.d.ts +1 -1
  320. package/dist/queries/surface.js +1 -1
  321. package/dist/queries/symbols.d.ts +1 -1
  322. package/dist/queries/symbols.js +1 -1
  323. package/dist/queries/system-map.d.ts +1 -1
  324. package/dist/queries/system-map.js +1 -1
  325. package/dist/queries/system.d.ts +1 -1
  326. package/dist/queries/system.js +1 -1
  327. package/dist/queries/test-quality.d.ts +1 -1
  328. package/dist/queries/test-quality.js +1 -1
  329. package/dist/queries/trace.d.ts +1 -1
  330. package/dist/queries/trace.js +1 -1
  331. package/dist/queries/twin-ab.d.ts +1 -1
  332. package/dist/queries/twin-ab.js +1 -1
  333. package/dist/queries/twin-drift.d.ts +1 -1
  334. package/dist/queries/twin-drift.js +1 -1
  335. package/dist/queries/unused-imports.d.ts +1 -1
  336. package/dist/queries/unused-imports.js +1 -1
  337. package/dist/queries/unused-params.d.ts +1 -1
  338. package/dist/queries/unused-params.js +1 -1
  339. package/dist/queries/value-flow.d.ts +2 -2
  340. package/dist/queries/value-flow.js +1 -1
  341. package/dist/queries/vue-component-duplicates.d.ts +1 -1
  342. package/dist/queries/vue-component-duplicates.js +1 -1
  343. package/dist/queries/vue-composable-candidates.d.ts +1 -1
  344. package/dist/queries/vue-composable-candidates.js +1 -1
  345. package/dist/queries/vue-large-view-pressure.d.ts +1 -1
  346. package/dist/queries/vue-large-view-pressure.js +1 -1
  347. package/dist/queries/wrapper-candidates.d.ts +1 -1
  348. package/dist/queries/wrapper-candidates.js +1 -1
  349. package/dist/reindex-worker.js +2 -2
  350. package/dist/reindex.d.ts +2 -4
  351. package/dist/reindex.js +71 -32
  352. package/dist/runtime.d.ts +1 -2
  353. package/dist/runtime.js +3 -3
  354. package/dist/rust-semantic-session-server.js +1 -1
  355. package/dist/rust-semantic-session-worker.js +1 -1
  356. package/dist/rust-semantic-worker.js +1 -1
  357. package/dist/sentinel-ensure-command-OSWGCFFL.js +3 -0
  358. package/dist/sentinel-ensure-command-SPW7XQLB.js +2 -0
  359. package/dist/sentinel-worker.js +1 -1
  360. package/dist/typescript-mailbox-worker.js +1 -1
  361. package/dist/watch-server.js +2 -2
  362. package/docs/INDEX_GENERATIONS.md +2 -2
  363. package/docs/NPM_RELEASE.md +323 -0
  364. package/docs/schemas/npm-release-state.schema.json +4 -13
  365. package/package.json +3 -11
  366. package/dist/chunk-2Q2LW5JW.js +0 -14
  367. package/dist/chunk-327YK6TB.js +0 -4
  368. package/dist/chunk-347TXATM.js +0 -2
  369. package/dist/chunk-36WRYYTE.js +0 -3
  370. package/dist/chunk-6OAHRI2D.js +0 -6
  371. package/dist/chunk-6URCE5QY.js +0 -2
  372. package/dist/chunk-6ZV5EDUT.js +0 -5
  373. package/dist/chunk-7R64XY4Y.js +0 -12
  374. package/dist/chunk-CANBLFVQ.js +0 -15
  375. package/dist/chunk-CCRZLRWJ.js +0 -2
  376. package/dist/chunk-G2XUZCF2.js +0 -88
  377. package/dist/chunk-H5QXP63L.js +0 -2
  378. package/dist/chunk-HCMQZPEO.js +0 -2
  379. package/dist/chunk-IEL6Q5W3.js +0 -308
  380. package/dist/chunk-IGQQUENU.js +0 -109
  381. package/dist/chunk-K2O7SBAU.js +0 -2
  382. package/dist/chunk-QVWDQTMG.js +0 -2
  383. package/dist/chunk-RJWAB4VR.js +0 -345
  384. package/dist/chunk-VCL7FK3E.js +0 -3
  385. package/dist/chunk-WOOTEWQT.js +0 -239
  386. package/dist/chunk-XYLV727H.js +0 -21
  387. package/dist/chunk-YMGZZEW4.js +0 -2
  388. package/dist/direct-navigation-B3SGOOBW.js +0 -2
  389. package/dist/direct-navigation-ZL362KXF.js +0 -3
  390. package/dist/invocation-command-descriptors-CSUGUHTT.js +0 -2
  391. package/dist/invocation-command-descriptors-PPVZOIE5.js +0 -3
  392. package/dist/output-continuation-command-FTVVBVSN.js +0 -2
  393. package/dist/output-continuation-command-ITPRC3YV.js +0 -3
  394. package/dist/project-reindex-7HZSLLLY.js +0 -3
  395. package/dist/project-reindex-NGM3DYBN.js +0 -2
  396. package/dist/sentinel-ensure-command-KYYULCFU.js +0 -2
  397. package/dist/sentinel-ensure-command-RIZA3RY7.js +0 -3
  398. package/docs/WINDOWS_SIDECAR_RELEASE.md +0 -424
  399. package/docs/schemas/windows-sidecar-provenance.schema.json +0 -137
  400. package/scripts/build-codebaseiq-windows.mjs +0 -197
  401. package/scripts/codebaseiq-windows-provenance.mjs +0 -364
  402. package/scripts/verify-codebaseiq-windows.mjs +0 -29
@@ -1,4 +1,4 @@
1
- import{a as Bn,b as _n}from"./chunk-PARCKE3Q.js";import{a as Dt,b as Bt}from"./chunk-KDYQQJ6X.js";import{a as Dn}from"./chunk-GXVDTHFC.js";import{b as An}from"./chunk-CMXW7MFV.js";import{a as Pn,b as At,c as kn,e as $n}from"./chunk-CCRZLRWJ.js";import{b as Rn,c as Tn,d as Fn}from"./chunk-VVCBMH5O.js";import{a as $t,b as wn,c as Cn,d as Nn,i as Mn}from"./chunk-U24M5RQM.js";import{a as Ln}from"./chunk-MTMF4N7F.js";import{c as En}from"./chunk-NK76RSB6.js";import{M as vn,N as In}from"./chunk-6ZV5EDUT.js";import{a as Pt}from"./chunk-BH5CE4LN.js";import{b as kt}from"./chunk-3XFJUWJE.js";import{g as hn,i as xn}from"./chunk-JN5LIBT3.js";import{a as dt}from"./chunk-ZOEDRCR4.js";import{A as ze,d as ie,i as le,t as Fe}from"./chunk-AM5SUGHF.js";import{f as Me,p as bn}from"./chunk-JOALNFY3.js";import{C as Be,a as gn,b as yn}from"./chunk-RVYLJDXC.js";import{g as fn,w as Sn,x as Ft}from"./chunk-PLZXWZHY.js";var On=["call","contract-symbol","import","reference","runtime-boundary"],sr={call:[{family:"control",subtype:"call"}],"contract-symbol":[{family:"contract",subtype:"uses-contract-symbol"}],import:[{family:"identity",subtype:"imports"}],reference:[{family:"identity",subtype:"references"}]},ar={"structural-membership":[{family:"identity",subtype:"contains"}],"boundary-observation":[{family:"identity",subtype:"owns-runtime-observation"}],"external-import":[{family:"identity",subtype:"imports-external"}]};function Kn(e){if(e.kind!=="runtime-boundary")return jn(sr[e.kind]);let t=e.fromBoundaryParticipant?.protocol??e.toBoundaryParticipant?.protocol,n={crossesRuntimeBoundary:!0,...t?{protocol:t}:{},...e.runtimeBoundaryKey?{runtimeKey:e.runtimeBoundaryKey}:{}},o=[{family:"control",subtype:"runtime-handoff",context:n}];return e.evidence==="runtime-boundary:carrier.discriminator"&&(o.push({family:"control",subtype:"discriminator-dispatch",context:{...n},attributes:{joinRule:"carrier.discriminator",...e.fromBoundaryParticipant?.action?{producerAction:e.fromBoundaryParticipant.action}:{},...e.toBoundaryParticipant?.action?{consumerAction:e.toBoundaryParticipant.action}:{}}}),o.push({family:"data",subtype:"serialized-discriminator-transfer",context:{...n},attributes:{joinRule:"carrier.discriminator"}})),e.evidence==="runtime-boundary:queue.address"&&e.fromBoundaryParticipant?.action==="queue.send"&&e.toBoundaryParticipant?.action==="queue.consume"&&o.push({family:"temporal",subtype:"enqueue-before-consume",context:{...n},attributes:{producerAction:e.fromBoundaryParticipant.action,consumerAction:e.toBoundaryParticipant.action,retryPolicy:"unknown"}}),o}function ct(e){return jn(ar[e])}function jn(e){return e.map(t=>({...t,...t.context?{context:{...t.context}}:{},...t.attributes?{attributes:{...t.attributes}}:{}}))}import{join as kr}from"path";import{createRequire as lr}from"module";import{resolve as Qe}from"path";var dr=lr(import.meta.url),Ye;function zn(e,t,n){let o=cr();if(!o)return _t("The TypeScript compiler runtime is unavailable.");let s=ur(o,e,t),i=s.getSourceFile(Qe(t))??s.getSourceFile(t);if(!i)return _t(`The TypeScript compiler did not materialize ${t}.`);let r={ts:o,sourceFile:i,checker:s.getTypeChecker(),points:new Map,edges:new Map,unsupported:new Set,nextCfgId:0},a=mr(o,i,n);if(a.length===0)return _t("No function-like construct intersects the selected source range.");let l=new Map(a.map(f=>[f,fr(i,f)])),d=a.map(f=>yr(r,f,gr(o,f,l),l.get(f)));for(let f of d)Sr(r,f),vr(r,f),Lr(r,f);Cr(r,d);let c=[...r.unsupported].sort();return{points:[...r.points.values()].map(({node:f,...y})=>y).sort(Pr),edges:[...r.edges.values()].sort((f,y)=>f.id.localeCompare(y.id)),coverage:{status:c.length===0?"complete":"partial",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:c}}}function cr(){if(Ye!==void 0)return Ye;try{Ye=dr("typescript")}catch{Ye=In()?.ts??null}return Ye}function ur(e,t,n){let o=Qe(n),s={target:e.ScriptTarget.ESNext,module:e.ModuleKind.NodeNext,moduleResolution:e.ModuleResolutionKind.NodeNext,skipLibCheck:!0,noResolve:!0},i=e.createSourceFile(o,t,s.target,!0,pr(e,o)),r=e.createCompilerHost(s,!0),a=r.getSourceFile.bind(r),l=r.readFile.bind(r),d=r.fileExists.bind(r);return r.getSourceFile=(c,f,y,m)=>Qe(c)===o?i:a(c,f,y,m),r.readFile=c=>Qe(c)===o?t:l(c),r.fileExists=c=>Qe(c)===o||d(c),e.createProgram([o],s,r)}function pr(e,t){return/\.tsx$/iu.test(t)?e.ScriptKind.TSX:/\.[cm]?js$/iu.test(t)?e.ScriptKind.JS:/\.jsx$/iu.test(t)?e.ScriptKind.JSX:e.ScriptKind.TS}function mr(e,t,n){let o=[],s=i=>{if(Un(e,i)){let r=t.getLineAndCharacterOfPosition(i.getStart(t)).line,a=t.getLineAndCharacterOfPosition(i.getEnd()).line;(!n||r<=n.endLine&&a>=n.startLine)&&o.push(i)}i.forEachChild(s)};return t.forEachChild(s),o.sort((i,r)=>i.getStart(t)-r.getStart(t))}function Un(e,t){return e.isFunctionLike(t)&&"body"in t&&t.body!==void 0}function fr(e,t){return`callable:${encodeURIComponent(e.fileName)}:${t.getStart(e)}:${t.getEnd()}`}function gr(e,t,n){for(let o=t.parent;o;o=o.parent)if(Un(e,o)&&n.has(o))return n.get(o);return null}function yr(e,t,n,o){let s=new Map,i=oe(e,s,"exit",null),r=t.body,a=i.id;if(r&&e.ts.isBlock(r))a=Ot(e,s,[...r.statements],i.id,{breakTarget:null,continueTarget:null});else if(r){let d=oe(e,s,"statement",r);Z(s,d.id,i.id),a=d.id}let l=oe(e,s,"entry",t);return Z(s,l.id,a),{id:o,node:t,parentId:n,cfg:s,entryId:l.id,exitId:i.id}}function Ot(e,t,n,o,s){let i=o;for(let r=n.length-1;r>=0;r-=1)i=_e(e,t,n[r],i,s);return i}function _e(e,t,n,o,s){let i=e.ts;if(i.isBlock(n))return Ot(e,t,[...n.statements],o,s);if(i.isIfStatement(n)){let a=oe(e,t,"predicate",n.expression),l=_e(e,t,n.thenStatement,o,s),d=n.elseStatement?_e(e,t,n.elseStatement,o,s):o;return Z(t,a.id,l),Z(t,a.id,d),a.id}if(i.isWhileStatement(n)){let a=oe(e,t,"predicate",n.expression),l=_e(e,t,n.statement,a.id,{breakTarget:o,continueTarget:a.id});return Z(t,a.id,l),Z(t,a.id,o),a.id}if(i.isDoStatement(n)){let a=oe(e,t,"predicate",n.expression),l=_e(e,t,n.statement,a.id,{breakTarget:o,continueTarget:a.id});return Z(t,a.id,l),Z(t,a.id,o),l}if(i.isForStatement(n)){let a=oe(e,t,"predicate",n.condition??n),l=n.incrementor?oe(e,t,"statement",n.incrementor):null;l&&Z(t,l.id,a.id);let d=l?.id??a.id,c=_e(e,t,n.statement,d,{breakTarget:o,continueTarget:d});if(Z(t,a.id,c),n.condition&&Z(t,a.id,o),!n.initializer)return a.id;let f=oe(e,t,"statement",n.initializer);return Z(t,f.id,a.id),f.id}if(i.isForInStatement(n)||i.isForOfStatement(n)){e.unsupported.add("for-in/for-of iterator assignment is conservatively represented without iterable element flow.");let a=oe(e,t,"predicate",n.expression),l=oe(e,t,"statement",n.initializer),d=_e(e,t,n.statement,a.id,{breakTarget:o,continueTarget:a.id});return Z(t,a.id,l.id),Z(t,a.id,o),Z(t,l.id,d),a.id}if(i.isSwitchStatement(n)){e.unsupported.add("switch fallthrough is represented conservatively; discriminant-to-case value refinement is unsupported.");let a=oe(e,t,"predicate",n.expression),l=o,d=[];for(let c=n.caseBlock.clauses.length-1;c>=0;c-=1){let f=n.caseBlock.clauses[c];l=Ot(e,t,[...f.statements],l,{...s,breakTarget:o}),d.push(l)}for(let c of d)Z(t,a.id,c);return Z(t,a.id,o),a.id}if(i.isReturnStatement(n)||i.isThrowStatement(n)){let a=oe(e,t,"statement",n),l=[...t.values()].find(d=>d.kind==="exit");return Z(t,a.id,l.id),a.id}if(i.isBreakStatement(n)){let a=oe(e,t,"statement",n);return s.breakTarget||e.unsupported.add("A break statement could not be attached to a structured target."),Z(t,a.id,s.breakTarget??o),a.id}if(i.isContinueStatement(n)){let a=oe(e,t,"statement",n);return s.continueTarget||e.unsupported.add("A continue statement could not be attached to a structured target."),Z(t,a.id,s.continueTarget??o),a.id}if(i.isTryStatement(n)){e.unsupported.add("Exceptional control-flow and finally completion are not included in the local compiler CFG.");let a=oe(e,t,"statement",n);return a.invalidatesAllDefinitions=!0,Z(t,a.id,o),a.id}let r=oe(e,t,"statement",n);return Z(t,r.id,o),r.id}function oe(e,t,n,o){let s={id:`cfg:${e.nextCfgId++}`,kind:n,ast:o,successors:new Set,predecessors:new Set,definitions:[],uses:[],displayPoint:null,invalidatesAllDefinitions:!1};return t.set(s.id,s),s}function Z(e,t,n){e.get(t).successors.add(n),e.get(n).predecessors.add(t)}function Sr(e,t){let n=t.cfg.get(t.entryId);for(let o of t.node.parameters){let s=Oe(e,o.name);if(!s){e.unsupported.add("Destructured parameter definition-use is not implemented.");continue}n.definitions.push({point:Ke(e,s.node,"parameter-definition",s.symbolKey,s.name,t.id),rhsUseIds:[]})}for(let o of t.cfg.values())!o.ast||o.kind==="entry"||o.kind==="exit"||(o.kind==="predicate"&&(o.displayPoint=Ke(e,o.ast,"predicate",null,"predicate",t.id)),br(e,t,o,o.ast),!o.displayPoint&&o.definitions.length===0&&o.uses.length===0&&(o.displayPoint=Ke(e,o.ast,"statement",null,Mr(e,o.ast),t.id)))}function br(e,t,n,o){let s=e.ts;if(s.isTryStatement(o))return;let i=r=>{if(!(r!==o&&s.isFunctionLike(r))){if(s.isVariableDeclaration(r)){let a=r.initializer?ut(e,t.id,r.initializer,n):[];n.uses.push(...a);let l=Oe(e,r.name);l?n.definitions.push({point:Ke(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:a.map(d=>d.point.id)}):(n.invalidatesAllDefinitions=!0,e.unsupported.add("Destructured variable reaching definitions are not implemented."));return}if(s.isBinaryExpression(r)&&Gn(s,r.operatorToken.kind)){let a=ut(e,t.id,r.right,n);r.operatorToken.kind!==s.SyntaxKind.EqualsToken&&a.push(...ut(e,t.id,r.left,n)),n.uses.push(...a);let l=Oe(e,r.left);l?n.definitions.push({point:Ke(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:a.map(d=>d.point.id)}):(n.invalidatesAllDefinitions=!0,e.unsupported.add("Dynamic or destructured assignment targets are not included in reaching definitions."));return}if((s.isPrefixUnaryExpression(r)||s.isPostfixUnaryExpression(r))&&(r.operator===s.SyntaxKind.PlusPlusToken||r.operator===s.SyntaxKind.MinusMinusToken)){let a=ut(e,t.id,r.operand,n);n.uses.push(...a);let l=Oe(e,r.operand);l&&n.definitions.push({point:Ke(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:a.map(d=>d.point.id)});return}if(!(s.isFunctionDeclaration(r)||s.isClassDeclaration(r)||s.isInterfaceDeclaration(r))){if(Wn(e,r)){let a=Hn(e,t.id,r);a&&n.uses.push(a),s.isPropertyAccessExpression(r)&&i(r.expression);return}r.forEachChild(i)}}};i(o),n.uses=Vn(n.uses)}function ut(e,t,n,o){let s=[],i=r=>{if(!e.ts.isFunctionLike(r)){if(e.ts.isBinaryExpression(r)&&Gn(e.ts,r.operatorToken.kind)){o.invalidatesAllDefinitions=!0,e.unsupported.add("Nested assignment expressions are not included in ordered local definition-use flow."),r.operatorToken.kind!==e.ts.SyntaxKind.EqualsToken&&i(r.left),i(r.right);return}if(Wn(e,r)){let a=Hn(e,t,r);a&&s.push(a),e.ts.isPropertyAccessExpression(r)&&i(r.expression);return}r.forEachChild(i)}};return i(n),Vn(s)}function Wn(e,t){if(e.ts.isPropertyAccessExpression(t))return!0;if(!e.ts.isIdentifier(t))return!1;let n=t.parent;return!(e.ts.isPropertyAccessExpression(n)&&n.name===t||"name"in n&&n.name===t&&hr(e.ts,n)||e.ts.isPropertyAssignment(n)&&n.name===t||e.ts.isBindingElement(n)&&n.propertyName===t||e.ts.isLabeledStatement(n)||e.ts.isBreakOrContinueStatement(n)||xr(e.ts,t))}function hr(e,t){return e.isVariableDeclaration(t)||e.isParameter(t)||e.isFunctionDeclaration(t)||e.isFunctionExpression(t)||e.isClassDeclaration(t)||e.isMethodDeclaration(t)||e.isPropertyDeclaration(t)||e.isInterfaceDeclaration(t)||e.isTypeAliasDeclaration(t)||e.isImportSpecifier(t)||e.isImportClause(t)||e.isNamespaceImport(t)}function xr(e,t){for(let n=t.parent;n;n=n.parent){if(e.isExpression(n)||e.isStatement(n)||e.isSourceFile(n))return!1;if(e.isTypeNode(n))return!0}return!1}function Hn(e,t,n){let o=Oe(e,n);return o?{point:Ke(e,o.node,"use",o.symbolKey,o.name,t),property:e.ts.isPropertyAccessExpression(n)}:null}function Oe(e,t){let n=e.ts;if(n.isIdentifier(t)){let o=qn(e,t);return o?{node:t,symbolKey:o,name:t.text}:null}if(n.isPropertyAccessExpression(t)){let o=qn(e,t.name);return o?{node:t,symbolKey:o,name:t.getText(e.sourceFile)}:null}return n.isParenthesizedExpression(t)||n.isAsExpression(t)||n.isTypeAssertionExpression(t)||n.isNonNullExpression(t)?Oe(e,t.expression):((n.isArrayLiteralExpression(t)||n.isObjectLiteralExpression(t))&&e.unsupported.add("Heap aggregate identity and destructured assignment are not included in local points-to flow."),null)}function qn(e,t){let n=e.checker.getSymbolAtLocation(t);if(!n)return null;if((n.flags&e.ts.SymbolFlags.Alias)!==0)try{n=e.checker.getAliasedSymbol(n)}catch{}let o=n.valueDeclaration??n.declarations?.[0];return o?`symbol:${encodeURIComponent(o.getSourceFile().fileName)}:${o.getStart()}:${n.getName()}`:`symbol:${n.getName()}`}function Ke(e,t,n,o,s,i){let r=t.getStart(e.sourceFile),a=t.getEnd(),l=e.sourceFile.getLineAndCharacterOfPosition(r),d=`flow-point:${encodeURIComponent(e.sourceFile.fileName)}:${r}:${a}:${n}:${encodeURIComponent(o??s)}`,c=e.points.get(d);if(c)return c;let f={id:d,kind:n,name:s,symbolKey:o,callableId:i,start:r,end:a,line:l.line,column:l.character,node:t};return e.points.set(d,f),f}function vr(e,t){let n=[...t.cfg.values()].flatMap(l=>l.definitions),o=new Map(n.map(l=>[l.point.id,l])),s=Ir(n),i=new Map,r=new Map;for(let l of t.cfg.values())i.set(l.id,new Set),r.set(l.id,new Set);let a=!0;for(;a;){a=!1;for(let l of t.cfg.values()){let d=Tr([...l.predecessors].map(y=>r.get(y))),c=new Set(d);l.invalidatesAllDefinitions&&c.clear();let f=Er(l.definitions);for(let y of f){for(let m of s.get(y.point.symbolKey)??[])c.delete(m.point.id);c.add(y.point.id)}Kt(i.get(l.id),d)||(i.set(l.id,d),a=!0),Kt(r.get(l.id),c)||(r.set(l.id,c),a=!0)}}for(let l of t.cfg.values()){let d=i.get(l.id);for(let c of l.uses){let f=l.definitions.filter(m=>m.point.symbolKey===c.point.symbolKey&&m.point.start<c.point.start&&!m.rhsUseIds.includes(c.point.id)).sort((m,v)=>v.point.start-m.point.start)[0],y=f?[f.point.id]:d;for(let m of y){let v=o.get(m);v.point.symbolKey===c.point.symbolKey&&Je(e,"reaching-definition",v.point.id,c.point.id,"exact","A CFG path reaches this use without an intervening definition.")}}for(let c of l.definitions)for(let f of c.rhsUseIds)Je(e,"value-source",f,c.point.id,"exact","This right-hand-side use supplies the new definition.")}}function Ir(e){let t=new Map;for(let n of e){if(!n.point.symbolKey)continue;let o=t.get(n.point.symbolKey)??[];o.push(n),t.set(n.point.symbolKey,o)}return t}function Er(e){let t=new Map;for(let n of e)n.point.symbolKey&&t.set(n.point.symbolKey,n);return[...t.values()]}function Lr(e,t){let n=wr(t);for(let o of t.cfg.values()){if(o.successors.size<2||!o.displayPoint)continue;let s=n.get(o.id);for(let i of o.successors)for(let r of n.get(i)??[]){if(s.has(r)||r===t.exitId)continue;let a=t.cfg.get(r),l=[...a.definitions.map(d=>d.point),...a.uses.map(d=>d.point),...a.displayPoint?[a.displayPoint]:[]];for(let d of Rr(l))Je(e,"control-dependence",o.displayPoint.id,d.id,"exact","The target postdominates a branch successor but does not postdominate the predicate.")}}}function wr(e){let t=[...e.cfg.keys()],n=new Set(t),o=new Map;for(let i of t)o.set(i,i===e.exitId?new Set([i]):new Set(n));let s=!0;for(;s;){s=!1;for(let i of e.cfg.values()){if(i.id===e.exitId)continue;let r=[...i.successors].map(l=>o.get(l)),a=new Set([i.id,...Fr(r)]);Kt(o.get(i.id),a)||(o.set(i.id,a),s=!0)}}return o}function Cr(e,t){let n=new Map(t.map(r=>[r.id,r.parentId])),o=t.flatMap(r=>[...r.cfg.values()].flatMap(a=>a.definitions.map(l=>l.point))),s=new Map;for(let r of o){if(!r.symbolKey)continue;let a=s.get(r.symbolKey)??[];a.push(r),s.set(r.symbolKey,a)}let i=new Set([...e.edges.values()].filter(r=>r.kind==="reaching-definition").map(r=>r.toPointId));for(let r of t)for(let a of[...r.cfg.values()].flatMap(l=>l.uses)){if(!a.point.symbolKey||i.has(a.point.id))continue;let l=s.get(a.point.symbolKey)??[];for(let d of l)Nr(d.callableId,a.point.callableId,n)?Je(e,"closure-capture",d.id,a.point.id,"candidate","Compiler identity proves the captured binding, but invocation order can select among outer definitions."):a.property&&Je(e,"field-definition-to-use",d.id,a.point.id,"candidate","Compiler identity matches the field; cross-callable receiver and execution order remain unresolved.")}[...e.edges.values()].some(r=>r.kind==="closure-capture")&&e.unsupported.add("Closure capture identity is known, but invocation order and intervening writes remain candidate flow."),[...e.edges.values()].some(r=>r.kind==="field-definition-to-use")&&e.unsupported.add("Cross-callable field flow lacks receiver points-to and invocation-order analysis.")}function Nr(e,t,n){for(let o=n.get(t)??null;o;o=n.get(o)??null)if(o===e)return!0;return!1}function Je(e,t,n,o,s,i){let r=`local-flow-edge:${t}:${encodeURIComponent(n)}:${encodeURIComponent(o)}`;e.edges.set(r,{id:r,kind:t,fromPointId:n,toPointId:o,strength:s,reason:i})}function Gn(e,t){return t>=e.SyntaxKind.FirstAssignment&&t<=e.SyntaxKind.LastAssignment}function Mr(e,t){let n=t.getText(e.sourceFile).replace(/\s+/gu," ").trim();return n.length>80?`${n.slice(0,77)}...`:n||e.ts.SyntaxKind[t.kind]||"statement"}function Vn(e){return[...new Map(e.map(t=>[t.point.id,t])).values()]}function Rr(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function Tr(e){return new Set(e.flatMap(t=>[...t]))}function Fr(e){return e.length===0?new Set:new Set([...e[0]].filter(t=>e.slice(1).every(n=>n.has(t))))}function Kt(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function Pr(e,t){return e.start-t.start||e.kind.localeCompare(t.kind)||e.id.localeCompare(t.id)}function _t(e){return{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[e]}}}var $r=fn("typescript-local-flow",{clearGroups:["whole-project","source-file","semantic-provider"]});function jt(e,t,n,o){if(!vn(t))return null;let s=`${t}\0${n}\0${o}`;return $r.get(e,s,()=>{let i=Sn(e,t);return i?zn(i,kr(e.config.projectRoot,t),{startLine:n,endLine:o}):{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[`Current source is unavailable for ${t}.`]}}})}function Ar(e,t=new Map){let n=new Map,o=new Map,s=[];for(let i of e.transfers){if(!e.caller)continue;let r=pt(e.caller,i.callerPosition),a=pt(e.callee,i.calleePosition);Xe(n,r),Xe(n,a),zt(o,e.caller,r),zt(o,e.callee,a);let l=se("edge","data-transfer",i.proof.file,String(i.proof.startLine),String(i.callerPosition),String(i.calleePosition));o.set(l,{id:l,kind:"data-transfer",fromNodeId:r.id,toNodeId:a.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:"argument-to-parameter",attributes:{argumentText:i.argumentText,callerPosition:i.callerPosition,calleePosition:i.calleePosition}}],evidence:[{method:"compiler-callsite-direct-parameter-transfer",strength:"exact",identity:`${e.caller.symbol}:${i.callerPosition} -> ${e.callee.symbol}:${i.calleePosition}`,location:{file:i.proof.file,line:i.proof.startLine,endLine:i.proof.endLine}}]})}return e.unknown.forEach((i,r)=>{let a=pt(e.callee,i.calleePosition);Xe(n,a),zt(o,e.callee,a);let l=t.get(i.calleePosition);if(l&&Hr(l)){Wr(o,n,e,i.calleePosition,i.argumentText,l);return}let d=zr(e,i.calleePosition,i.argumentText);Xe(n,d);let c=se("edge","data-transfer-unsupported",i.proof.file,String(i.proof.startLine),String(i.calleePosition),String(r));o.set(c,{id:c,kind:"data-transfer",fromNodeId:d.id,toNodeId:a.id,directed:!0,disposition:"unsupported",semantics:[{family:"data",subtype:"argument-to-parameter",attributes:{argumentText:i.argumentText,calleePosition:i.calleePosition}}],evidence:[{method:"compiler-callsite-argument-expression",strength:"exact",identity:i.argumentText,location:{file:i.proof.file,line:i.proof.startLine,endLine:i.proof.endLine}}]}),s.push({id:se("frontier","data-transfer",c),kind:"data-transfer",direction:"unresolved",fromNodeIds:[d.id],edgeIds:[c],memberNodeIds:[a.id],memberCount:1,disposition:"unsupported",reason:l?.derivation.rule??i.reason,expansion:null})}),{nodes:[...n.values()],edges:[...o.values()],frontiers:s,blindSpots:[]}}function Qn(e,t,n=[]){let o=Jn(),s=new Map,i=new Set;for(let r of t){if(r.kind!=="call"||!r.fromSymbol||!r.toSymbol||r.line===null)continue;let a=qr(s,e,r.toFile,r.toSymbol);if(!a)continue;let l=Cn(e,a),d=l.sites.filter(L=>L.file===r.fromFile&&L.startLine<=r.line&&L.endLine>=r.line&&L.caller?.symbol===r.fromSymbol);if(d.length!==1){let L=l.unresolved.find(S=>S.file===r.fromFile&&S.line===r.line);L&&o.blindSpots.push(`Parameter flow unresolved at ${r.fromFile}:${r.line+1}: ${L.reason}.`);continue}let c=d[0],f=`${c.file}\0${c.callNode.startIndex}\0${c.callNode.endIndex}\0${a.symbol}`;if(i.has(f))continue;i.add(f);let y=Nn(e,c),m=Be(e,c.file)?.rootNode,v=new Map;if(m)for(let L of y.unknown){let S=wn({db:e,file:c.file,root:m},c.arguments[L.calleePosition]);S&&v.set(L.calleePosition,S)}Yn(o,Ar(y,v)),y.caller&&Kr(c.callNode)&&jr(o,y,c.callNode)}for(let r of n){if(!r.location||!["source-construct","symbol"].includes(r.kind))continue;let a=r.location.endLine??r.location.line,l=jt(e,r.location.file,r.location.line,a);if(l){Yn(o,Dr(r,l.points,l.edges));for(let d of l.coverage.unsupported)o.blindSpots.push(`TypeScript local flow is partial for ${r.location.file}:${r.location.line+1}-${a+1}: ${d} Recover with: codebaseiq inspect --at '${r.location.file}:${r.location.line+1}-${a+1}' --view behavior.`)}}return o.blindSpots=[...new Set(o.blindSpots)].sort(),o}function Dr(e,t,n){let o=Jn(),s=new Map,i=new Map,r=new Map,a=e.location.file;for(let l of t){let d=Br(e,a,l);r.set(l.id,d.id),s.set(d.id,d),_r(i,e,d)}for(let l of n){let d=r.get(l.fromPointId),c=r.get(l.toPointId);if(!d||!c)continue;let f=Or(l),y=se("edge","typescript-local-flow",a,l.id);i.set(y,{id:y,kind:l.kind==="control-dependence"?"control-dependence":"data-transfer",fromNodeId:d,toNodeId:c,directed:!0,disposition:"folded",semantics:[f],evidence:[{method:"typescript-compiler-cfg-reaching-definitions",strength:l.strength,identity:l.reason,location:s.get(d)?.location??e.location}]})}return o.nodes=[...s.values()],o.edges=[...i.values()],o}function Br(e,t,n){return{id:se("local-flow-point",t,String(n.start),String(n.end),n.kind,n.symbolKey??n.name),kind:n.kind==="parameter-definition"||n.kind==="definition"?"local-definition":n.kind==="use"?"local-use":n.kind==="predicate"?"control-predicate":"local-statement",label:n.name,disposition:"folded",location:{file:t,line:n.line,endLine:n.line},anchorIds:[],attributes:{ownerNodeId:e.id,pointKind:n.kind,callableId:n.callableId,symbolKey:n.symbolKey,column:n.column}}}function _r(e,t,n){let o=se("edge","local-flow-owner",t.id,n.id);e.has(o)||e.set(o,{id:o,kind:"local-flow-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains"}],evidence:[{method:"typescript-compiler-local-flow-owner",strength:"exact",identity:t.id,location:n.location}]})}function Or(e){switch(e.kind){case"reaching-definition":return{family:"data",subtype:"definition-to-use"};case"value-source":return{family:"data",subtype:"value-to-definition"};case"closure-capture":return{family:"data",subtype:"closure-capture"};case"field-definition-to-use":return{family:"data",subtype:"field-definition-to-use"};case"control-dependence":return{family:"control",subtype:"control-dependence"}}}function Kr(e){let t=e;for(;t.parent&&["await_expression","yield_expression","parenthesized_expression","as_expression","type_assertion"].includes(t.parent.type);)t=t.parent;return t.parent!==null&&t.parent.type!=="expression_statement"}function jr(e,t,n){if(!t.caller)return;let o={id:se("call-result",t.call.file,String(n.startIndex),String(n.endIndex),t.callee.symbol),kind:"call-result",label:`result of ${t.callee.leaf}`,disposition:"folded",location:{file:t.call.file,line:t.call.startLine,endLine:t.call.endLine},anchorIds:[],attributes:{calleeSymbol:t.callee.symbol,callerSymbol:t.caller.symbol}},s=se("edge","return-to-call-result",t.callee.symbol,o.id),i=se("edge","call-result-owner",t.caller.symbol,o.id);e.nodes.push(o),e.edges.push({id:s,kind:"data-transfer",fromNodeId:Ut(t.callee.symbol),toNodeId:o.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:"return-to-call-result"}],evidence:[{method:"compiler-callsite-used-result",strength:"exact",identity:`${t.callee.symbol} -> ${t.caller.symbol}`,location:o.location}]},{id:i,kind:"call-result-owner",fromNodeId:Ut(t.caller.symbol),toNodeId:o.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains-call-result"}],evidence:[{method:"compiler-call-result-owner",strength:"exact",identity:t.caller.symbol,location:o.location}]})}function Jn(){return{nodes:[],edges:[],frontiers:[],blindSpots:[]}}function Yn(e,t){qt(e.nodes,t.nodes),qt(e.edges,t.edges),qt(e.frontiers,t.frontiers),e.blindSpots.push(...t.blindSpots)}function qt(e,t){let n=new Set(e.map(o=>o.id));for(let o of t)n.has(o.id)||(n.add(o.id),e.push(o))}function qr(e,t,n,o){let s=`${n}\0${o}`,i=e.get(s);if(i!==void 0)return i;let r=Fe(t,n).find(a=>a.symbol===o)??null;return e.set(s,r),r}function pt(e,t){return{id:Yr(e.symbol,t),kind:"parameter",label:`${e.leaf} parameter ${t}`,disposition:"folded",location:{file:e.relativePath,line:e.startLine,endLine:e.endLine},anchorIds:[],attributes:{ownerSymbol:e.symbol,position:t}}}function zr(e,t,n){return{id:se("argument-expression",e.call.file,String(e.call.startLine),String(e.call.endLine),String(t)),kind:"argument-expression",label:n,disposition:"unsupported",location:{file:e.call.file,line:e.call.startLine,endLine:e.call.endLine},anchorIds:[],attributes:{calleeSymbol:e.callee.symbol,position:t}}}function Ur(e,t,n){return{id:se("static-value",e.call.file,String(e.call.startLine),String(e.call.endLine),String(t)),kind:"static-value",label:n.value,disposition:"folded",location:{file:e.call.file,line:e.call.startLine,endLine:e.call.endLine},anchorIds:[],attributes:{value:n.value,precision:n.precision,evidence:n.evidence,termKind:n.term.kind,derivationRule:n.derivation.rule}}}function Wr(e,t,n,o,s,i){let r=Ur(n,o,i),a=pt(n.callee,o);Xe(t,r);let l=se("edge","static-value-transfer",n.call.file,String(n.call.startLine),String(o));e.set(l,{id:l,kind:"data-transfer",fromNodeId:r.id,toNodeId:a.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:Gr(i),attributes:{argumentText:s,calleePosition:o,value:i.value,precision:i.precision,derivationRule:i.derivation.rule}}],evidence:Vr(i,n)})}function Hr(e){return e.derivation.kind!=="heuristic"&&e.precision!=="symbolic"&&e.precision!=="unknown"}function Gr(e){return e.derivation.rule==="bounded-call-return"?"return-to-parameter":e.derivation.rule==="member-constant"||e.term.kind==="property"?"property-to-parameter":"constant-to-parameter"}function Vr(e,t){return(e.derivation.sourceSpans.length>0?e.derivation.sourceSpans:[t.call]).map(o=>({method:`static-value:${e.derivation.rule}`,strength:e.derivation.kind==="direct"?"exact":"derived",identity:e.derivation.inputFactIds.join(",")||e.value,location:{file:o.file,line:o.startLine,endLine:o.endLine}}))}function Xe(e,t){e.has(t.id)||e.set(t.id,t)}function zt(e,t,n){let o=se("edge","parameter-owner",t.symbol,n.id);e.has(o)||e.set(o,{id:o,kind:"parameter-owner",fromNodeId:Ut(t.symbol),toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains"}],evidence:[{method:"compiler-parameter-owner",strength:"exact",identity:t.symbol,location:{file:t.relativePath,line:t.startLine,endLine:t.endLine}}]})}function Yr(e,t){return se("parameter",e,String(t))}function Ut(e){return se("symbol",e)}function se(...e){return e.map(t=>encodeURIComponent(t)).join(":")}function Xn(e,t){let n=new Map,o=new Map,s=new Map,i=new Set;for(let r of t){if(!r.location||!["source-construct","symbol"].includes(r.kind))continue;let a=r.location.endLine??r.location.line,l=Tn(e,r.location.file,r.location.line,a);if(!l){i.add(`Control dependence unavailable for ${r.location.file}:${r.location.line+1}-${a+1}: no supported syntax tree or covering construct.`);continue}for(let d of l.facts){let c=Wt(r,d.controller),f=Wt(r,d.outcome);n.set(c.id,c),n.set(f.id,f),Qr(o,r,c);let y=je("edge","control-dependence",c.id,f.id,d.subtype);o.set(y,{id:y,kind:"control-dependence",fromNodeId:c.id,toNodeId:f.id,directed:!0,disposition:"folded",semantics:[{family:"control",subtype:d.subtype,attributes:{...d.attributes}}],evidence:[{method:"parser-control-dependence",strength:"exact",identity:`${r.location.file}:${d.controller.startLine+1}-${d.outcome.startLine+1}`,location:{file:r.location.file,line:d.controller.startLine,endLine:d.controller.endLine}}]})}for(let d of l.terminals){let c=Wt(r,d);n.set(c.id,c);let f=d.label.startsWith("throw")||d.label.startsWith("raise")?"throw":"return",y=je("edge","control-terminal",r.id,c.id,f);o.set(y,{id:y,kind:"control-terminal",fromNodeId:r.id,toNodeId:c.id,directed:!0,disposition:"folded",semantics:[{family:"control",subtype:f==="throw"?"throws":"returns"}],evidence:[{method:"parser-terminal-statement",strength:"exact",identity:d.label,location:{file:r.location.file,line:d.startLine,endLine:d.endLine}}]})}for(let d of l.unsupported){let c=je("control-unsupported",r.location.file,String(d.startLine),String(d.endLine),d.reason);n.set(c,{id:c,kind:"control-unsupported",label:d.reason,disposition:"unsupported",location:{file:r.location.file,line:d.startLine,endLine:d.endLine},anchorIds:[],attributes:{ownerNodeId:r.id}});let f=je("edge","control-unsupported",r.id,c);o.set(f,{id:f,kind:"control-dependence",fromNodeId:r.id,toNodeId:c,directed:!0,disposition:"unsupported",semantics:[{family:"control",subtype:"unresolved-control-construct"}],evidence:[{method:"parser-control-construct",strength:"exact",identity:d.reason,location:{file:r.location.file,line:d.startLine,endLine:d.endLine}}]});let y=je("frontier","control-dependence",c);s.set(y,{id:y,kind:"control-dependence",direction:"unresolved",fromNodeIds:[r.id],edgeIds:[f],memberNodeIds:[c],memberCount:1,disposition:"unsupported",reason:d.reason,expansion:null})}}return{nodes:[...n.values()],edges:[...o.values()],frontiers:[...s.values()],blindSpots:[...i].sort()}}function Wt(e,t){let n=e.location.file;return{id:je(`control-${t.kind}`,n,String(t.startLine),String(t.endLine),t.label),kind:`control-${t.kind}`,label:t.label,disposition:"folded",location:{file:n,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,constructKind:t.kind,implicit:t.implicit}}}function Qr(e,t,n){let o=je("edge","control-owner",t.id,n.id);e.has(o)||e.set(o,{id:o,kind:"control-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains-control"}],evidence:[{method:"parser-control-owner",strength:"exact",identity:t.id,location:t.location}]})}function je(...e){return e.map(t=>encodeURIComponent(t)).join(":")}var mt=new Set(["arrow_function","constructor_declaration","function_declaration","function_definition","function_expression","generator_function","generator_function_declaration","function_item","lambda","lambda_expression","method","method_declaration","method_definition"]),et=new Set(["block","body","compound_statement","declaration_list","statement_block"]),Jr=new Set(["assignment","assignment_expression","augmented_assignment_expression"]),Gt=new Set(["update_expression"]),no=new Set(["array_access","element_access_expression","subscript_expression"]),oo=new Set(["attribute","field_access","field_expression","member_access_expression","member_expression","selector_expression"]),Xr=new Set(["false","null","null_literal","number","number_literal","string","string_literal","template_string","true"]),Zr=new Set(["call_expression","method_invocation","object_creation_expression"]),ei=new Set(["comment","else_clause","formal_parameters","parameters","type_parameters"]);function ro(e,t,n,o){let s=Be(e,t);if(!s)return null;let i=li(s.rootNode,n,o);if(!i)return null;let r=[],a=[],l=[];return qe(i,d=>{if(Jr.has(d.type)||Gt.has(d.type)||so(d)){let c=ti(d);c?r.push(c):l.push({family:"state",startLine:d.startPosition.row,endLine:d.endPosition.row,reason:`Mutation target ${Ie(d.text)} could not be resolved to an exact source resource.`})}}),qe(i,d=>{if(!et.has(d.type))return;let c=si(d);for(let f=0;f<c.length-1;f+=1)a.push({from:Ze(c[f]),to:Ze(c[f+1]),subtype:"lexical-successor",synchronizationScope:null,attributes:{sameScope:!0,executionConditional:!0}});for(let f=0;f<c.length;f+=1){let y=c[f],m=ci(y).filter(v=>v.type==="await_expression");for(let v of m){let L=tt("event",`await ${Ie(v.text.replace(/^await\s+/u,""))}`,v);a.push({from:Ze(y),to:L,subtype:"awaits-completion",synchronizationScope:null,attributes:{completionRequired:!0}});let S=c[f+1];S&&a.push({from:L,to:Ze(S),subtype:"await-completion-before",synchronizationScope:null,attributes:{continuationOnly:!0}})}}}),qe(i,d=>{if(d.type!=="synchronized_statement")return;let c=d.childForFieldName("object")??d.childForFieldName("condition")??d.namedChildren.find(L=>!et.has(L.type)),f=d.childForFieldName("body")??d.namedChildren.find(L=>et.has(L.type));if(!c||!f){l.push({family:"temporal",startLine:d.startPosition.row,endLine:d.endPosition.row,reason:"Synchronized scope has no structurally resolved monitor or body."});return}let y=Ie(c.text).replace(/^\(|\)$/gu,""),m=tt("lock",y,c),v=di(f).filter(L=>L.parent!==null&&ao(L));for(let L of ai(v))a.push({from:m,to:Ze(L),subtype:"inside-lock-scope",synchronizationScope:y,attributes:{syntaxNative:!0}})}),{mutations:r,temporal:a,unsupported:l}}function ti(e){let t=so(e),n=e.childForFieldName("left")??e.childForFieldName("argument")??(t?e.namedChildren.at(-1)??null:e.namedChildren[0]??null);if(!n)return null;let o=ni(n);if(!o)return null;let s=t?"delete":Gt.has(e.type)||!ii(e,n).startsWith("=")?"update":"assign",i=t||Gt.has(e.type)?null:e.childForFieldName("right");return{event:tt("event",Ie(e.text),e),resource:{kind:"resource",label:o.name,startLine:n.startPosition.row,endLine:n.endPosition.row},operation:s,durabilityClass:"in-memory",recordIdentity:o.recordIdentity,value:i?tt("value",Ie(i.text),i):null,dataSubtype:i?oi(i,e):null}}function ni(e){if(no.has(e.type)){let t=e.childForFieldName("object")??e.childForFieldName("array")??e.namedChildren[0]??null,n=e.childForFieldName("index")??e.childForFieldName("subscript")??e.namedChildren[1]??null;return!t||!n?null:{name:`${Ie(t.text)}[]`,recordIdentity:Ie(n.text)}}return oo.has(e.type)?{name:Ie(e.text),recordIdentity:null}:/^(?:identifier|property_identifier|field_identifier)$/u.test(e.type)?{name:Ie(e.text),recordIdentity:null}:null}function oi(e,t){return Xr.has(e.type)||/(?:integer|float|decimal|boolean|character)_literal$/u.test(e.type)?"constant-to-state":Zr.has(e.type)?"return-to-state":oo.has(e.type)||no.has(e.type)?"property-to-state":/identifier$/u.test(e.type)?ri(e.text,t)?"captured-value-to-state":"value-to-state":"expression-to-state"}function ri(e,t){let n=Ht(t.parent);if(!n||Zn(n,e))return!1;let o=Ht(n.parent);for(;o;){if(Zn(o,e))return!0;o=Ht(o.parent)}return!1}function Ht(e){let t=e;for(;t;){if(mt.has(t.type))return t;t=t.parent}return null}function Zn(e,t){let n=e.childForFieldName("parameters")??e.namedChildren.find(i=>["formal_parameters","parameters"].includes(i.type));if(n&&eo(n,t))return!0;let o=e.childForFieldName("body")??e.namedChildren.find(i=>et.has(i.type));if(!o)return!1;let s=!1;return io(o,e,i=>{if(s||!/(?:declarator|declaration|parameter)$/u.test(i.type))return;let r=i.childForFieldName("name")??i.childForFieldName("pattern")??i.namedChildren[0];r&&eo(r,t)&&(s=!0)}),s}function eo(e,t){let n=!1;return qe(e,o=>{/identifier$/u.test(o.type)&&o.text===t&&(n=!0)}),n}function io(e,t,n){n(e);for(let o of e.namedChildren)o!==t&&mt.has(o.type)||io(o,t,n)}function ii(e,t){let n=e.childForFieldName("right"),o=Math.max(0,t.endIndex-e.startIndex),s=n?Math.max(o,n.startIndex-e.startIndex):e.text.length;return e.text.slice(o,s).trim()}function so(e){return(e.type==="delete_expression"||e.type==="unary_expression")&&/^delete\b/u.test(e.text.trim())}function si(e){return e.namedChildren.filter(t=>ao(t))}function ao(e){return ei.has(e.type)||et.has(e.type)?!1:/(?:statement|declaration)$/u.test(e.type)||e.type==="expression_statement"||e.type==="local_variable_declaration"}function ai(e){let t=new Set(e);return e.filter(n=>{let o=n.parent;for(;o;){if(t.has(o))return!1;o=o.parent}return!0})}function Ze(e){return tt("event",Ie(e.text),e)}function tt(e,t,n){return{kind:e,label:t,startLine:n.startPosition.row,endLine:n.endPosition.row}}function li(e,t,n){let o=[];return qe(e,i=>{i.startPosition.row<=t&&i.endPosition.row>=n&&o.push(i)}),o.filter(i=>mt.has(i.type)).sort(to)[0]??o.sort(to)[0]??null}function to(e,t){return e.endIndex-e.startIndex-(t.endIndex-t.startIndex)||e.startIndex-t.startIndex}function di(e){let t=[];return qe(e,n=>t.push(n)),t}function ci(e){let t=[],n=o=>{t.push(o);for(let s of o.namedChildren)s!==e&&mt.has(s.type)||n(s)};return n(e),t}function qe(e,t){t(e);for(let n of e.namedChildren)qe(n,t)}function Ie(e){return e.trim().replace(/\s+/gu," ")}function uo(e,t,n=[]){let o=new Map,s=new Map,i=new Map,r=new Set;for(let a of t){if(!a.location||!["source-construct","symbol"].includes(a.kind))continue;let l=a.location.endLine??a.location.line,d=ro(e,a.location.file,a.location.line,l);if(!d){r.add(`State and temporal analysis unavailable for ${a.location.file}:${a.location.line+1}-${l+1}: no supported syntax tree or covering construct.`);continue}for(let c of d.mutations){let f=gt(a,c.event),y=yi(a,c.resource,c.durabilityClass);if(o.set(f.id,f),o.set(y.id,y),yt(s,a,f,"contains-state-effect"),St(s,{kind:"state-resource",from:f,to:y,semantics:[{family:"state",subtype:c.operation==="delete"?"deletes-resource":"writes-resource",attributes:{operation:c.operation,durabilityClass:c.durabilityClass,resource:c.resource.label,recordIdentity:c.recordIdentity,transactionMembership:"unknown"}}],method:"parser-state-mutation",identity:c.event.label}),c.value&&c.dataSubtype){let m=gt(a,c.value);o.set(m.id,m),St(s,{kind:"data-to-state",from:m,to:y,semantics:[{family:"data",subtype:c.dataSubtype,attributes:{operation:c.operation,resource:c.resource.label,recordIdentity:c.recordIdentity,value:c.value.label}}],method:"parser-assignment-value",identity:`${c.value.label} -> ${c.resource.label}`})}}for(let c of d.temporal){let f=gt(a,c.from),y=gt(a,c.to);o.set(f.id,f),o.set(y.id,y),yt(s,a,f,c.from.kind==="lock"?"contains-lock-scope":"contains-event"),yt(s,a,y,"contains-event"),St(s,{kind:"temporal-order",from:f,to:y,semantics:[{family:"temporal",subtype:c.subtype,context:c.synchronizationScope?{synchronizationScope:c.synchronizationScope}:void 0,attributes:{...c.attributes}}],method:c.subtype==="inside-lock-scope"?"parser-synchronized-scope":"parser-program-order",identity:`${c.from.label} -> ${c.to.label}`})}for(let c of d.unsupported){let f=Re(`${c.family}-unsupported`,a.location.file,String(c.startLine),String(c.endLine),c.reason);o.set(f,{id:f,kind:`${c.family}-unsupported`,label:c.reason,disposition:"unsupported",location:{file:a.location.file,line:c.startLine,endLine:c.endLine},anchorIds:[],attributes:{ownerNodeId:a.id}});let y=Re("edge",`${c.family}-unsupported`,a.id,f);s.set(y,{id:y,kind:`${c.family}-unsupported`,fromNodeId:a.id,toNodeId:f,directed:!0,disposition:"unsupported",semantics:[{family:c.family,subtype:`unresolved-${c.family}-construct`}],evidence:[{method:`parser-${c.family}-construct`,strength:"exact",identity:c.reason,location:{file:a.location.file,line:c.startLine,endLine:c.endLine}}]});let m=Re("frontier",c.family,f);i.set(m,{id:m,kind:c.family,direction:"unresolved",fromNodeIds:[a.id],edgeIds:[y],memberNodeIds:[f],memberCount:1,disposition:"unsupported",reason:c.reason,expansion:null})}}for(let a of t.filter(l=>l.kind==="runtime-boundary-participant")){let l=ft(a,"protocol"),d=ft(a,"action"),c=ft(a,"address")??a.label;!l||!d||!co(l,d)||lo(o,s,a,{observationId:a.id,action:d,strength:"exact",file:a.location?.file??"",line:a.location?.line??0,address:c,protocol:l,role:ft(a,"role")??void 0,resolution:"locally-linked"})}for(let a of n){if(!a.protocol||!co(a.protocol,a.action))continue;let l=fi(t,a.file,a.line,a.ownerShortName??null);if(!l){r.add(`State observation ${a.observationId} at ${a.file}:${a.line+1} has no materialized owner node.`);continue}lo(o,s,l,a)}return{nodes:[...o.values()],edges:[...s.values()],frontiers:[...i.values()],blindSpots:[...r].sort()}}function lo(e,t,n,o){let s=pi(o),r={id:Re("runtime-state-event",o.observationId),kind:"runtime-state-event",label:`${o.action} ${s}`,disposition:"folded",location:{file:o.file,line:o.line},anchorIds:[],attributes:{action:o.action,protocol:o.protocol??null,modality:o.modality??null,resolution:o.resolution??null}},a=o.protocol==="database"?"external-durable-intent":"external",l={id:Re("runtime-state-resource",o.protocol??"unknown",s),kind:"runtime-state-resource",label:s,disposition:"folded",location:{file:o.file,line:o.line},anchorIds:[],attributes:{protocol:o.protocol??null,durabilityClass:a}};e.set(r.id,r),e.set(l.id,l),yt(t,n,r,"contains-runtime-state-effect");let d=ui(o.action);St(t,{kind:"runtime-state-resource",from:r,to:l,semantics:[{family:"state",subtype:d,context:{crossesRuntimeBoundary:!0,protocol:o.protocol},attributes:{operation:o.action,durabilityClass:a,resource:s,recordIdentity:mi(o),modality:o.modality??null,resolution:o.resolution??null,transactionMembership:"unknown",commitState:o.protocol==="database"?"unknown":null}}],method:`runtime-boundary-${o.strength}`,identity:o.observationId})}function ui(e){return e==="database.read"?"reads-resource":e==="queue.send"?"enqueues-resource":e==="queue.consume"?"consumes-resource":"writes-resource"}function pi(e){return(e.keyParts?.find(n=>["address","resource"].includes(n.name))?.value??e.address)||e.observationId}function mi(e){return e.keyParts?.find(n=>/^(?:id|key|record)$/u.test(n.name))?.value??null}function co(e,t){return e==="database"&&["database.read","database.write"].includes(t)||e==="queue"&&["queue.consume","queue.send"].includes(t)}function ft(e,t){let n=e.attributes[t];return typeof n=="string"?n:null}function fi(e,t,n,o){let s=e.filter(r=>r.location?.file===t&&["source-construct","symbol"].includes(r.kind)),i=s.filter(r=>r.location.line<=n&&(r.location.endLine??r.location.line)>=n).sort(gi)[0];if(i)return i;if(o){let r=s.find(a=>a.label===o||a.label.endsWith(`.${o}`)||a.label.includes(o));if(r)return r}return s.length===1?s[0]:null}function gi(e,t){let n=(e.location?.endLine??e.location?.line??0)-(e.location?.line??0),o=(t.location?.endLine??t.location?.line??0)-(t.location?.line??0);return n-o}function gt(e,t){let n=e.location.file;return{id:Re(`program-${t.kind}`,n,String(t.startLine),String(t.endLine),t.label),kind:`program-${t.kind}`,label:t.label,disposition:"folded",location:{file:n,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,constructKind:t.kind}}}function yi(e,t,n){let o=e.location.file;return{id:Re("program-resource",o,e.id,t.label,n),kind:"program-resource",label:t.label,disposition:"folded",location:{file:o,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,durabilityClass:n}}}function yt(e,t,n,o){let s=Re("edge","program-owner",t.id,n.id,o);e.has(s)||e.set(s,{id:s,kind:"program-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:o}],evidence:[{method:"parser-program-owner",strength:"exact",identity:t.id,location:n.location}]})}function St(e,t){let n=Re("edge",t.kind,t.from.id,t.to.id,t.semantics[0].subtype);e.set(n,{id:n,kind:t.kind,fromNodeId:t.from.id,toNodeId:t.to.id,directed:!0,disposition:"folded",semantics:t.semantics,evidence:[{method:t.method,strength:"exact",identity:t.identity,location:t.from.location}]})}function Re(...e){return e.map(t=>encodeURIComponent(t)).join(":")}var Si=new Set(["control","data","state","temporal"]),bt=new Set(["contains-control","contains-event","contains-lock-scope","contains-state-effect","contains-runtime-state-effect","contains","owns-parameter","owns-runtime-observation"]),go=new Set(["discriminator-dispatch","result-callback","returns","runtime-handoff","throws"]);function yo(e,t={}){let n=new Map(e.nodes.map(M=>[M.id,M])),o=Li(e.nodes,t.focusLocations),s=wi(e.edges,t.focusLocations),i=Ci(e.edges,s),r=new Set(e.paths.flatMap(M=>M.edgeIds)),a=Te(e.anchors.filter(M=>M.status==="matched").flatMap(M=>M.nodeIds)),d=e.edges.filter(fo).filter(M=>bi(M,o,s,r)),c=d.filter(M=>Ii(M,o,s,i,n,r)),f=po(a,c,"forward"),y=vi(f,c),m=po(y,c,"backward"),v=new Set([...f].filter(M=>m.has(M)));for(let M of a)v.add(M);let L=new Set(c.filter(M=>v.has(M.fromNodeId)&&v.has(M.toNodeId)).map(M=>M.id)),S=new Set(v),k=new Set(L);hi(d,S,k,o,s);let q=e.frontiers.filter(M=>Mi(M,S)),$=Te(q.filter(M=>M.disposition==="unsupported").map(M=>M.id)),P=Te(e.edges.filter(M=>!fo(M)&&bo(M)&&Ni(M,S)).map(M=>M.id)),H=Te(q.map(M=>M.id)),B=[];a.length===0&&B.push("No matched anchor node starts the corridor."),y.length===0&&B.push("No proved mechanical outcome is reachable from a matched anchor."),$.length>0&&B.push(`${$.length} unsupported frontier(s) touch the protected corridor.`),P.length>0&&B.push(`${P.length} candidate or unknown edge(s) touch the protected corridor.`);let j=B.length===0?"complete":"incomplete";return{schemaVersion:1,status:j,startNodeIds:a,outcomeNodeIds:y,baseNodeIds:Te([...v]),baseEdgeIds:Te([...L]),nodeIds:Te([...S]),edgeIds:Te([...k]),accountedFrontierIds:H,unresolvedFrontierIds:$,unresolvedEdgeIds:P,coverage:{protectedNodes:S.size,protectedEdges:k.size,baseNodes:v.size,baseEdges:L.size,accountedFrontiers:H.length,unresolvedFrontiers:$.length,unresolvedEdges:P.length},explanation:j==="complete"?"Every proved anchor-to-outcome path is closed over its material causal facts within reported coverage.":B.join(" ")}}function bi(e,t,n,o){return t===null||e.disposition==="emitted"||o.has(e.id)||n?.has(e.id)===!0?!0:(e.semantics??[]).some(s=>{if(s.family==="identity"&&bt.has(s.subtype))return t.has(e.toNodeId);if(s.family==="contract")return t.has(e.fromNodeId)&&t.has(e.toNodeId);if(s.family==="state")return t.has(e.fromNodeId);if(s.family==="data"||s.family==="temporal")return t.has(e.fromNodeId)||t.has(e.toNodeId);if(s.family==="control"){if(ho(s))return t.has(e.fromNodeId);if(["returns","throws"].includes(s.subtype))return t.has(e.toNodeId);if(s.subtype==="completion-callback")return t.has(e.fromNodeId)||t.has(e.toNodeId)}return!1})}function hi(e,t,n,o,s){let i=!0;for(;i;){i=!1;for(let r of e)xi(r,t,o,s)&&(n.has(r.id)||(n.add(r.id),i=!0),t.has(r.fromNodeId)||(t.add(r.fromNodeId),i=!0),t.has(r.toNodeId)||(t.add(r.toNodeId),i=!0))}}function xi(e,t,n,o){let s=t.has(e.fromNodeId),i=t.has(e.toNodeId);return!s&&!i?!1:(e.semantics??[]).some(r=>r.family==="identity"?bt.has(r.subtype)&&(i||n===null||n.has(e.toNodeId)):r.family==="contract"?!0:r.family==="state"?s&&(n===null||n.has(e.fromNodeId)):r.family==="temporal"?r.subtype==="lexical-successor"?s&&i:!0:r.family==="data"?i&&(s||n===null||n.has(e.fromNodeId)||o?.has(e.id)===!0):r.family==="control"?So(r)||["returns","throws"].includes(r.subtype)&&!i&&n!==null&&!n.has(e.toNodeId)?!1:go.has(r.subtype)||ho(r)||r.subtype==="completion-callback":!1)}function vi(e,t){let n=new Set,o=new Map,s=new Map;for(let i of t)!e.has(i.fromNodeId)||!e.has(i.toNodeId)||(o.set(i.fromNodeId,(o.get(i.fromNodeId)??0)+1),s.set(i.toNodeId,(s.get(i.toNodeId)??0)+1),(i.semantics??[]).some(r=>r.family==="state"||r.family==="control"&&go.has(r.subtype))&&n.add(i.toNodeId));for(let i of e)(s.get(i)??0)>0&&(o.get(i)??0)===0&&n.add(i);return Te([...n])}function po(e,t,n){let o=new Map;for(let r of t){let a=n==="forward"?r.fromNodeId:r.toNodeId,l=n==="forward"?r.toNodeId:r.fromNodeId,d=o.get(a)??[];d.push(l),o.set(a,d)}let s=new Set(e),i=[...e];for(;i.length>0;){let r=i.shift();for(let a of o.get(r)??[])s.has(a)||(s.add(a),i.push(a))}return s}function Ii(e,t,n,o,s,i){return(e.semantics??[]).some(r=>e.disposition==="emitted"||i.has(e.id)?!0:r.family==="identity"&&bt.has(r.subtype)?t===null||t.has(e.toNodeId)||o?.has(e.toNodeId)===!0:!Si.has(r.family)||So(r)?!1:r.family==="control"&&["returns","throws"].includes(r.subtype)&&t!==null?t.has(e.toNodeId):t===null?!0:r.family==="state"?t.has(e.fromNodeId):r.family==="data"?t.has(e.fromNodeId)||t.has(e.toNodeId)||n?.has(e.id)===!0:r.family==="temporal"?r.subtype==="lexical-successor"?t.has(e.fromNodeId)&&t.has(e.toNodeId):t.has(e.fromNodeId)||t.has(e.toNodeId):r.family==="control"?Ei(e,s)&&(t.has(e.fromNodeId)||t.has(e.toNodeId)):!1)}function So(e){return e.family==="control"&&["call","discriminator-dispatch","result-callback","runtime-handoff"].includes(e.subtype)}function Ei(e,t){let n=t.get(e.fromNodeId),o=t.get(e.toNodeId);if(!n||!o)return!1;let s=mo(n,"ownerNodeId")??(n.kind==="symbol"?n.id:null),i=mo(o,"ownerNodeId")??(o.kind==="symbol"?o.id:null);return s!==null&&s===i}function Li(e,t){if(!t)return null;let n=new Map;for(let o of t){let s=n.get(o.file)??[];s.push(o.line),n.set(o.file,s)}return new Set(e.filter(o=>{if(!o.location||o.kind==="parameter")return!1;let s=n.get(o.location.file)??[],i=o.location.endLine??o.location.line;return s.some(r=>r>=o.location.line&&r<=i)}).map(o=>o.id))}function wi(e,t){if(!t)return null;let n=new Map;for(let o of t){let s=n.get(o.file)??[];s.push(o.line),n.set(o.file,s)}return new Set(e.filter(o=>o.evidence.some(s=>{if(!s.location)return!1;let i=n.get(s.location.file)??[],r=s.location.endLine??s.location.line;return i.some(a=>a>=s.location.line&&a<=r)})).map(o=>o.id))}function Ci(e,t){return t===null?null:new Set(e.filter(n=>t.has(n.id)).flatMap(n=>[n.fromNodeId,n.toNodeId]))}function mo(e,t){let n=e.attributes[t];return typeof n=="string"?n:null}function fo(e){return e.disposition==="excluded"||e.disposition==="unsupported"||!bo(e)?!1:e.evidence.some(t=>t.strength==="exact"||t.strength==="derived")}function bo(e){return(e.semantics??[]).some(t=>t.family!=="identity"||bt.has(t.subtype))}function ho(e){return e.subtype.startsWith("predicate-")||e.subtype.startsWith("loop-")||e.subtype.startsWith("exception-")||e.subtype.startsWith("finally-")||e.subtype.startsWith("handler-")}function Ni(e,t){return t.has(e.fromNodeId)||t.has(e.toNodeId)}function Mi(e,t){return[...e.fromNodeIds,...e.memberNodeIds].some(n=>t.has(n))}function Te(e){return[...new Set(e)].sort()}import{createHash as Ri}from"crypto";var ht=["identity","contract","control","data","state","temporal"],Ti=new Set(ht);function vt(e){let t=We(e.anchors,"anchor"),n=We(e.nodes,"node"),o=We(e.edges,"edge"),s=We(e.paths??[],"path"),i=We(e.frontiers??[],"frontier"),r=new Set(t.map(m=>m.id)),a=new Set(n.map(m=>m.id)),l=new Set(o.map(m=>m.id)),d=e.routeCatalog?{...e.routeCatalog,routes:We(e.routeCatalog.routes,"route"),selectedRouteIds:de(e.routeCatalog.selectedRouteIds)}:void 0;for(let m of t)me(`anchor ${m.id}`,[...m.nodeIds,...m.candidateNodeIds],a,"node");for(let m of n)me(`node ${m.id}`,m.anchorIds,r,"anchor");for(let m of o){if(me(`edge ${m.id}`,[m.fromNodeId,m.toNodeId],a,"node"),m.evidence.length===0)throw new Error(`Exploration edge ${m.id} has no evidence source.`);ki(m)}for(let m of s)me(`path ${m.id}`,[m.fromAnchorId,m.toAnchorId],r,"anchor"),me(`path ${m.id}`,m.nodeIds,a,"node"),me(`path ${m.id}`,m.edgeIds,l,"edge");for(let m of i)if(me(`frontier ${m.id}`,m.fromNodeIds,a,"node"),me(`frontier ${m.id}`,m.edgeIds,l,"edge"),me(`frontier ${m.id}`,m.memberNodeIds,a,"node"),m.memberCount!==m.memberNodeIds.length)throw new Error(`Exploration frontier ${m.id} reports ${m.memberCount} member(s) but identifies ${m.memberNodeIds.length}.`);for(let m of d?.routes??[])me(`route ${m.id}`,m.nodeIds,a,"node"),me(`route ${m.id}`,m.edgeIds,l,"edge"),me(`route ${m.id}`,[m.anchorNodeId,m.endpointNodeId],a,"node");d&&me("route catalog selection",d.selectedRouteIds,new Set(d.routes.map(m=>m.id)),"route");let c=de(e.incompleteReasons??[]),f=c.length===0?"accounted":"incomplete",y=t.reduce((m,v)=>m+v.omittedCandidates,0);return{schemaVersion:1,anchors:t,nodes:n,edges:o,paths:s,frontiers:i,coverage:{status:f,scope:e.scope,nodes:Mo(n),edges:Mo(o),matchedAnchors:t.filter(m=>m.status==="matched").length,ambiguousAnchors:t.filter(m=>m.status==="ambiguous").length,missingAnchors:t.filter(m=>m.status==="missing").length,omittedCandidates:y,frontierGroups:i.length,programEdges:Pi(o),blindSpots:de(e.blindSpots??[]),explanation:f==="accounted"?"Every node and edge discovered within the declared query scope is emitted, folded with recoverable identity, explicitly excluded, or reported unsupported.":`The declared query scope is not fully accounted for: ${c.join("; ")}`},completion:Di(f,s,e.scope),...d?{routeCatalog:d}:{}}}function Fi(e){return e.flatMap(t=>$i(t.semantics??[]).map(n=>({id:Ai(t.id,n),sourceEdgeId:t.id,sourceKind:t.kind,fromNodeId:t.fromNodeId,toNodeId:t.toNodeId,directed:!0,disposition:t.disposition,evidence:[...t.evidence],family:n.family,subtype:n.subtype,...n.context?{context:{...n.context}}:{},...n.attributes?{attributes:{...n.attributes}}:{}}))).sort((t,n)=>t.id.localeCompare(n.id))}function Pi(e){let t=Fi(e),n=new Set(t.map(r=>r.sourceEdgeId)),o=new Map(ht.map(r=>[r,new Set])),s=new Map(ht.map(r=>[r,new Set])),i=new Map(ht.map(r=>[r,0]));for(let r of t)o.get(r.family).add(r.sourceEdgeId),s.get(r.family).add(r.subtype),i.set(r.family,i.get(r.family)+1);return{sourceEdges:e.length,mappedSourceEdges:n.size,projectedEdges:t.length,unmappedSourceEdges:e.length-n.size,unsupportedSourceEdges:e.filter(r=>r.disposition==="unsupported").length,unmappedKinds:de(e.filter(r=>!n.has(r.id)).map(r=>r.kind)),families:{identity:Ue("identity",o,i,s),contract:Ue("contract",o,i,s),control:Ue("control",o,i,s),data:Ue("data",o,i,s),state:Ue("state",o,i,s),temporal:Ue("temporal",o,i,s)}}}function Ue(e,t,n,o){return{sourceEdges:t.get(e)?.size??0,projectedEdges:n.get(e)??0,subtypes:[...o.get(e)??[]].sort()}}function ki(e){let t=new Set;for(let n of e.semantics??[]){if(!Ti.has(n.family))throw new Error(`Exploration edge ${e.id} has unknown program edge family: ${n.family}.`);if(n.subtype.trim().length===0)throw new Error(`Exploration edge ${e.id} has an empty program edge subtype.`);let o=Vt(n);if(t.has(o))throw new Error(`Exploration edge ${e.id} repeats program edge semantic ${o}.`);t.add(o)}}function $i(e){return[...e].sort((t,n)=>Vt(t).localeCompare(Vt(n)))}function Vt(e){return`${e.family}:${e.subtype}`}function Ai(e,t){return`program:${encodeURIComponent(e)}:${t.family}:${encodeURIComponent(t.subtype)}`}function Di(e,t,n){return e==="incomplete"||t.some(o=>o.status!=="connected")?{status:"coverage-incomplete",scope:n,explanation:"The declared graph query has an ambiguous, missing, candidate-only, or disconnected anchor relationship."}:t.length>0?{status:"connector-complete",scope:n,explanation:"Every requested anchor pair has a selected path supported by proved repository relationships."}:{status:"frontier-accounted",scope:n,explanation:"Every discovered direction in the declared graph query is emitted or represented by an exact frontier."}}function Ro(e,t={}){let n=t.maxSelectedNodes??24;if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`maxSelectedNodes must be a positive safe integer; received ${n}`);let o=new Set(e.anchors.flatMap(g=>[...g.nodeIds,...g.candidateNodeIds])),s=[],i=e.anchors.filter(g=>g.status!=="missing"&&g.nodeIds.length+g.candidateNodeIds.length>0);for(let g=0;g<i.length;g+=1)for(let u=g+1;u<i.length;u+=1){let b=i[g],N=i[u],_=Lo(e,b,N,!1),A=_??Lo(e,b,N,!0);A?(A.nodeIds.forEach(ee=>o.add(ee)),s.push({id:xt("path",b.id,N.id),fromAnchorId:b.id,toAnchorId:N.id,status:!_||b.status==="ambiguous"||N.status==="ambiguous"?"candidate":"connected",nodeIds:A.nodeIds,edgeIds:A.edgeIds})):s.push({id:xt("path",b.id,N.id),fromAnchorId:b.id,toAnchorId:N.id,status:"partial",nodeIds:[],edgeIds:[]})}let r=de(t.routeIds??[]),a=Bi(e,r),l=new Set(a.routes.map(g=>g.id)),d=r.filter(g=>!l.has(g));if(d.length>0)throw new Error(`Unknown exploration route id(s): ${d.join(", ")}`);let f=a.routes.filter(g=>r.includes(g.id)).map(g=>({anchorNodeId:g.anchorNodeId,endpointNodeId:g.endpointNodeId,endpointKind:g.endpointKind,endpointPriority:2,nodeIds:[...g.nodeIds].reverse(),edgeIds:[...g.edgeIds].reverse()}));for(let g of f)g.nodeIds.forEach(u=>o.add(u));let y=s.length===0||s.some(g=>g.edgeIds.length>0);y&&Co(e,o,n);let m=No(e,o),v=new Set(t.expandedFrontierIds??[]),L=new Set(m.map(g=>g.id)),S=[...v].filter(g=>!L.has(g)).sort();if(S.length>0)throw new Error(`Unknown exploration frontier id(s): ${S.join(", ")}`);for(let g of m)v.has(g.id)&&g.memberNodeIds.forEach(u=>o.add(u));y&&Co(e,o,n);let k=new Map(f.map(g=>[g.endpointNodeId,g.endpointKind])),q=new Set(f.flatMap(g=>g.nodeIds)),$=new Map;for(let g of f)for(let u=0;u<g.nodeIds.length;u+=1){let b=g.nodeIds[u],N=u;$.set(b,Math.max($.get(b)??0,N))}let P=e.nodes.map(g=>{let u=k.get(g.id),b=q.has(g.id)?{upstreamCausalPath:!0,upstreamCausalDistance:$.get(g.id)??0,...u?{upstreamCausalEndpoint:u}:{}}:{};return{...g,attributes:{...g.attributes,...b},disposition:g.disposition==="excluded"||g.disposition==="unsupported"?g.disposition:o.has(g.id)?"emitted":"folded"}}),H=new Set([...s.flatMap(g=>g.edgeIds),...f.flatMap(g=>g.edgeIds)]),B=e.edges.map(g=>({...g,disposition:g.disposition==="excluded"||g.disposition==="unsupported"?g.disposition:H.has(g.id)||o.has(g.fromNodeId)&&o.has(g.toNodeId)?"emitted":"folded"})),j=vt({anchors:e.anchors,nodes:P,edges:B,paths:s,frontiers:[...e.frontiers.filter(g=>g.disposition!=="folded"),...No({...e,nodes:P,edges:B},o)],scope:e.coverage.scope,blindSpots:e.coverage.blindSpots,incompleteReasons:e.coverage.status==="incomplete"?[e.coverage.explanation]:[],routeCatalog:a}),M=new Set(j.frontiers.flatMap(g=>g.edgeIds)),G=j.edges.filter(g=>g.disposition==="folded"&&!M.has(g.id)).map(g=>g.id);if(G.length>0)throw new Error(`Folded exploration edge(s) are not frontier-accounted: ${G.sort().join(", ")}`);return j}var xo=10;function Bi(e,t=[]){let n=new Map(e.nodes.map(S=>[S.id,S])),o=new Map(e.edges.map(S=>[S.id,S])),s=new Map;for(let S of e.edges){if(!_i(S))continue;let k=s.get(S.toNodeId)??[];k.push(S),s.set(S.toNodeId,k)}for(let S of s.values())S.sort((k,q)=>Number(nt(q))-Number(nt(k))||Eo(q)-Eo(k)||k.fromNodeId.localeCompare(q.fromNodeId)||k.id.localeCompare(q.id));let i=de(e.anchors.filter(S=>S.status==="matched").flatMap(S=>S.nodeIds)),r=new Map,a=new Set,l=(S,k,q)=>{let $=k.nodeIds[k.nodeIds.length-1],P=n.get($),H=n.get(S);if(!P?.location||!H)return;let B=[...k.nodeIds].reverse(),j=[...k.edgeIds].reverse(),M=new Set(B),G=j.flatMap(_=>{let Q=o.get(_);return Q?[Q]:[]}),g=e.edges.filter(_=>_.disposition!=="excluded"&&_.disposition!=="unsupported"&&(M.has(_.fromNodeId)||M.has(_.toNodeId))),u={id:xt("route",S,$,q,...j),status:"proved",anchorNodeId:S,anchorLabel:H.label,endpointNodeId:$,endpointLabel:P.label,endpointLocation:{...P.location},endpointKind:q,nodeIds:B,edgeIds:j,evidenceStrengths:de(G.flatMap(_=>_.evidence.map(Q=>Q.strength))),spineEdgeFamilies:vo(G,!0),relatedEdgeFamilies:vo(g,!1),crossesRuntimeBoundary:G.some(nt)},b=`${S}\0${$}\0${q}`,N=r.get(b);(!N||Io(u,N)<0)&&r.set(b,u)};for(let S of i){n.get(S)?.attributes.publicEntry===!0&&l(S,{nodeIds:[S],edgeIds:[]},"public-entry");let k=[{nodeIds:[S],edgeIds:[]}],q=new Map([[S,0]]);for(let $=0;$<k.length;$+=1){let P=k[$],H=P.nodeIds[P.nodeIds.length-1];P.edgeIds.length>0&&n.get(H)?.location&&n.get(H)?.attributes.publicEntry===!0&&l(S,P,"public-entry");let B=s.get(H)??[];if(P.edgeIds.length>=xo){B.some(j=>!P.nodeIds.includes(j.fromNodeId))&&a.add(S);continue}for(let j of B){if(P.nodeIds.includes(j.fromNodeId))continue;let M=P.edgeIds.length+1,G=q.get(j.fromNodeId);if(G!==void 0&&G<=M)continue;let g={nodeIds:[...P.nodeIds,j.fromNodeId],edgeIds:[...P.edgeIds,j.id]};if(q.set(j.fromNodeId,M),nt(j)&&n.get(j.fromNodeId)?.location){l(S,g,"runtime-boundary");continue}k.push(g)}}}let d=[...r.values()].sort(Io),c=new Set(d.map(S=>S.id)),f=de(t.filter(S=>c.has(S))),y=de(d.map(S=>S.anchorNodeId)),m=i.filter(S=>!y.includes(S)),v=[...a].sort(),L=e.coverage.status==="accounted"&&v.length===0?"accounted":"incomplete";return{schemaVersion:1,routes:d,selectedRouteIds:f,coverage:{status:L,scope:"Distinct proved public-entry and runtime-boundary endpoints reachable upstream in the supplied topology.",enumeration:"one-shortest-proved-path-per-endpoint",maximumDepth:xo,anchorNodeIds:i,anchorsWithRoutes:y,anchorsWithoutRoutes:m,depthLimitedAnchorNodeIds:v,routeCount:d.length,explanation:L==="accounted"?"Every distinct proved upstream public/runtime endpoint in the supplied topology has one stable shortest route.":"Route enumeration is incomplete because the supplied topology has incomplete coverage or a traversal reached the route-depth bound."}}}function vo(e,t){let n=e.flatMap(o=>o.semantics?.map(s=>s.family)??[]);return t&&e.length>0&&n.length===0&&n.push("control"),de(n)}function Io(e,t){return e.anchorNodeId.localeCompare(t.anchorNodeId)||e.edgeIds.length-t.edgeIds.length||e.endpointKind.localeCompare(t.endpointKind)||e.endpointNodeId.localeCompare(t.endpointNodeId)||e.id.localeCompare(t.id)}function _i(e){return e.disposition!=="excluded"&&e.disposition!=="unsupported"&&Oi(e)&&e.evidence.some(t=>["exact","derived","mixed"].includes(t.strength))}function Oi(e){return nt(e)||e.kind==="boundary-observation"||e.kind==="call"||e.kind==="compiler:call"}function nt(e){return e.kind==="runtime-boundary"||e.kind.startsWith("runtime:")}function Eo(e){let t={exact:5,derived:4,mixed:3,candidate:1,unknown:0};return Math.max(0,...e.evidence.map(n=>t[n.strength]))}function Lo(e,t,n,o){return wo(e,t,n,o)??wo(e,n,t,o)}function wo(e,t,n,o){let s=[...t.nodeIds,...t.candidateNodeIds].sort(),i=new Set([...n.nodeIds,...n.candidateNodeIds]);if(s.some(c=>i.has(c)))return{nodeIds:[s.find(f=>i.has(f))],edgeIds:[]};let r=new Set(e.nodes.filter(c=>c.kind==="structural-region").map(c=>c.id)),a=new Map;for(let c of e.edges)c.disposition==="excluded"||c.disposition==="unsupported"||c.kind==="structural-membership"||r.has(c.fromNodeId)||r.has(c.toNodeId)||c.evidence.every(y=>["candidate","unknown"].includes(y.strength))&&!o||Ki(a,c.fromNodeId,c.toNodeId,c.id);for(let c of a.values())c.sort((f,y)=>f.nodeId.localeCompare(y.nodeId)||f.edgeId.localeCompare(y.edgeId));let l=s.map(c=>({nodeId:c,nodeIds:[c],edgeIds:[]})),d=new Set(s);for(let c=0;c<l.length;c+=1){let f=l[c];for(let y of a.get(f.nodeId)??[]){if(d.has(y.nodeId))continue;let m={nodeId:y.nodeId,nodeIds:[...f.nodeIds,y.nodeId],edgeIds:[...f.edgeIds,y.edgeId]};if(i.has(y.nodeId))return m;d.add(y.nodeId),l.push(m)}}return null}function Ki(e,t,n,o){let s=e.get(t)??[];s.push({nodeId:n,edgeId:o}),e.set(t,s)}function ji(e,t,n){let o=new Map;for(let a of e.edges){let l=o.get(a.fromNodeId)??{incoming:0,outgoing:0},d=o.get(a.toNodeId)??{incoming:0,outgoing:0};l.outgoing+=1,d.incoming+=1,o.set(a.fromNodeId,l),o.set(a.toNodeId,d)}let s=new Set,i=new Map;for(let a of e.edges){let l=t.has(a.fromNodeId),d=t.has(a.toNodeId);if(l===d)continue;let c=l?a.toNodeId:a.fromNodeId,f=l?a.fromNodeId:a.toNodeId,y=e.nodes.find(L=>L.id===c);if(y?.kind==="structural-region")continue;let m=i.get(c)??new Set;m.add(f),i.set(c,m),(/(?:runtime-boundary|external)/u.test(a.kind)||y&&/(?:frontier|external)/u.test(y.kind))&&s.add(c)}let r=[...i].filter(([a,l])=>{if(s.has(a))return!0;let d=o.get(a)??{incoming:0,outgoing:0};return(d.incoming>1||d.outgoing>1)&&l.size>1}).sort(([a,l],[d,c])=>Number(s.has(d))-Number(s.has(a))||c.size-l.size||a.localeCompare(d)).map(([a])=>a);for(let a of r){if(t.size>=n)break;t.add(a)}}function Co(e,t,n){let o=-1;for(;t.size!==o&&t.size<n;)o=t.size,ji(e,t,n)}function No(e,t){let n=new Set(e.nodes.filter(r=>!t.has(r.id)&&r.disposition!=="excluded"&&r.disposition!=="unsupported").map(r=>r.id)),o=new Map;for(let r of e.edges){if(!n.has(r.fromNodeId)||!n.has(r.toNodeId))continue;let a=o.get(r.fromNodeId)??new Set,l=o.get(r.toNodeId)??new Set;a.add(r.toNodeId),l.add(r.fromNodeId),o.set(r.fromNodeId,a),o.set(r.toNodeId,l)}let s=[],i=new Set;for(let r of[...n].sort()){if(i.has(r))continue;let a=[],l=[r];i.add(r);for(let d=0;d<l.length;d+=1){let c=l[d];a.push(c);for(let f of[...o.get(c)??[]].sort())i.has(f)||(i.add(f),l.push(f))}s.push(a.sort())}return s.map(r=>{let a=new Set(r),l=e.edges.filter(v=>a.has(v.fromNodeId)||a.has(v.toNodeId)),d=l.filter(v=>a.has(v.fromNodeId)!==a.has(v.toNodeId)),c=de(d.map(v=>a.has(v.fromNodeId)?v.toNodeId:v.fromNodeId)),f=new Set(d.map(v=>a.has(v.toNodeId)?"outgoing":"incoming")),y=de(l.map(v=>v.id)),m=de(d.map(v=>v.kind));return{id:xt("frontier",...r,...y),kind:m.join("+")||"disconnected",direction:f.size===1?[...f][0]:"undirected",fromNodeIds:c,edgeIds:y,memberNodeIds:r,memberCount:r.length,disposition:"folded",reason:d.length>0?"Connected evidence is folded beyond the first edge leaving the selected connector graph.":"Discovered evidence is disconnected from every selected anchor connector under the declared relation scope.",expansion:null}})}function xt(e,...t){let n=Ri("sha256").update(t.join("\0")).digest("hex").slice(0,16);return`${e}:${n}`}function We(e,t){let n=[...e].sort((o,s)=>o.id.localeCompare(s.id));for(let o=1;o<n.length;o+=1)if(n[o-1].id===n[o].id)throw new Error(`Duplicate exploration ${t} id: ${n[o].id}`);return n}function me(e,t,n,o){let s=de(t.filter(i=>!n.has(i)));if(s.length>0)throw new Error(`Exploration ${e} references missing ${o}(s): ${s.join(", ")}`)}function Mo(e){return{total:e.length,emitted:e.filter(t=>t.disposition==="emitted").length,folded:e.filter(t=>t.disposition==="folded").length,excluded:e.filter(t=>t.disposition==="excluded").length,unsupported:e.filter(t=>t.disposition==="unsupported").length}}function de(e){return[...new Set(e)].sort()}var qi=5,zi=12,Ui=8,Wi=3,To=8,Hi=6,Gi=12,Fo=12,Vi=12,Yi=2,Qi=new Set(["branch","loop","call","await","return","throw","mutation","catch","finally"]),Ji=9e3,Po=On;function Xa(e,t){return jo(e,t,"full")}function Za(e,t){return jo(e,t,"topology")}function jo(e,t,n){let o=Lt(t.searches??[]),s=Lt(t.symbols??[]),i=Lt(t.relations&&t.relations.length>0?t.relations:Po),r=i.filter(p=>!Po.includes(p));if(r.length>0)throw new Error(`Unsupported system-map relation kind(s): ${r.join(", ")}`);let a=new Set(i),l=t.evidenceFloor??"derived";if(l!=="exact"&&l!=="derived")throw new Error(`Unsupported system-map evidence floor: ${l}`);let d=Lt(t.sourceScopes&&t.sourceScopes.length>0?t.sourceScopes:["production"]),c=["production","test","fixture","example","generated","script","unknown"],f=d.filter(p=>!c.includes(p));if(f.length>0)throw new Error(`Unsupported system-map source scope(s): ${f.join(", ")}`);let y=new Set(d),m=p=>y.has($t(p));if(o.length===0&&s.length===0)throw new Error("system-map requires at least one --search or --symbol anchor.");let v=t.maxDepth??qi;if(!Number.isSafeInteger(v)||v<0)throw new RangeError(`maxDepth must be a non-negative safe integer; received ${v}`);let L=t.maxTopologyCharacters??Ji;if(!Number.isSafeInteger(L)||L<=0)throw new RangeError(`maxTopologyCharacters must be a positive safe integer; received ${L}`);let S=new En(e),k=S.fileDependencyGraph(),q=As(k),$=Ds(S.sourceFiles()),P=Mn(e),H=new Map((P?.observations??[]).map(p=>[p.id,p])),B=new Set((P?.observations??[]).map(p=>`${p.source.file}\0${p.source.startLine}`)),j=new Set,M=new Map,G=new Map,g=new Map,u=new Map,b=[],N=new Map,_=new Map,Q=[],A=0,ee=0,ae=0,O=0,Le=0,we=0,Ce=new Set,$e=new Map,tn=new Map,Go=p=>{let E=tn.get(p);if(E)return E;let R=At(e,p,{excludeIndexedTargets:!1});return tn.set(p,R),R},Ne=(p,E,R,U,I=!1)=>{let h=G.get(p);if(h)return h.depth=Math.min(h.depth,E),h.primary||=U,h.promoteBoundaryImports||=I,h.origins.add(R),h;let C={file:p,depth:E,primary:U,promoteBoundaryImports:I,origins:new Set([R]),processed:!1};return G.set(p,C),C},ue=(p,E,R,U,I="none",h=!1)=>{let C=g.get(p.symbol);if(C)return C.depth=Math.min(C.depth,E),C.origins.add(R),U&&C.anchorQueries.add(U),C.referenceScope=$s(C.referenceScope,I),Ne(p.relativePath,E,R,!0,h),C;let F={definition:p,depth:E,origins:new Set([R]),anchorQueries:new Set(U?[U]:[]),referenceScope:I,processed:!1};return g.set(p.symbol,F),Ne(p.relativePath,E,R,!0,h),F},Ae=(p,E,R,U,I=!1,h=!0)=>{let C=Ee(p),F=u.get(C);if(F)return F.depth=Math.min(F.depth,E),F.origins.add(R),U&&F.anchorQueries.add(U),F.reverseCallExpansion||=I,F.traversalEligible||=h,Ne(p.file,E,R,F.traversalEligible,!0),F;let w={...p,depth:E,origins:new Set([R]),anchorQueries:new Set(U?[U]:[]),reverseCallExpansion:I,traversalEligible:h};return u.set(C,w),Ne(p.file,E,R,h,!0),w},nn=(p,E,R)=>{Ne(p.source.file,E,R,!0,!0),p.owner.file!==p.source.file&&Ne(p.owner.file,E,`${R}:owner`,!0,!0);let U=Fe(e,p.owner.file),I=p.owner.symbol?Pe(e,S,p.owner.symbol).matches.find(F=>F.relativePath===p.owner.file):null,h=(I&&!le(I.symbol)?I:null)??ze(U,p.source.startLine);if(h&&!le(h.symbol))return ue(h,E,R,void 0,"none",!0),h.symbol;p.owner.name&&Ae({file:p.owner.file,name:p.owner.name,startLine:p.owner.startLine,endLine:p.owner.endLine},E,`${R}:source-owner`,void 0,!0);let C=S.definitionsForFile(p.source.file).filter(F=>!!F.leaf&&Pt(e,p.source.file,F.leaf).some(w=>w>=p.source.startLine&&w<=p.source.endLine));if(C.length===1){let F=C[0];ue(F,E,`${R}:handler-identifier`,void 0,"none",!0),fe(N,{kind:"runtime-boundary",evidence:"runtime-boundary:handler-identifier",fromFile:p.source.file,fromSymbol:null,toFile:F.relativePath,toSymbol:F.symbol,fromBoundaryParticipant:Ge(p),line:p.source.startLine,strength:"derived"})}return null};for(let p of o){let E=Ss(e,S,p,B),R=E.filter(C=>Is(C,m)),U=!t.fullLiteralTraversal&&(E.length>zi||R.length>Ui),I=U?[]:E,h=new Set((U?[]:t.fullLiteralTraversal?R:[...R].sort(bs).slice(0,Wi)).map(Do));U&&(ee+=1,ae+=E.length);for(let C of I){let F=h.has(Do(C)),w=F&&!C.ownerSymbol&&C.ownerStartLine!==null&&C.ownerEndLine!==null;if(Ne(C.relativePath,0,`${F?"literal-anchor":"literal-match"}:${p}`,w,w),w&&Ae({file:C.relativePath,name:C.ownerShortName??`${C.relativePath}:${C.ownerStartLine+1}`,startLine:C.ownerStartLine,endLine:C.ownerEndLine},0,`literal-source-owner:${p}`,p,!0),F&&C.ownerSymbol){let D=Pe(e,S,C.ownerSymbol).matches[0];D&&!le(D.symbol)&&ue(D,0,"literal-owner",p,"all",!0)}b.push({query:p,file:C.relativePath,line:C.line,ownerSymbol:C.ownerSymbol,ownerShortName:C.ownerShortName,ownerStartLine:C.ownerStartLine,ownerEndLine:C.ownerEndLine,sourceLine:C.sourceLine.trim(),matchKind:C.matchKind,traversalSeed:F})}Q.push({kind:"literal",query:p,status:E.length>0?"matched":"missing",matchedRegionIds:[],matchingLines:E.length,seedMatchingLines:U?0:h.size,matchOnlyLines:E.length-h.size,eligibleSeedMatchingLines:R.length,materializedMatchingLines:I.length,withheldMatchingLines:U?E.length:0,literalTraversal:U?"withheld-broad":"materialized",representativeMatches:U?Es(p,E):void 0,narrowingCommands:U?ws(p,E):void 0,exhaustiveTraversalCommand:U||h.size<R.length?`codebaseiq system-map --search ${X(p)} --full-literal-traversal`:void 0,seedRegionIds:[],matchOnlyRegionIds:[]})}for(let p of s){let E=Pe(e,S,p);A+=E.omitted;let R=hs(e,p),U=E.matches.filter(w=>!le(w.symbol)),I=R!==null&&U.length===0;I&&Ae(R,0,"source-construct-anchor",p,!0);let h=I?U:E.matches;for(let w of h)ue(w,0,"symbol-anchor",p,"all",!0);let C=I?xs(R):null,F=I?1:E.total;Q.push({kind:"symbol",query:p,status:F===0?"missing":F===1?"matched":"ambiguous",matchedRegionIds:[],symbolCandidates:[...C?[C]:[],...h.map(Ts)],totalSymbolCandidates:F,omittedSymbolCandidates:E.omitted})}for(let p=0;p<v;p+=1){if(a.has("call")){let I=[...u.values()].filter(h=>h.traversalEligible&&h.reverseCallExpansion&&h.depth<=p&&!Ce.has(Ee(h)));for(let h of I){Ce.add(Ee(h));let C=Me(e,h.file);if((C?.callables??[]).filter(D=>D.name===h.name&&D.startLine<=h.endLine&&D.endLine>=h.startLine).length===1){let D=(C?.callSites??[]).filter(z=>z.calleeLeaf===h.name&&!z.memberAccess);for(let z of D){let J=p+1,K=ze(Fe(e,h.file),z.line),Y=null,te=null;if(K&&!le(K.symbol)){if(K.relativePath===h.file&&K.startLine<=h.endLine&&K.endLine>=h.startLine)continue;ue(K,J,"reverse-local-call-owner",void 0,"forward-regions",!0),Y=K.symbol}else{let x=Yt(e,h.file,z.line);x&&Ee(x)!==Ee(h)&&(te=Ae(x,J,"reverse-local-call-source-owner",void 0,!0))}!Y&&!te||fe(N,{kind:"call",evidence:"ast-callsite",fromFile:h.file,fromSymbol:Y,toFile:h.file,toSymbol:null,fromSourceConstruct:te?ce(te):void 0,toSourceConstruct:ce(h),line:z.line,strength:"derived"})}}let w=new Set([...q.get(h.file)??[],...$e.get(Ee(h))??[],...Pn(e,h.file).flatMap(D=>[...q.get(D)??[]])]);for(let D of w){if(!m(D))continue;let J=Go(D).targets.filter(K=>K.targetFile===h.file&&K.targetStartLine<=h.endLine&&K.targetEndLine>=h.startLine);for(let K of J){let Y=p+1,te=ze(Fe(e,D),K.line),x=null,W=null;if(te&&!le(te.symbol))ue(te,Y,"reverse-member-call-owner",void 0,"cross-workspace-or-forward",!0),x=te.symbol;else{let T=Yt(e,D,K.line);T&&(W=Ae(T,Y,"reverse-member-call-source-owner",void 0,!0))}!x&&!W||fe(N,{kind:"call",evidence:"ast-service-member-callsite",fromFile:D,fromSymbol:x,toFile:h.file,toSymbol:null,fromSourceConstruct:W?ce(W):void 0,toSourceConstruct:ce(h),line:K.line,strength:K.strength==="exact"?"exact":"derived"})}}}}let E=[...g.values()].filter(I=>!I.processed&&I.depth<=p),R=a.has("call")?S.calleeMap(E.map(I=>I.definition),{additive:!1,semantic:!1}):new Map;for(let I of E){I.processed=!0;let h=I.definition;if(I.referenceScope!=="none"&&(a.has("call")||a.has("reference")||a.has("contract-symbol"))){let C=Ns(e,S,h).filter(w=>m(w.file)&&ks(I,w.file,G,$)),F=new Set(C.flatMap(w=>{if(!(a.has("call")&&Me(e,w.file)?.callSites.some(J=>J.line===w.line&&J.calleeLeaf===h.leaf)===!0)||!w.enclosingSymbol)return[];let z=Pe(e,S,w.enclosingSymbol).matches[0];return z&&!le(z.symbol)?[{owner:z,site:w}]:[]}).sort((w,D)=>{let z=ye(h.relativePath,$).relativeDir,J=ye(w.owner.relativePath,$).relativeDir===z,K=ye(D.owner.relativePath,$).relativeDir===z,Y=ko(e,w.owner),te=ko(e,D.owner),x=w.owner.endLine-w.owner.startLine,W=D.owner.endLine-D.owner.startLine;return Number(K)-Number(J)||te-Y||x-W||w.owner.symbol.localeCompare(D.owner.symbol)}).filter((w,D,z)=>z.findIndex(J=>J.owner.symbol===w.owner.symbol)===D).reduce((w,D)=>{if(w.length>=Yi)return w;let z=ye(D.owner.relativePath,$).relativeDir;return w.some(J=>J.workspace===z)||w.push({symbol:D.owner.symbol,workspace:z}),w},[]).map(w=>w.symbol));for(let w of C){let D=p+1;Ne(w.file,D,`reference:${ie(h.symbol)}`,!0);let z=a.has("call")&&Me(e,w.file)?.callSites.some(Y=>Y.line===w.line&&Y.calleeLeaf===h.leaf)===!0,J=null,K=null;if(w.enclosingSymbol){let Y=Pe(e,S,w.enclosingSymbol).matches[0];Y&&!le(Y.symbol)&&(ue(Y,D,"reference-owner",void 0,z&&F.has(Y.symbol)?I.referenceScope:"none"),J=Y.symbol)}if(!J&&w.line!==null){let Y=Yt(e,w.file,w.line);Y&&(K=Ae(Y,D,"reference-source-owner",void 0,z))}a.has("reference")&&fe(N,{kind:"reference",evidence:"indexed-or-source-reference",fromFile:w.file,fromSymbol:J,toFile:h.relativePath,toSymbol:h.symbol,fromSourceConstruct:K?ce(K):void 0,line:w.line,strength:"mixed"}),z&&fe(N,{kind:"call",evidence:"ast-callsite",fromFile:w.file,fromSymbol:J,toFile:h.relativePath,toSymbol:h.symbol,fromSourceConstruct:K?ce(K):void 0,line:w.line,strength:"derived"}),a.has("contract-symbol")&&ye(w.file,$).relativeDir!==ye(h.relativePath,$).relativeDir&&fe(N,{kind:"contract-symbol",evidence:"compiler-cross-workspace-symbol",fromFile:w.file,fromSymbol:J,toFile:h.relativePath,toSymbol:h.symbol,fromSourceConstruct:K?ce(K):void 0,line:w.line,strength:"exact"})}}for(let C of R.get(h.symbolId)??[]){let F=Pe(e,S,C.symbol).matches.find(D=>D.relativePath===C.file);if(!F||!m(F.relativePath))continue;if(!(F.relativePath===h.relativePath||(k.get(h.relativePath)??new Set).has(F.relativePath))){O+=1;continue}ue(F,p+1,`call:${ie(h.symbol)}`,void 0,"none",!0),fe(N,{kind:"call",evidence:C.source,fromFile:h.relativePath,fromSymbol:h.symbol,toFile:F.relativePath,toSymbol:F.symbol,line:null,strength:ds(C.source)})}}let U=[...G.values()].filter(I=>!I.processed&&I.primary&&I.depth<=p);for(let I of U){I.processed=!0;let h=[...u.values()].filter(x=>x.traversalEligible&&x.file===I.file&&x.depth<=p),C=[...g.values()].filter(x=>x.definition.relativePath===I.file&&x.depth<=p).map(x=>{let W=Dt(e,I.file,x.definition.startLine);return{startLine:W?.startLine??x.definition.startLine,endLine:W?.endLine??x.definition.endLine}}),F=x=>[...g.values()].filter(W=>W.definition.relativePath===I.file&&W.definition.startLine<=x&&W.definition.endLine>=x).sort((W,T)=>W.definition.endLine-W.definition.startLine-(T.definition.endLine-T.definition.startLine)||W.definition.startLine-T.definition.startLine)[0],w=[...H.values()].filter(x=>x.source.file===I.file&&M.has(x.id)),D=[...h.map(x=>({startLine:x.startLine,endLine:x.endLine})),...w.map(x=>({...Et(e,x)}))],z=[...C,...D],J=(Me(e,I.file)?.callSites??[]).filter(x=>z.some(W=>x.line>=W.startLine&&x.line<=W.endLine)),K=new Set;if(a.has("call"))for(let x of z){let W=kn(e,I.file,x.startLine,x.endLine);for(let T of W.targets){if(!m(T.definition.relativePath))continue;let ne=F(T.sourceLine),xe=h.find(he=>he.startLine<=T.sourceLine&&he.endLine>=T.sourceLine),pe=w.find(he=>{let re=Et(e,he);return re.startLine<=T.sourceLine&&re.endLine>=T.sourceLine});ue(T.definition,p+1,`scip-occurrence-call:${I.file}:${T.sourceLine+1}`,void 0,"none",!0),fe(N,{kind:"call",evidence:"scip-occurrence-callsite",fromFile:I.file,fromSymbol:ne?.definition.symbol??null,toFile:T.definition.relativePath,toSymbol:T.definition.symbol,fromBoundaryParticipant:pe?Ge(pe):void 0,fromSourceConstruct:xe?ce(xe):void 0,line:T.sourceLine,strength:"exact"}),K.add(`${T.sourceLine}\0${T.calleeLeaf}`)}}if(a.has("reference"))for(let x of z){let W=$n(e,I.file,x.startLine,x.endLine);for(let T of W.targets){if(!m(T.definition.relativePath)||K.has(`${T.sourceLine}\0${T.calleeLeaf}`))continue;let ne=F(T.sourceLine);if(ne?.definition.symbol===T.definition.symbol)continue;let xe=h.find(he=>he.startLine<=T.sourceLine&&he.endLine>=T.sourceLine),pe=w.find(he=>{let re=Et(e,he);return re.startLine<=T.sourceLine&&re.endLine>=T.sourceLine});ue(T.definition,p+1,`scip-occurrence-reference:${I.file}:${T.sourceLine+1}`,void 0,"none",!0),fe(N,{kind:"reference",evidence:"scip-occurrence-reference",fromFile:I.file,fromSymbol:ne?.definition.symbol??null,toFile:T.definition.relativePath,toSymbol:T.definition.symbol,fromBoundaryParticipant:pe?Ge(pe):void 0,fromSourceConstruct:xe?ce(xe):void 0,line:T.sourceLine,strength:"exact"})}}let Y=a.has("call")?At(e,I.file,{ranges:z,excludeIndexedTargets:!1}):{targets:[],unresolvedCallsites:0};we+=Y.unresolvedCallsites;let te=Y.targets.filter(x=>!K.has(`${x.line}\0${x.calleeLeaf}`));Le+=te.filter(x=>x.strength!=="exact"&&(x.resolution!=="imported-service-object-member"||(x.resolutionAlternativeCount??0)>1)).length;for(let x of te){let W=(x.resolutionAlternativeCount??1)===1,T=x.targetSymbol?Fe(e,x.targetFile).find(re=>re.symbol===x.targetSymbol):void 0,ne=T?null:Ae({file:x.targetFile,name:x.calleeLeaf,startLine:x.targetStartLine,endLine:x.targetEndLine},p+1,`member-call:${I.file}`,void 0,x.resolution==="imported-service-object-member"&&W,W);if(ne&&x.serviceFile){let re=Ee(ne),Ve=$e.get(re)??new Set;for(let ir of q.get(x.serviceFile)??[])Ve.add(ir);$e.set(re,Ve)}T&&ue(T,p+1,`member-call:${I.file}`,void 0,"none",!0);let xe=h.find(re=>re.startLine<=x.line&&re.endLine>=x.line),pe=F(x.line),he=w.find(re=>{let Ve=Et(e,re);return Ve.startLine<=x.line&&Ve.endLine>=x.line});fe(N,{kind:"call",evidence:x.resolution==="constructed-member-receiver"?"ast-constructed-member-callsite":x.resolution==="factory-callback-member"?"ast-factory-callback-callsite":x.resolution==="imported-service-object-member"?"ast-service-member-callsite":"ast-member-import-candidate",fromFile:I.file,fromSymbol:pe?.definition.symbol??null,toFile:x.targetFile,toSymbol:T?.symbol??null,fromBoundaryParticipant:he?Ge(he):void 0,fromSourceConstruct:xe?ce(xe):void 0,toSourceConstruct:ne?ce(ne):void 0,line:x.line,strength:x.resolution==="imported-service-object-member"?(x.resolutionAlternativeCount??0)===1?"derived":"candidate":x.strength??"candidate"})}for(let x of a.has("import")||a.has("call")?Ms(e,I.file):[]){if(!x.fromFile){if(a.has("import")){let T=_.get(x.shortName)??{name:x.shortName,fromFiles:new Set};T.fromFiles.add(I.file),_.set(x.shortName,T)}continue}if(!m(x.fromFile))continue;if(a.has("import")&&(Ne(x.fromFile,p+1,`import:${I.file}`,!1),fe(N,{kind:"import",evidence:"indexed-or-source-import",fromFile:I.file,fromSymbol:null,toFile:x.fromFile,toSymbol:x.symbol,line:null,strength:"mixed"})),a.has("call")&&J.length>0){let T=(x.source==="compiler"?Pe(e,S,x.symbol).matches:Ln(e,x.fromFile,x.importedName)).filter(ne=>!le(ne.symbol));for(let ne of T){let xe=J.filter(pe=>pe.calleeLeaf===x.localName).map(pe=>pe.line);if(xe.length!==0){ue(ne,p+1,`source-call:${I.file}`,void 0,"none",!0);for(let pe of xe)fe(N,{kind:"call",evidence:"ast-callsite",fromFile:I.file,fromSymbol:null,toFile:ne.relativePath,toSymbol:ne.symbol,line:pe,strength:"derived"})}}}if(!I.promoteBoundaryImports||!Fs(I.file,x.fromFile,$))continue;let W=Pe(e,S,x.symbol);for(let T of W.matches)if(Ps(T.relativePath,x.fromFile,$)&&!le(T.symbol)){let ne=ye(I.file,$).relativeDir!==ye(T.relativePath,$).relativeDir;ue(T,p+1,`boundary-import:${I.file}`,void 0,ne?"cross-workspace-or-forward":"forward-regions")}}}for(let I of a.has("runtime-boundary")?P?.links??[]:[]){if(I.strength==="candidate"||l==="exact"&&I.strength!=="exact"||j.has(I.id))continue;let h=H.get(I.from),C=H.get(I.to);if(!h||!C||!m(h.source.file)||!m(C.source.file))continue;let F=Oo(h,p,M,g,u),w=Oo(C,p,M,g,u);if(F===null&&w===null)continue;let D=p+1,z=nn(h,F??D,`runtime-boundary:${I.joinRule}`),J=nn(C,w??D,`runtime-boundary:${I.joinRule}`),K=z?null:_o(u,h),Y=J?null:_o(u,C);M.set(h.id,F??D),M.set(C.id,w??D),fe(N,{kind:"runtime-boundary",evidence:`runtime-boundary:${I.joinRule}`,fromFile:h.source.file,fromSymbol:z,toFile:C.source.file,toSymbol:J,fromBoundaryParticipant:Ge(h),toBoundaryParticipant:Ge(C),fromSourceConstruct:K?ce(K):void 0,toSourceConstruct:Y?ce(Y):void 0,runtimeBoundaryKey:I.matchedKeyParts.map(te=>`${te.name}=${te.value}`).join(" "),line:h.source.startLine,strength:I.strength}),j.add(I.id)}}let Se=new Map;for(let p of G.keys())Se.set(p,ot(p,$));let it=[...N.values()].filter(p=>Se.has(p.fromFile)&&Se.has(p.toFile)).map(p=>({...p,fromRegionId:Se.get(p.fromFile).id,toRegionId:Se.get(p.toFile).id})).sort(Wo),Nt=qs(it),st=new Set(t.expand??[]),De=_s(G,g,b,it,Nt,Se,st),on=new Set([...G.values()].filter(p=>[...p.origins].some(E=>E.startsWith("literal-anchor:")||E==="literal-owner"||E==="symbol-anchor")).map(p=>Se.get(p.file).id)),rn=ms(De),Vo=new Set(De.map(p=>p.id)),Yo=[...st].filter(p=>!Vo.has(p)).sort();for(let p of Q)if(p.matchedRegionIds=Us(p,b,g,Se),p.kind==="literal"){let E=b.filter(R=>R.query===p.query);p.seedRegionIds=V(E.filter(R=>R.traversalSeed).map(R=>Se.get(R.file).id)),p.matchOnlyRegionIds=V(E.filter(R=>!R.traversalSeed).map(R=>Se.get(R.file).id))}let sn=[...g.values()].filter(p=>!p.processed).length,an=[...G.values()].filter(p=>p.primary&&!p.processed).length,ln=[...G.values()].filter(p=>!p.primary&&!p.processed).length,dn=[...g.values()].filter(p=>p.processed),at=(P?.frontiers??[]).flatMap(p=>{let E=H.get(p.observationId);return!E&&p.source&&p.action&&p.strength?!a.has("runtime-boundary")||!m(p.source.file)||l==="exact"||!G.has(p.source.file)?[]:[{observationId:p.observationId,action:p.action,strength:p.strength,file:p.source.file,line:p.source.startLine,ownerShortName:p.ownerShortName??null,address:p.address??p.missingKeyParts.join(", "),reason:p.reason}]:!a.has("runtime-boundary")||!E||!m(E.source.file)||l==="exact"&&E.strength!=="exact"||!G.has(E.source.file)?[]:[{observationId:E.id,action:E.action,strength:E.strength,file:E.source.file,line:E.source.startLine,ownerShortName:E.owner.name,address:Uo(E),reason:p.reason,protocol:E.protocol,role:E.role,modality:E.modality,resolution:E.resolution,sourceScope:E.sourceScope,keyParts:E.keyParts.map(R=>({name:R.name,value:R.value,evidence:R.evidence}))}]}).sort((p,E)=>p.file.localeCompare(E.file)||p.line-E.line),Mt=(P?.links??[]).filter(p=>{if(!a.has("runtime-boundary")||l==="exact"&&p.strength!=="exact")return!1;let E=H.get(p.from),R=H.get(p.to);return!!(E&&R&&m(E.source.file)&&m(R.source.file)&&(G.has(E.source.file)||G.has(R.source.file)))}),Qo=Mt.filter(p=>p.strength==="exact").length,Jo=Mt.filter(p=>p.strength==="derived").length,Xo=Mt.filter(p=>p.strength==="candidate").length,Zo=P?.links.filter(p=>p.strength==="exact").length??0,er=P?.links.filter(p=>p.strength==="derived").length??0,tr=P?.links.filter(p=>p.strength==="candidate").length??0,Rt=zs(_,Se),Tt=A===0?"accounted":"incomplete",cn=[...ee>0?[`${ee} broad literal anchor(s) withheld ${ae} exact match(es) before graph traversal; representative identities and scoped search commands preserve recovery without treating every textual occurrence as relevant.`]:[],`Literal matches outside the included source scopes (${d.join(", ")}) remain visible as match-only evidence and do not seed traversal.`,P?"Built-in runtime-boundary extractors traverse direct and replayably derived links; heuristic candidates, unsupported frameworks, reflection, generated names, and dependency wiring not recoverable from compiler occurrences or constructor assignments remain disclosed frontiers.":"Runtime-boundary evidence is unavailable for this index; run codebaseiq reindex with this build to extract supported HTTP, event, registry, and persistence observations.","Reverse references do not recursively expand from discovered callers or callees.","Member calls use compiler occurrences, exact constructor-assigned fields, bounded unique service providers, direct factory-return members, and compiler-resolved object-literal callbacks when available. Ambiguous providers remain candidate frontiers; callback values routed through mutation, reflection, or unsupported dependency containers remain unrepresented.","Literal traversal is bounded to the smallest parser-delimited source construct; parser gaps may reduce an owner to one source line and leave its continuation untraversed.","Schema consumers stay within forward-flow regions; cross-workspace contracts may discover consumers in other workspaces. Add an explicit symbol anchor to widen either scope.",`Traversal stops after depth ${v}; nonzero frontier counts identify evidence that was discovered but not traversed.`,"Region labels are structural path groupings, not inferred runtime or architectural boundaries."],be=ns({db:e,anchors:Q,regions:De,symbolStates:g,sourceConstructStates:u,literalHits:b,relations:it,externalBoundaries:Rt,boundaryFrontiers:at,regionForFile:Se,closureStatus:Tt,omittedSymbolCandidates:A,maxDepth:v,requestedRelationKinds:i,evidenceFloor:l,includedSourceScopes:d,blindSpots:cn,topologyFrontiers:t.topologyFrontiers??[],routeIds:t.routeIds??[],expandedRegionIds:[...st],maxTopologyCharacters:L,fullLiteralTraversal:t.fullLiteralTraversal??!1});if(n==="topology")return be;let un=(t.behaviorFocusLocations?.length??0)>0?new Set([...be.anchors.flatMap(p=>p.nodeIds),...be.paths.flatMap(p=>p.nodeIds)]).size:void 0,lt=An(e,be,{focusLocations:t.behaviorFocusLocations,...un?{maxSteps:un}:{}});_n(e,be,lt);let nr=Xi(e,be,lt,t.behaviorFocusLocations??[]);be.corridor=yo(be,{focusLocations:nr});let pn=Bn(e,be,lt,{sourceAllowed:m,selectionTerms:t.selectionTerms}),mn=as(be),or=us(o,s,v,i,l,d,t.fullLiteralTraversal??!1,L,De,Nt,on,st,mn),rr=cs(o,s,v,De.filter(p=>mn.has(p.id)),on,i,l,d,t.fullLiteralTraversal??!1,L);return{anchors:Q,regions:De,regionRelations:Nt,externalBoundaries:Rt,boundaryFrontiers:at,unmatchedExpansions:Yo,expansion:rr,drilldown:rn,presentation:or,topology:be,behavior:lt,nextAnchors:pn,closure:{status:Tt,emitted:{regions:De.length,relations:it.length,runtimeLinks:j.size},withheld:{symbols:sn,files:an+ln,regions:be.nodes.filter(p=>p.kind==="structural-region"&&p.disposition==="folded").length,drillAnchors:(rn?.omittedAnchors??0)+pn.omittedAnchors,literalMatches:ae},ambiguous:{anchors:Q.filter(p=>p.status==="ambiguous").length,omittedSymbolCandidates:A},external:Rt.length,unresolved:at.length,explanation:Tt==="accounted"?"Every fact reached under the declared anchors, relations, depth, evidence floor, source scopes, and installed analyzers is accounted for as emitted, withheld, ambiguous, external, or unresolved.":"Some ambiguous symbol candidates were not identified, so the declared query is not fully accounted for."},coverage:{explicitAnchorCount:Q.length,requestedRelationKinds:i,evidenceFloor:l,includedSourceScopes:d,matchedAnchorCount:Q.filter(p=>p.status!=="missing").length,literalSearchesComplete:!0,broadLiteralAnchors:ee,withheldLiteralMatches:ae,symbolCandidateSetsComplete:A===0,omittedSymbolCandidates:A,maxTraversalDepth:v,frontierSymbols:sn,frontierFiles:an,supportFilesNotTraversed:ln,filteredUnverifiedCallEdges:O,memberCallCandidateEdges:Le,unresolvedMemberCallsites:we,runtimeBoundaryEvidenceAvailable:P!==null,runtimeBoundaryObservations:P?.observations.length??0,runtimeBoundaryExactLinks:Qo,runtimeBoundaryDerivedLinks:Jo,runtimeBoundaryCandidateLinks:Xo,repositoryRuntimeBoundaryExactLinks:Zo,repositoryRuntimeBoundaryDerivedLinks:er,repositoryRuntimeBoundaryCandidateLinks:tr,runtimeBoundaryTraversedLinks:j.size,runtimeBoundaryFrontiers:at.length,referenceExpansionEligibleSymbols:dn.filter(p=>p.referenceScope!=="none").length,referenceExpansionSkippedSymbols:dn.filter(p=>p.referenceScope==="none").length,dynamicDispatchRepresented:P?.links.some(p=>p.joinRule==="carrier.discriminator"&&j.has(p.id))??!1,runtimeGeneratedLinksRepresented:P!==null,regionBoundariesAreStructural:!0,relationFamilies:{"literal-anchor":{evidence:"exact-source",scope:"all indexed documents for each explicit literal",completeWithinScope:!0},reference:{evidence:"compiler-graph",scope:"all cross-file indexed/source-attributed sites for explicit anchors and promoted non-module boundary symbols",completeWithinScope:!0},call:{evidence:"mixed",scope:"static callees plus exact SCIP call occurrences in traversed source ranges, exact constructor-assigned member receivers, and uniquely attributed direct-import member candidates",completeWithinScope:!0},"contract-symbol":{evidence:"compiler-graph",scope:"compiler-resolved symbol identities referenced across inferred workspace boundaries",completeWithinScope:!0},import:{evidence:"compiler-graph",scope:"all indexed or source-resolved imports of traversed primary files",completeWithinScope:!0},"runtime-boundary":{evidence:"exact-source",scope:"direct and mechanically derived links produced by grounded runtime adapters and factorized relation groups",completeWithinScope:!0}},blindSpots:cn}}}function Xi(e,t,n,o){let s=new Map,i=l=>{s.set(`${l.file}\0${l.line}`,l)};for(let l of o)i(l);let r=new Set(t.anchors.filter(l=>l.status==="matched").flatMap(l=>l.nodeIds));for(let l of n.steps)if(!(!l.location||!r.has(l.nodeId)||(l.behavior?.rawCharacters??1/0)>3e3))for(let d of l.behavior?.lines??[])d.signals.some(c=>Qi.has(c))&&i({file:l.location.file,line:d.line,endLine:d.endLine});let a=t.edges.filter(l=>l.disposition==="emitted").flatMap(l=>l.evidence.flatMap(d=>d.location?[d.location]:[]));for(let l of a){i(l);let d=t.nodes.filter(f=>f.location?.file===l.file&&["symbol","source-construct","runtime-boundary-participant"].includes(f.kind)&&f.location.line<=l.line&&(f.location.endLine??f.location.line)>=l.line).sort((f,y)=>(f.location.endLine??f.location.line)-f.location.line-((y.location.endLine??y.location.line)-y.location.line)||f.id.localeCompare(y.id))[0];if(!d?.location)continue;let c=Rn(e,l.file,d.location.line,d.location.endLine??d.location.line,[l.line]);for(let f of c)i({file:l.file,line:f.line,endLine:f.endLine})}return[...s.values()].sort((l,d)=>l.file.localeCompare(d.file)||l.line-d.line)}function Zi(e){if(e.ownerStartLine===null||e.ownerStartLine===void 0)throw new Error(`Literal hit ${e.file}:${e.line+1} has no source-owner start line.`);if(e.ownerEndLine===null||e.ownerEndLine===void 0)throw new Error(`Literal hit ${e.file}:${e.line+1} has no source-owner end line.`);return{file:e.file,name:e.ownerShortName??`${e.file}:${e.ownerStartLine+1}`,startLine:e.ownerStartLine,endLine:e.ownerEndLine}}function Ee(e){return`${e.file}\0${e.startLine}\0${e.endLine}\0${e.name}`}function ce(e){return{file:e.file,name:e.name,startLine:e.startLine,endLine:e.endLine}}function It(e,t){let n=Zt(Me(e,t.file)?.callables??[],t.startLine);if(n&&n.endLine>=t.endLine)return{file:t.file,name:/^source@\d+$/u.test(n.name)&&!/^source@\d+$/u.test(t.name)?t.name:n.name,startLine:n.startLine,endLine:n.endLine};let o=zo(e,t.file,t.startLine);return o&&o.endLine>=t.endLine?{file:t.file,name:o.name,startLine:o.startLine,endLine:o.endLine}:ce(t)}function He(e){return ge("source-construct",e.file,String(e.startLine),String(e.endLine),e.name)}function wt(e,t){let n=hn(e,t.symbol,t.relativePath),o=new Set(["package-surface-file","transitive-package-surface"]),s=n.filter(r=>!o.has(r)||Dn(e,t)),i=s.some(r=>!o.has(r));return{evidence:s,priority:i||xn(e,t.symbol,t.relativePath)?2:1}}function ko(e,t){let n=wt(e,t);return n.evidence.length>0?n.priority:0}function es(e,t){let n=Fe(e,t.file),o=n.filter(s=>s.startLine<=t.startLine&&s.endLine>=t.startLine).sort((s,i)=>s.endLine-s.startLine-(i.endLine-i.startLine)||s.startLine-i.startLine);for(let s of o){let i=wt(e,s);if(i.evidence.length>0)return i}for(let s of ts(e,t.file,t.startLine)){let i=n.filter(r=>r.leaf===s.name).sort((r,a)=>Math.abs(r.startLine-s.startLine)-Math.abs(a.startLine-s.startLine)||r.symbol.localeCompare(a.symbol));for(let r of i){let a=wt(e,r);if(a.evidence.length>0)return a}return{evidence:[],priority:0}}return{evidence:[],priority:0}}function ts(e,t,n){let o=Be(e,t)?.rootNode;if(!o||o.startPosition.row>n||o.endPosition.row<n)return[];let s=[],i=en(o,n);for(;i;){if(i.type==="variable_declarator"||i.type==="function_declaration"||i.type==="generator_function_declaration"||i.type==="class_declaration"){let r=i.childForFieldName("name")??i.namedChild(0);(r?.type==="identifier"||r?.type==="type_identifier")&&s.push({name:r.text,startLine:i.startPosition.row})}i=i.parent}return s}function ns(e){let t=[...new Map([...e.sourceConstructStates.values()].map(u=>It(e.db,u)).map(u=>[Ee(u),u])).values()].sort((u,b)=>u.file.localeCompare(b.file)||u.startLine-b.startLine||u.endLine-b.endLine),n=e.anchors.map((u,b)=>{let N=ge("anchor",String(b),u.kind,u.query),_=[...e.symbolStates.values()].filter(O=>O.anchorQueries.has(u.query)).flatMap(O=>{if(!le(O.definition.symbol))return[ke(O.definition.symbol)];let Le=t.filter(we=>we.file===O.definition.relativePath).map(we=>He(we));return Le.length>0?Le:[ke(O.definition.symbol)]}),Q=[...e.sourceConstructStates.values()].filter(O=>O.anchorQueries.has(u.query)).map(O=>He(It(e.db,O))),A=e.literalHits.filter(O=>O.query===u.query&&O.traversalSeed===!0&&O.ownerSymbol&&e.symbolStates.has(O.ownerSymbol)).map(O=>ke(O.ownerSymbol)),ee=e.literalHits.filter(O=>O.query===u.query&&O.traversalSeed===!0&&!O.ownerSymbol&&O.ownerStartLine!==null&&O.ownerStartLine!==void 0&&O.ownerEndLine!==null&&O.ownerEndLine!==void 0).map(O=>He(It(e.db,Zi(O)))),ae=V(u.kind==="symbol"?[..._,...Q]:A.length+ee.length>0?[...A,...ee]:u.seedRegionIds??[]);return{id:N,kind:u.kind,query:u.query,status:u.status,nodeIds:u.status==="ambiguous"?[]:ae,candidateNodeIds:u.status==="ambiguous"?ae:[],omittedCandidates:u.omittedSymbolCandidates??0}}),o=new Map;for(let u of n)for(let b of[...u.nodeIds,...u.candidateNodeIds]){let N=o.get(b)??[];N.push(u.id),o.set(b,N)}let s=e.relations.flatMap(u=>[u.fromBoundaryParticipant,u.toBoundaryParticipant].flatMap(b=>b?.ownerName?[b]:[])),i=e.regions.map(u=>({id:u.id,kind:"structural-region",label:u.label,disposition:"folded",location:null,anchorIds:V(o.get(u.id)??[]),attributes:{workspace:u.workspace,structuralPath:u.structuralPath,minimumDepth:u.minDepth,files:u.fileCount,symbols:u.symbolCount,expanded:u.expanded}}));for(let u of e.symbolStates.values()){let b=e.regionForFile.get(u.definition.relativePath)?.id;if(!b)throw new Error(`System-map symbol ${u.definition.symbol} has no structural region.`);let N=ke(u.definition.symbol),_=wt(e.db,u.definition);i.push({id:N,kind:"symbol",label:ie(u.definition.symbol),disposition:(o.get(N)?.length??0)>0?"emitted":"folded",location:{file:u.definition.relativePath,line:u.definition.startLine,endLine:u.definition.endLine},anchorIds:V(o.get(N)??[]),attributes:{regionId:b,depth:u.depth,leaf:u.definition.leaf??ie(u.definition.symbol),referenceScope:u.referenceScope,..._.evidence.length>0?{publicEntry:!0,publicEntryPriority:_.priority,publicEntryEvidence:_.evidence.join(",")}:{}}})}for(let u of t){let b=e.regionForFile.get(u.file)?.id;if(!b)throw new Error(`Source construct ${u.name} has no structural region.`);let N=He(u),Q=s.find(ee=>ee.file===u.file&&ee.line>=u.startLine&&ee.line<=u.endLine)?.ownerName??u.name,A=es(e.db,u);i.push({id:N,kind:"source-construct",label:Q,disposition:(o.get(N)?.length??0)>0?"emitted":"folded",location:{file:u.file,line:u.startLine,endLine:u.endLine},anchorIds:V(o.get(N)??[]),attributes:{regionId:b,leaf:Q,sourceOwned:!0,...A.evidence.length>0?{publicEntry:!0,publicEntryPriority:A.priority,publicEntryEvidence:A.evidence.join(",")}:{}}})}let r=new Map;for(let u of e.relations)u.fromBoundaryParticipant&&r.set(u.fromBoundaryParticipant.observationId,u.fromBoundaryParticipant),u.toBoundaryParticipant&&r.set(u.toBoundaryParticipant.observationId,u.toBoundaryParticipant);for(let u of[...r.values()].sort((b,N)=>b.observationId.localeCompare(N.observationId))){let b=e.regionForFile.get(u.file)?.id;if(!b)throw new Error(`Runtime-boundary participant ${u.observationId} has no structural region.`);i.push({id:Qt(u.observationId),kind:"runtime-boundary-participant",label:u.address||u.ownerName||`${u.role} ${u.action}`,disposition:"folded",location:{file:u.file,line:u.line,endLine:u.endLine},anchorIds:[],attributes:{regionId:b,action:u.action,protocol:u.protocol,role:u.role,...u.address?{address:u.address}:{},ownerSymbol:u.ownerSymbol}})}let a=new Set(i.map(u=>u.id)),l=ve(t,u=>u.file),d=(u,b,N,_,Q,A,ee=!1)=>{let ae=u?ke(u):null;if(ae&&a.has(ae)&&!le(u))return ae;let O=b?Qt(b.observationId):null;if(ee&&O&&a.has(O))return O;let Le=N?He(It(e.db,N)):null;if(Le&&a.has(Le))return Le;if(O&&a.has(O))return O;let we=A===null?null:(l.get(Q)??[]).filter(Ce=>Ce.startLine<=A&&Ce.endLine>=A).sort((Ce,$e)=>Ce.endLine-Ce.startLine-($e.endLine-$e.startLine)||Ce.startLine-$e.startLine)[0]??null;return we?He(we):ae&&a.has(ae)?ae:_},c=[];for(let u of e.symbolStates.values()){let b=e.regionForFile.get(u.definition.relativePath)?.id;if(!b)continue;let N=ke(u.definition.symbol);c.push({id:ge("edge","structural-membership",b,N),kind:"structural-membership",fromNodeId:b,toNodeId:N,directed:!0,disposition:"folded",semantics:ct("structural-membership"),evidence:[{method:"indexed-definition-file",strength:"exact",identity:u.definition.symbol,location:{file:u.definition.relativePath,line:u.definition.startLine,endLine:u.definition.endLine}}]})}let f=ve(e.relations,u=>`${d(u.fromSymbol,u.fromBoundaryParticipant,u.fromSourceConstruct,u.fromRegionId,u.fromFile,u.line,u.kind==="runtime-boundary")}\0${d(u.toSymbol,u.toBoundaryParticipant,u.toSourceConstruct,u.toRegionId,u.toFile,null)}\0${u.kind}`),y=new Set;for(let u of f.values()){let b=u[0],N=d(b.fromSymbol,b.fromBoundaryParticipant,b.fromSourceConstruct,b.fromRegionId,b.fromFile,b.line,b.kind==="runtime-boundary"),_=d(b.toSymbol,b.toBoundaryParticipant,b.toSourceConstruct,b.toRegionId,b.toFile,null);if(b.kind==="runtime-boundary"&&b.fromBoundaryParticipant){let A=Qt(b.fromBoundaryParticipant.observationId),ee=d(b.fromSymbol,void 0,b.fromSourceConstruct,b.fromRegionId,b.fromFile,b.line);ee!==A&&!y.has(A)&&(y.add(A),c.push({id:ge("edge","boundary-observation",ee,A),kind:"boundary-observation",fromNodeId:ee,toNodeId:A,directed:!0,disposition:"folded",semantics:ct("boundary-observation"),evidence:[{method:"runtime-boundary-observation-owner",strength:b.strength??"unknown",identity:b.fromBoundaryParticipant.observationId,location:{file:b.fromBoundaryParticipant.file,line:b.fromBoundaryParticipant.line,endLine:b.fromBoundaryParticipant.endLine}}]}))}(N===_?i.find(A=>A.id===N):null)?.kind!=="structural-region"&&c.push({id:ge("edge",b.kind,N,_),kind:b.kind,fromNodeId:N,toNodeId:_,directed:!0,disposition:"folded",semantics:Kn(b),evidence:ls(u.map(A=>({method:A.evidence,strength:A.strength??"unknown",identity:A.kind==="runtime-boundary"&&A.runtimeBoundaryKey?A.runtimeBoundaryKey:`${A.fromSymbol??A.fromFile} -> ${A.toSymbol??A.toFile}`,location:A.line===null?null:{file:A.fromFile,line:A.line}})))})}for(let u of e.externalBoundaries){let b=ge("external",u.kind,u.name),N=V(u.fromRegionIds);i.push({id:b,kind:u.kind,label:u.name,disposition:"folded",location:null,anchorIds:[],attributes:{}});for(let _ of N)c.push({id:ge("edge",u.kind,_,b),kind:u.kind,fromNodeId:_,toNodeId:b,directed:!0,disposition:"folded",semantics:ct("external-import"),evidence:[{method:"indexed-or-source-import",strength:"mixed",identity:`${_} -> ${u.name}`,location:null}]})}let m=[];e.boundaryFrontiers.forEach((u,b)=>{let N=e.regionForFile.get(u.file)?.id;if(!N)throw new Error(`Runtime-boundary frontier ${u.observationId} has no system-map region.`);let _=ge("unsupported","runtime-boundary",u.observationId,String(b)),Q=ge("edge","runtime-boundary-frontier",N,_);i.push({id:_,kind:"runtime-boundary-frontier",label:u.address,disposition:"unsupported",location:{file:u.file,line:u.line},anchorIds:[],attributes:{action:u.action,strength:u.strength,owner:u.ownerShortName}}),c.push({id:Q,kind:"runtime-boundary-frontier",fromNodeId:N,toNodeId:_,directed:!0,disposition:"unsupported",evidence:[{method:"runtime-boundary-extractor",strength:u.strength,identity:u.observationId,location:{file:u.file,line:u.line}}]}),m.push({id:ge("frontier","runtime-boundary",u.observationId,String(b)),kind:"runtime-boundary",direction:"unresolved",fromNodeIds:[N],edgeIds:[Q],memberNodeIds:[_],memberCount:1,disposition:"unsupported",reason:u.reason,expansion:null})});let v=vt({anchors:n,nodes:i,edges:c,paths:[],frontiers:m,scope:`explicit anchors; relations ${e.requestedRelationKinds.join(", ")}; depth ${e.maxDepth}; evidence floor ${e.evidenceFloor}; source scopes ${e.includedSourceScopes.join(", ")}`,blindSpots:[...e.blindSpots],incompleteReasons:e.closureStatus==="incomplete"?[`${e.omittedSymbolCandidates} ambiguous symbol candidate(s) were omitted`]:[]}),L=e.topologyFrontiers.some(u=>u==="frontier:program-facts"),S=Ro(v,{expandedFrontierIds:e.topologyFrontiers.filter(u=>u!=="frontier:program-facts"),routeIds:e.routeIds}),k=S.nodes.filter(u=>u.disposition==="emitted"||S.anchors.some(b=>b.status==="matched"&&b.nodeIds.includes(u.id))),q=e.relations.filter(u=>k.some(b=>os(u,b))),$=e.boundaryFrontiers.filter(u=>k.some(b=>rs(u,b))),P=Qn(e.db,q,k),H=Xn(e.db,k),B=uo(e.db,k,$),j=[...P.nodes,...H.nodes,...B.nodes].map(u=>L&&u.disposition==="folded"?{...u,disposition:"emitted"}:u),M=[...P.edges,...H.edges,...B.edges].map(u=>L&&u.disposition==="folded"?{...u,disposition:"emitted"}:u),G=L?null:is(k,j,M),g=vt({anchors:S.anchors,nodes:[...S.nodes,...j],edges:[...S.edges,...M],paths:S.paths,frontiers:[...S.frontiers,...P.frontiers,...H.frontiers,...B.frontiers,...G?[G]:[]],scope:S.coverage.scope,blindSpots:[...S.coverage.blindSpots,...P.blindSpots,...H.blindSpots,...B.blindSpots],incompleteReasons:S.coverage.status==="incomplete"?[S.coverage.explanation]:[],...S.routeCatalog?{routeCatalog:S.routeCatalog}:{}});g.completion=S.completion;for(let u of g.frontiers)u.disposition==="folded"&&(u.id.startsWith("frontier:program-facts:")||(u.expansion=ss(e,u.id)));return g}function os(e,t){if(e.fromSymbol&&t.id===ke(e.fromSymbol)||e.toSymbol&&t.id===ke(e.toSymbol))return!0;if(!t.location)return!1;let n=t.location.endLine??t.location.line;return t.location.file===e.fromFile&&e.line!==null&&e.line>=t.location.line&&e.line<=n||t.location.file===e.toFile}function rs(e,t){if(!t.location||t.location.file!==e.file)return!1;let n=t.location.endLine??t.location.line;return e.line>=t.location.line&&e.line<=n||t.label===e.ownerShortName||typeof e.ownerShortName=="string"&&t.label.includes(e.ownerShortName)}function is(e,t,n){let o=V(t.filter(i=>i.disposition==="folded").map(i=>i.id)),s=V(n.filter(i=>i.disposition==="folded").map(i=>i.id));return o.length===0&&s.length===0?null:{id:ge("frontier","program-facts"),kind:"program-facts",direction:"outgoing",fromNodeIds:V(e.map(i=>i.id)),edgeIds:s,memberNodeIds:o,memberCount:o.length,disposition:"folded",reason:"Control, data, state, and temporal facts are folded beneath the selected high-level owners.",expansion:null}}function ss(e,t){return`codebaseiq system-map ${[...e.anchors.flatMap(o=>o.kind==="literal"?[`--search ${X(o.query)}`]:[`--symbol ${X(o.query)}`]),`--depth ${e.maxDepth}`,...e.requestedRelationKinds.map(o=>`--relation ${X(o)}`),`--evidence-floor ${X(e.evidenceFloor)}`,...e.includedSourceScopes.map(o=>`--source-scope ${X(o)}`),...e.fullLiteralTraversal?["--full-literal-traversal"]:[],`--topology-characters ${e.maxTopologyCharacters}`,...e.expandedRegionIds.map(o=>`--expand ${X(o)}`),...e.topologyFrontiers.map(o=>`--frontier ${X(o)}`),...e.routeIds.map(o=>`--route ${X(o)}`),`--frontier ${X(t)}`].join(" ")}`}function as(e){let t=new Set;for(let n of e.nodes){if(n.disposition!=="emitted")continue;n.kind==="structural-region"&&t.add(n.id);let o=n.attributes.regionId;typeof o=="string"&&t.add(o)}return t}function ls(e){let t=new Map;for(let n of e){let o=n.location?`${n.location.file}:${n.location.line}`:"";t.set(`${n.method}\0${n.strength}\0${n.identity??""}\0${o}`,n)}return[...t.values()].sort((n,o)=>n.method.localeCompare(o.method)||(n.identity??"").localeCompare(o.identity??"")||(n.location?.file??"").localeCompare(o.location?.file??"")||(n.location?.line??0)-(o.location?.line??0))}function ge(...e){return e.map(t=>encodeURIComponent(t)).join(":")}function ke(e){return ge("symbol",e)}function ds(e){return e==="semantic-callee"||e==="scip-chunk"?"exact":"derived"}function cs(e,t,n,o,s,i,r,a,l,d){let c=[...o].sort((L,S)=>qo(L,S,s)),y=c.slice(0,Fo).map(L=>L.id),m=c.slice(Fo).map(L=>L.id),v=[...e.map(L=>`--search ${X(L)}`),...t.map(L=>`--symbol ${X(L)}`),`--depth ${n}`,...i.map(L=>`--relation ${X(L)}`),`--evidence-floor ${X(r)}`,...a.map(L=>`--source-scope ${X(L)}`),...l?["--full-literal-traversal"]:[],`--topology-characters ${d}`,...y.map(L=>`--expand ${X(L)}`)];return{command:y.length===0?null:`codebaseiq system-map ${v.join(" ")}`,regionCount:y.length,regionIds:y,candidateRegionCount:o.length,omittedRegionIds:m}}function us(e,t,n,o,s,i,r,a,l,d,c,f,y){let m=[...l].sort((g,u)=>qo(g,u,c)).filter(g=>!y||y.has(g.id)||f.has(g.id)),v=d.length>0?Math.floor(a*.4):0,L=a-v,S=new Set,k=0;for(let g of m){let u=$o(g);!f.has(g.id)&&S.size>0&&k+u>L||(S.add(g.id),k+=u)}let q=d.filter(g=>S.has(g.fromRegionId)&&S.has(g.toRegionId)).sort(ps),$=[];for(let g of q){let u=Ao(g);$.length>0&&k+u>a||($.push(Ct(g)),k+=u)}let P=l.filter(g=>!S.has(g.id)).map(g=>g.id).sort(),H=new Set($),B=d.filter(g=>!H.has(Ct(g))).length,j=l.reduce((g,u)=>g+$o(u),0)+d.reduce((g,u)=>g+Ao(u),0),M=m.every(g=>S.has(g.id))&&$.length===q.length,G=[...e.map(g=>`--search ${X(g)}`),...t.map(g=>`--symbol ${X(g)}`),`--depth ${n}`,...o.map(g=>`--relation ${X(g)}`),`--evidence-floor ${X(s)}`,...i.map(g=>`--source-scope ${X(g)}`),...r?["--full-literal-traversal"]:[],`--topology-characters ${Math.max(a,j)}`];return{maxCharacters:a,estimatedCharacters:k,totalEstimatedCharacters:j,regionIds:[...S],omittedRegionIds:P,relationKeys:$,omittedRelations:B,complete:M,expansionCommand:M?null:`codebaseiq system-map ${G.join(" ")}`}}function $o(e){return 120+e.id.length+e.anchorQueries.join(",").length+e.relationKinds.join(",").length+e.notableSymbols.slice(0,2).reduce((t,n)=>t+n.shortName.length+n.file.length,0)}function Ao(e){return 70+e.fromRegionId.length+e.toRegionId.length+e.kinds.join(",").length+e.evidence.join(",").length}function ps(e,t){let n=o=>o.kinds.includes("runtime-boundary")?0:o.kinds.includes("contract-symbol")?1:2;return n(e)-n(t)||t.relationCount-e.relationCount||Ct(e).localeCompare(Ct(t))}function Ct(e){return`${e.fromRegionId}\0${e.toRegionId}`}function qo(e,t,n){let o=a=>n.has(a.id)?0:1,s=a=>a.sourceFileCount===0?1:0,i=a=>a.symbolCount+a.literalHitCount>0?0:1,r=a=>[...a.incomingRegionIds,...a.outgoingRegionIds].filter(l=>n.has(l)).length;return o(e)-o(t)||i(e)-i(t)||s(e)-s(t)||e.minDepth-t.minDepth||r(t)-r(e)||t.literalHitCount-e.literalHitCount||e.testFileCount-t.testFileCount||e.label.localeCompare(t.label)}function ms(e){let t=[],n=new Set;for(let s of e.filter(i=>i.expanded)){for(let l of s.symbols)l.origins.includes("symbol-anchor")&&n.add(l.file);let i=ve(s.symbols,l=>l.file),r=ve(s.literalHits,l=>l.file),a=[...s.files].sort((l,d)=>gs(l,d,i,r));for(let l of a){let d=(i.get(l.file)??[]).sort(ys)[0];if(d){t.push({kind:"symbol",regionId:s.id,file:d.file,line:d.startLine,endLine:d.endLine,label:d.shortName});continue}let c=(r.get(l.file)??[]).sort(Ho)[0];c&&t.push({kind:"literal",regionId:s.id,file:c.file,line:c.line,endLine:null,label:c.ownerShortName??c.query})}}let o=fs(t,n);return{command:o.length===0?null:`codebaseiq inspect ${o.map(s=>`--at ${X(`${s.file}:${s.line+1}`)}`).join(" ")} --view behavior`,definitionCommand:null,candidateAnchors:t.length,selectedAnchors:o.length,omittedAnchors:t.length-o.length,anchors:o}}function fs(e,t){let n=[...ve(e,r=>r.regionId).values()],o=[],s=new Set,i=Math.min(Vi,24);for(let r of e)if(!(!t.has(r.file)||s.has(r.file))&&(o.push(r),s.add(r.file),o.length===i))return o;for(let r=0;o.length<i;r+=1){let a=!1;for(let l of n){let d=l[r];if(d&&(a=!0,!s.has(d.file)&&(o.push(d),s.add(d.file),o.length===i)))break}if(!a)break}return o}function gs(e,t,n,o){let s=a=>a.kind==="test"?2:a.kind==="barrel"?1:0,i=a=>(o.get(a.file)??[]).some(l=>l.traversalSeed)?0:1,r=a=>{let l=n.get(a.file)??[];return Math.min(5,...l.map(d=>rt(d.origins)))};return s(e)-s(t)||i(e)-i(t)||r(e)-r(t)||e.depth-t.depth||e.file.localeCompare(t.file)}function ys(e,t){return rt(e.origins)-rt(t.origins)||e.depth-t.depth||e.startLine-t.startLine||e.shortName.localeCompare(t.shortName)}function X(e){return`'${e.replaceAll("'","'\\''")}'`}function Ss(e,t,n,o){let s=[];for(let i of gn(e,{includeIgnored:!1})){let r=Ft(e,i);if(r.length===0)continue;let a=t.definitionsForFile(i),l=Me(e,i)?.callables??[];for(let d=0;d<r.length;d+=1){let c=r[d]??"";if(!c.includes(n))continue;let f=ze(a,d),y=Zt(l,d),m=f&&!le(f.symbol)?f:null,v=m?.startLine??y?.startLine??f?.startLine??d,L=m?.endLine??y?.endLine??f?.endLine??d,S=Bt(e,i,d,v,L),k=o.has(`${i}\0${d}`),q=!!(m?.isFunctionLike||y);s.push({relativePath:i,line:d,sourceLine:c,ownerSymbol:m?.symbol??null,ownerShortName:m?ie(m.symbol):y?.name??(f?ie(f.symbol):null),ownerStartLine:S.startLine,ownerEndLine:S.endLine,matchKind:vs(c,n),seedPriority:k?0:q?1:2})}}return s}function bs(e,t){let n={"exact-value":0,boundary:1,embedded:2};return e.seedPriority-t.seedPriority||n[e.matchKind]-n[t.matchKind]||e.relativePath.localeCompare(t.relativePath)||e.line-t.line}function Do(e){return`${e.relativePath}\0${e.line}`}function Zt(e,t){return e.filter(n=>n.startLine<=t&&n.endLine>=t).sort((n,o)=>n.endLine-n.startLine-(o.endLine-o.startLine)||n.startLine-o.startLine)[0]??null}function Yt(e,t,n){let s=Zt(Me(e,t)?.callables??[],n)??zo(e,t,n);if(!s)return null;let i=Bt(e,t,n,s.startLine,s.endLine);return{file:t,name:s.name,startLine:i.startLine,endLine:i.endLine}}function zo(e,t,n){let o=Be(e,t)?.rootNode;if(!o||o.startPosition.row>n||o.endPosition.row<n)return null;let s=en(o,n);for(;s;){if(s.type==="variable_declarator"){let r=s.childForFieldName("name")??s.namedChild(0),a=s.childForFieldName("value")??s.namedChild(1);if(r?.type==="identifier"&&a&&Jt(a,n))return{name:r.text,startLine:s.startPosition.row,endLine:s.endPosition.row}}if(s.type==="pair"){let r=s.childForFieldName("key")??s.namedChild(0),a=s.childForFieldName("value")??s.namedChild(1),l=r?.text.replace(/^(?:['"])(.*)(?:['"])$/u,"$1");if(l&&a&&/^[A-Za-z_$][\w$]*$/u.test(l)&&Jt(a,n))return{name:l,startLine:s.startPosition.row,endLine:s.endPosition.row}}s=s.parent}let i=Dt(e,t,n);return i?{name:`source@${n+1}`,startLine:i.startLine,endLine:i.endLine}:null}function Jt(e,t){return["arrow_function","function_expression","generator_function","generator_function_declaration"].includes(e.type)&&e.startPosition.row<=t&&e.endPosition.row>=t?!0:e.namedChildren.some(n=>n.startPosition.row<=t&&n.endPosition.row>=t&&Jt(n,t))}function en(e,t){let n=e.namedChildren.filter(o=>o.startPosition.row<=t&&o.endPosition.row>=t).sort((o,s)=>o.endIndex-o.startIndex-(s.endIndex-s.startIndex)||o.startPosition.row-s.startPosition.row)[0];return n?en(n,t):e}function hs(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/u);if(!n)return null;let o=yn(e,n[1],{allowMultiple:!1})[0]?.relativePath;if(!o)return null;let s=Math.max(0,Number.parseInt(n[2],10)-1),i=n[3]?Math.max(s,Number.parseInt(n[3],10)-1):s,r=(Me(e,o)?.callables??[]).filter(a=>a.startLine<=s&&a.endLine>=i).sort((a,l)=>a.endLine-a.startLine-(l.endLine-l.startLine)||a.startLine-l.startLine)[0];return r?{file:o,name:r.name,startLine:r.startLine,endLine:r.endLine}:null}function xs(e){return{symbol:`source-construct:${e.file}:${e.startLine}:${e.endLine}:${e.name}`,shortName:e.name,relativePath:e.file,startLine:e.startLine,endLine:e.endLine}}function vs(e,t){let n=/[\p{L}\p{N}_$]/u,o=e.indexOf(t);for(;o>=0;){let s=e[o-1]??"",i=e[o+t.length]??"";if((s==="'"||s==='"'||s==="`")&&i===s)return"exact-value";if(!n.test(s)&&!n.test(i))return"boundary";o=e.indexOf(t,o+Math.max(1,t.length))}return"embedded"}function Xt(e){return dt(e)==="test"?!1:!/(?:^|[/._-])(?:fixtures?|mocks?|previews?|demos?|examples?|stories)(?:[/._-]|$)/iu.test(e)}function Is(e,t){return e.matchKind!=="embedded"&&t(e.relativePath)&&($t(e.relativePath)!=="production"||Xt(e.relativePath))}function Es(e,t){let n=[...t].sort(Ls),o=[],s=new Set;for(let i of n)if(!s.has(i.relativePath)&&(o.push(i),s.add(i.relativePath),o.length>=To))break;for(let i of n){if(o.length>=To)break;o.includes(i)||o.push(i)}return o.map(i=>({query:e,file:i.relativePath,line:i.line,ownerSymbol:i.ownerSymbol,ownerShortName:i.ownerShortName,ownerStartLine:i.ownerStartLine,ownerEndLine:i.ownerEndLine,sourceLine:i.sourceLine.trim(),matchKind:i.matchKind,traversalSeed:!1}))}function Ls(e,t){let n={"exact-value":0,boundary:1,embedded:2};return n[e.matchKind]-n[t.matchKind]||+(t.ownerSymbol!==null)-+(e.ownerSymbol!==null)||+!Xt(e.relativePath)-+!Xt(t.relativePath)||e.relativePath.localeCompare(t.relativePath)||e.line-t.line}function ws(e,t){let n=new Map;for(let o of t){let s=Cs(o.relativePath);n.set(s,(n.get(s)??0)+1)}return[...n].sort(([o,s],[i,r])=>r-s||o.localeCompare(i)).slice(0,Hi).map(([o])=>`codebaseiq search ${X(e)} --scope ${X(o)}`)}function Cs(e){let t=e.split("/").filter(Boolean);if(t.length<=1)return e;let n=t.slice(0,-1),o=n.lastIndexOf("src");return o>=0?n.slice(0,Math.min(n.length,o+3)).join("/"):n.slice(0,Math.min(n.length,3)).join("/")}function Ns(e,t,n){let o=t.callerFileMap([n],{semantic:!1}).get(n.symbolId)??new Set,s=[];for(let i of[...o].sort()){let r=n.leaf?Pt(e,i,n.leaf):[];if(r.length===0){s.push({file:i,line:null,enclosingSymbol:null});continue}let a=t.definitionsForFile(i);for(let l of r)s.push({file:i,line:l,enclosingSymbol:ze(a,l)?.symbol??null})}return s}function Ms(e,t){let n=e.all(`SELECT DISTINCT gs.symbol, def_d.relative_path AS from_file
1
+ import{a as Bn,b as _n}from"./chunk-5IZRKWTZ.js";import{a as Dt,b as Bt}from"./chunk-BWL3PMPT.js";import{a as Dn}from"./chunk-U7NUXDQO.js";import{b as An}from"./chunk-AEXQYQD7.js";import{a as Pn,b as At,c as kn,e as $n}from"./chunk-FWQGH2N2.js";import{b as Rn,c as Tn,d as Fn}from"./chunk-BGGB5N53.js";import{a as $t,b as wn,c as Cn,d as Nn,i as Mn}from"./chunk-GQLDYCWS.js";import{a as Ln}from"./chunk-3VJ3OCRE.js";import{c as En}from"./chunk-HENP2O4A.js";import{S as vn,T as In}from"./chunk-SMDIEDM4.js";import{a as Pt}from"./chunk-J7AMBVWF.js";import{b as kt}from"./chunk-SGMNWYTH.js";import{g as hn,i as xn}from"./chunk-NDKOVQFG.js";import{a as dt}from"./chunk-BRQL7AFJ.js";import{A as ze,d as ie,i as le,t as Fe}from"./chunk-GVAF222T.js";import{f as Me,p as bn}from"./chunk-F74LZWCE.js";import{C as Be,a as gn,b as yn}from"./chunk-ICUL7XRT.js";import{g as fn,w as Sn,x as Ft}from"./chunk-7GAK2F3H.js";var On=["call","contract-symbol","import","reference","runtime-boundary"],sr={call:[{family:"control",subtype:"call"}],"contract-symbol":[{family:"contract",subtype:"uses-contract-symbol"}],import:[{family:"identity",subtype:"imports"}],reference:[{family:"identity",subtype:"references"}]},ar={"structural-membership":[{family:"identity",subtype:"contains"}],"boundary-observation":[{family:"identity",subtype:"owns-runtime-observation"}],"external-import":[{family:"identity",subtype:"imports-external"}]};function Kn(e){if(e.kind!=="runtime-boundary")return jn(sr[e.kind]);let t=e.fromBoundaryParticipant?.protocol??e.toBoundaryParticipant?.protocol,n={crossesRuntimeBoundary:!0,...t?{protocol:t}:{},...e.runtimeBoundaryKey?{runtimeKey:e.runtimeBoundaryKey}:{}},o=[{family:"control",subtype:"runtime-handoff",context:n}];return e.evidence==="runtime-boundary:carrier.discriminator"&&(o.push({family:"control",subtype:"discriminator-dispatch",context:{...n},attributes:{joinRule:"carrier.discriminator",...e.fromBoundaryParticipant?.action?{producerAction:e.fromBoundaryParticipant.action}:{},...e.toBoundaryParticipant?.action?{consumerAction:e.toBoundaryParticipant.action}:{}}}),o.push({family:"data",subtype:"serialized-discriminator-transfer",context:{...n},attributes:{joinRule:"carrier.discriminator"}})),e.evidence==="runtime-boundary:queue.address"&&e.fromBoundaryParticipant?.action==="queue.send"&&e.toBoundaryParticipant?.action==="queue.consume"&&o.push({family:"temporal",subtype:"enqueue-before-consume",context:{...n},attributes:{producerAction:e.fromBoundaryParticipant.action,consumerAction:e.toBoundaryParticipant.action,retryPolicy:"unknown"}}),o}function ct(e){return jn(ar[e])}function jn(e){return e.map(t=>({...t,...t.context?{context:{...t.context}}:{},...t.attributes?{attributes:{...t.attributes}}:{}}))}import{join as kr}from"path";import{createRequire as lr}from"module";import{resolve as Qe}from"path";var dr=lr(import.meta.url),Ye;function zn(e,t,n){let o=cr();if(!o)return _t("The TypeScript compiler runtime is unavailable.");let s=ur(o,e,t),i=s.getSourceFile(Qe(t))??s.getSourceFile(t);if(!i)return _t(`The TypeScript compiler did not materialize ${t}.`);let r={ts:o,sourceFile:i,checker:s.getTypeChecker(),points:new Map,edges:new Map,unsupported:new Set,nextCfgId:0},a=mr(o,i,n);if(a.length===0)return _t("No function-like construct intersects the selected source range.");let l=new Map(a.map(f=>[f,fr(i,f)])),d=a.map(f=>yr(r,f,gr(o,f,l),l.get(f)));for(let f of d)Sr(r,f),vr(r,f),Lr(r,f);Cr(r,d);let c=[...r.unsupported].sort();return{points:[...r.points.values()].map(({node:f,...y})=>y).sort(Pr),edges:[...r.edges.values()].sort((f,y)=>f.id.localeCompare(y.id)),coverage:{status:c.length===0?"complete":"partial",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:c}}}function cr(){if(Ye!==void 0)return Ye;try{Ye=dr("typescript")}catch{Ye=In()?.ts??null}return Ye}function ur(e,t,n){let o=Qe(n),s={target:e.ScriptTarget.ESNext,module:e.ModuleKind.NodeNext,moduleResolution:e.ModuleResolutionKind.NodeNext,skipLibCheck:!0,noResolve:!0},i=e.createSourceFile(o,t,s.target,!0,pr(e,o)),r=e.createCompilerHost(s,!0),a=r.getSourceFile.bind(r),l=r.readFile.bind(r),d=r.fileExists.bind(r);return r.getSourceFile=(c,f,y,m)=>Qe(c)===o?i:a(c,f,y,m),r.readFile=c=>Qe(c)===o?t:l(c),r.fileExists=c=>Qe(c)===o||d(c),e.createProgram([o],s,r)}function pr(e,t){return/\.tsx$/iu.test(t)?e.ScriptKind.TSX:/\.[cm]?js$/iu.test(t)?e.ScriptKind.JS:/\.jsx$/iu.test(t)?e.ScriptKind.JSX:e.ScriptKind.TS}function mr(e,t,n){let o=[],s=i=>{if(Un(e,i)){let r=t.getLineAndCharacterOfPosition(i.getStart(t)).line,a=t.getLineAndCharacterOfPosition(i.getEnd()).line;(!n||r<=n.endLine&&a>=n.startLine)&&o.push(i)}i.forEachChild(s)};return t.forEachChild(s),o.sort((i,r)=>i.getStart(t)-r.getStart(t))}function Un(e,t){return e.isFunctionLike(t)&&"body"in t&&t.body!==void 0}function fr(e,t){return`callable:${encodeURIComponent(e.fileName)}:${t.getStart(e)}:${t.getEnd()}`}function gr(e,t,n){for(let o=t.parent;o;o=o.parent)if(Un(e,o)&&n.has(o))return n.get(o);return null}function yr(e,t,n,o){let s=new Map,i=oe(e,s,"exit",null),r=t.body,a=i.id;if(r&&e.ts.isBlock(r))a=Ot(e,s,[...r.statements],i.id,{breakTarget:null,continueTarget:null});else if(r){let d=oe(e,s,"statement",r);Z(s,d.id,i.id),a=d.id}let l=oe(e,s,"entry",t);return Z(s,l.id,a),{id:o,node:t,parentId:n,cfg:s,entryId:l.id,exitId:i.id}}function Ot(e,t,n,o,s){let i=o;for(let r=n.length-1;r>=0;r-=1)i=_e(e,t,n[r],i,s);return i}function _e(e,t,n,o,s){let i=e.ts;if(i.isBlock(n))return Ot(e,t,[...n.statements],o,s);if(i.isIfStatement(n)){let a=oe(e,t,"predicate",n.expression),l=_e(e,t,n.thenStatement,o,s),d=n.elseStatement?_e(e,t,n.elseStatement,o,s):o;return Z(t,a.id,l),Z(t,a.id,d),a.id}if(i.isWhileStatement(n)){let a=oe(e,t,"predicate",n.expression),l=_e(e,t,n.statement,a.id,{breakTarget:o,continueTarget:a.id});return Z(t,a.id,l),Z(t,a.id,o),a.id}if(i.isDoStatement(n)){let a=oe(e,t,"predicate",n.expression),l=_e(e,t,n.statement,a.id,{breakTarget:o,continueTarget:a.id});return Z(t,a.id,l),Z(t,a.id,o),l}if(i.isForStatement(n)){let a=oe(e,t,"predicate",n.condition??n),l=n.incrementor?oe(e,t,"statement",n.incrementor):null;l&&Z(t,l.id,a.id);let d=l?.id??a.id,c=_e(e,t,n.statement,d,{breakTarget:o,continueTarget:d});if(Z(t,a.id,c),n.condition&&Z(t,a.id,o),!n.initializer)return a.id;let f=oe(e,t,"statement",n.initializer);return Z(t,f.id,a.id),f.id}if(i.isForInStatement(n)||i.isForOfStatement(n)){e.unsupported.add("for-in/for-of iterator assignment is conservatively represented without iterable element flow.");let a=oe(e,t,"predicate",n.expression),l=oe(e,t,"statement",n.initializer),d=_e(e,t,n.statement,a.id,{breakTarget:o,continueTarget:a.id});return Z(t,a.id,l.id),Z(t,a.id,o),Z(t,l.id,d),a.id}if(i.isSwitchStatement(n)){e.unsupported.add("switch fallthrough is represented conservatively; discriminant-to-case value refinement is unsupported.");let a=oe(e,t,"predicate",n.expression),l=o,d=[];for(let c=n.caseBlock.clauses.length-1;c>=0;c-=1){let f=n.caseBlock.clauses[c];l=Ot(e,t,[...f.statements],l,{...s,breakTarget:o}),d.push(l)}for(let c of d)Z(t,a.id,c);return Z(t,a.id,o),a.id}if(i.isReturnStatement(n)||i.isThrowStatement(n)){let a=oe(e,t,"statement",n),l=[...t.values()].find(d=>d.kind==="exit");return Z(t,a.id,l.id),a.id}if(i.isBreakStatement(n)){let a=oe(e,t,"statement",n);return s.breakTarget||e.unsupported.add("A break statement could not be attached to a structured target."),Z(t,a.id,s.breakTarget??o),a.id}if(i.isContinueStatement(n)){let a=oe(e,t,"statement",n);return s.continueTarget||e.unsupported.add("A continue statement could not be attached to a structured target."),Z(t,a.id,s.continueTarget??o),a.id}if(i.isTryStatement(n)){e.unsupported.add("Exceptional control-flow and finally completion are not included in the local compiler CFG.");let a=oe(e,t,"statement",n);return a.invalidatesAllDefinitions=!0,Z(t,a.id,o),a.id}let r=oe(e,t,"statement",n);return Z(t,r.id,o),r.id}function oe(e,t,n,o){let s={id:`cfg:${e.nextCfgId++}`,kind:n,ast:o,successors:new Set,predecessors:new Set,definitions:[],uses:[],displayPoint:null,invalidatesAllDefinitions:!1};return t.set(s.id,s),s}function Z(e,t,n){e.get(t).successors.add(n),e.get(n).predecessors.add(t)}function Sr(e,t){let n=t.cfg.get(t.entryId);for(let o of t.node.parameters){let s=Oe(e,o.name);if(!s){e.unsupported.add("Destructured parameter definition-use is not implemented.");continue}n.definitions.push({point:Ke(e,s.node,"parameter-definition",s.symbolKey,s.name,t.id),rhsUseIds:[]})}for(let o of t.cfg.values())!o.ast||o.kind==="entry"||o.kind==="exit"||(o.kind==="predicate"&&(o.displayPoint=Ke(e,o.ast,"predicate",null,"predicate",t.id)),br(e,t,o,o.ast),!o.displayPoint&&o.definitions.length===0&&o.uses.length===0&&(o.displayPoint=Ke(e,o.ast,"statement",null,Mr(e,o.ast),t.id)))}function br(e,t,n,o){let s=e.ts;if(s.isTryStatement(o))return;let i=r=>{if(!(r!==o&&s.isFunctionLike(r))){if(s.isVariableDeclaration(r)){let a=r.initializer?ut(e,t.id,r.initializer,n):[];n.uses.push(...a);let l=Oe(e,r.name);l?n.definitions.push({point:Ke(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:a.map(d=>d.point.id)}):(n.invalidatesAllDefinitions=!0,e.unsupported.add("Destructured variable reaching definitions are not implemented."));return}if(s.isBinaryExpression(r)&&Gn(s,r.operatorToken.kind)){let a=ut(e,t.id,r.right,n);r.operatorToken.kind!==s.SyntaxKind.EqualsToken&&a.push(...ut(e,t.id,r.left,n)),n.uses.push(...a);let l=Oe(e,r.left);l?n.definitions.push({point:Ke(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:a.map(d=>d.point.id)}):(n.invalidatesAllDefinitions=!0,e.unsupported.add("Dynamic or destructured assignment targets are not included in reaching definitions."));return}if((s.isPrefixUnaryExpression(r)||s.isPostfixUnaryExpression(r))&&(r.operator===s.SyntaxKind.PlusPlusToken||r.operator===s.SyntaxKind.MinusMinusToken)){let a=ut(e,t.id,r.operand,n);n.uses.push(...a);let l=Oe(e,r.operand);l&&n.definitions.push({point:Ke(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:a.map(d=>d.point.id)});return}if(!(s.isFunctionDeclaration(r)||s.isClassDeclaration(r)||s.isInterfaceDeclaration(r))){if(Wn(e,r)){let a=Hn(e,t.id,r);a&&n.uses.push(a),s.isPropertyAccessExpression(r)&&i(r.expression);return}r.forEachChild(i)}}};i(o),n.uses=Vn(n.uses)}function ut(e,t,n,o){let s=[],i=r=>{if(!e.ts.isFunctionLike(r)){if(e.ts.isBinaryExpression(r)&&Gn(e.ts,r.operatorToken.kind)){o.invalidatesAllDefinitions=!0,e.unsupported.add("Nested assignment expressions are not included in ordered local definition-use flow."),r.operatorToken.kind!==e.ts.SyntaxKind.EqualsToken&&i(r.left),i(r.right);return}if(Wn(e,r)){let a=Hn(e,t,r);a&&s.push(a),e.ts.isPropertyAccessExpression(r)&&i(r.expression);return}r.forEachChild(i)}};return i(n),Vn(s)}function Wn(e,t){if(e.ts.isPropertyAccessExpression(t))return!0;if(!e.ts.isIdentifier(t))return!1;let n=t.parent;return!(e.ts.isPropertyAccessExpression(n)&&n.name===t||"name"in n&&n.name===t&&hr(e.ts,n)||e.ts.isPropertyAssignment(n)&&n.name===t||e.ts.isBindingElement(n)&&n.propertyName===t||e.ts.isLabeledStatement(n)||e.ts.isBreakOrContinueStatement(n)||xr(e.ts,t))}function hr(e,t){return e.isVariableDeclaration(t)||e.isParameter(t)||e.isFunctionDeclaration(t)||e.isFunctionExpression(t)||e.isClassDeclaration(t)||e.isMethodDeclaration(t)||e.isPropertyDeclaration(t)||e.isInterfaceDeclaration(t)||e.isTypeAliasDeclaration(t)||e.isImportSpecifier(t)||e.isImportClause(t)||e.isNamespaceImport(t)}function xr(e,t){for(let n=t.parent;n;n=n.parent){if(e.isExpression(n)||e.isStatement(n)||e.isSourceFile(n))return!1;if(e.isTypeNode(n))return!0}return!1}function Hn(e,t,n){let o=Oe(e,n);return o?{point:Ke(e,o.node,"use",o.symbolKey,o.name,t),property:e.ts.isPropertyAccessExpression(n)}:null}function Oe(e,t){let n=e.ts;if(n.isIdentifier(t)){let o=qn(e,t);return o?{node:t,symbolKey:o,name:t.text}:null}if(n.isPropertyAccessExpression(t)){let o=qn(e,t.name);return o?{node:t,symbolKey:o,name:t.getText(e.sourceFile)}:null}return n.isParenthesizedExpression(t)||n.isAsExpression(t)||n.isTypeAssertionExpression(t)||n.isNonNullExpression(t)?Oe(e,t.expression):((n.isArrayLiteralExpression(t)||n.isObjectLiteralExpression(t))&&e.unsupported.add("Heap aggregate identity and destructured assignment are not included in local points-to flow."),null)}function qn(e,t){let n=e.checker.getSymbolAtLocation(t);if(!n)return null;if((n.flags&e.ts.SymbolFlags.Alias)!==0)try{n=e.checker.getAliasedSymbol(n)}catch{}let o=n.valueDeclaration??n.declarations?.[0];return o?`symbol:${encodeURIComponent(o.getSourceFile().fileName)}:${o.getStart()}:${n.getName()}`:`symbol:${n.getName()}`}function Ke(e,t,n,o,s,i){let r=t.getStart(e.sourceFile),a=t.getEnd(),l=e.sourceFile.getLineAndCharacterOfPosition(r),d=`flow-point:${encodeURIComponent(e.sourceFile.fileName)}:${r}:${a}:${n}:${encodeURIComponent(o??s)}`,c=e.points.get(d);if(c)return c;let f={id:d,kind:n,name:s,symbolKey:o,callableId:i,start:r,end:a,line:l.line,column:l.character,node:t};return e.points.set(d,f),f}function vr(e,t){let n=[...t.cfg.values()].flatMap(l=>l.definitions),o=new Map(n.map(l=>[l.point.id,l])),s=Ir(n),i=new Map,r=new Map;for(let l of t.cfg.values())i.set(l.id,new Set),r.set(l.id,new Set);let a=!0;for(;a;){a=!1;for(let l of t.cfg.values()){let d=Tr([...l.predecessors].map(y=>r.get(y))),c=new Set(d);l.invalidatesAllDefinitions&&c.clear();let f=Er(l.definitions);for(let y of f){for(let m of s.get(y.point.symbolKey)??[])c.delete(m.point.id);c.add(y.point.id)}Kt(i.get(l.id),d)||(i.set(l.id,d),a=!0),Kt(r.get(l.id),c)||(r.set(l.id,c),a=!0)}}for(let l of t.cfg.values()){let d=i.get(l.id);for(let c of l.uses){let f=l.definitions.filter(m=>m.point.symbolKey===c.point.symbolKey&&m.point.start<c.point.start&&!m.rhsUseIds.includes(c.point.id)).sort((m,v)=>v.point.start-m.point.start)[0],y=f?[f.point.id]:d;for(let m of y){let v=o.get(m);v.point.symbolKey===c.point.symbolKey&&Je(e,"reaching-definition",v.point.id,c.point.id,"exact","A CFG path reaches this use without an intervening definition.")}}for(let c of l.definitions)for(let f of c.rhsUseIds)Je(e,"value-source",f,c.point.id,"exact","This right-hand-side use supplies the new definition.")}}function Ir(e){let t=new Map;for(let n of e){if(!n.point.symbolKey)continue;let o=t.get(n.point.symbolKey)??[];o.push(n),t.set(n.point.symbolKey,o)}return t}function Er(e){let t=new Map;for(let n of e)n.point.symbolKey&&t.set(n.point.symbolKey,n);return[...t.values()]}function Lr(e,t){let n=wr(t);for(let o of t.cfg.values()){if(o.successors.size<2||!o.displayPoint)continue;let s=n.get(o.id);for(let i of o.successors)for(let r of n.get(i)??[]){if(s.has(r)||r===t.exitId)continue;let a=t.cfg.get(r),l=[...a.definitions.map(d=>d.point),...a.uses.map(d=>d.point),...a.displayPoint?[a.displayPoint]:[]];for(let d of Rr(l))Je(e,"control-dependence",o.displayPoint.id,d.id,"exact","The target postdominates a branch successor but does not postdominate the predicate.")}}}function wr(e){let t=[...e.cfg.keys()],n=new Set(t),o=new Map;for(let i of t)o.set(i,i===e.exitId?new Set([i]):new Set(n));let s=!0;for(;s;){s=!1;for(let i of e.cfg.values()){if(i.id===e.exitId)continue;let r=[...i.successors].map(l=>o.get(l)),a=new Set([i.id,...Fr(r)]);Kt(o.get(i.id),a)||(o.set(i.id,a),s=!0)}}return o}function Cr(e,t){let n=new Map(t.map(r=>[r.id,r.parentId])),o=t.flatMap(r=>[...r.cfg.values()].flatMap(a=>a.definitions.map(l=>l.point))),s=new Map;for(let r of o){if(!r.symbolKey)continue;let a=s.get(r.symbolKey)??[];a.push(r),s.set(r.symbolKey,a)}let i=new Set([...e.edges.values()].filter(r=>r.kind==="reaching-definition").map(r=>r.toPointId));for(let r of t)for(let a of[...r.cfg.values()].flatMap(l=>l.uses)){if(!a.point.symbolKey||i.has(a.point.id))continue;let l=s.get(a.point.symbolKey)??[];for(let d of l)Nr(d.callableId,a.point.callableId,n)?Je(e,"closure-capture",d.id,a.point.id,"candidate","Compiler identity proves the captured binding, but invocation order can select among outer definitions."):a.property&&Je(e,"field-definition-to-use",d.id,a.point.id,"candidate","Compiler identity matches the field; cross-callable receiver and execution order remain unresolved.")}[...e.edges.values()].some(r=>r.kind==="closure-capture")&&e.unsupported.add("Closure capture identity is known, but invocation order and intervening writes remain candidate flow."),[...e.edges.values()].some(r=>r.kind==="field-definition-to-use")&&e.unsupported.add("Cross-callable field flow lacks receiver points-to and invocation-order analysis.")}function Nr(e,t,n){for(let o=n.get(t)??null;o;o=n.get(o)??null)if(o===e)return!0;return!1}function Je(e,t,n,o,s,i){let r=`local-flow-edge:${t}:${encodeURIComponent(n)}:${encodeURIComponent(o)}`;e.edges.set(r,{id:r,kind:t,fromPointId:n,toPointId:o,strength:s,reason:i})}function Gn(e,t){return t>=e.SyntaxKind.FirstAssignment&&t<=e.SyntaxKind.LastAssignment}function Mr(e,t){let n=t.getText(e.sourceFile).replace(/\s+/gu," ").trim();return n.length>80?`${n.slice(0,77)}...`:n||e.ts.SyntaxKind[t.kind]||"statement"}function Vn(e){return[...new Map(e.map(t=>[t.point.id,t])).values()]}function Rr(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function Tr(e){return new Set(e.flatMap(t=>[...t]))}function Fr(e){return e.length===0?new Set:new Set([...e[0]].filter(t=>e.slice(1).every(n=>n.has(t))))}function Kt(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function Pr(e,t){return e.start-t.start||e.kind.localeCompare(t.kind)||e.id.localeCompare(t.id)}function _t(e){return{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[e]}}}var $r=fn("typescript-local-flow",{clearGroups:["whole-project","source-file","semantic-provider"]});function jt(e,t,n,o){if(!vn(t))return null;let s=`${t}\0${n}\0${o}`;return $r.get(e,s,()=>{let i=Sn(e,t);return i?zn(i,kr(e.config.projectRoot,t),{startLine:n,endLine:o}):{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[`Current source is unavailable for ${t}.`]}}})}function Ar(e,t=new Map){let n=new Map,o=new Map,s=[];for(let i of e.transfers){if(!e.caller)continue;let r=pt(e.caller,i.callerPosition),a=pt(e.callee,i.calleePosition);Xe(n,r),Xe(n,a),zt(o,e.caller,r),zt(o,e.callee,a);let l=se("edge","data-transfer",i.proof.file,String(i.proof.startLine),String(i.callerPosition),String(i.calleePosition));o.set(l,{id:l,kind:"data-transfer",fromNodeId:r.id,toNodeId:a.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:"argument-to-parameter",attributes:{argumentText:i.argumentText,callerPosition:i.callerPosition,calleePosition:i.calleePosition}}],evidence:[{method:"compiler-callsite-direct-parameter-transfer",strength:"exact",identity:`${e.caller.symbol}:${i.callerPosition} -> ${e.callee.symbol}:${i.calleePosition}`,location:{file:i.proof.file,line:i.proof.startLine,endLine:i.proof.endLine}}]})}return e.unknown.forEach((i,r)=>{let a=pt(e.callee,i.calleePosition);Xe(n,a),zt(o,e.callee,a);let l=t.get(i.calleePosition);if(l&&Hr(l)){Wr(o,n,e,i.calleePosition,i.argumentText,l);return}let d=zr(e,i.calleePosition,i.argumentText);Xe(n,d);let c=se("edge","data-transfer-unsupported",i.proof.file,String(i.proof.startLine),String(i.calleePosition),String(r));o.set(c,{id:c,kind:"data-transfer",fromNodeId:d.id,toNodeId:a.id,directed:!0,disposition:"unsupported",semantics:[{family:"data",subtype:"argument-to-parameter",attributes:{argumentText:i.argumentText,calleePosition:i.calleePosition}}],evidence:[{method:"compiler-callsite-argument-expression",strength:"exact",identity:i.argumentText,location:{file:i.proof.file,line:i.proof.startLine,endLine:i.proof.endLine}}]}),s.push({id:se("frontier","data-transfer",c),kind:"data-transfer",direction:"unresolved",fromNodeIds:[d.id],edgeIds:[c],memberNodeIds:[a.id],memberCount:1,disposition:"unsupported",reason:l?.derivation.rule??i.reason,expansion:null})}),{nodes:[...n.values()],edges:[...o.values()],frontiers:s,blindSpots:[]}}function Qn(e,t,n=[]){let o=Jn(),s=new Map,i=new Set;for(let r of t){if(r.kind!=="call"||!r.fromSymbol||!r.toSymbol||r.line===null)continue;let a=qr(s,e,r.toFile,r.toSymbol);if(!a)continue;let l=Cn(e,a),d=l.sites.filter(L=>L.file===r.fromFile&&L.startLine<=r.line&&L.endLine>=r.line&&L.caller?.symbol===r.fromSymbol);if(d.length!==1){let L=l.unresolved.find(S=>S.file===r.fromFile&&S.line===r.line);L&&o.blindSpots.push(`Parameter flow unresolved at ${r.fromFile}:${r.line+1}: ${L.reason}.`);continue}let c=d[0],f=`${c.file}\0${c.callNode.startIndex}\0${c.callNode.endIndex}\0${a.symbol}`;if(i.has(f))continue;i.add(f);let y=Nn(e,c),m=Be(e,c.file)?.rootNode,v=new Map;if(m)for(let L of y.unknown){let S=wn({db:e,file:c.file,root:m},c.arguments[L.calleePosition]);S&&v.set(L.calleePosition,S)}Yn(o,Ar(y,v)),y.caller&&Kr(c.callNode)&&jr(o,y,c.callNode)}for(let r of n){if(!r.location||!["source-construct","symbol"].includes(r.kind))continue;let a=r.location.endLine??r.location.line,l=jt(e,r.location.file,r.location.line,a);if(l){Yn(o,Dr(r,l.points,l.edges));for(let d of l.coverage.unsupported)o.blindSpots.push(`TypeScript local flow is partial for ${r.location.file}:${r.location.line+1}-${a+1}: ${d} Recover with: codebaseiq inspect --at '${r.location.file}:${r.location.line+1}-${a+1}' --view behavior.`)}}return o.blindSpots=[...new Set(o.blindSpots)].sort(),o}function Dr(e,t,n){let o=Jn(),s=new Map,i=new Map,r=new Map,a=e.location.file;for(let l of t){let d=Br(e,a,l);r.set(l.id,d.id),s.set(d.id,d),_r(i,e,d)}for(let l of n){let d=r.get(l.fromPointId),c=r.get(l.toPointId);if(!d||!c)continue;let f=Or(l),y=se("edge","typescript-local-flow",a,l.id);i.set(y,{id:y,kind:l.kind==="control-dependence"?"control-dependence":"data-transfer",fromNodeId:d,toNodeId:c,directed:!0,disposition:"folded",semantics:[f],evidence:[{method:"typescript-compiler-cfg-reaching-definitions",strength:l.strength,identity:l.reason,location:s.get(d)?.location??e.location}]})}return o.nodes=[...s.values()],o.edges=[...i.values()],o}function Br(e,t,n){return{id:se("local-flow-point",t,String(n.start),String(n.end),n.kind,n.symbolKey??n.name),kind:n.kind==="parameter-definition"||n.kind==="definition"?"local-definition":n.kind==="use"?"local-use":n.kind==="predicate"?"control-predicate":"local-statement",label:n.name,disposition:"folded",location:{file:t,line:n.line,endLine:n.line},anchorIds:[],attributes:{ownerNodeId:e.id,pointKind:n.kind,callableId:n.callableId,symbolKey:n.symbolKey,column:n.column}}}function _r(e,t,n){let o=se("edge","local-flow-owner",t.id,n.id);e.has(o)||e.set(o,{id:o,kind:"local-flow-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains"}],evidence:[{method:"typescript-compiler-local-flow-owner",strength:"exact",identity:t.id,location:n.location}]})}function Or(e){switch(e.kind){case"reaching-definition":return{family:"data",subtype:"definition-to-use"};case"value-source":return{family:"data",subtype:"value-to-definition"};case"closure-capture":return{family:"data",subtype:"closure-capture"};case"field-definition-to-use":return{family:"data",subtype:"field-definition-to-use"};case"control-dependence":return{family:"control",subtype:"control-dependence"}}}function Kr(e){let t=e;for(;t.parent&&["await_expression","yield_expression","parenthesized_expression","as_expression","type_assertion"].includes(t.parent.type);)t=t.parent;return t.parent!==null&&t.parent.type!=="expression_statement"}function jr(e,t,n){if(!t.caller)return;let o={id:se("call-result",t.call.file,String(n.startIndex),String(n.endIndex),t.callee.symbol),kind:"call-result",label:`result of ${t.callee.leaf}`,disposition:"folded",location:{file:t.call.file,line:t.call.startLine,endLine:t.call.endLine},anchorIds:[],attributes:{calleeSymbol:t.callee.symbol,callerSymbol:t.caller.symbol}},s=se("edge","return-to-call-result",t.callee.symbol,o.id),i=se("edge","call-result-owner",t.caller.symbol,o.id);e.nodes.push(o),e.edges.push({id:s,kind:"data-transfer",fromNodeId:Ut(t.callee.symbol),toNodeId:o.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:"return-to-call-result"}],evidence:[{method:"compiler-callsite-used-result",strength:"exact",identity:`${t.callee.symbol} -> ${t.caller.symbol}`,location:o.location}]},{id:i,kind:"call-result-owner",fromNodeId:Ut(t.caller.symbol),toNodeId:o.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains-call-result"}],evidence:[{method:"compiler-call-result-owner",strength:"exact",identity:t.caller.symbol,location:o.location}]})}function Jn(){return{nodes:[],edges:[],frontiers:[],blindSpots:[]}}function Yn(e,t){qt(e.nodes,t.nodes),qt(e.edges,t.edges),qt(e.frontiers,t.frontiers),e.blindSpots.push(...t.blindSpots)}function qt(e,t){let n=new Set(e.map(o=>o.id));for(let o of t)n.has(o.id)||(n.add(o.id),e.push(o))}function qr(e,t,n,o){let s=`${n}\0${o}`,i=e.get(s);if(i!==void 0)return i;let r=Fe(t,n).find(a=>a.symbol===o)??null;return e.set(s,r),r}function pt(e,t){return{id:Yr(e.symbol,t),kind:"parameter",label:`${e.leaf} parameter ${t}`,disposition:"folded",location:{file:e.relativePath,line:e.startLine,endLine:e.endLine},anchorIds:[],attributes:{ownerSymbol:e.symbol,position:t}}}function zr(e,t,n){return{id:se("argument-expression",e.call.file,String(e.call.startLine),String(e.call.endLine),String(t)),kind:"argument-expression",label:n,disposition:"unsupported",location:{file:e.call.file,line:e.call.startLine,endLine:e.call.endLine},anchorIds:[],attributes:{calleeSymbol:e.callee.symbol,position:t}}}function Ur(e,t,n){return{id:se("static-value",e.call.file,String(e.call.startLine),String(e.call.endLine),String(t)),kind:"static-value",label:n.value,disposition:"folded",location:{file:e.call.file,line:e.call.startLine,endLine:e.call.endLine},anchorIds:[],attributes:{value:n.value,precision:n.precision,evidence:n.evidence,termKind:n.term.kind,derivationRule:n.derivation.rule}}}function Wr(e,t,n,o,s,i){let r=Ur(n,o,i),a=pt(n.callee,o);Xe(t,r);let l=se("edge","static-value-transfer",n.call.file,String(n.call.startLine),String(o));e.set(l,{id:l,kind:"data-transfer",fromNodeId:r.id,toNodeId:a.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:Gr(i),attributes:{argumentText:s,calleePosition:o,value:i.value,precision:i.precision,derivationRule:i.derivation.rule}}],evidence:Vr(i,n)})}function Hr(e){return e.derivation.kind!=="heuristic"&&e.precision!=="symbolic"&&e.precision!=="unknown"}function Gr(e){return e.derivation.rule==="bounded-call-return"?"return-to-parameter":e.derivation.rule==="member-constant"||e.term.kind==="property"?"property-to-parameter":"constant-to-parameter"}function Vr(e,t){return(e.derivation.sourceSpans.length>0?e.derivation.sourceSpans:[t.call]).map(o=>({method:`static-value:${e.derivation.rule}`,strength:e.derivation.kind==="direct"?"exact":"derived",identity:e.derivation.inputFactIds.join(",")||e.value,location:{file:o.file,line:o.startLine,endLine:o.endLine}}))}function Xe(e,t){e.has(t.id)||e.set(t.id,t)}function zt(e,t,n){let o=se("edge","parameter-owner",t.symbol,n.id);e.has(o)||e.set(o,{id:o,kind:"parameter-owner",fromNodeId:Ut(t.symbol),toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains"}],evidence:[{method:"compiler-parameter-owner",strength:"exact",identity:t.symbol,location:{file:t.relativePath,line:t.startLine,endLine:t.endLine}}]})}function Yr(e,t){return se("parameter",e,String(t))}function Ut(e){return se("symbol",e)}function se(...e){return e.map(t=>encodeURIComponent(t)).join(":")}function Xn(e,t){let n=new Map,o=new Map,s=new Map,i=new Set;for(let r of t){if(!r.location||!["source-construct","symbol"].includes(r.kind))continue;let a=r.location.endLine??r.location.line,l=Tn(e,r.location.file,r.location.line,a);if(!l){i.add(`Control dependence unavailable for ${r.location.file}:${r.location.line+1}-${a+1}: no supported syntax tree or covering construct.`);continue}for(let d of l.facts){let c=Wt(r,d.controller),f=Wt(r,d.outcome);n.set(c.id,c),n.set(f.id,f),Qr(o,r,c);let y=je("edge","control-dependence",c.id,f.id,d.subtype);o.set(y,{id:y,kind:"control-dependence",fromNodeId:c.id,toNodeId:f.id,directed:!0,disposition:"folded",semantics:[{family:"control",subtype:d.subtype,attributes:{...d.attributes}}],evidence:[{method:"parser-control-dependence",strength:"exact",identity:`${r.location.file}:${d.controller.startLine+1}-${d.outcome.startLine+1}`,location:{file:r.location.file,line:d.controller.startLine,endLine:d.controller.endLine}}]})}for(let d of l.terminals){let c=Wt(r,d);n.set(c.id,c);let f=d.label.startsWith("throw")||d.label.startsWith("raise")?"throw":"return",y=je("edge","control-terminal",r.id,c.id,f);o.set(y,{id:y,kind:"control-terminal",fromNodeId:r.id,toNodeId:c.id,directed:!0,disposition:"folded",semantics:[{family:"control",subtype:f==="throw"?"throws":"returns"}],evidence:[{method:"parser-terminal-statement",strength:"exact",identity:d.label,location:{file:r.location.file,line:d.startLine,endLine:d.endLine}}]})}for(let d of l.unsupported){let c=je("control-unsupported",r.location.file,String(d.startLine),String(d.endLine),d.reason);n.set(c,{id:c,kind:"control-unsupported",label:d.reason,disposition:"unsupported",location:{file:r.location.file,line:d.startLine,endLine:d.endLine},anchorIds:[],attributes:{ownerNodeId:r.id}});let f=je("edge","control-unsupported",r.id,c);o.set(f,{id:f,kind:"control-dependence",fromNodeId:r.id,toNodeId:c,directed:!0,disposition:"unsupported",semantics:[{family:"control",subtype:"unresolved-control-construct"}],evidence:[{method:"parser-control-construct",strength:"exact",identity:d.reason,location:{file:r.location.file,line:d.startLine,endLine:d.endLine}}]});let y=je("frontier","control-dependence",c);s.set(y,{id:y,kind:"control-dependence",direction:"unresolved",fromNodeIds:[r.id],edgeIds:[f],memberNodeIds:[c],memberCount:1,disposition:"unsupported",reason:d.reason,expansion:null})}}return{nodes:[...n.values()],edges:[...o.values()],frontiers:[...s.values()],blindSpots:[...i].sort()}}function Wt(e,t){let n=e.location.file;return{id:je(`control-${t.kind}`,n,String(t.startLine),String(t.endLine),t.label),kind:`control-${t.kind}`,label:t.label,disposition:"folded",location:{file:n,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,constructKind:t.kind,implicit:t.implicit}}}function Qr(e,t,n){let o=je("edge","control-owner",t.id,n.id);e.has(o)||e.set(o,{id:o,kind:"control-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:"contains-control"}],evidence:[{method:"parser-control-owner",strength:"exact",identity:t.id,location:t.location}]})}function je(...e){return e.map(t=>encodeURIComponent(t)).join(":")}var mt=new Set(["arrow_function","constructor_declaration","function_declaration","function_definition","function_expression","generator_function","generator_function_declaration","function_item","lambda","lambda_expression","method","method_declaration","method_definition"]),et=new Set(["block","body","compound_statement","declaration_list","statement_block"]),Jr=new Set(["assignment","assignment_expression","augmented_assignment_expression"]),Gt=new Set(["update_expression"]),no=new Set(["array_access","element_access_expression","subscript_expression"]),oo=new Set(["attribute","field_access","field_expression","member_access_expression","member_expression","selector_expression"]),Xr=new Set(["false","null","null_literal","number","number_literal","string","string_literal","template_string","true"]),Zr=new Set(["call_expression","method_invocation","object_creation_expression"]),ei=new Set(["comment","else_clause","formal_parameters","parameters","type_parameters"]);function ro(e,t,n,o){let s=Be(e,t);if(!s)return null;let i=li(s.rootNode,n,o);if(!i)return null;let r=[],a=[],l=[];return qe(i,d=>{if(Jr.has(d.type)||Gt.has(d.type)||so(d)){let c=ti(d);c?r.push(c):l.push({family:"state",startLine:d.startPosition.row,endLine:d.endPosition.row,reason:`Mutation target ${Ie(d.text)} could not be resolved to an exact source resource.`})}}),qe(i,d=>{if(!et.has(d.type))return;let c=si(d);for(let f=0;f<c.length-1;f+=1)a.push({from:Ze(c[f]),to:Ze(c[f+1]),subtype:"lexical-successor",synchronizationScope:null,attributes:{sameScope:!0,executionConditional:!0}});for(let f=0;f<c.length;f+=1){let y=c[f],m=ci(y).filter(v=>v.type==="await_expression");for(let v of m){let L=tt("event",`await ${Ie(v.text.replace(/^await\s+/u,""))}`,v);a.push({from:Ze(y),to:L,subtype:"awaits-completion",synchronizationScope:null,attributes:{completionRequired:!0}});let S=c[f+1];S&&a.push({from:L,to:Ze(S),subtype:"await-completion-before",synchronizationScope:null,attributes:{continuationOnly:!0}})}}}),qe(i,d=>{if(d.type!=="synchronized_statement")return;let c=d.childForFieldName("object")??d.childForFieldName("condition")??d.namedChildren.find(L=>!et.has(L.type)),f=d.childForFieldName("body")??d.namedChildren.find(L=>et.has(L.type));if(!c||!f){l.push({family:"temporal",startLine:d.startPosition.row,endLine:d.endPosition.row,reason:"Synchronized scope has no structurally resolved monitor or body."});return}let y=Ie(c.text).replace(/^\(|\)$/gu,""),m=tt("lock",y,c),v=di(f).filter(L=>L.parent!==null&&ao(L));for(let L of ai(v))a.push({from:m,to:Ze(L),subtype:"inside-lock-scope",synchronizationScope:y,attributes:{syntaxNative:!0}})}),{mutations:r,temporal:a,unsupported:l}}function ti(e){let t=so(e),n=e.childForFieldName("left")??e.childForFieldName("argument")??(t?e.namedChildren.at(-1)??null:e.namedChildren[0]??null);if(!n)return null;let o=ni(n);if(!o)return null;let s=t?"delete":Gt.has(e.type)||!ii(e,n).startsWith("=")?"update":"assign",i=t||Gt.has(e.type)?null:e.childForFieldName("right");return{event:tt("event",Ie(e.text),e),resource:{kind:"resource",label:o.name,startLine:n.startPosition.row,endLine:n.endPosition.row},operation:s,durabilityClass:"in-memory",recordIdentity:o.recordIdentity,value:i?tt("value",Ie(i.text),i):null,dataSubtype:i?oi(i,e):null}}function ni(e){if(no.has(e.type)){let t=e.childForFieldName("object")??e.childForFieldName("array")??e.namedChildren[0]??null,n=e.childForFieldName("index")??e.childForFieldName("subscript")??e.namedChildren[1]??null;return!t||!n?null:{name:`${Ie(t.text)}[]`,recordIdentity:Ie(n.text)}}return oo.has(e.type)?{name:Ie(e.text),recordIdentity:null}:/^(?:identifier|property_identifier|field_identifier)$/u.test(e.type)?{name:Ie(e.text),recordIdentity:null}:null}function oi(e,t){return Xr.has(e.type)||/(?:integer|float|decimal|boolean|character)_literal$/u.test(e.type)?"constant-to-state":Zr.has(e.type)?"return-to-state":oo.has(e.type)||no.has(e.type)?"property-to-state":/identifier$/u.test(e.type)?ri(e.text,t)?"captured-value-to-state":"value-to-state":"expression-to-state"}function ri(e,t){let n=Ht(t.parent);if(!n||Zn(n,e))return!1;let o=Ht(n.parent);for(;o;){if(Zn(o,e))return!0;o=Ht(o.parent)}return!1}function Ht(e){let t=e;for(;t;){if(mt.has(t.type))return t;t=t.parent}return null}function Zn(e,t){let n=e.childForFieldName("parameters")??e.namedChildren.find(i=>["formal_parameters","parameters"].includes(i.type));if(n&&eo(n,t))return!0;let o=e.childForFieldName("body")??e.namedChildren.find(i=>et.has(i.type));if(!o)return!1;let s=!1;return io(o,e,i=>{if(s||!/(?:declarator|declaration|parameter)$/u.test(i.type))return;let r=i.childForFieldName("name")??i.childForFieldName("pattern")??i.namedChildren[0];r&&eo(r,t)&&(s=!0)}),s}function eo(e,t){let n=!1;return qe(e,o=>{/identifier$/u.test(o.type)&&o.text===t&&(n=!0)}),n}function io(e,t,n){n(e);for(let o of e.namedChildren)o!==t&&mt.has(o.type)||io(o,t,n)}function ii(e,t){let n=e.childForFieldName("right"),o=Math.max(0,t.endIndex-e.startIndex),s=n?Math.max(o,n.startIndex-e.startIndex):e.text.length;return e.text.slice(o,s).trim()}function so(e){return(e.type==="delete_expression"||e.type==="unary_expression")&&/^delete\b/u.test(e.text.trim())}function si(e){return e.namedChildren.filter(t=>ao(t))}function ao(e){return ei.has(e.type)||et.has(e.type)?!1:/(?:statement|declaration)$/u.test(e.type)||e.type==="expression_statement"||e.type==="local_variable_declaration"}function ai(e){let t=new Set(e);return e.filter(n=>{let o=n.parent;for(;o;){if(t.has(o))return!1;o=o.parent}return!0})}function Ze(e){return tt("event",Ie(e.text),e)}function tt(e,t,n){return{kind:e,label:t,startLine:n.startPosition.row,endLine:n.endPosition.row}}function li(e,t,n){let o=[];return qe(e,i=>{i.startPosition.row<=t&&i.endPosition.row>=n&&o.push(i)}),o.filter(i=>mt.has(i.type)).sort(to)[0]??o.sort(to)[0]??null}function to(e,t){return e.endIndex-e.startIndex-(t.endIndex-t.startIndex)||e.startIndex-t.startIndex}function di(e){let t=[];return qe(e,n=>t.push(n)),t}function ci(e){let t=[],n=o=>{t.push(o);for(let s of o.namedChildren)s!==e&&mt.has(s.type)||n(s)};return n(e),t}function qe(e,t){t(e);for(let n of e.namedChildren)qe(n,t)}function Ie(e){return e.trim().replace(/\s+/gu," ")}function uo(e,t,n=[]){let o=new Map,s=new Map,i=new Map,r=new Set;for(let a of t){if(!a.location||!["source-construct","symbol"].includes(a.kind))continue;let l=a.location.endLine??a.location.line,d=ro(e,a.location.file,a.location.line,l);if(!d){r.add(`State and temporal analysis unavailable for ${a.location.file}:${a.location.line+1}-${l+1}: no supported syntax tree or covering construct.`);continue}for(let c of d.mutations){let f=gt(a,c.event),y=yi(a,c.resource,c.durabilityClass);if(o.set(f.id,f),o.set(y.id,y),yt(s,a,f,"contains-state-effect"),St(s,{kind:"state-resource",from:f,to:y,semantics:[{family:"state",subtype:c.operation==="delete"?"deletes-resource":"writes-resource",attributes:{operation:c.operation,durabilityClass:c.durabilityClass,resource:c.resource.label,recordIdentity:c.recordIdentity,transactionMembership:"unknown"}}],method:"parser-state-mutation",identity:c.event.label}),c.value&&c.dataSubtype){let m=gt(a,c.value);o.set(m.id,m),St(s,{kind:"data-to-state",from:m,to:y,semantics:[{family:"data",subtype:c.dataSubtype,attributes:{operation:c.operation,resource:c.resource.label,recordIdentity:c.recordIdentity,value:c.value.label}}],method:"parser-assignment-value",identity:`${c.value.label} -> ${c.resource.label}`})}}for(let c of d.temporal){let f=gt(a,c.from),y=gt(a,c.to);o.set(f.id,f),o.set(y.id,y),yt(s,a,f,c.from.kind==="lock"?"contains-lock-scope":"contains-event"),yt(s,a,y,"contains-event"),St(s,{kind:"temporal-order",from:f,to:y,semantics:[{family:"temporal",subtype:c.subtype,context:c.synchronizationScope?{synchronizationScope:c.synchronizationScope}:void 0,attributes:{...c.attributes}}],method:c.subtype==="inside-lock-scope"?"parser-synchronized-scope":"parser-program-order",identity:`${c.from.label} -> ${c.to.label}`})}for(let c of d.unsupported){let f=Re(`${c.family}-unsupported`,a.location.file,String(c.startLine),String(c.endLine),c.reason);o.set(f,{id:f,kind:`${c.family}-unsupported`,label:c.reason,disposition:"unsupported",location:{file:a.location.file,line:c.startLine,endLine:c.endLine},anchorIds:[],attributes:{ownerNodeId:a.id}});let y=Re("edge",`${c.family}-unsupported`,a.id,f);s.set(y,{id:y,kind:`${c.family}-unsupported`,fromNodeId:a.id,toNodeId:f,directed:!0,disposition:"unsupported",semantics:[{family:c.family,subtype:`unresolved-${c.family}-construct`}],evidence:[{method:`parser-${c.family}-construct`,strength:"exact",identity:c.reason,location:{file:a.location.file,line:c.startLine,endLine:c.endLine}}]});let m=Re("frontier",c.family,f);i.set(m,{id:m,kind:c.family,direction:"unresolved",fromNodeIds:[a.id],edgeIds:[y],memberNodeIds:[f],memberCount:1,disposition:"unsupported",reason:c.reason,expansion:null})}}for(let a of t.filter(l=>l.kind==="runtime-boundary-participant")){let l=ft(a,"protocol"),d=ft(a,"action"),c=ft(a,"address")??a.label;!l||!d||!co(l,d)||lo(o,s,a,{observationId:a.id,action:d,strength:"exact",file:a.location?.file??"",line:a.location?.line??0,address:c,protocol:l,role:ft(a,"role")??void 0,resolution:"locally-linked"})}for(let a of n){if(!a.protocol||!co(a.protocol,a.action))continue;let l=fi(t,a.file,a.line,a.ownerShortName??null);if(!l){r.add(`State observation ${a.observationId} at ${a.file}:${a.line+1} has no materialized owner node.`);continue}lo(o,s,l,a)}return{nodes:[...o.values()],edges:[...s.values()],frontiers:[...i.values()],blindSpots:[...r].sort()}}function lo(e,t,n,o){let s=pi(o),r={id:Re("runtime-state-event",o.observationId),kind:"runtime-state-event",label:`${o.action} ${s}`,disposition:"folded",location:{file:o.file,line:o.line},anchorIds:[],attributes:{action:o.action,protocol:o.protocol??null,modality:o.modality??null,resolution:o.resolution??null}},a=o.protocol==="database"?"external-durable-intent":"external",l={id:Re("runtime-state-resource",o.protocol??"unknown",s),kind:"runtime-state-resource",label:s,disposition:"folded",location:{file:o.file,line:o.line},anchorIds:[],attributes:{protocol:o.protocol??null,durabilityClass:a}};e.set(r.id,r),e.set(l.id,l),yt(t,n,r,"contains-runtime-state-effect");let d=ui(o.action);St(t,{kind:"runtime-state-resource",from:r,to:l,semantics:[{family:"state",subtype:d,context:{crossesRuntimeBoundary:!0,protocol:o.protocol},attributes:{operation:o.action,durabilityClass:a,resource:s,recordIdentity:mi(o),modality:o.modality??null,resolution:o.resolution??null,transactionMembership:"unknown",commitState:o.protocol==="database"?"unknown":null}}],method:`runtime-boundary-${o.strength}`,identity:o.observationId})}function ui(e){return e==="database.read"?"reads-resource":e==="queue.send"?"enqueues-resource":e==="queue.consume"?"consumes-resource":"writes-resource"}function pi(e){return(e.keyParts?.find(n=>["address","resource"].includes(n.name))?.value??e.address)||e.observationId}function mi(e){return e.keyParts?.find(n=>/^(?:id|key|record)$/u.test(n.name))?.value??null}function co(e,t){return e==="database"&&["database.read","database.write"].includes(t)||e==="queue"&&["queue.consume","queue.send"].includes(t)}function ft(e,t){let n=e.attributes[t];return typeof n=="string"?n:null}function fi(e,t,n,o){let s=e.filter(r=>r.location?.file===t&&["source-construct","symbol"].includes(r.kind)),i=s.filter(r=>r.location.line<=n&&(r.location.endLine??r.location.line)>=n).sort(gi)[0];if(i)return i;if(o){let r=s.find(a=>a.label===o||a.label.endsWith(`.${o}`)||a.label.includes(o));if(r)return r}return s.length===1?s[0]:null}function gi(e,t){let n=(e.location?.endLine??e.location?.line??0)-(e.location?.line??0),o=(t.location?.endLine??t.location?.line??0)-(t.location?.line??0);return n-o}function gt(e,t){let n=e.location.file;return{id:Re(`program-${t.kind}`,n,String(t.startLine),String(t.endLine),t.label),kind:`program-${t.kind}`,label:t.label,disposition:"folded",location:{file:n,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,constructKind:t.kind}}}function yi(e,t,n){let o=e.location.file;return{id:Re("program-resource",o,e.id,t.label,n),kind:"program-resource",label:t.label,disposition:"folded",location:{file:o,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,durabilityClass:n}}}function yt(e,t,n,o){let s=Re("edge","program-owner",t.id,n.id,o);e.has(s)||e.set(s,{id:s,kind:"program-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:o}],evidence:[{method:"parser-program-owner",strength:"exact",identity:t.id,location:n.location}]})}function St(e,t){let n=Re("edge",t.kind,t.from.id,t.to.id,t.semantics[0].subtype);e.set(n,{id:n,kind:t.kind,fromNodeId:t.from.id,toNodeId:t.to.id,directed:!0,disposition:"folded",semantics:t.semantics,evidence:[{method:t.method,strength:"exact",identity:t.identity,location:t.from.location}]})}function Re(...e){return e.map(t=>encodeURIComponent(t)).join(":")}var Si=new Set(["control","data","state","temporal"]),bt=new Set(["contains-control","contains-event","contains-lock-scope","contains-state-effect","contains-runtime-state-effect","contains","owns-parameter","owns-runtime-observation"]),go=new Set(["discriminator-dispatch","result-callback","returns","runtime-handoff","throws"]);function yo(e,t={}){let n=new Map(e.nodes.map(M=>[M.id,M])),o=Li(e.nodes,t.focusLocations),s=wi(e.edges,t.focusLocations),i=Ci(e.edges,s),r=new Set(e.paths.flatMap(M=>M.edgeIds)),a=Te(e.anchors.filter(M=>M.status==="matched").flatMap(M=>M.nodeIds)),d=e.edges.filter(fo).filter(M=>bi(M,o,s,r)),c=d.filter(M=>Ii(M,o,s,i,n,r)),f=po(a,c,"forward"),y=vi(f,c),m=po(y,c,"backward"),v=new Set([...f].filter(M=>m.has(M)));for(let M of a)v.add(M);let L=new Set(c.filter(M=>v.has(M.fromNodeId)&&v.has(M.toNodeId)).map(M=>M.id)),S=new Set(v),k=new Set(L);hi(d,S,k,o,s);let q=e.frontiers.filter(M=>Mi(M,S)),$=Te(q.filter(M=>M.disposition==="unsupported").map(M=>M.id)),P=Te(e.edges.filter(M=>!fo(M)&&bo(M)&&Ni(M,S)).map(M=>M.id)),H=Te(q.map(M=>M.id)),B=[];a.length===0&&B.push("No matched anchor node starts the corridor."),y.length===0&&B.push("No proved mechanical outcome is reachable from a matched anchor."),$.length>0&&B.push(`${$.length} unsupported frontier(s) touch the protected corridor.`),P.length>0&&B.push(`${P.length} candidate or unknown edge(s) touch the protected corridor.`);let j=B.length===0?"complete":"incomplete";return{schemaVersion:1,status:j,startNodeIds:a,outcomeNodeIds:y,baseNodeIds:Te([...v]),baseEdgeIds:Te([...L]),nodeIds:Te([...S]),edgeIds:Te([...k]),accountedFrontierIds:H,unresolvedFrontierIds:$,unresolvedEdgeIds:P,coverage:{protectedNodes:S.size,protectedEdges:k.size,baseNodes:v.size,baseEdges:L.size,accountedFrontiers:H.length,unresolvedFrontiers:$.length,unresolvedEdges:P.length},explanation:j==="complete"?"Every proved anchor-to-outcome path is closed over its material causal facts within reported coverage.":B.join(" ")}}function bi(e,t,n,o){return t===null||e.disposition==="emitted"||o.has(e.id)||n?.has(e.id)===!0?!0:(e.semantics??[]).some(s=>{if(s.family==="identity"&&bt.has(s.subtype))return t.has(e.toNodeId);if(s.family==="contract")return t.has(e.fromNodeId)&&t.has(e.toNodeId);if(s.family==="state")return t.has(e.fromNodeId);if(s.family==="data"||s.family==="temporal")return t.has(e.fromNodeId)||t.has(e.toNodeId);if(s.family==="control"){if(ho(s))return t.has(e.fromNodeId);if(["returns","throws"].includes(s.subtype))return t.has(e.toNodeId);if(s.subtype==="completion-callback")return t.has(e.fromNodeId)||t.has(e.toNodeId)}return!1})}function hi(e,t,n,o,s){let i=!0;for(;i;){i=!1;for(let r of e)xi(r,t,o,s)&&(n.has(r.id)||(n.add(r.id),i=!0),t.has(r.fromNodeId)||(t.add(r.fromNodeId),i=!0),t.has(r.toNodeId)||(t.add(r.toNodeId),i=!0))}}function xi(e,t,n,o){let s=t.has(e.fromNodeId),i=t.has(e.toNodeId);return!s&&!i?!1:(e.semantics??[]).some(r=>r.family==="identity"?bt.has(r.subtype)&&(i||n===null||n.has(e.toNodeId)):r.family==="contract"?!0:r.family==="state"?s&&(n===null||n.has(e.fromNodeId)):r.family==="temporal"?r.subtype==="lexical-successor"?s&&i:!0:r.family==="data"?i&&(s||n===null||n.has(e.fromNodeId)||o?.has(e.id)===!0):r.family==="control"?So(r)||["returns","throws"].includes(r.subtype)&&!i&&n!==null&&!n.has(e.toNodeId)?!1:go.has(r.subtype)||ho(r)||r.subtype==="completion-callback":!1)}function vi(e,t){let n=new Set,o=new Map,s=new Map;for(let i of t)!e.has(i.fromNodeId)||!e.has(i.toNodeId)||(o.set(i.fromNodeId,(o.get(i.fromNodeId)??0)+1),s.set(i.toNodeId,(s.get(i.toNodeId)??0)+1),(i.semantics??[]).some(r=>r.family==="state"||r.family==="control"&&go.has(r.subtype))&&n.add(i.toNodeId));for(let i of e)(s.get(i)??0)>0&&(o.get(i)??0)===0&&n.add(i);return Te([...n])}function po(e,t,n){let o=new Map;for(let r of t){let a=n==="forward"?r.fromNodeId:r.toNodeId,l=n==="forward"?r.toNodeId:r.fromNodeId,d=o.get(a)??[];d.push(l),o.set(a,d)}let s=new Set(e),i=[...e];for(;i.length>0;){let r=i.shift();for(let a of o.get(r)??[])s.has(a)||(s.add(a),i.push(a))}return s}function Ii(e,t,n,o,s,i){return(e.semantics??[]).some(r=>e.disposition==="emitted"||i.has(e.id)?!0:r.family==="identity"&&bt.has(r.subtype)?t===null||t.has(e.toNodeId)||o?.has(e.toNodeId)===!0:!Si.has(r.family)||So(r)?!1:r.family==="control"&&["returns","throws"].includes(r.subtype)&&t!==null?t.has(e.toNodeId):t===null?!0:r.family==="state"?t.has(e.fromNodeId):r.family==="data"?t.has(e.fromNodeId)||t.has(e.toNodeId)||n?.has(e.id)===!0:r.family==="temporal"?r.subtype==="lexical-successor"?t.has(e.fromNodeId)&&t.has(e.toNodeId):t.has(e.fromNodeId)||t.has(e.toNodeId):r.family==="control"?Ei(e,s)&&(t.has(e.fromNodeId)||t.has(e.toNodeId)):!1)}function So(e){return e.family==="control"&&["call","discriminator-dispatch","result-callback","runtime-handoff"].includes(e.subtype)}function Ei(e,t){let n=t.get(e.fromNodeId),o=t.get(e.toNodeId);if(!n||!o)return!1;let s=mo(n,"ownerNodeId")??(n.kind==="symbol"?n.id:null),i=mo(o,"ownerNodeId")??(o.kind==="symbol"?o.id:null);return s!==null&&s===i}function Li(e,t){if(!t)return null;let n=new Map;for(let o of t){let s=n.get(o.file)??[];s.push(o.line),n.set(o.file,s)}return new Set(e.filter(o=>{if(!o.location||o.kind==="parameter")return!1;let s=n.get(o.location.file)??[],i=o.location.endLine??o.location.line;return s.some(r=>r>=o.location.line&&r<=i)}).map(o=>o.id))}function wi(e,t){if(!t)return null;let n=new Map;for(let o of t){let s=n.get(o.file)??[];s.push(o.line),n.set(o.file,s)}return new Set(e.filter(o=>o.evidence.some(s=>{if(!s.location)return!1;let i=n.get(s.location.file)??[],r=s.location.endLine??s.location.line;return i.some(a=>a>=s.location.line&&a<=r)})).map(o=>o.id))}function Ci(e,t){return t===null?null:new Set(e.filter(n=>t.has(n.id)).flatMap(n=>[n.fromNodeId,n.toNodeId]))}function mo(e,t){let n=e.attributes[t];return typeof n=="string"?n:null}function fo(e){return e.disposition==="excluded"||e.disposition==="unsupported"||!bo(e)?!1:e.evidence.some(t=>t.strength==="exact"||t.strength==="derived")}function bo(e){return(e.semantics??[]).some(t=>t.family!=="identity"||bt.has(t.subtype))}function ho(e){return e.subtype.startsWith("predicate-")||e.subtype.startsWith("loop-")||e.subtype.startsWith("exception-")||e.subtype.startsWith("finally-")||e.subtype.startsWith("handler-")}function Ni(e,t){return t.has(e.fromNodeId)||t.has(e.toNodeId)}function Mi(e,t){return[...e.fromNodeIds,...e.memberNodeIds].some(n=>t.has(n))}function Te(e){return[...new Set(e)].sort()}import{createHash as Ri}from"crypto";var ht=["identity","contract","control","data","state","temporal"],Ti=new Set(ht);function vt(e){let t=We(e.anchors,"anchor"),n=We(e.nodes,"node"),o=We(e.edges,"edge"),s=We(e.paths??[],"path"),i=We(e.frontiers??[],"frontier"),r=new Set(t.map(m=>m.id)),a=new Set(n.map(m=>m.id)),l=new Set(o.map(m=>m.id)),d=e.routeCatalog?{...e.routeCatalog,routes:We(e.routeCatalog.routes,"route"),selectedRouteIds:de(e.routeCatalog.selectedRouteIds)}:void 0;for(let m of t)me(`anchor ${m.id}`,[...m.nodeIds,...m.candidateNodeIds],a,"node");for(let m of n)me(`node ${m.id}`,m.anchorIds,r,"anchor");for(let m of o){if(me(`edge ${m.id}`,[m.fromNodeId,m.toNodeId],a,"node"),m.evidence.length===0)throw new Error(`Exploration edge ${m.id} has no evidence source.`);ki(m)}for(let m of s)me(`path ${m.id}`,[m.fromAnchorId,m.toAnchorId],r,"anchor"),me(`path ${m.id}`,m.nodeIds,a,"node"),me(`path ${m.id}`,m.edgeIds,l,"edge");for(let m of i)if(me(`frontier ${m.id}`,m.fromNodeIds,a,"node"),me(`frontier ${m.id}`,m.edgeIds,l,"edge"),me(`frontier ${m.id}`,m.memberNodeIds,a,"node"),m.memberCount!==m.memberNodeIds.length)throw new Error(`Exploration frontier ${m.id} reports ${m.memberCount} member(s) but identifies ${m.memberNodeIds.length}.`);for(let m of d?.routes??[])me(`route ${m.id}`,m.nodeIds,a,"node"),me(`route ${m.id}`,m.edgeIds,l,"edge"),me(`route ${m.id}`,[m.anchorNodeId,m.endpointNodeId],a,"node");d&&me("route catalog selection",d.selectedRouteIds,new Set(d.routes.map(m=>m.id)),"route");let c=de(e.incompleteReasons??[]),f=c.length===0?"accounted":"incomplete",y=t.reduce((m,v)=>m+v.omittedCandidates,0);return{schemaVersion:1,anchors:t,nodes:n,edges:o,paths:s,frontiers:i,coverage:{status:f,scope:e.scope,nodes:Mo(n),edges:Mo(o),matchedAnchors:t.filter(m=>m.status==="matched").length,ambiguousAnchors:t.filter(m=>m.status==="ambiguous").length,missingAnchors:t.filter(m=>m.status==="missing").length,omittedCandidates:y,frontierGroups:i.length,programEdges:Pi(o),blindSpots:de(e.blindSpots??[]),explanation:f==="accounted"?"Every node and edge discovered within the declared query scope is emitted, folded with recoverable identity, explicitly excluded, or reported unsupported.":`The declared query scope is not fully accounted for: ${c.join("; ")}`},completion:Di(f,s,e.scope),...d?{routeCatalog:d}:{}}}function Fi(e){return e.flatMap(t=>$i(t.semantics??[]).map(n=>({id:Ai(t.id,n),sourceEdgeId:t.id,sourceKind:t.kind,fromNodeId:t.fromNodeId,toNodeId:t.toNodeId,directed:!0,disposition:t.disposition,evidence:[...t.evidence],family:n.family,subtype:n.subtype,...n.context?{context:{...n.context}}:{},...n.attributes?{attributes:{...n.attributes}}:{}}))).sort((t,n)=>t.id.localeCompare(n.id))}function Pi(e){let t=Fi(e),n=new Set(t.map(r=>r.sourceEdgeId)),o=new Map(ht.map(r=>[r,new Set])),s=new Map(ht.map(r=>[r,new Set])),i=new Map(ht.map(r=>[r,0]));for(let r of t)o.get(r.family).add(r.sourceEdgeId),s.get(r.family).add(r.subtype),i.set(r.family,i.get(r.family)+1);return{sourceEdges:e.length,mappedSourceEdges:n.size,projectedEdges:t.length,unmappedSourceEdges:e.length-n.size,unsupportedSourceEdges:e.filter(r=>r.disposition==="unsupported").length,unmappedKinds:de(e.filter(r=>!n.has(r.id)).map(r=>r.kind)),families:{identity:Ue("identity",o,i,s),contract:Ue("contract",o,i,s),control:Ue("control",o,i,s),data:Ue("data",o,i,s),state:Ue("state",o,i,s),temporal:Ue("temporal",o,i,s)}}}function Ue(e,t,n,o){return{sourceEdges:t.get(e)?.size??0,projectedEdges:n.get(e)??0,subtypes:[...o.get(e)??[]].sort()}}function ki(e){let t=new Set;for(let n of e.semantics??[]){if(!Ti.has(n.family))throw new Error(`Exploration edge ${e.id} has unknown program edge family: ${n.family}.`);if(n.subtype.trim().length===0)throw new Error(`Exploration edge ${e.id} has an empty program edge subtype.`);let o=Vt(n);if(t.has(o))throw new Error(`Exploration edge ${e.id} repeats program edge semantic ${o}.`);t.add(o)}}function $i(e){return[...e].sort((t,n)=>Vt(t).localeCompare(Vt(n)))}function Vt(e){return`${e.family}:${e.subtype}`}function Ai(e,t){return`program:${encodeURIComponent(e)}:${t.family}:${encodeURIComponent(t.subtype)}`}function Di(e,t,n){return e==="incomplete"||t.some(o=>o.status!=="connected")?{status:"coverage-incomplete",scope:n,explanation:"The declared graph query has an ambiguous, missing, candidate-only, or disconnected anchor relationship."}:t.length>0?{status:"connector-complete",scope:n,explanation:"Every requested anchor pair has a selected path supported by proved repository relationships."}:{status:"frontier-accounted",scope:n,explanation:"Every discovered direction in the declared graph query is emitted or represented by an exact frontier."}}function Ro(e,t={}){let n=t.maxSelectedNodes??24;if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`maxSelectedNodes must be a positive safe integer; received ${n}`);let o=new Set(e.anchors.flatMap(g=>[...g.nodeIds,...g.candidateNodeIds])),s=[],i=e.anchors.filter(g=>g.status!=="missing"&&g.nodeIds.length+g.candidateNodeIds.length>0);for(let g=0;g<i.length;g+=1)for(let u=g+1;u<i.length;u+=1){let b=i[g],N=i[u],_=Lo(e,b,N,!1),A=_??Lo(e,b,N,!0);A?(A.nodeIds.forEach(ee=>o.add(ee)),s.push({id:xt("path",b.id,N.id),fromAnchorId:b.id,toAnchorId:N.id,status:!_||b.status==="ambiguous"||N.status==="ambiguous"?"candidate":"connected",nodeIds:A.nodeIds,edgeIds:A.edgeIds})):s.push({id:xt("path",b.id,N.id),fromAnchorId:b.id,toAnchorId:N.id,status:"partial",nodeIds:[],edgeIds:[]})}let r=de(t.routeIds??[]),a=Bi(e,r),l=new Set(a.routes.map(g=>g.id)),d=r.filter(g=>!l.has(g));if(d.length>0)throw new Error(`Unknown exploration route id(s): ${d.join(", ")}`);let f=a.routes.filter(g=>r.includes(g.id)).map(g=>({anchorNodeId:g.anchorNodeId,endpointNodeId:g.endpointNodeId,endpointKind:g.endpointKind,endpointPriority:2,nodeIds:[...g.nodeIds].reverse(),edgeIds:[...g.edgeIds].reverse()}));for(let g of f)g.nodeIds.forEach(u=>o.add(u));let y=s.length===0||s.some(g=>g.edgeIds.length>0);y&&Co(e,o,n);let m=No(e,o),v=new Set(t.expandedFrontierIds??[]),L=new Set(m.map(g=>g.id)),S=[...v].filter(g=>!L.has(g)).sort();if(S.length>0)throw new Error(`Unknown exploration frontier id(s): ${S.join(", ")}`);for(let g of m)v.has(g.id)&&g.memberNodeIds.forEach(u=>o.add(u));y&&Co(e,o,n);let k=new Map(f.map(g=>[g.endpointNodeId,g.endpointKind])),q=new Set(f.flatMap(g=>g.nodeIds)),$=new Map;for(let g of f)for(let u=0;u<g.nodeIds.length;u+=1){let b=g.nodeIds[u],N=u;$.set(b,Math.max($.get(b)??0,N))}let P=e.nodes.map(g=>{let u=k.get(g.id),b=q.has(g.id)?{upstreamCausalPath:!0,upstreamCausalDistance:$.get(g.id)??0,...u?{upstreamCausalEndpoint:u}:{}}:{};return{...g,attributes:{...g.attributes,...b},disposition:g.disposition==="excluded"||g.disposition==="unsupported"?g.disposition:o.has(g.id)?"emitted":"folded"}}),H=new Set([...s.flatMap(g=>g.edgeIds),...f.flatMap(g=>g.edgeIds)]),B=e.edges.map(g=>({...g,disposition:g.disposition==="excluded"||g.disposition==="unsupported"?g.disposition:H.has(g.id)||o.has(g.fromNodeId)&&o.has(g.toNodeId)?"emitted":"folded"})),j=vt({anchors:e.anchors,nodes:P,edges:B,paths:s,frontiers:[...e.frontiers.filter(g=>g.disposition!=="folded"),...No({...e,nodes:P,edges:B},o)],scope:e.coverage.scope,blindSpots:e.coverage.blindSpots,incompleteReasons:e.coverage.status==="incomplete"?[e.coverage.explanation]:[],routeCatalog:a}),M=new Set(j.frontiers.flatMap(g=>g.edgeIds)),G=j.edges.filter(g=>g.disposition==="folded"&&!M.has(g.id)).map(g=>g.id);if(G.length>0)throw new Error(`Folded exploration edge(s) are not frontier-accounted: ${G.sort().join(", ")}`);return j}var xo=10;function Bi(e,t=[]){let n=new Map(e.nodes.map(S=>[S.id,S])),o=new Map(e.edges.map(S=>[S.id,S])),s=new Map;for(let S of e.edges){if(!_i(S))continue;let k=s.get(S.toNodeId)??[];k.push(S),s.set(S.toNodeId,k)}for(let S of s.values())S.sort((k,q)=>Number(nt(q))-Number(nt(k))||Eo(q)-Eo(k)||k.fromNodeId.localeCompare(q.fromNodeId)||k.id.localeCompare(q.id));let i=de(e.anchors.filter(S=>S.status==="matched").flatMap(S=>S.nodeIds)),r=new Map,a=new Set,l=(S,k,q)=>{let $=k.nodeIds[k.nodeIds.length-1],P=n.get($),H=n.get(S);if(!P?.location||!H)return;let B=[...k.nodeIds].reverse(),j=[...k.edgeIds].reverse(),M=new Set(B),G=j.flatMap(_=>{let Q=o.get(_);return Q?[Q]:[]}),g=e.edges.filter(_=>_.disposition!=="excluded"&&_.disposition!=="unsupported"&&(M.has(_.fromNodeId)||M.has(_.toNodeId))),u={id:xt("route",S,$,q,...j),status:"proved",anchorNodeId:S,anchorLabel:H.label,endpointNodeId:$,endpointLabel:P.label,endpointLocation:{...P.location},endpointKind:q,nodeIds:B,edgeIds:j,evidenceStrengths:de(G.flatMap(_=>_.evidence.map(Q=>Q.strength))),spineEdgeFamilies:vo(G,!0),relatedEdgeFamilies:vo(g,!1),crossesRuntimeBoundary:G.some(nt)},b=`${S}\0${$}\0${q}`,N=r.get(b);(!N||Io(u,N)<0)&&r.set(b,u)};for(let S of i){n.get(S)?.attributes.publicEntry===!0&&l(S,{nodeIds:[S],edgeIds:[]},"public-entry");let k=[{nodeIds:[S],edgeIds:[]}],q=new Map([[S,0]]);for(let $=0;$<k.length;$+=1){let P=k[$],H=P.nodeIds[P.nodeIds.length-1];P.edgeIds.length>0&&n.get(H)?.location&&n.get(H)?.attributes.publicEntry===!0&&l(S,P,"public-entry");let B=s.get(H)??[];if(P.edgeIds.length>=xo){B.some(j=>!P.nodeIds.includes(j.fromNodeId))&&a.add(S);continue}for(let j of B){if(P.nodeIds.includes(j.fromNodeId))continue;let M=P.edgeIds.length+1,G=q.get(j.fromNodeId);if(G!==void 0&&G<=M)continue;let g={nodeIds:[...P.nodeIds,j.fromNodeId],edgeIds:[...P.edgeIds,j.id]};if(q.set(j.fromNodeId,M),nt(j)&&n.get(j.fromNodeId)?.location){l(S,g,"runtime-boundary");continue}k.push(g)}}}let d=[...r.values()].sort(Io),c=new Set(d.map(S=>S.id)),f=de(t.filter(S=>c.has(S))),y=de(d.map(S=>S.anchorNodeId)),m=i.filter(S=>!y.includes(S)),v=[...a].sort(),L=e.coverage.status==="accounted"&&v.length===0?"accounted":"incomplete";return{schemaVersion:1,routes:d,selectedRouteIds:f,coverage:{status:L,scope:"Distinct proved public-entry and runtime-boundary endpoints reachable upstream in the supplied topology.",enumeration:"one-shortest-proved-path-per-endpoint",maximumDepth:xo,anchorNodeIds:i,anchorsWithRoutes:y,anchorsWithoutRoutes:m,depthLimitedAnchorNodeIds:v,routeCount:d.length,explanation:L==="accounted"?"Every distinct proved upstream public/runtime endpoint in the supplied topology has one stable shortest route.":"Route enumeration is incomplete because the supplied topology has incomplete coverage or a traversal reached the route-depth bound."}}}function vo(e,t){let n=e.flatMap(o=>o.semantics?.map(s=>s.family)??[]);return t&&e.length>0&&n.length===0&&n.push("control"),de(n)}function Io(e,t){return e.anchorNodeId.localeCompare(t.anchorNodeId)||e.edgeIds.length-t.edgeIds.length||e.endpointKind.localeCompare(t.endpointKind)||e.endpointNodeId.localeCompare(t.endpointNodeId)||e.id.localeCompare(t.id)}function _i(e){return e.disposition!=="excluded"&&e.disposition!=="unsupported"&&Oi(e)&&e.evidence.some(t=>["exact","derived","mixed"].includes(t.strength))}function Oi(e){return nt(e)||e.kind==="boundary-observation"||e.kind==="call"||e.kind==="compiler:call"}function nt(e){return e.kind==="runtime-boundary"||e.kind.startsWith("runtime:")}function Eo(e){let t={exact:5,derived:4,mixed:3,candidate:1,unknown:0};return Math.max(0,...e.evidence.map(n=>t[n.strength]))}function Lo(e,t,n,o){return wo(e,t,n,o)??wo(e,n,t,o)}function wo(e,t,n,o){let s=[...t.nodeIds,...t.candidateNodeIds].sort(),i=new Set([...n.nodeIds,...n.candidateNodeIds]);if(s.some(c=>i.has(c)))return{nodeIds:[s.find(f=>i.has(f))],edgeIds:[]};let r=new Set(e.nodes.filter(c=>c.kind==="structural-region").map(c=>c.id)),a=new Map;for(let c of e.edges)c.disposition==="excluded"||c.disposition==="unsupported"||c.kind==="structural-membership"||r.has(c.fromNodeId)||r.has(c.toNodeId)||c.evidence.every(y=>["candidate","unknown"].includes(y.strength))&&!o||Ki(a,c.fromNodeId,c.toNodeId,c.id);for(let c of a.values())c.sort((f,y)=>f.nodeId.localeCompare(y.nodeId)||f.edgeId.localeCompare(y.edgeId));let l=s.map(c=>({nodeId:c,nodeIds:[c],edgeIds:[]})),d=new Set(s);for(let c=0;c<l.length;c+=1){let f=l[c];for(let y of a.get(f.nodeId)??[]){if(d.has(y.nodeId))continue;let m={nodeId:y.nodeId,nodeIds:[...f.nodeIds,y.nodeId],edgeIds:[...f.edgeIds,y.edgeId]};if(i.has(y.nodeId))return m;d.add(y.nodeId),l.push(m)}}return null}function Ki(e,t,n,o){let s=e.get(t)??[];s.push({nodeId:n,edgeId:o}),e.set(t,s)}function ji(e,t,n){let o=new Map;for(let a of e.edges){let l=o.get(a.fromNodeId)??{incoming:0,outgoing:0},d=o.get(a.toNodeId)??{incoming:0,outgoing:0};l.outgoing+=1,d.incoming+=1,o.set(a.fromNodeId,l),o.set(a.toNodeId,d)}let s=new Set,i=new Map;for(let a of e.edges){let l=t.has(a.fromNodeId),d=t.has(a.toNodeId);if(l===d)continue;let c=l?a.toNodeId:a.fromNodeId,f=l?a.fromNodeId:a.toNodeId,y=e.nodes.find(L=>L.id===c);if(y?.kind==="structural-region")continue;let m=i.get(c)??new Set;m.add(f),i.set(c,m),(/(?:runtime-boundary|external)/u.test(a.kind)||y&&/(?:frontier|external)/u.test(y.kind))&&s.add(c)}let r=[...i].filter(([a,l])=>{if(s.has(a))return!0;let d=o.get(a)??{incoming:0,outgoing:0};return(d.incoming>1||d.outgoing>1)&&l.size>1}).sort(([a,l],[d,c])=>Number(s.has(d))-Number(s.has(a))||c.size-l.size||a.localeCompare(d)).map(([a])=>a);for(let a of r){if(t.size>=n)break;t.add(a)}}function Co(e,t,n){let o=-1;for(;t.size!==o&&t.size<n;)o=t.size,ji(e,t,n)}function No(e,t){let n=new Set(e.nodes.filter(r=>!t.has(r.id)&&r.disposition!=="excluded"&&r.disposition!=="unsupported").map(r=>r.id)),o=new Map;for(let r of e.edges){if(!n.has(r.fromNodeId)||!n.has(r.toNodeId))continue;let a=o.get(r.fromNodeId)??new Set,l=o.get(r.toNodeId)??new Set;a.add(r.toNodeId),l.add(r.fromNodeId),o.set(r.fromNodeId,a),o.set(r.toNodeId,l)}let s=[],i=new Set;for(let r of[...n].sort()){if(i.has(r))continue;let a=[],l=[r];i.add(r);for(let d=0;d<l.length;d+=1){let c=l[d];a.push(c);for(let f of[...o.get(c)??[]].sort())i.has(f)||(i.add(f),l.push(f))}s.push(a.sort())}return s.map(r=>{let a=new Set(r),l=e.edges.filter(v=>a.has(v.fromNodeId)||a.has(v.toNodeId)),d=l.filter(v=>a.has(v.fromNodeId)!==a.has(v.toNodeId)),c=de(d.map(v=>a.has(v.fromNodeId)?v.toNodeId:v.fromNodeId)),f=new Set(d.map(v=>a.has(v.toNodeId)?"outgoing":"incoming")),y=de(l.map(v=>v.id)),m=de(d.map(v=>v.kind));return{id:xt("frontier",...r,...y),kind:m.join("+")||"disconnected",direction:f.size===1?[...f][0]:"undirected",fromNodeIds:c,edgeIds:y,memberNodeIds:r,memberCount:r.length,disposition:"folded",reason:d.length>0?"Connected evidence is folded beyond the first edge leaving the selected connector graph.":"Discovered evidence is disconnected from every selected anchor connector under the declared relation scope.",expansion:null}})}function xt(e,...t){let n=Ri("sha256").update(t.join("\0")).digest("hex").slice(0,16);return`${e}:${n}`}function We(e,t){let n=[...e].sort((o,s)=>o.id.localeCompare(s.id));for(let o=1;o<n.length;o+=1)if(n[o-1].id===n[o].id)throw new Error(`Duplicate exploration ${t} id: ${n[o].id}`);return n}function me(e,t,n,o){let s=de(t.filter(i=>!n.has(i)));if(s.length>0)throw new Error(`Exploration ${e} references missing ${o}(s): ${s.join(", ")}`)}function Mo(e){return{total:e.length,emitted:e.filter(t=>t.disposition==="emitted").length,folded:e.filter(t=>t.disposition==="folded").length,excluded:e.filter(t=>t.disposition==="excluded").length,unsupported:e.filter(t=>t.disposition==="unsupported").length}}function de(e){return[...new Set(e)].sort()}var qi=5,zi=12,Ui=8,Wi=3,To=8,Hi=6,Gi=12,Fo=12,Vi=12,Yi=2,Qi=new Set(["branch","loop","call","await","return","throw","mutation","catch","finally"]),Ji=9e3,Po=On;function Xa(e,t){return jo(e,t,"full")}function Za(e,t){return jo(e,t,"topology")}function jo(e,t,n){let o=Lt(t.searches??[]),s=Lt(t.symbols??[]),i=Lt(t.relations&&t.relations.length>0?t.relations:Po),r=i.filter(p=>!Po.includes(p));if(r.length>0)throw new Error(`Unsupported system-map relation kind(s): ${r.join(", ")}`);let a=new Set(i),l=t.evidenceFloor??"derived";if(l!=="exact"&&l!=="derived")throw new Error(`Unsupported system-map evidence floor: ${l}`);let d=Lt(t.sourceScopes&&t.sourceScopes.length>0?t.sourceScopes:["production"]),c=["production","test","fixture","example","generated","script","unknown"],f=d.filter(p=>!c.includes(p));if(f.length>0)throw new Error(`Unsupported system-map source scope(s): ${f.join(", ")}`);let y=new Set(d),m=p=>y.has($t(p));if(o.length===0&&s.length===0)throw new Error("system-map requires at least one --search or --symbol anchor.");let v=t.maxDepth??qi;if(!Number.isSafeInteger(v)||v<0)throw new RangeError(`maxDepth must be a non-negative safe integer; received ${v}`);let L=t.maxTopologyCharacters??Ji;if(!Number.isSafeInteger(L)||L<=0)throw new RangeError(`maxTopologyCharacters must be a positive safe integer; received ${L}`);let S=new En(e),k=S.fileDependencyGraph(),q=As(k),$=Ds(S.sourceFiles()),P=Mn(e),H=new Map((P?.observations??[]).map(p=>[p.id,p])),B=new Set((P?.observations??[]).map(p=>`${p.source.file}\0${p.source.startLine}`)),j=new Set,M=new Map,G=new Map,g=new Map,u=new Map,b=[],N=new Map,_=new Map,Q=[],A=0,ee=0,ae=0,O=0,Le=0,we=0,Ce=new Set,$e=new Map,tn=new Map,Go=p=>{let E=tn.get(p);if(E)return E;let R=At(e,p,{excludeIndexedTargets:!1});return tn.set(p,R),R},Ne=(p,E,R,U,I=!1)=>{let h=G.get(p);if(h)return h.depth=Math.min(h.depth,E),h.primary||=U,h.promoteBoundaryImports||=I,h.origins.add(R),h;let C={file:p,depth:E,primary:U,promoteBoundaryImports:I,origins:new Set([R]),processed:!1};return G.set(p,C),C},ue=(p,E,R,U,I="none",h=!1)=>{let C=g.get(p.symbol);if(C)return C.depth=Math.min(C.depth,E),C.origins.add(R),U&&C.anchorQueries.add(U),C.referenceScope=$s(C.referenceScope,I),Ne(p.relativePath,E,R,!0,h),C;let F={definition:p,depth:E,origins:new Set([R]),anchorQueries:new Set(U?[U]:[]),referenceScope:I,processed:!1};return g.set(p.symbol,F),Ne(p.relativePath,E,R,!0,h),F},Ae=(p,E,R,U,I=!1,h=!0)=>{let C=Ee(p),F=u.get(C);if(F)return F.depth=Math.min(F.depth,E),F.origins.add(R),U&&F.anchorQueries.add(U),F.reverseCallExpansion||=I,F.traversalEligible||=h,Ne(p.file,E,R,F.traversalEligible,!0),F;let w={...p,depth:E,origins:new Set([R]),anchorQueries:new Set(U?[U]:[]),reverseCallExpansion:I,traversalEligible:h};return u.set(C,w),Ne(p.file,E,R,h,!0),w},nn=(p,E,R)=>{Ne(p.source.file,E,R,!0,!0),p.owner.file!==p.source.file&&Ne(p.owner.file,E,`${R}:owner`,!0,!0);let U=Fe(e,p.owner.file),I=p.owner.symbol?Pe(e,S,p.owner.symbol).matches.find(F=>F.relativePath===p.owner.file):null,h=(I&&!le(I.symbol)?I:null)??ze(U,p.source.startLine);if(h&&!le(h.symbol))return ue(h,E,R,void 0,"none",!0),h.symbol;p.owner.name&&Ae({file:p.owner.file,name:p.owner.name,startLine:p.owner.startLine,endLine:p.owner.endLine},E,`${R}:source-owner`,void 0,!0);let C=S.definitionsForFile(p.source.file).filter(F=>!!F.leaf&&Pt(e,p.source.file,F.leaf).some(w=>w>=p.source.startLine&&w<=p.source.endLine));if(C.length===1){let F=C[0];ue(F,E,`${R}:handler-identifier`,void 0,"none",!0),fe(N,{kind:"runtime-boundary",evidence:"runtime-boundary:handler-identifier",fromFile:p.source.file,fromSymbol:null,toFile:F.relativePath,toSymbol:F.symbol,fromBoundaryParticipant:Ge(p),line:p.source.startLine,strength:"derived"})}return null};for(let p of o){let E=Ss(e,S,p,B),R=E.filter(C=>Is(C,m)),U=!t.fullLiteralTraversal&&(E.length>zi||R.length>Ui),I=U?[]:E,h=new Set((U?[]:t.fullLiteralTraversal?R:[...R].sort(bs).slice(0,Wi)).map(Do));U&&(ee+=1,ae+=E.length);for(let C of I){let F=h.has(Do(C)),w=F&&!C.ownerSymbol&&C.ownerStartLine!==null&&C.ownerEndLine!==null;if(Ne(C.relativePath,0,`${F?"literal-anchor":"literal-match"}:${p}`,w,w),w&&Ae({file:C.relativePath,name:C.ownerShortName??`${C.relativePath}:${C.ownerStartLine+1}`,startLine:C.ownerStartLine,endLine:C.ownerEndLine},0,`literal-source-owner:${p}`,p,!0),F&&C.ownerSymbol){let D=Pe(e,S,C.ownerSymbol).matches[0];D&&!le(D.symbol)&&ue(D,0,"literal-owner",p,"all",!0)}b.push({query:p,file:C.relativePath,line:C.line,ownerSymbol:C.ownerSymbol,ownerShortName:C.ownerShortName,ownerStartLine:C.ownerStartLine,ownerEndLine:C.ownerEndLine,sourceLine:C.sourceLine.trim(),matchKind:C.matchKind,traversalSeed:F})}Q.push({kind:"literal",query:p,status:E.length>0?"matched":"missing",matchedRegionIds:[],matchingLines:E.length,seedMatchingLines:U?0:h.size,matchOnlyLines:E.length-h.size,eligibleSeedMatchingLines:R.length,materializedMatchingLines:I.length,withheldMatchingLines:U?E.length:0,literalTraversal:U?"withheld-broad":"materialized",representativeMatches:U?Es(p,E):void 0,narrowingCommands:U?ws(p,E):void 0,exhaustiveTraversalCommand:U||h.size<R.length?`codebaseiq system-map --search ${X(p)} --full-literal-traversal`:void 0,seedRegionIds:[],matchOnlyRegionIds:[]})}for(let p of s){let E=Pe(e,S,p);A+=E.omitted;let R=hs(e,p),U=E.matches.filter(w=>!le(w.symbol)),I=R!==null&&U.length===0;I&&Ae(R,0,"source-construct-anchor",p,!0);let h=I?U:E.matches;for(let w of h)ue(w,0,"symbol-anchor",p,"all",!0);let C=I?xs(R):null,F=I?1:E.total;Q.push({kind:"symbol",query:p,status:F===0?"missing":F===1?"matched":"ambiguous",matchedRegionIds:[],symbolCandidates:[...C?[C]:[],...h.map(Ts)],totalSymbolCandidates:F,omittedSymbolCandidates:E.omitted})}for(let p=0;p<v;p+=1){if(a.has("call")){let I=[...u.values()].filter(h=>h.traversalEligible&&h.reverseCallExpansion&&h.depth<=p&&!Ce.has(Ee(h)));for(let h of I){Ce.add(Ee(h));let C=Me(e,h.file);if((C?.callables??[]).filter(D=>D.name===h.name&&D.startLine<=h.endLine&&D.endLine>=h.startLine).length===1){let D=(C?.callSites??[]).filter(z=>z.calleeLeaf===h.name&&!z.memberAccess);for(let z of D){let J=p+1,K=ze(Fe(e,h.file),z.line),Y=null,te=null;if(K&&!le(K.symbol)){if(K.relativePath===h.file&&K.startLine<=h.endLine&&K.endLine>=h.startLine)continue;ue(K,J,"reverse-local-call-owner",void 0,"forward-regions",!0),Y=K.symbol}else{let x=Yt(e,h.file,z.line);x&&Ee(x)!==Ee(h)&&(te=Ae(x,J,"reverse-local-call-source-owner",void 0,!0))}!Y&&!te||fe(N,{kind:"call",evidence:"ast-callsite",fromFile:h.file,fromSymbol:Y,toFile:h.file,toSymbol:null,fromSourceConstruct:te?ce(te):void 0,toSourceConstruct:ce(h),line:z.line,strength:"derived"})}}let w=new Set([...q.get(h.file)??[],...$e.get(Ee(h))??[],...Pn(e,h.file).flatMap(D=>[...q.get(D)??[]])]);for(let D of w){if(!m(D))continue;let J=Go(D).targets.filter(K=>K.targetFile===h.file&&K.targetStartLine<=h.endLine&&K.targetEndLine>=h.startLine);for(let K of J){let Y=p+1,te=ze(Fe(e,D),K.line),x=null,W=null;if(te&&!le(te.symbol))ue(te,Y,"reverse-member-call-owner",void 0,"cross-workspace-or-forward",!0),x=te.symbol;else{let T=Yt(e,D,K.line);T&&(W=Ae(T,Y,"reverse-member-call-source-owner",void 0,!0))}!x&&!W||fe(N,{kind:"call",evidence:"ast-service-member-callsite",fromFile:D,fromSymbol:x,toFile:h.file,toSymbol:null,fromSourceConstruct:W?ce(W):void 0,toSourceConstruct:ce(h),line:K.line,strength:K.strength==="exact"?"exact":"derived"})}}}}let E=[...g.values()].filter(I=>!I.processed&&I.depth<=p),R=a.has("call")?S.calleeMap(E.map(I=>I.definition),{additive:!1,semantic:!1}):new Map;for(let I of E){I.processed=!0;let h=I.definition;if(I.referenceScope!=="none"&&(a.has("call")||a.has("reference")||a.has("contract-symbol"))){let C=Ns(e,S,h).filter(w=>m(w.file)&&ks(I,w.file,G,$)),F=new Set(C.flatMap(w=>{if(!(a.has("call")&&Me(e,w.file)?.callSites.some(J=>J.line===w.line&&J.calleeLeaf===h.leaf)===!0)||!w.enclosingSymbol)return[];let z=Pe(e,S,w.enclosingSymbol).matches[0];return z&&!le(z.symbol)?[{owner:z,site:w}]:[]}).sort((w,D)=>{let z=ye(h.relativePath,$).relativeDir,J=ye(w.owner.relativePath,$).relativeDir===z,K=ye(D.owner.relativePath,$).relativeDir===z,Y=ko(e,w.owner),te=ko(e,D.owner),x=w.owner.endLine-w.owner.startLine,W=D.owner.endLine-D.owner.startLine;return Number(K)-Number(J)||te-Y||x-W||w.owner.symbol.localeCompare(D.owner.symbol)}).filter((w,D,z)=>z.findIndex(J=>J.owner.symbol===w.owner.symbol)===D).reduce((w,D)=>{if(w.length>=Yi)return w;let z=ye(D.owner.relativePath,$).relativeDir;return w.some(J=>J.workspace===z)||w.push({symbol:D.owner.symbol,workspace:z}),w},[]).map(w=>w.symbol));for(let w of C){let D=p+1;Ne(w.file,D,`reference:${ie(h.symbol)}`,!0);let z=a.has("call")&&Me(e,w.file)?.callSites.some(Y=>Y.line===w.line&&Y.calleeLeaf===h.leaf)===!0,J=null,K=null;if(w.enclosingSymbol){let Y=Pe(e,S,w.enclosingSymbol).matches[0];Y&&!le(Y.symbol)&&(ue(Y,D,"reference-owner",void 0,z&&F.has(Y.symbol)?I.referenceScope:"none"),J=Y.symbol)}if(!J&&w.line!==null){let Y=Yt(e,w.file,w.line);Y&&(K=Ae(Y,D,"reference-source-owner",void 0,z))}a.has("reference")&&fe(N,{kind:"reference",evidence:"indexed-or-source-reference",fromFile:w.file,fromSymbol:J,toFile:h.relativePath,toSymbol:h.symbol,fromSourceConstruct:K?ce(K):void 0,line:w.line,strength:"mixed"}),z&&fe(N,{kind:"call",evidence:"ast-callsite",fromFile:w.file,fromSymbol:J,toFile:h.relativePath,toSymbol:h.symbol,fromSourceConstruct:K?ce(K):void 0,line:w.line,strength:"derived"}),a.has("contract-symbol")&&ye(w.file,$).relativeDir!==ye(h.relativePath,$).relativeDir&&fe(N,{kind:"contract-symbol",evidence:"compiler-cross-workspace-symbol",fromFile:w.file,fromSymbol:J,toFile:h.relativePath,toSymbol:h.symbol,fromSourceConstruct:K?ce(K):void 0,line:w.line,strength:"exact"})}}for(let C of R.get(h.symbolId)??[]){let F=Pe(e,S,C.symbol).matches.find(D=>D.relativePath===C.file);if(!F||!m(F.relativePath))continue;if(!(F.relativePath===h.relativePath||(k.get(h.relativePath)??new Set).has(F.relativePath))){O+=1;continue}ue(F,p+1,`call:${ie(h.symbol)}`,void 0,"none",!0),fe(N,{kind:"call",evidence:C.source,fromFile:h.relativePath,fromSymbol:h.symbol,toFile:F.relativePath,toSymbol:F.symbol,line:null,strength:ds(C.source)})}}let U=[...G.values()].filter(I=>!I.processed&&I.primary&&I.depth<=p);for(let I of U){I.processed=!0;let h=[...u.values()].filter(x=>x.traversalEligible&&x.file===I.file&&x.depth<=p),C=[...g.values()].filter(x=>x.definition.relativePath===I.file&&x.depth<=p).map(x=>{let W=Dt(e,I.file,x.definition.startLine);return{startLine:W?.startLine??x.definition.startLine,endLine:W?.endLine??x.definition.endLine}}),F=x=>[...g.values()].filter(W=>W.definition.relativePath===I.file&&W.definition.startLine<=x&&W.definition.endLine>=x).sort((W,T)=>W.definition.endLine-W.definition.startLine-(T.definition.endLine-T.definition.startLine)||W.definition.startLine-T.definition.startLine)[0],w=[...H.values()].filter(x=>x.source.file===I.file&&M.has(x.id)),D=[...h.map(x=>({startLine:x.startLine,endLine:x.endLine})),...w.map(x=>({...Et(e,x)}))],z=[...C,...D],J=(Me(e,I.file)?.callSites??[]).filter(x=>z.some(W=>x.line>=W.startLine&&x.line<=W.endLine)),K=new Set;if(a.has("call"))for(let x of z){let W=kn(e,I.file,x.startLine,x.endLine);for(let T of W.targets){if(!m(T.definition.relativePath))continue;let ne=F(T.sourceLine),xe=h.find(he=>he.startLine<=T.sourceLine&&he.endLine>=T.sourceLine),pe=w.find(he=>{let re=Et(e,he);return re.startLine<=T.sourceLine&&re.endLine>=T.sourceLine});ue(T.definition,p+1,`scip-occurrence-call:${I.file}:${T.sourceLine+1}`,void 0,"none",!0),fe(N,{kind:"call",evidence:"scip-occurrence-callsite",fromFile:I.file,fromSymbol:ne?.definition.symbol??null,toFile:T.definition.relativePath,toSymbol:T.definition.symbol,fromBoundaryParticipant:pe?Ge(pe):void 0,fromSourceConstruct:xe?ce(xe):void 0,line:T.sourceLine,strength:"exact"}),K.add(`${T.sourceLine}\0${T.calleeLeaf}`)}}if(a.has("reference"))for(let x of z){let W=$n(e,I.file,x.startLine,x.endLine);for(let T of W.targets){if(!m(T.definition.relativePath)||K.has(`${T.sourceLine}\0${T.calleeLeaf}`))continue;let ne=F(T.sourceLine);if(ne?.definition.symbol===T.definition.symbol)continue;let xe=h.find(he=>he.startLine<=T.sourceLine&&he.endLine>=T.sourceLine),pe=w.find(he=>{let re=Et(e,he);return re.startLine<=T.sourceLine&&re.endLine>=T.sourceLine});ue(T.definition,p+1,`scip-occurrence-reference:${I.file}:${T.sourceLine+1}`,void 0,"none",!0),fe(N,{kind:"reference",evidence:"scip-occurrence-reference",fromFile:I.file,fromSymbol:ne?.definition.symbol??null,toFile:T.definition.relativePath,toSymbol:T.definition.symbol,fromBoundaryParticipant:pe?Ge(pe):void 0,fromSourceConstruct:xe?ce(xe):void 0,line:T.sourceLine,strength:"exact"})}}let Y=a.has("call")?At(e,I.file,{ranges:z,excludeIndexedTargets:!1}):{targets:[],unresolvedCallsites:0};we+=Y.unresolvedCallsites;let te=Y.targets.filter(x=>!K.has(`${x.line}\0${x.calleeLeaf}`));Le+=te.filter(x=>x.strength!=="exact"&&(x.resolution!=="imported-service-object-member"||(x.resolutionAlternativeCount??0)>1)).length;for(let x of te){let W=(x.resolutionAlternativeCount??1)===1,T=x.targetSymbol?Fe(e,x.targetFile).find(re=>re.symbol===x.targetSymbol):void 0,ne=T?null:Ae({file:x.targetFile,name:x.calleeLeaf,startLine:x.targetStartLine,endLine:x.targetEndLine},p+1,`member-call:${I.file}`,void 0,x.resolution==="imported-service-object-member"&&W,W);if(ne&&x.serviceFile){let re=Ee(ne),Ve=$e.get(re)??new Set;for(let ir of q.get(x.serviceFile)??[])Ve.add(ir);$e.set(re,Ve)}T&&ue(T,p+1,`member-call:${I.file}`,void 0,"none",!0);let xe=h.find(re=>re.startLine<=x.line&&re.endLine>=x.line),pe=F(x.line),he=w.find(re=>{let Ve=Et(e,re);return Ve.startLine<=x.line&&Ve.endLine>=x.line});fe(N,{kind:"call",evidence:x.resolution==="constructed-member-receiver"?"ast-constructed-member-callsite":x.resolution==="factory-callback-member"?"ast-factory-callback-callsite":x.resolution==="imported-service-object-member"?"ast-service-member-callsite":"ast-member-import-candidate",fromFile:I.file,fromSymbol:pe?.definition.symbol??null,toFile:x.targetFile,toSymbol:T?.symbol??null,fromBoundaryParticipant:he?Ge(he):void 0,fromSourceConstruct:xe?ce(xe):void 0,toSourceConstruct:ne?ce(ne):void 0,line:x.line,strength:x.resolution==="imported-service-object-member"?(x.resolutionAlternativeCount??0)===1?"derived":"candidate":x.strength??"candidate"})}for(let x of a.has("import")||a.has("call")?Ms(e,I.file):[]){if(!x.fromFile){if(a.has("import")){let T=_.get(x.shortName)??{name:x.shortName,fromFiles:new Set};T.fromFiles.add(I.file),_.set(x.shortName,T)}continue}if(!m(x.fromFile))continue;if(a.has("import")&&(Ne(x.fromFile,p+1,`import:${I.file}`,!1),fe(N,{kind:"import",evidence:"indexed-or-source-import",fromFile:I.file,fromSymbol:null,toFile:x.fromFile,toSymbol:x.symbol,line:null,strength:"mixed"})),a.has("call")&&J.length>0){let T=(x.source==="compiler"?Pe(e,S,x.symbol).matches:Ln(e,x.fromFile,x.importedName)).filter(ne=>!le(ne.symbol));for(let ne of T){let xe=J.filter(pe=>pe.calleeLeaf===x.localName).map(pe=>pe.line);if(xe.length!==0){ue(ne,p+1,`source-call:${I.file}`,void 0,"none",!0);for(let pe of xe)fe(N,{kind:"call",evidence:"ast-callsite",fromFile:I.file,fromSymbol:null,toFile:ne.relativePath,toSymbol:ne.symbol,line:pe,strength:"derived"})}}}if(!I.promoteBoundaryImports||!Fs(I.file,x.fromFile,$))continue;let W=Pe(e,S,x.symbol);for(let T of W.matches)if(Ps(T.relativePath,x.fromFile,$)&&!le(T.symbol)){let ne=ye(I.file,$).relativeDir!==ye(T.relativePath,$).relativeDir;ue(T,p+1,`boundary-import:${I.file}`,void 0,ne?"cross-workspace-or-forward":"forward-regions")}}}for(let I of a.has("runtime-boundary")?P?.links??[]:[]){if(I.strength==="candidate"||l==="exact"&&I.strength!=="exact"||j.has(I.id))continue;let h=H.get(I.from),C=H.get(I.to);if(!h||!C||!m(h.source.file)||!m(C.source.file))continue;let F=Oo(h,p,M,g,u),w=Oo(C,p,M,g,u);if(F===null&&w===null)continue;let D=p+1,z=nn(h,F??D,`runtime-boundary:${I.joinRule}`),J=nn(C,w??D,`runtime-boundary:${I.joinRule}`),K=z?null:_o(u,h),Y=J?null:_o(u,C);M.set(h.id,F??D),M.set(C.id,w??D),fe(N,{kind:"runtime-boundary",evidence:`runtime-boundary:${I.joinRule}`,fromFile:h.source.file,fromSymbol:z,toFile:C.source.file,toSymbol:J,fromBoundaryParticipant:Ge(h),toBoundaryParticipant:Ge(C),fromSourceConstruct:K?ce(K):void 0,toSourceConstruct:Y?ce(Y):void 0,runtimeBoundaryKey:I.matchedKeyParts.map(te=>`${te.name}=${te.value}`).join(" "),line:h.source.startLine,strength:I.strength}),j.add(I.id)}}let Se=new Map;for(let p of G.keys())Se.set(p,ot(p,$));let it=[...N.values()].filter(p=>Se.has(p.fromFile)&&Se.has(p.toFile)).map(p=>({...p,fromRegionId:Se.get(p.fromFile).id,toRegionId:Se.get(p.toFile).id})).sort(Wo),Nt=qs(it),st=new Set(t.expand??[]),De=_s(G,g,b,it,Nt,Se,st),on=new Set([...G.values()].filter(p=>[...p.origins].some(E=>E.startsWith("literal-anchor:")||E==="literal-owner"||E==="symbol-anchor")).map(p=>Se.get(p.file).id)),rn=ms(De),Vo=new Set(De.map(p=>p.id)),Yo=[...st].filter(p=>!Vo.has(p)).sort();for(let p of Q)if(p.matchedRegionIds=Us(p,b,g,Se),p.kind==="literal"){let E=b.filter(R=>R.query===p.query);p.seedRegionIds=V(E.filter(R=>R.traversalSeed).map(R=>Se.get(R.file).id)),p.matchOnlyRegionIds=V(E.filter(R=>!R.traversalSeed).map(R=>Se.get(R.file).id))}let sn=[...g.values()].filter(p=>!p.processed).length,an=[...G.values()].filter(p=>p.primary&&!p.processed).length,ln=[...G.values()].filter(p=>!p.primary&&!p.processed).length,dn=[...g.values()].filter(p=>p.processed),at=(P?.frontiers??[]).flatMap(p=>{let E=H.get(p.observationId);return!E&&p.source&&p.action&&p.strength?!a.has("runtime-boundary")||!m(p.source.file)||l==="exact"||!G.has(p.source.file)?[]:[{observationId:p.observationId,action:p.action,strength:p.strength,file:p.source.file,line:p.source.startLine,ownerShortName:p.ownerShortName??null,address:p.address??p.missingKeyParts.join(", "),reason:p.reason}]:!a.has("runtime-boundary")||!E||!m(E.source.file)||l==="exact"&&E.strength!=="exact"||!G.has(E.source.file)?[]:[{observationId:E.id,action:E.action,strength:E.strength,file:E.source.file,line:E.source.startLine,ownerShortName:E.owner.name,address:Uo(E),reason:p.reason,protocol:E.protocol,role:E.role,modality:E.modality,resolution:E.resolution,sourceScope:E.sourceScope,keyParts:E.keyParts.map(R=>({name:R.name,value:R.value,evidence:R.evidence}))}]}).sort((p,E)=>p.file.localeCompare(E.file)||p.line-E.line),Mt=(P?.links??[]).filter(p=>{if(!a.has("runtime-boundary")||l==="exact"&&p.strength!=="exact")return!1;let E=H.get(p.from),R=H.get(p.to);return!!(E&&R&&m(E.source.file)&&m(R.source.file)&&(G.has(E.source.file)||G.has(R.source.file)))}),Qo=Mt.filter(p=>p.strength==="exact").length,Jo=Mt.filter(p=>p.strength==="derived").length,Xo=Mt.filter(p=>p.strength==="candidate").length,Zo=P?.links.filter(p=>p.strength==="exact").length??0,er=P?.links.filter(p=>p.strength==="derived").length??0,tr=P?.links.filter(p=>p.strength==="candidate").length??0,Rt=zs(_,Se),Tt=A===0?"accounted":"incomplete",cn=[...ee>0?[`${ee} broad literal anchor(s) withheld ${ae} exact match(es) before graph traversal; representative identities and scoped search commands preserve recovery without treating every textual occurrence as relevant.`]:[],`Literal matches outside the included source scopes (${d.join(", ")}) remain visible as match-only evidence and do not seed traversal.`,P?"Built-in runtime-boundary extractors traverse direct and replayably derived links; heuristic candidates, unsupported frameworks, reflection, generated names, and dependency wiring not recoverable from compiler occurrences or constructor assignments remain disclosed frontiers.":"Runtime-boundary evidence is unavailable for this index; run codebaseiq reindex with this build to extract supported HTTP, event, registry, and persistence observations.","Reverse references do not recursively expand from discovered callers or callees.","Member calls use compiler occurrences, exact constructor-assigned fields, bounded unique service providers, direct factory-return members, and compiler-resolved object-literal callbacks when available. Ambiguous providers remain candidate frontiers; callback values routed through mutation, reflection, or unsupported dependency containers remain unrepresented.","Literal traversal is bounded to the smallest parser-delimited source construct; parser gaps may reduce an owner to one source line and leave its continuation untraversed.","Schema consumers stay within forward-flow regions; cross-workspace contracts may discover consumers in other workspaces. Add an explicit symbol anchor to widen either scope.",`Traversal stops after depth ${v}; nonzero frontier counts identify evidence that was discovered but not traversed.`,"Region labels are structural path groupings, not inferred runtime or architectural boundaries."],be=ns({db:e,anchors:Q,regions:De,symbolStates:g,sourceConstructStates:u,literalHits:b,relations:it,externalBoundaries:Rt,boundaryFrontiers:at,regionForFile:Se,closureStatus:Tt,omittedSymbolCandidates:A,maxDepth:v,requestedRelationKinds:i,evidenceFloor:l,includedSourceScopes:d,blindSpots:cn,topologyFrontiers:t.topologyFrontiers??[],routeIds:t.routeIds??[],expandedRegionIds:[...st],maxTopologyCharacters:L,fullLiteralTraversal:t.fullLiteralTraversal??!1});if(n==="topology")return be;let un=(t.behaviorFocusLocations?.length??0)>0?new Set([...be.anchors.flatMap(p=>p.nodeIds),...be.paths.flatMap(p=>p.nodeIds)]).size:void 0,lt=An(e,be,{focusLocations:t.behaviorFocusLocations,...un?{maxSteps:un}:{}});_n(e,be,lt);let nr=Xi(e,be,lt,t.behaviorFocusLocations??[]);be.corridor=yo(be,{focusLocations:nr});let pn=Bn(e,be,lt,{sourceAllowed:m,selectionTerms:t.selectionTerms}),mn=as(be),or=us(o,s,v,i,l,d,t.fullLiteralTraversal??!1,L,De,Nt,on,st,mn),rr=cs(o,s,v,De.filter(p=>mn.has(p.id)),on,i,l,d,t.fullLiteralTraversal??!1,L);return{anchors:Q,regions:De,regionRelations:Nt,externalBoundaries:Rt,boundaryFrontiers:at,unmatchedExpansions:Yo,expansion:rr,drilldown:rn,presentation:or,topology:be,behavior:lt,nextAnchors:pn,closure:{status:Tt,emitted:{regions:De.length,relations:it.length,runtimeLinks:j.size},withheld:{symbols:sn,files:an+ln,regions:be.nodes.filter(p=>p.kind==="structural-region"&&p.disposition==="folded").length,drillAnchors:(rn?.omittedAnchors??0)+pn.omittedAnchors,literalMatches:ae},ambiguous:{anchors:Q.filter(p=>p.status==="ambiguous").length,omittedSymbolCandidates:A},external:Rt.length,unresolved:at.length,explanation:Tt==="accounted"?"Every fact reached under the declared anchors, relations, depth, evidence floor, source scopes, and installed analyzers is accounted for as emitted, withheld, ambiguous, external, or unresolved.":"Some ambiguous symbol candidates were not identified, so the declared query is not fully accounted for."},coverage:{explicitAnchorCount:Q.length,requestedRelationKinds:i,evidenceFloor:l,includedSourceScopes:d,matchedAnchorCount:Q.filter(p=>p.status!=="missing").length,literalSearchesComplete:!0,broadLiteralAnchors:ee,withheldLiteralMatches:ae,symbolCandidateSetsComplete:A===0,omittedSymbolCandidates:A,maxTraversalDepth:v,frontierSymbols:sn,frontierFiles:an,supportFilesNotTraversed:ln,filteredUnverifiedCallEdges:O,memberCallCandidateEdges:Le,unresolvedMemberCallsites:we,runtimeBoundaryEvidenceAvailable:P!==null,runtimeBoundaryObservations:P?.observations.length??0,runtimeBoundaryExactLinks:Qo,runtimeBoundaryDerivedLinks:Jo,runtimeBoundaryCandidateLinks:Xo,repositoryRuntimeBoundaryExactLinks:Zo,repositoryRuntimeBoundaryDerivedLinks:er,repositoryRuntimeBoundaryCandidateLinks:tr,runtimeBoundaryTraversedLinks:j.size,runtimeBoundaryFrontiers:at.length,referenceExpansionEligibleSymbols:dn.filter(p=>p.referenceScope!=="none").length,referenceExpansionSkippedSymbols:dn.filter(p=>p.referenceScope==="none").length,dynamicDispatchRepresented:P?.links.some(p=>p.joinRule==="carrier.discriminator"&&j.has(p.id))??!1,runtimeGeneratedLinksRepresented:P!==null,regionBoundariesAreStructural:!0,relationFamilies:{"literal-anchor":{evidence:"exact-source",scope:"all indexed documents for each explicit literal",completeWithinScope:!0},reference:{evidence:"compiler-graph",scope:"all cross-file indexed/source-attributed sites for explicit anchors and promoted non-module boundary symbols",completeWithinScope:!0},call:{evidence:"mixed",scope:"static callees plus exact SCIP call occurrences in traversed source ranges, exact constructor-assigned member receivers, and uniquely attributed direct-import member candidates",completeWithinScope:!0},"contract-symbol":{evidence:"compiler-graph",scope:"compiler-resolved symbol identities referenced across inferred workspace boundaries",completeWithinScope:!0},import:{evidence:"compiler-graph",scope:"all indexed or source-resolved imports of traversed primary files",completeWithinScope:!0},"runtime-boundary":{evidence:"exact-source",scope:"direct and mechanically derived links produced by grounded runtime adapters and factorized relation groups",completeWithinScope:!0}},blindSpots:cn}}}function Xi(e,t,n,o){let s=new Map,i=l=>{s.set(`${l.file}\0${l.line}`,l)};for(let l of o)i(l);let r=new Set(t.anchors.filter(l=>l.status==="matched").flatMap(l=>l.nodeIds));for(let l of n.steps)if(!(!l.location||!r.has(l.nodeId)||(l.behavior?.rawCharacters??1/0)>3e3))for(let d of l.behavior?.lines??[])d.signals.some(c=>Qi.has(c))&&i({file:l.location.file,line:d.line,endLine:d.endLine});let a=t.edges.filter(l=>l.disposition==="emitted").flatMap(l=>l.evidence.flatMap(d=>d.location?[d.location]:[]));for(let l of a){i(l);let d=t.nodes.filter(f=>f.location?.file===l.file&&["symbol","source-construct","runtime-boundary-participant"].includes(f.kind)&&f.location.line<=l.line&&(f.location.endLine??f.location.line)>=l.line).sort((f,y)=>(f.location.endLine??f.location.line)-f.location.line-((y.location.endLine??y.location.line)-y.location.line)||f.id.localeCompare(y.id))[0];if(!d?.location)continue;let c=Rn(e,l.file,d.location.line,d.location.endLine??d.location.line,[l.line]);for(let f of c)i({file:l.file,line:f.line,endLine:f.endLine})}return[...s.values()].sort((l,d)=>l.file.localeCompare(d.file)||l.line-d.line)}function Zi(e){if(e.ownerStartLine===null||e.ownerStartLine===void 0)throw new Error(`Literal hit ${e.file}:${e.line+1} has no source-owner start line.`);if(e.ownerEndLine===null||e.ownerEndLine===void 0)throw new Error(`Literal hit ${e.file}:${e.line+1} has no source-owner end line.`);return{file:e.file,name:e.ownerShortName??`${e.file}:${e.ownerStartLine+1}`,startLine:e.ownerStartLine,endLine:e.ownerEndLine}}function Ee(e){return`${e.file}\0${e.startLine}\0${e.endLine}\0${e.name}`}function ce(e){return{file:e.file,name:e.name,startLine:e.startLine,endLine:e.endLine}}function It(e,t){let n=Zt(Me(e,t.file)?.callables??[],t.startLine);if(n&&n.endLine>=t.endLine)return{file:t.file,name:/^source@\d+$/u.test(n.name)&&!/^source@\d+$/u.test(t.name)?t.name:n.name,startLine:n.startLine,endLine:n.endLine};let o=zo(e,t.file,t.startLine);return o&&o.endLine>=t.endLine?{file:t.file,name:o.name,startLine:o.startLine,endLine:o.endLine}:ce(t)}function He(e){return ge("source-construct",e.file,String(e.startLine),String(e.endLine),e.name)}function wt(e,t){let n=hn(e,t.symbol,t.relativePath),o=new Set(["package-surface-file","transitive-package-surface"]),s=n.filter(r=>!o.has(r)||Dn(e,t)),i=s.some(r=>!o.has(r));return{evidence:s,priority:i||xn(e,t.symbol,t.relativePath)?2:1}}function ko(e,t){let n=wt(e,t);return n.evidence.length>0?n.priority:0}function es(e,t){let n=Fe(e,t.file),o=n.filter(s=>s.startLine<=t.startLine&&s.endLine>=t.startLine).sort((s,i)=>s.endLine-s.startLine-(i.endLine-i.startLine)||s.startLine-i.startLine);for(let s of o){let i=wt(e,s);if(i.evidence.length>0)return i}for(let s of ts(e,t.file,t.startLine)){let i=n.filter(r=>r.leaf===s.name).sort((r,a)=>Math.abs(r.startLine-s.startLine)-Math.abs(a.startLine-s.startLine)||r.symbol.localeCompare(a.symbol));for(let r of i){let a=wt(e,r);if(a.evidence.length>0)return a}return{evidence:[],priority:0}}return{evidence:[],priority:0}}function ts(e,t,n){let o=Be(e,t)?.rootNode;if(!o||o.startPosition.row>n||o.endPosition.row<n)return[];let s=[],i=en(o,n);for(;i;){if(i.type==="variable_declarator"||i.type==="function_declaration"||i.type==="generator_function_declaration"||i.type==="class_declaration"){let r=i.childForFieldName("name")??i.namedChild(0);(r?.type==="identifier"||r?.type==="type_identifier")&&s.push({name:r.text,startLine:i.startPosition.row})}i=i.parent}return s}function ns(e){let t=[...new Map([...e.sourceConstructStates.values()].map(u=>It(e.db,u)).map(u=>[Ee(u),u])).values()].sort((u,b)=>u.file.localeCompare(b.file)||u.startLine-b.startLine||u.endLine-b.endLine),n=e.anchors.map((u,b)=>{let N=ge("anchor",String(b),u.kind,u.query),_=[...e.symbolStates.values()].filter(O=>O.anchorQueries.has(u.query)).flatMap(O=>{if(!le(O.definition.symbol))return[ke(O.definition.symbol)];let Le=t.filter(we=>we.file===O.definition.relativePath).map(we=>He(we));return Le.length>0?Le:[ke(O.definition.symbol)]}),Q=[...e.sourceConstructStates.values()].filter(O=>O.anchorQueries.has(u.query)).map(O=>He(It(e.db,O))),A=e.literalHits.filter(O=>O.query===u.query&&O.traversalSeed===!0&&O.ownerSymbol&&e.symbolStates.has(O.ownerSymbol)).map(O=>ke(O.ownerSymbol)),ee=e.literalHits.filter(O=>O.query===u.query&&O.traversalSeed===!0&&!O.ownerSymbol&&O.ownerStartLine!==null&&O.ownerStartLine!==void 0&&O.ownerEndLine!==null&&O.ownerEndLine!==void 0).map(O=>He(It(e.db,Zi(O)))),ae=V(u.kind==="symbol"?[..._,...Q]:A.length+ee.length>0?[...A,...ee]:u.seedRegionIds??[]);return{id:N,kind:u.kind,query:u.query,status:u.status,nodeIds:u.status==="ambiguous"?[]:ae,candidateNodeIds:u.status==="ambiguous"?ae:[],omittedCandidates:u.omittedSymbolCandidates??0}}),o=new Map;for(let u of n)for(let b of[...u.nodeIds,...u.candidateNodeIds]){let N=o.get(b)??[];N.push(u.id),o.set(b,N)}let s=e.relations.flatMap(u=>[u.fromBoundaryParticipant,u.toBoundaryParticipant].flatMap(b=>b?.ownerName?[b]:[])),i=e.regions.map(u=>({id:u.id,kind:"structural-region",label:u.label,disposition:"folded",location:null,anchorIds:V(o.get(u.id)??[]),attributes:{workspace:u.workspace,structuralPath:u.structuralPath,minimumDepth:u.minDepth,files:u.fileCount,symbols:u.symbolCount,expanded:u.expanded}}));for(let u of e.symbolStates.values()){let b=e.regionForFile.get(u.definition.relativePath)?.id;if(!b)throw new Error(`System-map symbol ${u.definition.symbol} has no structural region.`);let N=ke(u.definition.symbol),_=wt(e.db,u.definition);i.push({id:N,kind:"symbol",label:ie(u.definition.symbol),disposition:(o.get(N)?.length??0)>0?"emitted":"folded",location:{file:u.definition.relativePath,line:u.definition.startLine,endLine:u.definition.endLine},anchorIds:V(o.get(N)??[]),attributes:{regionId:b,depth:u.depth,leaf:u.definition.leaf??ie(u.definition.symbol),referenceScope:u.referenceScope,..._.evidence.length>0?{publicEntry:!0,publicEntryPriority:_.priority,publicEntryEvidence:_.evidence.join(",")}:{}}})}for(let u of t){let b=e.regionForFile.get(u.file)?.id;if(!b)throw new Error(`Source construct ${u.name} has no structural region.`);let N=He(u),Q=s.find(ee=>ee.file===u.file&&ee.line>=u.startLine&&ee.line<=u.endLine)?.ownerName??u.name,A=es(e.db,u);i.push({id:N,kind:"source-construct",label:Q,disposition:(o.get(N)?.length??0)>0?"emitted":"folded",location:{file:u.file,line:u.startLine,endLine:u.endLine},anchorIds:V(o.get(N)??[]),attributes:{regionId:b,leaf:Q,sourceOwned:!0,...A.evidence.length>0?{publicEntry:!0,publicEntryPriority:A.priority,publicEntryEvidence:A.evidence.join(",")}:{}}})}let r=new Map;for(let u of e.relations)u.fromBoundaryParticipant&&r.set(u.fromBoundaryParticipant.observationId,u.fromBoundaryParticipant),u.toBoundaryParticipant&&r.set(u.toBoundaryParticipant.observationId,u.toBoundaryParticipant);for(let u of[...r.values()].sort((b,N)=>b.observationId.localeCompare(N.observationId))){let b=e.regionForFile.get(u.file)?.id;if(!b)throw new Error(`Runtime-boundary participant ${u.observationId} has no structural region.`);i.push({id:Qt(u.observationId),kind:"runtime-boundary-participant",label:u.address||u.ownerName||`${u.role} ${u.action}`,disposition:"folded",location:{file:u.file,line:u.line,endLine:u.endLine},anchorIds:[],attributes:{regionId:b,action:u.action,protocol:u.protocol,role:u.role,...u.address?{address:u.address}:{},ownerSymbol:u.ownerSymbol}})}let a=new Set(i.map(u=>u.id)),l=ve(t,u=>u.file),d=(u,b,N,_,Q,A,ee=!1)=>{let ae=u?ke(u):null;if(ae&&a.has(ae)&&!le(u))return ae;let O=b?Qt(b.observationId):null;if(ee&&O&&a.has(O))return O;let Le=N?He(It(e.db,N)):null;if(Le&&a.has(Le))return Le;if(O&&a.has(O))return O;let we=A===null?null:(l.get(Q)??[]).filter(Ce=>Ce.startLine<=A&&Ce.endLine>=A).sort((Ce,$e)=>Ce.endLine-Ce.startLine-($e.endLine-$e.startLine)||Ce.startLine-$e.startLine)[0]??null;return we?He(we):ae&&a.has(ae)?ae:_},c=[];for(let u of e.symbolStates.values()){let b=e.regionForFile.get(u.definition.relativePath)?.id;if(!b)continue;let N=ke(u.definition.symbol);c.push({id:ge("edge","structural-membership",b,N),kind:"structural-membership",fromNodeId:b,toNodeId:N,directed:!0,disposition:"folded",semantics:ct("structural-membership"),evidence:[{method:"indexed-definition-file",strength:"exact",identity:u.definition.symbol,location:{file:u.definition.relativePath,line:u.definition.startLine,endLine:u.definition.endLine}}]})}let f=ve(e.relations,u=>`${d(u.fromSymbol,u.fromBoundaryParticipant,u.fromSourceConstruct,u.fromRegionId,u.fromFile,u.line,u.kind==="runtime-boundary")}\0${d(u.toSymbol,u.toBoundaryParticipant,u.toSourceConstruct,u.toRegionId,u.toFile,null)}\0${u.kind}`),y=new Set;for(let u of f.values()){let b=u[0],N=d(b.fromSymbol,b.fromBoundaryParticipant,b.fromSourceConstruct,b.fromRegionId,b.fromFile,b.line,b.kind==="runtime-boundary"),_=d(b.toSymbol,b.toBoundaryParticipant,b.toSourceConstruct,b.toRegionId,b.toFile,null);if(b.kind==="runtime-boundary"&&b.fromBoundaryParticipant){let A=Qt(b.fromBoundaryParticipant.observationId),ee=d(b.fromSymbol,void 0,b.fromSourceConstruct,b.fromRegionId,b.fromFile,b.line);ee!==A&&!y.has(A)&&(y.add(A),c.push({id:ge("edge","boundary-observation",ee,A),kind:"boundary-observation",fromNodeId:ee,toNodeId:A,directed:!0,disposition:"folded",semantics:ct("boundary-observation"),evidence:[{method:"runtime-boundary-observation-owner",strength:b.strength??"unknown",identity:b.fromBoundaryParticipant.observationId,location:{file:b.fromBoundaryParticipant.file,line:b.fromBoundaryParticipant.line,endLine:b.fromBoundaryParticipant.endLine}}]}))}(N===_?i.find(A=>A.id===N):null)?.kind!=="structural-region"&&c.push({id:ge("edge",b.kind,N,_),kind:b.kind,fromNodeId:N,toNodeId:_,directed:!0,disposition:"folded",semantics:Kn(b),evidence:ls(u.map(A=>({method:A.evidence,strength:A.strength??"unknown",identity:A.kind==="runtime-boundary"&&A.runtimeBoundaryKey?A.runtimeBoundaryKey:`${A.fromSymbol??A.fromFile} -> ${A.toSymbol??A.toFile}`,location:A.line===null?null:{file:A.fromFile,line:A.line}})))})}for(let u of e.externalBoundaries){let b=ge("external",u.kind,u.name),N=V(u.fromRegionIds);i.push({id:b,kind:u.kind,label:u.name,disposition:"folded",location:null,anchorIds:[],attributes:{}});for(let _ of N)c.push({id:ge("edge",u.kind,_,b),kind:u.kind,fromNodeId:_,toNodeId:b,directed:!0,disposition:"folded",semantics:ct("external-import"),evidence:[{method:"indexed-or-source-import",strength:"mixed",identity:`${_} -> ${u.name}`,location:null}]})}let m=[];e.boundaryFrontiers.forEach((u,b)=>{let N=e.regionForFile.get(u.file)?.id;if(!N)throw new Error(`Runtime-boundary frontier ${u.observationId} has no system-map region.`);let _=ge("unsupported","runtime-boundary",u.observationId,String(b)),Q=ge("edge","runtime-boundary-frontier",N,_);i.push({id:_,kind:"runtime-boundary-frontier",label:u.address,disposition:"unsupported",location:{file:u.file,line:u.line},anchorIds:[],attributes:{action:u.action,strength:u.strength,owner:u.ownerShortName}}),c.push({id:Q,kind:"runtime-boundary-frontier",fromNodeId:N,toNodeId:_,directed:!0,disposition:"unsupported",evidence:[{method:"runtime-boundary-extractor",strength:u.strength,identity:u.observationId,location:{file:u.file,line:u.line}}]}),m.push({id:ge("frontier","runtime-boundary",u.observationId,String(b)),kind:"runtime-boundary",direction:"unresolved",fromNodeIds:[N],edgeIds:[Q],memberNodeIds:[_],memberCount:1,disposition:"unsupported",reason:u.reason,expansion:null})});let v=vt({anchors:n,nodes:i,edges:c,paths:[],frontiers:m,scope:`explicit anchors; relations ${e.requestedRelationKinds.join(", ")}; depth ${e.maxDepth}; evidence floor ${e.evidenceFloor}; source scopes ${e.includedSourceScopes.join(", ")}`,blindSpots:[...e.blindSpots],incompleteReasons:e.closureStatus==="incomplete"?[`${e.omittedSymbolCandidates} ambiguous symbol candidate(s) were omitted`]:[]}),L=e.topologyFrontiers.some(u=>u==="frontier:program-facts"),S=Ro(v,{expandedFrontierIds:e.topologyFrontiers.filter(u=>u!=="frontier:program-facts"),routeIds:e.routeIds}),k=S.nodes.filter(u=>u.disposition==="emitted"||S.anchors.some(b=>b.status==="matched"&&b.nodeIds.includes(u.id))),q=e.relations.filter(u=>k.some(b=>os(u,b))),$=e.boundaryFrontiers.filter(u=>k.some(b=>rs(u,b))),P=Qn(e.db,q,k),H=Xn(e.db,k),B=uo(e.db,k,$),j=[...P.nodes,...H.nodes,...B.nodes].map(u=>L&&u.disposition==="folded"?{...u,disposition:"emitted"}:u),M=[...P.edges,...H.edges,...B.edges].map(u=>L&&u.disposition==="folded"?{...u,disposition:"emitted"}:u),G=L?null:is(k,j,M),g=vt({anchors:S.anchors,nodes:[...S.nodes,...j],edges:[...S.edges,...M],paths:S.paths,frontiers:[...S.frontiers,...P.frontiers,...H.frontiers,...B.frontiers,...G?[G]:[]],scope:S.coverage.scope,blindSpots:[...S.coverage.blindSpots,...P.blindSpots,...H.blindSpots,...B.blindSpots],incompleteReasons:S.coverage.status==="incomplete"?[S.coverage.explanation]:[],...S.routeCatalog?{routeCatalog:S.routeCatalog}:{}});g.completion=S.completion;for(let u of g.frontiers)u.disposition==="folded"&&(u.id.startsWith("frontier:program-facts:")||(u.expansion=ss(e,u.id)));return g}function os(e,t){if(e.fromSymbol&&t.id===ke(e.fromSymbol)||e.toSymbol&&t.id===ke(e.toSymbol))return!0;if(!t.location)return!1;let n=t.location.endLine??t.location.line;return t.location.file===e.fromFile&&e.line!==null&&e.line>=t.location.line&&e.line<=n||t.location.file===e.toFile}function rs(e,t){if(!t.location||t.location.file!==e.file)return!1;let n=t.location.endLine??t.location.line;return e.line>=t.location.line&&e.line<=n||t.label===e.ownerShortName||typeof e.ownerShortName=="string"&&t.label.includes(e.ownerShortName)}function is(e,t,n){let o=V(t.filter(i=>i.disposition==="folded").map(i=>i.id)),s=V(n.filter(i=>i.disposition==="folded").map(i=>i.id));return o.length===0&&s.length===0?null:{id:ge("frontier","program-facts"),kind:"program-facts",direction:"outgoing",fromNodeIds:V(e.map(i=>i.id)),edgeIds:s,memberNodeIds:o,memberCount:o.length,disposition:"folded",reason:"Control, data, state, and temporal facts are folded beneath the selected high-level owners.",expansion:null}}function ss(e,t){return`codebaseiq system-map ${[...e.anchors.flatMap(o=>o.kind==="literal"?[`--search ${X(o.query)}`]:[`--symbol ${X(o.query)}`]),`--depth ${e.maxDepth}`,...e.requestedRelationKinds.map(o=>`--relation ${X(o)}`),`--evidence-floor ${X(e.evidenceFloor)}`,...e.includedSourceScopes.map(o=>`--source-scope ${X(o)}`),...e.fullLiteralTraversal?["--full-literal-traversal"]:[],`--topology-characters ${e.maxTopologyCharacters}`,...e.expandedRegionIds.map(o=>`--expand ${X(o)}`),...e.topologyFrontiers.map(o=>`--frontier ${X(o)}`),...e.routeIds.map(o=>`--route ${X(o)}`),`--frontier ${X(t)}`].join(" ")}`}function as(e){let t=new Set;for(let n of e.nodes){if(n.disposition!=="emitted")continue;n.kind==="structural-region"&&t.add(n.id);let o=n.attributes.regionId;typeof o=="string"&&t.add(o)}return t}function ls(e){let t=new Map;for(let n of e){let o=n.location?`${n.location.file}:${n.location.line}`:"";t.set(`${n.method}\0${n.strength}\0${n.identity??""}\0${o}`,n)}return[...t.values()].sort((n,o)=>n.method.localeCompare(o.method)||(n.identity??"").localeCompare(o.identity??"")||(n.location?.file??"").localeCompare(o.location?.file??"")||(n.location?.line??0)-(o.location?.line??0))}function ge(...e){return e.map(t=>encodeURIComponent(t)).join(":")}function ke(e){return ge("symbol",e)}function ds(e){return e==="semantic-callee"||e==="scip-chunk"?"exact":"derived"}function cs(e,t,n,o,s,i,r,a,l,d){let c=[...o].sort((L,S)=>qo(L,S,s)),y=c.slice(0,Fo).map(L=>L.id),m=c.slice(Fo).map(L=>L.id),v=[...e.map(L=>`--search ${X(L)}`),...t.map(L=>`--symbol ${X(L)}`),`--depth ${n}`,...i.map(L=>`--relation ${X(L)}`),`--evidence-floor ${X(r)}`,...a.map(L=>`--source-scope ${X(L)}`),...l?["--full-literal-traversal"]:[],`--topology-characters ${d}`,...y.map(L=>`--expand ${X(L)}`)];return{command:y.length===0?null:`codebaseiq system-map ${v.join(" ")}`,regionCount:y.length,regionIds:y,candidateRegionCount:o.length,omittedRegionIds:m}}function us(e,t,n,o,s,i,r,a,l,d,c,f,y){let m=[...l].sort((g,u)=>qo(g,u,c)).filter(g=>!y||y.has(g.id)||f.has(g.id)),v=d.length>0?Math.floor(a*.4):0,L=a-v,S=new Set,k=0;for(let g of m){let u=$o(g);!f.has(g.id)&&S.size>0&&k+u>L||(S.add(g.id),k+=u)}let q=d.filter(g=>S.has(g.fromRegionId)&&S.has(g.toRegionId)).sort(ps),$=[];for(let g of q){let u=Ao(g);$.length>0&&k+u>a||($.push(Ct(g)),k+=u)}let P=l.filter(g=>!S.has(g.id)).map(g=>g.id).sort(),H=new Set($),B=d.filter(g=>!H.has(Ct(g))).length,j=l.reduce((g,u)=>g+$o(u),0)+d.reduce((g,u)=>g+Ao(u),0),M=m.every(g=>S.has(g.id))&&$.length===q.length,G=[...e.map(g=>`--search ${X(g)}`),...t.map(g=>`--symbol ${X(g)}`),`--depth ${n}`,...o.map(g=>`--relation ${X(g)}`),`--evidence-floor ${X(s)}`,...i.map(g=>`--source-scope ${X(g)}`),...r?["--full-literal-traversal"]:[],`--topology-characters ${Math.max(a,j)}`];return{maxCharacters:a,estimatedCharacters:k,totalEstimatedCharacters:j,regionIds:[...S],omittedRegionIds:P,relationKeys:$,omittedRelations:B,complete:M,expansionCommand:M?null:`codebaseiq system-map ${G.join(" ")}`}}function $o(e){return 120+e.id.length+e.anchorQueries.join(",").length+e.relationKinds.join(",").length+e.notableSymbols.slice(0,2).reduce((t,n)=>t+n.shortName.length+n.file.length,0)}function Ao(e){return 70+e.fromRegionId.length+e.toRegionId.length+e.kinds.join(",").length+e.evidence.join(",").length}function ps(e,t){let n=o=>o.kinds.includes("runtime-boundary")?0:o.kinds.includes("contract-symbol")?1:2;return n(e)-n(t)||t.relationCount-e.relationCount||Ct(e).localeCompare(Ct(t))}function Ct(e){return`${e.fromRegionId}\0${e.toRegionId}`}function qo(e,t,n){let o=a=>n.has(a.id)?0:1,s=a=>a.sourceFileCount===0?1:0,i=a=>a.symbolCount+a.literalHitCount>0?0:1,r=a=>[...a.incomingRegionIds,...a.outgoingRegionIds].filter(l=>n.has(l)).length;return o(e)-o(t)||i(e)-i(t)||s(e)-s(t)||e.minDepth-t.minDepth||r(t)-r(e)||t.literalHitCount-e.literalHitCount||e.testFileCount-t.testFileCount||e.label.localeCompare(t.label)}function ms(e){let t=[],n=new Set;for(let s of e.filter(i=>i.expanded)){for(let l of s.symbols)l.origins.includes("symbol-anchor")&&n.add(l.file);let i=ve(s.symbols,l=>l.file),r=ve(s.literalHits,l=>l.file),a=[...s.files].sort((l,d)=>gs(l,d,i,r));for(let l of a){let d=(i.get(l.file)??[]).sort(ys)[0];if(d){t.push({kind:"symbol",regionId:s.id,file:d.file,line:d.startLine,endLine:d.endLine,label:d.shortName});continue}let c=(r.get(l.file)??[]).sort(Ho)[0];c&&t.push({kind:"literal",regionId:s.id,file:c.file,line:c.line,endLine:null,label:c.ownerShortName??c.query})}}let o=fs(t,n);return{command:o.length===0?null:`codebaseiq inspect ${o.map(s=>`--at ${X(`${s.file}:${s.line+1}`)}`).join(" ")} --view behavior`,definitionCommand:null,candidateAnchors:t.length,selectedAnchors:o.length,omittedAnchors:t.length-o.length,anchors:o}}function fs(e,t){let n=[...ve(e,r=>r.regionId).values()],o=[],s=new Set,i=Math.min(Vi,24);for(let r of e)if(!(!t.has(r.file)||s.has(r.file))&&(o.push(r),s.add(r.file),o.length===i))return o;for(let r=0;o.length<i;r+=1){let a=!1;for(let l of n){let d=l[r];if(d&&(a=!0,!s.has(d.file)&&(o.push(d),s.add(d.file),o.length===i)))break}if(!a)break}return o}function gs(e,t,n,o){let s=a=>a.kind==="test"?2:a.kind==="barrel"?1:0,i=a=>(o.get(a.file)??[]).some(l=>l.traversalSeed)?0:1,r=a=>{let l=n.get(a.file)??[];return Math.min(5,...l.map(d=>rt(d.origins)))};return s(e)-s(t)||i(e)-i(t)||r(e)-r(t)||e.depth-t.depth||e.file.localeCompare(t.file)}function ys(e,t){return rt(e.origins)-rt(t.origins)||e.depth-t.depth||e.startLine-t.startLine||e.shortName.localeCompare(t.shortName)}function X(e){return`'${e.replaceAll("'","'\\''")}'`}function Ss(e,t,n,o){let s=[];for(let i of gn(e,{includeIgnored:!1})){let r=Ft(e,i);if(r.length===0)continue;let a=t.definitionsForFile(i),l=Me(e,i)?.callables??[];for(let d=0;d<r.length;d+=1){let c=r[d]??"";if(!c.includes(n))continue;let f=ze(a,d),y=Zt(l,d),m=f&&!le(f.symbol)?f:null,v=m?.startLine??y?.startLine??f?.startLine??d,L=m?.endLine??y?.endLine??f?.endLine??d,S=Bt(e,i,d,v,L),k=o.has(`${i}\0${d}`),q=!!(m?.isFunctionLike||y);s.push({relativePath:i,line:d,sourceLine:c,ownerSymbol:m?.symbol??null,ownerShortName:m?ie(m.symbol):y?.name??(f?ie(f.symbol):null),ownerStartLine:S.startLine,ownerEndLine:S.endLine,matchKind:vs(c,n),seedPriority:k?0:q?1:2})}}return s}function bs(e,t){let n={"exact-value":0,boundary:1,embedded:2};return e.seedPriority-t.seedPriority||n[e.matchKind]-n[t.matchKind]||e.relativePath.localeCompare(t.relativePath)||e.line-t.line}function Do(e){return`${e.relativePath}\0${e.line}`}function Zt(e,t){return e.filter(n=>n.startLine<=t&&n.endLine>=t).sort((n,o)=>n.endLine-n.startLine-(o.endLine-o.startLine)||n.startLine-o.startLine)[0]??null}function Yt(e,t,n){let s=Zt(Me(e,t)?.callables??[],n)??zo(e,t,n);if(!s)return null;let i=Bt(e,t,n,s.startLine,s.endLine);return{file:t,name:s.name,startLine:i.startLine,endLine:i.endLine}}function zo(e,t,n){let o=Be(e,t)?.rootNode;if(!o||o.startPosition.row>n||o.endPosition.row<n)return null;let s=en(o,n);for(;s;){if(s.type==="variable_declarator"){let r=s.childForFieldName("name")??s.namedChild(0),a=s.childForFieldName("value")??s.namedChild(1);if(r?.type==="identifier"&&a&&Jt(a,n))return{name:r.text,startLine:s.startPosition.row,endLine:s.endPosition.row}}if(s.type==="pair"){let r=s.childForFieldName("key")??s.namedChild(0),a=s.childForFieldName("value")??s.namedChild(1),l=r?.text.replace(/^(?:['"])(.*)(?:['"])$/u,"$1");if(l&&a&&/^[A-Za-z_$][\w$]*$/u.test(l)&&Jt(a,n))return{name:l,startLine:s.startPosition.row,endLine:s.endPosition.row}}s=s.parent}let i=Dt(e,t,n);return i?{name:`source@${n+1}`,startLine:i.startLine,endLine:i.endLine}:null}function Jt(e,t){return["arrow_function","function_expression","generator_function","generator_function_declaration"].includes(e.type)&&e.startPosition.row<=t&&e.endPosition.row>=t?!0:e.namedChildren.some(n=>n.startPosition.row<=t&&n.endPosition.row>=t&&Jt(n,t))}function en(e,t){let n=e.namedChildren.filter(o=>o.startPosition.row<=t&&o.endPosition.row>=t).sort((o,s)=>o.endIndex-o.startIndex-(s.endIndex-s.startIndex)||o.startPosition.row-s.startPosition.row)[0];return n?en(n,t):e}function hs(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/u);if(!n)return null;let o=yn(e,n[1],{allowMultiple:!1})[0]?.relativePath;if(!o)return null;let s=Math.max(0,Number.parseInt(n[2],10)-1),i=n[3]?Math.max(s,Number.parseInt(n[3],10)-1):s,r=(Me(e,o)?.callables??[]).filter(a=>a.startLine<=s&&a.endLine>=i).sort((a,l)=>a.endLine-a.startLine-(l.endLine-l.startLine)||a.startLine-l.startLine)[0];return r?{file:o,name:r.name,startLine:r.startLine,endLine:r.endLine}:null}function xs(e){return{symbol:`source-construct:${e.file}:${e.startLine}:${e.endLine}:${e.name}`,shortName:e.name,relativePath:e.file,startLine:e.startLine,endLine:e.endLine}}function vs(e,t){let n=/[\p{L}\p{N}_$]/u,o=e.indexOf(t);for(;o>=0;){let s=e[o-1]??"",i=e[o+t.length]??"";if((s==="'"||s==='"'||s==="`")&&i===s)return"exact-value";if(!n.test(s)&&!n.test(i))return"boundary";o=e.indexOf(t,o+Math.max(1,t.length))}return"embedded"}function Xt(e){return dt(e)==="test"?!1:!/(?:^|[/._-])(?:fixtures?|mocks?|previews?|demos?|examples?|stories)(?:[/._-]|$)/iu.test(e)}function Is(e,t){return e.matchKind!=="embedded"&&t(e.relativePath)&&($t(e.relativePath)!=="production"||Xt(e.relativePath))}function Es(e,t){let n=[...t].sort(Ls),o=[],s=new Set;for(let i of n)if(!s.has(i.relativePath)&&(o.push(i),s.add(i.relativePath),o.length>=To))break;for(let i of n){if(o.length>=To)break;o.includes(i)||o.push(i)}return o.map(i=>({query:e,file:i.relativePath,line:i.line,ownerSymbol:i.ownerSymbol,ownerShortName:i.ownerShortName,ownerStartLine:i.ownerStartLine,ownerEndLine:i.ownerEndLine,sourceLine:i.sourceLine.trim(),matchKind:i.matchKind,traversalSeed:!1}))}function Ls(e,t){let n={"exact-value":0,boundary:1,embedded:2};return n[e.matchKind]-n[t.matchKind]||+(t.ownerSymbol!==null)-+(e.ownerSymbol!==null)||+!Xt(e.relativePath)-+!Xt(t.relativePath)||e.relativePath.localeCompare(t.relativePath)||e.line-t.line}function ws(e,t){let n=new Map;for(let o of t){let s=Cs(o.relativePath);n.set(s,(n.get(s)??0)+1)}return[...n].sort(([o,s],[i,r])=>r-s||o.localeCompare(i)).slice(0,Hi).map(([o])=>`codebaseiq search ${X(e)} --scope ${X(o)}`)}function Cs(e){let t=e.split("/").filter(Boolean);if(t.length<=1)return e;let n=t.slice(0,-1),o=n.lastIndexOf("src");return o>=0?n.slice(0,Math.min(n.length,o+3)).join("/"):n.slice(0,Math.min(n.length,3)).join("/")}function Ns(e,t,n){let o=t.callerFileMap([n],{semantic:!1}).get(n.symbolId)??new Set,s=[];for(let i of[...o].sort()){let r=n.leaf?Pt(e,i,n.leaf):[];if(r.length===0){s.push({file:i,line:null,enclosingSymbol:null});continue}let a=t.definitionsForFile(i);for(let l of r)s.push({file:i,line:l,enclosingSymbol:ze(a,l)?.symbol??null})}return s}function Ms(e,t){let n=e.all(`SELECT DISTINCT gs.symbol, def_d.relative_path AS from_file
2
2
  FROM mentions m
3
3
  JOIN chunks c ON m.chunk_id = c.id
4
4
  JOIN documents imp_d ON c.document_id = imp_d.id
@@ -13,4 +13,4 @@ import{a as Bn,b as _n}from"./chunk-PARCKE3Q.js";import{a as Dt,b as Bt}from"./c
13
13
  LEFT JOIN documents def_d ON sym_def.document_id = def_d.id
14
14
  WHERE imp_d.relative_path = ? AND m.role = 2
15
15
  ORDER BY def_d.relative_path, gs.symbol`,t);return n.length>0?n.map(o=>({symbol:o.symbol,shortName:ie(o.symbol),importedName:Bo(ie(o.symbol)),localName:Bo(ie(o.symbol)),fromFile:o.from_file,source:"compiler"})):bn(e,t).map(o=>{let s=Rs(o.importedName,o.localName,o.kind),i=o.localName??o.importedName,r=o.importedName==="default"?i:o.importedName;return{symbol:s,shortName:s,importedName:r,localName:i,fromFile:o.sourcePath,source:"parsed-source"}})}function Bo(e){return e.slice(e.lastIndexOf(":")+1).replace(/\(\)$/u,"")||e}function Rs(e,t,n){return n==="namespace"&&e==="*"&&t?`* as ${t}`:n==="default"&&t?`default as ${t}`:n==="side-effect"?"(side effect import)":t&&t!==e?`${e} as ${t}`:e}function Pe(e,t,n){let o=kt(e,n);if(!o.match)return{matches:[],total:0,omitted:0};let s=[o.match,...o.candidates.map(r=>kt(e,r.symbol).match)].filter(r=>r!==null),i=new Map;for(let r of s){let a=t.definitionsForFile(r.relativePath).find(l=>l.symbol===r.symbol);a&&i.set(a.symbol,a)}return{matches:[...i.values()],total:o.total,omitted:Math.max(0,o.total-i.size)}}function Ts(e){return{symbol:e.symbol,shortName:ie(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine}}function fe(e,t){let n=[t.kind,t.fromFile,t.fromSymbol??"",t.toFile,t.toSymbol??"",t.fromBoundaryParticipant?.observationId??"",t.toBoundaryParticipant?.observationId??"",t.fromSourceConstruct?Ee(t.fromSourceConstruct):"",t.toSourceConstruct?Ee(t.toSourceConstruct):"",t.runtimeBoundaryKey??"",t.line??""].join("\0");e.set(n,t)}function Ge(e){return{observationId:e.id,action:e.action,protocol:e.protocol,role:e.role,address:Uo(e),file:e.source.file,line:e.source.startLine,endLine:e.source.endLine,ownerName:e.owner.name,ownerSymbol:e.owner.symbol}}function Et(e,t){let n=Ft(e,t.source.file);return Fn(e,t.source.file,0,Math.max(0,n.length-1),[t.source.startLine])}function _o(e,t){let n=[...e.values()];for(let o of[t.owner,t.source]){let s=n.filter(i=>i.file===o.file&&i.startLine<=o.startLine&&i.endLine>=o.startLine).sort((i,r)=>i.endLine-i.startLine-(r.endLine-r.startLine)||i.startLine-r.startLine)[0];if(s)return s}return null}function Oo(e,t,n,o,s){let i=[],r=n.get(e.id);r!==void 0&&r<=t&&i.push(r);for(let a of o.values()){if(a.depth>t)continue;let l=a.definition;Ko(l,e)&&i.push(a.depth)}for(let a of s.values())a.depth>t||Ko(a,e)&&i.push(a.depth);return i.length>0?Math.min(...i):null}function Ko(e,t){let n=e.relativePath??e.file;return[t.owner,t.source].some(o=>n===o.file&&e.startLine<=o.startLine&&e.endLine>=o.startLine)}function Qt(e){return ge("runtime-boundary-participant",e)}function Fs(e,t,n){let o=ye(e,n),s=ye(t,n);return o.relativeDir!==s.relativeDir?!0:/(?:^|\/)(?:contracts?|schemas?|db\/schema)(?:\/|$)/u.test(t)}function Ps(e,t,n){return ot(e,n).id===ot(t,n).id}function ks(e,t,n,o){if(e.referenceScope==="all")return!0;let s=ot(t,o).id;return[...n.values()].some(r=>r.promoteBoundaryImports&&ot(r.file,o).id===s)?!0:e.referenceScope!=="cross-workspace-or-forward"?!1:ye(t,o).relativeDir!==ye(e.definition.relativePath,o).relativeDir}function $s(e,t){let n={none:0,"forward-regions":1,"cross-workspace-or-forward":2,all:3};return n[e]>=n[t]?e:t}function As(e){let t=new Map;for(let[n,o]of e)for(let s of o){let i=t.get(s)??new Set;i.add(n),t.set(s,i)}return t}function ye(e,t){return t.find(n=>e===n.relativeDir||e.startsWith(`${n.relativeDir}/`))??{name:"root",relativeDir:""}}function Ds(e){let t=new Set(["apps","packages","services","crates","libs","tools"]),n=new Map;for(let o of e){let s=o.split("/").filter(Boolean);if(s.length<3||!t.has(s[0]))continue;let i=`${s[0]}/${s[1]}`;n.set(i,{name:s[1],relativeDir:i})}return[...n.values()].sort((o,s)=>s.relativeDir.length-o.relativeDir.length)}function ot(e,t){let n=ye(e,t),s=(n.relativeDir?e.slice(n.relativeDir.length+1):e).split("/").filter(Boolean);s[0]==="src"&&s.shift();let i=Bs(s);return{id:`region:${n.relativeDir||"root"}:${i}`,label:`${n.name}:${i}`,workspace:n.name,structuralPath:i}}function Bs(e){if(e.length<=1)return"root";let t=e[0],n=e[1];return["components","features","modules"].includes(t)?`${t}/${n}`:t==="db"?`${t}/${n}`:["contracts","routes","services"].includes(t)?t:t==="tests"||t==="__tests__"?"tests":t}function _s(e,t,n,o,s,i,r){let a=ve([...e.values()],m=>i.get(m.file).id),l=ve([...t.values()],m=>i.get(m.definition.relativePath).id),d=ve(n,m=>i.get(m.file).id),c=new Map;for(let m of o)for(let v of new Set([m.fromRegionId,m.toRegionId])){let L=c.get(v)??[];L.push(m),c.set(v,L)}let f=ve(s,m=>m.toRegionId),y=ve(s,m=>m.fromRegionId);return[...a.entries()].map(([m,v])=>{let L=i.get(v[0].file),S=l.get(m)??[],k=d.get(m)??[],q=c.get(m)??[],$=r.has(m),P=S.map(js).sort(Ws).slice(0,Gi),H=v.filter(B=>dt(B.file)==="test").length;return{id:m,label:L.label,workspace:L.workspace,structuralPath:L.structuralPath,minDepth:Math.min(...v.map(B=>B.depth)),fileCount:v.length,sourceFileCount:v.length-H,testFileCount:H,symbolCount:S.length,literalHitCount:k.length,anchorQueries:V([...k.map(B=>B.query),...S.flatMap(B=>[...B.anchorQueries])]),relationKinds:V(q.map(B=>B.kind)),incomingRegionIds:V((f.get(m)??[]).map(B=>B.fromRegionId)),outgoingRegionIds:V((y.get(m)??[]).map(B=>B.toRegionId)),memberCallCandidateRelationCount:q.filter(B=>B.evidence==="ast-member-import-candidate").length,notableSymbols:P,omittedNotableSymbols:Math.max(0,S.length-P.length),expanded:$,files:$?v.map(Os).sort(Hs):[],symbols:$?S.map(Ks).sort(Gs):[],literalHits:$?[...k].sort(Ho):[],relations:$?[...q].sort(Wo):[]}}).sort((m,v)=>m.minDepth-v.minDepth||m.label.localeCompare(v.label))}function Os(e){return{file:e.file,kind:dt(e.file),depth:e.depth,origins:V([...e.origins])}}function Ks(e){return{symbol:e.definition.symbol,shortName:ie(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,depth:e.depth,origins:V([...e.origins]),anchorQueries:V([...e.anchorQueries]),referenceExpansion:e.referenceScope!=="none",referenceScope:e.referenceScope}}function js(e){return{shortName:ie(e.definition.symbol),file:e.definition.relativePath,origins:V([...e.origins])}}function qs(e){return[...ve(e.filter(n=>n.fromRegionId!==n.toRegionId),n=>`${n.fromRegionId}\0${n.toRegionId}`).values()].map(n=>({fromRegionId:n[0].fromRegionId,toRegionId:n[0].toRegionId,kinds:V(n.map(o=>o.kind)),relationCount:n.length,fromFiles:V(n.map(o=>o.fromFile)),toFiles:V(n.map(o=>o.toFile)),fromSymbols:V(n.flatMap(o=>o.fromSymbol?[ie(o.fromSymbol)]:[])),toSymbols:V(n.flatMap(o=>o.toSymbol?[ie(o.toSymbol)]:[])),evidence:V(n.map(o=>o.evidence)),strengths:V(n.map(o=>o.strength??"unknown"))})).sort((n,o)=>n.fromRegionId.localeCompare(o.fromRegionId)||n.toRegionId.localeCompare(o.toRegionId))}function zs(e,t){return[...e.values()].map(n=>({kind:"external-import",name:n.name,fromRegionIds:V([...n.fromFiles].flatMap(o=>{let s=t.get(o);return s?[s.id]:[]})),fromFiles:V([...n.fromFiles])})).sort((n,o)=>n.name.localeCompare(o.name))}function Us(e,t,n,o){let s=e.kind==="literal"?t.filter(i=>i.query===e.query).map(i=>i.file):[...n.values()].filter(i=>i.anchorQueries.has(e.query)).map(i=>i.definition.relativePath);return V(s.map(i=>o.get(i)?.id).filter(i=>!!i))}function Uo(e){return e.keyParts.map(t=>`${t.name}=${t.value}`).join(" ")}function Lt(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function V(e){return[...new Set(e)].sort()}function ve(e,t){let n=new Map;for(let o of e){let s=t(o),i=n.get(s)??[];i.push(o),n.set(s,i)}return n}function Wo(e,t){return e.fromRegionId.localeCompare(t.fromRegionId)||e.toRegionId.localeCompare(t.toRegionId)||e.kind.localeCompare(t.kind)||e.fromFile.localeCompare(t.fromFile)||e.toFile.localeCompare(t.toFile)||(e.line??-1)-(t.line??-1)}function Ws(e,t){return rt(e.origins)-rt(t.origins)||e.shortName.localeCompare(t.shortName)}function rt(e){return e.includes("symbol-anchor")?0:e.includes("literal-owner")?1:e.some(t=>t.startsWith("boundary-import:"))?2:e.includes("reference-owner")?3:4}function Hs(e,t){return e.depth-t.depth||e.file.localeCompare(t.file)}function Gs(e,t){return e.depth-t.depth||e.file.localeCompare(t.file)||e.symbol.localeCompare(t.symbol)}function Ho(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.query.localeCompare(t.query)}export{Xa as a,Za as b,Ct as c};
16
- //# sourceMappingURL=chunk-DKJXK3HA.js.map
16
+ //# sourceMappingURL=chunk-6BF3VYEF.js.map