scip-query 0.21.1 → 0.22.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 (354) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/by-kind-4IYG2SKW.js +2 -0
  4. package/dist/call-graph-WQNXMNNN.js +2 -0
  5. package/dist/{chunk-5QM7QT5B.js → chunk-25GWKRUZ.js} +2 -2
  6. package/dist/chunk-2BTJALUS.js +454 -0
  7. package/dist/{chunk-4ZCLDH6T.js → chunk-2KVU55CW.js} +2 -2
  8. package/dist/{chunk-CQVDALWQ.js → chunk-2OXVP5U5.js} +2 -2
  9. package/dist/{chunk-I2LY3KN7.js → chunk-2RE5OCHZ.js} +2 -2
  10. package/dist/{chunk-5J3A6RBZ.js → chunk-2XCGSDIT.js} +2 -2
  11. package/dist/{chunk-4KIPF45P.js → chunk-2YC7YNKT.js} +2 -2
  12. package/dist/{chunk-ZNW5A5VX.js → chunk-3QXC54FQ.js} +2 -2
  13. package/dist/{chunk-SGSPCEFC.js → chunk-3TJY6M3B.js} +2 -2
  14. package/dist/chunk-42W3LFUK.js +13 -0
  15. package/dist/chunk-44T4DUAA.js +2 -0
  16. package/dist/{chunk-YBWE6J32.js → chunk-4GAQ6FI4.js} +2 -2
  17. package/dist/{chunk-OU6SDWAM.js → chunk-4HE7MVWD.js} +2 -2
  18. package/dist/{chunk-QN2AI3D2.js → chunk-4TQU4TX2.js} +2 -2
  19. package/dist/{chunk-OMVNRPST.js → chunk-56NQAEPJ.js} +2 -2
  20. package/dist/{chunk-O4PZFAXA.js → chunk-57N6LN2A.js} +2 -2
  21. package/dist/{chunk-7MUHSZGN.js → chunk-5H5WTJSD.js} +2 -2
  22. package/dist/{chunk-J4HUBIVF.js → chunk-5YRQIE2B.js} +2 -2
  23. package/dist/{chunk-3XQLJG7V.js → chunk-5ZMBRQFC.js} +2 -2
  24. package/dist/{chunk-H2RBDP5S.js → chunk-6HRZQLOI.js} +2 -2
  25. package/dist/{chunk-PJBYDCBQ.js → chunk-6NC3YSPY.js} +2 -2
  26. package/dist/{chunk-MLTSTKXD.js → chunk-6VEFRPTD.js} +2 -2
  27. package/dist/{chunk-JLZWYDCZ.js → chunk-7C26EKLZ.js} +2 -2
  28. package/dist/{chunk-LXMW6ZAX.js → chunk-7IQXARSQ.js} +2 -2
  29. package/dist/chunk-7JYHQAH2.js +22 -0
  30. package/dist/{chunk-YA72ZUKO.js → chunk-7KSO2OAP.js} +2 -2
  31. package/dist/{chunk-YT4IQBET.js → chunk-7U2YQSDE.js} +2 -2
  32. package/dist/{chunk-XDOEHEET.js → chunk-7XA3OM44.js} +2 -2
  33. package/dist/{chunk-BCTCADNB.js → chunk-7XZGZBSQ.js} +2 -2
  34. package/dist/{chunk-3KXFB2FM.js → chunk-7YQOCABQ.js} +2 -2
  35. package/dist/chunk-A77SCPW2.js +3 -0
  36. package/dist/chunk-AK3PYTIK.js +5 -0
  37. package/dist/{chunk-6X4KO5A7.js → chunk-AMIMMNA4.js} +2 -2
  38. package/dist/{chunk-PWEQ6CZZ.js → chunk-AQ2PORIO.js} +2 -2
  39. package/dist/{chunk-E6N6YTVM.js → chunk-ARVO6TTW.js} +2 -2
  40. package/dist/{chunk-U7DOYZDH.js → chunk-AUY5BL74.js} +2 -2
  41. package/dist/{chunk-B3AREUQK.js → chunk-AYPDH2LU.js} +2 -2
  42. package/dist/{chunk-HR5JYLVV.js → chunk-AZS7YPCB.js} +2 -2
  43. package/dist/{chunk-ZQUNCTEZ.js → chunk-BDGTPN27.js} +2 -2
  44. package/dist/{chunk-DZNWXJN2.js → chunk-BDHFVH2M.js} +2 -2
  45. package/dist/{chunk-743MEVFJ.js → chunk-BECZLYNU.js} +2 -2
  46. package/dist/{chunk-4IASLUOP.js → chunk-BJT7LSPK.js} +2 -2
  47. package/dist/{chunk-X5MWO4DM.js → chunk-BTVKZGWT.js} +2 -2
  48. package/dist/{chunk-HYU4W353.js → chunk-BUTEIZKP.js} +2 -2
  49. package/dist/{chunk-UXNXOMXJ.js → chunk-BVFYEEBH.js} +2 -2
  50. package/dist/{chunk-UM56ZET4.js → chunk-BWVQP3LB.js} +2 -2
  51. package/dist/chunk-BYDAFMSR.js +57 -0
  52. package/dist/{chunk-P3UFF22M.js → chunk-C76O5MDS.js} +2 -2
  53. package/dist/chunk-C7IJMOFP.js +134 -0
  54. package/dist/{chunk-IM23CSG5.js → chunk-CBBHFNLX.js} +2 -2
  55. package/dist/{chunk-IZKJQQCQ.js → chunk-CKRWA452.js} +2 -2
  56. package/dist/{chunk-YLNCTPOI.js → chunk-CLG6DWVS.js} +2 -2
  57. package/dist/{chunk-DXEJ4FLZ.js → chunk-D2MVJSP4.js} +8 -8
  58. package/dist/chunk-D35XIZGN.js +2 -0
  59. package/dist/{chunk-AQF35NGT.js → chunk-DEAB5TGT.js} +2 -2
  60. package/dist/{chunk-7G2WIVIX.js → chunk-DJAO2OZJ.js} +2 -2
  61. package/dist/{chunk-PRLU3I7G.js → chunk-DKM723YF.js} +4 -4
  62. package/dist/{chunk-RSUH7G5T.js → chunk-DPWKKNKI.js} +2 -2
  63. package/dist/chunk-E44IVWIJ.js +367 -0
  64. package/dist/{chunk-W7HN6V4E.js → chunk-EDMB6SSO.js} +2 -2
  65. package/dist/{chunk-YCXQQ3YB.js → chunk-EELG7D3Q.js} +2 -2
  66. package/dist/{chunk-T2PBOVDI.js → chunk-EELPBR7E.js} +2 -2
  67. package/dist/{chunk-PAZSBPJR.js → chunk-EETGXQY7.js} +2 -2
  68. package/dist/{chunk-DUDUIT5P.js → chunk-ENWQWA2R.js} +2 -2
  69. package/dist/{chunk-QH5Q6M5C.js → chunk-ERCYGVAM.js} +2 -2
  70. package/dist/{chunk-ZGDHC5AT.js → chunk-EWWY2ZFL.js} +2 -2
  71. package/dist/{chunk-LJMWILX6.js → chunk-F24G5NBE.js} +2 -2
  72. package/dist/{chunk-XNF5T4T2.js → chunk-F24QUEQP.js} +2 -2
  73. package/dist/{chunk-IH3K5J6K.js → chunk-FBCVASUG.js} +2 -2
  74. package/dist/{chunk-EPLE5O5O.js → chunk-FELGD32K.js} +2 -2
  75. package/dist/{chunk-PU6XDQ2X.js → chunk-FFJQZG6J.js} +5 -5
  76. package/dist/{chunk-JGMD6JGB.js → chunk-FGNCOQUX.js} +2 -2
  77. package/dist/chunk-FKGQOTKD.js +2 -0
  78. package/dist/{chunk-27OUNZW5.js → chunk-GDRJB3SB.js} +2 -2
  79. package/dist/chunk-GH5YSGZL.js +5 -0
  80. package/dist/{chunk-IHGK3SZ7.js → chunk-GIQ6CSL4.js} +2 -2
  81. package/dist/{chunk-ITF3CWS5.js → chunk-GPGRZJ3R.js} +2 -2
  82. package/dist/{chunk-EJHNTAEE.js → chunk-GQIDEID3.js} +2 -2
  83. package/dist/{chunk-UEQORB2A.js → chunk-GRX7JOXQ.js} +2 -2
  84. package/dist/{chunk-6QN4FYQW.js → chunk-GVOMSPGL.js} +2 -2
  85. package/dist/{chunk-NT4NVEHU.js → chunk-GY7CCCEZ.js} +2 -2
  86. package/dist/{chunk-BVR44XXB.js → chunk-H7CG6LOE.js} +2 -2
  87. package/dist/{chunk-67FK5KGV.js → chunk-HCVJR2V4.js} +2 -2
  88. package/dist/{chunk-FOP7HD6H.js → chunk-HG722PO7.js} +2 -2
  89. package/dist/{chunk-YR7VRWNX.js → chunk-HISEUIL2.js} +2 -2
  90. package/dist/{chunk-Y2S4YNLH.js → chunk-HXOU4XNH.js} +2 -2
  91. package/dist/{chunk-DZA7MQMU.js → chunk-I6UTXNHU.js} +2 -2
  92. package/dist/{chunk-QZCACNV5.js → chunk-IJMD6BRI.js} +2 -2
  93. package/dist/{chunk-QGVUPYBC.js → chunk-IKVNEGTW.js} +2 -2
  94. package/dist/chunk-IMKZEXZG.js +2 -0
  95. package/dist/{chunk-LGVTIZPV.js → chunk-ISIQLPJ2.js} +2 -2
  96. package/dist/{chunk-BYXWXLKM.js → chunk-ISWFRGJ6.js} +2 -2
  97. package/dist/chunk-IW5XQG5G.js +2 -0
  98. package/dist/{chunk-ZMS4YCY7.js → chunk-IXESDH3J.js} +2 -2
  99. package/dist/{chunk-K63CAPS2.js → chunk-JAT6C3VX.js} +2 -2
  100. package/dist/{chunk-U2MNECDU.js → chunk-JFQBRL3J.js} +2 -2
  101. package/dist/{chunk-4SZJF4GK.js → chunk-JHH5SCZ3.js} +2 -2
  102. package/dist/{chunk-AAOEROT3.js → chunk-JJ62MTQH.js} +2 -2
  103. package/dist/chunk-JT6XX7QY.js +8 -0
  104. package/dist/{chunk-OY7PCALC.js → chunk-JUN5DOAK.js} +2 -2
  105. package/dist/{chunk-DXYMTQZ4.js → chunk-K3XFWJI2.js} +2 -2
  106. package/dist/{chunk-ZP2WUVZ5.js → chunk-KFVSJX25.js} +2 -2
  107. package/dist/{chunk-ND3BWIVN.js → chunk-KQHJEU6V.js} +2 -2
  108. package/dist/{chunk-KGKCJFWZ.js → chunk-KZYID5KV.js} +2 -2
  109. package/dist/{chunk-2LJLEM5B.js → chunk-LO5JSW2C.js} +2 -2
  110. package/dist/{chunk-CNT4ND5O.js → chunk-LRI5OMPE.js} +2 -2
  111. package/dist/{chunk-FCGMQETU.js → chunk-LXQUF2RP.js} +2 -2
  112. package/dist/{chunk-FSPENGSU.js → chunk-MHIEP7EG.js} +2 -2
  113. package/dist/{chunk-LIWIV26I.js → chunk-MSR2QRUE.js} +2 -2
  114. package/dist/chunk-N7FP5H5U.js +57 -0
  115. package/dist/{chunk-527HV7JY.js → chunk-NEIQPFBI.js} +2 -2
  116. package/dist/chunk-NK3JMP22.js +2 -0
  117. package/dist/{chunk-DK6MB565.js → chunk-NRBNAECH.js} +2 -2
  118. package/dist/{chunk-4HQYNZ3P.js → chunk-NVSZNESQ.js} +2 -2
  119. package/dist/{chunk-QLWZUFDT.js → chunk-OJNK5ALA.js} +2 -2
  120. package/dist/{chunk-MRXBLYRE.js → chunk-OPSAW5DT.js} +2 -2
  121. package/dist/{chunk-4TOU7HHQ.js → chunk-OTSPRVNW.js} +2 -2
  122. package/dist/{chunk-IQMGNIGY.js → chunk-OXYAWIEA.js} +2 -2
  123. package/dist/chunk-OZETODHH.js +2 -0
  124. package/dist/chunk-PBUH2P5S.js +3 -0
  125. package/dist/{chunk-5BJPJUXF.js → chunk-PIFTZEEM.js} +2 -2
  126. package/dist/{chunk-C52Q3JEQ.js → chunk-PLJUQFQN.js} +2 -2
  127. package/dist/{chunk-NODZYYGC.js → chunk-PLYUVM4F.js} +2 -2
  128. package/dist/{chunk-47WX6UC4.js → chunk-PXXYQK55.js} +2 -2
  129. package/dist/{chunk-SBFDPHKH.js → chunk-Q55NF3ZG.js} +2 -2
  130. package/dist/{chunk-N4EFQIRX.js → chunk-Q5TA4OY4.js} +2 -2
  131. package/dist/{chunk-HW7FASEL.js → chunk-Q6T2CAJL.js} +2 -2
  132. package/dist/chunk-Q7GBK5T7.js +81 -0
  133. package/dist/{chunk-CXT3GZSQ.js → chunk-QKT4UI2Y.js} +2 -2
  134. package/dist/{chunk-DGM2RJ3I.js → chunk-QLBSG7U5.js} +2 -2
  135. package/dist/chunk-QWKHW6VZ.js +2 -0
  136. package/dist/{chunk-3T5U2EQ2.js → chunk-R6M456QG.js} +2 -2
  137. package/dist/{chunk-RZWBTKXO.js → chunk-RDULNRSJ.js} +2 -2
  138. package/dist/{chunk-YKHL4J3G.js → chunk-RHHCLWQ6.js} +2 -2
  139. package/dist/{chunk-YF25RQER.js → chunk-RNKPYYYE.js} +2 -2
  140. package/dist/{chunk-XKM5D2XS.js → chunk-RPL3ARU7.js} +2 -2
  141. package/dist/{chunk-XFRHBAIT.js → chunk-RYOYJMGF.js} +2 -2
  142. package/dist/chunk-SB25YMEQ.js +2 -0
  143. package/dist/{chunk-SRIZDEWX.js → chunk-SVHTMVA4.js} +2 -2
  144. package/dist/{chunk-AFRS7WJU.js → chunk-SWK4XPUS.js} +2 -2
  145. package/dist/{chunk-YDTK77JP.js → chunk-T6QD2ZQB.js} +2 -2
  146. package/dist/{chunk-Z2QB75BS.js → chunk-TAYD3AE7.js} +2 -2
  147. package/dist/chunk-TD7VKJ2Y.js +117 -0
  148. package/dist/{chunk-K2DZCH2K.js → chunk-TH6IC56G.js} +2 -2
  149. package/dist/{chunk-FIO44MVK.js → chunk-TKDNDQA7.js} +2 -2
  150. package/dist/{chunk-Q4MRRB3C.js → chunk-TNG2FYS5.js} +2 -2
  151. package/dist/chunk-TQZV7KV4.js +2 -0
  152. package/dist/{chunk-NSDPPUDY.js → chunk-TUQIPUDS.js} +2 -2
  153. package/dist/chunk-TUSPIVZ3.js +4 -0
  154. package/dist/{chunk-RNKRYK6B.js → chunk-U2N2KE7A.js} +2 -2
  155. package/dist/{chunk-G47MFF47.js → chunk-UAQ4T73O.js} +2 -2
  156. package/dist/{chunk-5KIJMEPC.js → chunk-UDY7MIAW.js} +2 -2
  157. package/dist/{chunk-MLTKGHD2.js → chunk-URSGGIZX.js} +2 -2
  158. package/dist/{chunk-IGBQVEHE.js → chunk-UT7TADJX.js} +2 -2
  159. package/dist/{chunk-Z67JOKRE.js → chunk-V4NG5OMS.js} +105 -105
  160. package/dist/{chunk-OA2BO4DR.js → chunk-VMWUV6WB.js} +2 -2
  161. package/dist/{chunk-PX6QNUYF.js → chunk-VTCIYFEK.js} +2 -2
  162. package/dist/{chunk-6DO3VBLV.js → chunk-VU6LIWHT.js} +2 -2
  163. package/dist/{chunk-CTO3TRX7.js → chunk-VUSKPCUB.js} +2 -2
  164. package/dist/{chunk-V6XENWOF.js → chunk-VXJJTQYE.js} +2 -2
  165. package/dist/{chunk-BM4OTGSY.js → chunk-VZ7NXSHV.js} +2 -2
  166. package/dist/{chunk-ARGPDW2Y.js → chunk-WHADK6OS.js} +2 -2
  167. package/dist/chunk-WN3TCGJ4.js +2 -0
  168. package/dist/{chunk-GBZCVYWA.js → chunk-WOOAY3PA.js} +2 -2
  169. package/dist/{chunk-FLSVYEPL.js → chunk-WSLEJSFR.js} +2 -2
  170. package/dist/{chunk-BMKTDJI6.js → chunk-WYZIHUPZ.js} +2 -2
  171. package/dist/{chunk-WZ7V4BQV.js → chunk-XE33FV5W.js} +2 -2
  172. package/dist/{chunk-JO6FK3Q5.js → chunk-XFMVKFSF.js} +2 -2
  173. package/dist/{chunk-3YETOKNO.js → chunk-XGGBK66W.js} +2 -2
  174. package/dist/{chunk-BZCRHP46.js → chunk-XJX6LGHL.js} +2 -2
  175. package/dist/{chunk-OFZVFIDF.js → chunk-XN22RGSR.js} +2 -2
  176. package/dist/{chunk-VJAD5WX5.js → chunk-XSWYJCAK.js} +2 -2
  177. package/dist/{chunk-WV6R37XV.js → chunk-XU75YQN4.js} +2 -2
  178. package/dist/{chunk-UBETC3Q2.js → chunk-Y2VM4CJC.js} +2 -2
  179. package/dist/{chunk-7YZGSLW6.js → chunk-Y334QQU5.js} +2 -2
  180. package/dist/{chunk-TP2X2C2Y.js → chunk-YAGYMBEX.js} +2 -2
  181. package/dist/{chunk-KBIC6JHJ.js → chunk-YIHNPKWD.js} +2 -2
  182. package/dist/{chunk-5Z2H76VD.js → chunk-YXPUP5G2.js} +2 -2
  183. package/dist/{chunk-G6VV7ROY.js → chunk-Z2AWCTN6.js} +2 -2
  184. package/dist/{chunk-O3EX5STE.js → chunk-Z2PZVKPR.js} +2 -2
  185. package/dist/{chunk-OG5UK2K7.js → chunk-ZAZGGSM3.js} +2 -2
  186. package/dist/{chunk-GTZFKDP3.js → chunk-ZGW4HLPD.js} +2 -2
  187. package/dist/chunk-ZOXKSQQB.js +2 -0
  188. package/dist/{chunk-KFFQURUZ.js → chunk-ZPASRBLF.js} +2 -2
  189. package/dist/{chunk-WZRNEVYC.js → chunk-ZYM4HOFA.js} +2 -2
  190. package/dist/{chunk-FUUDUAKM.js → chunk-ZZ3Z7D56.js} +2 -2
  191. package/dist/cli-main.js +2 -2
  192. package/dist/code-EQJFDT6I.js +2 -0
  193. package/dist/code-result-json-7UWIWBOO.js +2 -0
  194. package/dist/{command-descriptors-6INSCKLW.js → command-descriptors-ORNTVNYV.js} +89 -89
  195. package/dist/dataflow-6VL54GX5.js +2 -0
  196. package/dist/dependence-slice-DT2NUHD2.js +2 -0
  197. package/dist/deps-DB7H5IKC.js +2 -0
  198. package/dist/direct-navigation-O3LUAYWQ.js +3 -0
  199. package/dist/entry-map-6K62RV3D.js +2 -0
  200. package/dist/files-MSLD7MO6.js +2 -0
  201. package/dist/hierarchy-IVBXAKFA.js +2 -0
  202. package/dist/imports-FRAVZ3Y2.js +2 -0
  203. package/dist/index.js +1 -1
  204. package/dist/members-KJOJDYGO.js +2 -0
  205. package/dist/methods-2AYABBT3.js +2 -0
  206. package/dist/output-continuation-command-JHMPH6NC.js +3 -0
  207. package/dist/project-reindex-HYO4WD7Z.js +3 -0
  208. package/dist/queries/affected.js +1 -1
  209. package/dist/queries/anchors.js +1 -1
  210. package/dist/queries/architecture.js +1 -1
  211. package/dist/queries/bottlenecks.js +1 -1
  212. package/dist/queries/by-kind.js +1 -1
  213. package/dist/queries/call-graph.js +1 -1
  214. package/dist/queries/change-surface.js +1 -1
  215. package/dist/queries/cleanup-plan.js +1 -1
  216. package/dist/queries/co-change.js +1 -1
  217. package/dist/queries/code.js +1 -1
  218. package/dist/queries/complexity-hotspots.js +1 -1
  219. package/dist/queries/complexity.d.ts +11 -0
  220. package/dist/queries/complexity.js +1 -1
  221. package/dist/queries/context.js +1 -1
  222. package/dist/queries/convergence.js +1 -1
  223. package/dist/queries/coupling.js +1 -1
  224. package/dist/queries/cycles.js +1 -1
  225. package/dist/queries/dataflow.js +1 -1
  226. package/dist/queries/dead.js +1 -1
  227. package/dist/queries/decorative-checkers.js +1 -1
  228. package/dist/queries/deep-chains.js +1 -1
  229. package/dist/queries/dependence-slice.js +1 -1
  230. package/dist/queries/dependency-depth.js +1 -1
  231. package/dist/queries/deps.js +1 -1
  232. package/dist/queries/diff-impact.js +1 -1
  233. package/dist/queries/doc-drift.js +1 -1
  234. package/dist/queries/drift.js +1 -1
  235. package/dist/queries/duplicate-bodies.js +1 -1
  236. package/dist/queries/entry-map.js +1 -1
  237. package/dist/queries/evidence.js +1 -1
  238. package/dist/queries/extract-candidates.js +1 -1
  239. package/dist/queries/fan.js +1 -1
  240. package/dist/queries/files.js +1 -1
  241. package/dist/queries/health.js +1 -1
  242. package/dist/queries/hierarchy.js +1 -1
  243. package/dist/queries/hotspots.js +1 -1
  244. package/dist/queries/imports.js +1 -1
  245. package/dist/queries/incomplete-migration.js +1 -1
  246. package/dist/queries/index.js +1 -1
  247. package/dist/queries/isolated.js +1 -1
  248. package/dist/queries/locality-candidates.js +1 -1
  249. package/dist/queries/members.js +1 -1
  250. package/dist/queries/methods.js +1 -1
  251. package/dist/queries/not-implemented.js +1 -1
  252. package/dist/queries/outline.js +1 -1
  253. package/dist/queries/passthrough-candidates.js +1 -1
  254. package/dist/queries/plan-context.js +1 -1
  255. package/dist/queries/react-component-duplicates.js +1 -1
  256. package/dist/queries/react-hook-candidates.js +1 -1
  257. package/dist/queries/react-large-component-pressure.js +1 -1
  258. package/dist/queries/recent-duplicates.js +1 -1
  259. package/dist/queries/redundant-reexports.js +1 -1
  260. package/dist/queries/reference-neighborhood.js +1 -1
  261. package/dist/queries/reference-reachability.js +1 -1
  262. package/dist/queries/refs.js +1 -1
  263. package/dist/queries/self-audit.js +1 -1
  264. package/dist/queries/similar-chains.js +1 -1
  265. package/dist/queries/similar-files.js +1 -1
  266. package/dist/queries/similar-signatures.js +1 -1
  267. package/dist/queries/similar.js +1 -1
  268. package/dist/queries/slice.js +1 -1
  269. package/dist/queries/source-inspection.js +1 -1
  270. package/dist/queries/source-search.js +1 -1
  271. package/dist/queries/stale-abstractions.js +1 -1
  272. package/dist/queries/surface.js +1 -1
  273. package/dist/queries/symbols.js +1 -1
  274. package/dist/queries/system-map.js +1 -1
  275. package/dist/queries/system.js +1 -1
  276. package/dist/queries/test-quality.js +1 -1
  277. package/dist/queries/trace.js +1 -1
  278. package/dist/queries/twin-ab.js +1 -1
  279. package/dist/queries/twin-drift.js +1 -1
  280. package/dist/queries/unused-imports.js +1 -1
  281. package/dist/queries/unused-params.js +1 -1
  282. package/dist/queries/value-flow.js +1 -1
  283. package/dist/queries/vue-component-duplicates.js +1 -1
  284. package/dist/queries/vue-composable-candidates.js +1 -1
  285. package/dist/queries/vue-large-view-pressure.js +1 -1
  286. package/dist/queries/wrapper-candidates.js +1 -1
  287. package/dist/query-service-fastpath.js +5 -5
  288. package/dist/query-service-server.js +2 -2
  289. package/dist/refs-ARMA6XUJ.js +2 -0
  290. package/dist/{refs-pagination-SRCUOYRD.js → refs-pagination-VUGIWN6U.js} +2 -2
  291. package/dist/reindex-worker.js +64 -22
  292. package/dist/reindex.js +74 -32
  293. package/dist/runtime.js +1 -1
  294. package/dist/rust-semantic-session-server.js +1 -1
  295. package/dist/rust-semantic-session-worker.js +1 -1
  296. package/dist/rust-semantic-worker.js +1 -1
  297. package/dist/slice-YOB5YFAM.js +2 -0
  298. package/dist/surface-VY5EFWTW.js +2 -0
  299. package/dist/{symbol-resolution-SVSMX4RN.js → symbol-resolution-DGQN4XIV.js} +2 -2
  300. package/dist/system-2KQ3QD2P.js +2 -0
  301. package/dist/trace-HTIPTXAE.js +2 -0
  302. package/dist/typescript-mailbox-worker.js +1 -1
  303. package/dist/value-flow-5FV3VQI7.js +2 -0
  304. package/dist/watch-server.js +3 -3
  305. package/package.json +1 -1
  306. package/dist/by-kind-XXGZGNZ6.js +0 -2
  307. package/dist/call-graph-VGY3R4L3.js +0 -2
  308. package/dist/chunk-3XZELASU.js +0 -2
  309. package/dist/chunk-63TFRBMB.js +0 -2
  310. package/dist/chunk-6LS3IG2I.js +0 -13
  311. package/dist/chunk-7Z4GMCHM.js +0 -117
  312. package/dist/chunk-ANCHW2R4.js +0 -57
  313. package/dist/chunk-C7WSQA6A.js +0 -21
  314. package/dist/chunk-DNPETNXT.js +0 -2
  315. package/dist/chunk-E7CJ6O72.js +0 -2
  316. package/dist/chunk-FYCH2EYQ.js +0 -2
  317. package/dist/chunk-GSHTVE56.js +0 -3
  318. package/dist/chunk-JSHDCVUM.js +0 -81
  319. package/dist/chunk-L7WRUNKJ.js +0 -2
  320. package/dist/chunk-LFWB7TOJ.js +0 -2
  321. package/dist/chunk-MFBVUQJZ.js +0 -2
  322. package/dist/chunk-MR4ZKWO6.js +0 -57
  323. package/dist/chunk-NP4JFCLE.js +0 -133
  324. package/dist/chunk-NQXWWE6S.js +0 -8
  325. package/dist/chunk-O2VY47Y5.js +0 -325
  326. package/dist/chunk-SIGVQT43.js +0 -2
  327. package/dist/chunk-UAQQR55F.js +0 -2
  328. package/dist/chunk-VRJG7N3I.js +0 -453
  329. package/dist/chunk-WCIKJ2E3.js +0 -3
  330. package/dist/chunk-WEXQYJY3.js +0 -5
  331. package/dist/chunk-WOPZX5GM.js +0 -2
  332. package/dist/chunk-XDQX6LDT.js +0 -4
  333. package/dist/chunk-XIPGCT3D.js +0 -5
  334. package/dist/chunk-Z2KGMIL4.js +0 -2
  335. package/dist/code-AXLJBZ6T.js +0 -2
  336. package/dist/code-result-json-CTZHAQXJ.js +0 -2
  337. package/dist/dataflow-AFXY423Q.js +0 -2
  338. package/dist/dependence-slice-2G4X6VSJ.js +0 -2
  339. package/dist/deps-LMCAV5DO.js +0 -2
  340. package/dist/direct-navigation-2ONV22Y2.js +0 -3
  341. package/dist/entry-map-ZOC3VXO5.js +0 -2
  342. package/dist/files-WJQJLHMH.js +0 -2
  343. package/dist/hierarchy-ASNIHAX4.js +0 -2
  344. package/dist/imports-JICEKDKK.js +0 -2
  345. package/dist/members-C5H2K3MS.js +0 -2
  346. package/dist/methods-KZOZHSD4.js +0 -2
  347. package/dist/output-continuation-command-NX3RH3TP.js +0 -3
  348. package/dist/project-reindex-A2SXUH2H.js +0 -3
  349. package/dist/refs-ZOORVRQC.js +0 -2
  350. package/dist/slice-NOTBWA7S.js +0 -2
  351. package/dist/surface-BTBCLKNA.js +0 -2
  352. package/dist/system-2EIUFP6B.js +0 -2
  353. package/dist/trace-BB2GHQPG.js +0 -2
  354. package/dist/value-flow-OA7AHSUG.js +0 -2
@@ -1,453 +0,0 @@
1
- #!/usr/bin/env node
2
- var Zl=Symbol.for("scip-query.project-file-listing-context.v1"),eu=globalThis,Ls=eu[Zl],G=Ls&&typeof Ls=="object"?Ls:{};eu[Zl]=G;function Z_(e){if(G.active)return e();let t=G.active,n=G.canonicalProjectRoots;G.active=new Map,G.canonicalProjectRoots=new Map;try{return e()}finally{G.active=t,G.canonicalProjectRoots=n}}function eL(){let e=G.active,t=G.canonicalProjectRoots;G.active=new Map,G.canonicalProjectRoots=new Map;let n=!1;return()=>{n||(n=!0,G.active=e,G.canonicalProjectRoots=t)}}function tu(e,t){let n=G.active?G.canonicalProjectRoots:void 0,r=n?.get(e);if(r!==void 0)return r;let i=t();return n?.set(e,i),i}function nu(){return G.sequence??0}function _i(e,t,n){let r=G.active,i=r?.get(e);if(i&&i.pathBytes<=t)return i;let o=Jy(n(),(G.sequence??0)+1);if(G.sequence=o.sequence,o.pathBytes>t)throw new RangeError(`Git project file listing exceeded ${t} path bytes.`);return r?.set(e,o),o}function ru(e,t){let n=G.active?.get(e);return n&&n.sequence>t?n.indexAllowsTreeFingerprintReuse:void 0}function*Li(e){let t=0;for(;t<e.taggedOutput.length;){let n=e.taggedOutput.indexOf("\0",t);if(n<0)return;yield e.taggedOutput.slice(t+2,n),t=n+1}}function Jy(e,t){let n=0,r=0,i=!0;for(;n<e.length;){let o=e.indexOf("\0",n);if(o<0||o<=n+2||e[n+1]!==" ")throw new Error("Git returned a malformed tagged project file listing.");let s=e[n];i&&=s==="H"||s==="?",r+=1,n=o+1}return{taggedOutput:e,pathBytes:Buffer.byteLength(e,"utf8")-r*2,indexAllowsTreeFingerprintReuse:i,sequence:t}}import{createRequire as Xy}from"module";var Yy=Xy(import.meta.url),Di=Qy().version;function Qy(){for(let e of["../package.json","../../package.json"])try{return Yy(e)}catch{}return{version:"0.0.0"}}import{createHash as ph}from"crypto";import{existsSync as fh,mkdirSync as mh}from"fs";import{dirname as Su,join as gh}from"path";import js from"better-sqlite3";function At(e,t,n=[]){let r=As(e);if(lu.has(r)||n.some(o=>Oi(r,o))||t.some(o=>uu(r,o)))return"config";if(t.some(pu)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return"ambient";let i=du(r);return t.some(o=>(fu[o]??[]).includes(i))?"source":"other"}function cu(e,t,n){let r=As(e);if(lu.has(r)||n?.some(o=>Oi(r,o))||uu(r,t)||pu(t)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return!0;let i=du(r);return(fu[t]??[]).includes(i)}function vr(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.version!="number"||!iu(t.languages)||typeof t.pnpmWorkspaces!="boolean"||typeof t.typescriptProjectMode!="string"||!iu(t.typescriptProjects)||t.clojureConfigPath!==void 0&&typeof t.clojureConfigPath!="string"||!Array.isArray(t.files)||!t.files.every(Ds)?null:t}function Ai(e){return{...e,files:e.files.map(({semanticHash:t,...n})=>n)}}function Ir(e,t){return!e||!t?e===t:JSON.stringify(Ai(e))===JSON.stringify(Ai(t))}function iL(e,t){let n=new Map((e?.files??[]).map(a=>[a.path,a])),r=new Map(t.files.map(a=>[a.path,a])),i=new Set([...n.keys(),...r.keys()]),o=[];for(let a of[...i].sort()){let c=n.get(a),l=r.get(a),u=At(a,t.languages);!c&&l?o.push({kind:"added",path:a,inputKind:u,after:l}):c&&!l?o.push({kind:"deleted",path:a,inputKind:u,before:c}):c&&l&&(c.hash!==l.hash||c.size!==l.size)&&o.push({kind:"modified",path:a,inputKind:u,before:c,after:l})}let s=new Set;return e||s.add("prior-snapshot-unavailable"),e&&e.version!==t.version&&s.add("snapshot-version-changed"),(ou(e?.files??[])||ou(t.files))&&s.add("duplicate-input-path"),[...e?.files??[],...t.files].some(Zy)&&s.add("unreadable-input"),{version:1,changes:o,projectIdentityChanged:e?!eh(e,t):!0,uncertainty:[...s].sort()}}function iu(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function ou(e){return new Set(e.map(t=>t.path)).size!==e.length}function Ds(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.path=="string"&&typeof t.size=="number"&&Number.isFinite(t.size)&&typeof t.hash=="string"&&(t.semanticHash===void 0||typeof t.semanticHash=="string")}function Zy(e){return e.hash==="unreadable"||e.size<0}function eh(e,t){return su(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&su(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function su(e,t){if(e.length!==t.length)return!1;let n=[...e].sort(),r=[...t].sort();return n.every((i,o)=>i===r[o])}var lu=new Set([".scipquery.json"]),th={typescript:["tsconfig.json"],javascript:["package.json"],java:["pom.xml","build.gradle"],scala:["build.sbt"],kotlin:["build.gradle.kts"],rust:["Cargo.toml"],python:["pyproject.toml","setup.py"],ruby:["Gemfile"],go:["go.mod"],cpp:["CMakeLists.txt","Makefile"],c:["CMakeLists.txt","Makefile"],csharp:["*.csproj","*.sln"],vb:["*.vbproj","*.sln"],dart:["pubspec.yaml"],php:["composer.json"],clojure:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"]},nh={typescript:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],javascript:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.json","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],java:["build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],scala:["plugins.sbt","build.properties"],kotlin:["pom.xml","build.gradle","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],rust:["Cargo.lock","rust-project.json","rust-toolchain","rust-toolchain.toml"],python:["setup.cfg","requirements*.txt","Pipfile","Pipfile.lock","poetry.lock","uv.lock"],ruby:["Gemfile.lock","gems.locked"],go:["go.sum","go.work","go.work.sum"],cpp:["compile_commands.json"],c:["compile_commands.json"],csharp:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],vb:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],dart:["pubspec.lock","analysis_options.yaml"],php:["composer.lock"],clojure:[]},au=new Map;function uu(e,t){return th[t].some(n=>Oi(e,n))||nh[t].some(n=>Oi(e,n))}function Oi(e,t){let n=As(t).replace(/^\.\//,"");if(!n)return!1;let r=e.split("/").at(-1)??e,i=n.includes("/")?e:r;if(!n.includes("*")&&!n.includes("?"))return i===n;let o=au.get(n);if(!o){let s=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]");o=new RegExp(`^${s}$`),au.set(n,o)}return o.test(i)}function As(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function du(e){return e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:""}function pu(e){return e==="typescript"||e==="javascript"}var fu={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs",".vue"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};function mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mi(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function sL(e){return mt(e)&&Object.values(e).every(t=>typeof t=="string"||t===null)}function R(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function aL(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var rh=/^[a-f0-9]{64}$/u;function cL(e){return typeof e=="string"&&rh.test(e)}function lL(e){return typeof e=="string"&&e.length>0&&e.length<=256&&!/[\0\r\n]/u.test(e)}function mu(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}var ji=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],dL=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var Os=2,tn=3;var Ms=new Set(ji);function Ot(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${uh(s)}`}}if(!mt(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let n=t.version;if(!Number.isInteger(n))return{kind:"malformed",reason:"version must be an integer"};if(n!==Os&&n!==tn)return{kind:"unsupported",version:n,direction:n<Os?"older":"future"};let r=oh(t,n);if(r)return{kind:"malformed",reason:r};let i=t,o={metadata:i,capabilities:ih(i)};return n===Os?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function hL(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function gu(e){if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.stableGenerationIdentity)return null;let t=e.metadata;return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion,sqliteLayoutVersion:t.version===tn?t.sqliteLayoutVersion:void 0})}function ih(e){let t=e.fingerprint!==void 0,n=mt(e.fingerprint),r=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===tn?e:null;return{usableForQuery:r,usableForEvidenceCache:t,publishableGeneration:i&&n&&r,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function oh(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!Mi(e.updatedAt))return"updatedAt must be a valid timestamp";for(let n of["requestedLanguages","indexedLanguages"])if(e[n]!==void 0&&!sh(e[n]))return`${n} must contain unique supported languages`;return e.skipped!==void 0&&!ah(e.skipped)?"skipped must contain supported language/reason pairs":e.scipCompanion!==void 0&&e.scipCompanion!=="current"&&e.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":t===tn&&e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":t===tn&&e.languageFingerprints!==void 0&&!ch(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===tn&&e.typescriptProjectShards!==void 0&&!lh(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function SL(e){return e.version===tn&&e.sqliteLayoutVersion===1}function sh(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Ms.has(t))?!1:new Set(e).size===e.length}function ah(e){return Array.isArray(e)&&e.every(t=>mt(t)&&typeof t.language=="string"&&Ms.has(t.language)&&typeof t.reason=="string")}function ch(e){return mt(e)&&Object.entries(e).every(([t,n])=>Ms.has(t)&&mt(n))}function lh(e){return mt(e)&&Object.values(e).every(t=>mt(t)&&Array.isArray(t.files)&&t.files.every(Ds))}function uh(e){return e instanceof Error?e.message:String(e)}var yu=[];function Mn(e){e.groups.length>0&&yu.push(e)}function xL(e,t){let n=new Set(t.groups);for(let r of yu)r.groups.some(i=>n.has(i))&&(t.file!==void 0&&r.clearFile?r.clearFile(e,t.file):r.clearAll(e))}function hu(){let e=new WeakMap;return{cache:e,ensure(t){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}}}function w(e,t){let{cache:n,ensure:r}=hu(),i={get(o,s,a){let c=r(o);if(c.has(s))return c.get(s);let l=a();return c.set(s,l),l},has(o,s){return n.get(o)?.has(s)??!1},invalidate(o,s){n.get(o)?.delete(s)},invalidateAll(o){n.delete(o)},size(o){return n.get(o)?.size??0}};return Mn({name:e,groups:t.clearGroups,clearAll:o=>i.invalidateAll(o),clearFile:(o,s)=>i.invalidate(o,s)}),i}function Ze(e,t){let n=new WeakMap,r={get(i,o){let s=n.get(i);if(s)return s.value;let a=o();return n.set(i,{value:a}),a},invalidate(i){n.delete(i)},has(i){return n.has(i)}};return Mn({name:e,groups:t.clearGroups,clearAll:i=>r.invalidate(i)}),r}var dh={clearGroups:["whole-project","source-file"]};function Mt(e){return nn(e,dh)}function nn(e,t){let{cache:n,ensure:r}=hu(),i={get(o,s,a,c){let l=r(o),u=l.get(s);if(u&&u.source===a)return u.value;let d=c();return l.set(s,{source:a,value:d}),d},invalidate(o,s){n.get(o)?.delete(s)},invalidateAll(o){n.delete(o)}};return Mn({name:e,groups:t.clearGroups,clearAll:o=>i.invalidateAll(o),clearFile:(o,s)=>i.invalidate(o,s)}),i}var yh="evidence.db";var hh=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],Bs=new Set(hh),Sh=25e4,bh=512*1024*1024,xh=6e4,Bi=new WeakMap,vh=w("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),Ih=w("evidence-project-fingerprint",{clearGroups:["whole-project"]}),Se="evidence-v1",jn="version NOT LIKE 'evidence-%'";function H(e){return ph("sha256").update(e).digest("hex")}function De(e,t,n){return vh.get(e,t,()=>H(n))}function gt(e){return Ih.get(e,"current",()=>{try{if(!e.generation.metadataRaw)return null;let t=Ot(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=t.metadata,r=[...n.indexedLanguages??[]].sort();return H(JSON.stringify({fingerprint:n.fingerprint,indexedLanguages:r,status:n.status}))}catch(t){return rn("project fingerprint unavailable",t),null}})}function rn(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function et(e){if(Bi.has(e))return Bi.get(e)??null;let t=null;try{let n=new js(e.config.evidenceDbPath??gh(Su(e.config.dbPath),yh));n.pragma("journal_mode = WAL"),n.pragma("busy_timeout = 5000"),n.pragma("synchronous = NORMAL"),n.exec(`
3
- CREATE TABLE IF NOT EXISTS file_evidence (
4
- kind TEXT NOT NULL,
5
- relative_path TEXT NOT NULL,
6
- content_hash TEXT NOT NULL,
7
- version TEXT NOT NULL,
8
- payload TEXT NOT NULL,
9
- PRIMARY KEY (kind, relative_path)
10
- );
11
- CREATE TABLE IF NOT EXISTS project_evidence (
12
- kind TEXT NOT NULL,
13
- cache_key TEXT NOT NULL,
14
- project_fingerprint TEXT NOT NULL,
15
- version TEXT NOT NULL,
16
- payload TEXT NOT NULL,
17
- PRIMARY KEY (kind, cache_key)
18
- );
19
- CREATE TABLE IF NOT EXISTS semantic_callees (
20
- relative_path TEXT NOT NULL,
21
- symbol TEXT NOT NULL,
22
- content_hash TEXT NOT NULL,
23
- deps_digest TEXT NOT NULL,
24
- version TEXT NOT NULL,
25
- payload TEXT NOT NULL,
26
- PRIMARY KEY (relative_path, symbol)
27
- );
28
- CREATE TABLE IF NOT EXISTS semantic_references (
29
- relative_path TEXT NOT NULL,
30
- symbol TEXT NOT NULL,
31
- project_fingerprint TEXT NOT NULL,
32
- version TEXT NOT NULL,
33
- payload TEXT NOT NULL,
34
- PRIMARY KEY (relative_path, symbol)
35
- );
36
- `),t={evidence:n,shared:Eh(e.config.sharedEvidenceDbPath),readFileEvidence:n.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:n.prepare(`SELECT payload FROM file_evidence
37
- WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${jn}
38
- ORDER BY version DESC
39
- LIMIT 1`),writeFileEvidence:n.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),rekeyFileEvidence:n.prepare("UPDATE file_evidence SET content_hash = ?, version = ? WHERE kind = ? AND relative_path = ? AND content_hash = ?"),readProjectEvidence:n.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:n.prepare(`SELECT payload FROM project_evidence
40
- WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${jn}
41
- ORDER BY version DESC
42
- LIMIT 1`),writeProjectEvidence:n.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),rekeyProjectEvidenceKind:n.prepare("UPDATE project_evidence SET project_fingerprint = ?, version = ? WHERE kind = ? AND project_fingerprint = ?"),readCallees:n.prepare(`SELECT payload FROM semantic_callees
43
- WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:n.prepare(`SELECT payload FROM semantic_callees
44
- WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${jn}
45
- ORDER BY version DESC
46
- LIMIT 1`),readCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
47
- WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
48
- WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${jn}
49
- ORDER BY symbol, version DESC`),writeCallees:n.prepare(`INSERT OR REPLACE INTO semantic_callees
50
- (relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:n.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:n.prepare(`SELECT payload FROM semantic_references
51
- WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:n.prepare(`SELECT payload FROM semantic_references
52
- WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${jn}
53
- ORDER BY version DESC
54
- LIMIT 1`),readReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
55
- WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
56
- WHERE relative_path = ? AND project_fingerprint = ? AND ${jn}
57
- ORDER BY symbol, version DESC`),writeReferences:n.prepare(`INSERT OR REPLACE INTO semantic_references
58
- (relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:n.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?")}}catch(n){rn("disabled (open failed)",n)}return Bi.set(e,t),t}function tt(e,t,n){rn(`disabled (${t})`,n),Bi.set(e,null)}function Eh(e){if(!e)return null;try{mh(Su(e),{recursive:!0});let t=new js(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
59
- CREATE TABLE IF NOT EXISTS file_evidence (
60
- kind TEXT NOT NULL,
61
- relative_path TEXT NOT NULL,
62
- content_hash TEXT NOT NULL,
63
- version TEXT NOT NULL,
64
- payload TEXT NOT NULL,
65
- last_accessed_at INTEGER NOT NULL,
66
- PRIMARY KEY (kind, relative_path, content_hash, version)
67
- );
68
- CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
69
- ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version);
70
- `),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
71
- VALUES (?, ?, ?, ?, ?, ?)
72
- ON CONFLICT(kind, relative_path, content_hash, version)
73
- DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`),touchFileEvidence:t.prepare(`UPDATE file_evidence
74
- SET last_accessed_at = ?
75
- WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?
76
- AND last_accessed_at < ?`)}}catch(t){return rn("shared cache disabled (open failed)",t),null}}function $s(e,t,n){rn(`shared cache disabled (${t})`,n);try{e.shared?.evidence.close()}catch{}e.shared=null}function kL(e,t={}){if(!fh(e))return null;let n;try{n=new js(e),n.pragma("busy_timeout = 50"),n.exec(`CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
77
- ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version)`),n.pragma("wal_checkpoint(TRUNCATE)");let r=n.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??Sh,o=t.budgetBytes??bh,s=Number(n.pragma("page_size",{simple:!0})),a=Number(n.pragma("page_count",{simple:!0})),c=Number(n.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,u=r>0&&l>o?Math.min(r,Math.ceil((l-o)/Math.max(1,l/r))):0,d=Math.max(r-i,u);return d>0&&(n.prepare(`DELETE FROM file_evidence WHERE rowid IN (
78
- SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
79
- )`).run(d),n.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:d,remainingRows:r-d}}catch(r){return rn("shared cache maintenance skipped",r),null}finally{try{n?.close()}catch{}}}function bu(e,t,n,r){let i=et(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,n,r,Se)??i.readLegacyFileEvidence.get(t,n,r);if(o?.payload!==void 0)return o.payload;if(!Bs.has(t)||!i.shared)return null;try{let s=i.shared.readFileEvidence.get(t,n,r,Se);return s?.payload!==void 0&&Ph(i.shared,t,n,r),s?.payload??null}catch(s){return $s(i,"file_evidence read",s),null}}catch(o){return tt(e,"file_evidence read",o),null}}function Ph(e,t,n,r){let i=Date.now();try{e.touchFileEvidence.run(i,t,n,r,Se,i-xh)}catch(o){rn("shared file_evidence recency touch skipped",o)}}function xu(e,t,n,r,i){let o=et(e);if(o)try{if(o.writeFileEvidence.run(t,n,r,Se,i),Bs.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,n,r,Se,i,Date.now())}catch(s){$s(o,"file_evidence write",s)}}catch(s){tt(e,"file_evidence write",s)}}function vu(e,t){if(t.length===0)return;let n=et(e);if(n)try{n.evidence.transaction(()=>{for(let i of t)n.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,Se,i.payload)})();let r=t.filter(i=>Bs.has(i.kind));if(r.length>0&&n.shared)try{n.shared.evidence.transaction(()=>{for(let i of r)n.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,Se,i.payload,Date.now())})()}catch(i){$s(n,"file_evidence batch write",i)}}catch(r){tt(e,"file_evidence batch write",r)}}function Iu(e,t,n,r){let i=et(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,n,r,Se)??i.readLegacyProjectEvidence.get(t,n,r))?.payload??null}catch(o){return tt(e,"project_evidence read",o),null}}function Eu(e,t,n,r,i){let o=et(e);if(o)try{o.writeProjectEvidence.run(t,n,r,Se,i)}catch(s){tt(e,"project_evidence write",s)}}function NL(e,t,n,r){if(n===r)return 0;let i=et(e);if(!i)return 0;try{return i.rekeyProjectEvidenceKind.run(r,Se,t,n).changes}catch(o){return tt(e,"project_evidence kind rekey",o),0}}function _L(e,t,n,r){let i=et(e);if(!i)return new Map;try{let o=i.readCalleesForFile.all(t,n,r,Se),s=i.readLegacyCalleesForFile.all(t,n,r);return Pu([...s,...o])}catch(o){return tt(e,"semantic_callees bulk read",o),new Map}}function LL(e,t,n){let r=et(e);if(!r)return new Map;try{let i=r.readReferencesForFile.all(t,n,Se),o=r.readLegacyReferencesForFile.all(t,n);return Pu([...o,...i])}catch(i){return tt(e,"semantic_references bulk read",i),new Map}}function Pu(e){let t=new Map;for(let n of e)t.set(n.symbol,n.payload);return t}function DL(e,t){if(t.length===0)return;let n=et(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.contentHash}`;r.has(o)||(r.add(o),n.dropStaleCallees.run(i.relativePath,i.contentHash)),n.writeCallees.run(i.relativePath,i.symbol,i.contentHash,i.depsDigest,Se,i.payload)}})()}catch(r){tt(e,"semantic_callees write",r)}}function AL(e,t){if(t.length===0)return;let n=et(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.projectFingerprint}`;r.has(o)||(r.add(o),n.dropStaleReferences.run(i.relativePath,i.projectFingerprint)),n.writeReferences.run(i.relativePath,i.symbol,i.projectFingerprint,Se,i.payload)}})()}catch(r){tt(e,"semantic_references write",r)}}import{appendFileSync as Rh,mkdirSync as Ch}from"fs";import{createHash as wh,randomUUID as Fh}from"crypto";import{dirname as Th}from"path";import{performance as Bn}from"perf_hooks";var Fu="SCIP_QUERY_PROFILE",Tu="SCIP_QUERY_PROFILE_OUT",ku="SCIP_QUERY_PROFILE_COMMAND",Nu="SCIP_QUERY_PROFILE_CACHE_STATE",Gs="SCIP_QUERY_PROFILE_RUN_ID",Vs="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY",qs="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND",_u=[Fu,Tu,ku,Nu,Gs,Vs,qs],GL=new Set(_u),Ru=new Set,Cu=new Map,wu=!1;function jt(){let e=process.env[Fu];return e==="1"||e==="true"}function kh(){return process.env[Tu]}function Lu(){return process.env[ku]}function Nh(){return process.env[Nu]}function Du(){let e=process.env[Gs];if(e)return e;if(!jt())return;let t=Fh();return process.env[Gs]=t,t}function Au(){return process.env[Vs]}function _h(e){let t=Au();if(t)return t;if(!jt())return;let n=Du();if(!n)return;let r=e.projectFingerprint?"published-project":"run-only",i=Er(["profile-workload-v1",e.toolVersion,e.command,e.projectFingerprint??n]);return process.env[Vs]=i,process.env[qs]=r,i}function Er(e){return wh("sha256").update(JSON.stringify(e)).digest("hex").slice(0,24)}function VL(){return Object.fromEntries(_u.flatMap(e=>{let t=process.env[e];return t===void 0?[]:[[e,t]]}))}function z(e,t,n){if(!jt())return t();let r=Bn.now();try{let i=t();return $i({type:"span",name:e,durationMs:Math.round(Bn.now()-r),ok:!0,...Gi(n)??{}}),i}catch(i){throw $i({type:"span",name:e,durationMs:Math.round(Bn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...Gi(n)??{}}),i}}async function qL(e,t,n){if(!jt())return t();let r=Bn.now();try{let i=await t();return $i({type:"span",name:e,durationMs:Math.round(Bn.now()-r),ok:!0,...Gi(n)??{}}),i}catch(i){throw $i({type:"span",name:e,durationMs:Math.round(Bn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...Gi(n)??{}}),i}}function $i(e,t=kh()){let n=Lh(e),r={timestamp:new Date().toISOString(),pid:process.pid,runId:Du(),command:Lu(),cacheState:Nh(),...n,...e},i=`${JSON.stringify(r)}
80
- `;if(t)try{let o=Th(t);Ru.has(o)||(Ch(o,{recursive:!0}),Ru.add(o)),Rh(t,i);return}catch(o){wu||(wu=!0,process.stderr.write(`[profile] failed to write ${t}: ${o instanceof Error?o.message:String(o)}
81
- `));return}jt()&&process.stderr.write(i)}function Lh(e){let t=Au()??_h({command:Lu()??"unknown",toolVersion:"unknown",projectFingerprint:null});if(!t)return{};let n=process.env[qs],r=typeof e.name=="string"?e.name:void 0;if(!r)return{workloadIdentity:t,workloadIdentityKind:n};let i=r.split(/[.:]/,1)[0]??r,o=`${t}\0${r}`,s=Cu.get(o);return s||(s=Er(["profile-subsystem-v1",t,r]),Cu.set(o,s)),{workloadIdentity:t,workloadIdentityKind:n,subsystem:i,subsystemWorkIdentity:s}}function Gi(e){return typeof e=="function"?e():e}import{isAbsolute as Ou,relative as Dh}from"path";var V=class extends Error{constructor(n,r){super(`refusing unsafe project file path ${JSON.stringify(n)} (${r})`);this.relativePath=n;this.reason=r;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function Bt(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function Z(e){return e.replace(/\\/g,"/")}function on(e,t){return Bt(e)===Bt(t)}function Ae(e,t){let n=Dh(e,t);return n===""||!n.startsWith("..")&&!Ou(n)}function Re(e){if(!e)throw new V(e,"empty-path");if(e.includes("\0"))throw new V(e,"nul-byte");if(Ou(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new V(e,"absolute-path");let t=Bt(e);if(t.split("/").some(r=>r===".."))throw new V(e,"parent-traversal");if(!t||t===".")throw new V(e,"empty-path");return t}import{closeSync as Ws,fstatSync as Vi,openSync as Hs,readFileSync as Ah,readSync as Mu}from"fs";import{createHash as Oh}from"crypto";var te=8*1024*1024,sn=64*1024*1024,be=512*1024*1024,Mh=256*1024*1024,nt=class extends Error{constructor(n,r,i,o,s){let a=i==="too-large"?`is ${o} bytes; the safety limit is ${s} bytes`:i==="not-regular"?"is not a regular file":"changed while it was being read";super(`${n} ${JSON.stringify(r)} ${a}`);this.inputKind=n;this.inputPath=r;this.reason=i;this.observedBytes=o;this.limitBytes=s;this.name="BoundedFileReadError"}inputKind;inputPath;reason;observedBytes;limitBytes;code="SCIP_QUERY_BOUNDED_FILE_READ"};function ee(e,t){cn(t.maxBytes);let n=String(e),r=Hs(e,"r");try{let i=Vi(r);Bu(i,t,n);let o=Ah(r),s=Vi(r);if(s.dev!==i.dev||s.ino!==i.ino||s.size!==i.size||o.byteLength!==i.size)throw new nt(t.inputKind,n,"changed-during-read",s.size,t.maxBytes);return o}finally{Ws(r)}}function j(e,t,n="utf8"){return ee(e,t).toString(n)}function T(e,t){return j(e,{maxBytes:te,inputKind:t})}function jh(e,t){return j(e,{maxBytes:sn,inputKind:t})}function zs(e,t){cn(t.maxBytes);let n=[],r=Buffer.allocUnsafe(64*1024),i=0;for(;;){let o=Mu(e,r,0,r.length,null);if(o===0)break;if(i+=o,!Number.isSafeInteger(i)||i>t.maxBytes)throw new nt(t.inputKind,`file descriptor ${e}`,"too-large",i,t.maxBytes);n.push(Buffer.from(r.subarray(0,o)))}return Buffer.concat(n,i)}function Bh(e,t,n="utf8"){return zs(e,t).toString(n)}function ju(e,t){let n=Hs(e,"r");try{return zs(n,t)}finally{Ws(n)}}function Us(e,t,n="utf8"){return ju(e,t).toString(n)}function $n(e,t,n){cn(t.maxBytes);let r=String(e),i=Hs(e,"r");try{let o=Vi(i);Bu(o,t,r);let s=Buffer.allocUnsafe(Math.min(1024*1024,Math.max(1,o.size))),a=0;for(;a<o.size;){let l=Mu(i,s,0,Math.min(s.length,o.size-a),a);if(l===0)break;n(s.subarray(0,l)),a+=l}let c=Vi(i);if(c.dev!==o.dev||c.ino!==o.ino||c.size!==o.size||a!==o.size)throw new nt(t.inputKind,r,"changed-during-read",c.size,t.maxBytes);return a}finally{Ws(i)}}function an(e,t){let n=Oh("sha256");return $n(e,t,r=>n.update(r)),n.digest("hex")}function Bu(e,t,n){if(!e.isFile())throw new nt(t.inputKind,n,"not-regular",Number(e.size),t.maxBytes);if(e.size>t.maxBytes)throw new nt(t.inputKind,n,"too-large",Number(e.size),t.maxBytes)}function cn(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}import{spawnSync as $h}from"child_process";import{createHash as Gh}from"crypto";import{existsSync as Vh,lstatSync as Wi,realpathSync as qh}from"fs";import{dirname as Wh,isAbsolute as Gu,join as Xs,relative as Hh,resolve as ln,sep as zh}from"path";var Ue={run(e,t){let n=$u(e,t);return n.kind==="success"?n.output:void 0},runResult:$u},Uh=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],Ys=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],Gn=/^[0-9a-f]{40,64}$/;function nD(e,t,n=Ue){if(!t||t.startsWith("-")||/[\0\r\n]/.test(t))throw new Error(`Invalid Git revision ${JSON.stringify(t)}.`);let r=n.runResult(e,["rev-parse","--verify","--end-of-options",`${t}^{commit}`]);if(r.kind!=="success"||!Gn.test(r.output))throw new Error(`Git revision ${JSON.stringify(t)} does not resolve to exactly one commit.`);return r.output}function Rr(e,t=Ue){return Kh(e,t)?.context}function Kh(e,t=Ue){let n=t.runResult(e,Uh);if(n.kind==="success"){let i=Xh(n.output);if(i){let o=Yh(i,t);if(o)return Ks(o)}}let r=Qh(e,t);return r?Ks(r):void 0}function Jh(e,t=Ue){if(!e.headCommit)return;let n=t.run(e.projectRoot,Ys);if(n===void 0)return;let r=Qs(n);if(!(!r?.headCommit||r.headCommit!==e.headCommit))return{...e,clean:r.clean}}function rD(e,t,n=Ue){if(!t.headCommit||!t.treeOid||!Gn.test(t.headCommit)||!Gn.test(t.treeOid)||n===Ue&&!iS()||!eS(e,t))return;let r=Jh({projectRoot:t.projectRoot,gitDir:t.gitDir,commonDir:t.commonDir,repositoryId:t.repositoryId,worktreeId:t.worktreeId,headCommit:t.headCommit,treeOid:t.treeOid,clean:!0},n);return r?Ks(r):void 0}function iD(e,t=Ue,n={}){let r=t===Ue&&n.cachedInventoryAfterSequence!==void 0?ru(e,n.cachedInventoryAfterSequence):void 0;if(r!==void 0)return r;let i=t.run(e,["ls-files","-v","-z"]);return i===void 0?!1:i.split("\0").filter(Boolean).every(o=>o.startsWith("H "))}function Ks(e){return{context:e,projectFileInventorySequence:nu()}}function Qs(e){let t=e.split("\0").filter(Boolean),n=t.find(i=>i.startsWith("# branch.oid "))?.slice(13),r=n==="(initial)"?void 0:n;if(!(r!==void 0&&!Gn.test(r))&&n!==void 0)return{headCommit:r,clean:t.every(i=>i.startsWith("# "))}}function Xh(e){let t=e.split(`
82
- `).map(c=>c.trim());if(t.length!==5)return;let[n,r,i,o,s]=t;if(!n||!r||!i||!o||!s||!Gn.test(o)||!Gn.test(s))return;let a=xe(n);return{root:a,gitDir:xe(qi(a,r)),commonDir:xe(qi(a,i)),headCommit:o,treeOid:s}}function Yh(e,t){let n=t.run(e.root,Ys);if(n===void 0)return;let r=Qs(n);return r?.headCommit!==e.headCommit?void 0:{...Vu(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:Pr("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.clean}}function Qh(e,t){let n=Zh(e,t);if(n.kind!=="worktree")return;let r=n.identity,i=r.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=xe(qi(i,o)),a=Js(t.run(i,["rev-parse","--verify","HEAD"])),c=Js(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,Ys);if(l===void 0)return;let u=Qs(l);if(!(!u||u.headCommit!==a))return{...r,commonDir:s,repositoryId:Pr("repository",s),headCommit:a,treeOid:c,clean:u.clean}}function Zh(e,t=Ue){let n=t.runResult(e,["rev-parse","--show-toplevel"]);if(n.kind==="not-repository")return{kind:"non-git"};if(n.kind==="error")return n;let r=n.output.trim();if(!r)return{kind:"error",message:"Git returned an empty worktree root."};let i=xe(r),o=t.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=xe(qi(i,o));return{kind:"worktree",identity:Vu(i,s)}}function Vu(e,t){return{projectRoot:e,gitDir:t,worktreeId:Pr("worktree",`${e}\0${t}`)}}function eS(e,t){try{let n=xe(t.projectRoot),r=ln(e)===n?n:xe(e);if(t.projectRoot!==n||!rS(n,r))return!1;let i=Xs(n,".git"),o=Wi(i);if(o.isSymbolicLink())return!1;let s=o.isDirectory()?xe(i):o.isFile()?tS(i,n,o):void 0;if(!s||s!==t.gitDir)return!1;let a=nS(s);return!a||a!==t.commonDir?!1:t.worktreeId===Pr("worktree",`${n}\0${s}`)&&t.repositoryId===Pr("repository",a)}catch{return!1}}function tS(e,t,n){let r=qu(e,"gitdir: ",n);return r?xe(ln(t,r)):void 0}function nS(e){let t=Xs(e,"commondir");try{let n=Wi(t);if(n.isSymbolicLink()||!n.isFile())return;let r=qu(t,"",n);return r?xe(ln(e,r)):void 0}catch(n){let r=n.code;return r==="ENOENT"||r==="ENOTDIR"?e:void 0}}function qu(e,t="",n=Wi(e)){if(!n.isFile()||n.isSymbolicLink()||n.size>4*1024)return;let r=j(e,{inputKind:"Git control path",maxBytes:4*1024}).split(/\r?\n/).filter(o=>o.length>0);if(r.length!==1||!r[0].startsWith(t))return;let i=r[0].slice(t.length);return i&&!i.includes("\0")?i:void 0}function rS(e,t){let n=Hh(e,t);return n===""||!n.startsWith(`..${zh}`)&&n!==".."&&!Gu(n)}function iS(e=process.env){return!(["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_REPLACE_REF_BASE","GIT_NO_REPLACE_OBJECTS","GIT_SHALLOW_FILE","GIT_GRAFT_FILE"].some(n=>e[n]!==void 0)||Object.keys(e).some(n=>n.startsWith("GIT_CONFIG_")))}function Wu(e,t=Ue){let n=t.run(e,["worktree","list","--porcelain","-z"]);return n===void 0?[]:oS(n)}function oS(e){let t=[],n;for(let r of e.split("\0")){if(r===""){n&&t.push(n),n=void 0;continue}let i=r.indexOf(" "),o=i<0?r:r.slice(0,i),s=i<0?"":r.slice(i+1);if(o==="worktree"){n&&t.push(n),n={path:xe(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}n&&(o==="HEAD"?n.head=s:o==="branch"?n.branch=s:o==="detached"?n.detached=!0:o==="bare"?n.bare=!0:o==="prunable"?n.prunable=!0:o==="locked"&&(n.locked=!0))}return n&&t.push(n),t}function oD(e,t,n=Ue){return Js(n.run(e,t))}function qi(e,t){return Gu(t)?t:ln(e,t)}function xe(e){try{return qh(e)}catch{return ln(e)}}function Pr(e,t){return Gh("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function Js(e){return e?.trim()||void 0}function $u(e,t){let n=$h("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(n.status===0)return{kind:"success",output:n.stdout.trimEnd()};let i=(typeof n.stderr=="string"?n.stderr.trim():"")||n.error?.message||`git exited with status ${n.status??"unknown"}`,o=n.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&Vh(ln(e)))&&!sS(e)?{kind:"not-repository"}:{kind:"error",message:i}}function sS(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=ln(e);for(;;){try{return Wi(Xs(t,".git")),!0}catch(r){let i=r.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let n=Wh(t);if(n===t)return!1;t=n}}import{createRequire as lS}from"module";import{existsSync as uS,lstatSync as zu,readdirSync as dS,statSync as pS}from"fs";import k from"path";import{AsyncLocalStorage as aS}from"async_hooks";var cS=new aS;function un(e,t){let n=Hi(e);if(!n||n.missing.has(t))return;let r=n.files.get(t);if(r)return r;let i=n.readBaseFile?.(t);return i&&n.files.set(t,i),i}function dn(e,t){let n=Hi(e);if(n)return n.missing.has(t)?"missing":n.paths.includes(t)?"present":"missing"}function Hu(e,t){return Hi(e)?.fingerprints.get(t)}function pn(e){return Hi(e)?.paths}function Hi(e){let t=cS.getStore();if(t)return t.projectRoot===xe(e)?t:void 0}var fS=lS(import.meta.url),Uu=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]),mS=18003;function zi(e,t=[]){let n=k.resolve(e),r=t.flatMap(c=>yS(n,c));if(r.length>0)return Ku(n,Xu(r));let i=gS(n),o=Xu(i),s=hS(n,o)?[n,...o]:o,a=s.length>0?s:[n];return Ku(n,a)}function Yu(e){return new Set(e.map(t=>t==="."?"tsconfig.json":`${t.replace(/\/$/u,"")}/tsconfig.json`))}function Qu(e){let t=e.split("/").at(-1)?.toLowerCase();return t?.startsWith("tsconfig")===!0&&t.endsWith(".json")}function Zu(e,t,n=[]){let r;try{r=fS("@ts-morph/common/dist/typescript.js")}catch{return null}let i=k.resolve(e),o=t==="workspace"?zi(i,n):["."],s=new Set;for(let a of o){let c=a==="."?i:k.join(i,a),l=k.join(c,"tsconfig.json"),u=bS(r,i);if(!u.fileExists(l))return null;let d=r.readConfigFile(l,u.readFile);if(d.error)return null;let p=r.parseJsonConfigFileContent(d.config,u,c);if(p.errors.some(f=>f.code!==mS))return null;for(let f of p.fileNames){let g=k.resolve(f);Ae(i,g)&&s.add(k.relative(i,g).split(k.sep).join("/"))}}return s}function bD(e,t,n,r){let i=k.resolve(e),o=new Set(r);for(let a of n){let c=k.resolve(i,a);if(Ae(i,c))try{let l=zu(c);if(l.isSymbolicLink()||l.isFile()&&!o.has(fn(i,c)))return!1}catch{}}let s=t==="workspace"?zi(i,n):["."];for(let a of s){let c=a==="."?i:k.join(i,a),l=k.join(c,"tsconfig.json");if(!td(i,l))continue;let u=fn(i,l);if(!o.has(u))return!1;try{if(zu(l).isSymbolicLink())return!1;let d=nd(i,l);if(d.includes("extends")||d.includes("\\"))return!1}catch{return!1}}return!0}function Ku(e,t){return[...new Set(t.map(n=>fn(e,n)))].sort((n,r)=>n.localeCompare(r))}function gS(e){let t=pn(e);if(t)return t.flatMap(i=>{if(i.split("/").some(s=>Uu.has(s)))return[];let o=k.join(e,...i.split("/"));return Ju(e,o)?[k.dirname(o)]:[]});let n=[],r=[e];for(;r.length>0;){let i=r.pop(),o;try{o=dS(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=k.join(i,s.name);if(s.isDirectory()){!Uu.has(s.name)&&!s.name.startsWith(".")&&r.push(a);continue}s.isFile()&&Ju(e,a)&&n.push(k.dirname(a))}}return n}function yS(e,t){let n=t.trim();if(!n)return[];let r=k.resolve(e,n);if(!Ae(e,r))return[];let i=pn(e);if(i){let o=fn(e,r);if(i.includes(o)&&Zs(k.basename(r)))return[k.dirname(r)];let s=o==="."?"":`${o}/`;return i.some(a=>a.startsWith(s))?[r]:[]}try{let o=pS(r);if(o.isDirectory())return[r];if(o.isFile()&&Zs(k.basename(r)))return[k.dirname(r)]}catch{return[]}return[]}function Ju(e,t){if(!Zs(k.basename(t)))return!1;let n=ed(e,t);return n?k.basename(t)==="tsconfig.json"||"include"in n||"files"in n||"references"in n:!1}function Zs(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Xu(e){let t=[...new Set(e.map(n=>k.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&vS(n,r)))}function hS(e,t){if(t.length===0||t.some(r=>k.resolve(r)===e))return!1;let n=k.join(e,"tsconfig.json");return td(e,n)&&SS(e,n)}function SS(e,t){let r=ed(e,t)?.include;return Array.isArray(r)?r.some(i=>typeof i=="string"&&i.trim()!==""&&!i.startsWith("!")&&(i.includes("/")||i.includes("**")||!k.extname(i))):!1}function ed(e,t){try{let n=JSON.parse(nd(e,t));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function td(e,t){let n=fn(e,t),r=dn(e,n);return r?r==="present":uS(t)}function nd(e,t){let n=fn(e,t);if(pn(e)){let i=un(e,n);if(!i)throw Object.assign(new Error(`Snapshot file ${n} is missing.`),{code:"ENOENT"});return i.content.toString("utf8")}return T(t,"TypeScript project config")}function bS(e,t){let n=pn(t);if(!n)return e.sys;let r=k.resolve(t),i=new Set(n),o=xS(r,n),s=e,a=c=>{let l=k.resolve(c);return Ae(r,l)?fn(r,l):null};return{useCaseSensitiveFileNames:e.sys.useCaseSensitiveFileNames,fileExists(c){let l=a(c);return l===null?e.sys.fileExists(c):i.has(l)},readFile(c){let l=a(c);return l===null?e.sys.readFile(c):un(r,l)?.content.toString("utf8")},readDirectory(c,l,u,d,p){let f=k.resolve(c);return Ae(r,f)?s.matchFiles(f,l,u,d,e.sys.useCaseSensitiveFileNames,r,p,g=>o.get(k.resolve(g))??{files:[],directories:[]},g=>g):e.sys.readDirectory(c,l,u,d,p)}}}function xS(e,t){let n=new Map,r=new Map,i=o=>{n.has(o)||n.set(o,new Set),r.has(o)||r.set(o,new Set)};i(e);for(let o of t){let s=o.split("/"),a=e;for(let c=0;c<s.length-1;c+=1){let l=s[c];i(a),r.get(a).add(l),a=k.join(a,l),i(a)}n.get(a).add(s.at(-1))}return new Map([...n].map(([o,s])=>[o,{files:[...s].sort(),directories:[...r.get(o)??[]].sort()}]))}function fn(e,t){let n=k.relative(e,t);return n?n.split(k.sep).join("/"):"."}function vS(e,t){let n=k.relative(e,t);return!!n&&!n.startsWith("..")&&!k.isAbsolute(n)}import{createHash as na}from"crypto";import{execFileSync as rd}from"child_process";import{createRequire as IS}from"module";var ES=IS(import.meta.url),PS=/\.(?:[cm]?[jt]sx?)$/iu,RS=/\.[jt]sx$/iu,id=/(?:^|\/)package\.json$/iu,Cr,ea=new Map;function od(e,t){if(!ra(e))return;let n=CS();if(n)try{let r=typeof t=="string"?t:t.toString("utf8"),i=RS.test(e)?n.LanguageVariant.JSX:n.LanguageVariant.Standard,o=n.createScanner(n.ScriptTarget.Latest,!1,i,r),s=na("sha256").update(`typescript-semantic-v1\0${i}\0`),a=!1,c=!1;for(;;){let l=o.scan();if(l===n.SyntaxKind.EndOfFileToken)break;if(l===n.SyntaxKind.WhitespaceTrivia)continue;if(l===n.SyntaxKind.NewLineTrivia){a&&(c=!0);continue}c&&s.update("line-break\0");let u=o.getTokenText();s.update(`${l}\0${Buffer.byteLength(u)}\0`).update(u).update("\0"),a=!0,c=!1}return s.digest("hex")}catch{return}}function ra(e){return PS.test(e)}function ia(e,t){if(id.test(e))try{let n=JSON.parse(typeof t=="string"?t:t.toString("utf8"));if(typeof n!="object"||n===null||Array.isArray(n))return;let{scripts:r,...i}=n;return na("sha256").update("typescript-package-json-v1\0").update(ta(i)).digest("hex")}catch{return}}function oa(e){return id.test(e)}function PD(e,t,n){if(!oa(t)||!/^[a-f0-9]{64}$/u.test(n))return;let r=`${e}\0${t}\0${n}`;if(ea.has(r))return ea.get(r);let i;try{let o=rd("git",["-C",e,"log","--all","--format=%H","--max-count=64","--",t],{encoding:"utf8",maxBuffer:1048576,timeout:5e3}).split(/\r?\n/u).filter(Boolean);for(let s of o){let a=rd("git",["-C",e,"show",`${s}:${t}`],{encoding:null,maxBuffer:4194304,timeout:5e3});if(na("sha256").update(a).digest("hex")===n){i=ia(t,a);break}}}catch{i=void 0}return ea.set(r,i),i}function CS(){if(Cr!==void 0)return Cr;try{Cr=ES("typescript")}catch{Cr=null}return Cr}function ta(e){return Array.isArray(e)?`[${e.map(ta).join(",")}]`:typeof e=="object"&&e!==null?`{${Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${JSON.stringify(t)}:${ta(n)}`).join(",")}}`:JSON.stringify(e)}import{createHash as ld,randomUUID as _S}from"crypto";import{chmodSync as ud,existsSync as qn,linkSync as LS,lstatSync as wr,readdirSync as aa,realpathSync as Oe,unlinkSync as DS,writeSync as AS}from"fs";import{homedir as OS}from"os";import{basename as MS,dirname as Ki,isAbsolute as ad,join as Ce,resolve as Ji}from"path";import{closeSync as wS,existsSync as FS,fsyncSync as TS,mkdirSync as kS,openSync as NS}from"fs";import{dirname as sd}from"path";function yt(e,t,n,r){let i=0;for(;i<t.length;){let o=n.writeFile(e,t,i,t.length-i);if(!Number.isSafeInteger(o)||o<=0||o>t.length-i)throw new Error(`${r} write did not make valid forward progress`);i+=o}}function Vn(e,t){if(t!=="win32")return!1;let n=e.code;return n==="EACCES"||n==="EBADF"||n==="EINVAL"||n==="EISDIR"||n==="EPERM"}var mn=Object.freeze({platform:process.platform,pathExists:e=>FS(e),makeDirectory:e=>kS(e,{recursive:!0}),openFile:(e,t,n)=>NS(e,t,n),syncFile:e=>TS(e),closeFile:e=>wS(e)});function ue(e,t=mn){let n=[],r=e;for(;!t.pathExists(r);){n.push(r);let o=sd(r);if(o===r)throw new Error(`Cannot establish a durable directory path without an existing ancestor: ${e}`);r=o}let i="synced";for(let o of n.reverse())t.makeDirectory(o),i=q(i,L(sd(o),t));return i}function L(e,t=mn){let n;try{n=t.openFile(e,"r")}catch(r){if(Vn(r,t.platform))return"unsupported";throw r}try{t.syncFile(n)}catch(r){try{t.closeFile(n)}catch{}if(Vn(r,t.platform))return"unsupported";throw r}return t.closeFile(n),"synced"}function q(...e){return e.every(t=>t==="not-requested")?"not-requested":e.includes("unsupported")?"unsupported":"synced"}var dd=1,Tr=".scip-query-cache-owner.json",jS=16*1024,pd=Object.freeze({...mn,randomToken:()=>_S(),linkFile:(e,t)=>LS(e,t),removeFile:e=>DS(e),writeFile:(e,t,n,r)=>AS(e,t,n,r)});function Ui(e,t){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(e)} (${t}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:e,reason:t})}function Ke(e,t){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(e)} (${t}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:e,reason:t})}function BS(e,t){let n=Oe(e);return $S(n,ca(n,t))}function ca(e,t){let n=Oe(e),r=process.env.SCIP_QUERY_CACHE_DIR;return r?Ji(r):t?.dbPath?VS(n,t.dbPath):Yi(n)}function Xi(){let e=process.env.XDG_CACHE_HOME;return Ce(e||Ce(OS(),".cache"),"scip-query")}function Yi(e){let t=Ji(e);try{t=Oe(t)}catch{}let n=ld("sha256").update(t).digest("hex").slice(0,12);return Ce(Xi(),"projects",n)}function Qi(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let t=Ce(Xi(),"repositories",e);return yd(t),Oe(t)}function la(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function $D(e,t){let n=BS(e,t);return{cacheDir:n,dbPath:Ce(n,"index.db"),indexPath:Ce(n,"index.scip"),metaPath:Ce(n,"meta.json")}}function $S(e,t,n=pd){return GS(e,t,n).cacheDir}function GS(e,t,n=pd){let r=Oe(e),i=qn(t)?"synced":yd(t,n),o=Oe(t),s=Ce(o,Tr);if(qn(s))return sa(r,o),ua(s),Fr(o),{kind:"existing",cacheDir:o};cd(o),zS(o),cd(o);let c=`${JSON.stringify({schemaVersion:dd,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:Di},null,2)}
83
- `;try{let l=US(s,c,n),u=q(i,l);return{kind:"published",cacheDir:o,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}catch(l){if(JS(l))return sa(r,o),{kind:"existing",cacheDir:o};throw l}}function sa(e,t){let n=Oe(e),r=Oe(t);return fd(r,n,r)}function GD(e){let t=wr(e);if(t.isSymbolicLink()||!t.isDirectory())throw Ke(e,"cache path is not a regular directory");let n=Oe(e);return fd(n,void 0,n)}function VD(e,t){return qn(Ce(t,Tr))?(sa(e,t),md(t),!0):!1}function VS(e,t){let n;try{n=Re(t)}catch(s){throw s instanceof V?Ui(t,s.reason):s}let r=Ji(e,...n.split("/"));if(r===e||!Ae(e,r))throw Ui(t,"outside-project");let i=qS(r),o=Oe(i);if(!Ae(e,o)&&o!==e)throw Ui(t,"symlink-escape");return r}function qS(e){let t=e;for(;!qn(t);){let n=Ki(t);if(n===t)throw Ui(e,"no-existing-ancestor");t=n}return t}function fd(e,t,n){let r=Ce(e,Tr);if(!qn(r)||wr(r).isSymbolicLink())throw Ke(e,"missing regular ownership record");let i=wr(r);if(!i.isFile()||i.size>jS)throw Ke(e,"invalid ownership record file");let o=T(r,"cache ownership record"),s=WS(o,e);if(t!==void 0&&s.canonicalProjectRoot!==t)throw Ke(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw Ke(e,"ownership record names a different cache directory");return{record:s,ownerSha256:ld("sha256").update(o).digest("hex"),physicalCacheDir:e}}function WS(e,t){try{let n=JSON.parse(e);if(n.schemaVersion!==dd||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!ad(n.canonicalProjectRoot)||!ad(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw Ke(t,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function cd(e){let t=aa(e).filter(n=>n!==Tr&&!HS(n));if(t.length>0)throw Ke(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function HS(e){return e.startsWith(`${Tr}.tmp-`)||e.startsWith("git-worktree-context.json.tmp-")||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","git-worktree-context.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function zS(e){for(let t of aa(e)){let n=Ce(e,t);try{let r=wr(n);if(r.isSymbolicLink())throw Ke(e,`legacy cache entry ${t} is a symlink`);if(r.isDirectory())Fr(n);else if(r.isFile())ua(n);else throw Ke(e,`legacy cache entry ${t} is not a file or directory`)}catch(r){if(gd(r))continue;throw r}}Fr(e)}function md(e,t=!1){try{let n=wr(e);if(n.isSymbolicLink())throw Ke(e,"managed cache tree contains a symlink");if(n.isFile()){ua(e);return}if(!n.isDirectory())throw Ke(e,"managed cache tree contains a special file");Fr(e);for(let r of aa(e))md(Ce(e,r),!0)}catch(n){if(t&&gd(n))return;throw n}}function gd(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function yd(e,t=mn){let n=ue(e,t);return Fr(e),n}function US(e,t,n){let r=`${e}.tmp-${process.pid}-${n.randomToken()}`,i,o=!1;try{i=n.openFile(r,"wx",384),o=!0,yt(i,Buffer.from(t),n,"cache ownership record"),n.syncFile(i),n.closeFile(i),i=void 0,n.linkFile(r,e);let s=L(Ki(e),n);return n.removeFile(r),o=!1,q(s,L(Ki(e),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function Fr(e){process.platform!=="win32"&&ud(e,448)}function ua(e){process.platform!=="win32"&&ud(e,384)}function KS(e){if(qn(e))return Oe(e);let t=Oe(Ki(e));return Ce(t,MS(e))}function da(e){return KS(Ji(e))}function JS(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{execFileSync as db}from"child_process";import{isUtf8 as Ed}from"buffer";import{createHash as ha}from"crypto";import{closeSync as Cd,fstatSync as kr,lstatSync as ba,openSync as wd,readdirSync as pb,readFileSync as fb,readSync as Pd,readlinkSync as mb,realpathSync as _r}from"fs";import{isAbsolute as gb,join as xa,relative as yb,resolve as hb,sep as Sb}from"path";import{closeSync as hd,existsSync as fa,openSync as XS,realpathSync as YS,renameSync as QS,unlinkSync as Sd,writeSync as ZS}from"fs";import{dirname as eb,join as tb}from"path";var nb="fingerprint-stat-cache.json",bd=1,rb=8*1024*1024,pa=new Map;function ma(e,t,n,r){let i=xd(e),o=i.files.get(t);if(!(!o||!vd(o,n,r)))return i.hits+=1,{hash:o.hash,size:o.fingerprintSize,...o.semanticHash===void 0?{}:{semanticHash:o.semanticHash}}}function ga(e,t,n,r,i){if(i.hash==="unreadable"||i.size<0||!Number.isFinite(i.size))return;let o=xd(e),s={kind:n,dev:r.dev,ino:r.ino,mtimeMs:r.mtimeMs,ctimeMs:r.ctimeMs,size:r.size,hash:i.hash,fingerprintSize:i.size,...i.semanticHash===void 0?{}:{semanticHash:i.semanticHash}},a=o.files.get(t);a&&lb(a,s)||(o.files.set(t,s),o.stores+=1,o.dirty=!0)}function ya(e){let t=pa.get(Id(e));if(!(!t?.dirty||!t.cachePath))try{let n=eb(t.cachePath);if(!fa(n))return;ub(t.cachePath,sb(t)),t.dirty=!1}catch{}}function xd(e){let t=Id(e),n=pa.get(t);if(n)return n;let r=ib(t),i=ob(r),o={cachePath:r,files:i,dirty:!1,hits:0,stores:0};return pa.set(t,o),o}function ib(e){try{let t=ca(e);return fa(t)?tb(t,nb):null}catch{return null}}function ob(e){let t=new Map;if(!e||!fa(e))return t;try{let n=JSON.parse(ee(e,{inputKind:"fingerprint stat cache",maxBytes:rb}).toString("utf8"));if(!ab(n))return t;for(let[r,i]of Object.entries(n.files))i&&t.set(r,i)}catch{return t}return t}function sb(e){return{version:bd,files:Object.fromEntries(e.files)}}function ab(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.version!==bd||typeof t.files!="object"||t.files===null?!1:Object.values(t.files).every(cb)}function cb(e){if(typeof e!="object"||e===null)return!1;let t=e;return(t.kind==="file"||t.kind==="symlink")&&Number.isFinite(t.dev)&&Number.isFinite(t.ino)&&Number.isFinite(t.mtimeMs)&&Number.isFinite(t.ctimeMs)&&Number.isFinite(t.size)&&Number.isFinite(t.fingerprintSize)&&typeof t.hash=="string"&&t.hash!=="unreadable"&&(t.semanticHash===void 0||typeof t.semanticHash=="string")}function vd(e,t,n){return e.kind===t&&e.dev===n.dev&&e.ino===n.ino&&e.mtimeMs===n.mtimeMs&&e.ctimeMs===n.ctimeMs&&e.size===n.size}function lb(e,t){return vd(e,t.kind,t)&&e.hash===t.hash&&e.fingerprintSize===t.fingerprintSize&&e.semanticHash===t.semanticHash}function ub(e,t){let n=`${e}.${process.pid}.tmp`;try{Sd(n)}catch{}let r=Buffer.from(`${JSON.stringify(t)}
84
- `,"utf8"),i=XS(n,"wx",384);try{yt(i,r,{writeFile:(o,s,a,c)=>ZS(o,s,a,c)},"fingerprint stat cache")}catch(o){throw hd(i),Sd(n),o}hd(i),QS(n,e)}function Id(e){return YS(e)}var Wn=64*1024*1024,bb=1024*1024,xb=1024,gn=class extends Error{constructor(n,r,i,o){super(`${n} ${JSON.stringify(r)} is ${i} bytes; the safety limit is ${o} bytes`);this.inputKind=n;this.inputPath=r;this.observedBytes=i;this.limitBytes=o;this.name="InputTooLargeError"}inputKind;inputPath;observedBytes;limitBytes;code="SCIP_QUERY_INPUT_TOO_LARGE"};function vb(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function Hn(e,t,n={}){let r=Re(t),i=tu(e,()=>_r(e)),o=hb(i,...r.split("/"));if(!Ae(i,o)||o===i)throw new V(t,"outside-project");let s=_r(o);if(!Ae(i,s)||s===i)throw new V(t,"outside-project");let a=ba(s);if(!a.isFile())throw new V(t,"not-a-file");let c={projectRoot:i,relativePath:r,absolutePath:s,size:a.size,mtimeMs:a.mtimeMs,device:a.dev,inode:a.ino},l=n.maxBytes??Wn;if(cn(l),c.size>l)throw new gn(n.inputKind??"project file",c.relativePath,c.size,l);return c}function to(e,t,n={}){let r=Re(t),i=dn(e,r);if(i){if(i==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(r)} does not exist.`),{code:"ENOENT"});let c=un(e,r);if(!c)throw new V(r,"changed-during-read");let l=n.maxBytes??Wn;if(cn(l),c.size>l)throw new gn(n.inputKind??"project file",r,c.size,l);return Buffer.from(c.content)}let o=Hn(e,t,n),s=n.maxBytes??Wn,a=wd(o.absolutePath,"r");try{let c=kr(a);if(Nr(c,o,t),c.size>s)throw new gn(n.inputKind??"project file",o.relativePath,c.size,s);let l=fb(a),u=kr(a);if(Nr(u,o,t),l.byteLength!==c.size)throw new V(t,"changed-during-read");return l}finally{Cd(a)}}function Ib(e,t,n,r={}){if(n.byteLength===0)throw new Error("Project file probe literal must not be empty.");let{matchedLiteralIndexes:i,...o}=Fd(e,t,[n],r);return{...o,includesLiteral:i.length>0}}function Fd(e,t,n,r={}){if(n.length===0||n.some(c=>c.byteLength===0))throw new Error("Project file probe literals must not be empty.");let i=Re(t),o=dn(e,i);if(o){if(o==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(i)} does not exist.`),{code:"ENOENT"});let c=un(e,i);if(!c)throw new V(i,"changed-during-read");let l=r.maxBytes??Wn;if(cn(l),c.size>l)throw new gn(r.inputKind??"project file",i,c.size,l);let u=!c.content.includes(0)&&Ed(c.content),d=n.map(Rd),p=u?Pb(c.content,n,d):[];return{byteLength:c.size,isUtf8Text:u,matchedLiteralIndexes:p,bytes:p.length>0?Buffer.from(c.content):null,...r.computeSha256?{sha256:c.sha256}:{}}}let s=Hn(e,t,r),a=wd(s.absolutePath,"r");try{let c=kr(a);Nr(c,s,t);let l=r.computeSha256?ha("sha256"):null,u=r.scratchBuffer??Buffer.allocUnsafe(bb);if(u.byteLength===0)throw new Error("Project file probe scratch buffer must not be empty.");let d=0,p=n.map(()=>!1),f=!1,g=!0,y=Buffer.alloc(0),m=n.map(()=>Buffer.alloc(0)),S=n.map(Rd);for(;d<c.size;){let I=Pd(a,u,0,Math.min(u.byteLength,c.size-d),d);if(I<=0)throw new V(t,"changed-during-read");let b=u.subarray(0,I);if(l?.update(b),f||=b.includes(0),g){let v=y.byteLength>0?Buffer.concat([y,b]):b,C=Eb(v);g=Ed(v.subarray(0,C)),y=Buffer.from(v.subarray(C))}for(let v=0;v<n.length;v+=1){if(p[v])continue;let C=n[v],M=m[v];p[v]=Rb(b,C,M,S[v]),m[v]=Cb(b,C,M)}d+=I}g&&=y.byteLength===0,Nr(kr(a),s,t);let h=!f&&g,x=h?p.flatMap((I,b)=>I?[b]:[]):[],P=null;if(x.length>0){P=Buffer.allocUnsafe(c.size);let I=0;for(;I<P.byteLength;){let b=Pd(a,P,I,P.byteLength-I,I);if(b<=0)throw new V(t,"changed-during-read");I+=b}Nr(kr(a),s,t)}return{byteLength:c.size,isUtf8Text:h,matchedLiteralIndexes:x,bytes:P,...l?{sha256:l.digest("hex")}:{}}}finally{Cd(a)}}function Lr(e,t,n={}){return to(e,t,n).toString("utf8")}function Nr(e,t,n){if(!e.isFile()||e.dev!==t.device||e.ino!==t.inode||e.size!==t.size)throw new V(n,"changed-during-read")}function Eb(e){if(e.byteLength===0)return 0;let t=e.byteLength-1,n=0;for(;t>=0&&n<3&&(e[t]&192)===128;)n+=1,t-=1;if(t<0)return e.byteLength;let r=e[t];return((r&128)===0?1:(r&224)===192?2:(r&240)===224?3:(r&248)===240?4:0)>e.byteLength-t?t:e.byteLength}function Pb(e,t,n){return t.flatMap((r,i)=>Sa(e,r,n[i])?[i]:[])}function Rb(e,t,n,r){if(Sa(e,t,r))return!0;if(n.byteLength===0||t.byteLength===1)return!1;let i=e.subarray(0,Math.min(e.byteLength,t.byteLength-1));return Sa(Buffer.concat([n,i]),t,r)}function Sa(e,t,n){if(n<0)return e.includes(t);let r=t[n],i=e.indexOf(r),o=0;for(;i>=0;){if(o+=1,o>xb)return e.includes(t);let s=i-n;if(s>=0&&s+t.byteLength<=e.byteLength&&e.compare(t,0,t.byteLength,s,s+t.byteLength)===0)return!0;i=e.indexOf(r,i+1)}return!1}function Rd(e){for(let n=1;n<e.byteLength;n+=1){let r=e[n];if(r>=65&&r<=90)return n}let t=e[0];return t>=65&&t<=90?0:-1}function Cb(e,t,n){let r=t.byteLength-1;if(r===0)return Buffer.alloc(0);if(e.byteLength>=r)return Buffer.from(e.subarray(e.byteLength-r));let i=Buffer.concat([n,e]);return Buffer.from(i.subarray(Math.max(0,i.byteLength-r)))}function $t(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function wb(e,t){try{return Hn(e,t),!0}catch(n){if($t(n))return!1;throw n}}function Fb(e){let t=pn(e);return t?t.filter(n=>n&&!eo(n)).sort():(Db(e)??Ab(e)).filter(n=>n&&!eo(n)).sort()}function Tb(e,t={}){let n=(t.includePaths??[]).map(Re),r=[...new Set([...Fb(e),...n])].filter(s=>!eo(s)).filter(s=>!t.language||cu(s,t.language,t.markerFiles)).filter(s=>!t.includePath||t.includePath(s)).sort((s,a)=>s.localeCompare(a)),i=_r(e),o=r.flatMap(s=>Td(e,i,s));return ya(i),o}function Td(e,t,n){let r=Hu(e,n);if(r)return[{path:n,size:r.fingerprintSize??r.size,hash:r.sha256}];if(dn(e,n)==="present"){let o=un(e,n);if(o)return[{path:n,size:o.fingerprintSize??o.size,hash:o.sha256}]}let i=xa(e,n);try{let o=ba(i);if(o.isSymbolicLink()){let y=ma(t,n,"symlink",Zi(o));if(y)return[{path:n,size:y.size,hash:y.hash}];let m=_r(i),S=yb(t,m);if(S===".."||S.startsWith(`..${Sb}`)||gb(S))throw new Error("external symlink");let h=mb(i),x=ha("sha256").update("symlink\0").update(h).digest("hex"),P=Buffer.byteLength(h);return ga(t,n,"symlink",Zi(o),{hash:x,size:P}),[{path:n,size:P,hash:x}]}let s=ra(n)||oa(n),a=ma(t,n,"file",Zi(o));if(a&&(!s||a.semanticHash!==void 0))return[{path:n,size:a.size,hash:a.hash,...a.semanticHash===void 0?{}:{semanticHash:a.semanticHash}}];let c=ha("sha256"),l=s,u=[],d=$n(i,{inputKind:"project fingerprint input",maxBytes:Wn},y=>{c.update(y),l&&u.push(Buffer.from(y))}),p=c.digest("hex"),f=l?Buffer.concat(u,d):void 0,g=f?od(n,f)??ia(n,f):void 0;return ga(t,n,"file",Zi(o),{hash:p,size:d,...g===void 0?{}:{semanticHash:g}}),[{path:n,size:d,hash:p,...g===void 0?{}:{semanticHash:g}}]}catch(o){return $t(o)?[]:[{path:n,size:-1,hash:"unreadable"}]}}function Zi(e){return{dev:e.dev,ino:e.ino,mtimeMs:e.mtimeMs,ctimeMs:e.ctimeMs,size:e.size}}function zn(e,t,n){let r=Un(t,n),i=[...r.typescriptProjects.filter(c=>_b(e,c)),...r.clojureConfigPath?[r.clojureConfigPath]:[]],o=r.languages.includes("typescript")?Zu(e,r.typescriptProjectMode,r.typescriptProjects):null,s=r.languages.includes("typescript")?r.typescriptProjectMode==="workspace"?zi(e,r.typescriptProjects):["."]:[],a=Yu(s);return{...r,files:Tb(e,{includePath:c=>{if(c===".scipquery.json")return!1;let l=At(c,t,i);return l==="other"||l==="config"&&Qu(c)&&!a.has(c)?!1:l!=="source"||!Nb(c)||!o?!0:o.has(c)},includePaths:i})}}function lA(e,t){let n=new Set(t.files.map(o=>o.path)),r=zn(e,t.languages,t),i=new Map(r.files.map(o=>[o.path,o]));return{...Un(t.languages,t),files:[...t.files.flatMap(o=>{let s=i.get(o.path);return s?[s]:[]}),...r.files.filter(o=>!n.has(o.path))]}}function uA(e,t,n,r,i,o){let s=d=>({mode:"full",fingerprint:zn(e,t,n),reason:d});if(!i)return s("change-journal-unavailable");if(!i.complete)return s(`change-journal-incomplete:${i.incompleteReason??"unknown"}`);if(!o)return s("accepted-generation-unavailable");if(i.baseGeneration!==o)return s("change-journal-base-mismatch");if(!r)return s("prior-project-input-snapshot-unavailable");let a=Un(t,n);if(!kb(r,a))return s("project-input-configuration-changed");if(new Set(r.files.map(d=>d.path)).size!==r.files.length)return s("prior-project-input-snapshot-has-duplicate-paths");if(i.entries.length===0)return{mode:"delta",fingerprint:{...a,files:[...r.files].sort((d,p)=>d.path.localeCompare(p.path))},changedPaths:[]};let c=[...a.typescriptProjects,...a.clojureConfigPath?[a.clojureConfigPath]:[]],l=new Map(r.files.map(d=>[d.path,d]));for(let d of i.entries){let p=l.get(d.path);if(At(d.path,t,c)!=="source")return s("non-source-project-input-changed");if(d.kind==="add"&&p)return s("added-path-already-in-prior-project-input-snapshot");if(d.kind==="delete"&&!p)return s("deleted-path-not-in-prior-project-input-snapshot");if(d.kind==="change"&&!p)return s("changed-path-not-in-prior-project-input-snapshot");if(p&&(p.hash==="unreadable"||p.size<0))return s("changed-path-was-unreadable")}let u=_r(e);for(let d of i.entries){let p=Td(e,u,d.path);if(d.kind==="delete"){if(p.length!==0)return s("deleted-source-is-still-readable");l.delete(d.path);continue}if(p.length!==1||p[0].hash==="unreadable"||p[0].size<0)return s(d.kind==="add"?"added-source-is-not-readable":"changed-source-no-longer-readable");l.set(d.path,p[0])}return ya(u),{mode:"delta",fingerprint:{...a,files:[...l.values()].sort((d,p)=>d.path.localeCompare(p.path))},changedPaths:i.entries.map(d=>d.path).sort()}}function kb(e,t){return e.version===t.version&&JSON.stringify([...e.languages].sort())===JSON.stringify(t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&JSON.stringify([...e.typescriptProjects].sort())===JSON.stringify(t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function Nb(e){return/\.(?:[cm]?[jt]sx?|vue)$/iu.test(e)}function _b(e,t){let n;try{n=Re(t)}catch{return!1}let r=dn(e,n);if(r)return r==="present";try{return ba(xa(e,n)).isFile()}catch(i){if($t(i))return!1;throw i}}function Un(e,t){return{version:3,languages:[...e].sort(),pnpmWorkspaces:t.typescriptProjectMode!=="workspace"&&t.pnpmWorkspaces===!0,typescriptProjectMode:t.typescriptProjectMode??"single",typescriptProjects:vb(t.typescriptProjects),clojureConfigPath:Lb(t.clojureConfigPath)}}function Lb(e){return e?.trim()||void 0}function Db(e){try{let t=_i(e,52428800,()=>db("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:104857600,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}));return[...Li(t)]}catch{return null}}function Ab(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?xa(e,r):e,o;try{o=pb(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){eo(a)||n.push(a);continue}t.push(a)}}return t}function eo(e){let t=e.split("/");return e==="meta.json"||t[0]===".scipquery"&&(t[1]==="events"||t[1]==="ledger"||t[1]==="releases"||t[1]==="suppressions")||t.some(n=>Ob.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var Ob=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{basename as kd}from"path";var Mb=w("indexed-document-paths",{clearGroups:["whole-project"]});function ve(e,t={}){let n=jb(t);return[...Mb.get(e,n,()=>{let i=t.scope?"AND relative_path LIKE ?":"",o=t.like?"AND relative_path LIKE ?":"",s=[...t.scope?[`%${t.scope}%`]:[],...t.like?[t.like]:[]],a=e.all(`SELECT relative_path
85
- FROM documents
86
- WHERE 1 = 1
87
- ${e.pathExclusionsFor("documents")}
88
- ${i}
89
- ${o}
90
- ORDER BY relative_path`,...s).map(l=>l.relative_path),c=t.extensions?a.filter(l=>t.extensions.some(u=>l.toLowerCase().endsWith(u.toLowerCase()))):a;return t.includeIgnored===!1?c.filter(l=>!e.isIgnored(l)):c})]}function jb(e){let t=e.extensions?[...new Set(e.extensions.map(n=>n.toLowerCase()))].sort():null;return JSON.stringify({scope:e.scope??null,like:e.like??null,extensions:t,includeIgnored:e.includeIgnored!==!1})}function _d(e,t,n){let r=Ld(t);if(!r)return[];let i=e.all(`SELECT relative_path
91
- FROM documents
92
- WHERE relative_path = ?
93
- ${e.pathExclusionsFor("documents")}`,r).filter(c=>!e.isIgnored(c.relative_path)).map(c=>({relativePath:c.relative_path,score:Nd(c.relative_path,r)}));if(i.length>0)return i;let o=ve(e,{includeIgnored:!1}).map(c=>({relativePath:c,score:Nd(c,r)})).filter(c=>c.score>0).sort((c,l)=>l.score-c.score||c.relativePath.localeCompare(l.relativePath)),s=o.filter(c=>c.score>=1100);if(s.length>0)return n.allowMultiple?s:[s[0]];if(n.requirePathMatch)return[];let a=o.filter(c=>c.score>=800);return a.length>0?n.allowMultiple?a:[a[0]]:n.allowMultiple?o:o.slice(0,1)}function Nd(e,t){let n=Ld(e),r=kd(n),i=kd(t),o=0;return n===t&&(o+=1200),n.endsWith(`/${t}`)&&(o+=1100),r===i&&(o+=900),n.startsWith(`${t}/`)&&(o+=850),n.includes(t)&&(o+=250),o}function Ld(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}var Bb=[de("source-facts",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/source-facts.ts"}),de("file-definitions",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/symbols/definition-catalog.ts"}),de("definition-exclusions",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/framework-patterns.ts"}),de("doc-path-tokens",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-products.test.ts",owner:"tests/storage/evidence-cache.test.ts"}),de("doc-path-evidence",{dependsOn:["content-hash","git-history","git-head","tool-version"],keyParts:["kind","relativePath","contentHash","trackedFiles","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/cleanup/doc-drift.ts"}),de("source-imports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),de("source-reexports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),de("source-fingerprints",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/definition-catalog.test.ts",owner:"src/queries/cleanup/similar.ts"}),de("consumer-file-usage",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/internal/consumer-evidence.ts"}),de("react-component-behavior-profiles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/react-profile.ts"}),de("git-file-adds",{dependsOn:["git-head","git-history","tool-version"],keyParts:["kind","cacheKey","head","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/git-history.ts"}),de("typescript-reference-fragments",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-reference-fragments.test.ts",owner:"src/semantic/typescript/reference-fragment-shadow.ts"}),de("typescript-import-usage",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),de("typescript-signatures",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),de("runtime-boundary-http-roles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundaries.test.ts",owner:"src/analysis/runtime-boundaries/http-summaries.ts"}),no("file-dependency-graph",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","scope","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/file-dep-graph.test.ts",owner:"src/symbols/graph/file-dep-graph.ts"}),no("semantic-import-usage",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","relativePath","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),no("semantic-signatures",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","symbol","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),no("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"})];function we(e){let t=new Map;return{kind:e.kind,read(n,r,i){let o=!1,s=0,a;if(jt()){let c=gt(n);if(c){let l=`${c}\0${r}\0${i}`;a=t.get(l),a||(a=Er(["evidence-product-file-read-v1",e.kind,c,r,i]),t.set(l,a))}}return z("evidence-product.file.read",()=>{let c=bu(n,e.kind,r,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(n,r,i,o){xu(n,e.kind,r,i,e.serialize(o))},writeBatch(n,r){vu(n,r.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function Dd(e){let t=new Map;return{kind:e.kind,read(n,r,i){let o=!1,s=0,a;if(jt()){let c=`${i}\0${r}`;a=t.get(c),a||(a=Er(["evidence-product-project-read-v1",e.kind,i,r]),t.set(c,a))}return z("evidence-product.project.read",()=>{let c=Iu(n,e.kind,r,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"project",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(n,r,i,o){Eu(n,e.kind,r,i,e.serialize(o))}}}function pe(e){let t=Bb.find(n=>n.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function de(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function no(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}var $b=w("source-text",{clearGroups:["whole-project","source-file"]}),Gb=w("source-lines",{clearGroups:["whole-project","source-file"]});function F(e,t){let n=t.replace(/\\/g,"/");return $b.get(e,n,()=>va(e,n))}function va(e,t){let n=t.replace(/\\/g,"/");try{return Lr(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(r){if($t(r))return"";throw r}}function IA(e){if(e.length===0)return[];let t=e.split(`
94
- `);return e.endsWith(`
95
- `)&&t.pop(),t}function Dr(e,t){let n=t.replace(/\\/g,"/");return Gb.get(e,n,()=>{let r=F(e,n);return r?r.split(`
96
- `):[]})}var Vb=/^\s*(?:\/\/|#|\/\*+|\*)\s*scip-query[\s:-]*ignore(?:[\s:-]+(dead(?:-code)?|stale|wrapper|passthrough|drift|extract|similar|twin))?\b/i;function qb(e){let t=Vb.exec(e);return t?t[1]??"":null}function EA(e,t,n){return Ad(e,t,n).length>0}function PA(e,t,n,r){let i=r.toLowerCase();return Ad(e,t,n).some(o=>o.toLowerCase()===i)}function Ad(e,t,n){if(n<=0)return[];let r=Dr(e,t);if(r.length===0)return[];let i=[];for(let o=n-1;o>=0&&o>=n-5;o-=1){let s=(r[o]??"").trim();if(s==="")continue;let a=qb(s);if(a!==null){i.push(a);continue}if(!s.startsWith("//")&&!s.startsWith("*")&&!s.startsWith("/*")&&!s.startsWith("@")&&!s.startsWith("#"))return i}return i}import{readdirSync as Wb}from"fs";import{execFileSync as Hb}from"child_process";import{extname as ro,join as zb}from"path";var Ub=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue",".rs",".py",".pyi",".java",".kt",".kts",".scala",".sc",".clj",".cljs",".cljc",".rb",".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx",".cs",".vb",".php",".dart"],NA=[".vue"],Od=[".tsx",".jsx"],Md=[".vue"],Kb=[...Od,...Md],Jb=new Set(Od),Xb=new Set(Md),jd=new Set(Ub.map(e=>e.toLowerCase())),Yb=[...jd].sort().join(","),Bd=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);function Me(e,t={}){let n=t.includeIndexed??!0,r=t.includeAuxiliary??!0,i=t.extensions?.map(c=>c.toLowerCase()),o=i?new Set(i):jd,s=i?[...o].sort().join(","):Yb,a=`${n?"1":"0"}|${r?"1":"0"}|${s}`;return Qb.get(e,a,()=>{let c=new Set;if(n)for(let l of ve(e,{includeIgnored:!1}))o.has(ro(l).toLowerCase())&&c.add(l);if(r)for(let l of Zb(e.config.projectRoot,o))e.isIgnored(l)||n&&c.has(l)||c.add(l);return[...c].sort()})}function _A(e,t={}){let n=!1,r=!1;for(let i of Me(e,{extensions:Kb})){if(t.scope&&!i.includes(t.scope))continue;let o=ro(i).toLowerCase();if(n||=Jb.has(o),r||=Xb.has(o),n&&r)break}return{react:n,vue:r}}var Qb=w("source-files",{clearGroups:[]});function Zb(e,t){return ex(e,t)??nx(e,t)}function ex(e,t){try{let n=Hb("git",["ls-files","--cached","--others","--exclude-standard"],{cwd:e,encoding:"utf-8",timeout:1e4,killSignal:"SIGKILL",stdio:["ignore","pipe","ignore"]}),r=new Set;for(let i of n.split(`
97
- `)){let o=i.trim();o&&(tx(o)||t.has(ro(o).toLowerCase())&&r.add(o))}return r}catch{return null}}function tx(e){return e.split("/").some(t=>Bd.has(t))}function nx(e,t){let n=new Set,r=i=>{let o=i?zb(e,i):e,s;try{s=Wb(o,{withFileTypes:!0})}catch{return}for(let a of s)if(!Bd.has(a.name)){if(a.isDirectory()){r(i?`${i}/${a.name}`:a.name);continue}t.has(ro(a.name).toLowerCase())&&n.add(i?`${i}/${a.name}`:a.name)}};return r(""),n}import{createRequire as fx}from"module";import{existsSync as Sn}from"fs";import{basename as Gd,dirname as Fe,extname as ht,join as je,relative as yn,resolve as ne,sep as mx}from"path";import{existsSync as Ea,readdirSync as rx,statSync as ix}from"fs";import{join as Kn,relative as ox}from"path";function $d(e){let t=sx(e)??ux(e);if(!t||t.length===0)return[];let n=[],r=new Set;for(let i of t)for(let o of dx(e,i)){if(r.has(o))continue;r.add(o);let s=px(e,o);s&&n.push(s)}return n}function sx(e){let t=Kn(e,"pnpm-workspace.yaml");if(!Ea(t))return null;try{return ax(T(t,"pnpm workspace manifest"))}catch{return null}}function ax(e){let t=[],n=!1;for(let r of e.split(/\r?\n/)){let i=cx(r);if(!n){/^packages\s*:\s*$/.test(i.trim())&&(n=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=lx(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function cx(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function lx(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function ux(e){let t=Kn(e,"package.json");if(!Ea(t))return null;try{let n=JSON.parse(T(t,"workspace package manifest"));return n.workspaces?Array.isArray(n.workspaces)?n.workspaces:n.workspaces.packages??[]:null}catch{return null}}function dx(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=Kn(e,t);return Ia(s)?[s]:[]}let n=t.indexOf("*"),r=t.slice(0,n).replace(/\/$/,""),i=t.slice(n+1).replace(/^\//,""),o=Kn(e,r||".");return Ia(o)?rx(o).map(s=>Kn(o,s,i)).filter(Ia):[]}function Ia(e){try{return ix(e).isDirectory()}catch{return!1}}function px(e,t){let n=Kn(t,"package.json");if(!Ea(n))return null;try{let r=JSON.parse(T(n,"workspace package manifest"));return typeof r.name!="string"||r.name.length===0?null:{name:r.name,relativeDir:ox(e,t).replace(/\\/g,"/"),exports:r.exports}}catch{return null}}var gx=Ze("indexed-paths",{clearGroups:[]}),yx=Ze("indexed-path-digest",{clearGroups:[]}),hx=w("tsconfig-alias-config",{clearGroups:["whole-project"]}),Sx=w("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),bx=fx(import.meta.url),Ar;function xx(){if(Ar!==void 0)return Ar;try{Ar=bx("typescript")}catch{Ar=null}return Ar}var vx=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],Ix=Ze("workspace-packages",{clearGroups:["whole-project"]}),hn=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],io=[".py",".pyi"],Te=[".java",".scala",".kt",".kts"],oo=[".rs"],so=[".rb"],ao=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],Gt=[".cs",".vb"],co=[".dart"],bn=[".php"],Jn=[".clj",".cljs",".cljc"],Ex=new Set(hn),Pa=new Set(io),Vd=new Set(Te),Ra=new Set(oo),Ca=new Set(so),qd=new Set(ao),Wd=new Set(Gt),wa=new Set(co),Hd=new Set(bn),zd=new Set(Jn),Px=[{extensions:hn,lookup:Ex},{extensions:io,lookup:Pa},{extensions:Te,lookup:Vd},{extensions:oo,lookup:Ra},{extensions:so,lookup:Ca},{extensions:ao,lookup:qd},{extensions:Gt,lookup:Wd},{extensions:co,lookup:wa},{extensions:bn,lookup:Hd},{extensions:Jn,lookup:zd}];function St(e,t){return t.has(ht(e).toLowerCase())}function Rx(e){return St(e,Pa)}function Cx(e){return St(e,Vd)}function wx(e){return St(e,Ra)}function Fx(e){return St(e,Ca)}function Tx(e){return St(e,qd)}function kx(e){return St(e,Wd)}function Ud(e){return ht(e).toLowerCase()===".vb"}function Nx(e){return St(e,wa)}function _x(e){return St(e,Hd)}function Lx(e){return St(e,zd)}function Fa(e){let t=ht(e).toLowerCase();for(let n of Px)if(n.lookup.has(t))return n.extensions;return hn}function Dx(e){return Cx(e)||kx(e)||_x(e)}function rt(e,t,n){return Rx(t)?Xn(e,t,n):wx(t)?bt(e,t,n):Fx(t)?lo(e,t,n):Tx(t)?uo(e,t,n):Dx(t)?U(e,n.replace(/\\/g,"."),Fa(t)):Nx(t)?po(e,t,n):Lx(t)?Ta(e,n):Ax(e,t,n)}function Ax(e,t,n){if(!n.startsWith(".")&&!n.startsWith("/"))return Ox(e,t,n)??jx(e,n);let r=Fe(je(e.config.projectRoot,t)),i=ne(r,n),o=xt(e);for(let s of Na(i)){let a=Z(yn(e.config.projectRoot,s));if(o.has(a)||Sn(s))return a}return Z(yn(e.config.projectRoot,i))}function Ox(e,t,n){let r=Wx(e,t);if(!r)return null;let i=xt(e);for(let o of Mx(r,n)){let s=ne(r.baseUrl,o);for(let a of Na(s)){let c=Z(yn(e.config.projectRoot,a));if(i.has(c)||Sn(a))return c}}return null}function Mx(e,t){let n=[];for(let[r,i]of Object.entries(e.paths)){let o=r.indexOf("*");if(o===-1){if(t!==r)continue;n.push(...i);continue}let s=r.slice(0,o),a=r.slice(o+1);if(!t.startsWith(s)||!t.endsWith(a)||t.length<s.length+a.length)continue;let c=t.slice(s.length,t.length-a.length);for(let l of i)n.push(l.includes("*")?l.replace("*",c):l)}return n}function jx(e,t){let n=$x(Bx(e),t);if(!n)return null;let r=xt(e);for(let i of Gx(n)){let o=ne(e.config.projectRoot,n.pkg.relativeDir,i);for(let s of Na(o)){let a=Z(yn(e.config.projectRoot,s));if(r.has(a)||Sn(s))return a}}return null}function Bx(e){return Ix.get(e,()=>$d(e.config.projectRoot))}function $x(e,t){let n=null;for(let r of e){let i=null;t===r.name?i="":t.startsWith(`${r.name}/`)&&(i=t.slice(r.name.length+1)),i!==null&&(!n||r.name.length>n.pkg.name.length)&&(n={pkg:r,subpath:i})}return n}function Gx(e){let t=[],n=Vx(e.pkg.exports,e.subpath);if(n){let r=qx(n);r&&t.push(r)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function Vx(e,t){if(!e||typeof e!="object")return null;let n=t===""?".":`./${t}`;return Kd(e[n])}function Kd(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let n of["types","import","default","require","node"]){let r=Kd(t[n]);if(r)return r}return null}function qx(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function Wx(e,t){let n=Z(Fe(t));return Sx.get(e,n,()=>Hx(e,n))}function Hx(e,t){let n=xx();if(!n)return null;let r=ne(e.config.projectRoot),i=ne(r,t);for(;i===r||i.startsWith(r+mx);){for(let s of vx){let a=je(i,s);if(!Sn(a))continue;let c=hx.get(e,a,()=>zx(n,a));if(c)return c}let o=Fe(i);if(o===i)break;i=o}return null}function zx(e,t){try{let n=e.readConfigFile(t,e.sys.readFile);if(n.error||!n.config)return null;let r=e.parseJsonConfigFileContent(n.config,e.sys,Fe(t)),i=r.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:r.options.baseUrl?ne(Fe(t),r.options.baseUrl):Fe(t),paths:i}}catch{return null}}function Xn(e,t,n){let r=xt(e),i;if(n.startsWith(".")){let o=n.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=Fe(je(e.config.projectRoot,t));for(let l=1;l<s;l++)c=Fe(c);i=a?ne(c,a.replace(/\./g,"/")):c}else i=ne(e.config.projectRoot,n.replace(/\./g,"/"));for(let o of Ux(i)){let s=Z(yn(e.config.projectRoot,o));if(r.has(s)||Sn(o))return s}return null}function bt(e,t,n){if(!n)return null;let r=n.replace(/\s+as\s+.+$/,"").trim();if(!r.startsWith("crate::")&&!r.startsWith("self::")&&!r.startsWith("super::"))return null;let i=Fe(je(e.config.projectRoot,t)),o;return r.startsWith("crate::")?o=ne(e.config.projectRoot,"src",r.slice(7).replace(/::/g,"/")):r.startsWith("self::")?o=ne(i,r.slice(6).replace(/::/g,"/")):o=ne(Fe(i),r.slice(7).replace(/::/g,"/")),ka(e,Kx(o))}function lo(e,t,n){let r=Fe(je(e.config.projectRoot,t)),i=ne(r,n);return ka(e,Jx(i))}function uo(e,t,n){let r=Fe(je(e.config.projectRoot,t)),i=[ne(r,n),ne(e.config.projectRoot,n),ne(e.config.projectRoot,"include",n),ne(e.config.projectRoot,"src",n)];return ka(e,i)}function U(e,t,n){let r=xt(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of n){let l=`${o}${c}`,u=[...r].find(d=>d.endsWith(l));if(u)return u}for(let c of n){let l=[...r].find(u=>Gd(u)===`${s}${c}`);if(l)return l}let a=[...r].filter(c=>n.includes(ht(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function po(e,t,n){let r=xt(e);if(n.startsWith("package:")){let s=n.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=Z(c.startsWith("lib/")?c:`lib/${c}`);return r.has(l)?l:null}let i=Fe(je(e.config.projectRoot,t)),o=ne(i,n);for(let s of Xx(o)){let a=Z(yn(e.config.projectRoot,s));if(r.has(a)||Sn(s))return a}return null}function Ta(e,t){let n=t.replace(/-/g,"_").replace(/\./g,"/"),r=xt(e);for(let i of Jn){let o=`${n}${i}`,s=[...r].find(a=>a.endsWith(o));if(s)return s}for(let i of Jn){let o=[...r].find(s=>Gd(s)===`${n.split("/").pop()}${i}`);if(o)return o}return null}function Ux(e){let t=ht(e);return Pa.has(t)?[e]:[`${e}.py`,`${e}.pyi`,je(e,"__init__.py"),je(e,"__init__.pyi")]}function ka(e,t){let n=xt(e);for(let r of t){let i=Z(yn(e.config.projectRoot,r));if(n.has(i)||Sn(r))return i}return null}function Kx(e){let t=ht(e);return Ra.has(t)?[e]:[`${e}.rs`,je(e,"mod.rs")]}function Jx(e){let t=ht(e);return Ca.has(t)?[e]:[`${e}.rb`,je(e,"index.rb")]}function Xx(e){let t=ht(e);return wa.has(t)?[e]:[`${e}.dart`,e]}function Na(e){let t=ht(e),n=new Set;if(t){n.add(e);for(let r of hn)n.add(e.slice(0,-t.length)+r)}else for(let r of hn)n.add(`${e}${r}`),n.add(je(e,`index${r}`));return[...n]}function xt(e){return gx.get(e,()=>new Set(ve(e,{includeIgnored:!1}).map(Z)))}function _a(e){return yx.get(e,()=>H([...xt(e)].sort().join(`
98
- `)))}function Vt(e){return typeof e=="object"&&e!==null}function Be(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{basename as Bp}from"path";function ie(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Da(e){return e.replace(/'''[\s\S]*?'''/g,qt).replace(/"""[\s\S]*?"""/g,qt).replace(/#.*$/gm,qt).replace(/\/\/.*$/gm,qt).replace(/\/\*[\s\S]*?\*\//g,qt).replace(/`(?:\\[\s\S]|[^`])*`/g,qt).replace(/'(?:\\.|[^'\\\r\n])*'/g,qt).replace(/"(?:\\.|[^"\\\r\n])*"/g,qt)}function QA(e){return Jd(e,{maskStrings:!1})}function ZA(e){return Jd(e,{maskStrings:!0})}function Jd(e,t){let n="",r=0,i=e.length;for(;r<i;){if(e[r]==="/"&&e[r+1]==="/"){let s=e.indexOf(`
99
- `,r),a=s===-1?i:s;n+=La(e,r,a),r=a;continue}if(e[r]==="/"&&e[r+1]==="*"){let s=e.indexOf("*/",r+2),a=s===-1?i:s+2;n+=La(e,r,a),r=a;continue}let o=e[r];if(o==="`"||o==="'"||o==='"'){let s=o,a=r+1;for(;a<i;){if(e[a]==="\\"){a+=2;continue}if(e[a]===s){a+=1;break}if(s!=="`"&&e[a]===`
100
- `)break;a+=1}n+=t.maskStrings?La(e,r,a):e.slice(r,a),r=a;continue}n+=o,r+=1}return n}function La(e,t,n){let r="";for(let i=t;i<n;i+=1)r+=e[i]===`
101
- `?`
102
- `:" ";return r}function qt(e){return e.replace(/[^\r\n]/g," ")}var eO=nn("stripped-lines",{clearGroups:["whole-project","source-file"]});Mn({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{fo=null,Or=""},clearFile:()=>{fo=null,Or=""}});var fo=null,Or="";function Yx(e){return fo===e||(fo=e,Or=Da(e)),Or}function Wt(e,t,n){let r=Yx(e);return`${r.slice(0,t)}${" ".repeat(n-t)}${r.slice(n)}`}function Ie(e,t){return new RegExp(`\\b${ie(t)}\\b`,"m").test(e)}function Yn(e,t){let n=new Set,r=new RegExp(`\\b${ie(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function Aa(e){let t=0;for(let n of e)n==="("&&(t+=1),n===")"&&(t-=1);return t}import{extname as Xd}from"path";var Qx={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb",".clj":"clojure",".cljs":"clojure",".cljc":"clojure"};function oe(e){return Qx[Xd(e).toLowerCase()]??null}function it(e){return Xd(e).toLowerCase()===".vue"}function se(e,t){t(e);for(let n of e.namedChildren)se(n,t)}function $e(e,t,n){let r=null;return se(e,i=>{!/(?:function|method|lambda)/u.test(i.type)&&i.type!=="arrow_function"||i.startPosition.row>t||i.endPosition.row<n||(!r||i.endIndex-i.startIndex<r.endIndex-r.startIndex)&&(r=i)}),r}function Yd(e,t,n){if(e.startPosition.row>t||e.endPosition.row<n)return null;for(let r of e.namedChildren){let i=Yd(r,t,n);if(i)return i}return e}function Ge(e){let t=e;for(;["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(t.type)&&t.namedChildren.length>0;)t=t.namedChildren[0];return t}function Mr(e){if(e.type==="identifier")return e.text;let t=e.childForFieldName("name")??e.childForFieldName("pattern");return t?Mr(t):e.namedChildren.find(n=>n.type==="identifier")?.text??null}function Ht(e){return(e.childForFieldName("parameters")??e.namedChildren.find(n=>/parameters/u.test(n.type)))?.namedChildren.map(Mr)??[]}import{createRequire as Zx}from"module";var fe=Zx(import.meta.url),jr=null,Oa=!1;function Qd(){if(Oa)return null;if(jr)return jr;try{return jr=fe("tree-sitter"),jr}catch{return Oa=!0,null}}function sO(e){if(e==="clojure")return"reader";let t=Qd();if(!t)return"unavailable";let n=Zd(e);if(!n)return"unavailable";try{return new t().setLanguage(n),"ast"}catch{return Qn.add(e),"unavailable"}}var Ma=new Map,Qn=new Set;function Zd(e){if(Qn.has(e))return null;let t=Ma.get(e);if(t)return t;let n;try{switch(e){case"rust":n=fe("tree-sitter-rust");break;case"typescript":n=fe("tree-sitter-typescript").typescript;break;case"tsx":n=fe("tree-sitter-typescript").tsx;break;case"javascript":n=fe("tree-sitter-javascript");break;case"python":n=fe("tree-sitter-python");break;case"java":n=fe("tree-sitter-java");break;case"kotlin":n=fe("tree-sitter-kotlin");break;case"scala":n=fe("tree-sitter-scala");break;case"ruby":n=fe("tree-sitter-ruby");break;case"c":n=fe("tree-sitter-c");break;case"cpp":n=fe("tree-sitter-cpp");break;case"csharp":n=fe("tree-sitter-c-sharp");break;case"php":n=fe("tree-sitter-php").php;break;case"vb":{let r=fe("tree-sitter-vb-dotnet");n=r.language??r;break}case"clojure":return Qn.add(e),null}}catch{return Qn.add(e),null}return Ma.set(e,n),n}var ja=new Map;function aO(){jr=null,Oa=!1,Ma.clear(),Qn.clear(),ja.clear(),nv.clear()}function ev(e){let t=ja.get(e);if(t)return t;let n=Zd(e);if(!n)return null;let r=Qd();if(!r)return null;let i=new r;try{i.setLanguage(n)}catch{return Qn.add(e),null}return ja.set(e,i),i}function tv(e,t){return e.parse(r=>r>=t.length?null:t.slice(r,Math.min(t.length,r+16384)))}function xn(e,t){let n=ev(e);if(!n)return null;try{return tv(n,t)}catch{return null}}var nv=new Map;import{createRequire as rv}from"module";import{posix as Ba}from"path";var iv=Mt("vue-sfc-units"),ov=rv(import.meta.url),sv;function av(){return sv??=ov("@vue/compiler-sfc")}function np(...e){return av().parse(...e)}function Zn(e,t){let n=rp(t),r=F(e,n);return iv.get(e,n,r,()=>$a(e,n,r))}function rp(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function cv(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function vn(e){return!e||e.body.length===0?0:e.body.split(`
103
- `).length}function $a(e,t,n){let r={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!n)return r;let i;try{i=np(n,{filename:t})}catch(s){return r.errors.push(tp(s)),r}r.errors.push(...i.errors.map(tp));let{descriptor:o}=i;return o.template&&(r.template=mo(e,t,"template",o.template)),o.script&&r.scripts.push(ep(e,t,o.script,!1)),o.scriptSetup&&r.scripts.push(ep(e,t,o.scriptSetup,!0)),r.styles=o.styles.map(s=>mo(e,t,"style",s)),r.customBlocks=o.customBlocks.map(s=>mo(e,t,"custom",s)),r.errors.push(...[r.template,...r.scripts,...r.styles,...r.customBlocks].flatMap(s=>s?.errors??[])),r}function ep(e,t,n,r){let i=mo(e,t,"script",n);return{...i,kind:"script",setup:r,astLanguage:cv(i.lang)}}function mo(e,t,n,r){let i=uv(r.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof r.src=="string"?r.src:void 0;if(s){let c=lv(t,s);if(!c)return{kind:n,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${n} block source: ${s}`]};let l=F(e,c),u=l?Math.max(0,l.split(`
104
- `).length-1):0;return{kind:n,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:u,errors:l?[]:[`Vue ${n} block source not found: ${c}`]}}let a=Math.max(0,r.loc.start.line-1);return{kind:n,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:r.content,startLine:a,endLine:Math.max(a,r.loc.end.line-1),errors:[]}}function lv(e,t){let n=t.split(/[?#]/,1)[0];if(!n||n.startsWith("/")||n.includes("://"))return null;let r=rp(Ba.normalize(Ba.join(Ba.dirname(e),n)));return r===".."||r.startsWith("../")?null:r}function uv(e){return{...e}}function tp(e){return e instanceof Error?e.message:String(e)}function Br(e,t,n){let i=$a(e,t,n).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
105
- `.repeat(s.startLine)}${s.body}`).join(`
106
- `),startLine:0,language:o}:null}var ip=nn("ast-trees",{clearGroups:["whole-project","source-file"]});function O(e,t){if(it(t))return dv(e,t);let n=oe(t);if(!n)return null;let r=F(e,t);return r?ip.get(e,t,r,()=>xn(n,r)):null}function In(e,t,n){if(it(t)){let o=Br(e,t,n);if(!o)return null;let s=xn(o.language,`
107
- `.repeat(o.startLine)+o.body);return s?{tree:s,language:o.language}:null}let r=oe(t);if(!r)return null;let i=xn(r,n);return i?{tree:i,language:r}:null}function dv(e,t){let n=F(e,t);return n?ip.get(e,t,n,()=>{let r=Br(e,t,n);if(!r)return null;let i=`
108
- `.repeat(r.startLine)+r.body;return xn(r.language,i)}):null}function er(e,t){let n=fv(e,t);if(!n)return null;let r=vt(n);if(!r)return null;let i=mv(n);return{calleeLeaf:r,calleeQualifier:i?pv(n):void 0,calleeText:n.text,memberAccess:i,line:e.startPosition.row}}function pv(e){return(e.childForFieldName("object")??e.childForFieldName("value")??e.namedChild(0)??void 0)?.text||void 0}function fv(e,t){if(t==="rust")return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null;if(t==="python")return e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0);if(t==="typescript"||t==="tsx"||t==="javascript"){if(e.type==="call_expression")return e.childForFieldName("function")??e.namedChild(0);if(e.type==="new_expression")return e.childForFieldName("constructor")??e.namedChild(0)}return null}function mv(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}function vt(e){switch(e.type){case"identifier":case"type_identifier":case"field_identifier":case"property_identifier":case"private_property_identifier":case"shorthand_property_identifier":return e.text.replace(/^#/u,"");case"field_expression":case"member_expression":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?vt(t):null}case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?vt(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?vt(t):null}case"super":case"self":case"this":return null;default:return null}}function $r(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var dp=["function_declaration","generator_function_declaration","method_definition","method_signature","function_signature"],gv=new Set(dp),yv=[...dp,"variable_declarator","public_field_definition"],hv=["function_item","function_signature_item"],Sv=["function_definition"],bv=[],op=new Set(["arrow_function","function_expression","generator_function"]);function pp(e){return e==="rust"?hv:e==="python"?Sv:e==="typescript"||e==="tsx"||e==="javascript"?yv:bv}function tr(e,t){let n=vv(e,t);if(n)return{name:n.name,startLine:n.definitionNode.startPosition.row,endLine:n.definitionNode.endPosition.row,paramCount:lp(n.functionNode),params:sp(n.functionNode),paramsEndLine:ap(n.functionNode),isLiteralPassthrough:up(n.functionNode,t)};if(!xv(e.type,t))return null;let r=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return r?{name:r.text,startLine:e.startPosition.row,endLine:e.endPosition.row,paramCount:lp(e),params:sp(e),paramsEndLine:ap(e),isLiteralPassthrough:up(e,t)}:null}function fp(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function sp(e){let t=fp(e);if(!t)return[];let n=[];for(let r of t.namedChildren){if($r(r))continue;if(r.type==="identifier"){n.push({name:r.text,simple:!0});continue}let i=r.namedChildren.some(a=>a.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(r.text),o=r.childForFieldName("pattern");if(!i&&o&&o.type==="identifier"){n.push({name:o.text,simple:!0});continue}let s=r.namedChildren.find(a=>a.type==="identifier");n.push({name:o?.type==="identifier"?o.text:s?.text??"",simple:!1})}return n}function ap(e){let t=fp(e);return t?t.endPosition.row:e.startPosition.row}function xv(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?gv.has(e):!1}function vv(e,t){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript")return null;if(e.type==="variable_declarator"){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(!n||!r)return null;let i=cp(r);return i?{name:n.text,definitionNode:e,functionNode:i}:null}if(e.type==="public_field_definition"){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(!n||!r)return null;let i=cp(r);return i?{name:n.text,definitionNode:e,functionNode:i}:null}return null}function cp(e){if(op.has(e.type))return e;if(e.type!=="call_expression"||(e.childForFieldName("function")??e.namedChild(0))?.type!=="call_expression")return null;let r=((e.childForFieldName("arguments")??e.namedChildren.find(i=>i.type==="arguments"))?.namedChildren??[]).filter(i=>op.has(i.type));return r.length===1?r[0]:null}function lp(e){let t=e.namedChildren.find(r=>r.type==="parameters"||r.type==="formal_parameters");if(!t)return 0;let n=0;for(let r of t.namedChildren)$r(r)||(n+=1);return n}function up(e,t){let n=e.namedChildren.find(d=>d.type==="block"||d.type==="statement_block");if(!n)return!1;let r=n.namedChildren.filter(d=>!$r(d));if(r.length!==1)return!1;let i=r[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:t==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let s=t==="python"?"call":"call_expression";if(o.type!==s)return!1;let a=o.namedChildren.find(d=>d.type==="arguments"||d.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(d=>!$r(d)),l=e.namedChildren.find(d=>d.type==="parameters"||d.type==="formal_parameters");if(!l)return!1;let u=[];for(let d of l.namedChildren){if(d.type==="identifier"){u.push(d.text);continue}let p=d.namedChildren.find(f=>f.type==="identifier");p&&u.push(p.text)}if(c.length!==u.length)return!1;for(let d=0;d<u.length;d+=1){let p=c[d];if(p.type!=="identifier"||p.text!==u[d])return!1}return!0}function RO(e,t){return e.filter(n=>n.startLine<=t&&n.endLine>=t).sort((n,r)=>n.endLine-n.startLine-(r.endLine-r.startLine)||n.startLine-r.startLine)[0]??null}var Iv=new Set(["identifier","type_identifier","field_identifier"]),Ev=new Set(["identifier"]),Pv=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),Rv=new Set(["rust","python"]),Cv=/\{([^{}]*)\}/g,wv=/\b([A-Za-z_][\w]*)\b/g;function mp(e,t){return Fv(t).has(e.type)}function gp(e,t){return Rv.has(t)&&e.type==="string_content"}function Ga(e){let t=0;for(let r of e.values()){let i=r[r.length-1];i!==void 0&&i>t&&(t=i)}let n=new Array(t+1);for(let r=0;r<=t;r+=1)n[r]=new Set;for(let[r,i]of e)for(let o of i)n[o].add(r);return n}function Fv(e){return e==="rust"?Iv:e==="python"?Ev:Pv}function yp(e,t){let n=e.startPosition.row;for(let r of e.text.matchAll(Cv)){let i=r[1]??"";for(let o of i.matchAll(wv))o[1]&&t(o[1],n)}}var Tv=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],kv=/^#!?\[\s*serde\s*\(/,Nv=/^#!?\[\s*schemars\s*\(/,_v=/^#!?\[\s*validate\s*\(/,Lv=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function hp(e,t,n){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript"||e.type!=="call_expression")return;let r=e.childForFieldName("function")??e.namedChild(0);if(!r)return;let i=vt(r);if(!i||!Lv.has(i))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let s=o.namedChild(0);if(!s||s.type!=="string")return;let a=s.namedChildren.find(c=>c.type==="string_fragment");a&&n.add(a.text)}function Sp(e,t){let n=kv.test(e),r=Nv.test(e),i=_v.test(e);if(!(!n&&!r&&!i))for(let o of Tv){o.lastIndex=0;let s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&t.add(c)}}}function bp(e,t){let n=new Map,r=(s,a)=>{if(s===a)return;let c=n.get(s);c||(c=new Set,n.set(s,c)),c.add(a)},i=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(s,a)=>{let c=l=>{i.has(l.type)&&l.text!==a&&r(l.text,a);for(let u of l.children)c(u)};for(let l of s.children)c(l)};if(t==="rust")for(let s of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=s.namedChildren.find(l=>l.type==="type_identifier")?.text;if(!a)continue;let c=s.namedChildren.find(l=>l.type==="field_declaration_list"||l.type==="enum_variant_list"||l.type==="ordered_field_declaration_list");c&&o(c,a),s.type==="type_item"&&o(s,a)}else if(t==="python")for(let s of e.rootNode.descendantsOfType("class_definition")){let a=s.namedChildren.find(u=>u.type==="identifier")?.text;if(!a)continue;let c=s.childForFieldName("superclasses");c&&o(c,a);let l=s.namedChildren.find(u=>u.type==="block");if(l)for(let u of l.descendantsOfType("type"))for(let d of u.descendantsOfType("identifier"))d.text!==a&&r(d.text,a)}else for(let s of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=s.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(s,a)}return n}var Dv=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),Va=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function xp(e){let t=[],n=[],r=[],i=new Map,o=[],s=0,a=0,c=(l,u)=>{let d=i.get(l);if(!d){i.set(l,[u]);return}d[d.length-1]!==u&&d.push(u)};for(;a<e.length;){let l=e[a];if(l===`
109
- `){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=yo(e,a);continue}if(l==='"'){let g=Vr(e,a,s);s=g.line,a=g.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:s,endLine:s,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let g=o.pop();g&&(g.endLine=s,Av(g,{callables:t,callSites:n,clojureMembers:r,recordIdentifier:c}),o[o.length-1]?.children.push(g)),a+=1;continue}if(qa(l)){a+=1;continue}let u=s,d=a;for(;a<e.length&&!Wa(e[a]);)a+=1;let p=e.slice(d,a);if(!p)continue;let f={text:p,line:u};Ov(o[o.length-1],f),c(Ve(p),u)}return{language:"clojure",callables:t,callSites:n,clojureMembers:r,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:Gv(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function Av(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let n=e.headTokens[0],r=Ve(n.text),i=Dv.get(n.text);if(i){let s=e.headTokens[1];if(s){let a=Ve(s.text);t.recordIdentifier(a,s.line),t.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:s.line,isLiteralPassthrough:!1,clojureKind:i})}}if(Mv(e,t),!r||Va.has(n.text)||Va.has(r)||r.startsWith(":"))return;let o=$v(n.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:n.line})}function Ov(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function Mv(e,t){let n=Ve(e.tokens[0]?.text??"");if(n==="defprotocol"){let r=Ve(e.tokens[1]?.text??"");if(!r)return;for(let i of go(e))Gr(t,r,"protocol",i,"protocol-method");return}if(n==="defrecord"||n==="deftype"){let r=Ve(e.tokens[1]?.text??"");if(!r)return;let i=n==="defrecord"?"record":"type",o=n==="defrecord"?"record-method":"type-method";for(let s of go(e))Gr(t,r,i,s,o);return}if(n==="extend-type"){let r=Ve(e.tokens[1]?.text??"");if(!r)return;for(let i of go(e))Gr(t,r,"extension",i,"extension-method");return}if(n==="extend-protocol"){let r=Ve(e.tokens[1]?.text??"");for(let i of go(e)){r&&Gr(t,r,"extension",i,"extension-method");let o=Bv(e,i.startLine);o&&o!==r&&Gr(t,o,"extension",i,"extension-method")}}}function go(e){return e.children.filter(jv)}function jv(e){if(e.kind!=="(")return!1;let t=Ve(e.tokens[0]?.text??"");return!!(t&&!Va.has(t)&&!t.startsWith(":"))}function Gr(e,t,n,r,i){let o=r.tokens[0],s=Ve(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:n,memberName:s,memberKind:i,startLine:r.startLine,endLine:r.endLine}))}function Bv(e,t){let n=null;for(let r=2;r<e.tokens.length;r+=1){let i=e.tokens[r];if(i.line>t)break;let o=Ve(i.text);o&&!o.startsWith(":")&&(n=o)}return n}function Ve(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function $v(e){let t=e.replace(/^#?['`~@]+/,""),n=t.lastIndexOf("/"),r=Ve(t);if(n<=0)return{leaf:r,text:t};let i=t.slice(0,n);return{leaf:r,qualifier:i,text:t}}function yo(e,t){let n=t;for(;n<e.length&&e[n]!==`
110
- `;)n+=1;return n}function Vr(e,t,n){let r=t+1,i=n;for(;r<e.length;){let o=e[r];if(o==="\\"){r+=2;continue}if(o===`
111
- `&&(i+=1),r+=1,o==='"')break}return{index:r,line:i}}function qa(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function Wa(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function Gv(e){let t=[];for(let[n,r]of e)for(let i of r)t[i]??=new Set,t[i].add(n);return t}var vp=6,Vv=nn("source-facts",{clearGroups:["whole-project","source-file"]}),Ha=we({kind:"source-facts",invalidation:pe("source-facts"),serialize:Hv,deserialize:zv});function me(e,t){return za(e,t).facts}function za(e,t){let n=F(e,t);if(!n)return{facts:null};let r=qv(e,t,n);return r?Vv.get(e,t,n,()=>Wv(e,t,r,n)):{facts:null}}function qv(e,t,n){return it(t)?Br(e,t,n)?.language??null:oe(t)}function Wv(e,t,n,r){let i=De(e,t,r),o=Ha.read(e,t,i);if(o&&o.language===n)return{facts:o};if(n==="clojure"){let c=xp(r);return Ha.write(e,t,i,c),{facts:c}}let s=O(e,t);if(!s)return{facts:null,unavailable:{language:n,reason:"parser-unavailable"}};let a=Xv(s,n);return Ha.write(e,t,i,a),{facts:a}}function Hv(e){let t={version:vp,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([n,r])=>[n,[...r]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function zv(e){try{let t=JSON.parse(e);if(t.version!==vp||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(r=>r.calleeText===void 0)))return null;let n=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([r,i])=>[r,new Set(i)])),identifierLineMap:n,identifiersByLine:Ga(n),fileIdentifiers:new Set(n.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function Uv(e,t,n,r){let i=me(e,t);return i?Jv(i,n,r)?.isLiteralPassthrough??!0:!0}function Kv(e,t){return t.relativePath.includes(".clj-kondo/hooks/")?!0:me(e,t.relativePath)?.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine)?.clojureKind==="macro"}function Jv(e,t,n){return e.callables.find(r=>r.startLine===t&&r.endLine===n)??null}function Xv(e,t){let n=[],r=[],i=new Set,o=new Set,s=new Map,a=(l,u)=>{let d=s.get(l);if(!d){s.set(l,[u]);return}d[d.length-1]!==u&&d.push(u)},c=l=>{let u=tr(l,t);u&&n.push(u);let d=er(l,t);d&&r.push(d),hp(l,t,o),t==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&Sp(l.text,i),mp(l,t)&&a(l.text,l.startPosition.row),gp(l,t)&&yp(l,a);for(let p of l.children)c(p)};return c(e.rootNode),{language:t,callables:n,callSites:r,clojureMembers:[],typeContainerMap:bp(e,t),identifierLineMap:s,identifiersByLine:Ga(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var Ip=new Set(["rust","typescript","tsx","javascript","python","clojure"]),Yv=new Set(["rust","typescript","tsx","javascript","python"]);function qr(e,t){let n=me(e,t);return!n||!Ip.has(n.language)?null:n.callables.map(r=>({name:r.name,startLine:r.startLine,endLine:r.endLine}))}function Ua(e,t){if(!Yv.has(t))return null;let n=[];for(let r of e.descendantsOfType([...pp(t)])){let i=tr(r,t);i&&n.push({name:i.name,startLine:i.startLine,endLine:i.endLine})}return n}function Qv(e,t){let n=me(e,t);return!n||!Ip.has(n.language)?null:n.callSites}function Zv(e,t){return me(e,t)?.typeContainerMap??new Map}import{createRequire as tI}from"module";var eI=new Set(["children","className","data","e","err","error","ev","event","false","id","idx","index","item","key","null","props","res","result","state","style","true","undefined","val","value"]);function ho(e){return e.length<=2||eI.has(e)}function So(e,t){return e.split(t).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}var nI=Mt("vue-template-facts"),rI=tI(import.meta.url),iI;function Wr(){return iI??=rI("@vue/compiler-dom")}var oI=new Set(["component","keep-alive","slot","suspense","teleport","template","transition","transition-group"]),sI=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]),aI=new Set(["div","span","template"]),cI=new Set(["as","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","from","function","if","import","in","instanceof","let","new","null","of","return","super","switch","this","throw","true","try","typeof","undefined","var","void","while","with","yield"]);function bo(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n);return nI.get(e,n,r,()=>lI(n,Zn(e,n).template))}function lI(e,t){let n={relativePath:e,template:t?{startLine:t.startLine,endLine:t.endLine}:null,componentTags:[],nativeTags:[],builtinTags:[],props:[],events:[],directives:[],slots:[],expressionIdentifiers:[],structuralTokens:[]};if(!t)return n;let r;try{r=Wr().parse(t.body,{comments:!1})}catch{return n}let i=new Set,o=s=>{s.trim()&&i.add(s)};return Pp(r.children,t.startLine,n,o),n.structuralTokens=[...i].sort(),n}function Pp(e,t,n,r){for(let i of e)if(i.type===Wr().NodeTypes.ELEMENT)uI(i,t,n,r),Pp(i.children,t,n,r);else if(i.type===Wr().NodeTypes.INTERPOLATION){r("interpolation");let o=Ka(i.content);o&&Rp(o,t,i.loc.start.line,n,r)}}function uI(e,t,n,r){let i=hI(e.tag),o={tag:e.tag,normalized:i,kind:yI(e),startLine:nr(t,e.loc.start.line),endLine:nr(t,e.loc.end.line)};o.kind==="component"?(n.componentTags.push(o),r(`component:${i}`)):o.kind==="builtin"?(n.builtinTags.push(o),r(`builtin:${i}`)):(n.nativeTags.push(o),aI.has(e.tag)||r(`native:${e.tag}`));for(let s of e.props)dI(s,t,n,r)}function dI(e,t,n,r){if(e.type===Wr().NodeTypes.ATTRIBUTE){let a=e.value?.content??null,c=Ep("prop",e.name,a,t,e.loc.start.line,e.loc.end.line);n.props.push(c),r(`prop:${e.name}`);return}let i=fI(e),o=Ka(e.exp),s=Ep(pI(e.name),i,o,t,e.loc.start.line,e.loc.end.line);switch(s.kind){case"prop":n.props.push(s),r(`prop:${i}`);break;case"event":n.events.push(s),r(`event:${i}`);break;case"slot":n.slots.push(s),r(`slot:${i}`);break;case"directive":n.directives.push(s),r(`directive:${i}`);break}o&&Rp(o,t,e.loc.start.line,n,r)}function Ep(e,t,n,r,i,o){return{kind:e,name:t,value:n,startLine:nr(r,i),endLine:nr(r,o)}}function pI(e){switch(e){case"bind":case"model":return"prop";case"on":return"event";case"slot":return"slot";default:return"directive"}}function fI(e){let t=Ka(e.arg);return t||e.name}function Ka(e){if(!e)return null;let t=("content"in e&&typeof e.content=="string"?e.content:e.loc.source).trim();return t||null}function Rp(e,t,n,r,i){for(let o of mI(e)){let s={name:o,startLine:nr(t,n),endLine:nr(t,n)};r.expressionIdentifiers.push(s),i(`id:${o}`)}}function mI(e){let t=new Set,n=gI(e),r=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,i;for(;i=r.exec(n);){let o=i[0];cI.has(o)||ho(o)||/^[A-Z_]+$/.test(o)||t.add(o)}return[...t].sort()}function gI(e){return e.replace(/\/\*[\s\S]*?\*\//g," ").replace(/\/\/.*$/gm," ").replace(/`(?:\\[\s\S]|\$\{([^}]*)\}|[^`\\])*`/g,(t,n)=>n??" ").replace(/'(?:\\[\s\S]|[^'\\])*'/g," ").replace(/"(?:\\[\s\S]|[^"\\])*"/g," ")}function yI(e){let t=e.tag;return e.tagType===Wr().ElementTypes.COMPONENT?"component":oI.has(t)?"builtin":sI.has(t)?"native":/^[A-Z]/.test(t)||t.includes("-")?"component":"native"}function hI(e){return So(e,/[-_:]/)}function nr(e,t){return e+Math.max(0,t-1)}var SI=new Set(["ref","shallowRef","reactive","computed","watch","watchEffect"]),bI=new Set(["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured"]),xI=new Set(["axios","fetch","runRequest","useAsyncData","useFetch","useResource"]),vI=new Set(["defineEmits","defineExpose","defineModel","defineOptions","defineProps","withDefaults"]),II=new Set(["catch","for","function","if","return","switch","while"]);function vo(e){let t={imports:[],functions:[],calls:[],composables:[],stores:[],reactivity:[],lifecycle:[],requests:[],macros:[],lineCount:0,externalLineCount:0,externalScriptPaths:[],unresolvedScripts:[]};for(let n of e.scripts){t.lineCount+=vn(n),n.external&&(t.externalLineCount+=vn(n),t.externalScriptPaths.push(n.sourcePath));for(let i of n.errors)t.unresolvedScripts.push({sourcePath:n.sourcePath,reason:i});if(!n.body||!n.astLanguage){n.astLanguage||t.unresolvedScripts.push({sourcePath:n.sourcePath,reason:`Unsupported Vue script language: ${n.lang??"unknown"}`});continue}t.imports.push(...CI(n));let r=xn(n.astLanguage,n.body);r?PI(n,r.rootNode,t):RI(n,t)}return EI(t),t.externalScriptPaths=wp(t.externalScriptPaths),t}function EI(e){e.composables=rr(e,"composable"),e.stores=rr(e,"store"),e.reactivity=rr(e,"reactivity"),e.lifecycle=rr(e,"lifecycle"),e.requests=rr(e,"request"),e.macros=rr(e,"macro")}function rr(e,t){return wp(e.calls.filter(n=>n.categories.includes(t)).map(n=>n.name))}function PI(e,t,n){let r=new Set,i=new Set,o=s=>{let a=tr(s,e.astLanguage);if(a){let l=`${a.name}:${a.startLine}:${a.endLine}`;i.has(l)||(i.add(l),n.functions.push({name:a.name,sourcePath:e.sourcePath,startLine:e.startLine+a.startLine,endLine:e.startLine+a.endLine,setup:e.setup}))}let c=er(s,e.astLanguage);if(c){let l=`${c.calleeLeaf}:${c.line}`;r.has(l)||(r.add(l),n.calls.push({name:c.calleeLeaf,sourcePath:e.sourcePath,line:e.startLine+c.line,categories:Cp(c.calleeLeaf),setup:e.setup}))}for(let l of s.children)o(l)};o(t)}function RI(e,t){for(let n of e.body.matchAll(/\b([A-Za-z_$][\w$]*)\s*\(/g)){let r=n[1];!r||II.has(r)||t.calls.push({name:r,sourcePath:e.sourcePath,line:e.startLine+xo(e.body,n.index??0),categories:Cp(r),setup:e.setup})}for(let n of e.body.matchAll(/\bfunction\s+([A-Za-z_$][\w$]*)\b/g)){let r=n[1];if(!r)continue;let i=e.startLine+xo(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}for(let n of e.body.matchAll(/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:async\s*)?(?:function\b|\([^)]*\)\s*=>|[A-Za-z_$][\w$]*\s*=>)/g)){let r=n[1];if(!r)continue;let i=e.startLine+xo(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}}function CI(e){let t=[];for(let n of e.body.matchAll(/\bimport\s+(?:type\s+)?([^'";]+?)\s+from\s+['"]([^'"]+)['"]/g)){let r=n[1]?.trim(),i=n[2];if(!r||!i)continue;let o=e.startLine+xo(e.body,n.index??0);for(let s of wI(r))t.push({local:s,source:i,sourcePath:e.sourcePath,line:o,setup:e.setup})}return t}function wI(e){let t=[],r=e.split(",").map(s=>s.trim()).filter(Boolean)[0];r&&!r.startsWith("{")&&!r.startsWith("*")&&t.push(r);let i=/\{([^}]*)\}/.exec(e)?.[1];if(i)for(let s of i.split(",")){let a=s.trim();if(!a)continue;let c=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(a)?.[1];t.push(c??a.replace(/^type\s+/,"").trim())}let o=/\*\s+as\s+([A-Za-z_$][\w$]*)/.exec(e)?.[1];return o&&t.push(o),t.filter(s=>/^[A-Za-z_$][\w$]*$/.test(s))}function Cp(e){let t=["call"];return/^use[A-Z0-9_]/.test(e)&&t.push("composable"),/^use[A-Z0-9_].*Store$/.test(e)&&t.push("store"),SI.has(e)&&t.push("reactivity"),bI.has(e)&&t.push("lifecycle"),xI.has(e)&&t.push("request"),vI.has(e)&&t.push("macro"),t}function xo(e,t){let n=0;for(let r=0;r<t&&r<e.length;r+=1)e.charCodeAt(r)===10&&(n+=1);return n}function wp(e){return[...new Set(e)].sort()}var FI=new Set(["in","key","of"]),TI=new Set(["computed","defineEmits","defineProps","reactive","ref","watch","watchEffect"]),kI=Mt("vue-component-behavior-profiles");function Fp(e,t={}){let n=Me(e,{extensions:[".vue"]}).filter(i=>!t.scope||i.includes(t.scope)).sort();return(typeof t.scanLimit=="number"&&t.scanLimit>0?n.slice(0,t.scanLimit):n).map(i=>Ja(e,i)).filter(i=>(t.minTemplateTokens===void 0||i.templateTokens.size>=t.minTemplateTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function Ja(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n),i=kI.get(e,n,r,()=>NI(e,n,r));return LI(i)}function NI(e,t,n){let r=Zn(e,t),i=bo(e,t),o=vo(r),s=OI(i),a=i.expressionIdentifiers.map(m=>m.name).filter(m=>!s.includes(m)).filter((m,S,h)=>h.indexOf(m)===S).sort(),c=i.componentTags.map(m=>m.normalized).filter((m,S,h)=>h.indexOf(m)===S).sort(),l=n?n.split(`
112
- `).length:0,u=vn(r.template),d=o.lineCount,p=r.styles.reduce((m,S)=>m+vn(S),0),f=r.customBlocks.reduce((m,S)=>m+vn(S),0),{lines:g,paths:y}=_I(e,t,o);return{file:t,sfc:r,templateFacts:i,scriptFacts:o,templateTokens:new Set(i.structuralTokens),behaviorTokens:AI(i,o,a),templateBindingNames:a,templateLocalNames:s,componentNames:c,sfcLines:l,totalLines:l+o.externalLineCount,templateLines:u,scriptLines:d,styleLines:p,externalScriptLines:o.externalLineCount,externalScriptPaths:o.externalScriptPaths,customBlockLines:f,delegatedComposableLines:g,delegatedComposablePaths:y}}function _I(e,t,n){let r=new Set;for(let s of n.composables){let a=n.imports.find(l=>l.local===s);if(!a)continue;let c=rt(e,a.sourcePath,a.source);!c||c===t||r.add(c)}let i=[...r].sort();return{lines:i.reduce((s,a)=>{let c=F(e,a);return s+(c?c.split(`
113
- `).length:0)},0),paths:i}}function LI(e){let t=DI(e.scriptFacts);return{...e,scriptFacts:t,templateTokens:new Set(e.templateTokens),behaviorTokens:new Set(e.behaviorTokens),templateBindingNames:[...e.templateBindingNames],templateLocalNames:[...e.templateLocalNames],componentNames:[...e.componentNames],externalScriptPaths:t.externalScriptPaths,delegatedComposablePaths:[...e.delegatedComposablePaths]}}function DI(e){return{...e,imports:e.imports.map(t=>({...t})),functions:e.functions.map(t=>({...t})),calls:e.calls.map(t=>({...t,categories:[...t.categories]})),composables:[...e.composables],stores:[...e.stores],reactivity:[...e.reactivity],lifecycle:[...e.lifecycle],requests:[...e.requests],macros:[...e.macros],externalScriptPaths:[...e.externalScriptPaths],unresolvedScripts:e.unresolvedScripts.map(t=>({...t}))}}function AI(e,t,n){let r=new Set;for(let i of t.composables)r.add(`composable:${i}`);for(let i of t.stores)r.add(`store:${i}`);for(let i of t.reactivity)r.add(`reactivity:${i}`);for(let i of t.lifecycle)r.add(`lifecycle:${i}`);for(let i of t.requests)r.add(`request:${i}`);for(let i of t.macros)r.add(`macro:${i}`);for(let i of t.functions){if(TI.has(i.name))continue;r.add(`function:${i.name}`);let o=/^[a-z]+/.exec(i.name)?.[0]??null;o&&o.length>2&&o!==i.name&&r.add(`function-verb:${o}`)}for(let i of e.events)r.add(`template-event:${i.name}`);for(let i of n)r.add(`template-binding:${i}`);return r}function OI(e){let t=new Set;for(let n of e.directives)if(n.name==="for"&&n.value)for(let r of MI(n.value))t.add(r);for(let n of e.slots)if(n.value)for(let r of Tp(n.value))t.add(r);return[...t].sort()}function MI(e){let t=/^(.*?)\s+(?:in|of)\s+/.exec(e.trim());return t?Tp(t[1]??""):[]}function Tp(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];FI.has(r)||t.push(r)}return t}import{extname as jI}from"path";var BI=[".tsx",".jsx"],kp=new Set(["useActionState","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useOptimistic","useReducer","useRef","useState","useSyncExternalStore","useTransition"]),$I=new Set(["useEffect","useInsertionEffect","useLayoutEffect"]),GI=new Set(["useActionState","useOptimistic","useReducer","useRef","useState"]),VI=new Set(["useLocation","useNavigate","useParams","useSearchParams","useTranslation"]),qI=new Set(["axios","fetch","gql","graphql","mutate","query","request","useMutation","useQuery","useSuspenseQuery"]),WI=new Set(["add","apply","cancel","change","clear","close","create","delete","fetch","filter","handle","load","open","refresh","remove","render","reset","save","select","submit","toggle","update"]),HI=new Set(["aria-hidden","className","clipRule","d","fill","fillRule","height","role","stroke","strokeLinecap","strokeLinejoin","strokeWidth","style","viewBox","width","xmlns"]),zI=Mt("react-component-behavior-profiles"),Np=we({kind:"react-component-behavior-profiles",invalidation:pe("react-component-behavior-profiles"),serialize:XI,deserialize:YI});function Ap(e,t={}){let n=Me(e,{extensions:BI}).filter(i=>!t.scope||i.includes(t.scope)).sort();return(typeof t.scanLimit=="number"&&t.scanLimit>0?n.slice(0,t.scanLimit):n).flatMap(i=>Ya(e,i)).filter(i=>(t.minJsxTokens===void 0||i.jsxTokens.size>=t.minJsxTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function Ya(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n);return zI.get(e,n,r,()=>UI(e,n,r)).map(JI)}function UI(e,t,n){let r=De(e,t,n),i=Np.read(e,t,r);if(i)return i;let o=KI(e,t);return Np.write(e,t,r,o),o}function KI(e,t){let n=ZI(t);if(!n)return[];let r=O(e,t);if(!r)return[];let i=Dr(e,t).length;return eE(r.rootNode,n).filter(s=>s.kind==="hook"||Qa(s.bodyNode)).map(s=>{let a=aE(s.bodyNode),c=pE(s.bodyNode,n);return{file:t,name:s.name,kind:s.kind,startLine:s.node.startPosition.row,endLine:s.node.endPosition.row,loc:Math.max(1,s.node.endPosition.row-s.node.startPosition.row+1),fileLines:i,jsxTokens:a.tokens,behaviorTokens:c.tokens,componentNames:It(a.componentNames),nativeTags:It(a.nativeTags),propNames:It(a.propNames),eventNames:It(a.eventNames),hookNames:It(c.hookNames),requestNames:It(c.requestNames),stateNames:It(c.stateNames),effectNames:It(c.effectNames),handlerNames:It(c.handlerNames)}})}function JI(e){return{...e,jsxTokens:new Set(e.jsxTokens),behaviorTokens:new Set(e.behaviorTokens),componentNames:[...e.componentNames],nativeTags:[...e.nativeTags],propNames:[...e.propNames],eventNames:[...e.eventNames],hookNames:[...e.hookNames],requestNames:[...e.requestNames],stateNames:[...e.stateNames],effectNames:[...e.effectNames],handlerNames:[...e.handlerNames]}}function XI(e){return JSON.stringify(e.map(t=>({...t,jsxTokens:[...t.jsxTokens],behaviorTokens:[...t.behaviorTokens]})))}function YI(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=[];for(let r of t){let i=QI(r);if(!i)return null;n.push(i)}return n}catch{return null}}function QI(e){if(!Vt(e))return null;let{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:c,behaviorTokens:l,componentNames:u,nativeTags:d,propNames:p,eventNames:f,hookNames:g,requestNames:y,stateNames:m,effectNames:S,handlerNames:h}=e;if(typeof t!="string"||typeof n!="string"||r!=="component"&&r!=="hook"||!Io(i)||!Io(o)||!Io(s)||!Io(a))return null;let x={jsxTokens:Be(c),behaviorTokens:Be(l),componentNames:Be(u),nativeTags:Be(d),propNames:Be(p),eventNames:Be(f),hookNames:Be(g),requestNames:Be(y),stateNames:Be(m),effectNames:Be(S),handlerNames:Be(h)};return Object.values(x).some(P=>P===null)?null:{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:new Set(x.jsxTokens),behaviorTokens:new Set(x.behaviorTokens),componentNames:x.componentNames,nativeTags:x.nativeTags,propNames:x.propNames,eventNames:x.eventNames,hookNames:x.hookNames,requestNames:x.requestNames,stateNames:x.stateNames,effectNames:x.effectNames,handlerNames:x.handlerNames}}function Io(e){return typeof e=="number"&&Number.isFinite(e)}function ZI(e){let t=jI(e).toLowerCase();return t!==".tsx"&&t!==".jsx"?null:oe(e)}function eE(e,t){let n=[],r=new Set,i=o=>{let s=tE(o);if(s&&(!oE(o)||s.kind==="component")){let a=`${s.name}:${s.node.startIndex}:${s.node.endIndex}`;r.has(a)||(r.add(a),n.push(s))}for(let a of o.namedChildren)i(a)};return(t==="tsx"||t==="javascript")&&i(e),n}function tE(e){if(e.type==="class_declaration"){let o=Xa(e);if(!o||!/^[A-Z]/.test(o))return null;let s=nE(e);return!s||!rE(e)&&!Qa(s)?null:{name:o,kind:"component",node:e,bodyNode:s}}if(e.type==="function_declaration"){let o=Xa(e);return!o||!_p(o)?null:{name:o,kind:Lp(o),node:e,bodyNode:e}}if(e.type!=="variable_declarator")return null;let t=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1),r=Hr(t);if(!r||!n||!_p(r))return null;let i=iE(n);return i?{name:r,kind:Lp(r),node:e,bodyNode:i}:null}function nE(e){for(let t of e.namedChildren)if(t.type==="class_body")for(let n of t.namedChildren){if(n.type!=="method_definition")continue;if((n.childForFieldName("name")??n.namedChild(0))?.text==="render")return n}return null}function rE(e){return/\b(?:React\.)?(?:Pure)?Component\b/.test(e.text)}function _p(e){return/^[A-Z]/.test(e)||/^use[A-Z0-9_]/.test(e)}function Lp(e){return/^use[A-Z0-9_]/.test(e)?"hook":"component"}function iE(e){if(e.type==="arrow_function"||e.type==="function_expression")return e;if(e.type!=="call_expression")return null;let t=sE(e);return t!=="memo"&&t!=="forwardRef"?null:e.namedChildren.find(i=>i.type==="arguments")?.namedChildren.find(i=>i.type==="arrow_function"||i.type==="function_expression")??null}function oE(e){let t=e.parent;for(;t;){if(t.type==="function_declaration"||t.type==="function_expression"||t.type==="arrow_function"||t.type==="method_definition")return!0;t=t.parent}return!1}function Xa(e){return Hr(e.childForFieldName("name")??e.namedChild(0))}function sE(e){let t=e.childForFieldName("function")??e.namedChild(0);return t?t.text.split(".").pop()??t.text:null}function Qa(e){return e.type.startsWith("jsx_")?!0:e.namedChildren.some(Qa)}function aE(e){let t={tokens:new Set,componentNames:new Set,nativeTags:new Set,propNames:new Set,eventNames:new Set},n=r=>{r.type==="jsx_opening_element"||r.type==="jsx_self_closing_element"?cE(r,t):r.type==="jsx_element"&&r.text.trimStart().startsWith("<>")?t.tokens.add("jsx:fragment"):r.type==="jsx_expression"?lE(r,t):r.type==="jsx_fragment"&&t.tokens.add("jsx:fragment");for(let i of r.children)n(i)};return n(e),t}function cE(e,t){let n=uE(e),r=!1;if(n){let i=Dp(n),o=i==="Fragment"||i==="React.Fragment";r=hE(i)&&!o,o?t.tokens.add("jsx:fragment"):r?(t.componentNames.add(i),t.tokens.add(`component:${i}`)):(t.nativeTags.add(i),t.tokens.add(`native:${i}`))}for(let i of e.namedChildren)if(i.type==="jsx_attribute"){let o=dE(i);if(!o)continue;let s=Dp(o);if(s.startsWith("on")&&s.length>2){let a=s.slice(2).replace(/^[A-Z]/,c=>c.toLowerCase());t.eventNames.add(a),t.tokens.add(`event:${a}`)}else HI.has(s)||(t.propNames.add(s),t.tokens.add(`${r?"prop":"native-prop"}:${s}`))}else i.type==="jsx_spread_attribute"&&t.tokens.add(Op(i))}function lE(e,t){let n=e.text;/^\{\s*\.\.\./.test(n)&&t.tokens.add(Op(e)),Mp(e)&&t.tokens.add("jsx:conditional"),(n.includes(".map(")||n.includes(".flatMap("))&&t.tokens.add("jsx:list");for(let r of SE(n))ho(r)||t.tokens.add(`binding:${r}`)}function Op(e){let t=/^\{\s*\.\.\.\s*([^}]+)\s*\}$/.exec(e.text)?.[1],n=e.namedChildren.find(o=>o.type!=="comment"),r=t??n?.text??"",i=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.exec(r.trim())?.[0];return i?`prop:spread:${i}`:"prop:spread"}function Mp(e){return e.type==="ternary_expression"||e.type==="conditional_expression"?!0:e.namedChildren.some(Mp)}function uE(e){for(let t of e.namedChildren)if(t.type==="identifier"||t.type==="jsx_identifier"||t.type==="property_identifier"||t.type==="member_expression"||t.type==="jsx_member_expression")return t.text;return/^<\s*([A-Za-z][\w$.]*)/.exec(e.text)?.[1]??null}function dE(e){for(let t of e.namedChildren)if(t.type==="property_identifier"||t.type==="identifier"||t.type==="jsx_identifier")return t.text;return/^([A-Za-z_$][\w$:-]*)/.exec(e.text)?.[1]??null}function pE(e,t){let n={tokens:new Set,hookNames:new Set,requestNames:new Set,stateNames:new Set,effectNames:new Set,handlerNames:new Set},r=i=>{if(i.type==="call_expression"){let o=er(i,t);o&&fE(o.calleeLeaf,n)}else if(i.type==="variable_declarator")gE(i,n);else if(i.type==="function_declaration"){let o=Xa(i);o&&jp(o,n)}for(let o of i.namedChildren)r(o)};return r(e),n}function fE(e,t){/^use[A-Z0-9_]/.test(e)&&(t.hookNames.add(e),!kp.has(e)&&!VI.has(e)&&t.tokens.add(`hook:${e}`)),kp.has(e)&&t.tokens.add(`react-hook:${e}`),$I.has(e)&&(t.effectNames.add(e),t.tokens.add(`effect:${e}`)),GI.has(e)&&t.tokens.add(`state-hook:${e}`),mE(e)&&(t.requestNames.add(e),t.tokens.add(`request:${e}`))}function mE(e){if(qI.has(e))return!0;let t=/^use([A-Z0-9_].*)$/.exec(e)?.[1];return t?/(Query|Mutation|Fetch|Resource)$/.test(t):!1}function gE(e,t){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(n?.type==="array_pattern"&&r?.text.includes("useState")){let o=n.namedChildren.find(a=>Hr(a)),s=Hr(o);s&&(t.stateNames.add(s),t.tokens.add(`state:${s}`))}let i=Hr(n);i&&jp(i,t)}function jp(e,t){let n=yE(e);!n||!WI.has(n)||(t.handlerNames.add(e),t.tokens.add(`handler:${e}`),t.tokens.add(`handler-verb:${n}`))}function yE(e){let t=e.startsWith("handle")&&e.length>6?e.slice(6).replace(/^[A-Z]/,n=>n.toLowerCase()):e;return/^[a-z]+/.exec(t)?.[0]??null}function hE(e){return/^[A-Z]/.test(e)||e.includes(".")}function Dp(e){return e.replace(/^this\./,"").replace(/\$/g,".")}function Hr(e){return e&&(e.type==="identifier"||e.type==="property_identifier"||e.type==="shorthand_property_identifier"||/^[A-Za-z_$][\w$]*$/.test(e.text))?e.text:null}function SE(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];t.includes(r)||t.push(r)}return t}function It(e){return[...e].sort()}function DM(e){return{capability:(t,n)=>bE(t,n),reactProfiles:(t={})=>Ap(e,t),reactProfilesForFile:t=>Ya(e,t),vueProfiles:(t={})=>Fp(e,t),vueProfileForFile:t=>Ja(e,t),vueTemplateFacts:t=>bo(e,t),vueScriptFacts:t=>vo(Zn(e,t))}}function bE(e,t){let n=e.startsWith("react-")?"react":"vue";if(t===void 0)return{slot:e,available:!0,framework:n};let r=t.replace(/\\/g,"/").toLowerCase();return n==="react"&&!r.endsWith(".tsx")&&!r.endsWith(".jsx")?{slot:e,available:!1,framework:n,reason:"React behavior profiles are only available for .tsx and .jsx files"}:n==="vue"&&!r.endsWith(".vue")?{slot:e,available:!1,framework:n,reason:"Vue behavior facts are only available for .vue files"}:{slot:e,available:!0,framework:n}}function xE(e,t,n={}){let r=me(e,t);if(!r)return[];let i=[];if(n.includeCrossLanguageDispatchNames)for(let o of r.crossLanguageDispatchNames)i.push({name:o,kind:"cross-language-dispatch",occurrences:1});if(n.includeRustAttributeNames&&r.language==="rust")for(let o of r.rustAttrReferencedNames)i.push({name:o,kind:"rust-attribute",occurrences:1});return i}var vE=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function Ee(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&n++,(o==="}"||o==="]"||o===")")&&n--,o===","&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function ke(e,t){for(let n of e.namedChildren)if(n.type===t)return n;return null}function K(e,t){let n=new Set,r=(i,o)=>{let s=o||t.has(i.type);!s&&vE.has(i.type)&&n.add(i.text);for(let a of i.children)r(a,s)};return r(e.rootNode,!1),n}function Je(e,t,n,r,i,o,s){return{importedName:i,localName:o,sourcePath:s??U(e,r,Fa(t)),kind:"named",used:Ie(n,o),usedMembers:[]}}function W(e,t,n,r,i="named",o={}){return{importedName:e,localName:t,sourcePath:n,kind:i,used:r.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function Et(e,t,n,r,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:n,kind:i,used:r,usedMembers:o,isTypeOnly:s.isTypeOnly}}function En(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function Pn(e,t,n={}){return{importedName:e,localName:n.localName??null,sourcePath:t,kind:"namespace",used:n.used??!0,usedMembers:n.usedMembers??[],isTypeOnly:n.isTypeOnly}}function qe(e,t,n){let r=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=Wt(e,i.index,i.index+o.length);for(let a of n(i,s))r.push(a)}return r}function We(e,t,n,r,i){let o=In(e,t,i)?.tree??null;if(o){let s=n(o);if(s)return s}return r()}function Eo(e,t,n,r,i){let o=In(e,t,i)?.tree??null,s=oe(t),a=s?n[s]:void 0;return o&&a?a(o):r()}function $p(e,t,n){return We(e,t,r=>EE(e,t,r),()=>IE(e,t,n),n)}function IE(e,t,n){return qe(n,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(r,i)=>{let o=r[1]?.trim();if(!o)return[];let s=Bp(o).replace(/\.[^.]+$/,"");return[Et(o,s,uo(e,t,o),Ie(i,s))]})}function EE(e,t,n){let r=K(n,new Set(["preproc_include"])),i=[];for(let o of n.rootNode.descendantsOfType("preproc_include")){let s=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){s=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){s=c.namedChildren.find(u=>u.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=Bp(s).replace(/\.[^.]+$/,"");i.push(W(s,a,uo(e,t,s),r))}return i}var PE=new Set([":require",":require-macros",":use"]),tc=String.raw`A-Za-z0-9_$*+!?.<>=-`;function Vp(e,t,n){let r=AE(n);if(!r)return[];let i=DE(n,r.start,r.end),o=[];for(let s of r.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=He(s.children[0]);if(a){if(PE.has(a)){for(let c of wE(s.children.slice(1)))o.push(...CE(e,c,i));continue}if(a===":import")for(let c of TE(s.children.slice(1)))o.push(c)}}return o}function RE(e){return e.type==="list"&&He(e.children[0])==="ns"}function CE(e,t,n){let r=Ta(e,t.namespace),i=t.alias??t.namespace,o=NE(n,i),s=[{importedName:t.namespace,localName:i,sourcePath:r,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||_E(n,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:r,kind:"named",used:LE(n,a),usedMembers:[]});return s}function wE(e){return e.flatMap(t=>Po(t,null))}function Po(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:ec(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&He(e.children[0])===null?e.children.flatMap(n=>Po(n,t)):FE(e,t);if(e.type==="list"&&e.children.length>0){let n=He(e.children[0]);return n?!n||n.startsWith(":")?[]:e.children.slice(1).flatMap(r=>Po(r,ec(t,n))):e.children.flatMap(r=>Po(r,t))}return[]}function FE(e,t){let n=He(e.children[0]);if(!n||n.startsWith(":"))return[];let r={namespace:ec(t,n),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=He(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){r.alias=He(s),i+=1;continue}o===":refer"&&s&&(He(s)===":all"?r.referAll=!0:(s.type==="vector"||s.type==="list")&&r.refers.push(...s.children.map(He).filter(kE)),i+=1)}return[r]}function TE(e){let t=[];for(let n of e){if(n.type==="atom"){let i=n.text.split(".").pop()??n.text;t.push(Et(i,i,null,!0));continue}if(n.type!=="vector")continue;let r=He(n.children[0]);if(r)for(let i of n.children.slice(1)){let o=He(i);o&&t.push(Et(`${r}.${o}`,o,null,!0))}}return t}function ec(e,t){return e?`${e}.${t}`:t}function He(e){return e?.type==="atom"?e.text:null}function kE(e){return!!(e&&!e.startsWith(":"))}function NE(e,t){let n=new Set,r=new RegExp(`${nc()}${ie(t)}\\s*/\\s*([${tc}]+)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function _E(e,t){return new RegExp(`${nc()}${ie(t)}\\s*/`,"m").test(e)}function LE(e,t){return new RegExp(`${nc()}${ie(t)}(?![${tc}])`,"m").test(e)}function nc(){return`(?<![${tc}])`}function DE(e,t,n){let r="",i=0;for(;i<e.length;){if(i>=t&&i<n){r+=e[i]===`
114
- `?`
115
- `:" ",i+=1;continue}let o=e[i];if(o===";"){let s=yo(e,i);r+=Gp(e.slice(i,s)),i=s;continue}if(o==='"'){let s=Vr(e,i,0).index;r+=Gp(e.slice(i,s)),i=s;continue}r+=o,i+=1}return r}function AE(e){let t=0;for(;t<e.length&&(t=rc(e,t),!(t>=e.length));){let n=Ro(e,t);if(!n){t+=1;continue}if(RE(n.form))return n.form;t=n.index}return null}function Ro(e,t){let n=rc(e,t);if(e.startsWith("#?@",n)||e.startsWith("#?",n))return OE(e,n);if(e.startsWith("#_",n)){let i=Ro(e,n+2);return i?{form:{type:"atom",text:"",start:n,end:i.index},index:i.index}:null}for(;qa(e[n]);)n+=1;let r=e[n];return r?r==="("?Za(e,n,"list",")"):r==="["?Za(e,n,"vector","]"):r==="{"?Za(e,n,"map","}"):r==='"'?{form:{type:"atom",text:"",start:n,end:Vr(e,n,0).index},index:Vr(e,n,0).index}:jE(e,n):null}function OE(e,t){let n=e.startsWith("#?@",t)?3:2,r=Ro(e,t+n);return r?{form:{type:"list",children:r.form.type==="list"||r.form.type==="vector"||r.form.type==="map"?ME(r.form.children):[],start:t,end:r.index},index:r.index}:null}function ME(e){let t=[];for(let n=0;n<e.length;n+=2){let r=He(e[n]),i=e[n+1];r?.startsWith(":")&&i&&t.push(i)}return t}function Za(e,t,n,r){let i=[],o=t+1;for(;o<e.length;){if(o=rc(e,o),e[o]===r)return{form:{type:n,children:i,start:t,end:o+1},index:o+1};let s=Ro(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:n,children:i,start:t,end:e.length},index:e.length}}function jE(e,t){let n=t;for(;n<e.length&&!Wa(e[n]);)n+=1;return{form:{type:"atom",text:e.slice(t,n),start:t,end:n},index:n}}function rc(e,t){let n=t;for(;n<e.length;){let r=e[n];if(/\s|,/.test(r)){n+=1;continue}if(r===";"){n=yo(e,n);continue}break}return n}function Gp(e){return e.replace(/[^\r\n]/g," ")}function qp(e,t,n){let r=[];for(let i of n.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),s=i[2]?.trim()??null,a=i[0];if(!o||!a||typeof i.index!="number")continue;let c=Wt(n,i.index,i.index+a.length);r.push({importedName:o,localName:s,sourcePath:po(e,t,o),kind:s?"namespace":"side-effect",used:s?Ie(c,s):!0,usedMembers:s?Yn(c,s):[]})}return r}function Wp(e,t,n){let r=[];for(let i of n.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&r.push({specifier:o,sourcePath:po(e,t,o)})}return r}function Hp(e,t,n){return Eo(e,t,{csharp:r=>$E(e,t,r),vb:r=>BE(e,t,r)},()=>{let r=Ud(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return qe(n,r,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,u=(l?c:a)?.trim()??s,d=u.split(".").pop()??u,p=l?a?.trim()??d:d;return[Je(e,t,o,u,d,p,U(e,u,Gt))]})},n)}function BE(e,t,n){let r=K(n,new Set(["imports_statement"])),i=[];for(let o of n.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(p=>p.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,u=l.split(".").pop()??l,d=c?.text??u;i.push(W(u,d,U(e,l,Gt),r,c?"namespace":"named"))}return i}function $E(e,t,n){let r=K(n,new Set(["using_directive"])),i=[];for(let o of n.rootNode.descendantsOfType("using_directive")){let s=o.namedChildren;if(s.length===0)continue;let a=null,c;s.length>=2&&s[0].type==="identifier"&&(s[1].type==="qualified_name"||s[1].type==="identifier")?(a=s[0],c=s[1]):c=s[s.length-1];let l=c.text,u=l.split(".").pop()??l,d=a?.text??u;i.push(W(u,d,U(e,l,Gt),r,a?"namespace":"named"))}return i}var GE=w("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function zp(e,t){return GE.get(e,t,()=>{let n=new Set,r=F(e,t);if(!r)return n;let o=r.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,s=>s.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,s=>s.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,s=>s.replace(/[^\r\n]/g," "));for(let s of o.matchAll(/[A-Za-z_$][\w$]*/g))n.add(s[0]);return n})}function ic(e,t,n){return We(e,t,r=>qE(e,t,r),()=>VE(e,t,n),n)}function VE(e,t,n){return eP(n).flatMap(r=>tP(e,t,r.clause,r.specifier,r.start,r.end,n))}function qE(e,t,n){let r=WE(e,t,n),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))i.push(...HE(e,t,n,o,r));return i}function WE(e,t,n){let r=K(n,new Set(["import_statement"]));if(it(t))for(let i of zp(e,t))r.add(i);return r}function HE(e,t,n,r,i){let o=XE(r);if(!o)return[];let s=rt(e,t,o),a=ke(r,"import_clause");return a?zE(n,a,s,i,YE(r.text)):[En("*",s)]}function zE(e,t,n,r,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(UE(s.text,n,r,i));else if(s.type==="namespace_import"){let a=KE(e,s,n,r,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...JE(s,n,r,i));return o}function UE(e,t,n,r){return W("default",e,t,n,"default",{isTypeOnly:r})}function KE(e,t,n,r,i){let s=ke(t,"identifier")?.text??"";if(!s)return null;let a=ZE(e,s);return Pn("*",n,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||r.has(s)})}function JE(e,t,n,r){let i=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let s=o.namedChild(0),a=o.namedChild(1);if(!s)continue;let c=s.text,l=a?.text??c;i.push(W(c,l,t,n,"named",{isTypeOnly:r||QE(o.text)}))}return i}function XE(e){let t=ke(e,"string");if(!t)return null;let n=ke(t,"string_fragment");return n?n.text:null}function YE(e){return/^\s*import\s+type\b/.test(e)}function QE(e){return/^\s*type\b/.test(e.trim())}function ZE(e,t){let n=new Set;for(let r of e.rootNode.descendantsOfType("member_expression")){let i=r.namedChild(0),o=r.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&n.add(o.text)}return[...n]}function eP(e){let t=[],n=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){let o=i[0],s=i[1],a=i[2];!o||!a||typeof i.index!="number"||t.push({clause:s,specifier:a,start:i.index,end:i.index+o.length})}let r=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){let o=i[0],s=i[1];!o||!s||typeof i.index!="number"||t.push({clause:null,specifier:s,start:i.index,end:i.index+o.length})}return t.sort((i,o)=>i.start-o.start)}function tP(e,t,n,r,i,o,s){let a=rt(e,t,r),c=Wt(s,i,o);return n?nP(n).map(u=>({...u,sourcePath:a})).map(u=>{if(u.kind==="namespace"){let d=Yn(c,u.localName);return Pn(u.importedName,u.sourcePath,{localName:u.localName,usedMembers:d,used:d.length>0||Ie(c,u.localName),isTypeOnly:u.isTypeOnly})}return u.kind==="side-effect"?En(u.importedName,u.sourcePath):Et(u.importedName,u.localName??"",u.sourcePath,u.localName?Ie(c,u.localName):!1,u.kind,[],{isTypeOnly:u.isTypeOnly})}):[En("*",a)]}function nP(e){let t=e.trim(),n=/^type\b/.test(t),r=t.replace(/^type\s+/,""),[i,o]=rP(r),s=[];return i&&s.push(...Up(i,n)),o&&s.push(...Up(o,n)),s}function Up(e,t){let n=e.trim();if(!n)return[];if(n.startsWith("{")){let r=n.slice(1,-1).trim();return r?Ee(r).map(i=>{let o=i.trim(),s=t||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,l]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(l??c).trim(),kind:"named",isTypeOnly:s}}):[]}return n.startsWith("* as ")?[{importedName:"*",localName:n.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:n,kind:"default",isTypeOnly:t}]}function rP(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r==="{"&&t++,r==="}"&&t--,r===","&&t===0)return[e.slice(0,n).trim(),e.slice(n+1).trim()]}return[e.trim(),null]}function oc(e,t,n){let r=O(e,t);return r?lP(e,t,r):iP(e,t,n)}function iP(e,t,n){return[...oP(e,t,n),...sP(e,t,n),...aP(e,t,n)]}function oP(e,t,n){let r=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=Ee(s).map(d=>cP(d.trim())).filter(d=>!!d),l=ir(n,o.index),u=ir(n,o.index+o[0].length-1);r.push({kind:"named",sourcePath:rt(e,t,a),names:c,startLine:l,endLine:u})}return r}function sP(e,t,n){let r=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=ir(n,o.index),c=ir(n,o.index+o[0].length-1);r.push({kind:"star-as",sourcePath:rt(e,t,s),names:o[1]?[o[1]]:[],startLine:a,endLine:c})}return r}function aP(e,t,n){let r=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=ir(n,o.index),c=ir(n,o.index+o[0].length-1);r.push({kind:"star",sourcePath:rt(e,t,s),names:[],startLine:a,endLine:c})}return r}function cP(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let n=t.match(/^(\w+)\s+as\s+(\w+)$/);if(n)return n[2]??null;let r=t.match(/^(\w+)$/);return r?r[1]??null:null}function ir(e,t){let n=0;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function lP(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("export_statement")){let o=uP(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=dP(i,o,s,a);r.push(c)}return r}function uP(e,t,n){let r=ke(n,"string");if(!r)return;let i=ke(r,"string_fragment");if(i)return rt(e,t,i.text)}function dP(e,t,n,r){let i=ke(e,"export_clause");if(i){let s=[];for(let a of i.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),l=a.namedChild(1);c&&s.push((l??c).text)}return{kind:"named",sourcePath:t,names:s,startLine:n,endLine:r}}let o=ke(e,"namespace_export");if(o){let s=o.namedChildren.find(a=>a.type==="identifier"||a.type==="type_identifier")?.text;return{kind:"star-as",sourcePath:t,names:s?[s]:[],startLine:n,endLine:r}}return{kind:"star",sourcePath:t,names:[],startLine:n,endLine:r}}function Kp(e,t,n){return Eo(e,t,{java:r=>pP(e,t,r),kotlin:r=>fP(e,t,r),scala:r=>mP(e,t,r)},()=>qe(n,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(r,i)=>{let o=r[1]?.trim();return o?gP(e,t,o,i):[]}),n)}function pP(e,t,n){let r=K(n,new Set(["import_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(d=>d.type==="asterisk"),c=o.namedChildren.find(d=>d.type==="scoped_identifier")??o.namedChildren.find(d=>d.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(Pn("*",U(e,l,Te)));continue}let u=l.split(".").pop()??l;i.push(W(u,u,U(e,l,Te),r))}return i}function fP(e,t,n){let r=K(n,new Set(["import_header","import_list"])),i=[];for(let o of n.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(f=>f.type==="identifier");if(!s)continue;let a=o.namedChildren.some(f=>f.type==="wildcard_import"),c=o.namedChildren.find(f=>f.type==="import_alias");if(a){i.push(Pn("*",U(e,s.text,Te)));continue}let l=s.text,u=l.split(".").pop()??l,p=c?.namedChild(0)?.text??u;i.push(W(u,p,U(e,l,Te),r))}return i}function mP(e,t,n){let r=K(n,new Set(["import_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(d=>d.type==="namespace_selectors"||d.type==="namespace_wildcard"),a=o.namedChildren.filter(d=>d!==s&&(d.type==="identifier"||d.type==="stable_identifier")),c=a.map(d=>d.text).join(".");if(!c)continue;if(s?.type==="namespace_wildcard"){i.push(Pn("*",U(e,c,Te)));continue}if(s?.type==="namespace_selectors"){for(let d of s.namedChildren)if(d.type==="arrow_renamed_identifier"){let[p,f]=d.namedChildren;if(!p)continue;let g=p.text,y=f?.text??g;if(g==="_")continue;i.push(W(g,y,U(e,`${c}.${g}`,Te),r))}else if(d.type==="identifier"){let p=d.text;i.push(W(p,p,U(e,`${c}.${p}`,Te),r))}continue}let l=a[a.length-1]?.text??c,u=a.slice(0,-1).map(d=>d.text).join(".")||c;i.push(W(l,l,U(e,u&&a.length>1?`${u}.${l}`:c,Te),r))}return i}function gP(e,t,n,r){if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/\.$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return Ee(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),u=c?.trim();if(!u||u==="_")return[];let d=(l??u.split(".").pop()??u).trim(),p=u==="_"?i:`${i}.${u}`.replace(/\.\./g,".");return[Je(e,t,r,p,u,d)]})}return[Je(e,t,r,n,n.split(".").pop()??n,n.split(".").pop()??n)]}function Xp(e,t,n){return We(e,t,r=>yP(e,t,r),()=>qe(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?Ee(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),u=c?.trim()??a,d=u.split("\\").pop()??u,p=(l??d).trim();return[Je(e,t,i,u,d,p,U(e,u.replace(/\\/g,"."),bn))]}):[]}),n)}function yP(e,t,n){let r=K(n,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(W(a,c,U(e,s.replace(/\\/g,"."),bn),r))};for(let s of n.rootNode.descendantsOfType("namespace_use_declaration")){let a=s.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=s.namedChildren.find(l=>l.type==="namespace_name")?.text??"";for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:u,localName:d,qualified:p}=Jp(l,c);u&&o(p,u,d)}continue}for(let c of s.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:u,qualified:d}=Jp(c,"");l&&o(d,l,u)}}return i}function Jp(e,t){let n=e.namedChildren.find(l=>l.type==="qualified_name"),r=e.namedChildren.filter(l=>l.type==="name"),i="";n?i=n.text:r.length>=1&&(i=r[0].text);let o=n&&r.length>0?r[r.length-1]:null,s=i.split("\\").pop()??i,a=o?.text??s,c=t?`${t}\\${i}`:i;return{importedName:s,localName:a,qualified:c}}function Qp(e,t,n){return We(e,t,r=>hP(e,t,r),()=>bP(n).flatMap(r=>vP(e,t,r,n)),n)}function hP(e,t,n){let r=K(n,new Set(["import_statement","import_from_statement"])),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=Yp(s);if(!a)continue;let c=Xn(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:r.has(a.localName),usedMembers:[]})}for(let o of n.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=SP(s);if(a===null)continue;let c=Xn(e,t,a);for(let l=1;l<o.namedChildCount;l+=1){let u=o.namedChild(l);if(u.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let d=Yp(u);d&&i.push({importedName:d.qualifiedName,localName:d.localName,sourcePath:c,kind:"named",used:r.has(d.localName),usedMembers:[]})}}return i}function Yp(e){if(e.type==="aliased_import"){let t=e.namedChild(0),n=e.namedChild(1);return!t||!n?null:{qualifiedName:t.text,localName:n.text}}if(e.type==="dotted_name"){let t=e.text;return{qualifiedName:t,localName:t.split(".")[0]??t}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function SP(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=ke(e,"import_prefix")?.text??"",n=ke(e,"dotted_name")?.text??"";return`${t}${n}`}return null}function bP(e){let t=e.split(`
116
- `),n=[],r=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=r;if(r+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,u=Aa(o);for(;i+1<t.length&&(u>0||c.trimEnd().endsWith("\\"));){i++;let p=t[i];c+=`
117
- ${p}`,l+=1+p.length,u+=Aa(p),r+=p.length+1}let d=xP(c);d&&n.push({...d,start:a,end:l})}return n}function xP(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let n=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!n)return null;let r=n[2].trim();return r.startsWith("(")&&r.endsWith(")")&&(r=r.slice(1,-1).trim()),{kind:"from",module:n[1],clause:r}}function vP(e,t,n,r){let i=Wt(r,n.start,n.end),o=n.clause.replace(/\n/g," ").trim();if(n.kind==="import")return Ee(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[u,d]=l.split(/\s+as\s+/),p=u.trim(),f=(d??p.split(".")[0]??p).trim(),g=Xn(e,t,p),y=Yn(i,f);return[{importedName:p,localName:f,sourcePath:g,kind:"namespace",used:Ie(i,f)||y.length>0,usedMembers:y}]});let s=n.module?Xn(e,t,n.module):null,a=[];for(let c of Ee(o)){let l=c.trim().replace(/,$/,"");if(!l)continue;if(l==="*"){a.push({importedName:"*",localName:null,sourcePath:s,kind:"side-effect",used:!0,usedMembers:[]});continue}let[u,d]=l.split(/\s+as\s+/),p=(d??u).trim();a.push({importedName:u.trim(),localName:p,sourcePath:s,kind:"named",used:Ie(i,p),usedMembers:[]})}return a}import{basename as IP}from"path";function Zp(e,t,n){return We(e,t,r=>PP(e,t,r),()=>EP(e,t,n),n)}function EP(e,t,n){return qe(n,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(r,i)=>{let o=r[1],s=r[2];if(!o||!s)return[];let a=o==="require_relative"?lo(e,t,s):null;if(a){let c=ef(s);return[Et(c,c,a,Ie(i,c))]}return[En(s,a)]})}function PP(e,t,n){let r=K(n,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of n.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=s.namedChildren.find(f=>f.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let d=l.namedChildren.find(f=>f.type==="string_content")?.text;if(!d)continue;let p=a.text==="require_relative"?lo(e,t,d):null;if(p){let f=ef(d);i.push(W(f,f,p,r))}else i.push(En(d,p))}return i}function ef(e){return So(IP(e).replace(/\.[^.]+$/,""),/_/)}function tf(e,t,n){return We(e,t,r=>RP(e,t,r),()=>qe(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?CP(e,t,o,i):[]}),n)}function RP(e,t,n){let r=K(n,new Set(["use_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of zr(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=bt(e,t,a.qualifiedName)??bt(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(W(a.importedName,a.localName,c,r))}}return i}function zr(e,t){switch(e.type){case"identifier":case"super":case"crate":{let n=e.text;return[{qualifiedName:Co(t,n),importedName:n,localName:n}]}case"self":{let n=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:n,localName:n}]}case"scoped_identifier":{let n=e.text,r=n.split("::").pop()??n;return[{qualifiedName:Co(t,n),importedName:r,localName:r}]}case"scoped_use_list":{let n=e.namedChild(0),r=e.namedChild(1);if(!n||!r)return[];let i=Co(t,n.text),o=[];for(let s of r.namedChildren)o.push(...zr(s,i));return o}case"use_list":{let n=[];for(let r of e.namedChildren)n.push(...zr(r,t));return n}case"use_as_clause":{let n=e.namedChild(0),r=e.namedChild(1);if(!n||!r)return[];let i=zr(n,t),o=r.text;return i.map(s=>({...s,localName:o}))}case"use_wildcard":{let n=e.namedChild(0),r=n?n.text:"";return[{qualifiedName:Co(t,`${r}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Co(e,t){return e?t?`${e}::${t}`:e:t}function CP(e,t,n,r){let i=n.trim();if(i.includes("{")&&i.includes("}")){let u=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),d=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return Ee(d).flatMap(p=>{let f=p.trim();if(!f)return[];if(f==="self"){let x=u.split("::").filter(Boolean).pop();return x?[Je(e,t,r,u,x,x)]:[]}let[g,y]=f.split(/\s+as\s+/),m=g?.trim();if(!m)return[];let S=(y??m.split("::").pop()??m).trim(),h=`${u}::${m}`.replace(/::::/g,"::");return[Je(e,t,r,h,m.split("::").pop()??m,S,bt(e,t,u))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=bt(e,t,a)??bt(e,t,a.split("::").slice(0,-1).join("::"));return[Je(e,t,r,a,a.split("::").pop()??a,c,l)]}function nf(e,t,n){let r=O(e,t);if(r)return wP(e,t,r);let i=[];for(let o of n.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...TP(e,t,s))}return i}function wP(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("use_declaration")){if(!FP(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of zr(o,""))s.importedName&&r.push(sc(e,t,s.qualifiedName))}return r}function FP(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function TP(e,t,n){let r=n.trim();if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/::$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return Ee(o).flatMap(s=>{let a=s.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),l=`${i}::${c?.trim()??a}`.replace(/::::/g,"::");return[sc(e,t,l)]})}return[sc(e,t,r)]}function sc(e,t,n){return{specifier:n,sourcePath:bt(e,t,n)??bt(e,t,n.split("::").slice(0,-1).join("::"))}}function zt({language:e,extensions:t,imports:n,parseImports:r}){return{language:e,extensions:t,capabilities:{imports:n},parseImports:r}}function rf(e,t){let n=t.toLowerCase();for(let r of e)for(let i of r.extensions)if(n.endsWith(i))return r;return null}var kP={language:"javascript",extensions:hn,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:ic,parseReExports:oc},NP=zt({language:"python",extensions:io,imports:"ast-with-regex-fallback",parseImports:Qp}),_P=zt({language:"jvm",extensions:Te,imports:"ast-dispatch-with-regex-fallback",parseImports:Kp}),LP={language:"rust",extensions:oo,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:tf,parseExports:nf},DP=zt({language:"ruby",extensions:so,imports:"ast-with-regex-fallback",parseImports:Zp}),AP=zt({language:"c/cpp",extensions:ao,imports:"ast-with-regex-fallback",parseImports:$p}),OP=zt({language:"dotnet",extensions:Gt,imports:"ast-dispatch-with-regex-fallback",parseImports:Hp}),MP={language:"dart",extensions:co,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:qp,parseExports:Wp},jP=zt({language:"php",extensions:bn,imports:"ast-with-regex-fallback",parseImports:Xp}),BP=zt({language:"clojure",extensions:Jn,imports:"regex-only",parseImports:Vp}),of=[kP,NP,_P,LP,DP,AP,OP,MP,jP,BP];function Ur(e){return rf(of,e)}function uB(e){return of.find(n=>n.language===e)?.capabilities??null}var ac={clearGroups:["whole-project","source-file"]},$P=w("source-imports",ac),GP=w("source-exports",ac),VP=w("source-reexports",ac),sf=we({kind:"source-imports",invalidation:pe("source-imports"),serialize:qP,deserialize:WP}),af=we({kind:"source-reexports",invalidation:pe("source-reexports"),serialize:HP,deserialize:zP});function Pt(e,t){let n=Z(t);return VP.get(e,n,()=>{let r=Ur(n);if(!r?.parseReExports)return[];let i=F(e,n);if(!i)return[];let o=De(e,n,i),s=_a(e),a=af.read(e,n,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=r.parseReExports(e,n,i);return af.write(e,n,o,{resolutionFingerprint:s,reExports:c}),c})}function ae(e,t){let n=Z(t);return $P.get(e,n,()=>{let r=Ur(n);if(!r)return[];let i=F(e,n);return i?cf(e,n,i,r):[]})}function cc(e,t){let n=Z(t),r=Ur(n);if(!r)return[];let i;try{i=Lr(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(o){if($t(o))return[];throw o}return cf(e,n,i,r)}function cf(e,t,n,r){let i=De(e,t,n),o=_a(e),s=sf.read(e,t,i);if(s?.resolutionFingerprint===o)return s.imports;let a=r.parseImports(e,t,n);return sf.write(e,t,i,{parserVersion:2,resolutionFingerprint:o,imports:a}),a}function xB(e,t,n){let r=ae(e,t).filter(i=>i.kind==="named"&&i.isTypeOnly!==!0&&i.localName===n&&i.sourcePath!==null);return r.length===1?r[0]:null}function vB(e,t){let n=Z(t);return GP.get(e,n,()=>{let r=Ur(n);if(!r?.parseExports)return[];let i=F(e,n);return i?r.parseExports(e,n,i):[]})}function qP(e){return JSON.stringify(e)}function WP(e){try{let t=JSON.parse(e);return!Vt(t)||t.parserVersion!==2||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{parserVersion:2,resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function HP(e){return JSON.stringify(e)}function zP(e){try{let t=JSON.parse(e);return!Vt(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}var wo=Dd({kind:"file-dependency-graph",invalidation:pe("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:QP}),UP=w("file-dep-graph",{clearGroups:["whole-project"]});function TB(e,t,n){if(n.length===0)return[];let r=new Set(n),i=or(e),o=new Set;if(t==="forward")for(let s of r)for(let a of i.get(s)??[])r.has(a)||o.add(a);else for(let[s,a]of i)if(!r.has(s))for(let c of r)a.has(c)&&o.add(s);return[...o].sort()}function or(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",o=Jr(t,r,i);return UP.get(e,o,()=>{let s=new Set(ve(e,{includeIgnored:!1})),a=gt(e),c=0,l=0,u=null,d=!1,p=0,f=0,g=null;return z("file-dep-graph.product",()=>{if(a){let h=wo.read(e,o,a);if(h){d=!0,g=h.construction;let x=uf(h);return c=h.sourceFileCount,l=h.sourceEdgeCount,p=h.scipEdgeCount,f=x.size,u=h.sourceDependencyFingerprint,x}}let y=i==="none"?{files:[],edges:[],fingerprint:H("no-source-dependency-fallback")}:z("file-dep-graph.source-imports",()=>{let h=XP(e,s,t,i);return c=h.files.length,l=h.edges.length,u=h.fingerprint,h},()=>({scope:t??null,sourceEdges:i,files:c,edges:l})),m=new Map,S=(h,x)=>Kr(e,m,s,h,x);z("file-dep-graph.scip-edges",()=>{for(let h of tR(e,t,r))p=(p??0)+1,S(h.from_file,h.to_file)},()=>({scope:t??null,edges:p}));for(let h of y.edges)S(h.fromFile,h.toFile);return f=m.size,a&&(g="full",wo.write(e,o,a,{version:2,construction:"full",sourceDependencyFingerprint:y.fingerprint,sourceFileCount:y.files.length,sourceEdgeCount:y.edges.length,scipEdgeCount:p,edgeCount:df(m),graph:lf(m)})),m},()=>({scope:t??null,available:a!==null,hit:d,construction:g,files:c,sourceEdges:l,sourceEdgeMode:i,scipEdges:p,graphFiles:f,sourceDependencyFingerprint:u}))})}function kB(e){return KP(e,"none")}function NB(e,t="imports-only"){let n=Jr(void 0,"all-references",t),r=gt(e);if(!r)return null;let i=wo.read(e,n,r);return i?{cacheKey:n,sourceEdges:t,graph:uf(i)}:null}function KP(e,t){let n=Jr(void 0,"all-references",t),r=or(e,void 0,{sourceEdges:t});return{cacheKey:n,sourceEdges:t,graph:r}}function _B(e,t,n,r){let i=t.sourceEdges??"imports-only",o=gt(e);if(!o)return!1;let s=r??JP(e,t,n);if(!s)return!1;let a=new Set(ve(e,{includeIgnored:!1})),c=Jr(void 0,"all-references",i);return wo.write(e,c,o,{version:2,construction:"carried",sourceDependencyFingerprint:null,sourceFileCount:a.size,sourceEdgeCount:null,scipEdgeCount:null,edgeCount:df(s),graph:lf(s)}),!0}function JP(e,t,n,r=[]){let i=t.sourceEdges??"imports-only",o=Jr(void 0,"all-references",i);if(t.cacheKey!==o)return null;let s=z("file-dep-graph.carry.indexed-files",()=>new Set(ve(e,{includeIgnored:!1}))),a=new Set(n),c=new Map;z("file-dep-graph.carry.reuse",()=>{if(r.length===0)for(let[u,d]of t.graph)a.has(u)||c.set(u,d);else for(let[u,d]of t.graph)if(!(a.has(u)||!s.has(u)))for(let p of d)Kr(e,c,s,u,p)});let l=z("file-dep-graph.carry.scip-edges",()=>nR(e,a,"all-references"));for(let u of l)Kr(e,c,s,u.from_file,u.to_file);return z("file-dep-graph.carry.source-edges",()=>{for(let u of a)if(s.has(u)){if(i!=="none")for(let d of cc(e,u))d.sourcePath&&Kr(e,c,s,u,d.sourcePath);if(i==="imports-and-reexports")for(let d of Pt(e,u))d.sourcePath&&Kr(e,c,s,u,d.sourcePath)}}),c}function XP(e,t,n,r){let i=[],o=[];for(let s of t)if(!(n&&!s.includes(n))){i.push(s);for(let a of cc(e,s))a.sourcePath&&o.push({fromFile:s,toFile:a.sourcePath});if(r==="imports-and-reexports")for(let a of Pt(e,s))a.sourcePath&&o.push({fromFile:s,toFile:a.sourcePath})}return{files:i,edges:o,fingerprint:YP(i,o)}}function YP(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return H(JSON.stringify({files:e,edges:n}))}function Jr(e,t,n){return`edge-mode-v4:${t}:${n}:${e??"<all>"}`}function lf(e){return[...e].map(([t,n])=>[t,[...n].sort()]).sort(([t],[n])=>t.localeCompare(n))}function uf(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function QP(e){let t=JSON.parse(e);return ZP(t)?t:null}function ZP(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===2&&(t.construction==="full"||t.construction==="carried")&&(t.sourceDependencyFingerprint===null||typeof t.sourceDependencyFingerprint=="string")&&typeof t.sourceFileCount=="number"&&(t.sourceEdgeCount===null||typeof t.sourceEdgeCount=="number")&&(t.scipEdgeCount===null||typeof t.scipEdgeCount=="number")&&typeof t.edgeCount=="number"&&Array.isArray(t.graph)&&t.graph.every(eR)}function df(e){let t=0;for(let n of e.values())t+=n.size;return t}function eR(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function tR(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],o=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
118
- d1.relative_path AS from_file,
119
- d2.relative_path AS to_file
120
- FROM mentions m
121
- JOIN chunks c ON m.chunk_id = c.id
122
- JOIN documents d1 ON c.document_id = d1.id
123
- JOIN global_symbols gs ON m.symbol_id = gs.id
124
- JOIN (
125
- SELECT m2.symbol_id, c2.document_id
126
- FROM mentions m2
127
- JOIN chunks c2 ON m2.chunk_id = c2.id
128
- WHERE m2.role = 1
129
- GROUP BY m2.symbol_id
130
- ) sym_def ON sym_def.symbol_id = gs.id
131
- JOIN documents d2 ON sym_def.document_id = d2.id
132
- WHERE d1.id != d2.id
133
- ${o}
134
- ${e.pathExclusionsFor("d1","d2")}
135
- ${r}`,...i)}function nR(e,t,n){let r=[...t].sort();if(r.length===0)return[];let i=n==="imports-only"?"AND m.role = 2":"AND m.role != 1",o=[];for(let s=0;s<r.length;s+=500){let a=r.slice(s,s+500),c=a.map(()=>"?").join(", ");o.push(...e.all(`SELECT DISTINCT
136
- d1.relative_path AS from_file,
137
- d2.relative_path AS to_file
138
- FROM documents d1
139
- CROSS JOIN chunks c
140
- CROSS JOIN mentions m
141
- CROSS JOIN global_symbols gs
142
- CROSS JOIN chunks c2
143
- CROSS JOIN documents d2
144
- WHERE d1.relative_path IN (${c})
145
- AND c.document_id = d1.id
146
- AND m.chunk_id = c.id
147
- AND gs.id = m.symbol_id
148
- AND c2.id = (
149
- SELECT m2.chunk_id
150
- FROM mentions m2
151
- WHERE m2.symbol_id = gs.id AND m2.role = 1
152
- ORDER BY m2.chunk_id
153
- LIMIT 1
154
- )
155
- AND d2.id = c2.document_id
156
- AND d1.id != d2.id
157
- ${i}
158
- ${e.pathExclusionsFor("d1","d2")}`,...a))}return o}function Kr(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let o=t.get(r);o||(o=new Set,t.set(r,o)),o.add(i)}var rR={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function Xe(e){if(e.startsWith("local "))return{kind:"local",id:e.slice(6),raw:e};let t=e.split(" ");if(t.length<4)return{scheme:t[0]??"",manager:t[1]??"",packageName:t[2]??"",version:"",descriptors:[],raw:e};let n=t[0],r=t[1],i=e.slice(n.length+1+r.length+1),o;if(i.startsWith("`")){let l=i.indexOf("`",1);l===-1?(o=i.slice(1),i=""):(o=i.slice(1,l),i=i.slice(l+2))}else{let l=i.indexOf(" ");l===-1?(o=i,i=""):(o=i.slice(0,l),i=i.slice(l+1))}let s,a=i.indexOf(" ");a===-1?(s=i,i=""):(s=i.slice(0,a),i=i.slice(a+1));let c=iR(i);return{scheme:n,manager:r,packageName:o,version:s,descriptors:c,raw:e}}function ge(e){let t=Xe(e);if("kind"in t)return null;for(let n=t.descriptors.length-2;n>=0;n--){let r=t.descriptors[n];if(r?.suffix==="type")return r.name}return null}function iR(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="["){let o=e.indexOf("]",n+1);if(o===-1){t.push({name:e.slice(n+1),suffix:"type-param"});break}t.push({name:e.slice(n+1,o),suffix:"type-param"}),n=o+1;continue}if(e[n]==="("&&(t.length===0||n===0||pf(e[n-1]))){let o=e.indexOf(")",n+1);if(o!==-1&&e[o+1]!=="."){t.push({name:e.slice(n+1,o),suffix:"parameter"}),n=o+1;continue}}let r;if(e[n]==="`"){let o=e.indexOf("`",n+1);if(o===-1){r=e.slice(n+1),t.push({name:r,suffix:"term"});break}r=e.slice(n+1,o),n=o+1}else{let o=n;for(;n<e.length&&!pf(e[n]);)n++;r=e.slice(o,n)}if(n>=e.length){r&&t.push({name:r,suffix:"term"});break}let i=e[n];if(i==="("){let o=e.indexOf(")",n+1);o!==-1&&e[o+1]==="."?(t.push({name:r,suffix:"method"}),n=o+2):o!==-1?(t.push({name:r,suffix:"method"}),n=o+1):(t.push({name:r,suffix:"term"}),n++)}else{let o=rR[i];o&&t.push({name:r,suffix:o}),n+=1}}return t}function pf(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function Ut(e){let t=Xe(e);if("kind"in t&&t.kind==="local")return`local:${t.id}`;let n=t;if(n.descriptors.length===0)return n.raw;let r=[];for(let i of n.descriptors){let o=oR(i);o&&r.push(o)}return r.join(":")}function oR(e){let t=e.suffix==="namespace"?sR(e.name):e.name;return t?e.suffix==="method"?`${t}()`:t:""}function sR(e){return e.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/,"").replace(/\.(py|pyi)$/,"").replace(/\.(rs)$/,"").replace(/\.(java|scala|kt|kts)$/,"").replace(/\.(rb)$/,"").replace(/\.(go)$/,"").replace(/\.(cs|vb)$/,"").replace(/\.(dart)$/,"").replace(/\.(php)$/,"").replace(/\.(c|cc|cpp|cxx|h|hpp)$/,"")}function ye(e){let t=Xe(e);if("kind"in t&&t.kind==="local")return t.id;let n=t;return n.descriptors.length===0?"":n.descriptors[n.descriptors.length-1].name}function Rn(e){let t=Xe(e);if("kind"in t&&t.kind==="local")return null;let n=t;return n.descriptors[n.descriptors.length-1]?.suffix??null}function lc(e){return e.endsWith("().")||Rn(e)==="method"}function sr(e){let t=Rn(e);return t==="method"?!0:t!=="term"?!1:e.endsWith("().")?!0:e.startsWith("rust-analyzer ")&&e.includes("#")?!1:e.startsWith("scip-typescript ")?!/#[A-Za-z0-9_$]+\.$/.test(e):!0}function ff(e){return Rn(e)==="namespace"}var aR=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function DB(e){return aR.test(e)}var cR=new Set(["test","tests","_tests"]);function AB(e){let t=Xe(e);if("kind"in t)return!1;for(let n=0;n<t.descriptors.length-1;n+=1){let r=t.descriptors[n];if(r?.suffix==="namespace"&&r.name&&cR.has(r.name))return!0}return!1}function OB(e,t){let n=Xe(e),r=Xe(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,o=r.descriptors;if(o.length!==i.length+1)return!1;for(let s=0;s<i.length;s++){let a=i[s],c=o[s];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}function MB(e,t){let n=Xe(e),r=Xe(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,o=r.descriptors;if(o.length<=i.length)return!1;for(let s=0;s<i.length;s++){let a=i[s],c=o[s];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}function Fo(e){return{forFile(t,n){return mf(e,t,n)},forFiles(t,n){let r=new Map;for(let i of t)r.set(i,mf(e,i,n));return r}}}function mf(e,t,n){let r={file:t},i=n.facts||n.identifiers;if(n.text&&(r.text=F(e,t)),n.lines&&(r.lines=Dr(e,t)),n.ast&&(r.ast=O(e,t)),n.imports&&(r.imports=ae(e,t)),n.reexports&&(r.reexports=Pt(e,t)),i){let o=za(e,t),s=o.facts;n.facts&&(r.facts=s),o.unavailable&&(r.sourceFactsUnavailable=o.unavailable),n.identifiers&&s&&(r.identifiers=s.fileIdentifiers,r.identifierLineMap=s.identifierLineMap)}return r}function Kt(e,t){return e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.start_char, der.end_line, der.end_char, d.relative_path, gs.display_name, gs.documentation
159
- FROM global_symbols gs
160
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
161
- JOIN documents d ON der.document_id = d.id
162
- WHERE ${t.where}
163
- ${e.pathExclusionsFor("d")}
164
- ${yf(t.orderBy)}
165
- ${hf(t.limit)}`,...t.params??[])}function Cn(e,t){return e.all(`SELECT
166
- gs.id,
167
- gs.symbol,
168
- c.document_id,
169
- MIN(c.start_line) AS start_line,
170
- 0 AS start_char,
171
- MAX(c.end_line) AS end_line,
172
- 0 AS end_char,
173
- d.relative_path,
174
- gs.display_name,
175
- gs.documentation
176
- FROM global_symbols gs
177
- JOIN mentions m ON m.symbol_id = gs.id
178
- JOIN chunks c ON m.chunk_id = c.id
179
- JOIN documents d ON c.document_id = d.id
180
- WHERE m.role = 1
181
- AND ${t.where}
182
- ${e.pathExclusionsFor("d")}
183
- GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation
184
- ${yf(t.orderBy)}
185
- ${hf(t.limit)}`,...t.params??[])}function yf(e){return e?`ORDER BY ${e}`:""}function hf(e){return typeof e=="number"?`LIMIT ${e}`:""}function uc(e){return!e||!e.trim()?null: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()||null}function dc(e){if(!e)return null;let t=gf(e);if(t)return t.replace(/\n/g," ");let n=e.indexOf("|");if(n===-1)return e.replace(/\n/g," ");let r=e.slice(n+1);return(gf(r)??r).replace(/\n/g," ")}function gf(e){return/^```(?:\w+)?\s*\n?([\s\S]*?)\n?```/.exec(e.trimStart())?.[1]?.trim()||null}function lR(e,t={}){if(ge(e.symbol)!==null)return t.includeClassMemberFallbacks===!0;let i=(e.documentation??"").replace(/^```\w*\s*/,"").replace(/\s*```$/,"").trim();return/^(?:var|let|const|function|class|interface|type|enum)\b/.test(i)}function Rt(e,t,n={}){let r=new Map;for(let o of t)e.length>0&&!lR(o,{includeClassMemberFallbacks:n.includeClassMemberFallbacks})||r.set(o.id,o);for(let o of e)r.set(o.id,o);let i=[...r.values()];return n.sort?i.sort((o,s)=>o.start_line-s.start_line||o.end_line-s.end_line||o.symbol.localeCompare(s.symbol)):i}function a0(e){let t=new Map;for(let n of e){if(!n.leaf)continue;let r=t.get(n.leaf)??[];r.push(n),t.set(n.leaf,r)}return t}var uR=w("file-definitions",{clearGroups:["definition-catalog"]}),dR=Ze("scoped-matched-definitions",{clearGroups:["definition-catalog"]}),pR=w("file-function-like-definitions",{clearGroups:["definition-catalog"]}),Sf=new WeakMap;function B(e,t,n={},r){return n.includeClassMemberFallbacks?pc(e,t,void 0,{includeClassMemberFallbacks:!0},r):uR.get(e,t,()=>{let i=ot(r,"evidence-read",()=>If(e,t));if(i)return i;let o=pc(e,t,void 0,n,r);return ot(r,"evidence-write",()=>{let s=gt(e),a=Fo(e).forFile(t,{text:!0}).text;s&&a&&vf.write(e,t,De(e,t,a),{projectFingerprint:s,definitions:o.map(c=>({...c}))})}),o})}function fR(e,t){return pR.get(e,t,()=>{let n=If(e,t);return n?n.filter(r=>r.isFunctionLike):pc(e,t,r=>r.isFunctionLike)})}var vf=we({kind:"file-definitions",invalidation:pe("file-definitions"),serialize:mR,deserialize:gR});function If(e,t){let n=gt(e);if(!n)return null;let r=Fo(e).forFile(t,{text:!0}).text;if(!r)return null;let i=vf.read(e,t,De(e,t,r));return i?yR(i,n,t):null}function mR(e){return JSON.stringify(e)}function gR(e){try{let t=JSON.parse(e);return!Vt(t)||typeof t.projectFingerprint!="string"||!Array.isArray(t.definitions)?null:{projectFingerprint:t.projectFingerprint,definitions:t.definitions}}catch{return null}}function yR(e,t,n){if(e.projectFingerprint!==t)return null;let r=[];for(let i of e.definitions){let o=hR(i,n);if(!o)return null;r.push(o)}return r}function hR(e,t){return!Vt(e)||typeof e.symbolId!="number"||typeof e.symbol!="string"||typeof e.documentId!="number"||typeof e.startLine!="number"||typeof e.startChar!="number"&&e.startChar!==void 0||typeof e.endLine!="number"||typeof e.endChar!="number"&&e.endChar!==void 0||e.relativePath!==t||typeof e.leaf!="string"||typeof e.parentTypeName!="string"&&e.parentTypeName!==null||typeof e.isFunctionLike!="boolean"||typeof e.isTypeLike!="boolean"||typeof e.kind!="number"&&e.kind!==null||typeof e.documentation!="string"&&e.documentation!==null||typeof e.enclosingSymbol!="string"&&e.enclosingSymbol!==null?null:{symbolId:e.symbolId,symbol:e.symbol,documentId:e.documentId,startLine:e.startLine,startChar:e.startChar,endLine:e.endLine,endChar:e.endChar,relativePath:e.relativePath,leaf:e.leaf,parentTypeName:e.parentTypeName,isFunctionLike:e.isFunctionLike,isTypeLike:e.isTypeLike,kind:e.kind,documentation:e.documentation,enclosingSymbol:e.enclosingSymbol}}function pc(e,t,n,r={},i){let o=ot(i,"primary-rows",()=>SR(e,t)),s=ot(i,"fallback-rows",()=>bR(e,t)),a=ot(i,"merge-rows",()=>Rt(o,s,{sort:!0,includeClassMemberFallbacks:r.includeClassMemberFallbacks}).map(fc));return n&&(a=a.filter(n)),ot(i,"range-correction",()=>mc(e,t,a,i,r.rangeCorrectionEvidence))}function ot(e,t,n){return e?e(t,n):n()}function SR(e,t){return e.all(`SELECT
186
- gs.id,
187
- gs.symbol,
188
- der.document_id,
189
- der.start_line,
190
- der.start_char,
191
- der.end_line,
192
- der.end_char,
193
- d.relative_path,
194
- gs.display_name,
195
- gs.kind,
196
- gs.documentation,
197
- gs.enclosing_symbol
198
- FROM global_symbols gs
199
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
200
- JOIN documents d ON der.document_id = d.id
201
- WHERE d.relative_path = ?
202
- ${e.symbolNoiseFor("gs")}
203
- ORDER BY der.start_line, der.end_line`,t)}function bR(e,t){return e.all(`SELECT
204
- gs.id,
205
- gs.symbol,
206
- c.document_id,
207
- MIN(c.start_line) AS start_line,
208
- 0 AS start_char,
209
- MAX(c.end_line) AS end_line,
210
- 0 AS end_char,
211
- d.relative_path,
212
- gs.display_name,
213
- gs.kind,
214
- gs.documentation,
215
- gs.enclosing_symbol
216
- FROM global_symbols gs
217
- JOIN mentions m ON m.symbol_id = gs.id
218
- JOIN chunks c ON m.chunk_id = c.id
219
- JOIN documents d ON c.document_id = d.id
220
- WHERE d.relative_path = ?
221
- AND m.role = 1
222
- ${e.symbolNoiseFor("gs")}
223
- GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
224
- ORDER BY start_line, end_line`,t)}function fc(e){return{symbolId:e.id,symbol:e.symbol,documentId:e.document_id,startLine:e.start_line,startChar:e.start_char??0,endLine:e.end_line,endChar:e.end_char??0,relativePath:e.relative_path,leaf:ye(e.symbol),parentTypeName:ge(e.symbol),isFunctionLike:sr(e.symbol),isTypeLike:Rn(e.symbol)==="type",kind:e.kind??null,documentation:e.documentation??null,enclosingSymbol:e.enclosing_symbol??null}}function c0(e,t={}){return xR(e,t.scope)}function xR(e,t){return ve(e,{scope:t,includeIgnored:!1}).flatMap(n=>B(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function l0(e,t){return ve(e,{scope:t,includeIgnored:!1}).flatMap(n=>fR(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function u0(e,t){let n=dR.get(e,()=>new WeakMap),r=n.get(t.symbolMatches);r||(r=new Map,n.set(t.symbolMatches,r));let i=JSON.stringify({scope:t.scope??null,sqlPrefilter:t.sqlPrefilter??null}),o=r.get(i);if(o)return[...o];let s=bf(vR(e,t.scope,t.sqlPrefilter)),a=bf(IR(e,t.scope,t.sqlPrefilter)),c=new Set([...s.keys(),...a.keys()]),l=[];for(let u of[...c].sort()){if(e.isIgnored(u))continue;let d=Rt(s.get(u)??[],a.get(u)??[],{sort:!0}).filter(p=>t.symbolMatches(p.symbol));d.length!==0&&l.push(...mc(e,u,d.map(fc)))}return r.set(i,l),[...l]}function vR(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${Ef("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
225
- gs.id,
226
- gs.symbol,
227
- der.document_id,
228
- der.start_line,
229
- der.start_char,
230
- der.end_line,
231
- der.end_char,
232
- d.relative_path,
233
- gs.display_name,
234
- gs.kind,
235
- gs.documentation,
236
- gs.enclosing_symbol
237
- FROM global_symbols gs
238
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
239
- JOIN documents d ON der.document_id = d.id
240
- WHERE 1 = 1
241
- ${e.pathExclusionsFor("d")}
242
- ${r}
243
- ${i}
244
- ${e.symbolNoiseFor("gs")}
245
- ORDER BY d.relative_path, der.start_line, der.end_line`,...o)}function IR(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${Ef("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
246
- gs.id,
247
- gs.symbol,
248
- c.document_id,
249
- MIN(c.start_line) AS start_line,
250
- 0 AS start_char,
251
- MAX(c.end_line) AS end_line,
252
- 0 AS end_char,
253
- d.relative_path,
254
- gs.display_name,
255
- gs.kind,
256
- gs.documentation,
257
- gs.enclosing_symbol
258
- FROM global_symbols gs
259
- JOIN mentions m ON m.symbol_id = gs.id
260
- JOIN chunks c ON m.chunk_id = c.id
261
- JOIN documents d ON c.document_id = d.id
262
- WHERE m.role = 1
263
- AND NOT EXISTS (
264
- SELECT 1
265
- FROM defn_enclosing_ranges existing_der
266
- WHERE existing_der.symbol_id = gs.id
267
- )
268
- ${e.pathExclusionsFor("d")}
269
- ${r}
270
- ${i}
271
- ${e.symbolNoiseFor("gs")}
272
- GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
273
- ORDER BY d.relative_path, start_line, end_line`,...o)}function ER(e){return`(${e}.symbol LIKE '%().' OR ${e}.symbol LIKE '%()')`}function Ef(e,t){return t==="callable"?ER(e):PR(e)}function PR(e){return`(${e}.symbol LIKE '%.' OR ${e}.symbol LIKE '%()')`}function bf(e){let t=new Map;for(let n of e){let r=t.get(n.relative_path);r?r.push(n):t.set(n.relative_path,[n])}return t}function d0(e,t,n={}){if(t.length===0)return[];let r=t.flatMap(i=>B(e,i)).filter(i=>!e.isIgnored(i.relativePath));return n.onlyDocumented&&(r=r.filter(i=>i.documentation!==null&&i.documentation!=="")),n.sort&&(r=r.sort((i,o)=>i.relativePath.localeCompare(o.relativePath)||i.startLine-o.startLine||i.endLine-o.endLine)),r.map(i=>({startLine:i.startLine,endLine:i.endLine,symbol:i.symbol,shortName:Ut(i.symbol),signature:uc(dc(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function RR(e){let t=new Map,n=e.map((r,i)=>({definition:r,index:i,span:r.endLine-r.startLine})).sort((r,i)=>r.span-i.span||r.index-i.index);for(let{definition:r}of n)for(let i=r.startLine;i<=r.endLine;i+=1)t.has(i)||t.set(i,r);return t}function ar(e,t){let n=Sf.get(e);return n||(n=RR(e),Sf.set(e,n)),n.get(t)??null}function To(e,t){let n=B(e,t.relative_path).find(r=>r.symbolId===t.id)??(ge(t.symbol)===null||!sr(t.symbol)?void 0:mc(e,t.relative_path,[fc(t)])[0]);return n?{symbolId:n.symbolId,symbol:n.symbol,documentId:n.documentId,startLine:n.startLine,startChar:n.startChar,endLine:n.endLine,endChar:n.endChar,relativePath:n.relativePath}:{symbolId:t.id,symbol:t.symbol,documentId:t.document_id,startLine:t.start_line,startChar:t.start_char??0,endLine:t.end_line,endChar:t.end_char??0,relativePath:t.relative_path}}function mc(e,t,n,r,i){let o=ot(r,"range-correction.source-text",()=>i?i.source:Fo(e).forFile(t,{text:!0}).text),s=ot(r,"range-correction.callable-sites",()=>i?i.callables:qr(e,t));return s?ot(r,"range-correction.ast-correction",()=>NR(n,s,o)):o?ot(r,"range-correction.regex-fallback",()=>CR(n,o)):n}function CR(e,t){let n=t.split(/\r?\n/),r=wR(e,n),i=FR(e,r),o=TR(i,n);return kR(e,o)}function wR(e,t){let n=e.some(i=>ko(i.symbol))?jR(t):null,r=new Map;for(let i of e)r.set(i.symbolId,MR(t,n,i));return r}function FR(e,t){return e.filter(n=>ko(n.symbol)).map(n=>({definition:n,startLine:t.get(n.symbolId)??n.startLine})).sort((n,r)=>n.startLine-r.startLine||n.definition.startLine-r.definition.startLine||n.definition.symbol.localeCompare(r.definition.symbol))}function TR(e,t){let n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r],o=e[r+1],s=o?Math.max(i.startLine,o.startLine-1):t.length-1;n.set(i.definition.symbolId,{startLine:i.startLine,endLine:BR(t,i.definition,i.startLine,s)})}return n}function kR(e,t){return e.map(n=>{let r=t.get(n.symbolId);return r?{...n,startLine:r.startLine,endLine:r.endLine}:n})}function NR(e,t,n=null){let r=new Map;for(let i of t){let o=r.get(i.name);o?o.push(i):r.set(i.name,[i])}return e.map(i=>{if(!OR(i)||!i.leaf)return xf(i,n);let o=r.get(i.leaf);if(!o||o.length===0)return xf(i,n);let s=n?_R(i,o,n):null;if(s)return{...i,startLine:s.startLine,endLine:s.endLine};let a=o[0],c=Math.abs(a.startLine-i.startLine);for(let l=1;l<o.length;l+=1){let u=o[l],d=Math.abs(u.startLine-i.startLine);d<c&&(a=u,c=d)}return{...i,startLine:a.startLine,endLine:a.endLine}})}function _R(e,t,n){let r=LR(e.symbol);if(!r)return null;let i=n.split(/\r?\n/),o=new RegExp(`\\b${ie(r)}\\b`);for(let s of t){let a=DR(i,s.startLine);if(a&&o.test(a))return s}return null}function LR(e){return e.match(/\/impl#\[([^\]]+)\]/)?.[1]??null}function DR(e,t){for(let n=t;n>=0;n-=1){let r=e[n]?.trim()??"";if(r){if(/^impl\b/.test(r))return AR(e,n,t);if(/^(?:struct|enum|trait|mod)\b/.test(r))return null}}return null}function AR(e,t,n){let r=[];for(let i=t;i<=n;i+=1){let o=e[i]??"";if(r.push(o),o.includes("{"))break}return r.join(" ")}function OR(e){return ko(e.symbol)?!0:Rn(e.symbol)==="term"&&ge(e.symbol)===null}function xf(e,t){if(!t||!e.leaf||Rn(e.symbol)!=="term"||ge(e.symbol)!==null)return e;let n=ie(e.leaf),r=new RegExp(`\\b(?:export\\s+)?(?:const|let|var)\\s+${n}\\b`),o=t.split(/\r?\n/).findIndex(s=>r.test(s));return o>=0?{...e,startLine:o,endLine:o}:e}function MR(e,t,n){if(!ko(n.symbol))return n.startLine;let r=Math.max(0,Math.min(n.startLine,e.length-1));if(!t)return r;let i=t.get(n.leaf);if(!i||i.length===0)return r;let o=null;for(let s of i){let a=Math.abs(s-n.startLine);(!o||a<o.distance)&&(o={line:s,distance:a})}return o?.line??r}function jR(e){let t=/\b(?:function|def|fn)\s+([A-Za-z_$][\w$]*)/g,n=/\b([A-Za-z_$][\w$]*)\s*[:=]\s*(?:async\s*)?(?:function\b|\()/g,r=/^\s*(?:(?:export|public|private|protected|static|readonly|async|abstract|get|set)\s+)*([A-Za-z_$][\w$]*)\s*(?:<[^(]*>)?\s*\(/,i=/\b([A-Za-z_$][\w$]*)\s*\(/g,o=new Map,s=(a,c)=>{let l=o.get(a);if(!l){o.set(a,[c]);return}l[l.length-1]!==c&&l.push(c)};for(let a=0;a<e.length;a+=1){let c=e[a]??"";for(let u of c.matchAll(t))u[1]&&s(u[1],a);for(let u of c.matchAll(n))u[1]&&s(u[1],a);let l=c.match(r);l?.[1]&&s(l[1],a);for(let u of c.matchAll(i))u[1]&&s(u[1],a)}return o}function BR(e,t,n,r){let i=Math.max(n,Math.min(e.length-1,r)),o=Math.max(n,Math.min(i,t.endLine)),s=0,a=0,c=!1;for(let l=n;l<=i;l+=1){let u=$R(e[l]??"");for(let d of u)d==="{"?(s+=1,c=!0):d==="}"?s=Math.max(0,s-1):d==="("?a+=1:d===")"&&(a=Math.max(0,a-1));if(c&&s===0||!c&&a===0&&l>=o)return l}return o}function $R(e){let t="",n=null,r=!1;for(let i=0;i<e.length;i+=1){let o=e[i],s=e[i+1];if(!n&&o==="/"&&s==="/"){t+=" ".repeat(e.length-i);break}if(n){if(r){r=!1,t+=" ";continue}if(o==="\\"){r=!0,t+=" ";continue}o===n&&(n=null),t+=" ";continue}if(o==='"'||o==="'"||o==="`"){n=o,t+=" ";continue}t+=o}return t}function ko(e){return e.includes("().")}function p0(e){let t=Xe(e);if("kind"in t)return[];let n=[];for(let r=t.descriptors.length-2;r>=0;r-=1){let i=t.descriptors[r];i?.suffix==="type"&&i.name&&n.push(i.name)}return n}var GR=w("symbol-resolution",{clearGroups:[]});function v0(e,t){return VR(e,t).match}function VR(e,t){return GR.get(e,t,()=>{let n=Cf(e,t.trim()).filter(s=>!e.isIgnored(s.relative_path));if(n.length>0)return cr(e,n);let r=XR(e,t);if(r&&!e.isIgnored(r.relative_path))return cr(e,[r]);let i=qR(e,t);if(i.length>0)return cr(e,i);let o=WR(e,t);return o.length>0?cr(e,o):KR(e,t)})}function qR(e,t){let n=t.trim().replace(/\(\)$/u,""),r=n.lastIndexOf(":");if(r<=0||r===n.length-1||n.startsWith("local:"))return[];let i=n.slice(r+1);if(!/^[\p{L}_$][\p{L}\p{N}_$]*$/u.test(i))return[];let o=[`/${i}().`,`/${i}.`,`/${i}#`,`#${i}().`,`#${i}.`,`/${i}/`],s=`gs.display_name = ? OR ${o.map(()=>"instr(gs.symbol, ?) > 0").join(" OR ")}`,a=[i,...o],c=Kt(e,{where:s,params:a,orderBy:"d.relative_path, der.start_line",limit:200}),l=c.length>0?[]:Cn(e,{where:s,params:a,orderBy:"d.relative_path, start_line",limit:200}),u=Rt(c,l).filter(d=>!e.isIgnored(d.relative_path)).filter(d=>Ut(d.symbol).replace(/\(\)$/u,"")===n);return[...new Map(u.map(d=>[`${d.symbol}\0${d.relative_path}`,d])).values()]}function WR(e,t){let n=No(t),r=gc(n);if(!r)return[];let i=`%${r.path}%`,o=r.leaf;return HR(e,i,o,n)}function HR(e,t,n,r){let i=Rt([],[...zR(e,t,n),...UR(e,t,n)]).filter(o=>!e.isIgnored(o.relative_path)).filter(o=>lr(o,r)>1);return i.sort((o,s)=>lr(s,r)-lr(o,r)||o.end_line-o.start_line-(s.end_line-s.start_line)||o.start_line-s.start_line||o.symbol.localeCompare(s.symbol)),i}function zR(e,t,n){return Kt(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function UR(e,t,n){return Cn(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function KR(e,t){let n=No(t),r=nC(t),i=eC(e,r),o=rC(i,t,n).filter(a=>!e.isIgnored(a.relative_path));if(o.length>0)return cr(e,o);let s=[];for(let a of i){if(e.isIgnored(a.relative_path))continue;let c=tC(a,t,n,r);c<=0||s.push({row:a,score:c})}return s.sort((a,c)=>c.score-a.score||a.row.end_line-a.row.start_line-(c.row.end_line-c.row.start_line)||a.row.relative_path.localeCompare(c.row.relative_path)||a.row.symbol.localeCompare(c.row.symbol)),cr(e,s.map(a=>a.row))}function cr(e,t){let n=t.map(i=>To(e,i)),r=n[0]??null;return{match:r,candidates:r?JR(n,r):[],total:n.length}}function JR(e,t){let n=new Set([`${t.symbolId}:${t.relativePath}:${t.startLine}`]),r=[];for(let i of e){let o=`${i.symbolId}:${i.relativePath}:${i.startLine}`;if(!n.has(o)&&(n.add(o),r.push({symbol:i.symbol,shortName:Ut(i.symbol),relativePath:i.relativePath,startLine:i.startLine}),r.length>=5))break}return r}function XR(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/);if(!n)return;let[,r,i,o]=n,s=_d(e,r,{allowMultiple:!1,requirePathMatch:!0})[0]?.relativePath;if(!s)return;let a=Math.max(0,parseInt(i,10)-1),c=o?Math.max(a,parseInt(o,10)-1):a;return YR(e,s,a,c)??QR(e,s,a,c)}function YR(e,t,n,r){return Kt(e,{where:"d.relative_path = ? AND der.start_line <= ? AND der.end_line >= ?",params:[t,n,r],orderBy:"(der.end_line - der.start_line) ASC",limit:1})[0]}function QR(e,t,n,r){return Cn(e,{where:"d.relative_path = ? AND c.start_line <= ? AND c.end_line >= ?",params:[t,n,r],orderBy:"(MAX(c.end_line) - MIN(c.start_line)) ASC",limit:1})[0]}function I0(e,t){let n=Cf(e,t).find(r=>!e.isIgnored(r.relative_path));return n?To(e,n):null}function Cf(e,t){let n=Kt(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, der.start_line"}),r=n.length>0?[]:Cn(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, start_line"});return Rt(n,r)}function Xr(e,t){if("symbol"in t&&"relativePath"in t)return t;let n=ZR(e,t.symbolId)[0];return n?To(e,n):null}function ZR(e,t){let n=Kt(e,{where:"gs.id = ?",params:[t],orderBy:"der.start_line, der.end_line"}),r=Cn(e,{where:"gs.id = ?",params:[t],orderBy:"start_line, end_line"});return Rt(n,r)}function eC(e,t){let n=t.map(()=>"(gs.symbol LIKE ? OR d.relative_path LIKE ? OR COALESCE(gs.display_name, '') LIKE ?)"),r=t.flatMap(a=>{let c=`%${a}%`;return[c,c,c]}),i=n.join(`
274
- AND `),o=Kt(e,{where:i,params:r,limit:200}),s=Cn(e,{where:i,params:r,limit:200});return Rt(o,s)}function tC(e,t,n,r){let i=t.trim(),o=n,s=o.replace(/\(\)$/,""),a=t.toLowerCase(),c=n.toLowerCase(),l=c.replace(/\(\)$/,""),u=e.symbol,d=Ut(e.symbol),p=ye(e.symbol),f=e.display_name??"",g=e.symbol.toLowerCase(),y=d.toLowerCase(),m=p.toLowerCase(),S=f.toLowerCase(),h=e.relative_path.toLowerCase(),x=/[/:.]/.test(n),P=gc(n),I=P?.leaf.toLowerCase(),b=0;return(u===i||u===o)&&(b+=1150),(d===i||d===o)&&(b+=1100),f===s&&(b+=1180),p===s&&(b+=1160),(`${p}()`===i||`${p}()`===o)&&(b+=955),(g===a||g===c)&&(b+=1e3),(y===a||y===c)&&(b+=950),(h===a||h===c)&&(b+=925),(h.endsWith(`/${c}`)||h.endsWith(`/${a}`))&&(b+=875),S===l&&(b+=850),m===l&&(b+=825),(`${m}()`===a||`${m}()`===c)&&(b+=820),(y.endsWith(`:${c}`)||y.endsWith(`:${l}`)||y.endsWith(`:${l}()`))&&(b+=800),g.includes(c)&&(b+=120),y.includes(c)&&(b+=140),h.includes(c)&&(b+=140),S.includes(c)&&(b+=110),r.every(v=>{let C=v.toLowerCase();return g.includes(C)||y.includes(C)||h.includes(C)||S.includes(C)})&&(b+=100+r.length*15),P&&h.includes(P.path.toLowerCase())&&(b+=360,I&&(m===I||`${m}()`===I||`${m}()`==`${I}()`)&&(b+=700),lc(e.symbol)&&(b+=180)),sr(e.symbol)&&m===l&&(b+=60),!x&&ff(e.symbol)&&(b-=160),b-=Math.min(50,Math.max(0,e.end_line-e.start_line)),b}function gc(e){let t=e.trim().replace(/\\/g,"/"),n=t.lastIndexOf("/");if(n<=0||n===t.length-1)return null;let r=t.slice(n+1).replace(/\(\)$/,"");return!r||r.includes(".")?null:{path:t.slice(0,n),leaf:r}}function No(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function nC(e){let t=No(e),n=t.split(/[^A-Za-z0-9_]+/).map(r=>r.trim()).filter(r=>r.length>0);return n.length>0?[...new Set(n)]:[t]}function rC(e,t,n){let r=t.trim(),i=e.filter(a=>{let c=Ut(a.symbol),l=ye(a.symbol),u=(a.display_name??"").trim();return a.symbol===r||c===r||c===n||l===r||l===n||`${l}()`===r||u===r||u===n||`${u}()`===r||lr(a,n)>1||a.relative_path===r});if(i.length===0)return[];let o=n.replace(/\(\)$/u,""),s=i.filter(a=>ye(a.symbol)===o);if(s.length>0){s.sort((c,l)=>Pf(c,l,n));let a=s.filter(c=>sr(c.symbol));return a.length>0?a:s}return i.sort((a,c)=>Pf(a,c,n)),i}function Pf(e,t,n){return lr(t,n)-lr(e,n)||e.end_line-e.start_line-(t.end_line-t.start_line)||e.relative_path.localeCompare(t.relative_path)||e.symbol.localeCompare(t.symbol)}function lr(e,t){let n=gc(t);if(!n)return 0;let r=e.relative_path.toLowerCase(),i=ye(e.symbol).toLowerCase(),o=n.path.toLowerCase(),s=n.leaf.toLowerCase();return r.includes(o)?i!==s?1:lc(e.symbol)?ge(e.symbol)===null?5:4:ge(e.symbol)===null?3:2:0}function E0(e,t,n=5){let r=Rf(t);if(!r)return[];let i=Kt(e,{where:"1 = 1",orderBy:"d.relative_path, der.start_line",limit:5e3}),o=new Map;for(let s of i){if(e.isIgnored(s.relative_path))continue;let a=Ut(s.symbol),c=ye(s.symbol),l=s.display_name??c,u=[a,c,l].filter(f=>f.trim().length>0),d=Math.min(...u.map(f=>iC(Rf(f),r))),p=o.get(a);(!p||d<p.distance)&&o.set(a,{shortName:a,distance:d})}return[...o.values()].sort((s,a)=>s.distance-a.distance||s.shortName.localeCompare(a.shortName)).slice(0,n).map(s=>s.shortName)}function Rf(e){return No(e).toLowerCase().replace(/[^a-z0-9_]+/g,"")}function iC(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:t.length+1},(r,i)=>i);for(let r=0;r<e.length;r++){let i=[r+1];for(let o=0;o<t.length;o++){let s=e[r]===t[o]?0:1;i[o+1]=Math.min(i[o]+1,n[o+1]+1,n[o]+s)}n=i}return n[t.length]}function _0(e,t){let n=wf(e);return n?t.filter(r=>wf(r.file)===n):t}function L0(e,t,n,r,i){let o=ae(e,t);if(r){let u=i?.match(/^[A-Za-z_$][\w$]*/u)?.[0];if(!u)return null;let d=new Set(o.filter(y=>y.localName===u||y.importedName===u).map(y=>y.sourcePath).filter(y=>!!y));for(let y of n)for(let m of d)if(on(m,y.file))return y;if(u==="this"||u==="self"||u==="cls"){let y=n.filter(m=>m.file===t&&ge(m.symbol)!==null);if(y.length===1)return y[0]}let p=oC(F(e,t)??"",u);if(p.size===0)return null;let f=new Set(o.filter(y=>p.has(y.localName??y.importedName)).map(y=>y.sourcePath).filter(y=>!!y)),g=n.filter(y=>p.has(ge(y.symbol)??"")&&(y.file===t||[...f].some(m=>on(m,y.file))));return g.length===1?g[0]:null}let s=n.filter(u=>ge(u.symbol)===null),a=s.find(u=>u.file===t);if(a)return a;let c=ye(n[0].symbol),l=o.filter(u=>u.kind!=="namespace"&&u.kind!=="side-effect"&&(u.localName===c||u.localName===null&&u.importedName===c));if(l.length>0){let u=s.filter(d=>l.some(p=>p.sourcePath!==null&&on(p.sourcePath,d.file)));return u.length===1?u[0]:null}return s.length===1?s[0]:null}function oC(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),r=new Set,i=[new RegExp(`\\b${n}\\s*:\\s*([A-Za-z_$][\\w$]*)`,"gu"),new RegExp(`\\b${n}\\s*=\\s*(?:new\\s+)?([A-Za-z_$][\\w$]*)\\s*\\(`,"gu")];for(let o of i)for(let s of e.matchAll(o))r.add(s[1]);return r.size===1?r:new Set}function wf(e){let t=oe(e);return t?t==="typescript"||t==="tsx"||t==="javascript"?"javascript-family":t:null}var sC=Ze("global-leaf-index",{clearGroups:["whole-project"]});function yc(e){return sC.get(e,()=>{let t=e.all(`SELECT gs.id, gs.symbol,
275
- COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
276
- FROM global_symbols gs
277
- LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
278
- LEFT JOIN documents der_doc ON der_doc.id = der.document_id
279
- LEFT JOIN (
280
- SELECT m.symbol_id, MIN(d.relative_path) AS relative_path
281
- FROM mentions m
282
- JOIN chunks c ON m.chunk_id = c.id
283
- JOIN documents d ON c.document_id = d.id
284
- WHERE m.role = 1
285
- GROUP BY m.symbol_id
286
- ) mention_doc ON mention_doc.symbol_id = gs.id
287
- WHERE 1 = 1
288
- ${e.symbolNoiseFor("gs")}`),n=new Map;for(let r of t){if(!r.relative_path||e.isIgnored(r.relative_path))continue;let i=ye(r.symbol);if(!i)continue;let o=n.get(i);o||(o=[],n.set(i,o)),o.some(s=>s.symbolId===r.id)||o.push({symbol:r.symbol,symbolId:r.id,file:r.relative_path})}return n})}function _o(e,t,n,r={}){if(!n)return[];let i=F(e,t);return i?i.indexOf(n)===-1?[]:(hc(e,t).get(n)??[]).filter(s=>!aC(s,r)):[]}function aC(e,t){return typeof t.excludeStartLine=="number"&&typeof t.excludeEndLine=="number"&&e>=t.excludeStartLine&&e<=t.excludeEndLine}var cC=w("file-identifiers",{clearGroups:["whole-project","source-file"]});function Ff(e,t){let n=me(e,t);return n?n.fileIdentifiers:cC.get(e,t,()=>new Set(hc(e,t).keys()))}var lC=w("file-ident-lines",{clearGroups:["whole-project","source-file"]});function hc(e,t){let n=me(e,t);return n?n.identifierLineMap:lC.get(e,t,()=>dC(e,t))}var uC=w("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function B0(e,t){let n=me(e,t);return n?n.identifiersByLine:uC.get(e,t,()=>{let r=hc(e,t),i=0;for(let s of r.values()){let a=s[s.length-1];a!==void 0&&a>i&&(i=a)}let o=new Array(i+1);for(let s=0;s<=i;s+=1)o[s]=new Set;for(let[s,a]of r)for(let c of a)o[c].add(s);return o})}function dC(e,t){let n=new Map,r=(a,c)=>{let l=n.get(a);if(!l){n.set(a,[c]);return}l[l.length-1]!==c&&l.push(c)},i=F(e,t);if(!i)return n;let o=Da(i).split(/\r?\n/),s=/\b([A-Za-z_$][\w$]*)\b/g;for(let a=0;a<o.length;a+=1){let c=o[a]??"";for(let l of c.matchAll(s))l[1]&&r(l[1],a)}return n}var Tf=/[A-Za-z_$][A-Za-z0-9_$]*/g,kf=/^[A-Za-z_$][A-Za-z0-9_$]*$/,pC=512;function Sc(e){let t=[],n=!1;for(let r of e)r&&(n=!0,kf.test(r)||t.push(r));return{candidateNames:e,hasUsableCandidate:n,nonIdentifierNames:t}}function Nf(e,t){let n=fC(t)?t:Sc(t);if(n.candidateNames.size===0||!n.hasUsableCandidate)return!0;if(n.candidateNames.size<=pC){for(let i of n.candidateNames)if(i){if(kf.test(i)){if(mC(i).test(e))return!0;continue}if(e.includes(i))return!0}return!1}Tf.lastIndex=0;let r;for(;(r=Tf.exec(e))!==null;)if(n.candidateNames.has(r[0]))return!0;for(let i of n.nonIdentifierNames)if(e.includes(i))return!0;return!1}function fC(e){return"candidateNames"in e}function mC(e){return new RegExp(`(?<![A-Za-z_$0-9])${ie(e)}(?![A-Za-z_$0-9])`)}var gC=w("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function Lf(e,t){let n=Bt(t);return gC.get(e,n,()=>yC(e,n))}function yC(e,t){let n=new Map;for(let r of ae(e,t)){if(!r.sourcePath)continue;let i=r.localName??r.importedName;if(i&&_f(n,i,r.sourcePath),r.kind==="namespace")for(let o of r.usedMembers)_f(n,o,r.sourcePath)}return n}function _f(e,t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n)}function bc(e,t,n){let r=yc(e).get(n);if(!r||r.length===0)return[];if(r.length===1)return[Yr(r[0])];let i=r.filter(c=>c.file===t);if(i.length>0)return i.map(Yr);let o=Lf(e,t),s=o.get(n);if(s)for(let c of s){let l=r.filter(u=>on(c,u.file));if(l.length>0)return l.map(Yr)}let a=new Set;for(let c of o.values())for(let l of c)a.add(l);for(let c of a){let l=r.filter(u=>on(c,u.file));if(l.length>0&&l.length===r.length)return l.map(Yr)}return[]}function r$(e,t,n){let r=bc(e,t,n);if(r.length>0)return r;let i=yc(e).get(n);return!i||i.length===0?[]:i.map(Yr)}function Df(e,t,n={}){let r=hC(e,t);if(!r)return[];let i=Xr(e,t);if(n.semantic!==!1&&n.semanticEvidence){let s=n.semanticEvidence.references(e,{...i,leaf:r.identifier,parentTypeName:null,isFunctionLike:!1,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null});if(s.length>0){let a=new Map;for(let c of s){let l=a.get(c.file)??[];l.push(c.line),a.set(c.file,l)}return Lo(e,a)}}let o=new Map;for(let s of Me(e)){let a=SC(e,r,s);a.length>0&&o.set(s,a)}return Lo(e,o)}function hC(e,t){let n=Xr(e,t);if(!n)return null;let r=ye(n.symbol);return r?{symbolId:n.symbolId,relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,identifier:r}:null}function SC(e,t,n){let r=F(e,n);return!r||r.indexOf(t.identifier)===-1?[]:n!==t.relativePath&&!bc(e,n,t.identifier).some(o=>o.symbolId===t.symbolId)?[]:_o(e,n,t.identifier,n===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{})}function i$(e,t,n={}){let r=new Map;for(let c of t){if(!c.leaf)continue;let l=r.get(c.leaf)??[];l.push(c),r.set(c.leaf,l)}if(r.size===0)return new Map;let i=new Set(t.map(c=>c.symbolId)),o=new Set(r.keys()),s=Sc(o),a=new Map;for(let c of Me(e)){if(n.skipPath?.(c)||!Nf(F(e,c),s))continue;let l=Ff(e,c);if(l.size!==0){for(let u of l)if(r.has(u))for(let d of bc(e,c,u)){if(!i.has(d.symbolId)||c===d.relativePath)continue;let p=a.get(d.symbolId);p||(p=new Set,a.set(d.symbolId,p)),p.add(c)}}}return a}function Yr(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function Lo(e,t){let n=[],r=new Set;for(let[i,o]of t){let s=B(e,i);for(let a of o){let c=ar(s,a),l=`${i}|${a}|${c?.symbol??""}`;r.has(l)||(r.add(l),n.push({file:i,line:a,enclosingSymbol:c?.symbol??null}))}}return n}function s$(e,t){return Ao(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT
289
- m.symbol_id,
290
- d.relative_path,
291
- COUNT(*) AS ref_count
292
- FROM mentions m
293
- JOIN chunks c ON m.chunk_id = c.id
294
- JOIN documents d ON c.document_id = d.id
295
- WHERE m.role != 1
296
- ${r}
297
- ${e.pathExclusionsFor("d")}
298
- GROUP BY m.symbol_id, d.relative_path`,...n??[])})}function a$(e,t){return Ao(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id, d.relative_path
299
- FROM mentions m
300
- JOIN chunks c ON m.chunk_id = c.id
301
- JOIN documents d ON c.document_id = d.id
302
- WHERE m.role != 1
303
- ${r}
304
- ${e.pathExclusionsFor("d")}`,...n??[])}).filter(n=>n.symbol_id!==null)}function c$(e,t){return Ao(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id
305
- FROM mentions m
306
- WHERE m.role != 1
307
- ${r}`,...n??[])}).filter(n=>n.symbol_id!==null)}function Do(e,t){let n=Ao(e,t,o=>{let s=o?`AND m.symbol_id IN (${o.map(()=>"?").join(",")})`:"";return e.all(`SELECT m.symbol_id, d.relative_path, c.document_id,
308
- c.start_line AS chunk_start, c.end_line AS chunk_end
309
- FROM mentions m
310
- JOIN chunks c ON m.chunk_id = c.id
311
- JOIN documents d ON c.document_id = d.id
312
- WHERE m.role != 1
313
- ${s}
314
- ${e.pathExclusionsFor("d")}`,...o??[])}),r=new Map;for(let o of n){let s=`${o.symbol_id}\0${o.document_id}\0${o.chunk_start}\0${o.chunk_end}`;r.set(s,o)}let i=t?new Map(t.map((o,s)=>[o,s])):null;return[...r.values()].sort((o,s)=>(i?(i.get(o.symbol_id)??0)-(i.get(s.symbol_id)??0):0)||o.relative_path.localeCompare(s.relative_path)||o.chunk_start-s.chunk_start||o.chunk_end-s.chunk_end||o.symbol_id-s.symbol_id)}function Ao(e,t,n){if(!t)return n();if(t.length===0)return[];let r=[];for(let i=0;i<t.length;i+=750)r.push(...n(t.slice(i,i+750)));return r}function bC(e,t){return xC(e,[t]).get(t.symbolId)??[]}function xC(e,t){let n=t.map(o=>({symbolId:o.symbolId,prelude:RC(e,o)})).filter(o=>o.prelude!==null),r=IC(e,n.map(o=>o.symbolId)),i=new Map;for(let{symbolId:o,prelude:s}of n){let a=vC(e,r.get(o)??new Map,s.match,s.identifier);i.set(o,Lo(e,a))}return i}function g$(e,t,n={}){return xc(e,t,n).map(r=>({file:r.file,line:r.line,enclosingSymbol:r.enclosingSymbol}))}function xc(e,t,n={}){let r=Df(e,t,{semantic:n.semantic,semanticEvidence:n.semanticEvidence}),i=r.length>0?Af(r,"source-attribution"):Af(bC(e,t),"scip-reference-chunk");return n.includeIgnored===!0?i:i.filter(o=>!e.isIgnored(o.file))}function Af(e,t){return e.map(n=>({...n,provenance:t}))}function vC(e,t,n,r){let i=new Map;for(let[o,s]of t)i.set(o,EC(e,o,s,n,r));return i}function IC(e,t){let n=new Map;for(let r of Do(e,t)){if(e.isIgnored(r.relative_path))continue;let i=n.get(r.symbol_id);i||(i=new Map,n.set(r.symbol_id,i));let o=i.get(r.relative_path);o||(o=[],i.set(r.relative_path,o)),o.push({start_line:r.chunk_start,end_line:r.chunk_end})}return n}function EC(e,t,n,r,i){let o=t===r.relativePath?{excludeStartLine:r.startLine,excludeEndLine:r.endLine}:{},s=i?_o(e,t,i,o):[];return n.flatMap(a=>PC(s,a))}function PC(e,t){let n=e.filter(r=>r>=t.start_line&&r<=t.end_line);return n.length>0?n:[t.start_line]}function RC(e,t){let n=Xr(e,t);return n?{match:n,identifier:ye(n.symbol)||null}:null}import{execFileSync as Of,spawnSync as CC}from"child_process";import{platform as wC}from"os";import{resolve as FC}from"path";var Mf=wC()==="win32";function x$(e,t=CC){try{return t(e,["--version"],{stdio:"ignore",timeout:1e4}).status===0}catch{return!1}}function jf(e){let t=Mf?"where":"which";try{return Of(t,[e],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var TC=/\.(?:c|m)?js$/i,kC=/\.(?:exe|com)$/i;function v$(e,t){return TC.test(e)?{binary:process.execPath,args:[e,...t]}:{binary:e,args:[...t]}}function NC(e,t){return Of(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL"})}function Bf(e,t={}){let n=t.isWindows??Mf,r=t.lookup??NC,i;try{i=r(n?"where":"which",[e])}catch{return null}let o=i.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(!n){let s=o[0];return s?FC(s):null}return o.find(s=>kC.test(s))??null}import{execFileSync as Gf}from"child_process";import{createHash as _C}from"crypto";import{existsSync as Oo,statSync as LC}from"fs";import{createRequire as DC}from"module";import{platform as AC}from"os";import{dirname as $f,join as Qr}from"path";var OC=DC(import.meta.url),_$={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function vc(e){return[e.indexerBinary,...e.binaryAliases??[]]}function MC(e){let t=vc(e);return t.length===1?t[0]:t.join(" or ")}function Ic(e){for(let t of vc(e)){let n=Bf(t);if(n)return n}return BC(e)}function L$(e){return Ic(e)!==null||jC(e)}function jC(e){return Vf(e)!==null}function BC(e){let t=Vf(e);if(!t)return null;let r=JSON.parse(T(t,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return Qr($f(t),r);for(let i of vc(e)){let o=r[i];if(o)return Qr($f(t),o)}return null}function Vf(e){if(!e.bundledNpmPackage)return null;try{return OC.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function $C(e,t){for(let n of e.projectLocalBinaries??[]){let r=Qr(t,n);if(Oo(r))return r}return null}function GC(e,t){for(let n of e.projectLocalBinaries??[]){let r=Qr(t,n);if(Oo(r))return qf(t,n,r)}return null}function D$(e,t){let n=VC(e,t);if(!n||n.canonicalPath!==t.canonicalPath||n.sha256!==t.sha256||n.size!==t.size||n.mtimeMs!==t.mtimeMs||n.device!==t.device||n.inode!==t.inode||n.executable!==t.executable)throw new Error(`refusing changed project-local indexer ${t.relativePath}; review the current file and rerun with --trust-project-tools`)}function VC(e,t){try{return qf(e,t.relativePath,t.configuredPath)}catch{return null}}function qf(e,t,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=Hn(e,t,r),o=to(e,t,r),s=LC(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:t,sha256:_C("sha256").update(o).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(s.mode&73)!==0}}function qC(e,t,n={}){return(n.trustProjectTools?GC(e,t)?.canonicalPath:null)??Ic(e)}function A$(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Ec(n,t))return t;let r=Wf(n,t);return r?{...t,DOTNET_ROOT:r}:t}function O$(e,t,n={}){let r=MC(e),i=t?qC(e,t,n):Ic(e);if(!i)return{language:e.language,binaryLabel:r,installed:!1,runnable:!1,resolvedBinary:null,installUrl:e.installUrl,...t&&$C(e,t)?{note:"project-local indexer available only with --trust-project-tools"}:{}};if(e.indexerBinary!=="scip-dotnet")return{language:e.language,binaryLabel:r,installed:!0,runnable:!0,resolvedBinary:i};let o=WC(i);return{language:e.language,binaryLabel:r,installed:!0,runnable:o.runnable,resolvedBinary:i,installUrl:e.installUrl,note:o.note}}function WC(e){if(Ec(e,process.env))return{runnable:!0};let t=Wf(e,process.env);if(t)return{runnable:!0,note:`using .NET 9 runtime from ${t}`};let n=Hf(process.env);return{runnable:!1,note:n.length>0?`.NET 9 runtime still unavailable after checking ${n.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function Wf(e,t){for(let n of Hf(t))if(Ec(e,{...t,DOTNET_ROOT:n}))return n;return null}function Hf(e){let t=[],n=e.DOTNET_ROOT;if(n&&Oo(n)&&t.push(n),AC()==="darwin"&&jf("brew"))try{let r=Gf("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=Qr(r,"libexec");Oo(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Ec(e,t){try{return Gf(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}function wn(e){try{return process.kill(e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}}var HC=new Set(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]);function Ct(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return t.version!==1||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.platform!="string"||!HC.has(t.platform)||typeof t.startToken!="string"||t.startToken.trim()===""?null:{version:1,pid:t.pid,platform:t.platform,startToken:t.startToken}}function Ne(e,t){return e.version===t.version&&e.pid===t.pid&&e.platform===t.platform&&e.startToken===t.startToken}import{execFileSync as zC}from"child_process";import{platform as UC}from"os";var KC=1e3,zf=16*1024,Pc;function wt(e,t=Kf){if(!Number.isSafeInteger(e)||e<=0)return null;let n=e===process.pid&&t===Kf;if(n&&Pc)return{...Pc};try{let r=JC(e,t);if(!r)return null;let i={version:1,pid:e,platform:t.platform,startToken:r};return n&&(Pc=i),{...i}}catch{return null}}function JC(e,t){if(t.platform==="linux"||t.platform==="android")return XC(t.readFile(`/proc/${e}/stat`));if(t.platform==="win32"){let n=`([DateTimeOffset](Get-Process -Id ${e} -ErrorAction Stop).StartTime).ToUnixTimeMilliseconds()`;return Uf(t.run("powershell.exe",["-NoProfile","-NonInteractive","-Command",n]))}return t.platform==="darwin"||t.platform==="freebsd"||t.platform==="openbsd"||t.platform==="netbsd"?Uf(t.run("ps",["-p",String(e),"-o","lstart="])):null}function XC(e){let t=e.lastIndexOf(")");if(t<0)return null;let r=e.slice(t+1).trim().split(/\s+/)[19];return r&&/^\d+$/.test(r)?r:null}function Uf(e){let t=e.trim();return t===""?null:t}var Kf={platform:UC(),readFile(e){return Us(e,{maxBytes:zf,inputKind:"process identity pseudo-file"})},run(e,t){return zC(e,[...t],{encoding:"utf8",timeout:KC,maxBuffer:zf,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}};function Ft(){return performance.now()}function H$(e,t,n,r,i,o){if(e>0)return n;let s=Math.max(0,Math.min(o,t-1));return Math.min(i,r*2**s)}import{randomUUID as tw}from"crypto";import{closeSync as nw,existsSync as rw,fsyncSync as iw,linkSync as ow,mkdirSync as sw,openSync as aw,renameSync as cw,unlinkSync as lw,writeSync as uw}from"fs";import{dirname as Xf}from"path";import{chmodSync as YC,constants as QC,copyFileSync as ZC}from"fs";import{dirname as ew}from"path";var Jf=Object.freeze({...mn,copyFile:(e,t)=>ZC(e,t,QC.COPYFILE_FICLONE),chmodFile:(e,t)=>YC(e,t)});function Zr(e,t,n={}){let r=n.runtime??Jf,i=ew(t),o=ue(i,r);r.copyFile(e,t),n.mode!==void 0&&r.chmodFile(t,n.mode);let s=r.openFile(t,"r");try{r.syncFile(s)}finally{r.closeFile(s)}return q(o,L(i,r))}var Yf=Object.freeze({platform:process.platform,randomToken:()=>tw(),pathExists:e=>rw(e),makeDirectory:e=>sw(e,{recursive:!0}),openFile:(e,t,n)=>aw(e,t,n),writeFile:(e,t,n,r)=>uw(e,t,n,r),syncFile:e=>iw(e),closeFile:e=>nw(e),renameFile:(e,t)=>cw(e,t),linkFile:(e,t)=>ow(e,t),removeFile:e=>lw(e)});function Rc(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??Yf,o=Xf(e),s=r==="durable"?ue(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,l,u=!1;try{l=i.openFile(a,"wx",n.mode??384),u=!0,yt(l,c,i,"atomic file"),r==="durable"&&i.syncFile(l),i.closeFile(l),l=void 0,i.renameFile(a,e),u=!1;let d=r==="durable"?q(s,L(o,i)):"not-requested";return Qf(r,d)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function Mo(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??Yf;if(!i.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=Xf(e),s=r==="durable"?ue(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,l,u=!1;try{l=i.openFile(a,"wx",n.mode??384),u=!0,yt(l,c,i,"exclusive atomic file"),r==="durable"&&i.syncFile(l),i.closeFile(l),l=void 0,i.linkFile(a,e);let d=r==="durable"?L(o,i):"not-requested";i.removeFile(a),u=!1;let p=r==="durable"?q(s,d,L(o,i)):"not-requested";return Qf(r,p)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function Qf(e,t){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":t==="synced"?"directory-durable":"file-flushed",directorySync:t}}function Jt(e,t,n={}){Rc(e,Zf(t,n),{durability:"visibility",runtime:n.runtime})}function _e(e,t,n={}){return Rc(e,Zf(t,n),{durability:"durable",runtime:n.runtime})}function Zf(e,t){let n=JSON.stringify(e,null,t.spacing);return t.trailingNewline?`${n}
315
- `:n}import{join as jo}from"path";var pG=6,fG=1e4,dw="watch.lock",pw="watch-state.json",fw="watch-activity.json",mw="watch-refresh-requests";function mG(e){return{lockPath:jo(e,dw),statePath:jo(e,pw),activityPath:jo(e,fw),refreshRequestsPath:jo(e,mw)}}function gG(e){try{return gw(JSON.parse(T(e,"watch service state")))}catch{return null}}function gw(e){if(!e||typeof e!="object")return null;let t=e;if(t.version!==1||typeof t.protocolVersion!="number"||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||t.worktreeId!==void 0&&(typeof t.worktreeId!="string"||t.worktreeId.length===0)||typeof t.cliVersion!="string"||!re(t.startedAt)||!re(t.heartbeatAt)||!re(t.lastActivityAt)||!yw(t.watcher)||t.idleDeadlineAt!==void 0&&!re(t.idleDeadlineAt))return null;if(t.processIdentity!==void 0){let n=Ct(t.processIdentity);if(!n||n.pid!==t.pid)return null;t.processIdentity=n}return t.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(t.indexGeneration)||t.lastError!==void 0&&!hw(t.lastError)||t.lastRefresh!==void 0&&!Sw(t.lastRefresh)||t.reindexActivity!==void 0&&!bw(t.reindexActivity)||t.refreshRequests!==void 0&&!vw(t.refreshRequests)||t.typescriptSemantic!==void 0&&!Iw(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!Ew(t.typescriptIndex)?null:t}function re(e){return Mi(e)}function yw(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return ce(t.changedFiles)&&ce(t.reindexAt);case"indexing":return ce(t.startedAt);case"cooldown":return ce(t.until)&&typeof t.dirty=="boolean";case"budget-paused":return ce(t.until)&&typeof t.dirty=="boolean"&&typeof t.reason=="string"&&R(t.rebuilt)&&R(t.estimatedWriteBytes);case"draining":return ce(t.startedAt)&&typeof t.reason=="string";default:return!1}}function hw(e){if(!e||typeof e!="object")return!1;let t=e;return re(t.at)&&typeof t.message=="string"}function Sw(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&re(t.startedAt)&&re(t.completedAt)&&ce(t.durationMs)}function bw(e){if(!e||typeof e!="object")return!1;let t=e;return t.confidence!==void 0&&t.confidence!=="complete"&&t.confidence!=="partial"&&t.confidence!=="unavailable"||t.recordsRead!==void 0&&!R(t.recordsRead)||t.invalidRecords!==void 0&&!R(t.invalidRecords)||t.skippedRecords!==void 0&&!R(t.skippedRecords)||t.readErrors!==void 0&&!R(t.readErrors)||t.ignoredPartialTailBytes!==void 0&&!R(t.ignoredPartialTailBytes)||!re(t.windowStartedAt)||!re(t.windowEndedAt)||!R(t.runs)||!R(t.rebuilt)||t.fullRebuilds!==void 0&&!R(t.fullRebuilds)||!R(t.reused)||!R(t.failed)||!R(t.suppressed)||!ce(t.estimatedLogicalOutputBytes)||t.estimatedWriteBytes!==void 0&&!R(t.estimatedWriteBytes)||t.reflinkedBytes!==void 0&&!R(t.reflinkedBytes)||t.fallbackCopiedBytes!==void 0&&!R(t.fallbackCopiedBytes)||t.oldestRebuildAt!==void 0&&!re(t.oldestRebuildAt)||t.oldestWriteAt!==void 0&&!re(t.oldestWriteAt)||t.languageAttribution!==void 0&&t.languageAttribution!=="complete"&&t.languageAttribution!=="partial"&&t.languageAttribution!=="unavailable"||t.attributedRuns!==void 0&&!R(t.attributedRuns)||t.unattributedRuns!==void 0&&!R(t.unattributedRuns)||t.invalidLanguageDetails!==void 0&&!R(t.invalidLanguageDetails)||t.estimatedLogicalOutputBytes<0||!t.byTrigger||typeof t.byTrigger!="object"||Array.isArray(t.byTrigger)||t.byLanguage!==void 0&&!xw(t.byLanguage)?!1:Object.values(t.byTrigger).every(n=>n===void 0||R(n))}function xw(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let[t,n]of Object.entries(e)){if(!ji.includes(t)||!n||typeof n!="object")return!1;let r=n;if(!R(r.runs)||!R(r.rebuilt)||!R(r.reused)||!R(r.producedOutputBytes)||!mu(r.durationMs)||r.rebuilt+r.reused!==r.runs)return!1}return!0}function vw(e){if(!e||typeof e!="object")return!1;let t=e;return R(t.pending)&&R(t.claimed)&&R(t.completed)&&R(t.expired)&&R(t.invalid)&&(t.oldestPendingAt===void 0||re(t.oldestPendingAt))}function Iw(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&ce(t.requests)&&ce(t.sessionsCreated)&&ce(t.sessionsReused)&&ce(t.sessionsRefreshed)&&ce(t.sessionsReplaced)&&ce(t.projectsCreated)&&(t.lastRequestAt===void 0||re(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||re(t.busyUntil))&&(t.mailbox===void 0||em(t.mailbox))}function Ew(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&R(t.requests)&&R(t.sessionsCreated)&&R(t.sessionsReplaced)&&(t.sessionsEvicted===void 0||R(t.sessionsEvicted))&&(t.activeSessions===void 0||R(t.activeSessions))&&(t.maxActiveSessions===void 0||R(t.maxActiveSessions))&&(t.heapUsedBytes===void 0||R(t.heapUsedBytes))&&(t.heapLimitBytes===void 0||R(t.heapLimitBytes))&&(t.softMemoryLimitBytes===void 0||R(t.softMemoryLimitBytes))&&(t.retireRequested===void 0||typeof t.retireRequested=="boolean")&&R(t.initializations)&&R(t.programUpdates)&&R(t.documentsEmitted)&&R(t.documentsRemoved)&&(t.lastRequestAt===void 0||re(t.lastRequestAt))&&(t.lastDurationMs===void 0||ce(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||re(t.busyUntil))&&(t.mailbox===void 0||em(t.mailbox))}function em(e){if(!e||typeof e!="object")return!1;let t=e;return R(t.pending)&&R(t.inflight)&&R(t.responses)&&R(t.deadLetters)&&R(t.invalid)&&R(t.totalItems)&&ce(t.totalBytes)&&t.totalBytes>=0&&t.totalItems===t.pending+t.inflight+t.responses+t.deadLetters&&(t.oldestPendingAt===void 0||re(t.oldestPendingAt))}function ce(e){return typeof e=="number"&&Number.isFinite(e)}var Pw=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function Bo(e){let t=e.toLowerCase();return Pw.some(n=>t.endsWith(n))}function Go(e){let t=$o(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(p=>[p.path,p])),i=e.snapshot.files.filter(p=>{let f=At(p.path,["typescript"]);return f==="config"||f==="ambient"}).map(p=>p.path),o=$o([...t,...i]),s=o.find(p=>!r.has(p)),a=new Set(e.snapshot.files.map(p=>p.path)).size!==e.snapshot.files.length,c=!s&&o.some(p=>tm(r.get(p))),l=H(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:$o(e.snapshot.typescriptProjects),membership:t})),u,d;return{identityFor(p,f){if(!n.has(p))return ur("target-outside-project");if(a)return ur("duplicate-input-path");if(s)return ur("missing-input-fingerprint");if(c)return ur("unreadable-input");let g=[],y,m;if(e.graph===null)g.push("dependency-graph-unavailable"),m="whole-project",y=o;else{let x=p===u&&d?d:Rw(p,e.graph);if(u=p,d=x,x.find(I=>!r.has(I)))return ur("missing-input-fingerprint");if(y=$o([...x,...i]),y.some(I=>tm(r.get(I))))return ur("unreadable-input");m="dependency-closure"}let S=y.map(x=>Cw(r.get(x)));return{version:1,key:H(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:f,projectIdentity:l,inputs:S})),mode:m,inputFiles:y,reasons:g}}}}function Rw(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let o=r[i];if(!(o===void 0||n.has(o))){n.add(o);for(let s of[...t.get(o)??[]].sort())n.has(s)||r.push(s)}}return[...n].sort()}function Cw(e){return e.semanticHash===void 0?{path:e.path,size:e.size,hash:e.hash}:{path:e.path,semanticHash:e.semanticHash}}function tm(e){return e.size<0||e.hash==="unreadable"}function ur(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function $o(e){return[...new Set(e)].sort()}import{createRequire as ww}from"module";var nm=ww(import.meta.url),ei,Vo;function Fw(){if(ei!==void 0)return ei;try{ei=nm("ts-morph")}catch{ei=null}return ei}function qo(){if(Vo)return Vo;let e=Fw();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=nm("ts-morph/package.json").version??"unknown"}catch{}return Vo=`ts-morph:${t}:typescript:${e.ts.version}`,Vo}function IG(e,t){return t.map(n=>({tsconfigPath:n,project:new e.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function EG(e,t,n){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var Tw=Ze("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function Cc(e,t,n){let r=Tw.get(e,()=>kw(e));if(!r)return null;let i=`${n}\0${t}`,o=r.identities.get(i);if(o)return o;let s=r.builder.identityFor(t,n);return r.identities.set(i,s),s}function ti(e){return ve(e,{includeIgnored:!1}).filter(Bo).sort()}function kw(e){try{if(!e.generation.metadataRaw)return null;let t=Ot(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=vr(t.metadata.fingerprint);return n?{builder:Go({projectFiles:ti(e),snapshot:n,graph:or(e),engineIdentity:qo()}),identities:new Map}:null}catch{return null}}function Wo(e,t){let n=new Map(e.map(i=>[i.symbol,i])),r=new Map(e.map(i=>[i.symbolId,[]]));for(let i of t.values())for(let o of i){let s=n.get(o.targetSymbol);s&&r.get(s.symbolId).push(o.location)}for(let[i,o]of r)r.set(i,Nw(o));return r}function om(e,t,n){let r=im(e,t),i=im(e,n),o=[...r].filter(d=>!i.has(d)).sort(),s=[...i].filter(d=>!r.has(d)).sort(),a=rm(e,t),c=rm(e,n),l=[...a].filter(d=>!c.has(d)).sort(),u=[...c].filter(d=>!a.has(d)).sort();return{passed:o.length===0&&s.length===0,expectedCount:r.size,actualCount:i.size,missing:o,extra:s,callerFiles:{passed:l.length===0&&u.length===0,expectedCount:a.size,actualCount:c.size,missing:l,extra:u}}}function rm(e,t){let n=new Set;for(let r of e)for(let i of t.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function DG(e,t,n){let r=new Set(n),i=new Map(n.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])r.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,_w(s));return i}function im(e,t){let n=new Set;for(let r of e)for(let i of t.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function Nw(e){let t=new Map;for(let n of e)t.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...t.values()].sort(sm)}function _w(e){let t=new Map;for(let n of e){let{location:r}=n;t.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...t.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||sm(n.location,r.location))}function sm(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}var wc="typescript-reference-fragment-v2",am=128,Ho=we({kind:"typescript-reference-fragments",invalidation:pe("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:Dw});function WG(e,t,n,r=e,i,o=new Set(n.keys())){let s=ti(e),a=Go({projectFiles:s,snapshot:t,graph:i??or(e),engineIdentity:qo()}),c=[],l=0;for(let[d,p]of n){let f=a.identityFor(d,wc).key;if(!f){l+=1;continue}c.push({relativePath:d,contentHash:f,value:[...p]})}let u=s.filter(d=>!o.has(d)&&!n.has(d)).length;return Ho.writeBatch(r,c),{affectedFiles:c.length,carriedFiles:u,skippedAffectedFiles:l}}function HG(e,t,n,r){let i=t.filter(s=>Bo(s.relativePath));if(i.length===0)return ni("no TypeScript definitions");let o=ni("shadow did not run");return z("typescript.reference-fragments.shadow",()=>{try{let s=r(i[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return o=ni("TypeScript reference fragment provider is unavailable"),o;let a=ti(e),c=new Set(a),l=new Map;for(let f of cm(a)){let g=s.referenceFragmentsForFiles(f);if(f.some(y=>!g.has(y)))return o=ni("TypeScript reference fragment provider returned an incomplete batch"),o;for(let y of f)l.set(y,g.get(y)??[])}let u=Wo(i,l),d=om(i,Lw(n,c),u);if(!d.passed)return o={state:"failing",files:a.length,keyedFiles:0,writtenFiles:0,...d},o;let p=[];for(let f of a){let g=Cc(e,f,wc);g?.key&&p.push({relativePath:f,contentHash:g.key,value:l.get(f)??[]})}return Ho.writeBatch(e,p),o={state:"passing",files:a.length,keyedFiles:p.length,writtenFiles:p.length,...d},o}catch(s){return o=ni(s instanceof Error?s.message:String(s)),o}},()=>({...o}))}function Lw(e,t){return new Map([...e].map(([n,r])=>[n,r.filter(i=>t.has(i.file))]))}function zG(e,t,n){if(t.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let r="fallback",i=0,o=0,s=0,a=0;return z("typescript.reference-fragments.materialize",()=>{try{let c=ti(e);i=c.length;let l=new Map,u=new Map,d=[];for(let f of c){let g=Cc(e,f,wc);if(!g?.key)return null;l.set(f,g.key);let y=Ho.read(e,f,g.key);y===null?(s+=1,d.push(f)):(o+=1,u.set(f,y))}if(s===0)return r="hit",{references:Wo(t,u),files:i,cacheHits:o,cacheMisses:s,computedFiles:a};let p=n(t[0].relativePath);if(!p.availability().available||!p.referenceFragmentsForFiles)return null;for(let f of cm(d)){let g=p.referenceFragmentsForFiles(f);if(f.some(y=>!g.has(y)))return null;Ho.writeBatch(e,f.map(y=>({relativePath:y,contentHash:l.get(y),value:g.get(y)??[]})));for(let y of f)u.set(y,g.get(y)??[]);a+=f.length}return r="computed",{references:Wo(t,u),files:i,cacheHits:o,cacheMisses:s,computedFiles:a}}catch{return null}},()=>({state:r,files:i,cacheHits:o,cacheMisses:s,computedFiles:a}))}function cm(e){let t=[];for(let n=0;n<e.length;n+=am)t.push(e.slice(n,n+am));return t}function ni(e){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:e}}function Dw(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(Aw)?null:t}catch{return null}}function Aw(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}function zo(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function lm(e,t){if(e?.aborted)throw zo(e,t)}import{randomUUID as Ow}from"crypto";import{closeSync as Mw,fsyncSync as jw,linkSync as Bw,mkdirSync as $w,openSync as Gw,statSync as Vw,unlinkSync as qw,writeSync as Ww}from"fs";import{dirname as _c}from"path";var Tc="scip-query-process-lock",kc=1,Uo=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:wn,readProcessIdentity:wt,randomToken:()=>Ow(),makeDirectory:e=>$w(e,{recursive:!0}),openFile:(e,t,n)=>Gw(e,t,n),writeFile:(e,t,n,r)=>Ww(e,t,n,r),syncFile:e=>jw(e),closeFile:e=>Mw(e),linkFile:(e,t)=>Bw(e,t),readFile:e=>T(e,"process lock record"),statFile:e=>{let t=Vw(e);return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs}},removeFile:e=>qw(e)});function Ko(e,t){let n=t.runtime??Uo;n.makeDirectory(_c(e));let r;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:um(e,t,n),...r?{reclaimed:r}:{}}}catch(o){if(o.code!=="EEXIST")throw o;let s=dr(e,{parseLegacy:t.parseLegacy,runtime:n});if(i===0&&zw(e,s,{creationGraceMs:t.creationGraceMs,parseLegacy:t.parseLegacy,runtime:n})){r=s;continue}return{kind:"contended",observation:s}}return{kind:"contended",observation:dr(e,{parseLegacy:t.parseLegacy,runtime:n})}}function dr(e,t={}){let n=t.runtime??Uo,r,i;try{r=n.statFile(e),i=n.readFile(e)}catch(c){return c.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let o;try{o=JSON.parse(i)}catch{return{state:"malformed",raw:i,identity:r}}let s=Hw(o);if(s)return{state:"valid",raw:i,identity:r,record:s,owner:Jw(s),parsed:o};let a=t.parseLegacy?.(o)??null;return a?{state:"legacy",raw:i,identity:r,owner:a,parsed:o}:{state:"malformed",raw:i,identity:r,parsed:o}}function Hw(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.protocol!==Tc||t.version!==kc||typeof t.kind!="string"||t.kind.trim()===""||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.token!="string"||t.token.trim()===""||typeof t.startedAt!="string"||!Number.isFinite(Date.parse(t.startedAt))||t.detail!==void 0&&(typeof t.detail!="object"||t.detail===null||Array.isArray(t.detail)))return null;let n=t.processIdentity===void 0?null:Ct(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{protocol:Tc,version:kc,kind:t.kind,pid:t.pid,token:t.token,...n?{processIdentity:n}:{},startedAt:t.startedAt,...t.detail?{detail:t.detail}:{}}}function zw(e,t,n={}){let r=n.runtime??Uo;if(!Nc(t,r))return!1;let i=Kw(`${e}.reclaim`,r);if(!i)return!1;try{let o=dr(e,{parseLegacy:n.parseLegacy,runtime:r});return!pm(t,o)||!Nc(o,r)?!1:Lc(e,r)}finally{i.release()}}function um(e,t,n){let r=t.directoryDurability??"durable",i=t.pid??process.pid,o=n.randomToken(),s=t.processIdentity===void 0?n.readProcessIdentity(i):t.processIdentity,a={protocol:Tc,version:kc,kind:t.kind,pid:i,token:o,...s?{processIdentity:s}:{},startedAt:new Date(n.wallNow()).toISOString(),...t.detail?{detail:t.detail}:{}},c=`${e}.${o}.candidate`,l=n.openFile(c,"wx",384),u;try{yt(l,Buffer.from(`${JSON.stringify(a)}
316
- `),n,"process lock"),n.syncFile(l)}catch(p){u=p}try{n.closeFile(l)}catch(p){u??=p}if(u!==void 0)throw Fc(c,n),u;try{n.linkFile(c,e)}catch(p){throw Fc(c,n),p}if(Fc(c,n),r==="durable")try{fm(_c(e),n)}catch(p){throw Uw(e,a,n),p}let d=!1;return{path:e,record:a,release:()=>d?!1:(d=!0,dm(e,a,n,r))}}function Uw(e,t,n=Uo){return dm(e,t,n,"durable")}function dm(e,t,n,r){let i=dr(e,{runtime:n});return i.state!=="valid"||!i.record||i.record.pid!==t.pid||i.record.token!==t.token||t.processIdentity&&(!i.record.processIdentity||!Ne(t.processIdentity,i.record.processIdentity))?!1:Lc(e,n,r)}function Kw(e,t){for(let n=0;n<2;n+=1)try{return um(e,{kind:"reclaim-guard",runtime:t},t)}catch(r){if(r.code!=="EEXIST")return null;let i=dr(e,{runtime:t});if(n>0||!Nc(i,t))return null;let o=dr(e,{runtime:t});if(!pm(i,o)||!Lc(e,t))return null}return null}function Nc(e,t){if(e.state==="missing")return!1;if(e.owner){if(!t.isProcessAlive(e.owner.pid))return!0;if(!e.owner.processIdentity)return!1;let n=t.readProcessIdentity(e.owner.pid);return n!==null&&!Ne(e.owner.processIdentity,n)}return!1}function pm(e,t){return e.state===t.state&&e.raw===t.raw&&e.identity!==void 0&&t.identity!==void 0&&e.identity.dev===t.identity.dev&&e.identity.ino===t.identity.ino&&e.identity.size===t.identity.size&&e.identity.mtimeMs===t.identity.mtimeMs}function Jw(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function fm(e,t){let n;try{n=t.openFile(e,"r")}catch(r){if(Vn(r,process.platform))return;throw r}try{t.syncFile(n)}catch(r){if(!Vn(r,process.platform))throw r}finally{t.closeFile(n)}}function Lc(e,t,n="durable"){try{return t.removeFile(e),n==="durable"&&fm(_c(e),t),!0}catch{return!1}}function Fc(e,t){try{t.removeFile(e)}catch{}}import{join as Xw}from"path";var Yw=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function mm(e,t={}){return Tt(Xw(e,"gc.lock"),t)}function Tt(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??Ft,o=i()+n;do{let s=gm(e,t.directoryDurability);if(s)return ym(s);let a=o-i();if(a<=0)return null;Qw(Math.min(r,a))}while(i()<=o);return null}async function a1(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??Ft,o=i()+n;do{lm(t.signal,"Lock acquisition was aborted.");let s=gm(e,t.directoryDurability);if(s)return ym(s);let a=o-i();if(a<=0)return null;await Zw(Math.min(r,a),t.signal)}while(i()<=o);return null}function gm(e,t){let n=Ko(e,{kind:"generic",parseLegacy:Yw,...t?{directoryDurability:t}:{}});return n.kind==="acquired"?n.lock:null}function ym(e){return{release:()=>{e.release()}}}function Qw(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function Zw(e,t){return t?.aborted?Promise.reject(zo(t,"Lock acquisition was aborted.")):new Promise((n,r)=>{let i=setTimeout(()=>{t?.removeEventListener("abort",o),n()},e),o=()=>{clearTimeout(i),t?.removeEventListener("abort",o),r(t?zo(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}import{createHash as eF,randomUUID as tF}from"crypto";import{existsSync as pr,mkdirSync as nF,readdirSync as rF,rmSync as Sm,statSync as bm}from"fs";import{basename as iF,dirname as Jo,join as Le}from"path";var Fn=1,Mc=1,ii=".scipquery-generations",Xo="manifest.json",xm="readers",oF="gc.lock",sF=128,ri=new Map,vm={pid:process.pid,now:()=>new Date,randomToken:()=>tF(),isProcessAlive:wn,readProcessIdentity:wt};function J(e){return Le(Jo(e),ii)}function Yo(e){return Le(J(e),oF)}function Im(e,t=vm){let n=Tt(Yo(e.dbPath),{waitMs:5e3,directoryDurability:"recoverable"});if(!n)throw new Error("SQLite generation retention is busy; retry opening the index.");let r;try{let i=Bc(e);if(i.source!=="immutable")return{generation:i,release(){}};let o=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(o))throw new Error("SQLite generation reader token is unsafe.");let s=Le(J(e.dbPath),xm);nF(s,{recursive:!0}),r=Le(s,`${t.pid}-${o}.json`);let a=t.readProcessIdentity(t.pid);Jt(r,{version:1,token:o,generationIdentity:i.identity,pid:t.pid,...a?{processIdentity:a}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!r||(c=!0,Sm(r,{force:!0}))}}}finally{n.release()}}function jc(e,t,n=vm,r={}){let i=Le(J(e),xm);if(!pr(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,s=0,a=0,c=0;for(let l of rF(i,{withFileTypes:!0})){if(!l.isFile()||!l.name.endsWith(".json"))continue;let u=Le(i,l.name),d;try{d=aF(JSON.parse(T(u,"SQLite generation reader lease")))}catch{d=null}if(!d){c+=1;for(let p of t)o.add(p);continue}if(!cF(d,n)){r.removeStale!==!1&&(Sm(u,{force:!0}),a+=1);continue}s+=1,o.add(d.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:c}}function aF(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.processIdentity===void 0?null:Ct(t.processIdentity);return t.version!==1||typeof t.token!="string"||t.token.trim()===""||typeof t.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(t.generationIdentity)||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.acquiredAt!="string"||!Number.isFinite(Date.parse(t.acquiredAt))||t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...n?{processIdentity:n}:{},acquiredAt:t.acquiredAt}}function cF(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let n=t.readProcessIdentity(e.pid);return n===null||Ne(e.processIdentity,n)}function Xt(e){try{let t=JSON.parse(T(Le(J(e),"state.json"),"SQLite generation state"));return pF(t)?t:null}catch{return null}}function oi(e,t){return si(J(e),t)}function si(e,t){try{let n=JSON.parse(T(Le(e,t,Xo),"SQLite generation manifest"));return dF(n,t)?n:null}catch{return null}}function Bc(e){let t=Xt(e.dbPath);if(t){let n=lF(e,t.currentGeneration);if(n)return n;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(pr(Le(Jo(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return uF(e,t?.currentGeneration)}function b1(e){let t=Xt(e);if(t)return t.currentGeneration;try{let n=Le(Jo(e),"meta.json"),r=pr(n)?T(n,"reindex metadata"):void 0;return Em(e,r)}catch{return null}}function Yt(e){return gu(Ot(e))??e}function lF(e,t){try{let n=Le(J(e.dbPath),t),r=oi(e.dbPath,t);if(!r)return null;let i=Dc(n,r.database),o=r.index?Dc(n,r.index):void 0,s=r.metadata?Dc(n,r.metadata):void 0;return!Ac(i,r.database)||r.index&&(!o||!Ac(o,r.index))||r.metadata&&(!s||!Ac(s,r.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...s?{metadataPath:s,metadataRaw:T(s,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function uF(e,t){let n=kt(e.dbPath),r=Le(Jo(e.dbPath),"meta.json"),i=pr(r)?T(r,"reindex metadata"):void 0,o=pr(e.indexPath)?e.indexPath:void 0;return{identity:t??Em(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function Em(e,t){let n=eF("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&n.update(Yt(t)),n.update(`\0${kt(e)}`),n.digest("hex")}function kt(e){let t=bm(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function Dc(e,t){if(iF(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return Le(e,t.file)}function Ac(e,t){if(!pr(e))return!1;let n=hm(e);if(!n||n.size!==t.size)return!1;let r=`${e}\0${t.sha256}\0${n.identity}`;if(ri.has(r))return!0;let i=an(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=hm(e);if(!o||o.identity!==n.identity||i!==t.sha256)return!1;for(ri.set(r,!0);ri.size>sF;){let s=ri.keys().next().value;if(s===void 0)break;ri.delete(s)}return!0}function hm(e){let t=bm(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function dF(e,t){return e.version===Mc&&e.identity===t&&Oc(e.database)&&(e.index===void 0||Oc(e.index))&&(e.metadata===void 0||Oc(e.metadata))}function Oc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function pF(e){return e.version===Fn&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&fF(e.stableMirrors)&&mF(e.previousGeneration)&&gF(e.publication)}function fF(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function mF(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function gF(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,n=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(r=>r!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import yF from"better-sqlite3";var hF=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],$c=class{constructor(t,n){this.connection=t;this.releaseGenerationReader=n}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let n of hF)this.connection.pragma(n);t(this.connection)}catch(n){try{this.close()}catch(r){throw new AggregateError([n,r],"SQLite initialization and rollback both failed.",{cause:r})}throw n}}close(){if(!this.active)return;this.active=!1;let t,n;try{this.connection.close()}catch(r){t=r}try{this.releaseGenerationReader()}catch(r){n=r}if(t!==void 0&&n!==void 0)throw new AggregateError([t,n],"SQLite connection close and generation-reader release both failed.");if(t!==void 0)throw t;if(n!==void 0)throw n}},SF=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],Pm=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;constructor(t,n){this.config=t,this.pathFilter=n??null;let r=IF(t),i=new $c(r.db,r.release);try{i.initialize(vF),this.generation=r.generation,this.connection=r.db,this.connectionOwnership=i,this.db=bF(r.db)}catch(o){try{i.close()}catch(s){throw new AggregateError([o,s],"SQLite construction and rollback both failed.",{cause:s})}throw o}}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
317
- EXISTS (
318
- SELECT 1
319
- FROM defn_enclosing_ranges local_der
320
- JOIN documents local_d ON local_der.document_id = local_d.id
321
- WHERE local_der.symbol_id = gs.id
322
- ${this.pathExclusionsFor("local_d").trimStart()}
323
- )
324
- OR EXISTS (
325
- SELECT 1
326
- FROM mentions local_m
327
- JOIN chunks local_c ON local_m.chunk_id = local_c.id
328
- JOIN documents local_d ON local_c.document_id = local_d.id
329
- WHERE local_m.symbol_id = gs.id
330
- AND local_m.role = 1
331
- ${this.pathExclusionsFor("local_d").trimStart()}
332
- )
333
- )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(n=>SF.flatMap(r=>[`AND ${n}.relative_path NOT LIKE '${r}/%'`,`AND ${n}.relative_path NOT LIKE '%/${r}/%'`])).join(`
334
- `)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...n){return this.statement(t).all(...n)}get(t,...n){return this.statement(t).get(...n)}close(){this.statementCache.clear(),this.connectionOwnership.close()}statement(t){let n=this.statementCache.get(t);return n||(n=this.connection.prepare(t),this.statementCache.set(t,n)),n}};function bF(e){return Object.freeze({prepare(t){let n=e.prepare(t);if(!n.readonly||!n.reader)throw new Error("ScipDatabase.db only permits read-only statements that return rows.");return xF(n)}})}function xF(e){let t={get:(...n)=>e.get(...n),all:(...n)=>e.all(...n),iterate:(...n)=>e.iterate(...n),pluck(n){return n===void 0?e.pluck():e.pluck(n),t},expand(n){return n===void 0?e.expand():e.expand(n),t},raw(n){return n===void 0?e.raw():e.raw(n),t},bind(...n){return e.bind(...n),t},columns:()=>e.columns(),safeIntegers(n){return n===void 0?e.safeIntegers():e.safeIntegers(n),t}};return Object.freeze(t)}function vF(e){if(!e.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'documents'").get())return;let n=e.prepare("SELECT relative_path FROM documents").iterate();for(let r of n)Re(r.relative_path)}function IF(e){for(let t=0;t<4;t+=1){let n=Im(e),r=n.generation,i;try{i=new yF(r.databasePath,{readonly:!0,fileMustExist:!0})}catch(o){throw n.release(),o}if(r.source==="immutable")return{db:i,generation:r,release:n.release};try{let o=Bc(e);if(r.databaseFileIdentity===kt(r.databasePath)&&o.source==="legacy"&&o.identity===r.identity&&o.databaseFileIdentity===r.databaseFileIdentity&&o.metadataRaw===r.metadataRaw)return{db:i,generation:r,release:n.release}}catch(o){throw i.close(),n.release(),o}i.close(),n.release()}throw new Error("SQLite index publication changed repeatedly while opening a coherent generation.")}import EF from"ignore";import{existsSync as Rm,readdirSync as PF}from"fs";import{dirname as Gc,isAbsolute as Cm,join as Qo,relative as RF,resolve as CF}from"path";function T1(e){let t=EF();return wF(e,t)||t.add(kF),{isIgnored:r=>Vc(t,e,r),filter:r=>r.filter(i=>!Vc(t,e,i))}}function wF(e,t){let n=new Set,r=(s,a)=>{if(!(n.has(s)||!Rm(s)))try{let c=j(s,{maxBytes:te,inputKind:"gitignore file"});t.add(a?FF(c,a):c),n.add(s)}catch{}},i=Gc(e),o=0;for(;i!==Gc(i)&&o<5&&(r(Qo(i,".gitignore"),""),!Rm(Qo(i,".git")));)i=Gc(i),o++;return wm(e,"",t,r),n.size>0}function wm(e,t,n,r){let i=t?Qo(e,t):e;r(Qo(i,".gitignore"),t);let o;try{o=PF(i,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name===".git")continue;let a=t?`${t}/${s.name}`:s.name;Vc(n,e,`${a}/`)||wm(e,a,n,r)}}function FF(e,t){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return e.split(/\r?\n/).map(r=>TF(r,n)).join(`
335
- `)}function TF(e,t){let n=e.trimStart();if(!n||n.startsWith("#"))return e;let r=e.slice(0,e.length-n.length),i=n.startsWith("!"),o=i?n.slice(1):n;if(!o||o.startsWith("#"))return e;let s=o.startsWith("/"),a=s?o.slice(1):o,u=(a.endsWith("/")?a.slice(0,-1):a).includes("/")||s?`${t}/${a}`:`${t}/**/${a}`;return`${r}${i?"!":""}${u}`}var kF=`
336
- # Dependencies
337
- node_modules/
338
- vendor/
339
- .bundle/
340
-
341
- # Build output
342
- dist/
343
- build/
344
- out/
345
- target/
346
- bin/
347
- obj/
348
-
349
- # Python
350
- __pycache__/
351
- *.pyc
352
- *.pyo
353
- .venv/
354
- venv/
355
- .env/
356
- env/
357
- *.egg-info/
358
-
359
- # Rust
360
- target/
361
-
362
- # Java / Kotlin / Scala
363
- *.class
364
- .gradle/
365
- .mvn/
366
-
367
- # C# / .NET
368
- bin/
369
- obj/
370
- packages/
371
-
372
- # Go
373
- vendor/
374
-
375
- # Dart
376
- .dart_tool/
377
- build/
378
-
379
- # PHP
380
- vendor/
381
-
382
- # IDE / OS
383
- .idea/
384
- .vscode/
385
- *.swp
386
- *.swo
387
- .DS_Store
388
- Thumbs.db
389
-
390
- # Type definitions (often noise in queries)
391
- *.d.ts
392
- `;function Vc(e,t,n){let r=NF(t,n);if(!r)return!1;try{return e.ignores(r)}catch{return!1}}function NF(e,t){if(!t||t===".")return null;if(!Cm(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let n=Cm(t)?t:CF(e,t),r=RF(e,n).replaceAll("\\","/");return!r||r==="."||r.startsWith("..")?null:r}import{execFileSync as _F}from"child_process";import{existsSync as LF,readdirSync as Fm}from"fs";import{extname as Tm,join as km}from"path";var Nm=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),DF=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function Zo(e){let t=[],n=AF(e),r=BF(e);for(let i of DF){if(OF(e,i.files)){t.push(i.language);continue}if(MF(n,i.globs)){t.push(i.language);continue}GF(r,i.extensions)&&t.push(i.language)}if(t.includes("typescript")&&qc(t,"javascript"),t.includes("cpp")&&t.includes("c")){let i=r.has(".c"),o=[".cc",".cpp",".cxx"].some(s=>r.has(s));i&&!o?qc(t,"cpp"):i||qc(t,"c")}return t}function AF(e){try{return Fm(e)}catch{return[]}}function OF(e,t){return t?.length?t.some(n=>LF(km(e,n))):!1}function MF(e,t){return t?.length?e.some(n=>t.some(r=>jF(n,r))):!1}function jF(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function BF(e){let t=$F(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=Fm(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=km(i,s.name);if(s.isDirectory()){Nm.has(s.name)||r.push(a);continue}let c=Tm(s.name).toLowerCase();c&&n.add(c)}}return n}function $F(e){try{let t=_i(e,26214400,()=>_F("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:52428800,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"})),n=new Set;for(let r of Li(t)){if(r.split("/").some(o=>Nm.has(o)))continue;let i=Tm(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function GF(e,t){return t?.length?t.some(n=>e.has(n)):!1}function qc(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import VF from"better-sqlite3";var qF=25,WF=new Set(["typescript","javascript"]);function B1(e,t,n){let r=null;try{r=new VF(e,{readonly:!0,fileMustExist:!0});let i=new Set(r.prepare("SELECT relative_path FROM documents").pluck().all().map(Bt)),o=HF(t,n),s=new Set([...o.values()].flatMap(u=>[...u])),a=[...s].filter(u=>!i.has(u)).sort();if(a.length===0)return{state:"complete",expectedDocumentCount:s.size,actualDocumentCount:i.size};let c=new Set(a),l=n.filter(u=>[...o.get(u)??[]].some(d=>c.has(d)));return{state:"incomplete",expectedDocumentCount:s.size,actualDocumentCount:i.size,missingDocumentCount:a.length,missingPaths:a.slice(0,qF),affectedLanguages:l}}catch(i){return{state:"unavailable",reason:i instanceof Error?i.message:String(i)}}finally{r?.close()}}function HF(e,t){let n=new Map,r=t.filter(i=>WF.has(i));for(let i of r)n.set(i,new Set);for(let i of e.files){let o=Bt(i.path);for(let s of r)At(o,[s])==="source"&&n.get(s).add(o)}return n}import{existsSync as Lm,readdirSync as Dm,rmSync as Am}from"fs";import{join as fr}from"path";import{create as Mm,fromBinary as jm,toBinary as J1}from"@bufbuild/protobuf";import{deserializeSCIP as Wc,DocumentSchema as Bm,IndexSchema as $m,serializeSCIP as Gm}from"@c4312/scip";import{existsSync as zF,mkdirSync as UF,renameSync as KF,writeFileSync as JF}from"fs";import{join as XF}from"path";function _m(e){UF(e.blobDir,{recursive:!0});let t=XF(e.blobDir,`${e.blobHash}.scipdoc`);if(zF(t)){let r=ee(t,{maxBytes:sn,inputKind:e.inputKind});if(r.byteLength!==e.bytes.byteLength||H(r)!==e.blobHash)throw new Error(`existing ${e.inputKind} is corrupt: ${e.relativePath}`);return}let n=`${t}.${process.pid}.${Date.now()}.tmp`;JF(n,e.bytes),KF(n,t)}var Hc=1,ai="typescript-scip-fragments";function Z1(e){let t=new Set,n=[];for(let o of e){let s=es(o.relativePath);if(t.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(t.add(s),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${s}`);let a=jm(Bm,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);n.push(a)}let r=Gm(Mm($m,{documents:n,externalSymbols:[]})),i=Wc(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function YF(e){let t=fr(e,ai);return{rootDir:t,blobDir:fr(t,"blobs"),generationDir:fr(t,"generations")}}function Vm(e){let t=QF(e);return ZF(t.baseIndex,t.completeDocuments,"assembled")}function QF(e){let t=Wc(e.baseIndexBytes);rT(t.metadata,iT(e)),nT(t.externalSymbols);let n=new Map;for(let a of e.fragments){let c=es(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);n.set(c,a)}if(n.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let r=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=es(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);r.add(c);let l=n.get(c);if(!l){i.push(a);continue}if(n.delete(c),l.bytes===null){s.push(c);continue}let u=Om(c,l.bytes);i.push(u),o.push(u)}for(let a of[...n.keys()].sort()){let c=n.get(a);if(c.bytes===null)continue;if(r.has(a))throw new Error(`duplicate TypeScript SCIP document path: ${a}`);r.add(a);let l=Om(a,c.bytes);i.push(l),o.push(l)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function Om(e,t){let n=jm(Bm,t);if(n.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${n.relativePath}`);return n}function ZF(e,t,n){let r=Gm(Mm($m,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Wc(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function eV(e,t){let n=YF(e);if(!Lm(n.generationDir))return;let r=new Set(t.map(s=>tT(s))),i=Dm(n.generationDir).filter(s=>s.endsWith(".json")),o=new Set;for(let s of i.filter(a=>r.has(a))){let a=eT(j(fr(n.generationDir,s),{maxBytes:te,inputKind:"TypeScript fragment manifest"}));for(let c of a.documents)o.add(`${c.blobHash}.scipdoc`)}for(let s of i)r.has(s)||Am(fr(n.generationDir,s),{force:!0});if(Lm(n.blobDir))for(let s of Dm(n.blobDir))o.has(s)||Am(fr(n.blobDir,s),{force:!0})}function eT(e){let t=JSON.parse(e);if(t.version!==Hc||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let n=new Set;for(let r of t.documents){if(!r||typeof r.relativePath!="string"||typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash)||typeof r.byteLength!="number"||!Number.isInteger(r.byteLength)||r.byteLength<0||typeof r.documentIdentity!="string"||!r.documentIdentity)throw new Error("invalid TypeScript fragment record");if(es(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function tT(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${H(e)}.json`}function nT(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function rT(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let n=e,r=n.toolInfo??n.tool_info;if(!r||typeof r!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=r;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function iT(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function es(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}import{existsSync as ts,readdirSync as zc,rmSync as qm}from"fs";import{join as st}from"path";var ns=1,ci="typescript-scip-overlays",Wm="typescript-project-v3:";function lV(e){let t=zm(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t?.producerIdentity!==void 0&&t.producerIdentity!==e.producerIdentity)throw new Error("TypeScript overlay producer identity changed");let n=e.allowLegacyProjectIdentityMigration===!0&&t!==null&&!t.projectIdentity.startsWith(Wm)&&e.projectIdentity.startsWith(Wm);if(t&&t.projectIdentity!==e.projectIdentity&&!e.allowProjectIdentityChange&&!n)throw new Error("TypeScript overlay project identity changed");let r=new Map((t?.overlays??[]).map(s=>[s.relativePath,s])),i=new Set;for(let s of e.fragments){let a=Jc(s.relativePath);if(i.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);i.add(a),r.set(a,oT(e.cacheDir,s))}if(i.size===0)throw new Error("TypeScript overlay generation requires affected documents");let o={version:ns,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((s,a)=>s.relativePath.localeCompare(a.relativePath))};return sT(e.cacheDir,o),o}function uV(e){let t=zm(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let n=t.overlays.map(r=>{if(r.blobHash===null)return{relativePath:r.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=ee(st(li(e.cacheDir),"blobs",`${r.blobHash}.scipdoc`),{maxBytes:sn,inputKind:"TypeScript overlay blob"});if(i.byteLength!==r.byteLength||H(i)!==r.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${r.relativePath}`);return{relativePath:r.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return Vm({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function dV(e,t){let n=li(e),r=st(n,"generations");if(!ts(r))return;let i=new Set(t.map(Kc)),o=new Set;for(let a of zc(r).filter(c=>i.has(c))){let c=Uc(j(st(r,a),{maxBytes:te,inputKind:"TypeScript overlay manifest"}));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of zc(r))i.has(a)||qm(st(r,a),{force:!0});let s=st(n,"blobs");if(ts(s))for(let a of zc(s))o.has(a)||qm(st(s,a),{force:!0})}function zm(e,t){let n=st(li(e),"generations",Kc(t));if(!ts(n))return null;let r=Uc(j(n,{maxBytes:te,inputKind:"TypeScript overlay manifest"}));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function oT(e,t){let n=Jc(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=H(r);return _m({blobDir:st(li(e),"blobs"),blobHash:i,bytes:r,relativePath:n,inputKind:"TypeScript overlay blob"}),{relativePath:n,blobHash:i,byteLength:r.byteLength}}function sT(e,t){let n=st(li(e),"generations",Kc(t.generationIdentity));if(ts(n)){let r=Uc(j(n,{maxBytes:te,inputKind:"TypeScript overlay manifest"}));if(Hm(r)!==Hm(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}Jt(n,t,{spacing:2,trailingNewline:!0})}function Uc(e){let t=JSON.parse(e);if(t.version!==ns||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let n=new Set;for(let r of t.overlays){if(!r||typeof r.relativePath!="string"||r.blobHash!==null&&(typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash))||!Number.isInteger(r.byteLength)||r.byteLength<0||r.blobHash===null&&r.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(Jc(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function li(e){return st(e,ci)}function Kc(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${H(e)}.json`}function Hm(e){return H(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function Jc(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}import{writeFileSync as aT}from"fs";import{create as Um}from"@bufbuild/protobuf";import{deserializeSCIP as cT,DocumentSchema as lT,IndexSchema as uT,serializeSCIP as dT,SymbolRole as pT}from"@c4312/scip";function SV(e){let t;try{t=cT(ee(e,{inputKind:"SCIP sanitization input",maxBytes:be}))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=Xc(t);return n.removedDefinitionOccurrences>0&&aT(e,dT(n.index)),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function Xc(e){let t=new Set;for(let o of e.documents){Re(o.relativePath);for(let s of o.symbols)s.symbol&&t.add(s.symbol)}for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let n=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&pT.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(Um(lT,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:Um(uT,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{writeFileSync as Yc}from"fs";import{create as ui}from"@bufbuild/protobuf";import{deserializeSCIP as Qc,serializeSCIP as Zc,DocumentSchema as fT,IndexSchema as Km,MetadataSchema as mT,SymbolInformationSchema as gT}from"@c4312/scip";function Jm(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=hT(e),n=ST(e.flatMap(i=>i.documents??[])),r=Ym(e.flatMap(i=>i.externalSymbols??[]));return ui(Km,{metadata:t,documents:n,externalSymbols:r})}function CV(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Qc(ee(i,{inputKind:"SCIP merge input",maxBytes:be}))),r=Jm(n);return Yc(t,Zc(r)),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function wV(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=z("reindex.publish.scip-output.deserialize",()=>e.map(o=>Qc(ee(o,{inputKind:"SCIP merge input",maxBytes:be})))),r=z("reindex.publish.scip-output.merge",()=>Jm(n)),i=z("reindex.publish.scip-output.sanitize",()=>Xc(r));return z("reindex.publish.scip-output.serialize",()=>Yc(t,Zc(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,touchedDocuments:i.touchedDocuments}}function yT(e,t,n){let r=e.metadata;if(!r)throw new Error("Cannot rebase a SCIP index without metadata");if(r.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${r.projectRoot}`);return ui(Km,{metadata:ui(mT,{...r,projectRoot:n}),documents:e.documents,externalSymbols:e.externalSymbols})}function Xm(e,t,n){let r=Qc(ee(e,{inputKind:"SCIP normalization input",maxBytes:be})),i=yT(r,t,n);Yc(e,Zc(i))}function hT(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function ST(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}t.set(n.relativePath,ui(fT,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:bT([...r.occurrences,...n.occurrences]),symbols:Ym([...r.symbols,...n.symbols]),text:vT(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function bT(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify(r);t.has(i)||(t.add(i),n.push(r))}return n}function Ym(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,ui(gT,{symbol:r.symbol,documentation:IT([...r.documentation,...n.documentation]),relationships:xT([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function xT(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function vT(e,t){return e?t?e.length>=t.length?e:t:e:t}function IT(e){return[...new Set(e)]}import{createHash as sl}from"crypto";import{closeSync as ET,existsSync as A,mkdirSync as PT,openSync as RT,readSync as CT,readdirSync as al,renameSync as rl,rmSync as di,statSync as Tn}from"fs";import{basename as cl,dirname as at,join as N,relative as Qm}from"path";var il=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function eg(e){let t=J(e.outputDb),n=NT(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=_T(e,n),o=ul({generationRoot:t,databasePath:e.tempOutputDb,indexPath:A(r)?r:void 0,verifiedIndexArtifact:i,metadataPath:A(e.tempMetaPath)?e.tempMetaPath:void 0}),s=(e.now??(()=>new Date))().toISOString(),a={version:Fn,currentGeneration:o.identity,artifactSet:"immutable-v1",...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:s},c=_e(N(t,"state.json"),a,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||nl(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),nl(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),nl(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let l=o.identity,u={...a,stableMirrors:ll(e.outputDb,e.outputScip)};_e(N(t,"state.json"),u,{spacing:2,trailingNewline:!0});let d=tg(e.outputDb,{now:e.now}),p=q(o.directorySync,c.directorySync);return{currentGeneration:l,...n?{previousGeneration:n}:{},retention:d,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}function wT(e,t,n,r=()=>new Date){if(!A(e))return null;let i=Xt(e),o=N(J(e),"state.json");if(i?.artifactSet==="immutable-v1"&&oi(e,i.currentGeneration))return i;let s=J(e),a=!i&&A(o)?DT(n,e,t):void 0;if(a&&!si(s,a))return null;let c=ul({generationRoot:s,databasePath:e,indexPath:A(t)?t:void 0,metadataPath:A(n)?n:void 0,forcedIdentity:i?.currentGeneration??a}),l={version:Fn,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:ll(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??r().toISOString()};return _e(N(s,"state.json"),l,{spacing:2,trailingNewline:!0}),l}function BV(e,t,n=()=>new Date){if(!A(e)||!A(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=Xt(e),i=J(e),o=ul({generationRoot:i,databasePath:e,indexPath:A(N(at(e),"index.scip"))?N(at(e),"index.scip"):void 0,metadataPath:t}),s=r&&r.currentGeneration!==o.identity?ig(e,r.currentGeneration):void 0,a={version:Fn,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:ll(e,N(at(e),"index.scip")),...s?{previousGeneration:s}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return _e(N(J(e),"state.json"),a,{spacing:2,trailingNewline:!0}),tg(e,{now:n}),a}function tg(e,t={}){let n=FT(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=Tt(Yo(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:"another process owns local generation retention"};try{let s=Xt(e),a=ng(e),c=jc(e,a.map(m=>m.identity),{isProcessAlive:t.isProcessAlive??wn,readProcessIdentity:t.readProcessIdentity??wt}),l=new Set(c.protectedGenerations);s?.currentGeneration&&l.add(s.currentGeneration),s?.previousGeneration?.generationIdentity&&l.add(s.previousGeneration.generationIdentity);let u=a.length,d=a.reduce((m,S)=>m+S.logicalBytes,0),p=0,f=0;for(let m of a){if(u<=n.maxGenerations&&d<=n.maxLogicalBytes)break;l.has(m.identity)||(t.onBeforeRemove?.(m.identity),di(m.path,{recursive:!0,force:!0}),u-=1,d-=m.logicalBytes,p+=1,f+=m.logicalBytes)}let g=u>n.maxGenerations||d>n.maxLogicalBytes,y={state:g?"protected":p>0?"collected":"within-bounds",generationCount:u,logicalBytes:d,protectedGenerations:l.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:p,removedLogicalBytes:f,limits:n,at:i,...g?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return Zm(e,y),y}catch(s){let a={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:s instanceof Error?s.message:String(s)};try{Zm(e,a)}catch{}return a}finally{o.release()}}function $V(e){let t=J(e);if(!A(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...il},reason:"local immutable generation store does not exist"};let n=TT(e),r=n?.limits??{...il},i=Tt(Yo(e),{waitMs:0});if(!i)return{state:"deferred",generationCount:n?.generationCount??0,logicalBytes:n?.logicalBytes??0,protectedGenerations:n?.protectedGenerations??0,activeReaderLeases:n?.activeReaderLeases??0,malformedReaderLeases:n?.malformedReaderLeases??0,limits:r,...n?{lastCollection:n}:{},reason:"another process owns local generation retention"};try{let o=ng(e),s=Xt(e),a=jc(e,o.map(l=>l.identity),{isProcessAlive:wn,readProcessIdentity:wt},{removeStale:!1}),c=new Set(a.protectedGenerations);return s?.currentGeneration&&c.add(s.currentGeneration),s?.previousGeneration?.generationIdentity&&c.add(s.previousGeneration.generationIdentity),{state:"managed",generationCount:o.length,logicalBytes:o.reduce((l,u)=>l+u.logicalBytes,0),...o[0]?{oldestGenerationAt:new Date(o[0].modifiedAtMs).toISOString()}:{},protectedGenerations:c.size,activeReaderLeases:a.activeLeases,malformedReaderLeases:a.malformedLeases,limits:r,...n?{lastCollection:n}:{},...a.malformedLeases>0?{reason:"malformed reader ownership evidence prevents unsafe collection"}:{}}}catch(o){return{state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:r,...n?{lastCollection:n}:{},reason:o instanceof Error?o.message:String(o)}}finally{i.release()}}function FT(e={}){let t={...il,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function ng(e){let t=J(e);return A(t)?al(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^[a-f0-9]{64}$/.test(n.name)).map(n=>{let r=N(t,n.name),i=si(t,n.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):rg(r);return{identity:n.name,path:r,logicalBytes:o,modifiedAtMs:Tn(r).mtimeMs}}).sort((n,r)=>n.modifiedAtMs-r.modifiedAtMs||n.identity.localeCompare(r.identity)):[]}function rg(e){let t=0;for(let n of al(e,{withFileTypes:!0})){let r=N(e,n.name);n.isDirectory()?t+=rg(r):n.isFile()&&(t+=Tn(r).size)}return t}function Zm(e,t){Jt(N(J(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function TT(e){try{let t=JSON.parse(T(N(J(e),"gc.json"),"local SQLite generation GC status"));return!t||t.state!=="within-bounds"&&t.state!=="collected"&&t.state!=="protected"&&t.state!=="deferred"&&t.state!=="error"||!Number.isSafeInteger(t.generationCount)||t.generationCount<0||!Number.isFinite(t.logicalBytes)||t.logicalBytes<0||!Number.isFinite(Date.parse(t.at))?void 0:t}catch{return}}function is(e,t=N(at(e),"meta.json")){let n=N(J(e),"state.json");if(!A(n))return{state:"legacy",statePath:n};let r=Xt(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=oi(e,r.currentGeneration),o=i!==null,s=i?kT(e,t,i,r):!1,a=r.previousGeneration?A(N(at(e),r.previousGeneration.databasePath)):!0;return!s||!o||!a?{state:"drifted",statePath:n,currentMatches:s,recoveryExists:a,generation:r,reason:o?s?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:n,currentMatches:s,recoveryExists:a,generation:r}}catch(i){return{state:"drifted",statePath:n,currentMatches:!1,recoveryExists:!1,generation:r,reason:i instanceof Error?i.message:String(i)}}}function kT(e,t,n,r){if(r.stableMirrors&&(r.stableMirrors.databaseFileIdentity!==kt(e)||r.stableMirrors.indexFileIdentity!==void 0&&r.stableMirrors.indexFileIdentity!==kt(N(at(e),"index.scip")))||!ol(e,n.database))return!1;let i=N(at(e),"index.scip");if(n.index&&!ol(i,n.index))return!1;if(!n.metadata)return!A(t);if(!A(t))return!1;let o=N(J(e),n.identity,n.metadata.file);return A(o)&&Yt(T(t,"reindex metadata"))===Yt(T(o,"immutable reindex metadata"))}function ol(e,t){return A(e)&&Tn(e).isFile()&&Tn(e).size===t.size}function NT(e){let t=wT(e.outputDb,e.outputScip,e.metaPath);return t?ig(e.outputDb,t.currentGeneration):void 0}function _T(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let n=is(e.outputDb,e.metaPath);if(n.state!=="current"||n.generation.currentGeneration!==t.generationIdentity){let i=n.state==="current"?"generation identity changed":"reason"in n?n.reason:`generation state is ${n.state}`;throw new Error(`deferred SCIP publication requires a verified accepted companion: ${i}`)}let r=oi(e.outputDb,t.generationIdentity);if(!r?.index||!ol(e.outputScip,r.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return r.index}function ll(e,t){return{databaseFileIdentity:kt(e),...A(t)?{indexFileIdentity:kt(t)}:{}}}function ig(e,t){let n=N(J(e),t),r=N(n,cl(e)),i=N(n,"meta.json");return{generationIdentity:t,databasePath:Qm(at(e),r),...A(i)?{metadataPath:Qm(at(e),i)}:{}}}function LT(e){if(A(e))for(let t of al(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&di(N(e,t.name),{recursive:!0,force:!0})}function DT(e,t,n=N(at(t),"index.scip")){let r=sl("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(rs(t)),A(n)&&r.update(`\0${rs(n)}`),A(e)&&r.update(`\0${Yt(T(e,"reindex metadata"))}`),r.digest("hex")}function ul(e){let t=el(e.databasePath),n=e.indexPath?e.verifiedIndexArtifact?OT(e.indexPath,e.verifiedIndexArtifact):el(e.indexPath):void 0,r=e.metadataPath?el(e.metadataPath):void 0,i=e.forcedIdentity??AT(t,n,e.metadataPath),o=N(e.generationRoot,i),s=N(o,Xo);if(A(s)){let l=si(e.generationRoot,i);if(l&&og(o,l.database,t)&&jT(o,l.index,n)&&BT(o,l.metadata,e.metadataPath))return{identity:i,directorySync:L(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let a=[ue(e.generationRoot)];LT(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;di(c,{recursive:!0,force:!0}),PT(c,{recursive:!0});try{a.push(tl(e.databasePath,N(c,t.file))),n&&e.indexPath&&a.push(tl(e.indexPath,N(c,n.file))),r&&e.metadataPath&&a.push(tl(e.metadataPath,N(c,r.file)));let l=_e(N(c,Xo),{version:Mc,identity:i,database:t,...n?{index:n}:{},...r?{metadata:r}:{}},{spacing:2,trailingNewline:!0});l.directorySync!=="not-requested"&&a.push(l.directorySync),a.push(L(c)),rl(c,o),a.push(L(e.generationRoot))}finally{di(c,{recursive:!0,force:!0})}return{identity:i,directorySync:q(...a)}}function AT(e,t,n){let r=sl("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${Yt(T(n,"reindex metadata"))}`),r.digest("hex")}function el(e){return{file:cl(e),size:Tn(e).size,sha256:rs(e)}}function OT(e,t){if(t.file!==cl(e)||Tn(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function rs(e){let t=sl("sha256"),n=RT(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=MT(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{ET(n)}return t.digest("hex")}function MT(e,t){let n=0;for(;n<t.length;){let r=CT(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function tl(e,t){return Zr(e,t,{mode:292})}function og(e,t,n){let r=N(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&A(r)&&Tn(r).size===t.size&&rs(r)===t.sha256}function jT(e,t,n){return!t||!n?t===n:og(e,t,n)}function BT(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=N(e,t.file);return A(r)&&Yt(T(r,"stored reindex metadata"))===Yt(T(n,"candidate reindex metadata"))}function nl(e,t){di(`${t}.tmp-replace`,{force:!0}),rl(e,`${t}.tmp-replace`),rl(`${t}.tmp-replace`,t)}import{createHash as yg,randomUUID as zT}from"crypto";import{existsSync as lt,lstatSync as fl,mkdirSync as mr,mkdtempSync as hg,readdirSync as Sg,realpathSync as bg,renameSync as kn,rmSync as Qt,statSync as ls}from"fs";import{dirname as ml,join as E,resolve as Nt}from"path";import{setTimeout as UT}from"timers/promises";import{pathToFileURL as lg}from"url";import{deserializeSCIP as xg}from"@c4312/scip";import KT from"better-sqlite3";import{lstatSync as $T,readdirSync as GT}from"fs";import{join as VT,relative as qT,resolve as dl,sep as WT}from"path";var pi=1,pl="language-indexes",sg=["index.db","index.scip","meta.json"],ag=[pl,ai,ci];function os(e){let t=[];for(let n of sg)HT(e,n),t.push(n);for(let n of ag)cg(e,n,t);return{version:pi,files:t.sort()}}function ss(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(r=>!r||r==="."||r===".."))throw new Error(`invalid index artifact path: ${e}`);let n=t[0];if(!sg.includes(e)&&!ag.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function ct(e,t){let n=ss(t),r=dl(e),i=dl(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${WT}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function cg(e,t,n){let r=VT(e,t),i;try{i=GT(r,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let s=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${s}`);o.isDirectory()?cg(e,s,n):o.isFile()&&n.push(ss(s))}}function HT(e,t){let n=ct(e,t),r;try{r=$T(n)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!r.isFile()||r.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(qT(dl(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var yl=1,ug="SCIP_QUERY_SHARED_CACHE",JT=2,as=JSON.stringify({cliVersion:Di,artifactCatalogVersion:pi,postIndexAugmentationSchemaVersion:JT,sqliteGenerationStoreVersion:Fn,typescriptFragmentStoreVersion:Hc,typescriptOverlayStoreVersion:ns}),hl="manifest.json",vg="shared-cache.json",XT=6e4,Sl=[pl,ai,ci];function cs(e,t){if(!e.clean||!e.treeOid)return;let n=wg(JSON.stringify({version:yl,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:Ai(t),producerIdentity:as}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:as,generationId:n,repositoryCacheDir:Qi(e.repositoryId)}}function Sq(e,t,n){if(!ck(n))return!1;let r=cs(e,n);if(!r)return!1;try{let i=Rg(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(j(E(r.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:te}));return o.version!==1||o.repositoryId!==i.repositoryId||o.worktreeId!==i.worktreeId||Nt(o.projectRoot)!==Nt(e.projectRoot)||o.treeOid!==e.treeOid||Nt(o.localCacheDir)!==Nt(t)||o.ownershipChecksum!==us(o)||o.baseGenerationId!==r.generationId||o.activeGenerationId!==r.generationId?!1:_t(r,!1)!==null}catch{return!1}}function Ig(e,t,n){if(process.env[ug]==="0")return`${ug}=0`;if(!la(n))return"explicit cache or database override";if(da(ml(t))!==da(Yi(e))||t!==E(ml(t),"index.db"))return"index database is outside the managed worktree cache"}function bq(e,t,n){if(!la(t))return;let r=n??Rr(e);return r?E(Qi(r.repositoryId),"evidence.db"):void 0}function _t(e,t=!0){let n=bl(e),r;try{r=Pg(j(E(n,hl),{inputKind:"shared-generation manifest",maxBytes:te}))}catch{return null}if(r.generationId!==e.generationId||r.repositoryId!==e.repositoryId||r.treeOid!==e.treeOid||r.producerIdentity!==e.producerIdentity||!Ir(r.fingerprint,e.fingerprint)||!nk(n))return null;if(!t)return r;try{for(let i of r.artifacts){let o=ct(n,i.path),s=ls(o);if(!s.isFile()||s.size!==i.size||an(o,{inputKind:"shared-generation artifact",maxBytes:be})!==i.sha256)return null}}catch{return null}return r}function dg(e,t,n,r){if(!e.treeOid)return null;let i=Un(t,n),o=E(Xi(),"repositories",e.repositoryId),s;try{let l=fl(o);if(!l.isDirectory()||l.isSymbolicLink())return null;s=bg(o)}catch{return null}let a=E(s,"generations"),c=[];try{for(let l of Sg(a)){if(!/^[a-f0-9]{64}$/.test(l))continue;let u=E(a,l),d;try{d=fl(u)}catch{continue}if(!(!d.isDirectory()||d.isSymbolicLink()))try{let p=Pg(j(E(u,hl),{inputKind:"shared-generation baseline manifest",maxBytes:te}));p.generationId===l&&p.repositoryId===e.repositoryId&&p.producerIdentity===as&&rk(p.fingerprint,i)&&c.push(p)}catch{continue}}}catch{return null}c.sort((l,u)=>{let d=l.treeOid===e.treeOid?0:1,p=u.treeOid===e.treeOid?0:1;if(d!==p)return d-p;if(r){let g=gg(l.fingerprint,r)-gg(u.fingerprint,r);if(g!==0)return g}return Date.parse(u.createdAt)-Date.parse(l.createdAt)||l.generationId.localeCompare(u.generationId)});for(let l of c){let u={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:l.treeOid,fingerprint:l.fingerprint,producerIdentity:l.producerIdentity,generationId:l.generationId,repositoryCacheDir:s},d=_t(u);if(d)return{snapshot:u,manifest:d}}return null}function Eg(e){let t=Tt(E(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return YT(e)}finally{t.release()}}function YT(e){let t=_t(e.snapshot);if(t)return pg(e.snapshot,t);if(!hi(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=mg(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=os(e.sourceCacheDir),i=E(e.snapshot.repositoryCacheDir,"generations"),o=[ue(i)],s=hg(E(i,`.tmp-${process.pid}-`));try{let a=[];for(let g of r.files){let y=ct(e.sourceCacheDir,g),m=ct(s,g);o.push(Si(y,m,292)),e.onPublicationStage?.("after-artifact-flushed",g);let S=ls(m).size;a.push({path:g,size:S,sha256:an(m,{inputKind:"staged shared-generation artifact",maxBytes:be})})}let c=xg(ee(E(s,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:be})).metadata?.projectRoot;if(!c)throw new Error("shared SCIP generation has no project root metadata");let l=vl(e.sourceProjectRoot);if(c!==l)throw new Error("shared SCIP generation root does not match its source worktree");if(mg(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let u={version:yl,artifactCatalogVersion:pi,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:a.sort((g,y)=>g.path.localeCompare(y.path))},d=_e(E(s,hl),u,{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&o.push(d.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(L(s)),e.onPublicationStage?.("after-staging-directory-synced");let p=bl(e.snapshot);try{if(lt(p)&&!_t(e.snapshot)){let g=`${p}.corrupt-${process.pid}-${Date.now()}`;kn(p,g),Qt(g,{recursive:!0,force:!0})}kn(s,p)}catch(g){let y=_t(e.snapshot);if(y)return pg(e.snapshot,y);throw g}e.onPublicationStage?.("after-generation-renamed"),o.push(L(i)),e.onPublicationStage?.("after-generations-directory-synced");let f=q(...o);return{kind:"published",manifest:u,achievedDurability:f==="synced"?"directory-durable":"file-flushed",directorySync:f}}finally{Qt(s,{recursive:!0,force:!0})}}function pg(e,t){let n=L(E(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:n==="synced"?"directory-durable":"file-flushed",directorySync:n}}function mi(e){let t=bl(e.snapshot);mr(e.targetCacheDir,{recursive:!0});let n=Tt(E(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:e.lockWaitMs??3e4});if(!n)throw new Error("timed out waiting for another cache hydration");let r,i,o=!1;try{r=hg(E(e.targetCacheDir,".shared-hydrate-")),ak(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=ct(t,c.path),u=ct(r,c.path);if(Si(l,u),ls(u).size!==c.size||an(u,{inputKind:"hydrated shared-generation artifact",maxBytes:be})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=vl(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Xm(ct(r,c.path),e.manifest.scipProjectRoot,s);if(!hi(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=ik(e.targetCacheDir,r),o=!0,ok(r,e.targetCacheDir,i),eg({tempOutputScip:E(r,"index.scip"),tempOutputDb:E(r,"index.db"),tempMetaPath:E(r,"meta.json"),outputScip:E(e.targetCacheDir,"index.scip"),outputDb:E(e.targetCacheDir,"index.db"),metaPath:E(e.targetCacheDir,"meta.json"),now:e.now});let a=is(E(e.targetCacheDir,"index.db"),E(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);e.persistLease!==!1&&gl(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&sk(e.targetCacheDir,i),s}finally{r&&Qt(r,{recursive:!0,force:!0}),n.release()}}function xq(e,t,n,r){let i=Ig(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??Rr(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean){if(lt(n.dbPath))return yi(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let d=t.languages??Zo(e),p=zn(e,d,gi(t)),f=dg(o,d,gi(t),p);return f?(mi({snapshot:f.snapshot,manifest:f.manifest,targetCacheDir:n.cacheDir,targetProjectRoot:e,persistLease:!1,lockWaitMs:0}),fg(f.snapshot,n.cacheDir),{kind:"overlay"}):(yi(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"})}let s=t.languages??Zo(e),a=zn(e,s,gi(t)),c=cs(o,a);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let l=_t(c);if(l)return mi({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let u=ek(c,e);if(!u){if(!lt(n.dbPath)){let d=dg(o,s,gi(t),a);if(d)return mi({snapshot:d.snapshot,manifest:d.manifest,targetCacheDir:n.cacheDir,targetProjectRoot:e,persistLease:!1,lockWaitMs:0}),fg(d.snapshot,n.cacheDir),{kind:"overlay"}}return yi(o,n.cacheDir,"missed",void 0,"no exact shared or peer generation exists"),{kind:"missed",reason:"no exact shared or peer generation exists"}}return l=u.manifest,mi({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e,action:"peer-imported"}),{kind:"peer-imported",generationId:c.generationId,sourceProjectRoot:u.sourceProjectRoot}}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}function vq(e,t,n,r){let i=Ig(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??Rr(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return yi(o,n.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let s=t.languages??Zo(e),a=zn(e,s,gi(t)),c=cs(o,a);if(!c)return yi(o,n.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let l=_t(c);if(l)return hi(n.cacheDir,e,a)?(gl(c,n.cacheDir,"local-fresh"),{kind:"local-fresh"}):(mi({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let u=ds(n.cacheDir);return!u||!Ir(vr(u.fingerprint),a)||JSON.stringify([...u.indexedLanguages??[]].sort())!==JSON.stringify([...s].sort())?{kind:"missed",reason:"local metadata does not match the clean worktree snapshot"}:hi(n.cacheDir,e,a)?(Eg({snapshot:c,sourceCacheDir:n.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let d=Rr(e);return(d?cs(d,a):void 0)?.generationId===c.generationId}}),gl(c,n.cacheDir,"built"),{kind:"built",generationId:c.generationId}):{kind:"missed",reason:"local index artifacts are incomplete or incompatible"}}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}async function Iq(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??Ft,o=i()+n,s=E(e.repositoryCacheDir,"locks"),a=E(s,`${e.generationId}.lock`),c=l=>{if(!l||typeof l!="object"||Array.isArray(l))return null;let u=l.pid;return typeof u=="number"&&Number.isSafeInteger(u)&&u>0?{pid:u}:null};for(;i()<=o;){if(_t(e))return{kind:"generation-ready"};let l=Ko(a,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(l.kind==="acquired")return{kind:"owner",release:()=>l.lock.release()};let u=o-i();if(u<=0)break;await UT(Math.min(r,u))}return _t(e)?{kind:"generation-ready"}:{kind:"timeout"}}function gl(e,t,n,r=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:n,lastSeenAt:(r??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:us(i)};return xl(e.repositoryCacheDir,o,!0),o}function fg(e,t,n=void 0){let r={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(n??(()=>new Date))().toISOString()},i={...r,ownershipChecksum:us(r)};return xl(e.repositoryCacheDir,i,!0),i}function yi(e,t,n,r=void 0,i=void 0){let o={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,lastAction:n,...i?{lastReason:i}:{},lastSeenAt:(r??(()=>new Date))().toISOString()},s={...o,ownershipChecksum:us(o)},a=Qi(e.repositoryId),c=QT(a,s);return c||(xl(a,s,!1),s)}function QT(e,t){try{let n=Rg(t.localCacheDir);if(!n||n.repositoryId!==t.repositoryId||n.worktreeId!==t.worktreeId)return null;let r=JSON.parse(j(E(e,"worktrees",`${t.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:te})),i=Date.parse(t.lastSeenAt)-Date.parse(r.lastSeenAt);return ZT(r,t)&&Number.isFinite(i)&&i<XT?r:null}catch{return null}}function ZT(e,t){return e.version===t.version&&e.repositoryId===t.repositoryId&&e.worktreeId===t.worktreeId&&e.projectRoot===t.projectRoot&&e.treeOid===t.treeOid&&e.localCacheDir===t.localCacheDir&&e.baseGenerationId===t.baseGenerationId&&e.activeGenerationId===t.activeGenerationId&&e.ownershipChecksum===t.ownershipChecksum&&e.lastAction===t.lastAction&&e.lastReason===t.lastReason}function us(e){return wg(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:Nt(e.projectRoot),localCacheDir:Nt(e.localCacheDir)}))}function Pg(e){let t=JSON.parse(e);if(t.version!==yl||t.artifactCatalogVersion!==pi||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==as||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let n=new Set;for(let r of t.artifacts){if(!r||typeof r.path!="string"||typeof r.size!="number"||r.size<0||typeof r.sha256!="string"||!/^[a-f0-9]{64}$/.test(r.sha256))throw new Error("invalid shared generation artifact");if(ss(r.path),n.has(r.path))throw new Error(`duplicate shared generation artifact: ${r.path}`);n.add(r.path)}for(let r of["index.db","index.scip","meta.json"])if(!n.has(r))throw new Error(`shared generation is missing ${r}`);return t}function Si(e,t,n=384){return Zr(e,t,{mode:n})}function ek(e,t){for(let n of Wu(t)){if(Nt(n.path)===Nt(t))continue;let r=Yi(n.path),i=ds(r);if(!(!i||JSON.stringify(i.fingerprint)!==JSON.stringify(e.fingerprint)||JSON.stringify([...i.indexedLanguages??[]].sort())!==JSON.stringify([...e.fingerprint.languages].sort()))&&hi(r,n.path,e.fingerprint))try{return{manifest:Eg({snapshot:e,sourceCacheDir:r,sourceProjectRoot:n.path}).manifest,sourceProjectRoot:n.path}}catch{continue}}return null}function tk(e,t,n){mr(e,{recursive:!0}),_e(E(e,vg),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function mg(e){try{let t=os(e),n=yg("sha256");for(let r of t.files){let i=ct(e,r),o=ls(i).size;n.update(r).update("\0").update(String(o)).update("\0"),$n(i,{inputKind:"source-generation artifact",maxBytes:be},s=>n.update(s)),n.update("\0")}return n.digest("hex")}catch{return null}}function ds(e){try{let t=Ot(j(E(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:te}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function nk(e){return ds(e)?.scipCompanion!=="deferred"}function gi(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function rk(e,t){let n=Un(e.languages,e);return JSON.stringify(n)===JSON.stringify(t)}function gg(e,t){let n=new Map(e.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),r=new Map(t.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),i=0;for(let[o,s]of n)r.get(o)!==s&&(i+=1);for(let o of r.keys())n.has(o)||(i+=1);return i}function bl(e){return E(e.repositoryCacheDir,"generations",e.generationId)}function Rg(e){let t=JSON.parse(j(E(e,vg),{inputKind:"worktree cache pointer",maxBytes:te}));return t.version!==1||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.worktreeId!="string"||!/^[a-f0-9]{24}$/.test(t.worktreeId)?null:{version:t.version,repositoryId:t.repositoryId,worktreeId:t.worktreeId}}function xl(e,t,n){let r=mm(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!lt(E(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=E(e,"worktrees");mr(i,{recursive:!0}),_e(E(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),tk(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function ik(e,t){let n=E(t,".rollback"),r=new Map,i=new Map;mr(n,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=E(e,a),l=lt(c);r.set(a,l),l&&Si(c,E(n,"stable",a))}for(let a of Sl){let c=E(e,a),l=lt(c);if(l){let u=fl(c);if(!u.isDirectory()||u.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=E(e,ii),s=lt(o);return s&&Cg(o,E(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:s}}function ok(e,t,n){for(let r of Sl){let i=E(t,r);if(n.managedDirectories.get(r)){let s=E(n.root,"managed",r);mr(ml(s),{recursive:!0}),kn(i,s)}let o=E(e,r);lt(o)&&kn(o,i)}}function sk(e,t){for(let i of Sl){let o=E(e,i),s=E(t.root,"managed",i);t.managedDirectories.get(i)?lt(s)&&(Qt(o,{recursive:!0,force:!0}),kn(s,o)):Qt(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=E(e,i);if(!o){Qt(s,{force:!0});continue}let a=`${s}.shared-restore-${zT()}`;Si(E(t.root,"stable",i),a),Qt(s,{force:!0}),kn(a,s)}let n=E(e,ii);Qt(n,{recursive:!0,force:!0});let r=E(t.root,"sqlite-generations");t.generationStoreExisted&&lt(r)&&kn(r,n)}function Cg(e,t){mr(t,{recursive:!0});for(let n of Sg(e,{withFileTypes:!0})){let r=E(e,n.name),i=E(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?Cg(r,i):n.isFile()&&Si(r,i)}}function ak(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!Ir(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function hi(e,t,n,r=!0,i=!0){try{let o=ds(e);if(!o||o.scipCompanion==="deferred"||!Ir(vr(o.fingerprint),n)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...n.languages].sort()))return fi("source validation rejected metadata"),!1;let s=os(e),a=is(E(e,"index.db"),E(e,"meta.json"));if(r?a.state!=="current":a.state==="invalid"||a.state==="drifted")return fi(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new KT(E(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let l=vl(t),d=(i?s.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let f=xg(ee(ct(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:be})).metadata?.projectRoot;return f!==l&&fi(`source validation rejected SCIP root for ${p}: ${String(f)}`),f===l});return d||fi("source validation rejected SCIP project roots"),d}catch(o){return fi(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function fi(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function vl(e){try{return lg(bg(e)).href}catch{return lg(Nt(e)).href}}function ck(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&Array.isArray(t.languages)&&typeof t.pnpmWorkspaces=="boolean"&&(t.typescriptProjectMode==="single"||t.typescriptProjectMode==="workspace")&&Array.isArray(t.typescriptProjects)&&Array.isArray(t.files)&&t.files.every(n=>n!==null&&typeof n=="object"&&typeof n.path=="string"&&typeof n.size=="number"&&typeof n.hash=="string"&&(n.semanticHash===void 0||typeof n.semanticHash=="string"))}function wg(e){return yg("sha256").update(e).digest("hex")}import{spawn as fk}from"child_process";import{platform as jg}from"os";import{performance as Bg}from"perf_hooks";import{execFileSync as kg}from"child_process";import{platform as lk}from"os";var Ng=1e3,_g=2*1024*1024,uk=25;function Lg(e,t,n=Mg){let r=n.readIdentity(e),i=new Map;return r&&i.set(e,r),{rootPid:e,rootIdentity:r,ownsProcessGroup:t,knownMembers:i}}async function Dg(e,t,n=Mg){if(!e.rootIdentity){let c=await bi(e,t.gracefulMs+t.forceMs,n);return{reaped:c,reason:c?"terminated":"identity-unavailable",detail:c?void 0:`Could not establish the birth identity of process ${e.rootPid}.`}}let r=Ag(e,n);if(r==="mismatch")return{reaped:!1,reason:"identity-mismatch",detail:`Process ${e.rootPid} no longer has the identity owned by this runner.`};if(r==="exited"&&!Og(e,n))return{reaped:!0,reason:"terminated"};if(n.platform==="win32"){try{n.terminateWindowsTree(e.rootPid)}catch(l){let u=await bi(e,t.forceMs,n);return{reaped:u,reason:u?"terminated":"signal-failed",detail:u?void 0:Il(l)}}let c=await bi(e,t.forceMs,n);return{reaped:c,reason:c?"terminated":"deadline"}}let i=Fg(e,"SIGTERM",n);if(await bi(e,t.gracefulMs,n))return{reaped:!0,reason:"terminated"};let s=Fg(e,"SIGKILL",n);return await bi(e,t.forceMs,n)?{reaped:!0,reason:"terminated"}:s?{reaped:!1,reason:s.reason,detail:s.detail}:i?{reaped:!1,reason:i.reason,detail:i.detail}:{reaped:!1,reason:"deadline",detail:`Process tree ${e.rootPid} did not exit before its termination deadline.`}}function Ag(e,t){let n=t.readIdentity(e.rootPid);if(!n)return"exited";if(!e.rootIdentity||!Ne(e.rootIdentity,n))return"mismatch";e.knownMembers.set(e.rootPid,n);for(let r of t.listDescendantPids(e.rootPid)){let i=t.readIdentity(r);i&&e.knownMembers.set(r,i)}return"owned"}function Fg(e,t,n){let r=Ag(e,n);if(r==="mismatch")return{reason:"identity-mismatch",detail:`Process ${e.rootPid} changed identity before ${t}.`};if(r==="owned"&&e.ownsProcessGroup)try{return n.signal(-e.rootPid,t),null}catch(o){if(!Tg(o))return{reason:"signal-failed",detail:Il(o)}}let i=null;for(let o of e.knownMembers.values()){let s=n.readIdentity(o.pid);if(!(!s||!Ne(o,s)))try{n.signal(o.pid,t)}catch(a){!Tg(a)&&i===null&&(i=Il(a))}}return i===null?null:{reason:"signal-failed",detail:i}}async function bi(e,t,n){let r=n.now()+t;for(;Og(e,n);){if(n.now()>=r)return!1;await n.sleep(Math.min(uk,Math.max(1,r-n.now())))}return!0}function Og(e,t){if(!e.rootIdentity&&t.isProcessAlive(e.rootPid))return!0;for(let n of e.knownMembers.values()){let r=t.readIdentity(n.pid);if(r&&Ne(n,r))return!0}return!!(e.ownsProcessGroup&&t.isProcessGroupAlive(e.rootPid))}function dk(e){let t=pk(!1),n=new Map;for(let s of t.split(/\r?\n/)){let a=/^\s*(\d+)\s+(\d+)\s*$/.exec(s);if(!a)continue;let c=Number(a[1]),l=Number(a[2]),u=n.get(l)??[];u.push(c),n.set(l,u)}let r=[],i=[...n.get(e)??[]],o=new Set;for(;i.length>0;){let s=i.pop();o.has(s)||(o.add(s),r.push(s),i.push(...n.get(s)??[]))}return r}function pk(e){return kg("ps",["-axo",e?"pid=,ppid=,rss=":"pid=,ppid="],{encoding:"utf8",timeout:Ng,maxBuffer:_g,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}function Tg(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ESRCH"}function Il(e){return e instanceof Error?e.message:String(e)}var Mg={platform:lk(),now:Date.now,readIdentity:wt,isProcessAlive(e){try{return process.kill(e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}},isProcessGroupAlive(e){if(this.platform==="win32")return!1;try{return process.kill(-e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}},listDescendantPids(e){if(this.platform==="win32")return[];try{return dk(e)}catch{return[]}},signal(e,t){process.kill(e,t)},terminateWindowsTree(e){kg("taskkill.exe",["/PID",String(e),"/T","/F"],{timeout:Ng,maxBuffer:_g,stdio:"ignore",windowsHide:!0})},async sleep(e){await new Promise(t=>setTimeout(t,e))}};var _q={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},vi=class extends Error{constructor(n,r,i,o={}){super(i,o.cause===void 0?void 0:{cause:o.cause});this.kind=n;this.label=r;this.name="BoundedProcessError",this.timedOut=o.timedOut??!1,this.reaped=o.reaped??!1,this.stdout=o.stdout??"",this.stderr=o.stderr??"",this.stdoutTruncated=o.stdoutTruncated??!1,this.stderrTruncated=o.stderrTruncated??!1}kind;label;timedOut;reaped;stdout;stderr;stdoutTruncated;stderrTruncated};function xi(e,t){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${t} must be a positive finite number.`)}function $g(e,t,n,r){let i=Math.max(0,r-n);i>0&&e.push(t.subarray(0,i))}function Gg(e,t,n){let r=Buffer.concat([...e,t]);e.length=0,e.push(r.subarray(Math.max(0,r.length-n)))}function Lq(e){xi(e.timeoutMs,"timeoutMs"),xi(e.maxStdoutBytes,"maxStdoutBytes"),xi(e.maxStderrBytes,"maxStderrBytes");let t=e.terminationGraceMs??1e3;xi(t,"terminationGraceMs");let n=e.terminationForceMs??t;return xi(n,"terminationForceMs"),new Promise((r,i)=>{let o=Bg.now(),s=jg()!=="win32"&&process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1",a=jg()!=="win32"&&!s,c;try{c=fk(e.command,[...e.args??[]],{cwd:e.cwd,env:e.env,detached:a?!0:e.detached,stdio:["pipe","pipe","pipe"]})}catch(v){let C=v instanceof Error?v.message:String(v);i(new vi("spawn",e.label,`${e.label} could not start: ${C}`,{cause:v,reaped:!0}));return}let l=[],u=[],d=0,p=0,f=!1,g=!1,y=null,m=!1,S=c.pid===void 0?null:Lg(c.pid,a),h=()=>{clearTimeout(I),e.signal?.removeEventListener("abort",b)},x=v=>{if(m||!y)return;m=!0,h();let C=Buffer.concat(l).toString("utf8"),M=Buffer.concat(u).toString("utf8"),Y=v.reaped||!v.detail?"":` Process-tree cleanup failed: ${v.detail}`;i(new vi(y.kind,e.label,`${y.message}${Y}`,{timedOut:y.timedOut,reaped:v.reaped,stdout:C,stderr:M,stdoutTruncated:f,stderrTruncated:g}))},P=v=>{if(!(y||m)){if(y=v,!S){x({reaped:c.pid===void 0,reason:c.pid===void 0?"terminated":"identity-unavailable"});return}Dg(S,{gracefulMs:t,forceMs:n}).then(x,C=>{x({reaped:!1,reason:"signal-failed",detail:C instanceof Error?C.message:String(C)})})}},I=setTimeout(()=>{P({kind:"timeout",timedOut:!0,message:`${e.label} timed out after ${e.timeoutMs}ms.`})},e.timeoutMs);I.unref();let b=()=>{P({kind:"aborted",timedOut:!1,message:`${e.label} was cancelled.`})};e.signal?.addEventListener("abort",b,{once:!0}),e.signal?.aborted&&b(),c.stdout.on("data",v=>{let C=Buffer.isBuffer(v)?v:Buffer.from(v);e.outputLimitBehavior==="truncate-tail"?Gg(l,C,e.maxStdoutBytes):$g(l,C,d,e.maxStdoutBytes),d+=C.length,d>e.maxStdoutBytes&&(f=!0,e.outputLimitBehavior!=="truncate-tail"&&P({kind:"stdout-limit",timedOut:!1,message:`${e.label} exceeded stdout limit (${e.maxStdoutBytes} bytes).`}))}),c.stderr.on("data",v=>{let C=Buffer.isBuffer(v)?v:Buffer.from(v);e.outputLimitBehavior==="truncate-tail"?Gg(u,C,e.maxStderrBytes):$g(u,C,p,e.maxStderrBytes),p+=C.length,p>e.maxStderrBytes&&(g=!0,e.outputLimitBehavior!=="truncate-tail"&&P({kind:"stderr-limit",timedOut:!1,message:`${e.label} exceeded stderr limit (${e.maxStderrBytes} bytes).`}))}),c.on("error",v=>{if(!m&&!y){if(c.pid===void 0){h(),m=!0,i(new vi("spawn",e.label,`${e.label} could not start: ${v.message}`,{cause:v,reaped:!0}));return}P({kind:"spawn",timedOut:!1,message:`${e.label} failed after start: ${v.message}`})}}),c.on("close",(v,C)=>{if(m||y)return;m=!0,h();let M=Buffer.concat(l).toString("utf8"),Y=Buffer.concat(u).toString("utf8");r({status:v,signal:C,stdout:M,stderr:Y,timedOut:!1,durationMs:Bg.now()-o,stdoutTruncated:f,stderrTruncated:g})}),e.input===void 0?c.stdin.end():c.stdin.end(e.input)})}function Oq(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function Vg(e){let t=Z(e);return mk(t)?"test":gk(t)?"worker":yk(t)?"entry":hk(t)?"barrel":"source"}function mk(e){return!!(/\.(?:test|spec)\.[a-z0-9]+$/i.test(e)||/(?:^|\/)(?:_)?test_[^/]+$/i.test(e)||/(?:^|\/)spec_[^/]+$/i.test(e)||/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i.test(e)||/(?:^|\/)[^/]+_tests\.rs$/i.test(e)||/(?:^|\/)tests\.rs$/i.test(e)||/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i.test(e)||/(?:^|\/)__tests__\//i.test(e)||/(?:^|\/)test\//i.test(e)||/(?:^|\/)tests\//i.test(e)||/(?:^|\/)__fixtures__\//i.test(e)||/(?:^|\/)__mocks__\//i.test(e)||/(?:^|\/)test-support\//i.test(e)||/(?:^|\/)test-utils\//i.test(e)||/(?:^|\/)testing\//i.test(e))}function gk(e){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(e)}function yk(e){let t=e.split("/"),n=t[t.length-1]??e;return n==="cli.ts"||n==="cli.js"||n==="postinstall.ts"||n==="postinstall.js"||n==="main.ts"||n==="main.js"||n==="main.rs"||n==="main.go"||n==="main.py"||n==="build.rs"||n==="lib.rs"||/\bsrc\/bin\/[^/]+\.rs$/.test(e)||/(?:^|\/)examples\/[^/]+\.rs$/.test(e)||/(?:^|\/)tests\/[^/]+\.rs$/.test(e)||/(?:^|\/)benches\/[^/]+\.rs$/.test(e)?!0:n==="index.ts"||n==="index.js"?/(?:^|\/)(?:apps|services)\/[^/]+\/src\/index\.(?:ts|js)$/.test(e)?!0:t.length<=2:!1}function hk(e){return e==="index.ts"||e==="index.js"||e.endsWith("/index.ts")||e.endsWith("/index.js")||e.endsWith("/mod.rs")||e.endsWith("/__init__.py")}import{createHash as El,randomUUID as Xg}from"crypto";import{existsSync as Lt,lstatSync as yr,mkdirSync as xk,readdirSync as _n,renameSync as Pl,rmSync as ut}from"fs";import{basename as gr,dirname as Rl,join as D}from"path";function qg(e){return ps(e,Sk)}function jq(e){return ps(e,bk)}function ps(e,t){return Array.isArray(e)?`[${e.map(n=>ps(n,t)).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([n],[r])=>t(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${ps(r,t)}`).join(",")}}`:JSON.stringify(e)}function Sk(e,t){return e.localeCompare(t)}function bk(e,t){return e<t?-1:e>t?1:0}var Cl=1,vk=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),dt=class extends Error{constructor(n,r,i,o){let s=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${s}. Retry after the service drains or expires retained work.`);this.code=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},Yg=".owner.json",wl={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function Jq(e){return{rootDir:e,pendingDir:D(e,"pending"),inflightDir:D(e,"inflight"),responseDir:D(e,"responses"),deadLetterDir:D(e,"dead-letter"),legacyRequestDir:D(e,"requests")}}function hr(e={}){let t={...vk,...e};for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return t}function ms(e){let t=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(n=>ue(n));return q(...t)}function Xq(e,t){return El("sha256").update(qg({namespace:e,payload:t})).digest("hex")}function Qg(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function Yq(e,t,n={}){let r=hr(n.limits),i=n.nowMs??Date.now(),o=ms(e);return Nk(t),Tl(e,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??Ft,n.durability??"durable",()=>{Fl(e,i,r);let s=D(e.pendingDir,`${t.id}.json`),a=D(e.responseDir,`${t.id}.json`),c=Wg(e,t.id);if(c){let p=Hg(c,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:p.deadlineAtMs??t.deadlineAtMs}}let l=`${JSON.stringify(t)}
393
- `,u=Buffer.byteLength(l),d=gs(e);if(u>r.maxItemBytes)throw new dt("item-too-large",d,r,u);if(d.totalItems+1>r.maxItems)throw new dt("item-capacity",d,r,u);if(d.totalBytes+u>r.maxBytes)throw new dt("byte-capacity",d,r,u);n.onBeforePublish?.();try{let p=n.durability??"durable",f=Mo(s,l,{durability:p}),g=p==="durable"?q(o,f.directorySync):"not-requested";return{disposition:"accepted",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:t.deadlineAtMs,achievedDurability:f.achievedDurability,directorySync:g}}catch(p){if(p.code!=="EEXIST")throw p;let f=Wg(e,t.id);if(!f)throw p;let g=Hg(f,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:g.deadlineAtMs??t.deadlineAtMs}}})}function Ik(e,t){if(!t.ownerId.trim())throw new Error("Mailbox claim owner identity is required.");if(t.owner&&(!Number.isSafeInteger(t.owner.pid)||t.owner.pid<=0||t.owner.processIdentity!==void 0&&t.owner.processIdentity.pid!==t.owner.pid))throw new Error("Mailbox claim process identity is invalid.");let n=t.nowMs??Date.now(),r=hr(t.limits),i=ms(e);try{return Tl(e,r,2e3,t.monotonicNow??Ft,t.durability??"durable",()=>Ek(e,t.ownerId,n,r,t.liveness??wl,t.owner??{pid:process.pid},i,t.durability??"durable",t.onClaimStage))}catch(o){if(o instanceof dt&&o.code==="admission-busy")return[];throw o}}function Qq(e,t){return!Kg(e.pendingDir)&&!Kg(e.legacyRequestDir)?[]:Ik(e,t)}function Ek(e,t,n,r,i,o,s,a,c){Fl(e,n,r,i);let l=D(e.inflightDir,fs(t)),u=[...zg(e.pendingDir,!1),...zg(e.legacyRequestDir,!0)].sort((f,g)=>f.orderAtMs-g.orderAtMs||f.header.id.localeCompare(g.header.id)||f.path.localeCompare(g.path)),d=a==="durable"?s:"not-requested";u.length>0&&(a==="durable"?d=q(d,ue(l)):xk(l,{recursive:!0}),c?.("after-owner-directory-durable"),Tk(l,t,o,a),c?.("after-owner-record-published"));let p=[];for(let f of u){if(p.length>=r.maxBatch)break;let g=D(e.responseDir,`${f.header.id}.json`);if(Lt(g)){ut(f.path,{force:!0});continue}let y=Math.max(n+r.claimLeaseMs,(f.header.deadlineAtMs??n)+5e3),m=`${fs(f.originalFile)}.${y}.claim`,S=D(l,m);try{Pl(f.path,S)}catch(I){let b=I.code;if(b==="ENOENT"||b==="EEXIST")continue;throw I}c?.("after-claim-renamed");let h=a==="durable"?L(Rl(f.path)):"not-requested";c?.("after-source-directory-synced");let x=a==="durable"?L(l):"not-requested";c?.("after-destination-directory-synced");let P=q(d,h,x);p.push({requestId:f.header.id,ownerId:t,path:S,originalFile:f.originalFile,claimedAtMs:n,claimExpiresAtMs:y,byteLength:f.byteLength,...f.header.operationKey?{operationKey:f.header.operationKey}:{},...f.header.clientId?{clientId:f.header.clientId}:{},...f.header.enqueuedAtMs===void 0?{}:{enqueuedAtMs:f.header.enqueuedAtMs},...f.header.deadlineAtMs===void 0?{}:{deadlineAtMs:f.header.deadlineAtMs},legacy:f.legacy,directorySync:P})}return p}function Zq(e,t={}){let n=hr(t);if(e.byteLength>n.maxItemBytes)throw new dt("item-too-large",{pending:0,inflight:1,responses:0,deadLetters:0,invalid:0,totalItems:1,totalBytes:e.byteLength},n,e.byteLength);return j(e.path,{maxBytes:n.maxItemBytes,inputKind:"bounded mailbox item"})}function Pk(e,t,n,r={}){let i=r.nowMs??Date.now(),o=hr(r.limits),s={...n,mailboxVersion:Cl,operationKey:t.operationKey??`legacy-${t.requestId}`,clientId:t.clientId??"legacy",...t.deadlineAtMs===void 0?{}:{deadlineAtMs:t.deadlineAtMs},completedAtMs:i,expiresAtMs:i+o.responseRetentionMs},a=Buffer.byteLength(`${JSON.stringify(s)}
394
- `),c=gs(e);if(a>o.maxItemBytes)throw new dt("item-too-large",c,o,a);let l=Math.max(0,c.totalBytes-t.byteLength)+a;if(l>o.maxBytes&&l>c.totalBytes)throw new dt("byte-capacity",c,o,a);let u=r.durability??"durable";if(Rk(e,t,s,u),r.onAfterResponsePublished?.(),ut(t.path,{force:!0}),u==="durable"){let d=Rl(t.path);L(Lt(d)?d:e.inflightDir)}}function eW(e,t,n,r,i={}){let o=i.nowMs??Date.now(),s=hr(i.limits);if(Pk(e,t,n,{...i,nowMs:o,limits:s}),!Lt(t.path)){let a=D(e.deadLetterDir,`${Dk(t.requestId)}.${o}.${El("sha256").update(r).digest("hex").slice(0,12)}.json`),c={mailboxVersion:Cl,requestId:t.requestId,ownerId:t.ownerId,rejectedAtMs:o,reason:r,originalFile:t.originalFile},l=Buffer.byteLength(`${JSON.stringify(c,null,2)}
395
- `),u=gs(e);u.totalItems<s.maxItems&&u.totalBytes+l<=s.maxBytes&&_e(a,c,{spacing:2,trailingNewline:!0})}}function tW(e,t={}){let n=t.nowMs??Date.now(),r=hr(t.limits);return ms(e),Tl(e,r,2e3,t.monotonicNow??Ft,"durable",()=>Fl(e,n,r,t.liveness??wl))}function Fl(e,t,n,r=wl){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let s of Nl(e.inflightDir)){if(o<=0)break;let a=D(e.responseDir,`${s.requestId}.json`);if(Lt(a)){ut(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>t||kk(e,s.ownerId,r)!=="dead")continue;let c=D(e.pendingDir,s.originalFile);try{Pl(s.path,c),i.reclaimed++}catch(l){if(l.code!=="EEXIST")throw l;ut(s.path,{force:!0})}L(Rl(s.path)),L(e.pendingDir),o--}o=Ug(e.responseDir,o,(s,a)=>a+n.responseRetentionMs,t,()=>{i.responsesRemoved++}),o=Ug(e.deadLetterDir,o,(s,a)=>a+n.deadLetterRetentionMs,t,()=>{i.deadLettersRemoved++});for(let s of[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir]){if(o<=0)break;for(let a of ey(s)){if(o<=0)break;if(!gr(a).includes(".tmp-"))continue;let c;try{c=yr(a).mtimeMs}catch(l){if(l.code==="ENOENT")continue;throw l}c+n.temporaryRetentionMs>t||(ut(a,{force:!0}),i.temporaryFilesRemoved++,o--)}}return _k(e.inflightDir),i}function gs(e){ms(e);let t=[...Nn(e.pendingDir).map(c=>({path:c,pending:!0})),...Nn(e.legacyRequestDir).map(c=>({path:c,pending:!0}))],n=Nl(e.inflightDir).map(c=>({path:c.path,pending:!1})),r=Nn(e.responseDir).map(c=>({path:c,pending:!1})),i=Nn(e.deadLetterDir).map(c=>({path:c,pending:!1})),o=[...t,...n,...r,...i],s=0,a;for(let c of t){let l=Ii(c.path);if(!l){s++;continue}let u=l.enqueuedAtMs;if(u===void 0)try{u=yr(c.path).mtimeMs}catch(d){if(d.code==="ENOENT")continue;throw d}a=a===void 0?u:Math.min(a,u)}return{pending:t.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((c,l)=>c+Lk(l.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function Rk(e,t,n,r){let i=D(e.responseDir,`${t.requestId}.json`),o=`${JSON.stringify(n)}
396
- `;try{Mo(i,o,{durability:r})}catch(s){if(s.code!=="EEXIST")throw s;let a=Ii(i),c=t.operationKey??`legacy-${t.requestId}`;if(a?.operationKey!==c)throw new Error(`Mailbox completion ${t.requestId} conflicts with an existing operation.`,{cause:s})}}function Tl(e,t,n,r,i,o){let s=D(e.rootDir,".admission.lock"),a=`${process.pid}-${Xg()}`,c=r()+Math.max(0,n);for(;!Ck(e.rootDir,s,a,i);){if(wk(s),r()>=c)throw new dt("admission-busy",gs(e),t,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{kl(s).ownerToken===a&&(ut(s,{recursive:!0,force:!0}),i==="durable"&&L(e.rootDir))}catch{}}}function Ck(e,t,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
397
- `;try{return Mo(t,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{kl(t).ownerToken===n&&(ut(t,{force:!0}),r==="durable"&&L(e))}catch{}throw o}}function wk(e){let t=null;try{let r=kl(e);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(t=Number(r.pid))}catch{}if(t===null||Fk(t))return;let n=`${e}.stale-${Xg()}`;try{Pl(e,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}ut(n,{recursive:!0,force:!0})}function kl(e){try{return JSON.parse(T(e,"mailbox lock record"))}catch(t){if(t.code!=="EISDIR"&&!(t instanceof nt&&t.reason==="not-regular"))throw t;return JSON.parse(T(D(e,"owner.json"),"mailbox lock owner record"))}}function Fk(e){try{return process.kill(e,0),!0}catch(t){let n=t.code;return n==="EPERM"||n!=="ESRCH"}}function Tk(e,t,n,r){let i=D(e,Yg),o=n.processIdentity,s=Zg(i);if(s&&s.ownerId===t&&s.pid===n.pid&&(!s.processIdentity&&!o||s.processIdentity&&o&&Ne(s.processIdentity,o)))return;if(Nn(e).some(c=>c.endsWith(".claim")))throw new Error(`Mailbox owner identity ${t} collides with retained work from another process instance.`);let a={version:1,ownerId:t,pid:n.pid,...o?{processIdentity:o}:{}};r==="durable"?_e(i,a):Jt(i,a)}function kk(e,t,n){let r=Zg(D(e.inflightDir,fs(t),Yg));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?Ne(r.processIdentity,i)?"live":"dead":"unknown"}function Zg(e){try{let t=JSON.parse(T(e,"mailbox owner record"));if(t.version!==1||typeof t.ownerId!="string"||!t.ownerId||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0)return null;let n=t.processIdentity===void 0?null:Ct(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,ownerId:t.ownerId,pid:t.pid,...n?{processIdentity:n}:{}}}catch{return null}}function Wg(e,t){for(let n of[D(e.pendingDir,`${t}.json`),D(e.legacyRequestDir,`${t}.json`),D(e.responseDir,`${t}.json`)])if(Lt(n))return n;for(let n of Nl(e.inflightDir))if(n.requestId===t)return n.path;return null}function Hg(e,t,n){let r=Ii(e);if(r?.operationKey===t)return r;if(gr(e)===`${Qg(t)}.json`)return{id:n,operationKey:t};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function Nk(e){if(e.mailboxVersion!==Cl||e.id!==Qg(e.operationKey)||!e.clientId.trim()||!Number.isFinite(e.enqueuedAtMs)||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function zg(e,t){return Nn(e).filter(n=>n.endsWith(".json")).map(n=>{let r=yr(n),i=gr(n,".json"),o=Ii(n)??{id:i};return{path:n,originalFile:gr(n),header:o,byteLength:r.size,orderAtMs:o.enqueuedAtMs??r.mtimeMs,legacy:t}})}function Nl(e){if(!Lt(e))return[];let t=[];for(let n of _n(e,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=Jg(n.name);if(r===null)continue;let i=D(e,n.name);for(let o of _n(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=Jg(s[1]),c=Number(s[2]);if(a===null||gr(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(c))continue;let l=D(i,o.name),u=Ii(l)??{id:gr(a,".json")},d;try{d=yr(l)}catch(p){if(p.code==="ENOENT")continue;throw p}t.push({requestId:u.id,ownerId:r,path:l,originalFile:a,claimedAtMs:d.mtimeMs,claimExpiresAtMs:c,byteLength:d.size,...u.operationKey?{operationKey:u.operationKey}:{},...u.clientId?{clientId:u.clientId}:{},...u.enqueuedAtMs===void 0?{}:{enqueuedAtMs:u.enqueuedAtMs},...u.deadlineAtMs===void 0?{}:{deadlineAtMs:u.deadlineAtMs},legacy:u.operationKey===void 0})}}return t.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function Ii(e){try{let t=JSON.parse(T(e,"mailbox record"));return typeof t.id!="string"||!t.id?null:{id:t.id,...typeof t.operationKey=="string"?{operationKey:t.operationKey}:{},...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.enqueuedAtMs=="number"?{enqueuedAtMs:t.enqueuedAtMs}:{},...typeof t.deadlineAtMs=="number"?{deadlineAtMs:t.deadlineAtMs}:{}}}catch{return null}}function Ug(e,t,n,r,i){for(let o of Nn(e)){if(t<=0)break;let s;try{s=yr(o)}catch(a){if(a.code==="ENOENT")continue;throw a}n(o,s.mtimeMs)>r||(ut(o,{force:!0}),i(),t--)}return t}function Nn(e){return Lt(e)?_n(e,{withFileTypes:!0}).filter(t=>t.isFile()).map(t=>D(e,t.name)).sort():[]}function Kg(e){try{return _n(e).some(t=>t.endsWith(".json"))}catch{return!1}}function ey(e){if(!Lt(e))return[];let t=[];for(let n of _n(e,{withFileTypes:!0})){let r=D(e,n.name);n.isFile()?t.push(r):n.isDirectory()&&t.push(...ey(r))}return t.sort()}function _k(e){if(Lt(e))for(let t of _n(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let n=D(e,t.name);_n(n).some(r=>r.endsWith(".claim"))||ut(n,{recursive:!0,force:!0})}}function Lk(e){try{return yr(e).size}catch{return 0}}function fs(e){return Buffer.from(e,"utf8").toString("base64url")}function Jg(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return fs(t)===e?t:null}catch{return null}}function Dk(e){return/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)?e:`invalid-${El("sha256").update(e).digest("hex")}`}var Ak=4;function Ln(e,t,n,r={}){return ty(e,t,n,r.maxReexportDepth??Ak,0,new Set)}function ty(e,t,n,r,i,o){let s=`${t}\0${n}`;if(o.has(s)||i>r)return[];o.add(s);let a=B(e,t).filter(c=>c.leaf===n);return a.length>0?a:Pt(e,t).flatMap(c=>c.sourcePath?c.kind==="named"&&!c.names.includes(n)?[]:ty(e,c.sourcePath,n,r,i+1,new Set(o)):[])}import{createHash as Ni}from"crypto";import{createRequire as d_}from"module";import{createHash as Qk}from"crypto";var ys=8;function Sr(e,t,n){return Ol(ny(e,t,Dl(n),0,new Set))}function Al(e,t,n){return _l(e,t,n,0,new Set)}function ny(e,t,n,r,i){if(r>ys)return[];let o=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n);return o?ry(e,t,o[1],o[2],r,i):/^[A-Za-z_$][\w$]*$/u.test(n)?iy(e,t,n,r,i):[]}function ry(e,t,n,r,i,o){let s=[];for(let a of _l(e,t,n,i+1,new Set(o))){let c=Ge(a.initializer);for(let l of c.namedChildren){if(l.type==="pair"){let u=l.childForFieldName("key")??l.namedChild(0);if($k(u)!==r)continue;let d=l.childForFieldName("value")??l.namedChild(1);d&&s.push(...ny(e,a.definition.relativePath,Dl(d.text),i+1,new Set(o)));continue}if(/(?:method|function)/u.test(l.type)){if((l.childForFieldName("name")??l.namedChild(0))?.text!==r)continue;let d=jk(e,a.definition.relativePath,r,l);s.push(...d.length>0?d:[Ok(a.definition,r,l)]);continue}if(l.type==="spread_element"){let u=l.namedChild(0);if(!u)continue;for(let d of _l(e,a.definition.relativePath,Dl(u.text),i+1,new Set(o)))s.push(...ry(e,d.definition.relativePath,d.definition.leaf,r,i+1,new Set(o)))}}}return Ol(s)}function Ok(e,t,n){return{documentId:e.documentId,symbolId:-1,symbol:`source-callable:${e.relativePath}:${n.startPosition.row}:${t}`,relativePath:e.relativePath,startLine:n.startPosition.row,startChar:n.startPosition.column,endLine:n.endPosition.row,endChar:n.endPosition.column,leaf:t,parentTypeName:e.leaf,isFunctionLike:!0,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:e.symbol}}function _l(e,t,n,r,i){return r>ys||!/^[A-Za-z_$][\w$]*$/u.test(n)?[]:iy(e,t,n,r,i).flatMap(o=>{let s=O(e,o.relativePath)?.rootNode,a=s?Bk(s,o.leaf):null;return a?[{definition:o,initializer:a}]:[]})}function iy(e,t,n,r,i){if(r>ys)return[];let o=`${t}\0${n}`;if(i.has(o))return[];i.add(o);let s=B(e,t).filter(l=>l.leaf===n);if(s.length>0)return s;let a=Mk(e,t,n);if(a.length>0)return a;let c=ae(e,t).find(l=>l.localName===n&&l.sourcePath);if(c?.sourcePath){let l=c.kind==="namespace"||c.importedName==="default"?n:c.importedName;return Ll(e,c.sourcePath,l,r+1,new Set(i))}return Ll(e,t,n,r+1,new Set(i))}function Mk(e,t,n){let r=e.get("SELECT id FROM documents WHERE relative_path = ?",t)?.id;return r===void 0?[]:(me(e,t)?.callables??[]).filter(i=>i.name===n).map(i=>({documentId:r,symbolId:-1,symbol:`source-callable:${t}:${i.startLine}:${n}`,relativePath:t,startLine:i.startLine,startChar:0,endLine:i.endLine,endChar:0,leaf:n,parentTypeName:null,isFunctionLike:!0,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null}))}function Ll(e,t,n,r,i){if(r>ys)return[];let o=B(e,t).filter(s=>s.leaf===n);return o.length>0?o:Ol(Pt(e,t).flatMap(s=>s.sourcePath?s.kind==="named"&&!s.names.includes(n)?[]:Ll(e,s.sourcePath,n,r+1,new Set(i)):[]))}function jk(e,t,n,r){return B(e,t).filter(i=>i.leaf===n&&i.startLine<=r.startPosition.row&&i.endLine>=r.endPosition.row)}function Bk(e,t){let n=null;return se(e,r=>{n||r.type!=="variable_declarator"||(r.childForFieldName("name")??r.namedChild(0))?.text.trim()!==t||(n=r.childForFieldName("value")??r.namedChild(1))}),n}function $k(e){return e?.text.replace(/^['"`]|['"`]$/gu,"")??null}function Dl(e){return e.replace(/\s+/gu,"").replace(/^\.\.\./u,"")}function Ol(e){return[...new Map(e.map(t=>[t.symbol,t])).values()]}function hs(e){let t=e.replaceAll("\\","/");return Vg(t)==="test"?/(?:^|\/)__fixtures__\//iu.test(t)?"fixture":"test":/(?:^|\/)(?:fixtures?|testdata)\//iu.test(t)?"fixture":/(?:^|\/)(?:examples?|demos?|previews?)\//iu.test(t)?"example":/(?:^|\/)(?:generated|dist|build|coverage)\//iu.test(t)||/\.generated\./iu.test(t)?"generated":/^(?:scripts?|tools?)\//iu.test(t)?"script":"production"}var Gk=8;function Qe(e,t){return t?br(e,t,0,new Set):null}function br(e,t,n,r){if(n>Gk)return pt(t,"value-evaluation-depth");let i=Ge(t),o=Uk(i);if(o)return Kk(e.file,i,o.term,o.value,o.precision);if(i.type==="binary_expression"&&/\+/u.test(i.text)){let c=i.namedChildren.map(l=>br(e,l,n+1,new Set(r)));if(c.length>=2&&c.every(l=>l!==null)){let l={kind:"concat",parts:c.map(d=>d.term)},u=c.map(d=>d.value).join("");return Jk(e.file,i,l,u,c.some(d=>d.precision!=="literal")?"constrained-pattern":"literal",c)}}let s=i.text.trim();if(/^[A-Za-z_$][\w$]*$/u.test(s))return Hk(e,s,i,n,r);let a=Xk(i);return a?zk(e,a.base,a.properties,i,n,r):i.type==="call_expression"||i.type==="call"?Vk(e,i,n,r):pt(i,`unsupported-expression:${i.type}`)}function Vk(e,t,n,r){let o=(t.childForFieldName("function")??t.namedChild(0))?.text.replace(/\s+/gu,"").replace(/<.*>$/u,"")??"",s=qk(e,o);if(s.length!==1)return pt(t,s.length===0?"call-target-unresolved":"call-target-ambiguous");let a=s[0],c=`${a.relativePath}\0${a.symbol}`;if(r.has(c))return pt(t,"call-return-cycle");let l=O(e.db,a.relativePath)?.rootNode;if(!l)return pt(t,"call-target-unparsed");let u=$e(l,a.startLine,a.endLine);if(!u)return pt(t,"call-target-syntax-unavailable");let d=Wk(u);if(!d)return pt(t,"call-return-not-single-expression");let p=new Set(r);p.add(c);let f=br({db:e.db,file:a.relativePath,root:l},d,n+1,p);return f?Ss(t,"bounded-call-return",f,a.symbol):pt(t,"call-return-unresolved")}function qk(e,t){if(/^[A-Za-z_$][\w$]*$/u.test(t)){let i=B(e.db,e.file).filter(s=>s.isFunctionLike&&s.leaf===t);if(i.length>0)return i;let o=ae(e.db,e.file).find(s=>s.localName===t&&s.sourcePath&&s.kind!=="namespace");return o?.sourcePath?Ln(e.db,o.sourcePath,o.importedName==="default"?t:o.importedName).filter(s=>s.isFunctionLike):[]}let n=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(t);if(!n)return[];let r=ae(e.db,e.file).find(i=>i.kind==="namespace"&&i.localName===n[1]&&i.sourcePath);return r?.sourcePath?Ln(e.db,r.sourcePath,n[2]).filter(i=>i.isFunctionLike):[]}function Wk(e){let t=e.childForFieldName("body");if(e.type==="arrow_function"&&t&&t.type!=="statement_block")return t;let n=[];return oy(t??e,t??e,n),n.length!==1?null:n[0].childForFieldName("argument")??n[0].namedChild(0)}function oy(e,t,n){if(!(t!==e&&(/(?:function|method|lambda)/u.test(t.type)||t.type==="arrow_function"))){if(t.type==="return_statement"){n.push(t);return}for(let r of t.namedChildren)oy(e,r,n)}}function Hk(e,t,n,r,i){let o=`${e.file}\0${t}`;if(i.has(o))return pt(n,"value-cycle");i.add(o);let s=Ml(e.root,t);if(s){let g=br(e,s,r+1,i);return g?Ss(n,"local-constant",g):pt(n,"non-foldable-local")}let a=ae(e.db,e.file).find(g=>g.localName===t&&g.sourcePath);if(!a?.sourcePath)return Ye(n,t,"unresolved-identifier");if(a.kind==="namespace")return Ye(n,t,"namespace-import-requires-property");let c=a.importedName==="default"?t:a.importedName,l=Ln(e.db,a.sourcePath,c);if(l.length!==1)return Ye(n,t,l.length===0?"import-definition-missing":"import-definition-ambiguous");let u=l[0],d=O(e.db,u.relativePath)?.rootNode;if(!d)return Ye(n,u.symbol,"import-definition-unparsed");let p=Ml(d,u.leaf);if(!p)return Ye(n,u.symbol,"import-definition-non-value");let f=br({db:e.db,file:u.relativePath,root:d},p,r+1,i);return f?Ss(n,"imported-constant",f,u.symbol):Ye(n,u.symbol,"import-value-unresolved")}function zk(e,t,n,r,i,o){let s=ae(e.db,e.file).find(f=>f.localName===t&&f.sourcePath),a=e.file,c=t,l;if(s?.sourcePath){s.kind==="namespace"?(c=n[0]??"",n=n.slice(1)):c=s.importedName==="default"?t:s.importedName;let f=Ln(e.db,s.sourcePath,c);if(f.length!==1)return Ye(r,`${t}.${n.join(".")}`,f.length===0?"member-definition-missing":"member-definition-ambiguous");a=f[0].relativePath,c=f[0].leaf,l=f[0].symbol}let u=a===e.file?e.root:O(e.db,a)?.rootNode;if(!u)return Ye(r,l??t,"member-definition-unparsed");let d=Ml(u,c);if(!d)return Ye(r,l??t,"member-base-non-value");for(let f of n){let g=Ge(d);if(d=Yk(g,f),!d)return Ye(r,l??`${t}.${n.join(".")}`,`member-property-missing:${f}`)}let p=br({db:e.db,file:a,root:u},d,i+1,o);return p?Ss(r,"member-constant",p,l):Ye(r,l??t,"member-value-unresolved")}function Uk(e){let t=e.text.trim(),n=t[0];if(n!=="'"&&n!=='"'&&n!=="`"||t.at(-1)!==n)return null;let r=t.slice(1,-1);if(n!=="`"||!r.includes("${"))return{term:{kind:"literal",value:r},value:r,precision:"literal"};let i=[],o=0,s=/\$\{([^}]*)\}/gu;for(let a of r.matchAll(s)){let c=a.index??0;c>o&&i.push({kind:"literal",value:r.slice(o,c)}),i.push({kind:"unknown",reason:`template-hole:${a[1]?.trim()||"expression"}`}),o=c+a[0].length}return o<r.length&&i.push({kind:"literal",value:r.slice(o)}),{term:{kind:"pattern",language:"template",value:r.replace(s,"{}")},value:r.replace(s,"{}"),precision:"constrained-pattern"}}function Kk(e,t,n,r,i){return{value:r,evidence:"literal",term:n,precision:i,derivation:bs("direct-literal","direct",e,t)}}function Jk(e,t,n,r,i,o){return{value:r,evidence:"constant",term:n,precision:i,derivation:{...bs("constant-concatenation","mechanically-derived",e,t),inputFactIds:o.flatMap(s=>s.derivation.inputFactIds),sourceSpans:o.flatMap(s=>s.derivation.sourceSpans)}}}function Ss(e,t,n,r){return n.evidence==="expression"?{...n,derivation:{kind:"heuristic",rule:t,ruleVersion:"1",inputFactIds:[...n.derivation.inputFactIds,...r?[r]:[]],sourceSpans:n.derivation.sourceSpans}}:{...n,evidence:"constant",derivation:{kind:"mechanically-derived",rule:t,ruleVersion:"1",inputFactIds:[...n.derivation.inputFactIds,...r?[r]:[]],sourceSpans:n.derivation.sourceSpans}}}function Ye(e,t,n){return{value:e.text.trim(),evidence:"expression",term:{kind:"symbol",symbol:t},precision:"symbolic",derivation:bs(n,"heuristic","",e)}}function pt(e,t){return{value:e.text.trim(),evidence:"expression",term:{kind:"unknown",reason:t},precision:"unknown",derivation:bs(t,"heuristic","",e)}}function bs(e,t,n,r){return{kind:t,rule:e,ruleVersion:"1",inputFactIds:[],sourceSpans:n?[{file:n,startLine:r.startPosition.row,endLine:r.endPosition.row}]:[]}}function Xk(e){let t=e.text.replace(/\s+/gu,"");if(!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/u.test(t))return null;let[n,...r]=t.split(".");return n?{base:n,properties:r}:null}function Ml(e,t){let n=null;return se(e,r=>{if(n||r.type!=="variable_declarator"||(r.childForFieldName("name")??r.namedChild(0))?.text.trim()!==t)return;let o=r.parent;!o||o.type!=="lexical_declaration"||!/^\s*(?:export\s+)?const\b/u.test(o.text)||(n=r.childForFieldName("value")??r.namedChild(1))}),n}function Yk(e,t){for(let n of e.namedChildren)if(!(n.type!=="pair"||(n.childForFieldName("key")??n.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")!==t))return n.childForFieldName("value")??n.namedChild(1);return null}var Zk=new WeakMap,fy=new Set(["delete","get","head","options","patch","post","put"]),eN=/(?:^|\.)(?:app|router|server)$/u,tN=new Set(["findFirst","findMany","findUnique","from","get","select"]),nN=new Set(["create","delete","insert","remove","update","upsert"]),rN=new Set(["execute","query","raw"]),sy=/(?:\b(?:name|id)|['"`](?:name|id)['"`])\s*:/u,ay=/(?:^\s*|[,{]\s*)(?:async\s+)?['"`]?(?:execute|handler|invoke|run)['"`]?\s*(?::|\([^)]*\)\s*\{)/mu,cy=/\b[A-Za-z_$][\w$-]*[_-][\w$-]*\s*\(/u,ly=/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s+[A-Za-z_$][\w$-]*\s*\(/iu,$l=[aN(),sN(),iN(),cN(),uN(),dN(),fN()],Bl=new Set(["exec","execFile","execFileSync","execSync","fork","spawn","spawnSync"]);function iN(){return{id:"builtin.node-child-process",supports:e=>/(?:from\s*|require\s*\(\s*)['"](?:node:)?child_process['"]/u.test(e)&&/\b(?:exec|execFile|execFileSync|execSync|fork|spawn|spawnSync)\s*\(/u.test(e),extract:e=>{let t=oN(e.source),n=[];return Zt(e.root,"call_expression",r=>{let i=Ci(r);if(!i)return;let o=t.direct.get(i),s=/^(.*?)\.([A-Za-z_$][\w$]*)$/u.exec(i),a=s&&t.namespaces.has(s[1])?s[2]:null,c=o??a;if(!c||!Bl.has(c))return;let l=Dn(r),u=ze(l[0],e)??{value:l[0]?.text.trim()||"<missing>",evidence:"expression"},d=["exec","execFile","execFileSync","execSync"].includes(c)?"process.exec":"process.spawn";n.push(le(e,r,"builtin.node-child-process",d,[{name:"operation",value:c,evidence:"literal"},{name:"executable",...u}],"exact","node-child-process-import"))}),n}}}function oN(e){let t=new Map,n=new Set,r=String.raw`['"](?:node:)?child_process['"]`,i=new RegExp(String.raw`\bimport\s*\{([^}]*)\}\s*from\s*${r}`,"gu");for(let c of e.matchAll(i))for(let l of(c[1]??"").split(",")){let u=/^\s*([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?\s*$/u.exec(l);u&&Bl.has(u[1])&&t.set(u[2]??u[1],u[1])}let o=new RegExp(String.raw`\b(?:const|let)\s*\{([^}]*)\}\s*=\s*require\s*\(\s*${r}\s*\)`,"gu");for(let c of e.matchAll(o))for(let l of(c[1]??"").split(",")){let u=/^\s*([A-Za-z_$][\w$]*)(?:\s*:\s*([A-Za-z_$][\w$]*))?\s*$/u.exec(l);u&&Bl.has(u[1])&&t.set(u[2]??u[1],u[1])}let s=new RegExp(String.raw`\bimport\s*\*\s*as\s*([A-Za-z_$][\w$]*)\s*from\s*${r}`,"gu");for(let c of e.matchAll(s))n.add(c[1]);let a=new RegExp(String.raw`\b(?:const|let)\s+([A-Za-z_$][\w$]*)\s*=\s*require\s*\(\s*${r}\s*\)`,"gu");for(let c of e.matchAll(a))n.add(c[1]);return{direct:t,namespaces:n}}function Pe(e,t,n,r){let i=Ei(r,"runtime-boundaries.context.ast",t,()=>n===void 0?O(e,t):In(e,t,n)?.tree);if(!i)return null;let o=i.rootNode;n!==void 0&&Zk.set(o,i);let s=n??F(e,t),a,c,l,u=()=>(c!==void 0||(c=Ei(r,"runtime-boundaries.context.callable-sites",t,()=>{let d=oe(t);return(d?Ua(o,d):null)??qr(e,t)})),c);return{db:e,file:t,source:s,root:o,get constants(){return l??=Ei(r,"runtime-boundaries.context.constants",t,()=>bN(o)),l},ownerAt:d=>{let f=(a??=Ei(r,"runtime-boundaries.context.definitions",t,()=>B(e,t,{rangeCorrectionEvidence:{source:s,callables:u()}},(m,S)=>Ei(r,`runtime-boundaries.context.definitions.${m}`,t,S)))).filter(m=>m.startLine<=d&&m.endLine>=d).sort((m,S)=>m.endLine-m.startLine-(S.endLine-S.startLine)||m.startLine-S.startLine)[0];if(f)return{file:t,symbol:f.symbol,name:f.leaf,startLine:f.startLine,endLine:f.endLine};let y=(u()??[]).filter(m=>m.startLine<=d&&m.endLine>=d).sort((m,S)=>m.endLine-m.startLine-(S.endLine-S.startLine)||m.startLine-S.startLine)[0];return{file:t,symbol:null,name:y?.name??null,startLine:y?.startLine??d,endLine:y?.endLine??d}}}}function Ei(e,t,n,r){return e?e(t,r,{file:n}):r()}function sN(){return{id:"builtin.effect-httpapi",supports:e=>Pi(e,"HttpApiEndpoint").size>0||Pi(e,"HttpApiBuilder").size>0,extract:e=>{let t=[],n=Pi(e.source,"HttpApiEndpoint"),r=Pi(e.source,"HttpApiGroup"),i=Pi(e.source,"HttpApiBuilder");return Zt(e.root,"call_expression",o=>{let s=my(o);if(!s)return;let a=Dn(o);if(n.has(s.receiver)&&fy.has(s.member)){let y=ze(a[0],e),m=ze(a[1],e),S=dy(o,r,"make",0,e);if(!y||!m||!S)return;let h=s.member.toUpperCase();t.push(le(e,o,"builtin.effect-httpapi","http.handle",[{name:"method",value:h,evidence:"literal"},{name:"path",...m}],ft([{name:"path",...m}]),"effect-httpapi-endpoint-declaration")),t.push(le(e,o,"builtin.effect-httpapi","framework.declare",jl(S,y),ft(jl(S,y)),"effect-httpapi-operation-declaration"));return}if(!["handle","handleRaw"].includes(s.member))return;let c=dy(o,i,"group",1,e),l=ze(a[0],e),u=a[1];if(!c||!l||!u)return;let d=jl(c,l),p=Sr(e.db,e.file,u.text),f=le(e,o,"builtin.effect-httpapi","framework.handle",d,p.length===1?ft(d):"candidate","effect-httpapi-handler-registration"),g=p[0];p.length===1&&g&&(f.owner={file:g.relativePath,symbol:g.symbol,name:g.leaf,startLine:g.startLine,endLine:g.endLine}),t.push(f)}),t}}}function jl(e,t){return[{name:"adapter",value:"effect-httpapi",evidence:"literal"},{name:"group",...e},{name:"operation",...t}]}function Pi(e,t){let n=new Set,r=/\bimport\s*\{([\s\S]*?)\}\s*from\s*['"]([^'"]+)['"]/gu;for(let o of e.matchAll(r)){let s=o[2]??"";if(uy(s))for(let a of(o[1]??"").split(",")){let c=a.trim().replace(/^type\s+/u,""),l=/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/u.exec(c);l?.[1]===t&&n.add(l[2]??l[1])}}let i=/\bimport\s*\*\s*as\s*([A-Za-z_$][\w$]*)\s*from\s*['"]([^'"]+)['"]/gu;for(let o of e.matchAll(i)){let s=o[2]??"";s.endsWith(`/${t}`)&&uy(s)&&n.add(o[1])}return n}function uy(e){return e==="effect/unstable/httpapi"||e==="@effect/platform"||e.startsWith("@effect/platform/HttpApi")}function dy(e,t,n,r,i){let o=e.parent;for(;o;){if(o.type==="call_expression"){let s=py(o,t,n,r,i);if(s)return s;let a=o.childForFieldName("function")??o.namedChild(0),c=null;if(a&&Vl(a,l=>{!c&&l.type==="call_expression"&&(c=py(l,t,n,r,i))}),c)return c}o=o.parent}return null}function py(e,t,n,r,i){let o=my(e);return!o||o.member!==n||!t.has(o.receiver)?null:ze(Dn(e)[r],i)}function my(e){let t=e.childForFieldName("function")??e.namedChild(0);if(!t||!["member_expression","subscript_expression"].includes(t.type))return null;let n=t.childForFieldName("object")??t.namedChild(0),r=t.childForFieldName("property")??t.childForFieldName("index")??t.namedChild(1);return!n||!r?null:{receiver:n.text.replace(/\s+/gu,""),member:r.text.replace(/^['"`]|['"`]$/gu,"")}}function aN(){return{id:"builtin.http",supports:e=>/\bfetch\s*\(|\baxios\b|\b(?:app|router|server)\s*\.\s*(?:get|post|put|patch|delete|options|head)\s*\(/u.test(e)||Ri(e,["axios"])||/\b(?:FastAPI|Flask|APIRouter|axum|Router::new)\b/u.test(e),extract:e=>{let t=[];return Zt(e.root,["decorator","call_expression"],n=>{if(n.type==="decorator"){let p=/^@[^\s(]+\.(get|post|put|patch|delete|options|head)\s*\(\s*(['"`])([^'"`]+)\2/iu.exec(n.text.trim());if(!p||!Ri(e.source,["fastapi","flask"]))return;t.push(le(e,n,"builtin.http","http.handle",[{name:"method",value:p[1].toUpperCase(),evidence:"literal"},{name:"path",value:p[3],evidence:"literal"}],"exact","framework-decorator"));return}if(n.type!=="call_expression")return;let r=Ci(n);if(!r)return;let i=r.split(".").at(-1)?.toLowerCase()??"",o=r.includes(".")?r.slice(0,r.lastIndexOf(".")):"",s=Dn(n);if(i==="route"&&Ri(e.source,["axum"])){let p=ze(s[0],e),f=/^\s*(get|post|put|patch|delete|options|head)\s*\(/iu.exec(s[1]?.text??"")?.[1];if(!p||!f)return;t.push(le(e,n,"builtin.http","http.handle",[{name:"method",value:f.toUpperCase(),evidence:"literal"},{name:"path",...p}],ft([{name:"path",...p}]),"framework-adapter"));return}if(r==="fetch"||r.endsWith(".fetch")){let p=ze(s[0],e);if(!p)return;let g=/\bmethod\s*:\s*['"`]([A-Za-z]+)['"`]/u.exec(s[1]?.text??"")?.[1]?.toUpperCase()??(s[1]?null:"GET"),y=[...g?[{name:"method",value:g,evidence:"literal"}]:[],{name:"path",...p}];t.push(le(e,n,"builtin.http","http.request",y,g?ft(y):"candidate","call-expression"));return}if(!fy.has(i))return;let a=ze(s[0],e);if(!a)return;let c=i.toUpperCase();if(eN.test(o)&&Ri(e.source,["express","fastify","hono","koa-router","@koa/router"])){t.push(le(e,n,"builtin.http","http.handle",[{name:"method",value:c,evidence:"literal"},{name:"path",...a}],ft([{name:"path",...a}]),"framework-adapter"));return}let u=yN(e.source,["axios"]),d=o.split(".")[0]??"";u.has(d)&&t.push(le(e,n,"builtin.http","http.request",[{name:"method",value:c,evidence:"literal"},{name:"path",...a}],ft([{name:"path",...a}]),"client-adapter"))}),t}}}function cN(){return{id:"builtin.capability-registry",supports:e=>sy.test(e)&&ay.test(e)||cy.test(e)||ly.test(e),extract:e=>{let t=[],n=new Set,r=[];return sy.test(e.source)&&ay.test(e.source)&&r.push("pair"),(cy.test(e.source)||ly.test(e.source))&&r.push("string","string_literal","template_string"),Zt(e.root,r,i=>{if(i.type==="pair"){let s=i.childForFieldName("key")??i.namedChild(0),a=i.childForFieldName("value")??i.namedChild(1),c=s?.text.replace(/^['"`]|['"`]$/gu,"");if(c!=="name"&&c!=="id")return;let l=gy(a,e),u=vN(i);if(!l||l.evidence!=="literal"||!u)return;let d=`handle\0${l.value}\0${u.startPosition.row}`;if(n.has(d))return;n.add(d),t.push(le(e,u,"builtin.capability-registry","registry.handle",[{name:"key",...l}],"exact","capability-descriptor"));return}if(!["string","string_literal","template_string"].includes(i.type))return;let o=i.text.replace(/^['"`]|['"`]$/gu,"");for(let s of o.matchAll(/\b([A-Za-z_$][\w$-]*)\s*\(/gu)){let a=s[1];if(!lN(o,a,s.index))continue;let c=`reference\0${a}\0${i.startPosition.row}`;n.has(c)||(n.add(c),t.push(le(e,i,"builtin.capability-registry","registry.reference",[{name:"key",value:a,evidence:"literal"}],"exact","capability-instruction-reference")))}}),t}}}function lN(e,t,n){if(t.includes("_")||t.includes("-"))return!0;let r=e.slice(Math.max(0,n-64),n);return/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s*$/iu.test(r)}function uN(){return{id:"builtin.registry",supports:e=>/(?:Handlers?|Registry|Routes?)\b/iu.test(e),extract:e=>{let t=[];return Zt(e.root,["pair","call_expression"],n=>{if(n.type==="pair"){let o=xN(n);if(!o)return;let s=n.childForFieldName("key")??n.namedChild(0),a=n.childForFieldName("value")??n.namedChild(1),c=gy(s,e);if(!c||!a||!yy(a))return;let l=Gl(a)?"exact":"candidate";t.push(le(e,n,"builtin.registry","registry.handle",[{name:"registry",value:o,evidence:"identifier"},{name:"key",...c}],ft([{name:"key",...c}],l),"object-member"));return}if(n.type!=="call_expression")return;let r=n.childForFieldName("function")??n.namedChild(0);if(!r)return;let i=/^([A-Za-z_$][\w$]*)\s*\[\s*(['"`])([^'"`]+)\2\s*\]$/u.exec(r.text.trim());i&&t.push(le(e,n,"builtin.registry","registry.dispatch",[{name:"registry",value:i[1],evidence:"identifier"},{name:"key",value:i[3],evidence:"literal"}],"exact","indexed-access-call"))}),t}}}function dN(){return{id:"builtin.persistence",supports:e=>/\b(?:db|database|prisma|drizzle|[A-Za-z_$][\w$]*(?:Repository|Repo))\b[^;]{0,1024}?\.\s*(?:findFirst|findMany|findUnique|from|get|select|create|delete|insert|remove|update|upsert|execute|query|raw|transaction)(?:\s*<[^()]{1,512}>)?\s*\(/iu.test(e),extract:e=>{let t=[],n=EN(e.root);return Zt(e.root,"call_expression",r=>{let i=Ci(r);if(!i)return;let o=i.split("."),s=o.at(-1)??"",a=Dn(r),c=a[0]?.text??"",l=IN(s,c);if(!l)return;let u=hy(o,n);if(!u)return;let d=pN(a[0],e)??PN(c),p=RN(u,o,s,d);if(!p)return;let f=s==="insert"?"persistence-insert":l==="database.read"&&/\bFOR\s+UPDATE\s+SKIP\s+LOCKED\b/iu.test(c)?"persistence-skip-locked-claim":"persistence-adapter";t.push(le(e,r,"builtin.persistence",l,[{name:"resource",...p}],ft([{name:"resource",...p}]),f))}),t}}}function pN(e,t){if(!e)return null;let n=e.text.replace(/\s+/gu,"");return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/u.test(n)?{value:n.split(".").at(-1),evidence:"identifier",term:{kind:"symbol",symbol:n}}:ze(e,t)}function fN(){return{id:"builtin.queue",supports:e=>Ri(e,["amqplib","bullmq","kafkajs","@aws-sdk/client-sqs","rabbitmq"])&&/\.(?:sendToQueue|consume|send|subscribe)\s*\(/u.test(e),extract:e=>{let t=[];return Zt(e.root,"call_expression",n=>{let r=Ci(n);if(!r)return;let i=r.split(".").at(-1)??"",o=Dn(n),s=i==="sendToQueue"||i==="send"?"queue.send":i==="consume"||i==="subscribe"?"queue.consume":null;if(!s)return;let a=i==="send"||i==="subscribe"?hN(o[0],"topic",e):ze(o[0],e);a&&t.push(le(e,n,"builtin.queue",s,[{name:"address",...a}],ft([{name:"address",...a}]),"framework-adapter"))}),t}}}function le(e,t,n,r,i,o,s){let a=e.ownerAt(t.startPosition.row),c=JSON.stringify({extractor:n,action:r,file:e.file,line:t.startPosition.row,keyParts:i});return{id:`boundary:${Qk("sha256").update(c).digest("hex").slice(0,16)}`,extractor:n,action:r,owner:a,source:{file:e.file,startLine:t.startPosition.row,endLine:t.endPosition.row},keyParts:i,evidence:s,strength:o,protocol:r.split(".")[0]??r,role:mN(r),executionDomain:gN(e.file),derivation:{kind:o==="candidate"?"heuristic":o==="derived"?"mechanically-derived":"direct",rule:s,ruleVersion:"1",inputFactIds:i.flatMap(l=>l.derivation?.inputFactIds??[]),sourceSpans:[{file:e.file,startLine:t.startPosition.row,endLine:t.endPosition.row},...i.flatMap(l=>l.derivation?.sourceSpans??[])]},valuePrecision:i.some(l=>l.evidence==="expression")?"unknown":i.some(l=>l.evidence==="identifier")?"symbolic":"literal",modality:"may",resolution:"unresolved",sourceScope:hs(e.file)}}function mN(e){let t=e.split(".").at(-1)??e;return["handle","subscribe","consume","read"].includes(t)?"consumer":["request","publish","send","write","dispatch","reference","invoke","spawn","exec"].includes(t)?"producer":"observe"}function gN(e){let t=e.replaceAll("\\","/"),n=/^(apps|services|packages)\/([^/]+)/u.exec(t);return n?`${n[1]}/${n[2]}`:null}function Ri(e,t){return t.some(n=>{let r=n.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`(?:\\bfrom\\s+${r}\\b|\\buse\\s+${r}\\b|(?:\\bfrom\\s*|\\brequire\\s*\\(\\s*)['"]${r}(?:[/']|"))`,"u").test(e)})}function yN(e,t){let n=new Set;for(let r of t){let i=r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),o=new RegExp(`(?:import\\s+([A-Za-z_$][\\w$]*)[^;]*?\\sfrom\\s*|(?:const|let)\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*require\\s*\\(\\s*)['"]${i}(?:[/']|")`,"gu");for(let s of e.matchAll(o)){let a=s[1]??s[2];a&&n.add(a)}}return n}function xs(e,t,n,r,i,o,s){return le(e,t,n,r,i,o,s)}function Ci(e){return(e.childForFieldName("function")??e.namedChild(0))?.text.replace(/\s+/gu,"")??null}function Dn(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function ze(e,t){let n=Qe(t,e);return n?{value:n.value,evidence:n.evidence,term:n.term,derivation:n.derivation}:null}function hN(e,t,n){if(!e)return null;let r=e.namedChildren.find(o=>o.type!=="pair"?!1:(o.childForFieldName("key")??o.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")===t),i=r?.childForFieldName("value")??r?.namedChild(1);return ze(i,n)}function gy(e,t){if(!e)return null;let n=ze(e,t);if(n?.evidence==="literal"||n?.evidence==="constant")return n;let r=e.text.trim();return/^[A-Za-z_$][\w$]*$/u.test(r)?{value:r,evidence:"identifier",term:{kind:"symbol",symbol:r}}:n}function ft(e,t="exact"){return t==="candidate"||e.some(n=>n.evidence==="expression")?"candidate":t==="derived"||e.some(n=>n.evidence==="constant")?"derived":"exact"}function SN(e){let t=e.text.trim(),n=t[0];if(n!=="'"&&n!=='"'&&n!=="`"||t.at(-1)!==n)return null;let r=t.slice(1,-1);return n==="`"&&r.includes("${")?null:r}function bN(e){let t=new Map;return Vl(e,n=>{if(n.type!=="variable_declarator")return;let r=n.childForFieldName("name")??n.namedChild(0),i=n.childForFieldName("value")??n.namedChild(1);if(!r||!i||!/^[A-Za-z_$][\w$]*$/u.test(r.text))return;let o=SN(i);o!==null&&t.set(r.text,o)}),t}function xN(e){let t=e.parent,n=t?.parent??null;for(;n&&["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(n.type);)n=n.parent;if(!t||!n||n.type!=="variable_declarator")return null;let i=(n.childForFieldName("name")??n.namedChild(0))?.text??"";return/(?:handlers?|registry|routes?)$/iu.test(i)?i:null}function Gl(e){return/(?:function|lambda|method)/u.test(e.type)||e.type==="arrow_function"}function yy(e){return Gl(e)||e.type==="member_expression"?!0:e.type==="identifier"&&/(?:command|controller|dispatch|handle|handler)/iu.test(e.text)}function vN(e){let t=e.parent;for(;t&&t.type!=="variable_declarator";){if(["object","object_literal","dictionary"].includes(t.type))for(let n of t.namedChildren){if(n.type==="pair"){let i=n.childForFieldName("key")??n.namedChild(0),o=n.childForFieldName("value")??n.namedChild(1),s=i?.text.replace(/^['"`]|['"`]$/gu,"");if(s&&["execute","handler","invoke","run"].includes(s)&&o&&yy(o))return t}let r=n.childForFieldName("name")??n.namedChild(0);if(r&&["execute","handler","invoke","run"].includes(r.text.replace(/^['"`]|['"`]$/gu,""))&&/(?:function|method)/u.test(n.type))return t}t=t.parent}return null}function hy(e,t=new Set){let n=e.slice(0,-1).map(r=>r.replace(/\([^)]*\)/gu,""));return n.some(r=>/^(?:prisma|drizzle)$/iu.test(r))?"orm":n.some(r=>/(?:Repository|Repo)$/u.test(r))?"repository":n.some(r=>/^(?:db|database)$/iu.test(r)||t.has(r))?"database":null}function IN(e,t){if(tN.has(e))return"database.read";if(nN.has(e))return"database.write";if(!rN.has(e))return null;let n=/\b(SELECT|INSERT|UPDATE|DELETE)\b/iu.exec(t)?.[1]?.toUpperCase();return n==="SELECT"?"database.read":n?"database.write":null}function EN(e){let t=new Set;return Zt(e,"call_expression",n=>{let r=Ci(n);if(!r)return;let i=r.split(".");if(!(i.at(-1)!=="transaction"||!hy(i)))for(let o of Dn(n)){if(!Gl(o))continue;let a=(o.childForFieldName("parameters")??o.namedChildren.find(l=>/parameters/u.test(l.type)))?.namedChildren[0],c=a?Mr(a):null;c&&t.add(c)}}),t}function PN(e){let t=Sy(e);return t?{value:t,evidence:"identifier",term:{kind:"symbol",symbol:t}}:null}function RN(e,t,n,r){if(e==="orm"&&t.length>=3)return{value:t.at(-2).replace(/\([^)]*\)/gu,""),evidence:"identifier"};if(e==="repository"){let o=t.at(-2)?.replace(/(?:Repository|Repo)$/u,"");return o?{value:o,evidence:"identifier"}:null}if(!r)return null;if(n==="from"||n==="insert")return r;let i=Sy(r.value);return i?{value:i,evidence:r.evidence}:null}function Sy(e){return/\b(?:from|into|update|table)\s+(?:\$\{\s*)?['"`]?([A-Za-z_$][\w$.-]*)/iu.exec(e)?.[1]??null}function Vl(e,t){t(e);for(let n of e.namedChildren)Vl(n,t)}function Zt(e,t,n){for(let r of e.descendantsOfType(t))n(r)}var CN=w("resolved-call-syntax",{clearGroups:[]}),ql=w("resolved-call-sites",{clearGroups:[]}),wN=w("resolved-call-sites-reference-evidence",{clearGroups:[]});function Wl(e,t){return ql.get(e,t.symbolId,()=>xy(e,t,FN(e,t)))}function by(e,t){let n=[...new Map(t.map(o=>[o.symbolId,o])).values()],r=n.filter(o=>!ql.has(e,o.symbolId)),i=vy(e,r);return new Map(n.map(o=>[o.symbolId,ql.get(e,o.symbolId,()=>xy(e,o,i.get(o.symbolId)??[]))]))}function xy(e,t,n){let r=[],i=[],o=new Set,s=new Set;for(let a of n){o.add(a.file);let c=CN.get(e,a.file,()=>kN(e,a.file));if(!c){i.push({callee:t,file:a.file,line:a.startLine,reason:"ast-unavailable",candidates:0,referenceProvenance:a.provenance});continue}let l=(c.byLeaf.get(t.leaf)??[]).filter(({callNode:p})=>p.startPosition.row<=a.endLine&&p.endPosition.row>=a.startLine);if(l.length!==1){i.push({callee:t,file:a.file,line:a.startLine,reason:l.length===0?"call-not-found":"ambiguous-call",candidates:l.length,referenceProvenance:a.provenance});continue}let u=l[0],d=`${a.file}\0${u.callNode.startIndex}\0${u.callNode.endIndex}`;s.has(d)||(s.add(d),r.push({callee:t,caller:ar(B(e,a.file),u.callNode.startPosition.row),file:a.file,line:u.callNode.startPosition.row,startLine:u.callNode.startPosition.row,endLine:u.callNode.endPosition.row,targetText:u.targetNode.text,callNode:u.callNode,targetNode:u.targetNode,arguments:u.arguments,referenceProvenance:a.provenance}))}return{sites:r,unresolved:i,filesVisited:o.size}}function FN(e,t){return vy(e,[t]).get(t.symbolId)??[]}function vy(e,t){if(!TN(e))return new Map(t.map(r=>[r.symbolId,xc(e,r,{semantic:!1}).map(i=>({file:i.file,startLine:i.line,endLine:i.line,provenance:i.provenance}))]));let n=new Map;for(let r of Do(e,t.map(i=>i.symbolId))){let i=n.get(r.symbol_id)??[];i.push({file:r.relative_path,startLine:r.chunk_start,endLine:r.chunk_end,provenance:"scip-reference-chunk"}),n.set(r.symbol_id,i)}return new Map(t.map(r=>[r.symbolId,n.get(r.symbolId)??[]]))}function TN(e){return wN.get(e,"project",()=>!!e.get("SELECT 1 AS present FROM mentions WHERE role != 1 LIMIT 1"))}function kN(e,t){let n=O(e,t)?.rootNode;if(!n)return null;let r=new Map;return Iy(n,i=>{if(i.type!=="call_expression"&&i.type!=="call")return;let o=i.childForFieldName("function")??i.namedChild(0);if(!o)return;let s=vt(o);if(!s)return;let a=i.childForFieldName("arguments")??i.namedChildren.find(u=>u.type==="arguments"),c={callNode:i,targetNode:o,arguments:a?.namedChildren??[]},l=r.get(s);l?l.push(c):r.set(s,[c])}),{byLeaf:r}}function Iy(e,t){t(e);for(let n of e.namedChildren)Iy(n,t)}var NN=w("call-parameter-value-flow",{clearGroups:[]});function wi(e,t){let n=`${t.callee.symbolId}\0${t.file}\0${t.callNode.startIndex}\0${t.callNode.endIndex}`;return NN.get(e,n,()=>_N(e,t))}function Fi(e,t){let n=new Set(t);return[...new Set(e.transfers.flatMap(r=>n.has(r.calleePosition)?[r.callerPosition]:[]))].sort((r,i)=>r-i)}function _N(e,t){let n={file:t.file,startLine:t.startLine,endLine:t.endLine};if(!t.caller)return{callee:t.callee,caller:null,call:n,transfers:[],unknown:t.arguments.map((c,l)=>({calleePosition:l,argumentText:c.text.trim(),reason:"caller-unavailable",proof:n}))};let r=O(e,t.caller.relativePath)?.rootNode,i=r?$e(r,t.caller.startLine,t.caller.endLine):null;if(!i)return{callee:t.callee,caller:t.caller,call:n,transfers:[],unknown:t.arguments.map((c,l)=>({calleePosition:l,argumentText:c.text.trim(),reason:"caller-syntax-unavailable",proof:n}))};let o=Ht(i),s=[],a=[];return t.arguments.forEach((c,l)=>{let u=c.text.trim(),d=o.indexOf(u);d>=0?s.push({calleePosition:l,callerPosition:d,argumentText:u,proof:n}):a.push({calleePosition:l,argumentText:u,reason:"argument-not-direct-parameter",proof:n})}),{callee:t.callee,caller:t.caller,call:n,transfers:s,unknown:a}}var LN=8,DN=8;function Py(e,t,n=[]){let r=[],i=AN(e,n,r),o=i.summaries,s=ON(e,t,o,r),a=MN(e,t,r);return{observations:UN([...s.observations,...a]),bodySummaries:o.size,discriminatorSummaries:s.summaries,filesInspected:i.filesInspected,errors:r}}function AN(e,t,n){let r=new Map,i=[],o=new Map,s=a=>{if(o.has(a))return o.get(a)??null;let c=Pe(e,a);return o.set(a,c),c};for(let a of t){let c={...a,depth:0,proofSpans:[{file:a.definition.relativePath,startLine:a.definition.startLine,endLine:a.definition.endLine}]};r.set(a.definition.symbol,c),i.push(c)}for(;i.length>0;){let a=i.shift();if(!(a.depth>=LN))try{for(let c of Wl(e,a.definition).sites){if(!s(c.file))continue;let u=c.caller;if(!u)continue;let d=Fi(wi(e,c),a.parameterIndexes);if(d.length===0)continue;let p={definition:u,parameterIndexes:ky(d),depth:a.depth+1,proofSpans:[...a.proofSpans,{file:c.file,startLine:c.startLine,endLine:c.endLine}]};GN(r,p)&&i.push(r.get(u.symbol))}}catch(c){n.push(`builtin.carrier body summary failed for ${a.definition.relativePath}: ${Ul(c)}`)}}return{summaries:r,filesInspected:new Set(t.map(a=>a.definition.relativePath)).size}}function ON(e,t,n,r){let i=new Map,o=[],s=[];for(let a of t){if(a.action!=="http.request"||a.strength==="candidate"||a.sourceScope!=="production")continue;let c=Cy(a);if(!c)continue;let l=Pe(e,a.source.file);if(!l)continue;let u=wy(l.root,a.source.startLine),d=u.find(h=>h.startPosition.row===a.source.startLine)??u[0];if(!d)continue;let p=zl(d);if(!p)continue;let f=Sr(e,a.source.file,p.text);if(f.length!==1)continue;let g=n.get(f[0].symbol);if(!g)continue;let y=a.owner.symbol?B(e,a.owner.file).find(h=>h.symbol===a.owner.symbol):null;if(!y)continue;let m=VN(l,y),S=vs(d);for(let h of g.parameterIndexes){let x=WN(l,S[h]);if(x)for(let P of HN(x)){let I=Fy(P),b=Ty(P);if(!I||!b)continue;let v=m.indexOf(b.text.trim());if(v>=0){let M={definition:y,carrier:c,field:I,parameterIndex:v,depth:0,proofObservationIds:[a.id],proofSpans:[a.source,{file:a.source.file,startLine:P.startPosition.row,endLine:P.endPosition.row}]},Y=Ey(M);i.has(Y)||(i.set(Y,M),o.push(M));continue}let C=Qe(l,b);!C||C.evidence==="expression"||s.push(Hl(l,P,"carrier.publish",c,I,C.value,[a.id]))}}}for(;o.length>0;){let a=o.shift();if(!(a.depth>=DN))try{for(let c of Wl(e,a.definition).sites){let l=Pe(e,c.file);if(!l)continue;let u=c.callNode,d=vs(u)[a.parameterIndex];if(!d)continue;let p=Qe(l,d);p&&p.evidence!=="expression"&&s.push(Hl(l,u,"carrier.publish",a.carrier,a.field,p.value,a.proofObservationIds));let f=c.caller;if(!f)continue;let g=wi(e,c).transfers.find(S=>S.calleePosition===a.parameterIndex)?.callerPosition;if(g===void 0)continue;let y={...a,definition:f,parameterIndex:g,depth:a.depth+1,proofSpans:[...a.proofSpans,{file:c.file,startLine:c.startLine,endLine:c.endLine}]},m=Ey(y);i.has(m)||(i.set(m,y),o.push(y))}}catch(c){r.push(`builtin.carrier discriminator summary failed for ${a.definition.relativePath}: ${Ul(c)}`)}}return{observations:s,summaries:i.size}}function MN(e,t,n){let r=[],i=t.filter(o=>o.action==="registry.handle"&&o.strength!=="candidate"&&o.sourceScope==="production");for(let o of t){if(o.action!=="http.handle"||o.strength==="candidate"||o.sourceScope!=="production")continue;let s=Cy(o);if(!s)continue;let a=Pe(e,o.source.file);if(!a)continue;let c=wy(a.root,o.source.startLine)[0];if(c)for(let l of vs(c).slice(1)){let u=Sr(e,o.source.file,l.text);for(let d of u)try{let p=Pe(e,d.relativePath);if(!p)continue;let f=$e(p.root,d.startLine,d.endLine);if(!f)continue;se(f,g=>{if(g.type!=="call_expression")return;let y=zl(g);if(!y)return;let m=/^([A-Za-z_$][\w$]*)\s*\[\s*([A-Za-z_$][\w$]*)\s*\]$/u.exec(y.text.trim());if(!m)return;let S=m[1],h=m[2],x=BN(e,p,d,h);if(!x)return;let P=$N(e,d.relativePath,S);for(let I of i){let b=I.keyParts.find(Y=>Y.name==="registry")?.value,v=I.keyParts.find(Y=>Y.name==="key")?.value;if(!b||!v||!P.some(Y=>Y.file===I.source.file&&Y.binding===b))continue;let C=Pe(e,I.source.file),M=C?qN(C.root,I.source.startLine):null;!C||!M||r.push(Hl(C,M,"carrier.consume",s,x,v,[o.id,I.id]))}})}catch(p){n.push(`builtin.carrier consumer analysis failed for ${d.relativePath}: ${Ul(p)}`)}}}return r}function Ry(e){let t=B(e.db,e.file),n=new Map;return se(e.root,r=>{if(r.type!=="pair"||Fy(r)?.toLowerCase()!=="body")return;let i=Ty(r);if(!i||!/\bJSON\.stringify\s*\(/u.test(i.text))return;let o=ar(t,r.startPosition.row),s=jN(r);if(!o||!s)return;let a=Ht(s),c=new Set;zN(i,a,c);let l=n.get(o.symbol)??new Set;a.forEach((u,d)=>{u&&c.has(u)&&l.add(d)}),l.size>0&&n.set(o.symbol,l)}),t.flatMap(r=>{let i=n.get(r.symbol);return i?[{definition:r,parameterIndexes:[...i].sort((o,s)=>o-s)}]:[]})}function jN(e){let t=e.parent;for(;t;){if(/(?:function|method|lambda)/u.test(t.type)||t.type==="arrow_function")return t;t=t.parent}return null}function BN(e,t,n,r){let i=$e(t.root,n.startLine,n.endLine);if(!i)return null;let o=new RegExp(`\\.body\\??\\.${ie(r)}\\b`,"u");if(o.test(i.text))return r;let s=null;if(se(i,u=>{if(s||u.type!=="variable_declarator")return;let d=u.childForFieldName("name")??u.namedChild(0),p=u.childForFieldName("value")??u.namedChild(1);!d||!p||!new RegExp(`(?:^|[,{}])\\s*${ie(r)}\\s*(?:[,}]|$)`,"u").test(d.text)||p.type==="call_expression"&&(s=zl(p)?.text??null)}),!s)return null;let a=Sr(e,n.relativePath,s);if(a.length!==1)return null;let c=Pe(e,a[0].relativePath),l=c?$e(c.root,a[0].startLine,a[0].endLine):null;return l&&o.test(l.text)&&new RegExp(`\\b${ie(r)}\\s*[,}]`,"u").test(l.text)?r:null}function $N(e,t,n){let r=[];for(let i of Al(e,t,n)){let o=Ge(i.initializer);if(o.type==="call_expression")for(let s of vs(o)){let a=s.text.trim();if(/^[A-Za-z_$][\w$]*$/u.test(a))for(let c of Al(e,i.definition.relativePath,a))r.push({file:c.definition.relativePath,binding:c.definition.leaf})}}return[...new Map(r.map(i=>[`${i.file}\0${i.binding}`,i])).values()]}function Hl(e,t,n,r,i,o,s){let c=xs(e,t,"builtin.carrier",n,[{name:"carrier",value:r,evidence:"constant",term:{kind:"literal",value:r}},{name:"field",value:i,evidence:"literal",term:{kind:"literal",value:i}},{name:"value",value:o,evidence:"constant",term:{kind:"literal",value:o}}],"derived","http-body-registry-discriminator");return c.derivation={kind:"mechanically-derived",rule:"http-body-registry-discriminator",ruleVersion:"1",inputFactIds:[...s],sourceSpans:[c.source]},c}function Cy(e){let t=e.keyParts.find(r=>r.name==="method"&&r.evidence!=="expression")?.value,n=e.keyParts.find(r=>r.name==="path"&&r.evidence!=="expression")?.value;return t&&n?`${t.toUpperCase()} ${n}`:null}function GN(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=ky([...n.parameterIndexes,...t.parameterIndexes]);return r.length===n.parameterIndexes.length&&t.depth>=n.depth?!1:(e.set(t.definition.symbol,{...n,parameterIndexes:r,depth:Math.min(n.depth,t.depth),proofSpans:[...n.proofSpans,...t.proofSpans]}),!0)}function Ey(e){return`${e.definition.symbol}\0${e.carrier}\0${e.field}\0${e.parameterIndex}`}function VN(e,t){let n=$e(e.root,t.startLine,t.endLine);return n?Ht(n):[]}function qN(e,t){let n=null;return se(e,r=>{r.startPosition.row>t||r.endPosition.row<t||(!n||r.endIndex-r.startIndex<n.endIndex-n.startIndex)&&(n=r)}),n}function wy(e,t){let n=[];return se(e,r=>{r.type==="call_expression"&&r.startPosition.row<=t&&r.endPosition.row>=t&&n.push(r)}),n.sort((r,i)=>r.endIndex-r.startIndex-(i.endIndex-i.startIndex))}function zl(e){return e.childForFieldName("function")??e.namedChild(0)}function vs(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function WN(e,t){if(!t)return null;let n=t.text.trim();if(!/^[A-Za-z_$][\w$]*$/u.test(n))return Ge(t);let r=null;return se(e.root,i=>{r||i.type!=="variable_declarator"||(i.childForFieldName("name")??i.namedChild(0))?.text.trim()!==n||(r=i.childForFieldName("value")??i.namedChild(1))}),r?Ge(r):Ge(t)}function HN(e){let t=Ge(e);return t.type==="object"?t.namedChildren.filter(n=>n.type==="pair"||n.type==="shorthand_property_identifier"):[]}function Fy(e){return e.type==="shorthand_property_identifier"?e.text:(e.childForFieldName("key")??e.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")??null}function Ty(e){return e.type==="shorthand_property_identifier"?e:e.childForFieldName("value")??e.namedChild(1)}function zN(e,t,n){let r=new Set(e.text.match(/[A-Za-z_$][\w$]*/gu)??[]);for(let i of t)i&&r.has(i)&&n.add(i)}function ky(e){return[...new Set(e)].sort((t,n)=>t-n)}function UN(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function Ul(e){return e instanceof Error?e.message:String(e)}import{createHash as KN}from"crypto";function Ny(e,t){let n=new Map;for(let o of t){if(o.action!=="http.handle"||o.sourceScope!=="production")continue;let s=n.get(o.source.file)??[];s.push(o),n.set(o.source.file,s)}let r=[],i=JN(e);for(let o of i.mounts)for(let s of o.targetFiles)for(let a of n.get(s)??[]){let c=a.keyParts.find(p=>p.name==="path");if(!c||c.evidence==="expression")continue;let l=YN(o.prefix.value,c.value),u=a.keyParts.map(p=>p.name==="path"?{name:"path",value:l,evidence:"constant",term:{kind:"concat",parts:[o.prefix.term??{kind:"literal",value:o.prefix.value},c.term??{kind:"literal",value:c.value}]},derivation:{kind:"mechanically-derived",rule:"http.mount-prefix",ruleVersion:"1",inputFactIds:[a.id],sourceSpans:[a.source,{file:o.file,startLine:o.line,endLine:o.line},...o.prefix.derivation?.sourceSpans??[],...c.derivation?.sourceSpans??[]]}}:p),d=`${a.id}\0${o.file}\0${o.line}\0${l}`;r.push({...a,id:`boundary:${KN("sha256").update(d).digest("hex").slice(0,16)}`,keyParts:u,strength:"derived",evidence:"framework-mount-composition",derivation:{kind:"mechanically-derived",rule:"http.mount-prefix",ruleVersion:"1",inputFactIds:[a.id],sourceSpans:[a.source,{file:o.file,startLine:o.line,endLine:o.line}]},resolution:"unresolved"}),a.strength="candidate",a.resolution="unresolved"}return{observations:r,filesInspected:i.filesInspected,mounts:i.mounts.length}}function JN(e){let t=[],n=Me(e);for(let r of n){let i=F(e,r);if(!QN(i))continue;let o=Pe(e,r);o&&_y(o.root,s=>{if(s.type!=="call_expression")return;let a=s.childForFieldName("function")??s.namedChild(0);if(!a||!a.text.replace(/\s+/gu,"").endsWith(".use"))return;let c=ZN(s);if(c.length<2)return;let l=Qe(o,c[0]);if(!l||l.evidence==="expression")return;let u=XN(e,r,c[1]);u.length!==0&&t.push({file:r,line:s.startPosition.row,prefix:{value:l.value,evidence:l.evidence,term:l.term,derivation:l.derivation},targetFiles:u})})}return{mounts:t,filesInspected:n.length}}function XN(e,t,n){let r=n.text.replace(/\s+/gu,""),i=/^([A-Za-z_$][\w$]*)/u.exec(r)?.[1];if(!i)return[];let o=ae(e,t).find(c=>c.localName===i&&c.sourcePath);if(!o?.sourcePath)return[t];if(o.kind==="namespace")return[o.sourcePath];let s=o.importedName==="default"?i:o.importedName,a=Ln(e,o.sourcePath,s);return[...new Set(a.map(c=>c.relativePath))]}function YN(e,t){let n=e==="/"?"":e.replace(/\/+$/u,""),r=t.startsWith("/")?t:`/${t}`;return`${n}${r}`||"/"}function QN(e){return/(?:\bfrom\s*|\brequire\s*\(\s*)['"](?:express|fastify|hono|koa-router|@koa\/router)(?:[/']|")/u.test(e)}function ZN(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function _y(e,t){t(e);for(let n of e.namedChildren)_y(n,t)}import{createHash as e_}from"crypto";function Is(e){return[...new Map(e.map(t=>[t.observationId,t])).values()].sort((t,n)=>t.observationId.localeCompare(n.observationId))}var Ps=new Set(["DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT"]),t_=8,Ly=we({kind:"runtime-boundary-http-roles",invalidation:pe("runtime-boundary-http-roles"),serialize:o_,deserialize:s_});function Oy(e,t,n){let r=n??((m,S)=>S()),i=new Map,o=[],s=[],a=new Set,c=[],l=[],u=new Map,d=new Map,p=new Map,f=m=>{if(u.has(m))return u.get(m)??null;let S=Pe(e,m);return u.set(m,S),S},g=m=>{let S=d.get(m);if(S)return S;let h=B(e,m);return d.set(m,h),h},y=(m,S)=>{let h=p.get(m.file);if(!h){let I=De(e,m.file,m.source),b=Ly.read(e,m.file,I)??[];h={contentHash:I,roles:new Map(b.map(v=>[v.symbol,v])),dirty:!1},p.set(m.file,h)}let x=h.roles.get(S.symbol);if(x)return x;let P=i_(m,S);return h.roles.set(S.symbol,{symbol:S.symbol,...P}),h.dirty=!0,P};for(r("runtime-boundaries.http-summary.seed",()=>{for(let m of t){if(m.action!=="http.request"||!m.owner.symbol||m.evidence!=="call-expression"&&m.evidence!=="client-adapter")continue;let S=g(m.owner.file).find(I=>I.symbol===m.owner.symbol);if(!S)continue;let h=f(S.relativePath);if(!h)continue;let x=y(h,S),P={definition:S,...x,constantMethods:m.keyParts.flatMap(I=>I.name==="method"&&I.evidence!=="expression"&&Ps.has(I.value.toUpperCase())?[I.value.toUpperCase()]:[]),depth:0,proofObservationIds:[m.id],proofSpans:[m.source]};Ay(i,P)&&o.push(i.get(S.symbol))}});o.length>0;){let m=o.splice(0,o.length),S=r("runtime-boundaries.http-summary.resolve-call-sites",()=>by(e,m.map(h=>h.definition)),{batchSize:m.length});r("runtime-boundaries.http-summary.process-call-sites",()=>{for(let h of m)if(!(h.depth>=t_))try{let x=S.get(h.definition.symbolId);if(!x)continue;l.push(...x.unresolved.map(P=>n_(h,P)));for(let P of x.sites){let I=f(P.file);if(!I)continue;a.add(P.file);let b=P.callNode,v=r_(h,b,I);v&&s.push(v);let C=P.caller;if(!C)continue;let M=y(I,C),Y=a_(e,h,P),he={definition:C,pathParameterIndexes:Es([...M.pathParameterIndexes,...Y.pathParameterIndexes]),methodParameterIndexes:Es([...M.methodParameterIndexes,...Y.methodParameterIndexes]),constantMethods:xr([...h.constantMethods,...M.constantMethods]),depth:h.depth+1,proofObservationIds:xr([...h.proofObservationIds,...v?[v.id]:[]]),proofSpans:[...h.proofSpans,{file:P.file,startLine:P.startLine,endLine:P.endLine}]};Ay(i,he)&&o.push(i.get(C.symbol))}}catch(x){c.push(`builtin.http-summary failed for ${h.definition.relativePath}:${h.definition.startLine+1}: ${x instanceof Error?x.message:String(x)}`)}},{batchSize:m.length})}return Ly.writeBatch(e,[...p.entries()].flatMap(([m,S])=>S.dirty?[{relativePath:m,contentHash:S.contentHash,value:[...S.roles.values()].sort((h,x)=>h.symbol.localeCompare(x.symbol))}]:[])),{observations:s,frontiers:Is(l),summaries:i.size,filesInspected:a.size,errors:c}}function n_(e,t){let n=xr([...e.pathParameterIndexes.length>0?["path"]:[],...e.methodParameterIndexes.length>0&&e.constantMethods.length!==1?["method"]:[]]),r=e.constantMethods.length===1?e.constantMethods[0]:"?",i=`${e.definition.symbol}\0${t.file}\0${t.line}\0${t.reason}`;return{observationId:`frontier:${e_("sha256").update(i).digest("hex").slice(0,16)}`,kind:"call-resolution",action:"http.request",strength:"candidate",source:{file:t.file,startLine:t.line,endLine:t.line},ownerShortName:null,address:`method=${r??"?"} path=?`,reason:`Compiler identity found a reference to ${e.definition.leaf}, but exact call recovery stopped with ${t.reason} (${t.candidates} syntax candidate(s)); HTTP value propagation did not cross this site.`,missingKeyParts:n.length>0?n:["call"],sourceScope:hs(t.file)}}function r_(e,t,n){let r=My(t),i=e.pathParameterIndexes.flatMap(d=>{let p=Qe(n,r[d]);return p&&p.evidence!=="expression"&&l_(p.value)?[{index:d,value:p}]:[]}),o=e.methodParameterIndexes.flatMap(d=>{let p=Qe(n,r[d]),f=p?.value.toUpperCase();return p&&f&&p.evidence!=="expression"&&Ps.has(f)?[{index:d,value:{...p,value:f}}]:[]}),s=xr([...e.constantMethods,...o.map(d=>d.value.value)]);if(i.length!==1||s.length!==1)return null;let a=i[0].value,c=o.find(d=>d.value.value===s[0])?.value,l=[{name:"method",value:s[0],evidence:c?"constant":"literal",term:c?.term??{kind:"literal",value:s[0]},derivation:c?.derivation},{name:"path",value:a.value,evidence:"constant",term:a.term,derivation:a.derivation}],u=xs(n,t,"builtin.http-summary","http.request",l,"derived","compiler-resolved-http-summary");return u.derivation={kind:"mechanically-derived",rule:"compiler-resolved-http-summary",ruleVersion:"1",inputFactIds:e.proofObservationIds,sourceSpans:[...e.proofSpans,u.source]},u}function i_(e,t){let n=$e(e.root,t.startLine,t.endLine);if(!n)return{pathParameterIndexes:[],methodParameterIndexes:[],constantMethods:[]};let r=Ht(n),i=new Set,o=new Set,s=new Set;return se(n,a=>{if(a.type==="call_expression"&&((a.childForFieldName("function")??a.namedChild(0))?.text.replace(/\s+/gu,"").split(".").at(-1)??"")==="fetch"){let f=My(a);Ti(f[0],r,i);let g=c_(f[1],"method");if(g){Ti(g,r,o);let y=Qe(e,g),m=y?.value.toUpperCase();m&&y?.evidence!=="expression"&&Ps.has(m)&&s.add(m)}else Ti(f[1],r,o)}if(a.type!=="pair")return;let c=a.childForFieldName("key")??a.namedChild(0),l=a.childForFieldName("value")??a.namedChild(1),u=c?.text.replace(/^['"`]|['"`]$/gu,"").toLowerCase();(u==="url"||u==="path"||u==="endpoint")&&Ti(l,r,i),(u==="init"||u==="requestinit"||u==="options")&&Ti(l,r,o)}),{pathParameterIndexes:r.flatMap((a,c)=>a&&i.has(a)?[c]:[]),methodParameterIndexes:r.flatMap((a,c)=>a&&o.has(a)?[c]:[]),constantMethods:[...s].sort()}}function o_(e){return e.map(t=>[encodeURIComponent(t.symbol),t.pathParameterIndexes.join(","),t.methodParameterIndexes.join(","),t.constantMethods.join(",")].join(" ")).join(`
398
- `)}function s_(e){if(!e)return[];let t=[];for(let n of e.split(`
399
- `)){let r=n.split(" ");if(r.length!==4)return null;let i=Dy(r[1]),o=Dy(r[2]),s=r[3]?r[3].split(","):[];if(i===null||o===null||s.some(a=>!Ps.has(a)))return null;t.push({symbol:decodeURIComponent(r[0]),pathParameterIndexes:i,methodParameterIndexes:o,constantMethods:s})}return t}function Dy(e){if(!e)return[];let t=e.split(",").map(Number);return t.every(n=>Number.isSafeInteger(n)&&n>=0)?t:null}function a_(e,t,n){let r=wi(e,n);return{pathParameterIndexes:Fi(r,t.pathParameterIndexes),methodParameterIndexes:Fi(r,t.methodParameterIndexes)}}function Ay(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=Es([...n.pathParameterIndexes,...t.pathParameterIndexes]),i=Es([...n.methodParameterIndexes,...t.methodParameterIndexes]),o=xr([...n.constantMethods,...t.constantMethods]);return r.length!==n.pathParameterIndexes.length||i.length!==n.methodParameterIndexes.length||o.length!==n.constantMethods.length||t.depth<n.depth?(e.set(t.definition.symbol,{...n,pathParameterIndexes:r,methodParameterIndexes:i,constantMethods:o,depth:Math.min(n.depth,t.depth),proofObservationIds:xr([...n.proofObservationIds,...t.proofObservationIds]),proofSpans:[...n.proofSpans,...t.proofSpans]}),!0):!1}function c_(e,t){if(!e)return null;for(let n of e.namedChildren)if(!(n.type!=="pair"||(n.childForFieldName("key")??n.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"").toLowerCase()!==t))return n.childForFieldName("value")??n.namedChild(1);return null}function Ti(e,t,n){if(!e)return;let r=new Set(e.text.match(/[A-Za-z_$][\w$]*/gu)??[]);for(let i of t)i&&r.has(i)&&n.add(i)}function My(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function l_(e){return e.startsWith("/")||/^https?:\/\//iu.test(e)}function Es(e){return[...new Set(e)].sort((t,n)=>t-n)}function xr(e){return[...new Set(e)].sort()}import{createHash as u_}from"crypto";function $y(e){let t=jy(e.filter(r=>r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim")),n=jy(e.filter(r=>r.action==="database.write"&&r.evidence==="persistence-insert"));return e.flatMap(r=>r.action==="database.write"&&r.evidence==="persistence-insert"?Kl(r).flatMap(i=>{let o=t.get(i)?.[0];return o?[By(r,o,i,"queue.send")]:[]}):r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim"?Kl(r).flatMap(i=>{let o=n.get(i)?.[0];return o?[By(r,o,i,"queue.consume")]:[]}):[])}function jy(e){let t=new Map;for(let n of e)for(let r of Kl(n)){let i=t.get(r);i?i.push(n):t.set(r,[n])}for(let n of t.values())n.sort((r,i)=>r.id.localeCompare(i.id));return t}function Kl(e){return e.keyParts.filter(t=>t.name==="resource").map(t=>t.value)}function By(e,t,n,r){let i=`database:${n}`,o=r==="queue.send"?"database-queue-insert":"database-queue-skip-locked-claim",s=[e.id,r,i,o].join("\0");return{...e,id:`boundary:${u_("sha256").update(s).digest("hex").slice(0,16)}`,extractor:"builtin.database-queue",action:r,keyParts:[{name:"address",value:i,evidence:"identifier",term:{kind:"symbol",symbol:n},derivation:{kind:"mechanically-derived",rule:"database-work-queue.resource",ruleVersion:"1",inputFactIds:[e.id,t.id],sourceSpans:[e.source,t.source]}}],evidence:o,strength:"derived",protocol:"queue",role:r==="queue.send"?"producer":"consumer",derivation:{kind:"mechanically-derived",rule:"database-work-queue.insert-skip-locked",ruleVersion:"1",inputFactIds:[e.id,t.id],sourceSpans:[e.source,t.source]},valuePrecision:"symbolic",resolution:"unresolved"}}var Jl="runtime-boundaries-v19",p_=d_(import.meta.url),X=p_("typescript"),f_=new Set([X.SyntaxKind.WhitespaceTrivia,X.SyntaxKind.NewLineTrivia,X.SyntaxKind.SingleLineCommentTrivia,X.SyntaxKind.MultiLineCommentTrivia]),m_=new Set([X.SyntaxKind.NoSubstitutionTemplateLiteral,X.SyntaxKind.TemplateHead,X.SyntaxKind.TemplateMiddle,X.SyntaxKind.TemplateTail]),ws=[{id:"http.method-path",protocol:"http",producerActions:["http.request"],consumerActions:["http.handle"],keyNames:["method","path"],traversable:!0},{id:"registry.identity-key",protocol:"registry",producerActions:["registry.dispatch"],consumerActions:["registry.handle"],keyNames:["registry","key"],traversable:!0},{id:"registry.capability-key",protocol:"registry",producerActions:["registry.reference"],consumerActions:["registry.handle"],keyNames:["key"],traversable:!0,requireUniqueConsumer:!0},{id:"queue.address",protocol:"queue",producerActions:["queue.send"],consumerActions:["queue.consume"],keyNames:["address"],traversable:!0},{id:"carrier.discriminator",protocol:"carrier",producerActions:["carrier.publish"],consumerActions:["carrier.consume"],keyNames:["carrier","field","value"],traversable:!0},{id:"resource.identity",protocol:"database",producerActions:["database.write"],consumerActions:["database.read"],keyNames:["resource"],traversable:!1},{id:"framework.effect-httpapi-operation",protocol:"framework",producerActions:[],consumerActions:["framework.handle"],declarationActions:["framework.declare"],keyNames:["adapter","group","operation"],traversable:!0,linkFrom:"declaration",requireUniquePair:!0}],g_=64,Wy="builtin.http-summary",Fs={HTTP_HANDLE:"http.handle",HTTP_REQUEST:"http.request",REGISTRY_HANDLE:"registry.handle"},Xl=new Set(Object.values(Fs));function y_(e,t={}){let n=Me(e),r=new Set(n),i=new Set((t.affectedFiles??[]).map(O_)),o=t.previousGraph?.fileCoverage,s=i.size>0&&t.previousGraph?.extractorVersion===Jl&&o!==void 0&&o.length===t.previousGraph.coverage.filesScanned,a=s?o.filter(_=>r.has(_.file)&&!i.has(_.file)):[],c=new Set(a.flatMap(_=>_.observationIds)),l=s?t.previousGraph.observations.filter(_=>c.has(_.id)&&r.has(_.source.file)):[],u=s?n.filter(_=>i.has(_)):n,d=[],p=o?.reduce((_,$)=>_+$.observationIds.length,0)??0,f=performance.now(),g=k_(e,u,t.profileSpan);Dt(d,"direct-extraction",f,u.length,g.observations.length,{filesVisited:u.length,filesReused:a.length,factsReused:l.length,factsInvalidated:Math.max(0,p-l.length)});let y=[...a,...g.fileCoverage].sort((_,$)=>_.file.localeCompare($.file)),m=A_(y),S=y.flatMap(_=>_.extractionErrors),h=ki([...l,...g.observations]);if(s&&!t.forceDerivedRebuild&&t.previousGraph&&h_(o,g.fileCoverage,i)&&(!E_(e,t.previousGraph,i)||C_(o,g.fileCoverage,i)&&!w_(t.previousGraph,i))){for(let $ of t.previousGraph.coverage.extractors)m.has($.id)||m.set($.id,$);let _=T_(t.previousGraph.coverage.phases);return d.push(..._),{...t.previousGraph,observations:t.previousGraph.observations,relationGroups:t.previousGraph.relationGroups,links:t.previousGraph.links,frontiers:t.previousGraph.frontiers,coverage:{filesScanned:n.length,filesWithAst:y.filter($=>$.hasAst).length,filesWithoutAst:y.filter($=>!$.hasAst).length,filesReused:a.length,extractors:[...m.values()],extractionErrors:t.previousGraph.coverage.extractionErrors,phases:d},fileCoverage:y}}let x=ki([...h,...$y(h)]),P=s&&t.previousGraph!==void 0?S_(t.previousGraph,o,g.fileCoverage,i,h):{reuse:!1,shapeUnchanged:!1,proofFilesUnchanged:!1,seedUnchanged:!1},I=P.reuse;t.profileSpan?.("runtime-boundaries.http-summary.reuse-decision",()=>{},P),f=performance.now();let b;if(I){let _=t.previousGraph.coverage.phases?.find(Q=>Q.id==="http-summary"),$=t.previousGraph.coverage.extractors.find(Q=>Q.id==="builtin.wrapper");b={observations:t.previousGraph.observations.filter(Q=>Q.extractor===Wy),frontiers:t.previousGraph.frontiers.filter(Q=>Q.kind==="call-resolution"&&Q.action===Fs.HTTP_REQUEST),summaries:0,filesInspected:_?.filesVisited??$?.applicableFiles??0,errors:t.previousGraph.coverage.extractionErrors.filter(Q=>Q.startsWith("builtin.http-summary failed"))},Dt(d,"http-summary",f,x.length,b.observations.length,{filesVisited:0,filesReused:b.filesInspected,factsReused:b.observations.length+b.frontiers.length,factsInvalidated:0}),$&&m.set($.id,$)}else b=Oy(e,x,t.profileSpan),Dt(d,"http-summary",f,x.length,b.observations.length,{filesVisited:b.filesInspected}),m.set("builtin.wrapper",{id:"builtin.wrapper",applicableFiles:b.filesInspected,observations:b.observations.length,errors:b.errors.length});S.push(...b.errors);let v=ki([...x,...b.observations]);f=performance.now();let C=Ny(e,v);Dt(d,"http-mount",f,v.length,C.observations.length,{filesVisited:C.filesInspected});let M=ki([...v,...C.observations]);f=performance.now();let Y=I&&t.previousGraph!==void 0&&b_(t.previousGraph,o,g.fileCoverage,i),he;if(Y){let _=t.previousGraph.coverage.phases?.find(Q=>Q.id==="carrier"),$=t.previousGraph.coverage.extractors.find(Q=>Q.id==="builtin.carrier");he={observations:t.previousGraph.observations.filter(Q=>Q.extractor==="builtin.carrier"),bodySummaries:$?.applicableFiles??0,discriminatorSummaries:0,filesInspected:_?.filesVisited??0,errors:t.previousGraph.coverage.extractionErrors.filter(Q=>Q.startsWith("builtin.carrier"))},Dt(d,"carrier",f,M.length,he.observations.length,{filesVisited:0,filesReused:he.filesInspected,factsReused:he.observations.length,factsInvalidated:0}),$&&m.set($.id,$)}else he=Py(e,M,y.flatMap(_=>_.bodySummaries??[])),Dt(d,"carrier",f,M.length,he.observations.length,{filesVisited:he.filesInspected}),m.set("builtin.carrier",{id:"builtin.carrier",applicableFiles:he.bodySummaries,observations:he.observations.length,errors:he.errors.length});S.push(...he.errors);let en=ki([...M,...he.observations]);f=performance.now();let On=M_(en);Dt(d,"relations",f,en.length,On.length),f=performance.now();let Yl=B_(en,On);Dt(d,"links",f,On.length,Yl.length),$_(en,On),f=performance.now();let Ql=Is([...G_(en,On),...b.frontiers]);return Dt(d,"frontiers",f,en.length,Ql.length),{schemaVersion:2,extractorVersion:Jl,observations:en,relationGroups:On,links:Yl,frontiers:Ql,coverage:{filesScanned:n.length,filesWithAst:y.filter(_=>_.hasAst).length,filesWithoutAst:y.filter(_=>!_.hasAst).length,...s?{filesReused:a.length}:{},extractors:[...m.values()],extractionErrors:S,phases:d},fileCoverage:y}}function h_(e,t,n){if(!e)return!1;let r=e.filter(o=>n.has(o.file)).filter(Gy).map(Vy).sort((o,s)=>o.file.localeCompare(s.file)),i=t.filter(Gy).map(Vy).sort((o,s)=>o.file.localeCompare(s.file));return JSON.stringify(r)===JSON.stringify(i)}function Gy(e){return e.observationIds.length>0||e.extractionErrors.length>0}function Vy(e){let{syntaxHash:t,shapeHash:n,bodySummaries:r,...i}=e;return i}function S_(e,t,n,r,i){let o=v_(t,n,r),s=I_(e),c=![...Hy(t,n)].some(p=>s.has(p)),l=new Set((t??[]).filter(p=>r.has(p.file)).flatMap(p=>p.observationIds)),u=new Set(n.flatMap(p=>p.observationIds)),d=qy(e.observations,l)===qy(i,u);return{reuse:o&&c&&d,shapeUnchanged:o,proofFilesUnchanged:c,seedUnchanged:d}}function Hy(e,t){let n=new Map(e?.map(r=>[r.file,r.syntaxHash])??[]);return new Set(t.filter(r=>r.syntaxHash===void 0||n.get(r.file)!==r.syntaxHash).map(r=>r.file))}function b_(e,t,n,r){if(!t)return!1;let i=t.filter(c=>r.has(c.file)).map(({file:c,bodySummaries:l})=>({file:c,bodySummaries:l??[]})).sort((c,l)=>c.file.localeCompare(l.file)),o=n.map(({file:c,bodySummaries:l})=>({file:c,bodySummaries:l??[]})).sort((c,l)=>c.file.localeCompare(l.file));if(JSON.stringify(i)!==JSON.stringify(o))return!1;let s=Hy(t,n),a=x_(e,"builtin.carrier");return![...s].some(c=>a.has(c))}function x_(e,t){let n=new Set;for(let r of e.observations)if(r.extractor===t){n.add(r.source.file);for(let i of r.derivation.sourceSpans)n.add(i.file)}return n}function v_(e,t,n){if(!e)return!1;let r=new Map(e.filter(i=>n.has(i.file)).map(i=>[i.file,i.shapeHash]));return t.length===n.size&&t.every(i=>i.shapeHash!==void 0&&r.get(i.file)===i.shapeHash)}function I_(e){let t=new Set;for(let n of e.observations)if(n.extractor===Wy){t.add(n.source.file);for(let r of n.derivation.sourceSpans)t.add(r.file)}for(let n of e.frontiers)n.kind==="call-resolution"&&n.action===Fs.HTTP_REQUEST&&n.source&&t.add(n.source.file);return t}function qy(e,t){return JSON.stringify(e.filter(n=>t.has(n.id)&&n.action===Fs.HTTP_REQUEST&&n.owner.symbol!==null&&(n.evidence==="call-expression"||n.evidence==="client-adapter")).map(n=>({ownerSymbol:n.owner.symbol,evidence:n.evidence,methods:n.keyParts.filter(r=>r.name==="method"&&r.evidence!=="expression").map(r=>r.value.toUpperCase()).sort()})).sort((n,r)=>`${n.ownerSymbol}\0${n.evidence}\0${n.methods.join(",")}`.localeCompare(`${r.ownerSymbol}\0${r.evidence}\0${r.methods.join(",")}`)))}function E_(e,t,n){let r=P_(t),i=R_(t);if([...n].some(a=>r.has(a)))return!0;if(i.size===0||n.size===0)return!1;if(!!!e.get("SELECT 1 AS present FROM mentions WHERE role != 1 LIMIT 1"))return!0;let s=[...n];for(let a=0;a<s.length;a+=750){let c=s.slice(a,a+750),l=c.map(()=>"?").join(",");if(e.all(`SELECT DISTINCT global_symbol.symbol
400
- FROM mentions mention
401
- JOIN chunks reference_chunk ON reference_chunk.id = mention.chunk_id
402
- JOIN documents reference_document ON reference_document.id = reference_chunk.document_id
403
- JOIN global_symbols global_symbol ON global_symbol.id = mention.symbol_id
404
- WHERE mention.role != 1
405
- AND reference_document.relative_path IN (${l})`,...c).some(d=>i.has(d.symbol)))return!0}return!1}function P_(e){let t=new Set;for(let n of e.observations)if(Xl.has(n.action)){t.add(n.source.file);for(let r of n.derivation?.sourceSpans??[])t.add(r.file)}for(let n of e.frontiers)!n.action||!Xl.has(n.action)||!n.source||t.add(n.source.file);return t}function R_(e){return new Set(e.observations.flatMap(t=>Xl.has(t.action)&&t.owner.symbol?[t.owner.symbol]:[]))}function C_(e,t,n){if(!e)return!1;let r=new Map(e.filter(i=>n.has(i.file)).map(i=>[i.file,i.syntaxHash]));return t.length===n.size&&t.every(i=>i.syntaxHash!==void 0&&r.get(i.file)===i.syntaxHash)}function w_(e,t){let n=F_(e);return[...t].some(r=>n.has(r))}function F_(e){let t=new Set;for(let n of e.observations){t.add(n.source.file);for(let r of n.derivation?.sourceSpans??[])t.add(r.file)}for(let n of e.frontiers)n.source&&t.add(n.source.file);return t}function T_(e){return(e??[]).filter(t=>t.id!=="direct-extraction").map(t=>({...t,durationMs:0,filesVisited:0,filesReused:t.filesVisited??0,factsReused:t.outputFacts,factsInvalidated:0}))}function Dt(e,t,n,r,i,o={}){e.push({id:t,durationMs:Math.max(0,performance.now()-n),inputFacts:r,outputFacts:i,...o})}function k_(e,t,n){let r=[],i=[];for(let o of t){let s=va(e,o),a=$l.filter(p=>p.supports(s)),c=/\bJSON\.stringify\s*\(/u.test(s)&&/\bbody\s*:/u.test(s),l=a.length>0||c?Pe(e,o,s,n):null,u=N_(o,s),d={file:o,hasAst:l!==null||D_(o,s),syntaxHash:u.syntaxHash,shapeHash:u.shapeHash,bodySummaries:l&&c?Ry(l):[],observationIds:[],extractors:[],extractionErrors:[]};if(l)for(let p of a){let f={id:p.id,applicableFiles:1,observations:0,errors:0};try{let g=L_(n,`runtime-boundaries.extractor.${p.id}`,o,()=>p.extract(l));f.observations=g.length,r.push(...g),d.observationIds.push(...g.map(y=>y.id))}catch(g){f.errors=1,d.extractionErrors.push(`${p.id} failed for ${o}: ${g instanceof Error?g.message:String(g)}`)}d.extractors.push(f)}i.push(d)}return{observations:r,fileCoverage:i}}function N_(e,t){if(!/\.(?:[cm]?[jt]sx?)$/iu.test(e)){let l=Ni("sha256").update(t).digest("hex");return{syntaxHash:l,shapeHash:l}}let n=/\.[jt]sx$/iu.test(e)?X.LanguageVariant.JSX:X.LanguageVariant.Standard,r=X.createScanner(X.ScriptTarget.Latest,!1,n,t),i=Ni("sha256"),o=Ni("sha256"),s=[],a=[0];for(let l=0;l<t.length;l+=1)t.charCodeAt(l)===10&&a.push(l+1);let c=0;for(let l=r.scan();l!==X.SyntaxKind.EndOfFileToken;l=r.scan()){if(l===X.SyntaxKind.CloseBraceToken&&s.length>0&&s.at(-1)===0&&(l=r.reScanTemplateToken(!1)),f_.has(l))continue;let u=r.getTokenText();for(;a[c+1]!==void 0&&a[c+1]<=r.getTokenPos();)c+=1;i.update(String(l)),i.update("\0"),i.update(u),i.update("\0"),i.update(String(c)),i.update("\0"),o.update(String(l)),o.update("\0"),!m_.has(l)&&!__(l,u)&&o.update(u),o.update("\0"),o.update(String(c)),o.update("\0"),l===X.SyntaxKind.TemplateHead?s.push(0):l===X.SyntaxKind.TemplateTail?s.pop():l===X.SyntaxKind.OpenBraceToken&&s.length>0?s[s.length-1]+=1:l===X.SyntaxKind.CloseBraceToken&&s.length>0&&s.at(-1)>0&&(s[s.length-1]-=1)}return{syntaxHash:i.digest("hex"),shapeHash:o.digest("hex")}}function __(e,t){if(e!==X.SyntaxKind.StringLiteral||t.length<2)return!1;let n=t.slice(1,-1);return n.startsWith("/")||n.includes("://")}function L_(e,t,n,r){return e?e(t,r,{file:n}):r()}function D_(e,t){return t?it(e)?/<script\b/iu.test(t):oe(e)!==null:!1}function A_(e){let t=new Map($l.map(n=>[n.id,{id:n.id,applicableFiles:0,observations:0,errors:0}]));for(let n of e)for(let r of n.extractors){let i=t.get(r.id);i&&(i.applicableFiles+=r.applicableFiles,i.observations+=r.observations,i.errors+=r.errors)}return t}function O_(e){return e.replaceAll("\\","/").replace(/^\.\//u,"")}function M_(e){let t=new Map;for(let n of ws){let r=new Set([...n.producerActions,...n.consumerActions,...n.declarationActions??[]]);for(let i of e){if(!r.has(i.action)||i.strength==="candidate")continue;let o=q_(i,n.keyNames);if(!o)continue;let s=o.map(d=>`${d.name}=${Uy(d.name,d.value)}`).join("\0"),a=i.sourceScope==="production"?"production":i.sourceScope,c=`${n.id}\0${a}\0${s}`,l=`boundary-group:${Ni("sha256").update(c).digest("hex").slice(0,16)}`,u=t.get(l)??{id:l,protocol:n.protocol,joinRule:n.id,normalizedKey:s,keyParts:o,producerIds:[],consumerIds:[],declarationIds:[],derivation:{kind:"mechanically-derived",rule:n.id,ruleVersion:"2",inputFactIds:[],sourceSpans:[]}};n.producerActions.includes(i.action)&&u.producerIds.push(i.id),n.consumerActions.includes(i.action)&&u.consumerIds.push(i.id),n.declarationActions?.includes(i.action)&&u.declarationIds.push(i.id),u.derivation.inputFactIds.push(i.id),u.derivation.sourceSpans.push(i.source),t.set(l,u)}}return[...t.values()].map(j_).sort(H_)}function j_(e){return{...e,producerIds:Rs(e.producerIds),consumerIds:Rs(e.consumerIds),declarationIds:Rs(e.declarationIds),derivation:{...e.derivation,inputFactIds:Rs(e.derivation.inputFactIds),sourceSpans:[...new Map(e.derivation.sourceSpans.map(t=>[`${t.file}:${t.startLine}:${t.endLine}`,t])).values()]}}}function B_(e,t){let n=new Map(e.map(i=>[i.id,i])),r=new Map;for(let i of t){let o=ws.find(a=>a.id===i.joinRule);if(!o?.traversable)continue;let s=o.linkFrom==="declaration"?i.declarationIds:i.producerIds;if(!(s.length===0||i.consumerIds.length===0)&&!(o.requireUniquePair&&(s.length!==1||i.consumerIds.length!==1))&&!(o.requireUniqueConsumer&&i.consumerIds.length!==1)&&!(s.length*i.consumerIds.length>g_))for(let a of s)for(let c of i.consumerIds){let l=n.get(a),u=n.get(c);if(!l||!u||W_(l,u))continue;let d=l.strength==="derived"||u.strength==="derived"?"derived":"exact",p=`${i.joinRule}\0${a}\0${c}`,f={id:`boundary-link:${Ni("sha256").update(p).digest("hex").slice(0,16)}`,from:a,to:c,joinRule:i.joinRule,matchedKeyParts:i.keyParts,strength:d,derivation:{kind:"mechanically-derived",rule:i.joinRule,ruleVersion:"2",inputFactIds:[a,c],sourceSpans:[l.source,u.source]}};r.set(f.id,f)}}return[...r.values()].sort(z_)}function $_(e,t){let n=new Set(t.filter(zy).flatMap(Cs)),r=new Set(t.filter(V_).flatMap(Cs));for(let i of e)i.resolution=n.has(i.id)?"locally-linked":r.has(i.id)?"ambiguous":"unresolved"}function G_(e,t){let n=new Set(e.filter(o=>o.strength!=="candidate").map(o=>`${o.action}\0${o.source.file}\0${o.source.startLine}\0${o.source.endLine}`)),r=new Set(t.flatMap(Cs)),i=new Set(t.filter(zy).flatMap(Cs));return e.filter(o=>o.sourceScope==="production").filter(o=>o.strength!=="candidate"||!n.has(`${o.action}\0${o.source.file}\0${o.source.startLine}\0${o.source.endLine}`)).filter(o=>!i.has(o.id)).map(o=>{let s=o.keyParts.filter(c=>c.evidence==="expression"||c.value.length===0).map(c=>c.name),a=s.length>0?`${o.extractor} observed ${o.action}, but ${s.join(", ")} remained symbolic or unknown.`:o.resolution==="ambiguous"?`${o.extractor} established the address for ${o.action}, but more than one indexed peer has the same runtime key.`:r.has(o.id)?`${o.extractor} established the address for ${o.action}, but the indexed production scope contains no counterpart role in that relation group.`:`${o.extractor} observed ${o.action}, but no supported factorization rule could establish its addressed relation.`;return{observationId:o.id,reason:a,missingKeyParts:s,sourceScope:o.sourceScope}}).sort((o,s)=>o.observationId.localeCompare(s.observationId))}function Cs(e){return[...e.producerIds,...e.consumerIds,...e.declarationIds]}function zy(e){let t=ws.find(r=>r.id===e.joinRule);if(!t)return!1;let n=t.linkFrom==="declaration"?e.declarationIds:e.producerIds;return n.length===0||e.consumerIds.length===0?!1:!t.requireUniquePair||n.length===1&&e.consumerIds.length===1}function V_(e){let t=ws.find(r=>r.id===e.joinRule);if(!t?.requireUniquePair)return!1;let n=t.linkFrom==="declaration"?e.declarationIds:e.producerIds;return n.length>0&&e.consumerIds.length>0&&(n.length!==1||e.consumerIds.length!==1)}function q_(e,t){let n=[];for(let r of t){let i=e.keyParts.find(o=>o.name===r);if(!i||i.evidence==="expression"||i.value.length===0)return null;n.push({...i,value:Uy(r,i.value)})}return n}function Uy(e,t){if(e==="method")return t.toUpperCase();if(e!=="path")return t;let n=t.startsWith("/")?t:`/${t}`;return n.length>1?n.replace(/\/+$/u,""):n}function W_(e,t){return e.source.file===t.source.file&&e.source.startLine===t.source.startLine}function ki(e){return[...new Map(e.map(t=>[t.id,t])).values()].sort((t,n)=>t.source.file.localeCompare(n.source.file)||t.source.startLine-n.source.startLine||t.action.localeCompare(n.action))}function Rs(e){return[...new Set(e)].sort()}function H_(e,t){return e.joinRule.localeCompare(t.joinRule)||e.normalizedKey.localeCompare(t.normalizedKey)}function z_(e,t){return e.joinRule.localeCompare(t.joinRule)||e.from.localeCompare(t.from)||e.to.localeCompare(t.to)}import U_ from"better-sqlite3";var ks="scip_query_runtime_boundaries",An="scip_query_runtime_observations",Ns="scip_query_runtime_relation_groups",_s="scip_query_runtime_relation_participants";function K_(e,t){let n=new U_(e);try{n.exec(`
406
- CREATE TABLE IF NOT EXISTS ${ks} (
407
- singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
408
- schema_version INTEGER NOT NULL,
409
- extractor_version TEXT NOT NULL,
410
- payload TEXT NOT NULL
411
- )
412
- `),X_(n),n.transaction(()=>{n.prepare(`INSERT OR REPLACE INTO ${ks} (singleton, schema_version, extractor_version, payload) VALUES (1, ?, ?, ?)`).run(t.schemaVersion,t.extractorVersion,JSON.stringify(t)),n.prepare(`DELETE FROM ${An}`).run(),n.prepare(`DELETE FROM ${_s}`).run(),n.prepare(`DELETE FROM ${Ns}`).run();let r=n.prepare(`INSERT INTO ${An}
413
- (id, protocol, action, role, strength, source_scope, resolution, file, start_line, end_line, owner_symbol, payload)
414
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);for(let s of t.observations)r.run(s.id,s.protocol,s.action,s.role,s.strength,s.sourceScope,s.resolution,s.source.file,s.source.startLine,s.source.endLine,s.owner.symbol,JSON.stringify(s));let i=n.prepare(`INSERT INTO ${Ns} (id, protocol, join_rule, normalized_key, payload) VALUES (?, ?, ?, ?, ?)`),o=n.prepare(`INSERT INTO ${_s} (group_id, observation_id, participant_role) VALUES (?, ?, ?)`);for(let s of t.relationGroups){i.run(s.id,s.protocol,s.joinRule,s.normalizedKey,JSON.stringify(s));for(let a of s.producerIds)o.run(s.id,a,"producer");for(let a of s.consumerIds)o.run(s.id,a,"consumer");for(let a of s.declarationIds)o.run(s.id,a,"declaration")}})()}finally{n.close()}}function J_(e,t={}){if(!Y_(e,An))return Ky(e)?.observations??[];let n=[],r=[];return Ts(n,r,"protocol",t.protocols),Ts(n,r,"action",t.actions),Ts(n,r,"source_scope",t.sourceScopes),Ts(n,r,"file",t.files),e.all(`SELECT payload FROM ${An}${n.length>0?` WHERE ${n.join(" AND ")}`:""} ORDER BY file, start_line, id`,...r).flatMap(o=>Q_(o.payload))}function X_(e){e.exec(`
415
- CREATE TABLE IF NOT EXISTS ${An} (
416
- id TEXT PRIMARY KEY,
417
- protocol TEXT NOT NULL,
418
- action TEXT NOT NULL,
419
- role TEXT NOT NULL,
420
- strength TEXT NOT NULL,
421
- source_scope TEXT NOT NULL,
422
- resolution TEXT NOT NULL,
423
- file TEXT NOT NULL,
424
- start_line INTEGER NOT NULL,
425
- end_line INTEGER NOT NULL,
426
- owner_symbol TEXT,
427
- payload TEXT NOT NULL
428
- );
429
- CREATE INDEX IF NOT EXISTS idx_runtime_observations_protocol_action_scope
430
- ON ${An}(protocol, action, source_scope);
431
- CREATE INDEX IF NOT EXISTS idx_runtime_observations_file_line
432
- ON ${An}(file, start_line);
433
-
434
- CREATE TABLE IF NOT EXISTS ${Ns} (
435
- id TEXT PRIMARY KEY,
436
- protocol TEXT NOT NULL,
437
- join_rule TEXT NOT NULL,
438
- normalized_key TEXT NOT NULL,
439
- payload TEXT NOT NULL
440
- );
441
- CREATE INDEX IF NOT EXISTS idx_runtime_groups_protocol_key
442
- ON ${Ns}(protocol, join_rule, normalized_key);
443
-
444
- CREATE TABLE IF NOT EXISTS ${_s} (
445
- group_id TEXT NOT NULL,
446
- observation_id TEXT NOT NULL,
447
- participant_role TEXT NOT NULL,
448
- PRIMARY KEY (group_id, observation_id, participant_role)
449
- );
450
- CREATE INDEX IF NOT EXISTS idx_runtime_participants_observation
451
- ON ${_s}(observation_id, participant_role);
452
- `)}function Y_(e,t){return!!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",t)}function Ts(e,t,n,r){!r||r.length===0||(e.push(`${n} IN (${r.map(()=>"?").join(", ")})`),t.push(...r))}function Q_(e){try{return[JSON.parse(e)]}catch{return[]}}function Ky(e){if(!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",ks))return null;let n=e.get(`SELECT schema_version, payload FROM ${ks} WHERE singleton = 1`);if(!n||n.schema_version!==2)return null;try{let r=JSON.parse(n.payload);return r.schemaVersion===2&&Array.isArray(r.observations)&&Array.isArray(r.relationGroups)&&Array.isArray(r.links)?r:null}catch{return null}}export{At as a,cu as b,vr as c,Ai as d,Ir as e,iL as f,th as g,V as h,Bt as i,Z as j,on as k,Ae as l,Re as m,te as n,sn as o,be as p,Mh as q,nt as r,ee as s,j as t,T as u,jh as v,Bh as w,an as x,Z_ as y,eL as z,Ue as A,nD as B,Rr as C,Kh as D,Jh as E,rD as F,iD as G,Zh as H,iS as I,Wu as J,oD as K,qi as L,xe as M,zi as N,Yu as O,Qu as P,Zu as Q,bD as R,PD as S,yt as T,Vn as U,ue as V,L as W,q as X,Di as Y,ca as Z,Xi as _,Yi as $,la as aa,$D as ba,sa as ca,GD as da,VD as ea,da as fa,gn as ga,vb as ha,Hn as ia,to as ja,Ib as ka,Fd as la,Lr as ma,$t as na,wb as oa,Fb as pa,Tb as qa,zn as ra,lA as sa,uA as ta,Un as ua,mt as va,Mi as wa,sL as xa,R as ya,aL as za,cL as Aa,lL as Ba,mu as Ca,ji as Da,dL as Ea,tn as Fa,Ot as Ga,hL as Ha,gu as Ia,ih as Ja,SL as Ka,Mn as La,xL as Ma,w as Na,Ze as Oa,Mt as Pa,yh as Qa,H as Ra,De as Sa,gt as Ta,kL as Ua,NL as Va,_L as Wa,LL as Xa,DL as Ya,AL as Za,ve as _a,_d as $a,$d as ab,dx as bb,Jn as cb,rt as db,Vt as eb,Be as fb,jt as gb,Lu as hb,Du as ib,Au as jb,_h as kb,VL as lb,z as mb,qL as nb,$i as ob,we as pb,Dd as qb,pe as rb,F as sb,IA as tb,Dr as ub,qb as vb,EA as wb,PA as xb,ie as yb,Da as zb,QA as Ab,ZA as Bb,Aa as Cb,oe as Db,it as Eb,se as Fb,$e as Gb,Yd as Hb,sO as Ib,aO as Jb,O as Kb,RO as Lb,me as Mb,Uv as Nb,Kv as Ob,qr as Pb,Qv as Qb,Zv as Rb,NA as Sb,Bd as Tb,Me as Ub,_A as Vb,DM as Wb,xE as Xb,Co as Yb,uB as Zb,Pt as _b,ae as $b,xB as ac,vB as bc,TB as cc,or as dc,kB as ec,NB as fc,_B as gc,JP as hc,Fo as ic,Xe as jc,ge as kc,Ut as lc,ye as mc,Rn as nc,lc as oc,sr as pc,ff as qc,DB as rc,AB as sc,OB as tc,MB as uc,uc as vc,dc as wc,a0 as xc,B as yc,c0 as zc,xR as Ac,l0 as Bc,u0 as Cc,d0 as Dc,RR as Ec,ar as Fc,p0 as Gc,Oq as Hc,Vg as Ic,_o as Jc,hc as Kc,B0 as Lc,v0 as Mc,VR as Nc,I0 as Oc,E0 as Pc,s$ as Qc,a$ as Rc,c$ as Sc,Do as Tc,_0 as Uc,L0 as Vc,yc as Wc,Sc as Xc,Nf as Yc,Lf as Zc,bc as _c,r$ as $c,hC as ad,SC as bd,i$ as cd,bC as dd,xC as ed,g$ as fd,xc as gd,x$ as hd,jf as id,v$ as jd,Bf as kd,_$ as ld,MC as md,Ic as nd,L$ as od,$C as pd,GC as qd,D$ as rd,A$ as sd,O$ as td,wn as ud,Ct as vd,Ne as wd,wt as xd,Ft as yd,H$ as zd,qg as Ad,jq as Bd,Rc as Cd,Mo as Dd,Jt as Ed,_e as Fd,Cl as Gd,dt as Hd,Jq as Id,ms as Jd,Xq as Kd,Qg as Ld,Yq as Md,Qq as Nd,Zq as Od,Pk as Pd,eW as Qd,tW as Rd,gs as Sd,Dg as Td,pG as Ud,fG as Vd,mG as Wd,gG as Xd,re as Yd,Pw as Zd,Bo as _d,Fw as $d,IG as ae,EG as be,DG as ce,Cc as de,WG as ee,HG as fe,zG as ge,hs as he,Ln as ie,Qe as je,Wl as ke,wi as le,Jl as me,y_ as ne,K_ as oe,J_ as pe,Ky as qe,zo as re,lm as se,Uo as te,Ko as ue,dr as ve,zw as we,mm as xe,Tt as ye,a1 as ze,b1 as Ae,Pm as Be,T1 as Ce,Zo as De,B1 as Ee,Z1 as Fe,eV as Ge,lV as He,uV as Ie,dV as Je,SV as Ke,CV as Le,wV as Me,eg as Ne,wT as Oe,BV as Pe,$V as Qe,is as Re,cs as Se,Sq as Te,Ig as Ue,bq as Ve,_t as We,dg as Xe,Eg as Ye,mi as Ze,xq as _e,vq as $e,Iq as af,gl as bf,fg as cf,us as df,_q as ef,vi as ff,Lq as gf};
453
- //# sourceMappingURL=chunk-VRJG7N3I.js.map