codebaseiq 0.1.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 (447) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +1 -1
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/{chunk-ZMI2JSX2.js → chunk-23C5AD3B.js} +2 -2
  5. package/dist/chunk-2E6OUPCF.js +2 -0
  6. package/dist/chunk-2EDX3JT5.js +3 -0
  7. package/dist/chunk-2I2UHZET.js +2 -0
  8. package/dist/{chunk-T3DGWPXM.js → chunk-2OMXFE64.js} +2 -2
  9. package/dist/chunk-2PRONPAS.js +3 -0
  10. package/dist/{chunk-GW6Z3WGY.js → chunk-356EZBIP.js} +2 -2
  11. package/dist/{chunk-UDS562V4.js → chunk-36JC5BG2.js} +2 -2
  12. package/dist/chunk-3RR2K7EZ.js +20 -0
  13. package/dist/{chunk-JE3WZ6II.js → chunk-3RSBGWGL.js} +2 -2
  14. package/dist/{chunk-VE5AVNMP.js → chunk-3VJ3OCRE.js} +2 -2
  15. package/dist/{chunk-FDGD5AB5.js → chunk-4LK5OIPW.js} +2 -2
  16. package/dist/chunk-5DSL3NT2.js +17 -0
  17. package/dist/chunk-5FWR5HLG.js +90 -0
  18. package/dist/chunk-5IC2WZAL.js +22 -0
  19. package/dist/{chunk-MVB3DAEY.js → chunk-5IZRKWTZ.js} +2 -2
  20. package/dist/{chunk-Q65CQ4XL.js → chunk-5LL4KEHO.js} +2 -2
  21. package/dist/chunk-5T44HG5Y.js +88 -0
  22. package/dist/{chunk-TRRC4ZJ7.js → chunk-5ZI2PPI7.js} +2 -2
  23. package/dist/{chunk-7XAN6GKB.js → chunk-67VJAYVR.js} +2 -2
  24. package/dist/{chunk-MOVBWNIP.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-JOIRNPPY.js → chunk-6VREELBC.js} +2 -2
  28. package/dist/chunk-6WAPPQ5F.js +82 -0
  29. package/dist/{chunk-FW53T7EB.js → chunk-75KJGYX7.js} +2 -2
  30. package/dist/chunk-7GAK2F3H.js +77 -0
  31. package/dist/{chunk-UBGWN7I4.js → chunk-7JELP5YE.js} +2 -2
  32. package/dist/chunk-7UCDGXRW.js +8 -0
  33. package/dist/{chunk-L57ZKWVG.js → chunk-AEXQYQD7.js} +2 -2
  34. package/dist/chunk-AQI4N64O.js +22 -0
  35. package/dist/{chunk-ICFDQHAM.js → chunk-AURCQHSG.js} +2 -2
  36. package/dist/{chunk-I2T2LLK2.js → chunk-BBP7HVBJ.js} +2 -2
  37. package/dist/{chunk-OFBE4NGP.js → chunk-BFBIMTCJ.js} +2 -2
  38. package/dist/{chunk-JEJLSICM.js → chunk-BGGB5N53.js} +2 -2
  39. package/dist/{chunk-TIIC3ZE7.js → chunk-BRQL7AFJ.js} +2 -2
  40. package/dist/{chunk-YSNONTJ2.js → chunk-BWL3PMPT.js} +2 -2
  41. package/dist/chunk-C6WKPKCF.js +127 -0
  42. package/dist/{chunk-YESXMKX3.js → chunk-C7OUW52M.js} +2 -2
  43. package/dist/chunk-C7QWUBR2.js +545 -0
  44. package/dist/{chunk-4WKDMDEW.js → chunk-CCIYWXX6.js} +2 -2
  45. package/dist/{chunk-FAJQ7LWY.js → chunk-CIYA2KZN.js} +2 -2
  46. package/dist/{chunk-VEXUL62T.js → chunk-CR3OG6SQ.js} +2 -2
  47. package/dist/{chunk-JSOYNVWH.js → chunk-CVHOQONG.js} +2 -2
  48. package/dist/{chunk-LU3BMVH2.js → chunk-CW6AXOLR.js} +2 -2
  49. package/dist/{chunk-TXXOEMZJ.js → chunk-D53LWANR.js} +2 -2
  50. package/dist/{chunk-DO6WQD2T.js → chunk-D62CTZX6.js} +2 -2
  51. package/dist/{chunk-N3IQCBCF.js → chunk-D7AZAOZX.js} +2 -2
  52. package/dist/{chunk-RDBI2RXU.js → chunk-D7DOB27N.js} +7 -7
  53. package/dist/chunk-DAKIGMIK.js +21 -0
  54. package/dist/chunk-DDN2F6GB.js +2 -0
  55. package/dist/chunk-DUKHVPU5.js +4 -0
  56. package/dist/chunk-DVWO7RBC.js +2 -0
  57. package/dist/{chunk-HKQUXIFO.js → chunk-E52K4L2W.js} +2 -2
  58. package/dist/chunk-EIBGSU2R.js +2 -0
  59. package/dist/chunk-EN4AHLL3.js +3 -0
  60. package/dist/chunk-EQNMD62X.js +51 -0
  61. package/dist/{chunk-ENCCHKM6.js → chunk-EXZ7VLRY.js} +4 -4
  62. package/dist/{chunk-NEDP5RFQ.js → chunk-F3QSL4W2.js} +2 -2
  63. package/dist/{chunk-O6QTXQPJ.js → chunk-F74LZWCE.js} +2 -2
  64. package/dist/{chunk-BH5F2Q4O.js → chunk-FEIZXBLH.js} +2 -2
  65. package/dist/chunk-FH5WG4LE.js +2 -0
  66. package/dist/{chunk-BVAJLC5A.js → chunk-FOZ74V56.js} +2 -2
  67. package/dist/{chunk-L4NRUAGJ.js → chunk-FQTIFWLR.js} +2 -2
  68. package/dist/chunk-FTTV7IRX.js +355 -0
  69. package/dist/chunk-FWQGH2N2.js +2 -0
  70. package/dist/{chunk-CAUCPUOF.js → chunk-GDHWOA57.js} +2 -2
  71. package/dist/{chunk-6MUIJMVL.js → chunk-GIDCP7KV.js} +2 -2
  72. package/dist/{chunk-ZV3JV5G5.js → chunk-GL6UTNUB.js} +2 -2
  73. package/dist/chunk-GP7C5VAE.js +2 -0
  74. package/dist/{chunk-FQKZWM4L.js → chunk-GQLDYCWS.js} +5 -5
  75. package/dist/chunk-GQXXOS55.js +2 -0
  76. package/dist/{chunk-H3LGFZVK.js → chunk-GUFPEFBG.js} +2 -2
  77. package/dist/{chunk-NNOKTMZT.js → chunk-GV2CEZCW.js} +2 -2
  78. package/dist/{chunk-FETNQCFO.js → chunk-GVAF222T.js} +2 -2
  79. package/dist/chunk-GWYZVVKY.js +21 -0
  80. package/dist/{chunk-7FND7D7N.js → chunk-HENP2O4A.js} +2 -2
  81. package/dist/{chunk-LZYFLFEH.js → chunk-HINZQKSY.js} +2 -2
  82. package/dist/{chunk-RR7SX44N.js → chunk-HQA7EBSK.js} +2 -2
  83. package/dist/{chunk-XMQ23E27.js → chunk-HVFB3PME.js} +2 -2
  84. package/dist/chunk-I22IZYDI.js +2 -0
  85. package/dist/chunk-ICUL7XRT.js +21 -0
  86. package/dist/{chunk-CQP3THUZ.js → chunk-IHSLIIL3.js} +2 -2
  87. package/dist/{chunk-34WBMAYK.js → chunk-ITSJMNUD.js} +2 -2
  88. package/dist/{chunk-PX4RYAAK.js → chunk-IZDPGOZR.js} +2 -2
  89. package/dist/chunk-J3GLP7Q5.js +3 -0
  90. package/dist/{chunk-CVYSU6BX.js → chunk-J7AMBVWF.js} +2 -2
  91. package/dist/{chunk-Y6KHROC3.js → chunk-JCMFBF4Z.js} +2 -2
  92. package/dist/chunk-JFIA2JI3.js +3 -0
  93. package/dist/chunk-JLZLLLW5.js +3 -0
  94. package/dist/{chunk-5PUWMSDU.js → chunk-JSNTHRLQ.js} +2 -2
  95. package/dist/{chunk-C6SBF2WH.js → chunk-JX6ZWDOS.js} +2 -2
  96. package/dist/{chunk-4XTAUQFD.js → chunk-JYI7CV25.js} +2 -2
  97. package/dist/chunk-K7JLSGCJ.js +8 -0
  98. package/dist/{chunk-XWUOUWYI.js → chunk-KPZGTB2O.js} +2 -2
  99. package/dist/{chunk-VXYS3FZD.js → chunk-LKUTSP4G.js} +2 -2
  100. package/dist/{chunk-GTXSJDCO.js → chunk-LMTSB3TB.js} +2 -2
  101. package/dist/chunk-LONKINMJ.js +543 -0
  102. package/dist/{chunk-WMPRTGH2.js → chunk-LQHYYIOB.js} +2 -2
  103. package/dist/{chunk-VUIYB2V3.js → chunk-LZSQ6X7E.js} +2 -2
  104. package/dist/{chunk-ST7V3SKN.js → chunk-M2Y6PCFE.js} +2 -2
  105. package/dist/chunk-MEUHIDI3.js +7 -0
  106. package/dist/{chunk-OZYRSMSH.js → chunk-MHWMEZDA.js} +2 -2
  107. package/dist/{chunk-RKEJ6VTF.js → chunk-MQW6SJ4P.js} +2 -2
  108. package/dist/{chunk-J77SU6VA.js → chunk-MSI3K7PJ.js} +2 -2
  109. package/dist/chunk-MVRGB4KJ.js +278 -0
  110. package/dist/{chunk-DQMDCD24.js → chunk-MZNMASFM.js} +2 -2
  111. package/dist/{chunk-ID63777H.js → chunk-NBCQZSGR.js} +2 -2
  112. package/dist/chunk-NBZKSTXP.js +2 -0
  113. package/dist/{chunk-SZD2KF7Q.js → chunk-NCJILOAK.js} +2 -2
  114. package/dist/{chunk-C7QOQX32.js → chunk-NDKOVQFG.js} +2 -2
  115. package/dist/{chunk-UNBY47BC.js → chunk-NEWHKGVD.js} +2 -2
  116. package/dist/{chunk-PYAB5SM6.js → chunk-O2M3VNDY.js} +2 -2
  117. package/dist/chunk-OFGOOL6U.js +3 -0
  118. package/dist/{chunk-SWHMHUKF.js → chunk-OQUCBKOI.js} +2 -2
  119. package/dist/{chunk-7MGU3HPH.js → chunk-P4NVCOM7.js} +2 -2
  120. package/dist/{chunk-ANFVSJWQ.js → chunk-PFC44E6D.js} +2 -2
  121. package/dist/{chunk-EZNMUY67.js → chunk-PHNCEUXX.js} +2 -2
  122. package/dist/{chunk-4FC325IF.js → chunk-PTQPPPG2.js} +2 -2
  123. package/dist/chunk-PUVNH4PO.js +3 -0
  124. package/dist/chunk-Q23IMHXS.js +343 -0
  125. package/dist/chunk-Q3ZCQY2Y.js +3 -0
  126. package/dist/{chunk-KMITESMT.js → chunk-Q4XEU3UH.js} +2 -2
  127. package/dist/{chunk-QKPLA6IC.js → chunk-QEOWONKY.js} +2 -2
  128. package/dist/{chunk-BJ6SQAEN.js → chunk-QMOZZ2VX.js} +2 -2
  129. package/dist/chunk-RCIGX23V.js +60 -0
  130. package/dist/{chunk-IOP6FWIM.js → chunk-RIYJ4L33.js} +2 -2
  131. package/dist/chunk-RJVAPMHF.js +14 -0
  132. package/dist/chunk-SB7NASHU.js +2 -0
  133. package/dist/{chunk-UZGZB3VB.js → chunk-SGMNWYTH.js} +2 -2
  134. package/dist/chunk-SMDIEDM4.js +27 -0
  135. package/dist/chunk-SV2LEFVM.js +2 -0
  136. package/dist/chunk-SX72EVMY.js +3 -0
  137. package/dist/chunk-T5X7DK6C.js +3 -0
  138. package/dist/{chunk-6NW7MU72.js → chunk-T6MQNNAC.js} +2 -2
  139. package/dist/chunk-T75DS2E6.js +21 -0
  140. package/dist/{chunk-HRWGYWRJ.js → chunk-TEANKHUU.js} +2 -2
  141. package/dist/chunk-TJBOJUVN.js +3 -0
  142. package/dist/{chunk-XLQ3GLWZ.js → chunk-TJWVT4DO.js} +2 -2
  143. package/dist/{chunk-7NVGT435.js → chunk-TNJGTQWO.js} +2 -2
  144. package/dist/{chunk-NE6IU5ZD.js → chunk-TOTWJZIX.js} +2 -2
  145. package/dist/{chunk-PBI2LFKH.js → chunk-TPO7XC5Z.js} +2 -2
  146. package/dist/{chunk-HPJRBHVT.js → chunk-U33PMPNW.js} +2 -2
  147. package/dist/{chunk-QHRNXP3C.js → chunk-U7NUXDQO.js} +2 -2
  148. package/dist/chunk-UC2FD2PS.js +4 -0
  149. package/dist/{chunk-PIOMTC27.js → chunk-UQE4XFSA.js} +2 -2
  150. package/dist/chunk-UQYQBLJX.js +5 -0
  151. package/dist/{chunk-KWVHSKHK.js → chunk-USOAJHY7.js} +2 -2
  152. package/dist/{chunk-GCHRX4YW.js → chunk-UW6KD57C.js} +2 -2
  153. package/dist/{chunk-PTAWHLVJ.js → chunk-VGWZ4MOY.js} +2 -2
  154. package/dist/{chunk-XME3HPXZ.js → chunk-VWYGCMV5.js} +2 -2
  155. package/dist/{chunk-AKB7V7TV.js → chunk-W7YLRXZE.js} +2 -2
  156. package/dist/{chunk-SYDJMPES.js → chunk-WK2IQJPK.js} +2 -2
  157. package/dist/{chunk-RBAS5ZHI.js → chunk-WWCV4E6J.js} +2 -2
  158. package/dist/{chunk-OL6KJP3N.js → chunk-XMJ53WG4.js} +2 -2
  159. package/dist/chunk-XN3EKMLI.js +4 -0
  160. package/dist/chunk-XQAVQVIL.js +3 -0
  161. package/dist/{chunk-IJ4HMYBE.js → chunk-XQPPURLQ.js} +2 -2
  162. package/dist/{chunk-OVTS4DKB.js → chunk-YHPG3S2U.js} +2 -2
  163. package/dist/{chunk-WOQBZPIF.js → chunk-YRKP7PM7.js} +2 -2
  164. package/dist/chunk-YT4DVWUV.js +11 -0
  165. package/dist/chunk-YTJHCGYB.js +61 -0
  166. package/dist/chunk-Z35GOVEH.js +2 -0
  167. package/dist/{chunk-OLF4MA5W.js → chunk-Z6RL7XOE.js} +4 -4
  168. package/dist/{chunk-UP3BUZR5.js → chunk-ZAFGY22Q.js} +2 -2
  169. package/dist/{chunk-CO5R3UNA.js → chunk-ZB4C5TTR.js} +2 -2
  170. package/dist/{chunk-ZZXSWSN6.js → chunk-ZNH33XIB.js} +2 -2
  171. package/dist/{chunk-EMNIHCRB.js → chunk-ZQ62NNKN.js} +2 -2
  172. package/dist/cli-context-FJL2JHOE.js +3 -0
  173. package/dist/cli-context-PQNWHMCQ.js +2 -0
  174. package/dist/cli-program-UO7PZD6V.js +7 -0
  175. package/dist/cli.js +1 -1
  176. package/dist/{code-DlqpBDd0.d.ts → code-DfX3xeWy.d.ts} +1 -1
  177. package/dist/code-viewer-KIXEYQNJ.js +12 -0
  178. package/dist/code-viewer-VHLBLIUM.js +11 -0
  179. package/dist/command-descriptors-F5P2V3NW.js +335 -0
  180. package/dist/command-descriptors-YCLATF5I.js +337 -0
  181. package/dist/{config-types-BNoC96J3.d.ts → config-types-D6X5S68_.d.ts} +50 -0
  182. package/dist/{db-D7sauVFH.d.ts → db-BoG_PWYH.d.ts} +2 -2
  183. package/dist/direct-navigation-4XJTXIDT.js +2 -0
  184. package/dist/direct-navigation-J5MVYYAD.js +3 -0
  185. package/dist/{graph-evidence-BIFqyisO.d.ts → graph-evidence-D1jx1Cql.d.ts} +1 -1
  186. package/dist/{health-DJaZXg8I.d.ts → health-DkYBS5BI.d.ts} +1 -1
  187. package/dist/index.d.ts +2 -2
  188. package/dist/index.js +1 -1
  189. package/dist/invocation-command-descriptors-RWV4VAI4.js +2 -0
  190. package/dist/invocation-command-descriptors-U76PN7IY.js +3 -0
  191. package/dist/{scip-cli-B7N3haxa.d.ts → maintenance-types-CdL5eQii.d.ts} +2 -21
  192. package/dist/output-continuation-command-BL25S26S.js +3 -0
  193. package/dist/output-continuation-command-BTETTXEC.js +2 -0
  194. package/dist/postinstall.js +1 -1
  195. package/dist/project-reindex-CRJU3IFG.js +2 -0
  196. package/dist/project-reindex-TQFCOA2O.js +3 -0
  197. package/dist/queries/affected.d.ts +2 -2
  198. package/dist/queries/affected.js +1 -1
  199. package/dist/queries/anchors.d.ts +2 -2
  200. package/dist/queries/anchors.js +1 -1
  201. package/dist/queries/architecture.d.ts +2 -2
  202. package/dist/queries/architecture.js +1 -1
  203. package/dist/queries/bottlenecks.d.ts +2 -2
  204. package/dist/queries/bottlenecks.js +1 -1
  205. package/dist/queries/by-kind.d.ts +2 -2
  206. package/dist/queries/by-kind.js +1 -1
  207. package/dist/queries/call-graph.d.ts +2 -2
  208. package/dist/queries/call-graph.js +1 -1
  209. package/dist/queries/change-surface.d.ts +2 -2
  210. package/dist/queries/change-surface.js +1 -1
  211. package/dist/queries/cleanup-plan.d.ts +2 -2
  212. package/dist/queries/cleanup-plan.js +1 -1
  213. package/dist/queries/co-change.d.ts +2 -2
  214. package/dist/queries/co-change.js +1 -1
  215. package/dist/queries/code.d.ts +3 -3
  216. package/dist/queries/code.js +1 -1
  217. package/dist/queries/complexity-hotspots.d.ts +2 -2
  218. package/dist/queries/complexity-hotspots.js +1 -1
  219. package/dist/queries/complexity.d.ts +2 -2
  220. package/dist/queries/complexity.js +1 -1
  221. package/dist/queries/context.d.ts +2 -2
  222. package/dist/queries/context.js +1 -1
  223. package/dist/queries/convergence.d.ts +2 -2
  224. package/dist/queries/convergence.js +1 -1
  225. package/dist/queries/coupling.d.ts +2 -2
  226. package/dist/queries/coupling.js +1 -1
  227. package/dist/queries/cycles.d.ts +2 -2
  228. package/dist/queries/cycles.js +1 -1
  229. package/dist/queries/dataflow.d.ts +2 -2
  230. package/dist/queries/dataflow.js +1 -1
  231. package/dist/queries/dead.d.ts +2 -2
  232. package/dist/queries/dead.js +1 -1
  233. package/dist/queries/decorative-checkers.d.ts +2 -2
  234. package/dist/queries/decorative-checkers.js +1 -1
  235. package/dist/queries/deep-chains.d.ts +2 -2
  236. package/dist/queries/deep-chains.js +1 -1
  237. package/dist/queries/dependence-slice.d.ts +3 -3
  238. package/dist/queries/dependence-slice.js +1 -1
  239. package/dist/queries/dependency-depth.d.ts +2 -2
  240. package/dist/queries/dependency-depth.js +1 -1
  241. package/dist/queries/deps.d.ts +2 -2
  242. package/dist/queries/deps.js +1 -1
  243. package/dist/queries/diff-impact.d.ts +2 -2
  244. package/dist/queries/diff-impact.js +1 -1
  245. package/dist/queries/doc-drift.d.ts +2 -2
  246. package/dist/queries/doc-drift.js +1 -1
  247. package/dist/queries/drift.d.ts +2 -2
  248. package/dist/queries/drift.js +1 -1
  249. package/dist/queries/duplicate-bodies.d.ts +2 -2
  250. package/dist/queries/duplicate-bodies.js +1 -1
  251. package/dist/queries/entry-map.d.ts +2 -2
  252. package/dist/queries/entry-map.js +1 -1
  253. package/dist/queries/evidence.d.ts +3 -3
  254. package/dist/queries/evidence.js +1 -1
  255. package/dist/queries/extract-candidates.d.ts +2 -2
  256. package/dist/queries/extract-candidates.js +1 -1
  257. package/dist/queries/fan.d.ts +2 -2
  258. package/dist/queries/fan.js +1 -1
  259. package/dist/queries/files.d.ts +2 -2
  260. package/dist/queries/files.js +1 -1
  261. package/dist/queries/health.d.ts +3 -3
  262. package/dist/queries/health.js +1 -1
  263. package/dist/queries/hierarchy.d.ts +2 -2
  264. package/dist/queries/hierarchy.js +1 -1
  265. package/dist/queries/hotspots.d.ts +2 -2
  266. package/dist/queries/hotspots.js +1 -1
  267. package/dist/queries/imports.d.ts +2 -2
  268. package/dist/queries/imports.js +1 -1
  269. package/dist/queries/incomplete-migration.d.ts +2 -2
  270. package/dist/queries/incomplete-migration.js +1 -1
  271. package/dist/queries/index.d.ts +5 -5
  272. package/dist/queries/index.js +1 -1
  273. package/dist/queries/isolated.d.ts +2 -2
  274. package/dist/queries/isolated.js +1 -1
  275. package/dist/queries/locality-candidates.d.ts +2 -2
  276. package/dist/queries/locality-candidates.js +1 -1
  277. package/dist/queries/members.d.ts +2 -2
  278. package/dist/queries/members.js +1 -1
  279. package/dist/queries/methods.d.ts +2 -2
  280. package/dist/queries/methods.js +1 -1
  281. package/dist/queries/not-implemented.d.ts +2 -2
  282. package/dist/queries/not-implemented.js +1 -1
  283. package/dist/queries/outline.d.ts +2 -2
  284. package/dist/queries/outline.js +1 -1
  285. package/dist/queries/passthrough-candidates.d.ts +2 -2
  286. package/dist/queries/passthrough-candidates.js +1 -1
  287. package/dist/queries/plan-context.d.ts +2 -2
  288. package/dist/queries/plan-context.js +1 -1
  289. package/dist/queries/react-component-duplicates.d.ts +2 -2
  290. package/dist/queries/react-component-duplicates.js +1 -1
  291. package/dist/queries/react-hook-candidates.d.ts +2 -2
  292. package/dist/queries/react-hook-candidates.js +1 -1
  293. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  294. package/dist/queries/react-large-component-pressure.js +1 -1
  295. package/dist/queries/recent-duplicates.d.ts +2 -2
  296. package/dist/queries/recent-duplicates.js +1 -1
  297. package/dist/queries/redundant-reexports.d.ts +2 -2
  298. package/dist/queries/redundant-reexports.js +1 -1
  299. package/dist/queries/reference-neighborhood.d.ts +2 -2
  300. package/dist/queries/reference-neighborhood.js +1 -1
  301. package/dist/queries/reference-reachability.d.ts +2 -2
  302. package/dist/queries/reference-reachability.js +1 -1
  303. package/dist/queries/refs.d.ts +2 -2
  304. package/dist/queries/refs.js +1 -1
  305. package/dist/queries/self-audit.d.ts +2 -2
  306. package/dist/queries/self-audit.js +1 -1
  307. package/dist/queries/similar-chains.d.ts +2 -2
  308. package/dist/queries/similar-chains.js +1 -1
  309. package/dist/queries/similar-files.d.ts +2 -2
  310. package/dist/queries/similar-files.js +1 -1
  311. package/dist/queries/similar-signatures.d.ts +2 -2
  312. package/dist/queries/similar-signatures.js +1 -1
  313. package/dist/queries/similar.d.ts +2 -2
  314. package/dist/queries/similar.js +1 -1
  315. package/dist/queries/slice.d.ts +2 -2
  316. package/dist/queries/slice.js +1 -1
  317. package/dist/queries/source-inspection.d.ts +4 -4
  318. package/dist/queries/source-inspection.js +1 -1
  319. package/dist/queries/source-search.d.ts +2 -2
  320. package/dist/queries/source-search.js +1 -1
  321. package/dist/queries/stale-abstractions.d.ts +2 -2
  322. package/dist/queries/stale-abstractions.js +1 -1
  323. package/dist/queries/stats.d.ts +2 -2
  324. package/dist/queries/surface.d.ts +2 -2
  325. package/dist/queries/surface.js +1 -1
  326. package/dist/queries/symbols.d.ts +2 -2
  327. package/dist/queries/symbols.js +1 -1
  328. package/dist/queries/system-map.d.ts +2 -2
  329. package/dist/queries/system-map.js +1 -1
  330. package/dist/queries/system.d.ts +2 -2
  331. package/dist/queries/system.js +1 -1
  332. package/dist/queries/test-quality.d.ts +2 -2
  333. package/dist/queries/test-quality.js +1 -1
  334. package/dist/queries/trace.d.ts +2 -2
  335. package/dist/queries/trace.js +1 -1
  336. package/dist/queries/twin-ab.d.ts +2 -2
  337. package/dist/queries/twin-ab.js +1 -1
  338. package/dist/queries/twin-drift.d.ts +2 -2
  339. package/dist/queries/twin-drift.js +1 -1
  340. package/dist/queries/unused-imports.d.ts +2 -2
  341. package/dist/queries/unused-imports.js +1 -1
  342. package/dist/queries/unused-params.d.ts +2 -2
  343. package/dist/queries/unused-params.js +1 -1
  344. package/dist/queries/value-flow.d.ts +3 -3
  345. package/dist/queries/value-flow.js +1 -1
  346. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  347. package/dist/queries/vue-component-duplicates.js +1 -1
  348. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  349. package/dist/queries/vue-composable-candidates.js +1 -1
  350. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  351. package/dist/queries/vue-large-view-pressure.js +1 -1
  352. package/dist/queries/wrapper-candidates.d.ts +2 -2
  353. package/dist/queries/wrapper-candidates.js +1 -1
  354. package/dist/reindex-worker.js +2 -2
  355. package/dist/reindex.d.ts +3 -5
  356. package/dist/reindex.js +72 -33
  357. package/dist/runtime.d.ts +23 -4
  358. package/dist/runtime.js +3 -3
  359. package/dist/rust-semantic-session-server.js +1 -1
  360. package/dist/rust-semantic-session-worker.js +1 -1
  361. package/dist/rust-semantic-worker.js +1 -1
  362. package/dist/sentinel-ensure-command-OSWGCFFL.js +3 -0
  363. package/dist/sentinel-ensure-command-SPW7XQLB.js +2 -0
  364. package/dist/sentinel-hook.js +39 -0
  365. package/dist/sentinel-worker.js +16 -0
  366. package/dist/typescript-mailbox-worker.js +1 -1
  367. package/dist/watch-server.js +6 -6
  368. package/docs/COMMAND_REFERENCE.md +5 -3
  369. package/docs/INDEX_GENERATIONS.md +2 -2
  370. package/docs/NPM_RELEASE.md +323 -0
  371. package/docs/schemas/npm-release-state.schema.json +4 -13
  372. package/docs/schemas/project-config.schema.json +159 -0
  373. package/package.json +10 -14
  374. package/skills/codebaseiq/SKILL.md +1 -1
  375. package/skills/concrete-plan/SKILL.md +1 -1
  376. package/ui/view/api.js +450 -0
  377. package/ui/view/app.js +394 -0
  378. package/ui/view/builder.js +323 -0
  379. package/ui/view/file-panel.js +170 -0
  380. package/ui/view/focus.js +379 -0
  381. package/ui/view/index.html +54 -0
  382. package/ui/view/map.js +424 -0
  383. package/ui/view/styles.css +1125 -0
  384. package/dist/chunk-2Q2LW5JW.js +0 -14
  385. package/dist/chunk-2X7V4HS4.js +0 -88
  386. package/dist/chunk-3IER7Q6H.js +0 -12
  387. package/dist/chunk-3JSXXYTZ.js +0 -345
  388. package/dist/chunk-476NR5B7.js +0 -2
  389. package/dist/chunk-5VKBFZZU.js +0 -3
  390. package/dist/chunk-6BQ3DSPK.js +0 -2
  391. package/dist/chunk-6CS3UQTN.js +0 -3
  392. package/dist/chunk-6OAHRI2D.js +0 -6
  393. package/dist/chunk-ADTBPVUZ.js +0 -21
  394. package/dist/chunk-BFFZDZQV.js +0 -2
  395. package/dist/chunk-BMYOV5GP.js +0 -77
  396. package/dist/chunk-C74PPYLA.js +0 -3
  397. package/dist/chunk-CWONGW6P.js +0 -3
  398. package/dist/chunk-DDZ7VHWV.js +0 -20
  399. package/dist/chunk-DR2LURYU.js +0 -3
  400. package/dist/chunk-ECQBG7PW.js +0 -564
  401. package/dist/chunk-EF2R3WNQ.js +0 -2
  402. package/dist/chunk-FM5BPL4V.js +0 -60
  403. package/dist/chunk-G6XFR4ZL.js +0 -4
  404. package/dist/chunk-GTIYTDRE.js +0 -562
  405. package/dist/chunk-HOA5YGOH.js +0 -3
  406. package/dist/chunk-KUW32IRO.js +0 -2
  407. package/dist/chunk-LTA3BRZX.js +0 -2
  408. package/dist/chunk-NAUD7LCA.js +0 -2
  409. package/dist/chunk-NCZUNH3E.js +0 -109
  410. package/dist/chunk-NNJ2KZZG.js +0 -4
  411. package/dist/chunk-NNO6A2PO.js +0 -2
  412. package/dist/chunk-OGTFJ3XD.js +0 -2
  413. package/dist/chunk-Q5ELPRKQ.js +0 -2
  414. package/dist/chunk-Q72QSKXC.js +0 -308
  415. package/dist/chunk-QCN62RTF.js +0 -3
  416. package/dist/chunk-QW7EP6WI.js +0 -21
  417. package/dist/chunk-RU65DDUP.js +0 -215
  418. package/dist/chunk-SELM5MER.js +0 -2
  419. package/dist/chunk-SMRBZ6EC.js +0 -2
  420. package/dist/chunk-SNNWPCN7.js +0 -4
  421. package/dist/chunk-TFZB6XTM.js +0 -239
  422. package/dist/chunk-UCD3H3UZ.js +0 -5
  423. package/dist/chunk-UXM43C7T.js +0 -3
  424. package/dist/chunk-VFY6Y2H6.js +0 -61
  425. package/dist/chunk-WE5RZHZ7.js +0 -5
  426. package/dist/chunk-YMGZZEW4.js +0 -2
  427. package/dist/chunk-YVCIMIOC.js +0 -12
  428. package/dist/chunk-Z54RD7VL.js +0 -3
  429. package/dist/chunk-ZKX2FRS6.js +0 -15
  430. package/dist/cli-context-3SNLDYBM.js +0 -3
  431. package/dist/cli-context-T3B7W6GG.js +0 -2
  432. package/dist/cli-program-YNOXO72B.js +0 -7
  433. package/dist/command-descriptors-6AOUKWW7.js +0 -346
  434. package/dist/command-descriptors-ZFKJSRUP.js +0 -344
  435. package/dist/direct-navigation-DP4LVMRX.js +0 -3
  436. package/dist/direct-navigation-FLUS3BT6.js +0 -2
  437. package/dist/invocation-command-descriptors-QT2JMY5J.js +0 -3
  438. package/dist/invocation-command-descriptors-YN4QJEAX.js +0 -2
  439. package/dist/output-continuation-command-2V2SL4TD.js +0 -2
  440. package/dist/output-continuation-command-65J5IP3O.js +0 -3
  441. package/dist/project-reindex-5JOKXAXT.js +0 -2
  442. package/dist/project-reindex-UQBIKO4M.js +0 -3
  443. package/docs/WINDOWS_SIDECAR_RELEASE.md +0 -424
  444. package/docs/schemas/windows-sidecar-provenance.schema.json +0 -137
  445. package/scripts/build-codebaseiq-windows.mjs +0 -197
  446. package/scripts/codebaseiq-windows-provenance.mjs +0 -364
  447. package/scripts/verify-codebaseiq-windows.mjs +0 -29
@@ -0,0 +1,543 @@
1
+ import{b as Nt,c as bl}from"./chunk-ZZ3MWF33.js";import{B as wm,C as Cr,D as Im,E as On,F as Lm,G as Dm,H as Pm,L as xr,M as es,Q as km,R as yl,T as _m,U as Bm,V as Om,a as Be,c as Sr,e as fl,f as pl,g as V,h as gl,i as _n,j as hm,k as yn,l as Oi,m as ym,n as fe,o as rt,p as ri,q as Zo,r as Yt,s as Bn,t as Xt,u as Cm,v as xm,w as Rm,x as hl,y as Em}from"./chunk-6WAPPQ5F.js";import{a as jm,b as Hm,c as Um,d as oi,i as is,j as rs,k as zm,l as os,o as Gm}from"./chunk-DDN2F6GB.js";import{a as ns}from"./chunk-P5XHIJHI.js";import{n as bm,o as Sm,p as vm,q as Qo,t as ts}from"./chunk-EQNMD62X.js";import{h as $m}from"./chunk-2PRONPAS.js";import{c as Ym}from"./chunk-CIYA2KZN.js";import{A as Nn,D as _i,E as Bi,G as mm,H as J,I as ze,J as fm,K as pm,L as vr,M as Yo,N as gm,O as Ge,Q as Xo,e as ee,f as om,g as qo,h as Mt,i as Jt,j as sm,k as At,l as Ai,m as am,o as br,p as Ce,q as Vo,s as Jo,t as lm}from"./chunk-C6WKPKCF.js";import{c as Mi,d as Wo}from"./chunk-XQAVQVIL.js";import{a as Ni,b as cm,c as k,d as re,e as kn,f as it,g as ke,h as Le,i as at,j as ki,k as um,l as dm}from"./chunk-DRENNWRG.js";import{a as Xm}from"./chunk-SV2LEFVM.js";import{T as as,U as Wm,da as Vm,fa as ls,pa as Sl,ra as Jm,t as Km,u as si,v as qm,y as ss}from"./chunk-MEUHIDI3.js";import{G as ae,a as jt,b as Ft,c as gn,e as Zd,f as Qd,g as dl,h as em,i as vt,j as hr,k as Je,l as se,m as ie,n as zo,o as Go,p as Ko,q as He,r as hn,s as yr,t as nm,x as im,y as ye,z as rm}from"./chunk-5FWR5HLG.js";import{d as $o,p as tm,q as ml}from"./chunk-T75DS2E6.js";import{a as Fi,b as Fe,e as he,f as Uo}from"./chunk-YT4DVWUV.js";import{c as Yd,d as Xd,f as ul}from"./chunk-RCIGX23V.js";import{a as ol,j as Kd,s as Jd,t as Tm,u as Fm,x as Mm,y as Am,z as Nm}from"./chunk-D7DOB27N.js";import{a as ft,g as Hd,i as $}from"./chunk-R2NOK63J.js";import{a as jo,d as zd,e as Gd}from"./chunk-6O3KXIDL.js";import{A as pt,B as Pt,F as pn,G as ii,S as sl,T as al,Y as qd,_ as ll,aa as Wd,ba as cl,ca as nt,da as St,ea as Tt,fa as Vd,g as $d,h as gr,o as jd,y as Ud,z as Ho}from"./chunk-UQYQBLJX.js";import{SymbolInformation_Kind as Re}from"@c4312/scip";var cs=new Map(Object.entries(Re).filter(([e,t])=>Number.isInteger(Number(e))&&typeof t=="string").map(([e,t])=>[Number(e),t])),Zm=new Map([...cs.entries()].map(([e,t])=>[t.toLowerCase(),e]));function Rr(e){return cs.get(e)??"Unknown"}function Zt(){return[Re.Function,Re.Method,Re.Macro,Re.Constructor,Re.Getter,Re.Setter,Re.StaticMethod,Re.SingletonMethod,Re.AbstractMethod,Re.ProtocolMethod,Re.TraitMethod]}function Qm(){return[Re.Class,Re.Interface,Re.Struct,Re.Trait,Re.Type,Re.TypeAlias,Re.Enum,Re.Union,Re.Protocol]}function EK(){return[Re.Constant,Re.Variable,Re.Value,Re.Field,Re.Property,Re.StaticDataMember,Re.StaticField,Re.StaticProperty,Re.StaticVariable,Re.EnumMember]}import{existsSync as gx}from"fs";import{isAbsolute as hx,join as yx}from"path";function lt(e,t){let n=tf(e,t,{allowMultiple:!1})[0]?.relativePath;return n||ef(e,t)}function bn(e,t){return tf(e,t,{allowMultiple:!0}).map(n=>n.relativePath)}function ef(e,t){if(!t)return null;let n=t.replace(/\\/g,"/").replace(/^\.\//,""),i=hx(n)&&n.startsWith(e.config.projectRoot)?n.slice(e.config.projectRoot.length).replace(/^\/+/,""):n,r=yx(e.config.projectRoot,i);return gx(r)?i:null}function tf(e,t,n){let i=Uo(e,t,n);if(i.length===0){if(ef(e,t))return[];let r=fe(e,t);return!r||e.isIgnored(r.relativePath)?[]:[{relativePath:r.relativePath,score:700}]}return i}function vl(e,t){let n=bn(e,t),i=Yo(e,n,{sort:!0});if(i.length===0)return[];let r=i.map(a=>({symbol:a.symbol,shortName:a.shortName,startLine:a.startLine,endLine:a.endLine,signature:a.signature,children:[]})),o=new Map;for(let a of r)o.set(a.symbol,a);let s=[];for(let a=0;a<i.length;a++){let l=i[a],c=r[a];if(l.enclosingSymbol&&o.has(l.enclosingSymbol)){o.get(l.enclosingSymbol).children.push(c);continue}let u=null,d=1/0;for(let m of r)if(m!==c&&m.startLine<=c.startLine&&m.endLine>=c.endLine){if(m.startLine===c.startLine&&m.endLine===c.endLine&&!dm(m.symbol,c.symbol))continue;let p=m.endLine-m.startLine;p<d&&(d=p,u=m)}u?u.children.push(c):s.push(c)}return s}import{basename as wR,extname as Ff}from"path";function Ct(e,t){let n=ie(e,t.relativePath);if(n.length===0)return!1;let i=re(t.symbol);if(!i)return!1;let r=n.slice(Math.max(0,t.startLine-2),t.startLine+1).join(`
2
+ `),o=He(i);return new RegExp(`^\\s*export\\s+(?:default\\s+)?(?:(?:async\\s+)?function\\s+${o}\\b|(?:abstract\\s+)?class\\s+${o}\\b|(?:interface|type|enum|namespace|module)\\s+${o}\\b|(?:const|let|var)\\s+${o}\\b)`,"m").test(r)?!0:bx(n,i)}function bx(e,t){if(!t)return!1;let n=new RegExp(`^\\s*export\\s*\\{[^}\\n]*\\b${He(t)}\\b`);return e.some(i=>n.test(i))}import{createHash as Sx}from"crypto";import{TextDecoder as vx}from"util";var Cx=new vx("utf-8",{fatal:!0});function Cl(e){return Vd(e.config.projectRoot)}function us(e,t){let n=pn(t),i;try{i=cl(e.config.projectRoot,n,{inputKind:"repository text file"})}catch(o){if(St(o)||o instanceof ll)return null;throw o}let r=af(i);return r===null?null:rf(n,i,r,sf(e),of(e))}function ds(e,t={}){let n=Cl(e).filter(u=>!t.scope||u.includes(t.scope)),i=sf(e),r=of(e),o=[],s=[],a=[],l=[],c=0;for(let u of n){let d;try{d=cl(e.config.projectRoot,u,{inputKind:"repository text file"})}catch(f){if(f instanceof ll){l.push(u);continue}if(St(f))continue;a.push(u);continue}let m=af(d);if(m===null){s.push(u);continue}c+=d.byteLength,o.push(rf(u,d,m,i,r))}return{files:o,candidateFiles:n.length,scannedBytes:c,skippedBinaryPaths:s,skippedUnreadablePaths:a,skippedOversizedPaths:l}}function rf(e,t,n,i,r){let o=Sx("sha256").update(t).digest("hex");return{relativePath:e,text:n,bytes:t.byteLength,freshness:{exactText:{state:"current",basis:"working-tree-read",sha256:o},semantic:xx(e,o,i,r)}}}function xx(e,t,n,i){if(!i.has(e))return{state:"unavailable",basis:"no-compiler-document"};let r=n.get(e);return r?{state:r===t?"aligned":"stale",basis:"indexed-input-fingerprint"}:{state:"unavailable",basis:"fingerprint-unavailable"}}function of(e){return new Set(e.all(`SELECT documents.relative_path FROM documents WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`).map(t=>t.relative_path))}function sf(e){let t=new Map;if(!e.generation.metadataRaw)return t;let n=$o(e.generation.metadataRaw);if(n.kind!=="legacy"&&n.kind!=="supported")return t;let i=n.metadata.fingerprint;if(!nf(i)||!Array.isArray(i.files))return t;for(let r of i.files)!nf(r)||typeof r.path!="string"||typeof r.hash!="string"||t.set(r.path,r.hash);return t}function af(e){if(e.includes(0))return null;try{return Cx.decode(e)}catch{return null}}function nf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ms(e,t,n={}){return ai(e,t,n).rows}function ai(e,t,n={}){let i=Er(e,[t],{additive:n.additive,semantic:n.semantic,semanticEvidence:n.semanticEvidence}),r=n.callableOnly?(i.rows.get(t.symbolId)??[]).filter(o=>it(o.symbol)||o.source==="ast-callsite"):i.rows.get(t.symbolId)??[];return{rows:typeof n.limit=="number"?r.slice(0,n.limit):r,semanticIncomplete:i.incompleteSymbolIds.has(t.symbolId),semanticUnavailable:i.unavailableSymbolIds.has(t.symbolId)}}function fs(e,t,n){return Rl(e,t,n).rows}function Rl(e,t,n){let i=Qt(e,[t],n);return{rows:i.rows.get(t.symbolId)??[],semanticIncomplete:i.incompleteSymbolIds.has(t.symbolId),semanticUnavailable:i.unavailableSymbolIds.has(t.symbolId)}}function cf(e,t,n){return Qt(e,t,n).rows}function Qt(e,t,n){let i=Lx(e)?Px(e,t,{semantic:n.semantic!==!1,semanticEvidence:n.semanticEvidence}):Dx(e,n.semanticEvidence,{semantic:n.semantic!==!1});return{rows:new Map(t.map(o=>[o.symbolId,typeof n.limit=="number"?(i.rows.get(o.symbolId)??[]).slice(0,n.limit):i.rows.get(o.symbolId)??[]])),incompleteSymbolIds:new Set(t.filter(o=>i.incompleteSymbolIds.has(o.symbolId)).map(o=>o.symbolId)),unavailableSymbolIds:new Set(t.filter(o=>i.unavailableSymbolIds.has(o.symbolId)).map(o=>o.symbolId))}}var Rx=Fe("caller-rows",{clearGroups:["whole-project"]}),Ex=Fe("caller-rows-non-semantic",{clearGroups:["whole-project"]}),wx=Fe("targeted-caller-strategy",{clearGroups:["whole-project"]}),Ix=2e4;function Lx(e){return wx.get(e,()=>(e.get("SELECT COUNT(*) AS count FROM global_symbols")?.count??0)>Ix)}function Dx(e,t,n={}){return(n.semantic===!1?Ex:Rx).get(e,()=>{let r=ze(e),o=Er(e,r,{semantic:n.semantic!==!1,semanticEvidence:t}),s=new Map;for(let c of r)s.set(c.symbol,c.symbolId);let a=new Map,l=new Map;for(let c of r){let u=o.rows.get(c.symbolId);if(!(!u||u.length===0))for(let d of u){let m=s.get(d.symbol);if(m===void 0||m===c.symbolId)continue;let f=a.get(m);f||(f=[],a.set(m,f),l.set(m,new Set));let p=`${c.symbol}|${c.relativePath}`;l.get(m).has(p)||(l.get(m).add(p),f.push({symbol:c.symbol,file:c.relativePath,source:"caller-map-inversion",callEvidence:d.source}))}}return{rows:a,incompleteSymbolIds:o.incompleteSymbolIds.size===0?new Set:new Set(r.map(c=>c.symbolId)),unavailableSymbolIds:o.unavailableSymbolIds.size===0?new Set:new Set(r.map(c=>c.symbolId))}})}function Px(e,t,n){let i=n.semantic&&n.semanticEvidence?t.flatMap(u=>{let d=Tx(e,u);return d?[d]:[]}):[],r=new Map(i.map(u=>[u.symbolId,u])),o=n.semantic&&n.semanticEvidence?n.semanticEvidence.referenceEvidenceMap(e,i):{rows:new Map,incompleteSymbolIds:new Set,unavailableSymbolIds:new Set},s=Im(e,t),a=new Map;for(let u of t){let d=[],m=new Set,f=g=>{if(g.symbol===u.symbol)return;let h=`${g.symbol}|${g.file}`;m.has(h)||(m.add(h),d.push(g))};for(let g of s.get(u.symbolId)??[])g.file!==u.relativePath&&f({symbol:g.enclosingSymbol??g.file,file:g.file,source:"resolved-reference"});let p=r.get(u.symbolId);if(p)for(let g of o.rows.get(p.symbolId)??[]){if(g.file===u.relativePath||e.isIgnored(g.file))continue;let h=Ge(J(e,g.file),g.line);f({symbol:h?.symbol??g.file,file:g.file,source:"semantic-reference"})}a.set(u.symbolId,d)}let l=new Set(o.incompleteSymbolIds),c=new Set(o.unavailableSymbolIds);if(n.semantic)for(let u of t)r.has(u.symbolId)||l.add(u.symbolId);return{rows:a,incompleteSymbolIds:l,unavailableSymbolIds:c}}function Tx(e,t){let n=Zt().join(", "),i=Qm().join(", ");return e.get(`SELECT
3
+ d.id AS documentId,
4
+ gs.id AS symbolId,
5
+ gs.symbol,
6
+ d.relative_path AS relativePath,
7
+ COALESCE(der.start_line, c.start_line) AS startLine,
8
+ COALESCE(der.end_line, c.end_line) AS endLine,
9
+ COALESCE(gs.display_name, '') AS leaf,
10
+ NULL AS parentTypeName,
11
+ CASE WHEN gs.kind IN (${n}) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
12
+ CASE WHEN gs.kind IN (${i}) THEN 1 ELSE 0 END AS isTypeLike,
13
+ gs.kind AS kind,
14
+ gs.documentation AS documentation,
15
+ gs.enclosing_symbol AS enclosingSymbol
16
+ FROM global_symbols gs
17
+ LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
18
+ LEFT JOIN chunks c ON c.document_id = der.document_id
19
+ JOIN documents d ON d.id = COALESCE(der.document_id, c.document_id)
20
+ WHERE gs.id = ?
21
+ LIMIT 1`,t.symbolId)??null}function El(e,t,n={}){return Er(e,t,n).rows}function Er(e,t,n={}){if(t.length===0)return{rows:new Map,incompleteSymbolIds:new Set,unavailableSymbolIds:new Set};let i=n.additive??!1,r=[],o=[];for(let m of t)ye(m.relativePath)&&Jt(e,m.relativePath)!==null?r.push(m):o.push(m);let s=new Map,a=new Map,l=m=>{for(let[f,p]of m){let g=s.get(f);g||(g=[],s.set(f,g));let h=a.get(f);h||(h=new Set,a.set(f,h));for(let S of p){let v=`${S.symbol}|${S.chunkId}`;h.has(v)||(h.add(v),g.push(S))}}};r.length>0&&l(Fx(e,r));let c=new Set,u=new Set;if(n.semantic!==!1&&n.semanticEvidence){let m=n.semanticEvidence.calleeEvidenceMap(e,t);l(Bx(m.rows));for(let f of m.incompleteSymbolIds)c.add(f);for(let f of m.unavailableSymbolIds)u.add(f)}else if(n.semantic!==!1)for(let m of t)u.add(m.symbolId);let d=i?t:o;return d.length>0&&l(kx(e,d)),{rows:s,incompleteSymbolIds:c,unavailableSymbolIds:u}}function Fx(e,t){let n=new Map,i=Mx(t,n),r=Xt(e);for(let[o,s]of i){let a=Jt(e,o);if(!a)continue;let l=gm(s);for(let c of a){let u=l.get(c.line);if(!u)continue;let d=Ax(e,o,r,c);d&&d.symbol!==u.symbol&&n.get(u.symbolId).push({symbol:d.symbol,file:d.file,chunkId:c.line,source:"ast-callsite",callsiteLine:c.line})}}return n}function Mx(e,t){let n=new Map;for(let i of e){let r=n.get(i.relativePath);r?r.push(i):n.set(i.relativePath,[i]),t.set(i.symbolId,[])}for(let i of n.values())i.sort((r,o)=>r.endLine-r.startLine-(o.endLine-o.startLine));return n}function Ax(e,t,n,i){let r=Yt(t,n.get(i.calleeLeaf)??[]);if(r.length===0)return null;let o=Nx(e,t,r,i.calleeQualifier);return o||Bn(e,t,r,i.memberAccess,i.calleeQualifier)}function Nx(e,t,n,i){if(!i||ye(t)!=="clojure")return null;let o=Ce(e,t).filter(s=>s.kind==="namespace"&&s.localName===i&&s.sourcePath).map(s=>s.sourcePath);for(let s of o){let a=n.find(l=>Pt(s,l.file));if(a)return a}return n.find(s=>/`([^`]+)`\//.exec(s.symbol)?.[1]===i)??null}function kx(e,t){if(t.length===0)return new Map;let i=xl(t.map(f=>f.documentId)).flatMap(f=>e.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
22
+ FROM mentions m
23
+ JOIN chunks c ON m.chunk_id = c.id
24
+ WHERE m.role != 1
25
+ AND c.document_id IN (${f.map(()=>"?").join(",")})`,...f)),r=new Map;for(let f of i)r.has(f.document_id)||r.set(f.document_id,[]),r.get(f.document_id).push(f);let s=xl(i.map(f=>f.symbol_id)).flatMap(f=>e.all(`SELECT gs.id AS symbol_id, gs.symbol,
26
+ COALESCE(der.document_id, def_chunk.document_id) AS document_id
27
+ FROM global_symbols gs
28
+ LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
29
+ LEFT JOIN (
30
+ SELECT m.symbol_id, MIN(c.document_id) AS document_id
31
+ FROM mentions m
32
+ JOIN chunks c ON m.chunk_id = c.id
33
+ WHERE m.role = 1
34
+ AND m.symbol_id IN (${f.map(()=>"?").join(",")})
35
+ GROUP BY m.symbol_id
36
+ ) def_chunk ON def_chunk.symbol_id = gs.id
37
+ WHERE gs.id IN (${f.map(()=>"?").join(",")})`,...f,...f)),a=xl([...t.map(f=>f.documentId),...s.flatMap(f=>f.document_id===null?[]:[f.document_id])]),l=new Map(a.flatMap(f=>e.all(`SELECT id, relative_path FROM documents
38
+ WHERE id IN (${f.map(()=>"?").join(",")})`,...f).map(p=>[p.id,p.relative_path]))),c=new Map;for(let f of s)c.has(f.symbol_id)||c.set(f.symbol_id,{symbol:f.symbol,file:f.document_id!==null?l.get(f.document_id)??"":""});let u=new Map,d=l,m=_x(t);for(let[f,p]of m){let h=[...r.get(f)??[]].sort((E,w)=>E.start_line-w.start_line||E.end_line-w.end_line),S=[...p].sort((E,w)=>E.startLine-w.startLine||E.endLine-w.endLine),v=new Set,y=0;for(let E of S){for(;y<h.length&&h[y].start_line<=E.endLine;)v.add(h[y]),y+=1;for(let L of v)L.end_line<E.startLine&&v.delete(L);let w=new Set,b=[],R=null,C=()=>{if(R)return R;let L=d.get(E.documentId)??"",I=new Set;if(L){let x=ym(e,L),P=Math.max(0,E.startLine),_=Math.min(x.length-1,E.endLine);for(let D=P;D<=_;D+=1)for(let T of x[D])I.add(T)}return R=I,I};for(let L of v){if(L.symbol_id===E.symbolId)continue;let I=c.get(L.symbol_id);if(!I)continue;if(!(L.start_line>=E.startLine&&L.end_line<=E.endLine)){if(!(L.start_line<=E.endLine&&L.end_line>=E.startLine))continue;let D=re(I.symbol);if(!D||!C().has(D))continue}let P=`${I.symbol}|${L.chunk_id}`;w.has(P)||(w.add(P),b.push({...I,chunkId:L.chunk_id,source:"scip-chunk"}))}u.set(E.symbolId,b)}}return u}var lf=500;function xl(e){let t=[...new Set(e)],n=[];for(let i=0;i<t.length;i+=lf)n.push(t.slice(i,i+lf));return n}function _x(e){let t=new Map;for(let n of e){let i=t.get(n.documentId);i?i.push(n):t.set(n.documentId,[n])}return t}function Bx(e){let t=new Map;for(let[n,i]of e){let r=[];for(let o of i)r.push({symbol:o.symbol,file:o.file,chunkId:-1,source:"semantic-callee",...o.callsiteLine===void 0?{}:{callsiteLine:o.callsiteLine}});t.set(n,r)}return t}var Ox=12,$x=280;function $i(e,t,n,i){let r=jx(e,t,n,i);if(r.size===0)return Gx();let o=[],s=new Set,a=(c,u,d,m)=>{if(u===t&&d<=i&&m>=n)return;let f=`${u}:${d}:${m}:${c}`;s.has(f)||(s.add(f),o.push({name:c,relativePath:u,startLine:d,endLine:m}))};for(let c of J(e,t))r.has(c.leaf)&&a(c.leaf,c.relativePath,c.startLine,c.endLine);for(let c of Ce(e,t)){let u=c.localName;if(!u||!r.has(u)||!c.sourcePath||c.kind==="namespace")continue;let d=c.importedName==="default"?u:c.importedName;for(let m of _n(e,c.sourcePath,d,{maxReexportDepth:3}))a(u,m.relativePath,m.startLine,m.endLine)}o.sort(df);let l=o.map(c=>{let u=Hx(e,c);return u?{...c,source:u}:null}).filter(c=>c!==null).slice(0,Ox);return wl(l)}function ps(e,t=[]){return wl(Ux(e.flatMap(n=>n?.inline??[]),t))}function uf(e){return e?e.inline.reduce((t,n)=>t+n.name.length+n.source.length+32,0):0}function jx(e,t,n,i){let r=ee(e,t),o=new Set;if(!r)return o;for(let s=n;s<=i;s+=1)for(let a of r.identifiersByLine[s]??[])o.add(a);return o}function Hx(e,t){if(t.startLine!==t.endLine)return null;let n=(ie(e,t.relativePath)[t.startLine]??"").trim();if(!n||n.length>$x)return null;let i=n.indexOf("=");if(i<0||n[i+1]===">")return null;let r=n.slice(i+1).replace(/(?:\/\/|#).*$/u,"").trim();if(!r||r.includes("${")||/\b(?:function|class|struct|interface|trait|enum|lambda)\b/u.test(r))return null;let s=r.replace(/(['"`])(?:\\.|(?!\1).)*\1/gu,"").replace(/\b(?:0[xX][\dA-Fa-f_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)n?\b/gu,""),a=new Set(["true","false","null","undefined","None","True","False"]);return(s.match(/[A-Za-z_][A-Za-z0-9_]*/gu)??[]).some(c=>!a.has(c))?null:n}function Ux(e,t){let n=new Map;for(let i of e){if(zx(i,t))continue;let r=`${i.relativePath}:${i.startLine}:${i.endLine}:${i.name}`;n.has(r)||n.set(r,{...i})}return[...n.values()].sort(df)}function zx(e,t){return t.some(n=>n.relativePath===e.relativePath&&n.startLine<=e.startLine&&n.endLine>=e.endLine)}function df(e,t){return e.relativePath.localeCompare(t.relativePath)||e.startLine-t.startLine||e.name.localeCompare(t.name)}function wl(e){return{coverage:"indexed-project-literal-values",inline:e}}function Gx(){return wl([])}var Kx=12,qx=20,Ll=200,Dl=800,Wx=.9,ff={if_statement:"branch",conditional_expression:"branch",ternary_expression:"branch",switch_statement:"branch",switch_expression:"branch",switch_case:"branch",case_statement:"branch",match_statement:"branch",match_expression:"branch",match_arm:"branch",for_statement:"loop",for_in_statement:"loop",for_of_statement:"loop",while_statement:"loop",do_statement:"loop",await_expression:"await",return_statement:"return",throw_statement:"throw",raise_statement:"throw",assignment_expression:"mutation",augmented_assignment_expression:"mutation",assignment:"mutation",pair:"shape",field_initializer:"shape",spread_element:"spread",dictionary_splat:"spread",catch_clause:"catch",except_clause:"catch",finally_clause:"finally"},vs=["anchor","signature","binding","branch","loop","call","await","return","throw","mutation","shape","spread","catch","finally"],pf=[...vs,"lifecycle"],gf=["loop","await","throw","mutation","spread","catch","finally","lifecycle"],Vx=new Set(["onBeforeMount","onBeforeUnmount","onMounted","onUnmounted","useEffect","useInsertionEffect","useLayoutEffect"]);var hf=new Set(["object","object_pattern","dictionary","field_declaration_list","struct_expression","struct_pattern"]);function ji(e,t,n,i,r=[],o={}){let s=ae(e,t);if(!s)return null;let a=ie(e,t),l=gt(e,t,n,i,r),c=Rs(e,t,l.startLine,l.endLine),u=c?.startLine??n,d=c?.endLine??i,m=(c?Hi(s.rootNode,l.startLine,l.endLine):null)??Mr(s.rootNode,u,d);if(!m)return null;let f=Cf(m,a,u,d,r);if(!f||f.lines.length===0||f.lines.some(S=>S.text.length>Dl))return null;let p=mR(a,u,d),g=fR(f);if((o.requireSavings??!0)&&g>=p*Wx)return null;let h=vs.filter(S=>f.lines.some(v=>v.signals.includes(S)));return{...c?{callable:{name:c.name,startLine:c.startLine,endLine:c.endLine}}:{},representation:"outline",constructKind:f.constructKind,signature:f.signature,lines:f.lines,signals:h,testCases:V(t)==="test"?bR(a,u,d):[],coverage:{sourceStatements:f.sourceStatements,representedStatements:f.sourceStatements,copiedStatements:f.copiedStatements,omittedStatements:0},rawCharacters:p,outlineCharacters:g,candidateLines:f.sourceStatements,omittedLines:0}}function Cs(e,t,n,i,r){if(r.length===0)return[];let o=ae(e,t);if(!o)return[];let s=ie(e,t),a=gt(e,t,n,i,r),l=Rs(e,t,a.startLine,a.endLine),c=l?.startLine??n,u=l?.endLine??i,d=(l?Hi(o.rootNode,a.startLine,a.endLine):null)??Mr(o.rootNode,c,u);if(!d)return[];let m=Cf(d,s,c,u,r);return m?m.lines.filter(f=>f.text.length<=Dl&&f.signals.some(p=>["branch","loop","catch","finally"].includes(p))&&r.some(p=>p>=f.line&&p<=f.endLine)):[]}function yf(e,t,n,i){let r=ae(e,t);if(!r)return null;let o=Hi(r.rootNode,n,i)??Mr(r.rootNode,n,i);if(!o)return null;let s=[],a=Fl(o),l=[];return Ml(o,o,c=>{if(Ir.has(c.type)||Jx.has(c.type)){Xx(s,l,c);return}if(xs.has(c.type)){Zx(s,l,c);return}if(Tr.has(c.type)){Qx(s,l,c);return}Fr.has(c.type)&&eR(s,c)}),{facts:oR(s),terminals:vf(a),unsupported:l}}function gt(e,t,n,i,r=[]){let o=r.filter(d=>d>=n&&d<=i),s=ae(e,t);if(o.length>0&&s){let d=[];li(s.rootNode,f=>{sR(f)&&f.startPosition.row>=n&&f.endPosition.row<=i&&o.every(p=>f.startPosition.row<=p&&f.endPosition.row>=p)&&d.push(f)});let m=d.sort((f,p)=>f.endPosition.row-f.startPosition.row-(p.endPosition.row-p.startPosition.row)||f.startPosition.row-p.startPosition.row)[0];if(m)return{startLine:m.startPosition.row,endLine:m.endPosition.row}}let a=Rs(e,t,n,i);if(a)return{startLine:a.startLine,endLine:a.endLine};if(o.length===0)return{startLine:n,endLine:i};let l=(ee(e,t)?.callables??[]).filter(d=>d.startLine>=n&&d.endLine<=i&&o.every(m=>d.startLine<=m&&d.endLine>=m)).sort((d,m)=>d.endLine-d.startLine-(m.endLine-m.startLine)||d.startLine-m.startLine)[0];if(!s)return l?{startLine:l.startLine,endLine:l.endLine}:{startLine:n,endLine:i};let c=[];li(s.rootNode,d=>{$n.has(d.type)&&d.startPosition.row>=n&&d.endPosition.row<=i&&o.every(m=>d.startPosition.row<=m&&d.endPosition.row>=m)&&c.push(d)});let u=c.sort((d,m)=>d.endPosition.row-d.startPosition.row-(m.endPosition.row-m.startPosition.row)||d.startPosition.row-m.startPosition.row)[0];return u?{startLine:u.startPosition.row,endLine:u.endPosition.row}:l?{startLine:l.startLine,endLine:l.endLine}:{startLine:n,endLine:i}}function Pl(e,t,n,i,r={}){if(i-n+1<(r.minimumBodyLines??qx))return null;let s=Rf(e,t,n,i,[],!1);if(!s)return null;let a=s.candidates.map(S=>({...S,signals:S.signals.filter(v=>v!=="anchor"&&v!=="signature")})).filter(S=>S.signals.length>0);if(a.length===0)return null;let l=hR(a),c=a.filter(S=>S.text.length<=Ll);if(c.length===0)return null;let u=gf.filter(S=>(l[S]??0)>0),d=u.filter(S=>S!=="await"),m=s.shapes.reduce((S,v)=>S+v.fields.length,0);if(d.length===0&&!((l.await??0)>0&&m>0)&&m<3)return null;let f=yR(c,l),p=new Map;for(let S of u){let v=f.find(y=>y.signals.includes(S));v&&p.set(v.line,v)}if(p.size===0){let S=f.find(v=>v.signals.includes("branch"));S&&p.set(S.line,S)}let g=Math.min(10,Math.max(1,r.maxLines??p.size)),h=new Map;for(let S of p.values()){if(h.size>=g)break;h.set(S.line,S)}return h.size>=a.length&&s.shapes.length===0?null:{owner:s.callable?.name??null,startLine:n,endLine:i,lines:[...h.values()].sort((S,v)=>S.line-v.line),shapes:s.shapes,signalCounts:l,candidateLines:a.length,omittedLines:a.length-h.size}}function Sn(e,t,n,i){let r=Rf(e,t,n,i,[],!1);return r?new Map(r.candidates.map(o=>[o.line,o.signals.filter(s=>s!=="lifecycle")])):new Map}var $n=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"]),xt=new Set(["block","body","compound_statement","declaration_list","statement_block"]),Ir=new Set(["if_expression","if_statement","unless","unless_statement"]),Jx=new Set(["conditional_expression","ternary_expression"]),xs=new Set(["do_statement","enhanced_for_statement","for_expression","for_in_statement","for_of_statement","for_statement","loop_expression","while_statement"]),Tr=new Set(["match_expression","match_statement","switch_expression","switch_statement"]),bf=new Set(["case_statement","match_arm","switch_case","switch_default"]),Fr=new Set(["try_expression","try_statement"]),ys=new Set(["catch_clause","except_clause","rescue"]),Dr=new Set(["ensure","finally_clause"]),Lr=new Set(["else","else_clause"]),Sf=new Set(["raise_statement","return_statement","throw_statement"]),Yx=new Set(["block_comment","comment","line_comment"]);function Xx(e,t,n){let i=n.childForFieldName("condition")??Nl(n),r=n.childForFieldName("consequence")??n.childForFieldName("body")??n.namedChildren.find(l=>xt.has(l.type)),o=n.childForFieldName("alternative")??n.namedChildren.find(l=>Lr.has(l.type));if(!i||!r){t.push(Al(n,"conditional-fields-unresolved"));return}let s=tn(i,"predicate",i.text),a=tn(r,mf(r),"consequence");if(en(e,s,a,"predicate-consequence",{branchRole:"consequence"}),bs(e,s,r,"consequence"),o){let l=tn(o,mf(o),"alternative");en(e,s,l,"predicate-alternative",{branchRole:"alternative"}),bs(e,s,o,"alternative");return}en(e,s,Tl(s,"otherwise continue"),"predicate-fallthrough",{branchRole:"fallthrough"})}function Zx(e,t,n){let i=n.childForFieldName("body")??n.namedChildren.find(s=>xt.has(s.type));if(!i){t.push(Al(n,"loop-body-unresolved"));return}let r=n.childForFieldName("condition"),o=tn(r??n,"predicate",r?.text??Ht(n,i));en(e,o,tn(i,"outcome","iteration"),"loop-iteration",{branchRole:"iteration"}),bs(e,o,i,"iteration"),en(e,o,Tl(o,"loop exits"),"loop-exit",{branchRole:"exit"})}function Qx(e,t,n){let i=n.childForFieldName("body")??n.namedChildren.find(l=>xt.has(l.type)),r=n.childForFieldName("value")??n.childForFieldName("condition")??n.childForFieldName("subject")??Nl(n),o=nR(i??n);if(!r||o.length===0){t.push(Al(n,"switch-cases-unresolved"));return}let s=tn(r,"predicate",r.text),a=!1;for(let l of o){let c=rR(l);a||=c;let u=Ht(l,l.namedChildren.find(d=>Ss(d)));en(e,s,tn(l,"outcome",u||(c?"default":"case")),c?"predicate-default":"predicate-case",{branchRole:c?"default":"case"}),bs(e,s,l,c?"default":"case")}a||en(e,s,Tl(s,"no case matched"),"predicate-fallthrough",{branchRole:"fallthrough"})}function eR(e,t){let n=tn(t,"scope","try");for(let i of iR(t)){let r=Dr.has(i.type),o=tn(i,"handler",r?"finally":Ht(i,gs(i)));en(e,n,o,r?"finally-cleanup":"exception-handler",{branchRole:r?"finally":"catch"}),tR(e,o,i,r?"finally":"catch")}}function tR(e,t,n,i){for(let r of Fl(n)){let o=r.label.startsWith("throw")||r.label.startsWith("raise")?"throw":"return";en(e,t,r,o==="throw"?"handler-throw":"handler-return",{branchRole:i,terminalKind:o})}}function bs(e,t,n,i){for(let r of Fl(n)){let o=r.label.startsWith("throw")||r.label.startsWith("raise")?"throw":"return";en(e,t,r,o==="throw"?"predicate-throw":"predicate-return",{branchRole:i,terminalKind:o})}}function en(e,t,n,i,r){e.push({controller:t,outcome:n,subtype:i,attributes:r})}function tn(e,t,n){return{kind:t,label:Pr(n).slice(0,Dl),startLine:e.startPosition.row,endLine:e.endPosition.row,implicit:!1}}function Tl(e,t){return{...e,kind:"outcome",label:t,implicit:!0}}function mf(e){return Sf.has(e.type)?"terminal":"outcome"}function Fl(e){let t=[];return Ml(e,e,n=>{Sf.has(n.type)&&t.push(tn(n,"terminal",n.text))}),vf(t)}function Ml(e,t,n){n(t);for(let i of t.namedChildren)i!==e&&$n.has(i.type)||Ml(e,i,n)}function nR(e){let t=[],n=i=>{for(let r of i.namedChildren)Tr.has(r.type)||(bf.has(r.type)?t.push(r):n(r))};return n(e),t}function iR(e){let t=[],n=i=>{for(let r of i.namedChildren)Fr.has(r.type)||(ys.has(r.type)||Dr.has(r.type)?t.push(r):$n.has(r.type)||n(r))};return n(e),t}function rR(e){let t=Ht(e,e.namedChildren.find(n=>Ss(n))).trim();return e.type==="switch_default"||/^(?:default\b|_\s*=>)/u.test(t)}function Al(e,t){return{startLine:e.startPosition.row,endLine:e.endPosition.row,reason:t}}function oR(e){let t=new Map;for(let n of e)t.set(`${n.controller.startLine}\0${n.controller.endLine}\0${n.outcome.startLine}\0${n.outcome.endLine}\0${n.subtype}\0${n.outcome.label}`,n);return[...t.values()]}function vf(e){let t=new Map;for(let n of e)t.set(`${n.startLine}\0${n.endLine}\0${n.kind}\0${n.label}`,n);return[...t.values()]}function sR(e){return $n.has(e.type)||xs.has(e.type)||Tr.has(e.type)||Fr.has(e.type)||ys.has(e.type)||Dr.has(e.type)}function Cf(e,t,n,i,r){let s=Hi(e,n,i)??e,a=gs(s),l=[],c=0,u=0,d=(b,R,C,L,I=!1,x=!0)=>{let P=I?C.trim():Pr(C);if(!P)return;let _=Math.max(n,b.startPosition.row),D=Math.min(i,b.endPosition.row);l.push({line:_,endLine:Math.max(_,D),depth:R,signals:vs.filter(T=>L.includes(T)||T==="anchor"&&r.some(A=>A>=_&&A<=D)),text:P,copied:I}),x&&(c+=1,I&&(u+=1))},m=(b,R)=>{for(let C of b.namedChildren)w(C,R)},f=(b,R)=>{if(Ir.has(b.type)){p(b,R,"else if");return}if(Lr.has(b.type)){let C=b.namedChildren.find(I=>Ir.has(I.type));if(C){p(C,R,"else if");return}d(b,R,"else",["branch"],!1,!1);let L=gs(b)??b.namedChildren.find(I=>xt.has(I.type));if(L)w(L,R+1);else for(let I of b.namedChildren)w(I,R+1);return}d(b,R,"else",["branch"],!1,!1),w(b,R+1)},p=(b,R,C=b.type.startsWith("unless")?"unless":"if")=>{let L=b.childForFieldName("condition")??Nl(b),I=b.childForFieldName("consequence")??b.childForFieldName("body")??b.namedChildren.find(_=>xt.has(_.type)),x=b.childForFieldName("alternative")??b.namedChildren.find(_=>Lr.has(_.type)),P=L?L.text:Ht(b,I);d(b,R,`${C} ${uR(P)}`,wr(L,["branch"])),I&&w(I,R+1),x&&f(x,R)},g=(b,R)=>{let C=b.childForFieldName("body")??b.namedChildren.find(L=>xt.has(L.type));d(b,R,Ht(b,C),wr(b,["loop"])),C&&w(C,R+1)},h=(b,R)=>{let C=b.childForFieldName("body")??b.namedChildren.find(L=>xt.has(L.type));d(b,R,Ht(b,C),wr(b,["branch"])),C&&w(C,R+1)},S=(b,R)=>{let C=b.namedChildren.find(L=>Ss(L));d(b,R,Ht(b,C),["branch"],!1,!1);for(let L of b.namedChildren)(L===C||Ss(L))&&w(L,R+1)},v=(b,R)=>{d(b,R,"try",[],!1);for(let C of b.namedChildren)xt.has(C.type)?w(C,R+1):(ys.has(C.type)||Dr.has(C.type))&&w(C,R)},y=(b,R,C)=>{let L=b.childForFieldName("body")??b.namedChildren.find(x=>xt.has(x.type)),I=C==="finally"?"finally":Ht(b,L);d(b,R,I,[C],!1,!1),L&&w(L,R+1)},E=(b,R)=>{let C=gs(b);d(b,R,Ht(b,C),wr(b,["binding"])),C&&w(C,R+1)},w=(b,R)=>{if(b.startPosition.row>i||b.endPosition.row<n||Yx.has(b.type)||b.type==="empty_statement")return;if(xt.has(b.type)){m(b,R);return}if(Ir.has(b.type)){p(b,R);return}if(xs.has(b.type)){g(b,R);return}if(Tr.has(b.type)){h(b,R);return}if(bf.has(b.type)){S(b,R);return}if(Fr.has(b.type)){v(b,R);return}if(ys.has(b.type)){y(b,R,"catch");return}if(Dr.has(b.type)){y(b,R,"finally");return}if(Lr.has(b.type)){f(b,R);return}if($n.has(b.type)){E(b,R);return}let L=!xf(b)||dR(b);d(b,R,b.text,wr(b),L)};return w(a&&a!==s?a:s,0),c===0?null:{constructKind:cR(s),signature:lR(s,a,t,n),lines:l,sourceStatements:c,copiedStatements:u}}function Hi(e,t,n){let i=e.namedChildren.filter(r=>r.startPosition.row<=t&&r.endPosition.row>=n);for(let r of i.sort(aR)){let o=Hi(r,t,n);if(o)return o}return $n.has(e.type)&&e.startPosition.row<=t&&e.endPosition.row>=n?e:null}function aR(e,t){return e.endPosition.row-e.startPosition.row-(t.endPosition.row-t.startPosition.row)||e.startPosition.row-t.startPosition.row}function gs(e){return e.childForFieldName("body")??e.childForFieldName("consequence")??e.namedChildren.find(t=>xt.has(t.type))??null}function lR(e,t,n,i){let r=Ht(e,t);return r||(n[i]??e.text).trim()}function cR(e){return e.type.includes("constructor")?"constructor":e.type.includes("method")||e.type==="method"?Il(e,new Set(["class_body","class_declaration","class_definition"]))?"class method":"object method":e.type==="arrow_function"||e.type==="function_expression"||e.type==="lambda"?Il(e,new Set(["object","pair"]))?"object member":"function value":e.type.includes("function")?Il(e,$n)?"nested function":"module function":"source construct"}function Il(e,t){let n=e.parent;for(;n;){if(t.has(n.type))return!0;n=n.parent}return!1}function Nl(e){return e.namedChildren.find(t=>!xt.has(t.type)&&!Lr.has(t.type))??null}function Ht(e,t){if(!t)return Pr(e.text);let n=Math.max(0,t.startIndex-e.startIndex);return Pr(e.text.slice(0,n)).replace(/[:{]\s*$/u,"").trim()}function uR(e){let t=Pr(e);return t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1).trim():t}function Pr(e){return e.trim().replace(/\r?\n[\t ]*/gu," ")}function wr(e,t=[]){let n=new Set(t);return e&&li(e,i=>{let r=ff[i.type];r&&n.add(r),i.type==="call_expression"&&(n.add("call"),Ef(i)&&n.add("shape")),kl.has(i.type)&&n.add("binding")}),vs.filter(i=>n.has(i))}function dR(e){let t=!1;return li(e,n=>{t||!n.text.includes(`
39
+ `)||/(?:string|template|heredoc|raw_string)/u.test(n.type)&&(t=!0)}),t}function Ss(e){return xt.has(e.type)||Ir.has(e.type)||xs.has(e.type)||Tr.has(e.type)||Fr.has(e.type)||$n.has(e.type)||xf(e)}function xf(e){return/(?:statement|declaration|expression|assignment|return|throw|raise|break|continue|yield|with_item)$/u.test(e.type)||kl.has(e.type)}function mR(e,t,n){let i=0;for(let r=t;r<=n;r+=1)i+=(e[r]?.length??0)+10;return i}function fR(e){return e.constructKind.length+e.signature.length+80+e.lines.reduce((t,n)=>t+n.text.length+n.depth*2+10,0)}function Rf(e,t,n,i,r,o){let s=ae(e,t);if(!s)return null;let a=ie(e,t),l=Rs(e,t,n,i),c=o?l?.startLine??n:n,u=o?l?.endLine??i:i,m=(l?.startLine===c&&l.endLine===u?Hi(s.rootNode,c,u):null)??Mr(s.rootNode,c,u);if(!m)return null;let f=new Map,p=new Map,g=new Map,h=(y,E)=>{if(y<c||y>u)return;let w=f.get(y)??new Set;w.add(E),f.set(y,w)};l&&h(l.startLine,"signature");for(let y of r)h(y,"anchor");li(m,y=>{let E=ff[y.type];if(E&&h(y.startPosition.row,E),E==="shape"&&pR(p,y,m,c,u),y.type==="call_expression"){let b=(y.childForFieldName("function")??y.namedChild(0))?.text.split(".").at(-1);if(Ef(y)){h(y.startPosition.row,"shape");let R=hs(y.text);R.length<=Ll&&g.set(y.startPosition.row,R)}if(b&&Vx.has(b)){h(y.startPosition.row,"lifecycle");let R=hs(y.text);R.length<=Ll&&g.set(y.startPosition.row,R)}}kl.has(y.type)&&h(y.startPosition.row,"binding")});let S=ee(e,t);for(let y of S?.callSites??[])y.line<c||y.line>u||(h(y.line,"call"),y.calleeLeaf==="catch"&&h(y.line,"catch"));let v=[...f.entries()].sort(([y],[E])=>y-E).map(([y,E])=>({line:y,signals:pf.filter(w=>E.has(w)),text:g.get(y)??hs(a[y]??"")})).filter(y=>y.text.length>0||y.signals.includes("anchor"));return{...l?{callable:l}:{},rangeStart:c,rangeEnd:u,sourceLines:a,candidates:v,shapes:[...p.values()].sort((y,E)=>y.startLine-E.startLine)}}function pR(e,t,n,i,r){if(t.startPosition.row<i||t.endPosition.row>r)return;let o=t.childForFieldName("key")??t.childForFieldName("name")??t.namedChild(0),s=hs(o?.text??"");if(!s||s.includes(`
40
+ `)||s.length>60)return;let a=gR(t,n);if(a.startPosition.row<i||a.endPosition.row>r)return;let l=`${a.startPosition.row}:${a.endPosition.row}`,c=e.get(l)??{startLine:a.startPosition.row,endLine:a.endPosition.row,fields:[]};c.fields.some(u=>u.name===s&&u.line===t.startPosition.row)||c.fields.push({name:s,line:t.startPosition.row}),e.set(l,c)}function gR(e,t){let n=e.parent;for(;n&&n!==t.parent;){if(hf.has(n.type))return n;if(n===t)break;n=n.parent}return e.parent??e}function Rs(e,t,n,i){return ee(e,t)?.callables.filter(r=>r.startLine<=n&&r.endLine>=i).sort((r,o)=>r.endLine-r.startLine-(o.endLine-o.startLine)||r.startLine-o.startLine)[0]}function Mr(e,t,n){if(e.startPosition.row>t||e.endPosition.row<n)return null;for(let i of e.namedChildren){let r=Mr(i,t,n);if(r)return r}return e}function li(e,t){t(e);for(let n of e.namedChildren)li(n,t)}function hs(e){return e.trim().replace(/\s+/gu," ")}function Ef(e){if(e.type!=="call_expression")return!1;let t=e.childForFieldName("arguments")??e.namedChildren.find(i=>i.type==="arguments"||i.type==="argument_list");if(!t)return!1;let n=!1;return li(t,i=>{hf.has(i.type)&&(n=!0)}),n}function hR(e){let t={};for(let n of pf){let i=e.filter(r=>r.signals.includes(n)).length;i>0&&(t[n]=i)}return t}function yR(e,t){let n=new Map;for(let o of e){let s=o.signals.join(",");n.set(s,(n.get(s)??0)+1)}let i=new Set(gf),r=o=>{let s=n.get(o.signals.join(","))??1,a=Math.min(...o.signals.map(u=>t[u]??1)),l=o.signals.some(u=>i.has(u))?3:1,c=Math.max(0,o.signals.length-1)*1e3;return l*(1e3/s+1e3/a)+c};return[...e].sort((o,s)=>r(s)-r(o)||s.line-o.line)}var kl=new Set(["lexical_declaration","variable_declarator","const_item","static_item","let_declaration","assignment"]);function bR(e,t,n){let i=[],r=/\b(?:describe|it|test)(?:\.(?:only|skip|todo))?\s*\(\s*(['"`])([^'"`]+)\1/u;for(let o=t;o<=n;o+=1){let s=r.exec(e[o]??"")?.[2];if(!(!s||i.includes(s))&&(i.push(s),i.length>=Kx))break}return i}var SR=new Set(["arrow_function","class_declaration","constructor_declaration","field_definition","function_declaration","function_definition","function_expression","function_item","generator_function_declaration","generator_function","lexical_declaration","method","method_declaration","method_definition","object_method","variable_declaration"]);function Ui(e,t,n){let i=ae(e,t)?.rootNode??null,r=vR(i,n);if(!r)return null;let o=ie(e,t);if(o.length===0)return null;let s=Math.max(0,r.startPosition.row),a=r.endPosition.column===0?r.endPosition.row-1:r.endPosition.row;return{type:r.type,startLine:s,endLine:Math.min(o.length-1,Math.max(s,a))}}function Ar(e,t,n,i,r){let o=gt(e,t,i,r,[n]),s=o.startLine===o.endLine&&/(?:=>|\(|\{|\[|,)\s*$/u.test(ie(e,t)[o.startLine]??"");if(!s&&(o.startLine>i||o.endLine<r))return o;let a=Ui(e,t,n);return s&&a?{startLine:a.startLine,endLine:a.endLine}:a&&a.startLine>=i&&a.endLine<=r?{startLine:a.startLine,endLine:a.endLine}:{startLine:i,endLine:r}}function vR(e,t){if(!e||!Lf(e,t))return null;let n=If(e,t);for(;n;){if(SR.has(n.type))return n;n=n.parent}return null}function If(e,t){let n=e.namedChildren.filter(i=>Lf(i,t)).sort((i,r)=>wf(i)-wf(r));return n.length>0?If(n[0],t):e}function Lf(e,t){return e.startPosition.row<=t&&e.endPosition.row>=t}function wf(e){return e.endIndex-e.startIndex}var CR=new Set(["call","call_expression","command","command_call","function_call_expression","invocation_expression","macro_invocation","method_call","method_invocation","new_expression","object_creation_expression"]);function Es(e,t,n,i){if(!Number.isSafeInteger(n)||n<0)return null;if(!Number.isSafeInteger(i)||i<0)throw new RangeError(`contextLines must be a non-negative safe integer; received ${i}`);let r=ie(e,t);if(r.length===0||n>=r.length)return null;let o=Math.max(0,n-i),s=Math.min(r.length-1,n+i);return{relativePath:t,startLine:o,endLine:s,focusLine:n,source:r.slice(o,s+1).join(`
41
+ `)}}function Df(e,t,n,i,r){let o=Es(e,t,n,i);if(!o)return null;let s=ae(e,t)?.rootNode??null;if(!s)return{...o,kind:"bounded-context"};let a=xR(s,n,r);if(a.length!==1)return{...o,kind:a.length===0?"non-call-reference":"bounded-context"};let l=a[0],c=ie(e,t),u=Math.max(0,l.startPosition.row),d=l.endPosition.column===0?l.endPosition.row-1:l.endPosition.row,m=Math.min(c.length-1,Math.max(u,d));return{relativePath:t,startLine:u,endLine:m,focusLine:n,source:c.slice(u,m+1).join(`
42
+ `),kind:"complete-call-expression"}}function Pf(e,t,n,i,r){if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`maxLines must be a positive safe integer; received ${r}`);let o=ie(e,t);if(o.length===0||n<0||n>=o.length)return null;let s=Math.min(o.length-1,i,n+r-1);return{relativePath:t,startLine:n,endLine:s,focusLine:n,source:o.slice(n,s+1).join(`
43
+ `)}}function jn(e,t,n,i,r=6){if(!Number.isSafeInteger(i)||i<=0)throw new RangeError(`maxLines must be a positive safe integer; received ${i}`);let o=ie(e,t);if(o.length===0||n<0||n>=o.length)return null;let s=Ui(e,t,n);if(!s){let g=Es(e,t,n,r);return g?{...g,unitType:null,unitStartLine:g.startLine,unitEndLine:g.endLine,omittedLines:0}:null}let a=s.startLine,l=s.endLine,c=l-a+1,u=Math.min(c,i),d=n-a-Math.floor(u/2),m=Math.max(0,Math.min(c-u,d)),f=a+m,p=f+u-1;return{relativePath:t,startLine:f,endLine:p,focusLine:n,source:o.slice(f,p+1).join(`
44
+ `),unitType:s.type,unitStartLine:a,unitEndLine:l,omittedLines:c-u}}function xR(e,t,n){let i=[];return Tf(e,t,n,i),i.filter(r=>!i.some(o=>o!==r&&o.startIndex>=r.startIndex&&o.endIndex<=r.endIndex))}function Tf(e,t,n,i){if(ER(e,t)){CR.has(e.type)&&RR(e)===n&&i.push(e);for(let r of e.namedChildren)Tf(r,t,n,i)}}function RR(e){let t=e.childForFieldName("function")??e.childForFieldName("constructor")??e.childForFieldName("method")??e.childForFieldName("name")??e.namedChild(0);return t?t.text.match(/[\p{L}_$][\p{L}\p{N}_$!?-]*/gu)?.at(-1)??null:null}function ER(e,t){return e.startPosition.row<=t&&e.endPosition.row>=t}function Ol(e,t,n={}){let{context:i=0}=n,r=Hf(t);if(r)return Uf(e,r.filePath,r.startLine,r.endLine,i);let o=$f(e,t);if(o)return _f(e,o);let s=fe(e,t);return s?Nr(e,s,i):null}function IR(e,t,n={}){if(t.length===0)throw new RangeError("code requires at least one selector.");if(t.length>24)throw new RangeError(`code accepts at most ${24} selectors per complete packet; received ${t.length}.`);let i=n.context??0,r=n.members??"exported",o=t.map(l=>LR(e,l,i,r)),s=o.flatMap(l=>l.results),a=s.map(l=>({relativePath:l.relativePath,startLine:l.startLine,endLine:l.endLine}));return{requested:t.length,matched:o.filter(l=>l.status==="matched").length,ambiguous:o.filter(l=>l.status==="ambiguous").length,missing:o.filter(l=>l.status==="missing").length,entries:o,bindingClosure:ps(s.map(l=>l.bindingClosure),a)}}function LR(e,t,n,i){let r=Hf(t);if(r){let u=Uf(e,r.filePath,r.startLine,r.endLine,n);return u?DR(e,t,u,n):_l(e,t,"definition-source-unreadable")}let o=$f(e,t);if(o)return TR(e,t,o,n,i);let s=rt(e,t);if(!s.match)return _l(e,t,"definition-not-found");let a=$R(e,s),l=a.map(jf);if(s.total>1){let u=s.total<=4&&a.length===s.total;return{selector:t,status:"ambiguous",kind:"source",totalCandidates:s.total,results:u?a.flatMap(d=>{let m=Nr(e,d,n);return m?[m]:[]}):[],definitions:[],candidates:l,omittedCandidates:Math.max(0,s.total-l.length),suggestions:[]}}let c=Nr(e,s.match,n);return c?OR(t,c):_l(e,t,"definition-source-unreadable")}function DR(e,t,n,i){let r=J(e,n.relativePath).filter(c=>!Mf(c,n.relativePath)),o=PR(e,n,r),s=kf(o.map(c=>Nr(e,c,i)).filter(c=>c!==null)).filter(c=>!Of(n,c)),a=new Set(s.map(c=>c.symbol)),l=o.filter(c=>!a.has(c.symbol)&&!(n.startLine<=c.startLine&&n.endLine>=c.endLine)).map(jf);return{selector:t,status:"matched",kind:"source",totalCandidates:1,results:[n,...s],definitions:[],candidates:[],omittedCandidates:0,suggestions:[],rangeCoverage:{basis:"requested-range-and-same-file-call-closure",referencedDefinitions:o.length,returnedDefinitions:o.length-l.length,returnedBodies:s.length,omittedDefinitions:l.length,omittedLedger:l}}}function PR(e,t,n){if(!kr(t.freshness))return[];if(n.length===0)return[];let i=El(e,n,{additive:!1,semantic:!1}),r=new Map;for(let s of n){let a=r.get(s.symbol)??[];a.push(s),r.set(s.symbol,a)}let o=new Map;for(let s of n)if(!(s.endLine<t.startLine||s.startLine>t.endLine)){for(let a of i.get(s.symbolId)??[])if(a.file===t.relativePath&&!(a.source==="ast-callsite"&&(a.chunkId<t.startLine||a.chunkId>t.endLine)))for(let l of r.get(a.symbol)??[])o.set(l.symbolId,l)}return Nf(e,[...o.values()],n)}function TR(e,t,n,i,r){let o=n.relativePath,s=MR(e,o),a=kr(n.freshness)?J(e,o).filter(g=>!Mf(g,o)):[],l=a.filter(g=>Ct(e,g)),c=l.length>0?l:FR(s,a),u=r==="all"?[]:Nf(e,c,a),d=r==="all"||a.length===0?[_f(e,n)]:kf(u.map(g=>Nr(e,g,i)).filter(g=>g!==null)),m=NR(s,d),f=kR(o,s,d),p=_R(s);return{selector:t,status:"matched",kind:"file-source",totalCandidates:1,results:d,definitions:[],candidates:[],omittedCandidates:0,suggestions:[],fileCoverage:{members:r,basis:r==="all"||a.length===0?"complete-file-source":l.length>0?"explicit-exports-and-same-file-reference-closure":"top-level-and-same-file-reference-closure",totalDefinitions:p,returnedDefinitions:m,returnedBodies:d.length,omittedDefinitions:Math.max(0,p-m),omittedLedger:f}}}function FR(e,t){let n=new Set(e.map(i=>i.symbol));return t.filter(i=>n.has(i.symbol))}function MR(e,t){return vl(e,t).flatMap(n=>AR(n,t)?n.children:[n])}function Mf(e,t){return Af(t).has(e.leaf)}function AR(e,t){return Af(t).has(re(e.symbol))}function Af(e){let t=wR(e);return new Set([t,t.slice(0,Math.max(0,t.length-Ff(t).length))])}function Nf(e,t,n){if(t.length===0)return[];let i=El(e,n,{additive:!0,semantic:!1}),r=new Map;for(let a of n){let l=r.get(a.symbol)??[];l.push(a),r.set(a.symbol,l)}let o=new Map,s=[...t];for(;s.length>0;){let a=s.shift();if(!o.has(a.symbolId)){o.set(a.symbolId,a);for(let l of i.get(a.symbolId)??[])for(let c of r.get(l.symbol)??[])o.has(c.symbolId)||s.push(c)}}return[...o.values()].sort(BR)}function kf(e){let t=[...e].sort((i,r)=>i.relativePath.localeCompare(r.relativePath)||i.startLine-r.startLine||r.endLine-i.endLine),n=[];for(let i of t)n.some(r=>Of(r,i))||n.push(i);return n}function _f(e,t){let n=t.text.split(`
45
+ `);return{symbol:t.relativePath,shortName:t.relativePath,relativePath:t.relativePath,startLine:0,endLine:Math.max(0,n.length-1),language:e.get("SELECT language FROM documents WHERE relative_path = ?",t.relativePath)?.language??$l(t.relativePath),source:t.text,freshness:t.freshness,...kr(t.freshness)?{bindingClosure:$i(e,t.relativePath,0,Math.max(0,n.length-1))}:{}}}function NR(e,t){return ws(e).filter(n=>t.some(i=>Bl(n,i))).length}function kR(e,t,n){let i=[];return Bf(i,e,t,n,0),i}function Bf(e,t,n,i,r){for(let o of n){if(i.some(a=>Bl(o,a)))continue;let s=ws(o.children).filter(a=>!i.some(l=>Bl(a,l))).length;e.push({symbol:o.symbol,shortName:o.shortName,relativePath:t,startLine:o.startLine,endLine:o.endLine,signature:o.signature,depth:r,nestedDefinitions:s}),Bf(e,t,o.children,i,r+1)}}function ws(e){return e.flatMap(t=>[t,...ws(t.children)])}function _R(e){return ws(e).length}function Bl(e,t){return t.startLine<=e.startLine&&t.endLine>=e.endLine}function Of(e,t){return e.relativePath===t.relativePath&&e.startLine<=t.startLine&&e.endLine>=t.endLine}function BR(e,t){return e.startLine-t.startLine||t.endLine-e.endLine||e.symbol.localeCompare(t.symbol)}function OR(e,t){return{selector:e,status:"matched",kind:"source",totalCandidates:1,results:[t],definitions:[],candidates:[],omittedCandidates:0,suggestions:[]}}function _l(e,t,n){return{selector:t,status:"missing",kind:"source",totalCandidates:0,results:[],definitions:[],candidates:[],omittedCandidates:0,suggestions:Zo(e,t,5),reason:n}}function $f(e,t){try{return us(e,t)}catch(n){if(n instanceof Ud)return null;throw n}}function $R(e,t){if(!t.match)return[];let n=[t.match];for(let r of t.candidates){let o=J(e,r.relativePath).find(s=>s.symbol===r.symbol&&s.startLine===r.startLine);o&&n.push(o)}let i=new Set;return n.filter(r=>{let o=`${r.relativePath}:${r.startLine}:${r.endLine}:${r.symbol}`;return i.has(o)?!1:(i.add(o),!0)})}function jf(e){return{symbol:e.symbol,shortName:k(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine}}function Hf(e){let t=e.match(/^(.+):(\d+)-(\d+)$/);if(!t)return null;let n=Number(t[2]),i=Number(t[3]);if(!Number.isSafeInteger(n)||n<1)throw new RangeError(`Source range start line must be a positive integer, got "${t[2]}".`);if(!Number.isSafeInteger(i)||i<n)throw new RangeError(`Source range end line must be an integer at or after ${n}, got "${t[3]}".`);return{filePath:t[1],startLine:n,endLine:i}}function Nr(e,t,n){let i=e.get("SELECT language FROM documents WHERE relative_path = ?",t.relativePath),r=us(e,t.relativePath);if(!r)return null;let s=r.text.split(`
46
+ `),a=t.endLine<=t.startLine?jn(e,t.relativePath,t.startLine,Number.MAX_SAFE_INTEGER):null,l=a?.unitType?a.unitStartLine:t.startLine,c=a?.unitType?a.unitEndLine:t.endLine,u=Math.max(0,l-n),d=Math.min(s.length-1,c+n),m=s.slice(u,d+1).join(`
47
+ `);return{symbol:t.symbol,shortName:k(t.symbol),relativePath:t.relativePath,startLine:u,endLine:d,language:i?.language??$l(t.relativePath),source:m,freshness:r.freshness,...kr(r.freshness)?{bindingClosure:$i(e,t.relativePath,u,d)}:{}}}function Uf(e,t,n,i,r){let o=us(e,t);if(!o)return null;let s=e.get("SELECT language FROM documents WHERE relative_path = ?",o.relativePath),l=o.text.split(`
48
+ `);if(n>l.length)return null;let c=Math.max(0,n-1-r),u=Math.min(l.length-1,i-1+r),d=l.slice(c,u+1).join(`
49
+ `);return{symbol:`${o.relativePath}:${n}-${i}`,shortName:`${o.relativePath}:${n}-${i}`,relativePath:o.relativePath,startLine:c,endLine:u,language:s?.language??$l(o.relativePath),source:d,freshness:o.freshness,...kr(o.freshness)?{bindingClosure:$i(e,o.relativePath,c,u)}:{}}}function kr(e){return!!(e&&e.semantic.state!=="stale"&&e.semantic.basis!=="no-compiler-document")}function $l(e){switch(Ff(e).toLowerCase()){case".ts":case".tsx":case".mts":case".cts":return"typescript";case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".py":case".pyi":return"python";case".rs":return"rust";case".go":return"go";case".java":return"java";case".kt":case".kts":return"kotlin";case".scala":return"scala";case".rb":return"ruby";case".php":return"php";case".cs":return"csharp";case".vb":return"vb";case".dart":return"dart";case".c":case".h":return"c";case".cc":case".cpp":case".cxx":case".hpp":case".hh":case".hxx":return"cpp";case".vue":return"vue";default:return null}}function Is(e){let t=new Map;for(let n of e){let i=t.get(n.relativePath)??[];i.push(n),t.set(n.relativePath,i)}return t}function zf(e){let t=new Map,n=HR(e),i=new Map;return r=>{let o=jR(r),s=i.get(o);if(s!==void 0)return s;if(!n.has(r.file))return i.set(o,r.symbol),r.symbol;let a=t.get(r.file);a||(a=UR(J(e,r.file)),t.set(r.file,a));let l=zR(a,r);return i.set(o,l),l}}function jR(e){return`${e.file}\0${e.symbol}\0${e.line}`}function HR(e){return new Set(e.all("SELECT relative_path FROM documents").map(t=>t.relative_path))}function UR(e){let t=new Map,n=new Map;for(let i of e){let r=t.get(i.leaf);r?r.push(i):t.set(i.leaf,[i]);let o=n.get(i.startLine);o?o.push(i):n.set(i.startLine,[i])}return{definitions:e,byLeaf:t,byStartLine:n}}function zR(e,t){if(e.definitions.length===0)return t.symbol;let n=qR(t.symbol),i=GR(e.byLeaf,n),r=KR(i,t.line);if(r)return r.symbol;let o=e.byStartLine.get(t.line)??[];return o.length===1?o[0].symbol:t.symbol}function GR(e,t){let n=[],i=new Set;for(let r of t)for(let o of e.get(r)??[])i.has(o.symbolId)||(i.add(o.symbolId),n.push(o));return n}function KR(e,t){let n=null;for(let i of e)if(!(i.startLine>t||i.endLine<t)){if(i.startLine===t)return i;(!n||i.endLine-i.startLine<n.endLine-n.startLine)&&(n=i)}return n}function qR(e){let t=new Set([e]),i=e.split(/::|\.|#/).filter(Boolean).at(-1);return i&&t.add(i),t}function Gf(e,t){let i=Ce(e,t).map(r=>VR(t,r));return{usage:i,positions:JR(e,t,i)}}function Kf(e,t){return{importUsage(n){let i=e.importUsageFacts(n);if(!t||i.positions.length===0)return i.usage;let r=t.importDefinitionsForFile(n,i.positions);return r.available?WR(i.usage,r.sourcePaths):i.usage}}}function WR(e,t){return e.map((n,i)=>{let r=t.get(String(i));return r?{...n,sourcePath:r}:n})}function VR(e,t){let n=t.isTypeOnly===!0,i=t.kind==="side-effect"||n||t.used;return{importer:e,sourcePath:t.sourcePath,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:n,isUsed:i,isTypeUsed:n,isValueUsed:t.kind==="side-effect"||!n&&t.used,references:[]}}function JR(e,t,n){let i=ae(e,t);if(!i)return[];let r=YR(i.rootNode),o=new Map;for(let a of r){let l=o.get(Hl(a.importedName,a.localName));l?l.push(a.position):o.set(Hl(a.importedName,a.localName),[a.position])}let s=[];return n.forEach((a,l)=>{let c=o.get(Hl(a.importedName,a.localName??a.importedName))?.shift();c&&s.push({...c,id:String(l),file:t})}),s}function YR(e){let t=[];for(let n of e.descendantsOfType("use_declaration")){let i=n.namedChildren.find(r=>r.type!=="visibility_modifier");i&&t.push(...Ls(i,""))}return t.filter(n=>n.importedName!=="*")}function Ls(e,t){switch(e.type){case"identifier":case"super":case"self":case"crate":return[{importedName:e.text,localName:e.text,position:jl(e,e.text)}];case"scoped_identifier":{let n=e.text.split("::").pop()??e.text;return[{importedName:n,localName:n,position:jl(e,n)}]}case"scoped_use_list":{let n=e.namedChild(0),i=e.namedChild(1);if(!n||!i)return[];let r=am(t,n.text);return i.namedChildren.flatMap(o=>Ls(o,r))}case"use_list":return e.namedChildren.flatMap(n=>Ls(n,t));case"use_as_clause":{let n=e.namedChild(0),i=e.namedChild(1);return!n||!i?[]:Ls(n,t).map(r=>({...r,localName:i.text}))}case"use_wildcard":{let n=e.namedChild(0),i="*";return[{importedName:i,localName:i,position:jl(n??e,i)}]}default:return[]}}function jl(e,t){let n=Math.max(0,e.text.lastIndexOf(t));return{id:"",file:"",line:e.startPosition.row,column:e.startPosition.column+n+XR(t)}}function XR(e){return Math.max(0,Math.min(e.length-1,1))}function Hl(e,t){return`${e}\0${t}`}import{spawnSync as Ul}from"child_process";import{existsSync as zl}from"fs";import{fileURLToPath as ZR}from"url";var Gl=15e3,Kl=8;function Jf(e,t={}){let n=t.status??Um,i=tE(e,n),r=nE(e,n),o=iE(e,n),s=t.referenceResolver||t.calleeResolver||t.signatureResolver||!QR(t)?null:zm(e,n,{fallbackReferenceResolver:i,fallbackCalleeResolver:r,fallbackSignatureResolver:o}),a=t.referenceResolver??s??i,l=t.calleeResolver??s??r,c=t.signatureResolver??s??o,u=t.importUsageResolver??Kf(t.sourceImportUsageResolver??eE(),t.importDefinitionResolver??s),d=t.calleeSymbolResolver,m=t.sourceZeroCalleeOracle,f=t.scipOccurrenceCalleeOracle,p=new Map,g=new Map,h=null,S=null,v=()=>(h??=n(e),h),y=()=>{let C=v();return C.dependencyAvailable?S??C:C},E=C=>{if(C.length===0)return new Map;let L=Br(C);try{let I=a.referencesForDefinitions(L),x=v();return S=Ds(x,I),I.available?new Map(I.references):is(L,I.references)}catch(I){let x=v();return S=_r(x,I),ci(L)}},w=C=>{if(C.length===0)return new Map;let L=Br(C),I=L.filter(qf);if(I.length===0)return ui(L);let x=new Map,P=Vf(I,f),_=[];for(let D of I)g.has(D.symbolId)?x.set(D.symbolId,g.get(D.symbolId)??[]):P.has(D.symbolId)?x.set(D.symbolId,P.get(D.symbolId)??[]):Wf(D,m)?x.set(D.symbolId,[]):_.push(D);if(_.length===0)return zi(L,x,void 0);try{let D=l.calleesForDefinitions(_),T=v();S=Ds(T,D);let A=zi(_,D.callees,d);for(let[W,le]of A)x.set(W,le);return zi(L,x,void 0)}catch(D){let T=v();return S=_r(T,D),ui(L)}},b=(C,L)=>{let I=Br(C),x=Br(L),P=x.filter(qf),_=new Map,D=Vf(P,f),T=[];for(let A of P)D.has(A.symbolId)?_.set(A.symbolId,D.get(A.symbolId)??[]):Wf(A,m)?_.set(A.symbolId,[]):T.push(A);if(I.length===0&&T.length===0)return{references:ci(I),callees:zi(x,_,void 0)};try{let A=s?s.referencesAndCalleesForDefinitions(I,T):aE(a,l,{referenceDefinitions:I,calleeDefinitions:T}),W=v();S=Ds(W,A);let le=A.available?new Map(A.references):is(I,A.references);for(let[Y,N]of A.callees)_.set(Y,N);let q=zi(x,_,d);for(let[Y,N]of q)g.set(Y,N);return{references:le,callees:q}}catch(A){let W=v();return S=_r(W,A),{references:ci(I),callees:ui(x)}}},R=C=>{if(C.length===0)return new Map;let L=Br(C);try{let I=c.signaturesForDefinitions(L),x=v();return S=Ds(x,I),Yf(L,I.signatures)}catch(I){let x=v();return S=_r(x,I),Ps(L)}};return{language:"rust",availability:y,dispose:()=>{s?.dispose()},importUsage:C=>{let L=p.get(C);if(L)return L;try{let I=u.importUsage(C);return p.set(C,I),I}catch(I){let x=v();return S=_r(x,I),[]}},referencesFor:C=>E([C]).get(C.symbolId)??[],referencesForDefinitions:E,referencesAndCalleesForDefinitions:b,calleesFor:C=>w([C]).get(C.symbolId)??[],calleesForDefinitions:w,signatureFor:C=>R([C]).get(C.symbolId)??null}}function Ds(e,t){let n={dependencyAvailable:e.dependencyAvailable,resolvedBinary:t.resolvedBinary??e.resolvedBinary,...e.note?{note:e.note}:{}};return t.available?{available:!0,...n}:{available:!1,reason:t.reason,...n}}function _r(e,t){return{available:!1,dependencyAvailable:e.dependencyAvailable,resolvedBinary:e.resolvedBinary,...e.note?{note:e.note}:{},reason:t instanceof Error?t.message:String(t)}}function QR(e){if(e.usePersistentSession!==void 0)return e.usePersistentSession;let t=process.env.SCIP_RUST_SEMANTIC_SESSION;return t!=="0"&&t!=="false"}function eE(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function Br(e){return e.map(t=>{let n=t;return{...t,leaf:typeof n.leaf=="string"?n.leaf:re(t.symbol),parentTypeName:n.parentTypeName??null,isFunctionLike:typeof n.isFunctionLike=="boolean"?n.isFunctionLike:ke(t.symbol),isTypeLike:n.isTypeLike??!1,kind:n.kind??null,documentation:n.documentation??null,enclosingSymbol:n.enclosingSymbol??null}})}function qf(e){return e.isFunctionLike}function Wf(e,t){if(!t)return!1;try{return t(e)}catch{return!1}}function Vf(e,t){if(!t||e.length===0)return new Map;try{return t(e)}catch{return new Map}}function tE(e,t){return{referencesForDefinitions:n=>rE(e,t,n)}}function nE(e,t){return{calleesForDefinitions:n=>oE(e,t,n)}}function iE(e,t){return{signaturesForDefinitions:n=>sE(e,t,n)}}function rE(e,t,n){let i=t(e);if(!i.available||!i.resolvedBinary)return{available:!1,resolvedBinary:i.resolvedBinary,reason:Vl(i),references:ci(n)};let r=ql();if(!zl(r))return{available:!1,resolvedBinary:i.resolvedBinary,reason:`Rust semantic worker was not found at ${r}. Run npm run build before using built semantic Rust queries.`,references:ci(n)};let o=Gi(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Gl),s=Ts(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=Gi(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Kl),l=Ts(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),c=os(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!0}),u={projectRoot:e,rustAnalyzerBinary:i.resolvedBinary,definitions:[...n],requestTimeoutMs:o,...s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:l,settleDelayMs:c,concurrency:a},d=Ul(process.execPath,[r],{cwd:e,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,windowsHide:!0,timeout:rs(n.length,Gm(o,u.referenceRetryTimeoutMs),a)}),m=Jl(d.stdout);if(m)return{...Wl(m),resolvedBinary:i.resolvedBinary,references:is(n,new Map(m.references),new Set(m.incompleteReferenceSymbolIds??[]))};let f=d.error instanceof Error?d.error.message:d.stderr.trim()||`Rust semantic worker exited with status ${d.status??"unknown"}.`;return{available:!1,resolvedBinary:i.resolvedBinary,reason:f,references:ci(n)}}function oE(e,t,n){let i=t(e);if(!i.available||!i.resolvedBinary)return{available:!1,resolvedBinary:i.resolvedBinary,reason:Vl(i),callees:ui(n)};let r=ql();if(!zl(r))return{available:!1,resolvedBinary:i.resolvedBinary,reason:`Rust semantic worker was not found at ${r}. Run npm run build before using built semantic Rust queries.`,callees:ui(n)};let o=Gi(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Gl),s=Gi(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Kl),a=Ts(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),l=os(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!0}),c={projectRoot:e,rustAnalyzerBinary:i.resolvedBinary,definitions:[...n],requestTimeoutMs:o,diagnosticsTimeoutMs:a,settleDelayMs:l,concurrency:s,includeReferences:!1,includeCallees:!0},u=Ul(process.execPath,[r],{cwd:e,input:JSON.stringify(c),encoding:"utf8",maxBuffer:50*1024*1024,windowsHide:!0,timeout:rs(n.length,o,s)}),d=Jl(u.stdout);if(d)return{...Wl(d),resolvedBinary:i.resolvedBinary,callees:zi(n,new Map(d.callees??[]),void 0)};let m=u.error instanceof Error?u.error.message:u.stderr.trim()||`Rust semantic worker exited with status ${u.status??"unknown"}.`;return{available:!1,resolvedBinary:i.resolvedBinary,reason:m,callees:ui(n)}}function sE(e,t,n){let i=t(e);if(!i.available||!i.resolvedBinary)return{available:!1,resolvedBinary:i.resolvedBinary,reason:Vl(i),signatures:Ps(n)};let r=ql();if(!zl(r))return{available:!1,resolvedBinary:i.resolvedBinary,reason:`Rust semantic worker was not found at ${r}. Run npm run build before using built semantic Rust queries.`,signatures:Ps(n)};let o=Gi(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Gl),s=Gi(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Kl),a=Ts(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),l=os(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),c={projectRoot:e,rustAnalyzerBinary:i.resolvedBinary,definitions:[...n],requestTimeoutMs:o,diagnosticsTimeoutMs:a,settleDelayMs:l,concurrency:s,includeReferences:!1,includeCallees:!1,includeSignatures:!0},u=Ul(process.execPath,[r],{cwd:e,input:JSON.stringify(c),encoding:"utf8",maxBuffer:50*1024*1024,windowsHide:!0,timeout:rs(n.length,o,s)}),d=Jl(u.stdout);if(d)return{...Wl(d),resolvedBinary:i.resolvedBinary,signatures:Yf(n,new Map(d.signatures??[]))};let m=u.error instanceof Error?u.error.message:u.stderr.trim()||`Rust semantic worker exited with status ${u.status??"unknown"}.`;return{available:!1,resolvedBinary:i.resolvedBinary,reason:m,signatures:Ps(n)}}function aE(e,t,n){let i=n.referenceDefinitions.length>0?e.referencesForDefinitions(n.referenceDefinitions):{available:!0,references:ci(n.referenceDefinitions)},r=n.calleeDefinitions.length>0?t.calleesForDefinitions(n.calleeDefinitions):{available:!0,callees:ui(n.calleeDefinitions)},o={resolvedBinary:i.resolvedBinary??r.resolvedBinary,references:i.references,callees:r.callees};return i.available&&r.available?{available:!0,...o}:{available:!1,reason:(i.available?void 0:i.reason)??(r.available?void 0:r.reason)??"Rust semantic resolution was unavailable.",...o}}function ci(e){return new Map(e.map(t=>[t.symbolId,[]]))}function ui(e){return new Map(e.map(t=>[t.symbolId,[]]))}function Ps(e){return new Map(e.map(t=>[t.symbolId,null]))}function zi(e,t,n){let i=0,r=0;return $("rust.semantic.callees.complete-map",()=>{let o=new Map;for(let s of e){let a=t.get(s.symbolId)??[];a.length>0&&(i+=1),r+=a.length,o.set(s.symbolId,a.map(l=>({...l,symbol:n?n(l):l.symbol})))}return o},()=>({definitions:e.length,rows:i,callees:r,resolveSymbols:!!n}))}function Yf(e,t){return new Map(e.map(n=>[n.symbolId,t.get(n.symbolId)??null]))}function ql(){return ZR(new URL("./rust-semantic-worker.js",import.meta.url))}function Wl(e){return e.available?{available:!0}:{available:!1,reason:e.reason}}function Vl(e){return e.available?"rust-analyzer binary path is unavailable.":e.reason}function Jl(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;if(typeof n.available!="boolean"||!Array.isArray(n.references)||n.available===!1&&typeof n.reason!="string"||n.available===!0&&n.reason!==void 0)return null;let i={references:n.references,incompleteReferenceSymbolIds:Array.isArray(n.incompleteReferenceSymbolIds)?n.incompleteReferenceSymbolIds.filter(r=>typeof r=="number"):void 0,callees:Array.isArray(n.callees)?n.callees:void 0,signatures:Array.isArray(n.signatures)?n.signatures:void 0};return n.available===!0?{available:!0,...i}:{available:!1,reason:String(n.reason),...i}}catch{return null}}function Gi(e,t){return ns(e)??t}function Ts(e,t){if(!e)return t;let n=Number(e);return Number.isInteger(n)&&n>=0?n:t}var Xf=new WeakMap;function Qf(e,t){let n=t.filter(cE);if(n.length===0)return new Map;let i=0,r=0;return $("rust.scip-occurrence.callees",()=>{let o=mE(e),s=new Map;for(let a of n){let l=uE(e,o,a);l!==null&&(s.set(a.symbolId,l),i+=1,r+=l.length)}return s},()=>({definitions:t.length,candidates:n.length,resolvedDefinitions:i,resolvedCallees:r}))}function cE(e){return!(!e.symbol.startsWith("rust-analyzer ")||!e.relativePath.endsWith(".rs")||!e.isFunctionLike||e.leaf==="main"||at(e.symbol))}function uE(e,t,n){let i=ee(e,n.relativePath);if(!i||i.language!=="rust")return null;let r=i.callables.find(u=>u.startLine!==n.startLine||u.endLine!==n.endLine?!1:u.name===n.leaf||n.leaf.endsWith(u.name)||u.name.endsWith(n.leaf));if(!r)return null;let o=i.callSites.filter(u=>u.line>=r.startLine&&u.line<=r.endLine);if(o.length===0)return null;let s=fE(e,t,n.relativePath);if(!s)return null;let a=s.filter(u=>u.line>=r.startLine&&u.line<=r.endLine&&u.callee.symbol!==n.symbol);if(a.some(u=>u.traitImplMember)||!dE(o,a))return null;let l=[],c=new Set;for(let u of a){let d=`${u.callee.symbol}\0${u.callee.file}\0${u.callee.line}`;c.has(d)||(c.add(d),l.push(u.callee))}return l}function dE(e,t){let n=Zf(e),i=Zf(t);if(n.size!==i.size)return!1;for(let[r,o]of n)if(i.get(r)!==o)return!1;return!0}function Zf(e){let t=new Map;for(let n of e){let i=n.calleeLeaf??n.leaf;if(!i)continue;let r=`${n.line}\0${i}`;t.set(r,(t.get(r)??0)+1)}return t}function mE(e){let t=Xf.get(e);if(!t){let n=ze(e).filter(i=>i.symbol.startsWith("rust-analyzer ")&&i.relativePath.endsWith(".rs")&&i.isFunctionLike);t={definitionBySymbol:new Map(n.map(i=>[i.symbol,i])),occurrencesByFile:new Map},Xf.set(e,t)}return t}function fE(e,t,n){return t.occurrencesByFile.has(n)||t.occurrencesByFile.set(n,pE(e,t,n)),t.occurrencesByFile.get(n)??null}function pE(e,t,n){if(!n.endsWith(".rs")||e.isIgnored(n))return[];let i=ts(e,n);if(!i)return null;let r=[];for(let o of i){if((o.roles&1)!==0)continue;let s=t.definitionBySymbol.get(o.symbol);if(!s)continue;let a=o.range[0];r.push({line:a,leaf:s.leaf,traitImplMember:at(s.symbol),callee:{symbol:s.symbol,file:s.relativePath,line:s.startLine,callsiteLine:a}})}return r}var Fs=class{sessions=new WeakMap;getOrCreate(t,n,i){let r=gE(t,n),o=this.sessions.get(t);o||(o=new Map,this.sessions.set(t,o));let s=o.get(r);if(s)return s.hits+=1,s.lastUsedAtMs=Date.now(),s.provider;let a=Date.now(),l=i();return o.set(r,{key:r,language:n,projectRoot:t.config.projectRoot,provider:l,createdAtMs:a,lastUsedAtMs:a,hits:1}),l}sessionsFor(t){return[...this.sessions.get(t)?.values()??[]]}clear(t){let n=this.sessions.get(t);if(n)for(let i of n.values())i.provider.dispose?.();this.sessions.delete(t)}};function gE(e,t){return`${e.config.projectRoot}:${t}-workspace`}import{randomUUID as hE}from"crypto";import{existsSync as yE}from"fs";import{dirname as bE}from"path";function ep(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(typeof t.available!="boolean"||t.dependencyAvailable!==void 0&&typeof t.dependencyAvailable!="boolean"||t.tsconfigPath!==void 0&&typeof t.tsconfigPath!="string"||t.tsconfigPaths!==void 0&&(!Array.isArray(t.tsconfigPaths)||!t.tsconfigPaths.every(n=>typeof n=="string"))||t.resolvedBinary!==void 0&&typeof t.resolvedBinary!="string"||t.note!==void 0&&typeof t.note!="string")return null;if(t.available===!0){if(t.reason!==void 0)return null}else if(typeof t.reason!="string"||t.reason.length===0)return null;return t}var SE=12e4,vE=5;function rp(e,t,n={}){let i=new Yl(e,n),r=null,o=null,s=process.env.CODEBASEIQ_SKIP_WATCH_SERVICE==="1",a=()=>(r??=Ym(e,t),r),l=(d,m,f)=>{if(s)return f();try{return m(i.request(d))}catch{return s=!0,f()}},c=(d,m)=>l({kind:"references",definitions:[...d],...m?.exact?{exact:!0}:{}},f=>ip(f),()=>a().referencesForDefinitions?.(d,m)??new Map(d.map(f=>[f.symbolId,a().referencesFor(f)]))),u=d=>l({kind:"callees",definitions:[...d]},m=>ip(m),()=>a().calleesForDefinitions?.(d)??new Map(d.map(m=>[m.symbolId,a().calleesFor(m)])));return{language:"typescript",availability:()=>(o??=l({kind:"availability"},RE,()=>a().availability()),o),importUsage:d=>l({kind:"import-usage",file:d},m=>m,()=>a().importUsage(d)),referencesFor:d=>tp(c([d]),d,"reference"),referencesForDefinitions:c,referenceFragmentsForFiles:d=>l({kind:"reference-fragments",files:[...d]},m=>xE(m),()=>a().referenceFragmentsForFiles?.(d)??new Map),calleesFor:d=>tp(u([d]),d,"callee"),calleesForDefinitions:u,signatureFor:d=>l({kind:"signature",definition:d},EE,()=>a().signatureFor(d)),dispose:()=>r?.dispose?.()}}function tp(e,t,n){if(!e.has(t.symbolId))throw new Error(`TypeScript ${n} evidence is incomplete for ${t.symbol}.`);return e.get(t.symbolId)}var Yl=class{constructor(t,n={}){this.db=t;this.runtime=n.runtime??IE,this.timeoutMs=n.timeoutMs??wE(),this.mailboxLimits=n.mailboxLimits??{},this.cacheDir=bE(t.config.dbPath),this.projectRoot=qd(t.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;mailboxLimits;request(t){let n=km(this.cacheDir),i=Wm(this.cacheDir),r=yl(n.statePath);if(!np(r,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let o=this.db.generation.identity;if(!o)throw new Error("Published TypeScript generation identity is unavailable.");let s=this.runtime.now(),a=s+this.timeoutMs,l=(this.runtime.monotonicNow??jo)()+this.timeoutMs,c=Hd(),u=Mm("typescript-semantic-v4",{generation:o,profileEnvironment:c,request:t}),d=Am(u),m=Nm(i,{mailboxVersion:Fm,operationKey:u,clientId:this.runtime.randomId(),enqueuedAtMs:s,deadlineAtMs:a,protocolVersion:as,id:d,generation:o,profileEnvironment:c,request:t},{nowMs:s,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??jo)()<=l;){if(yE(m.responsePath))return CE($d(m.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript semantic mailbox response"}),d,o,u);let f=yl(n.statePath);if(!np(f,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(vE)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}};function np(e,t,n){let i=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptSemantic?.protocolVersion===as&&n.isProcessAlive(e.pid)&&(!e.processIdentity||i!=null&&zd(e.processIdentity,i))}function CE(e,t,n,i){let r=JSON.parse(e);if(r.protocolVersion!==as||r.id!==t||r.operationKey!==i||r.ok===!0&&r.generation!==n)throw new Error("TypeScript semantic service wrote an incompatible response.");if(r.ok===!0)return r.response;throw new Error(typeof r.error=="string"?r.error:"TypeScript semantic service request failed.")}function ip(e){if(!Array.isArray(e))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(e)}function xE(e){if(!Array.isArray(e))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(e)}function RE(e){let t=ep(e);if(!t)throw new Error("TypeScript semantic service wrote invalid availability.");return t}function EE(e){if(e!==null&&typeof e!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return e}function wE(){let e=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:SE}var IE={now:Date.now,monotonicNow:jo,randomId:hE,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:Kd,readProcessIdentity:Gd};var Xl=new Fs;Yd({name:"semantic-provider",groups:["semantic-provider"],clearAll:e=>Xl.clear(e)});Xd({name:"semantic-provider",close:e=>Xl.clear(e)});function di(e,t){let n=Ke(t)??"typescript";return Xl.getOrCreate(e,n,()=>n==="rust"?Jf(e.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:i=>Gf(e,i)},calleeSymbolResolver:zf(e),sourceZeroCalleeOracle:i=>LE(e,i),scipOccurrenceCalleeOracle:i=>Qf(e,i)}):rp(e,t))}function Ke(e){return e?ye(e)==="rust"?"rust":Jo(e)?"typescript":null:"typescript"}function LE(e,t){let n=ee(e,t.relativePath);if(!n||n.language!=="rust")return!1;let i=n.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine&&r.name===t.leaf)??n.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine);return i?!n.callSites.some(r=>r.line>=i.startLine&&r.line<=i.endLine):!1}var DE=/^[A-Za-z_][A-Za-z0-9_]*$/,op=/\bDefault::default\b/g,PE=/^\.\.\s*Default::default\b/;function sp(e,t){let n=new Map,i=new Map;for(let r of t){let o=Zl(e,r,i);o!==null&&n.set(r.symbolId,o)}return n}function Zl(e,t,n=new Map){let i=FE(t.symbol);if(!i)return null;let r=Qo(e,[t.symbolId]);if(r.length===0)return null;let o=new RegExp(`(^|[^A-Za-z0-9_])${He(i)}::default\\b`,"g"),s=new RegExp(`(^|[^A-Za-z0-9_])${He(i)}\\s*$`),a=TE(e,t.symbolId),l=[];for(let c of r){let u=ME(e,c.relative_path,n);if(u===null)return null;let d=u.split(/\r?\n/),m=0,f=[],p=0;for(let g=c.chunk_start;g<=c.chunk_end&&g<d.length;g+=1){let S=d[g]??"",v=new Set;o.lastIndex=0;let y;for(;y=o.exec(S);)l.push({file:c.relative_path,line:g,column:y.index+y[1].length+i.length+2}),p+=1;for(let E=0;E<S.length;E+=1){let w=PE.exec(S.slice(E));if(w){if(a&&f.includes(m)){let R=E+w[0].lastIndexOf("default");l.push({file:c.relative_path,line:g,column:R}),v.add(R),p+=1}E+=w[0].length-1;continue}let b=S[E];if(b==="{"){let R=s.test(S.slice(0,E));m+=1,R&&f.push(m);continue}if(b==="}")for(m=Math.max(0,m-1);f.length>0&&f[f.length-1]>m;)f.pop()}for(op.lastIndex=0;y=op.exec(S);){let E=y.index+9;if(!v.has(E))return null}}if(p===0)return null}return $m(l)}function TE(e,t){return e.get("SELECT 1 AS present FROM mentions WHERE symbol_id = ? AND role = 1 LIMIT 1",t)?.present===1}function FE(e){let t=/impl#\[([^\]]+)\]\[Default\]default\(\)\./.exec(e)?.[1]??null;return!t||!DE.test(t)?null:t}function ME(e,t,n){if(n.has(t))return n.get(t)??null;let i=e.get("SELECT text FROM documents WHERE relative_path = ?",t),r=typeof i?.text=="string"?i.text:AE(e,t);return n.set(t,r),r}function AE(e,t){try{return nt(e.config.projectRoot,t,{inputKind:"indexed Rust source file"})}catch(n){if(!St(n))throw n;return null}}var Ms=new WeakMap;function mp(e){Ms.delete(e)}function fp(e){let t=Ms.get(e);return{incompleteSymbolIds:new Set(t?.incompleteSymbolIds),unavailableSymbolIds:new Set(t?.unavailableSymbolIds)}}function tc(e,t){if(t.incompleteSymbolIds.size===0&&t.unavailableSymbolIds.size===0)return;let n=Ms.get(e)??{incompleteSymbolIds:new Set,unavailableSymbolIds:new Set};for(let i of t.incompleteSymbolIds)n.incompleteSymbolIds.add(i);for(let i of t.unavailableSymbolIds)n.unavailableSymbolIds.add(i);Ms.set(e,n)}var NE="typescript-import-usage-v1",kE="typescript-signatures-v1",Ql=Fe("semantic-prefetched-callees",{clearGroups:["whole-project","source-file","semantic-provider"]}),ap=hr({kind:"semantic-import-usage",invalidation:Je("semantic-import-usage"),serialize:e=>JSON.stringify(e),deserialize:Rp}),lp=hr({kind:"semantic-signatures",invalidation:Je("semantic-signatures"),serialize:e=>JSON.stringify(e),deserialize:zE}),cp=vt({kind:"typescript-import-usage",invalidation:Je("typescript-import-usage"),serialize:e=>JSON.stringify(e),deserialize:Rp}),up=vt({kind:"typescript-signatures",invalidation:Je("typescript-signatures"),serialize:e=>JSON.stringify(e),deserialize:GE});function kt(e){let t=new Map,n=new Set;return{capability:(i,r)=>Ep(e,i,r),importUsage:i=>BE(e,i),references:i=>hp(e,i),materializeReferences:(i,r)=>bp(e,i,t,n,r),callerMap:i=>OE(e,i,t,n),calleeMap:i=>vp(e,i),signature:i=>HE(e,i)}}function _E(e,t){if(t.size===0)return;let n=Ql.get(e,()=>new Map);for(let[i,r]of t)n.set(i,[...r])}function pp(e,t){if(!Ql.has(e))return{hits:[],misses:[...t]};let n=Ql.get(e,()=>new Map),i=[],r=[];for(let o of t)n.has(o.symbolId)?i.push({definition:o,callees:n.get(o.symbolId)??[]}):r.push(o);return{hits:i,misses:r}}function $r(e,t){return kt(e).importUsage(t)}function BE(e,t){if(Ke(t)==="typescript"){let o="fallback",s=0,a=0,l=0,c=0;return $("typescript.import-usage.materialize",()=>{let u=Sr(e,t,NE);if(u?.key){s=1;let m=cp.read(e,t,u.key);if(m)return o="hit",a=1,m;l=1;let f=vn(e,t);if(!f)return o="unavailable",[];let p=f.importUsage(t);return cp.write(e,t,u.key,p),o="computed",p}c=1;let d=vn(e,t);return d?(o="direct-fallback",d.importUsage(t)):(o="unavailable",[])},()=>({state:o,eligible:s,cacheHits:a,cacheMisses:l,fallbacks:c}))}let n=xp(e,"semantic-import-usage",t);if(n){let o=ap.read(e,t,n);if(o)return o}let i=vn(e,t);if(!i)return[];let r=i.importUsage(t);return n&&ap.write(e,t,n,r),r}function gp(e,t){return kt(e).references(t)}function hp(e,t){let n=Zl(e,t);if(n)return n;let i=Hm(e,t);if(i)return i;let r=vn(e,t.relativePath);return r?r.referencesFor(t):[]}function yp(e,t){let n=Cn(e,t),i=n.incompleteSymbolIds.size+n.unavailableSymbolIds.size;if(i>0)throw new Error(`Exact semantic caller evidence is incomplete for ${i} definition(s).`);return n.callers}function Cn(e,t,n=i=>di(e,i)){let i=new Map,r=new Set,o=new Set,s=new Map;for(let l of t){let c=Ke(l.relativePath);if(!c)continue;let u;try{u=n(l.relativePath)}catch{o.add(l.symbolId);continue}if(!u.availability().available){o.add(l.symbolId);continue}if(c==="typescript"){let d=s.get(u)??[];d.push(l),s.set(u,d);continue}ec(e,i,l,hp(e,l))}for(let[l,c]of s){let u=pl(e,c,n),d=u?.references??(l.referencesForDefinitions?l.referencesForDefinitions(c,{exact:!0}):new Map(c.map(m=>[m.symbolId,l.referencesFor(m)])));!u&&ft()&&fl(e,c,d,n);for(let m of c){if(!d.has(m.symbolId)){r.add(m.symbolId);continue}ec(e,i,m,d.get(m.symbolId)??[])}}let a={callers:i,incompleteSymbolIds:r,unavailableSymbolIds:o};return tc(e,a),a}function OE(e,t,n=new Map,i=new Set){let r=new Map,o=bp(e,t,n,i),s=0;return $("semantic.callers.from-references",()=>{for(let a of t)s+=ec(e,r,a,n.get(a.symbolId)??[])},()=>({definitions:t.length,materialized:o.definitions,inMemoryHits:o.inMemoryHits,incompleteInMemoryHits:o.incompleteInMemoryHits,resultRows:r.size,callerFiles:s})),r}function bp(e,t,n,i,r={}){let o=gn(e),s=[],a=[],l=[],c=0,u=0,d=0,m=0,f=0,p=0,g=0,h=0,S=0,v=0,y=0,E=0,w=[],b=new Map,R=t.filter(L=>Ke(L.relativePath)==="typescript"&&!n.has(L.symbolId)&&!i.has(L.symbolId)),C=pl(e,R,L=>di(e,L));if(C){S=R.length,v=C.cacheHits,y=C.cacheMisses,E=C.computedFiles;for(let L of R)n.set(L.symbolId,C.references.get(L.symbolId)??[])}if($("semantic.references.cache-scan",()=>{for(let[L,I]of Is(t)){let x=[];for(let D of I)n.has(D.symbolId)?u+=1:i.has(D.symbolId)?h+=1:x.push(D);if(x.length===0){g+=1;continue}let P=$E(e,o,L);if(!P){for(let D of x)Ke(D.relativePath)||(c+=1),l.push(D);continue}p+=1;let _=Qd(e,L,P);for(let D of x){let T=_.get(D.symbol)??null;if(T!==null){let A=jE(T);if(A){d+=1,n.set(D.symbolId,A);continue}m+=1}a.push({definition:D,cacheFingerprint:P})}}},()=>({definitions:t.length,skippedUnsupportedLanguage:c,cacheHits:d,parseFailures:m,misses:a.length,unkeyed:l.length,inMemoryHits:u,incompleteInMemoryHits:h,fullyInMemoryFiles:g,cacheReadFiles:p})),a.length>0||l.length>0){w=[...l,...a.map(L=>L.definition)],b=$("semantic.references.compute-misses",()=>{let L=As(e,w,r);return f=L.size,L},()=>({definitions:w.length,misses:a.length,unkeyed:l.length,rows:f}));for(let L of w)b.has(L.symbolId)?(n.set(L.symbolId,b.get(L.symbolId)??[]),i.delete(L.symbolId)):i.add(L.symbolId);for(let{definition:L,cacheFingerprint:I}of a)b.has(L.symbolId)&&Ep(e,"semantic-references",L.relativePath).available&&s.push({relativePath:L.relativePath,symbol:L.symbol,projectFingerprint:I,payload:JSON.stringify(b.get(L.symbolId)??[])})}return s.length>0&&$("semantic.references.cache-write",()=>em(e,s),()=>({entries:s.length})),b.size>0&&fl(e,w,b,L=>di(e,L)),{definitions:t.length,inMemoryHits:u,incompleteInMemoryHits:h,cacheHits:d,misses:a.length,unkeyed:l.length,skippedUnsupportedLanguage:c,parseFailures:m,computed:f,incomplete:i.size,cacheWrites:s.length,fragmentDefinitions:S,fragmentCacheHits:v,fragmentCacheMisses:y,fragmentComputedFiles:E}}function $E(e,t,n){if(!t)return null;let i=Ke(n);return i==="typescript"?jt(JSON.stringify({kind:"semantic-references",language:i,schema:"typescript-references-v2-incomplete-scan",projectFingerprint:t})):i==="rust"?jt(JSON.stringify({kind:"semantic-references",language:i,engine:oi(e.config.projectRoot),projectFingerprint:t})):null}function As(e,t,n={}){let i=ft(),r=new Map,o=0,s=0,a=0,l=0,c=0,u=0,d=0,m=0,f=0;return $("semantic.references.provider-loop",()=>{let p=sp(e,t),g=jm(e,t),h=new Map,S=n.prefetchCallees?new Map:null,v=[];for(let E of t){let w,b=()=>(w??=vn(e,E.relativePath),w);if(S){let I=b();if(I?.referencesAndCalleesForDefinitions){let x=S.get(I);x?x.push(E):S.set(I,[E]),f+=1}}let R=p.get(E.symbolId);if(R){a+=1,l+=R.length,Or(r,E.symbolId,R,i,I=>{d+=1,m+=I});continue}let C=g.get(E.symbolId);if(C){c+=1,u+=C.length,Or(r,E.symbolId,C,i,I=>{d+=1,m+=I});continue}let L=b();if(!L){i&&(s+=1);continue}if(i&&(o+=1),L.referencesForDefinitions){let I=h.get(L);I?I.push(E):h.set(L,[E])}else v.push({provider:L,definition:E})}let y=new Set;if(S)for(let[E,w]of S){if(!E.referencesAndCalleesForDefinitions)continue;let b=h.get(E)??[],R=E.referencesAndCalleesForDefinitions(b,w);y.add(E),_E(e,R.callees);for(let C of b){if(!R.references.has(C.symbolId))continue;let L=R.references.get(C.symbolId)??[];Or(r,C.symbolId,L,i,I=>{d+=1,m+=I})}}for(let[E,w]of h){if(y.has(E))continue;let b=E.referencesForDefinitions(w);for(let R of w){if(!b.has(R.symbolId))continue;let C=b.get(R.symbolId)??[];Or(r,R.symbolId,C,i,L=>{d+=1,m+=L})}}for(let{provider:E,definition:w}of v){let b=E.referencesFor(w);Or(r,w.symbolId,b,i,R=>{d+=1,m+=R})}return r},()=>({definitions:t.length,providerHits:o,providerMisses:s,rustDefaultFastPathRows:a,rustDefaultFastPathReferences:l,rustScipOccurrenceFastPathRows:c,rustScipOccurrenceFastPathReferences:u,prefetchCalleeDefinitions:f,definitionsWithReferences:d,referenceCount:m,rows:r.size}))}function Ns(e,t,n={}){let i=As(e,t,n),r=Sp(e,t,i);return tc(e,r),{rows:i,...r}}function Or(e,t,n,i,r){e.set(t,n),i&&n.length>0&&r(n.length)}function ec(e,t,n,i){let r=0;for(let o of i){if(o.file===n.relativePath||e.isIgnored(o.file))continue;let s=t.get(n.symbolId);s||(s=new Set,t.set(n.symbolId,s));let a=s.size;s.add(o.file),s.size!==a&&(r+=1)}return r}function jE(e){try{return JSON.parse(e)}catch{return null}}function ks(e,t,n){let i=vp(e,t,n),r=Sp(e,t,i,n);return tc(e,r),{rows:i,...r}}function Sp(e,t,n,i){let r=new Set,o=new Set;for(let s of t)if(!(n.has(s.symbolId)||!Ke(s.relativePath)))try{(i?i(s.relativePath):di(e,s.relativePath)).availability().available?r.add(s.symbolId):o.add(s.symbolId)}catch{o.add(s.symbolId)}return{incompleteSymbolIds:r,unavailableSymbolIds:o}}function vp(e,t,n){let i=ft(),r=new Map,o=0,s=0,a=0,l=0;return $("semantic.callees.provider-loop",()=>{let c=new Map,u=[];for(let d of t){let m=n?n(d.relativePath):vn(e,d.relativePath);if(m&&!m.availability().available){i&&(s+=1);continue}if(!m){i&&(s+=1);continue}i&&(o+=1);let f=d;if(m.calleesForDefinitions){let p=c.get(m);p?p.push(f):c.set(m,[f])}else u.push({provider:m,definition:f})}for(let[d,m]of c){let f=d.calleesForDefinitions(m);for(let p of m){if(!f.has(p.symbolId))continue;let g=f.get(p.symbolId)??[];dp(r,p.symbolId,g,i,h=>{a+=1,l+=h})}}for(let{provider:d,definition:m}of u){let f=d.calleesFor(m);dp(r,m.symbolId,f,i,p=>{a+=1,l+=p})}return r},()=>({definitions:t.length,providerHits:o,providerMisses:s,definitionsWithCallees:a,calleeCount:l,rows:r.size}))}function dp(e,t,n,i,r){e.set(t,n),i&&n.length>0&&r(n.length)}function Cp(e,t){return kt(e).signature(t)}function HE(e,t){if(Ke(t.relativePath)==="typescript"){let s="fallback",a=0,l=0,c=0,u=0;return $("typescript.signature.materialize",()=>{let d=Sr(e,t.relativePath,kE);if(d?.key){a=1;let f=up.read(e,t.relativePath,d.key)??{};if(Object.prototype.hasOwnProperty.call(f,t.symbol))return s="hit",l=1,f[t.symbol]??null;c=1;let p=vn(e,t.relativePath);if(!p)return s="unavailable",null;let g=p.signatureFor(t);return up.write(e,t.relativePath,d.key,{...f,[t.symbol]:g}),s="computed",g}u=1;let m=vn(e,t.relativePath);return m?(s="direct-fallback",m.signatureFor(t)):(s="unavailable",null)},()=>({state:s,eligible:a,cacheHits:l,cacheMisses:c,fallbacks:u}))}let n=xp(e,"semantic-signatures",t.relativePath),i=UE(t);if(n){let s=lp.read(e,i,n);if(s)return s.signature}let r=vn(e,t.relativePath);if(!r)return null;let o=r.signatureFor(t);return n&&lp.write(e,i,n,{signature:o}),o}function xp(e,t,n){let i=gn(e);if(!i)return null;let r=Ke(n);return r!=="rust"?null:jt(JSON.stringify({kind:t,language:r,engine:oi(e.config.projectRoot),projectFingerprint:i}))}function UE(e){return`${e.relativePath}\0${e.symbol}`}function Rp(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function zE(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t.signature;return n!==null&&typeof n!="string"?null:{signature:n}}catch{return null}}function GE(e){try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return null;for(let n of Object.values(t))if(n!==null&&typeof n!="string")return null;return t}catch{return null}}function Ep(e,t,n){let i=Ke(n);if(!i)return{slot:t,language:"typescript",available:!1,reason:"semantic evidence is only available for TypeScript or Rust files"};try{return{slot:t,language:i,...di(e,n).availability()}}catch(r){return{slot:t,language:i,available:!1,reason:r instanceof Error?r.message:String(r)}}}function vn(e,t){if(!Ke(t))return null;let n=di(e,t);return n.availability().available?n:null}var pe={references:gp,referenceMap:As,referenceEvidenceMap:Ns,callerMap:(e,t)=>kt(e).callerMap(t),calleeMap:nc,calleeEvidenceMap:wp};function nc(e,t,n={}){return wp(e,t,n).rows}function wp(e,t,n={}){let i=ft(),r=new Map,o=pp(e,t),s=[],a=[],l=0,c=0,u=0,d=0,m=0,f=0,p=0,g=new Set,h=new Set;for(let{definition:b,callees:R}of o.hits)m+=1,r.set(b.symbolId,R),R.length>0&&(f+=1,p+=R.length);let S=KE(e,o.hits);if(S.entries.length>0&&$("semantic.callees.prefetch-cache-write",()=>dl(e,S.entries),()=>({entries:S.entries.length,sourceMissing:S.sourceMissing,skippedUnsupportedLanguage:S.skippedUnsupportedLanguage})),$("semantic.callees.cache-scan",()=>{for(let[b,R]of Is(o.misses)){if(!Ke(b)){i&&(l+=R.length);continue}let C=se(e,b);if(!C){i&&(c+=R.length),a.push(...R);continue}let L=Ft(e,b,C),I=Ip(e,b);if(!I){a.push(...R);continue}let x=Zd(e,b,L,I);for(let P of R){let _=x.get(P.symbol)??null;if(_!==null){let D=WE(_);if(D){i&&(u+=1),r.set(P.symbolId,D);continue}i&&(d+=1)}s.push({def:P,contentHash:L,depsDigest:I})}}},()=>({definitions:t.length,skippedUnsupportedLanguage:l,sourceMissing:c,cacheHits:u,parseFailures:d,misses:s.length,unkeyed:a.length,inMemoryHits:m,inMemoryRows:f,inMemoryCalleeCount:p,resultRows:r.size})),s.length===0&&a.length===0)return{rows:r,incompleteSymbolIds:g,unavailableSymbolIds:h};let v=[...a,...s.map(b=>b.def)],y=0,E=$("semantic.callees.compute-misses",()=>{let b=ks(e,v,n.resolveProvider);for(let R of b.incompleteSymbolIds)g.add(R);for(let R of b.unavailableSymbolIds)h.add(R);return y=b.rows.size,b.rows},()=>({definitions:v.length,misses:s.length,unkeyed:a.length,rows:y}));for(let[b,R]of E)r.set(b,R);let w=s.filter(b=>E.has(b.def.symbolId)&&kt(e).capability("semantic-callees",b.def.relativePath).available).map(b=>({relativePath:b.def.relativePath,symbol:b.def.symbol,contentHash:b.contentHash,depsDigest:b.depsDigest,payload:JSON.stringify(E.get(b.def.symbolId)??[])}));return w.length>0?$("semantic.callees.cache-write",()=>dl(e,w),()=>({entries:w.length})):$("semantic.callees.cache-write-skip",()=>{},()=>({reason:"provider-unavailable",misses:s.length})),{rows:r,incompleteSymbolIds:g,unavailableSymbolIds:h}}function KE(e,t){let n=[],i=new Map,r=0,o=0;for(let{definition:s,callees:a}of t){if(!Ke(s.relativePath)){o+=1;continue}if(!i.has(s.relativePath)){let c=se(e,s.relativePath),u=c?Ip(e,s.relativePath):null;i.set(s.relativePath,c&&u?{contentHash:Ft(e,s.relativePath,c),depsDigest:u}:null)}let l=i.get(s.relativePath);if(!l){r+=1;continue}n.push({relativePath:s.relativePath,symbol:s.symbol,contentHash:l.contentHash,depsDigest:l.depsDigest,payload:JSON.stringify(a)})}return{entries:n,sourceMissing:r,skippedUnsupportedLanguage:o}}var qE="typescript-callees-v3-incomplete-scan";function Ip(e,t){let n=Ke(t);if(n==="typescript")return Sr(e,t,qE)?.key??null;let i=JE(e,t);return n==="rust"?jt(JSON.stringify({kind:"semantic-callees",language:n,engine:oi(e.config.projectRoot),positionMapping:"nearby-leaf-v2-callsite-line",depsDigest:i})):i}function WE(e){try{return JSON.parse(e)}catch{return null}}var VE=Fi("semantic-deps-digest",{clearGroups:["whole-project","source-file"]});function JE(e,t){return VE.get(e,t,()=>{let i=[...Be(e).get(t)??[]].sort().map(r=>`${r}:${Ft(e,r,se(e,r))}`);return jt(i.join("|"))})}function d2(e,t,n={}){let i=fe(e,t);if(!i)return[];let o=!ke(i.symbol)&&!e.isIgnored(i.relativePath)?[{relativePath:i.relativePath,line:i.startLine}]:[],s=On(e,i,{semantic:n.semantic,semanticEvidence:pe}).map(u=>({relativePath:u.file,line:u.line})),a=YE(e,i),l=new Set,c=[];for(let u of[...o,...s,...a]){let d=`${u.relativePath}:${u.line}`;l.has(d)||(l.add(d),c.push(u))}return c}function YE(e,t){if(!t.relativePath.endsWith(".rb"))return[];let n=XE(t.symbol);if(n.length===0)return[];let i=[];for(let r of he(e,{extensions:[".rb"],includeIgnored:!1})){let o=se(e,r);if(!o)continue;let s=o.split(`
50
+ `);for(let a=0;a<s.length;a++){let l=s[a]??"";n.some(c=>new RegExp(`@${c}\\b|\\b${c}:`).test(l))&&i.push({relativePath:r,line:a})}}return i}function XE(e){let n=(e.split(":").pop()??e).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),i=n.split("_").filter(Boolean),r=new Set;return n&&r.add(n),i.length>=1&&r.add(i[i.length-1]),i.length>=2&&r.add(i.slice(-2).join("_")),[...r]}import{statSync as ZE}from"fs";function mi(e){let t=e.get("SELECT COUNT(*) as c FROM documents").c,n=e.get("SELECT COUNT(*) as c FROM global_symbols").c,i=e.get("SELECT COUNT(*) as c FROM mentions WHERE role = 1").c,r=e.get("SELECT COUNT(*) as c FROM mentions WHERE role != 1").c;return{documents:t,symbols:n,definitions:i,references:r,...QE(e.generation.databasePath)}}function QE(e){try{let t=ZE(e);return{indexSizeBytes:t.size,lastBuilt:t.mtime}}catch{return{indexSizeBytes:0,lastBuilt:null}}}function ew(e,t){return Cl(e).filter(n=>tw({pattern:t,relativePath:n})).map(n=>({relativePath:n}))}function tw(e,t){let n=typeof e=="string"?{pattern:e,relativePath:t}:e;if(typeof n.pattern!="string"||typeof n.relativePath!="string")throw new TypeError("pathMatchesGlob requires pattern and relativePath.");let i=pn(n.pattern),r=pn(n.relativePath);if(!/[*?]/.test(i))return r.includes(i);let o=i.includes("/")?i:`**/${i}`;return _s(o.split("/"),r.split("/"))}function _s(e,t){if(e.length===0)return t.length===0;let[n,...i]=e;return n==="**"?_s(i,t)||t.length>0&&_s(e,t.slice(1)):t.length===0||!nw(n??"",t[0]??"")?!1:_s(i,t.slice(1))}function nw(e,t){let n="^";for(let i of e)i==="*"?n+="[^/]*":i==="?"?n+="[^/]":n+=iw(i);return n+="$",new RegExp(n).test(t)}function iw(e){return/[\\^$.*+?()[\]{}|]/.test(e)?`\\${e}`:e}function Dp(e,t,n){let i=[],r=[],o=new Map;for(let s of[...e].sort(n)){let a=s.channel??"default",l=t[a]??Number.MAX_SAFE_INTEGER,c=o.get(a)??0;if(c>=l){r.push(s);continue}i.push(s),o.set(a,c+1)}return{selected:i,omitted:r}}function Bs(e,t,n,i,r=!1){let o=[...e],s=[],a=new Set,l=0;for(;o.length>0&&s.length<t;){let c=o.filter(m=>l+m.evidenceCharacters<=n||r&&s.length===0);if(c.length===0)break;let u=c.filter(m=>m.roles.includes("location")||m.roles.includes("definition")).sort(i);c.sort((m,f)=>Lp(f,a)-Lp(m,a)||i(m,f));let d=u[0]??c[0];s.push(d),l+=d.evidenceCharacters;for(let m of Pp(d))a.add(m.key);o.splice(o.indexOf(d),1)}return{selected:s,omitted:o.sort(i)}}function Lp(e,t){let n=Pp(e).reduce((o,s)=>o+(t.has(s.key)?0:s.weight),0),i=Math.max(0,8-e.priority)*20,r=Math.min(500,Math.ceil(e.evidenceCharacters/160));return n+i-r}function Pp(e){return[...e.reasons.map(rw),...e.roles.map(t=>({key:`role:${t}`,weight:ow(t)})),{key:`file:${e.relativePath}`,weight:180},{key:`scope:${sw(e.relativePath)}`,weight:120},{key:`kind:${e.fileKind}`,weight:40},...e.symbols.map(t=>({key:`symbol:${t}`,weight:100})),...e.behaviorSignals.map(t=>({key:`behavior:${t}`,weight:70}))]}function rw(e){let t=e.indexOf(":"),n=t<0?e:e.slice(0,t);return n==="dependency"||n==="consumer"?{key:`reason:${n}`,weight:220}:{key:`reason:${e}`,weight:n==="location"||n==="definition"?1400:800}}function ow(e){switch(e){case"location":return 1200;case"definition":return 1100;case"reference":return 600;case"caller":case"callee":return 550;case"dependency":case"consumer":return 500;case"search":return 400;default:return 300}}function sw(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}var Tp=64,Fp=12;function ic(e,t,n={}){if(t.length===0)throw new Error("The source search pattern must not be empty.");let i=n.context??6;if(!Number.isSafeInteger(i)||i<0)throw new RangeError(`context must be a non-negative safe integer; received ${i}`);let r=n.limit??12;if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`limit must be a positive safe integer; received ${r}`);let o=n.regexp?ss(t,"source search pattern",n.ignoreCase?"iu":"u"):null,s=n.ignoreCase?t.toLocaleLowerCase():t,a=ds(e,{scope:n.scope}),l=[],c=[];for(let h of a.files){let S=h.relativePath,v=cw(h.text);if(v.length===0)continue;let y=h.freshness.semantic.state!=="stale"&&h.freshness.semantic.basis!=="no-compiler-document"?J(e,S):[],E=ee(e,S)?.callables??[],w=0;for(let b=0;b<v.length;b+=1){let R=v[b]??"",C=R.endsWith("\r")?R.slice(0,-1):R;if(!(o?o.test(C):(n.ignoreCase?C.toLocaleLowerCase():C).includes(s)))continue;w+=1;let I=Ge(y,b),x=aw(E,b),P=I&&!Le(I.symbol)?I:null,_=P?.startLine??x?.startLine??I?.startLine??b,D=P?.endLine??x?.endLine??I?.endLine??b,T=Ar(e,S,b,_,D);l.push({relativePath:S,focusLine:b,ownerSymbol:P?.symbol??null,ownerShort:P?k(P.symbol):x?.name??(I?k(I.symbol):null),ownerStartLine:T.startLine,ownerEndLine:T.endLine,fileKind:V(S),freshness:h.freshness})}w>0&&c.push({relativePath:S,matchingLines:w,returnedMatches:0,freshness:h.freshness})}l.sort(Ap);let u=l.length>Tp?Mp(l,Tp):l,d=r===Number.MAX_SAFE_INTEGER?l:n.ranking?Mp(l,r):l.slice(0,r),m=new Map(a.files.map(h=>[h.relativePath,h.text])),f=d.flatMap(h=>{let S=m.get(h.relativePath),v=S===void 0?null:lw(h.relativePath,S,h.focusLine,i);return v?[{...v,...h}]:[]}),p=new Map;for(let h of f)p.set(h.relativePath,(p.get(h.relativePath)??0)+1);for(let h of c)h.returnedMatches=p.get(h.relativePath)??0;let g=uw(c);return{pattern:t,mode:n.regexp?"regexp":"literal",identities:l,...u.length<l.length?{identityManifest:u}:{},identityCoverage:{mode:u.length===l.length?"complete":"bounded",returned:u.length,total:l.length,omitted:l.length-u.length},matches:f,matchingLines:l.length,matchingFiles:c.length,omittedMatches:Math.max(0,l.length-f.length),fileCoverage:c,scopeHints:g.slice(0,Fp),omittedScopeHints:Math.max(0,g.length-Fp),scannedFiles:a.files.length,textCoverage:{basis:"current-project-text-files",candidateFiles:a.candidateFiles,scannedTextFiles:a.files.length,scannedBytes:a.scannedBytes,skippedBinaryPaths:a.skippedBinaryPaths,skippedUnreadablePaths:a.skippedUnreadablePaths,skippedOversizedPaths:a.skippedOversizedPaths,semanticFiles:{aligned:a.files.filter(h=>h.freshness.semantic.state==="aligned").length,stale:a.files.filter(h=>h.freshness.semantic.state==="stale").length,unavailable:a.files.filter(h=>h.freshness.semantic.state==="unavailable").length}}}}function aw(e,t){return e.filter(n=>n.startLine<=t&&n.endLine>=t).sort((n,i)=>n.endLine-n.startLine-(i.endLine-i.startLine)||n.startLine-i.startLine)[0]??null}function lw(e,t,n,i){let r=t.split(`
51
+ `),o=t.endsWith(`
52
+ `)?r.length-1:r.length;if(n<0||n>=o)return null;let s=Math.max(0,n-i),a=Math.min(o-1,n+i);return{relativePath:e,startLine:s,endLine:a,focusLine:n,source:r.slice(s,a+1).join(`
53
+ `)}}function cw(e){if(e.length===0)return[];let t=e.split(`
54
+ `);return e.endsWith(`
55
+ `)&&t.pop(),t}function uw(e){let t=new Map;for(let n of e){let i=dw(n.relativePath),r=t.get(i)??{matchingLines:0,matchingFiles:0};r.matchingLines+=n.matchingLines,r.matchingFiles+=1,t.set(i,r)}return[...t.entries()].map(([n,i])=>({scope:n,...i})).sort((n,i)=>i.matchingLines-n.matchingLines||i.matchingFiles-n.matchingFiles||n.scope.localeCompare(i.scope))}function dw(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}function Mp(e,t){let n=e.map((r,o)=>({...r,priority:Os(r.fileKind),sequence:o,evidenceCharacters:1,roles:["search"],reasons:["search"],symbols:r.ownerSymbol?[r.ownerSymbol]:[],behaviorSignals:[]})),i=[];for(let r of[0,1,2]){let o=t-i.length;if(o===0)break;let s=n.filter(a=>Os(a.fileKind)===r);i.push(...Bs(s,o,Number.MAX_SAFE_INTEGER,Ap).selected)}return i.map(({priority:r,sequence:o,evidenceCharacters:s,roles:a,reasons:l,symbols:c,behaviorSignals:u,...d})=>d)}function Ap(e,t){return Os(e.fileKind)-Os(t.fileKind)||+(t.ownerSymbol!==null)-+(e.ownerSymbol!==null)||e.relativePath.localeCompare(t.relativePath)||e.focusLine-t.focusLine}function Os(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}var rc=new Set(["a","an","and","are","as","at","be","become","becomes","by","can","does","for","from","how","in","into","is","it","its","of","on","or","that","the","their","then","this","through","to","what","when","where","which","with"]);function jr(e){return e.replace(/([\p{Ll}\d])([\p{Lu}])/gu,"$1 $2").replace(/([\p{Lu}]+)([\p{Lu}][\p{Ll}])/gu,"$1 $2").match(/[\p{L}\d]+/gu)??[]}function ct(e){return new Set(jr(e).flatMap(oc).filter(t=>t.length>=3))}function oc(e){let t=$s(e);return t.length>4&&t.endsWith("e")?[t,t.slice(0,-1)]:[t]}function $s(e){let t=e.toLocaleLowerCase();return t.length>5&&t.endsWith("ies")?`${t.slice(0,-3)}y`:t.length>4&&t.endsWith("ied")?`${t.slice(0,-3)}y`:t.length>4&&t.endsWith("ed")?Np(t.slice(0,-2)):t.length>5&&t.endsWith("ing")?Np(t.slice(0,-3)):t.length>4&&t.endsWith("ers")||t.length>3&&t.endsWith("s")&&!t.endsWith("ss")?t.slice(0,-1):t}function Np(e){if(e.length<2)return e;let t=e.at(-1),n=e.at(-2);return t===n&&!"aeiou".includes(t)?e.slice(0,-1):e}var kp=new WeakMap,_p=new WeakMap,Bp=new WeakMap,Op=new WeakMap,$p=new WeakMap;function jp(e,t){let n=_p.get(e);n||(n=new Map,_p.set(e,n));let i=n.get(t);if(i)return i;let r=ae(e,t)?.rootNode;if(!r)return n.set(t,[]),[];let o=new Set;Ut(r,c=>{if(c.type!=="call_expression")return;let u=c.childForFieldName("function")??c.namedChild(0),d=/^([A-Za-z_$][\w$]*(?:\.Service)?)\.of$/u.exec(u?.text.replace(/\s+/gu,"")??"");d&&o.add(d[1])});let s=Ce(e,t).filter(c=>!!c.sourcePath),a=new Set;for(let c of o){let u=/^([A-Za-z_$][\w$]*)\.Service$/u.exec(c);if(u){for(let d of s)d.localName===u[1]&&a.add(d.sourcePath);continue}if(c==="Service"){J(e,t).some(d=>d.leaf==="Service")&&a.add(t);for(let d of s)(d.localName??d.importedName)==="Service"&&a.add(d.sourcePath)}}let l=lc([...a]).sort();return n.set(t,l),l}function Un(e,t,n={}){let r=Jt(e,t)?.filter(f=>!n.ranges||n.ranges.some(p=>f.line>=p.startLine&&f.line<=p.endLine));if(!r)return{targets:[],unresolvedCallsites:0};let o=Ce(e,t).filter(f=>!!f.sourcePath),s=Dw(se(e,t)??""),a=ae(e,t)?.rootNode??null,l=a?fw(a):Hp(),c=new Map,u=Xt(e),d=[],m=0;for(let f of r){if(!f.memberAccess)continue;let p=Yt(t,u.get(f.calleeLeaf)??[]);if(n.excludeIndexedTargets!==!1&&Bn(e,t,p,!0,f.calleeQualifier))continue;let g=f.calleeQualifier,h=Iw(e,t,f,o);if(h){d.push(h);continue}let S=mw(e,t,f,o,pw(l,f.calleeQualifier,f.line));if(S.length>0){d.push(...S);continue}let v=gw(e,t,f);if(v.length>0){d.push(...v);continue}let y=g?s.get(g)??g:null,w=(y?lc(o.filter(R=>(R.localName??R.importedName)===y).map(R=>R.sourcePath)):[]).flatMap(R=>{let C=c.get(R);return C||(C=Mt(e,R)??[],c.set(R,C)),C.filter(L=>L.name===f.calleeLeaf).map(L=>({file:R,callable:L}))});if(w.length!==1){m+=1;continue}let b=w[0];d.push({calleeLeaf:f.calleeLeaf,line:f.line,sourceFile:t,targetFile:b.file,targetStartLine:b.callable.startLine,targetEndLine:b.callable.endLine,resolution:"direct-import-receiver",strength:"candidate"})}return{targets:d,unresolvedCallsites:m}}function mw(e,t,n,i,r){let o=n.calleeQualifier;if(!o||!/^[A-Za-z_$][\w$]*$/u.test(o))return[];if(r.size!==1)return[];let s=[...r][0],a=lc(i.filter(u=>u.localName===s||u.importedName===s).map(u=>u.sourcePath));if(a.length!==1)return[];let l=a[0],c=Sw(e,l,n.calleeLeaf);return c.map(u=>({calleeLeaf:u.name,line:n.line,sourceFile:t,targetFile:u.file,targetStartLine:u.startLine,targetEndLine:u.endLine,serviceFile:l,resolutionAlternativeCount:c.length,resolution:"imported-service-object-member",strength:"candidate"}))}function Hp(){return{declarations:new Map,callbacks:[]}}function fw(e){let t=Hp();return Ut(e,n=>{if(n.type==="variable_declarator"){let l=n.childForFieldName("name")??n.namedChild(0),c=n.childForFieldName("value")??n.namedChild(1);if(l?.type!=="identifier"||!c)return;let u=new Set;if(Ut(c,d=>{if(d.type!=="member_expression")return;let m=d.childForFieldName("object")??d.namedChild(0),f=d.childForFieldName("property")??d.namedChild(1);m?.type==="identifier"&&f?.text==="Service"&&u.add(m.text)}),u.size===1){let d=t.declarations.get(l.text)??[];d.push({line:n.startPosition.row,alias:[...u][0]}),t.declarations.set(l.text,d)}return}if(!["arrow_function","function_expression","generator_function"].includes(n.type))return;let i=n.childForFieldName("parameters")??n.childForFieldName("parameter");if(!i)return;let r=n.parent;for(;r&&r.type!=="call_expression";)r=r.parent;if(!r)return;let o=r.childForFieldName("function")??r.namedChild(0),s=/^([A-Za-z_$][\w$]*)\.Service\.use$/u.exec(o?.text??"");if(!s)return;let a=new Set;Ut(i,l=>{l.type==="identifier"&&a.add(l.text)}),a.size!==0&&t.callbacks.push({startLine:n.startPosition.row,endLine:n.endPosition.row,receivers:a,alias:s[1]})}),t}function pw(e,t,n){if(!t||!/^[A-Za-z_$][\w$]*$/u.test(t))return new Set;let i=new Set((e.declarations.get(t)??[]).filter(r=>r.line<=n).map(r=>r.alias));for(let r of e.callbacks)r.startLine<=n&&r.endLine>=n&&r.receivers.has(t)&&i.add(r.alias);return i}function gw(e,t,n){let i=n.calleeQualifier;if(!i||!/^[A-Za-z_$][\w$]*$/u.test(i))return[];let r=ae(e,t)?.rootNode;if(!r)return[];let o=hw(e,t,r,n.line,n.calleeLeaf,i),s=o?bw(o,i):null;if(!s)return[];if(!yw(s))return[];let a=(Mt(e,t)??[]).filter(f=>f.startLine<=s.startPosition.row&&f.endLine>=s.endPosition.row).sort((f,p)=>f.endLine-f.startLine-(p.endLine-p.startLine))[0];if(!a)return[];let l=J(e,t).filter(f=>f.isFunctionLike&&f.leaf===a.name);if(l.length!==1)return[];let c=l[0],u=Op.get(e);u||(u=new Map,Op.set(e,u));let d=`${c.symbol}\0${n.calleeLeaf}`,m=u.get(d);if(!m){let f=[];for(let p of Cr(e,c)){let g=ae(e,p.file)?.rootNode;if(!g)continue;let h=g.descendantsOfType("call_expression").filter(y=>y.startPosition.row>p.line||y.endPosition.row<p.line?!1:(y.childForFieldName("function")??y.namedChild(0))?.text.replace(/\s+/gu,"").replace(/<[^<>]*>$/u,"").match(/[A-Za-z_$][\w$]*$/u)?.[0]===c.leaf);if(h.length!==1)continue;let v=h[0].childForFieldName("arguments")?.namedChildren.find(y=>fi(y).type==="object");if(v)for(let y of fi(v).namedChildren){if(y.type==="shorthand_property_identifier"&&y.text===n.calleeLeaf){f.push(...js(e,p.file,n.calleeLeaf,y,y));continue}if(y.type!=="pair")continue;let E=y.childForFieldName("key")??y.namedChild(0),w=y.childForFieldName("value")??y.namedChild(1);Hs(E?.text)!==n.calleeLeaf||!w||f.push(...js(e,p.file,n.calleeLeaf,w,y))}}m=f.filter((p,g,h)=>h.findIndex(S=>S.file===p.file&&S.startLine===p.startLine&&S.endLine===p.endLine&&S.name===p.name)===g),u.set(d,m)}return m.map(f=>({calleeLeaf:f.name,line:n.line,sourceFile:t,targetFile:f.file,targetStartLine:f.startLine,targetEndLine:f.endLine,resolutionAlternativeCount:m.length,resolution:"factory-callback-member",strength:m.length===1?"exact":"candidate"}))}function hw(e,t,n,i,r,o){let s=Bp.get(e);s||(s=new Map,Bp.set(e,s));let a=s.get(t);if(!a){a=new Map;for(let l of n.descendantsOfType("call_expression")){let c=l.childForFieldName("function")??l.namedChild(0),u=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(c?.text.replace(/\s+/gu,"")??"");if(u)for(let d=l.startPosition.row;d<=l.endPosition.row;d+=1){let m=`${d}\0${u[1]}\0${u[2]}`,f=a.get(m);(!f||l.endIndex-l.startIndex<f.endIndex-f.startIndex)&&a.set(m,l)}}s.set(t,a)}return a.get(`${i}\0${o}\0${r}`)??null}function yw(e){return e.descendantsOfType("return_statement").some(t=>{let n=t.childForFieldName("argument")??t.namedChild(0);return!!(n&&fi(n).type==="object")})}function bw(e,t){let n=e.parent;for(;n;){if(/(?:function|method|lambda)/u.test(n.type)||n.type==="arrow_function"){let i=n.childForFieldName("parameters")??n.childForFieldName("parameter"),r=!1;if(i&&Ut(i,o=>{o.type==="identifier"&&o.text===t&&(r=!0)}),r)return n}n=n.parent}return null}function js(e,t,n,i,r){if(i.type==="identifier")return(Mt(e,t)??[]).filter(l=>l.name===i.text).map(l=>({...l,file:t}));let o=sc(e,t,i.text);if(o.length>0)return o;if(!ac(i))return[];let a=(Mt(e,t)??[]).filter(l=>l.startLine>=r.startPosition.row&&l.endLine<=r.endPosition.row&&(l.name===n||l.name.startsWith("source@"))).sort((l,c)=>l.endLine-l.startLine-(c.endLine-c.startLine))[0];return[a?{...a,file:t}:{name:n,file:t,startLine:r.startPosition.row,endLine:r.endPosition.row}]}function Sw(e,t,n){let i=$p.get(e);i||(i=new Map,$p.set(e,i));let r=`${t}\0${n}`,o=i.get(r);if(o)return o;let s=xw(e,t).flatMap(a=>vw(e,a,t,n));return i.set(r,s),s}function vw(e,t,n,i){let r=ae(e,t)?.rootNode,o=Mt(e,t)??[];if(!r)return[];let s=Rw(e,t,n);if(s.size===0)return[];let a=new Set,l=[],c=[],u=[];return Ut(r,m=>{if(Cw(m,s)){if(m.type==="pair"){let f=m.childForFieldName("key")??m.namedChild(0),p=m.childForFieldName("value")??m.namedChild(1);if(Hs(f?.text)!==i||!p)return;if(p.type==="identifier")a.add(p.text);else if(ac(p))l.push({name:i,startLine:m.startPosition.row,endLine:m.endPosition.row});else{let g=Ew(e,t,p.text),h=sc(e,t,p.text);if(g.length>0)u.push(...g);else if(h.length>0)u.push(...h);else{let S=ww(m);S&&c.push(S)}}return}m.type==="shorthand_property_identifier"&&m.text===i&&a.add(i)}}),[...o.filter(m=>a.has(m.name)).map(m=>({...m,file:t})),...l.map(m=>({...m,file:t})),...c.map(m=>({...m,file:t})),...u].filter((m,f,p)=>p.findIndex(g=>g.file===m.file&&g.name===m.name&&g.startLine===m.startLine&&g.endLine===m.endLine)===f)}function Cw(e,t){let n=e,i=null;for(;n;){if(n.type==="object"&&(i=n),n.type==="call_expression"){if(!i)return!1;let r=n.childForFieldName("function")??n.namedChild(0);return r?t.has(r.text.replace(/\.of$/u,""))&&r.text.endsWith(".of"):!1}n=n.parent}return!1}function xw(e,t){let n=kp.get(e);n||(n=new Map,kp.set(e,n));let i=n.get(t);if(i)return i;let r=new Set([t]),o=J(e,t).filter(a=>a.leaf==="Service"&&a.isTypeLike);for(let a of o)for(let l of Cr(e,a))r.add(l.file);let s=[...r].sort();return n.set(t,s),s}function Rw(e,t,n){let i=new Set;Pt(t,n)&&i.add("Service");for(let r of Ce(e,t)){if(!r.sourcePath||!Pt(r.sourcePath,n))continue;if(r.kind==="namespace"&&r.localName){i.add(`${r.localName}.Service`);continue}(r.importedName==="default"?r.localName:r.importedName)==="Service"?i.add(r.localName??r.importedName):r.localName&&r.importedName!=="default"&&i.add(`${r.localName}.Service`)}return i}function sc(e,t,n){let i=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n.replace(/\s+/gu,""));if(!i)return[];let r=ae(e,t)?.rootNode;if(!r)return[];let o=Up(r,i[1]),s=o?zp(o):null;if(!s)return[];let a=s.childForFieldName("function")??s.namedChild(0),l=a?Gp(e,t,a.text):[];if(l.length!==1)return[];let c=l[0],u=ae(e,c.relativePath)?.rootNode;if(!u)return[];let d=Kp(u,c.startLine,c.endLine);if(!d)return[];let m=[];for(let f of d.descendantsOfType("return_statement")){let p=f.childForFieldName("argument")??f.namedChild(0);if(!p)continue;let g=fi(p);if(g.type==="object")for(let h of g.namedChildren){if(h.type==="shorthand_property_identifier"&&h.text===i[2]){for(let y of Mt(e,c.relativePath)??[])y.name===i[2]&&m.push({...y,file:c.relativePath});continue}if(h.type!=="pair")continue;let S=h.childForFieldName("key")??h.namedChild(0),v=h.childForFieldName("value")??h.namedChild(1);if(!(Hs(S?.text)!==i[2]||!v))if(v.type==="identifier")for(let y of Mt(e,c.relativePath)??[])y.name===v.text&&m.push({...y,file:c.relativePath});else ac(v)&&m.push({name:i[2],startLine:h.startPosition.row,endLine:h.endPosition.row,file:c.relativePath})}}return m.filter((f,p,g)=>g.findIndex(h=>h.file===f.file&&h.name===f.name&&h.startLine===f.startLine&&h.endLine===f.endLine)===p)}function Ew(e,t,n){let i=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n.replace(/\s+/gu,""));if(!i)return[];let r=ae(e,t)?.rootNode;if(!r)return[];let o=Up(r,i[1]),s=o?zp(o):null,a=s?.childForFieldName("function")??s?.namedChild(0),l=a?Gp(e,t,a.text):[];if(l.length!==1||!s)return[];let c=l[0],u=ae(e,c.relativePath)?.rootNode;if(!u)return[];let d=Kp(u,c.startLine,c.endLine);if(!d)return[];let m=new Set,f=d.childForFieldName("parameters")??d.childForFieldName("parameter");if(f&&Ut(f,R=>{R.type==="identifier"&&m.add(R.text)}),m.size===0)return[];let p=sc(e,t,n);if(p.length===0)return[];let g=(Mt(e,c.relativePath)??[]).filter(R=>R.startLine>=c.startLine&&R.endLine<=c.endLine),h=(Jt(e,c.relativePath)??[]).filter(R=>R.line>=c.startLine&&R.line<=c.endLine),S=new Set,v=p.map(R=>({name:R.name,startLine:R.startLine,endLine:R.endLine})),y=new Set;for(;v.length>0&&y.size<32;){let R=v.shift(),C=`${R.name}\0${R.startLine}\0${R.endLine}`;if(!y.has(C)){y.add(C);for(let L of h.filter(I=>I.line>=R.startLine&&I.line<=R.endLine)){if(L.memberAccess&&L.calleeQualifier&&m.has(L.calleeQualifier)){S.add(L.calleeLeaf);continue}if(L.memberAccess)continue;let I=g.filter(x=>x.name===L.calleeLeaf);I.length===1&&v.push(I[0])}}}if(S.size===0)return[];let w=s.childForFieldName("arguments")?.namedChildren.find(R=>fi(R).type==="object");if(!w)return[];let b=[];for(let R of fi(w).namedChildren){if(R.type==="shorthand_property_identifier"&&S.has(R.text)){b.push(...js(e,t,R.text,R,R));continue}if(R.type!=="pair")continue;let C=R.childForFieldName("key")??R.namedChild(0),L=R.childForFieldName("value")??R.namedChild(1),I=Hs(C?.text);!I||!S.has(I)||!L||b.push(...js(e,t,I,L,R))}return b.filter((R,C,L)=>L.findIndex(I=>I.file===R.file&&I.name===R.name&&I.startLine===R.startLine&&I.endLine===R.endLine)===C)}function Up(e,t){for(let n of e.descendantsOfType("variable_declarator"))if((n.childForFieldName("name")??n.namedChild(0))?.text===t)return n.childForFieldName("value")??n.namedChild(1);return null}function zp(e){return e.type==="call_expression"?e:e.descendantsOfType("call_expression")[0]??null}function Gp(e,t,n){let i=n.replace(/\s+/gu,"").replace(/<[^<>]*>$/u,""),r=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(i);if(r){let d=Ce(e,t).filter(p=>p.localName===r[1]&&p.sourcePath);if(d.length!==1||!d[0].sourcePath)return[];let m=d[0].sourcePath,f=_n(e,m,r[2]).filter(p=>p.isFunctionLike);return f.length>0?f:(Mt(e,m)??[]).filter(p=>p.name===r[2]).map(p=>({...p,relativePath:m}))}if(!/^[A-Za-z_$][\w$]*$/u.test(i))return[];let o=J(e,t).filter(d=>d.leaf===i&&d.isFunctionLike);if(o.length>0)return o;let s=(Mt(e,t)??[]).filter(d=>d.name===i).map(d=>({...d,relativePath:t}));if(s.length>0)return s;let a=Ce(e,t).filter(d=>d.localName===i&&d.sourcePath&&d.kind!=="namespace");if(a.length!==1||!a[0].sourcePath)return[];let l=a[0].sourcePath,c=a[0].importedName==="default"?i:a[0].importedName,u=_n(e,l,c).filter(d=>d.isFunctionLike);return u.length>0?u:(Mt(e,l)??[]).filter(d=>d.name===c).map(d=>({...d,relativePath:l}))}function Kp(e,t,n){let i=null;return Ut(e,r=>{!/(?:function|method|lambda)/u.test(r.type)&&r.type!=="arrow_function"||r.startPosition.row>t||r.endPosition.row<n||(!i||r.endIndex-r.startIndex<i.endIndex-i.startIndex)&&(i=r)}),i}function ac(e){return["arrow_function","function_expression","generator_function"].includes(e.type)||e.descendantsOfType(["arrow_function","function_expression","generator_function"]).length>0}function ww(e){let t=e.parent;for(;t;){if(t.type==="variable_declarator"){let n=t.childForFieldName("name")??t.namedChild(0);if(n?.type==="identifier")return{name:n.text,startLine:t.startPosition.row,endLine:t.endPosition.row}}t=t.parent}return null}function Hs(e){return e?e.replace(/^(?:['"])(.*)(?:['"])$/u,"$1"):null}function Iw(e,t,n,i){let r=/^this\.([A-Za-z_$][\w$]*)$/u.exec(n.calleeQualifier??"");if(!r)return null;let o=ae(e,t)?.rootNode;if(!o)return null;let s=Lw(o,n.line);if(!s)return null;let a=new Set;if(Ut(s,g=>{if(g.type!=="assignment_expression")return;let h=g.childForFieldName("left")??g.namedChild(0),S=g.childForFieldName("right")??g.namedChild(g.namedChildCount-1);if(h?.text.replace(/\s+/gu,"")!==`this.${r[1]}`||!S)return;let v=fi(S);if(v.type!=="new_expression")return;let E=(v.childForFieldName("constructor")??v.namedChild(0))?.text.match(/[A-Za-z_$][\w$]*$/u)?.[0];E&&a.add(E)}),a.size!==1)return null;let l=[...a][0],c=i.filter(g=>g.localName===l);if(c.length!==1)return null;let u=c[0].importedName==="default"?l:c[0].importedName,d=c[0].importedName==="default"?_n(e,c[0].sourcePath,l):[],m=d.length===1?d[0].leaf:u,f=J(e,c[0].sourcePath).filter(g=>g.isFunctionLike&&g.leaf===n.calleeLeaf&&cm(g.symbol)===m);if(f.length!==1)return null;let p=f[0];return{calleeLeaf:n.calleeLeaf,line:n.line,sourceFile:t,targetFile:p.relativePath,targetStartLine:p.startLine,targetEndLine:p.endLine,targetSymbol:p.symbol,resolution:"constructed-member-receiver",strength:"exact"}}function Lw(e,t){let n=[];return Ut(e,i=>{["class","class_declaration","class_definition"].includes(i.type)&&i.startPosition.row<=t&&i.endPosition.row>=t&&n.push(i)}),n.sort((i,r)=>i.endPosition.row-i.startPosition.row-(r.endPosition.row-r.startPosition.row))[0]??null}function fi(e){let t=e;for(;["parenthesized_expression","as_expression","type_assertion","satisfies_expression"].includes(t.type)&&t.namedChildCount===1;)t=t.namedChild(0);return t}function Ut(e,t){t(e);for(let n of e.namedChildren)Ut(n,t)}function Dw(e){let t=new Map,n=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*([A-Za-z_$][\w$]*)\s*;/gu;for(let i of e.matchAll(n)){let r=i[1],o=i[2];r&&o&&t.set(r,o)}return t}function lc(e){let t=[];for(let n of e)t.some(i=>Pt(i,n))||t.push(n);return t}var qp=new WeakMap;function xn(e,t,n,i){let r=ee(e,t),o=(r?.callSites??[]).filter(f=>f.line>=n&&f.line<=i);if(!r||o.length===0)return{available:!!r,targets:[],resolvedCallsites:0,unresolvedCallsites:0};let s=uc(e,t);if(!s)return{available:!1,targets:[],resolvedCallsites:0,unresolvedCallsites:o.length};let a=s.filter(f=>f.sourceLine>=n&&f.sourceLine<=i).map(f=>({...f,calleeLeaf:f.definition.leaf})),l=Wp(o.map(f=>({line:f.line,leaf:f.calleeLeaf}))),c=Wp(a.map(f=>({line:f.sourceLine,leaf:f.calleeLeaf}))),u=new Set([...l].flatMap(([f,p])=>c.get(f)===p?[f]:[])),d=a.filter(f=>u.has(Jp(f.sourceLine,f.calleeLeaf))),m=[...u].reduce((f,p)=>f+(l.get(p)??0),0);return{available:!0,targets:d,resolvedCallsites:m,unresolvedCallsites:Math.max(0,o.length-m)}}function cc(e,t,n,i){let r=uc(e,t);return r?{available:!0,targets:r.filter(o=>o.sourceLine>=n&&o.sourceLine<=i)}:{available:!1,targets:[]}}function Vp(e,t,n,i){let r=uc(e,t);return r?{available:!0,targets:r.filter(o=>o.sourceLine>=n&&o.sourceLine<=i&&Us(e,o.definition)).map(o=>({...o,calleeLeaf:o.definition.leaf}))}:{available:!1,targets:[]}}function uc(e,t){let n=Pw(e);return n.byFile.has(t)||n.byFile.set(t,Tw(e,n,t)),n.byFile.get(t)??null}function Pw(e){let t=qp.get(e);if(!t){let n=ze(e);t={definitionBySymbol:new Map(n.map(i=>[i.symbol,i])),byFile:new Map},qp.set(e,t)}return t}function Tw(e,t,n){if(e.isIgnored(n))return[];let i=ts(e,n);if(!i)return null;let r=[];for(let o of i){if((o.roles&1)!==0)continue;let s=t.definitionBySymbol.get(o.symbol);s&&r.push({sourceLine:o.range[0],definition:s})}return r}function Us(e,t){if(!t.isFunctionLike)return!1;let n=ee(e,t.relativePath);return!n||n.callables.some(i=>i.name===t.leaf&&i.startLine===t.startLine&&i.endLine===t.endLine)?!0:Fw(t)}function Fw(e){let t=e.documentation;if(!t)return!1;let n=e.leaf.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`\\bfunction\\s+${n}\\s*(?:<[^>]*>)?\\s*\\(`,"u").test(t)||new RegExp(`\\b(?:const|let|var)\\s+${n}\\s*:\\s*(?:<[^>]*>\\s*)?\\([^\\n]*\\)\\s*=>`,"u").test(t)}function Wp(e){let t=new Map;for(let n of e){let i=Jp(n.line,n.leaf);t.set(i,(t.get(i)??0)+1)}return t}function Jp(e,t){return`${e}\0${t}`}import{existsSync as zs,readdirSync as Zp}from"fs";import{join as Hr}from"path";var Mw={files:new Set,pathPrefixes:[]},Aw={reasonsByFile:new Map},dc=/^(?:dist|build|lib|out|output|esm|cjs|umd)\//,Nw=/\.(?:d\.ts|d\.mts|d\.cts|ts|tsx|mts|cts|js|jsx|mjs|cjs)$/,Qp=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],kw=new Set([".git",".next",".turbo","build","coverage","dist","node_modules","out"]),_w=4,Bw=Fe("package-surface",{clearGroups:["whole-project"]}),Ow=Fe("package-operational-surface",{clearGroups:["whole-project"]});function eg(e){return Bw.get(e,()=>jw(e.config.projectRoot))}function En(e,t){let n=eg(e);return n.files.has(t)?!0:n.pathPrefixes.some(i=>t.startsWith(i))}function tg(e,t){return eg(e).files.has(t)}function $w(e){return Ow.get(e,()=>Hw(e.config.projectRoot))}function ng(e,t){return $w(e).reasonsByFile.get(t)??[]}function jw(e){let t=new Set,n=[];for(let{manifest:i,packageRoot:r}of ig(e))for(let o of Uw(i))ag(e,r,o,t,n);return t.size===0&&n.length===0?Mw:{files:t,pathPrefixes:n}}function Hw(e){let t=new Map;for(let{manifest:n,packageRoot:i}of ig(e)){let r=zw(n);for(let s of r)Yp(e,i,s,"package binary",t);let o=n.scripts;if(!(!o||typeof o!="object")){for(let[s,a]of Object.entries(o))if(typeof a=="string")for(let l of Gw(a))Yp(e,i,l,`package script "${s}"`,t)}}return t.size===0?Aw:{reasonsByFile:t}}function ig(e){let t=[],n=og(e,"");return n&&t.push({manifest:n,packageRoot:""}),rg(e,"",t,0),t}function rg(e,t,n,i){if(i>=_w)return;let r=Hr(e,t);if(zs(r))for(let o of Zp(r,{withFileTypes:!0})){if(!o.isDirectory()||kw.has(o.name))continue;let s=t?`${t}/${o.name}`:o.name,a=og(e,s);a&&n.push({manifest:a,packageRoot:s}),rg(e,s,n,i+1)}}function og(e,t){let n;try{n=nt(e,Hr(t,"package.json"),{maxBytes:8*1024*1024,inputKind:"package manifest"})}catch(i){if(!St(i))throw i;return null}try{let i=JSON.parse(n);return i&&typeof i=="object"?i:null}catch{return null}}function Uw(e){let t=[];for(let i of["main","module","types","browser"])typeof e[i]=="string"&&t.push(e[i]);let n=e.bin;if(typeof n=="string")t.push(n);else if(n&&typeof n=="object")for(let i of Object.values(n))typeof i=="string"&&t.push(i);return sg(e.exports,t),t}function zw(e){let t=e.bin;return typeof t=="string"?[t]:!t||typeof t!="object"?[]:Object.values(t).filter(n=>typeof n=="string")}function Gw(e){let t=[],n=/(?:^|&&|\|\||;)\s*(?:(?:cross-env|env)(?:\s+[A-Za-z_][A-Za-z0-9_]*=\S+)*\s+)?(?:node|bun|tsx|ts-node|vite-node|python3?|deno\s+run)\s+(?:(?:--?[A-Za-z0-9-]+(?:=\S+)?)\s+)*["']?([^"'`\s]+\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs|py))["']?/g;for(let i of e.matchAll(n)){let r=i[1];r&&!r.startsWith("node_modules/")&&!r.startsWith("./node_modules/")&&t.push(r)}return t}function Yp(e,t,n,i,r){let o=new Set;ag(e,t,n,o,[]);for(let s of o){let a=r.get(s)??[];a.includes(i)||a.push(i),r.set(s,a)}}function sg(e,t){if(typeof e=="string"){t.push(e);return}if(!(!e||typeof e!="object"))for(let n of Object.values(e))sg(n,t)}function ag(e,t,n,i,r){let o=n.replace(/\\/g,"/").replace(/^\.\//,"");if(o===""||o.startsWith(".."))return;let s=o.indexOf("*");if(s>=0){let l=o.slice(0,s);for(let c of Xp(l))c!==""&&r.push(Rn(t,c));return}let a=o.replace(Nw,"");for(let l of Xp(a)){l===a&&l===o&&i.add(Rn(t,o));for(let c of Qp)Kw(e,i,t,l+c)}i.add(Rn(t,o))}function Xp(e){let t=[e];return dc.test(e)&&(t.push(e.replace(dc,"src/")),t.push(e.replace(dc,""))),t}function Kw(e,t,n,i){let r=Rn(n,i);if(t.add(r),!i.startsWith("src/")||zs(Hr(e,r)))return;let o=Qp.find(u=>i.endsWith(u));if(!o)return;let s=i.slice(0,-o.length);qw(e,t,n,s,o);let a=s.lastIndexOf("/");if(a<=4)return;let l=s.slice(0,a),c=s.slice(a+1);for(let u of lg(e,n,l,`${c}${o}`))t.add(u)}function qw(e,t,n,i,r){let o=Rn(n,`${i}/index${r}`);zs(Hr(e,o))&&t.add(o)}function lg(e,t,n,i){let r=Hr(e,t,n);if(!zs(r))return[];let o=[];for(let s of Zp(r,{withFileTypes:!0})){let a=`${n}/${s.name}`;s.isDirectory()?o.push(...lg(e,t,a,i)):s.isFile()&&s.name===i&&o.push(Rn(t,a))}return o}function Rn(e,t){return e?`${e}/${t}`:t}import{existsSync as mc,readdirSync as Ww}from"fs";import{dirname as Vw,join as fc}from"path";var Jw={rootFiles:new Set,sourcePrefixes:[]},Yw=new Set([".git",".codebaseiq","node_modules","target"]),Xw=6,Zw=Fe("rust-library-surface",{clearGroups:["whole-project"]});function cg(e,t,n){if(!n.endsWith(".rs")||!tI(Qw(e),n))return!1;let i=J(e,n).find(r=>r.symbol===t);return i?nI(ie(e,n)[i.startLine]??""):!1}function Qw(e){return Zw.get(e,()=>eI(e.config.projectRoot))}function eI(e){let t=new Set,n=new Set;for(let i of iI(e)){let r=nt(e,fc(i,"Cargo.toml"),{maxBytes:8388608,inputKind:"Cargo manifest"}),o=rI(r),s=Rn(i,"src/lib.rs"),a=o?Rn(i,o):!oI(r)&&Tt(e,s)?s:null;if(!a)continue;t.add(a);let l=Vw(a).replaceAll("\\","/");n.add(l==="."?"":`${l}/`)}return t.size===0?Jw:{rootFiles:t,sourcePrefixes:[...n].sort()}}function tI(e,t){return t.endsWith(".rs")?e.rootFiles.has(t)?!0:sI(t)?!1:e.sourcePrefixes.some(n=>t.startsWith(n)):!1}function nI(e){return/^\s*pub\s+(?!\()/.test(e)}function iI(e){if(!mc(e))return[];let t=[];return ug(e,"",t,0),t}function ug(e,t,n,i){let r=fc(e,t);if(mc(r)&&(mc(fc(r,"Cargo.toml"))&&n.push(t),!(i>=Xw)))for(let o of Ww(r,{withFileTypes:!0})){if(!o.isDirectory()||Yw.has(o.name))continue;let s=t?`${t}/${o.name}`:o.name;ug(e,s,n,i+1)}}function rI(e){let t=!1;for(let n of e.split(`
56
+ `)){let i=n.replace(/\s+#.*$/,"").trim(),r=/^\[([^\]]+)\]$/.exec(i);if(r){t=r[1]==="lib";continue}if(!t)continue;let o=/^path\s*=\s*["']([^"']+)["']/.exec(i)?.[1];if(o)return o.replaceAll("\\","/").replace(/^\.\//,"")}return null}function oI(e){let t=!1;for(let n of e.split(`
57
+ `)){let i=n.replace(/\s+#.*$/,"").trim(),r=/^\[([^\]]+)\]$/.exec(i);if(r){t=r[1]==="package";continue}if(t&&/^autolib\s*=\s*false\b/.test(i))return!0}return!1}function sI(e){return/(?:^|\/)src\/main\.rs$/.test(e)||/(?:^|\/)src\/bin\//.test(e)||/(?:^|\/)(?:examples|tests|benches)\//.test(e)}function Ki(e){return V(e)==="barrel"}function mg(e){return aI.get(e,()=>{let n=he(e,{includeIgnored:!1}).filter(s=>{let a=V(s);return a==="entry"||a==="worker"});if(n.length===0)return new Set;let i=Be(e),r=new Set,o=new Set;for(;n.length>0;){let s=n.shift();if(!r.has(s)){r.add(s),V(s)==="barrel"&&o.add(s);for(let a of i.get(s)??[])r.has(a)||n.push(a)}}return o})}var aI=Fe("live-barrels",{clearGroups:["whole-project"]});function pc(e,t){return mg(e).has(pt(t))}function fg(e){let t=mg(e);return he(e,{includeIgnored:!1}).filter(n=>Ki(n)&&!t.has(n)&&!lI(e,n))}function lI(e,t){let n=pt(t),i=Nn(e).forFile(n,{facts:!0}).facts?.callables;return i&&i.length>0?!0:(e.get(`SELECT COUNT(*) AS n
58
+ FROM defn_enclosing_ranges der
59
+ JOIN documents d ON d.id = der.document_id
60
+ WHERE d.relative_path = ?
61
+ AND der.end_line - der.start_line >= 2`,n)?.n??0)>0}function Ye(e,t){let n=pt(t),i=V(t);return i==="entry"||i==="worker"||gc(n)||pc(e,n)}function qi(e,t,n){let i=pt(n),r=[];En(e,i)&&r.push("package-surface-file"),dI(e,t,i)&&r.push("transitive-package-surface"),cg(e,t,i)&&r.push("rust-public-library"),CI(t,i)&&r.push("framework-entrypoint");let o=e.config.entryRoots;return o&&(o.files?.some(s=>pt(s)===i)&&r.push("configured-file"),o.pathPrefixes?.some(s=>i.startsWith(pt(s)))&&r.push("configured-path-prefix"),o.qualifiedVars?.some(s=>EI(t,s))&&r.push("configured-qualified-var"),o.symbolPatterns?.some(s=>{try{return ss(s,"entryRoots.symbolPatterns entry").test(t)}catch{return!1}})&&r.push("configured-symbol-pattern")),r}function Ue(e,t,n){return qi(e,t,n).length>0}var cI=Fe("package-surface-reachability",{clearGroups:["whole-project"]}),uI=Fe("explicit-package-surface-reachability",{clearGroups:["whole-project"]});function dI(e,t,n){let i=mI(e).get(n);return i===void 0?!1:i===null||i.has(re(t))}function pg(e,t,n){let i=fI(e).get(n);return i===void 0?!1:i===null||i.has(re(t))}function mI(e){return cI.get(e,()=>gg(e,t=>En(e,t)))}function fI(e){return uI.get(e,()=>gg(e,t=>tg(e,t)))}function gg(e,t){let n=new Map,i=[];for(let r of he(e,{includeIgnored:!1}))t(r)&&(n.set(r,null),i.push(r));for(;i.length>0;){let r=i.shift(),o=n.get(r);if(o!==void 0)for(let s of br(e,r)){if(!s.sourcePath||e.isIgnored(s.sourcePath))continue;let a=pI(o,s);a!==void 0&&gI(n,s.sourcePath,a)&&i.push(s.sourcePath)}}return n}function pI(e,t){if(e===null)return t.kind==="named"?new Set(t.names):null;if(t.kind==="star")return new Set(e);if(t.kind==="star-as")return t.names.some(i=>e.has(i))?null:void 0;let n=t.names.filter(i=>e.has(i));return n.length>0?new Set(n):void 0}function gI(e,t,n){if(!e.has(t))return e.set(t,n),!0;let i=e.get(t);if(i===void 0)return!1;if(i===null||n===null)return i===null?!1:(e.set(t,null),!0);let r=!1;for(let o of n)i.has(o)||(i.add(o),r=!0);return r}var hg=new Set(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"]),hI=new Set(["default","generateMetadata","generateStaticParams"]),yI=new Set(["default","getStaticProps","getServerSideProps","getStaticPaths","config"]),bI=new Set(["default","loader","action","clientLoader","clientAction","headers","links","meta","shouldRevalidate","ErrorBoundary","HydrateFallback"]),SI=new Set(["load","actions","entries",...hg]),vI=new Set(["default"]);function CI(e,t){let n=re(e);return n===""?!1:yg(t)?hg.has(n):bg(t)?hI.has(n):Sg(t)?yI.has(n):vg(t)?bI.has(n):Cg(t)?SI.has(n):RI(t)?vI.has(n):!1}function gc(e){return yg(e)||bg(e)||Sg(e)||xI(e)||vg(e)||Cg(e)}function yg(e){return/(?:^|\/)app(?:\/[^/]+)*\/route\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(e)}function bg(e){return/(?:^|\/)app(?:\/[^/]+)*\/(?:page|layout|template|loading|error|not-found|global-error|head|default)\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(e)}function Sg(e){return/(?:^|\/)pages\/.+\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(e)}function xI(e){let t="(?:middleware|proxy|instrumentation)\\.(?:ts|js|mts|mjs)";return new RegExp(`^(?:src/)?${t}$`).test(e)||new RegExp(`(?:^|/)src/${t}$`).test(e)||new RegExp(`(?:^|/)(?:apps|services|packages)/[^/]+/(?:src/)?${t}$`).test(e)}function vg(e){return/(?:^|\/)app\/routes\/.+\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(e)}function Cg(e){return/(?:^|\/)src\/routes\/(?:.*\/)?\+(?:page|page\.server|layout|layout\.server|server)\.(?:ts|js)$/.test(e)}function RI(e){return/(?:^|\/)src\/(?:pages|views|routes)\/.+\.(?:ts|tsx|js|jsx|vue)$/.test(e)}function EI(e,t){let n=t.lastIndexOf("/");if(n<0)return!1;let i=t.slice(0,n),r=t.slice(n+1);return e.includes(dg(i)+"/")&&e.includes(dg(r)+".")}function dg(e){return/^[A-Za-z0-9_$+-]+$/.test(e)?e:"`"+e.replace(/`/g,"``")+"`"}function xg(e,t,n={}){let i=new Map;if(t&&t.length===0)return i;let r=he(e,{includeIgnored:!1}),o=Xt(e),s=t??ze(e),a=new Set(s.map(c=>c.symbolId)),l=FI(s);return wI(e,i,r,o,a,l),II(e,i,s,a),TI(e,i,r,o,a,l),n.semantic!==!1&&n.semanticEvidence&&AI(i,n.semanticEvidence.callerMap(e,MI(s))),i}function wI(e,t,n,i,r,o){for(let s of n){if(!ye(s))continue;let a=Jt(e,s);if(a)for(let l of a){if(o&&!o.has(l.calleeLeaf))continue;let c=Yt(s,i.get(l.calleeLeaf)??[]);if(!c||c.length===0)continue;let u=Bn(e,s,c,l.memberAccess,l.calleeQualifier);u&&r.has(u.symbolId)&&u.file!==s&&hc(t,u.symbolId,s)}}}function II(e,t,n,i){let r=DI(n);for(let o of LI(e,i))e.isIgnored(o.relative_path)||PI(o,r.get(o.symbol_id))||hc(t,o.symbol_id,o.relative_path)}function LI(e,t){return Qo(e,t?[...t]:void 0)}function DI(e){let t=new Map;for(let n of e)t.set(n.symbolId,{docId:n.documentId,startLine:n.startLine,endLine:n.endLine});return t}function PI(e,t){return!!t&&t.docId===e.document_id&&e.chunk_start>=t.startLine&&e.chunk_end<=t.endLine}function TI(e,t,n,i,r,o){for(let s of n){if(ye(s)!=="rust")continue;let a=Ai(e,s,{includeRustAttributeNames:!0});if(a.length!==0)for(let{name:l}of a){if(o&&!o.has(l))continue;let c=i.get(l);if(c)for(let u of c)r.has(u.symbolId)&&u.file!==s&&hc(t,u.symbolId,s)}}}function hc(e,t,n){let i=e.get(t);i||(i=new Set,e.set(t,i)),i.add(n)}function FI(e){let t=new Set;for(let n of e){let i="leaf"in n&&typeof n.leaf=="string"?n.leaf:"symbol"in n&&typeof n.symbol=="string"?re(n.symbol):"";i&&t.add(i)}return t.size>0?t:null}function MI(e){return e.filter(t=>"relativePath"in t&&"symbol"in t&&"leaf"in t)}function AI(e,t){for(let[n,i]of t){let r=e.get(n);r||(r=new Set,e.set(n,r));for(let o of i)r.add(o)}}function yc(e,t,n={}){return xg(e,t,n)}function Ur(e,t,n={}){return wm(e,t,n)}function Rg(e,t,n={}){let i=yc(e,t,{semantic:n.semantic,semanticEvidence:n.semanticEvidence});return n.sourceFallback===!1?i:pi(i,Ur(e,t))}function pi(e,t){let n=new Map;for(let[i,r]of e)n.set(i,new Set(r));for(let[i,r]of t){let o=n.get(i)??new Set;for(let s of r)o.add(s);n.set(i,o)}return n}function Eg(e,t,n){let i=t.identifierResolution==="strict"?hl:Em,r=t.candidateNames?Cm(t.candidateNames):null,o=0,s=0,a=0,l=0,c="";for(let u of t.paths)if(o+=1,c=u,!(!ye(u)&&!(t.includeVueSfc&&rm(u)))&&!e.isIgnored(u)&&!t.skipPath?.(u))try{if(r&&!xm(se(e,u),r))continue;s+=1;let m=(p,g,h,S)=>{if(t.candidateNames&&!t.candidateNames.has(p))return;a+=1;let v=t.resolveTargets?t.resolveTargets({sourceFile:u,name:p,kind:g,defaultTargets:S}):S();for(let y of v)l+=1,n({sourceFile:u,name:p,target:y,occurrences:h,kind:g})},f=Oi(e,u);for(let[p,g]of f)m(p,"identifier",g.length,()=>i(e,u,p));for(let p of Ai(e,u,{includeCrossLanguageDispatchNames:t.includeCrossLanguageDispatchNames,includeRustAttributeNames:t.includeRustAttributeNames})){let g=p.kind==="cross-language-dispatch"?()=>hl(e,u,p.name):()=>i(e,u,p.name);m(p.name,p.kind,p.occurrences,g)}}finally{t.afterPath?.(u),o%10===0&&$("source-reference-scan.progress",()=>{},()=>({scannedPaths:o,currentPath:c,candidateMatchedPaths:s,visitedNames:a,visitedHits:l}))}}function de(e){return e.endLine-e.startLine+1}function wg(e,t={}){let{scope:n,files:i,minLoc:r=1,maxLoc:o=Number.POSITIVE_INFINITY,excludeSymbol:s,excludeEntrySurfaces:a=!1,excludeTypesFiles:l=!1,excludeRootedSymbols:c=!1,requireFunctionLikeSymbol:u=!1,requireCallableSymbol:d=!1,excludeRustTraitImplMembers:m=!1,includeSuppressed:f=!1,sortByLocDesc:p=!1}=t,g=[],h=NI(e,{scope:n,files:i,requireFunctionLikeSymbol:u,requireCallableSymbol:d}),S=new Map,v=new Map,y=w=>{let b=S.get(w);if(b!==void 0)return b;let R=Ye(e,w);return S.set(w,R),R},E=w=>{let b=v.get(w);if(b!==void 0)return b;let R=V(w);return v.set(w,R),R};for(let w of h){let b=w.relativePath;if(e.isIgnored(b)||a&&y(b)||!kI(w,{requireFunctionLikeSymbol:u,requireCallableSymbol:d})||s!==void 0&&w.symbol===s)continue;let R=de(w);R<r||R>o||l&&_I(b)||c&&Ue(e,w.symbol,b)||m&&at(w.symbol)||E(b)!=="test"&&(ki(w.symbol)||!f&&Go(e,b,w.startLine)||g.push(w))}return p?g.sort((w,b)=>de(b)-de(w)):g}function NI(e,t){return t.files!==void 0?[...new Set(t.files.map(i=>i.replace(/\\/g,"/")))].sort().filter(i=>!t.scope||i.includes(t.scope)).flatMap(i=>J(e,i)):t.requireCallableSymbol?vr(e,{scope:t.scope,symbolMatches:it,sqlPrefilter:"callable"}):t.requireFunctionLikeSymbol?vr(e,{scope:t.scope,symbolMatches:ke,sqlPrefilter:"function-like"}):pm(e,t.scope)}function kI(e,t){return t.requireCallableSymbol?it(e.symbol):t.requireFunctionLikeSymbol?ke(e.symbol):e.isFunctionLike}function _I(e){return(e.split("/").pop()??"").includes("types")}var U=class{constructor(t){this.db=t}db;scopedDefinitions(t){return fm(this.db,t)}definitionsForFile(t){return J(this.db,t)}productionCallableDefinitions(t={}){return wg(this.db,t)}calleeMap(t,n={}){return this.calleeEvidenceMap(t,n).rows}calleeEvidenceMap(t,n={}){return Er(this.db,t,{...n,semanticEvidence:pe})}crossFileCallerMap(t,n={}){return yc(this.db,t,{...n,semanticEvidence:pe})}sourceFallbackCallerFiles(t,n={}){return Ur(this.db,t,n)}callerFileMap(t,n={}){return Rg(this.db,t,{...n,semanticEvidence:pe})}frameworkReferencedSymbolIds(t){let n=new Map;for(let r of t){if(!r.leaf)continue;let o=n.get(r.leaf)??[];o.push(r.symbolId),n.set(r.leaf,o)}let i=new Set;for(let r of he(this.db,{includeIgnored:!1}))if(ye(r)==="rust")for(let{name:o}of Ai(this.db,r,{includeRustAttributeNames:!0}))for(let s of n.get(o)??[])i.add(s);return i}symbolsWithNonSelfCallees(t,n={}){if(t.length===0)return new Set;let i=new Map(t.map(s=>[s.symbolId,s.symbol])),r=this.calleeEvidenceMap(t,n),o=new Set([...r.rows.entries()].filter(([s,a])=>{let l=i.get(s);return a.some(c=>c.symbol!==l)}).map(([s])=>s));for(let s of r.incompleteSymbolIds)o.add(s);for(let s of r.unavailableSymbolIds)o.add(s);return o}fileDependencyGraph(t){return Be(this.db,t)}fileKind(t){return V(t)}hasSuppressionComment(t){return Go(this.db,t.relativePath,t.startLine)}sourceFiles(){return Mi(this.db)}scanSourceReferences(t,n){Eg(this.db,t,n)}callableSignature(t){let n=Nn(this.db).forFile(t.relativePath,{facts:!0}).facts?.callables.find(i=>i.startLine===t.startLine&&i.endLine===t.endLine);return n?{paramCount:n.paramCount}:null}};var BI=16,OI=4,bc=3e3,$I=800,jI=new Set(["assignment","const_declaration","const_item","field_declaration","lexical_declaration","local_declaration_statement","local_variable_declaration","static_item","variable_declaration"]);function Fg(e,t,n={}){let i=n.maxSteps??BI;if(!Number.isSafeInteger(i)||i<=0)throw new RangeError(`maxSteps must be a positive safe integer; received ${i}`);let r=new Map(t.nodes.map(F=>[F.id,F])),o=WI(n.focusLocations??[]),s=new Set,a=new Map(t.edges.map(F=>[F.id,F])),l=wn(t.paths.flatMap(F=>F.nodeIds)),c=wn(t.anchors.filter(F=>F.status==="matched").flatMap(F=>F.nodeIds)),u=t.nodes.filter(F=>F.disposition==="emitted"&&F.attributes.upstreamCausalPath===!0).sort((F,Z)=>Number(Z.attributes.upstreamCausalDistance??0)-Number(F.attributes.upstreamCausalDistance??0)||F.id.localeCompare(Z.id)).map(F=>F.id),d=new Set(u),m=Math.max(0,i-c.length),p=HI(t,c,o,m).slice(0,m),g=new Set(p),h=new Set(p),S=new Set([...l,...u,...c]),v=t.edges.filter(F=>F.disposition==="emitted"&&F.kind!=="structural-membership"),y=t.edges.filter(F=>F.disposition!=="excluded"&&F.disposition!=="unsupported"&&F.kind!=="structural-membership"),E=new Set([...t.paths.flatMap(F=>F.edgeIds),...v.filter(F=>d.has(F.fromNodeId)&&d.has(F.toNodeId)).map(F=>F.id)]),w=t.paths.some(F=>F.edgeIds.length>0),b=new Set(c);for(let F of p)b.add(F);for(let F of t.paths){let Z=F.nodeIds[0],X=a.get(F.edgeIds[0]??""),Se=F.nodeIds[1];Z&&Se&&X?.fromNodeId===Z&&X.toNodeId===Se&&b.add(Z)}if(t.paths.every(F=>F.nodeIds.length===0))for(let F of t.anchors)for(let Z of F.nodeIds)b.add(Z);let R=ZI(c,y,r,OI),C=wn(v.filter(F=>F.kind==="call"&&c.includes(F.fromNodeId)).map(F=>F.toNodeId)),L=new Set(wn([...R,...w?[]:C]));for(let F of L)b.add(F);let I=wn(v.flatMap(F=>S.has(F.fromNodeId)||S.has(F.toNodeId)?[F.fromNodeId,F.toNodeId]:[])),x=t.nodes.filter(F=>F.disposition==="emitted"&&F.kind!=="structural-region"&&v.some(Z=>Z.fromNodeId===F.id||Z.toNodeId===F.id)).map(F=>F.id),P=wn([...u,...l,...c,...p,...L,...I,...x]).filter(F=>r.has(F)),_=[];for(let F of P)w&&!S.has(F)&&!g.has(F)&&!L.has(F)||_.length>=i&&!S.has(F)||_.push(F);let D=new Set(_),T=new Map(_.map(F=>[F,eL(F)])),A=new Set([...l,...u]),W=new Set(t.anchors.flatMap(F=>F.nodeIds)),le=_.map((F,Z)=>{let X=r.get(F),Se=qI(X,o);for(let tt of Se)s.add(Wi(X.location.file,tt));return{id:T.get(F),nodeId:F,order:Z,role:W.has(F)?"anchor":A.has(F)?"connector":"junction",kind:X.kind,label:X.label,location:X.location,behavior:UI(e,X,W.has(F),[...new Set([...Se,...KI(e,X,y,r,E,b)])],Se,b.has(X.id)&&(Se.length===0||W.has(X.id)),L.has(X.id),h.has(X.id)&&Se.length===0)}}),q=new Map;for(let F of t.paths)for(let Z=0;Z<F.edgeIds.length;Z+=1){let X=a.get(F.edgeIds[Z]),Se=F.nodeIds[Z],tt=F.nodeIds[Z+1];!X||!Se||!tt||q.set(X.id,X.fromNodeId===Se&&X.toNodeId===tt?"forward":"reverse")}let N=y.filter(F=>D.has(F.fromNodeId)&&D.has(F.toNodeId)).sort((F,Z)=>QI(F,Z,t)).map((F,Z)=>({id:tL(F.id),edgeId:F.id,order:Z,kind:F.kind,fromStepId:T.get(F.fromNodeId),toStepId:T.get(F.toNodeId),directed:!0,pathTraversal:q.get(F.id)??"adjacent",evidence:F.evidence})),K=new Map(N.map(F=>[F.edgeId,F.id])),te=t.paths.map(F=>({id:F.id,status:F.status,stepIds:F.nodeIds.flatMap(Z=>{let X=T.get(Z);return X?[X]:[]}),transitionIds:F.edgeIds.flatMap(Z=>{let X=K.get(Z);return X?[X]:[]})})),me=le.flatMap(F=>F.location?[`${F.location.file}:${F.location.line+1}`]:[]),ge=t.anchors.some(F=>F.status==="ambiguous"),ce=te.some(F=>F.status==="connected"||F.status==="candidate"),be=te.some(F=>F.status==="partial");return{status:le.length===0?"unavailable":ge?"ambiguous":ce&&!be?"connected":be?"partial":"connected",steps:le,transitions:N,paths:te,coverage:{candidateNodes:P.length,returnedNodes:_.length,omittedNodeIds:P.filter(F=>!D.has(F)),returnedTransitions:N.length,withheldStatements:le.reduce((F,Z)=>F+(Z.behavior?.coverage.omittedStatements??0),0),requestedFocusLocations:o,matchedFocusLocations:o.filter(F=>s.has(Wi(F.file,F.line))),unmatchedFocusLocations:o.filter(F=>!s.has(Wi(F.file,F.line)))},behaviorCommand:Tg(me,"behavior"),exactSourceCommand:Tg(me,"source")}}function HI(e,t,n,i){if(i<=0||n.length===0)return[];let r=new Set(t),o=new Set(n.map(s=>Wi(s.file,s.line)));return wn(e.edges.filter(s=>s.disposition!=="excluded"&&s.disposition!=="unsupported"&&["call","runtime-boundary"].includes(s.kind)&&r.has(s.fromNodeId)&&s.evidence.some(a=>!["candidate","unknown"].includes(a.strength)&&a.location&&o.has(Wi(a.location.file,a.location.line)))).sort((s,a)=>{let l=s.evidence.find(u=>u.location)?.location,c=a.evidence.find(u=>u.location)?.location;return(l?.file??"").localeCompare(c?.file??"")||(l?.line??Number.MAX_SAFE_INTEGER)-(c?.line??Number.MAX_SAFE_INTEGER)||s.id.localeCompare(a.id)}).map(s=>s.toNodeId)).slice(0,i)}function UI(e,t,n,i,r,o,s,a){if(!t.location||!["symbol","source-construct","runtime-boundary-participant"].includes(t.kind))return null;let l=t.location.endLine??t.location.line,c=ie(e,t.location.file),u=i.length>0?i:[t.location.line],d=t.kind==="runtime-boundary-participant"?gt(e,t.location.file,0,Math.max(0,c.length-1),[t.location.line]):gt(e,t.location.file,t.location.line,l,u),m=i.filter(L=>L>=d.startLine&&L<=d.endLine),f=ji(e,t.location.file,d.startLine,d.endLine,m),p=f??(m.length>0?ji(e,t.location.file,d.startLine,d.endLine,m,{requireSavings:!1}):null),g=m.length>0?VI(e,t,d.startLine,d.endLine,m,p,o):null,h=c.slice(d.startLine,d.endLine+1).join(`
62
+ `).length,S=Sn(e,t.location.file,d.startLine,d.endLine),v=c.slice(d.startLine,d.endLine+1).some((L,I)=>L.length>$I&&(S.get(d.startLine+I)??[]).some(x=>["binding","branch","loop","call","return","throw","mutation"].includes(x))),y=L=>zI(e,t,d.startLine,d.endLine,r.filter(I=>I>=d.startLine&&I<=d.endLine),L),E=(s||t.kind==="runtime-boundary-participant"||t.anchorIds.length>0)&&h<=bc,w=n&&(m.length===0||E);if(f&&(a||w))return y(Ig(f));if(!a&&!w&&g&&!v&&!E&&g.renderedCharacters<(p?.outlineCharacters??h))return y(g);if(f)return y(Ig(f));let b=c.slice(d.startLine,d.endLine+1),R=b.join(`
63
+ `),C=Sn(e,t.location.file,d.startLine,d.endLine);return y({kind:"source",constructKind:"source construct",signature:b.find(L=>L.trim().length>0)?.trim()??t.label,lines:b.map((L,I)=>({line:d.startLine+I,endLine:d.startLine+I,depth:0,signals:C.get(d.startLine+I)??[],text:L,copied:!0})),coverage:{sourceStatements:b.length,representedStatements:b.length,copiedStatements:b.length,omittedStatements:0},rawCharacters:R.length,renderedCharacters:R.length})}function zI(e,t,n,i,r,o){if(!t.location)return o;let s=cc(e,t.location.file,n,i);if(!s.available)return o;let a=Sn(e,t.location.file,n,i),l=ie(e,t.location.file),c=new Set(r);for(let v of r){let y=Gs(l[v]??"");if(!y)continue;let E=yn(e,t.location.file,y).find(w=>w>v&&w<=i);E!==void 0&&c.add(E)}let u=[...new Map(s.targets.flatMap(v=>{let y=v.definition,E=y.relativePath===t.location.file&&y.startLine<=i&&y.endLine>=n;if(y.isTypeLike||E)return[];let w=Us(e,y),b=r.length>0&&w&&a.get(v.sourceLine)?.includes("return"),R=w&&c.has(v.sourceLine);return w&&!b&&!R?[]:[[y.symbol,{definition:y,kind:b?"return-value-transformer":R?"focused-causal-target":"compiler-referenced-declaration"}]]})).values()].sort((v,y)=>v.definition.relativePath.localeCompare(y.definition.relativePath)||v.definition.startLine-y.definition.startLine||v.definition.symbol.localeCompare(y.definition.symbol)),d=[],m=u.filter(({kind:v})=>v!=="compiler-referenced-declaration").map(({definition:v})=>({owner:v,depth:1})),f=new Set,p=new Set(u.map(({definition:v})=>v.symbol));for(;m.length>0;){let v=m.shift();if(!v||f.has(v.owner.symbol))continue;f.add(v.owner.symbol);let{owner:y,depth:E}=v,w=cc(e,y.relativePath,y.startLine,y.endLine);if(!w.available)continue;let b=Sn(e,y.relativePath,y.startLine,y.endLine),R=ie(e,y.relativePath);for(let C of w.targets){let L=C.definition,I=L.relativePath===y.relativePath&&L.startLine<=y.endLine&&L.endLine>=y.startLine;if(L.isTypeLike||I)continue;let x=Us(e,L),P=Gs(R[C.sourceLine]??""),_=x&&P!==null&&yn(e,y.relativePath,P).some(T=>T>C.sourceLine&&T<=y.endLine&&(b.get(T)??[]).some(A=>["branch","return","throw"].includes(A))),D=x&&((b.get(C.sourceLine)??[]).some(T=>["branch","return","throw"].includes(T))||_);x&&!D||(p.has(L.symbol)||(p.add(L.symbol),d.push({definition:L,kind:x?"focused-causal-target":"compiler-referenced-declaration"})),x&&E<2&&m.push({owner:L,depth:E+1}))}}let g=[...new Map([...u,...d].map(v=>[v.definition.symbol,v])).values()].sort((v,y)=>v.definition.relativePath.localeCompare(y.definition.relativePath)||v.definition.startLine-y.definition.startLine||v.definition.symbol.localeCompare(y.definition.symbol)),h=[],S=[];for(let{definition:v,kind:y}of g){let E=y==="compiler-referenced-declaration"?GI(e,v.relativePath,v.startLine,v.endLine):{startLine:v.startLine,endLine:v.endLine},w=ie(e,v.relativePath).slice(E.startLine,E.endLine+1).join(`
64
+ `),b=y==="compiler-referenced-declaration"?null:ji(e,v.relativePath,v.startLine,v.endLine,[]),R=b?[b.signature,...b.lines.map(P=>`${P.line+1}${P.signals.length>0?`[${P.signals.join(",")}]`:""} ${P.text}`)].join(" | "):null,C=R&&R.length<w.length?R:w,L={symbol:v.symbol,label:v.leaf,file:v.relativePath,line:E.startLine,endLine:E.endLine},I=y==="compiler-referenced-declaration"?1e3:8e3,x=y==="compiler-referenced-declaration"?12:120;if(C.length>I||E.endLine-E.startLine>x){S.push({...L,reason:"source-too-large"});continue}h.push({kind:y,...L,text:C})}return{...o,...h.length===0?{}:{supportingDeclarations:h},...S.length===0?{}:{omittedSupportingDeclarations:S}}}function GI(e,t,n,i){let r=ae(e,t);if(!r)return{startLine:n,endLine:i};let o=[];Mg(r.rootNode,a=>{jI.has(a.type)&&a.startPosition.row<=n&&a.endPosition.row>=i&&o.push(a)});let s=o.sort((a,l)=>a.endPosition.row-a.startPosition.row-(l.endPosition.row-l.startPosition.row)||a.endIndex-a.startIndex-(l.endIndex-l.startIndex))[0];return s?{startLine:s.startPosition.row,endLine:s.endPosition.row}:{startLine:n,endLine:i}}function Mg(e,t){t(e);for(let n of e.namedChildren)Mg(n,t)}function Ig(e){return{kind:"outline",constructKind:e.constructKind,signature:e.signature,lines:e.lines,coverage:e.coverage,rawCharacters:e.rawCharacters,renderedCharacters:e.outlineCharacters}}function KI(e,t,n,i,r,o){if(!t.location||!["symbol","source-construct","runtime-boundary-participant"].includes(t.kind))return[];let s=new Set,a=new Set(ee(e,t.location.file)?.callSites.map(l=>l.line)??[]);if(t.kind==="runtime-boundary-participant"&&s.add(t.location.line),o.has(t.id))for(let l of xr(e,{files:[t.location.file]}))l.source.startLine>=t.location.line&&l.source.startLine<=(t.location.endLine??t.location.line)&&s.add(l.source.startLine);for(let l of n){if(l.fromNodeId!==t.id&&l.toNodeId!==t.id)continue;let c=i.get(l.fromNodeId===t.id?l.toNodeId:l.fromNodeId),u=o.has(t.id)&&["call","reference","runtime-boundary"].includes(l.kind)&&l.fromNodeId===t.id,d=(c?.anchorIds.length??0)>0;if(!r.has(l.id)&&!u&&!d)continue;let m=l.evidence.flatMap(S=>S.location?.file===t.location.file?[S.location.line]:[]),f=m.filter(S=>a.has(S));for(let S of f.length>0?f:m)s.add(S);let p=c?.attributes.leaf;if(typeof p!="string"||p.length===0)continue;let g=yn(e,t.location.file,p).filter(S=>S>=t.location.line&&S<=(t.location.endLine??t.location.line)),h=g.find(S=>a.has(S))??g[0];h!==void 0&&s.add(h)}return[...s].sort((l,c)=>l-c)}function qI(e,t){if(!e.location)return[];let n=e.location.endLine??e.location.line;return t.filter(i=>i.file===e.location.file&&i.line>=e.location.line&&i.line<=n).map(i=>i.line)}function WI(e){let t=new Map;for(let n of e){if(!n.file||!Number.isSafeInteger(n.line)||n.line<0)throw new RangeError(`Behavior focus locations require a repository file and non-negative line; received ${JSON.stringify(n)}.`);t.set(Wi(n.file,n.line),{file:n.file,line:n.line})}return[...t.values()].sort((n,i)=>n.file.localeCompare(i.file)||n.line-i.line)}function Wi(e,t){return`${e}\0${t}`}function VI(e,t,n,i,r,o,s){if(!t.location)return null;let a=ie(e,t.location.file),l=Sn(e,t.location.file,n,i),c=[...l].filter(([,D])=>D.length>0).map(([D])=>D).sort((D,T)=>D-T),u=r.map(D=>(l.get(D)??[]).length>0?D:c.find(T=>T>D&&T-D<=8)??D),d=new Set([...r,...u]),m=s?Pl(e,t.location.file,n,i,{minimumBodyLines:0}):null,f=o?[...new Map(u.flatMap(D=>o.lines.filter(T=>T.text.length<=500&&T.signals.some(A=>["branch","loop","catch","finally"].includes(A))&&D>=T.line&&D<=T.endLine).sort((T,A)=>T.endLine-T.line-(A.endLine-A.line)||T.line-A.line).slice(0,2).map(T=>[`${T.line}\0${T.endLine}`,T]))).values()]:Cs(e,t.location.file,n,i,u);for(let D of m?.lines??[])d.add(D.line);for(let D of f)d.add(D.line);for(let[D,T]of l)T.includes("call")&&T.includes("shape")&&d.add(D);let p=[];for(let D of u){let T=Gs(a[D]??"");if(!T)continue;let A=yn(e,t.location.file,T).filter(N=>N>D&&N<=i),W=A[0];W!==void 0&&d.add(W);let le=A.find(N=>(l.get(N)??[]).some(K=>K==="branch"||K==="loop"));if(le===void 0)continue;d.add(le);let q=(o?.lines??[]).find(N=>N.line===le)??{line:le,endLine:Math.min(i,le+40),depth:0,signals:l.get(le)??[],text:(a[le]??"").trim(),copied:!0},Y=o?.lines??a.slice(q.line,q.endLine+1).map((N,K)=>{let te=q.line+K;return{line:te,endLine:te,depth:0,signals:l.get(te)??[],text:N.trim(),copied:!0}});p.push({focusLine:D,governingUse:le,lines:Y.filter(N=>N.line>=q.line&&N.line<=q.endLine&&N.text.length<=500&&N.signals.some(K=>["binding","branch","call","mutation"].includes(K)))})}for(let D of p.sort((T,A)=>A.governingUse-A.focusLine-(T.governingUse-T.focusLine)||T.focusLine-A.focusLine).slice(0,2))for(let T of D.lines.slice(0,14))d.add(T.line);let g=new Set(["binding","branch","loop","call","return","throw","mutation"]);for(let D of f)for(let T of o?.lines??[])T.line<D.line||T.line>D.endLine||T.signals.some(A=>g.has(A))&&d.add(T.line);let h=a.slice(n,i+1).flatMap((D,T)=>{let A=Gs(D);return A?[{name:A,line:n+T}]:[]}),S=!0;for(;S;){S=!1;for(let D of h)if([...d].some(A=>YI(a[A]??"",D.name))){d.has(D.line)||(d.add(D.line),S=!0);for(let A of yn(e,t.location.file,D.name))A<n||A>i||d.has(A)||(l.get(A)??[]).some(W=>g.has(W))&&(d.add(A),S=!0)}}for(let D of o?.lines??[])if(D.signals.some(T=>["branch","loop","catch","finally"].includes(T))&&d.has(D.line))for(let T of o?.lines??[])T.line<D.line||T.line>D.endLine||T.signals.some(A=>g.has(A))&&d.add(T.line);let v=ee(e,t.location.file),y=new Set(v?.callSites.map(D=>D.line)??[]),E=l,w=new Map([...o?.lines??[],...f].filter(D=>D.signals.some(T=>["branch","loop","catch","finally"].includes(T))).map(D=>[D.line,D])),b=new Map((o?.lines??[]).filter(D=>D.text.length<=500&&D.signals.includes("shape")&&(D.signals.includes("call")||D.signals.includes("mutation")||D.signals.includes("return"))).sort((D,T)=>D.endLine-D.line-(T.endLine-T.line)||D.line-T.line).map(D=>[D.line,D])),R=new Map((m?.lines??[]).map(D=>[D.line,D.signals.filter(T=>T!=="lifecycle")])),C=[...d].filter(D=>D>=n&&D<=i).sort((D,T)=>D-T).map(D=>{let T=w.get(D)??b.get(D);return{line:D,endLine:T?.endLine??D,depth:T?.depth??0,signals:JI([...E.get(D)??[],...o?.lines.filter(A=>D>=A.line&&D<=A.endLine).flatMap(A=>A.signals)??[],...R.get(D)??[],...r.includes(D)?["anchor"]:[],...y.has(D)?["call"]:[]]),text:T?.text??(a[D]??"").trim(),copied:T?.copied??!0}}).filter(D=>D.text.length>0);if(C.length===0)return null;let L=m?.candidateLines??Pl(e,t.location.file,n,i,{minimumBodyLines:0})?.candidateLines??0,I=Math.max(o?.coverage.sourceStatements??0,L,C.length),x=o?.signature??(a[n]??t.label).trim(),P=x.length+C.reduce((D,T)=>D+T.text.length+T.signals.join(",").length+12,0),_=a.slice(n,i+1).join(`
65
+ `).length;return{kind:"connector-slice",constructKind:o?.constructKind??"source construct",signature:x,lines:C,coverage:{sourceStatements:I,representedStatements:C.length,copiedStatements:C.length,omittedStatements:Math.max(0,I-C.length)},rawCharacters:_,renderedCharacters:P}}function JI(e){let t=["anchor","signature","binding","branch","loop","call","await","return","throw","mutation","shape","spread","catch","finally"],n=new Set(e);return t.filter(i=>n.has(i))}function Gs(e){return/\b(?:const|let|var)\s+([\p{L}_$][\p{L}\p{N}_$]*)\s*(?:=|\bof\b|\bin\b)/u.exec(e)?.[1]??null}function YI(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`(?:^|[^\\p{L}\\p{N}_$])${n}(?:$|[^\\p{L}\\p{N}_$])`,"u").test(e)}function XI(e,t,n){return wn(e.flatMap(i=>{let r=n.get(i),o=t.filter(s=>s.kind==="call"&&s.toNodeId===i).map(s=>({edge:s,node:n.get(s.fromNodeId)})).filter(s=>s.node!==void 0&&["symbol","source-construct","runtime-boundary-participant"].includes(s.node.kind)&&s.node.location!==null).sort((s,a)=>{let l=Lg(a.edge)-Lg(s.edge);if(l!==0)return l;let c=Dg(s.node,r)?0:1,u=Dg(a.node,r)?0:1,d=(s.node.location?.endLine??s.node.location?.line??0)-(s.node.location?.line??0),m=(a.node.location?.endLine??a.node.location?.line??0)-(a.node.location?.line??0);return c-u||d-m||s.node.label.localeCompare(a.node.label)});return o[0]?[o[0].node.id]:[]}))}function Lg(e){let t={exact:4,mixed:3,derived:2,candidate:1,unknown:0};return Math.max(0,...e.evidence.map(n=>t[n.strength]))}function Dg(e,t){return!e.location||!t?.location?!1:Pg(e.location.file)===Pg(t.location.file)}function Pg(e){return e.split("/").filter(Boolean).slice(0,2).join("/")}function ZI(e,t,n,i){let r=new Set(e),o=new Set,s=[],a=wn(e);for(let l=0;l<i&&a.length>0;l+=1){let c=a.filter(d=>!o.has(d));for(let d of c)o.add(d);let u=XI(c,t,n);a=[];for(let d of u)!r.has(d)&&!s.includes(d)&&s.push(d),o.has(d)||a.push(d)}return s}function QI(e,t,n){let i=new Map(n.paths.flatMap(r=>r.edgeIds).map((r,o)=>[r,o]));return(i.get(e.id)??Number.MAX_SAFE_INTEGER)-(i.get(t.id)??Number.MAX_SAFE_INTEGER)||e.id.localeCompare(t.id)}function eL(e){return`step:${e}`}function tL(e){return`transition:${e}`}function Tg(e,t){return e.length===0?null:`codebaseiq inspect ${e.map(n=>`--at ${nL(n)}`).join(" ")} --view ${t}`}function nL(e){return`'${e.replace(/'/gu,`'"'"'`)}'`}function wn(e){return[...new Set(e)]}var Ag=4,iL=3,rL=12,oL=48,sL=64,yi=10,gi=6,aL=24,lL=320,Sc=6,cL=12,uL=1,dL=4,mL=7,fL=12,Ec="source-construct:",pL=96,gL=32,Ng=4,hL=32,yL=8;function bL(e,t,n={}){let i=Vg(t),r=rD(t);if(i.length===0)throw new Error("Anchor discovery requires at least one non-trivial repository term.");let o=n.limit??Ag,s=n.full===!0;if(!Number.isSafeInteger(o)||o<=0)throw new RangeError(`anchor group limit must be a positive safe integer; received ${o}`);let a=new U(e),l=a.scopedDefinitions(n.scope).filter(N=>!Le(N.symbol)),c=[...l],u=new Map(c.map(N=>[N.symbol,N])),d=new Map;for(let N of l)kg(d,N,i);let m=ds(e,{scope:n.scope});for(let N of m.files){let te=J(e,N.relativePath).filter(ge=>!Le(ge.symbol));if(te.length===0)continue;let me=Wg(N.text);for(let ge=0;ge<me.length;ge+=1){let ce=ct(me[ge]??""),be=i.filter(Z=>ce.has(Z));if(be.length===0)continue;let F=Ge(te,ge);if(!(!F||Le(F.symbol)))for(let Z of be)zr(d,F,Z,"source",N.relativePath,ge)}}let f=_g(d),p=[...d.values()].map(N=>Ks(N,f,r)).sort(Xe),g=vL(m.files,p,i),h=-1;for(let N of g){let K=J(e,N.relativePath),te=K.filter(F=>!Le(F.symbol)),me=ee(e,N.relativePath)?.callables??[],ge=new Map,ce=F=>{let Z=`${F.startLine}\0${F.endLine}\0${F.name}`,X=ge.get(Z);if(X)return X;let Se=SL(N.relativePath,K,F,()=>h--);return Se?(ge.set(Z,Se),c.push(Se),u.set(Se.symbol,Se),kg(d,Se,i),Se):null};for(let F of me){let Z=ct(F.name);i.some(X=>Z.has(X))&&ce(F)}if(me.length===0)continue;let be=Wg(N.text);for(let F=0;F<be.length;F+=1){let Z=ct(be[F]??""),X=i.filter(Ti=>Z.has(Ti));if(X.length===0)continue;let Se=CL(me,F),tt=Se?ce(Se):null;if(!tt)continue;let ni=Bg(te,F);if(Bg(ni?[ni,tt]:[tt],F)?.symbol===tt.symbol)for(let Ti of X)zr(d,tt,Ti,"source",N.relativePath,F)}}let S=_g(d),v=new Map(m.files.map(N=>[N.relativePath,N.text.split(/\r?\n/u)]));for(let N of d.values()){let K=v.get(N.definition.relativePath);K&&(N.sourceCharacters=K.slice(N.definition.startLine,N.definition.endLine+1).join(`
66
+ `).length)}let y=[...d.values()].map(N=>Ks(N,S,r)).sort(Xe),E=Math.min(y.length,Math.max(rL,o*iL)),w=s?y:Vi([...y.slice(0,E),...[...y].sort(Cc).slice(0,Math.max(oL,E)),...XL(y,i),...ZL(y,i,S)]),b=w.length,R=w.map(N=>u.get(N.symbol)).filter(N=>N?.isFunctionLike===!0),C=xL(c),L=RL(e,a,w,R,u,C,new Set(d.keys()),n.semantic!==!1),I=IL(L,w,d,S,u),x=LL(I,S,i),P=HL(e,a,L,d,S,c,u,n.semantic!==!1),D=[...PL(e,a,I,u,S,n.semantic!==!1),...x,...I,...P].map(N=>({...N,queryPathMatches:eD(N)})).sort((N,K)=>hi(N,K,S)),T=s?D:tD(D,o,S),A=i.filter(N=>S.has(N)),W=i.filter(N=>!S.has(N)),le=Math.max(0,y.length-b),q=Math.max(0,D.length-T.length)+le,Y=s?y.length:Math.min(y.length,o+Ag);return{query:t,queryPathFragments:r,normalizedTerms:i,matchedTerms:A,unmatchedTerms:W,groups:T,candidateRoots:y,candidateRootCount:y.length,analyzedRootCount:b,omittedRootCount:le,omittedGroupCount:q,scannedFiles:m.files.length,scannedBytes:m.scannedBytes,recoveryCommand:q===0?null:`codebaseiq anchors ${Js(t)}${n.scope?` --scope ${Js(n.scope)}`:""} --limit ${Y}`}}function Vg(e){let t=jr(e).filter(n=>!rc.has(n.toLocaleLowerCase())).map($s).filter(n=>n.length>=3&&!rc.has(n));return[...new Set(t)]}function kg(e,t,n){let i=ct(t.leaf),r=ct(t.relativePath),o=ct(t.documentation??"");for(let a of n)i.has(a)&&zr(e,t,a,"symbol"),r.has(a)&&zr(e,t,a,"path"),o.has(a)&&zr(e,t,a,"documentation");let s=e.get(t.symbol);s&&(s.symbolPhraseLength=sD(t.leaf,n))}function zr(e,t,n,i,r,o){let s=e.get(t.symbol)??{definition:t,matches:new Map,symbolPhraseLength:0},a=s.matches.get(n)??{sources:new Set,locations:new Map};a.sources.add(i),r!==void 0&&o!==void 0&&a.locations.set(`${r}\0${o}`,{file:r,line:o}),s.matches.set(n,a),e.set(t.symbol,s)}function _g(e){let t=new Map;for(let n of e.values())for(let i of n.matches.keys())t.set(i,(t.get(i)??0)+1);return t}function SL(e,t,n,i){let r=t[0]?.documentId;if(r===void 0||t.find(a=>a.isFunctionLike&&a.leaf===n.name&&a.startLine===n.startLine&&a.endLine===n.endLine))return null;let s=i();return{documentId:r,symbolId:s,symbol:`${Ec}${e}:${n.startLine}:${n.endLine}:${n.name}`,relativePath:e,startLine:n.startLine,startChar:0,endLine:n.endLine,endChar:0,leaf:n.name,parentTypeName:null,isFunctionLike:!0,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null}}function vL(e,t,n){let i=new Set(t.slice(0,pL).map(s=>s.file)),r=new Set(n),o=e.map(s=>{let a=ct(s.relativePath),l=s.relativePath.slice(s.relativePath.lastIndexOf("/")+1).replace(/\.[^.]+$/u,""),c=ct(l),u=[...a].filter(m=>r.has(m)).length,d=[...c].filter(m=>r.has(m)).length;return{file:s,score:d*4+u}}).filter(s=>s.score>0).sort((s,a)=>a.score-s.score||zt(V(s.file.relativePath))-zt(V(a.file.relativePath))||s.file.relativePath.localeCompare(a.file.relativePath)).slice(0,gL);for(let s of o)i.add(s.file.relativePath);return e.filter(s=>i.has(s.relativePath))}function CL(e,t){return e.filter(n=>n.startLine<=t&&n.endLine>=t).sort((n,i)=>n.endLine-n.startLine-(i.endLine-i.startLine)||n.startLine-i.startLine)[0]}function xL(e){let t=new Map;for(let n of e){if(!nn(n))continue;let i=`${n.relativePath}\0${rn(n.leaf)}`,r=t.get(i)??[];r.push(n),t.set(i,r)}return t}function Bg(e,t){return e.filter(n=>n.startLine<=t&&n.endLine>=t).sort((n,i)=>n.endLine-n.startLine-(i.endLine-i.startLine)||Number(nn(i))-Number(nn(n))||n.startLine-i.startLine||n.symbol.localeCompare(i.symbol))[0]}function nn(e){return e.symbol.startsWith(Ec)}function zn(e){return nn(e)?e.leaf:k(e.symbol)}function Ks(e,t,n=[]){let i=e.definition,r=[...e.matches.entries()].map(([c,u])=>({term:c,sources:[...u.sources].sort(aD),locations:[...u.locations.values()].sort(Xg).slice(0,3)})).sort((c,u)=>c.term.localeCompare(u.term)),o=r.filter(c=>c.sources.some(u=>u!=="source")).map(c=>c.term),s=r.filter(c=>c.sources.includes("symbol")).map(c=>c.term),a=r.reduce((c,u)=>c+1/Math.max(1,t.get(u.term)??1),0),l=r.filter(c=>c.sources.includes("symbol")).reduce((c,u)=>c+1/Math.max(1,t.get(u.term)??1),0);return{symbol:i.symbol,label:zn(i),leaf:i.leaf,file:i.relativePath,line:i.startLine,endLine:i.endLine,kind:i.isFunctionLike?"callable":i.isTypeLike?"type":"symbol",fileKind:V(i.relativePath),matches:r,focusLocations:uD(e,t),matchedTerms:r.map(c=>c.term),symbolMatchedTerms:s,symbolPhraseLength:e.symbolPhraseLength,identityMatchedTerms:o,rarity:a,symbolRarity:l,queryPathMatches:oD(i.relativePath,n),...e.sourceCharacters===void 0?{}:{sourceCharacters:e.sourceCharacters}}}function RL(e,t,n,i,r,o,s,a){let l=i.filter(g=>!nn(g)),c=t.calleeMap(l,{additive:!1,semantic:a}),u=new Map,d=new Map;for(let g of n){let h=r.get(g.symbol),S=h?nn(h)?Og(e,h,r,o,1):qs(e,h,c.get(h.symbolId)??[],r,1,s):[];u.set(g.symbol,S);for(let v of S){let y=r.get(v.toSymbol);y?.isFunctionLike&&(!h||!nn(h)||nn(y))&&d.set(y.symbol,y)}}let m=[...d.values()],f=t.calleeMap(m.filter(g=>!nn(g)),{additive:!1,semantic:a}),p=new Map;for(let g of m)p.set(g.symbol,nn(g)?Og(e,g,r,o,2):qs(e,g,f.get(g.symbolId)??[],r,2,s));return n.map(g=>{let h=u.get(g.symbol)??[],S=h.flatMap(y=>p.get(y.toSymbol)??[]),v=In([...h,...S]);return{root:g,relations:v,nodeSymbols:new Set([g.symbol,...v.flatMap(y=>[y.fromSymbol,y.toSymbol])])}})}function qs(e,t,n,i,r,o=new Set){let s=new Map;for(let a of n){let l=i.get(a.symbol);if(!l?.isFunctionLike||l.symbol===t.symbol||a.source==="ast-callsite"&&!wL(e,t,l,a.callsiteLine))continue;let c=s.get(l.symbol);(!c||iD(a,c)<0)&&s.set(l.symbol,a)}return[...s.entries()].map(([a,l])=>{let c=i.get(a);return{kind:"call",fromSymbol:t.symbol,fromLabel:k(t.symbol),fromFile:t.relativePath,toSymbol:c.symbol,toLabel:k(c.symbol),toFile:c.relativePath,depth:r,strength:Rc(l.source),evidence:l.source,callsiteLine:l.callsiteLine??EL(e,t,c)}}).sort((a,l)=>Number(o.has(l.toSymbol))-Number(o.has(a.toSymbol))||on(a,l)).slice(0,sL)}function Og(e,t,n,i,r){let o=xn(e,t.relativePath,t.startLine,t.endLine).targets.flatMap(s=>{let a=n.get(s.definition.symbol)??s.definition;return!a.isFunctionLike||a.symbol===t.symbol?[]:[{kind:"call",fromSymbol:t.symbol,fromLabel:zn(t),fromFile:t.relativePath,toSymbol:a.symbol,toLabel:zn(a),toFile:a.relativePath,depth:r,strength:"exact",evidence:"scip-occurrence-callsite",callsiteLine:s.sourceLine}]});for(let s of Un(e,t.relativePath,{ranges:[{startLine:t.startLine,endLine:t.endLine}],excludeIndexedTargets:!1}).targets){let a=[...i.get(`${s.targetFile}\0${rn(s.calleeLeaf)}`)??[],...J(e,s.targetFile).filter(l=>l.isFunctionLike&&rn(l.leaf)===s.calleeLeaf)].find(l=>l.startLine===s.targetStartLine&&l.endLine===s.targetEndLine);!a||a.symbol===t.symbol||o.push({kind:"call",fromSymbol:t.symbol,fromLabel:zn(t),fromFile:t.relativePath,toSymbol:a.symbol,toLabel:zn(a),toFile:a.relativePath,depth:r,strength:s.strength==="exact"?"exact":"derived",evidence:"ast-member-import-candidate",callsiteLine:s.line})}for(let s of ee(e,t.relativePath)?.callSites??[]){if(s.line<t.startLine||s.line>t.endLine||s.memberAccess)continue;let a=(i.get(`${t.relativePath}\0${rn(s.calleeLeaf)}`)??[]).filter(c=>c.symbol!==t.symbol);if(a.length!==1)continue;let l=a[0];o.push({kind:"call",fromSymbol:t.symbol,fromLabel:zn(t),fromFile:t.relativePath,toSymbol:l.symbol,toLabel:zn(l),toFile:l.relativePath,depth:r,strength:"derived",evidence:"ast-callsite",callsiteLine:s.line})}return In(o).sort(on)}function EL(e,t,n){let i=rn(n.leaf);return ee(e,t.relativePath)?.callSites.find(r=>r.line>=t.startLine&&r.line<=t.endLine&&rn(r.calleeLeaf)===i)?.line??null}function wL(e,t,n,i){if(i===void 0)return!1;let r=rn(n.leaf);return ee(e,t.relativePath)?.callSites.some(o=>o.line===i&&rn(o.calleeLeaf)===r)??!1}function rn(e){return e.replace(/^#/u,"").replace(/\(\)$/u,"")}function IL(e,t,n,i,r){let o=new Map(t.map((u,d)=>[u.symbol,d])),s=t.map((u,d)=>d),a=u=>{let d=u;for(;s[d]!==d;)d=s[d];for(;s[u]!==u;){let m=s[u];s[u]=d,u=m}return d},l=(u,d)=>{let m=a(u),f=a(d);m!==f&&(s[f]=m)};for(let u of e){let d=o.get(u.root.symbol);if(d!==void 0)for(let m of u.nodeSymbols){let f=o.get(m);f!==void 0&&l(d,f)}}let c=new Map;for(let u=0;u<t.length;u+=1){let d=a(u),m=c.get(d)??[];m.push(t[u]),c.set(d,m)}return[...c.values()].map((u,d)=>{let m=new Set(u.map(y=>y.symbol)),f=In(e.filter(y=>m.has(y.root.symbol)).flatMap(y=>y.relations)).sort(on),p=new Map(u.map(y=>[y.symbol,y]));for(let y of new Set(f.flatMap(E=>[E.fromSymbol,E.toSymbol]))){let E=n.get(y);if(E)p.has(y)||p.set(y,Ks(E,i));else{let w=r.get(y);w&&p.set(y,Yg(w))}}let g=VL(u,f,p),h=u.filter(y=>f.some(E=>E.fromSymbol===y.symbol)).length,S=[...new Set(u.flatMap(y=>y.matchedTerms))].sort(),v=WL(f,g,m,p);return{id:`anchor-set:${d+1}:${Kr(u[0])}`,kind:"connected-flow",roots:[...u].sort(Xe),keyAnchors:g,candidateOwnerCount:g.length,omittedCandidateOwners:[],ownerRecoveryCommands:[],upstreamEntries:[],matchedTerms:S,relations:v,relationCount:f.length,orchestrationRootCount:h,omittedRelations:Math.max(0,f.length-yi),systemMapCommand:Wr(g,f,S)}})}function LL(e,t,n){let i=new Map(n.map((o,s)=>[o,s])),r=[];for(let o=0;o<e.length;o+=1){let s=e[o],a=$g(s);if(a.size!==0)for(let l=o+1;l<e.length;l+=1){let c=e[l],u=$g(c),d=[...a].filter(w=>u.has(w));if(d.length===0||![...a].some(w=>!u.has(w))||![...u].some(w=>!a.has(w)))continue;let m=DL(s,c);if(m.length<2)continue;let f=In([...s.relations,...c.relations]).sort(on),p=f.slice(0,yi),g=Vi([...s.roots,...c.roots]).sort(Xe),h=[...new Set([...s.matchedTerms,...c.matchedTerms])].sort(),S=d.sort((w,b)=>(i.get(w)??Number.MAX_SAFE_INTEGER)-(i.get(b)??Number.MAX_SAFE_INTEGER)||w.localeCompare(b)),v=+(s.relationCount>0)+ +(c.relationCount>0),y=+((s.orchestrationRootCount??0)>0)+ +((c.orchestrationRootCount??0)>0),E=Math.min(...S.map(w=>t.get(w)??Number.MAX_SAFE_INTEGER));r.push({sharedOrder:Math.min(...S.map(w=>i.get(w)??Number.MAX_SAFE_INTEGER)),sharedFrequency:E,connectedSides:v,orchestrationSides:y,group:{id:`parallel-paths:${Kr(s.roots[0])}:${Kr(c.roots[0])}`,kind:"parallel-paths",roots:g,keyAnchors:m,candidateOwnerCount:m.length,omittedCandidateOwners:[],ownerRecoveryCommands:[],upstreamEntries:[...s.upstreamEntries,...c.upstreamEntries],matchedTerms:h,relations:p,relationCount:f.length,parallelConnectedSides:v,parallelOrchestrationSides:y,parallelSharedPathTerms:S,parallelSharedPathFrequency:E,orchestrationRootCount:(s.orchestrationRootCount??0)+(c.orchestrationRootCount??0),omittedRelations:Math.max(0,f.length-p.length),systemMapCommand:Wr(m,f,h)}})}}return r.sort((o,s)=>o.sharedFrequency-s.sharedFrequency||s.orchestrationSides-o.orchestrationSides||s.connectedSides-o.connectedSides||o.sharedOrder-s.sharedOrder||s.group.matchedTerms.length-o.group.matchedTerms.length||hi(o.group,s.group,t)).slice(0,fL).map(o=>o.group)}function $g(e){return new Set(e.roots.flatMap(t=>t.matches.filter(n=>n.sources.includes("path")).map(n=>n.term)))}function DL(e,t){return Vi([jg(e),jg(t)].filter(n=>n!==void 0))}function jg(e){let t=new Set(e.keyAnchors.map(i=>i.symbol)),n=new Map;for(let i of e.relations)!t.has(i.fromSymbol)||!t.has(i.toSymbol)||n.set(i.fromSymbol,(n.get(i.fromSymbol)??0)+1);return[...e.keyAnchors].sort((i,r)=>+((n.get(r.symbol)??0)>0)-+((n.get(i.symbol)??0)>0)||Hg(r)-Hg(i)||r.identityMatchedTerms.length-i.identityMatchedTerms.length||r.symbolMatchedTerms.length-i.symbolMatchedTerms.length||(n.get(r.symbol)??0)-(n.get(i.symbol)??0)||Xe(i,r))[0]}function Hg(e){return e.matchedTerms.length+e.identityMatchedTerms.length*2+(e.queryPathMatches?.length??0)*4}function PL(e,t,n,i,r,o){let s=es(e);if(!s||s.links.length===0||n.length<2)return[];let a=new Map(s.observations.map(f=>[f.id,f])),l=new Map,c=new Map,u=[...n].sort((f,p)=>hi(f,p,r)).slice(0,cL),d=s.links.filter(f=>f.strength!=="candidate").sort((f,p)=>Gn(p.strength)-Gn(f.strength)||p.matchedKeyParts.length-f.matchedKeyParts.length||f.id.localeCompare(p.id));for(let f of u)for(let p of d){let g=a.get(p.from),h=a.get(p.to);if(!g||!h||!TL(f,g,i))continue;let S=FL(f,g,i);if(!S)continue;let v=l.get(h.id)??NL(e,t,h,i,o,dL);if(l.set(h.id,v),v.reachedSymbols.size===0)continue;let y=n.filter(D=>D.id!==f.id&&ML(D).some(T=>v.reachedSymbols.has(T))&&vc(S,D)>=2).sort((D,T)=>vc(S,T)-vc(S,D)||hi(D,T,r)).slice(0,uL);if(y.length===0)continue;let E=[f.id,g.id,...y.map(D=>D.id).sort()].join("\0");if(c.has(E))continue;let w=new Set(y.flatMap(qr)),b=$L(Gr(h),w,v.relations);if(b.length===0)continue;let R=OL(g,h,p.joinRule,p.matchedKeyParts,p.strength),C=In([R,...v.relations,...f.relations,...y.flatMap(D=>D.relations)]),L=jL([R,...b],C,f,y),I=Vi([S,...y.flatMap(D=>D.roots)]).sort(Xe),x=Vi([S,...y.flatMap(D=>D.keyAnchors)]).slice(0,mL),P=[...new Set([...S.matchedTerms,...y.flatMap(D=>D.matchedTerms)])].sort(),_=AL(e,t,S,i,o);I.length===0||x.length<2||c.set(E,{id:`cross-boundary-set:${Kr(S)}:${c.size+1}`,kind:"cross-boundary-flow",roots:I,keyAnchors:x,candidateOwnerCount:x.length,omittedCandidateOwners:[],ownerRecoveryCommands:[],upstreamEntries:_,matchedTerms:P,relations:L,relationCount:C.length,omittedRelations:Math.max(0,C.length-L.length),systemMapCommand:Wr(x,C,P)})}let m=new Map;for(let[f,p]of c){let g=f.slice(0,f.indexOf("\0")),h=m.get(g);(!h||hi(p,h,r)<0)&&m.set(g,p)}return[...m.values()]}function TL(e,t,n){let i=new Set(qr(e));return t.owner.symbol&&i.has(t.owner.symbol)?!0:[...i].map(r=>n.get(r)).some(r=>r?.relativePath===t.source.file&&r.startLine<=t.source.startLine&&r.endLine>=t.source.endLine)}function FL(e,t,n){let i=Vi([...e.roots,...e.keyAnchors]);if(t.owner.symbol){let r=i.find(o=>o.symbol===t.owner.symbol);if(r)return r}return i.find(r=>{let o=n.get(r.symbol);return o?.relativePath===t.source.file&&o.startLine<=t.source.startLine&&o.endLine>=t.source.endLine})??null}function qr(e){return[...new Set([...e.roots.map(t=>t.symbol),...e.keyAnchors.map(t=>t.symbol),...e.relations.flatMap(t=>[t.fromSymbol,t.toSymbol])])]}function ML(e){return[...new Set([...e.roots,...e.keyAnchors].map(t=>t.symbol))]}function vc(e,t){let n=ct(e.leaf),i=[...t.roots,...t.keyAnchors].map(o=>ct(o.leaf)),r=0;for(let o of i){let s=0;for(let a of n)o.has(a)&&(s+=1);r=Math.max(r,s)}return r}function AL(e,t,n,i,r){let o=i.get(n.symbol);if(!o?.isFunctionLike)return[];let s=t.callerFileMap([o],{semantic:r,sourceFallback:!0}).get(o.symbolId);if(!s)return[];let a=ct(n.leaf);return[...s].filter(l=>l!==n.file&&V(l)!=="test").flatMap(l=>{let c=ee(e,l);return(c?.callSites??[]).filter(u=>rn(u.calleeLeaf)===rn(n.leaf)).flatMap(u=>{let d=(c?.callables??[]).filter(f=>f.startLine<=u.line&&f.endLine>=u.line).sort((f,p)=>f.endLine-f.startLine-(p.endLine-p.startLine)||f.startLine-p.startLine)[0];if(!d)return[];let m=[...ct(d.name)].filter(f=>a.has(f)).length;return m>=2?[{name:d.name,file:l,line:d.startLine,endLine:d.endLine,callsiteLine:u.line,overlap:m}]:[]})}).sort((l,c)=>c.overlap-l.overlap||l.file.localeCompare(c.file)||l.line-c.line).slice(0,1).map(({name:l,file:c,line:u,endLine:d,callsiteLine:m})=>({name:l,file:c,line:u,endLine:d,callsiteLine:m}))}function NL(e,t,n,i,r,o){let s=kL(e,n,i),a=s.map(({definition:m,evidence:f,line:p})=>({kind:"call",fromSymbol:Gr(n),fromLabel:Ws(n),fromFile:n.source.file,toSymbol:m.symbol,toLabel:k(m.symbol),toFile:m.relativePath,depth:1,strength:f==="scip-occurrence-callsite"?"exact":"derived",evidence:f,callsiteLine:p})),l=_L(e,n);a.push(...l.relations);let c=Jg([...s.map(m=>m.definition),...l.definitions]),u=c,d=new Set(u.map(m=>m.symbol));for(let m=2;m<=o+1&&u.length>0;m+=1){let f=t.calleeMap(u,{additive:!1,semantic:r}),p=new Map;for(let g of u){let h=qs(e,g,f.get(g.symbolId)??[],i,m);a.push(...h);for(let S of h){let v=i.get(S.toSymbol);v?.isFunctionLike&&!d.has(v.symbol)&&p.set(v.symbol,v)}}u=[...p.values()];for(let g of u)d.add(g.symbol)}return{entryDefinitions:c,relations:In(a),reachedSymbols:new Set([...c.map(m=>m.symbol),...a.flatMap(m=>[m.fromSymbol,m.toSymbol])])}}function kL(e,t,n){let i=t.owner.symbol?n.get(t.owner.symbol):void 0;if(i?.isFunctionLike&&!Le(i.symbol))return[{definition:i,evidence:"scip-occurrence-callsite",line:t.source.startLine}];let r=ie(e,t.source.file),o=gt(e,t.source.file,0,Math.max(0,r.length-1),[t.source.startLine]),s=xn(e,t.source.file,o.startLine,o.endLine).targets.map(u=>({definition:u.definition,evidence:"scip-occurrence-callsite",line:u.sourceLine})),a=ee(e,t.source.file),l=Xt(e),c=(a?.callSites??[]).flatMap(u=>{if(u.line<o.startLine||u.line>o.endLine)return[];let d=Yt(t.source.file,l.get(u.calleeLeaf)??[]),m=Bn(e,t.source.file,d,u.memberAccess,u.calleeQualifier),f=m?n.get(m.symbol):void 0;return f?.isFunctionLike?[{definition:f,evidence:"ast-callsite",line:u.line}]:[]});return BL([...s,...c])}function _L(e,t){let n=ie(e,t.source.file),i=gt(e,t.source.file,0,Math.max(0,n.length-1),[t.source.startLine]),r=Un(e,t.source.file,{ranges:[i],excludeIndexedTargets:!1}).targets,o=[],s=[];for(let a of r){let l=`source-construct:${a.targetFile}:${a.targetStartLine}:${a.targetEndLine}:${a.calleeLeaf}`;s.push({kind:"call",fromSymbol:Gr(t),fromLabel:Ws(t),fromFile:t.source.file,toSymbol:l,toLabel:a.calleeLeaf,toFile:a.targetFile,depth:1,strength:"derived",evidence:"ast-member-import-candidate",callsiteLine:a.line});let c=xn(e,a.targetFile,a.targetStartLine,a.targetEndLine).targets;for(let u of c)o.push(u.definition),s.push({kind:"call",fromSymbol:l,fromLabel:a.calleeLeaf,fromFile:a.targetFile,toSymbol:u.definition.symbol,toLabel:k(u.definition.symbol),toFile:u.definition.relativePath,depth:2,strength:"exact",evidence:"scip-occurrence-callsite",callsiteLine:u.sourceLine})}return{definitions:Jg(o),relations:In(s)}}function BL(e){return[...new Map(e.map(t=>[t.definition.symbol,t])).values()]}function Jg(e){return[...new Map(e.map(t=>[t.symbol,t])).values()]}function Gr(e){return e.owner.symbol??e.id}function Ws(e){return e.owner.name??`${e.source.file}:${e.source.startLine+1}`}function OL(e,t,n,i,r){return{kind:"runtime-boundary",fromSymbol:Gr(e),fromLabel:Ws(e),fromFile:e.source.file,toSymbol:Gr(t),toLabel:Ws(t),toFile:t.source.file,depth:1,strength:r,evidence:`runtime-boundary:${n}`,callsiteLine:e.source.startLine,runtimeBoundaryKey:i.map(o=>`${o.name}=${o.value}`).join(" ")}}function $L(e,t,n){let i=new Map;for(let s of n){let a=i.get(s.fromSymbol)??[];a.push(s),i.set(s.fromSymbol,a)}let r=[{symbol:e,path:[]}],o=new Set([e]);for(;r.length>0;){let s=r.shift();if(s.path.length>0&&t.has(s.symbol))return s.path;for(let a of(i.get(s.symbol)??[]).sort(on))o.has(a.toSymbol)||(o.add(a.toSymbol),r.push({symbol:a.toSymbol,path:[...s.path,a]}))}return[]}function jL(e,t,n,i){let r=In(e),o=new Set([n,...i].flatMap(s=>[...qr(s),...s.keyAnchors.map(a=>a.symbol)]));for(let s of t){if(r.length>=yi)break;!o.has(s.fromSymbol)&&!o.has(s.toSymbol)||r.some(a=>a.fromSymbol===s.fromSymbol&&a.toSymbol===s.toSymbol)||r.push(s)}return r.slice(0,yi)}function HL(e,t,n,i,r,o,s,a){let l=n.filter(u=>!u.root.symbol.startsWith(Ec)).map(u=>({root:u.root,relations:u.relations.filter(d=>d.depth===1&&d.fromSymbol===u.root.symbol)}));return UL(l).flatMap((u,d)=>{let m=new Set(u.map(A=>A.root.symbol)),f=new Map;for(let A of u)for(let W of new Set(A.relations.map(le=>le.toSymbol)))f.set(W,(f.get(W)??0)+1);let p=[...f].filter(([,A])=>A>=2).sort(([A,W],[le,q])=>q-W||zL(A,le,i,r,s)).map(([A])=>s.get(A)).filter(A=>A?.isFunctionLike===!0).slice(0,aL);if(p.length===0)return[];let g=t.callerFileMap(p,{semantic:a,sourceFallback:!0}),h=new Set;for(let A of p){h.add(A.relativePath);for(let W of g.get(A.symbolId)??[])h.add(W)}let S=o.filter(A=>A.isFunctionLike&&h.has(A.relativePath)).sort(GL).slice(0,lL),v=t.calleeMap(S,{additive:!1,semantic:a}),y=new Set(p.map(A=>A.symbol)),E=In(S.flatMap(A=>qs(e,A,v.get(A.symbolId)??[],s,1,y).filter(W=>y.has(W.toSymbol)))),w=new Map;for(let A of E){let W=w.get(A.fromSymbol)??new Set;W.add(A.toSymbol),w.set(A.fromSymbol,W)}let b=new Set([...w].filter(([A,W])=>W.size>=2||m.has(A)).map(([A])=>A)),R=E.filter(A=>b.has(A.fromSymbol));if(b.size<2||R.length===0)return[];let L=[...new Set(R.map(A=>A.toSymbol))].map(A=>Vs(A,i,r,s)).filter(A=>A!==null).sort(Xe),I=[...b].map(A=>Vs(A,i,r,s)).filter(A=>A!==null),x=KL(I,R),P=x.slice(0,Sc),_=x.slice(Sc);if(L.length===0||P.length===0)return[];let D=[...new Set([...L.flatMap(A=>A.matchedTerms),...u.flatMap(A=>A.root.matchedTerms)])].sort(),T=qL(R,P);return[{id:`effect-owner-set:${d+1}:${Kr(L[0])}`,kind:"shared-callee-owners",roots:L,keyAnchors:P,candidateOwnerCount:x.length,omittedCandidateOwners:_,ownerRecoveryCommands:dD(_,Sc),upstreamEntries:[],matchedTerms:D,relations:T,relationCount:R.length,omittedRelations:Math.max(0,R.length-T.length),systemMapCommand:Wr(P,R,D)}]})}function UL(e){let t=e.map((s,a)=>a),n=s=>{for(;t[s]!==s;)t[s]=t[t[s]],s=t[s];return s},i=(s,a)=>{let l=n(s),c=n(a);l!==c&&(t[c]=l)},r=e.map(s=>new Set(s.relations.map(a=>a.toSymbol)));for(let s=0;s<e.length;s+=1)for(let a=s+1;a<e.length;a+=1){let l=0;for(let c of r[s]??[])if((r[a]??new Set).has(c)&&(l+=1),l>=2)break;l>=2&&i(s,a)}let o=new Map;for(let s=0;s<e.length;s+=1){let a=n(s),l=o.get(a)??[];l.push(e[s]),o.set(a,l)}return[...o.values()].filter(s=>s.length>=2)}function zL(e,t,n,i,r){let o=Vs(e,n,i,r),s=Vs(t,n,i,r);return o?s?Xe(o,s):-1:s?1:e.localeCompare(t)}function GL(e,t){return zt(V(e.relativePath))-zt(V(t.relativePath))||e.relativePath.localeCompare(t.relativePath)||e.startLine-t.startLine}function Vs(e,t,n,i){let r=t.get(e);if(r)return Ks(r,n);let o=i.get(e);return o?Yg(o):null}function KL(e,t){let n=new Map;for(let r of t){let o=n.get(r.toSymbol)??new Set;o.add(r.fromSymbol),n.set(r.toSymbol,o)}let i=new Map;for(let r of t){let o=n.get(r.toSymbol)?.size??1;i.set(r.fromSymbol,(i.get(r.fromSymbol)??0)+o*o)}return[...e].sort((r,o)=>Number(r.leaf.startsWith("#"))-Number(o.leaf.startsWith("#"))||o.identityMatchedTerms.length-r.identityMatchedTerms.length||(i.get(o.symbol)??0)-(i.get(r.symbol)??0)||Xe(r,o))}function qL(e,t){let n=new Map(t.map((s,a)=>[s.symbol,a])),i=t.map(s=>e.filter(a=>a.fromSymbol===s.symbol).sort(on)),r=[],o=0;for(;r.length<yi&&i.some(s=>o<s.length);){for(let s of i){let a=s[o];if(a&&r.push(a),r.length>=yi)break}o+=1}return r.sort((s,a)=>n.get(s.fromSymbol)-n.get(a.fromSymbol)||on(s,a))}function WL(e,t,n,i){let r=new Map(t.map((a,l)=>[a.symbol,l])),o=new Map;for(let a of e)o.set(a.fromSymbol,(o.get(a.fromSymbol)??0)+1);return[...e].sort((a,l)=>{let c=u=>{let d=0;return r.has(u.fromSymbol)&&(d+=100),n.has(u.toSymbol)&&(d+=60),d+=Math.min(40,(o.get(u.toSymbol)??0)*8),(i.get(u.toSymbol)?.matchedTerms.length??0)>0&&(d+=25),u.fromFile!==u.toFile&&(d+=15),u.strength==="exact"&&(d+=5),d};return c(l)-c(a)||on(a,l)}).slice(0,yi).sort((a,l)=>(r.get(a.fromSymbol)??gi)-(r.get(l.fromSymbol)??gi)||a.depth-l.depth||(a.callsiteLine??Number.MAX_SAFE_INTEGER)-(l.callsiteLine??Number.MAX_SAFE_INTEGER)||on(a,l))}function Yg(e){return{symbol:e.symbol,label:zn(e),leaf:e.leaf,file:e.relativePath,line:e.startLine,endLine:e.endLine,kind:e.isFunctionLike?"callable":e.isTypeLike?"type":"symbol",fileKind:V(e.relativePath),matches:[],focusLocations:[],matchedTerms:[],symbolMatchedTerms:[],symbolPhraseLength:0,identityMatchedTerms:[],rarity:0,symbolRarity:0}}function VL(e,t,n){let i=[...e].sort(Xe),r=[],o=new Map;for(let u of t)o.set(u.fromSymbol,(o.get(u.fromSymbol)??0)+1);let s=new Set,a=new Set,l=u=>{if(!(!u||r.some(d=>d.symbol===u.symbol))){r.push(u);for(let d of u.matchedTerms)s.add(d);for(let d of u.symbolMatchedTerms)a.add(d)}},c=i.filter(u=>u.symbolPhraseLength>=2&&(o.get(u.symbol)??0)>=2);for(;r.length<Math.min(2,gi);){let u=c.filter(d=>!r.some(m=>m.symbol===d.symbol)).sort((d,m)=>m.symbolMatchedTerms.filter(f=>!a.has(f)).length-d.symbolMatchedTerms.filter(f=>!a.has(f)).length||m.symbolPhraseLength-d.symbolPhraseLength||(o.get(m.symbol)??0)-(o.get(d.symbol)??0)||Cc(d,m))[0];if(!u||r.length>0&&u.symbolMatchedTerms.every(d=>a.has(d)))break;l(u)}if(l(i[0]),r.length>=2){let u=JL(r[0].symbol,r[1].symbol,t,n);for(let d of u?.slice(1,-1)??[]){if(r.length>=gi)break;l(n.get(d))}if(r.length<gi){let d=new Set(r.map(p=>p.symbol)),m=new Set(t.filter(p=>p.depth===1&&d.has(p.fromSymbol)&&d.has(p.toSymbol)).map(p=>p.fromSymbol)),f=t.filter(p=>p.depth===1&&m.has(p.fromSymbol)&&!d.has(p.toSymbol)).map(p=>({relation:p,candidate:n.get(p.toSymbol)})).filter(p=>p.candidate!==void 0&&p.candidate.symbolPhraseLength>=2&&p.candidate.symbolMatchedTerms.length>=2).sort((p,g)=>(o.get(p.relation.fromSymbol)??0)-(o.get(g.relation.fromSymbol)??0)||Cc(p.candidate,g.candidate))[0]?.candidate;l(f)}}else for(;r.length<Math.min(3,gi);){let u=i.filter(d=>!r.some(m=>m.symbol===d.symbol)).sort((d,m)=>m.matchedTerms.filter(f=>!s.has(f)).length-d.matchedTerms.filter(f=>!s.has(f)).length||Xe(d,m))[0];if(!u||u.matchedTerms.every(d=>s.has(d)))break;l(u)}for(;r.length>=2&&r.length<gi;){let u=new Set(r.map(m=>m.symbol)),d=[...n.values()].filter(m=>!u.has(m.symbol)&&(o.get(m.symbol)??0)>0&&t.some(f=>u.has(f.fromSymbol)&&f.toSymbol===m.symbol)).sort((m,f)=>f.identityMatchedTerms.length-m.identityMatchedTerms.length||f.symbolMatchedTerms.length-m.symbolMatchedTerms.length||f.matchedTerms.length-m.matchedTerms.length||(o.get(f.symbol)??0)-(o.get(m.symbol)??0)||Xe(m,f))[0];if(!d)break;l(d)}if(r.length<2){let u=r[0],d=u?i.filter(m=>m.symbol!==u.symbol).map(m=>({root:m,path:YL(m.symbol,u.symbol,t)})).filter(m=>m.path!==null).sort((m,f)=>+(f.root.file!==u.file)-+(m.root.file!==u.file)||m.path.length-f.path.length||Xe(m.root,f.root))[0]?.root:void 0;l(d)}return r}function JL(e,t,n,i){let r=new Map;for(let a of n){let l=r.get(a.fromSymbol)??new Set;l.add(a.toSymbol),r.set(a.fromSymbol,l);let c=r.get(a.toSymbol)??new Set;c.add(a.fromSymbol),r.set(a.toSymbol,c)}let o=[{path:[e],cost:0}],s=new Map([[e,0]]);for(;o.length>0;){o.sort((u,d)=>u.cost-d.cost||u.path.length-d.path.length);let{path:a,cost:l}=o.shift(),c=a.at(-1);if(c===t)return a;for(let u of r.get(c)??[]){let d=i.get(u),m=u===t?1:!d||d.matchedTerms.length===0?9:d.symbolPhraseLength>=2?1:d.identityMatchedTerms.length>=2?2:4,f=l+m;f>=(s.get(u)??Number.POSITIVE_INFINITY)||(s.set(u,f),o.push({path:[...a,u],cost:f}))}}return null}function YL(e,t,n){let i=new Map;for(let s of n){let a=i.get(s.fromSymbol)??[];a.push(s.toSymbol),i.set(s.fromSymbol,a)}let r=[[e]],o=new Set([e]);for(;r.length>0;){let s=r.shift(),a=s.at(-1);if(a===t)return s;for(let l of i.get(a)??[])o.has(l)||(o.add(l),r.push([...s,l]))}return null}function Xe(e,t){return(t.queryPathMatches?.length??0)-(e.queryPathMatches?.length??0)||t.identityMatchedTerms.length-e.identityMatchedTerms.length||t.matchedTerms.length-e.matchedTerms.length||t.rarity-e.rarity||Ji(e.kind)-Ji(t.kind)||zt(e.fileKind)-zt(t.fileKind)||e.file.localeCompare(t.file)||e.line-t.line}function Cc(e,t){return t.symbolPhraseLength-e.symbolPhraseLength||t.symbolMatchedTerms.length-e.symbolMatchedTerms.length||Ji(e.kind)-Ji(t.kind)||t.symbolRarity-e.symbolRarity||Xe(e,t)}function XL(e,t){return t.flatMap(n=>{let i=e.filter(s=>s.matchedTerms.includes(n)).sort((s,a)=>QL(s,a,n)),r=[],o=new Set;for(let s of i)if(!o.has(s.file)&&(r.push(s),o.add(s.file),r.length>=Ng))return r;for(let s of i)if(!r.some(a=>a.symbol===s.symbol)&&(r.push(s),r.length>=Ng))break;return r})}function ZL(e,t,n){let i=new Set(t),r=new Map;for(let o of e){if(o.kind!=="callable")continue;let s=o.file.slice(o.file.lastIndexOf("/")+1).replace(/\.[^.]+$/u,"");if(![...ct(s)].some(l=>i.has(l)))continue;let a=r.get(o.file)??[];a.push(o),r.set(o.file,a)}return[...r.entries()].map(([o,s])=>{let a=o.slice(o.lastIndexOf("/")+1).replace(/\.[^.]+$/u,""),l=[...ct(a)].filter(c=>i.has(c));return{file:o,fileCandidates:s,sharedFrequency:Math.min(...l.map(c=>n.get(c)??Number.MAX_SAFE_INTEGER))}}).sort((o,s)=>zt(o.fileCandidates[0].fileKind)-zt(s.fileCandidates[0].fileKind)||o.sharedFrequency-s.sharedFrequency||o.file.localeCompare(s.file)).flatMap(({fileCandidates:o})=>[...o].sort(Xe).slice(0,yL)).slice(0,hL)}function QL(e,t,n){return Ug(e,n)-Ug(t,n)||zt(e.fileKind)-zt(t.fileKind)||t.symbolPhraseLength-e.symbolPhraseLength||Ji(e.kind)-Ji(t.kind)||Xe(e,t)}function Ug(e,t){let n=e.matches.find(i=>i.term===t)?.sources??[];return Math.min(...n.map(xc),Number.MAX_SAFE_INTEGER)}function Vi(e){return[...new Map(e.map(t=>[t.symbol,t])).values()]}function hi(e,t,n){let i=new Set(e.roots.flatMap(o=>o.symbolMatchedTerms)),r=new Set(t.roots.flatMap(o=>o.symbolMatchedTerms));return(t.queryPathMatches?.length??0)-(e.queryPathMatches?.length??0)||qg(e.kind)-qg(t.kind)||Gg(e)-Gg(t)||Kg(e)-Kg(t)||(e.kind==="parallel-paths"&&t.kind==="parallel-paths"?(e.parallelSharedPathFrequency??Number.MAX_SAFE_INTEGER)-(t.parallelSharedPathFrequency??Number.MAX_SAFE_INTEGER)||(t.parallelOrchestrationSides??0)-(e.parallelOrchestrationSides??0)||(t.parallelSharedPathTerms?.length??0)-(e.parallelSharedPathTerms?.length??0):0)||zg(t,n)-zg(e,n)||t.matchedTerms.length-e.matchedTerms.length||Math.max(...t.roots.map(o=>o.symbolPhraseLength))-Math.max(...e.roots.map(o=>o.symbolPhraseLength))||r.size-i.size||Xe(e.roots[0],t.roots[0])||t.roots.length-e.roots.length||e.relationCount-t.relationCount||e.id.localeCompare(t.id)}function zg(e,t){return e.matchedTerms.reduce((n,i)=>n+1/Math.max(1,t.get(i)??1),0)}function eD(e){return[...new Set(e.roots.flatMap(t=>t.queryPathMatches??[]))].sort()}function Gg(e){let t=e.keyAnchors.length>0?e.keyAnchors:e.roots;return Math.max(...t.map(n=>zt(n.fileKind)))}function Kg(e){return e.kind==="parallel-paths"?2-(e.parallelConnectedSides??0):e.kind!=="connected-flow"||e.relationCount>0?0:1}function tD(e,t,n){let i=e.slice(0,t);if(t<2||i.some(o=>o.kind==="shared-callee-owners"))return i;let r=e.filter(o=>o.kind==="shared-callee-owners");for(let o of i){if(o.kind==="shared-callee-owners"||o.kind==="parallel-paths")continue;let s=new Set(qr(o)),a=r.map(c=>({group:c,overlap:nD(c,s)})).filter(({overlap:c})=>c>0).sort(({group:c,overlap:u},{group:d,overlap:m})=>m-u||hi(c,d,n))[0]?.group;if(!a)continue;let l=i.length-1;for(;l>=0&&i[l]===o;)l-=1;return l<0?i:(i[l]=a,[...i].sort((c,u)=>hi(c,u,n)))}return i}function nD(e,t){return qr(e).filter(n=>t.has(n)).length}function qg(e){switch(e){case"cross-boundary-flow":return 0;case"parallel-paths":case"connected-flow":return 1;case"shared-callee-owners":return 2}}function on(e,t){return e.depth-t.depth||Gn(t.strength)-Gn(e.strength)||e.fromLabel.localeCompare(t.fromLabel)||e.toLabel.localeCompare(t.toLabel)||(e.callsiteLine??Number.MAX_SAFE_INTEGER)-(t.callsiteLine??Number.MAX_SAFE_INTEGER)}function iD(e,t){return Gn(Rc(t.source))-Gn(Rc(e.source))||(e.callsiteLine??Number.MAX_SAFE_INTEGER)-(t.callsiteLine??Number.MAX_SAFE_INTEGER)||e.symbol.localeCompare(t.symbol)}function In(e){let t=new Map;for(let n of e){let i=`${n.fromSymbol}\0${n.toSymbol}`,r=t.get(i);(!r||on(n,r)<0)&&t.set(i,n)}return[...t.values()]}function rD(e){let t=e.match(/[\p{L}\d_.-]+(?:\/[\p{L}\d_.-]+)+/gu)??[];return[...new Set(t.map(n=>n.replace(/[.;:!?]+$/gu,"").toLocaleLowerCase()))]}function oD(e,t){let n=e.replace(/\\/gu,"/").toLocaleLowerCase();return t.filter(i=>{let r=n.indexOf(i);if(r<0)return!1;let o=r===0?"/":n[r-1],s=n[r+i.length];return o==="/"&&(s===void 0||s==="/")})}function sD(e,t){let n=jr(e).map($s),i=0;for(let r=0;r<n.length;r+=1)for(let o=0;o<t.length;o+=1){let s=0;for(;r+s<n.length&&o+s<t.length&&n[r+s]===t[o+s];)s+=1;i=Math.max(i,s)}return i}function Wg(e){if(e.length===0)return[];let t=e.split(`
67
+ `);return e.endsWith(`
68
+ `)&&t.pop(),t}function aD(e,t){return xc(e)-xc(t)}function xc(e){switch(e){case"symbol":return 0;case"path":return 1;case"documentation":return 2;case"source":return 3}}function Ji(e){return e==="callable"?0:e==="type"?1:2}function zt(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function Rc(e){return e==="semantic-callee"||e==="scip-chunk"?"exact":"derived"}function Gn(e){return e==="exact"?2:1}function Xg(e,t){return e.file.localeCompare(t.file)||e.line-t.line}function Kr(e){return`${e.file}:${e.line+1}`}function Wr(e,t=[],n=[]){let i=e.map(s=>`--symbol ${Js(`${s.file}:${s.line+1}-${s.endLine+1}`)}`),r=new Set(e.map(s=>s.symbol)),o=e.flatMap(s=>(s.sourceCharacters??0)>bc?lD(s,t,n,r).map(a=>`--focus-at ${Js(`${a.file}:${a.line+1}`)}`):[]);return`codebaseiq system-map ${[...i,...o,"--relation call","--relation runtime-boundary"].join(" ")}`}function lD(e,t,n,i){let r=new Set(n),o=t.filter(c=>c.fromSymbol===e.symbol&&c.callsiteLine!==null&&c.callsiteLine>=e.line&&c.callsiteLine<=e.endLine).map(c=>({file:e.file,line:c.callsiteLine,connectsAnchor:i.has(c.toSymbol),overlap:new Set(jr(cD(c.toLabel)).flatMap(oc).filter(u=>r.has(u))).size,strength:c.strength})).filter(c=>c.overlap>0).sort((c,u)=>Number(u.connectsAnchor)-Number(c.connectsAnchor)||u.overlap-c.overlap||c.line-u.line||Gn(u.strength)-Gn(c.strength)),s=o.filter(c=>c.connectsAnchor),a=[...s.length>0?s:o,...s.length>0?[]:e.focusLocations.map(c=>({...c,connectsAnchor:!1,overlap:0,strength:"derived"}))],l=[];for(let c of a)if(!l.some(u=>u.file===c.file&&u.line===c.line)&&(l.push({file:c.file,line:c.line}),l.length>=3))break;return l}function cD(e){return e.slice(Math.max(e.lastIndexOf(":"),e.lastIndexOf("."))+1)}function uD(e,t){let n=new Map;for(let[o,s]of e.matches)for(let a of s.locations.values()){if(a.file!==e.definition.relativePath||a.line<e.definition.startLine||a.line>e.definition.endLine)continue;let l=`${a.file}\0${a.line}`,c=n.get(l)??{...a,matchedTerms:new Set};c.matchedTerms.add(o),n.set(l,c)}let i=[...n.values()].sort((o,s)=>s.matchedTerms.size-o.matchedTerms.size||[...s.matchedTerms].reduce((a,l)=>a+1/Math.max(1,t.get(l)??1),0)-[...o.matchedTerms].reduce((a,l)=>a+1/Math.max(1,t.get(l)??1),0)||Xg(o,s)),r=[];for(let o of i)if(!r.some(s=>s.file===o.file&&Math.abs(s.line-o.line)<8)&&(r.push(o),r.length>=3))break;return r.map(o=>({file:o.file,line:o.line,matchedTerms:[...o.matchedTerms].sort()}))}function dD(e,t){let n=[];for(let i=0;i<e.length;i+=t)n.push(Wr(e.slice(i,i+t)));return n}function Js(e){return`'${e.replaceAll("'",`'"'"'`)}'`}import{createHash as Ch}from"crypto";function Ys(e,t){return de(e)-de(t)||e.relativePath.localeCompare(t.relativePath)}function Ae(e,t){return typeof t!="number"||t<=0||e.length<=t?e:e.slice(0,t)}function Yi(e){let t=new Set,n=[];for(let i of e){let r=`${i.symbol}|${i.file}`;t.has(r)||(t.add(r),n.push(i))}return n}function Vr(e,t,n={}){let i=fe(e,t);if(!i)return null;let r=n.semantic!==!1,o=Rl(e,i,{semantic:r,semanticEvidence:pe}),s=o.rows.filter(d=>ke(d.symbol)).slice(0,50),a=ai(e,i,{limit:50,additive:!0,callableOnly:!0,semantic:r,semanticEvidence:pe}),l=Yi(a.rows),c=s.map(d=>({symbol:d.symbol,shortName:k(d.symbol),file:d.file,relationship:d.source!=="caller-map-inversion"?"reference-candidate":d.callEvidence==="scip-chunk"?"chunk-candidate":"resolved-call",evidenceStrength:d.source==="caller-map-inversion"&&d.callEvidence!=="scip-chunk"?"exact":"candidate",evidenceSource:d.callEvidence??d.source})),u=l.map(d=>({symbol:d.symbol,shortName:k(d.symbol),file:d.file,relationship:d.source==="scip-chunk"?"chunk-candidate":"resolved-call",evidenceStrength:d.source==="scip-chunk"?"candidate":"exact",evidenceSource:d.source}));return{symbol:i.symbol,shortName:k(i.symbol),callers:c.map(({symbol:d,shortName:m,file:f})=>({symbol:d,shortName:m,file:f})),callees:u.map(({symbol:d,shortName:m,file:f})=>({symbol:d,shortName:m,file:f})),callerEvidence:c,calleeEvidence:u,coverage:{scope:"indexed-static-call-graph",blindSpots:["unresolved dynamic dispatch and reflection","external or unindexed callees without a resolved symbol identity","SCIP chunk co-occurrence is retained only as candidate call evidence",...o.semanticIncomplete?["compiler-resolved incoming evidence was incomplete; known callers are retained"]:[],...o.semanticUnavailable?["compiler-resolved incoming evidence was unavailable; known callers are retained"]:[],...a.semanticIncomplete?["compiler-resolved outgoing evidence was incomplete; known callees are retained"]:[],...a.semanticUnavailable?["compiler-resolved outgoing evidence was unavailable; known callees are retained"]:[]],semanticEvidence:{enabled:r,incoming:Zg(r,o),outgoing:Zg(r,a)}}}}function Zg(e,t){return e?t.semanticIncomplete&&t.semanticUnavailable?"incomplete-and-unavailable":t.semanticIncomplete?"incomplete":t.semanticUnavailable?"unavailable":"complete":"disabled"}function Xi(e,t,n){if(n.length===0)return[];let i=new Set(n),r=Be(e),o=new Set;if(t==="forward")for(let s of i)for(let a of r.get(s)??[])i.has(a)||o.add(a);else for(let[s,a]of r)if(!i.has(s))for(let l of i)a.has(l)&&o.add(s);return[...o].sort()}function Jr(e,t){let n=lt(e,t);return n?Xi(e,"forward",[n]).filter(r=>!e.isIgnored(r)).map(r=>({relativePath:r,edgeBasis:"symbol-references",evidence:"cross-file SCIP references plus resolved source imports"})):[]}function Yr(e,t){let n=lt(e,t);return n?Xi(e,"reverse",[n]).filter(r=>!e.isIgnored(r)).map(r=>({relativePath:r,edgeBasis:"symbol-references",evidence:"cross-file SCIP references plus resolved source imports"})):[]}function wc(e,t,n={}){let i=Xs(e,t,n);return{definitions:i.definitions,referencedBy:i.referencedBy}}function Xs(e,t,n={}){let i=fe(e,t);if(!i)return{definitions:[],referencedBy:[],referenceEvidence:[],claimSupport:null};let r=e.get("SELECT display_name, documentation FROM global_symbols WHERE id = ?",i.symbolId),o=Bi(r?.documentation??null),s=e.isIgnored(i.relativePath)?[]:[{relativePath:i.relativePath,startLine:i.startLine,endLine:i.endLine,signature:yD(o,r?.display_name??null,i.symbol),source:hD(e,i.relativePath,i.startLine,i.endLine)}],a=n.referenceContext??2,l=Lm(e,i,{semantic:n.semantic,semanticEvidence:pe}).map(u=>{let d=Df(e,u.file,u.line,a,re(i.symbol));return{relativePath:u.file,line:u.line,enclosingSymbol:u.enclosingSymbol,enclosingShort:u.enclosingSymbol?k(u.enclosingSymbol):"(top-level)",provenance:u.provenance,sourceStartLine:d?.startLine??null,sourceEndLine:d?.endLine??null,source:d?.source??null,sourceKind:d?.kind??"unavailable"}}),c=l.map(mD);return{definitions:s,referencedBy:c,referenceEvidence:l.map(u=>({relativePath:u.relativePath,line:u.line,provenance:u.provenance,sourceKind:u.sourceKind})),claimSupport:fD(l)}}function mD(e){return{relativePath:e.relativePath,line:e.line,enclosingSymbol:e.enclosingSymbol,enclosingShort:e.enclosingShort,sourceStartLine:e.sourceStartLine,sourceEndLine:e.sourceEndLine,source:e.source}}function fD(e){let t="resolved source-attributed or SCIP-indexed references to this exact symbol",n=["Dynamic dispatch, reflection, generated calls, and unindexed source are outside this scope."],i=e.filter(o=>o.sourceKind!=="complete-call-expression"&&o.sourceKind!=="non-call-reference"),r="direct, statically visible call expressions among the resolved reference sites";return{referenceAbsence:{status:"eligible",scope:t,limitations:n},callsitePredicates:i.length===0?{status:"eligible",scope:r,limitations:n}:{status:"ineligible",scope:r,reason:`${i.length} reference site(s) lack one unambiguous complete call expression.`,followup:pD(i)}}}function pD(e){let t=[...new Set(e.map(n=>`${n.relativePath}:${n.line+1}`))];return t.length===0||t.length>24?null:`codebaseiq inspect ${t.map(n=>`--at ${gD(n)}`).join(" ")} --view behavior`}function gD(e){return`'${e.replaceAll("'","'\\''")}'`}function hD(e,t,n,i){let r=se(e,t);if(!r)return null;let s=r.split(`
69
+ `).slice(n,i+1).join(`
70
+ `).trimEnd();return s.length>0?s:null}function yD(e,t,n){let i=_i(e);if(i&&!bD(i))return i;let r=(t??"").trim();return r?ke(n)&&!r.endsWith("()")?`${r}()`:r:k(n)}function bD(e){return e.startsWith("undefined")||e.includes("|")||e.includes("```")}function Ic(e,t,n={}){let i=th(e,t,n);if(i.kind!=="matched")return i;let{referenceEvidence:r,claimSupport:o,...s}=i;return s}function th(e,t,n={}){let i=rt(e,t);if(!i.match)return{kind:"missing",query:t};if(i.total>1)return{kind:"ambiguous",query:t,total:i.total,candidates:[{symbol:i.match.symbol,shortName:k(i.match.symbol),relativePath:i.match.relativePath,startLine:i.match.startLine},...i.candidates]};let r=i.match,o=vD(n.parts),s=o.includes("definition")||o.includes("references")?Xs(e,r.symbol,{semantic:n.semantic,referenceContext:n.referenceContext}):{definitions:[],referencedBy:[],referenceEvidence:[],claimSupport:null},a=o.includes("callers")||o.includes("callees")?Vr(e,r.symbol,{semantic:n.semantic}):null,l=n.relatedSourceLines??80;return{kind:"matched",query:t,symbol:r.symbol,shortName:k(r.symbol),file:r.relativePath,parts:o,definition:o.includes("definition")?Ol(e,r.symbol):null,referenceWindows:o.includes("references")?SD(e,s.referencedBy):[],callers:o.includes("callers")?eh(e,a?.callers??[],l):[],callees:o.includes("callees")?eh(e,a?.callees??[],l):[],dependencies:o.includes("dependencies")?Jr(e,r.relativePath):[],consumers:o.includes("consumers")?Yr(e,r.relativePath):[],referenceEvidence:s.referenceEvidence,claimSupport:s.claimSupport}}function SD(e,t){let n=t.filter(r=>r.sourceStartLine!==null&&r.sourceEndLine!==null&&r.source!==null).sort((r,o)=>r.relativePath.localeCompare(o.relativePath)||r.sourceStartLine-o.sourceStartLine||r.line-o.line),i=[];for(let r of n){let o=i[i.length-1];if(o&&o.relativePath===r.relativePath&&r.sourceStartLine<=o.endLine+1){o.endLine=Math.max(o.endLine,r.sourceEndLine),o.references.push(Qg(r)),o.source=ie(e,o.relativePath).slice(o.startLine,o.endLine+1).join(`
71
+ `);continue}i.push({relativePath:r.relativePath,startLine:r.sourceStartLine,endLine:r.sourceEndLine,source:r.source,references:[Qg(r)]})}return i}function Qg(e){return{line:e.line,enclosingSymbol:e.enclosingSymbol,enclosingShort:e.enclosingShort}}function vD(e){let t=e&&e.length>0?e:["definition","references"];return[...new Set(t)]}function eh(e,t,n){let i=[],r=new Set;for(let o of t){if(r.has(o.symbol))continue;r.add(o.symbol);let s=(o.file?J(e,o.file).find(l=>l.symbol===o.symbol):void 0)??rt(e,o.symbol).match;if(!s)continue;let a=Pf(e,s.relativePath,s.startLine,s.endLine,n);a&&i.push({...a,symbol:o.symbol,shortName:o.shortName,omittedLines:Math.max(0,s.endLine-a.endLine)})}return i}var sh=6;function nh(e,t,n){return`${e}\0${t}\0${n??t}`}function ah(e,t,n,i={}){let r=i.limit??sh;if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`next-anchor limit must be a positive safe integer; received ${r}`);let o=i.sourceAllowed??(()=>!0),s=new Map(t.nodes.map(C=>[C.id,C])),a=new Set(n.steps.map(C=>C.nodeId)),l=new Set(n.steps.flatMap(C=>{let L=Pc(s.get(C.nodeId));return L?[L]:[]})),c=new Set;for(let C of n.steps)for(let L of C.behavior?.supportingDeclarations??[])l.add(L.symbol),c.add(nh(L.file,L.line,L.endLine));let u=C=>C.symbol!==null&&l.has(C.symbol)||c.has(nh(C.file,C.line,C.endLine)),d=new Map(n.steps.flatMap(C=>{if(!C.location)return[];let L=Pc(s.get(C.nodeId));if(!L)return[];let I=J(e,C.location.file).find(x=>x.symbol===L);return I?[[C.id,I]]:[]})),m=new U(e).calleeMap([...d.values()],{additive:!1,semantic:!0}),f=[],p=new Set,g=new Set,h=0,S=0,v=0,y=0,E=0,w=0,b=0,R=0;for(let C of n.steps){if(!C.location||!C.behavior)continue;let L=t.edges.filter(N=>["call","runtime-boundary"].includes(N.kind)&&(N.fromNodeId===C.nodeId||N.toNodeId===C.nodeId)&&N.disposition!=="excluded"&&N.disposition!=="unsupported");for(let N of L){let K=N.toNodeId===C.nodeId,te=K?N.fromNodeId:N.toNodeId;if(a.has(te))continue;let me=s.get(te);if(!me?.location||!o(me.location.file))continue;let ge=N.kind==="call"?Fc(e,me):Tc(me);if(!ge||u(ge))continue;let ce=Mc(N,me.location.file)??me.location,be=ie(e,ce.file)[ce.line]?.trim(),F=K?"upstream":"downstream",Z=N.kind==="runtime-boundary"?K?"runtime-producer":"runtime-consumer":K?"caller":"callee",X=["call"],Se=Lc(N.evidence),tt=Xr(me);f.push({anchor:{id:Kn(C.id,ce.line,me.id),status:Se,source:"graph-relation",direction:F,causalRole:Z,relationKind:N.kind,fromStepId:C.id,fromLabel:C.label,callsite:{file:ce.file,line:ce.line,endLine:ce.endLine??ce.line,text:be||`${me.label} \u2192 ${C.label}`,signals:X,calleeLeaf:tt},alternatives:[ge],alternativeCount:1,evidence:N.evidence}}),K&&(w+=1),N.kind==="runtime-boundary"&&(R+=1)}let I=t.edges.filter(N=>N.kind==="reference"&&N.fromNodeId===C.nodeId&&N.disposition!=="excluded"&&N.disposition!=="unsupported"&&!a.has(N.toNodeId));for(let N of I){let K=s.get(N.toNodeId);if(!K?.location||!o(K.location.file))continue;let te=Fc(e,K);if(!te||u(te))continue;let me=Xr(K),ge=Mc(N,C.location.file)?.line,ce=C.behavior.lines.find(X=>(ge===void 0||ge>=X.line&&ge<=X.endLine)&&X.text.includes(me));if(!ce)continue;let be=ch(ce.signals),F=be==="result-callback",Z=Lc(N.evidence);f.push({anchor:{id:Kn(C.id,ce.line,K.id),status:Z,source:"graph-relation",direction:"downstream",causalRole:be,relationKind:"reference",fromStepId:C.id,fromLabel:C.label,callsite:{file:C.location.file,line:ce.line,endLine:ce.endLine,text:ce.text,signals:ce.signals,calleeLeaf:me},alternatives:[te],alternativeCount:1,evidence:N.evidence}}),F&&(b+=1)}let x=xn(e,C.location.file,C.location.line,C.location.endLine??C.location.line),P=ie(e,C.location.file),_=Sn(e,C.location.file,C.location.line,C.location.endLine??C.location.line);for(let N of x.targets){if(!o(N.definition.relativePath))continue;let K=bi(C.location.file,N.sourceLine,N.calleeLeaf);if(p.has(K))continue;p.add(K);let te=Dc(_.get(N.sourceLine)),me={symbol:N.definition.symbol,label:N.definition.leaf,file:N.definition.relativePath,line:N.definition.startLine,endLine:N.definition.endLine};u(me)||f.push({anchor:{id:Kn(C.id,N.sourceLine,N.definition.symbol),status:"exact",source:"graph-call",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:C.id,fromLabel:C.label,callsite:{file:C.location.file,line:N.sourceLine,endLine:N.sourceLine,text:P[N.sourceLine]?.trim()||`${N.calleeLeaf}()`,signals:te,calleeLeaf:N.calleeLeaf},alternatives:[me],alternativeCount:1,evidence:[{method:"scip-occurrence-callsite",strength:"exact",identity:N.definition.symbol,location:{file:C.location.file,line:N.sourceLine}}]}})}let D=C.behavior.lines.filter(N=>N.signals.includes("call"));if(D.length===0)continue;h+=1;let T=(ee(e,C.location.file)?.callSites??[]).filter(N=>D.some(K=>N.line>=K.line&&N.line<=K.endLine));S+=T.length;let A=t.edges.filter(N=>N.kind==="call"&&N.fromNodeId===C.nodeId&&N.disposition!=="excluded"&&N.disposition!=="unsupported"),W=new Map;for(let N of A){let K=s.get(N.toNodeId);if(!K)continue;let te=Xr(K);W.set(te,(W.get(te)??0)+1)}let le=d.get(C.id),q=xD(e,le?m.get(le.symbolId)??[]:[]),Y=RD(q);for(let N of q){if(!o(N.alternative.file)||u(N.alternative))continue;let K=Zs(N.alternative.label),te=rh(T,D,K,N.row.callsiteLine,Y.get(K)===1);if(!te)continue;let me=Zr(D,te.line,K);if(!me)continue;let ge=bi(C.location.file,te.line,K);if(p.has(ge))continue;p.add(ge);let ce=fh(N.row.source);f.push({anchor:{id:Kn(C.id,te.line,N.alternative.symbol??N.alternative.file),status:ce,source:"graph-call",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:C.id,fromLabel:C.label,callsite:{file:C.location.file,line:me.line,endLine:me.endLine,text:me.text,signals:me.signals,calleeLeaf:K},alternatives:[N.alternative],alternativeCount:1,evidence:[{method:N.row.source,strength:ce,identity:N.row.symbol,location:{file:C.location.file,line:te.line}}]}})}for(let N of A){if(a.has(N.toNodeId))continue;let K=s.get(N.toNodeId);if(!K?.location||!o(K.location.file))continue;let te=Xr(K),me=N.evidence.find(X=>{let Se=X.location;return Se!==null&&Se.file===C.location?.file&&Se.line>=0})?.location?.line,ge=rh(T,D,te,me,W.get(te)===1);if(!ge)continue;let ce=Zr(D,ge.line,te);if(!ce)continue;let be=bi(C.location.file,ge.line,te);if(p.has(be))continue;p.add(be);let F=Tc(K);if(!F||u(F))continue;let Z=Lc(N.evidence);f.push({anchor:{id:Kn(C.id,ge.line,K.id),status:Z,source:"graph-call",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:C.id,fromLabel:C.label,callsite:{file:C.location.file,line:ce.line,endLine:ce.endLine,text:ce.text,signals:ce.signals,calleeLeaf:te},alternatives:[F],alternativeCount:1,evidence:N.evidence}})}for(let N of T){let K=bi(C.location.file,N.line,N.calleeLeaf);if(p.has(K))continue;let te=Zr(D,N.line,N.calleeLeaf);if(!te)continue;let me=Yt(C.location.file,Xt(e).get(N.calleeLeaf)??[]).flatMap(F=>J(e,F.file).filter(Z=>Z.symbol===F.symbol&&Z.isFunctionLike)).filter(F=>o(F.relativePath)&&!u({symbol:F.symbol,label:F.leaf,file:F.relativePath,line:F.startLine,endLine:F.endLine})),ge=ea(me.map(F=>({symbol:F.symbol,label:F.leaf??N.calleeLeaf,file:F.relativePath,line:F.startLine,endLine:F.endLine})));if(ge.length===0){E+=1;continue}let ce=`${C.id}\0${N.line}\0${N.calleeLeaf}`;if(g.has(ce))continue;g.add(ce);let be=ge.length>1;be?y+=1:v+=1,f.push({anchor:{id:Kn(C.id,N.line,N.calleeLeaf),status:be?"ambiguous":"candidate",source:"leaf-identity-candidate",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:C.id,fromLabel:C.label,callsite:{file:C.location.file,line:te.line,endLine:te.endLine,text:te.text,signals:te.signals,calleeLeaf:N.calleeLeaf},alternatives:ge.slice(0,3),alternativeCount:ge.length,evidence:[]}})}}return dh(e,f,n.steps,r,{scannedBehaviorSteps:h,visibleCallsites:S,graphEvidencedCallsites:p.size,identityCandidateCallsites:v,ambiguousCallsites:y,unresolvedCallsites:E,upstreamCandidates:w,resultCandidates:b,runtimeCandidates:R},i.selectionTerms)}function lh(e,t,n){let i=new Map(t.nodes.map(r=>[r.id,r]));for(let r of n.steps)if(!(!r.behavior||!r.location))for(let o of t.edges){if(o.kind!=="reference"||o.fromNodeId!==r.nodeId||o.disposition==="excluded"||o.disposition==="unsupported")continue;let s=i.get(o.toNodeId);if(!s?.location||!Fc(e,s))continue;let a=Xr(s),l=Mc(o,r.location.file)?.line,c=r.behavior.lines.find(u=>(l===void 0||l>=u.line&&l<=u.endLine)&&u.text.includes(a));!c||ch(c.signals)!=="result-callback"||o.semantics?.some(({family:u,subtype:d})=>u==="control"&&d==="result-callback")||(o.semantics=[...o.semantics??[],{family:"control",subtype:"result-callback",attributes:{evidenceRole:"result-producing-callable-reference"}}])}}function ch(e){return e.includes("call")&&e.some(t=>["return","mutation","shape","spread","binding"].includes(t))?"result-callback":"callable-reference"}function uh(e,t,n={}){let i=n.limit??sh;if(!Number.isSafeInteger(i)||i<=0)throw new RangeError(`next-anchor limit must be a positive safe integer; received ${i}`);let r=n.sourceAllowed??(()=>!0),o=[],s=t.map((f,p)=>({id:f.id,nodeId:f.id,order:p,role:"anchor",kind:"source-construct",label:f.label,location:{file:f.file,line:f.startLine,endLine:f.endLine},behavior:null})),a=t.map(f=>({file:f.file,startLine:f.startLine,endLine:f.endLine})),l=0,c=0,u=0,d=0,m=0;for(let f of t){let p=ie(e,f.file),h=(ee(e,f.file)?.callSites??[]).filter(b=>b.line>=f.startLine&&b.line<=f.endLine);l+=h.length;let S=Sn(e,f.file,f.startLine,f.endLine),v=xn(e,f.file,f.startLine,f.endLine),y=new Set;for(let b of v.targets){if(!r(b.definition.relativePath)||a.some(I=>I.file===b.definition.relativePath&&I.startLine<=b.definition.startLine&&I.endLine>=b.definition.endLine))continue;let R=bi(f.file,b.sourceLine,b.calleeLeaf);y.add(R);let C=Dc(S.get(b.sourceLine)),L={symbol:b.definition.symbol,label:b.definition.leaf,file:b.definition.relativePath,line:b.definition.startLine,endLine:b.definition.endLine};o.push({anchor:{id:Kn(f.id,b.sourceLine,b.definition.symbol),status:"exact",source:"graph-call",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:f.id,fromLabel:f.label,callsite:{file:f.file,line:b.sourceLine,endLine:b.sourceLine,text:p[b.sourceLine]?.trim()||`${b.calleeLeaf}()`,signals:C,calleeLeaf:b.calleeLeaf},alternatives:[L],alternativeCount:1,evidence:[{method:"scip-occurrence-callsite",strength:"exact",identity:b.definition.symbol,location:{file:f.file,line:b.sourceLine}}]}})}c+=v.resolvedCallsites;let E=Un(e,f.file,{ranges:[{startLine:f.startLine,endLine:f.endLine}]}),w=new Map;for(let b of E.targets){let R=h.find(I=>I.line===b.line)?.calleeLeaf??b.calleeLeaf,C=bi(f.file,b.line,R),L=w.get(C)??[];L.push(b),w.set(C,L)}for(let[b,R]of w){if(y.has(b))continue;y.add(b);let C=R.filter(D=>r(D.targetFile)&&!a.some(T=>T.file===D.targetFile&&T.startLine<=D.targetStartLine&&T.endLine>=D.targetEndLine));if(C.length===0)continue;let L=C[0],I=h.find(D=>D.line===L.line)?.calleeLeaf??L.calleeLeaf,x=Dc(S.get(L.line)),P=ea(C.map(D=>({symbol:D.targetSymbol??null,label:D.calleeLeaf,file:D.targetFile,line:D.targetStartLine,endLine:D.targetEndLine}))),_=C.some(D=>(D.resolutionAlternativeCount??0)>1)?"candidate":C.every(D=>D.strength==="exact")?"exact":"derived";o.push({anchor:{id:Kn(f.id,L.line,P.map(D=>`${D.file}:${D.line}`).join("|")),status:P.length>1?"ambiguous":_,source:"graph-call",direction:"downstream",causalRole:"callee",relationKind:"call",fromStepId:f.id,fromLabel:f.label,callsite:{file:f.file,line:L.line,endLine:L.line,text:p[L.line]?.trim()||`${L.calleeLeaf}()`,signals:x,calleeLeaf:I},alternatives:P.slice(0,3),alternativeCount:P.length,evidence:C.map(D=>({method:D.resolution==="constructed-member-receiver"?"ast-constructed-member-callsite":D.resolution==="factory-callback-member"?"ast-factory-callback-callsite":D.resolution==="imported-service-object-member"?"ast-service-member-callsite":"ast-import-member-callsite",strength:_,identity:D.targetSymbol??`${D.targetFile}:${D.targetStartLine}-${D.targetEndLine}`,location:{file:f.file,line:L.line}}))}})}c+=w.size;for(let b of h){let R=bi(f.file,b.line,b.calleeLeaf);y.has(R)||(m+=1)}}return dh(e,o,s,i,{scannedBehaviorSteps:t.length,visibleCallsites:l,graphEvidencedCallsites:c,identityCandidateCallsites:u,ambiguousCallsites:d,unresolvedCallsites:m,upstreamCandidates:0,resultCandidates:0,runtimeCandidates:0})}function dh(e,t,n,i,r,o=[]){let s=ED(t).sort(mh),a=s.filter(p=>CD(e,p)).slice(0,i),l=new Set(a.map(p=>p.anchor.id)),c=s.filter(p=>!l.has(p.anchor.id)),u=a.map(p=>p.anchor),d=c.map(p=>p.anchor),m=ea(u.flatMap(p=>p.alternativeCount===1?p.alternatives:[])),f=ea(d.flatMap(p=>p.alternativeCount===1?p.alternatives:[]));return{anchors:u,withheldAnchors:d,candidateAnchors:s.length,omittedAnchors:Math.max(0,s.length-u.length),...r,inspectCommand:m.length===0?null:`codebaseiq inspect ${m.map(oh).join(" ")} --view behavior`,remainingInspectCommands:ID(f,8).map(p=>`codebaseiq inspect ${p.map(oh).join(" ")} --view behavior`)}}function mh(e,t){let n=e.anchor.alternatives[0],i=t.anchor.alternatives[0];return Qs(e.anchor.status)-Qs(t.anchor.status)||(e.anchor.direction??"").localeCompare(t.anchor.direction??"")||(e.anchor.relationKind??"").localeCompare(t.anchor.relationKind??"")||(e.anchor.causalRole??"").localeCompare(t.anchor.causalRole??"")||e.anchor.fromStepId.localeCompare(t.anchor.fromStepId)||e.anchor.callsite.file.localeCompare(t.anchor.callsite.file)||e.anchor.callsite.line-t.anchor.callsite.line||(n?.file??"").localeCompare(i?.file??"")||(n?.line??0)-(i?.line??0)||e.anchor.id.localeCompare(t.anchor.id)}function CD(e,t){if(t.anchor.alternativeCount!==1)return!0;let n=t.anchor.alternatives[0],i=n.endLine??n.line;return ie(e,n.file).slice(n.line,i+1).join(`
72
+ `).length<=2e4}function Dc(e){return e?.includes("call")?[...e]:["call",...e??[]]}function xD(e,t){let n=new Map;for(let i of t){let r=J(e,i.file).find(a=>a.symbol===i.symbol&&a.isFunctionLike);if(!r)continue;let o={symbol:r.symbol,label:r.leaf,file:r.relativePath,line:r.startLine,endLine:r.endLine},s=n.get(r.symbol);!s||ih(i.source)>ih(s.row.source)?n.set(r.symbol,{row:{...i,...i.callsiteLine===void 0&&s?.row.callsiteLine!==void 0?{callsiteLine:s.row.callsiteLine}:{}},alternative:o}):s.row.callsiteLine===void 0&&i.callsiteLine!==void 0&&n.set(r.symbol,{...s,row:{...s.row,callsiteLine:i.callsiteLine}})}return[...n.values()]}function RD(e){let t=new Map;for(let n of e){let i=Zs(n.alternative.label);t.set(i,(t.get(i)??0)+1)}return t}function fh(e){return e==="semantic-callee"||e==="scip-chunk"?"exact":"derived"}function ih(e){return fh(e)==="exact"?2:1}function Zr(e,t,n){return e.find(i=>t>=i.line&&t<=i.endLine&&i.text.includes(n))??e.find(i=>t>=i.line&&t<=i.endLine)??null}function rh(e,t,n,i,r){if(i!==void 0)return e.find(s=>s.line===i&&s.calleeLeaf===n&&Zr(t,s.line,n)!==null)??null;let o=e.filter(s=>s.calleeLeaf===n&&Zr(t,s.line,s.calleeLeaf)!==null);return r&&o.length===1?o[0]:null}function Xr(e){let t=e.attributes.leaf;if(typeof t=="string"&&t.length>0)return Zs(t);let n=e.label.slice(e.label.lastIndexOf(":")+1);return Zs(n)}function Zs(e){return e.replace(/\(\)$/u,"").replace(/^#/u,"")}function Pc(e){if(e?.kind!=="symbol"||!e.id.startsWith("symbol:"))return null;try{return decodeURIComponent(e.id.slice(7))}catch{return null}}function Tc(e){return e.location?{symbol:Pc(e),label:e.label,file:e.location.file,line:e.location.line,endLine:e.location.endLine??null}:null}function Fc(e,t){let n=Tc(t);return n?.symbol&&J(e,n.file).some(r=>r.symbol===n.symbol&&r.isFunctionLike)?n:null}function Mc(e,t){return e.evidence.find(n=>n.location?.file===t)?.location??e.evidence.find(n=>n.location!==null)?.location??null}function Lc(e){let t={exact:5,derived:4,mixed:3,candidate:2,unknown:1};return e.reduce((n,i)=>t[i.strength]>t[n]?i.strength:n,"unknown")}function ED(e){let t=new Map;for(let n of e){let r=n.anchor.alternatives[0]?.symbol??`${n.anchor.callsite.file}:${n.anchor.callsite.line}:${n.anchor.callsite.calleeLeaf}`,o=t.get(r);(!o||wD(n,o)<0)&&t.set(r,n)}return[...t.values()]}function wD(e,t){return Qs(e.anchor.status)-Qs(t.anchor.status)||e.anchor.alternativeCount-t.anchor.alternativeCount||mh(e,t)}function Qs(e){return{exact:0,derived:1,mixed:2,candidate:3,unknown:4,ambiguous:5}[e]}function ea(e){let t=new Map;for(let n of e)t.set(n.symbol??`${n.file}:${n.line}`,n);return[...t.values()].sort((n,i)=>n.file.localeCompare(i.file)||n.line-i.line||n.label.localeCompare(i.label))}function oh(e){return`--at ${LD(`${e.file}:${e.line+1}`)}`}function ID(e,t){let n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n}function LD(e){return`'${e.replaceAll("'","'\\''")}'`}function bi(e,t,n){return`${e}\0${t}\0${n}`}function Kn(e,t,n){return["next-anchor",e,String(t),n].map(encodeURIComponent).join(":")}var xh=6,DD=12,PD=48,TD=2e4,ph=12,Si=Number.MAX_SAFE_INTEGER,FD=["definition","callers","callees"],Bc={search:12,"exact-source":24,definition:24,caller:8,callee:8,"production-reference":6,"test-reference":2,dependency:6,consumer:6};function MD(e,t){if(t.cursor)throw new Error("Inspect no longer accepts semantic packet cursors. Run the original inspect selectors again.");let n=ND(t),i=BD(e,n),r=i.candidates.sort((P,_)=>Ac(P,_));n.view==="behavior"&&jD(e,r),HD(e,r),n.view==="behavior"&&OD(e,r);let o=Dp(r.map(P=>kc(P,n.view)),n.evidenceBudgets,(P,_)=>Ac(P.candidate,_.candidate)),{selected:s,omitted:a}=Bs(o.selected,n.maxUnits,n.maxCharacters,(P,_)=>Ac(P.candidate,_.candidate),n.view==="source"),l=s.map(P=>P.candidate),c=[...o.omitted,...a].map(P=>P.candidate),u=l.map(YD),d=ps(l.map(P=>P.kind==="source"?P.bindingClosure:void 0),l.filter(P=>P.kind==="source").map(P=>({relativePath:P.relativePath,startLine:P.startLine,endLine:P.endLine}))),m=u.reduce((P,_)=>P+(_.kind==="source"?QD(_.source):0),0),f=u.reduce((P,_)=>P+(_.kind==="source"?_.source.length:0),0),p=u.reduce((P,_)=>P+wh(_,n.view),0),g=u.filter(P=>P.kind==="source"&&(P.roles.includes("search")||P.roles.includes("location"))).map(XD),h=r.filter(P=>P.kind==="source"&&(P.roles.includes("search")||P.roles.includes("location"))).length,S=u.filter(P=>P.kind==="source"&&(P.roles.includes("search")||P.roles.includes("location"))).length,v=i.searches.map(P=>GD(P,r,l)),y=KD(c),E=i.locations.every(P=>P.matched)&&i.evidence.every(P=>P.kind==="matched")&&i.searches.every(P=>WD(P.textCoverage))&&c.every(P=>!P.roles.some(_=>_==="location"||_==="definition")),w=v.reduce((P,_)=>P+_.omittedMatches,0),b=c.length===0&&w===0,R=b?void 0:Eh(n,!0),C=UD(n,c),L=AD(b,E,c.length+w,C,v,R),I=r.filter(P=>n.view==="behavior"&&P.kind==="source"&&P.roles.some(_=>_==="location"||_==="definition"||_==="search")).map(P=>({id:`inspect:${P.relativePath}:${P.startLine}-${P.endLine}`,label:P.ownerShort??`${P.relativePath}:${P.startLine+1}`,file:P.relativePath,startLine:P.startLine,endLine:P.endLine})),x=I.length>0?uh(e,I):void 0;return{searches:v,evidence:i.evidence,locations:i.locations,slices:g,candidateSlices:h,omittedSlices:h-S,maxSlices:h,maxTotalLines:m,units:u,candidateUnits:r.length,omittedUnits:c.length,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,returnedLines:m,returnedCharacters:f,returnedViewCharacters:p,view:n.view,omissionGroups:C,packetCoverage:{mode:b?"complete":"bounded",candidateUnits:r.length,returnedUnits:u.length,omittedUnits:c.length,omittedByRole:y,exactSelectorsComplete:E,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,channels:qD(r,l,n.evidenceBudgets,n.view),...R?{expansionCommand:R}:{}},stoppingSummary:L,...x&&x.candidateAnchors>0?{causalFrontier:x}:{},bindingClosure:d,continuation:null}}function AD(e,t,n,i,r,o){let s=ut([...i.map(a=>a.drillCommand),...r.flatMap(a=>a.exactFollowup?[a.exactFollowup]:[]),...o?[o]:[]]);return e&&t?{queryStatus:"selection-complete",status:"stop-ready",openEvidence:0,guidance:"All evidence requested by this inspect query was materialized.",drillCommands:[]}:t?{queryStatus:"frontier-accounted",status:"relevance-check-required",openEvidence:n,guidance:"Withheld evidence is accounted for by recoverable groups; drill the groups relevant to the current decision.",drillCommands:s}:{queryStatus:"coverage-incomplete",status:"exact-evidence-withheld",openEvidence:n,guidance:"A requested identity, exact source unit, or current-text coverage requirement is unresolved; drill before relying on it.",drillCommands:s}}function ND(e){let t=Nc(e.searches),n=Nc(e.symbols),i=Nc(e.locations),r=t.length+n.length+i.length;if(r===0)throw new Error("inspect requires at least one --search, --symbol, or --at selector.");if(r>24)throw new RangeError(`inspect accepts at most ${24} selectors; received ${r}.`);let o=e.evidence??{};if(e.unitLines!==void 0&&qn(e.unitLines,"unitLines"),e.totalLines!==void 0&&qn(e.totalLines,"totalLines"),e.sliceLimit!==void 0&&qn(e.sliceLimit,"sliceLimit"),e.maxCharacters!==void 0&&qn(e.maxCharacters,"maxCharacters"),e.maxUnits!==void 0&&qn(e.maxUnits,"maxUnits"),e.view!==void 0&&e.view!=="source"&&e.view!=="behavior")throw new Error(`Unknown inspect view: ${String(e.view)}. Use source or behavior.`);if(e.full&&(e.searchLimit!==void 0||e.maxUnits!==void 0||e.maxCharacters!==void 0||e.evidenceBudgets!==void 0))throw new Error("full inspect cannot be combined with searchLimit, maxUnits, maxCharacters, or evidenceBudgets.");let s=e.full??!1;return{searches:t,symbols:n,locations:i,...e.scope?.trim()?{scope:e.scope.trim()}:{},context:vh(e.context??xh,"context"),searchLimit:qn(e.searchLimit??(s?Si:DD),"searchLimit"),maxUnits:qn(s?Si:e.maxUnits??PD,"maxUnits"),maxCharacters:qn(s?Si:e.maxCharacters??TD,"maxCharacters"),evidenceBudgets:s?_D():kD(e.evidenceBudgets??Bc),view:e.view??"source",evidence:{...o.parts?{parts:[...o.parts]}:n.length>0?{parts:[...FD]}:{},...o.referenceContext!==void 0?{referenceContext:vh(o.referenceContext,"referenceContext")}:{},relatedSourceLines:o.relatedSourceLines??60,...o.semantic!==void 0?{semantic:o.semantic}:{}}}}function kD(e){let t={...Bc};for(let[n,i]of Object.entries(e)){if(!(n in t))throw new Error(`Unknown inspect evidence channel: ${n}.`);if(!Number.isSafeInteger(i)||(i??-1)<0)throw new RangeError(`Evidence budget ${n} must be a non-negative safe integer; received ${i}.`);t[n]=i}return t}function _D(){return Object.fromEntries(Object.keys(Bc).map(e=>[e,Si]))}function BD(e,t){let n=[],i=0,r=t.searches.map(c=>{let u=ic(e,c,{scope:t.scope,context:0,limit:t.searchLimit,ranking:"structural"});return{pattern:c,result:u,matches:u.matches}}),o=Math.max(0,...r.map(c=>c.matches.length));for(let c=0;c<o;c+=1)for(let u of r){let d=u.matches[c];if(!d)continue;let m=jn(e,d.relativePath,d.focusLine,Si,t.context);m&&Zi(e,n,m,"search",`search:${u.pattern}`,d.ownerSymbol,d.ownerShort,1,i++)}let s=r.map(({pattern:c,result:u})=>{let d=u.omittedMatches>0?Rh(c,t.scope):void 0,m=u.fileCoverage??[],f=VD(c,m,t.scope);return{pattern:c,matchingLines:u.matchingLines,returnedMatches:u.matches.length,omittedMatches:u.omittedMatches,matchingFiles:m.length,returnedFiles:m.filter(p=>p.returnedMatches>0).length,omittedFiles:m.filter(p=>p.returnedMatches===0).length,candidateUnits:0,selectedUnits:0,omittedUnits:0,scopeHints:f.slice(0,ph),omittedScopeHints:Math.max(0,f.length-ph),textCoverage:u.textCoverage,...d?{exactFollowup:d}:{}}}),a=t.locations.map(c=>{let u=ZD(c),d=u?lt(e,u.path):null,m=d?jn(e,d,u.line-1,Si,t.context):null;return m&&Zi(e,n,m,"location",`at:${c}`,null,null,0,i++),{target:c,matched:m!==null}}),l=t.symbols.map(c=>Ic(e,c,t.evidence));for(let c of l)if(c.kind==="matched"){if(c.definition){let u=jn(e,c.definition.relativePath,c.definition.startLine,Si,t.context);u&&Zi(e,n,u,"definition",`definition:${c.shortName}`,c.symbol,c.shortName,0,i++)}for(let u of c.referenceWindows){let d=u.references[0];Zi(e,n,{...u,focusLine:d?.line??u.startLine,unitType:null,unitStartLine:u.startLine,unitEndLine:u.endLine,omittedLines:0},"reference",`reference:${c.shortName}`,d?.enclosingSymbol??null,d?.enclosingShort??null,V(u.relativePath)==="test"?5:4,i++,u.references.map(m=>m.line),c.symbol)}for(let u of c.callers)hh(e,n,u,"caller",c,2,i++);for(let u of c.callees)hh(e,n,u,"callee",c,3,i++);for(let u of c.dependencies)yh(e,n,"dependency",c.file,u.relativePath,c.symbol,t.context,6,i++);for(let u of c.consumers)yh(e,n,"consumer",u.relativePath,c.file,c.symbol,t.context,7,i++)}return{searches:s,evidence:l,locations:a,candidates:n}}function Ac(e,t){return e.priority-t.priority||t.roles.length-e.roles.length||t.reasons.length-e.reasons.length||gh(V(e.relativePath))-gh(V(t.relativePath))||e.sequence-t.sequence}function gh(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function kc(e,t){return{candidate:e,priority:e.priority,sequence:e.sequence,relativePath:e.relativePath,fileKind:V(e.relativePath),evidenceCharacters:wh(e,t),roles:e.roles,reasons:e.reasons,symbols:e.symbols,behaviorSignals:e.kind==="source"?e.behavior?.signals??[]:[],channel:_c(e)}}function _c(e){let t=e.roles;return t.includes("location")?"exact-source":t.includes("definition")?"definition":t.includes("caller")?"caller":t.includes("callee")?"callee":t.includes("reference")?V(e.relativePath)==="test"?"test-reference":"production-reference":t.includes("dependency")?"dependency":t.includes("consumer")?"consumer":"search"}function OD(e,t){let n=t.filter(r=>r.kind==="source"),i=xr(e,{files:ut(n.map(r=>r.relativePath))});for(let r of n){r.behavior=ji(e,r.relativePath,r.startLine,r.endLine,r.focusLines)??void 0;let o=i.filter(a=>a.source.file===r.relativePath&&a.source.startLine<=r.endLine&&a.source.endLine>=r.startLine),s=o.filter(a=>!$D(a,o)).map(a=>({observationId:a.id,protocol:a.protocol,action:a.action,role:a.role,strength:a.strength,resolution:a.resolution,line:a.source.startLine,endLine:a.source.endLine,keyParts:a.keyParts.map(l=>({name:l.name,value:l.value,evidence:l.evidence})),derivation:{kind:a.derivation.kind,rule:a.derivation.rule,sourceSpans:a.derivation.sourceSpans.length}}));r.runtimeFacts=s.length>0?s:void 0}}function $D(e,t){if(e.strength!=="candidate"||e.protocol!=="http")return!1;let n=e.keyParts.find(r=>r.name==="path")?.value,i=e.keyParts.find(r=>r.name==="method")?.value;return n?t.some(r=>{if(r===e||r.action!==e.action||r.role!==e.role||r.source.startLine!==e.source.startLine||r.derivation.rule!=="http.mount-prefix")return!1;let o=r.keyParts.find(a=>a.name==="path")?.value,s=r.keyParts.find(a=>a.name==="method")?.value;return!!(o&&o!==n&&o.endsWith(n)&&(!i||i===s))}):!1}function jD(e,t){for(let n of t){if(n.kind!=="source")continue;let i=gt(e,n.relativePath,n.startLine,n.endLine,n.focusLines);i.startLine===n.startLine&&i.endLine===n.endLine||(n.startLine=i.startLine,n.endLine=i.endLine,n.source=ie(e,n.relativePath).slice(i.startLine,i.endLine+1).join(`
73
+ `),n.unitStartLine=i.startLine,n.unitEndLine=i.endLine,n.omittedLines=0)}}function HD(e,t){for(let n of t)n.kind==="source"&&(n.bindingClosure=$i(e,n.relativePath,n.startLine,n.endLine))}function UD(e,t){let n=new Map;for(let i of t){let r=ta(i.relativePath),o=_c(i),s=[...i.roles].sort().join(","),a=i.kind==="path"?i.relationship:"",l=`${r}|${o}|${s}|${a}`,c=n.get(l)??[];c.push(i),n.set(l,c)}return[...n.entries()].map(([i,r])=>{let o=r[0],s=ut(r.flatMap(l=>[...l.roles])).sort(),a=ut(r.flatMap(l=>l.kind==="source"?l.behavior?.signals??[]:[])).sort();return{id:`g-${Ch("sha256").update(i).digest("hex").slice(0,8)}`,scope:ta(o.relativePath),channel:_c(o),roles:s,behaviorSignals:a,candidateUnits:r.length,sourceCharacters:r.reduce((l,c)=>l+(c.kind==="source"?c.source.length:0),0),anchors:r.map(l=>({relativePath:l.relativePath,line:l.kind==="source"?l.focusLine:0,ownerShort:l.kind==="source"?l.ownerShort:null,roles:[...l.roles],behaviorSignals:l.kind==="source"?[...l.behavior?.signals??[]]:[]})),drillCommand:zD(e,r)}}).sort((i,r)=>r.candidateUnits-i.candidateUnits||r.sourceCharacters-i.sourceCharacters||i.scope.localeCompare(r.scope)||i.id.localeCompare(r.id))}function zD(e,t){let n=ut(t.flatMap(o=>o.reasons.filter(s=>s.startsWith("search:")).map(s=>s.slice(7)))),i=ta(t[0].relativePath);if(n.length>0&&t.every(o=>o.kind==="source"&&o.roles.includes("search"))){let o=["codebaseiq inspect"];for(let s of n)o.push(`--search ${_t(s)}`);return o.push(`--scope ${_t(i)}`,"--full"),e.view==="behavior"&&o.push("--view behavior"),o.join(" ")}let r=t.filter(o=>o.kind==="source");if(r.length>0&&r.length<=24){let o=["codebaseiq inspect"];for(let s of r)o.push(`--at ${_t(`${s.relativePath}:${s.focusLine+1}`)}`);return e.view==="behavior"&&o.push("--view behavior"),o.join(" ")}return t.length===1&&t[0].kind==="path"?t[0].exactFollowup:Eh(e,!0)}function GD(e,t,n){let i=`search:${e.pattern}`,r=t.filter(a=>a.reasons.includes(i)).length,o=new Set(n),s=t.filter(a=>a.reasons.includes(i)&&o.has(a)).length;return{...e,candidateUnits:r,selectedUnits:s,omittedUnits:r-s}}function KD(e){let t={};for(let n of e)for(let i of n.roles)t[i]=(t[i]??0)+1;return t}function qD(e,t,n,i){let r=e.map(s=>kc(s,i).channel),o=t.map(s=>kc(s,i).channel);return Object.fromEntries(Object.keys(n).map(s=>{let a=r.filter(c=>c===s).length,l=o.filter(c=>c===s).length;return[s,{candidateUnits:a,returnedUnits:l,omittedUnits:a-l,maxUnits:n[s]}]}))}function WD(e){return!!(e&&e.skippedUnreadablePaths.length===0&&e.skippedOversizedPaths.length===0)}function VD(e,t,n){let i=new Map;for(let r of t){let o=ta(r.relativePath),s=i.get(o)??{matchingLines:0,returnedMatches:0};s.matchingLines+=r.matchingLines,s.returnedMatches+=r.returnedMatches,i.set(o,s)}return[...i.entries()].map(([r,o])=>({scope:r,...o,exactFollowup:Rh(e,r||n)})).sort((r,o)=>o.matchingLines-r.matchingLines||o.returnedMatches-r.returnedMatches||r.scope.localeCompare(o.scope))}function ta(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}function Rh(e,t){return`codebaseiq inspect --search ${_t(e)}${t?` --scope ${_t(t)}`:""} --full`}function Eh(e,t){let n=["codebaseiq inspect"];for(let i of e.searches)n.push(`--search ${_t(i)}`);for(let i of e.symbols)n.push(`--symbol ${_t(i)}`);for(let i of e.locations)n.push(`--at ${_t(i)}`);return e.scope&&n.push(`--scope ${_t(e.scope)}`),e.context!==xh&&n.push(`--context ${e.context}`),e.evidence.parts&&n.push(`--include ${_t(e.evidence.parts.join(","))}`),t&&n.push("--full"),e.view==="behavior"&&n.push("--view behavior"),n.join(" ")}function hh(e,t,n,i,r,o,s){Zi(e,t,{...n,unitType:null,unitStartLine:n.startLine,unitEndLine:n.endLine+n.omittedLines},i,`${i}:${r.shortName}`,n.symbol,n.shortName,o,s,[n.focusLine],r.symbol)}function yh(e,t,n,i,r,o,s,a,l){let c=`${i} -> ${r}`,u=Ce(e,i).filter(h=>h.sourcePath===r),d=ie(e,i),m=JD(d,u,r),f=m===null?null:Es(e,i,m,Math.min(s,4));if(f){Zi(e,t,{...f,unitType:null,unitStartLine:f.startLine,unitEndLine:f.endLine,omittedLines:0},n,`${n}:${c}`,null,null,a,l,[f.focusLine],o);return}let p=`codebaseiq inspect --search ${_t(Ih(r))} --scope ${_t(i)}`,g=t.find(h=>h.kind==="path"&&h.relativePath===i&&h.relationship===c);if(g){g.roles=ut([...g.roles,n]),g.reasons=ut([...g.reasons,`${n}:${c}`]),g.symbols=ut([...g.symbols,o]),g.priority=Math.min(g.priority,a);return}t.push({kind:"path",roles:[n],relativePath:i,relationship:c,reasons:[`${n}:${c}`],symbols:[o],exactFollowup:p,priority:a,sequence:l})}function JD(e,t,n){let i=ut(t.flatMap(l=>[l.importedName,l.localName??""]).filter(l=>l.length>1)),r=Ih(n).replace(/\.[^.]+$/u,""),o=ut([...i,r]).filter(Boolean),s=/\b(?:from|import|include|require|use)\b/u,a=e.findIndex(l=>s.test(l)&&o.some(c=>l.includes(c)));return a>=0?a:null}function Zi(e,t,n,i,r,o,s,a,l,c=[n.focusLine],u){let d=t.find(m=>m.kind==="source"&&m.relativePath===n.relativePath&&m.startLine<=n.endLine&&n.startLine<=m.endLine);if(d){let m=Math.min(d.startLine,n.startLine),f=Math.max(d.endLine,n.endLine);d.startLine=m,d.endLine=f,d.source=ie(e,n.relativePath).slice(m,f+1).join(`
74
+ `),d.focusLine=Math.min(d.focusLine,n.focusLine),d.focusLines=Sh([...d.focusLines,...c]),d.unitStartLine=Math.min(d.unitStartLine,n.unitStartLine),d.unitEndLine=Math.max(d.unitEndLine,n.unitEndLine),d.omittedLines=Math.max(d.omittedLines,n.omittedLines),d.reasons=ut([...d.reasons,r]),d.roles=ut([...d.roles,i]),d.symbols=ut([...d.symbols,...u?[u]:[]]),!d.ownerSymbol&&o&&(d.ownerSymbol=o),!d.ownerShort&&s&&(d.ownerShort=s),d.priority=Math.min(d.priority,a);return}t.push({kind:"source",...n,reasons:[r],focusLines:Sh(c),ownerSymbol:o,ownerShort:s,roles:[i],symbols:u?[u]:[],priority:a,sequence:l})}function YD(e){if(e.kind==="path"){let{priority:o,sequence:s,...a}=e;return{...a,id:bh(a)}}let{priority:t,sequence:n,bindingClosure:i,...r}=e;return{...r,id:bh(r),omittedCharacters:0}}function XD(e){let{kind:t,id:n,roles:i,symbols:r,omittedCharacters:o,behavior:s,runtimeFacts:a,...l}=e;return l}function bh(e){return Ch("sha256").update(JSON.stringify(e)).digest("hex").slice(0,16)}function ZD(e){let t=e.match(/^(.+\.\w+):(\d+)$/u);if(!t)return null;let n=Number(t[2]);return Number.isSafeInteger(n)&&n>0?{path:t[1],line:n}:null}function Nc(e){return ut((e??[]).map(t=>t.trim()).filter(Boolean))}function ut(e){return[...new Set(e)]}function Sh(e){return ut(e).sort((t,n)=>t-n)}function QD(e){return e.length===0?0:e.split(`
75
+ `).length}function wh(e,t){if(e.kind==="path")return e.relationship.length+e.exactFollowup.length;let n="bindingClosure"in e?uf(e.bindingClosure):0,i=(e.runtimeFacts??[]).reduce((r,o)=>r+o.action.length+o.derivation.rule.length+o.keyParts.reduce((s,a)=>s+a.name.length+a.value.length+4,0)+24,0);return t!=="behavior"?e.source.length+n:e.behavior?e.behavior.lines.reduce((r,o)=>r+o.text.length+o.signals.join(",").length+12,0)+e.behavior.testCases.reduce((r,o)=>r+o.length+2,0)+i+n:e.source.length+n+i}function Ih(e){return e.split("/").at(-1)??e}function _t(e){return`'${e.replaceAll("'","'\\''")}'`}function qn(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new RangeError(`${t} must be a positive safe integer; received ${e}`);return e}function vh(e,t){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`${t} must be a non-negative safe integer; received ${e}`);return e}import{basename as eP}from"path";function tP(e,t){let n=t.className,i=rt(e,n);return i.match?i.total>1?{kind:"ambiguous",query:n,total:i.total,candidates:[Lh(i.match),...i.candidates]}:{kind:"matched",query:n,owner:iP(i.match),methods:nP(e,i.match)}:{kind:"missing",query:n,suggestions:Zo(e,n,5)}}function nP(e,t){let n=re(t.symbol),r=new U(e).definitionsForFile(t.relativePath).filter(l=>it(l.symbol)),o=r.filter(l=>l.parentTypeName===n||l.symbol.includes(n)),a=(o.length>0?o:rP(eP(t.relativePath))===n?r.filter(l=>l.symbol.includes("<invalid-global-code>")):[]).map(l=>({startLine:l.startLine,endLine:l.endLine,name:re(l.symbol)}));return ye(t.relativePath)!=="clojure"?a:sP(a,oP(e,t))}function Lh(e){return{symbol:e.symbol,shortName:k(e.symbol),relativePath:e.relativePath,startLine:e.startLine}}function iP(e){return{...Lh(e),endLine:e.endLine}}function rP(e){return e.replace(/\.[^.]+$/,"")}function oP(e,t){let n=re(t.symbol);return n?(ee(e,t.relativePath)?.clojureMembers??[]).filter(i=>i.ownerName===n).map(i=>({startLine:i.startLine,endLine:i.endLine,name:i.memberName})):[]}function sP(e,t){let n=new Map;for(let i of[...e,...t])n.set(`${i.name}:${i.startLine}:${i.endLine}`,i);return[...n.values()].sort((i,r)=>i.startLine-r.startLine||i.endLine-r.endLine)}import{createHash as iM}from"crypto";var AY={exact:"Direct compiler or source evidence establishes this relationship within the provider's reported coverage.",derived:"A deterministic analysis computed this relationship from reported input facts; it was not directly observed.",candidate:"Ambiguous or heuristic evidence identifies a lead that requires exact graph or source confirmation.",mixed:"The relationship combines evidence of different strengths; its constituent methods and strengths remain disclosed.",unknown:"The relationship has no calibrated evidence strength and cannot support a stronger claim than its raw observation."},aP=[{id:"general-interprocedural-value-flow",families:["dataflow"],capability:"Whole-program definition-use flow through arbitrary calls and returns is unavailable.",consequence:"Missing dataflow edges cannot establish that a value never crosses an unmodeled call.",recoverWith:["value-flow","dependence-slice","inspect","code"]},{id:"heap-aliasing",families:["dataflow","state"],capability:"Heap points-to and cross-instance alias analysis are unavailable.",consequence:"Missing field or state edges cannot establish that two references never reach the same object.",recoverWith:["value-flow","dependence-slice","inspect","code"]},{id:"exceptional-flow",families:["execution","dataflow","temporal"],capability:"Interprocedural exception propagation and finally completion flow are unavailable.",consequence:"Normal-path reachability and ordering do not establish behavior after a throw or rejection.",recoverWith:["dependence-slice","inspect","code"]},{id:"reflection",families:["execution","runtime","identity","dependencies"],capability:"Reflective lookup, dynamic loading, and name-computed invocation are unavailable without exact evidence.",consequence:"Missing static edges cannot establish that a construct is unreachable through reflection.",recoverWith:["search","inspect","code"]},{id:"generated-dispatch",families:["execution","runtime","identity"],capability:"Dispatch tables or names created only by generated or unavailable source are unavailable.",consequence:"Missing dispatch edges cannot establish that no generated consumer exists.",recoverWith:["search","inspect","code"]},{id:"unsupported-framework-adapters",families:["runtime","dataflow","state","temporal"],capability:"Framework runtime crossings without a registered source adapter are unavailable.",consequence:"Missing boundary edges cannot establish that no producer, consumer, state effect, or ordering exists.",recoverWith:["search","inspect","code"]}];function lP(e){let t=new Set(e);return aP.filter(n=>n.families.some(i=>t.has(i)))}function Dh(e){return lP(e).map(t=>`[${t.id}] ${t.capability} ${t.consequence} Recover selected paths with: ${t.recoverWith.map(n=>`codebaseiq ${n}`).join(", ")}.`)}var cP=["incoming","outgoing","both"];function Me(e,t,n,i={}){return{family:e,subtype:t,...i.match?{match:i.match}:{},directions:cP,evidenceStrengths:i.strengths??["exact","derived","mixed"],supportCeiling:i.supportCeiling??"partial",establishes:n,nonClaims:i.nonClaims??[],recoverWith:i.recoverWith??["inspect","code"]}}var uP=["predicate-consequence","predicate-alternative","predicate-fallthrough","predicate-case","predicate-default","predicate-return","predicate-throw","loop-iteration","loop-exit","exception-handler","finally-cleanup","handler-return","handler-throw"],dP=["captured-value-to-state","constant-to-state","expression-to-state","property-to-state","return-to-state","value-to-state"],mP=["await-completion-before","awaits-completion","inside-lock-scope","lexical-successor"],fP=[{id:"indexed-program-identity",label:"SCIP/compiler identity and source ownership",requirements:["indexed-graph"],relations:[Me("execution","call","The source construct may call the resolved target.",{nonClaims:["Static may-call reachability does not prove that an invocation occurred at runtime."],recoverWith:["call-graph","inspect","code"]}),Me("execution","result-callback","The referenced callable can produce the result consumed by this path.",{nonClaims:["A callback relationship does not prove invocation order or runtime selection."],recoverWith:["call-graph","inspect","code"]}),Me("contract","uses-contract-symbol","The source construct refers to the identified contract symbol.",{supportCeiling:"exact",nonClaims:["Contract identity does not prove runtime invocation or behavioral conformance."],recoverWith:["hierarchy","inspect","code"]}),Me("identity","references","The occurrence resolves to the identified compiler-owned symbol.",{supportCeiling:"exact",nonClaims:["A reference does not establish execution or value transfer."],recoverWith:["refs","trace","inspect"]}),Me("ownership","contains","The owner contains the identified program construct.",{supportCeiling:"exact",nonClaims:["Structural containment does not establish runtime lifetime or sharing scope."],recoverWith:["outline","inspect"]}),Me("ownership","contains-","The owner contains the identified program construct.",{match:"prefix",supportCeiling:"exact",nonClaims:["Structural containment does not establish runtime lifetime or sharing scope."],recoverWith:["outline","inspect"]}),Me("ownership","owns-","The owner owns the identified source or runtime observation.",{match:"prefix",supportCeiling:"exact",nonClaims:["Observation ownership does not establish singleton lifetime or exclusive ownership."],recoverWith:["inspect","code"]}),Me("dependencies","imports","The source file or module statically imports the indexed target.",{nonClaims:["An import does not establish that imported code executes."],recoverWith:["imports","deps","code"]}),Me("dependencies","imports-external","The source region statically imports an external package.",{nonClaims:["An external import does not establish which package behavior executes."],recoverWith:["imports","code"]})]},{id:"runtime-boundary-join",label:"source-grounded runtime-boundary joins",requirements:["indexed-graph","source-facts"],relations:[Me("runtime","runtime-handoff","A producer and consumer share a source-grounded runtime rendezvous.",{strengths:["exact","derived","candidate","mixed"],nonClaims:["A candidate or unresolved join does not prove a runtime handoff."],recoverWith:["evidence","inspect","code"]}),Me("runtime","discriminator-dispatch","A serialized discriminator selects the reported consumer.",{strengths:["exact","derived","mixed"],nonClaims:["The dispatch edge does not prove delivery, retry, or successful handling."],recoverWith:["evidence","inspect","code"]}),Me("dataflow","serialized-discriminator-transfer","The producer serializes the discriminator consumed by dispatch.",{strengths:["exact","derived","mixed"],nonClaims:["This edge does not establish the flow of every payload field."],recoverWith:["value-flow","inspect","code"]}),Me("temporal","enqueue-before-consume","The reported enqueue precedes a possible consume through the queue.",{strengths:["exact","derived","mixed"],nonClaims:["Queue order does not establish delivery time, uniqueness, retry count, or durability."],recoverWith:["evidence","inspect","code"]})]},{id:"parser-control-dependence",label:"parser-proved intraprocedural control dependence",requirements:["indexed-graph","source-facts"],relations:[...uP.map(e=>Me("execution",e,"The outcome is control-dependent on the reported predicate or handler.",{strengths:["exact"],nonClaims:["Local control dependence does not establish that the containing function executes."],recoverWith:["dependence-slice","inspect","code"]})),Me("execution","returns","The selected construct contains the reported return terminal.",{strengths:["exact"],nonClaims:["A local return terminal does not establish that the containing callable executes."],recoverWith:["inspect","code"]}),Me("execution","throws","The selected construct contains the reported throw terminal.",{strengths:["exact"],nonClaims:["A local throw terminal does not establish propagation, handling, or callable execution."],recoverWith:["inspect","code"]})]},{id:"bounded-static-value-flow",label:"compiler callsites and bounded static value evaluation",requirements:["indexed-graph","source-facts"],relations:[...["argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result"].map(e=>Me("dataflow",e,"The reported value may reach the target through the evidenced callsite transfer.",{strengths:["exact","derived","mixed"],nonClaims:["This provider does not establish general local definition-use, alias, field, or heap flow."],recoverWith:["value-flow","dependence-slice","inspect","code"]}))]},{id:"typescript-local-dependence",label:"TypeScript compiler identities, control-flow graph, and reaching definitions",requirements:["typescript-semantic"],relations:[Me("dataflow","definition-to-use","The definition reaches the reported read on a feasible local control-flow path.",{strengths:["exact"],nonClaims:["Local reaching definitions do not establish heap aliasing, exceptional flow, or the runtime order of closure invocation."],recoverWith:["value-flow","dependence-slice","inspect","code"]}),Me("dataflow","value-to-definition","The reported right-hand-side read supplies the assigned local definition.",{strengths:["exact"],nonClaims:["A local assignment edge does not establish field or heap points-to flow."],recoverWith:["value-flow","dependence-slice","inspect","code"]}),Me("dataflow","closure-capture","The nested callable reads the reported binding from an enclosing callable.",{strengths:["candidate"],supportCeiling:"candidate",nonClaims:["Closure capture does not establish whether or when the nested callable executes."],recoverWith:["call-graph","inspect","code"]}),Me("dataflow","field-definition-to-use","The reported same-owner field definition can reach the field read.",{strengths:["exact","candidate"],nonClaims:["Field-name identity does not establish whole-program heap aliasing or cross-instance flow."],recoverWith:["value-flow","dependence-slice","inspect","code"]}),Me("execution","control-dependence","Execution of the reported statement depends on the outcome of the predicate.",{strengths:["exact"],nonClaims:["Intraprocedural control dependence does not establish that the containing callable executes."],recoverWith:["dependence-slice","inspect","code"]})]},{id:"parser-state-temporal",label:"parser-proved local state and temporal facts",requirements:["indexed-graph","source-facts"],relations:[...dP.map(e=>Me("dataflow",e,"The reported source value is assigned into the identified state resource.",{strengths:["exact"],nonClaims:["The edge does not establish alias, heap, or later read flow."],recoverWith:["value-flow","inspect","code"]})),...["writes-resource","deletes-resource","reads-resource","enqueues-resource","consumes-resource"].map(e=>Me("state",e,"The reported construct performs the named operation on the identified resource.",{strengths:["exact"],nonClaims:["A state operation does not establish transactionality, durability, or exclusive ownership."],recoverWith:["evidence","inspect","code"]})),...mP.map(e=>Me("temporal",e,"The reported source constructs have the named local ordering relationship.",{strengths:["exact"],nonClaims:["Local source order does not establish cross-process happens-before or durable completion."],recoverWith:["evidence","inspect","code"]}))]}];function Ph(e,t){let n=fP.flatMap(i=>i.relations.filter(r=>r.family===e&&(r.match==="prefix"?t.startsWith(r.subtype):t===r.subtype)).map(r=>({provider:i,relation:r})));if(n.length>1)throw new Error(`Ambiguous graph relation provider for ${e}/${t}: ${n.map(i=>i.provider.id).join(", ")}`);return n[0]??null}var Gt=["execution","runtime","dataflow","state","temporal","contract","identity","ownership","dependencies"];var Th=["call","contract-symbol","import","reference","runtime-boundary"],pP={call:[{family:"control",subtype:"call"}],"contract-symbol":[{family:"contract",subtype:"uses-contract-symbol"}],import:[{family:"identity",subtype:"imports"}],reference:[{family:"identity",subtype:"references"}]},gP={"structural-membership":[{family:"identity",subtype:"contains"}],"boundary-observation":[{family:"identity",subtype:"owns-runtime-observation"}],"external-import":[{family:"identity",subtype:"imports-external"}]};function Fh(e){if(e.kind!=="runtime-boundary")return Mh(pP[e.kind]);let t=e.fromBoundaryParticipant?.protocol??e.toBoundaryParticipant?.protocol,n={crossesRuntimeBoundary:!0,...t?{protocol:t}:{},...e.runtimeBoundaryKey?{runtimeKey:e.runtimeBoundaryKey}:{}},i=[{family:"control",subtype:"runtime-handoff",context:n}];return e.evidence==="runtime-boundary:carrier.discriminator"&&(i.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}:{}}}),i.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"&&i.push({family:"temporal",subtype:"enqueue-before-consume",context:{...n},attributes:{producerAction:e.fromBoundaryParticipant.action,consumerAction:e.toBoundaryParticipant.action,retryPolicy:"unknown"}}),i}function na(e){return Mh(gP[e])}function Mh(e){return e.map(t=>({...t,...t.context?{context:{...t.context}}:{},...t.attributes?{attributes:{...t.attributes}}:{}}))}import{join as HP}from"path";import{createRequire as hP}from"module";import{resolve as eo}from"path";var yP=hP(import.meta.url),Qr;function Nh(e,t,n){let i=bP();if(!i)return Oc("The TypeScript compiler runtime is unavailable.");let r=SP(i,e,t),o=r.getSourceFile(eo(t))??r.getSourceFile(t);if(!o)return Oc(`The TypeScript compiler did not materialize ${t}.`);let s={ts:i,sourceFile:o,checker:r.getTypeChecker(),points:new Map,edges:new Map,unsupported:new Set,nextCfgId:0},a=CP(i,o,n);if(a.length===0)return Oc("No function-like construct intersects the selected source range.");let l=new Map(a.map(d=>[d,xP(o,d)])),c=a.map(d=>EP(s,d,RP(i,d,l),l.get(d)));for(let d of c)wP(s,d),PP(s,d),MP(s,d);NP(s,c);let u=[...s.unsupported].sort();return{points:[...s.points.values()].map(({node:d,...m})=>m).sort(jP),edges:[...s.edges.values()].sort((d,m)=>d.id.localeCompare(m.id)),coverage:{status:u.length===0?"complete":"partial",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:u}}}function bP(){if(Qr!==void 0)return Qr;try{Qr=yP("typescript")}catch{Qr=lm()?.ts??null}return Qr}function SP(e,t,n){let i=eo(n),r={target:e.ScriptTarget.ESNext,module:e.ModuleKind.NodeNext,moduleResolution:e.ModuleResolutionKind.NodeNext,skipLibCheck:!0,noResolve:!0},o=e.createSourceFile(i,t,r.target,!0,vP(e,i)),s=e.createCompilerHost(r,!0),a=s.getSourceFile.bind(s),l=s.readFile.bind(s),c=s.fileExists.bind(s);return s.getSourceFile=(u,d,m,f)=>eo(u)===i?o:a(u,d,m,f),s.readFile=u=>eo(u)===i?t:l(u),s.fileExists=u=>eo(u)===i||c(u),e.createProgram([i],r,s)}function vP(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 CP(e,t,n){let i=[],r=o=>{if(kh(e,o)){let s=t.getLineAndCharacterOfPosition(o.getStart(t)).line,a=t.getLineAndCharacterOfPosition(o.getEnd()).line;(!n||s<=n.endLine&&a>=n.startLine)&&i.push(o)}o.forEachChild(r)};return t.forEachChild(r),i.sort((o,s)=>o.getStart(t)-s.getStart(t))}function kh(e,t){return e.isFunctionLike(t)&&"body"in t&&t.body!==void 0}function xP(e,t){return`callable:${encodeURIComponent(e.fileName)}:${t.getStart(e)}:${t.getEnd()}`}function RP(e,t,n){for(let i=t.parent;i;i=i.parent)if(kh(e,i)&&n.has(i))return n.get(i);return null}function EP(e,t,n,i){let r=new Map,o=Ze(e,r,"exit",null),s=t.body,a=o.id;if(s&&e.ts.isBlock(s))a=$c(e,r,[...s.statements],o.id,{breakTarget:null,continueTarget:null});else if(s){let c=Ze(e,r,"statement",s);_e(r,c.id,o.id),a=c.id}let l=Ze(e,r,"entry",t);return _e(r,l.id,a),{id:i,node:t,parentId:n,cfg:r,entryId:l.id,exitId:o.id}}function $c(e,t,n,i,r){let o=i;for(let s=n.length-1;s>=0;s-=1)o=vi(e,t,n[s],o,r);return o}function vi(e,t,n,i,r){let o=e.ts;if(o.isBlock(n))return $c(e,t,[...n.statements],i,r);if(o.isIfStatement(n)){let a=Ze(e,t,"predicate",n.expression),l=vi(e,t,n.thenStatement,i,r),c=n.elseStatement?vi(e,t,n.elseStatement,i,r):i;return _e(t,a.id,l),_e(t,a.id,c),a.id}if(o.isWhileStatement(n)){let a=Ze(e,t,"predicate",n.expression),l=vi(e,t,n.statement,a.id,{breakTarget:i,continueTarget:a.id});return _e(t,a.id,l),_e(t,a.id,i),a.id}if(o.isDoStatement(n)){let a=Ze(e,t,"predicate",n.expression),l=vi(e,t,n.statement,a.id,{breakTarget:i,continueTarget:a.id});return _e(t,a.id,l),_e(t,a.id,i),l}if(o.isForStatement(n)){let a=Ze(e,t,"predicate",n.condition??n),l=n.incrementor?Ze(e,t,"statement",n.incrementor):null;l&&_e(t,l.id,a.id);let c=l?.id??a.id,u=vi(e,t,n.statement,c,{breakTarget:i,continueTarget:c});if(_e(t,a.id,u),n.condition&&_e(t,a.id,i),!n.initializer)return a.id;let d=Ze(e,t,"statement",n.initializer);return _e(t,d.id,a.id),d.id}if(o.isForInStatement(n)||o.isForOfStatement(n)){e.unsupported.add("for-in/for-of iterator assignment is conservatively represented without iterable element flow.");let a=Ze(e,t,"predicate",n.expression),l=Ze(e,t,"statement",n.initializer),c=vi(e,t,n.statement,a.id,{breakTarget:i,continueTarget:a.id});return _e(t,a.id,l.id),_e(t,a.id,i),_e(t,l.id,c),a.id}if(o.isSwitchStatement(n)){e.unsupported.add("switch fallthrough is represented conservatively; discriminant-to-case value refinement is unsupported.");let a=Ze(e,t,"predicate",n.expression),l=i,c=[];for(let u=n.caseBlock.clauses.length-1;u>=0;u-=1){let d=n.caseBlock.clauses[u];l=$c(e,t,[...d.statements],l,{...r,breakTarget:i}),c.push(l)}for(let u of c)_e(t,a.id,u);return _e(t,a.id,i),a.id}if(o.isReturnStatement(n)||o.isThrowStatement(n)){let a=Ze(e,t,"statement",n),l=[...t.values()].find(c=>c.kind==="exit");return _e(t,a.id,l.id),a.id}if(o.isBreakStatement(n)){let a=Ze(e,t,"statement",n);return r.breakTarget||e.unsupported.add("A break statement could not be attached to a structured target."),_e(t,a.id,r.breakTarget??i),a.id}if(o.isContinueStatement(n)){let a=Ze(e,t,"statement",n);return r.continueTarget||e.unsupported.add("A continue statement could not be attached to a structured target."),_e(t,a.id,r.continueTarget??i),a.id}if(o.isTryStatement(n)){e.unsupported.add("Exceptional control-flow and finally completion are not included in the local compiler CFG.");let a=Ze(e,t,"statement",n);return a.invalidatesAllDefinitions=!0,_e(t,a.id,i),a.id}let s=Ze(e,t,"statement",n);return _e(t,s.id,i),s.id}function Ze(e,t,n,i){let r={id:`cfg:${e.nextCfgId++}`,kind:n,ast:i,successors:new Set,predecessors:new Set,definitions:[],uses:[],displayPoint:null,invalidatesAllDefinitions:!1};return t.set(r.id,r),r}function _e(e,t,n){e.get(t).successors.add(n),e.get(n).predecessors.add(t)}function wP(e,t){let n=t.cfg.get(t.entryId);for(let i of t.node.parameters){let r=Ci(e,i.name);if(!r){e.unsupported.add("Destructured parameter definition-use is not implemented.");continue}n.definitions.push({point:xi(e,r.node,"parameter-definition",r.symbolKey,r.name,t.id),rhsUseIds:[]})}for(let i of t.cfg.values())!i.ast||i.kind==="entry"||i.kind==="exit"||(i.kind==="predicate"&&(i.displayPoint=xi(e,i.ast,"predicate",null,"predicate",t.id)),IP(e,t,i,i.ast),!i.displayPoint&&i.definitions.length===0&&i.uses.length===0&&(i.displayPoint=xi(e,i.ast,"statement",null,_P(e,i.ast),t.id)))}function IP(e,t,n,i){let r=e.ts;if(r.isTryStatement(i))return;let o=s=>{if(!(s!==i&&r.isFunctionLike(s))){if(r.isVariableDeclaration(s)){let a=s.initializer?ia(e,t.id,s.initializer,n):[];n.uses.push(...a);let l=Ci(e,s.name);l?n.definitions.push({point:xi(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:a.map(c=>c.point.id)}):(n.invalidatesAllDefinitions=!0,e.unsupported.add("Destructured variable reaching definitions are not implemented."));return}if(r.isBinaryExpression(s)&&Oh(r,s.operatorToken.kind)){let a=ia(e,t.id,s.right,n);s.operatorToken.kind!==r.SyntaxKind.EqualsToken&&a.push(...ia(e,t.id,s.left,n)),n.uses.push(...a);let l=Ci(e,s.left);l?n.definitions.push({point:xi(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:a.map(c=>c.point.id)}):(n.invalidatesAllDefinitions=!0,e.unsupported.add("Dynamic or destructured assignment targets are not included in reaching definitions."));return}if((r.isPrefixUnaryExpression(s)||r.isPostfixUnaryExpression(s))&&(s.operator===r.SyntaxKind.PlusPlusToken||s.operator===r.SyntaxKind.MinusMinusToken)){let a=ia(e,t.id,s.operand,n);n.uses.push(...a);let l=Ci(e,s.operand);l&&n.definitions.push({point:xi(e,l.node,"definition",l.symbolKey,l.name,t.id),rhsUseIds:a.map(c=>c.point.id)});return}if(!(r.isFunctionDeclaration(s)||r.isClassDeclaration(s)||r.isInterfaceDeclaration(s))){if(_h(e,s)){let a=Bh(e,t.id,s);a&&n.uses.push(a),r.isPropertyAccessExpression(s)&&o(s.expression);return}s.forEachChild(o)}}};o(i),n.uses=$h(n.uses)}function ia(e,t,n,i){let r=[],o=s=>{if(!e.ts.isFunctionLike(s)){if(e.ts.isBinaryExpression(s)&&Oh(e.ts,s.operatorToken.kind)){i.invalidatesAllDefinitions=!0,e.unsupported.add("Nested assignment expressions are not included in ordered local definition-use flow."),s.operatorToken.kind!==e.ts.SyntaxKind.EqualsToken&&o(s.left),o(s.right);return}if(_h(e,s)){let a=Bh(e,t,s);a&&r.push(a),e.ts.isPropertyAccessExpression(s)&&o(s.expression);return}s.forEachChild(o)}};return o(n),$h(r)}function _h(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&&LP(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)||DP(e.ts,t))}function LP(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 DP(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 Bh(e,t,n){let i=Ci(e,n);return i?{point:xi(e,i.node,"use",i.symbolKey,i.name,t),property:e.ts.isPropertyAccessExpression(n)}:null}function Ci(e,t){let n=e.ts;if(n.isIdentifier(t)){let i=Ah(e,t);return i?{node:t,symbolKey:i,name:t.text}:null}if(n.isPropertyAccessExpression(t)){let i=Ah(e,t.name);return i?{node:t,symbolKey:i,name:t.getText(e.sourceFile)}:null}return n.isParenthesizedExpression(t)||n.isAsExpression(t)||n.isTypeAssertionExpression(t)||n.isNonNullExpression(t)?Ci(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 Ah(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 i=n.valueDeclaration??n.declarations?.[0];return i?`symbol:${encodeURIComponent(i.getSourceFile().fileName)}:${i.getStart()}:${n.getName()}`:`symbol:${n.getName()}`}function xi(e,t,n,i,r,o){let s=t.getStart(e.sourceFile),a=t.getEnd(),l=e.sourceFile.getLineAndCharacterOfPosition(s),c=`flow-point:${encodeURIComponent(e.sourceFile.fileName)}:${s}:${a}:${n}:${encodeURIComponent(i??r)}`,u=e.points.get(c);if(u)return u;let d={id:c,kind:n,name:r,symbolKey:i,callableId:o,start:s,end:a,line:l.line,column:l.character,node:t};return e.points.set(c,d),d}function PP(e,t){let n=[...t.cfg.values()].flatMap(l=>l.definitions),i=new Map(n.map(l=>[l.point.id,l])),r=TP(n),o=new Map,s=new Map;for(let l of t.cfg.values())o.set(l.id,new Set),s.set(l.id,new Set);let a=!0;for(;a;){a=!1;for(let l of t.cfg.values()){let c=OP([...l.predecessors].map(m=>s.get(m))),u=new Set(c);l.invalidatesAllDefinitions&&u.clear();let d=FP(l.definitions);for(let m of d){for(let f of r.get(m.point.symbolKey)??[])u.delete(f.point.id);u.add(m.point.id)}jc(o.get(l.id),c)||(o.set(l.id,c),a=!0),jc(s.get(l.id),u)||(s.set(l.id,u),a=!0)}}for(let l of t.cfg.values()){let c=o.get(l.id);for(let u of l.uses){let d=l.definitions.filter(f=>f.point.symbolKey===u.point.symbolKey&&f.point.start<u.point.start&&!f.rhsUseIds.includes(u.point.id)).sort((f,p)=>p.point.start-f.point.start)[0],m=d?[d.point.id]:c;for(let f of m){let p=i.get(f);p.point.symbolKey===u.point.symbolKey&&to(e,"reaching-definition",p.point.id,u.point.id,"exact","A CFG path reaches this use without an intervening definition.")}}for(let u of l.definitions)for(let d of u.rhsUseIds)to(e,"value-source",d,u.point.id,"exact","This right-hand-side use supplies the new definition.")}}function TP(e){let t=new Map;for(let n of e){if(!n.point.symbolKey)continue;let i=t.get(n.point.symbolKey)??[];i.push(n),t.set(n.point.symbolKey,i)}return t}function FP(e){let t=new Map;for(let n of e)n.point.symbolKey&&t.set(n.point.symbolKey,n);return[...t.values()]}function MP(e,t){let n=AP(t);for(let i of t.cfg.values()){if(i.successors.size<2||!i.displayPoint)continue;let r=n.get(i.id);for(let o of i.successors)for(let s of n.get(o)??[]){if(r.has(s)||s===t.exitId)continue;let a=t.cfg.get(s),l=[...a.definitions.map(c=>c.point),...a.uses.map(c=>c.point),...a.displayPoint?[a.displayPoint]:[]];for(let c of BP(l))to(e,"control-dependence",i.displayPoint.id,c.id,"exact","The target postdominates a branch successor but does not postdominate the predicate.")}}}function AP(e){let t=[...e.cfg.keys()],n=new Set(t),i=new Map;for(let o of t)i.set(o,o===e.exitId?new Set([o]):new Set(n));let r=!0;for(;r;){r=!1;for(let o of e.cfg.values()){if(o.id===e.exitId)continue;let s=[...o.successors].map(l=>i.get(l)),a=new Set([o.id,...$P(s)]);jc(i.get(o.id),a)||(i.set(o.id,a),r=!0)}}return i}function NP(e,t){let n=new Map(t.map(s=>[s.id,s.parentId])),i=t.flatMap(s=>[...s.cfg.values()].flatMap(a=>a.definitions.map(l=>l.point))),r=new Map;for(let s of i){if(!s.symbolKey)continue;let a=r.get(s.symbolKey)??[];a.push(s),r.set(s.symbolKey,a)}let o=new Set([...e.edges.values()].filter(s=>s.kind==="reaching-definition").map(s=>s.toPointId));for(let s of t)for(let a of[...s.cfg.values()].flatMap(l=>l.uses)){if(!a.point.symbolKey||o.has(a.point.id))continue;let l=r.get(a.point.symbolKey)??[];for(let c of l)kP(c.callableId,a.point.callableId,n)?to(e,"closure-capture",c.id,a.point.id,"candidate","Compiler identity proves the captured binding, but invocation order can select among outer definitions."):a.property&&to(e,"field-definition-to-use",c.id,a.point.id,"candidate","Compiler identity matches the field; cross-callable receiver and execution order remain unresolved.")}[...e.edges.values()].some(s=>s.kind==="closure-capture")&&e.unsupported.add("Closure capture identity is known, but invocation order and intervening writes remain candidate flow."),[...e.edges.values()].some(s=>s.kind==="field-definition-to-use")&&e.unsupported.add("Cross-callable field flow lacks receiver points-to and invocation-order analysis.")}function kP(e,t,n){for(let i=n.get(t)??null;i;i=n.get(i)??null)if(i===e)return!0;return!1}function to(e,t,n,i,r,o){let s=`local-flow-edge:${t}:${encodeURIComponent(n)}:${encodeURIComponent(i)}`;e.edges.set(s,{id:s,kind:t,fromPointId:n,toPointId:i,strength:r,reason:o})}function Oh(e,t){return t>=e.SyntaxKind.FirstAssignment&&t<=e.SyntaxKind.LastAssignment}function _P(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 $h(e){return[...new Map(e.map(t=>[t.point.id,t])).values()]}function BP(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function OP(e){return new Set(e.flatMap(t=>[...t]))}function $P(e){return e.length===0?new Set:new Set([...e[0]].filter(t=>e.slice(1).every(n=>n.has(t))))}function jc(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function jP(e,t){return e.start-t.start||e.kind.localeCompare(t.kind)||e.id.localeCompare(t.id)}function Oc(e){return{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[e]}}}var UP=Fi("typescript-local-flow",{clearGroups:["whole-project","source-file","semantic-provider"]});function Hc(e,t,n,i){if(!Jo(t))return null;let r=`${t}\0${n}\0${i}`;return UP.get(e,r,()=>{let o=se(e,t);return o?Nh(o,HP(e.config.projectRoot,t),{startLine:n,endLine:i}):{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[`Current source is unavailable for ${t}.`]}}})}function zP(e,t=new Map){let n=new Map,i=new Map,r=[];for(let o of e.transfers){if(!e.caller)continue;let s=ra(e.caller,o.callerPosition),a=ra(e.callee,o.calleePosition);no(n,s),no(n,a),zc(i,e.caller,s),zc(i,e.callee,a);let l=dt("edge","data-transfer",o.proof.file,String(o.proof.startLine),String(o.callerPosition),String(o.calleePosition));i.set(l,{id:l,kind:"data-transfer",fromNodeId:s.id,toNodeId:a.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:"argument-to-parameter",attributes:{argumentText:o.argumentText,callerPosition:o.callerPosition,calleePosition:o.calleePosition}}],evidence:[{method:"compiler-callsite-direct-parameter-transfer",strength:"exact",identity:`${e.caller.symbol}:${o.callerPosition} -> ${e.callee.symbol}:${o.calleePosition}`,location:{file:o.proof.file,line:o.proof.startLine,endLine:o.proof.endLine}}]})}return e.unknown.forEach((o,s)=>{let a=ra(e.callee,o.calleePosition);no(n,a),zc(i,e.callee,a);let l=t.get(o.calleePosition);if(l&&eT(l)){QP(i,n,e,o.calleePosition,o.argumentText,l);return}let c=XP(e,o.calleePosition,o.argumentText);no(n,c);let u=dt("edge","data-transfer-unsupported",o.proof.file,String(o.proof.startLine),String(o.calleePosition),String(s));i.set(u,{id:u,kind:"data-transfer",fromNodeId:c.id,toNodeId:a.id,directed:!0,disposition:"unsupported",semantics:[{family:"data",subtype:"argument-to-parameter",attributes:{argumentText:o.argumentText,calleePosition:o.calleePosition}}],evidence:[{method:"compiler-callsite-argument-expression",strength:"exact",identity:o.argumentText,location:{file:o.proof.file,line:o.proof.startLine,endLine:o.proof.endLine}}]}),r.push({id:dt("frontier","data-transfer",u),kind:"data-transfer",direction:"unresolved",fromNodeIds:[c.id],edgeIds:[u],memberNodeIds:[a.id],memberCount:1,disposition:"unsupported",reason:l?.derivation.rule??o.reason,expansion:null})}),{nodes:[...n.values()],edges:[...i.values()],frontiers:r,blindSpots:[]}}function Hh(e,t,n=[]){let i=Uh(),r=new Map,o=new Set;for(let s of t){if(s.kind!=="call"||!s.fromSymbol||!s.toSymbol||s.line===null)continue;let a=YP(r,e,s.toFile,s.toSymbol);if(!a)continue;let l=Dm(e,a),c=l.sites.filter(g=>g.file===s.fromFile&&g.startLine<=s.line&&g.endLine>=s.line&&g.caller?.symbol===s.fromSymbol);if(c.length!==1){let g=l.unresolved.find(h=>h.file===s.fromFile&&h.line===s.line);g&&i.blindSpots.push(`Parameter flow unresolved at ${s.fromFile}:${s.line+1}: ${g.reason}.`);continue}let u=c[0],d=`${u.file}\0${u.callNode.startIndex}\0${u.callNode.endIndex}\0${a.symbol}`;if(o.has(d))continue;o.add(d);let m=Pm(e,u),f=ae(e,u.file)?.rootNode,p=new Map;if(f)for(let g of m.unknown){let h=hm({db:e,file:u.file,root:f},u.arguments[g.calleePosition]);h&&p.set(g.calleePosition,h)}jh(i,zP(m,p)),m.caller&&VP(u.callNode)&&JP(i,m,u.callNode)}for(let s of n){if(!s.location||!["source-construct","symbol"].includes(s.kind))continue;let a=s.location.endLine??s.location.line,l=Hc(e,s.location.file,s.location.line,a);if(l){jh(i,GP(s,l.points,l.edges));for(let c of l.coverage.unsupported)i.blindSpots.push(`TypeScript local flow is partial for ${s.location.file}:${s.location.line+1}-${a+1}: ${c} Recover with: codebaseiq inspect --at '${s.location.file}:${s.location.line+1}-${a+1}' --view behavior.`)}}return i.blindSpots=[...new Set(i.blindSpots)].sort(),i}function GP(e,t,n){let i=Uh(),r=new Map,o=new Map,s=new Map,a=e.location.file;for(let l of t){let c=KP(e,a,l);s.set(l.id,c.id),r.set(c.id,c),qP(o,e,c)}for(let l of n){let c=s.get(l.fromPointId),u=s.get(l.toPointId);if(!c||!u)continue;let d=WP(l),m=dt("edge","typescript-local-flow",a,l.id);o.set(m,{id:m,kind:l.kind==="control-dependence"?"control-dependence":"data-transfer",fromNodeId:c,toNodeId:u,directed:!0,disposition:"folded",semantics:[d],evidence:[{method:"typescript-compiler-cfg-reaching-definitions",strength:l.strength,identity:l.reason,location:r.get(c)?.location??e.location}]})}return i.nodes=[...r.values()],i.edges=[...o.values()],i}function KP(e,t,n){return{id:dt("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 qP(e,t,n){let i=dt("edge","local-flow-owner",t.id,n.id);e.has(i)||e.set(i,{id:i,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 WP(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 VP(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 JP(e,t,n){if(!t.caller)return;let i={id:dt("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}},r=dt("edge","return-to-call-result",t.callee.symbol,i.id),o=dt("edge","call-result-owner",t.caller.symbol,i.id);e.nodes.push(i),e.edges.push({id:r,kind:"data-transfer",fromNodeId:Gc(t.callee.symbol),toNodeId:i.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:i.location}]},{id:o,kind:"call-result-owner",fromNodeId:Gc(t.caller.symbol),toNodeId:i.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:i.location}]})}function Uh(){return{nodes:[],edges:[],frontiers:[],blindSpots:[]}}function jh(e,t){Uc(e.nodes,t.nodes),Uc(e.edges,t.edges),Uc(e.frontiers,t.frontiers),e.blindSpots.push(...t.blindSpots)}function Uc(e,t){let n=new Set(e.map(i=>i.id));for(let i of t)n.has(i.id)||(n.add(i.id),e.push(i))}function YP(e,t,n,i){let r=`${n}\0${i}`,o=e.get(r);if(o!==void 0)return o;let s=J(t,n).find(a=>a.symbol===i)??null;return e.set(r,s),s}function ra(e,t){return{id:iT(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 XP(e,t,n){return{id:dt("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 ZP(e,t,n){return{id:dt("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 QP(e,t,n,i,r,o){let s=ZP(n,i,o),a=ra(n.callee,i);no(t,s);let l=dt("edge","static-value-transfer",n.call.file,String(n.call.startLine),String(i));e.set(l,{id:l,kind:"data-transfer",fromNodeId:s.id,toNodeId:a.id,directed:!0,disposition:"folded",semantics:[{family:"data",subtype:tT(o),attributes:{argumentText:r,calleePosition:i,value:o.value,precision:o.precision,derivationRule:o.derivation.rule}}],evidence:nT(o,n)})}function eT(e){return e.derivation.kind!=="heuristic"&&e.precision!=="symbolic"&&e.precision!=="unknown"}function tT(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 nT(e,t){return(e.derivation.sourceSpans.length>0?e.derivation.sourceSpans:[t.call]).map(i=>({method:`static-value:${e.derivation.rule}`,strength:e.derivation.kind==="direct"?"exact":"derived",identity:e.derivation.inputFactIds.join(",")||e.value,location:{file:i.file,line:i.startLine,endLine:i.endLine}}))}function no(e,t){e.has(t.id)||e.set(t.id,t)}function zc(e,t,n){let i=dt("edge","parameter-owner",t.symbol,n.id);e.has(i)||e.set(i,{id:i,kind:"parameter-owner",fromNodeId:Gc(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 iT(e,t){return dt("parameter",e,String(t))}function Gc(e){return dt("symbol",e)}function dt(...e){return e.map(t=>encodeURIComponent(t)).join(":")}function zh(e,t){let n=new Map,i=new Map,r=new Map,o=new Set;for(let s of t){if(!s.location||!["source-construct","symbol"].includes(s.kind))continue;let a=s.location.endLine??s.location.line,l=yf(e,s.location.file,s.location.line,a);if(!l){o.add(`Control dependence unavailable for ${s.location.file}:${s.location.line+1}-${a+1}: no supported syntax tree or covering construct.`);continue}for(let c of l.facts){let u=Kc(s,c.controller),d=Kc(s,c.outcome);n.set(u.id,u),n.set(d.id,d),rT(i,s,u);let m=Ri("edge","control-dependence",u.id,d.id,c.subtype);i.set(m,{id:m,kind:"control-dependence",fromNodeId:u.id,toNodeId:d.id,directed:!0,disposition:"folded",semantics:[{family:"control",subtype:c.subtype,attributes:{...c.attributes}}],evidence:[{method:"parser-control-dependence",strength:"exact",identity:`${s.location.file}:${c.controller.startLine+1}-${c.outcome.startLine+1}`,location:{file:s.location.file,line:c.controller.startLine,endLine:c.controller.endLine}}]})}for(let c of l.terminals){let u=Kc(s,c);n.set(u.id,u);let d=c.label.startsWith("throw")||c.label.startsWith("raise")?"throw":"return",m=Ri("edge","control-terminal",s.id,u.id,d);i.set(m,{id:m,kind:"control-terminal",fromNodeId:s.id,toNodeId:u.id,directed:!0,disposition:"folded",semantics:[{family:"control",subtype:d==="throw"?"throws":"returns"}],evidence:[{method:"parser-terminal-statement",strength:"exact",identity:c.label,location:{file:s.location.file,line:c.startLine,endLine:c.endLine}}]})}for(let c of l.unsupported){let u=Ri("control-unsupported",s.location.file,String(c.startLine),String(c.endLine),c.reason);n.set(u,{id:u,kind:"control-unsupported",label:c.reason,disposition:"unsupported",location:{file:s.location.file,line:c.startLine,endLine:c.endLine},anchorIds:[],attributes:{ownerNodeId:s.id}});let d=Ri("edge","control-unsupported",s.id,u);i.set(d,{id:d,kind:"control-dependence",fromNodeId:s.id,toNodeId:u,directed:!0,disposition:"unsupported",semantics:[{family:"control",subtype:"unresolved-control-construct"}],evidence:[{method:"parser-control-construct",strength:"exact",identity:c.reason,location:{file:s.location.file,line:c.startLine,endLine:c.endLine}}]});let m=Ri("frontier","control-dependence",u);r.set(m,{id:m,kind:"control-dependence",direction:"unresolved",fromNodeIds:[s.id],edgeIds:[d],memberNodeIds:[u],memberCount:1,disposition:"unsupported",reason:c.reason,expansion:null})}}return{nodes:[...n.values()],edges:[...i.values()],frontiers:[...r.values()],blindSpots:[...o].sort()}}function Kc(e,t){let n=e.location.file;return{id:Ri(`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 rT(e,t,n){let i=Ri("edge","control-owner",t.id,n.id);e.has(i)||e.set(i,{id:i,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 Ri(...e){return e.map(t=>encodeURIComponent(t)).join(":")}var oa=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"]),ro=new Set(["block","body","compound_statement","declaration_list","statement_block"]),oT=new Set(["assignment","assignment_expression","augmented_assignment_expression"]),Wc=new Set(["update_expression"]),Wh=new Set(["array_access","element_access_expression","subscript_expression"]),Vh=new Set(["attribute","field_access","field_expression","member_access_expression","member_expression","selector_expression"]),sT=new Set(["false","null","null_literal","number","number_literal","string","string_literal","template_string","true"]),aT=new Set(["call_expression","method_invocation","object_creation_expression"]),lT=new Set(["comment","else_clause","formal_parameters","parameters","type_parameters"]);function Jh(e,t,n,i){let r=ae(e,t);if(!r)return null;let o=hT(r.rootNode,n,i);if(!o)return null;let s=[],a=[],l=[];return Ei(o,c=>{if(oT.has(c.type)||Wc.has(c.type)||Xh(c)){let u=cT(c);u?s.push(u):l.push({family:"state",startLine:c.startPosition.row,endLine:c.endPosition.row,reason:`Mutation target ${sn(c.text)} could not be resolved to an exact source resource.`})}}),Ei(o,c=>{if(!ro.has(c.type))return;let u=pT(c);for(let d=0;d<u.length-1;d+=1)a.push({from:io(u[d]),to:io(u[d+1]),subtype:"lexical-successor",synchronizationScope:null,attributes:{sameScope:!0,executionConditional:!0}});for(let d=0;d<u.length;d+=1){let m=u[d],f=bT(m).filter(p=>p.type==="await_expression");for(let p of f){let g=oo("event",`await ${sn(p.text.replace(/^await\s+/u,""))}`,p);a.push({from:io(m),to:g,subtype:"awaits-completion",synchronizationScope:null,attributes:{completionRequired:!0}});let h=u[d+1];h&&a.push({from:g,to:io(h),subtype:"await-completion-before",synchronizationScope:null,attributes:{continuationOnly:!0}})}}}),Ei(o,c=>{if(c.type!=="synchronized_statement")return;let u=c.childForFieldName("object")??c.childForFieldName("condition")??c.namedChildren.find(g=>!ro.has(g.type)),d=c.childForFieldName("body")??c.namedChildren.find(g=>ro.has(g.type));if(!u||!d){l.push({family:"temporal",startLine:c.startPosition.row,endLine:c.endPosition.row,reason:"Synchronized scope has no structurally resolved monitor or body."});return}let m=sn(u.text).replace(/^\(|\)$/gu,""),f=oo("lock",m,u),p=yT(d).filter(g=>g.parent!==null&&Zh(g));for(let g of gT(p))a.push({from:f,to:io(g),subtype:"inside-lock-scope",synchronizationScope:m,attributes:{syntaxNative:!0}})}),{mutations:s,temporal:a,unsupported:l}}function cT(e){let t=Xh(e),n=e.childForFieldName("left")??e.childForFieldName("argument")??(t?e.namedChildren.at(-1)??null:e.namedChildren[0]??null);if(!n)return null;let i=uT(n);if(!i)return null;let r=t?"delete":Wc.has(e.type)||!fT(e,n).startsWith("=")?"update":"assign",o=t||Wc.has(e.type)?null:e.childForFieldName("right");return{event:oo("event",sn(e.text),e),resource:{kind:"resource",label:i.name,startLine:n.startPosition.row,endLine:n.endPosition.row},operation:r,durabilityClass:"in-memory",recordIdentity:i.recordIdentity,value:o?oo("value",sn(o.text),o):null,dataSubtype:o?dT(o,e):null}}function uT(e){if(Wh.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:`${sn(t.text)}[]`,recordIdentity:sn(n.text)}}return Vh.has(e.type)?{name:sn(e.text),recordIdentity:null}:/^(?:identifier|property_identifier|field_identifier)$/u.test(e.type)?{name:sn(e.text),recordIdentity:null}:null}function dT(e,t){return sT.has(e.type)||/(?:integer|float|decimal|boolean|character)_literal$/u.test(e.type)?"constant-to-state":aT.has(e.type)?"return-to-state":Vh.has(e.type)||Wh.has(e.type)?"property-to-state":/identifier$/u.test(e.type)?mT(e.text,t)?"captured-value-to-state":"value-to-state":"expression-to-state"}function mT(e,t){let n=qc(t.parent);if(!n||Gh(n,e))return!1;let i=qc(n.parent);for(;i;){if(Gh(i,e))return!0;i=qc(i.parent)}return!1}function qc(e){let t=e;for(;t;){if(oa.has(t.type))return t;t=t.parent}return null}function Gh(e,t){let n=e.childForFieldName("parameters")??e.namedChildren.find(o=>["formal_parameters","parameters"].includes(o.type));if(n&&Kh(n,t))return!0;let i=e.childForFieldName("body")??e.namedChildren.find(o=>ro.has(o.type));if(!i)return!1;let r=!1;return Yh(i,e,o=>{if(r||!/(?:declarator|declaration|parameter)$/u.test(o.type))return;let s=o.childForFieldName("name")??o.childForFieldName("pattern")??o.namedChildren[0];s&&Kh(s,t)&&(r=!0)}),r}function Kh(e,t){let n=!1;return Ei(e,i=>{/identifier$/u.test(i.type)&&i.text===t&&(n=!0)}),n}function Yh(e,t,n){n(e);for(let i of e.namedChildren)i!==t&&oa.has(i.type)||Yh(i,t,n)}function fT(e,t){let n=e.childForFieldName("right"),i=Math.max(0,t.endIndex-e.startIndex),r=n?Math.max(i,n.startIndex-e.startIndex):e.text.length;return e.text.slice(i,r).trim()}function Xh(e){return(e.type==="delete_expression"||e.type==="unary_expression")&&/^delete\b/u.test(e.text.trim())}function pT(e){return e.namedChildren.filter(t=>Zh(t))}function Zh(e){return lT.has(e.type)||ro.has(e.type)?!1:/(?:statement|declaration)$/u.test(e.type)||e.type==="expression_statement"||e.type==="local_variable_declaration"}function gT(e){let t=new Set(e);return e.filter(n=>{let i=n.parent;for(;i;){if(t.has(i))return!1;i=i.parent}return!0})}function io(e){return oo("event",sn(e.text),e)}function oo(e,t,n){return{kind:e,label:t,startLine:n.startPosition.row,endLine:n.endPosition.row}}function hT(e,t,n){let i=[];return Ei(e,o=>{o.startPosition.row<=t&&o.endPosition.row>=n&&i.push(o)}),i.filter(o=>oa.has(o.type)).sort(qh)[0]??i.sort(qh)[0]??null}function qh(e,t){return e.endIndex-e.startIndex-(t.endIndex-t.startIndex)||e.startIndex-t.startIndex}function yT(e){let t=[];return Ei(e,n=>t.push(n)),t}function bT(e){let t=[],n=i=>{t.push(i);for(let r of i.namedChildren)r!==e&&oa.has(r.type)||n(r)};return n(e),t}function Ei(e,t){t(e);for(let n of e.namedChildren)Ei(n,t)}function sn(e){return e.trim().replace(/\s+/gu," ")}function ty(e,t,n=[]){let i=new Map,r=new Map,o=new Map,s=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,c=Jh(e,a.location.file,a.location.line,l);if(!c){s.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 u of c.mutations){let d=aa(a,u.event),m=ET(a,u.resource,u.durabilityClass);if(i.set(d.id,d),i.set(m.id,m),la(r,a,d,"contains-state-effect"),ca(r,{kind:"state-resource",from:d,to:m,semantics:[{family:"state",subtype:u.operation==="delete"?"deletes-resource":"writes-resource",attributes:{operation:u.operation,durabilityClass:u.durabilityClass,resource:u.resource.label,recordIdentity:u.recordIdentity,transactionMembership:"unknown"}}],method:"parser-state-mutation",identity:u.event.label}),u.value&&u.dataSubtype){let f=aa(a,u.value);i.set(f.id,f),ca(r,{kind:"data-to-state",from:f,to:m,semantics:[{family:"data",subtype:u.dataSubtype,attributes:{operation:u.operation,resource:u.resource.label,recordIdentity:u.recordIdentity,value:u.value.label}}],method:"parser-assignment-value",identity:`${u.value.label} -> ${u.resource.label}`})}}for(let u of c.temporal){let d=aa(a,u.from),m=aa(a,u.to);i.set(d.id,d),i.set(m.id,m),la(r,a,d,u.from.kind==="lock"?"contains-lock-scope":"contains-event"),la(r,a,m,"contains-event"),ca(r,{kind:"temporal-order",from:d,to:m,semantics:[{family:"temporal",subtype:u.subtype,context:u.synchronizationScope?{synchronizationScope:u.synchronizationScope}:void 0,attributes:{...u.attributes}}],method:u.subtype==="inside-lock-scope"?"parser-synchronized-scope":"parser-program-order",identity:`${u.from.label} -> ${u.to.label}`})}for(let u of c.unsupported){let d=Ln(`${u.family}-unsupported`,a.location.file,String(u.startLine),String(u.endLine),u.reason);i.set(d,{id:d,kind:`${u.family}-unsupported`,label:u.reason,disposition:"unsupported",location:{file:a.location.file,line:u.startLine,endLine:u.endLine},anchorIds:[],attributes:{ownerNodeId:a.id}});let m=Ln("edge",`${u.family}-unsupported`,a.id,d);r.set(m,{id:m,kind:`${u.family}-unsupported`,fromNodeId:a.id,toNodeId:d,directed:!0,disposition:"unsupported",semantics:[{family:u.family,subtype:`unresolved-${u.family}-construct`}],evidence:[{method:`parser-${u.family}-construct`,strength:"exact",identity:u.reason,location:{file:a.location.file,line:u.startLine,endLine:u.endLine}}]});let f=Ln("frontier",u.family,d);o.set(f,{id:f,kind:u.family,direction:"unresolved",fromNodeIds:[a.id],edgeIds:[m],memberNodeIds:[d],memberCount:1,disposition:"unsupported",reason:u.reason,expansion:null})}}for(let a of t.filter(l=>l.kind==="runtime-boundary-participant")){let l=sa(a,"protocol"),c=sa(a,"action"),u=sa(a,"address")??a.label;!l||!c||!ey(l,c)||Qh(i,r,a,{observationId:a.id,action:c,strength:"exact",file:a.location?.file??"",line:a.location?.line??0,address:u,protocol:l,role:sa(a,"role")??void 0,resolution:"locally-linked"})}for(let a of n){if(!a.protocol||!ey(a.protocol,a.action))continue;let l=xT(t,a.file,a.line,a.ownerShortName??null);if(!l){s.add(`State observation ${a.observationId} at ${a.file}:${a.line+1} has no materialized owner node.`);continue}Qh(i,r,l,a)}return{nodes:[...i.values()],edges:[...r.values()],frontiers:[...o.values()],blindSpots:[...s].sort()}}function Qh(e,t,n,i){let r=vT(i),s={id:Ln("runtime-state-event",i.observationId),kind:"runtime-state-event",label:`${i.action} ${r}`,disposition:"folded",location:{file:i.file,line:i.line},anchorIds:[],attributes:{action:i.action,protocol:i.protocol??null,modality:i.modality??null,resolution:i.resolution??null}},a=i.protocol==="database"?"external-durable-intent":"external",l={id:Ln("runtime-state-resource",i.protocol??"unknown",r),kind:"runtime-state-resource",label:r,disposition:"folded",location:{file:i.file,line:i.line},anchorIds:[],attributes:{protocol:i.protocol??null,durabilityClass:a}};e.set(s.id,s),e.set(l.id,l),la(t,n,s,"contains-runtime-state-effect");let c=ST(i.action);ca(t,{kind:"runtime-state-resource",from:s,to:l,semantics:[{family:"state",subtype:c,context:{crossesRuntimeBoundary:!0,protocol:i.protocol},attributes:{operation:i.action,durabilityClass:a,resource:r,recordIdentity:CT(i),modality:i.modality??null,resolution:i.resolution??null,transactionMembership:"unknown",commitState:i.protocol==="database"?"unknown":null}}],method:`runtime-boundary-${i.strength}`,identity:i.observationId})}function ST(e){return e==="database.read"?"reads-resource":e==="queue.send"?"enqueues-resource":e==="queue.consume"?"consumes-resource":"writes-resource"}function vT(e){return(e.keyParts?.find(n=>["address","resource"].includes(n.name))?.value??e.address)||e.observationId}function CT(e){return e.keyParts?.find(n=>/^(?:id|key|record)$/u.test(n.name))?.value??null}function ey(e,t){return e==="database"&&["database.read","database.write"].includes(t)||e==="queue"&&["queue.consume","queue.send"].includes(t)}function sa(e,t){let n=e.attributes[t];return typeof n=="string"?n:null}function xT(e,t,n,i){let r=e.filter(s=>s.location?.file===t&&["source-construct","symbol"].includes(s.kind)),o=r.filter(s=>s.location.line<=n&&(s.location.endLine??s.location.line)>=n).sort(RT)[0];if(o)return o;if(i){let s=r.find(a=>a.label===i||a.label.endsWith(`.${i}`)||a.label.includes(i));if(s)return s}return r.length===1?r[0]:null}function RT(e,t){let n=(e.location?.endLine??e.location?.line??0)-(e.location?.line??0),i=(t.location?.endLine??t.location?.line??0)-(t.location?.line??0);return n-i}function aa(e,t){let n=e.location.file;return{id:Ln(`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 ET(e,t,n){let i=e.location.file;return{id:Ln("program-resource",i,e.id,t.label,n),kind:"program-resource",label:t.label,disposition:"folded",location:{file:i,line:t.startLine,endLine:t.endLine},anchorIds:[],attributes:{ownerNodeId:e.id,durabilityClass:n}}}function la(e,t,n,i){let r=Ln("edge","program-owner",t.id,n.id,i);e.has(r)||e.set(r,{id:r,kind:"program-owner",fromNodeId:t.id,toNodeId:n.id,directed:!0,disposition:"folded",semantics:[{family:"identity",subtype:i}],evidence:[{method:"parser-program-owner",strength:"exact",identity:t.id,location:n.location}]})}function ca(e,t){let n=Ln("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 Ln(...e){return e.map(t=>encodeURIComponent(t)).join(":")}var wT=new Set(["control","data","state","temporal"]),ua=new Set(["contains-control","contains-event","contains-lock-scope","contains-state-effect","contains-runtime-state-effect","contains","owns-parameter","owns-runtime-observation"]),oy=new Set(["discriminator-dispatch","result-callback","returns","runtime-handoff","throws"]);function sy(e,t={}){let n=new Map(e.nodes.map(C=>[C.id,C])),i=MT(e.nodes,t.focusLocations),r=AT(e.edges,t.focusLocations),o=NT(e.edges,r),s=new Set(e.paths.flatMap(C=>C.edgeIds)),a=Dn(e.anchors.filter(C=>C.status==="matched").flatMap(C=>C.nodeIds)),c=e.edges.filter(ry).filter(C=>IT(C,i,r,s)),u=c.filter(C=>TT(C,i,r,o,n,s)),d=ny(a,u,"forward"),m=PT(d,u),f=ny(m,u,"backward"),p=new Set([...d].filter(C=>f.has(C)));for(let C of a)p.add(C);let g=new Set(u.filter(C=>p.has(C.fromNodeId)&&p.has(C.toNodeId)).map(C=>C.id)),h=new Set(p),S=new Set(g);LT(c,h,S,i,r);let v=e.frontiers.filter(C=>_T(C,h)),y=Dn(v.filter(C=>C.disposition==="unsupported").map(C=>C.id)),E=Dn(e.edges.filter(C=>!ry(C)&&ly(C)&&kT(C,h)).map(C=>C.id)),w=Dn(v.map(C=>C.id)),b=[];a.length===0&&b.push("No matched anchor node starts the corridor."),m.length===0&&b.push("No proved mechanical outcome is reachable from a matched anchor."),y.length>0&&b.push(`${y.length} unsupported frontier(s) touch the protected corridor.`),E.length>0&&b.push(`${E.length} candidate or unknown edge(s) touch the protected corridor.`);let R=b.length===0?"complete":"incomplete";return{schemaVersion:1,status:R,startNodeIds:a,outcomeNodeIds:m,baseNodeIds:Dn([...p]),baseEdgeIds:Dn([...g]),nodeIds:Dn([...h]),edgeIds:Dn([...S]),accountedFrontierIds:w,unresolvedFrontierIds:y,unresolvedEdgeIds:E,coverage:{protectedNodes:h.size,protectedEdges:S.size,baseNodes:p.size,baseEdges:g.size,accountedFrontiers:w.length,unresolvedFrontiers:y.length,unresolvedEdges:E.length},explanation:R==="complete"?"Every proved anchor-to-outcome path is closed over its material causal facts within reported coverage.":b.join(" ")}}function IT(e,t,n,i){return t===null||e.disposition==="emitted"||i.has(e.id)||n?.has(e.id)===!0?!0:(e.semantics??[]).some(r=>{if(r.family==="identity"&&ua.has(r.subtype))return t.has(e.toNodeId);if(r.family==="contract")return t.has(e.fromNodeId)&&t.has(e.toNodeId);if(r.family==="state")return t.has(e.fromNodeId);if(r.family==="data"||r.family==="temporal")return t.has(e.fromNodeId)||t.has(e.toNodeId);if(r.family==="control"){if(cy(r))return t.has(e.fromNodeId);if(["returns","throws"].includes(r.subtype))return t.has(e.toNodeId);if(r.subtype==="completion-callback")return t.has(e.fromNodeId)||t.has(e.toNodeId)}return!1})}function LT(e,t,n,i,r){let o=!0;for(;o;){o=!1;for(let s of e)DT(s,t,i,r)&&(n.has(s.id)||(n.add(s.id),o=!0),t.has(s.fromNodeId)||(t.add(s.fromNodeId),o=!0),t.has(s.toNodeId)||(t.add(s.toNodeId),o=!0))}}function DT(e,t,n,i){let r=t.has(e.fromNodeId),o=t.has(e.toNodeId);return!r&&!o?!1:(e.semantics??[]).some(s=>s.family==="identity"?ua.has(s.subtype)&&(o||n===null||n.has(e.toNodeId)):s.family==="contract"?!0:s.family==="state"?r&&(n===null||n.has(e.fromNodeId)):s.family==="temporal"?s.subtype==="lexical-successor"?r&&o:!0:s.family==="data"?o&&(r||n===null||n.has(e.fromNodeId)||i?.has(e.id)===!0):s.family==="control"?ay(s)||["returns","throws"].includes(s.subtype)&&!o&&n!==null&&!n.has(e.toNodeId)?!1:oy.has(s.subtype)||cy(s)||s.subtype==="completion-callback":!1)}function PT(e,t){let n=new Set,i=new Map,r=new Map;for(let o of t)!e.has(o.fromNodeId)||!e.has(o.toNodeId)||(i.set(o.fromNodeId,(i.get(o.fromNodeId)??0)+1),r.set(o.toNodeId,(r.get(o.toNodeId)??0)+1),(o.semantics??[]).some(s=>s.family==="state"||s.family==="control"&&oy.has(s.subtype))&&n.add(o.toNodeId));for(let o of e)(r.get(o)??0)>0&&(i.get(o)??0)===0&&n.add(o);return Dn([...n])}function ny(e,t,n){let i=new Map;for(let s of t){let a=n==="forward"?s.fromNodeId:s.toNodeId,l=n==="forward"?s.toNodeId:s.fromNodeId,c=i.get(a)??[];c.push(l),i.set(a,c)}let r=new Set(e),o=[...e];for(;o.length>0;){let s=o.shift();for(let a of i.get(s)??[])r.has(a)||(r.add(a),o.push(a))}return r}function TT(e,t,n,i,r,o){return(e.semantics??[]).some(s=>e.disposition==="emitted"||o.has(e.id)?!0:s.family==="identity"&&ua.has(s.subtype)?t===null||t.has(e.toNodeId)||i?.has(e.toNodeId)===!0:!wT.has(s.family)||ay(s)?!1:s.family==="control"&&["returns","throws"].includes(s.subtype)&&t!==null?t.has(e.toNodeId):t===null?!0:s.family==="state"?t.has(e.fromNodeId):s.family==="data"?t.has(e.fromNodeId)||t.has(e.toNodeId)||n?.has(e.id)===!0:s.family==="temporal"?s.subtype==="lexical-successor"?t.has(e.fromNodeId)&&t.has(e.toNodeId):t.has(e.fromNodeId)||t.has(e.toNodeId):s.family==="control"?FT(e,r)&&(t.has(e.fromNodeId)||t.has(e.toNodeId)):!1)}function ay(e){return e.family==="control"&&["call","discriminator-dispatch","result-callback","runtime-handoff"].includes(e.subtype)}function FT(e,t){let n=t.get(e.fromNodeId),i=t.get(e.toNodeId);if(!n||!i)return!1;let r=iy(n,"ownerNodeId")??(n.kind==="symbol"?n.id:null),o=iy(i,"ownerNodeId")??(i.kind==="symbol"?i.id:null);return r!==null&&r===o}function MT(e,t){if(!t)return null;let n=new Map;for(let i of t){let r=n.get(i.file)??[];r.push(i.line),n.set(i.file,r)}return new Set(e.filter(i=>{if(!i.location||i.kind==="parameter")return!1;let r=n.get(i.location.file)??[],o=i.location.endLine??i.location.line;return r.some(s=>s>=i.location.line&&s<=o)}).map(i=>i.id))}function AT(e,t){if(!t)return null;let n=new Map;for(let i of t){let r=n.get(i.file)??[];r.push(i.line),n.set(i.file,r)}return new Set(e.filter(i=>i.evidence.some(r=>{if(!r.location)return!1;let o=n.get(r.location.file)??[],s=r.location.endLine??r.location.line;return o.some(a=>a>=r.location.line&&a<=s)})).map(i=>i.id))}function NT(e,t){return t===null?null:new Set(e.filter(n=>t.has(n.id)).flatMap(n=>[n.fromNodeId,n.toNodeId]))}function iy(e,t){let n=e.attributes[t];return typeof n=="string"?n:null}function ry(e){return e.disposition==="excluded"||e.disposition==="unsupported"||!ly(e)?!1:e.evidence.some(t=>t.strength==="exact"||t.strength==="derived")}function ly(e){return(e.semantics??[]).some(t=>t.family!=="identity"||ua.has(t.subtype))}function cy(e){return e.subtype.startsWith("predicate-")||e.subtype.startsWith("loop-")||e.subtype.startsWith("exception-")||e.subtype.startsWith("finally-")||e.subtype.startsWith("handler-")}function kT(e,t){return t.has(e.fromNodeId)||t.has(e.toNodeId)}function _T(e,t){return[...e.fromNodeIds,...e.memberNodeIds].some(n=>t.has(n))}function Dn(e){return[...new Set(e)].sort()}import{createHash as BT}from"crypto";var da=["identity","contract","control","data","state","temporal"],OT=new Set(da);function fa(e){let t=er(e.anchors,"anchor"),n=er(e.nodes,"node"),i=er(e.edges,"edge"),r=er(e.paths??[],"path"),o=er(e.frontiers??[],"frontier"),s=new Set(t.map(f=>f.id)),a=new Set(n.map(f=>f.id)),l=new Set(i.map(f=>f.id)),c=e.routeCatalog?{...e.routeCatalog,routes:er(e.routeCatalog.routes,"route"),selectedRouteIds:ht(e.routeCatalog.selectedRouteIds)}:void 0;for(let f of t)Rt(`anchor ${f.id}`,[...f.nodeIds,...f.candidateNodeIds],a,"node");for(let f of n)Rt(`node ${f.id}`,f.anchorIds,s,"anchor");for(let f of i){if(Rt(`edge ${f.id}`,[f.fromNodeId,f.toNodeId],a,"node"),f.evidence.length===0)throw new Error(`Exploration edge ${f.id} has no evidence source.`);HT(f)}for(let f of r)Rt(`path ${f.id}`,[f.fromAnchorId,f.toAnchorId],s,"anchor"),Rt(`path ${f.id}`,f.nodeIds,a,"node"),Rt(`path ${f.id}`,f.edgeIds,l,"edge");for(let f of o)if(Rt(`frontier ${f.id}`,f.fromNodeIds,a,"node"),Rt(`frontier ${f.id}`,f.edgeIds,l,"edge"),Rt(`frontier ${f.id}`,f.memberNodeIds,a,"node"),f.memberCount!==f.memberNodeIds.length)throw new Error(`Exploration frontier ${f.id} reports ${f.memberCount} member(s) but identifies ${f.memberNodeIds.length}.`);for(let f of c?.routes??[])Rt(`route ${f.id}`,f.nodeIds,a,"node"),Rt(`route ${f.id}`,f.edgeIds,l,"edge"),Rt(`route ${f.id}`,[f.anchorNodeId,f.endpointNodeId],a,"node");c&&Rt("route catalog selection",c.selectedRouteIds,new Set(c.routes.map(f=>f.id)),"route");let u=ht(e.incompleteReasons??[]),d=u.length===0?"accounted":"incomplete",m=t.reduce((f,p)=>f+p.omittedCandidates,0);return{schemaVersion:1,anchors:t,nodes:n,edges:i,paths:r,frontiers:o,coverage:{status:d,scope:e.scope,nodes:by(n),edges:by(i),matchedAnchors:t.filter(f=>f.status==="matched").length,ambiguousAnchors:t.filter(f=>f.status==="ambiguous").length,missingAnchors:t.filter(f=>f.status==="missing").length,omittedCandidates:m,frontierGroups:o.length,programEdges:jT(i),blindSpots:ht(e.blindSpots??[]),explanation:d==="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: ${u.join("; ")}`},completion:GT(d,r,e.scope),...c?{routeCatalog:c}:{}}}function $T(e){return e.flatMap(t=>UT(t.semantics??[]).map(n=>({id:zT(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 jT(e){let t=$T(e),n=new Set(t.map(s=>s.sourceEdgeId)),i=new Map(da.map(s=>[s,new Set])),r=new Map(da.map(s=>[s,new Set])),o=new Map(da.map(s=>[s,0]));for(let s of t)i.get(s.family).add(s.sourceEdgeId),r.get(s.family).add(s.subtype),o.set(s.family,o.get(s.family)+1);return{sourceEdges:e.length,mappedSourceEdges:n.size,projectedEdges:t.length,unmappedSourceEdges:e.length-n.size,unsupportedSourceEdges:e.filter(s=>s.disposition==="unsupported").length,unmappedKinds:ht(e.filter(s=>!n.has(s.id)).map(s=>s.kind)),families:{identity:Qi("identity",i,o,r),contract:Qi("contract",i,o,r),control:Qi("control",i,o,r),data:Qi("data",i,o,r),state:Qi("state",i,o,r),temporal:Qi("temporal",i,o,r)}}}function Qi(e,t,n,i){return{sourceEdges:t.get(e)?.size??0,projectedEdges:n.get(e)??0,subtypes:[...i.get(e)??[]].sort()}}function HT(e){let t=new Set;for(let n of e.semantics??[]){if(!OT.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 i=Vc(n);if(t.has(i))throw new Error(`Exploration edge ${e.id} repeats program edge semantic ${i}.`);t.add(i)}}function UT(e){return[...e].sort((t,n)=>Vc(t).localeCompare(Vc(n)))}function Vc(e){return`${e.family}:${e.subtype}`}function zT(e,t){return`program:${encodeURIComponent(e)}:${t.family}:${encodeURIComponent(t.subtype)}`}function GT(e,t,n){return e==="incomplete"||t.some(i=>i.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 Sy(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 i=new Set(e.anchors.flatMap(I=>[...I.nodeIds,...I.candidateNodeIds])),r=[],o=e.anchors.filter(I=>I.status!=="missing"&&I.nodeIds.length+I.candidateNodeIds.length>0);for(let I=0;I<o.length;I+=1)for(let x=I+1;x<o.length;x+=1){let P=o[I],_=o[x],D=py(e,P,_,!1),A=D??py(e,P,_,!0);A?(A.nodeIds.forEach(W=>i.add(W)),r.push({id:ma("path",P.id,_.id),fromAnchorId:P.id,toAnchorId:_.id,status:!D||P.status==="ambiguous"||_.status==="ambiguous"?"candidate":"connected",nodeIds:A.nodeIds,edgeIds:A.edgeIds})):r.push({id:ma("path",P.id,_.id),fromAnchorId:P.id,toAnchorId:_.id,status:"partial",nodeIds:[],edgeIds:[]})}let s=ht(t.routeIds??[]),a=KT(e,s),l=new Set(a.routes.map(I=>I.id)),c=s.filter(I=>!l.has(I));if(c.length>0)throw new Error(`Unknown exploration route id(s): ${c.join(", ")}`);let d=a.routes.filter(I=>s.includes(I.id)).map(I=>({anchorNodeId:I.anchorNodeId,endpointNodeId:I.endpointNodeId,endpointKind:I.endpointKind,endpointPriority:2,nodeIds:[...I.nodeIds].reverse(),edgeIds:[...I.edgeIds].reverse()}));for(let I of d)I.nodeIds.forEach(x=>i.add(x));let m=r.length===0||r.some(I=>I.edgeIds.length>0);m&&hy(e,i,n);let f=yy(e,i),p=new Set(t.expandedFrontierIds??[]),g=new Set(f.map(I=>I.id)),h=[...p].filter(I=>!g.has(I)).sort();if(h.length>0)throw new Error(`Unknown exploration frontier id(s): ${h.join(", ")}`);for(let I of f)p.has(I.id)&&I.memberNodeIds.forEach(x=>i.add(x));m&&hy(e,i,n);let S=new Map(d.map(I=>[I.endpointNodeId,I.endpointKind])),v=new Set(d.flatMap(I=>I.nodeIds)),y=new Map;for(let I of d)for(let x=0;x<I.nodeIds.length;x+=1){let P=I.nodeIds[x],_=x;y.set(P,Math.max(y.get(P)??0,_))}let E=e.nodes.map(I=>{let x=S.get(I.id),P=v.has(I.id)?{upstreamCausalPath:!0,upstreamCausalDistance:y.get(I.id)??0,...x?{upstreamCausalEndpoint:x}:{}}:{};return{...I,attributes:{...I.attributes,...P},disposition:I.disposition==="excluded"||I.disposition==="unsupported"?I.disposition:i.has(I.id)?"emitted":"folded"}}),w=new Set([...r.flatMap(I=>I.edgeIds),...d.flatMap(I=>I.edgeIds)]),b=e.edges.map(I=>({...I,disposition:I.disposition==="excluded"||I.disposition==="unsupported"?I.disposition:w.has(I.id)||i.has(I.fromNodeId)&&i.has(I.toNodeId)?"emitted":"folded"})),R=fa({anchors:e.anchors,nodes:E,edges:b,paths:r,frontiers:[...e.frontiers.filter(I=>I.disposition!=="folded"),...yy({...e,nodes:E,edges:b},i)],scope:e.coverage.scope,blindSpots:e.coverage.blindSpots,incompleteReasons:e.coverage.status==="incomplete"?[e.coverage.explanation]:[],routeCatalog:a}),C=new Set(R.frontiers.flatMap(I=>I.edgeIds)),L=R.edges.filter(I=>I.disposition==="folded"&&!C.has(I.id)).map(I=>I.id);if(L.length>0)throw new Error(`Folded exploration edge(s) are not frontier-accounted: ${L.sort().join(", ")}`);return R}var uy=10;function KT(e,t=[]){let n=new Map(e.nodes.map(h=>[h.id,h])),i=new Map(e.edges.map(h=>[h.id,h])),r=new Map;for(let h of e.edges){if(!qT(h))continue;let S=r.get(h.toNodeId)??[];S.push(h),r.set(h.toNodeId,S)}for(let h of r.values())h.sort((S,v)=>Number(so(v))-Number(so(S))||fy(v)-fy(S)||S.fromNodeId.localeCompare(v.fromNodeId)||S.id.localeCompare(v.id));let o=ht(e.anchors.filter(h=>h.status==="matched").flatMap(h=>h.nodeIds)),s=new Map,a=new Set,l=(h,S,v)=>{let y=S.nodeIds[S.nodeIds.length-1],E=n.get(y),w=n.get(h);if(!E?.location||!w)return;let b=[...S.nodeIds].reverse(),R=[...S.edgeIds].reverse(),C=new Set(b),L=R.flatMap(D=>{let T=i.get(D);return T?[T]:[]}),I=e.edges.filter(D=>D.disposition!=="excluded"&&D.disposition!=="unsupported"&&(C.has(D.fromNodeId)||C.has(D.toNodeId))),x={id:ma("route",h,y,v,...R),status:"proved",anchorNodeId:h,anchorLabel:w.label,endpointNodeId:y,endpointLabel:E.label,endpointLocation:{...E.location},endpointKind:v,nodeIds:b,edgeIds:R,evidenceStrengths:ht(L.flatMap(D=>D.evidence.map(T=>T.strength))),spineEdgeFamilies:dy(L,!0),relatedEdgeFamilies:dy(I,!1),crossesRuntimeBoundary:L.some(so)},P=`${h}\0${y}\0${v}`,_=s.get(P);(!_||my(x,_)<0)&&s.set(P,x)};for(let h of o){n.get(h)?.attributes.publicEntry===!0&&l(h,{nodeIds:[h],edgeIds:[]},"public-entry");let S=[{nodeIds:[h],edgeIds:[]}],v=new Map([[h,0]]);for(let y=0;y<S.length;y+=1){let E=S[y],w=E.nodeIds[E.nodeIds.length-1];E.edgeIds.length>0&&n.get(w)?.location&&n.get(w)?.attributes.publicEntry===!0&&l(h,E,"public-entry");let b=r.get(w)??[];if(E.edgeIds.length>=uy){b.some(R=>!E.nodeIds.includes(R.fromNodeId))&&a.add(h);continue}for(let R of b){if(E.nodeIds.includes(R.fromNodeId))continue;let C=E.edgeIds.length+1,L=v.get(R.fromNodeId);if(L!==void 0&&L<=C)continue;let I={nodeIds:[...E.nodeIds,R.fromNodeId],edgeIds:[...E.edgeIds,R.id]};if(v.set(R.fromNodeId,C),so(R)&&n.get(R.fromNodeId)?.location){l(h,I,"runtime-boundary");continue}S.push(I)}}}let c=[...s.values()].sort(my),u=new Set(c.map(h=>h.id)),d=ht(t.filter(h=>u.has(h))),m=ht(c.map(h=>h.anchorNodeId)),f=o.filter(h=>!m.includes(h)),p=[...a].sort(),g=e.coverage.status==="accounted"&&p.length===0?"accounted":"incomplete";return{schemaVersion:1,routes:c,selectedRouteIds:d,coverage:{status:g,scope:"Distinct proved public-entry and runtime-boundary endpoints reachable upstream in the supplied topology.",enumeration:"one-shortest-proved-path-per-endpoint",maximumDepth:uy,anchorNodeIds:o,anchorsWithRoutes:m,anchorsWithoutRoutes:f,depthLimitedAnchorNodeIds:p,routeCount:c.length,explanation:g==="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 dy(e,t){let n=e.flatMap(i=>i.semantics?.map(r=>r.family)??[]);return t&&e.length>0&&n.length===0&&n.push("control"),ht(n)}function my(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 qT(e){return e.disposition!=="excluded"&&e.disposition!=="unsupported"&&WT(e)&&e.evidence.some(t=>["exact","derived","mixed"].includes(t.strength))}function WT(e){return so(e)||e.kind==="boundary-observation"||e.kind==="call"||e.kind==="compiler:call"}function so(e){return e.kind==="runtime-boundary"||e.kind.startsWith("runtime:")}function fy(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 py(e,t,n,i){return gy(e,t,n,i)??gy(e,n,t,i)}function gy(e,t,n,i){let r=[...t.nodeIds,...t.candidateNodeIds].sort(),o=new Set([...n.nodeIds,...n.candidateNodeIds]);if(r.some(u=>o.has(u)))return{nodeIds:[r.find(d=>o.has(d))],edgeIds:[]};let s=new Set(e.nodes.filter(u=>u.kind==="structural-region").map(u=>u.id)),a=new Map;for(let u of e.edges)u.disposition==="excluded"||u.disposition==="unsupported"||u.kind==="structural-membership"||s.has(u.fromNodeId)||s.has(u.toNodeId)||u.evidence.every(m=>["candidate","unknown"].includes(m.strength))&&!i||VT(a,u.fromNodeId,u.toNodeId,u.id);for(let u of a.values())u.sort((d,m)=>d.nodeId.localeCompare(m.nodeId)||d.edgeId.localeCompare(m.edgeId));let l=r.map(u=>({nodeId:u,nodeIds:[u],edgeIds:[]})),c=new Set(r);for(let u=0;u<l.length;u+=1){let d=l[u];for(let m of a.get(d.nodeId)??[]){if(c.has(m.nodeId))continue;let f={nodeId:m.nodeId,nodeIds:[...d.nodeIds,m.nodeId],edgeIds:[...d.edgeIds,m.edgeId]};if(o.has(m.nodeId))return f;c.add(m.nodeId),l.push(f)}}return null}function VT(e,t,n,i){let r=e.get(t)??[];r.push({nodeId:n,edgeId:i}),e.set(t,r)}function JT(e,t,n){let i=new Map;for(let a of e.edges){let l=i.get(a.fromNodeId)??{incoming:0,outgoing:0},c=i.get(a.toNodeId)??{incoming:0,outgoing:0};l.outgoing+=1,c.incoming+=1,i.set(a.fromNodeId,l),i.set(a.toNodeId,c)}let r=new Set,o=new Map;for(let a of e.edges){let l=t.has(a.fromNodeId),c=t.has(a.toNodeId);if(l===c)continue;let u=l?a.toNodeId:a.fromNodeId,d=l?a.fromNodeId:a.toNodeId,m=e.nodes.find(g=>g.id===u);if(m?.kind==="structural-region")continue;let f=o.get(u)??new Set;f.add(d),o.set(u,f),(/(?:runtime-boundary|external)/u.test(a.kind)||m&&/(?:frontier|external)/u.test(m.kind))&&r.add(u)}let s=[...o].filter(([a,l])=>{if(r.has(a))return!0;let c=i.get(a)??{incoming:0,outgoing:0};return(c.incoming>1||c.outgoing>1)&&l.size>1}).sort(([a,l],[c,u])=>Number(r.has(c))-Number(r.has(a))||u.size-l.size||a.localeCompare(c)).map(([a])=>a);for(let a of s){if(t.size>=n)break;t.add(a)}}function hy(e,t,n){let i=-1;for(;t.size!==i&&t.size<n;)i=t.size,JT(e,t,n)}function yy(e,t){let n=new Set(e.nodes.filter(s=>!t.has(s.id)&&s.disposition!=="excluded"&&s.disposition!=="unsupported").map(s=>s.id)),i=new Map;for(let s of e.edges){if(!n.has(s.fromNodeId)||!n.has(s.toNodeId))continue;let a=i.get(s.fromNodeId)??new Set,l=i.get(s.toNodeId)??new Set;a.add(s.toNodeId),l.add(s.fromNodeId),i.set(s.fromNodeId,a),i.set(s.toNodeId,l)}let r=[],o=new Set;for(let s of[...n].sort()){if(o.has(s))continue;let a=[],l=[s];o.add(s);for(let c=0;c<l.length;c+=1){let u=l[c];a.push(u);for(let d of[...i.get(u)??[]].sort())o.has(d)||(o.add(d),l.push(d))}r.push(a.sort())}return r.map(s=>{let a=new Set(s),l=e.edges.filter(p=>a.has(p.fromNodeId)||a.has(p.toNodeId)),c=l.filter(p=>a.has(p.fromNodeId)!==a.has(p.toNodeId)),u=ht(c.map(p=>a.has(p.fromNodeId)?p.toNodeId:p.fromNodeId)),d=new Set(c.map(p=>a.has(p.toNodeId)?"outgoing":"incoming")),m=ht(l.map(p=>p.id)),f=ht(c.map(p=>p.kind));return{id:ma("frontier",...s,...m),kind:f.join("+")||"disconnected",direction:d.size===1?[...d][0]:"undirected",fromNodeIds:u,edgeIds:m,memberNodeIds:s,memberCount:s.length,disposition:"folded",reason:c.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 ma(e,...t){let n=BT("sha256").update(t.join("\0")).digest("hex").slice(0,16);return`${e}:${n}`}function er(e,t){let n=[...e].sort((i,r)=>i.id.localeCompare(r.id));for(let i=1;i<n.length;i+=1)if(n[i-1].id===n[i].id)throw new Error(`Duplicate exploration ${t} id: ${n[i].id}`);return n}function Rt(e,t,n,i){let r=ht(t.filter(o=>!n.has(o)));if(r.length>0)throw new Error(`Exploration ${e} references missing ${i}(s): ${r.join(", ")}`)}function by(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 ht(e){return[...new Set(e)].sort()}var YT=5,XT=12,ZT=8,QT=3,vy=8,eF=6,tF=12,Cy=12,nF=12,iF=2,rF=new Set(["branch","loop","call","await","return","throw","mutation","catch","finally"]),oF=9e3,xy=Th;function sF(e,t){return My(e,t,"full")}function Fy(e,t){return My(e,t,"topology")}function My(e,t,n){let i=ha(t.searches??[]),r=ha(t.symbols??[]),o=ha(t.relations&&t.relations.length>0?t.relations:xy),s=o.filter(M=>!xy.includes(M));if(s.length>0)throw new Error(`Unsupported system-map relation kind(s): ${s.join(", ")}`);let a=new Set(o),l=t.evidenceFloor??"derived";if(l!=="exact"&&l!=="derived")throw new Error(`Unsupported system-map evidence floor: ${l}`);let c=ha(t.sourceScopes&&t.sourceScopes.length>0?t.sourceScopes:["production"]),u=["production","test","fixture","example","generated","script","unknown"],d=c.filter(M=>!u.includes(M));if(d.length>0)throw new Error(`Unsupported system-map source scope(s): ${d.join(", ")}`);let m=new Set(c),f=M=>m.has(gl(M));if(i.length===0&&r.length===0)throw new Error("system-map requires at least one --search or --symbol anchor.");let p=t.maxDepth??YT;if(!Number.isSafeInteger(p)||p<0)throw new RangeError(`maxDepth must be a non-negative safe integer; received ${p}`);let g=t.maxTopologyCharacters??oF;if(!Number.isSafeInteger(g)||g<=0)throw new RangeError(`maxTopologyCharacters must be a positive safe integer; received ${g}`);let h=new U(e),S=h.fileDependencyGraph(),v=GF(S),y=KF(h.sourceFiles()),E=es(e),w=new Map((E?.observations??[]).map(M=>[M.id,M])),b=new Set((E?.observations??[]).map(M=>`${M.source.file}\0${M.source.startLine}`)),R=new Set,C=new Map,L=new Map,I=new Map,x=new Map,P=[],_=new Map,D=new Map,T=[],A=0,W=0,le=0,q=0,Y=0,N=0,K=new Set,te=new Map,me=new Map,ge=M=>{let H=me.get(M);if(H)return H;let Q=Un(e,M,{excludeIndexedTargets:!1});return me.set(M,Q),Q},ce=(M,H,Q,we,j=!1)=>{let B=L.get(M);if(B)return B.depth=Math.min(B.depth,H),B.primary||=we,B.promoteBoundaryImports||=j,B.origins.add(Q),B;let G={file:M,depth:H,primary:we,promoteBoundaryImports:j,origins:new Set([Q]),processed:!1};return L.set(M,G),G},be=(M,H,Q,we,j="none",B=!1)=>{let G=I.get(M.symbol);if(G)return G.depth=Math.min(G.depth,H),G.origins.add(Q),we&&G.anchorQueries.add(we),G.referenceScope=zF(G.referenceScope,j),ce(M.relativePath,H,Q,!0,B),G;let oe={definition:M,depth:H,origins:new Set([Q]),anchorQueries:new Set(we?[we]:[]),referenceScope:j,processed:!1};return I.set(M.symbol,oe),ce(M.relativePath,H,Q,!0,B),oe},F=(M,H,Q,we,j=!1,B=!0)=>{let G=an(M),oe=x.get(G);if(oe)return oe.depth=Math.min(oe.depth,H),oe.origins.add(Q),we&&oe.anchorQueries.add(we),oe.reverseCallExpansion||=j,oe.traversalEligible||=B,ce(M.file,H,Q,oe.traversalEligible,!0),oe;let z={...M,depth:H,origins:new Set([Q]),anchorQueries:new Set(we?[we]:[]),reverseCallExpansion:j,traversalEligible:B};return x.set(G,z),ce(M.file,H,Q,B,!0),z},Z=(M,H,Q)=>{ce(M.source.file,H,Q,!0,!0),M.owner.file!==M.source.file&&ce(M.owner.file,H,`${Q}:owner`,!0,!0);let we=J(e,M.owner.file),j=M.owner.symbol?Wn(e,h,M.owner.symbol).matches.find(oe=>oe.relativePath===M.owner.file):null,B=(j&&!Le(j.symbol)?j:null)??Ge(we,M.source.startLine);if(B&&!Le(B.symbol))return be(B,H,Q,void 0,"none",!0),B.symbol;M.owner.name&&F({file:M.owner.file,name:M.owner.name,startLine:M.owner.startLine,endLine:M.owner.endLine},H,`${Q}:source-owner`,void 0,!0);let G=h.definitionsForFile(M.source.file).filter(oe=>!!oe.leaf&&yn(e,M.source.file,oe.leaf).some(z=>z>=M.source.startLine&&z<=M.source.endLine));if(G.length===1){let oe=G[0];be(oe,H,`${Q}:handler-identifier`,void 0,"none",!0),Et(_,{kind:"runtime-boundary",evidence:"runtime-boundary:handler-identifier",fromFile:M.source.file,fromSymbol:null,toFile:oe.relativePath,toSymbol:oe.symbol,fromBoundaryParticipant:nr(M),line:M.source.startLine,strength:"derived"})}return null};for(let M of i){let H=IF(e,h,M,b),Q=H.filter(G=>FF(G,f)),we=!t.fullLiteralTraversal&&(H.length>XT||Q.length>ZT),j=we?[]:H,B=new Set((we?[]:t.fullLiteralTraversal?Q:[...Q].sort(LF).slice(0,QT)).map(Iy));we&&(W+=1,le+=H.length);for(let G of j){let oe=B.has(Iy(G)),z=oe&&!G.ownerSymbol&&G.ownerStartLine!==null&&G.ownerEndLine!==null;if(ce(G.relativePath,0,`${oe?"literal-anchor":"literal-match"}:${M}`,z,z),z&&F({file:G.relativePath,name:G.ownerShortName??`${G.relativePath}:${G.ownerStartLine+1}`,startLine:G.ownerStartLine,endLine:G.ownerEndLine},0,`literal-source-owner:${M}`,M,!0),oe&&G.ownerSymbol){let ue=Wn(e,h,G.ownerSymbol).matches[0];ue&&!Le(ue.symbol)&&be(ue,0,"literal-owner",M,"all",!0)}P.push({query:M,file:G.relativePath,line:G.line,ownerSymbol:G.ownerSymbol,ownerShortName:G.ownerShortName,ownerStartLine:G.ownerStartLine,ownerEndLine:G.ownerEndLine,sourceLine:G.sourceLine.trim(),matchKind:G.matchKind,traversalSeed:oe})}T.push({kind:"literal",query:M,status:H.length>0?"matched":"missing",matchedRegionIds:[],matchingLines:H.length,seedMatchingLines:we?0:B.size,matchOnlyLines:H.length-B.size,eligibleSeedMatchingLines:Q.length,materializedMatchingLines:j.length,withheldMatchingLines:we?H.length:0,literalTraversal:we?"withheld-broad":"materialized",representativeMatches:we?MF(M,H):void 0,narrowingCommands:we?NF(M,H):void 0,exhaustiveTraversalCommand:we||B.size<Q.length?`codebaseiq system-map --search ${Ne(M)} --full-literal-traversal`:void 0,seedRegionIds:[],matchOnlyRegionIds:[]})}for(let M of r){let H=Wn(e,h,M);A+=H.omitted;let Q=DF(e,M),we=H.matches.filter(z=>!Le(z.symbol)),j=Q!==null&&we.length===0;j&&F(Q,0,"source-construct-anchor",M,!0);let B=j?we:H.matches;for(let z of B)be(z,0,"symbol-anchor",M,"all",!0);let G=j?PF(Q):null,oe=j?1:H.total;T.push({kind:"symbol",query:M,status:oe===0?"missing":oe===1?"matched":"ambiguous",matchedRegionIds:[],symbolCandidates:[...G?[G]:[],...B.map($F)],totalSymbolCandidates:oe,omittedSymbolCandidates:H.omitted})}for(let M=0;M<p;M+=1){if(a.has("call")){let j=[...x.values()].filter(B=>B.traversalEligible&&B.reverseCallExpansion&&B.depth<=M&&!K.has(an(B)));for(let B of j){K.add(an(B));let G=ee(e,B.file);if((G?.callables??[]).filter(ue=>ue.name===B.name&&ue.startLine<=B.endLine&&ue.endLine>=B.startLine).length===1){let ue=(G?.callSites??[]).filter(xe=>xe.calleeLeaf===B.name&&!xe.memberAccess);for(let xe of ue){let Te=M+1,ve=Ge(J(e,B.file),xe.line),Pe=null,We=null;if(ve&&!Le(ve.symbol)){if(ve.relativePath===B.file&&ve.startLine<=B.endLine&&ve.endLine>=B.startLine)continue;be(ve,Te,"reverse-local-call-owner",void 0,"forward-regions",!0),Pe=ve.symbol}else{let O=Jc(e,B.file,xe.line);O&&an(O)!==an(B)&&(We=F(O,Te,"reverse-local-call-source-owner",void 0,!0))}!Pe&&!We||Et(_,{kind:"call",evidence:"ast-callsite",fromFile:B.file,fromSymbol:Pe,toFile:B.file,toSymbol:null,fromSourceConstruct:We?yt(We):void 0,toSourceConstruct:yt(B),line:xe.line,strength:"derived"})}}let z=new Set([...v.get(B.file)??[],...te.get(an(B))??[],...jp(e,B.file).flatMap(ue=>[...v.get(ue)??[]])]);for(let ue of z){if(!f(ue))continue;let Te=ge(ue).targets.filter(ve=>ve.targetFile===B.file&&ve.targetStartLine<=B.endLine&&ve.targetEndLine>=B.startLine);for(let ve of Te){let Pe=M+1,We=Ge(J(e,ue),ve.line),O=null,Ie=null;if(We&&!Le(We.symbol))be(We,Pe,"reverse-member-call-owner",void 0,"cross-workspace-or-forward",!0),O=We.symbol;else{let ne=Jc(e,ue,ve.line);ne&&(Ie=F(ne,Pe,"reverse-member-call-source-owner",void 0,!0))}!O&&!Ie||Et(_,{kind:"call",evidence:"ast-service-member-callsite",fromFile:ue,fromSymbol:O,toFile:B.file,toSymbol:null,fromSourceConstruct:Ie?yt(Ie):void 0,toSourceConstruct:yt(B),line:ve.line,strength:ve.strength==="exact"?"exact":"derived"})}}}}let H=[...I.values()].filter(j=>!j.processed&&j.depth<=M),Q=a.has("call")?h.calleeMap(H.map(j=>j.definition),{additive:!1,semantic:!1}):new Map;for(let j of H){j.processed=!0;let B=j.definition;if(j.referenceScope!=="none"&&(a.has("call")||a.has("reference")||a.has("contract-symbol"))){let G=_F(e,h,B).filter(z=>f(z.file)&&UF(j,z.file,L,y)),oe=new Set(G.flatMap(z=>{if(!(a.has("call")&&ee(e,z.file)?.callSites.some(Te=>Te.line===z.line&&Te.calleeLeaf===B.leaf)===!0)||!z.enclosingSymbol)return[];let xe=Wn(e,h,z.enclosingSymbol).matches[0];return xe&&!Le(xe.symbol)?[{owner:xe,site:z}]:[]}).sort((z,ue)=>{let xe=It(B.relativePath,y).relativeDir,Te=It(z.owner.relativePath,y).relativeDir===xe,ve=It(ue.owner.relativePath,y).relativeDir===xe,Pe=Ry(e,z.owner),We=Ry(e,ue.owner),O=z.owner.endLine-z.owner.startLine,Ie=ue.owner.endLine-ue.owner.startLine;return Number(ve)-Number(Te)||We-Pe||O-Ie||z.owner.symbol.localeCompare(ue.owner.symbol)}).filter((z,ue,xe)=>xe.findIndex(Te=>Te.owner.symbol===z.owner.symbol)===ue).reduce((z,ue)=>{if(z.length>=iF)return z;let xe=It(ue.owner.relativePath,y).relativeDir;return z.some(Te=>Te.workspace===xe)||z.push({symbol:ue.owner.symbol,workspace:xe}),z},[]).map(z=>z.symbol));for(let z of G){let ue=M+1;ce(z.file,ue,`reference:${k(B.symbol)}`,!0);let xe=a.has("call")&&ee(e,z.file)?.callSites.some(Pe=>Pe.line===z.line&&Pe.calleeLeaf===B.leaf)===!0,Te=null,ve=null;if(z.enclosingSymbol){let Pe=Wn(e,h,z.enclosingSymbol).matches[0];Pe&&!Le(Pe.symbol)&&(be(Pe,ue,"reference-owner",void 0,xe&&oe.has(Pe.symbol)?j.referenceScope:"none"),Te=Pe.symbol)}if(!Te&&z.line!==null){let Pe=Jc(e,z.file,z.line);Pe&&(ve=F(Pe,ue,"reference-source-owner",void 0,xe))}a.has("reference")&&Et(_,{kind:"reference",evidence:"indexed-or-source-reference",fromFile:z.file,fromSymbol:Te,toFile:B.relativePath,toSymbol:B.symbol,fromSourceConstruct:ve?yt(ve):void 0,line:z.line,strength:"mixed"}),xe&&Et(_,{kind:"call",evidence:"ast-callsite",fromFile:z.file,fromSymbol:Te,toFile:B.relativePath,toSymbol:B.symbol,fromSourceConstruct:ve?yt(ve):void 0,line:z.line,strength:"derived"}),a.has("contract-symbol")&&It(z.file,y).relativeDir!==It(B.relativePath,y).relativeDir&&Et(_,{kind:"contract-symbol",evidence:"compiler-cross-workspace-symbol",fromFile:z.file,fromSymbol:Te,toFile:B.relativePath,toSymbol:B.symbol,fromSourceConstruct:ve?yt(ve):void 0,line:z.line,strength:"exact"})}}for(let G of Q.get(B.symbolId)??[]){let oe=Wn(e,h,G.symbol).matches.find(ue=>ue.relativePath===G.file);if(!oe||!f(oe.relativePath))continue;if(!(oe.relativePath===B.relativePath||(S.get(B.relativePath)??new Set).has(oe.relativePath))){q+=1;continue}be(oe,M+1,`call:${k(B.symbol)}`,void 0,"none",!0),Et(_,{kind:"call",evidence:G.source,fromFile:B.relativePath,fromSymbol:B.symbol,toFile:oe.relativePath,toSymbol:oe.symbol,line:null,strength:bF(G.source)})}}let we=[...L.values()].filter(j=>!j.processed&&j.primary&&j.depth<=M);for(let j of we){j.processed=!0;let B=[...x.values()].filter(O=>O.traversalEligible&&O.file===j.file&&O.depth<=M),G=[...I.values()].filter(O=>O.definition.relativePath===j.file&&O.depth<=M).map(O=>{let Ie=Ui(e,j.file,O.definition.startLine);return{startLine:Ie?.startLine??O.definition.startLine,endLine:Ie?.endLine??O.definition.endLine}}),oe=O=>[...I.values()].filter(Ie=>Ie.definition.relativePath===j.file&&Ie.definition.startLine<=O&&Ie.definition.endLine>=O).sort((Ie,ne)=>Ie.definition.endLine-Ie.definition.startLine-(ne.definition.endLine-ne.definition.startLine)||Ie.definition.startLine-ne.definition.startLine)[0],z=[...w.values()].filter(O=>O.source.file===j.file&&C.has(O.id)),ue=[...B.map(O=>({startLine:O.startLine,endLine:O.endLine})),...z.map(O=>({...ga(e,O)}))],xe=[...G,...ue],Te=(ee(e,j.file)?.callSites??[]).filter(O=>xe.some(Ie=>O.line>=Ie.startLine&&O.line<=Ie.endLine)),ve=new Set;if(a.has("call"))for(let O of xe){let Ie=xn(e,j.file,O.startLine,O.endLine);for(let ne of Ie.targets){if(!f(ne.definition.relativePath))continue;let Ve=oe(ne.sourceLine),$t=B.find(Dt=>Dt.startLine<=ne.sourceLine&&Dt.endLine>=ne.sourceLine),bt=z.find(Dt=>{let st=ga(e,Dt);return st.startLine<=ne.sourceLine&&st.endLine>=ne.sourceLine});be(ne.definition,M+1,`scip-occurrence-call:${j.file}:${ne.sourceLine+1}`,void 0,"none",!0),Et(_,{kind:"call",evidence:"scip-occurrence-callsite",fromFile:j.file,fromSymbol:Ve?.definition.symbol??null,toFile:ne.definition.relativePath,toSymbol:ne.definition.symbol,fromBoundaryParticipant:bt?nr(bt):void 0,fromSourceConstruct:$t?yt($t):void 0,line:ne.sourceLine,strength:"exact"}),ve.add(`${ne.sourceLine}\0${ne.calleeLeaf}`)}}if(a.has("reference"))for(let O of xe){let Ie=Vp(e,j.file,O.startLine,O.endLine);for(let ne of Ie.targets){if(!f(ne.definition.relativePath)||ve.has(`${ne.sourceLine}\0${ne.calleeLeaf}`))continue;let Ve=oe(ne.sourceLine);if(Ve?.definition.symbol===ne.definition.symbol)continue;let $t=B.find(Dt=>Dt.startLine<=ne.sourceLine&&Dt.endLine>=ne.sourceLine),bt=z.find(Dt=>{let st=ga(e,Dt);return st.startLine<=ne.sourceLine&&st.endLine>=ne.sourceLine});be(ne.definition,M+1,`scip-occurrence-reference:${j.file}:${ne.sourceLine+1}`,void 0,"none",!0),Et(_,{kind:"reference",evidence:"scip-occurrence-reference",fromFile:j.file,fromSymbol:Ve?.definition.symbol??null,toFile:ne.definition.relativePath,toSymbol:ne.definition.symbol,fromBoundaryParticipant:bt?nr(bt):void 0,fromSourceConstruct:$t?yt($t):void 0,line:ne.sourceLine,strength:"exact"})}}let Pe=a.has("call")?Un(e,j.file,{ranges:xe,excludeIndexedTargets:!1}):{targets:[],unresolvedCallsites:0};N+=Pe.unresolvedCallsites;let We=Pe.targets.filter(O=>!ve.has(`${O.line}\0${O.calleeLeaf}`));Y+=We.filter(O=>O.strength!=="exact"&&(O.resolution!=="imported-service-object-member"||(O.resolutionAlternativeCount??0)>1)).length;for(let O of We){let Ie=(O.resolutionAlternativeCount??1)===1,ne=O.targetSymbol?J(e,O.targetFile).find(st=>st.symbol===O.targetSymbol):void 0,Ve=ne?null:F({file:O.targetFile,name:O.calleeLeaf,startLine:O.targetStartLine,endLine:O.targetEndLine},M+1,`member-call:${j.file}`,void 0,O.resolution==="imported-service-object-member"&&Ie,Ie);if(Ve&&O.serviceFile){let st=an(Ve),pr=te.get(st)??new Set;for(let px of v.get(O.serviceFile)??[])pr.add(px);te.set(st,pr)}ne&&be(ne,M+1,`member-call:${j.file}`,void 0,"none",!0);let $t=B.find(st=>st.startLine<=O.line&&st.endLine>=O.line),bt=oe(O.line),Dt=z.find(st=>{let pr=ga(e,st);return pr.startLine<=O.line&&pr.endLine>=O.line});Et(_,{kind:"call",evidence:O.resolution==="constructed-member-receiver"?"ast-constructed-member-callsite":O.resolution==="factory-callback-member"?"ast-factory-callback-callsite":O.resolution==="imported-service-object-member"?"ast-service-member-callsite":"ast-member-import-candidate",fromFile:j.file,fromSymbol:bt?.definition.symbol??null,toFile:O.targetFile,toSymbol:ne?.symbol??null,fromBoundaryParticipant:Dt?nr(Dt):void 0,fromSourceConstruct:$t?yt($t):void 0,toSourceConstruct:Ve?yt(Ve):void 0,line:O.line,strength:O.resolution==="imported-service-object-member"?(O.resolutionAlternativeCount??0)===1?"derived":"candidate":O.strength??"candidate"})}for(let O of a.has("import")||a.has("call")?BF(e,j.file):[]){if(!O.fromFile){if(a.has("import")){let ne=D.get(O.shortName)??{name:O.shortName,fromFiles:new Set};ne.fromFiles.add(j.file),D.set(O.shortName,ne)}continue}if(!f(O.fromFile))continue;if(a.has("import")&&(ce(O.fromFile,M+1,`import:${j.file}`,!1),Et(_,{kind:"import",evidence:"indexed-or-source-import",fromFile:j.file,fromSymbol:null,toFile:O.fromFile,toSymbol:O.symbol,line:null,strength:"mixed"})),a.has("call")&&Te.length>0){let ne=(O.source==="compiler"?Wn(e,h,O.symbol).matches:_n(e,O.fromFile,O.importedName)).filter(Ve=>!Le(Ve.symbol));for(let Ve of ne){let $t=Te.filter(bt=>bt.calleeLeaf===O.localName).map(bt=>bt.line);if($t.length!==0){be(Ve,M+1,`source-call:${j.file}`,void 0,"none",!0);for(let bt of $t)Et(_,{kind:"call",evidence:"ast-callsite",fromFile:j.file,fromSymbol:null,toFile:Ve.relativePath,toSymbol:Ve.symbol,line:bt,strength:"derived"})}}}if(!j.promoteBoundaryImports||!jF(j.file,O.fromFile,y))continue;let Ie=Wn(e,h,O.symbol);for(let ne of Ie.matches)if(HF(ne.relativePath,O.fromFile,y)&&!Le(ne.symbol)){let Ve=It(j.file,y).relativeDir!==It(ne.relativePath,y).relativeDir;be(ne,M+1,`boundary-import:${j.file}`,void 0,Ve?"cross-workspace-or-forward":"forward-regions")}}}for(let j of a.has("runtime-boundary")?E?.links??[]:[]){if(j.strength==="candidate"||l==="exact"&&j.strength!=="exact"||R.has(j.id))continue;let B=w.get(j.from),G=w.get(j.to);if(!B||!G||!f(B.source.file)||!f(G.source.file))continue;let oe=Py(B,M,C,I,x),z=Py(G,M,C,I,x);if(oe===null&&z===null)continue;let ue=M+1,xe=Z(B,oe??ue,`runtime-boundary:${j.joinRule}`),Te=Z(G,z??ue,`runtime-boundary:${j.joinRule}`),ve=xe?null:Dy(x,B),Pe=Te?null:Dy(x,G);C.set(B.id,oe??ue),C.set(G.id,z??ue),Et(_,{kind:"runtime-boundary",evidence:`runtime-boundary:${j.joinRule}`,fromFile:B.source.file,fromSymbol:xe,toFile:G.source.file,toSymbol:Te,fromBoundaryParticipant:nr(B),toBoundaryParticipant:nr(G),fromSourceConstruct:ve?yt(ve):void 0,toSourceConstruct:Pe?yt(Pe):void 0,runtimeBoundaryKey:j.matchedKeyParts.map(We=>`${We.name}=${We.value}`).join(" "),line:B.source.startLine,strength:j.strength}),R.add(j.id)}}let X=new Map;for(let M of L.keys())X.set(M,ao(M,y));let Se=[..._.values()].filter(M=>X.has(M.fromFile)&&X.has(M.toFile)).map(M=>({...M,fromRegionId:X.get(M.fromFile).id,toRegionId:X.get(M.toFile).id})).sort(_y),tt=XF(Se),ni=new Set(t.expand??[]),An=WF(L,I,P,Se,tt,X,ni),Ti=new Set([...L.values()].filter(M=>[...M.origins].some(H=>H.startsWith("literal-anchor:")||H==="literal-owner"||H==="symbol-anchor")).map(M=>X.get(M.file).id)),Td=xF(An),ix=new Set(An.map(M=>M.id)),rx=[...ni].filter(M=>!ix.has(M)).sort();for(let M of T)if(M.matchedRegionIds=QF(M,P,I,X),M.kind==="literal"){let H=P.filter(Q=>Q.query===M.query);M.seedRegionIds=De(H.filter(Q=>Q.traversalSeed).map(Q=>X.get(Q.file).id)),M.matchOnlyRegionIds=De(H.filter(Q=>!Q.traversalSeed).map(Q=>X.get(Q.file).id))}let Fd=[...I.values()].filter(M=>!M.processed).length,Md=[...L.values()].filter(M=>M.primary&&!M.processed).length,Ad=[...L.values()].filter(M=>!M.primary&&!M.processed).length,Nd=[...I.values()].filter(M=>M.processed),Bo=(E?.frontiers??[]).flatMap(M=>{let H=w.get(M.observationId);return!H&&M.source&&M.action&&M.strength?!a.has("runtime-boundary")||!f(M.source.file)||l==="exact"||!L.has(M.source.file)?[]:[{observationId:M.observationId,action:M.action,strength:M.strength,file:M.source.file,line:M.source.startLine,ownerShortName:M.ownerShortName??null,address:M.address??M.missingKeyParts.join(", "),reason:M.reason}]:!a.has("runtime-boundary")||!H||!f(H.source.file)||l==="exact"&&H.strength!=="exact"||!L.has(H.source.file)?[]:[{observationId:H.id,action:H.action,strength:H.strength,file:H.source.file,line:H.source.startLine,ownerShortName:H.owner.name,address:ky(H),reason:M.reason,protocol:H.protocol,role:H.role,modality:H.modality,resolution:H.resolution,sourceScope:H.sourceScope,keyParts:H.keyParts.map(Q=>({name:Q.name,value:Q.value,evidence:Q.evidence}))}]}).sort((M,H)=>M.file.localeCompare(H.file)||M.line-H.line),nl=(E?.links??[]).filter(M=>{if(!a.has("runtime-boundary")||l==="exact"&&M.strength!=="exact")return!1;let H=w.get(M.from),Q=w.get(M.to);return!!(H&&Q&&f(H.source.file)&&f(Q.source.file)&&(L.has(H.source.file)||L.has(Q.source.file)))}),ox=nl.filter(M=>M.strength==="exact").length,sx=nl.filter(M=>M.strength==="derived").length,ax=nl.filter(M=>M.strength==="candidate").length,lx=E?.links.filter(M=>M.strength==="exact").length??0,cx=E?.links.filter(M=>M.strength==="derived").length??0,ux=E?.links.filter(M=>M.strength==="candidate").length??0,il=ZF(D,X),rl=A===0?"accounted":"incomplete",kd=[...W>0?[`${W} broad literal anchor(s) withheld ${le} 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 (${c.join(", ")}) remain visible as match-only evidence and do not seed traversal.`,E?"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 ${p}; nonzero frontier counts identify evidence that was discovered but not traversed.`,"Region labels are structural path groupings, not inferred runtime or architectural boundaries."],Lt=dF({db:e,anchors:T,regions:An,symbolStates:I,sourceConstructStates:x,literalHits:P,relations:Se,externalBoundaries:il,boundaryFrontiers:Bo,regionForFile:X,closureStatus:rl,omittedSymbolCandidates:A,maxDepth:p,requestedRelationKinds:o,evidenceFloor:l,includedSourceScopes:c,blindSpots:kd,topologyFrontiers:t.topologyFrontiers??[],routeIds:t.routeIds??[],expandedRegionIds:[...ni],maxTopologyCharacters:g,fullLiteralTraversal:t.fullLiteralTraversal??!1});if(n==="topology")return Lt;let _d=(t.behaviorFocusLocations?.length??0)>0?new Set([...Lt.anchors.flatMap(M=>M.nodeIds),...Lt.paths.flatMap(M=>M.nodeIds)]).size:void 0,Oo=Fg(e,Lt,{focusLocations:t.behaviorFocusLocations,..._d?{maxSteps:_d}:{}});lh(e,Lt,Oo);let dx=aF(e,Lt,Oo,t.behaviorFocusLocations??[]);Lt.corridor=sy(Lt,{focusLocations:dx});let Bd=ah(e,Lt,Oo,{sourceAllowed:f,selectionTerms:t.selectionTerms}),Od=hF(Lt),mx=vF(i,r,p,o,l,c,t.fullLiteralTraversal??!1,g,An,tt,Ti,ni,Od),fx=SF(i,r,p,An.filter(M=>Od.has(M.id)),Ti,o,l,c,t.fullLiteralTraversal??!1,g);return{anchors:T,regions:An,regionRelations:tt,externalBoundaries:il,boundaryFrontiers:Bo,unmatchedExpansions:rx,expansion:fx,drilldown:Td,presentation:mx,topology:Lt,behavior:Oo,nextAnchors:Bd,closure:{status:rl,emitted:{regions:An.length,relations:Se.length,runtimeLinks:R.size},withheld:{symbols:Fd,files:Md+Ad,regions:Lt.nodes.filter(M=>M.kind==="structural-region"&&M.disposition==="folded").length,drillAnchors:(Td?.omittedAnchors??0)+Bd.omittedAnchors,literalMatches:le},ambiguous:{anchors:T.filter(M=>M.status==="ambiguous").length,omittedSymbolCandidates:A},external:il.length,unresolved:Bo.length,explanation:rl==="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:T.length,requestedRelationKinds:o,evidenceFloor:l,includedSourceScopes:c,matchedAnchorCount:T.filter(M=>M.status!=="missing").length,literalSearchesComplete:!0,broadLiteralAnchors:W,withheldLiteralMatches:le,symbolCandidateSetsComplete:A===0,omittedSymbolCandidates:A,maxTraversalDepth:p,frontierSymbols:Fd,frontierFiles:Md,supportFilesNotTraversed:Ad,filteredUnverifiedCallEdges:q,memberCallCandidateEdges:Y,unresolvedMemberCallsites:N,runtimeBoundaryEvidenceAvailable:E!==null,runtimeBoundaryObservations:E?.observations.length??0,runtimeBoundaryExactLinks:ox,runtimeBoundaryDerivedLinks:sx,runtimeBoundaryCandidateLinks:ax,repositoryRuntimeBoundaryExactLinks:lx,repositoryRuntimeBoundaryDerivedLinks:cx,repositoryRuntimeBoundaryCandidateLinks:ux,runtimeBoundaryTraversedLinks:R.size,runtimeBoundaryFrontiers:Bo.length,referenceExpansionEligibleSymbols:Nd.filter(M=>M.referenceScope!=="none").length,referenceExpansionSkippedSymbols:Nd.filter(M=>M.referenceScope==="none").length,dynamicDispatchRepresented:E?.links.some(M=>M.joinRule==="carrier.discriminator"&&R.has(M.id))??!1,runtimeGeneratedLinksRepresented:E!==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:kd}}}function aF(e,t,n,i){let r=new Map,o=l=>{r.set(`${l.file}\0${l.line}`,l)};for(let l of i)o(l);let s=new Set(t.anchors.filter(l=>l.status==="matched").flatMap(l=>l.nodeIds));for(let l of n.steps)if(!(!l.location||!s.has(l.nodeId)||(l.behavior?.rawCharacters??1/0)>3e3))for(let c of l.behavior?.lines??[])c.signals.some(u=>rF.has(u))&&o({file:l.location.file,line:c.line,endLine:c.endLine});let a=t.edges.filter(l=>l.disposition==="emitted").flatMap(l=>l.evidence.flatMap(c=>c.location?[c.location]:[]));for(let l of a){o(l);let c=t.nodes.filter(d=>d.location?.file===l.file&&["symbol","source-construct","runtime-boundary-participant"].includes(d.kind)&&d.location.line<=l.line&&(d.location.endLine??d.location.line)>=l.line).sort((d,m)=>(d.location.endLine??d.location.line)-d.location.line-((m.location.endLine??m.location.line)-m.location.line)||d.id.localeCompare(m.id))[0];if(!c?.location)continue;let u=Cs(e,l.file,c.location.line,c.location.endLine??c.location.line,[l.line]);for(let d of u)o({file:l.file,line:d.line,endLine:d.endLine})}return[...r.values()].sort((l,c)=>l.file.localeCompare(c.file)||l.line-c.line)}function lF(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 an(e){return`${e.file}\0${e.startLine}\0${e.endLine}\0${e.name}`}function yt(e){return{file:e.file,name:e.name,startLine:e.startLine,endLine:e.endLine}}function pa(e,t){let n=Qc(ee(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 i=Ny(e,t.file,t.startLine);return i&&i.endLine>=t.endLine?{file:t.file,name:i.name,startLine:i.startLine,endLine:i.endLine}:yt(t)}function tr(e){return wt("source-construct",e.file,String(e.startLine),String(e.endLine),e.name)}function ya(e,t){let n=qi(e,t.symbol,t.relativePath),i=new Set(["package-surface-file","transitive-package-surface"]),r=n.filter(s=>!i.has(s)||Ct(e,t)),o=r.some(s=>!i.has(s));return{evidence:r,priority:o||pg(e,t.symbol,t.relativePath)?2:1}}function Ry(e,t){let n=ya(e,t);return n.evidence.length>0?n.priority:0}function cF(e,t){let n=J(e,t.file),i=n.filter(r=>r.startLine<=t.startLine&&r.endLine>=t.startLine).sort((r,o)=>r.endLine-r.startLine-(o.endLine-o.startLine)||r.startLine-o.startLine);for(let r of i){let o=ya(e,r);if(o.evidence.length>0)return o}for(let r of uF(e,t.file,t.startLine)){let o=n.filter(s=>s.leaf===r.name).sort((s,a)=>Math.abs(s.startLine-r.startLine)-Math.abs(a.startLine-r.startLine)||s.symbol.localeCompare(a.symbol));for(let s of o){let a=ya(e,s);if(a.evidence.length>0)return a}return{evidence:[],priority:0}}return{evidence:[],priority:0}}function uF(e,t,n){let i=ae(e,t)?.rootNode;if(!i||i.startPosition.row>n||i.endPosition.row<n)return[];let r=[],o=eu(i,n);for(;o;){if(o.type==="variable_declarator"||o.type==="function_declaration"||o.type==="generator_function_declaration"||o.type==="class_declaration"){let s=o.childForFieldName("name")??o.namedChild(0);(s?.type==="identifier"||s?.type==="type_identifier")&&r.push({name:s.text,startLine:o.startPosition.row})}o=o.parent}return r}function dF(e){let t=[...new Map([...e.sourceConstructStates.values()].map(x=>pa(e.db,x)).map(x=>[an(x),x])).values()].sort((x,P)=>x.file.localeCompare(P.file)||x.startLine-P.startLine||x.endLine-P.endLine),n=e.anchors.map((x,P)=>{let _=wt("anchor",String(P),x.kind,x.query),D=[...e.symbolStates.values()].filter(q=>q.anchorQueries.has(x.query)).flatMap(q=>{if(!Le(q.definition.symbol))return[Vn(q.definition.symbol)];let Y=t.filter(N=>N.file===q.definition.relativePath).map(N=>tr(N));return Y.length>0?Y:[Vn(q.definition.symbol)]}),T=[...e.sourceConstructStates.values()].filter(q=>q.anchorQueries.has(x.query)).map(q=>tr(pa(e.db,q))),A=e.literalHits.filter(q=>q.query===x.query&&q.traversalSeed===!0&&q.ownerSymbol&&e.symbolStates.has(q.ownerSymbol)).map(q=>Vn(q.ownerSymbol)),W=e.literalHits.filter(q=>q.query===x.query&&q.traversalSeed===!0&&!q.ownerSymbol&&q.ownerStartLine!==null&&q.ownerStartLine!==void 0&&q.ownerEndLine!==null&&q.ownerEndLine!==void 0).map(q=>tr(pa(e.db,lF(q)))),le=De(x.kind==="symbol"?[...D,...T]:A.length+W.length>0?[...A,...W]:x.seedRegionIds??[]);return{id:_,kind:x.kind,query:x.query,status:x.status,nodeIds:x.status==="ambiguous"?[]:le,candidateNodeIds:x.status==="ambiguous"?le:[],omittedCandidates:x.omittedSymbolCandidates??0}}),i=new Map;for(let x of n)for(let P of[...x.nodeIds,...x.candidateNodeIds]){let _=i.get(P)??[];_.push(x.id),i.set(P,_)}let r=e.relations.flatMap(x=>[x.fromBoundaryParticipant,x.toBoundaryParticipant].flatMap(P=>P?.ownerName?[P]:[])),o=e.regions.map(x=>({id:x.id,kind:"structural-region",label:x.label,disposition:"folded",location:null,anchorIds:De(i.get(x.id)??[]),attributes:{workspace:x.workspace,structuralPath:x.structuralPath,minimumDepth:x.minDepth,files:x.fileCount,symbols:x.symbolCount,expanded:x.expanded}}));for(let x of e.symbolStates.values()){let P=e.regionForFile.get(x.definition.relativePath)?.id;if(!P)throw new Error(`System-map symbol ${x.definition.symbol} has no structural region.`);let _=Vn(x.definition.symbol),D=ya(e.db,x.definition);o.push({id:_,kind:"symbol",label:k(x.definition.symbol),disposition:(i.get(_)?.length??0)>0?"emitted":"folded",location:{file:x.definition.relativePath,line:x.definition.startLine,endLine:x.definition.endLine},anchorIds:De(i.get(_)??[]),attributes:{regionId:P,depth:x.depth,leaf:x.definition.leaf??k(x.definition.symbol),referenceScope:x.referenceScope,...D.evidence.length>0?{publicEntry:!0,publicEntryPriority:D.priority,publicEntryEvidence:D.evidence.join(",")}:{}}})}for(let x of t){let P=e.regionForFile.get(x.file)?.id;if(!P)throw new Error(`Source construct ${x.name} has no structural region.`);let _=tr(x),T=r.find(W=>W.file===x.file&&W.line>=x.startLine&&W.line<=x.endLine)?.ownerName??x.name,A=cF(e.db,x);o.push({id:_,kind:"source-construct",label:T,disposition:(i.get(_)?.length??0)>0?"emitted":"folded",location:{file:x.file,line:x.startLine,endLine:x.endLine},anchorIds:De(i.get(_)??[]),attributes:{regionId:P,leaf:T,sourceOwned:!0,...A.evidence.length>0?{publicEntry:!0,publicEntryPriority:A.priority,publicEntryEvidence:A.evidence.join(",")}:{}}})}let s=new Map;for(let x of e.relations)x.fromBoundaryParticipant&&s.set(x.fromBoundaryParticipant.observationId,x.fromBoundaryParticipant),x.toBoundaryParticipant&&s.set(x.toBoundaryParticipant.observationId,x.toBoundaryParticipant);for(let x of[...s.values()].sort((P,_)=>P.observationId.localeCompare(_.observationId))){let P=e.regionForFile.get(x.file)?.id;if(!P)throw new Error(`Runtime-boundary participant ${x.observationId} has no structural region.`);o.push({id:Yc(x.observationId),kind:"runtime-boundary-participant",label:x.address||x.ownerName||`${x.role} ${x.action}`,disposition:"folded",location:{file:x.file,line:x.line,endLine:x.endLine},anchorIds:[],attributes:{regionId:P,action:x.action,protocol:x.protocol,role:x.role,...x.address?{address:x.address}:{},ownerSymbol:x.ownerSymbol}})}let a=new Set(o.map(x=>x.id)),l=Kt(t,x=>x.file),c=(x,P,_,D,T,A,W=!1)=>{let le=x?Vn(x):null;if(le&&a.has(le)&&!Le(x))return le;let q=P?Yc(P.observationId):null;if(W&&q&&a.has(q))return q;let Y=_?tr(pa(e.db,_)):null;if(Y&&a.has(Y))return Y;if(q&&a.has(q))return q;let N=A===null?null:(l.get(T)??[]).filter(K=>K.startLine<=A&&K.endLine>=A).sort((K,te)=>K.endLine-K.startLine-(te.endLine-te.startLine)||K.startLine-te.startLine)[0]??null;return N?tr(N):le&&a.has(le)?le:D},u=[];for(let x of e.symbolStates.values()){let P=e.regionForFile.get(x.definition.relativePath)?.id;if(!P)continue;let _=Vn(x.definition.symbol);u.push({id:wt("edge","structural-membership",P,_),kind:"structural-membership",fromNodeId:P,toNodeId:_,directed:!0,disposition:"folded",semantics:na("structural-membership"),evidence:[{method:"indexed-definition-file",strength:"exact",identity:x.definition.symbol,location:{file:x.definition.relativePath,line:x.definition.startLine,endLine:x.definition.endLine}}]})}let d=Kt(e.relations,x=>`${c(x.fromSymbol,x.fromBoundaryParticipant,x.fromSourceConstruct,x.fromRegionId,x.fromFile,x.line,x.kind==="runtime-boundary")}\0${c(x.toSymbol,x.toBoundaryParticipant,x.toSourceConstruct,x.toRegionId,x.toFile,null)}\0${x.kind}`),m=new Set;for(let x of d.values()){let P=x[0],_=c(P.fromSymbol,P.fromBoundaryParticipant,P.fromSourceConstruct,P.fromRegionId,P.fromFile,P.line,P.kind==="runtime-boundary"),D=c(P.toSymbol,P.toBoundaryParticipant,P.toSourceConstruct,P.toRegionId,P.toFile,null);if(P.kind==="runtime-boundary"&&P.fromBoundaryParticipant){let A=Yc(P.fromBoundaryParticipant.observationId),W=c(P.fromSymbol,void 0,P.fromSourceConstruct,P.fromRegionId,P.fromFile,P.line);W!==A&&!m.has(A)&&(m.add(A),u.push({id:wt("edge","boundary-observation",W,A),kind:"boundary-observation",fromNodeId:W,toNodeId:A,directed:!0,disposition:"folded",semantics:na("boundary-observation"),evidence:[{method:"runtime-boundary-observation-owner",strength:P.strength??"unknown",identity:P.fromBoundaryParticipant.observationId,location:{file:P.fromBoundaryParticipant.file,line:P.fromBoundaryParticipant.line,endLine:P.fromBoundaryParticipant.endLine}}]}))}(_===D?o.find(A=>A.id===_):null)?.kind!=="structural-region"&&u.push({id:wt("edge",P.kind,_,D),kind:P.kind,fromNodeId:_,toNodeId:D,directed:!0,disposition:"folded",semantics:Fh(P),evidence:yF(x.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 x of e.externalBoundaries){let P=wt("external",x.kind,x.name),_=De(x.fromRegionIds);o.push({id:P,kind:x.kind,label:x.name,disposition:"folded",location:null,anchorIds:[],attributes:{}});for(let D of _)u.push({id:wt("edge",x.kind,D,P),kind:x.kind,fromNodeId:D,toNodeId:P,directed:!0,disposition:"folded",semantics:na("external-import"),evidence:[{method:"indexed-or-source-import",strength:"mixed",identity:`${D} -> ${x.name}`,location:null}]})}let f=[];e.boundaryFrontiers.forEach((x,P)=>{let _=e.regionForFile.get(x.file)?.id;if(!_)throw new Error(`Runtime-boundary frontier ${x.observationId} has no system-map region.`);let D=wt("unsupported","runtime-boundary",x.observationId,String(P)),T=wt("edge","runtime-boundary-frontier",_,D);o.push({id:D,kind:"runtime-boundary-frontier",label:x.address,disposition:"unsupported",location:{file:x.file,line:x.line},anchorIds:[],attributes:{action:x.action,strength:x.strength,owner:x.ownerShortName}}),u.push({id:T,kind:"runtime-boundary-frontier",fromNodeId:_,toNodeId:D,directed:!0,disposition:"unsupported",evidence:[{method:"runtime-boundary-extractor",strength:x.strength,identity:x.observationId,location:{file:x.file,line:x.line}}]}),f.push({id:wt("frontier","runtime-boundary",x.observationId,String(P)),kind:"runtime-boundary",direction:"unresolved",fromNodeIds:[_],edgeIds:[T],memberNodeIds:[D],memberCount:1,disposition:"unsupported",reason:x.reason,expansion:null})});let p=fa({anchors:n,nodes:o,edges:u,paths:[],frontiers:f,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`]:[]}),g=e.topologyFrontiers.some(x=>x==="frontier:program-facts"),h=Sy(p,{expandedFrontierIds:e.topologyFrontiers.filter(x=>x!=="frontier:program-facts"),routeIds:e.routeIds}),S=h.nodes.filter(x=>x.disposition==="emitted"||h.anchors.some(P=>P.status==="matched"&&P.nodeIds.includes(x.id))),v=e.relations.filter(x=>S.some(P=>mF(x,P))),y=e.boundaryFrontiers.filter(x=>S.some(P=>fF(x,P))),E=Hh(e.db,v,S),w=zh(e.db,S),b=ty(e.db,S,y),R=[...E.nodes,...w.nodes,...b.nodes].map(x=>g&&x.disposition==="folded"?{...x,disposition:"emitted"}:x),C=[...E.edges,...w.edges,...b.edges].map(x=>g&&x.disposition==="folded"?{...x,disposition:"emitted"}:x),L=g?null:pF(S,R,C),I=fa({anchors:h.anchors,nodes:[...h.nodes,...R],edges:[...h.edges,...C],paths:h.paths,frontiers:[...h.frontiers,...E.frontiers,...w.frontiers,...b.frontiers,...L?[L]:[]],scope:h.coverage.scope,blindSpots:[...h.coverage.blindSpots,...E.blindSpots,...w.blindSpots,...b.blindSpots],incompleteReasons:h.coverage.status==="incomplete"?[h.coverage.explanation]:[],...h.routeCatalog?{routeCatalog:h.routeCatalog}:{}});I.completion=h.completion;for(let x of I.frontiers)x.disposition==="folded"&&(x.id.startsWith("frontier:program-facts:")||(x.expansion=gF(e,x.id)));return I}function mF(e,t){if(e.fromSymbol&&t.id===Vn(e.fromSymbol)||e.toSymbol&&t.id===Vn(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 fF(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 pF(e,t,n){let i=De(t.filter(o=>o.disposition==="folded").map(o=>o.id)),r=De(n.filter(o=>o.disposition==="folded").map(o=>o.id));return i.length===0&&r.length===0?null:{id:wt("frontier","program-facts"),kind:"program-facts",direction:"outgoing",fromNodeIds:De(e.map(o=>o.id)),edgeIds:r,memberNodeIds:i,memberCount:i.length,disposition:"folded",reason:"Control, data, state, and temporal facts are folded beneath the selected high-level owners.",expansion:null}}function gF(e,t){return`codebaseiq system-map ${[...e.anchors.flatMap(i=>i.kind==="literal"?[`--search ${Ne(i.query)}`]:[`--symbol ${Ne(i.query)}`]),`--depth ${e.maxDepth}`,...e.requestedRelationKinds.map(i=>`--relation ${Ne(i)}`),`--evidence-floor ${Ne(e.evidenceFloor)}`,...e.includedSourceScopes.map(i=>`--source-scope ${Ne(i)}`),...e.fullLiteralTraversal?["--full-literal-traversal"]:[],`--topology-characters ${e.maxTopologyCharacters}`,...e.expandedRegionIds.map(i=>`--expand ${Ne(i)}`),...e.topologyFrontiers.map(i=>`--frontier ${Ne(i)}`),...e.routeIds.map(i=>`--route ${Ne(i)}`),`--frontier ${Ne(t)}`].join(" ")}`}function hF(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 i=n.attributes.regionId;typeof i=="string"&&t.add(i)}return t}function yF(e){let t=new Map;for(let n of e){let i=n.location?`${n.location.file}:${n.location.line}`:"";t.set(`${n.method}\0${n.strength}\0${n.identity??""}\0${i}`,n)}return[...t.values()].sort((n,i)=>n.method.localeCompare(i.method)||(n.identity??"").localeCompare(i.identity??"")||(n.location?.file??"").localeCompare(i.location?.file??"")||(n.location?.line??0)-(i.location?.line??0))}function wt(...e){return e.map(t=>encodeURIComponent(t)).join(":")}function Vn(e){return wt("symbol",e)}function bF(e){return e==="semantic-callee"||e==="scip-chunk"?"exact":"derived"}function SF(e,t,n,i,r,o,s,a,l,c){let u=[...i].sort((g,h)=>Ay(g,h,r)),m=u.slice(0,Cy).map(g=>g.id),f=u.slice(Cy).map(g=>g.id),p=[...e.map(g=>`--search ${Ne(g)}`),...t.map(g=>`--symbol ${Ne(g)}`),`--depth ${n}`,...o.map(g=>`--relation ${Ne(g)}`),`--evidence-floor ${Ne(s)}`,...a.map(g=>`--source-scope ${Ne(g)}`),...l?["--full-literal-traversal"]:[],`--topology-characters ${c}`,...m.map(g=>`--expand ${Ne(g)}`)];return{command:m.length===0?null:`codebaseiq system-map ${p.join(" ")}`,regionCount:m.length,regionIds:m,candidateRegionCount:i.length,omittedRegionIds:f}}function vF(e,t,n,i,r,o,s,a,l,c,u,d,m){let f=[...l].sort((I,x)=>Ay(I,x,u)).filter(I=>!m||m.has(I.id)||d.has(I.id)),p=c.length>0?Math.floor(a*.4):0,g=a-p,h=new Set,S=0;for(let I of f){let x=Ey(I);!d.has(I.id)&&h.size>0&&S+x>g||(h.add(I.id),S+=x)}let v=c.filter(I=>h.has(I.fromRegionId)&&h.has(I.toRegionId)).sort(CF),y=[];for(let I of v){let x=wy(I);y.length>0&&S+x>a||(y.push(ba(I)),S+=x)}let E=l.filter(I=>!h.has(I.id)).map(I=>I.id).sort(),w=new Set(y),b=c.filter(I=>!w.has(ba(I))).length,R=l.reduce((I,x)=>I+Ey(x),0)+c.reduce((I,x)=>I+wy(x),0),C=f.every(I=>h.has(I.id))&&y.length===v.length,L=[...e.map(I=>`--search ${Ne(I)}`),...t.map(I=>`--symbol ${Ne(I)}`),`--depth ${n}`,...i.map(I=>`--relation ${Ne(I)}`),`--evidence-floor ${Ne(r)}`,...o.map(I=>`--source-scope ${Ne(I)}`),...s?["--full-literal-traversal"]:[],`--topology-characters ${Math.max(a,R)}`];return{maxCharacters:a,estimatedCharacters:S,totalEstimatedCharacters:R,regionIds:[...h],omittedRegionIds:E,relationKeys:y,omittedRelations:b,complete:C,expansionCommand:C?null:`codebaseiq system-map ${L.join(" ")}`}}function Ey(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 wy(e){return 70+e.fromRegionId.length+e.toRegionId.length+e.kinds.join(",").length+e.evidence.join(",").length}function CF(e,t){let n=i=>i.kinds.includes("runtime-boundary")?0:i.kinds.includes("contract-symbol")?1:2;return n(e)-n(t)||t.relationCount-e.relationCount||ba(e).localeCompare(ba(t))}function ba(e){return`${e.fromRegionId}\0${e.toRegionId}`}function Ay(e,t,n){let i=a=>n.has(a.id)?0:1,r=a=>a.sourceFileCount===0?1:0,o=a=>a.symbolCount+a.literalHitCount>0?0:1,s=a=>[...a.incomingRegionIds,...a.outgoingRegionIds].filter(l=>n.has(l)).length;return i(e)-i(t)||o(e)-o(t)||r(e)-r(t)||e.minDepth-t.minDepth||s(t)-s(e)||t.literalHitCount-e.literalHitCount||e.testFileCount-t.testFileCount||e.label.localeCompare(t.label)}function xF(e){let t=[],n=new Set;for(let r of e.filter(o=>o.expanded)){for(let l of r.symbols)l.origins.includes("symbol-anchor")&&n.add(l.file);let o=Kt(r.symbols,l=>l.file),s=Kt(r.literalHits,l=>l.file),a=[...r.files].sort((l,c)=>EF(l,c,o,s));for(let l of a){let c=(o.get(l.file)??[]).sort(wF)[0];if(c){t.push({kind:"symbol",regionId:r.id,file:c.file,line:c.startLine,endLine:c.endLine,label:c.shortName});continue}let u=(s.get(l.file)??[]).sort(By)[0];u&&t.push({kind:"literal",regionId:r.id,file:u.file,line:u.line,endLine:null,label:u.ownerShortName??u.query})}}let i=RF(t,n);return{command:i.length===0?null:`codebaseiq inspect ${i.map(r=>`--at ${Ne(`${r.file}:${r.line+1}`)}`).join(" ")} --view behavior`,definitionCommand:null,candidateAnchors:t.length,selectedAnchors:i.length,omittedAnchors:t.length-i.length,anchors:i}}function RF(e,t){let n=[...Kt(e,s=>s.regionId).values()],i=[],r=new Set,o=Math.min(nF,24);for(let s of e)if(!(!t.has(s.file)||r.has(s.file))&&(i.push(s),r.add(s.file),i.length===o))return i;for(let s=0;i.length<o;s+=1){let a=!1;for(let l of n){let c=l[s];if(c&&(a=!0,!r.has(c.file)&&(i.push(c),r.add(c.file),i.length===o)))break}if(!a)break}return i}function EF(e,t,n,i){let r=a=>a.kind==="test"?2:a.kind==="barrel"?1:0,o=a=>(i.get(a.file)??[]).some(l=>l.traversalSeed)?0:1,s=a=>{let l=n.get(a.file)??[];return Math.min(5,...l.map(c=>lo(c.origins)))};return r(e)-r(t)||o(e)-o(t)||s(e)-s(t)||e.depth-t.depth||e.file.localeCompare(t.file)}function wF(e,t){return lo(e.origins)-lo(t.origins)||e.depth-t.depth||e.startLine-t.startLine||e.shortName.localeCompare(t.shortName)}function Ne(e){return`'${e.replaceAll("'","'\\''")}'`}function IF(e,t,n,i){let r=[];for(let o of he(e,{includeIgnored:!1})){let s=ie(e,o);if(s.length===0)continue;let a=t.definitionsForFile(o),l=ee(e,o)?.callables??[];for(let c=0;c<s.length;c+=1){let u=s[c]??"";if(!u.includes(n))continue;let d=Ge(a,c),m=Qc(l,c),f=d&&!Le(d.symbol)?d:null,p=f?.startLine??m?.startLine??d?.startLine??c,g=f?.endLine??m?.endLine??d?.endLine??c,h=Ar(e,o,c,p,g),S=i.has(`${o}\0${c}`),v=!!(f?.isFunctionLike||m);r.push({relativePath:o,line:c,sourceLine:u,ownerSymbol:f?.symbol??null,ownerShortName:f?k(f.symbol):m?.name??(d?k(d.symbol):null),ownerStartLine:h.startLine,ownerEndLine:h.endLine,matchKind:TF(u,n),seedPriority:S?0:v?1:2})}}return r}function LF(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 Iy(e){return`${e.relativePath}\0${e.line}`}function Qc(e,t){return e.filter(n=>n.startLine<=t&&n.endLine>=t).sort((n,i)=>n.endLine-n.startLine-(i.endLine-i.startLine)||n.startLine-i.startLine)[0]??null}function Jc(e,t,n){let r=Qc(ee(e,t)?.callables??[],n)??Ny(e,t,n);if(!r)return null;let o=Ar(e,t,n,r.startLine,r.endLine);return{file:t,name:r.name,startLine:o.startLine,endLine:o.endLine}}function Ny(e,t,n){let i=ae(e,t)?.rootNode;if(!i||i.startPosition.row>n||i.endPosition.row<n)return null;let r=eu(i,n);for(;r;){if(r.type==="variable_declarator"){let s=r.childForFieldName("name")??r.namedChild(0),a=r.childForFieldName("value")??r.namedChild(1);if(s?.type==="identifier"&&a&&Xc(a,n))return{name:s.text,startLine:r.startPosition.row,endLine:r.endPosition.row}}if(r.type==="pair"){let s=r.childForFieldName("key")??r.namedChild(0),a=r.childForFieldName("value")??r.namedChild(1),l=s?.text.replace(/^(?:['"])(.*)(?:['"])$/u,"$1");if(l&&a&&/^[A-Za-z_$][\w$]*$/u.test(l)&&Xc(a,n))return{name:l,startLine:r.startPosition.row,endLine:r.endPosition.row}}r=r.parent}let o=Ui(e,t,n);return o?{name:`source@${n+1}`,startLine:o.startLine,endLine:o.endLine}:null}function Xc(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&&Xc(n,t))}function eu(e,t){let n=e.namedChildren.filter(i=>i.startPosition.row<=t&&i.endPosition.row>=t).sort((i,r)=>i.endIndex-i.startIndex-(r.endIndex-r.startIndex)||i.startPosition.row-r.startPosition.row)[0];return n?eu(n,t):e}function DF(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/u);if(!n)return null;let i=Uo(e,n[1],{allowMultiple:!1})[0]?.relativePath;if(!i)return null;let r=Math.max(0,Number.parseInt(n[2],10)-1),o=n[3]?Math.max(r,Number.parseInt(n[3],10)-1):r,s=(ee(e,i)?.callables??[]).filter(a=>a.startLine<=r&&a.endLine>=o).sort((a,l)=>a.endLine-a.startLine-(l.endLine-l.startLine)||a.startLine-l.startLine)[0];return s?{file:i,name:s.name,startLine:s.startLine,endLine:s.endLine}:null}function PF(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 TF(e,t){let n=/[\p{L}\p{N}_$]/u,i=e.indexOf(t);for(;i>=0;){let r=e[i-1]??"",o=e[i+t.length]??"";if((r==="'"||r==='"'||r==="`")&&o===r)return"exact-value";if(!n.test(r)&&!n.test(o))return"boundary";i=e.indexOf(t,i+Math.max(1,t.length))}return"embedded"}function Zc(e){return V(e)==="test"?!1:!/(?:^|[/._-])(?:fixtures?|mocks?|previews?|demos?|examples?|stories)(?:[/._-]|$)/iu.test(e)}function FF(e,t){return e.matchKind!=="embedded"&&t(e.relativePath)&&(gl(e.relativePath)!=="production"||Zc(e.relativePath))}function MF(e,t){let n=[...t].sort(AF),i=[],r=new Set;for(let o of n)if(!r.has(o.relativePath)&&(i.push(o),r.add(o.relativePath),i.length>=vy))break;for(let o of n){if(i.length>=vy)break;i.includes(o)||i.push(o)}return i.map(o=>({query:e,file:o.relativePath,line:o.line,ownerSymbol:o.ownerSymbol,ownerShortName:o.ownerShortName,ownerStartLine:o.ownerStartLine,ownerEndLine:o.ownerEndLine,sourceLine:o.sourceLine.trim(),matchKind:o.matchKind,traversalSeed:!1}))}function AF(e,t){let n={"exact-value":0,boundary:1,embedded:2};return n[e.matchKind]-n[t.matchKind]||+(t.ownerSymbol!==null)-+(e.ownerSymbol!==null)||+!Zc(e.relativePath)-+!Zc(t.relativePath)||e.relativePath.localeCompare(t.relativePath)||e.line-t.line}function NF(e,t){let n=new Map;for(let i of t){let r=kF(i.relativePath);n.set(r,(n.get(r)??0)+1)}return[...n].sort(([i,r],[o,s])=>s-r||i.localeCompare(o)).slice(0,eF).map(([i])=>`codebaseiq search ${Ne(e)} --scope ${Ne(i)}`)}function kF(e){let t=e.split("/").filter(Boolean);if(t.length<=1)return e;let n=t.slice(0,-1),i=n.lastIndexOf("src");return i>=0?n.slice(0,Math.min(n.length,i+3)).join("/"):n.slice(0,Math.min(n.length,3)).join("/")}function _F(e,t,n){let i=t.callerFileMap([n],{semantic:!1}).get(n.symbolId)??new Set,r=[];for(let o of[...i].sort()){let s=n.leaf?yn(e,o,n.leaf):[];if(s.length===0){r.push({file:o,line:null,enclosingSymbol:null});continue}let a=t.definitionsForFile(o);for(let l of s)r.push({file:o,line:l,enclosingSymbol:Ge(a,l)?.symbol??null})}return r}function BF(e,t){let n=e.all(`SELECT DISTINCT gs.symbol, def_d.relative_path AS from_file
76
+ FROM mentions m
77
+ JOIN chunks c ON m.chunk_id = c.id
78
+ JOIN documents imp_d ON c.document_id = imp_d.id
79
+ JOIN global_symbols gs ON m.symbol_id = gs.id
80
+ LEFT JOIN (
81
+ SELECT m2.symbol_id, c2.document_id
82
+ FROM mentions m2
83
+ JOIN chunks c2 ON m2.chunk_id = c2.id
84
+ WHERE m2.role = 1
85
+ GROUP BY m2.symbol_id
86
+ ) sym_def ON sym_def.symbol_id = gs.id
87
+ LEFT JOIN documents def_d ON sym_def.document_id = def_d.id
88
+ WHERE imp_d.relative_path = ? AND m.role = 2
89
+ ORDER BY def_d.relative_path, gs.symbol`,t);return n.length>0?n.map(i=>({symbol:i.symbol,shortName:k(i.symbol),importedName:Ly(k(i.symbol)),localName:Ly(k(i.symbol)),fromFile:i.from_file,source:"compiler"})):Ce(e,t).map(i=>{let r=OF(i.importedName,i.localName,i.kind),o=i.localName??i.importedName,s=i.importedName==="default"?o:i.importedName;return{symbol:r,shortName:r,importedName:s,localName:o,fromFile:i.sourcePath,source:"parsed-source"}})}function Ly(e){return e.slice(e.lastIndexOf(":")+1).replace(/\(\)$/u,"")||e}function OF(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 Wn(e,t,n){let i=rt(e,n);if(!i.match)return{matches:[],total:0,omitted:0};let r=[i.match,...i.candidates.map(s=>rt(e,s.symbol).match)].filter(s=>s!==null),o=new Map;for(let s of r){let a=t.definitionsForFile(s.relativePath).find(l=>l.symbol===s.symbol);a&&o.set(a.symbol,a)}return{matches:[...o.values()],total:i.total,omitted:Math.max(0,i.total-o.size)}}function $F(e){return{symbol:e.symbol,shortName:k(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine}}function Et(e,t){let n=[t.kind,t.fromFile,t.fromSymbol??"",t.toFile,t.toSymbol??"",t.fromBoundaryParticipant?.observationId??"",t.toBoundaryParticipant?.observationId??"",t.fromSourceConstruct?an(t.fromSourceConstruct):"",t.toSourceConstruct?an(t.toSourceConstruct):"",t.runtimeBoundaryKey??"",t.line??""].join("\0");e.set(n,t)}function nr(e){return{observationId:e.id,action:e.action,protocol:e.protocol,role:e.role,address:ky(e),file:e.source.file,line:e.source.startLine,endLine:e.source.endLine,ownerName:e.owner.name,ownerSymbol:e.owner.symbol}}function ga(e,t){let n=ie(e,t.source.file);return gt(e,t.source.file,0,Math.max(0,n.length-1),[t.source.startLine])}function Dy(e,t){let n=[...e.values()];for(let i of[t.owner,t.source]){let r=n.filter(o=>o.file===i.file&&o.startLine<=i.startLine&&o.endLine>=i.startLine).sort((o,s)=>o.endLine-o.startLine-(s.endLine-s.startLine)||o.startLine-s.startLine)[0];if(r)return r}return null}function Py(e,t,n,i,r){let o=[],s=n.get(e.id);s!==void 0&&s<=t&&o.push(s);for(let a of i.values()){if(a.depth>t)continue;let l=a.definition;Ty(l,e)&&o.push(a.depth)}for(let a of r.values())a.depth>t||Ty(a,e)&&o.push(a.depth);return o.length>0?Math.min(...o):null}function Ty(e,t){let n=e.relativePath??e.file;return[t.owner,t.source].some(i=>n===i.file&&e.startLine<=i.startLine&&e.endLine>=i.startLine)}function Yc(e){return wt("runtime-boundary-participant",e)}function jF(e,t,n){let i=It(e,n),r=It(t,n);return i.relativeDir!==r.relativeDir?!0:/(?:^|\/)(?:contracts?|schemas?|db\/schema)(?:\/|$)/u.test(t)}function HF(e,t,n){return ao(e,n).id===ao(t,n).id}function UF(e,t,n,i){if(e.referenceScope==="all")return!0;let r=ao(t,i).id;return[...n.values()].some(s=>s.promoteBoundaryImports&&ao(s.file,i).id===r)?!0:e.referenceScope!=="cross-workspace-or-forward"?!1:It(t,i).relativeDir!==It(e.definition.relativePath,i).relativeDir}function zF(e,t){let n={none:0,"forward-regions":1,"cross-workspace-or-forward":2,all:3};return n[e]>=n[t]?e:t}function GF(e){let t=new Map;for(let[n,i]of e)for(let r of i){let o=t.get(r)??new Set;o.add(n),t.set(r,o)}return t}function It(e,t){return t.find(n=>e===n.relativeDir||e.startsWith(`${n.relativeDir}/`))??{name:"root",relativeDir:""}}function KF(e){let t=new Set(["apps","packages","services","crates","libs","tools"]),n=new Map;for(let i of e){let r=i.split("/").filter(Boolean);if(r.length<3||!t.has(r[0]))continue;let o=`${r[0]}/${r[1]}`;n.set(o,{name:r[1],relativeDir:o})}return[...n.values()].sort((i,r)=>r.relativeDir.length-i.relativeDir.length)}function ao(e,t){let n=It(e,t),r=(n.relativeDir?e.slice(n.relativeDir.length+1):e).split("/").filter(Boolean);r[0]==="src"&&r.shift();let o=qF(r);return{id:`region:${n.relativeDir||"root"}:${o}`,label:`${n.name}:${o}`,workspace:n.name,structuralPath:o}}function qF(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 WF(e,t,n,i,r,o,s){let a=Kt([...e.values()],f=>o.get(f.file).id),l=Kt([...t.values()],f=>o.get(f.definition.relativePath).id),c=Kt(n,f=>o.get(f.file).id),u=new Map;for(let f of i)for(let p of new Set([f.fromRegionId,f.toRegionId])){let g=u.get(p)??[];g.push(f),u.set(p,g)}let d=Kt(r,f=>f.toRegionId),m=Kt(r,f=>f.fromRegionId);return[...a.entries()].map(([f,p])=>{let g=o.get(p[0].file),h=l.get(f)??[],S=c.get(f)??[],v=u.get(f)??[],y=s.has(f),E=h.map(YF).sort(eM).slice(0,tF),w=p.filter(b=>V(b.file)==="test").length;return{id:f,label:g.label,workspace:g.workspace,structuralPath:g.structuralPath,minDepth:Math.min(...p.map(b=>b.depth)),fileCount:p.length,sourceFileCount:p.length-w,testFileCount:w,symbolCount:h.length,literalHitCount:S.length,anchorQueries:De([...S.map(b=>b.query),...h.flatMap(b=>[...b.anchorQueries])]),relationKinds:De(v.map(b=>b.kind)),incomingRegionIds:De((d.get(f)??[]).map(b=>b.fromRegionId)),outgoingRegionIds:De((m.get(f)??[]).map(b=>b.toRegionId)),memberCallCandidateRelationCount:v.filter(b=>b.evidence==="ast-member-import-candidate").length,notableSymbols:E,omittedNotableSymbols:Math.max(0,h.length-E.length),expanded:y,files:y?p.map(VF).sort(tM):[],symbols:y?h.map(JF).sort(nM):[],literalHits:y?[...S].sort(By):[],relations:y?[...v].sort(_y):[]}}).sort((f,p)=>f.minDepth-p.minDepth||f.label.localeCompare(p.label))}function VF(e){return{file:e.file,kind:V(e.file),depth:e.depth,origins:De([...e.origins])}}function JF(e){return{symbol:e.definition.symbol,shortName:k(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,depth:e.depth,origins:De([...e.origins]),anchorQueries:De([...e.anchorQueries]),referenceExpansion:e.referenceScope!=="none",referenceScope:e.referenceScope}}function YF(e){return{shortName:k(e.definition.symbol),file:e.definition.relativePath,origins:De([...e.origins])}}function XF(e){return[...Kt(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:De(n.map(i=>i.kind)),relationCount:n.length,fromFiles:De(n.map(i=>i.fromFile)),toFiles:De(n.map(i=>i.toFile)),fromSymbols:De(n.flatMap(i=>i.fromSymbol?[k(i.fromSymbol)]:[])),toSymbols:De(n.flatMap(i=>i.toSymbol?[k(i.toSymbol)]:[])),evidence:De(n.map(i=>i.evidence)),strengths:De(n.map(i=>i.strength??"unknown"))})).sort((n,i)=>n.fromRegionId.localeCompare(i.fromRegionId)||n.toRegionId.localeCompare(i.toRegionId))}function ZF(e,t){return[...e.values()].map(n=>({kind:"external-import",name:n.name,fromRegionIds:De([...n.fromFiles].flatMap(i=>{let r=t.get(i);return r?[r.id]:[]})),fromFiles:De([...n.fromFiles])})).sort((n,i)=>n.name.localeCompare(i.name))}function QF(e,t,n,i){let r=e.kind==="literal"?t.filter(o=>o.query===e.query).map(o=>o.file):[...n.values()].filter(o=>o.anchorQueries.has(e.query)).map(o=>o.definition.relativePath);return De(r.map(o=>i.get(o)?.id).filter(o=>!!o))}function ky(e){return e.keyParts.map(t=>`${t.name}=${t.value}`).join(" ")}function ha(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function De(e){return[...new Set(e)].sort()}function Kt(e,t){let n=new Map;for(let i of e){let r=t(i),o=n.get(r)??[];o.push(i),n.set(r,o)}return n}function _y(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 eM(e,t){return lo(e.origins)-lo(t.origins)||e.shortName.localeCompare(t.shortName)}function lo(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 tM(e,t){return e.depth-t.depth||e.file.localeCompare(t.file)}function nM(e,t){return e.depth-t.depth||e.file.localeCompare(t.file)||e.symbol.localeCompare(t.symbol)}function By(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.query.localeCompare(t.query)}var rM=["causal","structure","complete"],oM={causal:["execution","runtime","dataflow","state","temporal"],structure:["contract","identity","ownership","dependencies"],complete:Gt},sM=2,aM=48,Oy=64,lM=5e4;function co(e,t,n={}){let i=Pn([...t.symbols??[],...t.locations??[]]),r=Pn(t.searches??[]);if(i.length===0&&r.length===0)throw new Error("evidence requires at least one positional symbol, --symbol, --at, or --search selector.");let o=n.view??"causal",s=cM(n.families,o),a=n.direction??"both",l=Pn(n.subtypes??[]),c=n.connecting??!1,u=n.inventoryOnly??!1,d=Pn(n.foldIds??[]),m=n.maxDepth??sM,f=n.maxEdges??aM;if(!Number.isSafeInteger(m)||m<0)throw new RangeError(`Evidence depth must be a non-negative safe integer; received ${m}.`);if(!Number.isSafeInteger(f)||f<=0)throw new RangeError(`Evidence max edges must be a positive safe integer; received ${f}.`);if(!["incoming","outgoing","both"].includes(a))throw new Error(`Unsupported graph evidence direction: ${a}.`);if(u&&d.length>0)throw new Error("Evidence fold materialization cannot be combined with --inventory-only.");let p=Fy(e,{symbols:i,searches:r,maxDepth:m,maxTopologyCharacters:lM,relations:uM(s)}),g=new Map(p.nodes.map(Y=>[Y.id,Y])),h=p.edges.filter(Y=>Y.disposition==="emitted"||Y.disposition==="folded").flatMap(Y=>dM(Y,g)),S=h.filter(Y=>s.includes(Y.family)).filter(Y=>l.length===0||l.includes(Y.subtype)),v=new Set(p.anchors.flatMap(Y=>Y.nodeIds));if(c&&v.size<2)throw new Error("Connecting evidence requires at least two resolved root nodes.");let y=new Set(S.map(Y=>Y.id)),E=tu(h,v,"incoming").filter(Y=>y.has(Y.id)),w=tu(h,v,"outgoing").filter(Y=>y.has(Y.id)),b=tu(h,v,"both").filter(Y=>y.has(Y.id)),R=hM(s,l,E,w,b),C=a==="incoming"?E:a==="outgoing"?w:b,L=c?RM(C,[...v],a):C,I=wM(L,v,a),x=[...L].sort((Y,N)=>IM(Y,N,I)),P=yM(x,f),_=SM(P,d),D=u?[]:d.length>0?x.filter(Y=>_.has(Y.id)):x,T=d.length>0?D:D.slice(0,f),A=d.length>0||u?[]:P,W=Math.max(0,D.length-T.length),le=p.frontiers.filter(Y=>Y.disposition==="unsupported").length,q=p.coverage.status==="incomplete"?"incomplete":W>0?"bounded":"accounted";return{kind:"graph",view:n.families&&n.families.length>0?"custom":o,families:s,selection:{direction:a,subtypes:l,connecting:c,inventoryOnly:u,foldIds:d},targets:p.anchors.map(Y=>({kind:Y.kind,query:Y.query,status:Y.status,nodeIds:[...Y.nodeIds],omittedCandidates:Y.omittedCandidates})),inventory:R,edges:T,folds:A,coverage:{status:q,topologyStatus:p.coverage.status,scope:p.coverage.scope,maxDepth:m,maxEdges:f,matchedEdges:x.length,eligibleEdges:D.length,returnedEdges:T.length,omittedEdges:W,frontierGroups:p.frontiers.length,unsupportedFrontiers:le,blindSpots:Pn([...p.coverage.blindSpots,...Dh(s)]),explanation:u?`${x.length} relationship(s) match the explicit projection; only exact inventory counts were requested.`:d.length>0?`Every relationship in ${d.length} explicitly selected recoverable fold(s) was emitted.`:q==="accounted"?"Every selected relationship in the bounded topology was emitted.":q==="bounded"?`${W} selected relationship(s) were withheld by the explicit edge budget.`:p.coverage.explanation}}}function cM(e,t){let n=e&&e.length>0?e:oM[t],i=n.filter(r=>!Gt.includes(r));if(i.length>0)throw new Error(`Unsupported graph evidence family: ${i.join(", ")}.`);return Pn(n)}function uM(e){return["call","contract-symbol","import","reference","runtime-boundary"]}function dM(e,t){let n=t.get(e.fromNodeId),i=t.get(e.toNodeId);return!n||!i?[]:(e.semantics??[]).flatMap((r,o)=>{let s=fM(r);if(!s)return[];let a=Ph(s,r.subtype);if(!a)throw new Error(`No graph relation provider contract is registered for ${s}/${r.subtype}.`);let l=gM(e);if(!a.relation.evidenceStrengths.includes(l))throw new Error(`Graph relation provider ${a.provider.id} does not admit ${l} evidence for ${s}/${r.subtype}.`);return[{id:`${e.id}:${o}:${s}`,family:s,semanticFamily:r.family,subtype:r.subtype,from:$y(n),to:$y(i),sourceKind:e.kind,providerId:a.provider.id,supportCeiling:a.relation.supportCeiling,establishes:a.relation.establishes,nonClaims:[...a.relation.nonClaims],recoverWith:[...a.relation.recoverWith],evidenceStrength:l,evidenceMethods:Pn(e.evidence.map(c=>c.method)),evidenceConstituents:mM(e.evidence),context:r.context?{...r.context}:null,attributes:r.attributes?{...r.attributes}:null}]})}function mM(e){let t=new Map;for(let n of e)t.set(`${n.method}\0${n.strength}`,n);return[...t.values()].map(({method:n,strength:i})=>({method:n,strength:i}))}function fM(e){switch(e.family){case"control":return e.context?.crossesRuntimeBoundary===!0||e.subtype==="runtime-handoff"?"runtime":"execution";case"data":return"dataflow";case"state":return"state";case"temporal":return"temporal";case"contract":return"contract";case"identity":return e.subtype.startsWith("contains")||e.subtype.startsWith("owns-")?"ownership":e.subtype.startsWith("import")?"dependencies":"identity"}}function $y(e){let t=pM(e);return{id:e.id,kind:e.kind,label:t?k(t):e.label,symbol:t,location:e.location?{...e.location}:null}}function pM(e){return e.kind!=="symbol"||!e.id.startsWith("symbol:")?null:decodeURIComponent(e.id.slice(7))}function gM(e){let t=Pn(e.evidence.map(n=>n.strength));return t.length===1?t[0]:t.includes("exact")&&t.every(n=>n==="exact"||n==="derived")?"mixed":t.includes("candidate")?"candidate":t.includes("unknown")||t.length===0?"unknown":"mixed"}function tu(e,t,n){let i=nu(e,n),r=new Map,o=new Map,s=[...t].sort();for(let a of s)o.set(a,0);for(let a=0;a<s.length;a+=1){let l=s[a],c=o.get(l);for(let u of i.get(l)??[])r.set(u.edge.id,u.edge),!o.has(u.next)&&(o.set(u.next,c+1),s.push(u.next))}return[...r.values()]}function nu(e,t){let n=new Map,i=(r,o,s)=>{let a=n.get(r)??[];a.push({edge:s,next:o}),n.set(r,a)};for(let r of e)t!=="incoming"&&i(r.from.id,r.to.id,r),t!=="outgoing"&&i(r.to.id,r.from.id,r);for(let r of n.values())r.sort((o,s)=>o.edge.id.localeCompare(s.edge.id)||o.next.localeCompare(s.next));return n}function hM(e,t,n,i,r){let o=new Set;for(let u of[...n,...i,...r])o.add(`${u.family}\0${u.subtype}`);if(t.length>0)for(let u of e)for(let d of t)o.add(`${u}\0${d}`);let s=u=>{let d=new Map;for(let m of u){let f=`${m.family}\0${m.subtype}`;d.set(f,(d.get(f)??0)+1)}return d},a=s(n),l=s(i),c=s(r);return[...o].map(u=>{let[d,m]=u.split("\0");return{family:d,subtype:m,incoming:a.get(u)??0,outgoing:l.get(u)??0,both:c.get(u)??0}}).sort((u,d)=>Gt.indexOf(u.family)-Gt.indexOf(d.family)||u.subtype.localeCompare(d.subtype))}function yM(e,t){let n=e.slice(t),i=new Map;for(let s of n){let a=bM(s),l=`${s.family}\0${a}`,c=i.get(l)??[];c.push(s),i.set(l,c)}let r=new Map(e.map((s,a)=>[s.id,a+1])),o=[];for(let[s,a]of[...i].sort(([l],[c])=>l.localeCompare(c))){let[l,c]=s.split("\0"),u=[...a].sort((d,m)=>d.id.localeCompare(m.id));for(let d=0;d<u.length;d+=Oy){let m=u.slice(d,d+Oy),f=m.map(S=>S.id),p=Pn(m.map(S=>S.subtype)).sort(),g=p.length===1?p[0]:"mixed",h=[...new Set(m.flatMap(S=>[S.from.id,S.to.id]))].sort();o.push({id:xM(l,p.join("\0"),f),mode:vM(m),family:l,subtype:g,subtypes:p,region:c,edgeCount:f.length,edgeIds:f,nodeIds:h,minimumMaxEdges:Math.max(...f.map(S=>r.get(S)??e.length))})}}return o.sort((s,a)=>Gt.indexOf(s.family)-Gt.indexOf(a.family)||(s.region??"").localeCompare(a.region??"")||s.id.localeCompare(a.id))}function bM(e){let t=e.from.location?.file??`kind:${e.from.kind}`,n=e.to.location?.file??`kind:${e.to.kind}`;return t===n?t:`${t} -> ${n}`}function SM(e,t){if(t.length===0)return new Set;let n=new Map(e.map(r=>[r.id,r])),i=t.filter(r=>!n.has(r));if(i.length>0){let r=e.map(o=>o.id).sort();throw new Error(`Unknown evidence fold ${i.join(", ")} for this projection. Available folds: ${r.join(", ")||"(none)"}.`)}return new Set(t.flatMap(r=>n.get(r).edgeIds))}function vM(e){let t=new Map,n=new Map,i=new Set;for(let o of e){i.add(o.from.id),i.add(o.to.id);let s=t.get(o.from.id)??new Set;s.add(o.to.id),t.set(o.from.id,s);let a=n.get(o.to.id)??new Set;a.add(o.from.id),n.set(o.to.id,a)}return CM(i,t)?"scc":[...i].every(o=>(n.get(o)?.size??0)<=1&&(t.get(o)?.size??0)<=1)?"linear":"topology"}function CM(e,t){let n=new Set,i=new Set,r=o=>{if(n.has(o))return!0;if(i.has(o))return!1;n.add(o);for(let s of t.get(o)??[])if(r(s))return!0;return n.delete(o),i.add(o),!1};return[...e].some(r)}function xM(e,t,n){return`fold:${iM("sha256").update([e,t,...n].join("\0")).digest("hex").slice(0,16)}`}function RM(e,t,n){let i=new Map,r=[...new Set(t)].sort();for(let o=0;o<r.length;o+=1)for(let s=o+1;s<r.length;s+=1)for(let a of EM(e,r[o],r[s],n))i.set(a.id,a);return[...i.values()]}function EM(e,t,n,i){let r=nu(e,i),o=new Map([[t,0]]),s=new Map,a=[t];for(let c=0;c<a.length;c+=1){let u=a[c],d=o.get(u);if(u!==n)for(let m of r.get(u)??[])o.has(m.next)||(o.set(m.next,d+1),s.set(m.next,{node:u,edge:m.edge}),a.push(m.next))}if(!o.has(n))return[];let l=[];for(let c=n;c!==t;){let u=s.get(c);if(!u)return[];l.push(u.edge),c=u.node}return l.reverse()}function wM(e,t,n){let i=nu(e,n),r=new Map,o=[...t];for(let s of t)r.set(s,0);for(let s=0;s<o.length;s+=1){let a=o[s],l=r.get(a);for(let{next:c}of i.get(a)??[])r.has(c)||(r.set(c,l+1),o.push(c))}return r}function IM(e,t,n){return jy(e,n)-jy(t,n)||Hy(e)-Hy(t)||Uy(e.evidenceStrength)-Uy(t.evidenceStrength)||Gt.indexOf(e.family)-Gt.indexOf(t.family)||e.from.label.localeCompare(t.from.label)||e.to.label.localeCompare(t.to.label)||e.subtype.localeCompare(t.subtype)||e.id.localeCompare(t.id)}function jy(e,t){return Math.min(t.get(e.from.id)??Number.MAX_SAFE_INTEGER,t.get(e.to.id)??Number.MAX_SAFE_INTEGER)}function Hy(e){let t=[e.from,e.to].filter(n=>n.kind==="structural-region").length;return t===2?2:t}function Uy(e){switch(e){case"exact":return 0;case"mixed":return 1;case"derived":return 2;case"candidate":return 3;case"unknown":return 4}}function Pn(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function iu(e,t){let n=bn(e,t);if(n.length===0)return{files:[],symbols:[],dependsOn:[],dependedOnBy:[]};let i=n.map(()=>"?").join(", "),o=e.all(`SELECT relative_path FROM documents
90
+ WHERE relative_path IN (${i})
91
+ ORDER BY relative_path`,...n).map(c=>c.relative_path).filter(c=>!e.isIgnored(c)),s=Yo(e,o,{onlyDocumented:!0,sort:!0}).map(({relativePath:c,...u})=>u),a=Xi(e,"forward",n).filter(c=>!e.isIgnored(c)),l=Xi(e,"reverse",n).filter(c=>!e.isIgnored(c));return{files:o,symbols:s,dependsOn:a,dependedOnBy:l}}function ru(e,t){let n=bn(e,t);return n.length===0?[]:Gy([...zy(e,n),...DM(e,n)]).filter(i=>!e.isIgnored(i.relative_path)).map(Ky)}function LM(e,t){let n=bn(e,t);return n.length===0?[]:Gy(zy(e,n)).filter(i=>!e.isIgnored(i.relative_path)).map(i=>({...Ky(i),basis:"external-reference"}))}function zy(e,t){let n=t.map(()=>"?").join(", ");return e.all(`SELECT DISTINCT d1.relative_path, gs.symbol
92
+ FROM mentions m
93
+ JOIN chunks c ON m.chunk_id = c.id
94
+ JOIN documents d1 ON c.document_id = d1.id
95
+ JOIN global_symbols gs ON m.symbol_id = gs.id
96
+ WHERE d1.relative_path NOT IN (${n})
97
+ AND (
98
+ EXISTS (
99
+ SELECT 1
100
+ FROM defn_enclosing_ranges der
101
+ JOIN documents d2 ON der.document_id = d2.id
102
+ WHERE der.symbol_id = gs.id
103
+ AND d2.relative_path IN (${n})
104
+ )
105
+ OR EXISTS (
106
+ SELECT 1
107
+ FROM mentions def_m
108
+ JOIN chunks def_c ON def_m.chunk_id = def_c.id
109
+ JOIN documents d2 ON def_c.document_id = d2.id
110
+ WHERE def_m.symbol_id = gs.id
111
+ AND def_m.role = 1
112
+ AND d2.relative_path IN (${n})
113
+ )
114
+ )
115
+ AND m.role != 1
116
+ AND ${e.localSymbolPredicate}
117
+ ${e.pathExclusionsFor("d1")}
118
+ ORDER BY d1.relative_path`,...t,...t,...t)}function DM(e,t){let n=new U(e);return t.flatMap(i=>n.definitionsForFile(i).filter(r=>it(r.symbol)).map(r=>({relative_path:i,symbol:r.symbol})))}function Gy(e){let t=new Set;return e.filter(n=>{let i=`${n.relative_path}|${n.symbol}`;return t.has(i)?!1:(t.add(i),!0)})}function Ky(e){return{consumer:e.relative_path,symbol:e.symbol,shortName:k(e.symbol)}}var uo=new WeakMap,qy=vt({kind:"definition-exclusions",invalidation:Je("definition-exclusions"),serialize:e=>JSON.stringify(e),deserialize:PM});function Vy(e,t){let n=ye(t);if(!(n==="rust"||n==="typescript"||n==="tsx"||n==="javascript"))return[];let r=se(e,t);if(!r)return[];let o=Ft(e,t,r),s=qy.read(e,t,o);if(s)return s;let a=n==="rust"?BM(e,t):AM(e,t);return qy.write(e,t,o,a),a}function PM(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=t.map(TM);return n.some(i=>i===null)?null:n}catch{return null}}function TM(e){if(!e||typeof e!="object")return null;let t=e;if(typeof t.startLine!="number"||!Number.isFinite(t.startLine)||typeof t.endLine!="number"||!Number.isFinite(t.endLine)||typeof t.reason!="string"||t.containerName!==void 0&&typeof t.containerName!="string")return null;let n=t.disposition===void 0?JM(t.reason):t.disposition;return n!=="exclude"&&n!=="implicit-usage"?null:{startLine:t.startLine,endLine:t.endLine,reason:t.reason,disposition:n,...t.containerName?{containerName:t.containerName}:{}}}var Jy=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]),FM=/\b(?:describe|it|test|fdescribe|fit|xdescribe|xit|beforeEach|afterEach|beforeAll|afterAll|before|after|suite|bench|benchmark)\s*\(/,MM=/\b(?:export\s+)?(?:async\s+)?function\s+use[A-Z][A-Za-z0-9_$]*\b|\b(?:const|let|var)\s+use[A-Z][A-Za-z0-9_$]*\s*(?::[^=;]+)?=\s*(?:async\s*)?(?:function\b|(?:<[^=;{]+>\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>)/;function AM(e,t){let n=se(e,t);if(!n||!NM(n))return[];let i=ae(e,t);if(!i)return[];let r=uo.get(i);if(r)return r;let o=!1,s=i.rootNode;for(let l of s.namedChildren){if(l.type!=="expression_statement")continue;let c=l.namedChild(0);if(!c||c.type!=="call_expression")continue;let u=c.namedChild(0);if(!u)continue;let d=u.type==="member_expression"?u.namedChild(u.namedChildCount-1)?.text:u.text;if(d&&Jy.has(d)){o=!0;break}}let a=[];o&&a.push({startLine:0,endLine:s.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)",disposition:"exclude"});for(let l of s.namedChildren){let c=null,u=null;if(l.type==="function_declaration")c=l.namedChild(0)?.text??null,u=l;else if(l.type==="export_statement"){let d=l.namedChild(0);d?.type==="function_declaration"&&(c=d.namedChild(0)?.text??null,u=d)}else if(l.type==="lexical_declaration"){let d=l.namedChild(0);if(d?.type==="variable_declarator"){let m=d.namedChild(0)?.text,f=d.namedChild(1);m&&(f?.type==="arrow_function"||f?.type==="function_expression")&&(c=m,u=d)}}c&&/^use[A-Z]/.test(c)&&u&&a.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"React custom hook (use*)",disposition:"exclude"})}return a.push(...Yy(i,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),uo.set(i,a),a}function NM(e){if(e.includes("codebaseiq"))return!0;let t=!1;for(let n of Jy)if(e.includes(n)){t=!0;break}return t&&FM.test(e)?!0:e.includes("use")&&MM.test(e)}var kM=/codebaseiq[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function _M(e){return kM.test(e)}function Yy(e,t,n){let i=[],r=o=>{if(t.has(o.type)&&o.parent){let a=o.parent.children,l=-1;for(let c=0;c<a.length;c+=1)if(a[c].startIndex===o.startIndex&&a[c].type===o.type){l=c;break}if(l>0)for(let c=l-1;c>=0;c-=1){let u=a[c];if(n.has(u.type)){if(_M(u.text)){i.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:"codebaseiq suppression comment",disposition:"exclude"});break}continue}if(!(u.type==="attribute_item"||u.type==="inner_attribute_item"))break}}for(let s of o.namedChildren)r(s)};return r(e.rootNode),i}function BM(e,t){let n=ae(e,t);if(!n)return[];let i=uo.get(n);if(i)return i;let r=[],o=OM(n);return o?(uo.set(n,o),o):(Xy(n.rootNode,r,!1,!1),r.push(...Yy(n,new Set(["function_item","function_signature_item","struct_item","enum_item","union_item","impl_item","mod_item","static_item","const_item"]),new Set(["line_comment","block_comment"]))),r.push(...WM(n.rootNode)),uo.set(n,r),r)}function OM(e){return YM(e.rootNode)?[{startLine:0,endLine:e.rootNode.endPosition.row,reason:"generated file (@generated header)",disposition:"exclude"}]:null}function Xy(e,t,n,i){let r=n,o=i;e.type==="trait_item"&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait declaration body (dynamic dispatch)",disposition:"implicit-usage"}),e.type==="impl_item"&&e.childForFieldName("trait")&&(o=!0,t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl block (dynamic dispatch)",disposition:"implicit-usage"})),e.type==="function_item"||e.type==="function_signature_item"?$M(e,t,n,i):i&&qM(e)?t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl associated item (dynamic dispatch)",disposition:"implicit-usage"}):e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"?jM(e,t,n):e.type==="mod_item"&&ou(e).some(s=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(s))&&(r=!0);for(let s of e.namedChildren)Xy(s,t,r,o)}function $M(e,t,n,i){let r=ou(e),o=null;i?o={reason:"trait impl method (dynamic dispatch)",disposition:"implicit-usage"}:n&&(o={reason:"inside #[cfg(test)] mod",disposition:"exclude"});for(let s of r){if(Zy(s)){o={reason:"#[allow(dead_code)]",disposition:"exclude"};break}let a=GM(s);if(a){o=a;break}}o&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:o.reason,disposition:o.disposition})}function jM(e,t,n){let i=ou(e),r=e.namedChildren.find(o=>o.type==="type_identifier")?.text;i.some(KM)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(...)] - generated impl may access fields",disposition:"implicit-usage",containerName:r}),i.some(Zy)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",disposition:"exclude",containerName:r}),n&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",disposition:"exclude",containerName:r})}function ou(e){let t=e.parent;if(!t)return[];let n=t.children,i=-1;for(let o=0;o<n.length;o+=1)if(n[o].startIndex===e.startIndex&&n[o].type===e.type){i=o;break}if(i<=0)return[];let r=[];for(let o=i-1;o>=0;o-=1){let s=n[o];if(s.type==="attribute_item"||s.type==="inner_attribute_item")r.push(s.text);else{if(s.type==="line_comment"||s.type==="block_comment")continue;break}}return r}var HM=new Set(["test","bench","tokio::test","async_std::test"]),UM=new Set(["no_mangle","export_name","link_name","used","macro_export","proc_macro","proc_macro_derive","proc_macro_attribute"]),zM=new Set(["allow","warn","deny","forbid","cfg","cfg_attr","doc","inline","cold","must_use","deprecated","repr","derive","automatically_derived","non_exhaustive","path","link","link_section","global_allocator","panic_handler"]);function GM(e){if(/#\[\s*cfg\s*\(\s*test\s*\)/.test(e))return{reason:"#[cfg(test)]",disposition:"exclude"};let t=VM(e);return t?HM.has(t)?{reason:`#[${t}]`,disposition:"exclude"}:UM.has(t)?{reason:`Rust ABI/export attribute #[${t}]`,disposition:"implicit-usage"}:zM.has(t)?null:{reason:`Rust attribute macro #[${t}]`,disposition:"implicit-usage"}:null}function KM(e){return/#\[\s*derive\s*\(/.test(e)}function Zy(e){return/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e)}function qM(e){return e.type==="const_item"||e.type==="type_item"||e.type==="static_item"||e.type==="associated_type"}function WM(e){let t=XM(e);if(t.size===0)return[];let n=[];for(let i of e.descendantsOfType("mod_item")){let r=i.childForFieldName("name")?.text;r&&t.has(r)&&n.push({startLine:i.startPosition.row,endLine:i.endPosition.row,reason:'attribute `with = "..."` module - body may be invoked via reflection',disposition:"implicit-usage",containerName:r})}return n}function VM(e){let t=/^#!?\[\s*([A-Za-z_][A-Za-z0-9_]*(?:\s*::\s*[A-Za-z_][A-Za-z0-9_]*)*)/.exec(e);return t?t[1].replace(/\s+/g,""):null}function JM(e){return e==="#[tauri::command]"||e==="#[command]"||e==="#[wasm_bindgen]"||e==="#[no_mangle]"||e==="#[napi]"||e==="#[pyfunction]"||e==="#[pymethod]"||e==="#[pyo3]"||e==="#[doc(hidden)]"||e.startsWith("trait ")||e.startsWith("#[derive(<reflective>)]")||e.startsWith("#[derive(...)]")||e.startsWith('serde `with = "')||e.startsWith('attribute `with = "')||e.startsWith("Rust attribute macro #[")||e.startsWith("Rust ABI/export attribute #[")?"implicit-usage":"exclude"}function YM(e){for(let t=0;t<Math.min(e.namedChildCount,12);t+=1){let n=e.namedChild(t);if(!n||n.type!=="line_comment"&&n.type!=="block_comment")break;if(/@generated\b/.test(n.text)||/This file is .*generated\b/i.test(n.text)||/Code generated by/i.test(n.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(n.text)||/openapi-generator/i.test(n.text)&&/Generated by/i.test(n.text))return!0}return!1}var Wy=/\bwith\s*=\s*"([^"]+)"/g;function XM(e){let t=new Set;for(let n of e.descendantsOfType("attribute_item")){Wy.lastIndex=0;let i;for(;(i=Wy.exec(n.text))!==null;){let r=i[1],o=r.split("::").pop()??r;o&&t.add(o)}}return t}function Qy(e){let t=su(e);return(n,i,r,o)=>t(n,i,r,o)?.disposition==="exclude"}function su(e){let t=new Map,n=i=>{let r=t.get(i);if(r)return r;let o=Vy(e,i),s=new Map;for(let a of o){if(!a.containerName)continue;let l=s.get(a.containerName)??[];l.push(a),s.set(a.containerName,l)}return r={ranges:o,containers:s},t.set(i,r),r};return(i,r,o,s)=>{let a=n(i),l=[];for(let u of a.ranges)r>=u.startLine&&r<=u.endLine&&l.push(u);let c=new Set;s&&c.add(s);for(let u of Xo(o))c.add(u);for(let u of c){let d=a.containers.get(u);d&&l.push(...d)}return ZM(l)}}function ZM(e){if(e.length===0)return null;let n=e.find(i=>i.disposition==="exclude")??e[0];return{disposition:n.disposition,reason:n.reason}}function au(e,t={}){ul(e,{groups:t.semanticProvider===!0?["whole-project","semantic-provider"]:["whole-project"]})}function eb(e,t,n={}){ul(e,{groups:n.definitions===!0?["source-file","definition-catalog"]:["source-file"],file:t.replace(/\\/g,"/")})}function tb(e,t){if(t.isIgnoredPath(e.relativePath))return mt("ignored-file");if(Le(e.symbol))return mt("module-like-symbol");if(!Sa(e.symbol))return mt("non-value-symbol");if(!e.isFunctionLike&&e.enclosingSymbol&&Sa(e.enclosingSymbol))return mt("nested-non-callable-value");if(!t.includeTests&&!QM(e.relativePath))return mt("test-file");if(!t.includeTests&&t.isExcludedRegion(e.relativePath,e.startLine,e.symbol,e.parentTypeName))return mt("excluded-file-region");let n=re(e.symbol);if(n==="<constructor>")return mt("implicit-constructor");if(e.symbol.startsWith("scip-python ")){if(n==="__all__")return mt("python-runtime-metadata");if(/^__[^_].*__$/.test(n))return mt("python-protocol-member")}return t.isDeclarationOnlyCallable()?mt("declaration-only-callable"):t.isFrameworkContractCallable()?mt("framework-contract-member"):at(e.symbol)?mt("rust-trait-impl-member"):ki(e.symbol)?mt("rust-test-module"):!t.includeMembers&&!e0(e)?mt("member"):e.endLine-e.startLine+1<t.minLoc?mt("below-min-loc"):{accepted:!0}}function QM(e){return V(e)!=="test"}function mt(e){return{accepted:!1,rejectionReason:e}}function Sa(e){return ke(e)||e.endsWith("().")||e.endsWith(".")}function e0(e){return it(e.symbol)||Xo(e.symbol).length===0}function nb(){return new Map}function ib(e,t,n){let i=new Map;for(let r of bm(e,n))e.isIgnored(r.relative_path)||t.has(r.relative_path)||Ca(i,r.symbol_id,r.relative_path,r.ref_count,"scip-mention");return i}function rb(e,t,n,i={}){let r=new Set;if(i.conservative||n.size===0){for(let o of vm(e,t))r.add(o.symbol_id);return r}for(let o of Sm(e,t))e.isIgnored(o.relative_path)||n.has(o.relative_path)||r.add(o.symbol_id);return r}function lu(e,t){let n=e.get(t);if(!n)return!1;for(let i of n.values())if(i.occurrences>0)return!0;return!1}function va(e,t,n){let i=e.get(t);if(!i)return!1;for(let[r,o]of i)if(r!==n&&o.occurrences>0)return!0;return!1}function ob(e){return e?.occurrences??0}function Ca(e,t,n,i,r="source-fallback"){if(i<=0)return;let o=ab(e,t,n);o.occurrences+=i,o.sources.add(r)}function sb(e,t,n,i,r){if(i<=0)return;let o=ab(e,t,n);o.occurrences=Math.max(i,o.occurrences),o.sources.add(r)}function ab(e,t,n){let i=e.get(t);i||(i=new Map,e.set(t,i));let r=i.get(n);return r||(r={occurrences:0,sources:new Set},i.set(n,r)),r}var t0=new Set(["componentDidCatch","componentDidMount","componentDidUpdate","componentWillUnmount","getDerivedStateFromError","getDerivedStateFromProps","getSnapshotBeforeUpdate","render","shouldComponentUpdate","UNSAFE_componentWillMount","UNSAFE_componentWillReceiveProps","UNSAFE_componentWillUpdate"]);function ir(e,t){if(!t.parentTypeName||!/\.[cm]?[jt]sx?$/.test(t.relativePath))return!1;let n=ae(e,t.relativePath);if(!n)return!1;let i=n.rootNode.descendantsOfType("method_definition").find(s=>s.startPosition.row<=t.startLine&&s.endPosition.row>=t.endLine);if(!i)return!1;if(/\boverride\b/.test(i.text.slice(0,Math.max(0,i.text.indexOf("{")))))return!0;let r=i.parent;for(;r&&r.type!=="class_declaration"&&r.type!=="class";)r=r.parent;if(!r)return!1;let o=r.text.slice(0,Math.max(0,r.text.indexOf("{")));return/\bimplements\b/.test(o)||/\bextends\b/.test(o)?!0:t0.has(t.leaf)&&/\bextends\s+(?:React\.)?(?:Component|PureComponent)\b/.test(o)}function wi(e,t={}){let{scope:n,minLoc:i=1,includeTests:r=!1,skipBarrels:o=!1,includeMembers:s=!1,deadCodeOnly:a=!1,scanLimit:l,semantic:c=!0}=t,u=0,d=$("dead.candidates",()=>{let b=Ae(n0(e,{scope:n,minLoc:i,includeTests:r,includeMembers:s}),l);return u=b.length,b},()=>({definitions:u})),m=0,f=o?$("dead.inactive-barrels",()=>{let b=new Set(fg(e));return m=b.size,b},()=>({paths:m})):new Set,p=0,g=a?nb():$("dead.mention-reference-counts",()=>{let b=ib(e,f,d.map(R=>R.symbolId));return p=b.size,b},()=>({definitions:d.length,symbolsWithReferences:p})),h=0,S=a?$("dead.mentioned-symbol-ids",()=>{let b=rb(e,d.map(R=>R.symbolId),f,{conservative:f.size===0});return h=b.size,b},()=>({definitions:d.length,referencedSymbols:h})):new Set,v=a?d.filter(b=>!S.has(b.symbolId)):d.filter(b=>!va(g,b.symbolId,b.relativePath));a?$("dead.source-fallback.dead-code-only",()=>c0(e,v,g,{inactiveBarrelPaths:f}),()=>({definitions:v.length,testReferencesIncluded:!0})):$("dead.source-fallback.ast",()=>l0(e,v,g,{inactiveBarrelPaths:f}),()=>({definitions:v.length,testReferencesIncluded:!0}));let y=a?v.filter(b=>!lu(g,b.symbolId)):v.filter(b=>!va(g,b.symbolId,b.relativePath)),E=new Set;$("dead.caller-map-supplement",()=>{E=f0(e,y,g,{inactiveBarrelPaths:f,includeSemantic:!a&&c})},()=>({definitions:y.length,semantic:!a&&c}));let w=a?v.filter(b=>!lu(g,b.symbolId)):d.filter(b=>!E.has(b.symbolId));return a0(e,o0(w,g))}function n0(e,t){let n=Qy(e),i=[];for(let r of vr(e,{scope:t.scope,symbolMatches:Sa,sqlPrefilter:"function-like"}))tb(r,{minLoc:t.minLoc,includeTests:t.includeTests,includeMembers:t.includeMembers,isIgnoredPath:s=>e.isIgnored(s),isExcludedRegion:n,isDeclarationOnlyCallable:()=>r0(e,r),isFrameworkContractCallable:()=>ir(e,r)}).accepted&&i.push(r);return i}var i0=["method_signature","abstract_method_signature","call_signature","construct_signature"];function r0(e,t){if(!t.parentTypeName||!/\.[cm]?[jt]sx?$/.test(t.relativePath))return!1;let n=ae(e,t.relativePath);if(n)return n.rootNode.descendantsOfType([...i0]).some(r=>r.startPosition.row<=t.startLine&&r.endPosition.row>=t.endLine);let i=ie(e,t.relativePath).slice(t.startLine,t.endLine+1).join(`
119
+ `).trim();return i.endsWith(";")&&!i.includes("=>")&&!i.includes("{")}function o0(e,t){return e.map(n=>s0(n,t)).filter(n=>n.cross_file_refs===0).sort((n,i)=>i.loc-n.loc||n.relative_path.localeCompare(i.relative_path)||n.start_line-i.start_line)}function s0(e,t){let n=t.get(e.symbolId)??new Map,i=ob(n.get(e.relativePath)),r=0;for(let[o,s]of n)o!==e.relativePath&&(r+=s.occurrences);return{relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine,loc:e.endLine-e.startLine+1,symbol:e.symbol,parent_type_name:e.parentTypeName,same_file_refs:i,cross_file_refs:r}}function a0(e,t){let n=su(e),i=[],r=0,o=0,s=0,a=0,l=0,c=0;for(let u of t){if(e.isIgnored(u.relative_path))continue;if(Ye(e,u.relative_path)){a++;continue}if(Ue(e,u.symbol,u.relative_path)){l++;continue}let d=n(u.relative_path,u.start_line,u.symbol,u.parent_type_name),m=d?.disposition==="implicit-usage"?d.reason:void 0,f=m?"implicit-usage":u.same_file_refs===0?"dead-code":"file-internal";f==="dead-code"?r++:f==="file-internal"?o++:s++,c+=u.loc,i.push({relativePath:u.relative_path,startLine:u.start_line,endLine:u.end_line,loc:u.loc,symbol:u.symbol,shortName:k(u.symbol),sameFileRefs:u.same_file_refs,kind:f,...m?{implicitUsageReason:m}:{}})}return{symbols:i,counts:{total:i.length,deadCode:r,fileInternal:o,implicitUsage:s,loc:c},applicability:{entrySurfaceExcluded:a,externalRootExcluded:l,implicitUsageSignals:s},totalCount:i.length,deadCodeCount:r,fileInternalCount:o,implicitUsageCount:s,totalLoc:c}}function l0(e,t,n,i){if(t.length===0)return;let r=new U(e),o=new Set(t.map(l=>l.symbolId)),s=new Set(t.map(l=>l.leaf).filter(Boolean)),a=new Set(r.sourceFiles());for(let l of he(e))a.add(l);r.scanSourceReferences({paths:a,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:s,skipPath:l=>i.inactiveBarrelPaths.has(l)},l=>{o.has(l.target.symbolId)&&(d0(e,l)||Ca(n,l.target.symbolId,l.sourceFile,m0(l),"source-fallback"))})}function c0(e,t,n,i){if(t.length===0)return;let r=new U(e),o=mm(t),s=new Set(r.sourceFiles());for(let u of he(e))s.add(u);let a=new Set(o.keys()),l=new Map,c=u=>{let d=l.get(u);return d||(d=Rm(e,u),l.set(u,d)),d};r.scanSourceReferences({paths:s,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:a,skipPath:u=>i.inactiveBarrelPaths.has(u),resolveTargets:({sourceFile:u,name:d,kind:m})=>{let f=o.get(d);return f?u0(u,d,f,()=>c(u),{permissive:m!=="cross-language-dispatch"}):[]},afterPath:u=>{l.delete(u),eb(e,u)}},u=>{let d=u.kind==="identifier"&&u.sourceFile===u.target.relativePath?Math.max(0,u.occurrences-1):u.occurrences;u.kind==="identifier"&&lb(e,{sourceFile:u.sourceFile,name:u.name,target:u.target,occurrences:d})||Ca(n,u.target.symbolId,u.sourceFile,d,"source-fallback")})}function u0(e,t,n,i,r){let o=n.filter(c=>c.relativePath===e);if(o.length>0)return o;if(!r.permissive&&n.length===1)return[...n];let s=i(),a=s.get(t);if(a)for(let c of a){let u=n.filter(d=>Pt(c,d.relativePath));if(u.length>0)return u}let l=new Set;for(let c of s.values())for(let u of c)l.add(u);for(let c of l){let u=n.filter(d=>Pt(c,d.relativePath));if(u.length>0&&u.length===n.length)return u}return r.permissive?[...n]:[]}function d0(e,t){return t.kind==="cross-language-dispatch"&&t.target.relativePath===t.sourceFile?!0:t.kind==="identifier"&&lb(e,t)}function m0(e){return e.kind==="identifier"&&e.target.relativePath===e.sourceFile?Math.max(0,e.occurrences-1):e.occurrences}function lb(e,t){return t.occurrences>1?!1:Ce(e,t.sourceFile).some(n=>n.used||n.sourcePath!==t.target.relativePath?!1:n.importedName===t.name||n.localName===t.name)}function f0(e,t,n,i){let r=new Set,o=i.includeSemantic!==!1,s=(u,d)=>{d===u.relativePath||e.isIgnored(d)||i.inactiveBarrelPaths.has(d)||sb(n,u.symbolId,d,1,"caller-map")};if($("dead.caller-map.per-symbol-non-semantic",()=>{for(let u of t){let d=fs(e,u,{semantic:!1,semanticEvidence:pe});for(let m of d)s(u,m.file)}},()=>({definitions:t.length,semantic:!1})),!o)return r;let a=0,l=$("dead.caller-map.semantic-candidates",()=>{let u=t.filter(d=>!va(n,d.symbolId,d.relativePath));return a=u.length,u},()=>({definitions:t.length,semanticCandidates:a}));if(l.length===0)return r;let c=Cn(e,l);for(let u of c.incompleteSymbolIds)r.add(u);for(let u of c.unavailableSymbolIds)r.add(u);for(let u of l){let d=c.callers.get(u.symbolId);if(d)for(let m of d)s(u,m)}return r}function p0(e,t={}){let{limit:n=30,scope:i}=t,r=i?"AND def_d.relative_path LIKE ?":"",o=i?[`%${i}%`]:[],a=e.all(`SELECT
120
+ gs.symbol,
121
+ COUNT(*) AS ref_count,
122
+ COUNT(DISTINCT ref_d.id) AS file_count,
123
+ def_d.relative_path AS defined_in
124
+ FROM mentions m
125
+ JOIN chunks c ON m.chunk_id = c.id
126
+ JOIN documents ref_d ON c.document_id = ref_d.id
127
+ JOIN global_symbols gs ON m.symbol_id = gs.id
128
+ JOIN (
129
+ SELECT m2.symbol_id, c2.document_id
130
+ FROM mentions m2
131
+ JOIN chunks c2 ON m2.chunk_id = c2.id
132
+ WHERE m2.role = 1
133
+ GROUP BY m2.symbol_id
134
+ ) sym_def ON sym_def.symbol_id = gs.id
135
+ JOIN documents def_d ON sym_def.document_id = def_d.id
136
+ WHERE m.role != 1
137
+ AND def_d.id != ref_d.id
138
+ ${e.pathExclusionsFor("def_d")}
139
+ ${e.symbolNoiseFor("gs")}
140
+ ${r}
141
+ GROUP BY gs.id
142
+ ORDER BY ref_count DESC
143
+ LIMIT ?`,...o,n).filter(l=>!e.isIgnored(l.defined_in)).map(l=>({symbol:l.symbol,shortName:k(l.symbol),refCount:l.ref_count,fileCount:l.file_count,definedIn:l.defined_in,basis:"scip-cross-file-mentions",countUnit:"reference-occurrences"}));return a.length>0?{rows:a,coverage:{semanticEvidence:{enabled:!1,status:"disabled",incompleteSymbolCount:0,unavailableSymbolCount:0}}}:g0(e,i,n)}function g0(e,t,n){let i=ze(e,{scope:t}).filter(a=>!e.isIgnored(a.relativePath)),r=Qt(e,i,{limit:500,semanticEvidence:pe}),o=i.filter(a=>!r.incompleteSymbolIds.has(a.symbolId)&&!r.unavailableSymbolIds.has(a.symbolId)).map(a=>h0(a,r.rows.get(a.symbolId)??[])).filter(a=>a.refCount>0).sort((a,l)=>l.refCount-a.refCount||l.fileCount-a.fileCount).slice(0,n),s=r.incompleteSymbolIds.size>0&&r.unavailableSymbolIds.size>0?"incomplete-and-unavailable":r.incompleteSymbolIds.size>0?"incomplete":r.unavailableSymbolIds.size>0?"unavailable":"complete";return{rows:o,coverage:{semanticEvidence:{enabled:!0,status:s,incompleteSymbolCount:r.incompleteSymbolIds.size,unavailableSymbolCount:r.unavailableSymbolIds.size}}}}function h0(e,t){let n=t.filter(i=>i.file!==e.relativePath);return{symbol:e.symbol,shortName:k(e.symbol),refCount:n.length,fileCount:new Set(n.map(i=>i.file)).size,definedIn:e.relativePath,basis:"source-backed-incoming-evidence",countUnit:"distinct-incoming-evidence-rows"}}function y0(e,t,n={}){return L0(e,t,n)?.map(i=>({symbol:i.symbol,shortName:i.shortName,fromFile:i.fromFile}))??[]}function b0(e,t){let n=fe(e,t),i=C0(e,t);if(i.length>0&&!R0(n))return i;let r=x0(e,t,n);return cu(t)&&r.length>0?r:E0([...i,...r])}function S0(e,t,n={}){let i=lt(e,t);if(!i)return[];let r=ub(e,i),o=n.semantic===!1?null:cb(e,i);return(o?v0(o,r):r).filter(a=>!a.used).map(a=>({symbol:a.symbol,shortName:a.shortName,importedIn:a.importer}))}function v0(e,t){let n=new Map;for(let r of t){let o=n.get(r.shortName);o?o.push(r):n.set(r.shortName,[r])}let i=e.map(r=>{let o=n.get(r.shortName),s=o?.shift();return o?.length===0&&n.delete(r.shortName),s?{...r,used:r.used||s.used}:r});return i.push(...[...n.values()].flat()),i}function C0(e,t){return e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
144
+ FROM mentions m
145
+ JOIN chunks c ON m.chunk_id = c.id
146
+ JOIN documents d ON c.document_id = d.id
147
+ JOIN global_symbols gs ON m.symbol_id = gs.id
148
+ WHERE gs.symbol LIKE ?
149
+ AND m.role = 2
150
+ ORDER BY d.relative_path`,`%${t}%`).filter(i=>!e.isIgnored(i.importer)).map(i=>({symbol:i.symbol,shortName:k(i.symbol),fromFile:i.importer}))}function x0(e,t,n=fe(e,t)){let i=n?.relativePath??null,r=n?re(n.symbol):t.replace(/\(\)$/,""),o=n?Le(n.symbol):!1,s=new Set;for(let l of he(e,{includeIgnored:!1}))for(let c of Ce(e,l))w0(c,l,{targetFile:i,targetLeaf:r,targetIsModule:o,targetPattern:t})&&s.add(l);let a=cu(t)?t.trim():null;return[...s].sort().map(l=>({symbol:a??n?.symbol??r,shortName:a??(n?k(n.symbol):r),fromFile:l}))}function R0(e){return!!(e&&(e.symbol.startsWith("scip-clojure ")||ye(e.relativePath)==="clojure"))}function E0(e){let t=new Set,n=[];for(let i of e){let r=`${i.symbol}|${i.fromFile}`;t.has(r)||(t.add(r),n.push(i))}return n.sort((i,r)=>i.fromFile.localeCompare(r.fromFile)||i.shortName.localeCompare(r.shortName))}function w0(e,t,n){return!e.sourcePath||n.targetFile&&pt(e.sourcePath)!==pt(n.targetFile)?!1:e.kind==="side-effect"||n.targetFile&&F0(t)||e.kind==="namespace"&&I0(e,n.targetPattern)||n.targetIsModule||e.kind==="named"&&e.importedName===n.targetLeaf?!0:e.kind==="namespace"&&e.usedMembers.includes(n.targetLeaf)}function I0(e,t){let n=t.trim().replace(/\(\)$/,"");return cu(n)?e.importedName===n||e.localName===n:!1}function cu(e){let t=e.trim().replace(/\(\)$/,"");return t.includes(".")&&!t.includes("/")&&!t.includes(":")}function L0(e,t,n={}){let i=lt(e,t);return i?D0(e,i,n)??(n.semantic===!1?null:cb(e,i))??ub(e,i):null}function D0(e,t,n){let r=e.all(`SELECT DISTINCT
151
+ gs.symbol,
152
+ def_d.relative_path AS from_file,
153
+ imp_d.relative_path AS importer,
154
+ EXISTS (
155
+ SELECT 1
156
+ FROM mentions ref_m
157
+ JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
158
+ WHERE ref_m.symbol_id = gs.id
159
+ AND ref_m.role != 1
160
+ AND ref_c.document_id = imp_d.id
161
+ ) AS used
162
+ FROM mentions m
163
+ JOIN chunks c ON m.chunk_id = c.id
164
+ JOIN documents imp_d ON c.document_id = imp_d.id
165
+ JOIN global_symbols gs ON m.symbol_id = gs.id
166
+ LEFT JOIN (
167
+ SELECT m2.symbol_id, c2.document_id
168
+ FROM mentions m2
169
+ JOIN chunks c2 ON m2.chunk_id = c2.id
170
+ WHERE m2.role = 1
171
+ GROUP BY m2.symbol_id
172
+ ) sym_def ON sym_def.symbol_id = gs.id
173
+ LEFT JOIN documents def_d ON sym_def.document_id = def_d.id
174
+ WHERE imp_d.relative_path = ?
175
+ AND m.role = 2
176
+ ORDER BY def_d.relative_path, gs.symbol`,t).filter(o=>!e.isIgnored(o.importer));if(r.length>0){let o=n.semantic===!1?[]:$r(e,t);return r.map(s=>({symbol:s.symbol,shortName:k(s.symbol),fromFile:s.from_file??"(external)",importer:s.importer,used:s.used!==0||o.some(a=>a.isUsed&&a.sourcePath===s.from_file)}))}return null}function cb(e,t){let n=$r(e,t);return n.length>0?n.map(i=>{let r=db(i.importedName,i.localName,i.kind);return{symbol:r,shortName:r,fromFile:i.sourcePath??"(external)",importer:t,used:i.kind==="side-effect"?!0:i.isUsed}}):null}function ub(e,t){let n=P0(t,se(e,t));return Ce(e,t).map(i=>{let r=db(i.importedName,i.localName,i.kind),o=i.kind==="side-effect"||T0(t,i)||n.has(i.localName??i.importedName)?!0:i.used;return{symbol:r,shortName:r,fromFile:i.sourcePath??"(external)",importer:t,used:o}})}function P0(e,t){let n=new Set;if(ye(e)!=="python")return n;let i=/(?:^|\n)\s*__all__\s*(?:\+?=)\s*[[(]([\s\S]*?)[\])]/g;for(let r of t.matchAll(i)){let o=r[1]??"";for(let s of o.matchAll(/(['"])([A-Za-z_]\w*)\1/g))n.add(s[2])}return n}function T0(e,t){if(ye(e)!=="rust"||t.used||t.kind==="side-effect")return!1;let n=t.localName??t.importedName;return n==="_"||/^[A-Z]/.test(n)}function db(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 F0(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}function M0(e,t){let n=fe(e,t);if(!n)return[];let r=new U(e).definitionsForFile(n.relativePath).filter(o=>o.symbol!==n.symbol).filter(o=>um(n.symbol,o.symbol)).sort((o,s)=>o.startLine-s.startLine||o.endLine-s.endLine).map(o=>({symbol:o.symbol,shortName:k(o.symbol),startLine:o.startLine,endLine:o.endLine,kind:kn(o.symbol)??"unknown"}));return ye(n.relativePath)!=="clojure"?r:N0(r,A0(e,n))}function A0(e,t){let n=re(t.symbol);if(!n)return[];let i=k(t.symbol);return(ee(e,t.relativePath)?.clojureMembers??[]).filter(r=>r.ownerName===n).map(r=>({symbol:`${t.symbol}${r.memberName}().`,shortName:`${i}:${r.memberName}()`,startLine:r.startLine,endLine:r.endLine,kind:r.memberKind}))}function N0(e,t){let n=new Map;for(let i of[...e,...t])n.set(`${i.shortName}:${i.startLine}:${i.endLine}`,i);return[...n.values()].sort((i,r)=>i.startLine-r.startLine||i.endLine-r.endLine)}function k0(e,t){let n=fe(e,t);if(!n)return[];let i=e.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
177
+ FROM mentions m
178
+ JOIN chunks c ON m.chunk_id = c.id
179
+ JOIN (
180
+ SELECT m2.symbol_id, c2.document_id
181
+ FROM mentions m2
182
+ JOIN chunks c2 ON m2.chunk_id = c2.id
183
+ WHERE m2.role = 1
184
+ GROUP BY m2.symbol_id
185
+ ) sym_def ON sym_def.symbol_id = m.symbol_id
186
+ WHERE m.symbol_id = ?
187
+ AND m.role != 1
188
+ AND sym_def.document_id != c.document_id`,n.symbolId);return[{name:k(n.symbol),count:i?.file_count??0,symbol:n.symbol,definedIn:n.relativePath}]}function _0(e,t){let n=lt(e,t);return n?e.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
189
+ FROM mentions m
190
+ JOIN chunks c ON m.chunk_id = c.id
191
+ JOIN documents d ON c.document_id = d.id
192
+ JOIN global_symbols gs ON m.symbol_id = gs.id
193
+ JOIN (
194
+ SELECT m2.symbol_id, c2.document_id
195
+ FROM mentions m2
196
+ JOIN chunks c2 ON m2.chunk_id = c2.id
197
+ WHERE m2.role = 1
198
+ GROUP BY m2.symbol_id
199
+ ) sym_def ON sym_def.symbol_id = gs.id
200
+ JOIN documents def_d ON sym_def.document_id = def_d.id
201
+ WHERE d.relative_path = ?
202
+ AND m.role != 1
203
+ AND def_d.id != d.id
204
+ GROUP BY d.id
205
+ ORDER BY symbol_count DESC`,n).filter(o=>!e.isIgnored(o.relative_path)).map(o=>({name:o.relative_path,count:o.symbol_count,file:o.relative_path,basis:"external-symbol-references"})):[]}function B0(e,t={}){return O0(e,t).map(n=>({name:k(n.symbol),count:n.file_count,symbol:n.symbol,definedIn:n.defined_in}))}function O0(e,t){let{limit:n=30,scope:i}=t,r=i?"AND def_d.relative_path LIKE ?":"",o=i?[`%${i}%`]:[];return e.all(`SELECT gs.symbol,
206
+ COUNT(DISTINCT c.document_id) AS file_count,
207
+ def_d.relative_path AS defined_in
208
+ FROM mentions m
209
+ JOIN chunks c ON m.chunk_id = c.id
210
+ JOIN global_symbols gs ON m.symbol_id = gs.id
211
+ JOIN (
212
+ SELECT m2.symbol_id, c2.document_id
213
+ FROM mentions m2
214
+ JOIN chunks c2 ON m2.chunk_id = c2.id
215
+ WHERE m2.role = 1
216
+ GROUP BY m2.symbol_id
217
+ ) sym_def ON sym_def.symbol_id = gs.id
218
+ JOIN documents def_d ON sym_def.document_id = def_d.id
219
+ WHERE m.role != 1
220
+ AND def_d.id != c.document_id
221
+ ${e.pathExclusionsFor("def_d")}
222
+ ${e.symbolNoiseFor("gs")}
223
+ ${r}
224
+ GROUP BY gs.id
225
+ HAVING file_count > 1
226
+ ORDER BY file_count DESC
227
+ LIMIT ?`,...o,n)}function $0(e,t={}){let{limit:n=30,scope:i}=t,r=i?"AND d.relative_path LIKE ?":"",o=i?[`%${i}%`]:[];return e.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
228
+ FROM mentions m
229
+ JOIN chunks c ON m.chunk_id = c.id
230
+ JOIN documents d ON c.document_id = d.id
231
+ JOIN global_symbols gs ON m.symbol_id = gs.id
232
+ JOIN (
233
+ SELECT m2.symbol_id, c2.document_id
234
+ FROM mentions m2
235
+ JOIN chunks c2 ON m2.chunk_id = c2.id
236
+ WHERE m2.role = 1
237
+ GROUP BY m2.symbol_id
238
+ ) sym_def ON sym_def.symbol_id = gs.id
239
+ JOIN documents def_d ON sym_def.document_id = def_d.id
240
+ WHERE m.role != 1
241
+ AND def_d.id != d.id
242
+ ${e.pathExclusionsFor("d")}
243
+ ${e.symbolNoiseFor("gs")}
244
+ ${r}
245
+ GROUP BY d.id
246
+ ORDER BY symbol_count DESC
247
+ LIMIT ?`,...o,n).filter(a=>!e.isIgnored(a.relative_path)).map(a=>({name:a.relative_path,count:a.symbol_count}))}var mb=`SELECT COUNT(*) AS shared
248
+ FROM (
249
+ SELECT definition_m.symbol_id
250
+ FROM documents definition_d
251
+ JOIN chunks definition_c ON definition_c.document_id = definition_d.id
252
+ JOIN mentions definition_m ON definition_m.chunk_id = definition_c.id
253
+ AND definition_m.role = 1
254
+ JOIN mentions reference_m ON reference_m.symbol_id = definition_m.symbol_id
255
+ AND reference_m.role != 1
256
+ JOIN chunks reference_c ON reference_c.id = reference_m.chunk_id
257
+ JOIN documents reference_d ON reference_d.id = reference_c.document_id
258
+ WHERE definition_d.relative_path = ?
259
+ AND reference_d.relative_path = ?
260
+ UNION
261
+ SELECT definition_m.symbol_id
262
+ FROM documents definition_d
263
+ JOIN chunks definition_c ON definition_c.document_id = definition_d.id
264
+ JOIN mentions definition_m ON definition_m.chunk_id = definition_c.id
265
+ AND definition_m.role = 1
266
+ JOIN mentions reference_m ON reference_m.symbol_id = definition_m.symbol_id
267
+ AND reference_m.role != 1
268
+ JOIN chunks reference_c ON reference_c.id = reference_m.chunk_id
269
+ JOIN documents reference_d ON reference_d.id = reference_c.document_id
270
+ WHERE definition_d.relative_path = ?
271
+ AND reference_d.relative_path = ?
272
+ )`;function j0(e,t,n){let i=lt(e,t)??t,r=lt(e,n)??n,o=e.get(mb,i,r,r,i);return{...fb(i,r,o?.shared??0)}}function H0(e,t={}){let{limit:n=20,scope:i}=t,r=i?"AND def_d.relative_path LIKE ? AND ref_d.relative_path LIKE ?":"",o=i?[`%${i}%`,`%${i}%`]:[];return e.all(`SELECT
273
+ CASE WHEN def_d.relative_path < ref_d.relative_path THEN def_d.relative_path ELSE ref_d.relative_path END AS file1,
274
+ CASE WHEN def_d.relative_path < ref_d.relative_path THEN ref_d.relative_path ELSE def_d.relative_path END AS file2,
275
+ COUNT(DISTINCT gs.id) AS shared
276
+ FROM mentions m
277
+ JOIN chunks c ON m.chunk_id = c.id
278
+ JOIN documents ref_d ON c.document_id = ref_d.id
279
+ JOIN global_symbols gs ON m.symbol_id = gs.id
280
+ JOIN (
281
+ SELECT m2.symbol_id, c2.document_id
282
+ FROM mentions m2
283
+ JOIN chunks c2 ON m2.chunk_id = c2.id
284
+ WHERE m2.role = 1
285
+ GROUP BY m2.symbol_id
286
+ ) sym_def ON sym_def.symbol_id = gs.id
287
+ JOIN documents def_d ON sym_def.document_id = def_d.id
288
+ WHERE m.role != 1
289
+ AND def_d.id != ref_d.id
290
+ ${e.pathExclusionsFor("def_d","ref_d")}
291
+ ${r}
292
+ GROUP BY file1, file2
293
+ ORDER BY shared DESC, file1, file2
294
+ LIMIT ?`,...o,n).filter(a=>!e.isIgnored(a.file1)&&!e.isIgnored(a.file2)).map(a=>fb(a.file1,a.file2,a.shared))}function fb(e,t,n){return{file1:e,file2:t,sharedSymbols:n,actionTier:"signal",couplingKind:"shared-symbol-coupling",evidenceReasons:[`${n} symbol(s) are defined in one file and referenced by the other`],recommendation:"Review whether the shared symbol surface is an intentional boundary or hidden coordination pressure before moving code."}}function Ii(e){let t=new Map,n=[],i=new Map,r=new Map,o=new Set,s=[],a=0,l=c=>(e.get(c)??[]).values();for(let c of e.keys()){if(i.has(c))continue;let u=[];for(i.set(c,a),r.set(c,a),a+=1,s.push(c),o.add(c),u.push({node:c,iter:l(c),pendingChild:null});u.length>0;){let d=u[u.length-1];if(d.pendingChild!==null){let p=d.pendingChild;d.pendingChild=null,r.set(d.node,Math.min(r.get(d.node),r.get(p)))}let m=d.iter.next();if(m.done){if(r.get(d.node)===i.get(d.node)){let p=[];for(;;){let g=s.pop();if(o.delete(g),p.push(g),t.set(g,n.length),g===d.node)break}n.push(p)}u.pop();continue}let f=m.value;i.has(f)?o.has(f)&&r.set(d.node,Math.min(r.get(d.node),i.get(f))):(i.set(f,a),r.set(f,a),a+=1,s.push(f),o.add(f),d.pendingChild=f,u.push({node:f,iter:l(f),pendingChild:null}))}}return{components:n,componentOf:t}}function mo(e,t={}){return hb(e,t).cycles}function hb(e,t={}){return yb(e,t)}function yb(e,t={}){let{scope:n,maxDepth:i=10,edgeBasis:r="symbol-references"}=t,o=Be(e,n,r==="imports"?{scipEdges:"imports-only",sourceEdges:"imports-only"}:void 0),{components:s}=Ii(o),a=s.filter(l=>U0(o,l)).map(l=>{let c=[...l].sort(),u=z0(o,c),d=K0(u);return{path:u,component:c,edgeBasis:r,witness:!0,classification:d==="real"?"dependency-cycle":"module-structure-candidate",kind:d}});return a.sort((l,c)=>l.kind!==c.kind?l.kind==="real"?-1:1:l.path.length-c.path.length),{cycles:a,truncated:!1,edgeBasis:r,maxDepth:i}}function U0(e,t){if(t.length>1)return!0;let n=t[0];return n!==void 0&&e.get(n)?.has(n)===!0}function z0(e,t){let n=t[0];if(!n)return[];let i=new Set(t);for(let r of[...e.get(n)??[]].filter(o=>i.has(o)).sort()){if(r===n)return[n,n];let o=G0(e,r,n,i);if(o)return[n,...o]}throw new Error(`Cyclic component did not contain a witness path from ${n}.`)}function G0(e,t,n,i){let r=[t],o=new Map([[t,null]]);for(let s=0;s<r.length;s+=1){let a=r[s];if(a===n){let l=[];for(let c=a;c!==null;c=o.get(c)??null)l.push(c);return l.reverse()}for(let l of[...e.get(a)??[]].filter(c=>i.has(c)).sort())o.has(l)||(o.set(l,a),r.push(l))}return null}function K0(e){for(let i of e){let r=V(i);if(r==="test"||r==="barrel"||r==="entry")return"module-hierarchy"}if(e.length!==3)return"real";let[t,n]=e;return!t||!n?"real":Ki(t)||Ki(n)||pb(t,n)||pb(n,t)||gb(t,n)||gb(n,t)||V(t)==="entry"||V(n)==="entry"?"module-hierarchy":"real"}function pb(e,t){if(!/\.rs$/.test(e)||!/\.rs$/.test(t))return!1;let n=t.replace(/\.rs$/,"/");return e.startsWith(n)?!e.slice(n.length).includes("/"):!1}function gb(e,t){if(!/\.rs$/.test(e)||!/\.rs$/.test(t))return!1;let n=e.replace(/\.rs$/,""),i=t.replace(/\.rs$/,"");if(n===i+"_tests"||n===i+"/tests")return!0;let r=e.split("/"),o=t.split("/");if(r.length===o.length&&r.includes("tests")&&o.includes("src")){let s=r[r.length-1],a=o[o.length-1];if(s&&s===a)return!0}return!1}import{readdirSync as q0}from"fs";import{join as bb}from"path";function Jn(e,t){return Xm(e,t)}function W0(e){return Sb(e).replace(/\/\*\*?$/,"")}function xa(e,t){let n=Sb(t),i=W0(n),r=n.endsWith("/**"),o=[],s=(a,l)=>{let c;try{c=q0(a,{withFileTypes:!0})}catch{return}for(let u of c){if(u.name.startsWith("."))continue;let d=l?`${l}/${u.name}`:u.name;Jn(n,d)&&o.push(d),r&&u.isDirectory()&&s(bb(a,u.name),d)}};return s(bb(e,i),i),o.sort()}function Sb(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"")}var V0=/\.(test|spec)\.(ts|tsx|js|jsx|mts|cts)$/,vb=new Map;function Cb(e,t,n,i){if(!t?.testPaths?.length)return[];let r=J0(t),o=[];for(let s of Y0(e,t.testPaths)){let a=X0(e,s,i),l=a?n(a):null;if(l)for(let c of Ce(e,s)){let u=c.sourcePath;if(!u)continue;let d=n(u);d&&d!==l&&(r.get(l)?.has(d)||o.push({testFile:s,ownerBoundary:l,importedFile:u,importedBoundary:d,reason:"outside-owner-policy"}))}}return Z0(o)}function J0(e){let t=e.allowedDependencies??{},n=e.boundaries.map(s=>s.name),i=new Map,r=(s,a)=>{for(let l of t[s]??[])a.has(l)||(a.add(l),r(l,a))};for(let s of n){let a=new Set;r(s,a),i.set(s,a)}let o=new Map;for(let s of n){let a=new Set(i.get(s));for(let l of n)l!==s&&i.get(l)?.has(s)&&a.add(l);o.set(s,a)}return o}function Y0(e,t){let n=`${e.config.projectRoot}\0${t.join("\0")}`,i=vb.get(n);if(i)return i;let r=new Set;for(let s of t)for(let a of xa(e.config.projectRoot,s))V0.test(a)&&r.add(a);let o=[...r].sort();return vb.set(n,o),o}function X0(e,t,n){let i=t.replace(/^tests\//,"src/").replace(/\.(test|spec)\.(\w+)$/,".$2");if(i!==t&&n(i))return i;let r=t.split("/").pop().replace(/\.(test|spec)\.(\w+)$/,".$2"),o=Ce(e,t).map(s=>s.sourcePath).filter(s=>!!s&&n(s)&&s.split("/").pop()===r);return o.length===1?o[0]:null}function Z0(e){let t=new Map;for(let n of e){let i=`${n.testFile}\0${n.importedBoundary}`;t.has(i)||t.set(i,n)}return[...t.values()].sort((n,i)=>n.testFile.localeCompare(i.testFile)||n.importedBoundary.localeCompare(i.importedBoundary))}function xb(e,t){let n=(e?.boundaries??[]).filter(i=>i.paths.some(r=>Jn(r,t)));return n.length===1?n[0].name:null}var Tn="architecture:";function Rb(e,t,n,i={}){let r=eA(e,t);if(!n||n.boundaries.length===0)return{configured:!1,boundaries:[],edges:[],forbiddenEdges:[],reciprocalPairs:[],cycles:[],coarseBoundaries:[],staleAllowances:[],boundaryLimits:[],fragileEdges:[],testBoundaryViolations:[],coverage:{totalFiles:r.length,mappedFiles:0,unmappedFiles:[],ambiguousFiles:[]},policyCoverage:{declaredRows:0,totalBoundaries:0,missingRows:[],requiresCompletePolicy:!1,requiresCompleteCoverage:!1,requiresMinimalPolicy:!1}};let o=new Map,s=new Map(n.boundaries.map(y=>[y.name,new Set])),a=[],l=[];for(let y of r){let E=n.boundaries.filter(w=>w.paths.some(b=>Jn(b,y))).map(w=>w.name).sort();if(E.length===0)a.push(y);else if(E.length>1)l.push({file:y,boundaries:E});else{let w=E[0];o.set(y,w),s.get(w).add(y)}}let c=new Map;for(let[y,E]of e){let w=o.get(y);if(w)for(let b of E){let R=o.get(b);if(!R||w===R)continue;let C=rr(w,R),L=c.get(C);L||(L={from:w,to:R,fileEdges:[],importers:new Set,importedFiles:new Set},c.set(C,L)),L.fileEdges.push({fromFile:y,toFile:b}),L.importers.add(y),L.importedFiles.add(b)}}let u=[...c.values()].map(y=>tA(y,n)).sort(cA),d=u,m=new Map(d.map(y=>[rr(y.from,y.to),y])),f=new Map(n.boundaries.map(y=>[y.name,new Set]));for(let y of d)f.get(y.from).add(y.to);let p=[];for(let y of d){if(y.from>=y.to)continue;let E=m.get(rr(y.to,y.from));E&&p.push({boundaries:[y.from,y.to],forward:y,reverse:E})}let{components:g}=Ii(f),h=g.filter(y=>y.length>1).map(y=>iA(y,d,n.requireAcyclic===!0)).sort((y,E)=>E.boundaries.length-y.boundaries.length||y.boundaries.join("/").localeCompare(E.boundaries.join("/"))),S=n.allowedDependencies??{},v=n.boundaries.map(y=>y.name).filter(y=>!Object.hasOwn(S,y)).sort();return{configured:!0,boundaries:n.boundaries.map(y=>({name:y.name,paths:[...y.paths],fileCount:s.get(y.name).size,dependencyPolicyDeclared:Object.hasOwn(S,y.name)})).sort((y,E)=>y.name.localeCompare(E.name)),edges:u,forbiddenEdges:d.filter(y=>y.policyStatus==="forbidden"),reciprocalPairs:p,cycles:h,staleAllowances:oA(n,d),boundaryLimits:sA(n,d,s),fragileEdges:d.filter(y=>y.fragile),testBoundaryViolations:i.testBoundaryViolations??[],coarseBoundaries:rA(e,s,i.isModuleHierarchyFile,n.requireResolvedBoundaries===!0,y=>n.boundaries.find(E=>E.name===y)?.subUnits??"directory"),coverage:{totalFiles:r.length,mappedFiles:o.size,unmappedFiles:a,ambiguousFiles:l},policyCoverage:{declaredRows:n.boundaries.length-v.length,totalBoundaries:n.boundaries.length,missingRows:v,requiresCompletePolicy:n.requireCompletePolicy===!0,requiresCompleteCoverage:n.requireCompleteCoverage===!0,requiresMinimalPolicy:n.requireMinimalPolicy===!0}}}function fo(e,t={}){let n=Be(e,t.scope,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}),i=he(e,{includeIgnored:!1}).filter(o=>!t.scope||o.includes(t.scope)),r=new Set(i);return Rb(n,i,e.config.architecture,{isModuleHierarchyFile:o=>Q0(e,o),testBoundaryViolations:Cb(e,e.config.architecture,o=>xb(e.config.architecture,o),o=>r.has(o))})}function Q0(e,t){let n=V(t);return n==="test"||n==="entry"?!0:n!=="barrel"?!1:J(e,t).length===0}function uu(e){let t=e.forbiddenEdges.map(i=>`${Tn}forbidden-edge:${encodeURIComponent(i.from)}:${encodeURIComponent(i.to)}`);if(e.policyCoverage.requiresCompletePolicy)for(let i of e.policyCoverage.missingRows)t.push(`${Tn}missing-policy-row:${encodeURIComponent(i)}`);if(e.policyCoverage.requiresCompleteCoverage){for(let i of e.coverage.unmappedFiles)t.push(`${Tn}unmapped-file:${encodeURIComponent(i)}`);for(let i of e.coverage.ambiguousFiles)t.push(`${Tn}ambiguous-file:${encodeURIComponent(i.file)}:${i.boundaries.map(r=>encodeURIComponent(r)).sort().join("|")}`)}if(e.policyCoverage.requiresMinimalPolicy)for(let i of e.staleAllowances)t.push(`${Tn}stale-allowance:${encodeURIComponent(i.from)}:${encodeURIComponent(i.to)}`);for(let i of e.testBoundaryViolations)t.push(`${Tn}test-boundary:${encodeURIComponent(i.testFile)}:${encodeURIComponent(i.importedBoundary)}`);for(let i of e.boundaryLimits)t.push(`${Tn}boundary-limit:${i.kind}:${encodeURIComponent(i.boundary)}`);let n=new Map;for(let i of e.coarseBoundaries)i.violatesPolicy&&n.set(i.boundary,(n.get(i.boundary)??0)+1);for(let[i,r]of n){let o=`${Tn}coarse-boundary:${encodeURIComponent(i)}`;t.push(o);for(let s=2;s<=r;s+=1)t.push(`${o}:component:${s}`)}for(let i of e.cycles)i.violatesPolicy&&t.push(`${Tn}cycle:${i.boundaries.map(r=>encodeURIComponent(r)).sort().join("|")}`);return[...new Set(t)].sort()}function eA(e,t){let n=new Set(t);for(let[i,r]of e){n.add(i);for(let o of r)n.add(o)}return[...n].sort()}function tA(e,t){let n=[...e.fileEdges].sort((i,r)=>i.fromFile.localeCompare(r.fromFile)||i.toFile.localeCompare(r.toFile));return{from:e.from,to:e.to,policyStatus:nA(t,e.from,e.to),fileEdgeCount:n.length,importerCount:e.importers.size,importedFileCount:e.importedFiles.size,examples:n.slice(0,5),fragile:n.length===1}}function nA(e,t,n){return!e.allowedDependencies||!Object.hasOwn(e.allowedDependencies,t)?"undeclared":e.allowedDependencies[t].includes(n)?"allowed":"forbidden"}function iA(e,t,n){let i=[...e].sort(),r=new Set(i),o=t.filter(a=>r.has(a.from)&&r.has(a.to)),s=Math.min(...o.map(a=>a.fileEdgeCount));return{boundaries:i,internalEdges:o,narrowestEdges:o.filter(a=>a.fileEdgeCount===s),violatesPolicy:n}}function rA(e,t,n=aA,i=!1,r=()=>"directory"){let o=[];for(let[s,a]of t){let l=r(s)==="file"?p=>p:lA,c=[...a].filter(p=>!n(p));if(c.length<2)continue;let u=new Set(c),d=new Map,m=new Map;for(let p of c)m.set(l(p),new Set);for(let p of c)for(let g of e.get(p)??[]){if(!u.has(g))continue;let h=l(p),S=l(g);if(h===S)continue;let v=rr(h,S),y=d.get(v);y||(y={from:h,to:S,fileEdges:[]},d.set(v,y)),y.fileEdges.push({fromFile:p,toFile:g}),m.get(h).add(S)}let{components:f}=Ii(m);for(let p of f){if(p.length<2)continue;let g=new Set(p),h=[...d.values()].filter(v=>g.has(v.from)&&g.has(v.to)).map(v=>({from:v.from,to:v.to,fileEdgeCount:v.fileEdges.length,examples:v.fileEdges.slice(0,5)})).sort((v,y)=>v.from.localeCompare(y.from)||v.to.localeCompare(y.to)),S=Math.min(...h.map(v=>v.fileEdgeCount));o.push({boundary:s,violatesPolicy:i,subUnits:[...p].sort(),internalEdges:h,narrowestEdges:h.filter(v=>v.fileEdgeCount===S)})}}return o.sort((s,a)=>a.subUnits.length-s.subUnits.length||s.boundary.localeCompare(a.boundary))}function oA(e,t){let n=new Set(t.map(s=>rr(s.from,s.to))),i=e.allowedDependencies??{},r=new Set(e.boundaries.map(s=>s.name)),o=[];for(let[s,a]of Object.entries(i))if(r.has(s))for(let l of a)!r.has(l)||n.has(rr(s,l))||o.push({from:s,to:l});return o.sort((s,a)=>s.from.localeCompare(a.from)||s.to.localeCompare(a.to))}function sA(e,t,n){let i=[],r=new Map;for(let o of t)r.set(o.from,(r.get(o.from)??0)+1);for(let o of e.boundaries){if(e.maxBoundaryFanOut!==void 0){let a=r.get(o.name)??0;a>e.maxBoundaryFanOut&&i.push({boundary:o.name,kind:"fan-out",observed:a,limit:e.maxBoundaryFanOut})}let s=o.maxFiles??e.maxBoundaryFiles;if(s!==void 0){let a=n.get(o.name)?.size??0;a>s&&i.push({boundary:o.name,kind:"files",observed:a,limit:s})}}return i.sort((o,s)=>o.boundary.localeCompare(s.boundary)||o.kind.localeCompare(s.kind))}function aA(e){let t=V(e);return t==="test"||t==="entry"}function lA(e){let t=e.lastIndexOf("/");return t===-1?".":e.slice(0,t)}function rr(e,t){return`${e}\0${t}`}function cA(e,t){return e.from.localeCompare(t.from)||e.to.localeCompare(t.to)}function uA(e,t={}){let{limit:n=20,scope:i,minFanIn:r=2,minFanOut:o=2,scanLimit:s}=t,a=new U(e),l=Ae(a.productionCallableDefinitions({scope:i,requireCallableSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof s=="number"&&s>0}),s),c=t.semantic!==!1,u=Qt(e,l,{limit:500,semantic:c,semanticEvidence:pe}),d=a.calleeEvidenceMap(l,{semantic:c}),m=new Set([...u.incompleteSymbolIds,...d.incompleteSymbolIds]),f=new Set([...u.unavailableSymbolIds,...d.unavailableSymbolIds]);return{rows:l.filter(g=>!m.has(g.symbolId)&&!f.has(g.symbolId)).map(g=>mA(g,u.rows.get(g.symbolId)??[],d.rows.get(g.symbolId)??[])).filter(g=>g.fanIn>=r&&g.fanOut>=o).sort((g,h)=>h.score-g.score||h.fanIn-g.fanIn).slice(0,n),coverage:dA(c,m,f)}}function dA(e,t,n){let i=e?t.size>0&&n.size>0?"incomplete-and-unavailable":t.size>0?"incomplete":n.size>0?"unavailable":"complete":"disabled";return{semanticEvidence:{enabled:e,status:i,incompleteSymbolCount:t.size,unavailableSymbolCount:n.size,excludedSymbolCount:new Set([...t,...n]).size}}}function mA(e,t,n){let i=[...new Set(t.map(d=>d.file))].sort(),r=[...new Set(t.filter(d=>d.source!=="caller-map-inversion"||d.callEvidence==="scip-chunk").map(d=>d.file))].sort(),o=new Map;for(let d of n.slice(0,500)){if(d.file===e.relativePath)continue;let m=`${d.symbol}|${d.file}`;o.has(m)||o.set(m,{symbol:d.symbol,shortName:k(d.symbol),file:d.file,evidenceStrength:d.source==="scip-chunk"?"candidate":"exact",evidenceSource:d.source})}let s=[...o.values()].sort((d,m)=>d.file.localeCompare(m.file)||d.symbol.localeCompare(m.symbol)),a=i.length,l=s.length,c=a*l,u=s.filter(d=>d.evidenceStrength==="candidate").map(d=>d.symbol);return{symbol:e.symbol,shortName:k(e.symbol),fanIn:a,fanOut:l,callerFiles:i,candidateCallerFiles:r,externalCallees:s.map(({symbol:d,shortName:m,file:f})=>({symbol:d,shortName:m,file:f})),externalCalleeEvidence:s,candidateExternalCallees:u,inputBasis:"mixed-static-call-or-reference-evidence",score:c,definedIn:e.relativePath,actionTier:"signal",riskKind:"coordination-hotspot",evidenceReasons:[`${a} incoming file(s) reference this symbol`,`${l} distinct cross-file callee symbol(s) are reached from it`,`centrality score is ${c} (fan-in * fan-out)`,`${r.length} incoming file(s) and ${u.length} outgoing target(s) rely on candidate rather than exact call evidence`],recommendation:"Review ownership, API stability, and caller groups before changing this central symbol; do not refactor solely from graph centrality."}}function po(e,t={}){let{scope:n,minLoc:i=3,scanLimit:r}=t,o=new U(e),s=t.semantic!==!1,a=0,l=$("isolated.candidates",()=>{let b=Ae(o.productionCallableDefinitions({scope:n,minLoc:i,excludeEntrySurfaces:!0,excludeRootedSymbols:!0,excludeRustTraitImplMembers:!0,includeSuppressed:!0,requireFunctionLikeSymbol:!0,sortByLocDesc:typeof r=="number"&&r>0}),r).filter(R=>!ir(e,R));return a=b.length,b},()=>({definitions:a})),c=0,u=$("isolated.strict-callees",()=>{let w=o.symbolsWithNonSelfCallees(l,{additive:!1,semantic:!1});return c=w.size,w},()=>({definitions:l.length,symbols:c})),d=l.filter(w=>!u.has(w.symbolId)),m=0,f=$("isolated.scip-callers",()=>{let w=o.crossFileCallerMap(d,{semantic:!1});return m=w.size,w},()=>({definitions:d.length,symbols:m})),p=new Set(f.keys());for(let w of o.frameworkReferencedSymbolIds(d))p.add(w);let g=d.filter(w=>!p.has(w.symbolId));if(s&&g.length>0){let w=Cn(e,g);for(let b of w.callers.keys())p.add(b);for(let b of w.incompleteSymbolIds)p.add(b);for(let b of w.unavailableSymbolIds)p.add(b);for(let b of o.symbolsWithNonSelfCallees(g,{additive:!1,semantic:!0}))u.add(b);g=g.filter(b=>!p.has(b.symbolId)).filter(b=>!u.has(b.symbolId))}let h=0,S=$("isolated.source-fallback-callers",()=>{let w=o.sourceFallbackCallerFiles(g,{skipPath:b=>V(b)==="test"});return h=w.size,w},()=>({definitions:g.length,symbols:h}));for(let w of S.keys())p.add(w);let v=g.filter(w=>!p.has(w.symbolId)),y=0,E=$("isolated.additive-callees",()=>{let w=o.symbolsWithNonSelfCallees(v,{additive:!0,semantic:s});return y=w.size,w},()=>({definitions:v.length,symbols:y}));for(let w of E)u.add(w);return v.filter(w=>!u.has(w.symbolId)).sort((w,b)=>de(b)-de(w)||w.relativePath.localeCompare(b.relativePath)||w.startLine-b.startLine).map(w=>({symbol:w.symbol,shortName:k(w.symbol),relativePath:w.relativePath,startLine:w.startLine,endLine:w.endLine,loc:de(w)}))}import{SymbolInformation_Kind as Qe}from"@c4312/scip";var Eb=500;function fA(e){let t=parseInt(e,10);if(!isNaN(t))return t;let n=e.toLowerCase(),i=Zm.get(n);if(i!==void 0)return i;for(let[r,o]of cs)if(o.toLowerCase().includes(n))return r;return null}function pA(e,t,n={}){let{scope:i,limit:r=100}=n,o=fA(t);return o===null?[]:hA(e,i).map(a=>({row:a,resolvedKind:Ib(a)})).filter(a=>a.resolvedKind===o).slice(0,r).map(({row:a,resolvedKind:l})=>({symbol:a.symbol,shortName:k(a.symbol),kind:l,kindName:Rr(l),relativePath:a.relative_path,startLine:a.start_line,endLine:a.end_line}))}function gA(e,t={}){let n=yA(e,t.scope);for(let i of bA(e,t.scope)){let r=Ib(i);r===null||r===0||n.set(r,(n.get(r)??0)+1)}return[...n.entries()].sort((i,r)=>r[1]-i[1]||i[0]-r[0]).map(([i,r])=>({kind:i,kindName:Rr(i),count:r}))}function hA(e,t){return ze(e,{scope:t}).map(SA)}function yA(e,t){let n=new Map;for(let i of wb(he(e,{scope:t,includeIgnored:!1}))){let r=i.map(()=>"?").join(", "),o=e.all(`SELECT gs.kind AS kind, COUNT(*) AS count
295
+ FROM defn_enclosing_ranges der
296
+ JOIN global_symbols gs ON der.symbol_id = gs.id
297
+ JOIN documents d ON der.document_id = d.id
298
+ WHERE gs.kind IS NOT NULL
299
+ AND gs.kind != 0
300
+ AND gs.symbol NOT LIKE '%#'
301
+ AND d.relative_path IN (${r})
302
+ GROUP BY gs.kind`,...i);for(let s of o)n.set(s.kind,(n.get(s.kind)??0)+s.count)}return n}function bA(e,t){let n=[];for(let i of wb(he(e,{scope:t,includeIgnored:!1}))){let r=i.map(()=>"?").join(", ");n.push(...e.all(`SELECT gs.symbol,
303
+ gs.kind,
304
+ gs.documentation,
305
+ gs.enclosing_symbol,
306
+ d.relative_path,
307
+ der.start_line,
308
+ der.end_line
309
+ FROM defn_enclosing_ranges der
310
+ JOIN global_symbols gs ON der.symbol_id = gs.id
311
+ JOIN documents d ON der.document_id = d.id
312
+ WHERE (gs.kind IS NULL OR gs.kind = 0 OR gs.symbol LIKE '%#')
313
+ ${e.symbolNoiseFor("gs")}
314
+ AND d.relative_path IN (${r})
315
+ ORDER BY d.relative_path, der.start_line, der.end_line, gs.symbol`,...i))}return n}function wb(e){let t=[];for(let n=0;n<e.length;n+=Eb)t.push(e.slice(n,n+Eb));return t}function SA(e){return{symbol:e.symbol,kind:e.kind,documentation:e.documentation,enclosing_symbol:e.enclosingSymbol,relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine}}function Ib(e){return e.kind!==null&&e.kind!==0?vA(e.kind,e.symbol,e.documentation):CA(e.symbol,e.documentation,e.enclosing_symbol)}function vA(e,t,n){let i=(n??"").toLowerCase();if(kn(t)==="type"){if(i.includes("type "))return Qe.TypeAlias;if(i.includes("interface "))return Qe.Interface;if(i.includes("struct "))return Qe.Struct;if(i.includes("trait "))return Qe.Trait;if(i.includes("class "))return Qe.Class}return e}function CA(e,t,n){let i=Ni(e);if("kind"in i)return null;let r=i.descriptors,o=r[r.length-2]??null,s=kn(e),a=(t??"").toLowerCase();return s==="type"?a.includes("type ")?Qe.TypeAlias:a.includes("interface ")?Qe.Interface:a.includes("struct ")?Qe.Struct:a.includes("trait ")?Qe.Trait:a.includes("class ")?Qe.Class:Qe.Class:s==="method"?o?.suffix==="type"?Qe.Method:Qe.Function:s==="namespace"?Qe.Module:s!=="term"?null:a.includes("async def ")||a.includes("def ")?Qe.Function:(n?kn(n):o?.suffix??null)==="type"?Qe.Field:Qe.Variable}function xA(e,t={}){let{limit:n=10,scope:i,minDepth:r=3,edgeBasis:o="symbol-references"}=t,s=Be(e,i,o==="imports"?{scipEdges:"imports-only",sourceEdges:"imports-only"}:void 0),{components:a,componentOf:l}=Ii(s),c=new Map;for(let h=0;h<a.length;h++)c.set(h,new Set);for(let[h,S]of s){let v=l.get(h);for(let y of S){let E=l.get(y);E!==v&&c.get(v).add(E)}}let u=new Array(a.length),d=new Array(a.length);for(let h=0;h<a.length;h++){let S=[],v=0;for(let y of[...c.get(h)].sort((E,w)=>E-w)){let E=d[y];(E>v||E===v&&RA(u[y],S,a)<0)&&(v=E,S=u[y])}u[h]=[h,...S],d[h]=1+v}function m(h){return u[h]}let f=a.map(h=>[...h].sort()),p=new Set,g=[];for(let h=0;h<a.length;h++){let v=m(h).map(w=>f[w]),y=v.map(w=>w[0]);if(v.length<r)continue;let E=y.join(" ");p.has(E)||(p.add(E),g.push(EA(y,v,o)))}return g.sort((h,S)=>S.depth-h.depth||h.chain.join("\0").localeCompare(S.chain.join("\0"))),wA(g).slice(0,n)}function RA(e,t,n){if(t.length===0)return-1;let i=e.map(o=>[...n[o]].sort()[0]??"").join("\0"),r=t.map(o=>[...n[o]].sort()[0]??"").join("\0");return i.localeCompare(r)}function EA(e,t,n){let i=t.reduce((o,s)=>o+s.length,0),r=t.filter(o=>o.length>1).length;return{chain:e,components:t,depth:t.length,fileCount:i,edgeBasis:n,actionTier:"signal",chainKind:"transitive-dependency-depth",evidenceReasons:[`${t.length} condensed dependency component(s) form the representative transitive path`,`${i} file(s) are represented; ${r} component(s) contain a dependency cycle`,`edge basis: ${n==="imports"?"resolved file imports":"cross-file symbol references plus resolved source imports"}`,"cycles count once toward depth and retain their full membership separately"],recommendation:"Review whether the chain crosses ownership or layer boundaries; shorten it only when the dependency direction is accidental."}}function wA(e){let t=[];for(let n of e)t.some(i=>IA(n.chain,i.chain))||t.push(n);return t}function IA(e,t){if(e.length>=t.length)return!1;let n=t.length-e.length;for(let i=0;i<e.length;i++)if(e[i]!==t[n+i])return!1;return!0}function LA(e,t){let n=fe(e,t);if(!n)return[];let i=e.get(`SELECT symbol, enclosing_symbol FROM global_symbols
316
+ WHERE id = ? LIMIT 1`,n.symbolId);if(!i)return[];let r=[{symbol:i.symbol,shortName:k(i.symbol),depth:0}],o=i.enclosing_symbol,s=1,a=new Set([i.symbol]);for(;o&&!a.has(o)&&s<20;){a.add(o);let d=e.get("SELECT symbol, enclosing_symbol FROM global_symbols WHERE symbol = ?",o);if(!d)break;r.push({symbol:d.symbol,shortName:k(d.symbol),depth:s}),o=d.enclosing_symbol,s++}if(r.length>1)return r;let l=Ni(i.symbol);if("kind"in l)return r;let c=l.descriptors;if(c.length<=1)return r;let u=[r[0]];for(let d=c.length-2,m=1;d>=0;d--,m++){let p=c.slice(0,d+1).map(g=>g.suffix==="method"?`${g.name}()`:g.name.replace(/\.(ts|tsx|js|jsx|mjs|cjs|py|pyi|rs|java|scala|kt|kts|rb|go|cs|vb|dart|php|c|cc|cpp|cxx|h|hpp)$/,"")).join(":");u.push({symbol:p,shortName:p,depth:m})}return u}function DA(e,t={}){let i=new U(e).productionCallableDefinitions({scope:t.scope,requireCallableSymbol:!0,includeSuppressed:!0}),r=Tb(e,i),o=t.search?.trim().toLocaleLowerCase();return i.map(s=>Fb(e,s,r.get(s.symbolId)??[])).filter(s=>s!==null).map(s=>s.result).filter(s=>!o||FA(s).includes(o)).sort(MA)}function PA(e,t,n={}){let i=rt(e,t);if(!i.match)return{kind:"missing",query:t};if(i.total>1)return{kind:"ambiguous",query:t,total:i.total,candidates:[{symbol:i.match.symbol,shortName:k(i.match.symbol),relativePath:i.match.relativePath,startLine:i.match.startLine},...i.candidates]};let r=new U(e),o=r.definitionsForFile(i.match.relativePath).find(f=>f.symbol===i.match.symbol);if(!o?.isFunctionLike)return{kind:"not-entry",query:t,symbol:i.match.symbol,shortName:k(i.match.symbol),file:i.match.relativePath,reason:"The resolved symbol is not a callable definition."};let s=Tb(e,[o]),a=Fb(e,o,s.get(o.symbolId)??[]);if(!a)return{kind:"not-entry",query:t,symbol:o.symbol,shortName:k(o.symbol),file:o.relativePath,reason:"The callable is neither an external root nor an uncalled callable on a detected entry surface."};let l=AA(e,r,o),c=new Set(n.expand??[]),u=BA(l,c),d=new Set(u.regions.filter(f=>f.expanded).map(f=>f.id)),m=[...c].filter(f=>!d.has(f)).sort();return{kind:"matched",query:t,entry:a.result,regions:u.regions,regionEdges:u.regionEdges,unmatchedExpansions:m,coverage:{completeWithinIndexedStaticCallEdges:!0,completeWithinSelectedStaticEvidence:!0,candidateReachabilityIncluded:l.edges.some(f=>f.evidenceStrength==="candidate"),dynamicDispatchRepresented:!1,symbolCount:l.symbols.length,symbolEdgeCount:l.edges.length,exactSymbolEdgeCount:l.edges.filter(f=>f.evidenceStrength==="exact").length,candidateSymbolEdgeCount:l.edges.filter(f=>f.evidenceStrength==="candidate").length,regionCount:u.regions.length,regionEdgeCount:u.regionEdges.length,externalCallCount:l.externalCalls.length}}}function Tb(e,t){let n=t.filter(i=>Mb(e,i.relativePath)||qi(e,i.symbol,i.relativePath).length>0);return cf(e,n,{semantic:!1,semanticEvidence:pe})}function Fb(e,t,n){let i=TA(e,t),r=i.length>0,o=Mb(e,t.relativePath)&&n.length===0;if(!r&&!o)return null;let s=[...i];return o&&s.push("entry-surface-without-indexed-caller"),{definition:t,result:{symbol:t.symbol,shortName:k(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,documentation:t.documentation,confidence:r?"root":"candidate",evidence:s,indexedCallerCount:n.length}}}function Mb(e,t){return Ye(e,t)||/(?:^|\/)entry\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(t)}function TA(e,t){let n=qi(e,t.symbol,t.relativePath),i=[];return Lb(n,["package-surface-file","transitive-package-surface"])&&Ct(e,t)&&i.push("package-public-export"),n.includes("rust-public-library")&&i.push("rust-public-library"),n.includes("framework-entrypoint")&&i.push("framework-dispatched-export"),Lb(n,["configured-file","configured-path-prefix","configured-qualified-var","configured-symbol-pattern"])&&i.push("configured-entry-root"),i}function Lb(e,t){return t.some(n=>e.includes(n))}function FA(e){return[e.symbol,e.shortName,e.file,e.documentation??"",...e.evidence].join(`
317
+ `).toLocaleLowerCase()}function MA(e,t){return Db(e.confidence)-Db(t.confidence)||e.file.localeCompare(t.file)||e.startLine-t.startLine||e.symbol.localeCompare(t.symbol)}function Db(e){return e==="root"?0:1}function AA(e,t,n){let i=new Map([[n.symbol,0]]),r=new Map,o=new Map([[n.symbol,n]]),s=new Map,a=new Map,l=[n];for(;l.length>0;){let c=t.calleeMap(l,{additive:!1,semantic:!1}),u=[];for(let d of l){let m=i.get(d.symbol)??0;r.set(d.symbol,Pb(d,m));for(let f of c.get(d.symbolId)??[]){let p=NA(t,f,o);if(!p){let v=_A(d,f);a.set(jA(v),v);continue}let g=m+1,h=i.get(p.symbol);(h===void 0||g<h)&&i.set(p.symbol,g),r.set(p.symbol,Pb(p,Math.min(g,h??g)));let S=kA(d,p,f);s.set($A(S),S),h===void 0&&u.push(p)}}l=u}return{symbols:[...r.values()].sort(HA),edges:[...s.values()].sort(UA),externalCalls:[...a.values()].sort(zA)}}function NA(e,t,n){let i=n.get(t.symbol);if(i)return i;let r=e.definitionsForFile(t.file).find(o=>o.symbol===t.symbol)??null;return r&&n.set(r.symbol,r),r}function Pb(e,t){return{symbol:e.symbol,shortName:k(e.symbol),file:e.relativePath,depth:t}}function kA(e,t,n){return{fromSymbol:e.symbol,fromShortName:k(e.symbol),fromFile:e.relativePath,toSymbol:t.symbol,toShortName:k(t.symbol),toFile:t.relativePath,source:n.source,evidenceStrength:n.source==="scip-chunk"?"candidate":"exact"}}function _A(e,t){return{fromSymbol:e.symbol,fromShortName:k(e.symbol),fromFile:e.relativePath,toSymbol:t.symbol,toShortName:k(t.symbol),reportedFile:t.file,source:t.source,evidenceStrength:t.source==="scip-chunk"?"candidate":"exact"}}function BA(e,t){let n=go(e.symbols,c=>c.file),i=go(e.edges.filter(c=>c.fromFile===c.toFile),c=>c.fromFile),r=go(e.externalCalls,c=>c.fromFile),o=OA(e.edges.filter(c=>c.fromFile!==c.toFile)),s=go(o,c=>c.toRegionId),a=go(o,c=>c.fromRegionId);return{regions:[...n.entries()].map(([c,u])=>{let d=du(c),m=t.has(d),f=i.get(c)??[],p=r.get(c)??[];return{id:d,file:c,minDepth:Math.min(...u.map(g=>g.depth)),symbolCount:u.length,internalEdgeCount:f.length,externalCallCount:p.length,incomingRegionIds:ho((s.get(d)??[]).map(g=>g.fromRegionId)),outgoingRegionIds:ho((a.get(d)??[]).map(g=>g.toRegionId)),expanded:m,symbols:m?u:[],internalEdges:m?f:[],externalCalls:m?p:[]}}).sort((c,u)=>c.minDepth-u.minDepth||c.file.localeCompare(u.file)),regionEdges:o}}function OA(e){let t=new Map;for(let n of e){let i=`${n.fromFile}\0${n.toFile}`,r=t.get(i)??[];r.push(n),t.set(i,r)}return[...t.values()].map(n=>{let i=n[0];return{fromRegionId:du(i.fromFile),fromFile:i.fromFile,toRegionId:du(i.toFile),toFile:i.toFile,callCount:n.length,exactCallCount:n.filter(r=>r.evidenceStrength==="exact").length,candidateCallCount:n.filter(r=>r.evidenceStrength==="candidate").length,fromSymbols:ho(n.map(r=>r.fromShortName)),toSymbols:ho(n.map(r=>r.toShortName)),evidence:ho(n.map(r=>r.source))}}).sort((n,i)=>n.fromFile.localeCompare(i.fromFile)||n.toFile.localeCompare(i.toFile))}function go(e,t){let n=new Map;for(let i of e){let r=t(i),o=n.get(r)??[];o.push(i),n.set(r,o)}return n}function du(e){return`file:${e}`}function ho(e){return[...new Set(e)].sort()}function $A(e){return`${e.fromSymbol}\0${e.toSymbol}`}function jA(e){return`${e.fromSymbol}\0${e.toSymbol}`}function HA(e,t){return e.depth-t.depth||e.file.localeCompare(t.file)||e.symbol.localeCompare(t.symbol)}function UA(e,t){return e.fromFile.localeCompare(t.fromFile)||e.fromSymbol.localeCompare(t.fromSymbol)||e.toSymbol.localeCompare(t.toSymbol)}function zA(e,t){return e.fromFile.localeCompare(t.fromFile)||e.fromSymbol.localeCompare(t.fromSymbol)||e.toSymbol.localeCompare(t.toSymbol)}function Bt(e,t){let n=new Set;for(let i of e)t.has(i)&&n.add(i);return n}function et(e,t){let n=new Set;for(let i of e)t.has(i)||n.add(i);return n}function Yn(e,t){if(e.size===0&&t.size===0)return 0;let n=0;for(let r of e)t.has(r)&&(n+=1);let i=e.size+t.size-n;return i===0?0:n/i}function Ab(e,t){if(e.size===0)return 0;let n=0;for(let i of e)t.has(i)&&(n+=1);return n/e.size}function mu(e,t){if(t<=0)return new Map;let n=new Map;for(let[i,r]of e)r>0&&n.set(i,Math.log(t/r));return n}function or(e){let t=[...e.values()].sort((i,r)=>i-r);if(t.length===0)return 0;let n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function sr(e,t){let n=0;for(let i of e){let r=t.get(i)??0;n+=r*r}return Math.sqrt(n)}function Nb(e,t,n,i={}){let r=0,o=0,s=0,a=i.medianIdf??or(n),l=[],c=[];for(let m of e){let f=n.get(m)??0;o+=f*f,t.has(m)&&(r+=f*f,f>=a?l.push(m):c.push(m))}if(l.length===0&&c.length===0)return{similarity:0,significantShared:[],trivialShared:[]};for(let m of t){let f=n.get(m)??0;s+=f*f}let u=Math.sqrt(o)*Math.sqrt(s),d=u>0?r/u:0;return l.sort((m,f)=>(n.get(f)??0)-(n.get(m)??0)),{similarity:d,significantShared:l,trivialShared:c}}function kb(e,t,n,i){let r=0,o=i.medianIdf??or(n),s=[],a=[];for(let u of e){if(!t.has(u))continue;let d=n.get(u)??0;r+=d*d,d>=o?s.push(u):a.push(u)}if(s.length===0&&a.length===0)return{similarity:0,significantShared:[],trivialShared:[]};let l=i.magnitudeA*i.magnitudeB,c=l>0?r/l:0;return s.sort((u,d)=>(n.get(d)??0)-(n.get(u)??0)),{similarity:c,significantShared:s,trivialShared:a}}function yo(e,t,n={}){let{minSimilarity:i=.4,limit:r=20}=n,o=()=>lN(e,t,{minSimilarity:i,limit:r,scanLimit:n.scanLimit,candidateMode:n.sourceCandidateMode??"full"}),s=ZA(e,t,{semantic:n.semantic!==!1});if(s.kind==="not-callable")return[];if(s.kind==="callee-evidence-unusable")return o();let a=s.target;if(!ke(a.symbol))return[];if(a.callees.size===0)return o();let l=KA(e,a,i,{scanLimit:n.scanLimit,semantic:n.semantic!==!1});return l.length>0?l.slice(0,r):o()}function hu(e,t,n,i={}){let r=fe(e,t),o=fe(e,n);if(!r||!o)return null;let s=yo(e,r.symbol,{minSimilarity:0,limit:Number.POSITIVE_INFINITY,semantic:i.semantic,scanLimit:i.scanLimit}).find(c=>c.symbolB===o.symbol||c.symbolA===o.symbol);if(!s)return null;let a=r.endLine-r.startLine+1,l=o.endLine-o.startLine+1;return{symbolA:{symbol:r.symbol,shortName:k(r.symbol),file:r.relativePath,loc:a},symbolB:{symbol:o.symbol,shortName:k(o.symbol),file:o.relativePath,loc:l},similarity:s.similarity,similarityBasis:s.similarityBasis??"callees",sharedEvidence:s.sharedCallees,uniqueToA:s.uniqueToA,uniqueToB:s.uniqueToB,evidenceClass:s.evidenceClass,actionTier:s.actionTier,recommendation:s.recommendation,consolidationStrategy:GA(s)}}function GA(e){let t=e.similarityBasis==="source-tokens"?"source-token":"tracked callee";return e.sharedCallees.length===0?`No shared ${t} evidence survived similar's weighting. Inspect the source before attempting consolidation.`:e.uniqueToA.length===0&&e.uniqueToB.length===0?`The functions have identical ${t} evidence under similar's weighting. Verify signatures, guards, and return values before consolidating.`:e.uniqueToA.length===0?`A's ${t} evidence is a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToB.length===0?`B's ${t} evidence is a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToA.length<=2&&e.uniqueToB.length<=2?`Create a shared helper around the ${e.sharedCallees.length} shared ${t}(s). Pass the ${e.uniqueToA.length+e.uniqueToB.length} divergent point(s) as parameters or callbacks.`:`Extract the ${e.sharedCallees.length} shared ${t}(s) into a common helper. Keep each function's unique logic outside that helper (${e.uniqueToA.length} item(s) in A, ${e.uniqueToB.length} in B).`}function KA(e,t,n,i){let r=ar(e).calleeIndex({minCallees:3,scanLimit:i.scanLimit,semantic:i.semantic}),o=sN(t,r.corpus),s=iN(o,r),a=qA(o,r),l=or(a),c=sr(o.callees,a),u=[];for(let d of s){if(d.callees.size<3)continue;let m=sr(d.callees,a),f=$b(o,d,a,{minSimilarity:n,requireSignificantShared:1,requireSharedCount:0,medianIdf:l,magnitudeA:c,magnitudeB:m});f&&u.push(f)}return u.sort((d,m)=>m.similarity-d.similarity),u}function qA(e,t){let n=new Map(t.docFreq);for(let i of e.callees)n.set(i,(n.get(i)??0)+1);return mu(n,t.corpus.length+1)}function $b(e,t,n,i){let r=VA(e,t,n,i);if(!JA(r,i))return null;let{similarity:o,significantShared:s,trivialShared:a}=r,l=s.length>0?s:a,c=Gb(l,"callees");return{symbolA:e.symbol,shortNameA:k(e.symbol),fileA:e.file,symbolB:t.symbol,shortNameB:k(t.symbol),fileB:t.file,similarity:o,similarityBasis:"callees",sharedCallees:l.map(k),uniqueToA:[...et(e.callees,t.callees)].map(k),uniqueToB:[...et(t.callees,e.callees)].map(k),...c}}function WA(e,t,n,i){let r=i.magnitudeA??sr(e.callees,n),o=i.magnitudeB??sr(t.callees,n),s=0,a=0,l=0,c=i.medianIdf??or(n);for(let m of e.callees){if(!t.callees.has(m))continue;let f=n.get(m)??0;s+=f*f,l+=1,f>=c&&(a+=1)}if(l===0)return!1;let u=r*o;return(u>0?s/u:0)<i.minSimilarity?!1:a>=i.requireSignificantShared||l>=i.requireSharedCount}function VA(e,t,n,i){return i.magnitudeA===void 0||i.magnitudeB===void 0?Nb(e.callees,t.callees,n,{medianIdf:i.medianIdf}):kb(e.callees,t.callees,n,{medianIdf:i.medianIdf,magnitudeA:i.magnitudeA,magnitudeB:i.magnitudeB})}function JA(e,t){if(e.similarity<t.minSimilarity)return!1;let n=e.significantShared.length+e.trivialShared.length;return e.significantShared.length>=t.requireSignificantShared||n>=t.requireSharedCount}function bo(e,t={}){let{minSimilarity:n=.5,limit:i=20,scope:r,minCallees:o=4,crossFileOnly:s=!1,scanLimit:a}=t,l=t.semantic!==!1,c=ft(),u=0,d=0,m=0,f=0,p=0,g=0,h=0;return $("similar.all",()=>{let v=ar(e).calleeIndex({minCallees:o,scope:r,scanLimit:a,semantic:l}),y=v.corpus;u=y.length;let E=t.focusFiles,w=[],b=0;return $("similar.all.pair-scan",()=>{for(let R=0;R<y.length;R+=1){let C=y[R],L=E?.has(C.file)??!1,I=v.weightedMagnitudes[R],x=new Set;for(let P of C.callees){let _=v.candidateIndexesByCallee.get(P);if(_)for(let D of _)D<=R||E&&!L&&!E.has(y[D].file)||x.add(D)}c&&(m+=x.size,x.size>0&&(d+=1));for(let P of x){let _=y[P];if(s&&C.file===_.file){c&&(p+=1);continue}if(jb(C,_)){c&&(g+=1);continue}c&&(f+=1);let D=$b(C,_,v.idfWeights,{minSimilarity:n,requireSignificantShared:2,requireSharedCount:4,medianIdf:v.medianIdf,magnitudeA:I,magnitudeB:v.weightedMagnitudes[P]});D&&(YA(w,D,i,b),c&&(h+=1),b+=1)}}},()=>({corpusSize:u,candidateSets:d,candidatePairs:m,comparedPairs:f,crossFileSkips:p,signatureSkips:g,insertedResults:h,topResults:w.length})),$("similar.all.sort-project",()=>(w.sort((R,C)=>C.result.similarity-R.result.similarity||R.order-C.order),w.map(R=>R.result)),()=>({topResults:w.length}))},()=>({minSimilarity:n,limit:i,scope:r,minCallees:o,crossFileOnly:s,scanLimit:a,semantic:l,corpusSize:u,candidateSets:d,candidatePairs:m,comparedPairs:f,crossFileSkips:p,signatureSkips:g,insertedResults:h}))}function yu(e,t={}){let{minSimilarity:n=.5,scope:i,minCallees:r=4,crossFileOnly:o=!1,scanLimit:s}=t,a=t.semantic!==!1,l=ft(),c=0,u=0,d=0,m=0,f=0,p=0,g=0;return $("similar.all-count",()=>{let S=ar(e).calleeIndex({minCallees:r,scope:i,scanLimit:s,semantic:a}),v=S.corpus;c=v.length;let y=t.focusFiles;return $("similar.all-count.pair-scan",()=>{for(let E=0;E<v.length;E+=1){let w=v[E],b=y?.has(w.file)??!1,R=S.weightedMagnitudes[E],C=new Set;for(let L of w.callees){let I=S.candidateIndexesByCallee.get(L);if(I)for(let x of I)x<=E||y&&!b&&!y.has(v[x].file)||C.add(x)}l&&(d+=C.size,C.size>0&&(u+=1));for(let L of C){let I=v[L];if(o&&w.file===I.file){l&&(f+=1);continue}if(jb(w,I)){l&&(p+=1);continue}l&&(m+=1),WA(w,I,S.idfWeights,{minSimilarity:n,requireSignificantShared:2,requireSharedCount:4,medianIdf:S.medianIdf,magnitudeA:R,magnitudeB:S.weightedMagnitudes[L]})&&(g+=1)}}},()=>({corpusSize:c,candidateSets:u,candidatePairs:d,comparedPairs:m,crossFileSkips:f,signatureSkips:p,insertedResults:g})),g},()=>({minSimilarity:n,scope:i,minCallees:r,crossFileOnly:o,scanLimit:s,semantic:a,corpusSize:c,candidateSets:u,candidatePairs:d,comparedPairs:m,crossFileSkips:f,signatureSkips:p,insertedResults:g}))}function jb(e,t){if(e.paramCount<0||t.paramCount<0)return!1;let n=Math.abs(e.paramCount-t.paramCount),i=Math.max(2,Math.ceil(Math.max(e.paramCount,t.paramCount)*.5));return n>i}var Hb=vt({kind:"source-fingerprints",invalidation:Je("source-fingerprints"),serialize:LN,deserialize:IN});function YA(e,t,n,i){if(n<=0)return;if(e.length<n){e.push({result:t,order:i});return}let r=0;for(let s=1;s<e.length;s+=1){let a=e[s],l=e[r];(a.result.similarity<l.result.similarity||a.result.similarity===l.result.similarity&&a.order>l.order)&&(r=s)}let o=e[r];t.similarity<=o.result.similarity||(e[r]={result:t,order:i})}var XA=["ScipDatabase#all","ScipDatabase#get","ScipDatabase#prepare","ScipDatabase#pathExclusionsFor","ScipDatabase#isIgnored","ScipDatabase#symbolNoiseFor","PerDbValue#get","PerDbValue#has",":storage:db:ScipDatabase:all",":storage:db:ScipDatabase:get",":storage:db:ScipDatabase:prepare",":storage:db:ScipDatabase:pathExclusionsFor",":storage:db:ScipDatabase:isIgnored",":storage:db:ScipDatabase:symbolNoiseFor",":storage:per-db-cache:PerDbValue:get",":storage:per-db-cache:PerDbValue:has"];function ZA(e,t,n){let i=fe(e,t);if(!i)return{kind:"not-callable"};if(!ke(i.symbol))return{kind:"not-callable"};let r=new U(e),o=ai(e,i,{semantic:n.semantic,semanticEvidence:pe});return o.semanticIncomplete||o.semanticUnavailable?{kind:"callee-evidence-unusable"}:{kind:"resolved",target:{symbol:i.symbol,file:i.relativePath,callees:Ra(o.rows.map(s=>s.symbol)),paramCount:r.callableSignature(i)?.paramCount??-1}}}var QA=Fe("callee-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),eN=Fe("callee-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function Ub(e,t){let{minCallees:n,scope:i,excludeSymbol:r,scanLimit:o}=t,s=t.semantic!==!1,a=QA.get(e,()=>new Map),l=`${n}|${i??""}|${o??""}|${s}`,c=!0,u=0,d=0;return $("similar.callee-fingerprints.resolve",()=>{let m=a.get(l);if(c=m!==void 0,m||(m=rN(e,{minCallees:n,scope:i,scanLimit:o,semantic:s}),a.set(l,m)),u=m.length,r===void 0)return m;let f=m.filter(p=>p.symbol!==r);return d=m.length-f.length,f},()=>({minCallees:n,scope:i,scanLimit:o,semantic:s,cacheHit:c,corpusSize:u,excludeSymbol:r!==void 0,excludedSymbols:d}))}function tN(e,t){let{minCallees:n,scope:i,scanLimit:r}=t,o=t.semantic!==!1,s=eN.get(e,()=>new Map),a=`${n}|${i??""}|${r??""}|${o}`,l=!0,c=0,u=0,d=0;return $("similar.callee-index.resolve",()=>{let m=s.get(a);return l=m!==void 0,m||(m=nN(Ub(e,{minCallees:n,scope:i,scanLimit:r,semantic:o})),s.set(a,m)),c=m.corpus.length,u=m.docFreq.size,d=m.candidateIndexesByCallee.size,m},()=>({minCallees:n,scope:i,scanLimit:r,semantic:o,cacheHit:l,corpusSize:c,indexedCallees:u,candidateBuckets:d}))}function ar(e){return{calleeCorpus:t=>Ub(e,t),calleeIndex:t=>tN(e,t),sourceCorpus:(t={})=>Jb(e,t),sourceIndex:(t={})=>Ob(e,t),sourceCandidates:(t,n)=>(n.candidateMode??"full")==="target-pruned"?bN(e,t,{minSimilarity:n.minSimilarity,scanLimit:n.scanLimit}):yN(t,Ob(e,{scanLimit:n.scanLimit}))}}function nN(e){let t=ft(),n=0,i=$("similar.callee-index.doc-frequency",()=>{let m=new Map;for(let f of e)for(let p of f.callees)m.set(p,(m.get(p)??0)+1);return n=m.size,m},()=>({corpusSize:e.length,uniqueCallees:n})),r=Math.max(8,Math.ceil(Math.sqrt(e.length))),o=$("similar.callee-index.idf-weights",()=>mu(i,e.length),()=>({corpusSize:e.length,uniqueCallees:i.size})),s=$("similar.callee-index.weighted-magnitudes",()=>e.map(m=>sr(m.callees,o)),()=>({corpusSize:e.length})),a=0,l=0,c=0,u=$("similar.callee-index.candidate-buckets",()=>{let m=new Map;for(let f=0;f<e.length;f+=1){let p=e[f];for(let g of p.callees){if((i.get(g)??0)>r){t&&(l+=1);continue}let h=m.get(g);h||(h=[],m.set(g,h)),h.push(f),t&&(a+=1)}}return t&&(c=m.size),m},()=>({corpusSize:e.length,buckets:c,candidateRefs:a,ubiquitousSkips:l,ubiquityThreshold:r})),d=$("similar.callee-index.median-idf",()=>or(o),()=>({uniqueCallees:o.size}));return{corpus:e,candidateIndexesByCallee:u,docFreq:i,idfWeights:o,weightedMagnitudes:s,medianIdf:d,ubiquityThreshold:r}}function iN(e,t){let n=new Map;for(let i of e.callees)for(let r of t.candidateIndexesByCallee.get(i)??[]){let o=t.corpus[r];o.symbol!==e.symbol&&n.set(o.symbol,o)}return n.size>0?[...n.values()]:t.corpus.filter(i=>i.symbol!==e.symbol)}function rN(e,t){let{minCallees:n,scope:i,scanLimit:r,semantic:o}=t,s=ft(),a=new U(e),l=0,c=$("similar.callee-fingerprints.candidates",()=>{let g=Ae(a.productionCallableDefinitions({scope:i,minLoc:5,sortByLocDesc:typeof r=="number"&&r>0}),r);return l=g.length,g},()=>({scope:i,scanLimit:r,candidateCount:l})),u=0,d=$("similar.callee-fingerprints.callee-map",()=>{let g=a.calleeEvidenceMap(c,{semantic:o});if(s)for(let h of g.rows.values())u+=h.length;return g},()=>({candidateCount:l,semantic:o,calleeEdges:u})),m=0,f=0,p=0;return $("similar.callee-fingerprints.shape",()=>{let h=c.filter(y=>!d.incompleteSymbolIds.has(y.symbolId)&&!d.unavailableSymbolIds.has(y.symbolId)).map(y=>({symbol:y.symbol,file:y.relativePath,callees:Ra((d.rows.get(y.symbolId)??[]).map(E=>E.symbol)),paramCount:a.callableSignature(y)?.paramCount??-1})),S=oN(h);s&&(p=S.filter((y,E)=>y.callees.size!==h[E].callees.size).length);let v=S.filter(y=>y.callees.size>=n);return m=v.length,s&&(f=v.reduce((y,E)=>y+E.callees.size,0)),v},()=>({candidateCount:l,fingerprintCount:m,retainedCalleeCount:f,minCallees:n,siblingSaturatedFingerprints:p}))}var zb=5;function oN(e){let t=new Map;for(let n of e){let i=t.get(n.file);i||(i=new Map,t.set(n.file,i));for(let r of n.callees)i.set(r,(i.get(r)??0)+1)}return e.map(n=>{let i=t.get(n.file);if(!i)return n;let r=[...n.callees].filter(s=>(i.get(s)??0)>=zb);if(r.length===0)return n;let o=new Set(n.callees);for(let s of r)o.delete(s);return{...n,callees:o}})}function sN(e,t){let n=new Map;for(let o of t)if(!(o.file!==e.file||o.symbol===e.symbol))for(let s of o.callees)n.set(s,(n.get(s)??0)+1);let i=[...e.callees].filter(o=>(n.get(o)??0)+1>=zb);if(i.length===0)return e;let r=new Set(e.callees);for(let o of i)r.delete(o);return{...e,callees:r}}function Ra(e){return new Set([...e].filter(t=>!aN(t)))}function aN(e){return XA.some(t=>e.includes(t))}function lN(e,t,n){let i=mN(e,t);if(!i||i.tokens.size<3)return[];let r=n.minSimilarity>=.5?n.minSimilarity:.3,o=[],s=n.candidateMode??"full",a=0,l=0,c=0,u=0;return $("similar.source-shape",()=>{let m=ar(e).sourceCandidates(i,{minSimilarity:r,scanLimit:n.scanLimit,candidateMode:s});a=m.length;for(let f of m){if(f.symbol===i.symbol||f.tokens.size<3)continue;l+=1;let p=Bt(i.tokens,f.tokens);if(p.size<2){c+=1;continue}let g=new Set([...i.tokens,...f.tokens]),h=g.size>0?p.size/g.size:0;if(h<r){u+=1;continue}o.push({symbolA:i.symbol,shortNameA:k(i.symbol),fileA:i.file,symbolB:f.symbol,shortNameB:k(f.symbol),fileB:f.file,similarity:h,similarityBasis:"source-tokens",sharedCallees:[...p].sort(),uniqueToA:[...et(i.tokens,f.tokens)].sort(),uniqueToB:[...et(f.tokens,i.tokens)].sort(),...Gb([...p],"source-tokens")})}return o.sort((f,p)=>p.similarity-f.similarity||f.shortNameB.localeCompare(p.shortNameB)),o.slice(0,n.limit)},()=>({symbol:i.symbol,file:i.file,targetTokens:i.tokens.size,candidateMode:s,candidates:a,comparedPairs:l,sharedSkips:c,similaritySkips:u,results:o.length}))}function Gb(e,t){let n=e.flatMap(pu),i=e.flatMap(h=>_b(h,t)),r=fu(n,Kb),o=fu(n,qb),s=fu(i,gu),a=[...new Set(i.filter(Bb))],l=e.filter(h=>{let S=_b(h,t);return S.some(v=>gu.has(v))&&S.some(Bb)}).length,c=[];r.length>0&&c.push(`access/query scaffolding: ${r.slice(0,5).join(", ")}`),o.length>0&&c.push(`framework/generic scaffolding: ${o.slice(0,5).join(", ")}`),s.length>0&&c.push(`domain behavior verbs: ${s.slice(0,5).join(", ")}`),s.length>0&&a.length>0&&c.push(`domain-specific terms: ${a.slice(0,5).join(", ")}`);let u=t==="source-tokens"&&n.length>0&&n.every(h=>Wb.has(h));u&&c.push("shared source tokens are generic scaffolding");let d=s.length>0&&a.length>0,m=r.length+o.length>0,f=t==="callees"&&d&&e.length>=4&&a.length>=4&&l>=2,p=f?"domain-behavior":d?m?"mixed":"domain-behavior":r.length>0?"access-query-scaffolding":o.length>0||u?"framework-scaffolding":"structural-overlap";p==="structural-overlap"&&e.length>0&&c.push(`shared ${t} overlap has no recognized domain or scaffolding category`);let g=p==="domain-behavior"&&(e.length>=3||f)?"direct":"signal";return{evidenceClass:p,actionTier:g,evidenceClassReasons:c,recommendation:cN(p,g)}}function cN(e,t){return t==="direct"?"Shared domain behavior looks concrete; review for an extract/reuse opportunity.":e==="mixed"?"Shared evidence mixes domain behavior with scaffolding; review semantics before extracting anything.":e==="access-query-scaffolding"?"Shared evidence is mostly access/query scaffolding; compare product semantics before reusing code.":e==="structural-overlap"?"Shared structure has no domain or scaffolding classification; inspect names and behavior before reusing code.":"Shared evidence is mostly framework or generic scaffolding; treat as a contextual signal."}function fu(e,t){return[...new Set(e.filter(n=>t.has(n)))]}function pu(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>1)}function _b(e,t){if(t==="source-tokens")return pu(e);let n=re(e);return pu(n.length>0?n:uN(e))}function uN(e){return e.replace(/[()`]/g," ").replace(/\.[a-z][a-z0-9]+(?=\s|$)/gi," ").split(/[:/\\\s]+/).map(i=>i.trim()).filter(i=>/[A-Za-z]/.test(i)).at(-1)?.replace(/\.$/,"")??e}function Bb(e){return e.length>3&&!gu.has(e)&&!Kb.has(e)&&!qb.has(e)&&!Wb.has(e)&&!dN.has(e)}var gu=new Set(["archive","assign","book","cancel","create","delete","ensure","export","import","notify","persist","publish","restore","schedule","send","set","submit","sync","update","upload","validate","write"]),Kb=new Set(["access","auth","authorize","cache","context","db","find","get","guard","list","permission","permissions","prisma","query","request","response","role","route","session","sql","where"]),qb=new Set(["bytes","computed","crypto","describe","effect","expect","fetch","filter","hex","hook","json","map","mounted","on","promise","random","react","reduce","ref","render","state","test","token","trim","uuid","vue","watch"]),Wb=new Set(["bytes","crypto","data","false","get","hex","id","key","map","name","num","random","result","secret","set","string","to","token","true","type","value"]),dN=new Set(["best","backend","conflict","database","effect","effects","error","errors","frontend","found","helpers","javascript","module","modules","scip","shared","source","typescript","utils","with","workflow","workflows"]);function mN(e,t){let n=fe(e,t);if(!n||!ke(n.symbol))return null;let i=fN(e,n);return i?{symbol:n.symbol,file:n.relativePath,tokens:i}:null}function fN(e,t){let n=re(t.symbol),i=RN(e,t.relativePath,t.startLine,t.endLine,n),r=Zb(i,n);return r.size>0?r:null}var pN=Fe("source-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),gN=Fe("source-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function Vb(e){return`${e.scanLimit??""}`}function Jb(e,t={}){let n=pN.get(e,()=>new Map),i=Vb(t),r=n.get(i);return r||(r=xN(e,t),n.set(i,r)),r}function Ob(e,t={}){let n=gN.get(e,()=>new Map),i=Vb(t),r=n.get(i);return r||(r=hN(Jb(e,t)),n.set(i,r)),r}function hN(e){let t=new Map;for(let r of e)for(let o of r.tokens)t.set(o,(t.get(o)??0)+1);let n=Math.max(8,Math.ceil(Math.sqrt(e.length))),i=new Map;for(let r of e)for(let o of r.tokens){if((t.get(o)??0)>n)continue;let s=i.get(o);s||(s=[],i.set(o,s)),s.push(r)}return{corpus:e,candidateByToken:i,docFreq:t,ubiquityThreshold:n}}function yN(e,t){let n=new Map;for(let i of e.tokens)for(let r of t.candidateByToken.get(i)??[])r.symbol!==e.symbol&&n.set(r.symbol,r);return n.size>0?[...n.values()]:t.corpus.filter(i=>i.symbol!==e.symbol)}function bN(e,t,n){let i=ft(),r=new U(e),o=SN(t.tokens.size,n.minSimilarity),s=0,a=0,l=0,c=$("similar.source-shape.target-files",()=>{let p=[...t.tokens],g=[];for(let h of he(e,{includeIgnored:!1})){s+=1;let S=se(e,h);S&&(a+=1,vN(S,p,o)&&g.push(h))}return l=g.length,g},()=>({symbol:t.symbol,targetTokens:t.tokens.size,requiredSharedTokens:o,scannedFiles:s,readableFiles:a,candidateFiles:l})),u=0,d=$("similar.source-shape.target-definitions",()=>{let p=Ae(r.productionCallableDefinitions({files:c,sortByLocDesc:typeof n.scanLimit=="number"&&n.scanLimit>0}),n.scanLimit);return u=p.length,p},()=>({symbol:t.symbol,candidateFiles:l,scanLimit:n.scanLimit,definitionCount:u})),m=0;return $("similar.source-shape.target-fingerprints",()=>{let p=Yb(e,d);return i&&(m=p.length),p},()=>({symbol:t.symbol,definitionCount:u,fingerprintCount:m})).filter(p=>p.symbol!==t.symbol)}function SN(e,t){return Math.max(2,Math.ceil(e*t))}function vN(e,t,n){if(t.length<n)return!1;let i=e.toLowerCase(),r=0;for(let o of t)if(CN(i,o)&&(r+=1,r>=n))return!0;return!1}function CN(e,t){return t==="num"?/\b\d+\b/.test(e):e.includes(t)}function xN(e,t={}){let n=new U(e),{scanLimit:i}=t,r=Ae(n.productionCallableDefinitions({sortByLocDesc:typeof i=="number"&&i>0}),i);return Yb(e,r)}function Yb(e,t){let n=new Map;for(let r of t){let o=n.get(r.relativePath)??[];o.push(r),n.set(r.relativePath,o)}let i=new Map;for(let[r,o]of n){let s=se(e,r);if(!s)continue;let a=Ft(e,r,s),l=wN(e,r,a),c=!1,u=null;for(let d of o){let m=EN(d),f=l.get(m),p=f?new Set(f.tokens):null;p||(u??=ie(e,r),p=Zb(Xb(u,d.startLine,d.endLine,d.leaf),d.leaf),l.set(m,{key:m,symbol:d.symbol,startLine:d.startLine,endLine:d.endLine,leaf:d.leaf,tokens:[...p].sort()}),c=!0),p.size>0&&i.set(d.symbol,{symbol:d.symbol,file:d.relativePath,tokens:p})}c&&DN(e,r,a,l)}return t.map(r=>i.get(r.symbol)).filter(r=>!!r)}function RN(e,t,n,i,r){let o=ie(e,t);return o.length===0?"":Xb(o,n,i,r)}function Xb(e,t,n,i){if(n>=t&&n-t<=12)return e.slice(t,n+1).join(`
318
+ `);let r=[new RegExp(`\\bdef\\s+${He(i)}\\b`),new RegExp(`\\bfun\\s+${He(i)}\\b`),new RegExp(`\\bfn\\s+${He(i)}\\b`),new RegExp(`\\bfunction\\s+${He(i)}\\b`),new RegExp(`\\b${He(i)}\\s*\\(`)],o=e.findIndex(s=>r.some(a=>a.test(s)));if(o>=0){let s=o;for(let a=o+1;a<e.length&&a<=o+8;a++){let l=e[a]??"";if(a>o&&TN(l)||(s=a,l.trim()===""&&a>o+1))break}return e.slice(o,s+1).join(`
319
+ `)}return e.slice(t,Math.min(e.length,t+8)).join(`
320
+ `)}function EN(e){return`${e.symbol}\0${e.startLine}\0${e.endLine}\0${e.leaf}`}function wN(e,t,n){return Hb.read(e,t,n)??new Map}function IN(e){try{let t=JSON.parse(e);if(!Array.isArray(t.entries))return null;let n=new Map;for(let i of t.entries){if(!i||typeof i.key!="string"||typeof i.symbol!="string"||typeof i.startLine!="number"||typeof i.endLine!="number"||typeof i.leaf!="string"||!Array.isArray(i.tokens)||!i.tokens.every(r=>typeof r=="string"))return null;n.set(i.key,i)}return n}catch{return null}}function LN(e){let t={entries:[...e.values()].sort((n,i)=>n.key.localeCompare(i.key))};return JSON.stringify(t)}function DN(e,t,n,i){Hb.write(e,t,n,new Map(i))}function Zb(e,t){if(!e)return new Set;let n=new Set(["public","private","protected","final","static","class","def","fun","fn","function","return","string","bool","boolean","void","unit","self","this","new","const","let","var","end","pub"]),i=PN(t),o=e.replace(/["'`]/g," ").replace(/\b\d+\b/g," NUM ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9_]+/g," ").replace(/_/g," ").toLowerCase().split(/\s+/).map(s=>s.trim()).filter(s=>s.length>1).filter(s=>!n.has(s)).filter(s=>!i.has(s));return new Set(o)}function PN(e){return new Set(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(t=>t.toLowerCase()).filter(t=>t.length>1))}function TN(e){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(e)}function ln(e,t){let n=new Map;return e.forEach((i,r)=>{let o=new Set;for(let s of t(i)){if(o.has(s))continue;o.add(s);let a=n.get(s);a?a.push(r):n.set(s,[r])}}),{candidatesFor:(i,r)=>{let o=new Set;for(let s of t(i)){let a=n.get(s);if(a)for(let l of a)l!==r&&o.add(l)}return[...o].sort((s,a)=>s-a)}}}function cn(e){let t=Qb(e.profile?.name),n=()=>{let i=[];t=Qb(e.profile?.name,e);let r=(s,a)=>{let l=e.profiles[s],c=e.profiles[a];t.candidatePairs+=1,t.comparedPairs+=1;let u=e.compare(l,c);u&&i.push(u)};if(e.filePattern){let s=e.profiles.findIndex(a=>a.file.includes(e.filePattern));if(s>=0){let a=e.profiles[s];for(let l of FN(e,s)){let c=e.profiles[l];e.focusFiles&&!e.focusFiles.has(a.file)&&!e.focusFiles.has(c.file)||r(s,l)}}}else if(e.focusFiles?.size!==0){let s=typeof e.overrunFactor=="number"&&Number.isFinite(e.limit)?e.limit*e.overrunFactor:Number.POSITIVE_INFINITY;for(let a=0;a<e.profiles.length;a+=1){let l=e.profiles[a],c=e.focusFiles?.has(l.file)??!1;for(let u of MN(e,a))e.focusFiles&&!c&&!e.focusFiles.has(e.profiles[u].file)||r(a,u);if(i.length>s){t.overrunApplied=!0;break}}}i.sort(e.sort??((s,a)=>a.similarity-s.similarity)),t.matchedResults=i.length;let o=i.slice(0,e.limit);return t.emittedResults=o.length,e.onProfile?.({...t}),o};return e.profile?$(`pairwise-profile:${e.profile.name}`,n,()=>({...AN(e.profile?.metadata),...t})):n()}function FN(e,t){if(e.candidateIndex)return eS(e,t,-1);let n=[];for(let i=0;i<e.profiles.length;i+=1)i!==t&&n.push(i);return n}function MN(e,t){if(e.candidateIndex)return eS(e,t,t);let n=[];for(let i=t+1;i<e.profiles.length;i+=1)n.push(i);return n}function eS(e,t,n){let i=e.profiles[t],r=new Set;for(let o of e.candidateIndex?.candidatesFor(i,t,e.profiles)??[])o<=n||o!==t&&(o<0||o>=e.profiles.length||r.add(o));return[...r].sort((o,s)=>o-s)}function Qb(e,t){return{pipeline:e,profileCount:t?.profiles.length??0,focusedProfileCount:t?.focusFiles?t.profiles.filter(n=>t.focusFiles.has(n.file)).length:0,candidatePairs:0,comparedPairs:0,matchedResults:0,emittedResults:0,candidateIndexApplied:t?.candidateIndex!==void 0,focusApplied:t?.focusFiles!==void 0,filePatternApplied:t?.filePattern!==void 0,overrunApplied:!1}}function AN(e){return typeof e=="function"?e():e??{}}function NN(e,t={}){let{minSimilarity:n=.5,limit:i=20,scope:r,filePattern:o}=t,s=t.minDeps??(o?1:3),{profiles:a,distinctiveDeps:l}=kN(e,{scope:r,minDeps:s}),c=ln(a,u=>u.deps);return cn({profiles:a,limit:i,filePattern:o,overrunFactor:5,candidateIndex:c,profile:{name:"similar-files"},compare:(u,d)=>BN(u,d,n,l)})}function kN(e,t){let{scope:n,minDeps:i}=t,r=Be(e,n),{universalDeps:o,distinctiveDeps:s}=_N(r),a=[];for(let[l,c]of r)c.size>=i&&a.push({file:l,deps:new Set([...c].filter(u=>!o.has(u)))});return{profiles:a,distinctiveDeps:s}}function _N(e){let t=new Set,n=new Set,i=e.size;if(i===0)return{universalDeps:t,distinctiveDeps:n};let r=new Map;for(let s of e.values())for(let a of s)r.set(a,(r.get(a)??0)+1);let o=Math.max(3,Math.ceil(i*.03));for(let[s,a]of r)a>=5&&a/i>.3?t.add(s):a<=o&&n.add(s);return{universalDeps:t,distinctiveDeps:n}}function BN(e,t,n,i){let r=new Set;for(let c of e.deps)t.deps.has(c)&&r.add(c);if(r.size<3||e.deps.size<4||t.deps.size<4)return null;let o=0;for(let c of r)i.has(c)&&o++;if(o<2)return null;let s=Yn(e.deps,t.deps);if(s<n)return null;let a=[];for(let c of e.deps)t.deps.has(c)||a.push(c);let l=[];for(let c of t.deps)e.deps.has(c)||l.push(c);return{fileA:e.file,fileB:t.file,similarity:s,sharedDeps:[...r],uniqueToA:a,uniqueToB:l}}function Xn(e){let t=[],n=[],i=[];for(let c of e.primitiveGroups)c.values.length!==0&&tS(c.bucket,n,i).push(`${c.reasonPrefix}: ${c.values.join(", ")}`);for(let c of e.nameGroups)ON(c.names,c.label,e.genericWords,e.stripPrefixes??[],t,tS(c.fallbackBucket,n,i));let r=t.length>0,o=n.length>0,s=i.length>0,a=r?o||s?"mixed":"domain-behavior":s?"shared-abstraction":"generic-workflow-scaffolding";return{actionTier:a==="domain-behavior"||a==="mixed"?"signal":"support",evidenceClass:a,reasons:[...t,...i,...n].slice(0,6),recommendation:e.recommendation(a)}}function Ea(e,t){if(e.size===0||t.size===0)return 0;let r=Bt(e,t).size/Math.min(e.size,t.size)*Math.min(1,Math.min(e.size,t.size)/(.35*Math.max(e.size,t.size)));return Math.max(Yn(e,t),r)}function Zn(e,t){let n=Object.fromEntries(e.map(i=>[i.name,i.count]));for(let i of t)if(Object.entries(i.min).every(([o,s])=>(n[o]??0)>=s))return{pass:!0,reason:i.reason,counts:n};return{pass:!1,reason:"shared tokens did not meet calibrated overlap thresholds",counts:n}}function wa(e,t,n){let i=t.map(l=>{let c=l.value(e),u=l.weightedValue?l.weightedValue(e,c):c;return{axis:l,value:c,weighted:u,qualifies:l.qualifies?l.qualifies(e,c):c>0}}),r=i.filter(l=>l.qualifies&&l.axis.reason).map(l=>l.axis.reason(e,l.value)),o=i.filter(l=>l.qualifies&&l.axis.dominantEligible!==!1).sort((l,c)=>c.weighted-l.weighted)[0],s=o&&o.weighted>0?o.axis.axis:n,a=[...new Set(i.filter(l=>l.qualifies).map(l=>l.axis.axis).concat(r.length>0?[]:[s]))];return{dominantPressure:s,pressureKinds:a,reasons:r}}function Ee(e,t){return[...e].filter(n=>n.startsWith(t)).map(n=>n.slice(t.length)).sort()}function ot(e){return[...e].sort()}function ON(e,t,n,i,r,o){let s=[],a=[];for(let l of e)$N(l,i).filter(u=>!n.has(u)).length>0?s.push(l):a.push(l);s.length&&r.push(`${t} has domain term(s): ${s.slice(0,6).join(", ")}`),a.length&&o.push(`${t} is generic workflow: ${a.slice(0,6).join(", ")}`)}function $N(e,t){let n=e.replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/([a-z0-9])([A-Z])/g,"$1 $2");for(let i of t)n=n.replace(i,"");return n.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)}function tS(e,t,n){return e==="generic"?t:n}function So(e,t={}){let{minSimilarity:n=.62,minTokens:i=8,limit:r=20,scope:o,scanLimit:s,filePattern:a,focusFiles:l}=t,c=At(e).reactProfiles({scope:o,minJsxTokens:i,scanLimit:s}).filter(d=>d.kind==="component").map(d=>({file:d.file,component:d.name,tokens:d.jsxTokens,profile:d})),u=ln(c,d=>d.tokens);return cn({profiles:c,limit:r,filePattern:a,focusFiles:l,candidateIndex:u,profile:{name:"react-component-duplicates"},compare:(d,m)=>jN(d,m,n),sort:(d,m)=>m.similarity-d.similarity||d.fileA.localeCompare(m.fileA)||d.componentA.localeCompare(m.componentA)||d.fileB.localeCompare(m.fileB)||d.componentB.localeCompare(m.componentB)})}function jN(e,t,n){let i=Bt(e.tokens,t.tokens);if(i.size<6||!HN(i))return null;let r=Yn(e.tokens,t.tokens);if(r<n)return null;let o=Ee(i,"component:"),s=Ee(i,"native:"),a=Ee(i,"prop:"),l=Ee(i,"event:"),c=Ee(i,"binding:"),u=UN({sharedComponents:o,sharedNativeTags:s,sharedProps:a,sharedEvents:l,sharedBindings:c});return{fileA:e.file,componentA:e.component,fileB:t.file,componentB:t.component,similarity:r,tokenCountA:e.tokens.size,tokenCountB:t.tokens.size,sharedTokens:ot(i),sharedComponents:o,sharedNativeTags:s,sharedProps:a,sharedEvents:l,sharedBindings:c,evidenceClass:u.evidenceClass,actionTier:u.actionTier,evidenceClassReasons:u.reasons,recommendation:u.recommendation,uniqueToA:ot(et(e.tokens,t.tokens)).slice(0,25),uniqueToB:ot(et(t.tokens,e.tokens)).slice(0,25),locA:e.profile.loc,locB:t.profile.loc}}function HN(e){let t=0,n=0;for(let i of e)i.startsWith("component:")&&(t+=1),(i.startsWith("prop:")||i.startsWith("event:")||i.startsWith("native:")||i.startsWith("jsx:"))&&(n+=1);return Zn([{name:"component",count:t},{name:"shape",count:n}],[{min:{component:1},reason:"shared custom component"},{min:{shape:4},reason:"shared JSX structure"}]).pass}function UN(e){return Xn({genericWords:GN,primitiveGroups:[{values:e.sharedNativeTags,reasonPrefix:"shared native tags",bucket:"generic"},{values:e.sharedProps,reasonPrefix:"shared props",bucket:"generic"},{values:e.sharedEvents,reasonPrefix:"shared events",bucket:"generic"}],nameGroups:[{names:e.sharedComponents,label:"shared component",fallbackBucket:"generic"},{names:e.sharedBindings,label:"shared binding",fallbackBucket:"generic"}],recommendation:zN})}function zN(e){switch(e){case"domain-behavior":case"mixed":return"Review for a shared component or feature-specific UI primitive around the named domain structure.";case"shared-abstraction":return"Review the existing shared component usage first; extract only if duplicated structure remains outside it.";case"generic-workflow-scaffolding":return"Generic structural overlap \u2014 verify intent before consolidating."}}var GN=new Set(["actions","app","button","card","children","content","container","dialog","field","form","header","input","item","label","layout","list","modal","page","panel","row","section","shell","table","text","toolbar","ui","value","view","wrapper"]);function vo(e,t={}){let{minSimilarity:n=.45,minSharedBehaviors:i=6,limit:r=20,scope:o,scanLimit:s,filePattern:a,focusFiles:l}=t,c=At(e).reactProfiles({scope:o,minBehaviorTokens:Math.max(3,i),scanLimit:s}).map(d=>({file:d.file,component:d.name,tokens:d.behaviorTokens,profile:d})),u=ln(c,d=>d.tokens);return cn({profiles:c,limit:r,filePattern:a,focusFiles:l,candidateIndex:u,profile:{name:"react-hook-candidates"},compare:(d,m)=>KN(d,m,n,i),sort:(d,m)=>m.similarity-d.similarity||d.fileA.localeCompare(m.fileA)||d.componentA.localeCompare(m.componentA)||d.fileB.localeCompare(m.fileB)||d.componentB.localeCompare(m.componentB)})}function KN(e,t,n,i){let r=Bt(e.tokens,t.tokens);if(r.size<i||!VN(r))return null;let o=Ea(e.tokens,t.tokens);if(o<n)return null;let s=Ee(r,"hook:"),a=Ee(r,"react-hook:"),l=Ee(r,"effect:"),c=Ee(r,"state:"),u=Ee(r,"request:"),d=Ee(r,"handler:"),m=Ee(r,"handler-verb:"),f=qN({sharedHooks:s,sharedReactHooks:a,sharedEffects:l,sharedState:c,sharedRequests:u,sharedHandlers:d,sharedHandlerVerbs:m});return{fileA:e.file,componentA:e.component,fileB:t.file,componentB:t.component,similarity:o,tokenCountA:e.tokens.size,tokenCountB:t.tokens.size,sharedTokens:ot(r),sharedHooks:s,sharedReactHooks:a,sharedEffects:l,sharedState:c,sharedRequests:u,sharedHandlers:d,sharedHandlerVerbs:m,evidenceClass:f.evidenceClass,actionTier:f.actionTier,evidenceClassReasons:f.reasons,recommendation:f.recommendation,uniqueToA:ot(et(e.tokens,t.tokens)).slice(0,25),uniqueToB:ot(et(t.tokens,e.tokens)).slice(0,25),reason:JN({sharedHooks:s,sharedReactHooks:a,sharedEffects:l,sharedState:c,sharedRequests:u,sharedHandlers:d,sharedHandlerVerbs:m}),locA:e.profile.loc,locB:t.profile.loc}}function qN(e){return Xn({genericWords:YN,stripPrefixes:XN,primitiveGroups:[{values:e.sharedReactHooks,reasonPrefix:"shared React primitives",bucket:"generic"},{values:e.sharedEffects,reasonPrefix:"shared lifecycle primitive",bucket:"generic"}],nameGroups:[{names:e.sharedHooks,label:"shared hook",fallbackBucket:"shared-abstraction"},{names:e.sharedRequests,label:"shared request",fallbackBucket:"generic"},{names:e.sharedState,label:"shared state",fallbackBucket:"generic"},{names:e.sharedHandlers,label:"shared handler",fallbackBucket:"generic"},{names:e.sharedHandlerVerbs,label:"shared action verb",fallbackBucket:"generic"}],recommendation:WN})}function WN(e){switch(e){case"domain-behavior":return"Review for a shared hook, controller, or feature module around the named domain behavior.";case"mixed":return"Separate generic React mechanics from domain-specific behavior before extracting a shared hook.";case"shared-abstraction":return"Review the existing shared hook usage first; extract only if duplicated behavior remains outside it.";case"generic-workflow-scaffolding":return"Treat as support evidence for a repeated workflow shape, not direct hook-extraction evidence."}}function VN(e){let t=0,n=0,i=0,r=0,o=0,s=0,a=0;for(let u of e)u.startsWith("hook:")?t+=1:u.startsWith("react-hook:")?n+=1:u.startsWith("effect:")?i+=1:u.startsWith("request:")?r+=1:u.startsWith("handler:")||u.startsWith("handler-verb:")?o+=1:u.startsWith("state:")?s+=1:u.startsWith("state-hook:")&&(a+=1);let l=s+a,c=t+n+i+r+o+l;return Zn([{name:"requests",count:r},{name:"customHooks",count:t},{name:"namedStates",count:s},{name:"handlers",count:o},{name:"effects",count:i},{name:"reactHooks",count:n},{name:"namedBehavior",count:c}],[{min:{requests:1,namedBehavior:4},reason:"shared request workflow"},{min:{customHooks:1,requests:1,namedBehavior:5},reason:"shared custom hook and request workflow"},{min:{customHooks:1,namedStates:1,namedBehavior:5},reason:"shared custom hook and state"},{min:{customHooks:1,handlers:2,namedBehavior:5},reason:"shared custom hook and handlers"},{min:{namedStates:1,handlers:2,effects:1,namedBehavior:5},reason:"shared stateful effects"},{min:{namedStates:1,handlers:2,reactHooks:2,namedBehavior:5},reason:"shared stateful React primitives"}]).pass}function JN(e){let t=[];return e.sharedHooks.length&&t.push(`shared hooks: ${e.sharedHooks.join(", ")}`),e.sharedReactHooks.length&&t.push(`shared React hooks: ${e.sharedReactHooks.join(", ")}`),e.sharedEffects.length&&t.push(`shared effects: ${e.sharedEffects.join(", ")}`),e.sharedState.length&&t.push(`shared state: ${e.sharedState.join(", ")}`),e.sharedRequests.length&&t.push(`shared requests: ${e.sharedRequests.join(", ")}`),e.sharedHandlers.length&&t.push(`shared handlers: ${e.sharedHandlers.slice(0,6).join(", ")}`),e.sharedHandlerVerbs.length&&t.push(`shared action verbs: ${e.sharedHandlerVerbs.slice(0,6).join(", ")}`),t.join("; ")||"shared React behavior profile"}var YN=new Set(["add","apply","async","callback","cancel","change","clear","close","create","data","delete","draft","edit","effect","error","fetch","filter","form","handle","has","is","item","items","load","loader","loading","memo","name","open","reducer","refresh","ref","remove","request","reset","resource","row","rows","save","saving","search","select","selected","state","store","submit","toggle","update","use","value"]),XN=[/^use(?=[A-Z])/,/^handle(?=[A-Z])/,/^is(?=[A-Z])/,/^has(?=[A-Z])/];function bu(e,t={}){let{minComponentLines:n=300,minFileLines:i=800,minJsxTokens:r=80,minBehaviorTokens:o=40,limit:s=20,scope:a,scanLimit:l,filePattern:c}=t;return At(e).reactProfiles({scope:a,scanLimit:l}).filter(d=>d.kind==="component").filter(d=>!c||d.file.includes(c)||d.name.includes(c)).map(d=>ZN(d,{minComponentLines:n,minFileLines:i,minJsxTokens:r,minBehaviorTokens:o})).filter(d=>d!==null).sort((d,m)=>m.componentLines-d.componentLines||m.fileLines-d.fileLines||d.file.localeCompare(m.file)).slice(0,s)}function ZN(e,t){let n=Math.max(80,Math.floor(t.minComponentLines/2)),i=wa(e,QN({minComponentLines:t.minComponentLines,minFileLines:t.minFileLines,minJsxTokens:t.minJsxTokens,minBehaviorTokens:t.minBehaviorTokens,substantialComponentLines:n}),"component"),{reasons:r}=i;if(r.length===0)return null;let o=i.dominantPressure,s=i.pressureKinds,a=ek(e),l=tk(o,s,a);return{file:e.file,component:e.name,componentLines:e.loc,fileLines:e.fileLines,jsxTokens:e.jsxTokens.size,behaviorTokens:e.behaviorTokens.size,dominantPressure:o,pressureKinds:s,contextKind:a,recommendationKind:l,recommendation:nk(l,a),reasons:r,loc:e.loc}}function QN(e){return[{axis:"component",value:t=>t.loc,qualifies:(t,n)=>n>=e.minComponentLines,reason:(t,n)=>`${n} component line(s)`},{axis:"file",value:t=>t.fileLines,qualifies:(t,n)=>n>=e.minFileLines&&t.loc>=e.substantialComponentLines,reason:(t,n)=>`${n} file line(s)`},{axis:"jsx-structure",value:t=>t.jsxTokens.size,weightedValue:(t,n)=>n*3,qualifies:(t,n)=>n>=e.minJsxTokens,reason:(t,n)=>`${n} JSX structure token(s)`},{axis:"hook-behavior",value:t=>t.behaviorTokens.size,weightedValue:(t,n)=>n*4,qualifies:(t,n)=>n>=e.minBehaviorTokens,reason:(t,n)=>`${n} behavior token(s)`}]}function ek(e){let t=e.file.split(/[\\/]+/).filter(Boolean),n=t.slice(0,-1).map(m=>m.toLowerCase()),i=(t.at(-1)??e.name).replace(/\.[^.]+$/,""),o=n.findIndex(m=>rk.has(m))>=0,s=n.some(m=>ik.has(m));if(nS(i)||nS(e.name))return"component";let l=ok.has(i.toLowerCase()),c=/(?:Page|Route|Screen)$/.test(e.name),u=o&&/View$/.test(e.name),d=!s&&i.replace(/[^A-Za-z0-9]+/g,"").toLowerCase()===e.name.replace(/[^A-Za-z0-9]+/g,"").toLowerCase()&&/(?:Page|Route|Screen|View)$/.test(i);return l||c||u||d?"route-page":"component"}function nS(e){let t=e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(n=>n.toLowerCase());return t.at(-1)&&iS.has(t.at(-1))?!0:[...iS].some(n=>e.endsWith(sk(n)))}function tk(e,t,n){return e==="hook-behavior"?"behavior-extraction":n==="route-page"?"route-page-decomposition":t.includes("hook-behavior")?"behavior-extraction":t.includes("jsx-structure")?"jsx-decomposition":t.includes("file")?"file-decomposition":e==="jsx-structure"?"jsx-decomposition":e==="file"&&!t.includes("component")?"file-decomposition":"component-decomposition"}function nk(e,t){switch(e){case"behavior-extraction":return"Extract independent state, effects, requests, or handlers into hooks, controllers, or feature modules.";case"route-page-decomposition":return"Split route/page orchestration from reusable panels and feature controllers.";case"jsx-decomposition":return t==="route-page"?"Split page JSX into named layout sections before extracting behavior.":"Split repeated JSX sections into named presentational components.";case"file-decomposition":return"Review file-level decomposition; split colocated panels or helpers before changing behavior.";case"component-decomposition":return"Review component boundaries around props, state ownership, and independently changing UI sections."}}var ik=new Set(["component","components","panel","panels","partial","partials"]),iS=new Set(["banner","button","card","dialog","drawer","filter","form","grid","header","item","list","menu","modal","nav","panel","picker","rail","row","section","selector","shell","sidebar","table","toolbar"]),rk=new Set(["landing","page","pages","route","routes","screen","screens","view","views"]),ok=new Set(["page","route","screen"]);function sk(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Co(e,t={}){let{minSimilarity:n=.62,minTokens:i=8,limit:r=20,scope:o,scanLimit:s,filePattern:a,focusFiles:l}=t,c=ak(e,{scope:o,minTokens:i,scanLimit:s}),u=ln(c,d=>d.tokens);return cn({profiles:c,limit:r,filePattern:a,focusFiles:l,candidateIndex:u,profile:{name:"vue-component-duplicates"},compare:(d,m)=>ck(d,m,n),sort:(d,m)=>m.similarity-d.similarity||d.fileA.localeCompare(m.fileA)||d.fileB.localeCompare(m.fileB)})}function ak(e,t){return At(e).vueProfiles({scope:t.scope,minTemplateTokens:t.minTokens,scanLimit:t.scanLimit}).map(n=>({file:n.file,tokens:n.templateTokens,loc:lk(n)}))}function lk(e){return e.totalLines}function ck(e,t,n){let i=Bt(e.tokens,t.tokens);if(i.size<6||!uk(i))return null;let r=Yn(e.tokens,t.tokens);if(r<n)return null;let o=Ee(i,"component:"),s=Ee(i,"prop:"),a=Ee(i,"event:"),l=Ee(i,"directive:"),c=Ee(i,"slot:"),u=Ee(i,"id:"),d=dk({sharedComponents:o,sharedProps:s,sharedEvents:a,sharedDirectives:l,sharedSlots:c,sharedIdentifiers:u});return{fileA:e.file,fileB:t.file,similarity:r,tokenCountA:e.tokens.size,tokenCountB:t.tokens.size,sharedTokens:ot(i),sharedComponents:o,sharedProps:s,sharedEvents:a,sharedDirectives:l,sharedSlots:c,sharedIdentifiers:u,evidenceClass:d.evidenceClass,actionTier:d.actionTier,evidenceClassReasons:d.reasons,recommendation:d.recommendation,uniqueToA:ot(et(e.tokens,t.tokens)).slice(0,25),uniqueToB:ot(et(t.tokens,e.tokens)).slice(0,25),locA:e.loc,locB:t.loc}}function uk(e){let t=0,n=0;for(let i of e)i.startsWith("component:")&&(t+=1),(i.startsWith("prop:")||i.startsWith("event:")||i.startsWith("directive:")||i.startsWith("slot:"))&&(n+=1);return Zn([{name:"component",count:t},{name:"behavior",count:n}],[{min:{component:1},reason:"shared custom component"},{min:{behavior:3},reason:"shared Vue template structure"}]).pass}function dk(e){return Xn({genericWords:fk,primitiveGroups:[{values:e.sharedProps,reasonPrefix:"shared props",bucket:"generic"},{values:e.sharedEvents,reasonPrefix:"shared events",bucket:"generic"},{values:e.sharedDirectives,reasonPrefix:"shared directives",bucket:"generic"},{values:e.sharedSlots,reasonPrefix:"shared slots",bucket:"generic"}],nameGroups:[{names:e.sharedComponents,label:"shared component",fallbackBucket:"generic"},{names:e.sharedIdentifiers,label:"shared identifier",fallbackBucket:"generic"}],recommendation:mk})}function mk(e){switch(e){case"domain-behavior":case"mixed":return"Review for a shared component or feature-specific Vue primitive around the named domain structure.";case"shared-abstraction":return"Review the existing shared component usage first; extract only if duplicated structure remains outside it.";case"generic-workflow-scaffolding":return"Generic structural overlap \u2014 verify intent before consolidating."}}var fk=new Set(["actions","app","button","card","content","container","dialog","field","form","header","input","item","label","layout","list","modal","page","panel","row","section","shell","table","text","toolbar","ui","value","view","wrapper"]);function xo(e,t={}){let{minSimilarity:n=.45,minSharedBehaviors:i=6,limit:r=20,scope:o,scanLimit:s,filePattern:a,focusFiles:l}=t,c=At(e).vueProfiles({scope:o,minBehaviorTokens:Math.max(3,i),scanLimit:s}).map(d=>({file:d.file,tokens:d.behaviorTokens,profile:d})),u=ln(c,d=>d.tokens);return cn({profiles:c,limit:r,filePattern:a,focusFiles:l,candidateIndex:u,profile:{name:"vue-composable-candidates"},compare:(d,m)=>pk(d,m,n,i),sort:(d,m)=>m.similarity-d.similarity||d.fileA.localeCompare(m.fileA)||d.fileB.localeCompare(m.fileB)})}function pk(e,t,n,i){let r=Bt(e.tokens,t.tokens);if(r.size<i||!yk(r))return null;let o=Ea(e.tokens,t.tokens);if(o<n)return null;let s=Ee(r,"composable:"),a=Ee(r,"store:"),l=Ee(r,"reactivity:"),c=Ee(r,"lifecycle:"),u=Ee(r,"request:"),d=Ee(r,"function:"),m=Ee(r,"function-verb:"),f=Ee(r,"template-binding:"),p=Ee(r,"template-event:"),g=gk({sharedComposables:s,sharedStores:a,sharedReactivity:l,sharedLifecycle:c,sharedRequests:u,sharedFunctions:d,sharedFunctionVerbs:m,sharedBindings:f,sharedTemplateEvents:p});return{fileA:e.file,fileB:t.file,similarity:o,tokenCountA:e.tokens.size,tokenCountB:t.tokens.size,sharedTokens:ot(r),sharedComposables:s,sharedStores:a,sharedReactivity:l,sharedLifecycle:c,sharedRequests:u,sharedFunctions:d,sharedFunctionVerbs:m,sharedBindings:f,sharedTemplateEvents:p,evidenceClass:g.evidenceClass,actionTier:g.actionTier,evidenceClassReasons:g.reasons,recommendation:g.recommendation,uniqueToA:ot(et(e.tokens,t.tokens)).slice(0,25),uniqueToB:ot(et(t.tokens,e.tokens)).slice(0,25),reason:bk({sharedComposables:s,sharedStores:a,sharedRequests:u,sharedLifecycle:c,sharedFunctions:d,sharedFunctionVerbs:m,sharedBindings:f}),locA:e.profile.totalLines,locB:t.profile.totalLines}}function gk(e){return Xn({genericWords:Sk,primitiveGroups:[{values:e.sharedReactivity,reasonPrefix:"shared reactivity primitive",bucket:"generic"},{values:e.sharedLifecycle,reasonPrefix:"shared lifecycle primitive",bucket:"generic"}],nameGroups:[{names:e.sharedComposables,label:"shared composable",fallbackBucket:"shared-abstraction"},{names:e.sharedStores,label:"shared store",fallbackBucket:"shared-abstraction"},{names:e.sharedRequests,label:"shared request",fallbackBucket:"generic"},{names:e.sharedFunctions,label:"shared function",fallbackBucket:"generic"},{names:e.sharedFunctionVerbs,label:"shared action verb",fallbackBucket:"generic"},{names:e.sharedBindings,label:"shared binding",fallbackBucket:"generic"},{names:e.sharedTemplateEvents,label:"shared template event",fallbackBucket:"generic"}],recommendation:hk})}function hk(e){switch(e){case"domain-behavior":return"Review for a shared composable, store, or feature module around the named domain behavior.";case"mixed":return"Separate generic Vue mechanics from domain-specific behavior before extracting a composable.";case"shared-abstraction":return"Review the existing composable/store usage first; extract only if duplicated behavior remains outside it.";case"generic-workflow-scaffolding":return"Treat as support evidence for a repeated workflow shape, not direct composable-extraction evidence."}}function yk(e){let t=0,n=0,i=0,r=0,o=0,s=0,a=0;for(let u of e)u.startsWith("composable:")?t+=1:u.startsWith("store:")?n+=1:u.startsWith("request:")?i+=1:u.startsWith("lifecycle:")?r+=1:u.startsWith("function:")?o+=1:u.startsWith("reactivity:")?s+=1:(u.startsWith("function-verb:")||u.startsWith("template-binding:")||u.startsWith("template-event:"))&&(a+=1);let l=t+n,c=l+i+r+o+a;return Zn([{name:"requests",count:i},{name:"lifecycle",count:r},{name:"functions",count:o},{name:"reusableHooks",count:l},{name:"reactivity",count:s},{name:"namedBehavior",count:c}],[{min:{requests:1,namedBehavior:4},reason:"shared request workflow"},{min:{lifecycle:1,functions:2,namedBehavior:4},reason:"shared lifecycle workflow"},{min:{reusableHooks:2,requests:1,namedBehavior:5},reason:"shared reusable Vue hooks and requests"},{min:{reusableHooks:2,functions:2,namedBehavior:5},reason:"shared reusable Vue hooks and functions"},{min:{functions:2,reactivity:1,namedBehavior:4},reason:"shared reactive functions"}]).pass}function bk(e){let t=[];return e.sharedComposables.length&&t.push(`shared composables: ${e.sharedComposables.join(", ")}`),e.sharedStores.length&&t.push(`shared stores: ${e.sharedStores.join(", ")}`),e.sharedRequests.length&&t.push(`shared request helpers: ${e.sharedRequests.join(", ")}`),e.sharedLifecycle.length&&t.push(`shared lifecycle: ${e.sharedLifecycle.join(", ")}`),e.sharedFunctions.length&&t.push(`shared functions: ${e.sharedFunctions.slice(0,6).join(", ")}`),e.sharedFunctionVerbs.length&&t.push(`shared action verbs: ${e.sharedFunctionVerbs.slice(0,6).join(", ")}`),e.sharedBindings.length&&t.push(`shared template bindings: ${e.sharedBindings.slice(0,6).join(", ")}`),t.join("; ")||"shared Vue behavior profile"}var Sk=new Set(["add","apply","cancel","change","clear","close","composable","create","data","delete","draft","edit","error","fetch","filter","form","item","items","load","loading","name","open","reactive","ref","refresh","remove","request","reset","resource","row","rows","save","saving","search","select","selected","store","submit","toggle","update","use","value","watch"]);function Su(e,t={}){let{minTotalLines:n=800,minTemplateLines:i=300,minScriptLines:r=300,minStyleLines:o=500,limit:s=20,scope:a,scanLimit:l,filePattern:c}=t;return At(e).vueProfiles({scope:a,scanLimit:l}).filter(d=>!c||d.file.includes(c)).map(d=>vk(d,{minTotalLines:n,minTemplateLines:i,minScriptLines:r,minStyleLines:o})).filter(d=>d!==null).sort((d,m)=>m.totalLines-d.totalLines||d.file.localeCompare(m.file)).slice(0,s)}function vk(e,t){let n=wa(e,Ck(t),"total"),{reasons:i}=n;if(i.length===0)return null;let r=n.dominantPressure,o=n.pressureKinds.includes("total")?[...new Set([...n.pressureKinds,r])]:n.pressureKinds,s=xk(e.file),a=Rk(r,s),l=e.totalLines+e.delegatedComposableLines;return{file:e.file,totalLines:l,sfcLines:e.sfcLines,templateLines:e.templateLines,scriptLines:e.scriptLines,styleLines:e.styleLines,externalScriptLines:e.externalScriptLines,externalScriptPaths:e.externalScriptPaths,customBlockLines:e.customBlockLines,delegatedComposableLines:e.delegatedComposableLines,delegatedComposablePaths:e.delegatedComposablePaths,dominantPressure:r,pressureKinds:o,contextKind:s,recommendationKind:a,recommendation:Ek(a,s),reasons:i,loc:l}}function Ck(e){return[{axis:"total",value:t=>t.totalLines+t.delegatedComposableLines,qualifies:(t,n)=>n>=e.minTotalLines,reason:(t,n)=>t.delegatedComposableLines>0?`${n} total line(s) (${t.totalLines} component + ${t.delegatedComposableLines} delegated composable line(s) across ${t.delegatedComposablePaths.length} file(s))`:`${n} total component line(s)`,dominantEligible:!1},{axis:"template",value:t=>t.templateLines,qualifies:(t,n)=>n>=e.minTemplateLines,reason:(t,n)=>`${n} template line(s)`},{axis:"script",value:t=>t.scriptLines-t.externalScriptLines,qualifies:t=>t.scriptLines>=e.minScriptLines,reason:t=>`${t.scriptLines} script line(s)`},{axis:"style",value:t=>t.styleLines,qualifies:(t,n)=>n>=e.minStyleLines,reason:(t,n)=>`${n} style line(s)`},{axis:"external-script",value:t=>t.externalScriptLines,qualifies:(t,n)=>n>=e.minScriptLines},{axis:"custom-block",value:t=>t.customBlockLines,qualifies:()=>!1}]}function xk(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).some(i=>wk.has(i))||/(?:view|page|route)\.vue$/i.test(e)||/(?:^|\/)(views|pages|routes)\//i.test(e)?"route-page":"component"}function Rk(e,t){return e==="style"?"style-decomposition":e==="template"?"template-decomposition":e==="external-script"?"external-script-boundary":e==="custom-block"?"custom-block-review":t==="route-page"?"route-page-decomposition":e==="script"?"script-behavior-extraction":"total-size-review"}function Ek(e,t){switch(e){case"template-decomposition":return t==="route-page"?"Split route template sections into named panels before extracting script behavior.":"Split repeated template sections into named presentational components.";case"script-behavior-extraction":return"Extract independent script behavior into composables, controllers, or feature modules.";case"style-decomposition":return"Review UI/style decomposition; move repeated styling to component or style primitives, not composables.";case"external-script-boundary":return"Review the external script boundary and split controller/composable modules by workflow.";case"custom-block-review":return"Review custom block ownership before splitting template or script code.";case"route-page-decomposition":return"Split route/page orchestration from reusable panels and feature controllers.";case"total-size-review":return"Review the largest block first, then split by the dominant reason to change."}}var wk=new Set(["landing","page","pages","route","routes","view","views"]);function Ik(e,t={}){let{minSimilarity:n=.5,limit:i=15,scope:r,minChainLength:o=3,maxChainLength:s=8}=t,a=Be(e,r),l=Nk(a,o,s);if(l.length===0)return[];let c=Lk(l);return c.length<2?[]:Ak(Tk(c,n,i),i)}function Lk(e){let t=Dk(e),n=[];for(let i of e){let r=i.filter(o=>!t.has(o));r.length>=2&&n.push({original:i,filtered:r})}return n}function Dk(e){let{nodeFreq:t,tailFreq:n}=Pk(e),i=e.length*.9,r=e.length*.8,o=new Set;for(let[a,l]of t)l>i&&o.add(a);for(let[a,l]of n)l>r&&o.add(a);let s=["index.ts","index.js","cli.ts","main.ts","health.ts","health.js"];for(let a of t.keys()){let l=a.split("/").pop()??"";s.includes(l)&&o.add(a)}return o}function Pk(e){let t=new Map,n=new Map;for(let i of e){let r=new Set;for(let o of i)r.has(o)||(t.set(o,(t.get(o)??0)+1),r.add(o));for(let o=Math.max(0,i.length-2);o<i.length;o++)n.set(i[o],(n.get(i[o])??0)+1)}return{nodeFreq:t,tailFreq:n}}function Tk(e,t,n){let i=[];for(let r=0;r<e.length;r++){for(let o=r+1;o<e.length;o++){let s=Fk(e[r],e[o],t);s&&i.push(s)}if(i.length>n*10)break}return i.sort((r,o)=>Math.abs(o.similarity-r.similarity)>.01?o.similarity-r.similarity:r.divergencePoints.length-o.divergencePoints.length),i}function Fk(e,t,n){if(!Mk(e.filtered,t.filtered))return null;let{distance:i,ops:r}=kk(e.filtered,t.filtered),o=Math.max(e.filtered.length,t.filtered.length);if(o===0)return null;let s=1-i/o;if(s<n||i===0)return null;let a=r.filter(c=>c.type==="substitute").map(c=>({index:c.indexA,nodeA:e.filtered[c.indexA],nodeB:t.filtered[c.indexB]}));return a.length===0||r.filter(c=>c.type==="match").length<2?null:{chainA:e.original,chainB:t.original,similarity:s,editDistance:i,divergencePoints:a,commonPrefix:_k(e.original,t.original),commonSuffix:Bk(e.original,t.original)}}function Mk(e,t){let n=new Set(e);return t.some(i=>n.has(i))}function Ak(e,t){let n=[];for(let i of e)if(n.some(o=>rS(i.chainA,o.chainA)&&rS(i.chainB,o.chainB))||n.push(i),n.length>=t)break;return n}function Nk(e,t,n){let i=[];for(let o of e.keys()){if(i.length>=500)break;oS(e,o,[o],new Set([o]),t,n,i,500)}return i}function oS(e,t,n,i,r,o,s,a){if(s.length>=a)return;if(n.length>=o){n.length>=r&&s.push([...n]);return}let l=e.get(t);if(!l||l.size===0){n.length>=r&&s.push([...n]);return}let c=!1;for(let u of l)if(!i.has(u)&&(i.add(u),n.push(u),oS(e,u,n,i,r,o,s,a),n.pop(),i.delete(u),c=!0,s.length>=a))return;!c&&n.length>=r&&s.push([...n])}function kk(e,t){let n=e.length,i=t.length,r=Array.from({length:n+1},()=>Array(i+1).fill(0));for(let l=0;l<=n;l++)r[l][0]=l;for(let l=0;l<=i;l++)r[0][l]=l;for(let l=1;l<=n;l++)for(let c=1;c<=i;c++)e[l-1]===t[c-1]?r[l][c]=r[l-1][c-1]:r[l][c]=1+Math.min(r[l-1][c],r[l][c-1],r[l-1][c-1]);let o=[],s=n,a=i;for(;s>0||a>0;)s>0&&a>0&&e[s-1]===t[a-1]?(o.unshift({type:"match",indexA:s-1,indexB:a-1}),s--,a--):s>0&&a>0&&r[s][a]===r[s-1][a-1]+1?(o.unshift({type:"substitute",indexA:s-1,indexB:a-1}),s--,a--):a>0&&r[s][a]===r[s][a-1]+1?(o.unshift({type:"insert",indexA:s,indexB:a-1}),a--):(o.unshift({type:"delete",indexA:s-1,indexB:a}),s--);return{distance:r[n][i],ops:o}}function _k(e,t){let n=[];for(let i=0;i<Math.min(e.length,t.length)&&e[i]===t[i];i++)n.push(e[i]);return n}function Bk(e,t){let n=[],i=e.length-1,r=t.length-1;for(;i>=0&&r>=0&&e[i]===t[r];)n.unshift(e[i]),i--,r--;return n}function rS(e,t){if(e.length>t.length)return!1;let n=t.join("\u2192"),i=e.join("\u2192");return n.includes(i)}function Ot(e){let t=Ok(e.profile?.name),n=()=>{let i=e.candidates(),r=e.filterCandidate?i.filter(e.filterCandidate):i,o=e.orderCandidates?[...r].sort(e.orderCandidates):r,s=Ae(o,e.scanLimit);t={pipeline:e.profile?.name,loadedCandidates:i.length,filteredCandidates:r.length,scannedCandidates:s.length,evaluatedCandidates:0,matchedResults:0,emittedResults:0,scanLimitApplied:s.length<r.length,resultLimitApplied:!1};let a=e.prepare?.(s)??void 0,l=[];for(let u of s){t.evaluatedCandidates+=1;let d=e.evaluate(u,a);d&&l.push(d)}t.matchedResults=l.length,e.orderResults&&l.sort(e.orderResults);let c=typeof e.limit=="number"?l.slice(0,e.limit):l;return t.emittedResults=c.length,t.resultLimitApplied=c.length<l.length,e.onProfile?.({...t}),c};return e.profile?$(`candidate-pipeline:${e.profile.name}`,n,()=>({...$k(e.profile?.metadata),...t})):n()}function Ok(e){return{pipeline:e,loadedCandidates:0,filteredCandidates:0,scannedCandidates:0,evaluatedCandidates:0,matchedResults:0,emittedResults:0,scanLimitApplied:!1,resultLimitApplied:!1}}function $k(e){return typeof e=="function"?e():e??{}}function Ro(e,t={}){let{scope:n,minLoc:i=10,minCallees:r=6,limit:o=20,scanLimit:s}=t,a=new U(e);return Ot({candidates:()=>a.productionCallableDefinitions({scope:n,minLoc:i,excludeTypesFiles:!0,requireFunctionLikeSymbol:!0,sortByLocDesc:!0}),scanLimit:s,profile:{name:"extract-candidates"},prepare:l=>a.calleeEvidenceMap(l,{semantic:t.semantic!==!1}),evaluate:(l,c)=>c.incompleteSymbolIds.has(l.symbolId)||c.unavailableSymbolIds.has(l.symbolId)?null:jk(l,c.rows.get(l.symbolId)??[],r),orderResults:(l,c)=>c.clusters.length-l.clusters.length||c.loc-l.loc,limit:o})}function jk(e,t,n){let i=new Set(t.map(c=>c.symbol));if(i.size<n)return null;let r=Kk(i,t),o=qk(i,r);if(o.length<2)return null;let s=Wk(o,r);if(s.length===0)return null;let a=k(e.symbol),l=Hk(a,i.size,o.length,s);return{symbol:e.symbol,shortName:a,relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:de(e),totalCallees:i.size,extractionKind:l.extractionKind,actionTier:"signal",evidenceReasons:l.evidenceReasons,recommendation:l.recommendation,clusters:s}}function Hk(e,t,n,i){let r=Math.max(...i.map(l=>l.callees.length)),o=Math.max(...i.map(l=>l.isolation)),s=[`${t} distinct callees across ${n} co-occurrence cluster(s)`,`${i.length} extractable cluster(s) passed size and isolation thresholds`,`largest extractable cluster has ${r} callees at ${Math.round(o*100)}% isolation`],a=Uk(e,t,n);return a!==null?{extractionKind:"workflow-orchestration",evidenceReasons:[...s,a],recommendation:"Review the isolated helper group as a possible private or feature-local helper, but keep the orchestration sequence together when it preserves the workflow."}:r>=6?{extractionKind:"broad-helper-cluster",evidenceReasons:[...s,"one isolated helper group is broad enough to deserve a named review"],recommendation:"Review whether the broad helper cluster has a stable concept name before extracting it; avoid creating a bag-of-helpers abstraction."}:{extractionKind:"cohesive-helper-cluster",evidenceReasons:s,recommendation:"Review the isolated callee group as a possible same-file or feature-local helper; extract only if the new name preserves the current behavior."}}function Uk(e,t,n){if(t>=10)return`callee breadth suggests orchestration: ${t} callees`;if(n>=4)return`multiple disconnected callee groups suggest orchestration: ${n} groups`;let i=zk(e);return Gk.has(i)?`caller verb suggests orchestration: ${i}`:null}function zk(e){return e.split(":").pop()?.replace(/\(\)$/,"").replace(/[^A-Za-z0-9_]/g,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_\s-]+/).filter(Boolean)[0]?.toLowerCase()??""}var Gk=new Set(["apply","build","check","collect","create","diff","execute","find","handle","load","prepare","process","render","resolve","run","select","sync","update","validate","verify","write"]);function Kk(e,t){let n=new Map;for(let r of e)n.set(r,new Set);let i=new Map;for(let r of t){let o=i.get(r.chunkId);o||(o=new Set,i.set(r.chunkId,o)),o.add(r.symbol)}for(let r of i.values()){let o=[...r];for(let s=0;s<o.length;s++)for(let a=s+1;a<o.length;a++)n.get(o[s]).add(o[a]),n.get(o[a]).add(o[s])}return n}function qk(e,t){let n=new Set,i=[];for(let r of e){if(n.has(r))continue;let o=new Set,s=[r];for(;s.length>0;){let a=s.pop();if(!n.has(a)){n.add(a),o.add(a);for(let l of t.get(a)??[])n.has(l)||s.push(l)}}i.push(o)}return i}function Wk(e,t){return e.filter(n=>n.size>=3).map(n=>Vk(n,e,t)).filter(n=>n.isolation>.5).sort((n,i)=>i.isolation-n.isolation)}function Vk(e,t,n){let i=new Set;for(let a of t)if(a!==e)for(let l of a)i.add(l);let r=0;for(let a of e)for(let l of n.get(a)??[])i.has(l)&&r++;let o=e.size*i.size,s=o>0?1-r/o:1;return{callees:[...e].map(k),isolation:s}}import{posix as lr}from"path";import{spawnSync as Jk}from"child_process";import{createHash as Yk}from"crypto";import{existsSync as Xk}from"fs";import{dirname as sS,join as Zk}from"path";import{fileURLToPath as Qk}from"url";var cS=Fi("definition-consumer-file-usage",{clearGroups:["whole-project","source-file"]}),aS=vt({kind:"consumer-file-usage",invalidation:Je("consumer-file-usage"),serialize:c_,deserialize:u_});function un(e,t){return{forDefinitions(n,i){return e_(e,t,n,i)}}}function Qn(e){let t=new Map;for(let[n,i]of e)t.set(n,new Set(i.files.map(r=>r.file)));return t}function La(e,t,n){return dS(e,t,n).partition}function e_(e,t,n,i){let r=uS(n.length),o=ft()?gn(e):null,s=o?t_(n,i,o):void 0,a=s?{workIdentity:s,workOutcome:"computed"}:{};return $("consumer-evidence.product",()=>{let l=$("consumer-evidence.provenance",()=>n_(e,t,n,i),()=>({...a,definitions:n.length,semantic:i.semantic,sourceFallback:i.sourceFallback!==!1})),c=new Map;r={...r,...l.counters};let u=i_(n,l.sources);return $("consumer-evidence.classify",()=>{let d=r_(e,n,l.sources,u);for(let m of n){let f=d.get(m.symbolId)??s_();r.realFiles+=f.partition.realConsumers.length,r.reexportOnlyFiles+=f.partition.barrelConsumers,r.importOnlyFiles+=f.partition.importOnlyConsumers,c.set(m.symbolId,{definition:m,files:f.files,semanticIncomplete:l.incompleteSymbolIds.has(m.symbolId),semanticUnavailable:l.unavailableSymbolIds.has(m.symbolId),...f.partition})}},()=>({...a,...u,realFiles:r.realFiles,reexportOnlyFiles:r.reexportOnlyFiles,importOnlyFiles:r.importOnlyFiles})),c},()=>({...a,...r}))}function t_(e,t,n){let i=Yk("sha256").update("consumer-evidence-v3-calibrated-semantic\0").update(n).update("\0").update(t.semantic?"semantic\0":"indexed\0").update(t.sourceFallback===!1?"no-source-fallback":"source-fallback");for(let r of e.map(o=>o.symbol).sort())i.update("\0").update(r);return i.digest("hex").slice(0,24)}function uS(e){return{definitions:e,indexedFiles:0,semanticFiles:0,fallbackFiles:0,totalFiles:0,realFiles:0,reexportOnlyFiles:0,importOnlyFiles:0}}function n_(e,t,n,i){let r=uS(n.length),o=new Map,s=new Set,a=new Set;if(vu(o,r,"indexed",t.crossFileCallerMap(n,{semantic:!1})),i.semantic){let l=Cn(e,n);vu(o,r,"semantic",l.callers);for(let c of l.incompleteSymbolIds)s.add(c);for(let c of l.unavailableSymbolIds)a.add(c)}return i.sourceFallback!==!1&&vu(o,r,"source-fallback",t.sourceFallbackCallerFiles(n)),r.totalFiles=[...o.values()].reduce((l,c)=>l+c.size,0),{sources:o,counters:r,incompleteSymbolIds:s,unavailableSymbolIds:a}}function i_(e,t){return{definitions:e.length,consumerFiles:[...t.values()].reduce((n,i)=>n+i.size,0),nativeAttempted:!1,nativeUsed:!1,nativeReason:"not-attempted"}}function vu(e,t,n,i){let r=0;for(let[o,s]of i){let a=e.get(o);a||(a=new Map,e.set(o,a));for(let l of s){r++;let c=a.get(l)??new Set;c.add(n),a.set(l,c)}}n==="indexed"?t.indexedFiles+=r:n==="semantic"?t.semanticFiles+=r:t.fallbackFiles+=r}function r_(e,t,n,i){let r=y_(e,t,n,i);return r||o_(e,t,n)}function o_(e,t,n){let i=new Map;for(let r of t){let o=n.get(r.symbolId)??new Map;i.set(r.symbolId,dS(e,r,[...o.keys()],o))}return i}function dS(e,t,n,i=new Map){let r=[],o=0,s=0,a=re(t.symbol),l=[];for(let c of n){let u;d_(e,c,t.relativePath,a)?(o++,u="reexport-only"):Cu(e,c,a)?(s++,u="import-only"):(r.push(c),u="real"),l.push({file:c,sources:[...i.get(c)??[]],classification:u})}return{partition:{realConsumers:r,barrelConsumers:o,importOnlyConsumers:s},files:l}}function s_(){return{partition:{realConsumers:[],barrelConsumers:0,importOnlyConsumers:0},files:[]}}function Cu(e,t,n){if(!n)return!1;let i=ye(t);if(!i)return!1;let r=cS.get(e,t,()=>mS(e,t,i));return r.importedLeaves.has(n)&&!r.usedLeaves.has(n)}function mS(e,t,n){let i=Nn(e).forFile(t,{text:!0,ast:!0}),r=i.text;if(!r)return l_();let o=Ft(e,t,r),s=aS.read(e,t,o);if(s)return s;let a=a_(i.ast,n);return aS.write(e,t,o,a),a}function a_(e,t){let n=new Set,i=new Set;if(!e)return{importedLeaves:n,usedLeaves:i};let r=t==="rust"?new Set(["use_declaration"]):t==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),o=(s,a)=>{let l=a||r.has(s.type);(s.type==="identifier"||s.type==="type_identifier"||s.type==="property_identifier"||s.type==="field_identifier")&&(l?n.add(s.text):i.add(s.text));for(let c of s.children)o(c,l)};return o(e.rootNode,!1),{importedLeaves:n,usedLeaves:i}}function l_(){return{importedLeaves:new Set,usedLeaves:new Set}}function c_(e){return JSON.stringify({importedLeaves:[...e.importedLeaves],usedLeaves:[...e.usedLeaves]})}function u_(e){try{let t=JSON.parse(e);return!Array.isArray(t.importedLeaves)||!Array.isArray(t.usedLeaves)?null:{importedLeaves:new Set(t.importedLeaves.filter(n=>typeof n=="string")),usedLeaves:new Set(t.usedLeaves.filter(n=>typeof n=="string"))}}catch{return null}}function d_(e,t,n,i){if(!i)return!1;let r=Nn(e).forFile(t,{lines:!0,reexports:!0}),o=r.lines??[];if(o.length===0)return!1;let s=r.reexports??[];return fS(o,s,i)}function fS(e,t,n){if(e.length===0||t.length===0)return!1;let i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b${i}\\b`),o=0;for(let s=0;s<e.length;s++){if(!r.test(e[s]??""))continue;if(o++,!t.find(l=>l.startLine<=s&&s<=l.endLine))return!1}return o>0}var m_="CODEBASEIQ_NATIVE_CONSUMER_CLASSIFY",f_="CODEBASEIQ_NATIVE_KERNELS_BIN",p_="CODEBASEIQ_NATIVE_CONSUMER_CLASSIFY_MIN_FILES",lS=1e3,g_=5e3,h_=64*1024*1024,Ia;function y_(e,t,n,i){let r=process.env[m_]?.toLowerCase();if(r!=="1"&&r!=="true")return i.nativeReason=r==="0"||r==="false"?"disabled":"opt-in-required",null;if(i.consumerFiles<E_())return i.nativeReason="below-threshold",null;let o=w_();if(!o)return i.nativeReason="binary-missing",null;i.nativeAttempted=!0;let s=b_(e,t,n),a=Jk(o,["consumer-classify"],{input:JSON.stringify(s),encoding:"utf8",timeout:g_,maxBuffer:h_,windowsHide:!0});if(a.status!==0||a.error)return i.nativeReason=a.error?`spawn-error:${a.error.message}`:`exit-${a.status??"null"}`,null;try{let l=JSON.parse(a.stdout),c=v_(l,t);return c?(i.nativeUsed=!0,i.nativeReason="used",c):(i.nativeReason="invalid-response",null)}catch{return i.nativeReason="invalid-json",null}}function b_(e,t,n){let i=new Map,r=[];for(let a of t){let l=re(a.symbol),u=[...(n.get(a.symbolId)??new Map).entries()].map(([d,m])=>{let f=i.get(d)??new Set;return l&&f.add(l),i.set(d,f),{file:d,sources:[...m]}});r.push({symbol_id:a.symbolId,leaf:l,consumer_files:u})}let o={},s={};for(let[a,l]of i){let c=ye(a);if(c){let d=cS.get(e,a,()=>mS(e,a,c));o[a]={imported_leaves:[...d.importedLeaves],used_leaves:[...d.usedLeaves]}}let u=S_(e,a,l);u.length>0&&(s[a]=u)}return{definitions:r,file_usages:o,reexport_only_leaves:s}}function S_(e,t,n){if(n.size===0)return[];let i=Nn(e).forFile(t,{lines:!0,reexports:!0}),r=i.lines??[],o=i.reexports??[];return r.length===0||o.length===0?[]:[...n].filter(s=>fS(r,o,s))}function v_(e,t){if(!Array.isArray(e.entries)||e.entries.length!==t.length)return null;let n=new Set(t.map(r=>r.symbolId)),i=new Map;for(let r of e.entries){let o=C_(r);if(!o||!n.has(o.symbol_id))return null;i.set(o.symbol_id,{partition:{realConsumers:o.real_consumers,barrelConsumers:o.barrel_consumers,importOnlyConsumers:o.import_only_consumers},files:o.files})}for(let r of n)if(!i.has(r))return null;return i}function C_(e){if(!e||typeof e!="object")return null;let t=e;if(typeof t.symbol_id!="number"||!Array.isArray(t.real_consumers)||typeof t.barrel_consumers!="number"||typeof t.import_only_consumers!="number"||!Array.isArray(t.files)||!t.real_consumers.every(i=>typeof i=="string"))return null;let n=[];for(let i of t.files){if(!i||typeof i!="object")return null;let r=i;if(typeof r.file!="string"||!Array.isArray(r.sources)||!r.sources.every(x_)||!R_(r.classification))return null;n.push({file:r.file,sources:r.sources,classification:r.classification})}return{symbol_id:t.symbol_id,real_consumers:t.real_consumers,barrel_consumers:t.barrel_consumers,import_only_consumers:t.import_only_consumers,files:n}}function x_(e){return e==="indexed"||e==="semantic"||e==="source-fallback"}function R_(e){return e==="real"||e==="reexport-only"||e==="import-only"}function E_(){let e=process.env[p_];if(!e)return lS;let t=Number(e);return Number.isFinite(t)&&t>=0?t:lS}function w_(){if(Ia!==void 0)return Ia;let e=process.env[f_],t=process.platform==="win32"?"codebaseiq-kernels.exe":"codebaseiq-kernels";return Ia=[...e?[e]:[],...I_().map(i=>Zk(i,"target","release",t))].find(i=>Xk(i))??null,Ia}function I_(){let e=new Set,t=sS(Qk(import.meta.url));for(let n=0;n<5;n++)e.add(t),t=sS(t);return[...e]}var L_=20,D_=1,P_=new Map([["app","app"],["apps","app"],["component","component"],["components","component"],["composable","composable"],["composables","composable"],["contract","contract"],["contracts","contract"],["domain","domain"],["domains","domain"],["feature","feature"],["features","feature"],["hook","hook"],["hooks","hook"],["lib","library"],["module","module"],["modules","module"],["package","package"],["packages","package"],["page","page"],["pages","page"],["route","route"],["routes","route"],["screen","screen"],["screens","screen"],["service","service"],["services","service"],["shared","shared"],["src","source-root"],["store","state"],["stores","state"],["test","test"],["tests","test"],["util","utility"],["utils","utility"],["view","view"],["views","view"]]),T_=new Set(["components","contracts","hooks","lib","services","shared","stores","utils"]),F_=new Set(["access","api","auth","config","db","effect","errors","hooks","lib","middleware","permissions","routes","schemas","servicetasks","services","startup","store","stores","test-utils","repository","repositories","tests","types","ui","utils","workflow","workflows"]);function M_(e,t={}){let n=Eu(t.limit,L_),i=Eu(t.minConsumers,D_),r=new U(e),o=r.fileDependencyGraph(t.scope),s=Z_(he(e,{includeIgnored:!1})),a=tB(e.config.locality?.architecturalBoundarySegments,t.architecturalBoundarySegments);return(t.target?A_(e,r,t.target):N_(e,t.scope,t.scanLimit)).map(u=>k_(e,r,o,u,t,s,a)).filter(u=>u.consumerFiles.length>=i||t.target).sort(X_).slice(0,n)}function A_(e,t,n){let i=O_(e,n);if(i)return[bS(i)];let r=fe(e,n);if(!r)return[];let o=t.definitionsForFile(r.relativePath).find(s=>s.symbolId===r.symbolId);return o?[$_(o)]:[{unit:{kind:"symbol",file:r.relativePath,shortName:k(r.symbol),symbol:r.symbol,startLine:r.startLine,endLine:r.endLine}}]}function N_(e,t,n){let i=he(e,{scope:t,includeIgnored:!1}),r=Eu(n,i.length);return i.slice(0,r).map(o=>bS(o))}function k_(e,t,n,i,r,o,s){let a=i.definition?__(e,t,i.definition,r.semantic):null,l=a?.files??B_(n,i.unit.file),c=i.definition?a.coverage==="complete"?l.length>0?"exact":"none":a.coverage:l.length>0?"file-level":"none",u=c==="incomplete"||c==="unavailable"||c==="incomplete-and-unavailable",d=i.unit.file,m=qt(lr.dirname(d)),f=H_(l),p=j_(m),g=Iu([...pS(m),...f?pS(f):[]]),h=u?"repository-level-review":U_(i.unit,m,f,l),S=u?{suggestedHome:null,confidence:"withheld",whyNoSuggestedHome:`Compiler-resolved consumer evidence is ${c}; no relocation destination is safe to score.`}:z_(h,i.unit,m,f,l,o,s),v=V_(i.unit,c,f,l,m,S.whyNoSuggestedHome),y=J_(i.unit,m,f,l,S.suggestedHome,S.whyNoSuggestedHome);return{actionTier:"signal",sourceUnit:i.unit,candidatePath:d,currentDirectory:m,directoryAncestry:p,consumerFiles:l,consumerCoverage:c,nearestCommonOwner:f,boundaryMarkers:g,recommendedTier:h,suggestedHome:S.suggestedHome,destinationConfidence:S.confidence,whyNoSuggestedHome:S.whyNoSuggestedHome,counterevidence:u?[...v,"Known consumer files are retained, but missing compiler evidence can hide additional owners."]:v,reasons:y,recommendation:u?"Retain the current location until compiler-resolved consumer evidence is complete.":Y_(h,S.suggestedHome,c)}}function __(e,t,n,i){let r=un(e,t).forDefinitions([n],{semantic:i!==!1,sourceFallback:!0}).get(n.symbolId),o=r?.semanticIncomplete?r.semanticUnavailable?"incomplete-and-unavailable":"incomplete":r?.semanticUnavailable?"unavailable":"complete";return{files:RS(r?.files.map(s=>s.file)??[]),coverage:o}}function B_(e,t){let n=[];for(let[i,r]of e.entries())i!==t&&r.has(t)&&n.push(i);return RS(n)}function O_(e,t){let n=Ho(t),i=he(e,{includeIgnored:!1}),r=i.find(s=>s===n);if(r)return r;let o=i.find(s=>s.endsWith(`/${n}`));return o||(i.find(s=>s.includes(n))??null)}function $_(e){return{definition:e,unit:{kind:"symbol",file:e.relativePath,shortName:k(e.symbol),symbol:e.symbol,startLine:e.startLine,endLine:e.endLine}}}function bS(e){return{unit:{kind:"file",file:e,shortName:lr.basename(e)}}}function j_(e){if(e===".")return[{path:".",depth:0,markers:[]}];let t=[],n=e.split("/").filter(Boolean);for(let i=0;i<n.length;i+=1){let r=n.slice(0,i+1).join("/");t.push({path:r,depth:i,markers:wu(r)})}return t}function pS(e){return e==="."?[]:SS(e).map(({marker:t,prefix:n})=>`${t}: ${n}`)}function wu(e){return Iu(SS(e).map(({marker:t})=>t))}function SS(e){let t=e.split("/").filter(Boolean),n=[];for(let i=0;i<t.length;i+=1){let r=P_.get(t[i]);r&&n.push({marker:r,prefix:t.slice(0,i+1).join("/")})}return n}function H_(e){if(e.length===0)return null;let t=e.map(i=>qt(lr.dirname(i))),n=t[0].split("/").filter(Boolean);for(let i of t.slice(1)){let r=i.split("/").filter(Boolean),o=[],s=Math.min(n.length,r.length);for(let a=0;a<s&&n[a]===r[a];a+=1)o.push(n[a]);n=o}return n.length===0?".":n.join("/")}function U_(e,t,n,i){return n?e.kind==="symbol"&&i.length===1?i[0]===e.file?"same-file":"sibling-folder":n==="."||n==="src"?"repository-level-review":hS(n,"package")?"package-level-shared":hS(n,"app")?"app-level-shared":yS(n,["feature","domain","module"])||yS(t,["feature","domain","module"])?"feature-local-shared":"sibling-folder":"no-exact-consumers"}function z_(e,t,n,i,r,o,s){let a=G_(e,i);if(a)return ei(a);let l=Q_(t.file),c=K_(e,n,l,r,s);if(c)return c;let u=i;if(qt(n)===qt(u))return ei(`${n} is already the nearest common owner for its consumers.`);let d=q_(u,n,l,s);return d||W_(u,n,l,o,s)}function G_(e,t){return t?e==="no-exact-consumers"||e==="repository-level-review"?"The inferred owner is too broad or unsupported for an exact destination.":null:"No consumer owner could be inferred from the current index."}function K_(e,t,n,i,r){if(e==="same-file"){let o=i[0]??null;return o?xu(o):ei("No same-file consumer path was available.")}if(e==="sibling-folder"&&i.length===1){let o=qt(lr.dirname(i[0])),s=xS(t,n,o,r);return s?ei(s):xu(o)}return null}function q_(e,t,n,i){return iB(e)?vS(e,t,n,i,`Nearest shared owner ${e} is outside source root ${n}.`):null}function W_(e,t,n,i,r){if(e===".")return ei("The nearest common owner is the repository root.");let o=`${e}/shared`,s=vS(o,t,n,r,`Proposed home ${o} is outside source root ${n}.`);return s.confidence==="withheld"||i.has(o)?s:ei(`${o} does not exist in the indexed project.`)}function vS(e,t,n,i,r){if(!CS(e,n))return ei(r);let o=xS(t,n,e,i);return o?ei(o):xu(e)}function xu(e){return{suggestedHome:e,confidence:"exact",whyNoSuggestedHome:null}}function ei(e){return{suggestedHome:null,confidence:"withheld",whyNoSuggestedHome:e}}function V_(e,t,n,i,r,o){let s=["Report-only signal; review ownership before moving files."];return t==="none"&&s.push("No consumers were found in the current index."),t==="file-level"&&s.push("File-level import evidence can hide which exported unit is actually used."),(n==="."||n==="src")&&s.push("Nearest common owner is broad, so this is not enough evidence for automatic placement."),i.length===1&&s.push("Only one consumer was found; inlining or same-folder placement may be better than shared extraction."),e.kind==="file"&&s.push("File targets describe module locality, not symbol-level usage."),n&&r.startsWith(`${n}/`)&&s.push("Candidate already lives under the nearest common owner."),o&&s.push(`No exact suggested home: ${o}`),s}function J_(e,t,n,i,r,o){let s=[];return s.push(`${e.shortName} currently lives in ${t}.`),n?s.push(`${i.length} consumer file(s) share ${n} as their nearest common owner.`):s.push("No consumer owner could be inferred from the current index."),r?s.push(`Suggested home is ${r}.`):o&&s.push(`No exact suggested home: ${o}`),s}function Y_(e,t,n){return e==="no-exact-consumers"?"Review references before moving; no consumers were found.":e==="repository-level-review"?"Keep this as a broad locality signal; the inferred owner is too general for automatic relocation.":t?`Review whether ${n==="exact"?"symbol usage":"module import"} supports moving or extracting toward ${t}.`:"Review ownership manually before changing structure."}function X_(e,t){return gS(t)-gS(e)||e.candidatePath.localeCompare(t.candidatePath)}function gS(e){let t=e.consumerFiles.length*10;return e.consumerCoverage==="exact"&&(t+=5),e.suggestedHome&&(t+=3),e.recommendedTier==="repository-level-review"&&(t*=.1),e.recommendedTier==="no-exact-consumers"&&(t*=.05),t}function Z_(e){let t=new Set(["."]);for(let n of e){let i=qt(lr.dirname(n));for(;!t.has(i)&&(t.add(i),i!==".");)i=qt(lr.dirname(i))}return t}function Q_(e){let t=Ru(e),n=t.indexOf("src");return n>=0?t.slice(0,n+1).join("/"):t.length<=1?".":t[0]}function CS(e,t){let n=qt(e),i=qt(t);return i==="."||n===i||n.startsWith(`${i}/`)}function eB(e,t,n){let i=Ru(e),r=Ru(t);return(CS(e,t)?i.slice(r.length):i).some(s=>n.has(s.toLowerCase()))}function xS(e,t,n,i){return qt(e)===qt(n)||!eB(e,t,i)?null:`${e} is a named architectural boundary; an exact move to ${n} needs human design.`}function tB(...e){let t=new Set(F_);for(let n of e)for(let i of n??[]){let r=nB(i);r&&t.add(r)}return t}function nB(e){let t=e.trim().toLowerCase();return t===""?null:t}function hS(e,t){return wu(e).includes(t)}function yS(e,t){let n=wu(e);return t.some(i=>n.includes(i))}function iB(e){let t=e.split("/").filter(Boolean),n=t[t.length-1];return n?T_.has(n):!1}function qt(e){let t=Ho(e);return t===""?".":t}function Ru(e){let t=Ho(e);return t==="."?[]:t.split("/").filter(Boolean)}function Eu(e,t){return!Number.isFinite(e)||e===void 0||e<1?t:Math.floor(e)}function RS(e){return Iu([...e]).sort((t,n)=>t.localeCompare(n))}function Iu(e){return[...new Set(e)]}function Lu(e,t,n={}){return rB(e,t,n)}function rB(e,t,n){let{maxDepth:i=5,scope:r}=n,o=i===Number.MAX_SAFE_INTEGER,s=o?null:500,a=fe(e,t);if(!a)return{rows:[],coverage:{status:"incomplete",edgeBasis:"reverse-static-call-or-reference-evidence",maxDepth:i,reachedDepth:0,perSymbolEvidenceLimit:s,remainingFrontierSymbols:0,reasons:["The requested symbol could not be resolved."],semanticEvidence:"incomplete"}};let l=[],c=new Set([a.symbolId]),u=new Set,d=[a],m=0,f=!1,p=!1,g=!1;for(let v=1;v<=i&&d.length!==0;v++){m=v;let y=[],E=Qt(e,d,{...o?{}:{limit:s+1},semanticEvidence:pe});E.incompleteSymbolIds.size>0&&(p=!0),E.unavailableSymbolIds.size>0&&(g=!0);for(let w of d){let b=E.rows.get(w.symbolId)??[];s!==null&&b.length>s&&(f=!0);let R=s===null?b:b.slice(0,s);for(let C of oB(e,w,r,R)){let L=`${C.file}|${C.shortName}`;if(C.symbolId!==null){if(c.has(C.symbolId))continue;c.add(C.symbolId)}else if(u.has(L))continue;u.add(L),l.push({symbol:C.symbol,shortName:C.shortName,file:C.file,depth:v}),C.symbolId!==null&&C.symbolMatch&&y.push(C.symbolMatch)}}d=y}l.sort((v,y)=>v.depth-y.depth||v.file.localeCompare(y.file));let h=d.length>0,S=[];return h&&S.push(`${d.length} symbol(s) remain eligible beyond depth ${i}.`),f&&S.push(`At least one symbol had more than ${s} incoming evidence row(s).`),p&&S.push("Compiler-resolved incoming evidence was incomplete for at least one traversed symbol."),g&&S.push("Compiler-resolved incoming evidence was unavailable for at least one traversed symbol."),S.length===0&&S.push("The discovered reverse evidence frontier was exhausted."),{rows:l,coverage:{status:p||g?"incomplete":h||f?"bounded":"accounted",edgeBasis:"reverse-static-call-or-reference-evidence",maxDepth:i,reachedDepth:m,perSymbolEvidenceLimit:s,remainingFrontierSymbols:d.length,reasons:S,semanticEvidence:p&&g?"incomplete-and-unavailable":p?"incomplete":g?"unavailable":"complete"}}}function oB(e,t,n,i){let r=i.filter(u=>!e.isIgnored(u.file)).filter(u=>!n||u.file.includes(n)),o=new Set(r.map(u=>u.file)),s=[];for(let u of sB(e,t,n)){if(o.has(u))continue;let d=J(e,u),m=d.length>0?Ge(d,d[0].startLine):null;s.push({symbol:m?.symbol??u,file:u})}let a=[...r,...s],l=[],c=new Set;for(let u of a){let d=ri(e,u.symbol);if(!d){let f=`${u.file}|${u.symbol}`;if(c.has(f))continue;c.add(f),l.push({symbolId:null,symbol:u.symbol,shortName:k(u.symbol),file:u.file,symbolMatch:null});continue}if(d.symbolId===t.symbolId||e.isIgnored(d.relativePath)||!aB(d))continue;let m=`${d.symbolId}|${d.relativePath}`;c.has(m)||(c.add(m),l.push({symbolId:d.symbolId,symbol:d.symbol,shortName:k(d.symbol),file:d.relativePath,symbolMatch:d}))}return l}function sB(e,t,n){let i=n?"AND consumer_d.relative_path LIKE ?":"",r=[t.symbolId,t.documentId];return n&&r.push(`%${n}%`),new Set(e.all(`SELECT DISTINCT consumer_d.relative_path
321
+ FROM mentions m
322
+ JOIN chunks c ON m.chunk_id = c.id
323
+ JOIN documents consumer_d ON consumer_d.id = c.document_id
324
+ WHERE m.symbol_id = ?
325
+ AND m.role != 1
326
+ AND c.document_id != ?
327
+ ${e.pathExclusionsFor("consumer_d")}
328
+ ${i}`,...r).map(o=>o.relative_path).filter(o=>!e.isIgnored(o)))}function aB(e){if(e.symbol.startsWith("scip-clojure ")||ye(e.relativePath)==="clojure")return!0;let t=kn(e.symbol);return t==="method"||t==="type"||e.symbol.endsWith("().")}function wS(e,t){let n=pt(t),i=[],r="complete",o=V(n);o==="entry"&&Fn(i,"operational-root","structural entrypoint path"),o==="worker"&&Fn(i,"operational-root","worker launch convention"),gc(n)&&Fn(i,"operational-root","framework-discovered entrypoint"),lB(e,n)&&Fn(i,"operational-root","configured entry root");let s=!1;try{s=En(e,n),s&&Fn(i,"published-api","package manifest export");for(let a of ng(e,n))Fn(i,"operational-root",a)}catch(a){r="partial",Fn(i,"metadata-unavailable",`package metadata unavailable: ${ES(a)}`)}try{let a=nt(e.config.projectRoot,n,{maxBytes:8388608,inputKind:"change-surface source"});cB(a)&&Fn(i,"operational-root","module contains a direct-execution process guard")}catch(a){r="partial",Fn(i,"metadata-unavailable",St(a)?"indexed source file is unavailable on disk":`source metadata unavailable: ${ES(a)}`)}return{operationalRoot:i.some(a=>a.kind==="operational-root"),publishedApi:s,coverage:r,reasons:i}}function lB(e,t){let n=e.config.entryRoots;return n?n.files?.some(i=>pt(i)===t)?!0:n.pathPrefixes?.some(i=>t.startsWith(pt(i)))??!1:!1}function cB(e){return e.includes("import.meta.url")&&/process\.argv\s*\[\s*1\s*\]/.test(e)||/require\.main\s*===\s*module/.test(e)||/__name__\s*==\s*['"]__main__['"]/.test(e)}function Fn(e,t,n){e.some(i=>i.kind===t&&i.detail===n)||e.push({kind:t,detail:n})}function ES(e){return e instanceof Error?e.message:String(e)}function Du(e,t,n={}){let i=lt(e,t);if(!i)return null;let r=dB(e,i);if(!r||e.isIgnored(r.relative_path))return null;let o=[],s=0,a=!0,l=mB(e,r.relative_path),c=wS(e,r.relative_path),u=n.semantic===!1?{callers:new Map,incompleteSymbolIds:new Set,unavailableSymbolIds:new Set}:Cn(e,l);for(let d of l){let m=fB(e,r,d,u.callers.get(d.symbolId)??new Set);s+=m;let f=uB(n.semantic!==!1,d.symbolId,u),p=f==="complete"||f==="disabled";p||(a=!1);let g=p?m:null,h=g===null?void 0:pB(g),S=[...c.reasons,...m>0?[{kind:"external-consumers",detail:`${m} known external consumer${m===1?"":"s"}`}]:[],...p?[]:[{kind:"semantic-consumer-coverage",detail:`compiler-resolved consumer evidence is ${f}`}]];o.push({symbol:d.symbol,shortName:k(d.symbol),startLine:d.startLine,endLine:d.endLine,externalConsumers:g,knownExternalConsumers:m,consumerCoverage:f,externalConsumerRiskLevel:h,riskLevel:gB(h,c,!p),riskReasons:S})}return{file:r.relative_path,symbols:o,totalExternalConsumers:a?s:null,knownTotalExternalConsumers:s,fileRisk:c}}function uB(e,t,n){if(!e)return"disabled";let i=n.incompleteSymbolIds.has(t),r=n.unavailableSymbolIds.has(t);return i&&r?"incomplete-and-unavailable":i?"incomplete":r?"unavailable":"complete"}function dB(e,t){return e.get(`SELECT id, relative_path FROM documents
329
+ WHERE relative_path = ?
330
+ ${e.pathExclusionsFor("documents")}
331
+ LIMIT 1`,t)??null}function mB(e,t){return new U(e).definitionsForFile(t).sort((n,i)=>n.startLine-i.startLine||n.endLine-i.endLine)}function fB(e,t,n,i){let r=e.all(`SELECT DISTINCT consumer_d.relative_path
332
+ FROM mentions m
333
+ JOIN chunks c ON m.chunk_id = c.id
334
+ JOIN documents consumer_d ON consumer_d.id = c.document_id
335
+ WHERE m.symbol_id = ?
336
+ AND m.role != 1
337
+ AND c.document_id != ?`,n.symbolId,t.id);return new Set([...r.map(o=>o.relative_path),...[...i].filter(o=>o!==t.relative_path)]).size}function pB(e){return e>10?"high":e>0?"medium":"low"}function gB(e,t,n){return e==="high"?"high":n||e==="medium"||t.operationalRoot||t.publishedApi||t.coverage==="partial"?"medium":"low"}function hB(e,t={}){let{scope:n,minLoc:i=1,maxDepth:r=5,scanLimit:o}=t,s=new U(e),a=yB(e,n,i,o),l=new Pu;for(let g of a)l.add(g);let c=[],u=[];a.length>0&&c.push(IS(e,0,a,l));let d=a.map(g=>g.definition).filter(g=>g!==null),m=new Set(a.map(g=>g.symbol));for(let g=1;g<=r&&d.length>0;g++){let h=s.calleeMap(d,{semantic:!1}),S=new Set;for(let y of d)for(let E of h.get(y.symbolId)??[])m.has(E.symbol)||S.add(E.symbol);let v=[];for(let y of S){m.add(y);let E=LS(e,y);if(!E||e.isIgnored(E.relativePath)||Ye(e,E.relativePath)||Ue(e,E.symbol,E.relativePath)||s.fileKind(E.relativePath)==="test"||s.hasSuppressionComment(E))continue;let w=SB(e,E,l);w.removable?v.push(bB(E,"cascade")):w.blockingFiles.length>0&&u.push({shortName:k(E.symbol),file:E.relativePath,blockingFiles:w.blockingFiles.slice(0,3)})}if(v.length===0)break;for(let y of v)l.add(y);c.push(IS(e,g,v,l)),d=v.map(y=>y.definition).filter(y=>y!==null)}let f=c.reduce((g,h)=>g+h.loc,0),p=c.reduce((g,h)=>g+h.entries.length,0);return{batches:c,totalSymbols:p,totalLoc:f,blocked:u}}function yB(e,t,n,i){let r=wi(e,{scope:t,minLoc:n,skipBarrels:!0,deadCodeOnly:!0,scanLimit:i,semantic:!1}),o=[];for(let s of r.symbols)s.kind==="dead-code"&&(Ye(e,s.relativePath)||Ue(e,s.symbol,s.relativePath)||o.push({symbol:s.symbol,shortName:s.shortName,file:s.relativePath,startLine:s.startLine,endLine:s.endLine,loc:s.loc,evidence:"graph-fact",definition:LS(e,s.symbol)}));return o}function bB(e,t){return{symbol:e.symbol,shortName:k(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:e.endLine-e.startLine+1,evidence:t,definition:e}}function LS(e,t){let n=e.get(`SELECT d.relative_path
338
+ FROM global_symbols gs
339
+ JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
340
+ JOIN documents d ON d.id = der.document_id
341
+ WHERE gs.symbol = ?
342
+ LIMIT 1`,t);return n?J(e,n.relative_path).find(i=>i.symbol===t)??null:null}function SB(e,t,n){let i=Cr(e,t);if(i.length===0)return{removable:!1,blockingFiles:[]};let r=new Set;for(let o of i)o.file===t.relativePath&&o.line>=t.startLine&&o.line<=t.endLine||n.contains(o.file,o.line)||r.add(o.file);return{removable:r.size===0,blockingFiles:[...r]}}function IS(e,t,n,i){let r=[...n].sort((a,l)=>a.file.localeCompare(l.file)||a.startLine-l.startLine),o=new Set(r.map(a=>a.file)),s=[];for(let a of o){let l=J(e,a);l.length>0&&l.every(c=>i.contains(a,c.startLine))&&s.push(a)}return{depth:t,entries:r.map(({definition:a,...l})=>l),loc:r.reduce((a,l)=>a+l.loc,0),filesEmptied:s.sort()}}var Pu=class{ranges=new Map;add(t){let n=this.ranges.get(t.file)??[];n.push({start:t.startLine,end:t.endLine}),this.ranges.set(t.file,n)}contains(t,n){let i=this.ranges.get(t);return i?i.some(r=>n>=r.start&&n<=r.end):!1}};import{execFileSync as cr}from"child_process";import{existsSync as vB}from"fs";import{basename as DS}from"path";function Da(e){let t=new Map;for(let n of e){let i=t.get(n.file);i||(i=[],t.set(n.file,i)),i.push(n)}return t}var Nu="Unable to compute git diff.",CB={semanticConsumers:yp,sourceFallbackConsumers:Ur},ku={resolveCommit:sl,readBatch({projectRoot:e,resolvedBase:t,relativePaths:n}){let i=n.map(r=>`${t}:./${r}
343
+ `).join("");return cr("git",["cat-file","--batch"],{cwd:e,input:i,maxBuffer:256*1024*1024,timeout:1e4,stdio:["pipe","pipe","ignore"],windowsHide:!0})}};function Pa(e,t={}){let n=t.plan??ur(e,t);return n.note?xB(n.note,n.changedFileLines):n.changedFiles.length===0?RB(n.changedFileLines):Ta(n.changedFiles,[MS(e,n.changedFiles,n.changedFiles,n.changedRanges)])}function ur(e,t={}){let{base:n="HEAD"}=t;try{let i=sl(e.config.projectRoot,n),r=EB(e.config.projectRoot,i),o=r.changedFileLines,s=TB(e,o),a=FB(e,r.changedRanges);return{changedFileLines:o,changedFiles:s,changedRanges:a,renamedFiles:LB(e.config.projectRoot,i,s,r),note:o.length===0?"No changed files found.":void 0}}catch{return{changedFileLines:[],changedFiles:[],changedRanges:[],renamedFiles:[],note:Nu}}}function MS(e,t,n,i=[],r={}){let o=r.evidenceRuntime??CB,s=new U(e),a=new Set(n),l=Da(i),c=[],u=new Map,d=t.flatMap(C=>s.definitionsForFile(C)).filter(WB),m=d.filter(C=>AB(C,l)),f=kB(e,d,m,l),p=OB([...m,...f.definitions]).sort((C,L)=>C.relativePath.localeCompare(L.relativePath)||C.startLine-L.startLine),g=p.map(C=>C.symbolId),h=GB(e,g),S=KB(e,g,n),v=p.filter(C=>(h.get(C.symbolId)??0)===0),y=FS("semantic-consumers",v.length,()=>o.semanticConsumers(e,v)),E=y.values,w=v.filter(C=>(E.get(C.symbolId)?.size??0)===0),b=FS("source-fallback-consumers",w.length,()=>o.sourceFallbackConsumers(e,w)),R=b.values;for(let C of p)HB(e,C,a,c,u,E.get(C.symbolId)??new Set,R.get(C.symbolId)??new Set,h.get(C.symbolId)??0,S.get(C.symbolId)??new Set);return{changedSymbols:c,consumerEntries:[...u.entries()].map(([C,L])=>({file:C,symbols:[...L].sort()})),attributionNotes:f.notes,evidenceTiers:[y.status,b.status]}}function Ta(e,t){let n=new Map,i=t.flatMap(a=>a.changedSymbols),r=t.flatMap(a=>a.attributionNotes??[]),o=UB(t);for(let a of t)for(let l of a.consumerEntries){let c=n.get(l.file);c||(c=new Set,n.set(l.file,c));for(let u of l.symbols)c.add(u)}let s=qB(n);return{changedFiles:[...e],changedSymbols:i,affectedConsumers:s,attributionNotes:r,evidenceTiers:o,summary:{totalChangedFiles:e.length,totalChangedSymbols:i.length,totalAffectedFiles:s.length}}}function xB(e,t=[]){return{changedFiles:t,changedSymbols:[],affectedConsumers:[],attributionNotes:[],evidenceTiers:$S(),summary:{totalChangedFiles:t.length,totalChangedSymbols:0,totalAffectedFiles:0,note:e}}}function RB(e){return{changedFiles:e,changedSymbols:[],affectedConsumers:[],attributionNotes:[],evidenceTiers:$S(),summary:{totalChangedFiles:e.length,totalChangedSymbols:0,totalAffectedFiles:0,note:"Changed files are not present in the current SCIP index."}}}function EB(e,t){let n=cr("git",["diff","--name-status","--find-renames",t,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:67108864,windowsHide:!0}),i=cr("git",["diff","--name-status","--find-renames","--cached",t,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024,windowsHide:!0}),r=cr("git",["ls-files","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024,windowsHide:!0}),o=cr("git",["diff","--unified=0",t,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024,windowsHide:!0}),s=cr("git",["diff","--unified=0","--cached",t,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024,windowsHide:!0}),a=DB([n,i]);return{changedFileLines:[...new Set([...a.changedFiles,...kS(r)])],changedRanges:BS([...TS(o),...TS(s)]),renamedFiles:a.renamedFiles,deletedFiles:a.deletedFiles}}function wB(e,t,n){let i=typeof e=="string"?{projectRoot:e,base:t,relativePath:n}:e;if(typeof i.projectRoot!="string"||typeof i.base!="string"||typeof i.relativePath!="string")throw new TypeError("fileContentAtBase requires projectRoot, base, and relativePath.");let r={projectRoot:i.projectRoot,base:i.base,relativePath:i.relativePath},{relativePath:o}=r,s=_u(r);if(s.state==="unavailable")throw new Error(`Base content unavailable for ${o}: ${s.reason}`);return s.state==="present"?s.content:null}function _u(e,t=ku){return NS(e.relativePath),Bu({projectRoot:e.projectRoot,base:e.base,relativePaths:[e.relativePath]},t).get(e.relativePath)??{state:"unavailable",reason:`Base-content lookup omitted ${e.relativePath}.`}}function Bu(e,t=ku){for(let s of e.relativePaths)NS(s);let n=[...new Set(e.relativePaths)];if(n.length===0)return new Map;let i;try{i=t.resolveCommit(e.projectRoot,e.base)}catch(s){return Tu(n,Fu(s))}let r;try{r=t.readBatch({projectRoot:e.projectRoot,resolvedBase:i,relativePaths:n})}catch(s){return Tu(n,Fu(s))}let o;try{o=IB(r,n)}catch(s){return Tu(n,`Malformed git cat-file batch output: ${Fu(s)}`)}return new Map(n.map(s=>{let a=o.get(s)??null;return[s,a===null?{state:"absent"}:{state:"present",content:a}]}))}function Ou(e,t=ku){let n=Bu({projectRoot:e.projectRoot,base:e.base,relativePaths:e.preloadPaths??[]},t);return i=>(n.has(i)||n.set(i,_u({projectRoot:e.projectRoot,base:e.base,relativePath:i},t)),n.get(i)??{state:"unavailable",reason:`Base-content reader omitted ${i}.`})}function AS(e,t=e.changedFiles){let n=new Map(e.renamedFiles.map(i=>[i.to,i.from]));return[...new Set(t.map(i=>n.get(i)??i))]}function NS(e){pn(e)}function Tu(e,t){return new Map(e.map(n=>[n,{state:"unavailable",reason:t}]))}function Fu(e){let n=(e instanceof Error?e.message:String(e)).replaceAll(/\s+/g," ").trim().slice(0,500);return n===""?"Git base-content lookup failed without a reason.":n}function IB(e,t){let n=new Map,i=0;for(let r of t){let o=e.indexOf(10,i);if(o<0)throw new Error("git cat-file batch output ended before object header");let s=e.subarray(i,o).toString("utf-8");if(i=o+1,s.endsWith(" missing")){n.set(r,null);continue}let a=/^[0-9a-f]+ ([^ ]+) (\d+)$/.exec(s);if(!a)throw new Error(`unexpected git cat-file batch header: ${s}`);let[,l,c]=a,u=Number(c);if(!Number.isFinite(u)||u<0)throw new Error(`unexpected git cat-file batch size: ${s}`);if(i+u>e.length)throw new Error("git cat-file batch output ended before blob payload");let d=e.subarray(i,i+u);n.set(r,l==="blob"?d.toString("utf-8"):null),i+=u,e[i]===10&&(i+=1)}return n}function LB(e,t,n,i){if(n.length===0)return[];let r=new Map,o=new Set;for(let a of i.renamedFiles)n.includes(a.to)&&(r.set(a.to,a),o.add(a.from));let s=i.deletedFiles;if(s.length===0)return[...r.values()].sort((a,l)=>a.to.localeCompare(l.to));for(let a of n){if(r.has(a)||!vB(`${e}/${a}`))continue;let l=s.filter(d=>!o.has(d)).filter(d=>DS(d)===DS(a));if(l.length===0)continue;let c=nt(e,a),u=l.map(d=>({from:d,to:a,similarity:PB(wB({projectRoot:e,base:t,relativePath:d})??"",c)})).sort((d,m)=>m.similarity-d.similarity)[0];u&&u.similarity>=.45&&(r.set(a,u),o.add(u.from))}return[...r.values()].sort((a,l)=>a.to.localeCompare(l.to))}function DB(e){let t=new Set,n=new Map,i=new Set;for(let r of e.flatMap(o=>kS(o))){let[o,s,a]=r.split(" ");if(!(!o||!s)){if(o.startsWith("R")&&a){t.add(a),n.set(a,{from:s,to:a,similarity:Number(o.slice(1))/100});continue}t.add(s),o.startsWith("D")&&i.add(s)}}return{changedFiles:[...t],renamedFiles:[...n.values()],deletedFiles:[...i]}}function PB(e,t){let n=new Set(PS(e)),i=new Set(PS(t));if(n.size===0&&i.size===0)return 1;if(n.size===0||i.size===0)return 0;let r=0;for(let o of n)i.has(o)&&(r+=1);return 2*r/(n.size+i.size)}function PS(e){return e.match(/[A-Za-z_$][\w$]*|[{}()[\].,]/g)??[]}function kS(e){return e.split(`
344
+ `).map(t=>t.trim()).filter(t=>t.length>0)}function TB(e,t){let n=_S(e),i=[];for(let r of t){let o=n(r);o&&!e.isIgnored(o)&&i.push(o)}return i}function FB(e,t){let n=_S(e),i=[];for(let r of t){let o=n(r.file);o&&!e.isIgnored(o)&&i.push({...r,file:o})}return BS(i)}function _S(e){let n=e.all(`SELECT relative_path FROM documents
345
+ ORDER BY id`).map(r=>r.relative_path).map(r=>({path:r,normalized:pn(r)})),i=new Map;for(let r of n){let o=i.get(r.normalized);i.set(r.normalized,o===void 0||o===r.path?r.path:null)}return r=>{let o=pn(r),s=i.get(o);if(s)return s;let a=n.filter(l=>l.normalized.endsWith(o));return a.length===1?a[0].path:null}}function TS(e){let t=[],n=null;for(let i of e.split(`
346
+ `)){if(i.startsWith("+++ ")){n=MB(i.slice(4).trim());continue}if(!n||!i.startsWith("@@ "))continue;let r=/@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/.exec(i);if(!r)continue;let o=Math.max(0,Number(r[1])-1),s=r[2]===void 0?1:Number(r[2]);t.push({file:n,startLine:o,endLine:Math.max(o,o+Math.max(s,1)-1)})}return t}function MB(e){return e==="/dev/null"?null:e.startsWith("a/")||e.startsWith("b/")?e.slice(2):e}function BS(e){let t=new Set,n=[];for(let i of e){let r=`${i.file}:${i.startLine}:${i.endLine}`;t.has(r)||(t.add(r),n.push(i))}return n}function AB(e,t){let n=t.get(e.relativePath);return!n||n.length===0?!0:n.some(i=>$u(e.startLine,e.endLine,i.startLine,i.endLine))}function NB(e,t,n){let i=new Map,r=[],o=OS(e),s=$B(n);for(let a of t){let l=o.get(a.file)??[];if(l.some(d=>$u(d.startLine,d.endLine,a.startLine,a.endLine)))continue;let c=s.get(a.file)??[],u=jB(c,a);if(u){let d=l.find(m=>m.startLine>=u.startLine&&m.startLine<=u.endLine);if(d){i.set(d.symbolId,d),r.push(Mu(a,"ast-widened"));continue}}if(c.length===0){let d=[...l].filter(m=>m.startLine<=a.startLine).sort((m,f)=>f.startLine-m.startLine||m.endLine-f.endLine)[0];if(d){i.set(d.symbolId,d),r.push(Mu(a,"nearest-preceding"));continue}}r.push(Mu(a,"unattributed"))}return{definitions:[...i.values()],notes:r}}function kB(e,t,n,i){let r=OS(n),o=[],s=[],a=[...new Set(t.map(l=>l.relativePath))];for(let l of a){let c=i.get(l)??[];if(c.length===0)continue;let u=r.get(l)??[];for(let d of c)u.some(m=>$u(m.startLine,m.endLine,d.startLine,d.endLine))||o.push(d);o.some(d=>d.file===l)&&s.push(..._B(e,l))}return NB(t,o,s)}function _B(e,t){let n=ae(e,t);return n?n.rootNode.namedChildren.filter(BB).map(i=>({file:t,startLine:i.startPosition.row,endLine:i.endPosition.row})).filter(i=>i.endLine>=i.startLine):[]}function BB(e){return e.endPosition.row<e.startPosition.row?!1:!new Set(["import_statement","comment"]).has(e.type)}function OB(e){let t=new Map;for(let n of e)t.set(n.symbolId,n);return[...t.values()]}function OS(e){let t=new Map;for(let n of e){let i=t.get(n.relativePath)??[];i.push(n),t.set(n.relativePath,i)}return t}function $B(e){let t=new Map;for(let n of e){let i=t.get(n.file)??[];i.push(n),t.set(n.file,i)}return t}function jB(e,t){return e.filter(n=>n.startLine<=t.startLine&&n.endLine>=t.endLine).sort((n,i)=>n.endLine-n.startLine-(i.endLine-i.startLine))[0]}function Mu(e,t){return{file:e.file,startLine:e.startLine,endLine:e.endLine,method:t}}function $u(e,t,n,i){return e<=i&&n<=t}function HB(e,t,n,i,r,o,s,a,l){let c=Math.max(a,o.size,s.size);if(!VB(t,c))return;let u=k(t.symbol);i.push({symbol:t.symbol,shortName:u,file:t.relativePath,startLine:t.startLine,endLine:t.endLine,fanIn:c});for(let d of l)Au(e,n,r,d,u);for(let d of o)Au(e,n,r,d,u);for(let d of s)Au(e,n,r,d,u)}function FS(e,t,n){try{return{values:n(),status:{tier:e,state:"complete",attemptedSymbols:t}}}catch(i){return{values:new Map,status:{tier:e,state:"failed",attemptedSymbols:t,reason:zB(i)}}}}function UB(e){return["semantic-consumers","source-fallback-consumers"].map(t=>{let n=e.map(o=>o.evidenceTiers?.find(s=>s.tier===t)??{tier:t,state:"failed",attemptedSymbols:0,reason:"isolated diff-impact batch omitted its evidence-tier status"}),i=n.reduce((o,s)=>o+s.attemptedSymbols,0),r=[...new Set(n.filter(o=>o.state==="failed").map(o=>o.reason))];return r.length===0?{tier:t,state:"complete",attemptedSymbols:i}:{tier:t,state:"failed",attemptedSymbols:i,reason:r.join("; ").slice(0,500)}})}function $S(){return[{tier:"semantic-consumers",state:"complete",attemptedSymbols:0},{tier:"source-fallback-consumers",state:"complete",attemptedSymbols:0}]}function zB(e){let n=(e instanceof Error?e.message:String(e)).replaceAll(/\s+/g," ").trim().slice(0,500);return n===""?"evidence provider failed without a reason":n}function GB(e,t){if(t.length===0)return new Map;let n=e.all(`SELECT m.symbol_id, COUNT(DISTINCT c.document_id) AS fan_in
347
+ FROM mentions m
348
+ JOIN chunks c ON m.chunk_id = c.id
349
+ WHERE m.symbol_id IN (${t.map(()=>"?").join(",")})
350
+ AND m.role != 1
351
+ GROUP BY m.symbol_id`,...t);return new Map(n.map(i=>[i.symbol_id,i.fan_in]))}function KB(e,t,n){if(t.length===0||n.length===0)return new Map;let i=e.all(`SELECT DISTINCT m.symbol_id, ref_d.relative_path
352
+ FROM mentions m
353
+ JOIN chunks c ON m.chunk_id = c.id
354
+ JOIN documents ref_d ON c.document_id = ref_d.id
355
+ WHERE m.symbol_id IN (${t.map(()=>"?").join(",")})
356
+ AND m.role != 1
357
+ AND ref_d.relative_path NOT IN (${n.map(()=>"?").join(",")})
358
+ ${e.pathExclusionsFor("ref_d")}`,...t,...n),r=new Map;for(let o of i){let s=r.get(o.symbol_id);s||(s=new Set,r.set(o.symbol_id,s)),s.add(o.relative_path)}return r}function Au(e,t,n,i,r){if(e.isIgnored(i)||t.has(i))return;let o=n.get(i);o||(o=new Set,n.set(i,o)),o.add(r)}function qB(e){return[...e.entries()].map(([t,n])=>({file:t,consumedSymbols:n.size})).sort((t,n)=>n.consumedSymbols-t.consumedSymbols)}function WB(e){return!(Le(e.symbol)||e.parentTypeName!==null&&!it(e.symbol))}function VB(e,t){return it(e.symbol)||e.isTypeLike?!0:e.parentTypeName===null&&t>0}var JB=5;function YB(e,t={}){let{base:n="HEAD",minContainment:i=.7,minCallees:r=3,minSiteCoverage:o=.4,maxHelpers:s=Number.POSITIVE_INFINITY,limit:a=20,scanLimit:l}=t,c=t.semantic!==!1,u=t.diffPlan??ur(e,{base:n}),d={available:u.note!==Nu,base:n,changedFiles:u.changedFiles,helpersChecked:0,skipped:[],findings:[],...u.note?{note:u.note}:{}};if(!d.available||u.changedFiles.length===0)return d;let m=new U(e),f=new Set(u.changedFiles),p=new Map(u.renamedFiles.map(R=>[R.to,R.from]));if(t.baseContentAt&&t.baseContentResultAt)throw new Error("Specify only one of baseContentAt or baseContentResultAt.");let g=t.baseContentResultAt?t.baseContentResultAt:t.baseContentAt?iO(t.baseContentAt):Ou({projectRoot:e.config.projectRoot,base:n,preloadPaths:AS(u)}),h=nO(m,f,p,g);if(h.unavailable)return d.available=!1,d.note=`Base content unavailable: ${h.unavailable.reason}`,d;if(h.definitions.length===0)return d;let S=h.definitions.slice(0,s);h.definitions.length>s&&(d.note=`helper scoring capped at ${s} of ${h.definitions.length} new symbols`);let v=m.calleeEvidenceMap(S,{semantic:c}),y=S.filter(R=>!v.incompleteSymbolIds.has(R.symbolId)&&!v.unavailableSymbolIds.has(R.symbolId)).map(R=>({def:R,callees:Ra((v.rows.get(R.symbolId)??[]).map(C=>C.symbol))}));for(let R of S)!v.incompleteSymbolIds.has(R.symbolId)&&!v.unavailableSymbolIds.has(R.symbolId)||d.skipped.push({helperShortName:k(R.symbol),helperFile:R.relativePath,reason:"compiler-resolved callee evidence is incomplete or unavailable \u2014 unsafe to score"});let E=ar(e),w,b=()=>(w??=E.calleeIndex({minCallees:Math.min(3,r),scanLimit:l,semantic:c}),w);for(let{def:R,callees:C}of y){let L=k(R.symbol);if(C.size<r){d.skipped.push({helperShortName:L,helperFile:R.relativePath,reason:`fewer than ${r} meaningful callees \u2014 too small to score`});continue}let I=b(),x=tO(C,I);if(x===0){d.skipped.push({helperShortName:L,helperFile:R.relativePath,reason:"helper callee pattern is all project-wide infrastructure \u2014 too generic to score"});continue}let P=rO(e,R.symbolId);if(P.length===0){d.skipped.push({helperShortName:L,helperFile:R.relativePath,reason:"no references yet \u2014 covered by the new-dead check"});continue}d.helpersChecked+=1;let _=XB({candidateIndex:I,changed:f,helperCallees:C,helperFile:R.relativePath,helperSymbol:R.symbol,minContainment:i,minSiteCoverage:o,migratedFiles:P});_.length!==0&&(_.sort((D,T)=>jS(T.migrationScope)-jS(D.migrationScope)||T.containment-D.containment||T.siteCoverage-D.siteCoverage||D.file.localeCompare(T.file)),d.findings.push({helperSymbol:R.symbol,helperShortName:L,helperFile:R.relativePath,helperShape:"specific-callee-cluster",helperCalleeCount:C.size,specificHelperCalleeCount:x,migratedFiles:P.sort(),leftovers:_.slice(0,JB)}))}return d.findings.sort((R,C)=>(C.leftovers[0]?.containment??0)-(R.leftovers[0]?.containment??0)||R.helperFile.localeCompare(C.helperFile)),d.findings=d.findings.slice(0,a),d}function XB(e){let t=[],n=ZB(e.helperSymbol,e.helperFile,e.migratedFiles),i=new Set;for(let r of e.helperCallees)for(let o of e.candidateIndex.candidateIndexesByCallee.get(r)??[])i.add(o);for(let r of i){let o=e.candidateIndex.corpus[r];if(o.symbol===e.helperSymbol||e.changed.has(o.file)||o.callees.has(e.helperSymbol))continue;let s=Ab(e.helperCallees,o.callees);if(s<e.minContainment)continue;let a=[...e.helperCallees].filter(u=>o.callees.has(u)),l=o.callees.size===0?0:a.length/o.callees.size;if(l<e.minSiteCoverage||!a.some(u=>(e.candidateIndex.docFreq.get(u)??0)<=e.candidateIndex.ubiquityThreshold))continue;let c=QB(n,o.symbol,o.file);t.push({symbol:o.symbol,shortName:k(o.symbol),file:o.file,...c,containment:s,siteCoverage:l,uniqueSiteCalleeCount:Math.max(0,o.callees.size-a.length),sharedCallees:a.map(k).sort()})}return t}function jS(e){return e==="same-scope"?2:e==="unknown"?1:0}function ZB(e,t,n){let i=new Set([...ju(t),...Hu(re(e))]);for(let r of n)for(let o of ju(r))i.add(o);return i}function QB(e,t,n){let i=new Set([...ju(n),...Hu(re(t))]);if(e.size===0||i.size===0)return{migrationScope:"unknown",migrationScopeReasons:["insufficient path/name tokens to infer migration scope"]};let r=[...i].filter(o=>e.has(o)).sort();return r.length>0?{migrationScope:"same-scope",migrationScopeReasons:[`shares migration-scope token(s): ${r.slice(0,5).join(", ")}`]}:{migrationScope:"possible-subtype",migrationScopeReasons:["no path/name tokens shared with the helper or already migrated files"]}}var eO=new Set(["app","apps","common","component","components","helper","helpers","index","lib","package","packages","page","pages","route","routes","service","services","shared","spec","src","test","tests","util","utils"]);function ju(e){return Hu(e.replace(/\.[^.]+$/,""))}function Hu(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>1&&!eO.has(t))}function tO(e,t){let n=0;for(let i of e)(t.docFreq.get(i)??0)<=t.ubiquityThreshold&&(n+=1);return n}function nO(e,t,n,i){let r=[];for(let o of e.productionCallableDefinitions({files:[...t],requireFunctionLikeSymbol:!0})){if(!t.has(o.relativePath))continue;let s=n.get(o.relativePath)??o.relativePath,a=i(s);if(a.state==="unavailable")return{definitions:[],unavailable:a};(a.state==="absent"||!new RegExp(`\\b${He(o.leaf)}\\b`).test(a.content))&&r.push(o)}return{definitions:r}}function iO(e){return t=>{let n=e(t);return n===null?{state:"absent"}:{state:"present",content:n}}}function rO(e,t){return e.all(`SELECT DISTINCT ref_d.relative_path
359
+ FROM mentions m
360
+ JOIN chunks c ON m.chunk_id = c.id
361
+ JOIN documents ref_d ON c.document_id = ref_d.id
362
+ WHERE m.symbol_id = ?
363
+ AND m.role != 1
364
+ ${e.pathExclusionsFor("ref_d")}`,t).map(i=>i.relative_path)}import{execFileSync as oO}from"child_process";var KS=2e3,Fa=50,sO=64,aO=8,lO=3,cO=2160*60*60,uO=/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i,dO=3,mO=/#\d+|\b[A-Z][A-Z0-9]+-\d+\b/g,fO=/^([a-z][a-z0-9-]+)(?:\([^)]+\))?!?:/i;function pO(e){let t=Fe(e,{clearGroups:["whole-project"]});return(n,i,r)=>{let o=r??Uu(n.config.projectRoot);if(!o)return null;let s=t.has(n)?t.get(n,()=>({head:"",value:null})):null;return s&&s.head===o?s.value:(t.invalidate(n),t.get(n,()=>({head:o,value:i(n.config.projectRoot,o)})).value)}}function Ma(e){let t=Fe(e,{clearGroups:["whole-project"]});return(n,i,r,o)=>{let s=o??Uu(n.config.projectRoot);if(!s)return null;let a=t.has(n)?t.get(n,()=>({head:"",values:new Map})):null;(!a||a.head!==s)&&t.invalidate(n);let l=t.get(n,()=>({head:s,values:new Map}));if(l.values.has(i))return l.values.get(i)??null;let c=r(n.config.projectRoot,s);return l.values.set(i,c),c}}var gO=Ma("git-commit-history");function Wt(e,t={}){let n=t.historyMode??"bounded",i=t.head;return{capability:r=>hO(e,r,i),commitHistory:()=>Eo(e,n,i),fileChurn:()=>SO(e,n,i),changeAmplification:()=>vO(e,n,i),trackedFiles:()=>xO(e,i),fileAddRecords:()=>EO(e,n,i),coChangePairs:(r={})=>FO(e,r,n,i),coChangePairsForFiles:(r,o={})=>VS(e,r,o,n,i),directionalCoChangePairsForFiles:(r,o={})=>MO(e,r,o,n,i)}}function Eo(e,t="bounded",n){return gO(e,dr(t),(i,r)=>yO(i,r,t),n)}function hO(e,t,n){let i=n??Uu(e.config.projectRoot);return i?{slot:t,available:!0,head:i}:{slot:t,available:!1,head:null,reason:"git history is unavailable for this project"}}function Uu(e){try{return dn(e,["rev-parse","HEAD"]).trim()||null}catch{return null}}function dn(e,t){return oO("git",["-C",e,...t],{encoding:"utf-8",maxBuffer:64*1024*1024,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"})}function yO(e,t,n){let i;try{i=dn(e,["log","--no-merges","--name-only",...Aa(n),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}return{head:t,...Ku(i,Fa)}}function bO(e){return uO.test(e.subject)}function SO(e,t,n){let i=Eo(e,t,n);if(!i)return null;let r=new Map;for(let o of i.commits){let s=bO(o);for(let a of o.files){let l=r.get(a)??{changes:0,fixChanges:0,lastChangedAt:0};l.changes+=1,s&&(l.fixChanges+=1),o.timestamp>l.lastChangedAt&&(l.lastChangedAt=o.timestamp),r.set(a,l)}}return r}function vO(e,t,n){let i=Eo(e,t,n);if(!i||i.commits.length===0)return null;let r=i.commits.map(o=>o.files.length).filter(o=>o>0).sort((o,s)=>o-s);return r.length===0?null:{medianFilesPerCommit:HS(r,.5),p90FilesPerCommit:HS(r,.9),commitsAnalyzed:r.length}}function HS(e,t){let n=Math.min(e.length-1,Math.floor(e.length*t));return e[n]}var CO=pO("git-tracked-files");function xO(e,t){return CO(e,n=>{try{let i=dn(n,["ls-files"]);return new Set(i.split(`
365
+ `).map(r=>r.trim()).filter(r=>r!==""))}catch{return null}},t)}var RO=Ma("git-file-adds"),US="__git__/file-adds",zS=vt({kind:"git-file-adds",invalidation:Je("git-file-adds"),serialize:IO,deserialize:LO});function qS(e){return Wt(e).fileAddRecords()}function EO(e,t,n){let i=dr(t);return RO(e,i,(r,o)=>wO(e,r,o,t),n)}function wO(e,t,n,i){let r=zS.read(e,GS(i),n);if(r)return r;let o=DO(t,i);return o&&zS.write(e,GS(i),n,o),o}function IO(e){return JSON.stringify([...e.entries()])}function LO(e){if(!e)return null;try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=new Map;for(let i of t){if(!Array.isArray(i)||i.length!==2||typeof i[0]!="string")return null;let r=i[1];if(!r||typeof r.commitsAgo!="number"||!Number.isFinite(r.commitsAgo)||typeof r.addedAt!="number"||!Number.isFinite(r.addedAt))return null;n.set(i[0],{commitsAgo:r.commitsAgo,addedAt:r.addedAt})}return n}catch{return null}}function DO(e,t){let n;try{n=dn(e,["log","--no-merges","--find-renames","--name-status",...Aa(t),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}let i=new Map,r=new Map,o=-1;for(let s of n.split("")){if(s.trim()==="")continue;o+=1;let a=s.indexOf(`
366
+ `),l=a>=0?s.slice(0,a):s,[,c]=l.split("\0"),u=Number(c)||0;if(!(a<0))for(let d of s.slice(a+1).split(`
367
+ `)){let m=PO(d);if(!m)continue;if(m.status==="R"&&m.from&&m.to){let p=r.get(m.to)??new Set([m.to]);r.set(m.from,p);continue}if(m.status!=="A"||!m.to)continue;let f={commitsAgo:o,addedAt:u};i.set(m.to,f);for(let p of r.get(m.to)??[])i.set(p,f)}}return i}function PO(e){let t=e.trim().split(" "),n=t[0]??"";if(!n)return null;let i=n[0]??"";if(i==="R"){let o=t[1],s=t[2];return o&&s?{status:i,from:o,to:s}:null}let r=t[1];return r?{status:i,to:r}:null}var WS=Ma("git-co-change-pairs"),TO=Ma("git-directional-co-change-pairs");function FO(e,t,n,i){let r=`all\0${dr(n)}\0${zu(t)}`,o=WS(e,r,()=>{let s=Eo(e,n,i);return s?Gu(s,t):null},i);return o&&[...o]}function VS(e,t,n,i,r){if(t.size===0)return[];let o=`files\0${dr(i)}\0${JS(t)}\0${zu(n)}`,s=WS(e,o,()=>{let a=Eo(e,i,r);return a?Gu(a,n,t):null},r);return s&&[...s]}function MO(e,t,n,i,r){if(t.size===0)return[];let o=n.maxFilesPerCommit??Fa;if(t.size>sO)return VS(e,t,n,i,r);let s=`directional\0${dr(i)}\0${JS(t)}\0${zu({...n,maxFilesPerCommit:o})}`,a=TO(e,s,(l,c)=>{let u=AO(l,c,t,o,i);return u?Gu(u,n,t):null},r);return a&&[...a]}function zu(e){let t=e.minTogether??4,n=e.minConfidence??.6,i=e.maxFilesPerCommit??Fa;return`${t}\0${n}\0${i}`}function JS(e){return[...e].sort().join("\0")}function Gu(e,t,n){let{minTogether:i=4,minConfidence:r=.6,maxFilesPerCommit:o=Fa}=t,s=new Map,a=new Map,l=e.newestAnalyzedAt??0;for(let d of e.commits){let m=[...new Set(d.files)].sort();if(m.length>o)continue;e.newestAnalyzedAt===void 0&&d.timestamp>l&&(l=d.timestamp);let f=_O(m),p=n===void 0||m.some(g=>n.has(g));for(let g of m)s.set(g,(s.get(g)??0)+1);if(p)for(let g=0;g<m.length;g++)for(let h=g+1;h<m.length;h++){if(n&&!n.has(m[g])&&!n.has(m[h]))continue;let S=`${m[g]}\0${m[h]}`,v=a.get(S)??{together:0,focusedTogether:0,broadTogether:0,lastTogetherAt:0,timestamps:[],subjects:[]};v.together+=1,f?v.broadTogether+=1:v.focusedTogether+=1,d.timestamp>v.lastTogetherAt&&(v.lastTogetherAt=d.timestamp),v.timestamps.push(d.timestamp),v.subjects.push(d.subject),a.set(S,v)}}let c=[],u=l-cO;for(let[d,m]of a){let f=m.together;if(f<i)continue;let[p,g]=d.split("\0"),h=s.get(p)??f,S=s.get(g)??f,v=Math.max(f/h,f/S);if(v<r)continue;let y=m.broadTogether/f,E=m.timestamps.filter(w=>w>=u).length;c.push({fileA:p,fileB:g,together:f,confidence:v,changesA:h,changesB:S,focusedTogether:m.focusedTogether,broadTogether:m.broadTogether,broadCommitRatio:y,lastTogetherAt:m.lastTogetherAt,recentTogether:E,commitScope:OO(m.broadTogether,f),recency:E>0?"recent":"stale",subjectContext:$O(m.subjects)})}return c.sort((d,m)=>m.together-d.together||m.confidence-d.confidence||d.fileA.localeCompare(m.fileA)),c}function AO(e,t,n,i,r){let o;try{o=NO(e,r)}catch{return null}if(o.length===0)return{head:t,commits:[],skippedBulkCommits:0,newestAnalyzedAt:0};let s;try{s=dn(e,["log","--no-merges","--format=%H",...Aa(r),"--",...[...n].sort()])}catch{return null}let a=new Set(o.map(m=>m.hash)),l=s.split(`
368
+ `).map(m=>m.trim()).filter(m=>m!==""&&a.has(m)),c=kO(e,o,i);if(l.length===0)return{head:t,commits:[],skippedBulkCommits:0,newestAnalyzedAt:c};let u;try{u=dn(e,["show","--no-walk=unsorted","--name-only","--pretty=format:%x01%H%x00%ct%x00%s",...l])}catch{return null}let d=Ku(u,i);return{head:t,...d,newestAnalyzedAt:c}}function NO(e,t){return dn(e,["log","--no-merges","--format=%H%x00%ct",...Aa(t)]).split(`
369
+ `).map(i=>i.trim()).filter(i=>i!=="").map(i=>{let[r,o]=i.split("\0");return{hash:r??"",timestamp:Number(o)||0}}).filter(i=>i.hash!=="")}function Aa(e){return e==="full"?[]:["-n",String(YS())]}function YS(){return ns(process.env.CODEBASEIQ_GIT_HISTORY_MAX_COMMITS)??KS}function dr(e){return e==="full"?"full":`bounded:${YS()}`}function GS(e){let t=dr(e);return t===`bounded:${KS}`?US:`${US}:${t}`}function kO(e,t,n){for(let r=0;r<t.length;r+=20){let o=t.slice(r,r+20),s;try{s=dn(e,["show","--no-walk=unsorted","--name-only","--pretty=format:%x01%H%x00%ct%x00%s",...o.map(l=>l.hash)])}catch{return t[0]?.timestamp??0}let a=Ku(s,n);if(a.commits.length>0)return a.commits[0].timestamp}return 0}function Ku(e,t){let n=[],i=0;for(let r of e.split("")){if(r.trim()==="")continue;let o=r.indexOf(`
370
+ `),s=o>=0?r.slice(0,o):r,[a,l,c]=s.split("\0");if(!a||!l)continue;let u=o>=0?r.slice(o+1).split(`
371
+ `).map(d=>d.trim()).filter(d=>d!==""):[];if(u.length>t){i+=1;continue}n.push({hash:a,timestamp:Number(l)||0,subject:c??"",files:u})}return{commits:n,skippedBulkCommits:i}}function _O(e){return e.length>=aO?!0:BO(e).size>=lO}function BO(e){let t=new Set;for(let n of e){let i=n.indexOf("/");t.add(i>=0?n.slice(0,i):".")}return t}function OO(e,t){return e===0?"focused":e/t>=.5?"broad-sweep":"mixed"}function $O(e){let t=new Set,n=[],i=[];for(let r of e){!i.includes(r)&&i.length<dO&&i.push(r);for(let o of jO(r))t.add(o);for(let o of r.match(mO)??[])n.includes(o)||n.push(o)}return{subjectLabels:[...t].sort(),issueRefs:n,sampleSubjects:i,externalIssueLabelStatus:"unavailable"}}function jO(e){let t=new Set,n=fO.exec(e)?.[1]?.toLowerCase();return n&&t.add(HO(n)),/\b(?:feat|feature)\b/i.test(e)&&t.add("feature"),/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i.test(e)&&t.add("fix"),/\b(?:docs?|documentation|guide|readme)\b/i.test(e)&&t.add("docs"),/\brefactor(?:ing|ed)?\b/i.test(e)&&t.add("refactor"),/\btests?\b/i.test(e)&&t.add("test"),/\b(?:release|version|v\d+\.\d+)\b/i.test(e)&&t.add("release"),/\bchore\b/i.test(e)&&t.add("chore"),/\bbuild\b/i.test(e)&&t.add("build"),/\bci\b/i.test(e)&&t.add("ci"),/\bperf(?:ormance)?\b/i.test(e)&&t.add("perf"),[...t]}function HO(e){return e==="feat"?"feature":e}var XS=/(?:^|\/)(?:package-lock\.json|pnpm-lock\.yaml|yarn\.lock|Cargo\.lock|uv\.lock|poetry\.lock|Pipfile\.lock|bun\.lockb?|\.SRCINFO|CHANGELOG(?:\.[a-z]+)?|.*\.(?:map|tsbuildinfo))$|(?:^|\/)(?:dist|build|out|node_modules|docs\/plans)\//i;function wo(e,t,n={}){let{minTogether:i=4,minConfidence:r=.6,limit:o=30,maxFilesPerCommit:s=20}=n,a=Wt(e,{historyMode:n.historyMode,...n.head?{head:n.head}:{}}),l=a.commitHistory(),c=t!==void 0,u=a.coChangePairs({minTogether:c?Math.min(i,2):i,minConfidence:c?0:r,maxFilesPerCommit:s});if(!l||!u)return{available:!1,commitsAnalyzed:0,findings:[]};let d=typeof n.scanLimit=="number"?u.slice(0,n.scanLimit):u,m=Be(e),f=nv(e),p=GO(e,m,f),g=n.includeLinked===!0||c,h=[];for(let S of d){if(XS.test(S.fileA)||XS.test(S.fileB)||!ZS(e,S.fileA)||!ZS(e,S.fileB)||c&&!S.fileA.includes(t)&&!S.fileB.includes(t)||!c&&(V(S.fileA)==="test"||V(S.fileB)==="test"||VO(S.fileA,S.fileB)||qO(S.fileA,S.fileB)))continue;let v=p(S.fileA,S.fileB);if(!g&&v)continue;let y=UO(S.fileA,S.fileB),E=zO(S,y,v);if(h.push({...S,structurallyLinked:v,partnerClass:y.partnerClass,partnerClassReasons:y.reasons,...E?{declaredCouplingSuggestion:E}:{}}),h.length>=o)break}return{available:!0,commitsAnalyzed:l.commits.length,findings:h}}function ZS(e,t){return Tt(e.config.projectRoot,t)}function UO(e,t){let n=ev(e),i=ev(t),r=[],o=l=>{r.includes(l)||r.push(l)},s=(l,c)=>n.tags.has(l)&&i.tags.has(c)||n.tags.has(c)&&i.tags.has(l);if(s("doc","code"))return o("one side is documentation and the other is executable source"),{partnerClass:"doc-code",reasons:r};if(n.tags.has("test")||i.tags.has("test"))return o("one side is classified as a test file"),{partnerClass:"test-code",reasons:r};if(s("schema","script"))return o("schema or contract file changes with a script or generated-code path"),{partnerClass:"schema-script",reasons:r};if(s("model","view"))return o("model or state path changes with a view or component path"),{partnerClass:"model-view",reasons:r};if(s("config","code"))return o("configuration file changes with executable source"),{partnerClass:"config-code",reasons:r};let a=o$(n.tokens,i.tokens).filter(l=>!i$.has(l));return tv(e,t)||a.length>=2?(o(tv(e,t)?"both files live in the same directory":`files share feature tokens: ${a.slice(0,4).join(", ")}`),{partnerClass:"same-feature",reasons:r}):(o("no specific relationship pattern matched"),{partnerClass:"unknown",reasons:r})}function zO(e,t,n){if(n||e.together<4||e.confidence<.75||e.commitScope==="broad-sweep"||e.recency==="stale"||!n$.has(t.partnerClass))return;let i=[e.fileA,e.fileB].sort();return{name:`co-change ${t.partnerClass}: ${s$(i)}`,files:i,reason:`${t.partnerClass} pair changed together ${e.together}x with ${Math.round(e.confidence*100)}% confidence; declare it if future edits should require both sides.`}}function GO(e,t=Be(e),n=nv(e)){return(i,r)=>JO(t,n,i,r)}var KO=/(?:^|\/)(?:locales|i18n)\//i;function QS(e){return KO.test(e)}function qO(e,t){return QS(e)&&QS(t)?!0:WO(e,t)}function WO(e,t){if(!e.endsWith(".json")||!t.endsWith(".json"))return!1;let n=e.lastIndexOf("/"),i=t.lastIndexOf("/");if(n<0||i<0)return!1;let r=e.slice(0,n),o=t.slice(0,i);if(r===o)return!1;let s=e.slice(n+1),a=t.slice(i+1);if(s!==a)return!1;let l=r.lastIndexOf("/"),c=o.lastIndexOf("/"),u=l>=0?r.slice(0,l):"",d=c>=0?o.slice(0,c):"";return u===d}function VO(e,t){let n=e.lastIndexOf("/"),i=t.lastIndexOf("/");if(e.slice(0,n)!==t.slice(0,i))return!1;let r=e.slice(n+1).split(".")[0],o=t.slice(i+1).split(".")[0];return r!==""&&r===o}function nv(e){return(e.config.declaredCouplings??[]).filter(t=>Array.isArray(t.files)&&t.files.length>=2).map(t=>new Set(t.files))}function JO(e,t,n,i){return e.get(n)?.has(i)===!0||e.get(i)?.has(n)===!0?!0:t.some(r=>r.has(n)&&r.has(i))}var YO=/(?:^|\/)(?:readme|docs?|guides?|adr|architecture|design)(?:\/|$)|\.(?:md|mdx|rst|adoc|txt)$/i,XO=/(?:^|\/)(?:\.[a-z0-9-]+rc|config|configs|settings|\.github)(?:\/|$)|(?:^|\/)(?:package\.json|tsconfig(?:\.[^.]+)?\.json|vite\.config\.[cm]?[jt]s|rollup\.config\.[cm]?[jt]s|eslint\.config\.[cm]?[jt]s)$|\.(?:json|ya?ml|toml|ini|env)$/i,ZO=/(?:^|\/)(?:schemas?|contracts?|migrations?|models?|types?)(?:\/|$)|(?:^|\/)[^/]*(?:schema|contract|migration|model|types?)[^/]*|(?:\.schema)?\.(?:graphql|gql|proto|prisma)$/i,QO=/(?:^|\/)(?:scripts?|bin|tools?|tasks?|generators?|codegen|migrations?|seeds?)(?:\/|$)|(?:^|\/)[^/]*(?:generate|codegen|migrate|seed|script)[^/]*\.[cm]?[jt]s$/i,e$=/(?:^|\/)(?:models?|entities|domain|state|stores?|reducers?)(?:\/|$)|(?:^|\/)[^/]*(?:model|entity|state|store|reducer|viewmodel)[^/]*\.[^.]+$/i,t$=/(?:^|\/)(?:views?|pages?|components?|screens?|routes?|templates?)(?:\/|$)|(?:^|\/)[^/]*(?:view|page|component|screen|template)[^/]*\.[^.]+$|\.(?:vue|svelte|tsx|jsx)$/i,n$=new Set(["doc-code","config-code","schema-script","model-view","test-code"]),i$=new Set(["src","lib","app","apps","packages","frontend","backend","examples","python","typescript","javascript","test","tests","spec","index","main","utils","util","types","type","config","docs","doc","package","requirements","ts","tsx","js","jsx","mjs","cjs","vue","py","md","mdx","json","yaml","yml","toml","txt"]);function ev(e){let t=e.replace(/\\/g,"/"),n=new Set;return YO.test(t)&&n.add("doc"),XO.test(t)&&n.add("config"),ZO.test(t)&&n.add("schema"),QO.test(t)&&n.add("script"),e$.test(t)&&n.add("model"),t$.test(t)&&n.add("view"),V(t)==="test"&&n.add("test"),!n.has("doc")&&!n.has("config")&&n.add("code"),{tags:n,tokens:r$(t)}}function tv(e,t){let n=e.lastIndexOf("/"),i=t.lastIndexOf("/"),r=n>=0?e.slice(0,n):"",o=i>=0?t.slice(0,i):"";return r!==""&&r===o}function r$(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).map(t=>t.toLowerCase()).filter(t=>t.length>=2)}function o$(e,t){let n=new Set(t);return[...new Set(e.filter(i=>n.has(i)))].sort()}function s$(e){return e.map(t=>t.split("/").pop()?.replace(/\.[^.]+$/,"")||t).join(" + ")}function _a(e,t){let n=a$(e,t)??l$(e,t)??c$(e,t)??u$(e,t);return d$(e,n,t)}function a$(e,t){let n=-1,i=null;for(let r=0;r<=t;r+=1){let o=qu(e[r]??"");o&&(i===null?(i=o,n=r):o===i&&(i=null,n=-1))}if(i===null||n<0)return null;for(let r=t+1;r<e.length;r+=1)if(qu(e[r]??"")===i)return{start:n,end:r+1};return{start:n,end:e.length}}function qu(e){let t=e.match(/^\s*(```+|~~~+)/);return t?t[1].startsWith("`")?"`":"~":null}function l$(e,t){if(!Na(e[t]??""))return null;let n=t;for(;n>0&&Na(e[n-1]??"");)n-=1;let i=t+1;for(;i<e.length&&Na(e[i]??"");)i+=1;return{start:n,end:i}}function Na(e){let t=e.trim();return t.startsWith("|")&&t.endsWith("|")&&t.includes("|")}function c$(e,t){let n=t;for(;n>=0;){let o=e[n]??"";if(ka(o)!==null)break;if(Wu(o)!==null)return null;n-=1}if(n<0)return null;let i=ka(e[n]??"");if(i===null)return null;let r=n+1;for(;r<e.length;){let o=e[r]??"",s=ka(o);if(s!==null){if(s<=i)break;r+=1;continue}if(Wu(o)!==null)break;r+=1}return{start:n,end:r}}function ka(e){let t=e.match(/^(\s*)(?:[-*+]\s+|\d+[.)]\s+)/);return t?t[1].length:null}function u$(e,t){let n=e[t]??"";if(rv(n)||n.trim().length===0)return{start:t,end:t+1};let i=t;for(;i>0&&iv(e[i-1]??"");)i-=1;let r=t+1;for(;r<e.length&&iv(e[r]??"");)r+=1;return{start:i,end:r}}function iv(e){return Wu(e)===null}function Wu(e){return e.trim().length===0?"blank":rv(e)?"heading":qu(e)?"fence":Na(e)?"table":ka(e)!==null?"list":null}function rv(e){return/^#{1,6}\s+/.test(e.trim())}function d$(e,t,n){let{start:i,end:r}=t;if(r-i>40){let s=Math.floor(20);i=Math.max(i,n-s),r=Math.min(r,i+40),i=Math.max(t.start,r-40)}let o=e.slice(i,r).join(`
372
+ `).trim();return o.length<=2e3?o:`${o.slice(0,2e3).trimEnd()}...`}function Li(e,t){return t.filter(n=>e.includes(n))}var m$=/<!--\s*codebaseiq:\s*snapshot\s*-->/i;function ov(e,t){if((e.config.docs?.snapshotPaths??[]).some(r=>Jn(r,t)))return!0;let i=se(e,t);return i.length>0&&m$.test(i)}var sv={classifyCitation:p$,citationContexts:g$,citationKindLabel:y$,citationRemediation:b$,referenceTargets:S$,hasLineAnchoredCitation:f$};function f$(e){return e.some(t=>(t.lineReferences?.length??0)>0)}function p$(e){let t=e.join(`
373
+ `).toLowerCase(),n=[],i=Li(t,[".codebaseiq","declaredcouplings","suppression","suppressions","config","configuration","json"]);if(i.length>0)return n.push(`configuration/example terms near citation: ${i.join(", ")}`),{citationKind:"configuration-example",actionTier:"support",reasons:n};let r=Li(t,["accepted","intentional","intentionally","retained","historical"]);if(r.length>0)return n.push(`intentional-record terms near citation: ${r.join(", ")}`),{citationKind:"intentional-record",actionTier:"support",reasons:n};let o=Li(t,["command","cli","usage","example","run","workflow"]);return o.length>0?(n.push(`guide/reference terms near citation: ${o.join(", ")}`),{citationKind:"guide-reference",actionTier:"signal",reasons:n}):(n.push(e.length>0?"citation appears in prose without config or guide markers":"citation context unavailable"),{citationKind:"behavioral-claim",actionTier:"direct",reasons:n})}function g$(e,t,n){let i=se(e,t);if(!i&&!Tt(e.config.projectRoot,t))return[];let r=i.split(/\r?\n/),o=n.flatMap(h$),s=[];for(let a=0;a<r.length;a+=1){let l=r[a]??"";o.some(c=>l.includes(c))&&s.push(_a(r,a))}return s}function h$(e){let t=e.split("/");return[e,`./${e}`,t.slice(-3).join("/"),t.slice(-2).join("/")].filter((n,i,r)=>n.length>0&&r.indexOf(n)===i)}function y$(e){switch(e){case"behavioral-claim":return"a behavioral doc claim";case"configuration-example":return"a configuration example";case"guide-reference":return"a guide reference";case"intentional-record":return"an intentional record"}}function b$(e,t){switch(e){case"behavioral-claim":return`Re-read ${t} and update the behavioral claim or citation.`;case"configuration-example":return`Verify the configuration example in ${t} still points at the intended file; update only if the example target changed.`;case"guide-reference":return`Verify the guide reference in ${t} still sends readers to the right implementation or command surface.`;case"intentional-record":return`Verify the intentional citation in ${t} is still meant to name this file.`}}function S$(e,t,n){let i=Da(n),r=new Set;for(let o of t)v$(e,o,i.get(o)??[])&&r.add(o);return r}function v$(e,t,n){if(!C$.test(t)||!Tt(e.config.projectRoot,t))return!0;if(n.length===0)return!1;let i=nt(e.config.projectRoot,t,{inputKind:"changed source file"}).split(/\r?\n/),r=x$(i);for(let o of n)for(let s=o.startLine;s<=o.endLine;s+=1)if((i[s]??"").trim()!==""&&!r.has(s))return!0;return!1}var C$=/\.(?:[cm]?[jt]sx?)$/i;function x$(e){let t=new Set,n=!1;for(let i=0;i<e.length;i+=1){let r=e[i].trim();!n&&R$(r)&&(n=!0),n&&(t.add(i),r.endsWith(";")&&(n=!1))}return t}function R$(e){return/^import(?:\s|$)/.test(e)||/^export(?:\s+type)?\s+(?:\*|\{)/.test(e)}var av=vt({kind:"doc-path-evidence",invalidation:Je("doc-path-evidence"),serialize:B$,deserialize:O$}),Io=/\.(?:md|mdx|rst|txt)$/i;function E$(e){return/(?:^|\/)(?:docs\/plans|plans|adrs?|rfcs?|decisions|changelogs?|archive|reports?)\//i.test(e)||/(?:^|\/)CHANGELOG\.(?:md|mdx|rst|txt)$/i.test(e)}var w$=3,I$=/([A-Za-z0-9_@-]+(?:\/[A-Za-z0-9_.@-]+)+\.[A-Za-z0-9]{1,6})(?::([1-9][0-9]*))?\b/g;function L$(e,t={}){let{doc:n,limit:i=20,minCoupling:r=w$,includeSnapshotExcluded:o=!1}=t,s=F$(e,t.historyMode??"bounded");if(!s)return{available:!1,commitsAnalyzed:0,docsScanned:0,findings:[]};let a=[];for(let l of s.docFiles){if(n!==void 0&&!l.includes(n)||n===void 0&&!M$(e,l)||n!==void 0&&!Tt(e.config.projectRoot,l))continue;let c=ov(e,l);if(c&&!o)continue;let{value:u,estimated:d}=D$(e,l,s.changeTimes.get(l)),m=P$(e,l),f=new Map,{resolved:p,broken:g,citations:h}=N$(e,l,s.tracked,s.trackedBySuffix,s.everSeenInHistory),S=new Map(h.map(y=>[y.file,y]));for(let y of p){if(y===l||Io.test(y))continue;let E=(s.changeTimes.get(y)??[]).filter(b=>b>u).length;if(E===0)continue;let w=S.get(y);f.set(y,{file:y,evidence:"reference",coChanges:0,changesSinceDocUpdate:E,...Vu("reference",m,w?.contexts),citationContexts:w?.contexts,citedLines:w?.lineReferences})}for(let[y,E]of s.coupling.get(l)??[]){if(E<r||!s.tracked.has(y))continue;let w=(s.changeTimes.get(y)??[]).filter(R=>R>u).length;if(w===0)continue;let b=f.get(y);b?(b.evidence="both",b.coChanges=E,Object.assign(b,Vu("both",m,b.citationContexts))):f.set(y,{file:y,evidence:"co-change",coChanges:E,changesSinceDocUpdate:w,...Vu("co-change",m)})}if(f.size===0&&g.length===0)continue;let v=[...f.values()].sort((y,E)=>E.changesSinceDocUpdate-y.changesSinceDocUpdate);a.push({doc:l,docLastChangedAt:u,staleness:v.reduce((y,E)=>y+E.changesSinceDocUpdate,0)+g.length*10,subjects:v.slice(0,8),brokenReferences:g,...c?{snapshotExcluded:!0}:{},...d?{docLastChangedAtEstimated:!0}:{}})}return a.sort((l,c)=>c.staleness-l.staleness),{available:!0,commitsAnalyzed:s.historyCommitCount,docsScanned:s.docFiles.length,findings:a.slice(0,i)}}function D$(e,t,n){if(n&&n.length>0)return{value:Math.max(...n),estimated:!1};try{return{value:Math.floor(Wd(e.config.projectRoot,t).mtimeMs/1e3),estimated:!0}}catch(i){if(Tt(e.config.projectRoot,t))throw i;return{value:0,estimated:!1}}}function P$(e,t){let n=se(e,t).slice(0,6e3);if(!n)return{docIntent:"unknown",reasons:["doc text unavailable"]};let i=`${t}
374
+ ${n}`.toLowerCase(),r=Li(i,["historical note","historical record","history note","retrospective","postmortem","post-mortem","archived","archive","previously","legacy","recorded","record of","snapshot","as of","migration note","decision record"]);if(r.length>0)return{docIntent:"historical-note",reasons:[`historical-note terms: ${r.join(", ")}`]};let o=Li(i,["current","standard","standards","must","should","policy","guide","guidance","workflow","contract","invariant","source of truth"]);return o.length>0?{docIntent:"current-guidance",reasons:[`current-guidance terms: ${o.join(", ")}`]}:{docIntent:"unknown",reasons:["no current-guidance or historical-note markers found"]}}function Vu(e,t,n=[]){let i=e==="co-change"||n.length===0?null:sv.classifyCitation(n);return{actionTier:T$(e,t.docIntent,i?.actionTier),docIntent:t.docIntent,docIntentReasons:t.reasons,...i?{citationKind:i.citationKind,citationKindReasons:i.reasons}:{}}}function T$(e,t,n){return t==="historical-note"?"support":n||(e==="co-change"?"signal":"direct")}function F$(e,t){let n=Wt(e,{historyMode:t}),i=n.commitHistory();if(!i)return null;let r=n.trackedFiles()??new Set,o=new Map,s=new Map,a=new Set;for(let l of i.commits){let c=[...new Set(l.files)],u=c.filter(m=>Io.test(m)),d=c.filter(m=>!Io.test(m));for(let m of c){a.add(m);let f=o.get(m)??[];f.push(l.timestamp),o.set(m,f)}for(let m of u){let f=s.get(m);f||(f=new Map,s.set(m,f));for(let p of d)f.set(p,(f.get(p)??0)+1)}}return{changeTimes:o,coupling:s,docFiles:[...r].filter(l=>Io.test(l)),everSeenInHistory:a,historyCommitCount:i.commits.length,tracked:r,trackedBySuffix:A$(r)}}function M$(e,t){return Io.test(t)&&!E$(t)&&Tt(e.config.projectRoot,t)}function A$(e){let t=new Map;for(let n of e){let i=n.split("/");for(let r of[2,3]){if(i.length<r)continue;let o=i.slice(-r).join("/"),s=t.get(o)??[];s.push(n),t.set(o,s)}}return t}function N$(e,t,n,i,r){let o=new Set,s=new Set,a=k$(e,t);if(!a)return{resolved:o,broken:[],citations:[]};let l=a.candidates,c=a.contextsByCandidate,u=a.lineReferencesByCandidate,d=new Map,m=new Map,f=(p,g)=>{let h=c.get(g);if(h&&h.length>0){let v=d.get(p)??[];v.push(...h),d.set(p,lv(v).slice(0,3))}let S=u.get(g);S&&S.length>0&&m.set(p,Ju([...m.get(p)??[],...S]))};for(let p of l){if(n.has(p)){o.add(p),f(p,p);continue}let g=i.get(p);if(g&&g.length===1){o.add(g[0]),f(g[0],p);continue}g&&g.length>1||r.has(p)&&s.add(p)}return{resolved:o,broken:[...s],citations:[...d].map(([p,g])=>({file:p,contexts:g,lineReferences:m.get(p)}))}}function k$(e,t,n){let i=n;if(i===void 0&&(i=se(e,t),!i&&!Tt(e.config.projectRoot,t)))return null;let r=Ft(e,t,i),o=av.read(e,t,r);if(o)return o;let s=_$(i);return av.write(e,t,r,s),s}function _$(e){let t=e.split(/\r?\n/),n=new Set,i=new Map,r=new Map;for(let o=0;o<t.length;o+=1){let s=t[o]??"";for(let a of s.matchAll(I$)){let l=(a[1]??"").replace(/^\.?\//,"");if(l.length===0)continue;n.add(l);let c=a[2]?Number(a[2]):null;c!==null&&Number.isSafeInteger(c)&&r.set(l,Ju([...r.get(l)??[],c]));let u=_a(t,o);if(u.length===0)continue;let d=i.get(l)??[];d.push(u),i.set(l,lv(d).slice(0,3))}}return{candidates:[...n],contextsByCandidate:i,lineReferencesByCandidate:r}}function B$(e){let t={candidates:e.candidates,contextsByCandidate:[...e.contextsByCandidate.entries()],lineReferencesByCandidate:[...e.lineReferencesByCandidate.entries()]};return JSON.stringify(t)}function O$(e){try{let t=JSON.parse(e);if(!tm(t))return null;let n=ml(t.candidates),i=j$(t.contextsByCandidate),r=$$(t.lineReferencesByCandidate);return!n||!i?null:{candidates:n,contextsByCandidate:new Map(i),lineReferencesByCandidate:new Map(r??[])}}catch{return null}}function $$(e){if(e===void 0)return[];if(!Array.isArray(e))return null;let t=[];for(let n of e){if(!Array.isArray(n)||n.length!==2||typeof n[0]!="string"||!Array.isArray(n[1]))return null;let i=[];for(let r of n[1]){if(typeof r!="number"||!Number.isSafeInteger(r))return null;i.push(r)}t.push([n[0],Ju(i)])}return t}function j$(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(!Array.isArray(n)||n.length!==2||typeof n[0]!="string")return null;let i=ml(n[1]);if(!i)return null;t.push([n[0],i])}return t}function lv(e){let t=[];for(let n of new Set(e))t.some(i=>H$(i,n))||t.push(n);return t}function Ju(e){return[...new Set(e)].sort((t,n)=>t-n)}function H$(e,t){if(e===t)return!0;let n=e.split(/\r?\n/).map(a=>a.trim()).filter(a=>a.length>0),i=t.split(/\r?\n/).map(a=>a.trim()).filter(a=>a.length>0),r=Math.min(n.length,i.length);if(r===0)return!1;if(r<3)return e.includes(t)||t.includes(e);let o=new Set(i),s=n.filter(a=>o.has(a)).length;return s>=3&&s/r>=.6}import{createHash as U$}from"crypto";var z$=3;function Lo(e,t={}){let{scope:n,maxLoc:i=15,minLoc:r=z$,limit:o,scanLimit:s}=t,a=qS(e),l=G$(e,{scope:n,maxLoc:i,scanLimit:s}).map(u=>K$(e,u,a,r)).filter(u=>u!==null),c=dv(l);return o?c.slice(0,o):c}function uv(e){let t=mn(e);return hn(t).replace(/\s+/g,"")}function dv(e){let t=new Map;for(let i of e){if(i.normalizedBody.length<8)continue;let r=W$(i.normalizedBody),o=t.get(r)??[];o.push(i),t.set(r,o)}let n=[];for(let[i,r]of t){let o=new Set(r.map(a=>a.file));if(r.length<2||o.size<2)continue;let s=[...r].sort(V$).map(({normalizedBody:a,...l})=>l);n.push({hash:i,canonical:s[0],functions:s})}return n.sort((i,r)=>{let o=r.functions.length-i.functions.length;if(o!==0)return o;let s=cv(r)-cv(i);return s!==0?s:i.canonical.file.localeCompare(r.canonical.file)}),n}function G$(e,t){let n=ze(e,{scope:t.scope}).filter(i=>i.isFunctionLike&&!e.isIgnored(i.relativePath)).filter(i=>!Ko(e,i.relativePath,i.startLine,"similar")).filter(i=>de(i)<=t.maxLoc);return n.sort((i,r)=>de(r)-de(i)||i.relativePath.localeCompare(r.relativePath)),Ae(n,t.scanLimit)}function K$(e,t,n,i){let r=Vt(e,t);if(!r||q$(r)<i)return null;let o=Yu(e,t);return o?{symbol:t.symbol,shortName:k(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:de(t),ageCommits:n?.get(t.relativePath)?.commitsAgo??null,normalizedBody:o}:null}function Yu(e,t){let n=Vt(e,t);return n&&uv(n)||null}function Vt(e,t){let n=ie(e,t.relativePath);return n.length===0?null:n.slice(t.startLine,t.endLine+1).join(`
375
+ `)}function mn(e){let t=e.indexOf("{"),n=e.lastIndexOf("}");if(t>=0&&n>t)return e.slice(t+1,n);let i=e.indexOf("=>");return i>=0?e.slice(i+2).replace(/;+\s*$/,""):e}function q$(e){return mn(e).split(/\r?\n/).map(n=>n.trim()).filter(n=>n.length>0).length}function W$(e){return U$("sha256").update(e).digest("hex").slice(0,16)}function V$(e,t){let n=e.ageCommits??-1;return(t.ageCommits??-1)-n||e.file.localeCompare(t.file)||e.startLine-t.startLine}function cv(e){return e.functions.reduce((t,n)=>t+n.loc,0)}var J$=new Set(Zt());function Y$(e,t={}){let{includeHomonyms:n=!1,limit:i}=t,r=Ba(e,t).filter(o=>o.relationship==="divergent"||n&&o.relationship==="homonym");return i?r.slice(0,i):r}function Ba(e,t={}){let{scope:n,minSimilarity:i=.3,scanLimit:r}=t,o=Q$(e,{scope:n,scanLimit:r});return pv(o,{minSimilarity:i,isDelegatePair:C1(e)}).filter(s=>!s.members.some(a=>Ko(e,a.file,a.startLine,"twin")))}function pv(e,t={}){let n=t.minSimilarity??.3,i=t.isDelegatePair,r=e.filter(c=>!Cv(c.leaf)&&!u1(c.leaf)&&V(c.file)!=="test"&&!at(c.symbol)&&!hv(c.symbol)&&!yv(c.symbol,c.leaf)),{recordsByLeaf:o,recordOrder:s}=$("twin-drift.group-by-leaf",()=>X$(r),()=>({records:r.length})),a=$("twin-drift.cluster-leaf-names",()=>gv([...o.keys()]),()=>({leaves:o.size}));return $("twin-drift.compare-clusters",()=>{let c=[];for(let u of a){let d=Z$(u,o,s);if(d.length<2||new Set(d.map(v=>v.file)).size<2)continue;let m=null,f=!1,p=!1,g=new Set;for(let v=0;v<d.length;v+=1)for(let y=v+1;y<d.length;y+=1){let E=d[v],w=d[y];if(E.file===w.file||!p1(E,w)||i?.(E,w,d)||i?.(w,E,d))continue;if(f=!0,g.add(E.symbol),g.add(w.symbol),E.normalizedBody===w.normalizedBody){p=!0;continue}let b=s1(E.tokens,w.tokens);(!m||b>m.similarity)&&(m={a:E,b:w,similarity:b})}if(!f)continue;let h=d.filter(v=>g.has(v.symbol)).sort((v,y)=>v.file.localeCompare(y.file)||v.startLine-y.startLine).map(o1);if(!m){c.push({leaf:fv(u),relationship:p?"identical":"homonym",maxDivergence:0,members:h});continue}let S=m.similarity>=n?"divergent":"homonym";c.push({leaf:fv(u),relationship:S,maxDivergence:Math.round((1-m.similarity)*1e3)/1e3,members:h,...S==="divergent"?{firstDivergentTokens:a1(m.a.tokens,m.b.tokens)}:{}})}return c},()=>({clusters:a.length,records:r.length})).sort((c,u)=>u.members.length-c.members.length||u.maxDivergence-c.maxDivergence||c.leaf.localeCompare(u.leaf))}function X$(e){let t=new Map,n=new Map;for(let[i,r]of e.entries()){let o=t.get(r.leaf)??[];o.push(r),t.set(r.leaf,o),n.set(r,i)}return{recordsByLeaf:t,recordOrder:n}}function Z$(e,t,n){let i=[...e].flatMap(r=>t.get(r)??[]);return e.size>1&&i.sort((r,o)=>(n.get(r)??0)-(n.get(o)??0)),i}function Q$(e,t){let n=$("twin-drift.load-definitions",()=>ze(e,{scope:t.scope}).filter(o=>e1(o)&&!e.isIgnored(o.relativePath)).filter(o=>!Ki(o.relativePath)));$("twin-drift.sort-definitions",()=>n.sort((o,s)=>o.relativePath.localeCompare(s.relativePath)||o.startLine-s.startLine),()=>({definitions:n.length}));let i=Ae(n,t.scanLimit),r=$("twin-drift.select-candidates",()=>t1(i),()=>({scanned:i.length}));return $("twin-drift.build-records",()=>{let o=[];for(let s of r){let a=n1(e,s);a&&o.push(a)}return o},()=>({candidates:r.length,scanned:i.length}))}function e1(e){return e.isFunctionLike?e.symbol.startsWith("rust-analyzer ")?typeof e.kind=="number"&&J$.has(e.kind):!0:!1}function t1(e){let t=e.filter(o=>o.leaf&&!Cv(o.leaf)&&!at(o.symbol)&&!hv(o.symbol)&&!yv(o.symbol,o.leaf)),n=new Map;for(let o of t){let s=n.get(o.leaf)??[];s.push(o),n.set(o.leaf,s)}let i=gv([...n.keys()]),r=new Set;for(let o of i){let s=[...o].flatMap(a=>n.get(a)??[]);if(!(s.length<2)&&!(new Set(s.map(a=>a.relativePath)).size<2)&&!s.every(a=>V(a.relativePath)==="test"))for(let a of s)r.add(a)}return e.filter(o=>r.has(o))}function n1(e,t){if(!t.leaf)return null;let n=Vt(e,t);if(!n||!it(t.symbol)&&!i1(n,t.leaf))return null;let i=hn(mn(n)),r=i.replace(/\s+/g,"");if(!r||r.length<8)return null;let o=i.match(r1)??[];return o.length===0?null:{leaf:t.leaf,symbol:t.symbol,shortName:k(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:de(t),normalizedBody:r,tokens:o,isThinForwarder:Sv(i)}}function i1(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`\\b(?:const|let|var)\\s+${n}(?:\\s*:[^=]+)?\\s*=\\s*(?:async\\s*)?(?:\\([^)]*\\)|[A-Za-z_$][\\w$]*)\\s*=>`,"s").test(e)}var r1=/[A-Za-z_$][A-Za-z0-9_$]*|\d+(?:\.\d+)?|[^\sA-Za-z0-9_$]/g;function o1(e){return{symbol:e.symbol,shortName:e.shortName,file:e.file,startLine:e.startLine,endLine:e.endLine,loc:e.loc}}function s1(e,t){let n=new Set(e),i=new Set(t);if(n.size===0&&i.size===0)return 1;if(n.size===0||i.size===0)return 0;let r=0;for(let s of n)i.has(s)&&(r+=1);let o=n.size+i.size-r;return o===0?0:r/o}function a1(e,t){let n=Math.min(e.length,t.length),i=0;for(;i<n&&e[i]===t[i];)i+=1;let r=e.slice(i,i+6).join(" "),o=t.slice(i,i+6).join(" ");return!r&&!o?"(bodies differ only in trailing length)":`A: ${r||"(end)"} | B: ${o||"(end)"}`}function gv(e){let t=new Map;for(let s of e)t.set(s,s);let n=s=>{let a=s;for(;t.get(a)!==a;)a=t.get(a);let l=s;for(;t.get(l)!==a;){let c=t.get(l);t.set(l,a),l=c}return a},i=(s,a)=>{let l=n(s),c=n(a);l!==c&&t.set(l,c)},r=new Map;for(let s of e){let a=s.slice(0,2).toLowerCase(),l=r.get(a)??[];l.push(s),r.set(a,l)}for(let s of r.values())for(let a=0;a<s.length;a+=1)for(let l=a+1;l<s.length;l+=1)l1(s[a],s[l])&&i(s[a],s[l]);let o=new Map;for(let s of e){let a=n(s),l=o.get(a)??new Set;l.add(s),o.set(a,l)}return[...o.values()]}function l1(e,t){return e===t||e.toLowerCase()===t.toLowerCase()?!0:e.length<8||t.length<8||Math.abs(e.length-t.length)>2||c1(e.toLowerCase(),t.toLowerCase())/Math.max(e.length,t.length)<.8?!1:g1(e.toLowerCase(),t.toLowerCase(),2)}function c1(e,t){let n=Math.min(e.length,t.length),i=0;for(;i<n&&e[i]===t[i];)i+=1;return i}function u1(e){return/^[A-Z][A-Z0-9_]*$/.test(e)||/^__[^_].*__$/.test(e)||d1.has(e.toLowerCase())}var d1=new Set(["main","row"]),m1=new Set(["app","component","components","feature","features","impl","index","lib","route","routes","shared","src","tsx","typescript","ui"]);function hv(e){return e.startsWith("rust-analyzer ")&&/\/(?:tests?|benches?)\//.test(e)}var f1=new Set(["default","new","reset"]);function yv(e,t){return e.startsWith("rust-analyzer ")&&f1.has(t.toLowerCase())}function p1(e,t){if(e.leaf.toLowerCase()!==t.leaf.toLowerCase()||e.leaf.length>4)return!0;let n=mv(e);return[...mv(t)].some(i=>n.has(i))}function mv(e){let t=e.leaf.toLowerCase();return new Set(`${e.file}/${e.shortName}`.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(n=>n.length>2&&n!==t&&!m1.has(n)))}function g1(e,t,n){if(Math.abs(e.length-t.length)>n)return!1;let i=Array.from({length:t.length+1},(r,o)=>o);for(let r=1;r<=e.length;r+=1){let o=[r],s=o[0];for(let a=1;a<=t.length;a+=1){let l=e[r-1]===t[a-1]?0:1,c=Math.min(i[a]+1,o[a-1]+1,i[a-1]+l);o.push(c),s=Math.min(s,c)}if(s>n)return!1;i=o}return i[t.length]<=n}function bv(e){return Sv(hn(mn(e)))}function Sv(e){let t=e.trim();if(!t||h1.test(t))return!1;let n=S1(t);return n.length===0||n.length>2?!1:b1(n[n.length-1])}var h1=/\b(?:if|else|for|while|switch|try|catch|do)\b/,y1=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\[[^[\]]*\])*\((?:[^()]|\([^()]*\))*\)$/;function b1(e){let t=e.trim().replace(/^return\s+/,"").replace(/^await\s+/,"").replace(/;\s*$/,"").trim();return y1.test(t)}function S1(e){let t=[],n=0,i="";for(let r of e){if(r==="("||r==="["||r==="{"?n+=1:(r===")"||r==="]"||r==="}")&&(n=Math.max(0,n-1)),r===";"&&n===0){t.push(i),i="";continue}i+=r}return i.trim()&&t.push(i),t.map(r=>r.trim()).filter(r=>r.length>0)}var v1=3;function C1(e){let t=new Map;return(n,i,r)=>{if(!n.isThinForwarder)return!1;let o=`${n.symbol}\0${i.symbol}`,s=t.get(o);if(s!==void 0)return s;let a=vv(e,n,i,r,v1,new Set);return t.set(o,a),a}}function vv(e,t,n,i,r,o){if(r<=0||o.has(t.symbol)||(o.add(t.symbol),(Jt(e,t.file)??[]).filter(l=>l.line>=t.startLine&&l.line<=t.endLine&&l.calleeLeaf===n.leaf).length===0))return!1;let a=new Set(Ce(e,t.file).filter(l=>l.sourcePath&&(l.kind!=="namespace"||l.usedMembers.includes(n.leaf))).map(l=>l.sourcePath));if([...a].some(l=>Pt(l,n.file)))return!0;for(let l of i)if(!(l.symbol===t.symbol||l.symbol===n.symbol||!l.isThinForwarder)&&[...a].some(c=>Pt(c,l.file))&&vv(e,l,n,i,r-1,o))return!0;return!1}function Cv(e){return e.startsWith("<")&&e.endsWith(">")}function fv(e){return[...e].sort()[0]}import{dirname as _1,isAbsolute as B1,relative as O1,resolve as $1}from"path";import{basename as xv,extname as Rv}from"path";function Oa(e,t,n,i,r,o){let s=new Set;R1(e,t,n,i)&&s.add(r);for(let a of o)a.value&&x1(s,a.label,a.value);return[...s].slice(0,6)}function x1(e,t,n){let i=E1(n);t.endsWith("name")&&w1(i)&&e.add(`${t} has type-guard boundary shape`);for(let r of i){let o=I1.get(r);o&&e.add(`${t} has ${o} term: ${r}`)}}function R1(e,t,n,i){if(n<=0)return!1;let r=ie(e,t);if(r.length===0)return!1;for(let o=n-1;o>=0&&o>=n-5;o-=1){let s=(r[o]??"").trim();if(s!==""){if(zo(s)===i)return!0;if(!s.startsWith("//")&&!s.startsWith("*")&&!s.startsWith("/*")&&!s.startsWith("@")&&!s.startsWith("#"))return!1}}return!1}function E1(e){return e.replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)}function w1(e){return e.some(t=>L1.has(t))&&e.some(t=>D1.has(t))}var I1=new Map([["access","access policy"],["accessible","access policy"],["adapter","adapter"],["adapters","adapter"],["allow","access policy"],["allowed","access policy"],["animation","animation calculation"],["api","api surface"],["apply","settings/application"],["audit","side-effect boundary"],["auth","authorization"],["authorize","authorization"],["audio","audio side-effect"],["can","access policy"],["capabilities","capability boundary"],["capability","capability boundary"],["boundary","boundary"],["begin","lifecycle"],["bridge","bridge"],["bridges","bridge"],["cache","state cache"],["chase","gameplay action"],["command","command boundary"],["context","context policy"],["cooldown","temporal state"],["cooldowns","temporal state"],["controller","controller"],["controllers","controller"],["diagnostic","diagnostics"],["diagnostics","diagnostics"],["effect","side-effect boundary"],["effects","side-effect boundary"],["energy","gameplay calculation"],["expired","temporal state"],["facade","facade"],["facades","facade"],["fire","gameplay action"],["gateway","gateway"],["gateways","gateway"],["guard","guard"],["guards","guard"],["haptic","haptic side-effect"],["haptics","haptic side-effect"],["head","sequence boundary"],["history","state history"],["input","input boundary"],["jump","gameplay action"],["keyboard","input boundary"],["log","side-effect boundary"],["logger","side-effect boundary"],["lock","coordination boundary"],["middleware","middleware"],["multiplier","gameplay calculation"],["mute","audio side-effect"],["normalize","normalization"],["normalise","normalization"],["normalizer","normalization"],["oscillate","animation calculation"],["oscillation","animation calculation"],["overlap","collision predicate"],["performance","diagnostics"],["permission","access policy"],["permissions","access policy"],["policy","policy"],["pool","state pool"],["pooled","state pool"],["pools","state pool"],["predict","prediction"],["presenter","presenter"],["presenters","presenter"],["projectile","gameplay entity"],["provider","provider boundary"],["providers","provider boundary"],["public","public surface"],["quality","settings/application"],["rate","calculation"],["register","registry"],["registry","registry"],["relay","relay"],["relays","relay"],["reseed","state lifecycle"],["reset","state lifecycle"],["respond","response boundary"],["response","response boundary"],["resolve","resolution"],["resolver","resolution"],["route","route boundary"],["routes","route boundary"],["run","lifecycle"],["sample","diagnostics"],["score","gameplay calculation"],["scope","scope policy"],["scroll","position state"],["scrolled","position state"],["seed","state lifecycle"],["seeded","state lifecycle"],["segment","segment boundary"],["segments","segment boundary"],["setting","settings/application"],["settings","settings/application"],["spawn","gameplay lifecycle"],["spawning","gameplay lifecycle"],["speed","gameplay calculation"],["surface","public surface"],["tail","sequence boundary"],["tick","temporal state"],["transaction","transaction"],["transactional","transaction"],["transform","transformation"],["transformer","transformation"],["translate","translation"],["translator","translation"],["try","fallible action"],["validate","validation"],["validation","validation"],["validator","validation"],["visual","diagnostics"],["window","settings/application"],["socket","transport boundary"],["websocket","transport boundary"]]),L1=new Set(["can","has","is","should"]),D1=new Set(["access","api","auth","collision","expired","input","keyboard","overlap","permission","permissions","policy","projectile","response","route","routes","scope"]);function Do(e,t){let{scope:n,maxLoc:i=15,limit:r=30,scanLimit:o}=t??{},s=new U(e);return Ot({candidates:()=>k1(e,s,n,i),orderCandidates:Ys,scanLimit:o,profile:{name:"passthrough-candidates"},prepare:a=>s.calleeEvidenceMap(a,{semantic:t?.semantic!==!1}),evaluate:(a,l)=>l.incompleteSymbolIds.has(a.symbolId)||l.unavailableSymbolIds.has(a.symbolId)?null:P1(e,a,l.rows.get(a.symbolId)??[]),orderResults:(a,l)=>a.loc-l.loc||a.file.localeCompare(l.file),limit:r})}function P1(e,t,n){let i=N1(n);if(i.size!==1||!om(e,t.relativePath,t.startLine,t.endLine))return null;let[,r]=[...i.entries()][0],o=T1(e,t,r),s=M1(e,t),a=o.length>0||s.length>0?"signal":"direct";return{symbol:t.symbol,shortName:k(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:de(t),forwardsTo:r.symbol,forwardsToShort:k(r.symbol),forwardsToFile:r.file,actionTier:a,boundaryEvidence:o,publicFacadeEvidence:s,recommendation:F1(a,o,s)}}function T1(e,t,n){return Oa(e,t.relativePath,t.startLine,"passthrough","explicit ignore-passthrough comment",[{label:"passthrough name",value:k(t.symbol)},{label:"callee name",value:k(n.symbol)},{label:"passthrough module",value:xv(t.relativePath,Rv(t.relativePath))},{label:"callee module",value:xv(n.file,Rv(n.file))}])}function F1(e,t,n){if(e==="signal"){if(n.length>0)return`Review the public API before inlining; public-facade evidence: ${n.slice(0,2).join("; ")}.`;let i=t.filter(A1);return i.length>0?`Review the public API before inlining; public-surface evidence: ${i.slice(0,2).join("; ")}.`:`Review the boundary before inlining; boundary evidence: ${t.slice(0,2).join("; ")}.`}return"Inline or remove this passthrough unless an external API or runtime registration depends on the forwarding name."}function M1(e,t){return Ct(e,t)?En(e,t.relativePath)?["exported passthrough is declared on the package public surface"]:Ue(e,t.symbol,t.relativePath)?["exported passthrough matches configured or framework public entry surface"]:[]:[]}function A1(e){return e.includes("public surface")}function N1(e){let t=e.some(i=>ke(i.symbol))?e.filter(i=>ke(i.symbol)):e,n=new Map;for(let i of t)n.has(i.symbol)||n.set(i.symbol,i);return n}function k1(e,t,n,i){return t.productionCallableDefinitions({scope:n,minLoc:3,maxLoc:i,requireFunctionLikeSymbol:!0,excludeRustTraitImplMembers:!0}).filter(r=>!qo(e,r))}var j1=new Set(Zt());function H1(e,t){return`tests/generated/twin-ab/${Ev(e)}-vs-${Ev(t)}.test.ts`}function Ev(e){return(e.split(/[/#]/).pop()||e).replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"symbol"}function U1(e,t,n,i){let{refA:r,refB:o,outFile:s}=typeof t=="string"?{refA:t,refB:n,outFile:i}:t;if(typeof r!="string"||typeof o!="string"||typeof s!="string")throw new TypeError("twinAb requires refA, refB, and outFile.");if(!B1(s))throw new TypeError("twinAb outFile must be an absolute path.");let a=wv(e,r);if(!a.ok)return a;let l=wv(e,o);if(!l.ok)return l;let c=a.symbol.paramCount===null||l.symbol.paramCount===null?null:a.symbol.paramCount===l.symbol.paramCount,u=G1(a.symbol,l.symbol,e.config.projectRoot,s,c);return{ok:!0,a:a.symbol,b:l.symbol,signatureCompatible:c,testSource:u}}function wv(e,t){let i=rt(e,t).match;if(!i)return{ok:!1,reason:`${t} does not resolve to an indexed symbol.`};let o=e.get("SELECT kind FROM global_symbols WHERE id = ?",i.symbolId)?.kind??null;if(!(o!==null?j1.has(o):ke(i.symbol)))return{ok:!1,reason:`${t} resolves to ${k(i.symbol)}${o!==null?` with SCIP kind ${Rr(o)}`:""} \u2014 twin-ab compares call outputs, so both referents must be functions or methods.`};if(!Ct(e,i))return{ok:!1,reason:`${t} (${k(i.symbol)} at ${i.relativePath}:${i.startLine+1}) is not exported \u2014 twin-ab needs an importable named binding for both twins.`};let a=e.get("SELECT documentation FROM global_symbols WHERE id = ?",i.symbolId),l=_i(Bi(a?.documentation??null));return{ok:!0,symbol:{ref:t,symbol:i.symbol,shortName:re(i.symbol)||k(i.symbol),file:i.relativePath,startLine:i.startLine,signature:l,paramCount:l?z1(l):null}}}function z1(e){let t=e.indexOf("(");if(t===-1)return null;let n=0,i=-1;for(let a=t;a<e.length;a+=1){let l=e[a];if(l==="(")n+=1;else if(l===")"&&(n-=1,n===0)){i=a;break}}if(i===-1)return null;let r=e.slice(t+1,i).trim();if(!r)return 0;let o=1,s=0;for(let a of r)a==="("||a==="["||a==="{"?s+=1:a===")"||a==="]"||a==="}"?s=Math.max(0,s-1):a===","&&s===0&&(o+=1);return o}function Iv(e,t,n){let i=_1(t),r=$1(e,n),s=O1(i,r).replace(/\\/g,"/").replace(/\.tsx?$/,".js");return s.startsWith(".")?s:`./${s}`}function G1(e,t,n,i,r){let o=Iv(n,i,e.file),s=Iv(n,i,t.file),a=r===null?"Signature comparison: unknown (one or both signatures unavailable in the index) \u2014 check by hand.":r?"Signature comparison: param counts match.":"Signature comparison: param counts DIFFER \u2014 twins may not be directly comparable; check by hand.";return`/**
376
+ * Generated by 'codebaseiq twin-ab'. Cleanup integrity scenario.
377
+ * ("cross-examine same-concept twins"): where one concept is computed in
378
+ * more than one place, feed both the same input and require the same
379
+ * answer. Disagreement between twins means at least one is wrong \u2014
380
+ * determine which before consolidating.
381
+ *
382
+ * Twin A: ${e.shortName} (${e.file}:${e.startLine+1})
383
+ * ${e.signature??"(signature unavailable)"}
384
+ * Twin B: ${t.shortName} (${t.file}:${t.startLine+1})
385
+ * ${t.signature??"(signature unavailable)"}
386
+ * ${a}
387
+ *
388
+ * Fill in the TODO input table below with inputs both twins should agree
389
+ * on, then run this file with vitest.
390
+ */
391
+ import { describe, expect, it } from 'vitest';
392
+ import { ${e.shortName} as twinA } from '${o}';
393
+ import { ${t.shortName} as twinB } from '${s}';
394
+
395
+ // TODO: fill in shared inputs both twins should agree on \u2014 one arg array per call.
396
+ const inputs: any[][] = [
397
+ // [/* arg1, arg2, ... */],
398
+ ];
399
+
400
+ // Cast to a variadic signature so the input table can hold any arg shape \u2014
401
+ // the real twins have fixed, non-rest parameter lists, and TS rejects
402
+ // spreading a generic args array into those (TS2556) even when the array
403
+ // itself is 'any'; casting the callee's signature, not the args, satisfies
404
+ // the checker without weakening the twins' real exported types elsewhere.
405
+ const callA = twinA as (...callArgs: any[]) => any;
406
+ const callB = twinB as (...callArgs: any[]) => any;
407
+
408
+ describe.skipIf(inputs.length === 0)('twin-ab: ${e.shortName} vs ${t.shortName}', () => {
409
+ it.each(inputs)('agrees on input %#', (...args) => {
410
+ expect(callA(...args)).toEqual(callB(...args));
411
+ });
412
+ });
413
+ `}var Lv={caller:3,"entry-surface":2,rooted:1},K1=/not\s*yet\s*implement|not\s*implement|unimplement|\bnyi\b|\btodo\b|\bstub\b|not\s*supported|coming\s*soon/i,q1=/^throw\s+new\s+[\w.]*Error\s*\(([\s\S]*)\)\s*;?$/,W1=/^return(\s+(null|undefined|false|0|''|""|``|\[\]|\{\}))?\s*;?$/,V1=/\/\/\s*TODO\b|\/\*\s*TODO\b/i,J1=/(?:=>|\))\s*(?::\s*[^{;=]+)?\s*\{\s*\}\s*;?\s*$/;function Y1(e,t={}){let{scope:n,limit:i=30,scanLimit:r,semantic:o=!0}=t,s=new U(e),a=Ae(s.productionCallableDefinitions({scope:n,minLoc:1,requireFunctionLikeSymbol:!0,excludeTypesFiles:!0}),r),l=[];for(let f of a){let p=Z1(e,f);p&&l.push(p)}if(l.length===0)return[];let c=nj(e,l,a),u=l.filter(f=>!c.has(f.def.symbol));if(u.length===0)return[];let d=un(e,s).forDefinitions(u.map(f=>f.def),{semantic:o}),m=[];for(let f of u){let p=d.get(f.def.symbolId);if(p?.semanticIncomplete||p?.semanticUnavailable)continue;let g=p?.realConsumers.length??0,h=X1(e,f.def,g);h&&m.push({symbol:f.def.symbol,shortName:k(f.def.symbol),file:f.def.relativePath,startLine:f.def.startLine,endLine:f.def.endLine,loc:de(f.def),stubKind:f.stubKind,reachability:h,callerFanIn:g,stubText:f.stubText})}return m.sort((f,p)=>Lv[p.reachability]-Lv[f.reachability]||p.callerFanIn-f.callerFanIn||f.file.localeCompare(p.file)||f.startLine-p.startLine),i?m.slice(0,i):m}function X1(e,t,n){return n>0?"caller":Ue(e,t.symbol,t.relativePath)?"rooted":Ye(e,t.relativePath)?"entry-surface":null}function Z1(e,t){let n=Vt(e,t);if(!n)return null;let i=mn(n),r=i.trim();if(r==="")return!tj(n)||!Ct(e,t)?null:{def:t,stubKind:"empty-body",stubText:"(empty body)"};let o=yr(i),s=hn(i),a=Q1(o,s);if(a.length!==1)return null;let l=a[0];return ej(l)?{def:t,stubKind:"throw-stub",stubText:l.trim()}:V1.test(i)&&W1.test(l.trim())?{def:t,stubKind:"todo-return-default",stubText:r}:null}function Q1(e,t){let n=[],i=0,r="";for(let o=0;o<t.length;o+=1){let s=t[o];if(s==="("||s==="["||s==="{"?i+=1:(s===")"||s==="]"||s==="}")&&(i=Math.max(0,i-1)),s===";"&&i===0){n.push(r),r="";continue}r+=e[o]??""}return r.trim()&&n.push(r),n.map(o=>o.trim()).filter(o=>o.length>0)}function ej(e){let t=q1.exec(e.trim());return t?K1.test(t[1]??""):!1}function tj(e){return J1.test(e.trimEnd())}function nj(e,t,n){let i=new Set,r=new Set(t.map(a=>a.def.parentTypeName).filter(a=>a!==null));if(r.size===0)return i;let o=rj(e,r),s=new Map;for(let a of n){if(!a.parentTypeName)continue;let l=s.get(a.leaf)??new Set;l.add(a.parentTypeName),s.set(a.leaf,l)}for(let a of t){let l=a.def.parentTypeName;if(!l)continue;let c=o.get(l);if(!c||c.size===0)continue;let u=s.get(a.def.leaf)??new Set;[...c].every(m=>u.has(m))&&i.add(a.def.symbol)}return i}var ij=/\bclass\s+([A-Za-z_$][\w$]*)\s+extends\s+([A-Za-z_$][\w$]*)/g;function rj(e,t){let n=new Map;for(let i of he(e,{includeIgnored:!1})){let r=se(e,i);if(r)for(let o of r.matchAll(ij)){let s=o[1],a=o[2];if(!s||!a||!t.has(a))continue;let l=n.get(a)??new Set;l.add(s),n.set(a,l)}}return n}var oj=/^(?:validate|verify|check|assert)(?:[A-Z].*)?$/,sj=/^(?:is|has)(?:[A-Z].*)?$/,aj=/[{,]\s*(?:ok|success|valid|isValid)\s*:\s*false\b/,Xu=/\breturn\b/g,lj=/\bfunction\b|=>|\)\s*(?::\s*[^{;=]+)?\s*\{/,cj=/\.(?:addIssue|push)\s*\(/;function uj(e,t={}){let{scope:n,limit:i=30,scanLimit:r}=t,o=new U(e),s=Ae(o.productionCallableDefinitions({scope:n,minLoc:1,requireFunctionLikeSymbol:!0,excludeTypesFiles:!0}),r),a=[];for(let l of s){let c=mj(e,l);c&&a.push({symbol:l.symbol,shortName:k(l.symbol),file:l.relativePath,startLine:l.startLine,endLine:l.endLine,loc:de(l),...c})}return a.sort((l,c)=>l.file.localeCompare(c.file)||l.startLine-c.startLine||l.loc-c.loc),i?a.slice(0,i):a}function dj(e){return oj.test(e)?"imperative":sj.test(e)?"predicate":null}function mj(e,t){let n=dj(t.leaf);if(!n||ir(e,t))return null;let i=Vt(e,t);if(!i||!lj.test(i))return null;let r=ee(e,t.relativePath)?.callables.find(s=>s.startLine===t.startLine&&s.endLine===t.endLine);if(n==="predicate"&&r?.paramCount===0)return null;if(bv(i)){let s=gj(e,t);return!s||Tv(s.body,Pv(s.snippet))||Dv(s.body)?null:{nameKind:n,resolvedVia:"one-hop-delegate",delegateTarget:s.shortName}}let o=mn(i);return Tv(o,Pv(i))||Dv(o)?null:{nameKind:n,resolvedVia:"direct"}}var fj=new Set(["if","for","while","switch","catch","function"]);function Dv(e){let t=yr(e);for(let n of t.matchAll(/\b([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\(/g))if(!fj.has(n[1]))return!0;return!1}function Pv(e){let t=e.indexOf("=>");return t===-1?!1:!/^\s*\{/.test(e.slice(t+2))}function Tv(e,t){let n=yr(e);if(/\bthrow\b/.test(n)||/\.reject\s*\(/.test(n)||aj.test(n)||cj.test(n))return!0;let i=pj(n);if(t&&i.length===0){let r=n.trim();return r!==""&&r!=="true"}for(let r of i)if(r!==""&&r!=="true")return!0;return!1}function pj(e){let t=[];Xu.lastIndex=0;let n;for(;n=Xu.exec(e);){let i=n.index+n[0].length,r=0,o=e.length;for(let s=i;s<e.length;s+=1){let a=e[s];if(a==="("||a==="["||a==="{")r+=1;else if(a===")"||a==="]"||a==="}"){if(r===0){o=s;break}r-=1}else if(a===";"&&r===0){o=s;break}}t.push(e.slice(i,o).trim()),Xu.lastIndex=o}return t}function gj(e,t){let n=ai(e,t,{callableOnly:!0,limit:3,semanticEvidence:pe});if(n.semanticIncomplete||n.semanticUnavailable)return null;let i=n.rows,r=[...new Set(i.map(c=>c.symbol))].filter(c=>c!==t.symbol);if(r.length!==1)return null;let s=rt(e,r[0]).match;if(!s)return null;let a=J(e,s.relativePath).find(c=>c.symbolId===s.symbolId);if(!a)return null;let l=Vt(e,a);return l?{body:mn(l),snippet:l,shortName:k(a.symbol)}:null}var hj=60;function yj(e,t={}){let{scope:n,limit:i=30,scanLimit:r,rotDays:o=hj}=t,s=Ae(Mi(e,{extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs"]}).filter(u=>V(u)==="test").filter(u=>!n||u.includes(n)).filter(u=>!e.isIgnored(u)).sort(),r),a=[],l=[],c=[];for(let u of s){let d=se(e,u);if(!d)continue;let m=nm(d),f=vj(d);for(let g of Ej(m,f))f.add(g);let p=bj(m);for(let g of p){if(g.skip){l.push(Fj(e,u,g,o));continue}if(g.kind==="describe")continue;let h=Mv(d,g.argsStart),S=m.slice(g.argsStart,g.callEnd),v=d.slice(g.argsStart,g.callEnd);Av(S,f)||a.push({file:u,startLine:Po(d,g.callStart),endLine:Po(d,g.callEnd),title:h,severity:/\bawait\b/.test(S)?"low":"high"});let y=Dj(S,v);y&&c.push({file:u,startLine:Po(d,g.callStart),endLine:Po(d,g.callEnd),title:h,echoedValue:y})}}return{assertionFree:i?a.slice(0,i):a,skipped:i?l.slice(0,i):l,mockEcho:i?c.slice(0,i):c}}var Zu=/(?<!\.)\b(?:x(it|test|describe)|(it|test|describe)(?:\.\s*(skip|only|todo|each\s*\([^)]*\)))?)\s*\(/g;function bj(e){let t=[];Zu.lastIndex=0;let n;for(;n=Zu.exec(e);){let i=n[1],r=i??n[2];if(!r)continue;let o=n[3]?.split(/\s*\(/)[0],s=n.index,a=n.index+n[0].length-1,l=To(e,a);Zu.lastIndex=a+1,o!=="each"&&t.push({kind:r,skip:i!==void 0||o==="skip"||o==="todo",skipKind:o==="todo"?"todo":"skip",callStart:s,argsStart:a+1,callEnd:l+1})}return t}function To(e,t){let n=0;for(let i=t;i<e.length;i+=1){let r=e[i];if(r==="(")n+=1;else if(r===")"&&(n-=1,n===0))return i}return e.length-1}function Po(e,t){let n=0;for(let i=0;i<t&&i<e.length;i+=1)e[i]===`
414
+ `&&(n+=1);return n}function Mv(e,t){let n=e.slice(t,t+400),i=/^\s*(['"`])((?:\\.|(?!\1)[\s\S])*)\1/.exec(n);return i?i[2]:"(anonymous)"}var Sj=new Set(["vitest","chai","jest","@jest/globals","assert","node:assert","node:assert/strict","assert/strict","uvu/assert","expect","chai-as-promised"]),Fv=/import\s+(?:\*\s+as\s+(\w+)|\{([^}]*)\}|(\w+))\s+from\s+['"]([^'"]+)['"]/g;function vj(e){let t=new Set(["expect","assert"]);Fv.lastIndex=0;let n;for(;n=Fv.exec(e);){let[,i,r,o,s]=n;if(!(!s||!Sj.has(s))&&(i&&t.add(i),o&&t.add(o),r))for(let a of r.split(",")){let l=a.trim().replace(/^type\s+/,"");if(!l)continue;let c=/^(\w+)\s+as\s+(\w+)$/.exec(l);t.add(c?c[2]:l)}}return t}function Av(e,t){if(/\.should\b/.test(e)||/\bawait\s+(?:[\w$.]+\.)?findBy[A-Z]\w*\s*\(/.test(e)||/\bawait\s+\w*waitFor(?:Text|Value|Condition|Result|Event)\s*\(/.test(e)||/\bthrow\b/.test(e))return!0;for(let n of t){let i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${i}\\s*(?:<[^<>]*>)?\\s*[.(]`).test(e))return!0}return!1}var Cj=/\bfunction\s+(\w+)\s*\(/g,xj=/\b(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?\(/g,Rj=60;function Ej(e,t){let n=new Set;for(let i of[Cj,xj]){i.lastIndex=0;let r;for(;r=i.exec(e);){let o=r[1],s=r.index+r[0].length-1,a=To(e,s),l=e.indexOf("{",a+1);if(l===-1||l-a>Rj)continue;let c=wj(e,l),u=e.slice(l+1,c);Av(u,t)&&n.add(o)}}return n}function wj(e,t){let n=0;for(let i=t;i<e.length;i+=1){let r=e[i];if(r==="{")n+=1;else if(r==="}"&&(n-=1,n===0))return i}return e.length-1}var Ij=/\bmock(?:ReturnValue|ResolvedValue)(?:Once)?\s*\(/g,Qu=/\bexpect\s*\(/g,Lj=/^\s*\.\s*(?:toBe|toEqual|toStrictEqual)\s*\(/,Nv=/^(?:-?\d+(?:\.\d+)?|(['"`]).+\1)$/;function Dj(e,t){let n=Pj(e,t,Ij);if(n.length===0)return null;let i=Tj(e,t);for(let r of i)if(n.includes(r))return r;return null}function Pj(e,t,n){let i=[];n.lastIndex=0;let r;for(;r=n.exec(e);){let o=r.index+r[0].length-1,s=To(e,o),a=t.slice(o+1,s).trim();Nv.test(a)&&i.push(a),n.lastIndex=s+1}return i}function Tj(e,t){let n=[];Qu.lastIndex=0;let i;for(;i=Qu.exec(e);){let r=i.index+i[0].length-1,o=To(e,r),s=e.slice(o+1),a=Lj.exec(s);if(Qu.lastIndex=o+1,!a)continue;let l=o+1+a[0].length-1,c=To(e,l),u=t.slice(l+1,c).trim();Nv.test(u)&&n.push(u)}return n}function Fj(e,t,n,i){let r=se(e,t),o=Mv(r,n.argsStart),s=Po(r,n.callStart),a=Mj(e.config.projectRoot,t,s),l=a===null?"unknown":a>=i?"rot":"workflow";return{file:t,startLine:s,title:o,skipKind:n.skipKind,blockKind:n.kind,ageDays:a,rot:l}}function Mj(e,t,n){let i=n+1;try{let r=dn(e,["blame","-L",`${i},${i}`,"--porcelain","--",t]),o=/^author-time (\d+)$/m.exec(r);if(!o)return null;let s=Number(o[1]);return Number.isFinite(s)?Math.max(0,Math.round((Date.now()/1e3-s)/86400)):null}catch{return null}}var Aj=.7,kv=.62,_v=.45;function Nj(e,t={}){let{windowCommits:n=100,limit:i=30,scope:r,scanLimit:o}=t,s=Wt(e,{historyMode:t.historyMode}).fileAddRecords();if(!s)return{available:!1,windowCommits:n,findings:[]};if(i<=0)return{available:!0,windowCommits:n,findings:[]};let a=zj(s,n);if(a.size===0)return{available:!0,windowCommits:n,findings:[]};let c=kj(e,{limit:i,minSimilarity:t.minSimilarity,scanLimit:o,scope:r,semantic:t.semantic,focusFiles:Number.isFinite(i)?void 0:a}).map(d=>Gj(d,s,n)).filter(d=>d!==null);c.sort((d,m)=>(d.kind===m.kind?0:d.kind==="echo"?-1:1)||m.similarity-d.similarity||d.echoFile.localeCompare(m.echoFile)||d.echoSymbol.localeCompare(m.echoSymbol)||d.domain.localeCompare(m.domain));let u=c.slice(0,i).map(Kj);return{available:!0,windowCommits:n,findings:u,rootCauseGroups:qj(u)}}function kj(e,t){let n=Vj(t.limit),i=[..._j(e,{scope:t.scope,minSimilarity:t.minSimilarity??Aj,limit:n,scanLimit:t.scanLimit,semantic:t.semantic,focusFiles:t.focusFiles})],r=Wo(e,{scope:t.scope});return r.react&&i.push(...Bj(e,{scope:t.scope,minSimilarity:t.minSimilarity??kv,limit:n,scanLimit:t.scanLimit,focusFiles:t.focusFiles}),...Oj(e,{scope:t.scope,minSimilarity:t.minSimilarity??_v,limit:n,scanLimit:t.scanLimit,focusFiles:t.focusFiles})),r.vue&&i.push(...Hj(e,{scope:t.scope,minSimilarity:t.minSimilarity??kv,limit:n,scanLimit:t.scanLimit,focusFiles:t.focusFiles}),...Uj(e,{scope:t.scope,minSimilarity:t.minSimilarity??_v,limit:n,scanLimit:t.scanLimit,focusFiles:t.focusFiles})),i}function _j(e,t){return bo(e,{scope:t.scope,minSimilarity:t.minSimilarity,limit:t.limit,crossFileOnly:!0,scanLimit:t.scanLimit,semantic:t.semantic,focusFiles:t.focusFiles}).filter(n=>!at(n.symbolA)&&!at(n.symbolB)).map(n=>({domain:"callable",basis:n.similarityBasis??"callees",symbolA:n.shortNameA,fileA:n.fileA,symbolB:n.shortNameB,fileB:n.fileB,similarity:n.similarity,sharedEvidence:n.sharedCallees,sharedCallees:n.sharedCallees}))}function Bj(e,t){return ja(e,t,{query:So,domain:"react-component",basis:"jsx-structure",symbolA:n=>n.componentA,symbolB:n=>n.componentB,evidenceBuckets:n=>[["component",n.sharedComponents],["tag",n.sharedNativeTags],["prop",n.sharedProps],["event",n.sharedEvents],["binding",n.sharedBindings]]})}function ja(e,t,n){return n.query(e,t).filter(i=>i.fileA!==i.fileB).filter(i=>n.acceptPair?.(i)??!0).map(i=>({domain:n.domain,basis:n.basis,symbolA:n.symbolA(i),fileA:i.fileA,symbolB:n.symbolB(i),fileB:i.fileB,similarity:i.similarity,sharedEvidence:Jj(...n.evidenceBuckets(i)),sharedCallees:[]}))}function Oj(e,t){return ja(e,t,{query:vo,domain:"react-hook",basis:"react-behavior",symbolA:n=>n.componentA,symbolB:n=>n.componentB,acceptPair:jj,evidenceBuckets:n=>[["hook",n.sharedHooks],["react-hook",n.sharedReactHooks],["effect",n.sharedEffects],["state",n.sharedState],["request",n.sharedRequests],["handler",n.sharedHandlers],["action",n.sharedHandlerVerbs]]})}var $j=new Set(["useCallback","useEffect","useLayoutEffect","useMemo","useMutation","useQueries","useQuery","useQueryClient","useReducer","useRef","useState"]);function jj(e){return e.sharedHooks.some(t=>!$j.has(t))||e.sharedState.length>0||e.sharedHandlers.length>0||e.sharedHandlerVerbs.length>=2}function Hj(e,t){return ja(e,t,{query:Co,domain:"vue-component",basis:"vue-template",symbolA:n=>$a(n.fileA),symbolB:n=>$a(n.fileB),evidenceBuckets:n=>[["component",n.sharedComponents],["prop",n.sharedProps],["event",n.sharedEvents],["directive",n.sharedDirectives],["slot",n.sharedSlots],["identifier",n.sharedIdentifiers]]})}function Uj(e,t){return ja(e,t,{query:xo,domain:"vue-composable",basis:"vue-behavior",symbolA:n=>$a(n.fileA),symbolB:n=>$a(n.fileB),evidenceBuckets:n=>[["composable",n.sharedComposables],["store",n.sharedStores],["reactivity",n.sharedReactivity],["lifecycle",n.sharedLifecycle],["request",n.sharedRequests],["function",n.sharedFunctions],["action",n.sharedFunctionVerbs],["binding",n.sharedBindings],["template-event",n.sharedTemplateEvents]]})}function zj(e,t){let n=new Set;for(let[i,r]of e)r.commitsAgo<=t&&n.add(i);return n}function Gj(e,t,n){let i=t.get(e.fileA)?.commitsAgo??null,r=t.get(e.fileB)?.commitsAgo??null,o=i!==null&&i<=n,s=r!==null&&r<=n;if(!o&&!s)return null;if(o&&s){let a=(i??0)<=(r??0);return{kind:"twin",domain:e.domain,basis:e.basis,echoSymbol:a?e.symbolA:e.symbolB,echoFile:a?e.fileA:e.fileB,echoAgeCommits:(a?i:r)??0,establishedSymbol:a?e.symbolB:e.symbolA,establishedFile:a?e.fileB:e.fileA,establishedAgeCommits:a?r:i,similarity:e.similarity,sharedEvidence:e.sharedEvidence,sharedCallees:e.sharedCallees}}return{kind:"echo",domain:e.domain,basis:e.basis,echoSymbol:o?e.symbolA:e.symbolB,echoFile:o?e.fileA:e.fileB,echoAgeCommits:(o?i:r)??0,establishedSymbol:o?e.symbolB:e.symbolA,establishedFile:o?e.fileB:e.fileA,establishedAgeCommits:o?r:i,similarity:e.similarity,sharedEvidence:e.sharedEvidence,sharedCallees:e.sharedCallees}}function Kj(e){let t=Bv(e);return{...e,rootCauseKey:t,groupKey:`recent-duplicate:${t}`}}function Bv(e){if(e.kind==="echo")return["echo",e.domain,e.basis,e.establishedSymbol].join(":");let t=e.sharedEvidence.slice().sort().join("|"),n=[e.echoSymbol,e.establishedSymbol].sort().join("|");return["twin",e.domain,e.basis,t||n].join(":")}function qj(e){let t=new Map;for(let[n,i]of e.entries()){let r=i.rootCauseKey??Bv(i),o=i.groupKey??`recent-duplicate:${r}`,s=t.get(o);s||(s={groupKey:o,rootCauseKey:r,kind:i.kind,domain:i.domain,basis:i.basis,count:0,maxSimilarity:i.similarity,findingIndexes:[],echoFiles:new Set,establishedFile:i.kind==="echo"?i.establishedFile:void 0,establishedSymbol:i.kind==="echo"?i.establishedSymbol:void 0,relatedFiles:new Set,sharedEvidence:new Set,recommendation:Wj(i)},t.set(o,s)),s.count+=1,s.maxSimilarity=Math.max(s.maxSimilarity,i.similarity),s.findingIndexes.push(n),s.echoFiles.add(i.echoFile),s.relatedFiles.add(i.echoFile),s.relatedFiles.add(i.establishedFile);for(let a of i.sharedEvidence)s.sharedEvidence.add(a)}return[...t.values()].map(n=>({...n,echoFiles:[...n.echoFiles].sort(),relatedFiles:[...n.relatedFiles].sort(),sharedEvidence:[...n.sharedEvidence].sort().slice(0,16)})).sort((n,i)=>i.count-n.count||i.maxSimilarity-n.maxSimilarity||n.groupKey.localeCompare(i.groupKey))}function Wj(e){return e.kind==="echo"?"Review the established side once, then migrate or delete every echo in this group.":"Pick one owner for the new twins and consolidate the group before the copies diverge."}function Vj(e){return Number.isFinite(e)?e*5:Number.POSITIVE_INFINITY}function Jj(...e){let t=[],n=new Set;for(let[i,r]of e)for(let o of r){let s=`${i}:${o}`;n.has(s)||(n.add(s),t.push(s))}return t}function $a(e){return(e.split("/").pop()??e).replace(/\.[^.]+$/,"")}var Yj=Fe("suppression-inventory",{clearGroups:["whole-project"]});function Ha(e){return Yj.get(e,()=>Xj(e))}function Xj(e){let t={dead:0,stale:0,wrapper:0,passthrough:0,drift:0,extract:0,similar:0,twin:0,uncategorized:0},n=new Map,i=0;for(let r of Mi(e)){let o=se(e,r);if(!(!o||!o.includes("codebaseiq")))for(let s of o.split(/\r?\n/)){let a=zo(s);if(a===null)continue;i+=1,n.set(r,(n.get(r)??0)+1);let l=Ov(a);t[l]+=1}}for(let r of e.config.suppressions??[])r.expiresAt&&Date.parse(r.expiresAt)<=Date.now()||(i+=1,r.file&&n.set(r.file,(n.get(r.file)??0)+1),t[Ov(r.check)]+=1);return{total:i,byCategory:t,byFile:n}}function Ov(e){if(!e)return"uncategorized";let t=e.toLowerCase();return t==="dead-code"||t==="new-dead"?"dead":t.includes("twin")?"twin":t.includes("similar")||t.includes("duplicate")?"similar":t.includes("wrapper")?"wrapper":t.includes("passthrough")?"passthrough":t.includes("drift")?"drift":t.includes("extract")?"extract":t.includes("stale")?"stale":"uncategorized"}function ed(e,t,n={}){let i=fe(e,t);if(!i)return null;let r=new U(e),o=Zj(e,i),s=i.endLine-i.startLine+1,a=r.calleeEvidenceMap([i],{additive:!0,semantic:n.semantic}),l=a.rows.get(i.symbolId)??[],c=new Set(l.map(p=>p.symbol)),u=a.incompleteSymbolIds.has(i.symbolId),d=a.unavailableSymbolIds.has(i.symbolId),m=n.semantic===!1?"disabled":u&&d?"incomplete-and-unavailable":u?"incomplete":d?"unavailable":"complete",f=!u&&!d;return{symbol:i.symbol,shortName:k(i.symbol),relativePath:i.relativePath,startLine:i.startLine,endLine:i.endLine,loc:s,branches:o.branches,estimateBasis:o.estimateBasis,cyclomaticEstimate:o.branches+1,calleeCount:f?c.size:null,fanIn:eH(e,i.symbolId),fanOut:f?tH(l,i.relativePath):null,coverage:{semanticEvidence:m}}}function Zj(e,t){let n=ae(e,t.relativePath);if(n){let i=Uv(n.rootNode,t.startLine,t.endLine);if(i)return{branches:nH(i),estimateBasis:"ast"}}return{branches:Gv(Hv(e,t.relativePath,t.startLine,t.endLine),jv(e,t.relativePath)),estimateBasis:"regex-fallback"}}function $v(e,t){let n=new Map,i=new Map;for(let r of t){let o=i.get(r.relativePath)??[];o.push(r),i.set(r.relativePath,o)}for(let[r,o]of i){let s=ae(e,r),a=s===null?[]:o.filter(c=>s.rootNode.startPosition.row<=c.startLine&&s.rootNode.endPosition.row>=c.endLine),l=new Set(a.map(c=>c.symbolId));if(s&&a.length>0){for(let c of a)n.set(c.symbolId,{branches:0,estimateBasis:"ast"});iH(s.rootNode,a,n)}for(let c of o)l.has(c.symbolId)||n.set(c.symbolId,Qj(e,c))}return n}function Qj(e,t){return{branches:Gv(Hv(e,t.relativePath,t.startLine,t.endLine),jv(e,t.relativePath)),estimateBasis:"regex-fallback"}}function jv(e,t){return e.get("SELECT language FROM documents WHERE relative_path = ?",t)?.language??"unknown"}function Hv(e,t,n,i){try{return nt(e.config.projectRoot,t,{inputKind:"indexed source file"}).split(`
415
+ `).slice(n,i+1).join(`
416
+ `)}catch(r){if(!St(r))throw r;return""}}function eH(e,t){return e.get(`SELECT COUNT(DISTINCT c.document_id) AS c
417
+ FROM mentions m
418
+ JOIN chunks c ON m.chunk_id = c.id
419
+ JOIN (
420
+ SELECT m2.symbol_id, c2.document_id
421
+ FROM mentions m2
422
+ JOIN chunks c2 ON m2.chunk_id = c2.id
423
+ WHERE m2.role = 1
424
+ GROUP BY m2.symbol_id
425
+ ) sym_def ON sym_def.symbol_id = m.symbol_id
426
+ WHERE m.symbol_id = ?
427
+ AND m.role != 1
428
+ AND sym_def.document_id != c.document_id`,t)?.c??0}function tH(e,t){return new Set(e.filter(n=>n.file!==t).map(n=>n.symbol)).size}function nH(e){let t=0;return td(e,n=>{t+=zv(n)}),t}function iH(e,t,n){let i=[...t].sort((r,o)=>r.startLine-o.startLine||o.endLine-r.endLine);td(e,r=>{let o=zv(r);if(o===0)return;let s=r.startPosition.row,a=r.endPosition.row;for(let l of i){if(l.startLine>s)break;if(l.endLine<a)continue;let c=n.get(l.symbolId);c&&(c.branches+=o)}})}function td(e,t){t(e);for(let n of e.namedChildren)td(n,t)}function Uv(e,t,n){if(e.startPosition.row>t||e.endPosition.row<n)return null;for(let i of e.namedChildren){let r=Uv(i,t,n);if(r)return r}return e}var rH=new Set(["if_statement","conditional_expression","ternary_expression","for_statement","for_in_statement","for_of_statement","while_statement","do_statement","switch_case","case_statement","catch_clause","except_clause","elif_clause","match_arm"]);function zv(e){return rH.has(e.type)?1:e.type==="binary_expression"&&e.parent?.type!=="binary_expression"&&(e.text.includes("&&")||e.text.includes("||"))?oH(e.text):0}function oH(e){return(e.match(/&&|\|\|/g)??[]).length}function Gv(e,t){let n=hn(e),i=0,r=[/\bif\b/g,/\belse\s+if\b/g,/\belse\b/g,/\bfor\b/g,/\bwhile\b/g,/\bswitch\b/g,/\bcase\b/g,/\bcatch\b/g,/\?\s*[^?]/g,/&&/g,/\|\|/g];for(let o of r){let s=n.match(o);s&&(i+=s.length)}if(t==="python"){let o=[/\belif\b/g,/\bexcept\b/g,/\bfinally\b/g];for(let s of o){let a=n.match(s);a&&(i+=a.length)}}else if(t==="rust"){let o=[/\bmatch\b/g,/=>/g,/\bloop\b/g];for(let s of o){let a=n.match(s);a&&(i+=a.length)}}else if(t==="ruby"){let o=[/\belsif\b/g,/\bunless\b/g,/\brescue\b/g,/\bwhen\b/g];for(let s of o){let a=n.match(s);a&&(i+=a.length)}}else if(t==="go"){let o=[/\bselect\b/g,/\bdefer\b/g];for(let s of o){let a=n.match(s);a&&(i+=a.length)}}return i}function Kv(e,t,n={}){let i=fe(e,t);if(!i)return null;let r=[{file:i.relativePath,line:i.startLine}],o=On(e,i,{semantic:n.semantic,semanticEvidence:pe}).map(l=>({file:l.file,line:l.line,enclosingSymbol:l.enclosingSymbol??"(top-level)",enclosingShort:l.enclosingSymbol?k(l.enclosingSymbol):"(top-level)"})),{outgoingCalls:s,incomingCalls:a}=sH(e,i,o,{semantic:n.semantic!==!1});return{symbol:i.symbol,shortName:k(i.symbol),relativePath:i.relativePath,definitionSites:r.filter(l=>!e.isIgnored(l.file)),referenceSites:o,outgoingCalls:s.filter(l=>!e.isIgnored(l.file)).map(l=>({symbol:l.symbol,shortName:k(l.symbol),file:l.file})),incomingCalls:a.filter(l=>!e.isIgnored(l.file)).map(l=>({symbol:l.symbol,shortName:l.symbol===l.file?"(top-level)":k(l.symbol),file:l.file}))}}function nd(e,t,n={}){let i=Kv(e,t,n);return i?{symbol:i.symbol,shortName:i.shortName,relativePath:i.relativePath,definitionSites:i.definitionSites,usageSites:i.referenceSites,producers:i.outgoingCalls,consumers:i.incomingCalls}:null}function sH(e,t,n,i){let r=Yi(ms(e,t,{limit:30,semantic:i.semantic,semanticEvidence:pe}).map(a=>({symbol:a.symbol,file:a.file}))),o=Yi(fs(e,t,{limit:30,semantic:i.semantic,semanticEvidence:pe})),s=o.length>0?o:Yi(n.map(a=>({symbol:a.enclosingSymbol==="(top-level)"?a.file:a.enclosingSymbol,file:a.file})));return{outgoingCalls:r,incomingCalls:s}}function qv(e,t,n={}){let{direction:i="backward",maxDepth:r=3}=n,o=fe(e,t);return o?i==="backward"?aH(e,o,r,{semantic:n.semantic!==!1}):lH(e,o,{semantic:n.semantic!==!1}):null}function Ua(e,t,n={}){return qv(e,t,n)}function aH(e,t,n,i){let r=[],o=new Set([t.symbol]),s=[t];for(let a=1;a<=n&&s.length!==0;a++){let l=[];for(let c of s){let u=ms(e,c,{semantic:i.semantic,semanticEvidence:pe});for(let d of u){if(o.has(d.symbol))continue;o.add(d.symbol),r.push({symbol:d.symbol,shortName:k(d.symbol),file:d.file,relationship:a===1?"referenced within definition (callee)":`depth ${a} callee`});let m=ri(e,d.symbol);m&&!e.isIgnored(m.relativePath)&&l.push(m)}}s=l}return{symbol:t.symbol,shortName:k(t.symbol),direction:"backward",connectedSymbols:r}}function lH(e,t,n){let i=new Set,r=[],o=new U(e);for(let s of On(e,t,{semantic:n.semantic,semanticEvidence:pe})){if(r.length>=30)break;let a=s.enclosingSymbol??Ge(o.definitionsForFile(s.file),s.line)?.symbol??null;if(!a||a===t.symbol)continue;let l=ri(e,a);!l||e.isIgnored(l.relativePath)||i.has(l.symbol)||(i.add(l.symbol),r.push({symbol:l.symbol,shortName:k(l.symbol),file:l.relativePath,relationship:`references target at ${s.file}:${s.line+1}`}))}return r.sort((s,a)=>s.file.localeCompare(a.file)),{symbol:t.symbol,shortName:k(t.symbol),direction:"forward",connectedSymbols:r}}function Wv(e){let t=new Set(e.filter(n=>n.definition?.isFunctionLike).map(n=>`${n.role}:${n.definition.relativePath}`));return e.flatMap(n=>n.definition?!n.definition.isFunctionLike&&t.has(`${n.role}:${n.definition.relativePath}`)?[]:[{definition:n.definition,role:n.role}]:[])}var Qv=6,Ga=10,rd=3,od=8,cH=.7,Vv=24,id=200,eC=12,Jv=80,Yv=600;function uH(e,t,n={}){let i=n.impactDepth??3,r=n.sliceDepth??3,o=n.semantic,s=vH(t)?mH(e,t):null,a=s?s.primary?.symbol??null:t,l=a!==null,c=l?qe("trace",a,()=>wc(e,a,{semantic:o,referenceContext:eC}),T=>({definitions:T.definitions.length,references:T.referencedBy.length})):{definitions:[],referencedBy:[],claimSupport:null},u=l?qe("call-graph",a,()=>Vr(e,a,{semantic:o}),T=>({callers:T?.callers.length??0,callees:T?.callees.length??0})):null,d=l?qe("complexity",a,()=>ed(e,a,{semantic:o}),T=>({callees:T?.calleeCount??0})):null,m=l?qe("dataflow",a,()=>nd(e,a,{semantic:o}),T=>({references:T?.usageSites.length??0,producers:T?.producers.length??0,consumers:T?.consumers.length??0})):null,f=l?qe("backward-slice",a,()=>Ua(e,a,{direction:"backward",maxDepth:r,semantic:o}),T=>({maxDepth:r,connectedSymbols:T?.connectedSymbols.length??0})):null,p=l?qe("forward-slice",a,()=>Ua(e,a,{direction:"forward",maxDepth:r,semantic:o}),T=>({maxDepth:r,connectedSymbols:T?.connectedSymbols.length??0})):null,g=l?qe("affected",a,()=>Lu(e,a,{maxDepth:i,scope:n.scope}),T=>({maxDepth:i,affectedSymbols:T.rows.length,coverage:T.coverage.status})):null,h=g?.rows??[],S=g?.coverage??null,v=l?qe("reuse-candidates",a,()=>yo(e,a,{minSimilarity:.4,limit:5,semantic:o,sourceCandidateMode:"target-pruned"}),T=>({candidates:T.length,direct:T.filter(A=>A.actionTier==="direct").length})):[],y=l?fe(e,a)?.symbol??null:null,E=l?qe("affected-consumer-reuse",a,()=>pH(c,y,T=>yo(e,T,{minSimilarity:.4,limit:Ga,semantic:o,sourceCandidateMode:"target-pruned"}),{consumerLimit:Qv,perConsumerSearchLimit:Ga,perConsumerCandidateLimit:rd,candidateLimit:od}),T=>({totalConsumers:T.coverage.totalConsumers,analyzedConsumers:T.coverage.analyzedConsumers,candidates:T.candidates.length})):bH(),w=qe("change-surface",t,()=>Du(e,t,{semantic:o}),T=>({symbols:T?.symbols.length??0,externalConsumers:T?.totalExternalConsumers??0})),b=qe("system",t,()=>iu(e,t),T=>({files:T.files.length,symbols:T.symbols.length})),R=b.files.length===1,C=qe("deps",t,()=>R?b.dependsOn.map(T=>({relativePath:T,edgeBasis:"symbol-references",evidence:"cross-file SCIP references plus resolved source imports"})):Jr(e,t),T=>({files:T.length,reusedSystem:R})),L=qe("rdeps",t,()=>R?b.dependedOnBy.map(T=>({relativePath:T,edgeBasis:"symbol-references",evidence:"cross-file SCIP references plus resolved source imports"})):Yr(e,t),T=>({files:T.length,reusedSystem:R})),I=qe("surface",t,()=>ru(e,t),T=>({consumers:T.length})),x={symbol:c.definitions.length>0||c.referencedBy.length>0||u!==null||d!==null||m!==null||f!==null||p!==null||h.length>0,file:w!==null||C.length>0||L.length>0,module:b.files.length>0||b.symbols.length>0||I.length>0},P=[];s&&!s.primary&&s.callableCount>1&&P.push(`File target has ${s.callableCount} callable symbols; use one callable name for compiler-resolved flow.`);let _=[...new Set(c.referencedBy.map(T=>T.relativePath))];_.length>0&&_.every(T=>V(T)==="test")&&P.push("Only test references were found for this target. For replacement or retirement work, map the currently wired owner or one production entry point before planning; this target does not describe the live affected surface."),!x.symbol&&!x.file&&!x.module&&P.push("No symbol, file, or module matched target."),S&&S.status!=="accounted"&&P.push(`Possible-impact coverage is ${S.status}: ${S.reasons.join(" ")}`);let D=w?.file??c.definitions[0]?.relativePath??null;return{target:t,...s?.primary?{primaryCallable:{symbol:s.primary.symbol,shortName:re(s.primary.symbol),file:s.primary.relativePath}}:{},matched:x,history:qe("history",D??t,()=>SH(e,D,n.gitHead)),trace:dH(c),callGraph:u,complexity:d,dataflow:m,backwardSlice:f,forwardSlice:p,affected:h,affectedCoverage:S,changeSurface:w,deps:C,rdeps:L,system:b,surface:I,reuseCandidates:v,affectedConsumerReuse:E,sourcePacket:fH(e,y,c,E,v),warnings:P}}function dH(e){return{definitions:e.definitions,referencedBy:e.referencedBy.map(t=>({relativePath:t.relativePath,line:t.line,enclosingSymbol:t.enclosingSymbol,enclosingShort:t.enclosingShort}))}}function mH(e,t){let n=bn(e,t);if(n.length!==1)return{primary:null,callableCount:0};let i=J(e,n[0]).filter(s=>s.isFunctionLike),r=i.filter(s=>s.enclosingSymbol===null),o=r.length>0?r:i;return{primary:o.length===1?o[0]:null,callableCount:o.length}}function fH(e,t,n,i,r){let o=[...t?[{definition:Xv(e,t),role:"target"}]:[],...[...i.candidates.map(d=>d.candidate),...r].map(d=>({definition:Xv(e,d.symbolB),role:"reuse-candidate"}))],s=new Map;for(let d of Wv(o)){if(s.has(d.definition.symbol))continue;let m=d.role==="target"?id:Jv,f=d.definition.endLine<=d.definition.startLine?jn(e,d.definition.relativePath,d.definition.startLine,m):null,p=f?.unitType?f.source:Vt(e,d.definition);if(!p)continue;let g=p.split(`
429
+ `),h=Math.min(g.length,m),S=f?.unitType?f.startLine:d.definition.startLine;s.set(d.definition.symbol,{role:d.role,symbol:d.definition.symbol,shortName:re(d.definition.symbol),file:d.definition.relativePath,startLine:S,endLine:S+h-1,source:g.slice(0,h).join(`
430
+ `),omittedLines:(f?.unitType?f.omittedLines:0)+Math.max(0,g.length-h)})}let a=new Map;for(let d of n.referencedBy){if(d.source===void 0||d.source===null||d.sourceStartLine===void 0||d.sourceStartLine===null||d.sourceEndLine===void 0||d.sourceEndLine===null)continue;let m=`${d.relativePath}:${d.sourceStartLine}-${d.sourceEndLine}`,f=a.get(m);if(f){f.focusLines=[...new Set([...f.focusLines??[],d.line])].sort((p,g)=>p-g);continue}a.set(m,{role:"consumer",symbol:d.enclosingSymbol??`${d.relativePath}:${d.line}`,shortName:d.enclosingShort,file:d.relativePath,startLine:d.sourceStartLine,endLine:d.sourceEndLine,source:d.source,omittedLines:0,focusLines:[d.line]})}let l=[...[...s.values()].filter(d=>d.role==="target"),...a.values(),...[...s.values()].filter(d=>d.role==="reuse-candidate")],c=[],u=Yv;for(let d of l){if(c.length>=Vv||u<=0)break;let m=d.source.split(`
431
+ `),f=Math.min(m.length,u);c.push({...d,endLine:d.startLine+f-1,source:m.slice(0,f).join(`
432
+ `),omittedLines:d.omittedLines+Math.max(0,m.length-f),...d.focusLines?{focusLines:d.focusLines.filter(p=>p<=d.startLine+f-1)}:{}}),u-=f}return{slices:c,candidateSlices:l.length,omittedSlices:Math.max(0,l.length-c.length),maxSlices:Vv,maxLinesPerSlice:id,maxTotalLines:Yv,targetLineLimit:id,consumerContextLines:eC,reuseLineLimit:Jv}}function Xv(e,t){let n=ri(e,t);return n?J(e,n.relativePath).find(i=>i.symbol===t)??null:null}function pH(e,t,n,i={}){let r=za(i.consumerLimit,Qv),o=za(i.perConsumerSearchLimit,Ga),s=za(i.perConsumerCandidateLimit,rd),a=za(i.candidateLimit,od),l=gH(e),c=l.slice(0,r),u=new Set(l.map(f=>f.symbol));t&&u.add(t);let d=new Map;for(let f of c){let p=n(f.symbol).slice(0,o),g=0;for(let h of p){let S=hH(h,f.symbol);if(!S||u.has(S.symbolB))continue;let v=d.get(S.symbolB);if(v?(v.consumers.some(y=>y.symbol===f.symbol)||v.consumers.push(f),S.similarity>v.candidate.similarity&&(v.candidate=S)):d.set(S.symbolB,{candidate:S,consumers:[f]}),g+=1,g>=s)break}}let m=[...d.values()].filter(f=>f.candidate.actionTier==="direct"||f.candidate.similarity>=cH||f.consumers.length>1).sort(yH).slice(0,a);return{candidates:m,coverage:{totalConsumers:l.length,analyzedConsumers:c.length,omittedConsumers:Math.max(0,l.length-c.length),perConsumerSearchLimit:o,perConsumerCandidateLimit:s,candidateLimit:a,returnedCandidates:m.length}}}function gH(e){let t=new Map;for(let n of e.referencedBy){if(!n.enclosingSymbol)continue;let i=t.get(n.enclosingSymbol);if(i){i.referenceCount+=1;continue}t.set(n.enclosingSymbol,{symbol:n.enclosingSymbol,shortName:re(n.enclosingSymbol)||n.enclosingShort,file:n.relativePath,referenceCount:1})}return[...t.values()].sort((n,i)=>i.referenceCount-n.referenceCount||n.symbol.localeCompare(i.symbol))}function hH(e,t){return e.symbolA===t?e:e.symbolB!==t?null:{...e,symbolA:e.symbolB,shortNameA:e.shortNameB,fileA:e.fileB,symbolB:e.symbolA,shortNameB:e.shortNameA,fileB:e.fileA,uniqueToA:e.uniqueToB,uniqueToB:e.uniqueToA}}function yH(e,t){let n=Zv(t.candidate.actionTier)-Zv(e.candidate.actionTier);if(n!==0)return n;let i=t.consumers.length-e.consumers.length;if(i!==0)return i;let r=t.candidate.similarity-e.candidate.similarity;return r!==0?r:e.candidate.symbolB.localeCompare(t.candidate.symbolB)}function Zv(e){return e==="direct"?1:0}function za(e,t){return typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.floor(e)):t}function bH(){return{candidates:[],coverage:{totalConsumers:0,analyzedConsumers:0,omittedConsumers:0,perConsumerSearchLimit:Ga,perConsumerCandidateLimit:rd,candidateLimit:od,returnedCandidates:0}}}function qe(e,t,n,i=()=>({})){let r;return $(`context.${e}`,()=>(r=n(),r),()=>({target:t,...i(r)}))}function SH(e,t,n){let i={available:!1,file:t,churn:null,coChangePartners:[],suppressionsInFile:0};if(!t)return i;let r=Wt(e,n?{head:n}:{}),o=qe("history.churn",t,()=>r.fileChurn(),l=>({files:l?.size??0}));if(!o)return i;let s=qe("history.co-change",t,()=>wo(e,t,{limit:5,...n?{head:n}:{}}),l=>({commits:l.commitsAnalyzed,partners:l.findings.length})),a=qe("history.suppressions",t,()=>Ha(e).byFile.get(t)??0,l=>({suppressions:l}));return{available:!0,file:t,churn:o.get(t)??{changes:0,fixChanges:0,lastChangedAt:0},coChangePartners:s.findings.map(l=>({file:l.fileA===t?l.fileB:l.fileA,together:l.together,confidence:l.confidence,subjectContext:l.subjectContext})),suppressionsInFile:a}}function vH(e){return e.includes("/")||e.includes("\\")||/\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/.test(e)}var Oe={dead:{minLoc:3,skipBarrels:!0,deadCodeOnly:!0},isolated:{minLoc:3},similar:{minSimilarity:.6,limit:50,minCallees:4},duplicateBodies:{maxLoc:15,limit:50},extract:{minLoc:15,minCallees:5,limit:50},wrappers:{maxLoc:15,limit:50},passthroughs:{maxLoc:15,limit:50},stale:{minLoc:3,limit:50},drift:{},twinDrift:{minSimilarity:.3}};import{existsSync as CH}from"fs";import{isAbsolute as xH,join as RH}from"path";var EH=".codebaseiq-baseline.json";function sd(e){if(e.startsWith("similar:")){let t=e.slice(8).split("|");return t.length!==2?e:`similar:${t.map(k).sort().join("|")}`}if(e.startsWith("duplicate-bodies:")){let t=e.slice(17),n=t.indexOf(":");if(n<0)return e;let i=t.slice(0,n),r=t.slice(n+1).split("|");return r.length<2?e:`duplicate-bodies:${i}:${r.map(k).sort().join("|")}`}return e}function ad(e,t){return t&&xH(t)?t:RH(e.config.projectRoot,t??EH)}function tC(e,t,n={}){let i=ad(e,n.path);if(!CH(i))throw new Error(`No baseline found at ${i}. Create one with: codebaseiq health --write-baseline`);let o=(JSON.parse(gr(i,"health baseline")).findings??[]).map(sd),s=new Set(n.accept?o.filter(n.accept):o),a=new Set(t);return{baselinePath:i,baselineCount:s.size,current:[...t],newFindings:t.filter(l=>!s.has(l)),fixedFindings:[...s].filter(l=>!a.has(l))}}import Fo from"path";function Ao(e,t){let{scope:n,minDeviation:i=5,limit:r=50}=t??{},o=t?.semantic!==!1,s=t?.includePatternDeviations===!0,l=new U(e).fileDependencyGraph(n),c=fo(e,{scope:n}),u=PH([...wH(e,l,{scope:n,semantic:o}),...LH(c.forbiddenEdges),...s?DH(l,i):[]]);return t?.includeArchitecture===!0&&(u.architecture=c),r<=0||u.results.length<=r?u:{...u,results:u.results.slice(0,r),totalResults:u.results.length}}function wH(e,t,n){let i=MH(e,n.scope),r=[],o=new Set;for(let[a,l]of t){if(Mo(a))continue;let c=i.get(a)??new Set;for(let u of l)Mo(u)||c.has(u)||IH(e,a,u,n)||(r.push({file:a,dep:u}),o.add(a))}o.size>0&&kH(e,i,{paths:[...o]});let s=[];for(let{file:a,dep:l}of r)(i.get(a)??new Set).has(l)||s.push({file:a,kind:"unused-import",description:`Depends on ${l} but references none of its symbols`,dep:l,actionTier:"direct",evidenceReasons:[`dependency edge exists from ${a} to ${l}`,"no semantic, source, type-only, side-effect, or Vue-template usage survived the conservative skip gates"],recommendation:"Remove the unused import or dependency edge after running the project checks."});return s}function IH(e,t,n,i){return OH(e,t,n)||$H(e,t,n)||_H(n)||HH(e,t,n)||jH(n)?!0:i.semantic&&BH(e,t,n)}function LH(e){return e.flatMap(t=>{let n=t.examples[0];return n?[{file:n.fromFile,kind:"architecture-violation",description:`${t.from} depends on forbidden boundary ${t.to} through ${t.fileEdgeCount} file edge(s)`,dep:n.toFile,detail:`${t.from} may not depend on ${t.to}`,actionTier:"direct",policyBasis:"explicit",architecture:{fromBoundary:t.from,toBoundary:t.to,fileEdgeCount:t.fileEdgeCount,importerCount:t.importerCount,importedFileCount:t.importedFileCount,examples:t.examples},evidenceReasons:[`configured dependency row for ${t.from} does not allow ${t.to}`,`${t.fileEdgeCount} file edge(s) connect ${t.importerCount} importer(s) to ${t.importedFileCount} imported file(s)`,...t.examples.map(i=>`${i.fromFile} imports ${i.toFile}`)],recommendation:"Move the dependency behind an allowed boundary, reverse the dependency through an owned interface, or deliberately update the project architecture rule."}]:[]})}function DH(e,t){let n=[];for(let[i,r]of TH(e)){let o=r.filter(a=>!Mo(a));if(o.length<t)continue;let s=FH(e,o);for(let a of o)for(let l of e.get(a)??[])Mo(l)||(s.get(l)??0)===1&&Fo.dirname(l)!==i&&Fo.dirname(l)!==Fo.dirname(i)&&n.push({file:a,kind:"pattern-deviation",description:`Only file in ${i}/ that depends on ${l}`,dep:l,actionTier:"signal",evidenceReasons:[`${o.length} sibling file(s) in ${i}/ were compared`,`${a} is the only non-skipped sibling depending on ${l}`],recommendation:"Review sibling ownership before changing this import; unique dependency shape can be intentional specialization."})}return n}function PH(e){let t=e.filter(n=>n.kind==="architecture-violation").length;return{results:e,unusedImports:e.filter(n=>n.kind==="unused-import").length,architectureViolations:t,layerViolations:t,patternDeviations:e.filter(n=>n.kind==="pattern-deviation").length}}function TH(e){let t=new Map;for(let n of e.keys()){let i=Fo.dirname(n),r=t.get(i);r||(r=[],t.set(i,r)),r.push(n)}return t}function FH(e,t){let n=new Map;for(let i of t)for(let r of e.get(i)??[])Mo(r)||n.set(r,(n.get(r)??0)+1);return n}function MH(e,t){let n=new Map;return AH(e,n,t),n}function AH(e,t,n){for(let i of NH(e,n))nC(e,t,i.from_file,i.to_file)}function NH(e,t){let n=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[];return e.all(`SELECT DISTINCT d1.relative_path AS from_file, d2.relative_path AS to_file
433
+ FROM mentions m
434
+ JOIN chunks c ON m.chunk_id = c.id
435
+ JOIN documents d1 ON c.document_id = d1.id
436
+ JOIN global_symbols gs ON m.symbol_id = gs.id
437
+ JOIN (
438
+ SELECT m2.symbol_id, c2.document_id
439
+ FROM mentions m2
440
+ JOIN chunks c2 ON m2.chunk_id = c2.id
441
+ WHERE m2.role = 1
442
+ GROUP BY m2.symbol_id
443
+ ) sym_def ON sym_def.symbol_id = gs.id
444
+ JOIN documents d2 ON sym_def.document_id = d2.id
445
+ WHERE d1.id != d2.id
446
+ AND m.role != 1
447
+ ${e.pathExclusionsFor("d1","d2")}
448
+ ${n}`,...i)}function kH(e,t,n={}){new U(e).scanSourceReferences({paths:n.paths??he(e,{includeIgnored:!1}),includeRustAttributeNames:!0,identifierResolution:"permissive"},r=>{r.target.relativePath!==r.sourceFile&&(e.isIgnored(r.target.relativePath)||nC(e,t,r.sourceFile,r.target.relativePath))})}function nC(e,t,n,i){if(e.isIgnored(n)||e.isIgnored(i))return;let r=t.get(n);r||(r=new Set,t.set(n,r)),r.add(i)}function _H(e){return e.includes("types")||e.endsWith(".d.ts")}function BH(e,t,n){let i=$r(e,t).filter(r=>r.sourcePath===n);return i.length>0&&i.some(r=>r.isUsed)}function OH(e,t,n){let i=Ce(e,t).filter(r=>r.sourcePath===n);return i.length>0&&i.some(r=>r.used)}function $H(e,t,n){let i=Ce(e,t).filter(r=>r.sourcePath===n);return i.length>0&&i.every(r=>r.isTypeOnly===!0)}function jH(e){return e.endsWith(".vue")}function HH(e,t,n){let i=Ce(e,t).filter(r=>r.sourcePath===n);return i.length===0?!1:i.every(r=>r.kind==="side-effect"||r.kind==="namespace"&&r.usedMembers.length===0&&!r.used)}function Mo(e){let t=V(e);return!!(t==="entry"||t==="barrel"||t==="test"||t==="worker"||UH(Fo.basename(e)))}function UH(e){return!!(e==="index.ts"||e==="index.js"||e==="cli.ts"||e==="main.ts"||e==="main.rs"||e.includes("worker.")||e.includes("postinstall.")||e==="health.ts"||e==="health.js")}function No(e,t){let{scope:n,minLoc:i=3,maxLoc:r=80,limit:o=30,includeLowConfidence:s=!1,scanLimit:a}=t??{},l=t?.semantic!==!1,c=new U(e),u=c.scopedDefinitions(n),d=eU(c,n),m={high:0,medium:1,low:2};return Ot({candidates:()=>zH(e,c,u,{minLoc:i,maxLoc:r}),orderCandidates:(f,p)=>de(p)-de(f)||f.relativePath.localeCompare(p.relativePath),scanLimit:a,profile:{name:"stale-abstractions"},prepare:f=>{let p=KH(f),g=GH(e,c,f,p,{semantic:l}),h=f.filter(S=>{if(g.incompleteSymbolIds.has(S.symbolId)||g.unavailableSymbolIds.has(S.symbolId)||c.hasSuppressionComment(S))return!1;let v=Ka(e,S,g.consumerFileMap,p);return v.realConsumers.length<=1&&!v.transitivelyReachable&&rC(S,v.realConsumers.length,d)});return{...g,singletonBackedClassIds:VH(e,c,u,h,{semantic:l}),candidateIndex:p}},evaluate:(f,p)=>{if(p.incompleteSymbolIds.has(f.symbolId)||p.unavailableSymbolIds.has(f.symbolId)||c.hasSuppressionComment(f)||p.singletonBackedClassIds.has(f.symbolId))return null;let g=Ka(e,f,p.consumerFileMap,p.candidateIndex);if(g.transitivelyReachable||g.realConsumers.length>1||g.realConsumers.length===0&&g.barrelConsumers>0||!rC(g.definition,g.realConsumers.length,d))return null;let h=qH(e,g);return!s&&h.confidence==="low"?null:h},orderResults:(f,p)=>m[f.confidence]-m[p.confidence]||p.loc-f.loc||f.file.localeCompare(p.file)||f.startLine-p.startLine,limit:o})}function zH(e,t,n,i){return n.filter(r=>r.isTypeLike&&de(r)>=i.minLoc).filter(r=>de(r)<=i.maxLoc).filter(r=>!e.isIgnored(r.relativePath)).filter(r=>!r.relativePath.endsWith(".d.ts")).filter(r=>V(r.relativePath)!=="test").filter(r=>!Ue(e,r.symbol,r.relativePath)).filter(r=>!tU(r.symbol))}function iC(e,t,n,i){return Qn(un(e,t).forDefinitions(n,{semantic:i.semantic,sourceFallback:i.sourceFallback}))}function GH(e,t,n,i,r){let o=iC(e,t,n,{semantic:!1,sourceFallback:!1}),s=n.filter(m=>{let f=Ka(e,m,o,i);return f.realConsumers.length<=1&&!(f.realConsumers.length>0&&ld(m.relativePath))}),a=un(e,t).forDefinitions(s,{semantic:r.semantic,sourceFallback:!1}),l=new Set([...a.values()].filter(m=>m.semanticIncomplete).map(m=>m.definition.symbolId)),c=new Set([...a.values()].filter(m=>m.semanticUnavailable).map(m=>m.definition.symbolId)),u=r.semantic&&s.length>0?pi(o,Qn(a)):o,d=s.filter(m=>Ka(e,m,u,i).realConsumers.length<=1);return{consumerFileMap:pi(u,iC(e,t,d,{semantic:!1,sourceFallback:!0})),incompleteSymbolIds:l,unavailableSymbolIds:c}}function KH(e){let t=new Map;for(let n of e){let i=t.get(n.relativePath);i||(i=new Map,t.set(n.relativePath,i));let r=re(n.symbol);r&&i.set(r,n)}return t}function Ka(e,t,n,i){let o=[...n.get(t.symbolId)??new Set].filter(u=>u!==t.relativePath&&!e.isIgnored(u)),{realConsumers:s,barrelConsumers:a,importOnlyConsumers:l}=La(e,t,o),c=nU(e,t,n,i);return{definition:t,realConsumers:s,barrelConsumers:a+l,transitivelyReachable:c}}function qH(e,t){let n=sC(e,t.definition.relativePath,t.definition.startLine),i=ld(t.definition.relativePath)?!0:iU(e,t.definition),{confidence:r,reason:o}=rU(t.realConsumers.length,n,i),s=WH(t.realConsumers.length,n,i);return{symbol:t.definition.symbol,shortName:k(t.definition.symbol),file:t.definition.relativePath,startLine:t.definition.startLine,endLine:t.definition.endLine,loc:de(t.definition),consumers:t.realConsumers.length,barrelConsumers:t.barrelConsumers,kind:n,definerUsesType:i,confidence:r,reason:o,actionTier:s.actionTier,stalenessKind:s.stalenessKind,recommendation:s.recommendation}}function WH(e,t,n){return e===0?{actionTier:"direct",stalenessKind:"unused-abstraction",recommendation:"Delete the abstraction or wire the missing consumer after checking public/package surfaces."}:t==="class"?{actionTier:"signal",stalenessKind:"one-to-one-class-encapsulation",recommendation:"Treat as weak signal: a one-consumer class may be intentional encapsulation, so inline only after reviewing ownership and state boundaries."}:n?{actionTier:"signal",stalenessKind:"single-consumer-abstraction",recommendation:"Review whether this single-consumer abstraction earns its name or should be folded into the owning feature."}:{actionTier:"signal",stalenessKind:"misplaced-single-consumer-type",recommendation:"Review moving or co-locating the type with its only real consumer; keep it here only if this file owns the public contract."}}function VH(e,t,n,i,r){let o=YH(e,JH(n),i),s=o.map(u=>u.singleton);if(o.length===0)return new Set;let a=un(e,t).forDefinitions(s,{semantic:r.semantic,sourceFallback:!0}),l=Qn(a),c=new Set;for(let{singleton:u,classId:d}of o){let m=a.get(u.symbolId);(m?.semanticIncomplete||m?.semanticUnavailable||ZH(e,u,l))&&c.add(d)}return c}function JH(e){let t=new Map;for(let n of e){let i=re(n.symbol);i&&t.set(oC(n.relativePath,i),n)}return t}function YH(e,t,n){let i=[];for(let r of n){let o=XH(e,t,r);o&&i.push({singleton:o,classId:r.symbolId})}return i}function XH(e,t,n){if(sC(e,n.relativePath,n.startLine)!=="class")return null;let i=re(n.symbol);if(!i)return null;let r=QH(e,n.relativePath,i);return r?t.get(oC(n.relativePath,r))??null:null}function ZH(e,t,n){let i=re(t.symbol),r=n.get(t.symbolId);return!i||!r?!1:[...r].some(o=>o!==t.relativePath&&!e.isIgnored(o)&&!Cu(e,o,i))}function oC(e,t){return`${e}\0${t}`}function QH(e,t,n){let i=se(e,t);if(!i)return null;let r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`\\bexport\\s+const\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*new\\s+${r}\\s*\\(`);return i.match(o)?.[1]??null}function eU(e,t){return new Set(e.scopedDefinitions(t).filter(n=>n.isFunctionLike).map(n=>n.relativePath))}function tU(e){let t=Ni(e);if("kind"in t)return!1;let n=t.descriptors;if(n.length<2)return!1;let i=n[n.length-1],r=n[n.length-2];return i?.suffix==="type"&&r?.suffix==="type"}function ld(e){let n=(e.split("/").pop()??"").replace(/\.[^.]+$/,"");return!!(n==="types"||n.endsWith("-types")||n==="models"||n==="schema"||n==="common"||n==="protocol"||n==="proto"||n==="dto"||n==="mod"||n==="contracts"||/(^|\/)types(\/|\.)/.test(e)||/(^|\/)models?(\/|\.)/.test(e)||/(^|\/)proto(?:col)?(\/|\.)/.test(e)||/(^|\/)schema(\/|\.)/.test(e)||/(^|\/)contracts?(\/|\.)/.test(e))}function rC(e,t,n){return!(ld(e.relativePath)&&t>0||t===0&&n.has(e.relativePath))}function nU(e,t,n,i){let r=sm(e,t.relativePath),o=re(t.symbol);if(!o)return!1;let s=i.get(t.relativePath);if(!s)return!1;let a=[...r.get(o)??[]],l=new Set;for(;a.length>0;){let c=a.pop();if(l.has(c))continue;l.add(c);let u=s.get(c);if(!u)continue;let d=n.get(u.symbolId);if(d){for(let m of d)if(m!==t.relativePath&&!e.isIgnored(m))return!0}for(let m of r.get(c)??[])a.push(m)}return!1}function sC(e,t,n){let i=se(e,t);if(!i)return"other";let r=i.split(`
449
+ `),o=Math.max(0,n-2),s=Math.min(r.length-1,n+2);for(let a=o;a<=s;a++){let c=(r[a]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(c))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(c))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(c))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(c))return"enum"}return"other"}function iU(e,t){let n=se(e,t.relativePath);if(!n)return!1;let i=re(t.symbol);if(!i)return!1;let r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`\\b${r}\\b`),s=n.split(`
450
+ `);for(let a=0;a<s.length;a++)if(!(a>=t.startLine&&a<=t.endLine)&&o.test(s[a]??""))return!0;return!1}function rU(e,t,n){return e===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:e===1&&t==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:e===1&&!n?{confidence:"high",reason:"1 consumer + defining file never uses it \u2014 type belongs with its consumer"}:{confidence:"medium",reason:"1 consumer \u2014 single-use abstraction"}}import{basename as mr,extname as qa}from"path";function ko(e,t){let{scope:n,maxLoc:i=15,limit:r=30,scanLimit:o}=t??{},s=new U(e),a=uU(s.fileDependencyGraph(n));return Ot({candidates:()=>aU(e,s,n,i),orderCandidates:Ys,scanLimit:o,profile:{name:"wrapper-candidates"},prepare:l=>({...oU(e,s,l,{semantic:t?.semantic!==!1}),reverseFanIn:a}),evaluate:(l,c)=>sU(e,s,l,c),orderResults:(l,c)=>c.callerFanIn-l.callerFanIn||c.loc-l.loc,limit:r})}function oU(e,t,n,i){let r=un(e,t),o=Qn(r.forDefinitions(n,{semantic:!1,sourceFallback:!1})),s=[];i.semantic&&$("wrapper.semantic-candidates",()=>{s=n.filter(h=>cd(e,t,h,o).length<=1)},()=>({symbols:n.length,semanticCandidates:s.length}));let a=r.forDefinitions(s,{semantic:!0,sourceFallback:!1}),l=Qn(a),c=new Set([...a.values()].filter(h=>h.semanticIncomplete).map(h=>h.definition.symbolId)),u=new Set([...a.values()].filter(h=>h.semanticUnavailable).map(h=>h.definition.symbolId)),d=l.size===0?o:pi(o,l),m=new Map(n.map(h=>[h.symbolId,h])),f=new Map;for(let h of n){let S=cd(e,t,h,d);if(S.length>1||(f.set(h.symbolId,h),S.length!==1))continue;let v=S[0],y=aC(e,h.symbolId,v);if(!y)continue;let E=lC(t,e,v,h.symbol,y);E?.isFunctionLike&&m.has(E.symbolId)&&f.set(E.symbolId,m.get(E.symbolId))}let p=[...f.values()];return{callerFileMap:p.length===0?d:pi(d,Qn(r.forDefinitions(p,{semantic:!1,sourceFallback:!0}))),incompleteSymbolIds:c,unavailableSymbolIds:u}}function sU(e,t,n,i){if(i.incompleteSymbolIds.has(n.symbolId)||i.unavailableSymbolIds.has(n.symbolId))return null;let r=cd(e,t,n,i.callerFileMap);if(r.length!==1)return null;let o=r[0],s=aC(e,n.symbolId,o);if(!s)return null;let a=lC(t,e,o,n.symbol,s);if(a&&ki(a.symbol))return null;let{fanIn:l,source:c}=lU(i.callerFileMap,i.reverseFanIn,o,a);if(c==="function"?l<=3:l<=5)return null;let u=mU(e,n,o,a);return{symbol:n.symbol,shortName:k(n.symbol),file:n.relativePath,startLine:n.startLine,endLine:n.endLine,loc:de(n),singleCaller:a?.symbol??"",singleCallerShort:a?.isFunctionLike?k(a.symbol):mr(o),callerFanIn:l,actionTier:u.length>0?"signal":"direct",boundaryEvidence:u}}function aU(e,t,n,i){return t.productionCallableDefinitions({scope:n,minLoc:2,maxLoc:i,requireFunctionLikeSymbol:!0,excludeRootedSymbols:!0,excludeRustTraitImplMembers:!0}).filter(r=>!qo(e,r))}function cd(e,t,n,i){let r=mr(n.relativePath,qa(n.relativePath)),o=[...i.get(n.symbolId)??[]].filter(s=>s!==n.relativePath).filter(s=>mr(s,qa(s))!==r).filter(s=>{let a=t.fileKind(s);return a!=="barrel"&&a!=="entry"&&a!=="test"});return La(e,n,o).realConsumers}function aC(e,t,n){return e.get(`SELECT c.start_line, c.end_line
451
+ FROM mentions m
452
+ JOIN chunks c ON m.chunk_id = c.id
453
+ JOIN documents d ON c.document_id = d.id
454
+ WHERE m.symbol_id = ? AND m.role != 1 AND d.relative_path = ?
455
+ LIMIT 1`,t,n)}function lC(e,t,n,i,r){let o=e.definitionsForFile(n),s=cU(t,n,i,r.start_line,r.end_line);return Ge(o,s)}function lU(e,t,n,i){if(i?.isFunctionLike){let r=[...e.get(i.symbolId)??[]].filter(o=>o!==i.relativePath);if(r.length>0)return{fanIn:r.length,source:"function"}}return{fanIn:dU(t,n),source:"file"}}function cU(e,t,n,i,r){let o=re(n);if(!o)return i;let s=Oi(e,t).get(o);if(!s||s.length===0)return i;for(let a of s)if(a>=i&&a<=r)return a;return i}function uU(e){let t=new Map;for(let[n,i]of e){t.has(n)||t.set(n,t.get(n)??0);for(let r of i)t.set(r,(t.get(r)??0)+1)}return t}function dU(e,t){let n=e.get(t)??0;if(n>0)return n;let i=mr(t,qa(t)),r=0;for(let[o,s]of e)o!==t&&mr(o,qa(o))===i&&s>r&&(r=s);return r}function mU(e,t,n,i){return Oa(e,t.relativePath,t.startLine,"wrapper","explicit ignore-wrapper comment",[{label:"wrapper name",value:k(t.symbol)},{label:"caller name",value:i?.symbol?k(i.symbol):mr(n)},{label:"wrapper path",value:t.relativePath},{label:"caller path",value:n}])}var fU=25e3,pU=2500,gU=2500;function hU(e){let t=mi(e);return t.symbols>=fU||t.documents>=pU?gU:void 0}function ud(e,t={}){let{scope:n}=t,i=hU(e),r=[],o=wi(e,{scope:n,...Oe.dead,scanLimit:i});for(let s of o.symbols)Ye(e,s.relativePath)||Ue(e,s.symbol,s.relativePath)||s.kind==="dead-code"&&r.push(`dead:${s.relativePath}:${s.shortName}`);for(let s of po(e,{scope:n,...Oe.isolated,scanLimit:i}))Ye(e,s.relativePath)||Ue(e,s.symbol,s.relativePath)||r.push(`isolated:${s.relativePath}:${s.shortName}`);for(let s of mo(e,{scope:n}))s.kind==="real"&&r.push(`cycle:${yU(s.path)}`);for(let s of bo(e,{scope:n,...Oe.similar,scanLimit:i}))r.push(`similar:${[s.symbolA,s.symbolB].sort().join("|")}`);for(let s of Lo(e,{scope:n,...Oe.duplicateBodies,scanLimit:i}))r.push(`duplicate-bodies:${s.hash}:${s.functions.map(a=>a.symbol).sort().join("|")}`);for(let s of Ro(e,{scope:n,...Oe.extract,scanLimit:i}))r.push(`extract:${s.relativePath}:${s.shortName}`);for(let s of ko(e,{scope:n,...Oe.wrappers,scanLimit:i}))r.push(`wrapper:${s.file}:${s.shortName}`);for(let s of Do(e,{scope:n,...Oe.passthroughs,scanLimit:i}))r.push(`passthrough:${s.file}:${s.shortName}`);for(let s of No(e,{scope:n,...Oe.stale,scanLimit:i}))r.push(`stale:${s.file}:${s.shortName}`);for(let s of Ao(e,{scope:n,...Oe.drift,includePatternDeviations:!1,limit:Number.POSITIVE_INFINITY}).results)s.kind!=="architecture-violation"&&r.push(`drift:${s.kind}:${s.file}:${s.dep}`);return r.push(...uu(fo(e,{scope:n}))),[...new Set(r.map(sd))].sort()}function yU(e){if(e.length===0)return"";let t=0;for(let n=1;n<e.length;n++)e[n]<e[t]&&(t=n);return[...e.slice(t),...e.slice(0,t)].join(">")}function bU(e,t={}){let n=ud(e,{scope:t.scope}),i=ad(e,t.path);return Jd(i,{version:1,findings:n},{spacing:2,trailingNewline:!0}),{path:i,findingCount:n.length}}function SU(e,t={}){return tC(e,ud(e,{scope:t.scope}),{path:t.path})}function vU(e,t={}){let{scope:n,limit:i=30,scanLimit:r}=t,o=new U(e);return Ot({candidates:()=>o.productionCallableDefinitions({scope:n,files:t.files,minLoc:2,excludeRootedSymbols:!0,requireFunctionLikeSymbol:!0}),filterCandidate:s=>CU(s.relativePath),scanLimit:r,profile:{name:"unused-params"},evaluate:s=>{let a=ee(e,s.relativePath)?.callables.find(u=>u.startLine===s.startLine&&u.endLine===s.endLine);if(!a||a.params.length===0||a.params.some(u=>!u.simple)||a.paramsEndLine>=a.endLine)return null;let l=Oi(e,s.relativePath),c=[];for(let u=a.params.length-1;u>=0;u--){let d=a.params[u];if(d.name===""||d.name.startsWith("_")||xU(l.get(d.name),a.paramsEndLine,a.endLine))break;c.unshift(d.name)}return c.length===0?null:{symbol:s.symbol,shortName:k(s.symbol),file:s.relativePath,startLine:s.startLine,endLine:s.endLine,paramCount:a.paramCount,unusedTrailing:c}},orderResults:(s,a)=>a.unusedTrailing.length-s.unusedTrailing.length||s.file.localeCompare(a.file)||s.startLine-a.startLine,limit:i})}function CU(e){let t=ye(e);return t==="typescript"||t==="tsx"||t==="javascript"}function xU(e,t,n){return e?e.some(i=>i>t&&i<=n):!1}var RU=new Set(Zt());function dd(e,t){let{scope:n,minLoc:i=10,limit:r=30,scanLimit:o}=t??{},s=new U(e),a=t?.semantic!==!1,l=cC(a,new Set,new Set);return{rows:Ot({candidates:()=>s.productionCallableDefinitions({scope:n,minLoc:i,requireFunctionLikeSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof o=="number"&&o>0}),scanLimit:o,filterCandidate:EU,profile:{name:"complexity-hotspots"},prepare:u=>{let d=IU(e,u);(a?kt(e):null)?.materializeReferences(u,{prefetchCallees:!0});let f=Qt(e,u,{semantic:a,semanticEvidence:pe}),p=s.calleeEvidenceMap(u,{semantic:a}),g=new Set([...f.incompleteSymbolIds,...p.incompleteSymbolIds]),h=new Set([...f.unavailableSymbolIds,...p.unavailableSymbolIds]);l=cC(a,g,h);let S=new Map(u.map(v=>[v.symbolId,v]));return{callerMap:new Map([...f.rows].map(([v,y])=>[v,new Set(y.filter(E=>E.file!==S.get(v)?.relativePath).map(E=>E.file))])),calleeMap:p.rows,incompleteSymbolIds:g,unavailableSymbolIds:h,languageByFile:d,clojureCallableIds:LU(e,u,d),branchEstimates:$v(e,u)}},evaluate:(u,d)=>d.incompleteSymbolIds.has(u.symbolId)||d.unavailableSymbolIds.has(u.symbolId)?null:wU(u,d,i),orderResults:(u,d)=>d.score-u.score||d.loc-u.loc,limit:r}),coverage:l}}function cC(e,t,n){let i=new Set([...t,...n]).size,r=e?t.size>0&&n.size>0?"incomplete-and-unavailable":t.size>0?"incomplete":n.size>0?"unavailable":"complete":"disabled";return{semanticEvidence:{enabled:e,status:r,incompleteSymbolCount:t.size,unavailableSymbolCount:n.size,excludedSymbolCount:i}}}function EU(e){return e.symbol.startsWith("rust-analyzer ")?typeof e.kind=="number"&&RU.has(e.kind):!0}function wU(e,t,n){if(t.languageByFile.get(e.relativePath)==="clojure"&&!t.clojureCallableIds.has(e.symbolId))return null;let i=e.endLine-e.startLine+1;if(i<n)return null;let r=t.callerMap.get(e.symbolId)?.size??0,o=t.calleeMap.get(e.symbolId)??[],s=new Set,a=new Set;for(let m of o){let f=`${m.symbol}|${m.file}`;s.add(f),m.file!==e.relativePath&&a.add(f)}let l=a.size,c=s.size,u=t.branchEstimates.get(e.symbolId)??{branches:0,estimateBasis:"regex-fallback"},d=u.branches+1;return{symbol:e.symbol,shortName:k(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:i,fanIn:r,fanOut:l,calleeCount:c,branches:u.branches,estimateBasis:u.estimateBasis,score:Math.round(i/50*(r/5)*Math.max(l/5,1)*Math.max(d/5,1)*100)/100}}function IU(e,t){let n=[...new Set(t.map(o=>o.relativePath))];if(n.length===0)return new Map;let i=n.map(()=>"?").join(", "),r=e.all(`SELECT relative_path, language
456
+ FROM documents
457
+ WHERE relative_path IN (${i})`,...n);return new Map(r.map(o=>[o.relative_path,o.language?.toLowerCase()??null]))}function LU(e,t,n){let i=new Set,r=new Map;for(let o of t){if(n.get(o.relativePath)!=="clojure")continue;let s=r.get(o.relativePath);s||(s=new Set((ee(e,o.relativePath)?.callables??[]).map(a=>`${a.name}:${a.startLine}`)),r.set(o.relativePath,s)),s.has(`${o.leaf}:${o.startLine}`)&&i.add(o.symbolId)}return i}import{readdirSync as DU}from"fs";import{basename as PU,join as uC}from"path";function TU(e,t,n={}){let i=new Set(e),r=new Set(t),o=[...r].filter(a=>!i.has(a)).sort(),s=n.allowExtra?[]:[...i].filter(a=>!r.has(a)).sort();return{missing:o,extra:s}}function FU(e,t){let n=MU(e,t.file,t.keys);if(!n.ok)return{name:t.name,file:t.file,status:"unavailable",missing:[],extra:[],unavailableReason:n.reason};let i=OU(e.config.projectRoot,t.mustEqual),r=TU(n.keys,i,{allowExtra:t.allowExtra??!1}),o=r.missing.length>0||r.extra.length>0?"violated":"ok";return{name:t.name,file:t.file,status:o,missing:r.missing,extra:r.extra}}function mC(e,t){return t.map(n=>FU(e,n))}function MU(e,t,n){return n.type==="markdown-list"?BU(e,t,n.marker):AU(e,t,n)}function AU(e,t,n){if(!se(e,t))return{ok:!1,reason:`file not found: ${t}`};let r=ye(t);if(!r)return{ok:!1,reason:`unsupported file type for ${n.type} extraction: ${t}`};let o=ae(e,t);if(!o)return{ok:!1,reason:`tree-sitter parser unavailable for ${r} (${t}) \u2014 contract skipped, not silently passed`,disclosedUnavailable:{language:r,reason:"parser-unavailable"}};let s=n.type==="object-literal-keys"?NU(o,n.identifier):_U(o,n.identifier);return s===null?{ok:!1,reason:`no ${n.type==="object-literal-keys"?"object literal":"string array"} named "${n.identifier}" found in ${t}`}:{ok:!0,keys:s}}function fC(e){let t=e.childForFieldName("value");return t?t.type==="as_expression"||t.type==="satisfies_expression"?t.namedChild(0):t:null}function NU(e,t){for(let n of e.rootNode.descendantsOfType("variable_declarator")){if(n.childForFieldName("name")?.text!==t)continue;let r=fC(n);if(r?.type==="object")return kU(r)}return null}function kU(e){let t=new Set;for(let n of e.namedChildren)if(n.type==="pair"){let i=n.childForFieldName("key");i&&t.add(pC(i.text))}else n.type==="shorthand_property_identifier"&&t.add(n.text);return[...t].sort()}function _U(e,t){for(let n of e.rootNode.descendantsOfType("variable_declarator")){if(n.childForFieldName("name")?.text!==t)continue;let r=fC(n);if(r?.type!=="array")continue;let o=new Set;for(let s of r.namedChildren)s.type==="string"&&o.add(pC(s.text));return[...o].sort()}return null}function pC(e){return e.length>=2&&(e[0]==="'"&&e.endsWith("'")||e[0]==='"'&&e.endsWith('"'))?e.slice(1,-1):e}function BU(e,t,n){let i=se(e,t);if(!i)return{ok:!1,reason:`file not found: ${t}`};let r=gC(i,n);return r===null?{ok:!1,reason:`no <!-- BEGIN GENERATED ${n} --> ... <!-- END GENERATED ${n} --> block in ${t}`}:{ok:!0,keys:hC(r)}}function gC(e,t){let n=He(t),r=new RegExp(`<!--\\s*BEGIN GENERATED ${n}\\s*-->([\\s\\S]*?)<!--\\s*END GENERATED ${n}\\s*-->`).exec(e);return r?r[1]:null}function hC(e){let t=new Set;for(let n of e.matchAll(/`([a-z][a-z0-9-]*)`/g))t.add(n[1]);for(let n of e.matchAll(/\[([a-z][a-z0-9-]*)\]\([^)]*\)/g))t.add(n[1]);return[...t].sort()}function OU(e,t){switch(t.type){case"top-level-dirs":return dC(uC(e,t.path));case"file-glob":return[...new Set(xa(e,t.pattern).map(n=>PU(n)))].sort();case"registered-commands":return $U(e);case"builtin-skills":return dC(uC(e,"skills"))}}function dC(e){let t;try{t=DU(e,{withFileTypes:!0})}catch{return[]}return t.filter(n=>n.isDirectory()&&!n.name.startsWith(".")).map(n=>n.name).sort()}function $U(e){let t;try{t=nt(e,"docs/COMMAND_REFERENCE.md",{maxBytes:8*1024*1024,inputKind:"generated command reference"})}catch(i){if(!St(i))throw i;return[]}let n=gC(t,"COMMAND REFERENCE");return n?hC(n):[]}function Mn(e){return e.scoreCount??e.count}function SC(e){let t=GU(e),{breakdown:n,pressure:i}=KU(e),r=bC(n,"risk"),o=bC(n,"hygiene"),s=jU(e),a=[...e.warnings];e.complexity.coverage.semanticEvidence.excludedSymbolCount>0&&a.push(`Complexity scoring excluded ${e.complexity.coverage.semanticEvidence.excludedSymbolCount} symbol(s) with incomplete or unavailable compiler evidence.`);let l=e.evidenceCoverage.filter(c=>c.semanticEvidence.status!=="complete"&&c.semanticEvidence.status!=="disabled");return l.length>0&&a.push(`Compiler-resolved evidence was incomplete or unavailable in health phase(s): ${l.map(c=>c.phase).join(", ")}.`),{score:Math.min(r,o),riskScore:r,hygieneScore:o,scoreBreakdown:n,overview:{documents:e.statsResult.documents,symbols:e.statsResult.symbols,indexSizeBytes:e.statsResult.indexSizeBytes},findings:{deadSymbols:e.dead.count,deadLoc:e.dead.loc,isolatedSymbols:e.isolated.count,isolatedLoc:e.isolated.loc,cycles:e.realCycleCount,similarPairs:e.similarCount,duplicateBodyGroups:e.duplicateBodies.count,duplicateBodyLoc:e.duplicateBodies.loc,twinDriftGroups:e.twinDrift.count,twinDriftLoc:e.twinDrift.loc,reactComponentDuplicatePairs:e.reactComponentDuplicates.count,reactHookCandidatePairs:e.reactHookCandidates.count,reactHookCandidateScoreCount:Mn(e.reactHookCandidates),reactLargeComponentPressureFiles:e.reactLargeComponentPressure.count,vueComponentDuplicatePairs:e.vueComponentDuplicates.count,vueComposableCandidatePairs:e.vueComposableCandidates.count,vueComposableCandidateScoreCount:Mn(e.vueComposableCandidates),vueLargeViewPressureFiles:e.vueLargeViewPressure.count,extractionCandidates:e.extractCount,wrappers:e.wrappers.count,wrapperScoreCount:Mn(e.wrappers),passthroughs:e.passthroughs.count,staleTypes:e.stale.count,driftedFiles:e.drift.count,complexityHotspotCount:e.complexity.extremeCount,hiddenCouplingPairs:e.gitEvidence?.hiddenCoupling.pairCount??null,hiddenCouplingScoreCount:e.gitEvidence?.hiddenCoupling.scoreCount??null,coverageContractViolations:e.coverageContracts.count},axes:HU(e),validation:zU(e),suppressions:e.suppressions,actions:t,pressure:i,topComplexity:e.complexity.top,coverage:s,warnings:a.length>0?a:void 0}}function jU(e){let t=e.complexity.coverage.semanticEvidence.status;return{status:e.evidenceCoverage.some(i=>i.semanticEvidence.status!=="complete"&&i.semanticEvidence.status!=="disabled")?"incomplete":t==="disabled"?"semantic-disabled":t==="complete"?"complete":"incomplete",complexity:e.complexity.coverage,phases:e.evidenceCoverage}}function HU(e){return{deletable:{loc:e.dead.loc+e.isolated.loc,symbols:e.dead.count+e.isolated.count},cycles:{count:e.realCycleCount},changeAmplification:e.gitEvidence?.amplification??null,hiddenCoupling:e.gitEvidence?.hiddenCoupling??null,churnWeightedComplexity:UU(e),evidenceQuality:{graphFindings:e.dead.count+e.isolated.count+e.realCycleCount,heuristicFindings:e.similarCount+e.duplicateBodies.count+e.twinDrift.count+e.reactComponentDuplicates.count+e.reactHookCandidates.count+e.reactLargeComponentPressure.count+e.vueComponentDuplicates.count+e.vueComposableCandidates.count+e.vueLargeViewPressure.count+e.extractCount+e.wrappers.count+e.passthroughs.count+e.stale.count+e.drift.count,userSuppressed:e.suppressions?.total??0}}}function UU(e){let t=e.gitEvidence?.fileStats;return t?e.complexity.top.map(n=>{let i=n.file?t[n.file]?.changes??0:0;return{...n,changes:i,weighted:fn(n.score*Math.log2(1+i))}}).sort((n,i)=>i.weighted-n.weighted):null}function zU(e){let t=e.gitEvidence?.fileStats;if(!t)return null;let n={dead:e.dead.files??[],isolated:e.isolated.files??[],twinDrift:e.twinDrift.files??[],wrappers:e.wrappers.files??[],passthroughs:e.passthroughs.files??[],stale:e.stale.files??[],reactComponents:e.reactComponentDuplicates.files??[],reactHooks:e.reactHookCandidates.files??[],reactLargeComponents:e.reactLargeComponentPressure.files??[],vueComponents:e.vueComponentDuplicates.files??[],vueComposables:e.vueComposableCandidates.files??[],vueLargeViews:e.vueLargeViewPressure.files??[]},i=new Set(Object.values(n).flat()),r=0,o=0,s=0;for(let[u,d]of Object.entries(t))i.has(u)?r+=d.fixChanges:(o+=d.fixChanges,s+=1);let a=i.size>0?fn(r/i.size):0,l=s>0?fn(o/s):0,c={};for(let[u,d]of Object.entries(n)){let m=new Set(d);if(m.size===0)continue;let f=0;for(let g of m)f+=t[g]?.fixChanges??0;let p=fn(f/m.size);c[u]={flaggedFiles:m.size,fixDensity:p,lift:l>0?fn(p/l):null}}return{flaggedFiles:i.size,flaggedFixDensity:a,baselineFixDensity:l,ratio:i.size>0&&l>0?fn(a/l):null,byCategory:c,validationBasis:{method:"subject-regex",commitsScanned:e.gitEvidence?.commitsScanned??0}}}function fn(e){return Math.round(e*100)/100}function vC(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,"").replace(/\.$/,"")}function Wa(e,t="existing shared infrastructure discount"){let n=Mn(e);return Math.abs(n-e.count)<.01?"":` (${vC(n)} score-weighted after ${t})`}function _o(e,t){let n=Mn(e),i=`${e.count} ${t}`;return Math.abs(n-e.count)<.01?i:`${i} (${vC(n)} score-weighted)`}function GU(e){let t=[];if(e.dead.count>0&&t.push({category:"Dead code",evidence:"graph-fact",description:`${e.dead.count} indexed symbols with no visible repository references \u2014 review runtime/framework roots and the capability disclosure, then verify any deletion with cleanup-plan --verify`,effort:"low",impact:"high",count:e.dead.count,locRecoverable:e.dead.loc}),e.isolated.count>0&&t.push({category:"Isolated symbols",evidence:"graph-fact",description:`${e.isolated.count} symbols completely disconnected from the codebase graph`,effort:"low",impact:"medium",count:e.isolated.count,locRecoverable:e.isolated.loc}),e.realCycleCount>0&&t.push({category:"Circular dependencies",evidence:"graph-fact",description:`${e.realCycleCount} indexed dependency cycle(s) \u2014 inspect ownership and runtime order before choosing whether or how to break them`,effort:"medium",impact:"high",count:e.realCycleCount,locRecoverable:0}),e.similarCount>0&&t.push({category:"Similar functions",evidence:"heuristic",description:`${e.similarCount} pairs share disclosed call or source-token evidence beyond imports \u2014 review domain identity before considering consolidation`,effort:"medium",impact:"medium",count:e.similarCount,locRecoverable:0}),e.duplicateBodies.count>0&&t.push({category:"Duplicate function bodies",evidence:"heuristic",description:`${e.duplicateBodies.count} exact small-body group(s) across files \u2014 consolidate only when the domain concept matches`,effort:"low",impact:"medium",count:e.duplicateBodies.count,locRecoverable:e.duplicateBodies.loc}),e.twinDrift.count>0&&t.push({category:"Drifted twin implementations",evidence:"heuristic",description:`${e.twinDrift.count} same-name (or near-name) function group(s) across files with diverged or identical bodies \u2014 determine whether they represent the same concept before acting`,effort:"medium",impact:"medium",count:e.twinDrift.count,locRecoverable:0}),e.reactComponentDuplicates.count>0&&t.push({category:"Duplicated React components",evidence:"heuristic",description:`${e.reactComponentDuplicates.count} React component pair(s) share JSX structure \u2014 review whether local product intent justifies reuse`,effort:"medium",impact:"medium",count:e.reactComponentDuplicates.count,locRecoverable:e.reactComponentDuplicates.loc}),e.reactHookCandidates.count>0&&t.push({category:"Duplicated React hook behavior",evidence:"heuristic",description:`${e.reactHookCandidates.count} React component pair(s) share state/effect/request behavior${Wa(e.reactHookCandidates)} \u2014 review whether a common hook would preserve ownership and lifecycle semantics`,effort:"medium",impact:"medium",count:e.reactHookCandidates.count,locRecoverable:e.reactHookCandidates.loc}),e.reactLargeComponentPressure.count>0&&t.push({category:"Large React components",evidence:"heuristic",description:`${e.reactLargeComponentPressure.count} React component(s) concentrate JSX/behavior pressure \u2014 split by reason to change`,effort:"medium",impact:"medium",count:e.reactLargeComponentPressure.count,locRecoverable:0}),e.vueComponentDuplicates.count>0&&t.push({category:"Duplicated Vue components",evidence:"heuristic",description:`${e.vueComponentDuplicates.count} Vue component pair(s) share template structure \u2014 review whether local product intent justifies reuse`,effort:"medium",impact:"medium",count:e.vueComponentDuplicates.count,locRecoverable:e.vueComponentDuplicates.loc}),e.vueComposableCandidates.count>0&&t.push({category:"Duplicated Vue behavior",evidence:"heuristic",description:`${e.vueComposableCandidates.count} Vue component pair(s) share state/effect/request behavior${Wa(e.vueComposableCandidates)} \u2014 review whether a common composable would preserve ownership and lifecycle semantics`,effort:"medium",impact:"medium",count:e.vueComposableCandidates.count,locRecoverable:e.vueComposableCandidates.loc}),e.vueLargeViewPressure.count>0&&t.push({category:"Large Vue views",evidence:"heuristic",description:`${e.vueLargeViewPressure.count} Vue file(s) concentrate template/script/style pressure \u2014 split by reason to change`,effort:"medium",impact:"medium",count:e.vueLargeViewPressure.count,locRecoverable:0}),e.extractCount>0&&t.push({category:"Extraction candidates",evidence:"heuristic",description:`${e.extractCount} large functions with isolated callee clusters \u2014 review same-file or feature-local extraction seams`,effort:"medium",impact:"medium",count:e.extractCount,locRecoverable:0}),e.wrappers.count>0&&t.push({category:"Wrapper functions",evidence:"heuristic",description:`${e.wrappers.count} single-consumer symbols${Wa(e.wrappers,"boundary-evidence discount")} \u2014 inspect whether each is indirection or an intentional API, framework, or ownership boundary`,effort:"low",impact:"low",count:e.wrappers.count,locRecoverable:e.wrappers.loc}),e.passthroughs.count>0&&t.push({category:"Passthrough functions",evidence:"heuristic",description:`${e.passthroughs.count} functions that literally forward to one callee \u2014 inspect whether each is unnecessary indirection or an intentional boundary`,effort:"low",impact:"low",count:e.passthroughs.count,locRecoverable:e.passthroughs.loc}),e.stale.count>0){let r=[];e.stale.unused>0&&r.push(`${e.stale.unused} unused`),e.stale.singleUse>0&&r.push(`${e.stale.singleUse} single-consumer (not in types file)`),t.push({category:"Stale abstractions",evidence:"heuristic",description:`${r.join(", ")} \u2014 review public, runtime-registration, and ownership evidence before removing, moving, or inlining`,effort:"low",impact:"medium",count:e.stale.count,locRecoverable:e.stale.loc})}if(e.drift.count>0){let r=[];e.drift.unusedImports>0&&r.push(`${e.drift.unusedImports} unused imports`),e.drift.architectureViolations>0&&r.push(`${e.drift.architectureViolations} declared architecture violations`),t.push({category:"Structural drift",evidence:"heuristic",description:`${r.join(", ")} \u2014 repair direct dependency-rule breaks; inspect boundary signals with \`drift --architecture\``,effort:e.drift.architectureViolations>0?"medium":"low",impact:e.drift.architectureViolations>0?"medium":"low",count:e.drift.count,locRecoverable:0})}if(e.coverageContracts.count>0&&t.push({category:"Coverage contract drift",evidence:"graph-fact",description:`${e.coverageContracts.count} configured coverage contract(s) drifted from their ground-truth source (enumeration rot) \u2014 run \`codebaseiq health --json\` for the missing/extra keys`,effort:"low",impact:"medium",count:e.coverageContracts.count,locRecoverable:0}),e.gitEvidence&&e.gitEvidence.hiddenCoupling.pairCount>0){let r=e.gitEvidence.hiddenCoupling.top[0];t.push({category:"Hidden coupling",evidence:"change-graph",description:`${e.gitEvidence.hiddenCoupling.pairCount} file pair(s) co-change without a structural link`+Wa({count:e.gitEvidence.hiddenCoupling.pairCount,scoreCount:e.gitEvidence.hiddenCoupling.scoreCount},"broad/stale-history discount")+(r?` (e.g. ${r.fileA} \u2194 ${r.fileB})`:"")+" \u2014 inspect whether a shared concept, generated artifact, or coordinated contract explains the history",effort:"medium",impact:"high",count:e.gitEvidence.hiddenCoupling.pairCount,locRecoverable:0})}let n={high:3,medium:2,low:1},i={low:3,medium:2,high:1};return t.sort((r,o)=>{let s=n[r.impact]*i[r.effort];return n[o.impact]*i[o.effort]-s}),t}var yC={"dead-code":"risk",isolated:"risk",cycles:"risk",complexity:"risk","hidden-coupling":"risk","cycles-pressure":"risk","complexity-pressure":"risk","hidden-coupling-pressure":"risk",similar:"hygiene","duplicate-bodies":"hygiene","twin-drift":"hygiene","react-component-duplicates":"hygiene","react-hook-candidates":"hygiene","react-large-component-pressure":"hygiene","vue-component-duplicates":"hygiene","vue-composable-candidates":"hygiene","vue-large-view-pressure":"hygiene",extract:"hygiene",wrappers:"hygiene",passthroughs:"hygiene","stale-abstractions":"hygiene",drift:"hygiene","similar-pressure":"hygiene","duplicate-bodies-pressure":"hygiene","twin-drift-pressure":"hygiene","react-component-duplicates-pressure":"hygiene","react-hook-candidates-pressure":"hygiene","react-large-component-pressure-pressure":"hygiene","vue-component-duplicates-pressure":"hygiene","vue-composable-candidates-pressure":"hygiene","vue-large-view-pressure-pressure":"hygiene","extract-pressure":"hygiene","wrappers-pressure":"hygiene","passthroughs-pressure":"hygiene","stale-abstractions-pressure":"hygiene","drift-pressure":"hygiene"};function bC(e,t){let n=e.filter(i=>i.kind===t).reduce((i,r)=>i+r.points,0);return Math.max(0,Math.min(100,100-n))}function KU(e){let t=Math.max(e.statsResult.documents,1),n=Math.max(e.statsResult.symbols,1),i=[],r=[],o=(R,C,L)=>{C>0&&i.push({axis:R,points:C,detail:L,kind:yC[R]??"hygiene"})},s=(R,C,L,I,x,P,_)=>{let D=Math.max(I,1);if(L<=D)return;let T=L/D,A=Math.min(x,Math.ceil(Math.log2(T)*P));if(A<=0)return;let W=yC[R]??"hygiene";r.push({axis:R,category:C,kind:W,count:L,threshold:fn(D),ratio:fn(T),extraPenalty:A}),o(R,A,`${L} ${_} exceed pressure threshold ${fn(D)} (${fn(T)}x)`)},a=e.dead.count/n;o("dead-code",Math.min(20,Math.round(a*200)),`${e.dead.count} dead symbols (${e.dead.loc} LOC deletable)`);let l=e.isolated.count/n;o("isolated",Math.min(10,Math.round(l*200)),`${e.isolated.count} isolated symbols (${e.isolated.loc} LOC deletable)`),o("cycles",Math.min(15,e.realCycleCount*5),`${e.realCycleCount} real dependency cycle(s)`);let c=e.similarCount/n*1e3;o("similar",Math.min(10,Math.round(c)),`${e.similarCount} similar function pair(s)`);let u=e.duplicateBodies.count/n*1e3;o("duplicate-bodies",Math.min(10,Math.round(u*2)),`${e.duplicateBodies.count} exact duplicate small-body group(s) (${e.duplicateBodies.loc} duplicate LOC)`);let d=e.twinDrift.count/n*1e3;o("twin-drift",Math.min(10,Math.round(d*2)),`${e.twinDrift.count} drifted twin implementation group(s) (same or near-same name, diverged or identical bodies)`);let m=e.reactComponentDuplicates.count/t*1e3;o("react-component-duplicates",Math.min(10,Math.round(m)),`${e.reactComponentDuplicates.count} duplicated React component pair(s)`);let f=Mn(e.reactHookCandidates),p=f/t*1e3;o("react-hook-candidates",Math.min(10,Math.round(p)),_o(e.reactHookCandidates,"duplicated React behavior pair(s)"));let g=e.reactLargeComponentPressure.count/t*1e3;o("react-large-component-pressure",Math.min(5,Math.round(g/2)),`${e.reactLargeComponentPressure.count} large React component pressure file(s)`);let h=e.vueComponentDuplicates.count/t*1e3;o("vue-component-duplicates",Math.min(10,Math.round(h)),`${e.vueComponentDuplicates.count} duplicated Vue component pair(s)`);let S=Mn(e.vueComposableCandidates),v=S/t*1e3;o("vue-composable-candidates",Math.min(10,Math.round(v)),_o(e.vueComposableCandidates,"duplicated Vue behavior pair(s)"));let y=e.vueLargeViewPressure.count/t*1e3;o("vue-large-view-pressure",Math.min(5,Math.round(y/2)),`${e.vueLargeViewPressure.count} large Vue view pressure file(s)`);let E=Mn(e.wrappers);o("wrappers",Math.min(3,E),_o(e.wrappers,"wrapper candidate(s)"));let w=Mn(e.passthroughs);o("passthroughs",Math.min(3,w),_o(e.passthroughs,"passthrough candidate(s)")),o("stale-abstractions",Math.min(8,e.stale.unused),`${e.stale.unused} unused stale abstraction(s); ${e.stale.singleUse} single-consumer signal(s)`);let b=e.drift.direct/t;if(o("drift",Math.min(5,Math.round(b*50)),`${e.drift.direct} direct drift finding(s); ${e.drift.signal} signal drift finding(s)`),o("complexity",Math.min(5,e.complexity.extremeCount*2),`${e.complexity.extremeCount} extreme complexity hotspot(s)`),e.gitEvidence){let R=e.gitEvidence.hiddenCoupling.scoreCount;o("hidden-coupling",Math.min(5,Math.ceil(R/10)),_o({count:e.gitEvidence.hiddenCoupling.pairCount,scoreCount:R},"co-changing pair(s) without a structural link"))}if(s("cycles-pressure","Circular dependencies",e.realCycleCount,3,10,3,"cycle(s)"),s("complexity-pressure","Extreme complexity",e.complexity.extremeCount,3,5,2,"extreme complexity hotspot(s)"),e.gitEvidence){let R=e.gitEvidence.hiddenCoupling.scoreCount;s("hidden-coupling-pressure","Hidden coupling",R,50,10,4,"score-weighted co-changing pair(s)")}return s("similar-pressure","Similar functions",e.similarCount,Math.max(50,n*.01),8,4,"similar function pair(s)"),s("duplicate-bodies-pressure","Duplicate function bodies",e.duplicateBodies.count,Math.max(20,n*.005),8,4,"exact duplicate small-body group(s)"),s("twin-drift-pressure","Drifted twin implementations",e.twinDrift.count,Math.max(20,n*.005),8,4,"drifted twin implementation group(s)"),s("react-component-duplicates-pressure","Duplicated React components",e.reactComponentDuplicates.count,Math.max(10,t*.01),8,4,"duplicated React component pair(s)"),s("react-hook-candidates-pressure","Duplicated React hook behavior",f,Math.max(10,t*.01),8,4,"duplicated React behavior pair(s)"),s("react-large-component-pressure-pressure","Large React components",e.reactLargeComponentPressure.count,Math.max(10,t*.01),4,2,"large React component pressure file(s)"),s("vue-component-duplicates-pressure","Duplicated Vue components",e.vueComponentDuplicates.count,Math.max(10,t*.01),8,4,"duplicated Vue component pair(s)"),s("vue-composable-candidates-pressure","Duplicated Vue behavior",S,Math.max(10,t*.01),8,4,"duplicated Vue behavior pair(s)"),s("vue-large-view-pressure-pressure","Large Vue views",e.vueLargeViewPressure.count,Math.max(10,t*.01),4,2,"large Vue view pressure file(s)"),s("extract-pressure","Extraction candidates",e.extractCount,Math.max(50,n*.01),4,2,"extraction candidate(s)"),s("wrappers-pressure","Wrapper functions",E,50,4,2,"wrapper candidate(s)"),s("passthroughs-pressure","Passthrough functions",w,50,4,2,"passthrough candidate(s)"),s("stale-abstractions-pressure","Single-consumer stale abstraction signals",e.stale.singleUse,Math.max(50,n*.02),4,2,"single-consumer stale abstraction signal(s)"),s("drift-pressure","Structural drift signals",e.drift.signal,Math.max(10,t*.1),4,2,"signal drift finding(s)"),{breakdown:i,pressure:r}}import{getHeapStatistics as qU}from"v8";var WU=64*1024*1024;function md(){let e=globalThis.gc;if(!e)return;let t=qU();t.heap_size_limit-t.used_heap_size<WU||e()}var VU=50,JU=25e3,YU=2500,CC=2500,xC=50,XU=10,Va=["overview","dead","isolated","cycles","similar","duplicate-bodies","twin-drift","react-component-duplicates","react-hook-candidates","react-large-component-pressure","vue-component-duplicates","vue-composable-candidates","vue-large-view-pressure","extract-candidates","wrapper-candidates","passthrough-candidates","stale-abstractions","drift","complexity-hotspots","git-evidence","suppressions","coverage-contracts"],ZU={overview:(e,t,n,i)=>({phase:"overview",statsResult:i,warnings:n.warnings}),dead:(e,t,n)=>({phase:"dead",dead:iz(e,t,n)}),isolated:(e,t,n)=>({phase:"isolated",isolated:rz(e,t,n)}),cycles:(e,t,n)=>({phase:"cycles",realCycleCount:oz(e,t,n)}),similar:(e,t,n)=>({phase:"similar",similarCount:sz(e,t,n)}),"duplicate-bodies":(e,t,n)=>({phase:"duplicate-bodies",duplicateBodies:lz(e,t,n)}),"twin-drift":(e,t,n)=>({phase:"twin-drift",twinDrift:cz(e,t,n)}),"react-component-duplicates":(e,t,n)=>({phase:"react-component-duplicates",reactComponentDuplicates:uz(e,t,n)}),"react-hook-candidates":(e,t,n)=>({phase:"react-hook-candidates",reactHookCandidates:dz(e,t,n)}),"react-large-component-pressure":(e,t,n)=>({phase:"react-large-component-pressure",reactLargeComponentPressure:mz(e,t,n)}),"vue-component-duplicates":(e,t,n)=>({phase:"vue-component-duplicates",vueComponentDuplicates:fz(e,t,n)}),"vue-composable-candidates":(e,t,n)=>({phase:"vue-composable-candidates",vueComposableCandidates:pz(e,t,n)}),"vue-large-view-pressure":(e,t,n)=>({phase:"vue-large-view-pressure",vueLargeViewPressure:gz(e,t,n)}),"extract-candidates":(e,t,n)=>({phase:"extract-candidates",extractCount:az(e,t,n)}),"wrapper-candidates":(e,t,n)=>({phase:"wrapper-candidates",wrappers:hz(e,t,n)}),"passthrough-candidates":(e,t,n)=>({phase:"passthrough-candidates",passthroughs:yz(e,t,n)}),"stale-abstractions":(e,t,n)=>({phase:"stale-abstractions",stale:bz(e,t,n)}),drift:(e,t,n)=>({phase:"drift",drift:xz(e,t,n)}),"complexity-hotspots":(e,t,n)=>({phase:"complexity-hotspots",complexity:Rz(e,t,n)}),"git-evidence":(e,t,n)=>({phase:"git-evidence",gitEvidence:Sz(e,n)}),suppressions:(e,t,n)=>({phase:"suppressions",suppressions:vz(e,n)}),"coverage-contracts":(e,t,n)=>({phase:"coverage-contracts",coverageContracts:Cz(e,n)})};function fd(e,t,n={}){return QU(e,[t],n)[0]}function QU(e,t,n={}){return ez(e,n.full!==!1,(i,r)=>{let o={...r,releaseCachesBetweenPhases:!1};return t.map(s=>nz(e,s,n.scope,o,i))})}function ez(e,t,n){let i=mi(e),r=Ez(i,t);try{return n(i,r)}finally{au(e,{semanticProvider:!0}),md()}}function pd(e){return SC(tz(e))}function tz(e){let t=je(e,"overview");return{statsResult:t.statsResult,warnings:t.warnings,evidenceCoverage:e.map(i=>({phase:i.phase,semanticEvidence:i.evidenceCoverage})),dead:je(e,"dead").dead,isolated:je(e,"isolated").isolated,realCycleCount:je(e,"cycles").realCycleCount,similarCount:je(e,"similar").similarCount,duplicateBodies:je(e,"duplicate-bodies").duplicateBodies,twinDrift:je(e,"twin-drift").twinDrift,reactComponentDuplicates:je(e,"react-component-duplicates").reactComponentDuplicates,reactHookCandidates:je(e,"react-hook-candidates").reactHookCandidates,reactLargeComponentPressure:je(e,"react-large-component-pressure").reactLargeComponentPressure,vueComponentDuplicates:je(e,"vue-component-duplicates").vueComponentDuplicates,vueComposableCandidates:je(e,"vue-composable-candidates").vueComposableCandidates,vueLargeViewPressure:je(e,"vue-large-view-pressure").vueLargeViewPressure,extractCount:je(e,"extract-candidates").extractCount,wrappers:je(e,"wrapper-candidates").wrappers,passthroughs:je(e,"passthrough-candidates").passthroughs,stale:je(e,"stale-abstractions").stale,drift:je(e,"drift").drift,complexity:je(e,"complexity-hotspots").complexity,gitEvidence:RC(e,"git-evidence")?.gitEvidence??null,suppressions:RC(e,"suppressions")?.suppressions??null,coverageContracts:je(e,"coverage-contracts").coverageContracts}}function RC(e,t){return e.find(n=>n.phase===t)}function je(e,t){let n=e.find(i=>i.phase===t);if(!n)throw new Error(`Missing health phase result: ${t}`);return n}function nz(e,t,n,i,r){mp(e);let o=ZU[t](e,n,i,r),s=fp(e),a=s.incompleteSymbolIds.size,l=s.unavailableSymbolIds.size,c=i.semantic?a>0&&l>0?"incomplete-and-unavailable":a>0?"incomplete":l>0?"unavailable":"complete":"disabled";return{...o,evidenceCoverage:{enabled:i.semantic,status:c,incompleteSymbolCount:a,unavailableSymbolCount:l}}}function iz(e,t,n){return $e(e,n,"dead",()=>{let i=wi(e,{scope:t,...Oe.dead,scanLimit:n.candidateScanLimit,semantic:n.semantic});return Ja(Lz(e,i.symbols))})}function rz(e,t,n){return $e(e,n,"isolated",()=>{let i=po(e,{scope:t,...Oe.isolated,scanLimit:n.candidateScanLimit,semantic:n.semantic});return Ja(Dz(e,i))})}function oz(e,t,n){return $e(e,n,"cycles",()=>mo(e,{scope:t}).filter(r=>r.kind==="real").length)}function sz(e,t,n){let i=$e(e,n,"similar",()=>yu(e,{scope:t,...Oe.similar,scanLimit:n.candidateScanLimit,semantic:n.semantic}));return Math.min(i,n.candidateResultLimit)}function az(e,t,n){return $e(e,n,"extract-candidates",()=>Ro(e,{scope:t,...Oe.extract,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit,semantic:n.semantic}).length)}function lz(e,t,n){return $e(e,n,"duplicate-bodies",()=>{let i=Lo(e,{scope:t,...Oe.duplicateBodies,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit}),r=new Set,o=0;for(let s of i)for(let a of s.functions.slice(1))r.add(a.file),o+=a.loc;return{count:i.length,loc:o,files:[...r]}})}function cz(e,t,n){return $e(e,n,"twin-drift",()=>{let i=Ba(e,{scope:t,...Oe.twinDrift,scanLimit:n.candidateScanLimit}).filter(s=>s.relationship==="divergent"||s.relationship==="identical"),r=new Set,o=0;for(let s of i)for(let a of s.members)r.add(a.file),o+=a.loc;return{count:i.length,loc:o,files:[...r].sort()}})}function uz(e,t,n){return $e(e,n,"react-component-duplicates",()=>{let i=So(e,{scope:t,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit});return gd(i)})}function dz(e,t,n){return $e(e,n,"react-hook-candidates",()=>{let i=vo(e,{scope:t,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit});return IC(i,Tz)})}function mz(e,t,n){return $e(e,n,"react-large-component-pressure",()=>{let i=bu(e,{scope:t,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit});return Pz(i)})}function fz(e,t,n){return $e(e,n,"vue-component-duplicates",()=>{let i=Co(e,{scope:t,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit});return gd(i)})}function pz(e,t,n){return $e(e,n,"vue-composable-candidates",()=>{let i=xo(e,{scope:t,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit});return IC(i,Fz)})}function gz(e,t,n){return $e(e,n,"vue-large-view-pressure",()=>{let i=Su(e,{scope:t,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit});return Ja(i)})}function hz(e,t,n){return $e(e,n,"wrapper-candidates",()=>{let i=ko(e,{scope:t,...Oe.wrappers,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit,semantic:n.semantic});return wC(i,Mz)})}function yz(e,t,n){return $e(e,n,"passthrough-candidates",()=>{let i=Do(e,{scope:t,...Oe.passthroughs,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit,semantic:n.semantic});return wC(i,Az)})}function bz(e,t,n){return $e(e,n,"stale-abstractions",()=>{let i=No(e,{scope:t,...Oe.stale,limit:n.candidateResultLimit,scanLimit:n.candidateScanLimit,semantic:n.semantic}),r=i.filter(o=>o.consumers===0).length;return{count:i.length,loc:i.reduce((o,s)=>o+s.loc,0),files:[...new Set(i.map(o=>o.file))],unused:r,singleUse:i.length-r}})}function Sz(e,t){return $e(e,t,"git-evidence",()=>{let n=Wt(e,{historyMode:t.gitHistoryMode}),i=n.fileChurn();if(!i)return null;let r=n.commitHistory(),o=wo(e,void 0,{limit:t.candidateResultLimit,historyMode:t.gitHistoryMode}),s={};for(let[a,l]of i)s[a]={changes:l.changes,fixChanges:l.fixChanges};return{amplification:n.changeAmplification(),hiddenCoupling:{pairCount:o.findings.length,scoreCount:hd(o.findings.reduce((a,l)=>a+EC(l),0)),top:o.findings.slice(0,5).map(a=>({fileA:a.fileA,fileB:a.fileB,together:a.together,confidence:a.confidence,focusedTogether:a.focusedTogether,broadTogether:a.broadTogether,broadCommitRatio:a.broadCommitRatio,lastTogetherAt:a.lastTogetherAt,recentTogether:a.recentTogether,commitScope:a.commitScope,recency:a.recency,scoreWeight:EC(a),subjectContext:a.subjectContext}))},fileStats:s,commitsScanned:r?.commits.length??0}})}function vz(e,t){return $e(e,t,"suppressions",()=>{let n=Ha(e);return{total:n.total,byCategory:{...n.byCategory}}})}function Cz(e,t){return $e(e,t,"coverage-contracts",()=>{let n=e.config.coverageContracts??[],r=mC(e,n).filter(o=>o.status!=="ok");return{count:r.length,loc:0,files:[...new Set(r.map(o=>o.file))].sort()}})}function xz(e,t,n){return $e(e,n,"drift",()=>{let i=Ao(e,{scope:t,...Oe.drift,includePatternDeviations:!1,limit:Number.POSITIVE_INFINITY,semantic:n.semantic}),r=i.results.filter(a=>a.kind!=="pattern-deviation"),o=r.filter(a=>a.actionTier==="direct").length,s=r.length-o;return{count:r.length,unusedImports:i.unusedImports,architectureViolations:i.architectureViolations,layerViolations:i.layerViolations,direct:o,signal:s}})}function Rz(e,t,n){return $e(e,n,"complexity-hotspots",()=>{let i=dd(e,{scope:t,minLoc:10,limit:n.complexityResultLimit,scanLimit:n.candidateScanLimit,semantic:n.semantic});return{top:i.rows.slice(0,5).map(r=>({symbol:r.shortName,score:r.score,file:r.file})),extremeCount:i.rows.filter(r=>r.score>VU).length,coverage:i.coverage}})}function Ez(e,t){let n=e.symbols>=JU||e.documents>=YU,i=t?Number.POSITIVE_INFINITY:xC,r=t?Number.POSITIVE_INFINITY:XU;return!n||t?{candidateScanLimit:void 0,candidateResultLimit:i,complexityResultLimit:r,semantic:!0,gitHistoryMode:t?"full":"bounded",releaseCachesBetweenPhases:!0,warnings:t&&n?["Large index detected; running health without candidate scan or result caps because full mode is enabled."]:[]}:{candidateScanLimit:CC,candidateResultLimit:i,complexityResultLimit:r,semantic:!1,gitHistoryMode:"bounded",releaseCachesBetweenPhases:!0,warnings:[`Large index detected; candidate-style health checks scanned their highest-priority ${CC} symbols and reported their top ${xC} findings. Enable full mode for unbounded candidate counts.`]}}function wz(e,t){t.releaseCachesBetweenPhases&&(au(e),md())}function $e(e,t,n,i){Iz(n);try{return i()}finally{wz(e,t)}}function Iz(e){process.env.CODEBASEIQ_HEALTH_TRACE==="1"&&console.error(`[health] ${e}`)}function Lz(e,t){return t.filter(n=>!Ye(e,n.relativePath)&&!Ue(e,n.symbol,n.relativePath)&&n.kind==="dead-code")}function Dz(e,t){return t.filter(n=>!Ye(e,n.relativePath)&&!Ue(e,n.symbol,n.relativePath))}function Ja(e){let t=new Set;for(let n of e){let i=n.relativePath??n.file;i&&t.add(i)}return{count:e.length,loc:e.reduce((n,i)=>n+i.loc,0),files:[...t]}}function wC(e,t){return{...Ja(e),scoreCount:hd(e.reduce((i,r)=>i+t(r),0))}}function Pz(e){let t=new Map;for(let n of e)t.set(n.file,Math.max(t.get(n.file)??0,n.loc));return{count:t.size,loc:[...t.values()].reduce((n,i)=>n+i,0),files:[...t.keys()]}}function gd(e){let t=new Map;for(let n of e)t.set(n.fileA,Math.max(t.get(n.fileA)??0,n.locA)),t.set(n.fileB,Math.max(t.get(n.fileB)??0,n.locB));return{count:e.length,loc:[...t.values()].reduce((n,i)=>n+i,0),files:[...t.keys()]}}function IC(e,t){return{...gd(e),scoreCount:hd(e.reduce((i,r)=>i+t(r),0))}}function Tz(e){let t=e.sharedHooks.length>0,n=LC({namedState:e.sharedState,requests:e.sharedRequests,lifecycle:e.sharedEffects,functions:e.sharedHandlers});return t&&n<=2?0:t?.5:DC(e.sharedState,e.sharedHandlers,e.sharedHandlerVerbs)?.25:n>=2?1:.5}function Fz(e){let t=e.sharedComposables.length+e.sharedStores.length>0,n=LC({namedState:e.sharedBindings,requests:e.sharedRequests,lifecycle:e.sharedLifecycle,functions:e.sharedFunctions});return t&&n<=2?0:t?.5:DC(e.sharedBindings,e.sharedFunctions,e.sharedFunctionVerbs)?.25:n>=2?1:.5}function LC(e){return e.requests.length*2+e.lifecycle.length+e.namedState.filter(t=>!TC.has(PC(t))).length+Math.min(e.functions.length,3)}function DC(e,t,n){let i=[...e,...t,...n].map(PC);return i.length>0&&i.every(r=>TC.has(r))}function PC(e){return e.replace(/^handle/,"").replace(/^is/,"").replace(/^has/,"").toLowerCase()}function Mz(e){return e.actionTier==="signal"?.25:1}function Az(e){return e.actionTier==="signal"?.25:1}function EC(e){return e.commitScope==="broad-sweep"?e.recency==="recent"?.25:0:e.commitScope==="mixed"?e.recency==="recent"?.5:.25:e.recency==="recent"?1:.5}function hd(e){return Math.round(e*100)/100}var TC=new Set(["add","apply","cancel","change","clear","close","create","delete","draft","edit","error","filter","form","load","loading","name","open","refresh","remove","reset","save","saving","search","select","selected","submit","toggle","update","value"]);function Nz(e,t,n,i={}){let r=hu(e,t,n,i);return r?{symbolA:r.symbolA,symbolB:r.symbolB,similarity:r.similarity,sharedCallees:r.sharedEvidence,uniqueToA:r.uniqueToA,uniqueToB:r.uniqueToB,consolidationStrategy:r.consolidationStrategy}:null}function kz(e,t,n={}){let i=co(e,t,{families:["dataflow"],...n.maxDepth!==void 0?{maxDepth:n.maxDepth}:{},...n.maxEdges!==void 0?{maxEdges:n.maxEdges}:{}});return{kind:"value-flow",targets:i.targets,edges:i.edges,coverage:{status:i.coverage.status,basis:"proved-bounded-static-value-flow",analysisBasis:"partial-system-definition-use",providers:["bounded-static-value-flow","typescript-local-dependence"],supportedRelations:["compiler-identified local definitions reaching local reads through a TypeScript control-flow graph","right-hand-side local reads supplying assignments and declarations","candidate closure captures and bounded same-owner field flow with explicit evidence strength","direct argument-to-parameter forwarding at compiler-resolved calls","bounded mechanically derived static arguments","callee return value to a consumed compiler-resolved call result"],unsupportedRelations:["general heap alias and cross-instance field points-to flow","exceptional control and value flow","closure invocation order","downstream local definition-use after a call result","dynamic calls not resolved by the semantic provider"],graph:i.coverage}}}var _z=/:\d+(?:-\d+)?$/u;function Bz(e,t,n={}){let i=n.direction??"backward",r=n.maxDepth??3;if(!Number.isSafeInteger(r)||r<0)throw new RangeError(`Dependence-slice depth must be a non-negative safe integer; received ${r}.`);let o=_z.test(t),s=co(e,o?{locations:[t]}:{symbols:[t]},{families:["execution","runtime","dataflow","ownership"],maxDepth:r+1,maxEdges:n.maxEdges??200}),a=new Set(s.targets.flatMap(d=>d.nodeIds)),l=new Set(a),c=new Map;FC(s.edges,l,c,0);for(let d=1;d<=r;d+=1){let m=[];for(let f of s.edges)if(i==="backward"?l.has(f.to.id):l.has(f.from.id)){let p=i==="backward"?f.from.id:f.to.id;if(l.has(p))continue;m.push(p),c.set(f.id,d)}if(m.length===0)break;for(let f of m)l.add(f);FC(s.edges,l,c,d)}let u=s.edges.filter(d=>l.has(d.from.id)&&l.has(d.to.id)).filter(d=>c.has(d.id)||d.family==="ownership").map(d=>({...d,traversalDepth:c.get(d.id)??0,supporting:d.family!=="dataflow"&&!Oz(d)})).sort((d,m)=>d.traversalDepth-m.traversalDepth||d.family.localeCompare(m.family)||d.from.label.localeCompare(m.from.label)||d.to.label.localeCompare(m.to.label));return{kind:"dependence-slice",direction:i,criterion:t,targets:s.targets,nodeIds:[...l].sort(),edges:u,coverage:{status:s.coverage.status,criterionKind:o?"source-location-summary":"symbol-summary",basis:"partial-system-dependence-graph",analysisBasis:"typescript-cfg-reaching-definitions-plus-system-edges",providers:["typescript-local-dependence","bounded-static-value-flow"],graph:s.coverage,unsupportedRelations:["general heap alias and cross-instance field points-to flow","exceptional control and value flow","closure invocation order","downstream local definition-use after a call result","unresolved dynamic dispatch"]}}}function FC(e,t,n,i){let r=!0;for(;r;){r=!1;for(let o of e)o.family!=="ownership"||!t.has(o.from.id)||t.has(o.to.id)||(t.add(o.to.id),n.set(o.id,i),r=!0)}}function Oz(e){return e.semanticFamily==="control"&&e.sourceKind==="control-dependence"}function $z(e,t={}){let{scope:n,limit:i}=t,r=new U(e),o=Vz([...jz(e,n),...zz(e,r,n)]);return Jz(o),i?o.slice(0,i):o}function jz(e,t){let n=[];for(let i of Hz(e,t)){if(e.isIgnored(i.barrel_path)||e.isIgnored(i.original_path)||pc(e,i.barrel_path)||se(e,i.barrel_path)&&Vo(e,i.barrel_path).length===0)continue;let r=Uz(e,i),o=r?.barrel_consumers??0,s=r?.direct_consumers??0;o!==0||s!==0||n.push({barrelFile:i.barrel_path,symbol:i.symbol,shortName:k(i.symbol),originalFile:i.original_path,barrelConsumers:o,directConsumers:s,...AC(e,i.barrel_path)})}return n}function Hz(e,t){let n=t?"AND barrel_d.relative_path LIKE ?":"",i=t?[`%${t}%`]:[];return e.all(`WITH barrel_refs AS MATERIALIZED (
458
+ SELECT DISTINCT
459
+ barrel_d.id AS barrel_doc_id,
460
+ barrel_d.relative_path AS barrel_path,
461
+ m.symbol_id
462
+ FROM documents barrel_d
463
+ JOIN chunks c ON c.document_id = barrel_d.id
464
+ JOIN mentions m ON m.chunk_id = c.id
465
+ WHERE m.role != 1
466
+ AND (barrel_d.relative_path LIKE '%/index.ts'
467
+ OR barrel_d.relative_path LIKE '%/index.js'
468
+ OR barrel_d.relative_path = 'index.ts'
469
+ OR barrel_d.relative_path = 'index.js')
470
+ ${e.pathExclusionsFor("barrel_d")}
471
+ ${n}
472
+ ),
473
+ sym_def AS MATERIALIZED (
474
+ SELECT m2.symbol_id, c2.document_id
475
+ FROM barrel_refs br
476
+ -- Keep the bounded barrel-symbol set on the outer side. An ordinary
477
+ -- JOIN lets SQLite scan every definition mention before applying the
478
+ -- barrel-symbol bloom filter on large indexes.
479
+ CROSS JOIN mentions m2 ON m2.symbol_id = br.symbol_id
480
+ AND m2.role = 1
481
+ JOIN chunks c2 ON m2.chunk_id = c2.id
482
+ GROUP BY m2.symbol_id
483
+ )
484
+ SELECT DISTINCT
485
+ br.barrel_doc_id,
486
+ br.barrel_path,
487
+ gs.id AS symbol_id,
488
+ gs.symbol AS symbol,
489
+ orig_d.id AS original_doc_id,
490
+ orig_d.relative_path AS original_path
491
+ FROM barrel_refs br
492
+ JOIN global_symbols gs ON br.symbol_id = gs.id
493
+ JOIN sym_def ON sym_def.symbol_id = gs.id
494
+ JOIN documents orig_d ON sym_def.document_id = orig_d.id
495
+ WHERE orig_d.id != br.barrel_doc_id
496
+ ${e.pathExclusionsFor("orig_d")}
497
+ ${e.symbolNoiseFor("gs")}
498
+ -- Only function-level symbols (ending with ().), not module-level
499
+ AND gs.symbol LIKE '%().'
500
+ ORDER BY br.barrel_path, gs.symbol`,...i)}function Uz(e,t){return e.get(`SELECT
501
+ SUM(CASE WHEN uses_barrel = 1 THEN 1 ELSE 0 END) AS barrel_consumers,
502
+ SUM(CASE WHEN uses_barrel = 0 THEN 1 ELSE 0 END) AS direct_consumers
503
+ FROM (
504
+ SELECT
505
+ consumer_d.id AS consumer_doc_id,
506
+ MAX(CASE WHEN EXISTS (
507
+ SELECT 1
508
+ FROM mentions barrel_m
509
+ JOIN chunks barrel_c ON barrel_m.chunk_id = barrel_c.id
510
+ WHERE barrel_c.document_id = consumer_d.id
511
+ AND barrel_m.role != 1
512
+ AND barrel_m.symbol_id IN (
513
+ SELECT m2.symbol_id
514
+ FROM mentions m2
515
+ JOIN chunks c2 ON m2.chunk_id = c2.id
516
+ WHERE c2.document_id = ?
517
+ AND m2.role != 1
518
+ )
519
+ ) THEN 1 ELSE 0 END) AS uses_barrel
520
+ FROM mentions ref_m
521
+ JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
522
+ JOIN documents consumer_d ON ref_c.document_id = consumer_d.id
523
+ WHERE ref_m.symbol_id = ?
524
+ AND ref_m.role != 1
525
+ AND consumer_d.id != ?
526
+ AND consumer_d.id != ?
527
+ ${e.pathExclusionsFor("consumer_d")}
528
+ GROUP BY consumer_d.id
529
+ )`,t.barrel_doc_id,t.symbol_id,t.barrel_doc_id,t.original_doc_id)}function zz(e,t,n){let i=[],r=Wz(e);for(let o of Gz(e,n))NC(r,o,o)>0||i.push(...Kz(e,t,o,r));return i}function Gz(e,t){return he(e,{scope:t,includeIgnored:!1}).filter(n=>Vo(e,n).length>0||br(e,n).length>0)}function Kz(e,t,n,i){let r=Vo(e,n).filter(s=>s.sourcePath&&!e.isIgnored(s.sourcePath)).flatMap(s=>MC(e,t,n,s.sourcePath,i,[qz(s.specifier)])),o=br(e,n).filter(s=>s.sourcePath&&!e.isIgnored(s.sourcePath)).flatMap(s=>MC(e,t,n,s.sourcePath,i,s.kind==="named"&&s.names.length>0?s.names:[s.kind==="star"?`* from ${s.sourcePath}`:`* namespace from ${s.sourcePath}`]));return[...r,...o]}function MC(e,t,n,i,r,o){let s=t.definitionsForFile(i);return o.map(a=>{let l=s.find(c=>c.leaf===a);return{barrelFile:n,symbol:l?.symbol??`source-reexport:${n}:${a}`,shortName:l?k(l.symbol):a,originalFile:i,barrelConsumers:0,directConsumers:NC(r,i,n),...AC(e,n)}})}function qz(e){return e.split("::").at(-1)?.split("/").at(-1)?.replace(/\.[^.]+$/,"")??e}function AC(e,t){return En(e,t)?{actionTier:"signal",surfaceEvidence:["barrel file is declared on the package public surface"],recommendation:"Review the package API before removing this re-export; local consumers are zero, but external consumers may import through the public barrel."}:{actionTier:"direct",surfaceEvidence:[],recommendation:"Remove this unused re-export when the barrel is not part of an external API surface."}}function Wz(e){let t=new Map;for(let n of he(e,{includeIgnored:!1}))for(let i of Ce(e,n)){if(!i.sourcePath)continue;let r=t.get(i.sourcePath)??new Set;r.add(n),t.set(i.sourcePath,r)}return t}function NC(e,t,n){let i=e.get(t);return i?i.size-(i.has(n)?1:0):0}function Vz(e){let t=new Set,n=[];for(let i of e){let r=`${i.barrelFile}|${i.symbol}|${i.originalFile}`;t.has(r)||(t.add(r),n.push(i))}return n}function Jz(e){e.sort((t,n)=>n.directConsumers-t.directConsumers||t.barrelFile.localeCompare(n.barrelFile)||t.shortName.localeCompare(n.shortName))}function Yz(e,t={}){let{samples:n=50,scope:i,maxDisagreements:r=5}=t,o=new U(e),s=Xz(o.productionCallableDefinitions({scope:i,minLoc:2,requireFunctionLikeSymbol:!0}),n),a=Zz(e,s);if(s.length===0||!a)return{available:!1,sampleSize:s.length,oracleCoverage:0,scores:[],topDisagreements:[]};let l={references:kC(),callees:kC()},c=[],u=0,d=a==="semantic"?Ns(e,s):{rows:new Map,incompleteSymbolIds:new Set,unavailableSymbolIds:new Set},m=a==="semantic"?ks(e,s):{rows:new Map,incompleteSymbolIds:new Set,unavailableSymbolIds:new Set},f=a==="source"?tG(e,o,s):null;for(let p of s){let g=Ya(p,a==="semantic"?(d.rows.get(p.symbolId)??[]).map(R=>R.file):[...f?.referencesBySymbolId.get(p.symbolId)??[]]),h=Ya(p,a==="semantic"?(m.rows.get(p.symbolId)??[]).map(R=>R.file):[...f?.calleesBySymbolId.get(p.symbolId)??[]]),S=a!=="semantic"||!d.incompleteSymbolIds.has(p.symbolId)&&!d.unavailableSymbolIds.has(p.symbolId),v=a!=="semantic"||!m.incompleteSymbolIds.has(p.symbolId)&&!m.unavailableSymbolIds.has(p.symbolId);S&&v&&(u+=1);let y=Ya(p,On(e,p,{semanticEvidence:pe}).map(R=>R.file)),E=Ya(p,(o.calleeMap([p],{semantic:!1}).get(p.symbolId)??[]).map(R=>R.file)),w=yd(a,"references"),b=yd(a,"callees");S?_C(l.references,p,"references",y,g,w,c):l.references.skippedOracleUnavailable+=1,v?_C(l.callees,p,"callees",E,h,b,c):l.callees.skippedOracleUnavailable+=1}return c.sort((p,g)=>g.cheapOnly.length+g.oracleOnly.length-(p.cheapOnly.length+p.oracleOnly.length)),{available:!0,sampleSize:s.length,oracleCoverage:s.length>0?Sd(u/s.length):0,oracleKind:a,scores:["references","callees"].map(p=>eG(p,l[p],a)),topDisagreements:c.slice(0,r)}}function kC(){return{comparedSymbols:0,agreed:0,cheapTotal:0,oracleTotal:0,skippedOraclePartial:0,skippedOracleUnavailable:0}}function Xz(e,t){let n=[...e].sort((o,s)=>o.symbolId-s.symbolId);if(n.length<=t)return n;let i=n.length/t,r=[];for(let o=0;o<t;o++)r.push(n[Math.floor(o*i)]);return r}function Zz(e,t){let n=t[0];if(!n)return null;if(bd(e,n))return"source";try{if(kt(e).capability("semantic-references",n.relativePath).available)return"semantic"}catch{}return t.some(i=>bd(e,i))?"source":null}function Ya(e,t){let n=new Set;for(let i of t)i!==e.relativePath&&n.add(i);return n}function _C(e,t,n,i,r,o,s){if(!o&&r.size===0){e.skippedOraclePartial+=1;return}e.comparedSymbols+=1,e.cheapTotal+=i.size,e.oracleTotal+=r.size;let a=[],l=[];for(let c of i)r.has(c)?e.agreed+=1:a.push(c);for(let c of r)i.has(c)||l.push(c);(a.length>0||l.length>0)&&s.push({symbol:k(t.symbol),question:n,cheapOnly:a,oracleOnly:l})}var Qz={references:!0,callees:!1};function eG(e,t,n){let i=t.oracleTotal>0?t.agreed/t.oracleTotal:1,r=t.cheapTotal-t.agreed,o=yd(n,e);return{question:e,comparedSymbols:t.comparedSymbols,precision:o&&t.cheapTotal>0?Sd(t.agreed/t.cheapTotal):null,recall:Sd(i),unverified:r,skippedOraclePartial:t.skippedOraclePartial,skippedOracleUnavailable:t.skippedOracleUnavailable}}function yd(e,t){return e==="semantic"?Qz[t]:!1}function bd(e,t){return ye(t.relativePath)==="clojure"&&ee(e,t.relativePath)!==null}function tG(e,t,n){let i=new Map,r=new Map,o=n.filter(l=>bd(e,l)),s=new Map;for(let l of o){let c=s.get(l.leaf)??[];c.push(l),s.set(l.leaf,c)}for(let l of t.sourceFiles()){if(ye(l)!=="clojure")continue;let c=ee(e,l);if(c)for(let u of c.fileIdentifiers)for(let d of s.get(u)??[])BC(i,d.symbolId,l)}let a=new Map;for(let l of t.scopedDefinitions()){if(ye(l.relativePath)!=="clojure")continue;let c=a.get(l.leaf)??[];c.push(l),a.set(l.leaf,c)}for(let l of o){let c=ee(e,l.relativePath);if(c){for(let u of c.callSites)if(!(u.line<l.startLine||u.line>l.endLine))for(let d of a.get(u.calleeLeaf)??[])BC(r,l.symbolId,d.relativePath)}}return{referencesBySymbolId:i,calleesBySymbolId:r}}function BC(e,t,n){let i=e.get(t);if(i){i.add(n);return}e.set(t,new Set([n]))}function Sd(e){return Math.round(e*1e3)/1e3}var nG=new Set(Zt());function iG(e,t={}){let{scope:n,minLoc:i=1,limit:r,scanLimit:o,maxShapeFrequency:s=12}=t,a=t.semantic!==!1,l=sG(e,rG(e,{scope:n,minLoc:i,scanLimit:o}),{semantic:a,maxShapeFrequency:s}),c=lG(l);return r?c.slice(0,r):c}function rG(e,t){let n=ze(e,{scope:t.scope}).filter(i=>oG(i)&&!e.isIgnored(i.relativePath)).filter(i=>de(i)>=t.minLoc);return typeof t.scanLimit=="number"&&t.scanLimit>0&&n.sort((i,r)=>de(r)-de(i)||i.relativePath.localeCompare(r.relativePath)),Ae(n,t.scanLimit)}function oG(e){return!e.isFunctionLike||at(e.symbol)?!1:e.kind===null||nG.has(e.kind)}function sG(e,t,n){let i=[];for(let s of t){let a=uG(e,s,n);a&&i.push({signature:a,definition:s,fn:aG(s)})}let r=new Map;for(let s of i)r.set(s.signature,(r.get(s.signature)??0)+1);let o=new Map;for(let s of i){let a=cG(s.fn.loc),l=(r.get(s.signature)??0)>n.maxShapeFrequency,c=l?Yu(e,s.definition):null;if(l&&!c)continue;let u=l?`${s.signature}\0body\0${c}`:`${s.signature}\0band\0${a}`,d=o.get(u)??{signature:s.signature,locBand:a,exactBody:l,functions:[]};d.functions.push(s.fn),o.set(u,d)}return[...o.values()]}function aG(e){return{symbol:e.symbol,shortName:k(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:de(e)}}function lG(e){let t=[];for(let n of e)n.functions.length>=2&&t.push(n);return t.sort((n,i)=>{let r=i.functions.length-n.functions.length;if(r!==0)return r;let o=n.functions.reduce((a,l)=>a+l.loc,0);return i.functions.reduce((a,l)=>a+l.loc,0)-o}),t}function cG(e){return e<=5?"<=5":e<=20?"6-20":">20"}function uG(e,t,n){if(n.semantic){let o=Cp(e,t);if(o)return o}let i=dG(t.documentation),r=i?pG(i):null;return r||gG(mG(e,t.relativePath,t.startLine,t.endLine,t.leaf),t.leaf)}function dG(e){return _i(Bi(e))}function mG(e,t,n,i,r){let o=se(e,t);if(!o)return null;let s=o.split(/\r?\n/),a=yG(s,n,i,r);for(let l of a){let c=Math.min(s.length-1,Math.max(l,l+4)),u="";for(let d=l;d<=c;d+=1){let m=s[d]?.trim();if(m&&(u=u?`${u} ${m}`:m,fG(u)))return u}if(u&&u.includes("("))return u}return null}function fG(e){let t=e.replace(/\s+/g," ").trim();return!t.includes("(")||im(t)>0?!1:/[;{]$/.test(t)||/\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(t)||/\)\s*As\s+.+$/i.test(t)}function pG(e){if(!e||!e.trim())return null;let t=e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim(),n=t.indexOf("(");return n===-1||(t=t.slice(n),t=t.replace(/\s+/g,"").toLowerCase(),t.length<3)?null:t}function gG(e,t){if(!e||!e.trim())return null;let n=e.replace(/\s+/g," ").trim(),i=n.indexOf("(");if(i===-1)return null;let r=n.slice(0,i),s=new RegExp(`\\b${He(t)}\\b`,"i").exec(r);s&&typeof s.index=="number"&&(r=r.slice(0,s.index)),r=r.replace(/\b(public|private|protected|internal|final|static|abstract|sealed|virtual|override|async|suspend|inline|constexpr|consteval|constinit|const|pub|fn|function|def|sub|friend|shared|readonly|new|open|partial|export)\b/gi," ").replace(/\s+/g," ").trim();let a=hG(n.slice(i)).replace(/\)\s*=\s*[\s\S]*$/,")").replace(/\s+throws\s+[^={]+$/i,"").replace(/\s+where\s+.+$/i,"").replace(/\s+/g," ").trim();if(!a.startsWith("("))return null;let l=`${r?`${r} `:""}${a}`.replace(/\s+/g,"").toLowerCase();return l.length>=3?l:null}function hG(e){let t=0,n=0,i=0,r=0,o=null,s=!1;for(let a=0;a<e.length;a+=1){let l=e[a];if(o){if(s){s=!1;continue}if(l==="\\"){s=!0;continue}l===o&&(o=null);continue}if(l==='"'||l==="'"||l==="`"){o=l;continue}if(l==="(")t+=1;else if(l===")")t=Math.max(0,t-1);else if(l==="[")i+=1;else if(l==="]")i=Math.max(0,i-1);else if(l==="<")r+=1;else if(l===">")r=Math.max(0,r-1);else if(l==="{"){if(t===0&&i===0&&r===0)return e.slice(0,a);n+=1}else if(l==="}")n=Math.max(0,n-1);else if(l==="="&&e[a+1]===">"&&t===0&&n===0&&i===0&&r===0)return e.slice(0,a)}return e}function yG(e,t,n,i){let r=He(i),o=new RegExp(`\\b${r}\\b\\s*\\(`,"i"),s=new RegExp(`\\bdef\\s+${r}\\b`,"i"),a=[],l=new Set,c=Math.max(0,Math.min(t,e.length-1)),u=Math.max(c,Math.min(e.length-1,Math.max(n,t+4)));for(let d=c;d<=u;d+=1){let m=e[d]??"";(o.test(m)||s.test(m))&&!l.has(d)&&(l.add(d),a.push(d))}for(let d=0;d<e.length;d+=1){let m=e[d]??"";(o.test(m)||s.test(m))&&!l.has(d)&&(l.add(d),a.push(d))}return a}function OC(e){return e+1}function SG(e,t){return`${OC(e)}-${OC(t)}`}function sie(e,t,n){return`${Nt(e)}:${SG(t,n)}`}function aie(e,t=180){let n=Nt(e).replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-3)}...`:n}var vd={empty(e){console.log(Nt(e))},list(e,t){for(let n of e)console.log(Nt(t(n)))},groupedByFile(e,t,n=i=>i.relativePath){let i="";for(let r of e){let o=n(r);o!==i&&(i&&console.log(""),console.log(Nt(o)),i=o),console.log(Nt(t(r)))}},sectionedReport(e){let t=!0;for(let n of e)if(!(n.skipIfEmpty&&n.rows.length===0)){t||console.log(""),t=!1,n.title!==void 0&&console.log(`\u2550\u2550\u2550 ${Nt(n.title)} \u2550\u2550\u2550`),n.explanation!==void 0&&console.log(Nt(n.explanation));for(let i of n.rows)console.log(Nt(i))}},table(e,t,n){console.log(` ${e.map(Nt).join(" ")}`);let i=n??e.map(r=>r.length);console.log(` ${i.map(r=>"\u2500".repeat(r)).join(" ")}`);for(let r of t)console.log(Nt(r))}};import{availableParallelism as UG}from"os";import{fileURLToPath as Pd}from"url";import{spawnSync as jie}from"child_process";import{execFileSync as uie}from"child_process";import{createHash as mie}from"crypto";import{lstatSync as pie,readlinkSync as gie,readdirSync as hie,realpathSync as yie,statSync as bie}from"fs";import{dirname as vie,isAbsolute as Cie,join as xie,posix as Rie,relative as Eie,resolve as wie,sep as Iie}from"path";var Die=512*1024*1024;function $C(e){return Tm({version:e.version,...e.base?{base:e.base}:{},files:[...e.files].sort((t,n)=>t.path.localeCompare(n.path))})}function Cd(e){return JSON.stringify({...e.clojureConfigPath?{clojureConfigPath:e.clojureConfigPath}:{},files:[...e.files].sort((t,n)=>t.path.localeCompare(n.path)).map(t=>({hash:t.hash,path:t.path,size:t.size})),languages:[...e.languages].sort(),pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),version:e.version})}var vG="codebaseiq:collaboration-domain",CG="codebaseiq:workspace-instance",xG="codebaseiq:index-generation",RG="codebaseiq:repository-content",jC="codebaseiq:index-inputs",EG="codebaseiq:index-inputs";function Di(e){let t=e.snapshot,n=e.observedSourceKinds?new Set(e.observedSourceKinds):void 0,i=e.gitContext??t?.gitContext??(n?.has("live-workspace")?al(e.projectRoot):void 0),r=e.collaborationDomainId??e.db?.config.collaborationDomainId,o=r?si(vG,1,r):void 0,s=i?si(CG,1,i.worktreeId):void 0,a=t?si(RG,1,$C(t.repositoryContent)):void 0,l=t?si(jC,t.indexInputs.version,Cd(t.indexInputs)):void 0,c=e.db&&t?IG(e.db.generation.metadataRaw):void 0,u=e.db?{generation:si(xG,1,e.db.generation.identity),...c?{inputs:c}:{},source:e.db.generation.source}:void 0,d=n??new Set([...u?["index-generation"]:[],...a?["repository-snapshot"]:s?["live-workspace"]:[]]),m=[...u&&d.has("index-generation")?[{kind:"index-generation",identity:u.generation}]:[],...a&&d.has("repository-snapshot")?[{kind:"repository-snapshot",identity:a}]:[],...s&&d.has("live-workspace")?[{kind:"live-workspace",identity:s}]:[],...d.has("process")?[{kind:"process"}]:[]],f=[...u&&d.has("index-generation")?[{source:"index-generation",kind:u.source==="immutable"?"immutable":"not-established"}]:[],...a&&d.has("repository-snapshot")?[{source:"repository-snapshot",kind:"fixed-snapshot"}]:[],...s&&d.has("live-workspace")?[{source:"live-workspace",kind:"not-established"}]:[],...d.has("process")?[{source:"process",kind:"not-established"}]:[]];return m.length===0&&(m.push({kind:"process"}),f.push({source:"process",kind:"not-established"})),{schemaVersion:Km,observedAt:(e.observedAt??(t?new Date(t.capturedAt):new Date)).toISOString(),facts:{...o?{collaborationDomain:o}:{},...s?{workspaceInstance:s}:{},...a?{wholeContent:a}:{},...l?{relevantInputs:[{subject:EG,identity:l}]}:{},...u?{index:u}:{}},observedSources:m,stabilityProofs:f,...i?{diagnostics:{clean:i.clean,...i.headCommit?{headCommit:i.headCommit}:{},...i.treeOid?{treeOid:i.treeOid}:{}}}:{}}}function wG(e){return Di({projectRoot:e.projectRoot,db:e.db,...e.gitContext?{gitContext:e.gitContext}:{},...e.observedAt?{observedAt:e.observedAt}:{},observedSourceKinds:["index-generation"]})}function Bie(){let e=ls();if(!e)return Di({projectRoot:Vm(),observedSourceKinds:["process"]});let t=e.config.projectRoot,n=al(t);return wG({projectRoot:t,db:e,...n?{gitContext:n}:{}})}function IG(e){if(!e)return;let t=$o(e);if(t.kind!=="legacy"&&t.kind!=="supported")return;let n=jd(t.metadata.fingerprint);return n&&Number.isSafeInteger(n.version)&&n.version>0?si(jC,n.version,Cd(n)):void 0}var Rd="codebaseiq-isolated-analysis",Ed=1;function LG(e){let t=[...e??[]];return t.includes("--json")?t:["--json",...t]}var fr=class extends Error{constructor(n,i,r=!0){super(`${n} timed out after ${i}ms.`);this.label=n;this.timeoutMs=i;this.reaped=r;this.name="IsolatedProcessTimeoutError"}label;timeoutMs;reaped;timedOut=!0};function Vie(e,t){let n=ls(),i={protocol:Rd,schemaVersion:Ed,producer:{name:"codebaseiq",version:ii},command:e,result:t,...n?{observationReceipt:Di({projectRoot:n.config.projectRoot,db:n,observedSourceKinds:["index-generation"]})}:{}};bl(JSON.stringify(i))}function HC(e,t){let n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n}function Xa(e){let t=e.timeoutMs??_m.analysis,n=e.maxBuffer??10*1024*1024;return Om({command:process.execPath,args:[...process.execArgv,e.cliPath,e.command,...LG(e.args)],cwd:process.cwd(),env:e.env??process.env,label:e.label,timeoutMs:t,maxStdoutBytes:n,maxStderrBytes:n,signal:e.signal}).catch(i=>{throw i instanceof Bm&&i.kind==="timeout"?new fr(e.label,t,i.reaped):i}).then(i=>{let r=i.stderr.trim();if(i.status!==0)throw new Error(`${e.label} failed${r?`:
530
+ ${r}`:""}`);return DG(i.stdout,e)})}function DG(e,t){let n;try{n=JSON.parse(e)}catch(r){throw new Error(`${t.label} returned invalid JSON: ${r instanceof Error?r.message:r}`,{cause:r})}if(!ol(n))throw new Error(`${t.label} returned a non-object isolated-analysis message.`);if(n.protocol!==Rd)throw new Error(`${t.label} returned protocol ${xd(n.protocol)}; expected ${Rd}.`);if(n.schemaVersion!==Ed)throw new Error(`${t.label} returned unsupported isolated-analysis schemaVersion ${xd(n.schemaVersion)}; expected ${Ed}.`);if(!PG(n.producer))throw new Error(`${t.label} did not identify a codebaseiq producer version.`);if(n.command!==t.command)throw new Error(`${t.label} returned result for command ${xd(n.command)}; expected ${t.command}.`);if(!Object.hasOwn(n,"result"))throw new Error(`${t.label} omitted the isolated-analysis result.`);let i=n.observationReceipt;if(i!==void 0&&(!qm(i)||i.schemaVersion!==2))throw new Error(`${t.label} returned an invalid observation receipt.`);return{result:n.result,...i?{observationReceipt:i}:{}}}function PG(e){return ol(e)&&e.name==="codebaseiq"&&typeof e.version=="string"&&e.version.length>0}function xd(e){return typeof e=="string"?JSON.stringify(e):String(e)}async function wd(e,t,n){let i=new Array(e.length),r=new AbortController,o=0,s,a=!1;async function l(){for(;!r.signal.aborted&&o<e.length;){let c=o++;try{i[c]=await n(e[c],r.signal)}catch(u){throw a||(a=!0,s=u,r.abort(u)),u}}}if(await Promise.allSettled(Array.from({length:Math.min(t,e.length)},()=>l())),a)throw s;return i}function UC(e,t){let n=new Set,i=[];for(let r of e){if(n.has(r))continue;let o=t.find(a=>a.has(r));if(!o){n.add(r),i.push([r]);continue}let s=e.filter(a=>o.has(a));s.forEach(a=>n.add(a)),i.push(s)}return i}import{spawnSync as TG}from"child_process";import{existsSync as FG,mkdirSync as MG,renameSync as AG,writeFileSync as NG}from"fs";import{dirname as GC,join as kG}from"path";var Za=6,_G="health-report-cache.json";function Id(e,t,n,i=HG()){let r=gn(e);return r?{version:Za,projectFingerprint:r,cliVersion:n,scope:t.scope??null,full:t.full===!0,phaseTimeoutMs:t.phaseTimeoutMs??null,gitHead:i.gitHead(e.config.projectRoot)}:null}function KC(e,t,n=JC()){let i=WC(e),r=VC(t),o=!1;return $("health.report-cache.read",()=>{if(!n.existsSync(i))return null;try{let s=JSON.parse(n.readFile(i));return!BG(s)||s.keyHash!==r?null:(o=!0,s.report)}catch{return null}},()=>({available:!0,hit:o,keyHash:r}))}function qC(e,t,n,i=JC()){let r=WC(e),o={version:Za,keyHash:VC(t),key:t,writtenAt:i.nowIso(),report:n};i.mkdirSync(GC(r),{recursive:!0});let s=`${r}.${process.pid}.${Date.now()}.tmp`;i.writeFileSync(s,JSON.stringify(o)),i.renameSync(s,r)}function WC(e){return kG(GC(e.config.dbPath),_G)}function VC(e){return jt(JSON.stringify(e))}function BG(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===Za&&typeof t.keyHash=="string"&&OG(t.key)&&typeof t.writtenAt=="string"&&$G(t.report)}function OG(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===Za&&typeof t.projectFingerprint=="string"&&typeof t.cliVersion=="string"&&(t.scope===null||typeof t.scope=="string")&&typeof t.full=="boolean"&&(t.phaseTimeoutMs===null||typeof t.phaseTimeoutMs=="number")&&(t.gitHead===null||typeof t.gitHead=="string")}function $G(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.score=="number"&&typeof t.riskScore=="number"&&typeof t.hygieneScore=="number"&&typeof t.overview=="object"&&typeof t.findings=="object"&&Array.isArray(t.scoreBreakdown)&&Array.isArray(t.actions)&&Array.isArray(t.pressure)&&Array.isArray(t.topComplexity)&&jG(t.coverage)}function jG(e){if(!e||typeof e!="object")return!1;let t=e;if(t.status!=="complete"&&t.status!=="incomplete"&&t.status!=="semantic-disabled")return!1;let n=t.complexity?.semanticEvidence;return zC(n)&&typeof n.excludedSymbolCount=="number"&&Array.isArray(t.phases)&&t.phases.every(i=>!!i&&typeof i=="object"&&typeof i.phase=="string"&&zC(i.semanticEvidence))}function zC(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.enabled=="boolean"&&(t.status==="complete"||t.status==="incomplete"||t.status==="unavailable"||t.status==="incomplete-and-unavailable"||t.status==="disabled")&&typeof t.incompleteSymbolCount=="number"&&typeof t.unavailableSymbolCount=="number"}function HG(){return{gitHead(e){let t=TG("git",["rev-parse","HEAD"],{cwd:e,encoding:"utf8",timeout:3e4,killSignal:"SIGKILL",windowsHide:!0});return t.status===0?t.stdout.trim():null}}}function JC(){return{existsSync:FG,mkdirSync:MG,readFile:e=>gr(e,"health report cache"),renameSync:AG,writeFileSync:NG,nowIso:()=>new Date().toISOString()}}var ZC="__health-phase",zG="__diff-impact-batch",GG=10,KG=4,qG=8,WG=25e3,VG=2500,Ld=2500,JG=4,YG=12,YC=3e4,QC=new Set(["react-component-duplicates","react-hook-candidates","react-large-component-pressure"]),ex=new Set(["vue-component-duplicates","vue-composable-candidates","vue-large-view-pressure"]),XG=new Set([...ex,"suppressions"]),ZG=new Set(["similar","extract-candidates"]),el=3,XC=hr({kind:"health-semantic-prewarm",invalidation:Je("health-semantic-prewarm"),serialize:e=>JSON.stringify(e),deserialize:QG});function QG(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;return n.version!==el||typeof n.definitions!="number"||!Number.isFinite(n.definitions)||typeof n.referenceCacheWrites!="number"||!Number.isFinite(n.referenceCacheWrites)||typeof n.referenceIncomplete!="number"||!Number.isFinite(n.referenceIncomplete)||typeof n.calleeRows!="number"||!Number.isFinite(n.calleeRows)||typeof n.warmedAt!="number"||!Number.isFinite(n.warmedAt)?null:{version:el,definitions:n.definitions,referenceCacheWrites:n.referenceCacheWrites,referenceIncomplete:n.referenceIncomplete,calleeRows:n.calleeRows,warmedAt:n.warmedAt}}catch{return null}}function vre(e){console.log(`Heuristic ${e}: review before acting; these are candidates, not exact compiler facts.
531
+ `)}function eK(e){let t=mi(e);return t.symbols>=WG||t.documents>=VG}function Cre(e,t,n,i={}){if(!eK(e))return{semantic:!0};if(n)return i.quiet||console.error(`Large index detected; ${t} is running the unbounded semantic pass because --full was supplied.`),{semantic:!0};if(!i.quiet){let r=t==="inspect"?"Use --full only when every omitted semantic candidate can change the decision; it does not override source or behavior materialization ceilings.":`Run "codebaseiq ${t} --full" for the unbounded semantic pass.`;console.error(`Large index detected; ${t} is using its bounded default analysis with semantic enrichment disabled. Candidate scans, when this command uses one, are capped at ${Ld}. `+r)}return{scanLimit:Ld,semantic:!1,analysisBudget:{scanLimit:Ld,semanticEnrichment:!1,reason:"large index default budget; pass --full for unbounded semantic analysis"}}}var tK={env:process.env,projectFingerprint:gn,semanticEngineFingerprint:oK,readMarker:(e,t,n)=>XC.read(e,t,n),writeMarker:(e,t,n,i)=>XC.write(e,t,n,i),candidateDefinitions:(e,t)=>new U(e).scopedDefinitions(t.scope).filter(n=>Ke(n.relativePath)!==null),materializeReferences:(e,t,n)=>kt(e).materializeReferences(t,n),materializeCallees:nc};function nK(e,t,n=tK){if(t.full!==!0)return ti("default-mode");if((n.env??process.env).CODEBASEIQ_HEALTH_SEMANTIC_PREWARM==="0")return ti("disabled");let i=ti("error");return $("health.semantic-prewarm",()=>{try{i=iK(e,t,n)}catch(r){i=ti("error",{error:r instanceof Error?r.message:String(r)})}return i},()=>sK(i))}function iK(e,t,n){let i=n.projectFingerprint(e);if(!i)return ti("missing-project-fingerprint");let r=rK(t,n.semanticEngineFingerprint(e)),o=n.readMarker(e,r,i);if(o&&o.referenceIncomplete===0)return ti("cache-hit");let s=[];if(s=$("health.semantic-prewarm.candidate-definitions",()=>(s=n.candidateDefinitions(e,t),s),()=>({definitions:s.length})),s.length===0)return ti("no-semantic-definitions");let a=0,l=$("health.semantic-prewarm.references",()=>{let m=n.materializeReferences(e,s,{prefetchCallees:!0});return a=m.cacheHits+m.cacheWrites+m.inMemoryHits,m},()=>({definitions:s.length,rows:a}));if(l.cacheHits+l.cacheWrites+l.inMemoryHits===0&&l.misses+l.unkeyed>0)return ti("provider-unavailable",{definitions:s.length,referenceMisses:l.misses});let u=0,d=$("health.semantic-prewarm.callees",()=>{let m=n.materializeCallees(e,s);return u=m.size,m},()=>({definitions:s.length,rows:u}));return l.incomplete>0?{status:"partial",reason:"incomplete-references",definitions:s.length,referenceCacheHits:l.cacheHits,referenceCacheWrites:l.cacheWrites,referenceMisses:l.misses,referenceIncomplete:l.incomplete,calleeRows:d.size}:($("health.semantic-prewarm.marker-write",()=>n.writeMarker(e,r,i,{version:el,definitions:s.length,referenceCacheWrites:l.cacheWrites,referenceIncomplete:l.incomplete,calleeRows:d.size,warmedAt:Date.now()})),{status:"warmed",reason:"cache-miss",definitions:s.length,referenceCacheHits:l.cacheHits,referenceCacheWrites:l.cacheWrites,referenceMisses:l.misses,referenceIncomplete:l.incomplete,calleeRows:d.size})}function rK(e,t){return JSON.stringify({version:el,cliVersion:ii,semanticEngineFingerprint:t,scope:e.scope??null})}function oK(e){return jt(JSON.stringify({kind:"health-semantic-prewarm-engine",rust:oi(e.config.projectRoot)}))}function ti(e,t={}){return{status:"skipped",reason:e,definitions:0,referenceCacheHits:0,referenceCacheWrites:0,referenceMisses:0,referenceIncomplete:0,calleeRows:0,...t}}function sK(e){return{status:e.status,reason:e.reason,definitions:e.definitions,referenceCacheHits:e.referenceCacheHits,referenceCacheWrites:e.referenceCacheWrites,referenceMisses:e.referenceMisses,referenceIncomplete:e.referenceIncomplete,calleeRows:e.calleeRows,error:e.error}}function Qa(e){return Sl(t=>{let n=Di({projectRoot:t.config.projectRoot,db:t,observedSourceKinds:["index-generation"]});return{value:e(t),anchor:{database:{config:t.config,generation:t.generation},generationDigest:n.facts.index.generation.digest}}})}function tl(e,t,n){let i=e[0];if(!i)throw new Error("An evidence-bound analysis requires at least one index observation anchor.");let r=i.generationDigest,o=e.every(a=>a.generationDigest===r),s=t.every(a=>a?.facts.index?.generation.digest===r);return Di({projectRoot:i.database.config.projectRoot,...o&&s?{db:i.database}:{},observedSourceKinds:n})}async function xre(e){return(await aK(e)).result}async function aK(e){let t=fK(e),n={...e,phaseTimeoutMs:t??null},i=Qa(g=>{let h=Id(g,n,ii);if(!h)return null;let S=KC(g,h);return S||null});if(i.value)return{result:i.value,observationReceipt:tl([i.anchor],[],["index-generation","live-workspace"])};let r=Qa(g=>({applicability:lK(g,e),overview:fd(g,"overview",e)})),{applicability:o,overview:s}=r.value,a=[i.anchor,r.anchor],l=new Map;l.set("overview",s);let c=Va.filter(g=>g==="overview"?!1:cK(g,o)?!0:(l.set(g,Pi(g)),!1)),u=uK(c);if(e.full){let g=Qa(h=>nK(h,e));a.push(g.anchor)}let d=await wd(u,pK(u.length),(g,h)=>dK(g,e,t,h)),m=d.flatMap(g=>g.result),f=[];if(m.forEach(g=>{g.healthPhaseMeta&&f.push(`Health phase "${g.phase}" deferred: ${g.healthPhaseMeta.reason}. Run health --full for exhaustive analysis.`),l.set(g.phase,g)}),f.length>0){let g=l.get("overview");l.set("overview",{...g,warnings:[...g.warnings,...f]})}let p=pd(Va.map(g=>l.get(g)));return Sl(g=>{let h=Id(g,n,ii);h&&qC(g,h,p)}),{result:p,observationReceipt:tl(a,d.map(g=>g.observationReceipt),["index-generation","live-workspace"])}}function lK(e,t){return Wo(e,{scope:t.scope})}function cK(e,t){return QC.has(e)?t.react:ex.has(e)?t.vue:!0}function uK(e){return UC(e,[QC,XG,ZG])}function Pi(e){let t={enabled:!0,status:"complete",incompleteSymbolCount:0,unavailableSymbolCount:0};switch(e){case"react-component-duplicates":return{phase:e,reactComponentDuplicates:{count:0,loc:0,files:[]},evidenceCoverage:t};case"react-hook-candidates":return{phase:e,reactHookCandidates:{count:0,loc:0,files:[]},evidenceCoverage:t};case"react-large-component-pressure":return{phase:e,reactLargeComponentPressure:{count:0,loc:0,files:[]},evidenceCoverage:t};case"vue-component-duplicates":return{phase:e,vueComponentDuplicates:{count:0,loc:0,files:[]},evidenceCoverage:t};case"vue-composable-candidates":return{phase:e,vueComposableCandidates:{count:0,loc:0,files:[]},evidenceCoverage:t};case"vue-large-view-pressure":return{phase:e,vueLargeViewPressure:{count:0,loc:0,files:[]},evidenceCoverage:t};default:throw new Error(`Health phase "${e}" cannot be synthesized.`)}}function dK(e,t,n,i){if(e.length===1)return mK(e[0],t,n,i).then(a=>({result:[a.result],...a.observationReceipt?{observationReceipt:a.observationReceipt}:{}}));let r=e.join(","),o=process.argv[1]??Pd(import.meta.url),s=[r];return t.scope&&s.push("--scope",t.scope),t.full&&s.push("--full"),Xa({cliPath:o,command:ZC,args:s,label:`Health phases "${r}"`,timeoutMs:n,signal:i}).catch(a=>{if(t.full||!(a instanceof fr))throw a;return{result:e.map(l=>tx(l,a.timeoutMs,`timed out after ${a.timeoutMs}ms`))}})}function mK(e,t,n,i){let r=process.argv[1]??Pd(import.meta.url),o=[e];return t.scope&&o.push("--scope",t.scope),t.full&&o.push("--full"),Xa({cliPath:r,command:ZC,args:o,label:`Health phase "${e}"`,timeoutMs:n,signal:i}).catch(s=>{if(t.full||!(s instanceof fr))throw s;return{result:tx(e,s.timeoutMs,`timed out after ${s.timeoutMs}ms`)}})}function fK(e,t=process.env){if(e.full)return;let n=t.CODEBASEIQ_HEALTH_PHASE_TIMEOUT_MS;if(!n)return YC;let i=parseInt(n,10);return!Number.isFinite(i)||i<0?YC:i===0?void 0:i}function tx(e,t,n){let i={evidenceCoverage:{enabled:!0,status:"unavailable",incompleteSymbolCount:0,unavailableSymbolCount:0},healthPhaseMeta:{status:"deferred",reason:n,timeoutMs:t}};switch(e){case"overview":throw new Error("Overview health phase cannot be deferred.");case"dead":return{phase:e,dead:{count:0,loc:0,files:[]},...i};case"isolated":return{phase:e,isolated:{count:0,loc:0,files:[]},...i};case"cycles":return{phase:e,realCycleCount:0,...i};case"similar":return{phase:e,similarCount:0,...i};case"duplicate-bodies":return{phase:e,duplicateBodies:{count:0,loc:0,files:[]},...i};case"twin-drift":return{phase:e,twinDrift:{count:0,loc:0,files:[]},...i};case"react-component-duplicates":return{...Pi(e),...i};case"react-hook-candidates":return{...Pi(e),...i};case"react-large-component-pressure":return{...Pi(e),...i};case"vue-component-duplicates":return{...Pi(e),...i};case"vue-composable-candidates":return{...Pi(e),...i};case"vue-large-view-pressure":return{...Pi(e),...i};case"extract-candidates":return{phase:e,extractCount:0,...i};case"wrapper-candidates":return{phase:e,wrappers:{count:0,loc:0,files:[]},...i};case"passthrough-candidates":return{phase:e,passthroughs:{count:0,loc:0,files:[]},...i};case"stale-abstractions":return{phase:e,stale:{count:0,loc:0,files:[],unused:0,singleUse:0},...i};case"drift":return{phase:e,drift:{count:0,unusedImports:0,architectureViolations:0,layerViolations:0,direct:0,signal:0},...i};case"complexity-hotspots":return{phase:e,complexity:{top:[],extremeCount:0,coverage:{semanticEvidence:{enabled:!0,status:"unavailable",incompleteSymbolCount:0,unavailableSymbolCount:0,excludedSymbolCount:0}}},...i};case"git-evidence":return{phase:e,gitEvidence:null,...i};case"suppressions":return{phase:e,suppressions:{total:0,byCategory:{}},...i};case"coverage-contracts":return{phase:e,coverageContracts:{count:0,loc:0,files:[]},...i}}}var pK=nx({envKey:"CODEBASEIQ_HEALTH_CONCURRENCY",defaultMinimum:JG,defaultMaximum:YG});function Rre(e){if(console.log(`
532
+ Codebase Health Score: ${e.score}/100`),console.log(` Risk: ${e.riskScore}/100 (risk-oriented graph facts + change graph)`),console.log(` Hygiene: ${e.hygieneScore}/100 (tidiness candidates)
533
+ `),console.log(` ${e.overview.documents} files | ${e.overview.symbols} symbols | ${Jm(e.overview.indexSizeBytes)}
534
+ `),e.warnings&&e.warnings.length>0){console.log(" Warnings:");for(let n of e.warnings)console.log(` ${n}`);console.log("")}console.log(" Findings:");let t=e.findings;if(t.deadSymbols>0&&console.log(` Dead code: ${t.deadSymbols} symbols (${t.deadLoc} LOC)`),t.isolatedSymbols>0&&console.log(` Isolated symbols: ${t.isolatedSymbols} (${t.isolatedLoc} LOC)`),t.cycles>0&&console.log(` Circular deps: ${t.cycles}`),t.similarPairs>0&&console.log(` Similar pairs: ${t.similarPairs}`),t.twinDriftGroups>0&&console.log(` Drifted twins: ${t.twinDriftGroups} group(s)`),t.reactComponentDuplicatePairs>0&&console.log(` React components: ${t.reactComponentDuplicatePairs} duplicate pair(s)`),t.reactHookCandidatePairs>0&&console.log(` React hook reuse: ${Dd(t.reactHookCandidatePairs,t.reactHookCandidateScoreCount)} candidate pair(s)`),t.reactLargeComponentPressureFiles>0&&console.log(` React large comps: ${t.reactLargeComponentPressureFiles} component(s)`),t.vueComponentDuplicatePairs>0&&console.log(` Vue components: ${t.vueComponentDuplicatePairs} duplicate pair(s)`),t.vueComposableCandidatePairs>0&&console.log(` Vue composables: ${Dd(t.vueComposableCandidatePairs,t.vueComposableCandidateScoreCount)} candidate pair(s)`),t.vueLargeViewPressureFiles>0&&console.log(` Vue large views: ${t.vueLargeViewPressureFiles} file(s)`),t.extractionCandidates>0&&console.log(` Extract candidates: ${t.extractionCandidates}`),t.wrappers>0&&console.log(` Wrapper functions: ${Dd(t.wrappers,t.wrapperScoreCount)}`),t.passthroughs>0&&console.log(` Passthroughs: ${t.passthroughs}`),t.staleTypes>0&&console.log(` Stale abstractions: ${t.staleTypes}`),t.driftedFiles>0&&console.log(` Pattern drift: ${t.driftedFiles} files`),t.complexityHotspotCount>0&&console.log(` Complexity hotspots: ${t.complexityHotspotCount}`),e.actions.length>0){console.log(`
535
+ Prioritized Actions (highest impact + lowest effort first):`);for(let n=0;n<e.actions.length;n++){let i=e.actions[n],r=i.locRecoverable>0?` (~${i.locRecoverable} LOC involved)`:"";console.log(` ${n+1}. [${i.effort} effort / ${i.impact} impact] ${i.description}${r}`)}}if(e.topComplexity.length>0){console.log(`
536
+ Top Complexity Hotspots:`);for(let n of e.topComplexity)console.log(` ${n.score.toFixed(1).padStart(6)} ${n.symbol}`)}if(yK(e),hK(e),e.scoreBreakdown.length>0){console.log(`
537
+ Score Breakdown (100 minus the following):`);for(let n of e.scoreBreakdown)console.log(` -${String(n.points).padStart(2)} ${n.axis}: ${n.detail}`)}e.actions.length===0&&console.log(e.warnings&&e.warnings.length>0?`
538
+ No findings from completed analyses. Review warnings before interpreting this result as clean.`:`
539
+ No issues found. Codebase is clean.`)}function Dd(e,t){return Math.abs(e-t)<.01?String(e):`${e} (${gK(t)} score-weighted)`}function gK(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,"").replace(/\.$/,"")}function hK(e){if(e.pressure.length!==0){console.log(`
540
+ Maintenance Pressure:`);for(let t of e.pressure)console.log(` ${t.category}: ${t.count} / ${t.threshold} threshold (${t.ratio}x, -${t.extraPenalty} ${t.kind})`)}}function yK(e){let t=e.axes;if(console.log(`
541
+ Axes:`),console.log(` Zero-reference candidates: ${t.deletable.loc} LOC across ${t.deletable.symbols} symbols`),t.changeAmplification){let i=t.changeAmplification;console.log(` Change amplification: ${i.medianFilesPerCommit} files/commit median, ${i.p90FilesPerCommit} p90 (${i.commitsAnalyzed} commits)`)}if(t.hiddenCoupling&&t.hiddenCoupling.pairCount>0){console.log(` Hidden coupling: ${t.hiddenCoupling.pairCount} co-changing pair(s) without a dependency edge`);for(let i of t.hiddenCoupling.top.slice(0,3))console.log(` ${i.fileA} <-> ${i.fileB} (${i.together}x together, ${Math.round(i.confidence*100)}%)`)}if(t.churnWeightedComplexity&&t.churnWeightedComplexity.length>0){let i=t.churnWeightedComplexity[0];i.weighted>0&&console.log(` Churn x complexity: hottest is ${i.symbol} (${i.changes} changes, weighted ${i.weighted})`)}let n=t.evidenceQuality;if(console.log(` Evidence quality: ${n.graphFindings} graph-fact finding(s), ${n.heuristicFindings} heuristic finding(s), ${n.userSuppressed} user-suppressed`),e.validation&&e.validation.flaggedFiles>0){let i=e.validation,r=i.ratio===null?"n/a":`${i.ratio}x`;console.log(` Validation: flagged files fix-density ${i.flaggedFixDensity} vs baseline ${i.baselineFixDensity} (${r})`),console.log(` fix-commit signal: subject-keyword heuristic over ${i.validationBasis.commitsScanned} commits`)}}async function Ere(e){let t=Qa(o=>{let s=ur(o,{base:e.base});return s.note?{kind:"complete",result:Pa(o,{base:e.base})}:s.changedFiles.length===0?{kind:"complete",result:Pa(o,{base:e.base})}:{kind:"batched",plan:s}}),n=t.value;if(n.kind==="complete")return{result:n.result,observationReceipt:tl([t.anchor],[],["index-generation","live-workspace"])};let i=HC(n.plan.changedFiles,GG),r=await wd(i,bK(i.length),(o,s)=>xK(o,e,s));return{result:Ta(n.plan.changedFiles,r.map(o=>o.result)),observationReceipt:tl([t.anchor],r.map(o=>o.observationReceipt),["index-generation","live-workspace"])}}var bK=nx({envKey:"CODEBASEIQ_DIFF_IMPACT_CONCURRENCY",defaultMinimum:KG,defaultMaximum:qG});function nx(e){return(t,n=process.env,i=UG)=>SK(t,n,i,e)}function SK(e,t,n,i){let r=t[i.envKey],o=CK(n,i),s=r?parseInt(r,10):o,a=!Number.isFinite(s)||s<1?Math.min(o,e):Math.min(s,e),l=vK(t);return l===null?a:Math.min(l,a)}function vK(e){let t=e.CODEBASEIQ_MAX_CONCURRENCY;if(!t)return null;let n=parseInt(t,10);return Number.isFinite(n)&&n>=1?n:null}function CK(e,t){let n=e(),i=Number.isFinite(n)?Math.max(t.defaultMinimum,n-1):0;return Math.min(t.defaultMaximum,Math.max(t.defaultMinimum,i))}function xK(e,t,n){let i=process.argv[1]??Pd(import.meta.url),r=[];return t.base&&r.push("--base",t.base),Xa({cliPath:i,command:zG,args:r,env:{...process.env,CODEBASEIQ_DIFF_IMPACT_FILES:JSON.stringify(e)},label:"Diff-impact batch",signal:n})}function wre(e){console.log(`Changed files: ${e.summary.totalChangedFiles}`),console.log(`Changed symbols: ${e.summary.totalChangedSymbols}`),console.log(`Affected consumer files: ${e.summary.totalAffectedFiles}`),e.summary.note&&console.log(`Note: ${e.summary.note}`);for(let n of e.evidenceTiers.filter(i=>i.state==="failed"))console.log(`WARNING: ${n.tier} evidence failed for ${n.attemptedSymbols} candidate symbol(s): ${n.reason}`);let t=e.attributionNotes.filter(n=>n.method==="unattributed");if(t.length>0){let n=[...new Set(t.map(i=>i.file))];for(let i of n){let r=t.filter(o=>o.file===i).length;console.log(`note: ${r} changed line-range(s) in ${i} belong to no indexed symbol`)}}console.log(""),e.changedSymbols.length>0&&(console.log("Changed symbols:"),vd.list(e.changedSymbols,n=>` ${n.file} ${n.shortName} (fan-in: ${n.fanIn})`)),e.affectedConsumers.length>0&&(console.log(`
542
+ Affected consumer files:`),vd.list(e.affectedConsumers,n=>` ${n.file} (${n.consumedSymbols} symbol(s))`))}export{Rr as a,Zt as b,Qm as c,EK as d,mi as e,ew as f,ic as g,rc as h,jr as i,oc as j,$s as k,bL as l,Vr as m,vl as n,Ol as o,IR as p,Jr as q,Yr as r,Xs as s,th as t,MD as u,tP as v,d2 as w,AY as x,aP as y,fP as z,Gt as A,sF as B,rM as C,co as D,iu as E,LM as F,ib as G,wi as H,p0 as I,y0 as J,b0 as K,S0 as L,M0 as M,k0 as N,_0 as O,B0 as P,$0 as Q,j0 as R,H0 as S,Ii as T,yb as U,fo as V,uu as W,uA as X,po as Y,pA as Z,gA as _,xA as $,LA as aa,DA as ba,PA as ca,yo as da,hu as ea,bo as fa,NN as ga,So as ha,vo as ia,bu as ja,Co as ka,xo as la,Su as ma,Ik as na,Ro as oa,M_ as pa,Lu as qa,Du as ra,hB as sa,ur as ta,MS as ua,YB as va,wo as wa,L$ as xa,Lo as ya,Y$ as za,Do as Aa,H1 as Ba,U1 as Ca,Y1 as Da,uj as Ea,yj as Fa,Nj as Ga,ed as Ha,Kv as Ia,nd as Ja,qv as Ka,Ua as La,uH as Ma,Ao as Na,No as Oa,ko as Pa,bU as Qa,SU as Ra,vU as Sa,dd as Ta,Va as Ua,fd as Va,QU as Wa,Nz as Xa,kz as Ya,Bz as Za,$z as _a,Yz as $a,iG as ab,Di as bb,Bie as cb,Vie as db,OC as eb,SG as fb,sie as gb,aie as hb,vd as ib,ZC as jb,zG as kb,vre as lb,Cre as mb,xre as nb,aK as ob,Rre as pb,Ere as qb,wre as rb};
543
+ //# sourceMappingURL=chunk-LONKINMJ.js.map