scip-query 0.22.0 → 0.24.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 (470) hide show
  1. package/CHANGELOG.md +500 -0
  2. package/README.md +13 -0
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-H3P6BR5G.js +2 -0
  5. package/dist/call-graph-VTG2CUOQ.js +2 -0
  6. package/dist/call-graph-evidence-BociKRpF.d.ts +19 -0
  7. package/dist/chunk-2BMSSRBH.js +2 -0
  8. package/dist/{chunk-TAYD3AE7.js → chunk-2GJSD5GY.js} +2 -2
  9. package/dist/{chunk-TUQIPUDS.js → chunk-2M2LSIMY.js} +3 -3
  10. package/dist/{chunk-GIQ6CSL4.js → chunk-2N6WBNDC.js} +2 -2
  11. package/dist/{chunk-JHH5SCZ3.js → chunk-2OOY75BW.js} +2 -2
  12. package/dist/{chunk-EELPBR7E.js → chunk-2USA3S3P.js} +2 -2
  13. package/dist/chunk-2VAHDDLM.js +133 -0
  14. package/dist/chunk-2XWIUW5Z.js +455 -0
  15. package/dist/{chunk-57N6LN2A.js → chunk-3AF4TUFK.js} +2 -2
  16. package/dist/chunk-3D4BOXW6.js +20 -0
  17. package/dist/{chunk-FFJQZG6J.js → chunk-3LO4FST5.js} +2 -2
  18. package/dist/{chunk-HXOU4XNH.js → chunk-3WTY4LP2.js} +2 -2
  19. package/dist/{chunk-DPWKKNKI.js → chunk-3Z5AMSK6.js} +2 -2
  20. package/dist/{chunk-F24G5NBE.js → chunk-44IETFOU.js} +2 -2
  21. package/dist/chunk-4FR6GQIT.js +2 -0
  22. package/dist/chunk-4KBTHJLP.js +2 -0
  23. package/dist/chunk-5BIKR67W.js +2 -0
  24. package/dist/{chunk-DJAO2OZJ.js → chunk-5PROPLHI.js} +2 -2
  25. package/dist/chunk-5V7EPTII.js +2 -0
  26. package/dist/{chunk-VZ7NXSHV.js → chunk-62LPZCBQ.js} +2 -2
  27. package/dist/{chunk-LXQUF2RP.js → chunk-64O2JHQA.js} +2 -2
  28. package/dist/chunk-6D4F5VWG.js +10 -0
  29. package/dist/{chunk-NEIQPFBI.js → chunk-6ERFBC3X.js} +2 -2
  30. package/dist/{chunk-4HE7MVWD.js → chunk-6ILKOOGH.js} +2 -2
  31. package/dist/chunk-6MFXCMZC.js +2 -0
  32. package/dist/chunk-6O7FACKB.js +2 -0
  33. package/dist/{chunk-R6M456QG.js → chunk-6TS3KOXR.js} +2 -2
  34. package/dist/{chunk-7U2YQSDE.js → chunk-76QOU4PK.js} +2 -2
  35. package/dist/{chunk-25GWKRUZ.js → chunk-7DUI77BN.js} +2 -2
  36. package/dist/chunk-7F45LJKI.js +2 -0
  37. package/dist/{chunk-DEAB5TGT.js → chunk-7F7T6DCR.js} +2 -2
  38. package/dist/chunk-7H6VHWWJ.js +2 -0
  39. package/dist/chunk-7HXT6YLU.js +5 -0
  40. package/dist/{chunk-KZYID5KV.js → chunk-7R4V5ES6.js} +4 -4
  41. package/dist/chunk-7RIRIADH.js +7 -0
  42. package/dist/chunk-7ZLWLOGT.js +2 -0
  43. package/dist/{chunk-WHADK6OS.js → chunk-A4WEAK35.js} +2 -2
  44. package/dist/chunk-AADQLOQ4.js +38 -0
  45. package/dist/{chunk-XFMVKFSF.js → chunk-AN76MGUE.js} +2 -2
  46. package/dist/chunk-ANLNLY66.js +2 -0
  47. package/dist/chunk-ATXPTSEI.js +81 -0
  48. package/dist/{chunk-EELG7D3Q.js → chunk-AX7IDVFT.js} +2 -2
  49. package/dist/chunk-B3PYOSCX.js +2 -0
  50. package/dist/chunk-B7MPDEAK.js +3 -0
  51. package/dist/chunk-BBB5FBX4.js +2 -0
  52. package/dist/{chunk-Y2VM4CJC.js → chunk-BHKK5RJY.js} +2 -2
  53. package/dist/chunk-BJWFVAA5.js +2 -0
  54. package/dist/chunk-BKVWUP7Y.js +2 -0
  55. package/dist/{chunk-7XA3OM44.js → chunk-BKZYTLGE.js} +2 -2
  56. package/dist/chunk-BL6DCHQP.js +2 -0
  57. package/dist/chunk-BOW7SSQH.js +43 -0
  58. package/dist/{chunk-KQHJEU6V.js → chunk-C4RHHCKL.js} +2 -2
  59. package/dist/chunk-C7C6AKAT.js +117 -0
  60. package/dist/chunk-CD6M6LS2.js +16 -0
  61. package/dist/chunk-CFE6PSG6.js +2 -0
  62. package/dist/{chunk-GPGRZJ3R.js → chunk-CFNIGQMT.js} +2 -2
  63. package/dist/{chunk-K3XFWJI2.js → chunk-CKBUBRYD.js} +2 -2
  64. package/dist/chunk-CZW5MZ5B.js +2 -0
  65. package/dist/chunk-DBBZ63ZX.js +2 -0
  66. package/dist/chunk-DBN7DMJB.js +18 -0
  67. package/dist/{chunk-CKRWA452.js → chunk-DUULLZHZ.js} +2 -2
  68. package/dist/{chunk-6HRZQLOI.js → chunk-DV5Y5NOS.js} +2 -2
  69. package/dist/chunk-DZOIKCTM.js +3 -0
  70. package/dist/chunk-E4PKTOL3.js +2 -0
  71. package/dist/{chunk-GVOMSPGL.js → chunk-E65ELFKU.js} +2 -2
  72. package/dist/{chunk-VXJJTQYE.js → chunk-E7QR35ST.js} +2 -2
  73. package/dist/{chunk-2RE5OCHZ.js → chunk-EFSXAINW.js} +2 -2
  74. package/dist/{chunk-GY7CCCEZ.js → chunk-EHVEIEQN.js} +2 -2
  75. package/dist/{chunk-BVFYEEBH.js → chunk-EHYDXE3Z.js} +2 -2
  76. package/dist/{chunk-HISEUIL2.js → chunk-EP63Y6LD.js} +2 -2
  77. package/dist/chunk-EPX6NQN6.js +4 -0
  78. package/dist/chunk-ETC674NS.js +5 -0
  79. package/dist/{chunk-5H5WTJSD.js → chunk-F5GSBHC6.js} +2 -2
  80. package/dist/chunk-FH3DGXC6.js +2 -0
  81. package/dist/{chunk-2XCGSDIT.js → chunk-FI7VGOR4.js} +2 -2
  82. package/dist/chunk-FJF6VO2P.js +2 -0
  83. package/dist/{chunk-FELGD32K.js → chunk-FLMTCX5R.js} +2 -2
  84. package/dist/chunk-FVFDOIM3.js +2 -0
  85. package/dist/{chunk-AQ2PORIO.js → chunk-G2HU5WRN.js} +2 -2
  86. package/dist/{chunk-7YQOCABQ.js → chunk-G4ALYS4J.js} +2 -2
  87. package/dist/{chunk-SWK4XPUS.js → chunk-G56I7K4W.js} +2 -2
  88. package/dist/{chunk-JFQBRL3J.js → chunk-GC4DG2V5.js} +2 -2
  89. package/dist/chunk-GG45PK4S.js +4 -0
  90. package/dist/{chunk-XN22RGSR.js → chunk-GHNPACNP.js} +2 -2
  91. package/dist/{chunk-XU75YQN4.js → chunk-GINH3YQU.js} +2 -2
  92. package/dist/chunk-GTZZVLKJ.js +2 -0
  93. package/dist/chunk-GXXW5ZHH.js +2 -0
  94. package/dist/{chunk-RNKPYYYE.js → chunk-HAXXKRTD.js} +2 -2
  95. package/dist/chunk-HEZWBAZY.js +2 -0
  96. package/dist/chunk-HMEWLMML.js +2 -0
  97. package/dist/{chunk-2KVU55CW.js → chunk-HOBOVYPO.js} +2 -2
  98. package/dist/{chunk-2YC7YNKT.js → chunk-HRFQ6GW5.js} +2 -2
  99. package/dist/{chunk-RYOYJMGF.js → chunk-HX4X7KG3.js} +2 -2
  100. package/dist/{chunk-AZS7YPCB.js → chunk-HYT2R7LX.js} +2 -2
  101. package/dist/chunk-IKQVBVQL.js +40 -0
  102. package/dist/chunk-J6GLBBRK.js +4 -0
  103. package/dist/{chunk-TNG2FYS5.js → chunk-J7A4PWFX.js} +2 -2
  104. package/dist/chunk-JCSAZ35V.js +2 -0
  105. package/dist/{chunk-EWWY2ZFL.js → chunk-JDU2IV3A.js} +2 -2
  106. package/dist/{chunk-SB25YMEQ.js → chunk-JFMEXGFE.js} +2 -2
  107. package/dist/chunk-JFMI5SGB.js +4 -0
  108. package/dist/chunk-JJP37RGX.js +57 -0
  109. package/dist/chunk-JZ2A7LDM.js +5 -0
  110. package/dist/chunk-KNLQGXVH.js +80 -0
  111. package/dist/chunk-KVQCECPR.js +2 -0
  112. package/dist/{chunk-F24QUEQP.js → chunk-KXXORBZ2.js} +2 -2
  113. package/dist/{chunk-IKVNEGTW.js → chunk-L5KYH6U3.js} +2 -2
  114. package/dist/chunk-L6XHYJPZ.js +21 -0
  115. package/dist/chunk-L7KTFEAV.js +43 -0
  116. package/dist/{chunk-UAQ4T73O.js → chunk-LDXHR5EL.js} +2 -2
  117. package/dist/chunk-LEECKFCJ.js +2 -0
  118. package/dist/{chunk-LO5JSW2C.js → chunk-MHGDSBFX.js} +2 -2
  119. package/dist/{chunk-JUN5DOAK.js → chunk-MLQVVDG3.js} +2 -2
  120. package/dist/chunk-MOKUWRHO.js +3 -0
  121. package/dist/{chunk-44T4DUAA.js → chunk-MPYAPMNE.js} +2 -2
  122. package/dist/{chunk-ARVO6TTW.js → chunk-MV6SPXCR.js} +2 -2
  123. package/dist/{chunk-NRBNAECH.js → chunk-MWN53KRN.js} +2 -2
  124. package/dist/{chunk-TH6IC56G.js → chunk-MZPXPSUJ.js} +2 -2
  125. package/dist/{chunk-FBCVASUG.js → chunk-N55KIE46.js} +2 -2
  126. package/dist/{chunk-VMWUV6WB.js → chunk-NB4D3BNM.js} +2 -2
  127. package/dist/{chunk-JAT6C3VX.js → chunk-NGKBOT6G.js} +2 -2
  128. package/dist/{chunk-Q6T2CAJL.js → chunk-NJGKXKQF.js} +2 -2
  129. package/dist/chunk-NJQISBL4.js +8 -0
  130. package/dist/chunk-NJT3ZEKY.js +16 -0
  131. package/dist/{chunk-KFVSJX25.js → chunk-NKMKZP6A.js} +2 -2
  132. package/dist/chunk-NODFZ6ED.js +2 -0
  133. package/dist/{chunk-ERCYGVAM.js → chunk-NSM5IEVW.js} +2 -2
  134. package/dist/{chunk-YAGYMBEX.js → chunk-NTGUVNR2.js} +2 -2
  135. package/dist/{chunk-N7FP5H5U.js → chunk-NU3KFF2O.js} +8 -8
  136. package/dist/chunk-NWLVNU66.js +557 -0
  137. package/dist/{chunk-Q55NF3ZG.js → chunk-NYKZMCRC.js} +2 -2
  138. package/dist/{chunk-I6UTXNHU.js → chunk-O6BUXZEH.js} +2 -2
  139. package/dist/chunk-ODPDP7A4.js +3 -0
  140. package/dist/{chunk-ZAZGGSM3.js → chunk-OHIV323X.js} +2 -2
  141. package/dist/chunk-OIAPEKMT.js +3 -0
  142. package/dist/chunk-OIOC5EHF.js +3 -0
  143. package/dist/{chunk-YIHNPKWD.js → chunk-ONPPQM4G.js} +2 -2
  144. package/dist/{chunk-RHHCLWQ6.js → chunk-OUHEZBYI.js} +2 -2
  145. package/dist/{chunk-MSR2QRUE.js → chunk-OVGYW7UD.js} +2 -2
  146. package/dist/{chunk-OPSAW5DT.js → chunk-OYKU4B3Y.js} +2 -2
  147. package/dist/{chunk-5YRQIE2B.js → chunk-POBJ6FR2.js} +2 -2
  148. package/dist/{chunk-ZGW4HLPD.js → chunk-PSZPMMWN.js} +2 -2
  149. package/dist/chunk-PXTRBKRK.js +3 -0
  150. package/dist/{chunk-U2N2KE7A.js → chunk-Q5JRIHT3.js} +2 -2
  151. package/dist/{chunk-GRX7JOXQ.js → chunk-Q7ATHARX.js} +2 -2
  152. package/dist/{chunk-5ZMBRQFC.js → chunk-Q7CSKIDM.js} +2 -2
  153. package/dist/{chunk-HG722PO7.js → chunk-QBQE7ZJ5.js} +2 -2
  154. package/dist/{chunk-Z2PZVKPR.js → chunk-QH22UIXP.js} +2 -2
  155. package/dist/chunk-QXCKQTKR.js +60 -0
  156. package/dist/chunk-RBAD4GJ2.js +13 -0
  157. package/dist/chunk-RMDPFPNW.js +2 -0
  158. package/dist/chunk-ROPJDEJZ.js +4 -0
  159. package/dist/{chunk-56NQAEPJ.js → chunk-RVZC6TJE.js} +2 -2
  160. package/dist/{chunk-XJX6LGHL.js → chunk-S4QZBKSR.js} +2 -2
  161. package/dist/chunk-SCPMZ73U.js +2 -0
  162. package/dist/{chunk-7IQXARSQ.js → chunk-SIAP5RGI.js} +2 -2
  163. package/dist/{chunk-4TQU4TX2.js → chunk-SIX4RFR3.js} +2 -2
  164. package/dist/{chunk-AYPDH2LU.js → chunk-SKKXTABJ.js} +2 -2
  165. package/dist/{chunk-ZYM4HOFA.js → chunk-SSRFUQBD.js} +2 -2
  166. package/dist/chunk-SYVJEEUJ.js +3 -0
  167. package/dist/chunk-T3CZAZSI.js +8 -0
  168. package/dist/chunk-T3I6NHBH.js +2 -0
  169. package/dist/{chunk-GDRJB3SB.js → chunk-T6DWDI5E.js} +2 -2
  170. package/dist/chunk-T6HRIROJ.js +7 -0
  171. package/dist/{chunk-OTSPRVNW.js → chunk-TAA7HXHE.js} +2 -2
  172. package/dist/{chunk-IJMD6BRI.js → chunk-TJ2JQYT3.js} +2 -2
  173. package/dist/chunk-TULNMD5T.js +368 -0
  174. package/dist/chunk-U2FPY5XA.js +3 -0
  175. package/dist/chunk-U3SXIMII.js +38 -0
  176. package/dist/{chunk-ENWQWA2R.js → chunk-U6KCHXJ4.js} +2 -2
  177. package/dist/chunk-UH3XSKS5.js +9 -0
  178. package/dist/{chunk-UDY7MIAW.js → chunk-UIFUZVCC.js} +2 -2
  179. package/dist/{chunk-BDGTPN27.js → chunk-UXKURIVI.js} +2 -2
  180. package/dist/{chunk-FGNCOQUX.js → chunk-V2RBODHL.js} +2 -2
  181. package/dist/chunk-VBKUWB6N.js +2 -0
  182. package/dist/{chunk-PIFTZEEM.js → chunk-VBV6ALJE.js} +2 -2
  183. package/dist/{chunk-2OXVP5U5.js → chunk-VDGFWCQV.js} +2 -2
  184. package/dist/chunk-VDSDOEWF.js +2 -0
  185. package/dist/{chunk-C76O5MDS.js → chunk-VZPWVCLN.js} +2 -2
  186. package/dist/chunk-WDSFQDPN.js +2 -0
  187. package/dist/{chunk-BTVKZGWT.js → chunk-WFA35BGR.js} +2 -2
  188. package/dist/{chunk-H7CG6LOE.js → chunk-WLMP3OCW.js} +2 -2
  189. package/dist/{chunk-WOOAY3PA.js → chunk-WSA52GOR.js} +2 -2
  190. package/dist/chunk-WYPL7GF7.js +2 -0
  191. package/dist/{chunk-RDULNRSJ.js → chunk-X3YVZAKZ.js} +2 -2
  192. package/dist/chunk-X6OGVFIT.js +2 -0
  193. package/dist/{chunk-ISWFRGJ6.js → chunk-XKXTR6ZI.js} +2 -2
  194. package/dist/chunk-Y5DFAW5W.js +4 -0
  195. package/dist/chunk-YSYPDRD5.js +3 -0
  196. package/dist/chunk-ZFVPWH62.js +5 -0
  197. package/dist/chunk-ZGIHTH27.js +2 -0
  198. package/dist/{chunk-QKT4UI2Y.js → chunk-ZGIQN2SX.js} +2 -2
  199. package/dist/chunk-ZHG4WAHR.js +12 -0
  200. package/dist/{chunk-CLG6DWVS.js → chunk-ZKB2XUEN.js} +2 -2
  201. package/dist/chunk-ZLMXIQLC.js +21 -0
  202. package/dist/chunk-ZMCQIHI4.js +2 -0
  203. package/dist/cli-main.js +2 -2
  204. package/dist/code-TAVIKWJI.js +2 -0
  205. package/dist/code-result-json-5FEFQCAQ.js +2 -0
  206. package/dist/command-descriptors-7BKH53Y3.js +343 -0
  207. package/dist/dataflow-GFBTVDH3.js +2 -0
  208. package/dist/dependence-slice-GWGQCODG.js +2 -0
  209. package/dist/deps-4QHVDPYA.js +2 -0
  210. package/dist/direct-navigation-4UBC6HNW.js +3 -0
  211. package/dist/entry-map-QCTF4RVY.js +2 -0
  212. package/dist/files-M2UBF5HJ.js +2 -0
  213. package/dist/frontend-profile-roles-D7eCum8P.d.ts +10 -0
  214. package/dist/{health-CPp2Jf1Z.d.ts → health-BI2a9WPy.d.ts} +60 -2
  215. package/dist/hierarchy-2UIHRLW4.js +2 -0
  216. package/dist/imports-WIE3YZOB.js +2 -0
  217. package/dist/index.d.ts +1 -1
  218. package/dist/index.js +1 -1
  219. package/dist/members-YKD636DA.js +2 -0
  220. package/dist/methods-VDF4IMYG.js +2 -0
  221. package/dist/output-continuation-command-4UMDOOLO.js +3 -0
  222. package/dist/output-pagination-2GME6OPY.js +19 -0
  223. package/dist/postinstall.js +1 -1
  224. package/dist/project-reindex-XEQTRCV5.js +3 -0
  225. package/dist/queries/affected.js +1 -1
  226. package/dist/queries/anchors.d.ts +1 -1
  227. package/dist/queries/anchors.js +1 -1
  228. package/dist/queries/architecture.js +1 -1
  229. package/dist/queries/bottlenecks.js +1 -1
  230. package/dist/queries/by-kind.js +1 -1
  231. package/dist/queries/call-graph.d.ts +2 -0
  232. package/dist/queries/call-graph.js +1 -1
  233. package/dist/queries/change-surface.js +1 -1
  234. package/dist/queries/cleanup-plan.js +1 -1
  235. package/dist/queries/co-change.d.ts +20 -2
  236. package/dist/queries/co-change.js +1 -1
  237. package/dist/queries/code.js +1 -1
  238. package/dist/queries/complexity-hotspots.js +1 -1
  239. package/dist/queries/complexity.js +1 -1
  240. package/dist/queries/context.js +1 -1
  241. package/dist/queries/convergence.js +1 -1
  242. package/dist/queries/coupling.js +1 -1
  243. package/dist/queries/cycles.js +1 -1
  244. package/dist/queries/dataflow.js +1 -1
  245. package/dist/queries/dead.d.ts +2 -0
  246. package/dist/queries/dead.js +1 -1
  247. package/dist/queries/decorative-checkers.js +1 -1
  248. package/dist/queries/deep-chains.js +1 -1
  249. package/dist/queries/dependence-slice.js +1 -1
  250. package/dist/queries/dependency-depth.js +1 -1
  251. package/dist/queries/deps.js +1 -1
  252. package/dist/queries/diff-impact.d.ts +9 -0
  253. package/dist/queries/diff-impact.js +1 -1
  254. package/dist/queries/doc-drift.js +1 -1
  255. package/dist/queries/drift.js +1 -1
  256. package/dist/queries/duplicate-bodies.d.ts +28 -1
  257. package/dist/queries/duplicate-bodies.js +1 -1
  258. package/dist/queries/entry-map.d.ts +1 -1
  259. package/dist/queries/entry-map.js +1 -1
  260. package/dist/queries/evidence.js +1 -1
  261. package/dist/queries/extract-candidates.d.ts +50 -23
  262. package/dist/queries/extract-candidates.js +1 -1
  263. package/dist/queries/fan.js +1 -1
  264. package/dist/queries/files.js +1 -1
  265. package/dist/queries/health.d.ts +1 -1
  266. package/dist/queries/health.js +1 -1
  267. package/dist/queries/hierarchy.js +1 -1
  268. package/dist/queries/hotspots.js +1 -1
  269. package/dist/queries/imports.js +1 -1
  270. package/dist/queries/incomplete-migration.js +1 -1
  271. package/dist/queries/index.d.ts +4 -3
  272. package/dist/queries/index.js +1 -1
  273. package/dist/queries/isolated.js +1 -1
  274. package/dist/queries/locality-candidates.js +1 -1
  275. package/dist/queries/members.js +1 -1
  276. package/dist/queries/methods.js +1 -1
  277. package/dist/queries/not-implemented.js +1 -1
  278. package/dist/queries/outline.js +1 -1
  279. package/dist/queries/passthrough-candidates.d.ts +9 -1
  280. package/dist/queries/passthrough-candidates.js +1 -1
  281. package/dist/queries/plan-context.js +1 -1
  282. package/dist/queries/react-component-duplicates.d.ts +19 -3
  283. package/dist/queries/react-component-duplicates.js +1 -1
  284. package/dist/queries/react-hook-candidates.d.ts +22 -3
  285. package/dist/queries/react-hook-candidates.js +1 -1
  286. package/dist/queries/react-large-component-pressure.d.ts +17 -3
  287. package/dist/queries/react-large-component-pressure.js +1 -1
  288. package/dist/queries/recent-duplicates.js +1 -1
  289. package/dist/queries/redundant-reexports.js +1 -1
  290. package/dist/queries/reference-neighborhood.js +1 -1
  291. package/dist/queries/reference-reachability.js +1 -1
  292. package/dist/queries/refs.js +1 -1
  293. package/dist/queries/self-audit.d.ts +7 -1
  294. package/dist/queries/self-audit.js +1 -1
  295. package/dist/queries/similar-chains.js +1 -1
  296. package/dist/queries/similar-files.js +1 -1
  297. package/dist/queries/similar-signatures.js +1 -1
  298. package/dist/queries/similar.js +1 -1
  299. package/dist/queries/slice.js +1 -1
  300. package/dist/queries/source-inspection.js +1 -1
  301. package/dist/queries/source-search.js +1 -1
  302. package/dist/queries/stale-abstractions.js +1 -1
  303. package/dist/queries/surface.js +1 -1
  304. package/dist/queries/symbols.js +1 -1
  305. package/dist/queries/system-map.d.ts +1 -1
  306. package/dist/queries/system-map.js +1 -1
  307. package/dist/queries/system.js +1 -1
  308. package/dist/queries/test-quality.js +1 -1
  309. package/dist/queries/trace.js +1 -1
  310. package/dist/queries/twin-ab.js +1 -1
  311. package/dist/queries/twin-drift.d.ts +22 -6
  312. package/dist/queries/twin-drift.js +1 -1
  313. package/dist/queries/unused-imports.js +1 -1
  314. package/dist/queries/unused-params.js +1 -1
  315. package/dist/queries/value-flow.js +1 -1
  316. package/dist/queries/vue-component-duplicates.js +1 -1
  317. package/dist/queries/vue-composable-candidates.js +1 -1
  318. package/dist/queries/vue-large-view-pressure.js +1 -1
  319. package/dist/queries/wrapper-candidates.d.ts +16 -1
  320. package/dist/queries/wrapper-candidates.js +1 -1
  321. package/dist/query-service-fastpath.js +5 -5
  322. package/dist/query-service-server.js +3 -3
  323. package/dist/refs-JNK5CLM7.js +2 -0
  324. package/dist/refs-pagination-6BLRYGMV.js +2 -0
  325. package/dist/reindex-worker.js +25 -25
  326. package/dist/reindex.d.ts +3 -2
  327. package/dist/reindex.js +35 -35
  328. package/dist/runtime.d.ts +34 -2
  329. package/dist/runtime.js +4 -4
  330. package/dist/rust-semantic-session-server.js +1 -1
  331. package/dist/rust-semantic-session-worker.js +1 -1
  332. package/dist/rust-semantic-worker.js +1 -1
  333. package/dist/{scip-cli-H-n59izO.d.ts → scip-cli-DOerTq-R.d.ts} +42 -4
  334. package/dist/slice-PHPVNCWX.js +2 -0
  335. package/dist/surface-MQX5MPIV.js +2 -0
  336. package/dist/symbol-resolution-DBLVXLBC.js +2 -0
  337. package/dist/system-JOPKV4OG.js +2 -0
  338. package/dist/trace-I2P2YFH4.js +2 -0
  339. package/dist/typescript-mailbox-worker.js +1 -1
  340. package/dist/value-flow-JJVMF7NP.js +2 -0
  341. package/dist/watch-server.js +3 -3
  342. package/docs/COMMAND_REFERENCE.md +2 -2
  343. package/docs/DETECTOR_GUIDE.md +51 -12
  344. package/docs/accuracy-audit-checklist.md +36 -13
  345. package/docs/locality-analyzer-design.md +9 -9
  346. package/package.json +2 -2
  347. package/skills/conductor/SKILL.md +110 -0
  348. package/skills/conductor/agents/openai.yaml +4 -0
  349. package/skills/principal-maintainability-review/SKILL.md +273 -0
  350. package/skills/principal-maintainability-review/agents/openai.yaml +4 -0
  351. package/skills/scip-calibrate/SKILL.md +102 -0
  352. package/skills/scip-calibrate/agents/openai.yaml +4 -0
  353. package/skills/scip-claim-audit/SKILL.md +113 -0
  354. package/skills/scip-claim-audit/agents/openai.yaml +4 -0
  355. package/skills/scip-probe-reachability/SKILL.md +93 -0
  356. package/skills/scip-probe-reachability/agents/openai.yaml +4 -0
  357. package/skills/scip-root-cause/SKILL.md +160 -0
  358. package/skills/scip-root-cause/agents/openai.yaml +4 -0
  359. package/skills/scip-system-compression/SKILL.md +252 -0
  360. package/skills/scip-system-compression/agents/openai.yaml +4 -0
  361. package/skills/scip-system-compression/references/compression-atlas.md +116 -0
  362. package/skills/scip-system-compression/references/compression-patterns.md +87 -0
  363. package/skills/scip-twin-drift/SKILL.md +109 -0
  364. package/skills/scip-twin-drift/agents/openai.yaml +4 -0
  365. package/dist/by-kind-4IYG2SKW.js +0 -2
  366. package/dist/call-graph-WQNXMNNN.js +0 -2
  367. package/dist/call-graph-evidence-lZa2dwQA.d.ts +0 -11
  368. package/dist/chunk-2BTJALUS.js +0 -454
  369. package/dist/chunk-3QXC54FQ.js +0 -3
  370. package/dist/chunk-3TJY6M3B.js +0 -7
  371. package/dist/chunk-42W3LFUK.js +0 -13
  372. package/dist/chunk-4GAQ6FI4.js +0 -43
  373. package/dist/chunk-6NC3YSPY.js +0 -38
  374. package/dist/chunk-6VEFRPTD.js +0 -5
  375. package/dist/chunk-7C26EKLZ.js +0 -4
  376. package/dist/chunk-7JYHQAH2.js +0 -22
  377. package/dist/chunk-7KSO2OAP.js +0 -2
  378. package/dist/chunk-7XZGZBSQ.js +0 -2
  379. package/dist/chunk-A77SCPW2.js +0 -3
  380. package/dist/chunk-AK3PYTIK.js +0 -5
  381. package/dist/chunk-AMIMMNA4.js +0 -11
  382. package/dist/chunk-AUY5BL74.js +0 -2
  383. package/dist/chunk-BDHFVH2M.js +0 -18
  384. package/dist/chunk-BECZLYNU.js +0 -8
  385. package/dist/chunk-BUTEIZKP.js +0 -10
  386. package/dist/chunk-BWVQP3LB.js +0 -38
  387. package/dist/chunk-BYDAFMSR.js +0 -57
  388. package/dist/chunk-BZYSGZRK.js +0 -2
  389. package/dist/chunk-C7IJMOFP.js +0 -134
  390. package/dist/chunk-CBBHFNLX.js +0 -2
  391. package/dist/chunk-D2MVJSP4.js +0 -21
  392. package/dist/chunk-D35XIZGN.js +0 -2
  393. package/dist/chunk-DKM723YF.js +0 -79
  394. package/dist/chunk-DRENNWRG.js +0 -2
  395. package/dist/chunk-E44IVWIJ.js +0 -367
  396. package/dist/chunk-EDMB6SSO.js +0 -7
  397. package/dist/chunk-EETGXQY7.js +0 -3
  398. package/dist/chunk-FKGQOTKD.js +0 -2
  399. package/dist/chunk-GH5YSGZL.js +0 -5
  400. package/dist/chunk-GQIDEID3.js +0 -2
  401. package/dist/chunk-HCVJR2V4.js +0 -3
  402. package/dist/chunk-IMKZEXZG.js +0 -2
  403. package/dist/chunk-ISIQLPJ2.js +0 -61
  404. package/dist/chunk-IXESDH3J.js +0 -2
  405. package/dist/chunk-JJ62MTQH.js +0 -40
  406. package/dist/chunk-JT6XX7QY.js +0 -8
  407. package/dist/chunk-KFOYCQAJ.js +0 -9
  408. package/dist/chunk-LRI5OMPE.js +0 -2
  409. package/dist/chunk-MHIEP7EG.js +0 -4
  410. package/dist/chunk-NK3JMP22.js +0 -2
  411. package/dist/chunk-NVSZNESQ.js +0 -2
  412. package/dist/chunk-OJNK5ALA.js +0 -2
  413. package/dist/chunk-OXYAWIEA.js +0 -2
  414. package/dist/chunk-OZETODHH.js +0 -2
  415. package/dist/chunk-PBUH2P5S.js +0 -3
  416. package/dist/chunk-PLJUQFQN.js +0 -2
  417. package/dist/chunk-PLYUVM4F.js +0 -2
  418. package/dist/chunk-PXXYQK55.js +0 -2
  419. package/dist/chunk-Q5TA4OY4.js +0 -20
  420. package/dist/chunk-Q7GBK5T7.js +0 -81
  421. package/dist/chunk-QLBSG7U5.js +0 -3
  422. package/dist/chunk-QWKHW6VZ.js +0 -2
  423. package/dist/chunk-RPL3ARU7.js +0 -16
  424. package/dist/chunk-SVHTMVA4.js +0 -4
  425. package/dist/chunk-T6QD2ZQB.js +0 -43
  426. package/dist/chunk-TD7VKJ2Y.js +0 -117
  427. package/dist/chunk-TKDNDQA7.js +0 -3
  428. package/dist/chunk-TQZV7KV4.js +0 -2
  429. package/dist/chunk-TUSPIVZ3.js +0 -4
  430. package/dist/chunk-URSGGIZX.js +0 -2
  431. package/dist/chunk-UT7TADJX.js +0 -2
  432. package/dist/chunk-V4NG5OMS.js +0 -554
  433. package/dist/chunk-VTCIYFEK.js +0 -2
  434. package/dist/chunk-VU6LIWHT.js +0 -2
  435. package/dist/chunk-VUSKPCUB.js +0 -2
  436. package/dist/chunk-WN3TCGJ4.js +0 -2
  437. package/dist/chunk-WSLEJSFR.js +0 -2
  438. package/dist/chunk-WYZIHUPZ.js +0 -16
  439. package/dist/chunk-XE33FV5W.js +0 -2
  440. package/dist/chunk-XGGBK66W.js +0 -4
  441. package/dist/chunk-XSWYJCAK.js +0 -2
  442. package/dist/chunk-Y334QQU5.js +0 -3
  443. package/dist/chunk-Z2AWCTN6.js +0 -2
  444. package/dist/chunk-ZOXKSQQB.js +0 -2
  445. package/dist/chunk-ZPASRBLF.js +0 -2
  446. package/dist/chunk-ZZ3Z7D56.js +0 -2
  447. package/dist/code-EQJFDT6I.js +0 -2
  448. package/dist/code-result-json-7UWIWBOO.js +0 -2
  449. package/dist/command-descriptors-ORNTVNYV.js +0 -342
  450. package/dist/dataflow-6VL54GX5.js +0 -2
  451. package/dist/dependence-slice-DT2NUHD2.js +0 -2
  452. package/dist/deps-DB7H5IKC.js +0 -2
  453. package/dist/direct-navigation-O3LUAYWQ.js +0 -3
  454. package/dist/entry-map-6K62RV3D.js +0 -2
  455. package/dist/files-MSLD7MO6.js +0 -2
  456. package/dist/hierarchy-IVBXAKFA.js +0 -2
  457. package/dist/imports-FRAVZ3Y2.js +0 -2
  458. package/dist/members-KJOJDYGO.js +0 -2
  459. package/dist/methods-2AYABBT3.js +0 -2
  460. package/dist/output-continuation-command-JHMPH6NC.js +0 -3
  461. package/dist/output-pagination-3OFL2MJV.js +0 -19
  462. package/dist/project-reindex-HYO4WD7Z.js +0 -3
  463. package/dist/refs-ARMA6XUJ.js +0 -2
  464. package/dist/refs-pagination-VUGIWN6U.js +0 -2
  465. package/dist/slice-YOB5YFAM.js +0 -2
  466. package/dist/surface-VY5EFWTW.js +0 -2
  467. package/dist/symbol-resolution-DGQN4XIV.js +0 -2
  468. package/dist/system-2KQ3QD2P.js +0 -2
  469. package/dist/trace-HTIPTXAE.js +0 -2
  470. package/dist/value-flow-5FV3VQI7.js +0 -2
@@ -0,0 +1,455 @@
1
+ #!/usr/bin/env node
2
+ var bu=Symbol.for("scip-query.project-file-listing-context.v1"),xu=globalThis,ea=xu[bu],G=ea&&typeof ea=="object"?ea:{};xu[bu]=G;function iA(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 oA(){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 vu(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 Iu(){return G.sequence??0}function Xi(e,t,n){let r=G.active,i=r?.get(e);if(i&&i.pathBytes<=t)return i;let o=eS(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 Eu(e,t){let n=G.active?.get(e);return n&&n.sequence>t?n.indexAllowsTreeFingerprintReuse:void 0}function*Yi(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 eS(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{createHash as sS}from"crypto";import{createRequire as aS}from"module";import{closeSync as ta,fstatSync as Qi,openSync as na,readFileSync as tS,readSync as Ru}from"fs";import{createHash as nS}from"crypto";var z=8*1024*1024,an=64*1024*1024,se=512*1024*1024,rS=256*1024*1024,it=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 H(e,t){ln(t.maxBytes);let n=String(e),r=na(e,"r");try{let i=Qi(r);wu(i,t,n);let o=tS(r),s=Qi(r);if(s.dev!==i.dev||s.ino!==i.ino||s.size!==i.size||o.byteLength!==i.size)throw new it(t.inputKind,n,"changed-during-read",s.size,t.maxBytes);return o}finally{ta(r)}}function j(e,t,n="utf8"){return H(e,t).toString(n)}function T(e,t){return j(e,{maxBytes:z,inputKind:t})}function iS(e,t){return j(e,{maxBytes:an,inputKind:t})}function ra(e,t){ln(t.maxBytes);let n=[],r=Buffer.allocUnsafe(64*1024),i=0;for(;;){let o=Ru(e,r,0,r.length,null);if(o===0)break;if(i+=o,!Number.isSafeInteger(i)||i>t.maxBytes)throw new it(t.inputKind,`file descriptor ${e}`,"too-large",i,t.maxBytes);n.push(Buffer.from(r.subarray(0,o)))}return Buffer.concat(n,i)}function oS(e,t,n="utf8"){return ra(e,t).toString(n)}function Pu(e,t){let n=na(e,"r");try{return ra(n,t)}finally{ta(n)}}function ia(e,t,n="utf8"){return Pu(e,t).toString(n)}function Vn(e,t,n){ln(t.maxBytes);let r=String(e),i=na(e,"r");try{let o=Qi(i);wu(o,t,r);let s=Buffer.allocUnsafe(Math.min(1024*1024,Math.max(1,o.size))),a=0;for(;a<o.size;){let l=Ru(i,s,0,Math.min(s.length,o.size-a),a);if(l===0)break;n(s.subarray(0,l)),a+=l}let c=Qi(i);if(c.dev!==o.dev||c.ino!==o.ino||c.size!==o.size||a!==o.size)throw new it(t.inputKind,r,"changed-during-read",c.size,t.maxBytes);return a}finally{ta(i)}}function cn(e,t){let n=nS("sha256");return Vn(e,t,r=>n.update(r)),n.digest("hex")}function wu(e,t,n){if(!e.isFile())throw new it(t.inputKind,n,"not-regular",Number(e.size),t.maxBytes);if(e.size>t.maxBytes)throw new it(t.inputKind,n,"too-large",Number(e.size),t.maxBytes)}function ln(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}var cS=aS(import.meta.url),Zi=lS().version,Cr;function Cu(){if(Cr!==void 0)return Cr;let e=process.argv[1];try{Cr=e?sS("sha256").update(H(e,{maxBytes:z,inputKind:"CLI entry bundle"})).digest("hex").slice(0,16):"source"}catch{Cr="source"}return Cr}function lS(){for(let e of["../package.json","../../package.json"])try{return cS(e)}catch{}return{version:"0.0.0"}}import{createHash as ES}from"crypto";import{existsSync as RS,mkdirSync as PS}from"fs";import{dirname as Ku,join as wS}from"path";import la from"better-sqlite3";function Mt(e,t,n=[]){let r=sa(e);if(Lu.has(r)||n.some(o=>to(r,o))||t.some(o=>Du(r,o)))return"config";if(t.some(Ou)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return"ambient";let i=Au(r);return t.some(o=>(Mu[o]??[]).includes(i))?"source":"other"}function ku(e,t,n){let r=sa(e);if(Lu.has(r)||n?.some(o=>to(r,o))||Du(r,t)||Ou(t)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return!0;let i=Au(r);return(Mu[t]??[]).includes(i)}function Fr(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.version!="number"||!Fu(t.languages)||typeof t.pnpmWorkspaces!="boolean"||typeof t.typescriptProjectMode!="string"||!Fu(t.typescriptProjects)||t.clojureConfigPath!==void 0&&typeof t.clojureConfigPath!="string"||!Array.isArray(t.files)||!t.files.every(oa)?null:t}function eo(e){return{...e,files:e.files.map(({semanticHash:t,...n})=>n)}}function Tr(e,t){return!e||!t?e===t:JSON.stringify(eo(e))===JSON.stringify(eo(t))}function mA(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=Mt(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"),(Tu(e?.files??[])||Tu(t.files))&&s.add("duplicate-input-path"),[...e?.files??[],...t.files].some(uS)&&s.add("unreadable-input"),{version:1,changes:o,projectIdentityChanged:e?!dS(e,t):!0,uncertainty:[...s].sort()}}function Fu(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Tu(e){return new Set(e.map(t=>t.path)).size!==e.length}function oa(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 uS(e){return e.hash==="unreadable"||e.size<0}function dS(e,t){return _u(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&_u(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function _u(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"]),pS={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"]},fS={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:[]},Nu=new Map;function Du(e,t){return pS[t].some(n=>to(e,n))||fS[t].some(n=>to(e,n))}function to(e,t){let n=sa(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=Nu.get(n);if(!o){let s=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]");o=new RegExp(`^${s}$`),Nu.set(n,o)}return o.test(i)}function sa(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Au(e){return e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:""}function Ou(e){return e==="typescript"||e==="javascript"}var Mu={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 ht(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function no(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function yA(e){return ht(e)&&Object.values(e).every(t=>typeof t=="string"||t===null)}function w(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function hA(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var mS=/^[a-f0-9]{64}$/u;function SA(e){return typeof e=="string"&&mS.test(e)}function bA(e){return typeof e=="string"&&e.length>0&&e.length<=256&&!/[\0\r\n]/u.test(e)}function ju(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}var ro=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],vA=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var aa=2,un=3;var ca=new Set(ro);function jt(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${vS(s)}`}}if(!ht(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!==aa&&n!==un)return{kind:"unsupported",version:n,direction:n<aa?"older":"future"};let r=yS(t,n);if(r)return{kind:"malformed",reason:r};let i=t,o={metadata:i,capabilities:gS(i)};return n===aa?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function CA(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function Bu(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===un?t.sqliteLayoutVersion:void 0})}function gS(e){let t=e.fingerprint!==void 0,n=ht(e.fingerprint),r=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===un?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 yS(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!no(e.updatedAt))return"updatedAt must be a valid timestamp";for(let n of["requestedLanguages","indexedLanguages"])if(e[n]!==void 0&&!hS(e[n]))return`${n} must contain unique supported languages`;return e.skipped!==void 0&&!SS(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===un&&e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":t===un&&e.languageFingerprints!==void 0&&!bS(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===un&&e.typescriptProjectShards!==void 0&&!xS(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function FA(e){return e.version===un&&e.sqliteLayoutVersion===1}function hS(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&ca.has(t))?!1:new Set(e).size===e.length}function SS(e){return Array.isArray(e)&&e.every(t=>ht(t)&&typeof t.language=="string"&&ca.has(t.language)&&typeof t.reason=="string")}function bS(e){return ht(e)&&Object.entries(e).every(([t,n])=>ca.has(t)&&ht(n))}function xS(e){return ht(e)&&Object.values(e).every(t=>ht(t)&&Array.isArray(t.files)&&t.files.every(oa))}function vS(e){return e instanceof Error?e.message:String(e)}var $u=[];function Hn(e){e.groups.length>0&&$u.push(e)}function Gu(e,t){let n=new Set(t.groups);for(let r of $u)r.groups.some(i=>n.has(i))&&(t.file!==void 0&&r.clearFile?r.clearFile(e,t.file):r.clearAll(e))}var Vu=256;function Hu(e){let t=e.maxEntries;if(t!==void 0){if(!Number.isSafeInteger(t)||t<1)throw new Error(`Per-database cache maxEntries must be a positive safe integer; received ${t}.`);return t}return e.clearGroups.includes("source-file")?Vu:void 0}function Wu(e,t,n){e.delete(t),e.set(t,n)}function qu(e,t){if(t!==void 0)for(;e.size>t;){let n=e.keys().next().value;if(n===void 0)return;e.delete(n)}}function Uu(){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 C(e,t){let{cache:n,ensure:r}=Uu(),i=Hu(t),o={get(s,a,c){let l=r(s);if(l.has(a)){let d=l.get(a);return Wu(l,a,d),d}let u=c();return l.set(a,u),qu(l,i),u},has(s,a){return n.get(s)?.has(a)??!1},invalidate(s,a){n.get(s)?.delete(a)},invalidateAll(s){n.delete(s)},size(s){return n.get(s)?.size??0}};return Hn({name:e,groups:t.clearGroups,clearAll:s=>o.invalidateAll(s),clearFile:(s,a)=>o.invalidate(s,a)}),o}function ot(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 Hn({name:e,groups:t.clearGroups,clearAll:i=>r.invalidate(i)}),r}var IS={clearGroups:["whole-project","source-file"],maxEntries:Vu};function Bt(e){return dn(e,IS)}function dn(e,t){let{cache:n,ensure:r}=Uu(),i=Hu(t),o={get(s,a,c,l){let u=r(s),d=u.get(a);if(d&&d.source===c)return Wu(u,a,d),d.value;let p=l();return u.set(a,{source:c,value:p}),qu(u,i),p},invalidate(s,a){n.get(s)?.delete(a)},invalidateAll(s){n.delete(s)}};return Hn({name:e,groups:t.clearGroups,clearAll:s=>o.invalidateAll(s),clearFile:(s,a)=>o.invalidate(s,a)}),o}var CS="evidence.db";var FS=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],oo=new Set(FS),TS=25e4,_S=512*1024*1024,NS=6e4,io=new WeakMap,kS=C("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),LS=C("evidence-project-fingerprint",{clearGroups:["whole-project"]}),_r="evidence-v1",pn="version NOT LIKE 'evidence-%'",zu=null;function Ce(){return zu??=`${_r}+${Cu()}`,zu}function K(e){return ES("sha256").update(e).digest("hex")}function fe(e,t,n){return kS.get(e,t,()=>K(n))}function St(e){return LS.get(e,"current",()=>{try{if(!e.generation.metadataRaw)return null;let t=jt(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=t.metadata,r=[...n.indexedLanguages??[]].sort();return K(JSON.stringify({fingerprint:n.fingerprint,indexedLanguages:r,status:n.status}))}catch(t){return fn("project fingerprint unavailable",t),null}})}function fn(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function Je(e){if(io.has(e))return io.get(e)??null;let t=null;try{let n=new la(e.config.evidenceDbPath??wS(Ku(e.config.dbPath),CS));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
+ `);for(let r of["file_evidence","project_evidence"])n.prepare(`DELETE FROM ${r} WHERE version LIKE 'evidence-%' AND version != ?`).run(Ce());t={evidence:n,shared:DS(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 ${pn}
38
+ ORDER BY version DESC
39
+ LIMIT 1`),existsFileEvidence:n.prepare("SELECT 1 AS present FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),existsLegacyFileEvidence:n.prepare(`SELECT 1 AS present FROM file_evidence
40
+ WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${pn}
41
+ 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
42
+ WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${pn}
43
+ ORDER BY version DESC
44
+ 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
45
+ WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:n.prepare(`SELECT payload FROM semantic_callees
46
+ WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${pn}
47
+ ORDER BY version DESC
48
+ LIMIT 1`),readCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
49
+ WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
50
+ WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${pn}
51
+ ORDER BY symbol, version DESC`),writeCallees:n.prepare(`INSERT OR REPLACE INTO semantic_callees
52
+ (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
53
+ WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:n.prepare(`SELECT payload FROM semantic_references
54
+ WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${pn}
55
+ ORDER BY version DESC
56
+ LIMIT 1`),readReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
57
+ WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
58
+ WHERE relative_path = ? AND project_fingerprint = ? AND ${pn}
59
+ ORDER BY symbol, version DESC`),writeReferences:n.prepare(`INSERT OR REPLACE INTO semantic_references
60
+ (relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:n.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?")}}catch(n){fn("disabled (open failed)",n)}return io.set(e,t),t}function Xe(e,t,n){fn(`disabled (${t})`,n),io.set(e,null)}function DS(e){if(!e)return null;try{PS(Ku(e),{recursive:!0});let t=new la(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
61
+ CREATE TABLE IF NOT EXISTS file_evidence (
62
+ kind TEXT NOT NULL,
63
+ relative_path TEXT NOT NULL,
64
+ content_hash TEXT NOT NULL,
65
+ version TEXT NOT NULL,
66
+ payload TEXT NOT NULL,
67
+ last_accessed_at INTEGER NOT NULL,
68
+ PRIMARY KEY (kind, relative_path, content_hash, version)
69
+ );
70
+ CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
71
+ ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version);
72
+ `),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),existsFileEvidence:t.prepare("SELECT 1 AS present 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)
73
+ VALUES (?, ?, ?, ?, ?, ?)
74
+ ON CONFLICT(kind, relative_path, content_hash, version)
75
+ DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`),touchFileEvidence:t.prepare(`UPDATE file_evidence
76
+ SET last_accessed_at = ?
77
+ WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?
78
+ AND last_accessed_at < ?`)}}catch(t){return fn("shared cache disabled (open failed)",t),null}}function so(e,t,n){fn(`shared cache disabled (${t})`,n);try{e.shared?.evidence.close()}catch{}e.shared=null}function $A(e,t={}){if(!RS(e))return null;let n;try{n=new la(e),n.pragma("busy_timeout = 50"),n.exec(`CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
79
+ 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??TS,o=t.budgetBytes??_S,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 (
80
+ SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
81
+ )`).run(d),n.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:d,remainingRows:r-d}}catch(r){return fn("shared cache maintenance skipped",r),null}finally{try{n?.close()}catch{}}}function Ju(e,t,n,r){let i=Je(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,n,r,Ce())??i.readLegacyFileEvidence.get(t,n,r);if(o?.payload!==void 0)return o.payload;if(!oo.has(t)||!i.shared)return null;try{let s=i.shared.readFileEvidence.get(t,n,r,Ce());return s?.payload!==void 0&&Yu(i.shared,t,n,r),s?.payload??null}catch(s){return so(i,"file_evidence read",s),null}}catch(o){return Xe(e,"file_evidence read",o),null}}function Xu(e,t,n,r){let i=Je(e);if(!i)return!1;try{if((i.existsFileEvidence.get(t,n,r,Ce())??i.existsLegacyFileEvidence.get(t,n,r))?.present!==void 0)return!0;if(!oo.has(t)||!i.shared)return!1;try{return i.shared.existsFileEvidence.get(t,n,r,Ce())?.present===void 0?!1:(Yu(i.shared,t,n,r),!0)}catch(s){return so(i,"file_evidence exists",s),!1}}catch(o){return Xe(e,"file_evidence exists",o),!1}}function Yu(e,t,n,r){let i=Date.now();try{e.touchFileEvidence.run(i,t,n,r,Ce(),i-NS)}catch(o){fn("shared file_evidence recency touch skipped",o)}}function Qu(e,t,n,r,i){let o=Je(e);if(o)try{if(o.writeFileEvidence.run(t,n,r,Ce(),i),oo.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,n,r,Ce(),i,Date.now())}catch(s){so(o,"file_evidence write",s)}}catch(s){Xe(e,"file_evidence write",s)}}function Zu(e,t){if(t.length===0)return;let n=Je(e);if(n)try{n.evidence.transaction(()=>{for(let i of t)n.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,Ce(),i.payload)})();try{n.evidence.pragma("wal_checkpoint(TRUNCATE)")}catch{}let r=t.filter(i=>oo.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,Ce(),i.payload,Date.now())})()}catch(i){so(n,"file_evidence batch write",i)}}catch(r){Xe(e,"file_evidence batch write",r)}}function ed(e,t,n,r){let i=Je(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,n,r,Ce())??i.readLegacyProjectEvidence.get(t,n,r))?.payload??null}catch(o){return Xe(e,"project_evidence read",o),null}}function td(e,t,n,r,i){let o=Je(e);if(o)try{o.writeProjectEvidence.run(t,n,r,Ce(),i)}catch(s){Xe(e,"project_evidence write",s)}}function GA(e,t,n,r){if(n===r)return 0;let i=Je(e);if(!i)return 0;try{return i.rekeyProjectEvidenceKind.run(r,Ce(),t,n).changes}catch(o){return Xe(e,"project_evidence kind rekey",o),0}}function VA(e,t,n,r){let i=Je(e);if(!i)return new Map;try{let o=i.readCalleesForFile.all(t,n,r,_r),s=i.readLegacyCalleesForFile.all(t,n,r);return nd([...s,...o])}catch(o){return Xe(e,"semantic_callees bulk read",o),new Map}}function HA(e,t,n){let r=Je(e);if(!r)return new Map;try{let i=r.readReferencesForFile.all(t,n,_r),o=r.readLegacyReferencesForFile.all(t,n);return nd([...o,...i])}catch(i){return Xe(e,"semantic_references bulk read",i),new Map}}function nd(e){let t=new Map;for(let n of e)t.set(n.symbol,n.payload);return t}function WA(e,t){if(t.length===0)return;let n=Je(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,_r,i.payload)}})()}catch(r){Xe(e,"semantic_callees write",r)}}function qA(e,t){if(t.length===0)return;let n=Je(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,_r,i.payload)}})()}catch(r){Xe(e,"semantic_references write",r)}}import{appendFileSync as AS,mkdirSync as OS}from"fs";import{createHash as MS,randomUUID as jS}from"crypto";import{dirname as BS}from"path";import{performance as Wn}from"perf_hooks";var sd="SCIP_QUERY_PROFILE",ad="SCIP_QUERY_PROFILE_OUT",cd="SCIP_QUERY_PROFILE_COMMAND",ld="SCIP_QUERY_PROFILE_CACHE_STATE",ua="SCIP_QUERY_PROFILE_RUN_ID",da="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY",pa="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND",ud=[sd,ad,cd,ld,ua,da,pa],YA=new Set(ud),rd=new Set,id=new Map,od=!1;function $t(){let e=process.env[sd];return e==="1"||e==="true"}function $S(){return process.env[ad]}function dd(){return process.env[cd]}function GS(){return process.env[ld]}function pd(){let e=process.env[ua];if(e)return e;if(!$t())return;let t=jS();return process.env[ua]=t,t}function fd(){return process.env[da]}function VS(e){let t=fd();if(t)return t;if(!$t())return;let n=pd();if(!n)return;let r=e.projectFingerprint?"published-project":"run-only",i=Nr(["profile-workload-v1",e.toolVersion,e.command,e.projectFingerprint??n]);return process.env[da]=i,process.env[pa]=r,i}function Nr(e){return MS("sha256").update(JSON.stringify(e)).digest("hex").slice(0,24)}function QA(){return Object.fromEntries(ud.flatMap(e=>{let t=process.env[e];return t===void 0?[]:[[e,t]]}))}function J(e,t,n){if(!$t())return t();let r=Wn.now();try{let i=t();return ao({type:"span",name:e,durationMs:Math.round(Wn.now()-r),ok:!0,...co(n)??{}}),i}catch(i){throw ao({type:"span",name:e,durationMs:Math.round(Wn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...co(n)??{}}),i}}async function md(e,t,n){if(!$t())return t();let r=Wn.now();try{let i=await t();return ao({type:"span",name:e,durationMs:Math.round(Wn.now()-r),ok:!0,...co(n)??{}}),i}catch(i){throw ao({type:"span",name:e,durationMs:Math.round(Wn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...co(n)??{}}),i}}function ao(e,t=$S()){let n=HS(e),r={timestamp:new Date().toISOString(),pid:process.pid,runId:pd(),command:dd(),cacheState:GS(),...n,...e},i=`${JSON.stringify(r)}
82
+ `;if(t)try{let o=BS(t);rd.has(o)||(OS(o,{recursive:!0}),rd.add(o)),AS(t,i);return}catch(o){od||(od=!0,process.stderr.write(`[profile] failed to write ${t}: ${o instanceof Error?o.message:String(o)}
83
+ `));return}$t()&&process.stderr.write(i)}function HS(e){let t=fd()??VS({command:dd()??"unknown",toolVersion:"unknown",projectFingerprint:null});if(!t)return{};let n=process.env[pa],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=id.get(o);return s||(s=Nr(["profile-subsystem-v1",t,r]),id.set(o,s)),{workloadIdentity:t,workloadIdentityKind:n,subsystem:i,subsystemWorkIdentity:s}}function co(e){return typeof e=="function"?e():e}import{isAbsolute as gd,relative as WS}from"path";var W=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 Gt(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function X(e){return e.replace(/\\/g,"/")}function mn(e,t){return Gt(e)===Gt(t)}function Oe(e,t){let n=WS(e,t);return n===""||!n.startsWith("..")&&!gd(n)}function Ie(e){if(!e)throw new W(e,"empty-path");if(e.includes("\0"))throw new W(e,"nul-byte");if(gd(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new W(e,"absolute-path");let t=Gt(e);if(t.split("/").some(r=>r===".."))throw new W(e,"parent-traversal");if(!t||t===".")throw new W(e,"empty-path");return t}import{spawnSync as qS}from"child_process";import{createHash as US}from"crypto";import{existsSync as zS,lstatSync as uo,realpathSync as KS}from"fs";import{dirname as JS,isAbsolute as hd,join as ga,relative as XS,resolve as gn,sep as YS}from"path";var Ye={run(e,t){let n=yd(e,t);return n.kind==="success"?n.output:void 0},runResult:yd},QS=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],ya=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],qn=/^[0-9a-f]{40,64}$/;function cO(e,t,n=Ye){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"||!qn.test(r.output))throw new Error(`Git revision ${JSON.stringify(t)} does not resolve to exactly one commit.`);return r.output}function Lr(e,t=Ye){return ZS(e,t)?.context}function ZS(e,t=Ye){let n=t.runResult(e,QS);if(n.kind==="success"){let i=tb(n.output);if(i){let o=nb(i,t);if(o)return fa(o)}}let r=rb(e,t);return r?fa(r):void 0}function eb(e,t=Ye){if(!e.headCommit)return;let n=t.run(e.projectRoot,ya);if(n===void 0)return;let r=ha(n);if(!(!r?.headCommit||r.headCommit!==e.headCommit))return{...e,clean:r.clean}}function lO(e,t,n=Ye){if(!t.headCommit||!t.treeOid||!qn.test(t.headCommit)||!qn.test(t.treeOid)||n===Ye&&!lb()||!ob(e,t))return;let r=eb({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?fa(r):void 0}function uO(e,t=Ye,n={}){let r=t===Ye&&n.cachedInventoryAfterSequence!==void 0?Eu(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 fa(e){return{context:e,projectFileInventorySequence:Iu()}}function ha(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&&!qn.test(r))&&n!==void 0)return{headCommit:r,clean:t.every(i=>i.startsWith("# "))}}function tb(e){let t=e.split(`
84
+ `).map(c=>c.trim());if(t.length!==5)return;let[n,r,i,o,s]=t;if(!n||!r||!i||!o||!s||!qn.test(o)||!qn.test(s))return;let a=Ee(n);return{root:a,gitDir:Ee(lo(a,r)),commonDir:Ee(lo(a,i)),headCommit:o,treeOid:s}}function nb(e,t){let n=t.run(e.root,ya);if(n===void 0)return;let r=ha(n);return r?.headCommit!==e.headCommit?void 0:{...Sd(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:kr("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.clean}}function rb(e,t){let n=ib(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=Ee(lo(i,o)),a=ma(t.run(i,["rev-parse","--verify","HEAD"])),c=ma(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,ya);if(l===void 0)return;let u=ha(l);if(!(!u||u.headCommit!==a))return{...r,commonDir:s,repositoryId:kr("repository",s),headCommit:a,treeOid:c,clean:u.clean}}function ib(e,t=Ye){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=Ee(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=Ee(lo(i,o));return{kind:"worktree",identity:Sd(i,s)}}function Sd(e,t){return{projectRoot:e,gitDir:t,worktreeId:kr("worktree",`${e}\0${t}`)}}function ob(e,t){try{let n=Ee(t.projectRoot),r=gn(e)===n?n:Ee(e);if(t.projectRoot!==n||!cb(n,r))return!1;let i=ga(n,".git"),o=uo(i);if(o.isSymbolicLink())return!1;let s=o.isDirectory()?Ee(i):o.isFile()?sb(i,n,o):void 0;if(!s||s!==t.gitDir)return!1;let a=ab(s);return!a||a!==t.commonDir?!1:t.worktreeId===kr("worktree",`${n}\0${s}`)&&t.repositoryId===kr("repository",a)}catch{return!1}}function sb(e,t,n){let r=bd(e,"gitdir: ",n);return r?Ee(gn(t,r)):void 0}function ab(e){let t=ga(e,"commondir");try{let n=uo(t);if(n.isSymbolicLink()||!n.isFile())return;let r=bd(t,"",n);return r?Ee(gn(e,r)):void 0}catch(n){let r=n.code;return r==="ENOENT"||r==="ENOTDIR"?e:void 0}}function bd(e,t="",n=uo(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 cb(e,t){let n=XS(e,t);return n===""||!n.startsWith(`..${YS}`)&&n!==".."&&!hd(n)}function lb(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 xd(e,t=Ye){let n=t.run(e,["worktree","list","--porcelain","-z"]);return n===void 0?[]:ub(n)}function ub(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:Ee(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 dO(e,t,n=Ye){return ma(n.run(e,t))}function lo(e,t){return hd(t)?t:gn(e,t)}function Ee(e){try{return KS(e)}catch{return gn(e)}}function kr(e,t){return US("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function ma(e){return e?.trim()||void 0}function yd(e,t){let n=qS("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"&&zS(gn(e)))&&!db(e)?{kind:"not-repository"}:{kind:"error",message:i}}function db(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=gn(e);for(;;){try{return uo(ga(t,".git")),!0}catch(r){let i=r.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let n=JS(t);if(n===t)return!1;t=n}}import{createRequire as mb}from"module";import{existsSync as gb,lstatSync as Id,readdirSync as yb,statSync as hb}from"fs";import _ from"path";import{AsyncLocalStorage as pb}from"async_hooks";var fb=new pb;function yn(e,t){let n=po(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 hn(e,t){let n=po(e);if(n)return n.missing.has(t)?"missing":n.paths.includes(t)?"present":"missing"}function vd(e,t){return po(e)?.fingerprints.get(t)}function Sn(e){return po(e)?.paths}function po(e){let t=fb.getStore();if(t)return t.projectRoot===Ee(e)?t:void 0}var Sb=mb(import.meta.url),Ed=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]),bb=18003;function fo(e,t=[]){let n=_.resolve(e),r=t.flatMap(c=>Ib(n,c));if(r.length>0)return Rd(n,wd(r));let i=vb(n),o=wd(i),s=Eb(n,o)?[n,...o]:o,a=s.length>0?s:[n];return Rd(n,a)}function Cd(e){return new Set(e.map(t=>t==="."?"tsconfig.json":`${t.replace(/\/$/u,"")}/tsconfig.json`))}function Fd(e){let t=e.split("/").at(-1)?.toLowerCase();return t?.startsWith("tsconfig")===!0&&t.endsWith(".json")}var xb=/^\.scipquery-compiler-shard-\d+\.tsconfig\.json$/;function PO(e){return`.scipquery-compiler-shard-${e}.tsconfig.json`}function Td(e){return xb.test(e)}function _d(e,t,n=[]){let r;try{r=Sb("@ts-morph/common/dist/typescript.js")}catch{return null}let i=_.resolve(e),o=t==="workspace"?fo(i,n):["."],s=new Set;for(let a of o){let c=a==="."?i:_.join(i,a),l=_.join(c,"tsconfig.json"),u=Pb(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!==bb))return null;for(let f of p.fileNames){let m=_.resolve(f);Oe(i,m)&&s.add(_.relative(i,m).split(_.sep).join("/"))}}return s}function wO(e,t,n,r){let i=_.resolve(e),o=new Set(r);for(let a of n){let c=_.resolve(i,a);if(Oe(i,c))try{let l=Id(c);if(l.isSymbolicLink()||l.isFile()&&!o.has(bn(i,c)))return!1}catch{}}let s=t==="workspace"?fo(i,n):["."];for(let a of s){let c=a==="."?i:_.join(i,a),l=_.join(c,"tsconfig.json");if(!kd(i,l))continue;let u=bn(i,l);if(!o.has(u))return!1;try{if(Id(l).isSymbolicLink())return!1;let d=Ld(i,l);if(d.includes("extends")||d.includes("\\"))return!1}catch{return!1}}return!0}function Rd(e,t){return[...new Set(t.map(n=>bn(e,n)))].sort((n,r)=>n.localeCompare(r))}function vb(e){let t=Sn(e);if(t)return t.flatMap(i=>{if(i.split("/").some(s=>Ed.has(s)))return[];let o=_.join(e,...i.split("/"));return Pd(e,o)?[_.dirname(o)]:[]});let n=[],r=[e];for(;r.length>0;){let i=r.pop(),o;try{o=yb(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=_.join(i,s.name);if(s.isDirectory()){!Ed.has(s.name)&&!s.name.startsWith(".")&&r.push(a);continue}s.isFile()&&Pd(e,a)&&n.push(_.dirname(a))}}return n}function Ib(e,t){let n=t.trim();if(!n)return[];let r=_.resolve(e,n);if(!Oe(e,r))return[];let i=Sn(e);if(i){let o=bn(e,r);if(i.includes(o)&&Sa(_.basename(r)))return[_.dirname(r)];let s=o==="."?"":`${o}/`;return i.some(a=>a.startsWith(s))?[r]:[]}try{let o=hb(r);if(o.isDirectory())return[r];if(o.isFile()&&Sa(_.basename(r)))return[_.dirname(r)]}catch{return[]}return[]}function Pd(e,t){if(!Sa(_.basename(t)))return!1;let n=Nd(e,t);return n?_.basename(t)==="tsconfig.json"||"include"in n||"files"in n||"references"in n:!1}function Sa(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function wd(e){let t=[...new Set(e.map(n=>_.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&Cb(n,r)))}function Eb(e,t){if(t.length===0||t.some(r=>_.resolve(r)===e))return!1;let n=_.join(e,"tsconfig.json");return kd(e,n)&&Rb(e,n)}function Rb(e,t){let r=Nd(e,t)?.include;return Array.isArray(r)?r.some(i=>typeof i=="string"&&i.trim()!==""&&!i.startsWith("!")&&(i.includes("/")||i.includes("**")||!_.extname(i))):!1}function Nd(e,t){try{let n=JSON.parse(Ld(e,t));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function kd(e,t){let n=bn(e,t),r=hn(e,n);return r?r==="present":gb(t)}function Ld(e,t){let n=bn(e,t);if(Sn(e)){let i=yn(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 Pb(e,t){let n=Sn(t);if(!n)return e.sys;let r=_.resolve(t),i=new Set(n),o=wb(r,n),s=e,a=c=>{let l=_.resolve(c);return Oe(r,l)?bn(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):yn(r,l)?.content.toString("utf8")},readDirectory(c,l,u,d,p){let f=_.resolve(c);return Oe(r,f)?s.matchFiles(f,l,u,d,e.sys.useCaseSensitiveFileNames,r,p,m=>o.get(_.resolve(m))??{files:[],directories:[]},m=>m):e.sys.readDirectory(c,l,u,d,p)}}}function wb(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=_.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 bn(e,t){let n=_.relative(e,t);return n?n.split(_.sep).join("/"):"."}function Cb(e,t){let n=_.relative(e,t);return!!n&&!n.startsWith("..")&&!_.isAbsolute(n)}import{createHash as va}from"crypto";import{execFileSync as Dd}from"child_process";import{createRequire as Fb}from"module";var Tb=Fb(import.meta.url),_b=/\.(?:[cm]?[jt]sx?)$/iu,Nb=/\.[jt]sx$/iu,Ad=/(?:^|\/)package\.json$/iu,Dr,ba=new Map;function Od(e,t){if(!Ia(e))return;let n=kb();if(n)try{let r=typeof t=="string"?t:t.toString("utf8"),i=Nb.test(e)?n.LanguageVariant.JSX:n.LanguageVariant.Standard,o=n.createScanner(n.ScriptTarget.Latest,!1,i,r),s=va("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 Ia(e){return _b.test(e)}function Ea(e,t){if(Ad.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 va("sha256").update("typescript-package-json-v1\0").update(xa(i)).digest("hex")}catch{return}}function Ra(e){return Ad.test(e)}function NO(e,t,n){if(!Ra(t)||!/^[a-f0-9]{64}$/u.test(n))return;let r=`${e}\0${t}\0${n}`;if(ba.has(r))return ba.get(r);let i;try{let o=Dd("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=Dd("git",["-C",e,"show",`${s}:${t}`],{encoding:null,maxBuffer:4194304,timeout:5e3});if(va("sha256").update(a).digest("hex")===n){i=Ea(t,a);break}}}catch{i=void 0}return ba.set(r,i),i}function kb(){if(Dr!==void 0)return Dr;try{Dr=Tb("typescript")}catch{Dr=null}return Dr}function xa(e){return Array.isArray(e)?`[${e.map(xa).join(",")}]`:typeof e=="object"&&e!==null?`{${Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${JSON.stringify(t)}:${xa(n)}`).join(",")}}`:JSON.stringify(e)}import{createHash as $d,randomUUID as jb}from"crypto";import{chmodSync as Gd,existsSync as zn,linkSync as Bb,lstatSync as Ar,readdirSync as wa,realpathSync as Me,unlinkSync as $b,writeSync as Gb}from"fs";import{homedir as Vb}from"os";import{basename as Hb,dirname as go,isAbsolute as jd,join as Fe,resolve as yo}from"path";import{closeSync as Lb,existsSync as Db,fsyncSync as Ab,mkdirSync as Ob,openSync as Mb}from"fs";import{dirname as Md}from"path";function bt(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 Un(e,t){if(t!=="win32")return!1;let n=e.code;return n==="EACCES"||n==="EBADF"||n==="EINVAL"||n==="EISDIR"||n==="EPERM"}var xn=Object.freeze({platform:process.platform,pathExists:e=>Db(e),makeDirectory:e=>Ob(e,{recursive:!0}),openFile:(e,t,n)=>Mb(e,t,n),syncFile:e=>Ab(e),closeFile:e=>Lb(e)});function me(e,t=xn){let n=[],r=e;for(;!t.pathExists(r);){n.push(r);let o=Md(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,D(Md(o),t));return i}function D(e,t=xn){let n;try{n=t.openFile(e,"r")}catch(r){if(Un(r,t.platform))return"unsupported";throw r}try{t.syncFile(n)}catch(r){try{t.closeFile(n)}catch{}if(Un(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 Vd=1,Mr=".scip-query-cache-owner.json",Wb=16*1024,Hd=Object.freeze({...xn,randomToken:()=>jb(),linkFile:(e,t)=>Bb(e,t),removeFile:e=>$b(e),writeFile:(e,t,n,r)=>Gb(e,t,n,r)});function mo(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 Qe(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 qb(e,t){let n=Me(e);return Ub(n,Ca(n,t))}function Ca(e,t){let n=Me(e),r=process.env.SCIP_QUERY_CACHE_DIR;return r?yo(r):t?.dbPath?Kb(n,t.dbPath):So(n)}function ho(){let e=process.env.XDG_CACHE_HOME;return Fe(e||Fe(Vb(),".cache"),"scip-query")}function So(e){let t=yo(e);try{t=Me(t)}catch{}let n=$d("sha256").update(t).digest("hex").slice(0,12);return Fe(ho(),"projects",n)}function bo(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let t=Fe(ho(),"repositories",e);return zd(t),Me(t)}function Fa(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function zO(e,t){let n=qb(e,t);return{cacheDir:n,dbPath:Fe(n,"index.db"),indexPath:Fe(n,"index.scip"),metaPath:Fe(n,"meta.json")}}function Ub(e,t,n=Hd){return zb(e,t,n).cacheDir}function zb(e,t,n=Hd){let r=Me(e),i=zn(t)?"synced":zd(t,n),o=Me(t),s=Fe(o,Mr);if(zn(s))return Pa(r,o),Ta(s),Or(o),{kind:"existing",cacheDir:o};Bd(o),Qb(o),Bd(o);let c=`${JSON.stringify({schemaVersion:Vd,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:Zi},null,2)}
85
+ `;try{let l=Zb(s,c,n),u=q(i,l);return{kind:"published",cacheDir:o,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}catch(l){if(tx(l))return Pa(r,o),{kind:"existing",cacheDir:o};throw l}}function Pa(e,t){let n=Me(e),r=Me(t);return Wd(r,n,r)}function KO(e){let t=Ar(e);if(t.isSymbolicLink()||!t.isDirectory())throw Qe(e,"cache path is not a regular directory");let n=Me(e);return Wd(n,void 0,n)}function JO(e,t){return zn(Fe(t,Mr))?(Pa(e,t),qd(t),!0):!1}function Kb(e,t){let n;try{n=Ie(t)}catch(s){throw s instanceof W?mo(t,s.reason):s}let r=yo(e,...n.split("/"));if(r===e||!Oe(e,r))throw mo(t,"outside-project");let i=Jb(r),o=Me(i);if(!Oe(e,o)&&o!==e)throw mo(t,"symlink-escape");return r}function Jb(e){let t=e;for(;!zn(t);){let n=go(t);if(n===t)throw mo(e,"no-existing-ancestor");t=n}return t}function Wd(e,t,n){let r=Fe(e,Mr);if(!zn(r)||Ar(r).isSymbolicLink())throw Qe(e,"missing regular ownership record");let i=Ar(r);if(!i.isFile()||i.size>Wb)throw Qe(e,"invalid ownership record file");let o=T(r,"cache ownership record"),s=Xb(o,e);if(t!==void 0&&s.canonicalProjectRoot!==t)throw Qe(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw Qe(e,"ownership record names a different cache directory");return{record:s,ownerSha256:$d("sha256").update(o).digest("hex"),physicalCacheDir:e}}function Xb(e,t){try{let n=JSON.parse(e);if(n.schemaVersion!==Vd||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!jd(n.canonicalProjectRoot)||!jd(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw Qe(t,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function Bd(e){let t=wa(e).filter(n=>n!==Mr&&!Yb(n));if(t.length>0)throw Qe(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function Yb(e){return e.startsWith(`${Mr}.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","typescript-shard-costs.json","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function Qb(e){for(let t of wa(e)){let n=Fe(e,t);try{let r=Ar(n);if(r.isSymbolicLink())throw Qe(e,`legacy cache entry ${t} is a symlink`);if(r.isDirectory())Or(n);else if(r.isFile())Ta(n);else throw Qe(e,`legacy cache entry ${t} is not a file or directory`)}catch(r){if(Ud(r))continue;throw r}}Or(e)}function qd(e,t=!1){try{let n=Ar(e);if(n.isSymbolicLink())throw Qe(e,"managed cache tree contains a symlink");if(n.isFile()){Ta(e);return}if(!n.isDirectory())throw Qe(e,"managed cache tree contains a special file");Or(e);for(let r of wa(e))qd(Fe(e,r),!0)}catch(n){if(t&&Ud(n))return;throw n}}function Ud(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function zd(e,t=xn){let n=me(e,t);return Or(e),n}function Zb(e,t,n){let r=`${e}.tmp-${process.pid}-${n.randomToken()}`,i,o=!1;try{i=n.openFile(r,"wx",384),o=!0,bt(i,Buffer.from(t),n,"cache ownership record"),n.syncFile(i),n.closeFile(i),i=void 0,n.linkFile(r,e);let s=D(go(e),n);return n.removeFile(r),o=!1,q(s,D(go(e),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function Or(e){process.platform!=="win32"&&Gd(e,448)}function Ta(e){process.platform!=="win32"&&Gd(e,384)}function ex(e){if(zn(e))return Me(e);let t=Me(go(e));return Fe(t,Hb(e))}function _a(e){return ex(yo(e))}function tx(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{execFileSync as hx}from"child_process";import{isUtf8 as ep}from"buffer";import{createHash as Oa}from"crypto";import{closeSync as rp,fstatSync as jr,lstatSync as ja,openSync as ip,readdirSync as Sx,readFileSync as bx,readSync as tp,readlinkSync as xx,realpathSync as $r}from"fs";import{isAbsolute as vx,join as Ba,relative as Ix,resolve as Ex,sep as Rx}from"path";import{closeSync as Kd,existsSync as ka,openSync as nx,realpathSync as rx,renameSync as ix,unlinkSync as Jd,writeSync as ox}from"fs";import{dirname as sx,join as ax}from"path";var cx="fingerprint-stat-cache.json",Xd=1,lx=8*1024*1024,Na=new Map;function La(e,t,n,r){let i=Yd(e),o=i.files.get(t);if(!(!o||!Qd(o,n,r)))return i.hits+=1,{hash:o.hash,size:o.fingerprintSize,...o.semanticHash===void 0?{}:{semanticHash:o.semanticHash}}}function Da(e,t,n,r,i){if(i.hash==="unreadable"||i.size<0||!Number.isFinite(i.size))return;let o=Yd(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&&gx(a,s)||(o.files.set(t,s),o.stores+=1,o.dirty=!0)}function Aa(e){let t=Na.get(Zd(e));if(!(!t?.dirty||!t.cachePath))try{let n=sx(t.cachePath);if(!ka(n))return;yx(t.cachePath,px(t)),t.dirty=!1}catch{}}function Yd(e){let t=Zd(e),n=Na.get(t);if(n)return n;let r=ux(t),i=dx(r),o={cachePath:r,files:i,dirty:!1,hits:0,stores:0};return Na.set(t,o),o}function ux(e){try{let t=Ca(e);return ka(t)?ax(t,cx):null}catch{return null}}function dx(e){let t=new Map;if(!e||!ka(e))return t;try{let n=JSON.parse(H(e,{inputKind:"fingerprint stat cache",maxBytes:lx}).toString("utf8"));if(!fx(n))return t;for(let[r,i]of Object.entries(n.files))i&&t.set(r,i)}catch{return t}return t}function px(e){return{version:Xd,files:Object.fromEntries(e.files)}}function fx(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.version!==Xd||typeof t.files!="object"||t.files===null?!1:Object.values(t.files).every(mx)}function mx(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 Qd(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 gx(e,t){return Qd(e,t.kind,t)&&e.hash===t.hash&&e.fingerprintSize===t.fingerprintSize&&e.semanticHash===t.semanticHash}function yx(e,t){let n=`${e}.${process.pid}.tmp`;try{Jd(n)}catch{}let r=Buffer.from(`${JSON.stringify(t)}
86
+ `,"utf8"),i=nx(n,"wx",384);try{bt(i,r,{writeFile:(o,s,a,c)=>ox(o,s,a,c)},"fingerprint stat cache")}catch(o){throw Kd(i),Jd(n),o}Kd(i),ix(n,e)}function Zd(e){return rx(e)}var Kn=64*1024*1024,Px=1024*1024,wx=1024,vn=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 Cx(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function Jn(e,t,n={}){let r=Ie(t),i=vu(e,()=>$r(e)),o=Ex(i,...r.split("/"));if(!Oe(i,o)||o===i)throw new W(t,"outside-project");let s=$r(o);if(!Oe(i,s)||s===i)throw new W(t,"outside-project");let a=ja(s);if(!a.isFile())throw new W(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??Kn;if(ln(l),c.size>l)throw new vn(n.inputKind??"project file",c.relativePath,c.size,l);return c}function Io(e,t,n={}){let r=Ie(t),i=hn(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=yn(e,r);if(!c)throw new W(r,"changed-during-read");let l=n.maxBytes??Kn;if(ln(l),c.size>l)throw new vn(n.inputKind??"project file",r,c.size,l);return Buffer.from(c.content)}let o=Jn(e,t,n),s=n.maxBytes??Kn,a=ip(o.absolutePath,"r");try{let c=jr(a);if(Br(c,o,t),c.size>s)throw new vn(n.inputKind??"project file",o.relativePath,c.size,s);let l=bx(a),u=jr(a);if(Br(u,o,t),l.byteLength!==c.size)throw new W(t,"changed-during-read");return l}finally{rp(a)}}function Fx(e,t,n,r={}){if(n.byteLength===0)throw new Error("Project file probe literal must not be empty.");let{matchedLiteralIndexes:i,...o}=op(e,t,[n],r);return{...o,includesLiteral:i.length>0}}function op(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=Ie(t),o=hn(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=yn(e,i);if(!c)throw new W(i,"changed-during-read");let l=r.maxBytes??Kn;if(ln(l),c.size>l)throw new vn(r.inputKind??"project file",i,c.size,l);let u=!c.content.includes(0)&&ep(c.content),d=n.map(np),p=u?_x(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=Jn(e,t,r),a=ip(s.absolutePath,"r");try{let c=jr(a);Br(c,s,t);let l=r.computeSha256?Oa("sha256"):null,u=r.scratchBuffer??Buffer.allocUnsafe(Px);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,m=!0,y=Buffer.alloc(0),g=n.map(()=>Buffer.alloc(0)),S=n.map(np);for(;d<c.size;){let x=tp(a,u,0,Math.min(u.byteLength,c.size-d),d);if(x<=0)throw new W(t,"changed-during-read");let b=u.subarray(0,x);if(l?.update(b),f||=b.includes(0),m){let I=y.byteLength>0?Buffer.concat([y,b]):b,P=Tx(I);m=ep(I.subarray(0,P)),y=Buffer.from(I.subarray(P))}for(let I=0;I<n.length;I+=1){if(p[I])continue;let P=n[I],k=g[I];p[I]=Nx(b,P,k,S[I]),g[I]=kx(b,P,k)}d+=x}m&&=y.byteLength===0,Br(jr(a),s,t);let h=!f&&m,v=h?p.flatMap((x,b)=>x?[b]:[]):[],E=null;if(v.length>0){E=Buffer.allocUnsafe(c.size);let x=0;for(;x<E.byteLength;){let b=tp(a,E,x,E.byteLength-x,x);if(b<=0)throw new W(t,"changed-during-read");x+=b}Br(jr(a),s,t)}return{byteLength:c.size,isUtf8Text:h,matchedLiteralIndexes:v,bytes:E,...l?{sha256:l.digest("hex")}:{}}}finally{rp(a)}}function Gr(e,t,n={}){return Io(e,t,n).toString("utf8")}function Br(e,t,n){if(!e.isFile()||e.dev!==t.device||e.ino!==t.inode||e.size!==t.size)throw new W(n,"changed-during-read")}function Tx(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 _x(e,t,n){return t.flatMap((r,i)=>Ma(e,r,n[i])?[i]:[])}function Nx(e,t,n,r){if(Ma(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 Ma(Buffer.concat([n,i]),t,r)}function Ma(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>wx)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 np(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 kx(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 Vt(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function Lx(e,t){try{return Jn(e,t),!0}catch(n){if(Vt(n))return!1;throw n}}function Dx(e){let t=Sn(e);return t?t.filter(n=>n&&!vo(n)).sort():($x(e)??Gx(e)).filter(n=>n&&!vo(n)).sort()}function Ax(e,t={}){let n=(t.includePaths??[]).map(Ie),r=[...new Set([...Dx(e),...n])].filter(s=>!vo(s)).filter(s=>!t.language||ku(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=>sp(e,i,s));return Aa(i),o}function sp(e,t,n){let r=vd(e,n);if(r)return[{path:n,size:r.fingerprintSize??r.size,hash:r.sha256}];if(hn(e,n)==="present"){let o=yn(e,n);if(o)return[{path:n,size:o.fingerprintSize??o.size,hash:o.sha256}]}let i=Ba(e,n);try{let o=ja(i);if(o.isSymbolicLink()){let y=La(t,n,"symlink",xo(o));if(y)return[{path:n,size:y.size,hash:y.hash}];let g=$r(i),S=Ix(t,g);if(S===".."||S.startsWith(`..${Rx}`)||vx(S))throw new Error("external symlink");let h=xx(i),v=Oa("sha256").update("symlink\0").update(h).digest("hex"),E=Buffer.byteLength(h);return Da(t,n,"symlink",xo(o),{hash:v,size:E}),[{path:n,size:E,hash:v}]}let s=Ia(n)||Ra(n),a=La(t,n,"file",xo(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=Oa("sha256"),l=s,u=[],d=Vn(i,{inputKind:"project fingerprint input",maxBytes:Kn},y=>{c.update(y),l&&u.push(Buffer.from(y))}),p=c.digest("hex"),f=l?Buffer.concat(u,d):void 0,m=f?Od(n,f)??Ea(n,f):void 0;return Da(t,n,"file",xo(o),{hash:p,size:d,...m===void 0?{}:{semanticHash:m}}),[{path:n,size:d,hash:p,...m===void 0?{}:{semanticHash:m}}]}catch(o){return Vt(o)?[]:[{path:n,size:-1,hash:"unreadable"}]}}function xo(e){return{dev:e.dev,ino:e.ino,mtimeMs:e.mtimeMs,ctimeMs:e.ctimeMs,size:e.size}}function Xn(e,t,n){let r=Yn(t,n),i=[...r.typescriptProjects.filter(c=>jx(e,c)),...r.clojureConfigPath?[r.clojureConfigPath]:[]],o=r.languages.includes("typescript")?_d(e,r.typescriptProjectMode,r.typescriptProjects):null,s=r.languages.includes("typescript")?r.typescriptProjectMode==="workspace"?fo(e,r.typescriptProjects):["."]:[],a=Cd(s);return{...r,files:Ax(e,{includePath:c=>{if(c===".scipquery.json")return!1;let l=Mt(c,t,i);return l==="other"||l==="config"&&Fd(c)&&!a.has(c)?!1:l!=="source"||!Mx(c)||!o?!0:o.has(c)},includePaths:i})}}function yM(e,t){let n=new Set(t.files.map(o=>o.path)),r=Xn(e,t.languages,t),i=new Map(r.files.map(o=>[o.path,o]));return{...Yn(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 hM(e,t,n,r,i,o){let s=d=>({mode:"full",fingerprint:Xn(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=Yn(t,n);if(!Ox(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(Mt(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=sp(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 Aa(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 Ox(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 Mx(e){return/\.(?:[cm]?[jt]sx?|vue)$/iu.test(e)}function jx(e,t){let n;try{n=Ie(t)}catch{return!1}let r=hn(e,n);if(r)return r==="present";try{return ja(Ba(e,n)).isFile()}catch(i){if(Vt(i))return!1;throw i}}function Yn(e,t){return{version:3,languages:[...e].sort(),pnpmWorkspaces:t.typescriptProjectMode!=="workspace"&&t.pnpmWorkspaces===!0,typescriptProjectMode:t.typescriptProjectMode??"single",typescriptProjects:Cx(t.typescriptProjects),clojureConfigPath:Bx(t.clojureConfigPath)}}function Bx(e){return e?.trim()||void 0}function $x(e){try{let t=Xi(e,52428800,()=>hx("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:104857600,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}));return[...Yi(t)]}catch{return null}}function Gx(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?Ba(e,r):e,o;try{o=Sx(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){vo(a)||n.push(a);continue}t.push(a)}}return t}function vo(e){let t=e.split("/");return e==="meta.json"||Td(e)||t[0]===".scipquery"&&(t[1]==="events"||t[1]==="ledger"||t[1]==="releases"||t[1]==="suppressions")||t.some(n=>Vx.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var Vx=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{basename as ap}from"path";var Hx=C("indexed-document-paths",{clearGroups:["whole-project"]});function ge(e,t={}){let n=Wx(t);return[...Hx.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
87
+ FROM documents
88
+ WHERE 1 = 1
89
+ ${e.pathExclusionsFor("documents")}
90
+ ${i}
91
+ ${o}
92
+ 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 Wx(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 lp(e,t,n){let r=up(t);if(!r)return[];let i=e.all(`SELECT relative_path
93
+ FROM documents
94
+ WHERE relative_path = ?
95
+ ${e.pathExclusionsFor("documents")}`,r).filter(c=>!e.isIgnored(c.relative_path)).map(c=>({relativePath:c.relative_path,score:cp(c.relative_path,r)}));if(i.length>0)return i;let o=ge(e,{includeIgnored:!1}).map(c=>({relativePath:c,score:cp(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 cp(e,t){let n=up(e),r=ap(n),i=ap(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 up(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}var qx=[ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("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"}),ie("runtime-boundary-source-hashes",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundaries.test.ts",owner:"src/analysis/runtime-boundaries/graph.ts"}),ie("runtime-boundary-direct-extraction",{dependsOn:["content-hash","direct-deps-digest","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundaries.test.ts",owner:"src/analysis/runtime-boundaries/graph.ts"}),Vr("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"}),Vr("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"}),Vr("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"}),Vr("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"}),Vr("typescript-hierarchy-targets",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","definitionSet","projectFingerprint","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/typescript/ts-morph-provider.ts"})];function ae(e){let t=new Map;return{kind:e.kind,read(n,r,i){let o=!1,s=0,a;if($t()){let c=St(n);if(c){let l=`${c}\0${r}\0${i}`;a=t.get(l),a||(a=Nr(["evidence-product-file-read-v1",e.kind,c,r,i]),t.set(l,a))}}return J("evidence-product.file.read",()=>{let c=Ju(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}))},has(n,r,i){return Xu(n,e.kind,r,i)},write(n,r,i,o){Qu(n,e.kind,r,i,e.serialize(o))},writeBatch(n,r){Zu(n,r.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function dp(e){let t=new Map;return{kind:e.kind,read(n,r,i){let o=!1,s=0,a;if($t()){let c=`${i}\0${r}`;a=t.get(c),a||(a=Nr(["evidence-product-project-read-v1",e.kind,i,r]),t.set(c,a))}return J("evidence-product.project.read",()=>{let c=ed(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){td(n,e.kind,r,i,e.serialize(o))}}}function ne(e){let t=qx.find(n=>n.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function ie(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function Vr(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}var Eo=null;function Hr(e){Eo?.(e)}function pp(e,t){let n=Eo;Eo=e;try{return t()}finally{Eo=n}}var Ux=C("source-text",{clearGroups:["whole-project","source-file"]}),zx=C("source-lines",{clearGroups:["whole-project","source-file"]});function F(e,t){let n=t.replace(/\\/g,"/");return Hr(n),Ux.get(e,n,()=>Ro(e,n))}function Ro(e,t){let n=t.replace(/\\/g,"/");Hr(n);try{return Gr(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(r){if(Vt(r))return"";throw r}}function NM(e){if(e.length===0)return[];let t=e.split(`
96
+ `);return e.endsWith(`
97
+ `)&&t.pop(),t}function Wr(e,t){let n=t.replace(/\\/g,"/");return zx.get(e,n,()=>{let r=F(e,n);return r?r.split(`
98
+ `):[]})}var Kx=/^\s*(?:\/\/|#|\/\*+|\*)\s*scip-query[\s:-]*ignore(?:[\s:-]+(dead(?:-code)?|stale|wrapper|passthrough|drift|extract|similar|twin))?\b/i;function Jx(e){let t=Kx.exec(e);return t?t[1]??"":null}function kM(e,t,n){return fp(e,t,n).length>0}function LM(e,t,n,r){let i=r.toLowerCase();return fp(e,t,n).some(o=>o.toLowerCase()===i)}function fp(e,t,n){if(n<=0)return[];let r=Wr(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=Jx(s);if(a!==null){i.push(a);continue}if(!s.startsWith("//")&&!s.startsWith("*")&&!s.startsWith("/*")&&!s.startsWith("@")&&!s.startsWith("#"))return i}return i}import{setFlagsFromString as mp}from"v8";import{runInNewContext as Xx}from"vm";var In;function Yx(){if(In!==void 0)return In;let e=globalThis.gc;if(typeof e=="function")return In=e,In;try{mp("--expose_gc");let t=Xx("gc");mp("--no-expose_gc"),In=typeof t=="function"?t:null}catch{In=null}return In}function En(){let e=Yx();return e?(e(),!0):!1}var Qx=512*1024*1024,$a=0;function gp(e,t=En){!Number.isFinite(e)||e<=0||($a+=e,!($a<Qx)&&($a=0,t()))}import{readdirSync as Zx}from"fs";import{execFileSync as ev}from"child_process";import{extname as Po,join as tv}from"path";var nv=[".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"],HM=[".vue"],yp=[".tsx",".jsx"],hp=[".vue"],rv=[...yp,...hp],iv=new Set(yp),ov=new Set(hp),Sp=new Set(nv.map(e=>e.toLowerCase())),sv=[...Sp].sort().join(","),bp=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 je(e,t={}){let n=t.includeIndexed??!0,r=t.includeAuxiliary??!0,i=t.extensions?.map(c=>c.toLowerCase()),o=i?new Set(i):Sp,s=i?[...o].sort().join(","):sv,a=`${n?"1":"0"}|${r?"1":"0"}|${s}`;return av.get(e,a,()=>{let c=new Set;if(n)for(let l of ge(e,{includeIgnored:!1}))o.has(Po(l).toLowerCase())&&c.add(l);if(r)for(let l of cv(e.config.projectRoot,o))e.isIgnored(l)||n&&c.has(l)||c.add(l);return[...c].sort()})}function WM(e,t={}){let n=!1,r=!1;for(let i of je(e,{extensions:rv})){if(t.scope&&!i.includes(t.scope))continue;let o=Po(i).toLowerCase();if(n||=iv.has(o),r||=ov.has(o),n&&r)break}return{react:n,vue:r}}var av=C("source-files",{clearGroups:[]});function cv(e,t){return lv(e,t)??dv(e,t)}function lv(e,t){try{let n=ev("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(`
99
+ `)){let o=i.trim();o&&(uv(o)||t.has(Po(o).toLowerCase())&&r.add(o))}return r}catch{return null}}function uv(e){return e.split("/").some(t=>bp.has(t))}function dv(e,t){let n=new Set,r=i=>{let o=i?tv(e,i):e,s;try{s=Zx(o,{withFileTypes:!0})}catch{return}for(let a of s)if(!bp.has(a.name)){if(a.isDirectory()){r(i?`${i}/${a.name}`:a.name);continue}t.has(Po(a.name).toLowerCase())&&n.add(i?`${i}/${a.name}`:a.name)}};return r(""),n}import{createRequire as Iv}from"module";import{existsSync as Wt}from"fs";import{basename as vp,dirname as Te,extname as xt,join as Be,relative as Ht,resolve as re,sep as Ev}from"path";import{existsSync as Va,readdirSync as pv,statSync as fv}from"fs";import{join as Qn,relative as mv}from"path";function xp(e){let t=gv(e)??bv(e);if(!t||t.length===0)return[];let n=[],r=new Set;for(let i of t)for(let o of xv(e,i)){if(r.has(o))continue;r.add(o);let s=vv(e,o);s&&n.push(s)}return n}function gv(e){let t=Qn(e,"pnpm-workspace.yaml");if(!Va(t))return null;try{return yv(T(t,"pnpm workspace manifest"))}catch{return null}}function yv(e){let t=[],n=!1;for(let r of e.split(/\r?\n/)){let i=hv(r);if(!n){/^packages\s*:\s*$/.test(i.trim())&&(n=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=Sv(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function hv(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function Sv(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function bv(e){let t=Qn(e,"package.json");if(!Va(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 xv(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=Qn(e,t);return Ga(s)?[s]:[]}let n=t.indexOf("*"),r=t.slice(0,n).replace(/\/$/,""),i=t.slice(n+1).replace(/^\//,""),o=Qn(e,r||".");return Ga(o)?pv(o).map(s=>Qn(o,s,i)).filter(Ga):[]}function Ga(e){try{return fv(e).isDirectory()}catch{return!1}}function vv(e,t){let n=Qn(t,"package.json");if(!Va(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:mv(e,t).replace(/\\/g,"/"),exports:r.exports}}catch{return null}}var Rv=ot("indexed-paths",{clearGroups:[]}),Pv=ot("indexed-path-digest",{clearGroups:[]}),wv=C("tsconfig-alias-config",{clearGroups:["whole-project"]}),Cv=C("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),Fv=Iv(import.meta.url),qr;function Tv(){if(qr!==void 0)return qr;try{qr=Fv("typescript")}catch{qr=null}return qr}var _v=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],Nv=ot("workspace-packages",{clearGroups:["whole-project"]}),Rn=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],wo=[".py",".pyi"],_e=[".java",".scala",".kt",".kts"],Co=[".rs"],Fo=[".rb"],To=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],qt=[".cs",".vb"],_o=[".dart"],Pn=[".php"],Zn=[".clj",".cljs",".cljc"],kv=new Set(Rn),Ha=new Set(wo),Ip=new Set(_e),Wa=new Set(Co),qa=new Set(Fo),Ep=new Set(To),Rp=new Set(qt),Ua=new Set(_o),Pp=new Set(Pn),wp=new Set(Zn),Lv=[{extensions:Rn,lookup:kv},{extensions:wo,lookup:Ha},{extensions:_e,lookup:Ip},{extensions:Co,lookup:Wa},{extensions:Fo,lookup:qa},{extensions:To,lookup:Ep},{extensions:qt,lookup:Rp},{extensions:_o,lookup:Ua},{extensions:Pn,lookup:Pp},{extensions:Zn,lookup:wp}];function vt(e,t){return t.has(xt(e).toLowerCase())}function Dv(e){return vt(e,Ha)}function Av(e){return vt(e,Ip)}function Ov(e){return vt(e,Wa)}function Mv(e){return vt(e,qa)}function jv(e){return vt(e,Ep)}function Bv(e){return vt(e,Rp)}function Cp(e){return xt(e).toLowerCase()===".vb"}function $v(e){return vt(e,Ua)}function Gv(e){return vt(e,Pp)}function Vv(e){return vt(e,wp)}function za(e){let t=xt(e).toLowerCase();for(let n of Lv)if(n.lookup.has(t))return n.extensions;return Rn}function Hv(e){return Av(e)||Bv(e)||Gv(e)}function st(e,t,n){return Dv(t)?er(e,t,n):Ov(t)?It(e,t,n):Mv(t)?No(e,t,n):jv(t)?ko(e,t,n):Hv(t)?Y(e,n.replace(/\\/g,"."),za(t)):$v(t)?Lo(e,t,n):Vv(t)?Ka(e,n):Wv(e,t,n)}function Wv(e,t,n){if(!n.startsWith(".")&&!n.startsWith("/"))return qv(e,t,n)??Uv(e,n);let r=Te(Be(e.config.projectRoot,t)),i=re(r,n),o=Et(e);for(let s of Xa(i)){let a=X(Ht(e.config.projectRoot,s));if(o.has(a)||Wt(s))return a}return X(Ht(e.config.projectRoot,i))}function qv(e,t,n){let r=_p(e,t);if(!r)return null;let i=Et(e);for(let o of Fp(r,n)){let s=re(r.baseUrl,o);for(let a of Xa(s)){let c=X(Ht(e.config.projectRoot,a));if(i.has(c)||Wt(a))return c}}return null}function ij(e,t,n){let r=_p(e,t);if(!r)return null;for(let i of Fp(r,n)){let o=re(r.baseUrl,i);if(Wt(o))return X(Ht(e.config.projectRoot,o))}return null}function Fp(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 Uv(e,t){let n=Kv(zv(e),t);if(!n)return null;let r=Et(e);for(let i of Jv(n)){let o=re(e.config.projectRoot,n.pkg.relativeDir,i);for(let s of Xa(o)){let a=X(Ht(e.config.projectRoot,s));if(r.has(a)||Wt(s))return a}}return null}function zv(e){return Nv.get(e,()=>xp(e.config.projectRoot))}function Kv(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 Jv(e){let t=[],n=Xv(e.pkg.exports,e.subpath);if(n){let r=Yv(n);r&&t.push(r)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function Xv(e,t){if(!e||typeof e!="object")return null;let n=t===""?".":`./${t}`;return Tp(e[n])}function Tp(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=Tp(t[n]);if(r)return r}return null}function Yv(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function _p(e,t){let n=X(Te(t));return Cv.get(e,n,()=>Qv(e,n))}function Qv(e,t){let n=Tv();if(!n)return null;let r=re(e.config.projectRoot),i=re(r,t);for(;i===r||i.startsWith(r+Ev);){for(let s of _v){let a=Be(i,s);if(!Wt(a))continue;let c=wv.get(e,a,()=>Zv(n,a));if(c)return c}let o=Te(i);if(o===i)break;i=o}return null}function Zv(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,Te(t)),i=r.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:r.options.baseUrl?re(Te(t),r.options.baseUrl):Te(t),paths:i}}catch{return null}}function er(e,t,n){let r=Et(e),i;if(n.startsWith(".")){let o=n.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=Te(Be(e.config.projectRoot,t));for(let l=1;l<s;l++)c=Te(c);i=a?re(c,a.replace(/\./g,"/")):c}else i=re(e.config.projectRoot,n.replace(/\./g,"/"));for(let o of eI(i)){let s=X(Ht(e.config.projectRoot,o));if(r.has(s)||Wt(o))return s}return null}function It(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=Te(Be(e.config.projectRoot,t)),o;return r.startsWith("crate::")?o=re(e.config.projectRoot,"src",r.slice(7).replace(/::/g,"/")):r.startsWith("self::")?o=re(i,r.slice(6).replace(/::/g,"/")):o=re(Te(i),r.slice(7).replace(/::/g,"/")),Ja(e,tI(o))}function No(e,t,n){let r=Te(Be(e.config.projectRoot,t)),i=re(r,n);return Ja(e,nI(i))}function ko(e,t,n){let r=Te(Be(e.config.projectRoot,t)),i=[re(r,n),re(e.config.projectRoot,n),re(e.config.projectRoot,"include",n),re(e.config.projectRoot,"src",n)];return Ja(e,i)}function Y(e,t,n){let r=Et(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=>vp(u)===`${s}${c}`);if(l)return l}let a=[...r].filter(c=>n.includes(xt(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Lo(e,t,n){let r=Et(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=X(c.startsWith("lib/")?c:`lib/${c}`);return r.has(l)?l:null}let i=Te(Be(e.config.projectRoot,t)),o=re(i,n);for(let s of rI(o)){let a=X(Ht(e.config.projectRoot,s));if(r.has(a)||Wt(s))return a}return null}function Ka(e,t){let n=t.replace(/-/g,"_").replace(/\./g,"/"),r=Et(e);for(let i of Zn){let o=`${n}${i}`,s=[...r].find(a=>a.endsWith(o));if(s)return s}for(let i of Zn){let o=[...r].find(s=>vp(s)===`${n.split("/").pop()}${i}`);if(o)return o}return null}function eI(e){let t=xt(e);return Ha.has(t)?[e]:[`${e}.py`,`${e}.pyi`,Be(e,"__init__.py"),Be(e,"__init__.pyi")]}function Ja(e,t){let n=Et(e);for(let r of t){let i=X(Ht(e.config.projectRoot,r));if(n.has(i)||Wt(r))return i}return null}function tI(e){let t=xt(e);return Wa.has(t)?[e]:[`${e}.rs`,Be(e,"mod.rs")]}function nI(e){let t=xt(e);return qa.has(t)?[e]:[`${e}.rb`,Be(e,"index.rb")]}function rI(e){let t=xt(e);return Ua.has(t)?[e]:[`${e}.dart`,e]}function Xa(e){let t=xt(e),n=new Set;if(t){n.add(e);for(let r of Rn)n.add(e.slice(0,-t.length)+r)}else for(let r of Rn)n.add(`${e}${r}`),n.add(Be(e,`index${r}`));return[...n]}function Et(e){return Rv.get(e,()=>new Set(ge(e,{includeIgnored:!1}).map(X)))}function Ya(e){return Pv.get(e,()=>K([...Et(e)].sort().join(`
100
+ `)))}function Ut(e){return typeof e=="object"&&e!==null}function $e(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{basename as Cf}from"path";function ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Za(e){return e.replace(/'''[\s\S]*?'''/g,zt).replace(/"""[\s\S]*?"""/g,zt).replace(/#.*$/gm,zt).replace(/\/\/.*$/gm,zt).replace(/\/\*[\s\S]*?\*\//g,zt).replace(/`(?:\\[\s\S]|[^`])*`/g,zt).replace(/'(?:\\.|[^'\\\r\n])*'/g,zt).replace(/"(?:\\.|[^"\\\r\n])*"/g,zt)}function dj(e){return Np(e,{maskStrings:!1})}function pj(e){return Np(e,{maskStrings:!0})}function Np(e,t){let n="",r=0,i=e.length;for(;r<i;){if(e[r]==="/"&&e[r+1]==="/"){let s=e.indexOf(`
101
+ `,r),a=s===-1?i:s;n+=Qa(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+=Qa(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]===`
102
+ `)break;a+=1}n+=t.maskStrings?Qa(e,r,a):e.slice(r,a),r=a;continue}n+=o,r+=1}return n}function Qa(e,t,n){let r="";for(let i=t;i<n;i+=1)r+=e[i]===`
103
+ `?`
104
+ `:" ";return r}function zt(e){return e.replace(/[^\r\n]/g," ")}var fj=dn("stripped-lines",{clearGroups:["whole-project","source-file"]});Hn({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{Do=null,Ur=""},clearFile:()=>{Do=null,Ur=""}});var Do=null,Ur="";function iI(e){return Do===e||(Do=e,Ur=Za(e)),Ur}function Kt(e,t,n){let r=iI(e);return`${r.slice(0,t)}${" ".repeat(n-t)}${r.slice(n)}`}function Re(e,t){return new RegExp(`\\b${ce(t)}\\b`,"m").test(e)}function tr(e,t){let n=new Set,r=new RegExp(`\\b${ce(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 ec(e){let t=0;for(let n of e)n==="("&&(t+=1),n===")"&&(t-=1);return t}import{extname as kp}from"path";var oI={".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 le(e){return oI[kp(e).toLowerCase()]??null}function at(e){return kp(e).toLowerCase()===".vue"}var Lp=new WeakMap,Dp=new Set(["call_expression","call","decorator","pair","string","string_literal","template_string","variable_declarator"]);function zr(e,t){let n=Array.isArray(t)?t:[t];if(!n.every(o=>Dp.has(o)))return e.descendantsOfType(t);let r=sI(e);return n.length===1?r.get(n[0])??[]:n.flatMap(o=>r.get(o)??[]).sort((o,s)=>o.startIndex-s.startIndex)}function tc(e,t){let n=e.walk(),r=0,i=!1;for(;!i;){if(t(n),n.gotoFirstChild()){r+=1;continue}for(;;){if(r===0){i=!0;break}if(n.gotoNextSibling())break;n.gotoParent(),r-=1}}}function sI(e){let t=Lp.get(e);if(t)return t;let n=new Map;return tc(e,r=>{let i=r.nodeType;if(!Dp.has(i))return;let o=n.get(i);o?o.push(r.currentNode):n.set(i,[r.currentNode])}),Lp.set(e,n),n}function ye(e,t){t(e);for(let n of e.namedChildren)ye(n,t)}var aI=/(?:function|method|lambda)/u,Ap=new WeakMap;function cI(e){let t=Ap.get(e);if(t)return t;let n=[];return tc(e,r=>{if(!r.nodeIsNamed)return;let i=r.nodeType;(i==="arrow_function"||aI.test(i))&&n.push(r.currentNode)}),Ap.set(e,n),n}function Ge(e,t,n){let r=null;for(let i of cI(e))i.startPosition.row>t||i.endPosition.row<n||(!r||i.endIndex-i.startIndex<r.endIndex-r.startIndex)&&(r=i);return r}function Op(e,t,n){if(e.startPosition.row>t||e.endPosition.row<n)return null;for(let r of e.namedChildren){let i=Op(r,t,n);if(i)return i}return e}function Ve(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 Kr(e){if(e.type==="identifier")return e.text;let t=e.childForFieldName("name")??e.childForFieldName("pattern");return t?Kr(t):e.namedChildren.find(n=>n.type==="identifier")?.text??null}function Jt(e){return(e.childForFieldName("parameters")??e.namedChildren.find(n=>/parameters/u.test(n.type)))?.namedChildren.map(Kr)??[]}import{createRequire as lI}from"module";var he=lI(import.meta.url),Jr=null,nc=!1;function Mp(){if(nc)return null;if(Jr)return Jr;try{return Jr=he("tree-sitter"),Jr}catch{return nc=!0,null}}function Ij(e){if(e==="clojure")return"reader";let t=Mp();if(!t)return"unavailable";let n=jp(e);if(!n)return"unavailable";try{return new t().setLanguage(n),"ast"}catch{return nr.add(e),"unavailable"}}var rc=new Map,nr=new Set;function jp(e){if(nr.has(e))return null;let t=rc.get(e);if(t)return t;let n;try{switch(e){case"rust":n=he("tree-sitter-rust");break;case"typescript":n=he("tree-sitter-typescript").typescript;break;case"tsx":n=he("tree-sitter-typescript").tsx;break;case"javascript":n=he("tree-sitter-javascript");break;case"python":n=he("tree-sitter-python");break;case"java":n=he("tree-sitter-java");break;case"kotlin":n=he("tree-sitter-kotlin");break;case"scala":n=he("tree-sitter-scala");break;case"ruby":n=he("tree-sitter-ruby");break;case"c":n=he("tree-sitter-c");break;case"cpp":n=he("tree-sitter-cpp");break;case"csharp":n=he("tree-sitter-c-sharp");break;case"php":n=he("tree-sitter-php").php;break;case"vb":{let r=he("tree-sitter-vb-dotnet");n=r.language??r;break}case"clojure":return nr.add(e),null}}catch{return nr.add(e),null}return rc.set(e,n),n}var ic=new Map;function Ej(){Jr=null,nc=!1,rc.clear(),nr.clear(),ic.clear(),fI.clear()}function uI(e){let t=ic.get(e);if(t)return t;let n=jp(e);if(!n)return null;let r=Mp();if(!r)return null;let i=new r;try{i.setLanguage(n)}catch{return nr.add(e),null}return ic.set(e,i),i}function dI(e,t){return e.parse(r=>r>=t.length?null:t.slice(r,Math.min(t.length,r+16384)))}var pI=24;function wn(e,t){let n=uI(e);if(!n)return null;try{let r=dI(n,t);return gp(t.length*pI),r}catch{return null}}var fI=new Map;import{createRequire as mI}from"module";import{posix as oc}from"path";var gI=Bt("vue-sfc-units"),yI=mI(import.meta.url),hI;function SI(){return hI??=yI("@vue/compiler-sfc")}function Gp(...e){return SI().parse(...e)}function rr(e,t){let n=Vp(t),r=F(e,n);return gI.get(e,n,r,()=>sc(e,n,r))}function Vp(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function bI(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function Cn(e){return!e||e.body.length===0?0:e.body.split(`
105
+ `).length}function sc(e,t,n){let r={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!n)return r;let i;try{i=Gp(n,{filename:t})}catch(s){return r.errors.push($p(s)),r}r.errors.push(...i.errors.map($p));let{descriptor:o}=i;return o.template&&(r.template=Ao(e,t,"template",o.template)),o.script&&r.scripts.push(Bp(e,t,o.script,!1)),o.scriptSetup&&r.scripts.push(Bp(e,t,o.scriptSetup,!0)),r.styles=o.styles.map(s=>Ao(e,t,"style",s)),r.customBlocks=o.customBlocks.map(s=>Ao(e,t,"custom",s)),r.errors.push(...[r.template,...r.scripts,...r.styles,...r.customBlocks].flatMap(s=>s?.errors??[])),r}function Bp(e,t,n,r){let i=Ao(e,t,"script",n);return{...i,kind:"script",setup:r,astLanguage:bI(i.lang)}}function Ao(e,t,n,r){let i=vI(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=xI(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(`
106
+ `).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 xI(e,t){let n=t.split(/[?#]/,1)[0];if(!n||n.startsWith("/")||n.includes("://"))return null;let r=Vp(oc.normalize(oc.join(oc.dirname(e),n)));return r===".."||r.startsWith("../")?null:r}function vI(e){return{...e}}function $p(e){return e instanceof Error?e.message:String(e)}function Xr(e,t,n){let i=sc(e,t,n).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
107
+ `.repeat(s.startLine)}${s.body}`).join(`
108
+ `),startLine:0,language:o}:null}var Oo=dn("ast-trees",{clearGroups:["whole-project","source-file"]});function M(e,t){if(at(t))return II(e,t);let n=le(t);if(!n)return null;let r=F(e,t);return r?Oo.get(e,t,r,()=>wn(n,r)):null}function ir(e,t,n){if(at(t))return Oo.get(e,t,n,()=>{let i=Xr(e,t,n);return i?wn(i.language,`
109
+ `.repeat(i.startLine)+i.body):null});let r=le(t);return r?Oo.get(e,t,n,()=>wn(r,n)):null}function II(e,t){let n=F(e,t);return n?Oo.get(e,t,n,()=>{let r=Xr(e,t,n);if(!r)return null;let i=`
110
+ `.repeat(r.startLine)+r.body;return wn(r.language,i)}):null}function or(e,t){let n=PI(e,t);if(!n)return null;let r=Rt(n);if(!r)return null;let i=FI(n);return{kind:EI(e),calleeLeaf:r,calleeQualifier:i?RI(n):void 0,calleeText:n.text,memberAccess:i,line:e.startPosition.row}}function EI(e){return Wp.has(e.type)?"jsx-render":e.type==="new_expression"?"new":"call"}var Wp=new Set(["jsx_opening_element","jsx_self_closing_element"]);function RI(e){return(e.childForFieldName("object")??e.childForFieldName("value")??e.namedChild(0)??void 0)?.text||void 0}function PI(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 Hp(e.childForFieldName("function")??e.namedChild(0));if(e.type==="new_expression")return Hp(e.childForFieldName("constructor")??e.namedChild(0));if(Wp.has(e.type))return CI(e)}return null}var wI=new Set(["await_expression","parenthesized_expression","non_null_expression","as_expression","satisfies_expression"]);function Hp(e){let t=e;for(;t&&wI.has(t.type);){let n=t.namedChild(0);if(!n)return t;t=n}return t}function CI(e){let t=e.childForFieldName("name")??e.namedChild(0);return t&&(t.type==="member_expression"||t.type==="nested_identifier"||(t.type==="identifier"||t.type==="jsx_identifier")&&/^[A-Z]/.test(t.text))?t:null}function FI(e){switch(e.type){case"field_expression":case"member_expression":case"nested_identifier":case"attribute":return!0;default:return!1}}function Rt(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"nested_identifier":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?Rt(t):null}case"jsx_identifier":return e.text;case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?Rt(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?Rt(t):null}case"super":case"self":case"this":return null;default:return null}}function Yr(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var Yp=["function_declaration","generator_function_declaration","method_definition","method_signature","function_signature"],TI=new Set(Yp),_I=[...Yp,"variable_declarator","public_field_definition"],NI=["function_item","function_signature_item"],kI=["function_definition"],LI=[],qp=new Set(["arrow_function","function_expression","generator_function"]);function Qp(e){return e==="rust"?NI:e==="python"?kI:e==="typescript"||e==="tsx"||e==="javascript"?_I:LI}function sr(e,t){let n=AI(e,t);if(n)return{name:n.name,startLine:n.definitionNode.startPosition.row,endLine:n.definitionNode.endPosition.row,paramCount:Jp(n.functionNode),params:Up(n.functionNode),paramsEndLine:zp(n.functionNode),isLiteralPassthrough:Xp(n.functionNode,t),branches:0};if(!DI(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:Jp(e),params:Up(e),paramsEndLine:zp(e),isLiteralPassthrough:Xp(e,t),branches:0}:null}function Zp(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function Up(e){let t=Zp(e);if(!t)return[];let n=[];for(let r of t.namedChildren){if(Yr(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 zp(e){let t=Zp(e);return t?t.endPosition.row:e.startPosition.row}function DI(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?TI.has(e):!1}function AI(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=Kp(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=Kp(r);return i?{name:n.text,definitionNode:e,functionNode:i}:null}return null}function Kp(e){if(qp.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=>qp.has(i.type));return r.length===1?r[0]:null}function Jp(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)Yr(r)||(n+=1);return n}function Xp(e,t){let n=e.namedChildren.find(p=>p.type==="block"||p.type==="statement_block");if(!n)return!1;let r=n.namedChildren.filter(p=>!Yr(p));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.childForFieldName("function")??o.namedChild(0);if(a&&(a.type===s||a.type==="call_expression"))return!1;let c=o.namedChildren.find(p=>p.type==="arguments"||p.type==="argument_list");if(!c)return!1;let l=c.namedChildren.filter(p=>!Yr(p)),u=e.namedChildren.find(p=>p.type==="parameters"||p.type==="formal_parameters");if(!u)return!1;let d=[];for(let p of u.namedChildren){if(p.type==="identifier"){d.push(p.text);continue}let f=p.namedChildren.find(m=>m.type==="identifier");f&&d.push(f.text)}if(l.length!==d.length)return!1;for(let p=0;p<d.length;p+=1){let f=l[p];if(f.type!=="identifier"||f.text!==d[p])return!1}return!0}function Gj(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 OI=new Set(["if_statement","conditional_expression","ternary_expression","for_statement","for_in_statement","for_of_statement","while_statement","do_statement","switch_case","case_statement","catch_clause","except_clause","elif_clause","match_arm"]);function ef(e){return OI.has(e.type)?1:e.type==="binary_expression"&&e.parent?.type!=="binary_expression"&&(e.text.includes("&&")||e.text.includes("||"))?MI(e.text):0}function MI(e){return(e.match(/&&|\|\|/g)??[]).length}var jI=new Set(["identifier","type_identifier","field_identifier"]),BI=new Set(["identifier"]),$I=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),GI=new Set(["rust","python"]),VI=/\{([^{}]*)\}/g,HI=/\b([A-Za-z_][\w]*)\b/g;function tf(e,t){return WI(t).has(e.type)}function nf(e,t){return GI.has(t)&&e.type==="string_content"}function ac(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 WI(e){return e==="rust"?jI:e==="python"?BI:$I}function rf(e,t){let n=e.startPosition.row;for(let r of e.text.matchAll(VI)){let i=r[1]??"";for(let o of i.matchAll(HI))o[1]&&t(o[1],n)}}var qI=[/\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],UI=/^#!?\[\s*serde\s*\(/,zI=/^#!?\[\s*schemars\s*\(/,KI=/^#!?\[\s*validate\s*\(/,JI=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function of(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=Rt(r);if(!i||!JI.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 sf(e,t){let n=UI.test(e),r=zI.test(e),i=KI.test(e);if(!(!n&&!r&&!i))for(let o of qI){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 af(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 XI=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),cc=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 cf(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===`
111
+ `){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=jo(e,a);continue}if(l==='"'){let m=Zr(e,a,s);s=m.line,a=m.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 m=o.pop();m&&(m.endLine=s,YI(m,{callables:t,callSites:n,clojureMembers:r,recordIdentifier:c}),o[o.length-1]?.children.push(m)),a+=1;continue}if(lc(l)){a+=1;continue}let u=s,d=a;for(;a<e.length&&!uc(e[a]);)a+=1;let p=e.slice(d,a);if(!p)continue;let f={text:p,line:u};QI(o[o.length-1],f),c(He(p),u)}return{language:"clojure",callables:t,callSites:n,clojureMembers:r,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:rE(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function YI(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let n=e.headTokens[0],r=He(n.text),i=XI.get(n.text);if(i){let s=e.headTokens[1];if(s){let a=He(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(ZI(e,t),!r||cc.has(n.text)||cc.has(r)||r.startsWith(":"))return;let o=nE(n.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:n.line})}function QI(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function ZI(e,t){let n=He(e.tokens[0]?.text??"");if(n==="defprotocol"){let r=He(e.tokens[1]?.text??"");if(!r)return;for(let i of Mo(e))Qr(t,r,"protocol",i,"protocol-method");return}if(n==="defrecord"||n==="deftype"){let r=He(e.tokens[1]?.text??"");if(!r)return;let i=n==="defrecord"?"record":"type",o=n==="defrecord"?"record-method":"type-method";for(let s of Mo(e))Qr(t,r,i,s,o);return}if(n==="extend-type"){let r=He(e.tokens[1]?.text??"");if(!r)return;for(let i of Mo(e))Qr(t,r,"extension",i,"extension-method");return}if(n==="extend-protocol"){let r=He(e.tokens[1]?.text??"");for(let i of Mo(e)){r&&Qr(t,r,"extension",i,"extension-method");let o=tE(e,i.startLine);o&&o!==r&&Qr(t,o,"extension",i,"extension-method")}}}function Mo(e){return e.children.filter(eE)}function eE(e){if(e.kind!=="(")return!1;let t=He(e.tokens[0]?.text??"");return!!(t&&!cc.has(t)&&!t.startsWith(":"))}function Qr(e,t,n,r,i){let o=r.tokens[0],s=He(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 tE(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=He(i.text);o&&!o.startsWith(":")&&(n=o)}return n}function He(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function nE(e){let t=e.replace(/^#?['`~@]+/,""),n=t.lastIndexOf("/"),r=He(t);if(n<=0)return{leaf:r,text:t};let i=t.slice(0,n);return{leaf:r,qualifier:i,text:t}}function jo(e,t){let n=t;for(;n<e.length&&e[n]!==`
112
+ `;)n+=1;return n}function Zr(e,t,n){let r=t+1,i=n;for(;r<e.length;){let o=e[r];if(o==="\\"){r+=2;continue}if(o===`
113
+ `&&(i+=1),r+=1,o==='"')break}return{index:r,line:i}}function lc(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function uc(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function rE(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 lf=9,oE=dn("source-facts",{clearGroups:["whole-project","source-file"]}),dc=ae({kind:"source-facts",invalidation:ne("source-facts"),serialize:cE,deserialize:lE});function Se(e,t){return pc(e,t).facts}function pc(e,t){let n=F(e,t);if(!n)return{facts:null};let r=sE(e,t,n);return r?oE.get(e,t,n,()=>aE(e,t,r,n)):{facts:null}}function sE(e,t,n){return at(t)?Xr(e,t,n)?.language??null:le(t)}function aE(e,t,n,r){let i=fe(e,t,r),o=dc.read(e,t,i);if(o&&o.language===n)return{facts:o};if(n==="clojure"){let c=cf(r);return dc.write(e,t,i,c),{facts:c}}let s=M(e,t);if(!s)return{facts:null,unavailable:{language:n,reason:"parser-unavailable"}};let a=fE(s,n);return dc.write(e,t,i,a),{facts:a}}function cE(e){let t={version:lf,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 lE(e){try{let t=JSON.parse(e);if(t.version!==lf||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:ac(n),fileIdentifiers:new Set(n.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function uE(e,t,n,r){let i=Se(e,t);return i?pE(i,n,r)?.isLiteralPassthrough??!0:!0}function dE(e,t){return t.relativePath.includes(".clj-kondo/hooks/")?!0:Se(e,t.relativePath)?.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine)?.clojureKind==="macro"}function pE(e,t,n){return e.callables.find(r=>r.startLine===t&&r.endLine===n)??null}function fE(e,t){let n=[],r=[],i=new Set,o=new Set,s=new Map,a=(u,d)=>{let p=s.get(u);if(!p){s.set(u,[d]);return}p[p.length-1]!==d&&p.push(d)},c=[],l=u=>{let d=sr(u,t);d&&(d.branches=0,n.push(d),c.push(d));let p=ef(u);if(p>0)for(let m of c)m.branches=(m.branches??0)+p;let f=or(u,t);f&&r.push(f),of(u,t,o),t==="rust"&&(u.type==="attribute_item"||u.type==="inner_attribute_item")&&sf(u.text,i),tf(u,t)&&a(u.text,u.startPosition.row),nf(u,t)&&rf(u,a);for(let m of u.children)l(m);d&&c.pop()};return l(e.rootNode),{language:t,callables:n,callSites:r,clojureMembers:[],typeContainerMap:af(e,t),identifierLineMap:s,identifiersByLine:ac(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var uf=new Set(["rust","typescript","tsx","javascript","python","clojure"]),mE=new Set(["rust","typescript","tsx","javascript","python"]);function ei(e,t){let n=Se(e,t);return!n||!uf.has(n.language)?null:n.callables.map(r=>({name:r.name,startLine:r.startLine,endLine:r.endLine}))}function fc(e,t){if(!mE.has(t))return null;let n=[];for(let r of e.descendantsOfType([...Qp(t)])){let i=sr(r,t);i&&n.push({name:i.name,startLine:i.startLine,endLine:i.endLine})}return n}function gE(e,t){let n=Se(e,t);return!n||!uf.has(n.language)?null:n.callSites}function yE(e,t){return Se(e,t)?.typeContainerMap??new Map}import{createRequire as SE}from"module";var hE=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 Bo(e){return e.length<=2||hE.has(e)}function $o(e,t){return e.split(t).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}var bE=Bt("vue-template-facts"),xE=SE(import.meta.url),vE;function ti(){return vE??=xE("@vue/compiler-dom")}var IE=new Set(["component","keep-alive","slot","suspense","teleport","template","transition","transition-group"]),EE=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"]),RE=new Set(["div","span","template"]),PE=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 Go(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n);return bE.get(e,n,r,()=>wE(n,rr(e,n).template))}function wE(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=ti().parse(t.body,{comments:!1})}catch{return n}let i=new Set,o=s=>{s.trim()&&i.add(s)};return pf(r.children,t.startLine,n,o),n.structuralTokens=[...i].sort(),n}function pf(e,t,n,r){for(let i of e)if(i.type===ti().NodeTypes.ELEMENT)CE(i,t,n,r),pf(i.children,t,n,r);else if(i.type===ti().NodeTypes.INTERPOLATION){r("interpolation");let o=mc(i.content);o&&ff(o,t,i.loc.start.line,n,r)}}function CE(e,t,n,r){let i=DE(e.tag),o={tag:e.tag,normalized:i,kind:LE(e),startLine:ar(t,e.loc.start.line),endLine:ar(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),RE.has(e.tag)||r(`native:${e.tag}`));for(let s of e.props)FE(s,t,n,r)}function FE(e,t,n,r){if(e.type===ti().NodeTypes.ATTRIBUTE){let a=e.value?.content??null,c=df("prop",e.name,a,t,e.loc.start.line,e.loc.end.line);n.props.push(c),r(`prop:${e.name}`);return}let i=_E(e),o=mc(e.exp),s=df(TE(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&&ff(o,t,e.loc.start.line,n,r)}function df(e,t,n,r,i,o){return{kind:e,name:t,value:n,startLine:ar(r,i),endLine:ar(r,o)}}function TE(e){switch(e){case"bind":case"model":return"prop";case"on":return"event";case"slot":return"slot";default:return"directive"}}function _E(e){let t=mc(e.arg);return t||e.name}function mc(e){if(!e)return null;let t=("content"in e&&typeof e.content=="string"?e.content:e.loc.source).trim();return t||null}function ff(e,t,n,r,i){for(let o of NE(e)){let s={name:o,startLine:ar(t,n),endLine:ar(t,n)};r.expressionIdentifiers.push(s),i(`id:${o}`)}}function NE(e){let t=new Set,n=kE(e),r=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,i;for(;i=r.exec(n);){let o=i[0];PE.has(o)||Bo(o)||/^[A-Z_]+$/.test(o)||t.add(o)}return[...t].sort()}function kE(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 LE(e){let t=e.tag;return e.tagType===ti().ElementTypes.COMPONENT?"component":IE.has(t)?"builtin":EE.has(t)?"native":/^[A-Z]/.test(t)||t.includes("-")?"component":"native"}function DE(e){return $o(e,/[-_:]/)}function ar(e,t){return e+Math.max(0,t-1)}var AE=new Set(["ref","shallowRef","reactive","computed","watch","watchEffect"]),OE=new Set(["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured"]),ME=new Set(["axios","fetch","runRequest","useAsyncData","useFetch","useResource"]),jE=new Set(["defineEmits","defineExpose","defineModel","defineOptions","defineProps","withDefaults"]),BE=new Set(["catch","for","function","if","return","switch","while"]);function Ho(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+=Cn(n),n.external&&(t.externalLineCount+=Cn(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(...HE(n));let r=wn(n.astLanguage,n.body);r?GE(n,r.rootNode,t):VE(n,t)}return $E(t),t.externalScriptPaths=gf(t.externalScriptPaths),t}function $E(e){e.composables=cr(e,"composable"),e.stores=cr(e,"store"),e.reactivity=cr(e,"reactivity"),e.lifecycle=cr(e,"lifecycle"),e.requests=cr(e,"request"),e.macros=cr(e,"macro")}function cr(e,t){return gf(e.calls.filter(n=>n.categories.includes(t)).map(n=>n.name))}function GE(e,t,n){let r=new Set,i=new Set,o=s=>{let a=sr(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=or(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:mf(c.calleeLeaf),setup:e.setup}))}for(let l of s.children)o(l)};o(t)}function VE(e,t){for(let n of e.body.matchAll(/\b([A-Za-z_$][\w$]*)\s*\(/g)){let r=n[1];!r||BE.has(r)||t.calls.push({name:r,sourcePath:e.sourcePath,line:e.startLine+Vo(e.body,n.index??0),categories:mf(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+Vo(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+Vo(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}}function HE(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+Vo(e.body,n.index??0);for(let s of WE(r))t.push({local:s,source:i,sourcePath:e.sourcePath,line:o,setup:e.setup})}return t}function WE(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 mf(e){let t=["call"];return/^use[A-Z0-9_]/.test(e)&&t.push("composable"),/^use[A-Z0-9_].*Store$/.test(e)&&t.push("store"),AE.has(e)&&t.push("reactivity"),OE.has(e)&&t.push("lifecycle"),ME.has(e)&&t.push("request"),jE.has(e)&&t.push("macro"),t}function Vo(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 gf(e){return[...new Set(e)].sort()}var qE=new Set(["in","key","of"]),UE=new Set(["computed","defineEmits","defineProps","reactive","ref","watch","watchEffect"]),zE=Bt("vue-component-behavior-profiles");function yf(e,t={}){let n=je(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=>gc(e,i)).filter(i=>(t.minTemplateTokens===void 0||i.templateTokens.size>=t.minTemplateTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function gc(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n),i=zE.get(e,n,r,()=>KE(e,n,r));return XE(i)}function KE(e,t,n){let r=rr(e,t),i=Go(e,t),o=Ho(r),s=ZE(i),a=i.expressionIdentifiers.map(g=>g.name).filter(g=>!s.includes(g)).filter((g,S,h)=>h.indexOf(g)===S).sort(),c=i.componentTags.map(g=>g.normalized).filter((g,S,h)=>h.indexOf(g)===S).sort(),l=n?n.split(`
114
+ `).length:0,u=Cn(r.template),d=o.lineCount,p=r.styles.reduce((g,S)=>g+Cn(S),0),f=r.customBlocks.reduce((g,S)=>g+Cn(S),0),{lines:m,paths:y}=JE(e,t,o);return{file:t,sfc:r,templateFacts:i,scriptFacts:o,templateTokens:new Set(i.structuralTokens),behaviorTokens:QE(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:m,delegatedComposablePaths:y}}function JE(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=st(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(`
115
+ `).length:0)},0),paths:i}}function XE(e){let t=YE(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 YE(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 QE(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(UE.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 ZE(e){let t=new Set;for(let n of e.directives)if(n.name==="for"&&n.value)for(let r of eR(n.value))t.add(r);for(let n of e.slots)if(n.value)for(let r of hf(n.value))t.add(r);return[...t].sort()}function eR(e){let t=/^(.*?)\s+(?:in|of)\s+/.exec(e.trim());return t?hf(t[1]??""):[]}function hf(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];qE.has(r)||t.push(r)}return t}import{extname as tR}from"path";var nR=[".tsx",".jsx"],Sf=new Set(["useActionState","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useOptimistic","useReducer","useRef","useState","useSyncExternalStore","useTransition"]),rR=new Set(["useEffect","useInsertionEffect","useLayoutEffect"]),iR=new Set(["useActionState","useOptimistic","useReducer","useRef","useState"]),oR=new Set(["useLocation","useNavigate","useParams","useSearchParams","useTranslation"]),sR=new Set(["axios","fetch","gql","graphql","mutate","query","request","useMutation","useQuery","useSuspenseQuery"]),aR=new Set(["add","apply","cancel","change","clear","close","create","delete","fetch","filter","handle","load","open","refresh","remove","render","reset","save","select","submit","toggle","update"]),cR=new Set(["aria-hidden","className","clipRule","d","fill","fillRule","height","role","stroke","strokeLinecap","strokeLinejoin","strokeWidth","style","viewBox","width","xmlns"]),lR=Bt("react-component-behavior-profiles"),bf=ae({kind:"react-component-behavior-profiles",invalidation:ne("react-component-behavior-profiles"),serialize:fR,deserialize:mR});function Ef(e,t={}){let n=je(e,{extensions:nR}).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=>hc(e,i)).filter(i=>(t.minJsxTokens===void 0||i.jsxTokens.size>=t.minJsxTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function hc(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n);return lR.get(e,n,r,()=>uR(e,n,r)).map(pR)}function uR(e,t,n){let r=fe(e,t,n),i=bf.read(e,t,r);if(i)return i;let o=dR(e,t);return bf.write(e,t,r,o),o}function dR(e,t){let n=yR(t);if(!n)return[];let r=M(e,t);if(!r)return[];let i=Wr(e,t).length;return hR(r.rootNode,n).filter(s=>s.kind==="hook"||Sc(s.bodyNode)).map(s=>{let a=RR(s.bodyNode),c=TR(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:Pt(a.componentNames),nativeTags:Pt(a.nativeTags),propNames:Pt(a.propNames),eventNames:Pt(a.eventNames),hookNames:Pt(c.hookNames),requestNames:Pt(c.requestNames),stateNames:Pt(c.stateNames),effectNames:Pt(c.effectNames),handlerNames:Pt(c.handlerNames)}})}function pR(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 fR(e){return JSON.stringify(e.map(t=>({...t,jsxTokens:[...t.jsxTokens],behaviorTokens:[...t.behaviorTokens]})))}function mR(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=[];for(let r of t){let i=gR(r);if(!i)return null;n.push(i)}return n}catch{return null}}function gR(e){if(!Ut(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:m,requestNames:y,stateNames:g,effectNames:S,handlerNames:h}=e;if(typeof t!="string"||typeof n!="string"||r!=="component"&&r!=="hook"||!Wo(i)||!Wo(o)||!Wo(s)||!Wo(a))return null;let v={jsxTokens:$e(c),behaviorTokens:$e(l),componentNames:$e(u),nativeTags:$e(d),propNames:$e(p),eventNames:$e(f),hookNames:$e(m),requestNames:$e(y),stateNames:$e(g),effectNames:$e(S),handlerNames:$e(h)};return Object.values(v).some(E=>E===null)?null:{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:new Set(v.jsxTokens),behaviorTokens:new Set(v.behaviorTokens),componentNames:v.componentNames,nativeTags:v.nativeTags,propNames:v.propNames,eventNames:v.eventNames,hookNames:v.hookNames,requestNames:v.requestNames,stateNames:v.stateNames,effectNames:v.effectNames,handlerNames:v.handlerNames}}function Wo(e){return typeof e=="number"&&Number.isFinite(e)}function yR(e){let t=tR(e).toLowerCase();return t!==".tsx"&&t!==".jsx"?null:le(e)}function hR(e,t){let n=[],r=new Set,i=o=>{let s=SR(o);if(s&&(!IR(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 SR(e){if(e.type==="class_declaration"){let o=yc(e);if(!o||!/^[A-Z]/.test(o))return null;let s=bR(e);return!s||!xR(e)&&!Sc(s)?null:{name:o,kind:"component",node:e,bodyNode:s}}if(e.type==="function_declaration"){let o=yc(e);return!o||!xf(o)?null:{name:o,kind:vf(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=ni(t);if(!r||!n||!xf(r))return null;let i=vR(n);return i?{name:r,kind:vf(r),node:e,bodyNode:i}:null}function bR(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 xR(e){return/\b(?:React\.)?(?:Pure)?Component\b/.test(e.text)}function xf(e){return/^[A-Z]/.test(e)||/^use[A-Z0-9_]/.test(e)}function vf(e){return/^use[A-Z0-9_]/.test(e)?"hook":"component"}function vR(e){if(e.type==="arrow_function"||e.type==="function_expression")return e;if(e.type!=="call_expression")return null;let t=ER(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 IR(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 yc(e){return ni(e.childForFieldName("name")??e.namedChild(0))}function ER(e){let t=e.childForFieldName("function")??e.namedChild(0);return t?t.text.split(".").pop()??t.text:null}function Sc(e){return e.type.startsWith("jsx_")?!0:e.namedChildren.some(Sc)}function RR(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"?PR(r,t):r.type==="jsx_element"&&r.text.trimStart().startsWith("<>")?t.tokens.add("jsx:fragment"):r.type==="jsx_expression"?wR(r,t):r.type==="jsx_fragment"&&t.tokens.add("jsx:fragment");for(let i of r.children)n(i)};return n(e),t}function PR(e,t){let n=CR(e),r=!1;if(n){let i=If(n),o=i==="Fragment"||i==="React.Fragment";r=DR(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=FR(i);if(!o)continue;let s=If(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 cR.has(s)||(t.propNames.add(s),t.tokens.add(`${r?"prop":"native-prop"}:${s}`))}else i.type==="jsx_spread_attribute"&&t.tokens.add(Rf(i))}function wR(e,t){let n=e.text;/^\{\s*\.\.\./.test(n)&&t.tokens.add(Rf(e)),Pf(e)&&t.tokens.add("jsx:conditional"),(n.includes(".map(")||n.includes(".flatMap("))&&t.tokens.add("jsx:list");for(let r of AR(n))Bo(r)||t.tokens.add(`binding:${r}`)}function Rf(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 Pf(e){return e.type==="ternary_expression"||e.type==="conditional_expression"?!0:e.namedChildren.some(Pf)}function CR(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 FR(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 TR(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=or(i,t);o&&_R(o.calleeLeaf,n)}else if(i.type==="variable_declarator")kR(i,n);else if(i.type==="function_declaration"){let o=yc(i);o&&wf(o,n)}for(let o of i.namedChildren)r(o)};return r(e),n}function _R(e,t){/^use[A-Z0-9_]/.test(e)&&(t.hookNames.add(e),!Sf.has(e)&&!oR.has(e)&&t.tokens.add(`hook:${e}`)),Sf.has(e)&&t.tokens.add(`react-hook:${e}`),rR.has(e)&&(t.effectNames.add(e),t.tokens.add(`effect:${e}`)),iR.has(e)&&t.tokens.add(`state-hook:${e}`),NR(e)&&(t.requestNames.add(e),t.tokens.add(`request:${e}`))}function NR(e){if(sR.has(e))return!0;let t=/^use([A-Z0-9_].*)$/.exec(e)?.[1];return t?/(Query|Mutation|Fetch|Resource)$/.test(t):!1}function kR(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=>ni(a)),s=ni(o);s&&(t.stateNames.add(s),t.tokens.add(`state:${s}`))}let i=ni(n);i&&wf(i,t)}function wf(e,t){let n=LR(e);!n||!aR.has(n)||(t.handlerNames.add(e),t.tokens.add(`handler:${e}`),t.tokens.add(`handler-verb:${n}`))}function LR(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 DR(e){return/^[A-Z]/.test(e)||e.includes(".")}function If(e){return e.replace(/^this\./,"").replace(/\$/g,".")}function ni(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 AR(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 Pt(e){return[...e].sort()}function Q0(e){return{capability:(t,n)=>OR(t,n),reactProfiles:(t={})=>Ef(e,t),reactProfilesForFile:t=>hc(e,t),vueProfiles:(t={})=>yf(e,t),vueProfileForFile:t=>gc(e,t),vueTemplateFacts:t=>Go(e,t),vueScriptFacts:t=>Ho(rr(e,t))}}function OR(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 MR(e,t,n={}){let r=Se(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 jR=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function Pe(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 Ne(e,t){for(let n of e.namedChildren)if(n.type===t)return n;return null}function Q(e,t){let n=new Set,r=(i,o)=>{let s=o||t.has(i.type);!s&&jR.has(i.type)&&n.add(i.text);for(let a of i.children)r(a,s)};return r(e.rootNode,!1),n}function Ze(e,t,n,r,i,o,s){return{importedName:i,localName:o,sourcePath:s??Y(e,r,za(t)),kind:"named",used:Re(n,o),usedMembers:[]}}function U(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 wt(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 Fn(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function Tn(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 We(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=Kt(e,i.index,i.index+o.length);for(let a of n(i,s))r.push(a)}return r}function qe(e,t,n,r,i){let o=ir(e,t,i);if(o){let s=n(o);if(s)return s}return r()}function qo(e,t,n,r,i){let o=ir(e,t,i),s=le(t),a=s?n[s]:void 0;return o&&a?a(o):r()}function Ff(e,t,n){return qe(e,t,r=>$R(e,t,r),()=>BR(e,t,n),n)}function BR(e,t,n){return We(n,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(r,i)=>{let o=r[1]?.trim();if(!o)return[];let s=Cf(o).replace(/\.[^.]+$/,"");return[wt(o,s,ko(e,t,o),Re(i,s))]})}function $R(e,t,n){let r=Q(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=Cf(s).replace(/\.[^.]+$/,"");i.push(U(s,a,ko(e,t,s),r))}return i}var GR=new Set([":require",":require-macros",":use"]),vc=String.raw`A-Za-z0-9_$*+!?.<>=-`;function _f(e,t,n){let r=QR(n);if(!r)return[];let i=YR(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=Ue(s.children[0]);if(a){if(GR.has(a)){for(let c of WR(s.children.slice(1)))o.push(...HR(e,c,i));continue}if(a===":import")for(let c of UR(s.children.slice(1)))o.push(c)}}return o}function VR(e){return e.type==="list"&&Ue(e.children[0])==="ns"}function HR(e,t,n){let r=Ka(e,t.namespace),i=t.alias??t.namespace,o=KR(n,i),s=[{importedName:t.namespace,localName:i,sourcePath:r,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||JR(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:XR(n,a),usedMembers:[]});return s}function WR(e){return e.flatMap(t=>Uo(t,null))}function Uo(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:xc(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&Ue(e.children[0])===null?e.children.flatMap(n=>Uo(n,t)):qR(e,t);if(e.type==="list"&&e.children.length>0){let n=Ue(e.children[0]);return n?!n||n.startsWith(":")?[]:e.children.slice(1).flatMap(r=>Uo(r,xc(t,n))):e.children.flatMap(r=>Uo(r,t))}return[]}function qR(e,t){let n=Ue(e.children[0]);if(!n||n.startsWith(":"))return[];let r={namespace:xc(t,n),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=Ue(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){r.alias=Ue(s),i+=1;continue}o===":refer"&&s&&(Ue(s)===":all"?r.referAll=!0:(s.type==="vector"||s.type==="list")&&r.refers.push(...s.children.map(Ue).filter(zR)),i+=1)}return[r]}function UR(e){let t=[];for(let n of e){if(n.type==="atom"){let i=n.text.split(".").pop()??n.text;t.push(wt(i,i,null,!0));continue}if(n.type!=="vector")continue;let r=Ue(n.children[0]);if(r)for(let i of n.children.slice(1)){let o=Ue(i);o&&t.push(wt(`${r}.${o}`,o,null,!0))}}return t}function xc(e,t){return e?`${e}.${t}`:t}function Ue(e){return e?.type==="atom"?e.text:null}function zR(e){return!!(e&&!e.startsWith(":"))}function KR(e,t){let n=new Set,r=new RegExp(`${Ic()}${ce(t)}\\s*/\\s*([${vc}]+)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function JR(e,t){return new RegExp(`${Ic()}${ce(t)}\\s*/`,"m").test(e)}function XR(e,t){return new RegExp(`${Ic()}${ce(t)}(?![${vc}])`,"m").test(e)}function Ic(){return`(?<![${vc}])`}function YR(e,t,n){let r="",i=0;for(;i<e.length;){if(i>=t&&i<n){r+=e[i]===`
116
+ `?`
117
+ `:" ",i+=1;continue}let o=e[i];if(o===";"){let s=jo(e,i);r+=Tf(e.slice(i,s)),i=s;continue}if(o==='"'){let s=Zr(e,i,0).index;r+=Tf(e.slice(i,s)),i=s;continue}r+=o,i+=1}return r}function QR(e){let t=0;for(;t<e.length&&(t=Ec(e,t),!(t>=e.length));){let n=zo(e,t);if(!n){t+=1;continue}if(VR(n.form))return n.form;t=n.index}return null}function zo(e,t){let n=Ec(e,t);if(e.startsWith("#?@",n)||e.startsWith("#?",n))return ZR(e,n);if(e.startsWith("#_",n)){let i=zo(e,n+2);return i?{form:{type:"atom",text:"",start:n,end:i.index},index:i.index}:null}for(;lc(e[n]);)n+=1;let r=e[n];return r?r==="("?bc(e,n,"list",")"):r==="["?bc(e,n,"vector","]"):r==="{"?bc(e,n,"map","}"):r==='"'?{form:{type:"atom",text:"",start:n,end:Zr(e,n,0).index},index:Zr(e,n,0).index}:tP(e,n):null}function ZR(e,t){let n=e.startsWith("#?@",t)?3:2,r=zo(e,t+n);return r?{form:{type:"list",children:r.form.type==="list"||r.form.type==="vector"||r.form.type==="map"?eP(r.form.children):[],start:t,end:r.index},index:r.index}:null}function eP(e){let t=[];for(let n=0;n<e.length;n+=2){let r=Ue(e[n]),i=e[n+1];r?.startsWith(":")&&i&&t.push(i)}return t}function bc(e,t,n,r){let i=[],o=t+1;for(;o<e.length;){if(o=Ec(e,o),e[o]===r)return{form:{type:n,children:i,start:t,end:o+1},index:o+1};let s=zo(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 tP(e,t){let n=t;for(;n<e.length&&!uc(e[n]);)n+=1;return{form:{type:"atom",text:e.slice(t,n),start:t,end:n},index:n}}function Ec(e,t){let n=t;for(;n<e.length;){let r=e[n];if(/\s|,/.test(r)){n+=1;continue}if(r===";"){n=jo(e,n);continue}break}return n}function Tf(e){return e.replace(/[^\r\n]/g," ")}function Nf(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=Kt(n,i.index,i.index+a.length);r.push({importedName:o,localName:s,sourcePath:Lo(e,t,o),kind:s?"namespace":"side-effect",used:s?Re(c,s):!0,usedMembers:s?tr(c,s):[]})}return r}function kf(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:Lo(e,t,o)})}return r}function Lf(e,t,n){return qo(e,t,{csharp:r=>rP(e,t,r),vb:r=>nP(e,t,r)},()=>{let r=Cp(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return We(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[Ze(e,t,o,u,d,p,Y(e,u,qt))]})},n)}function nP(e,t,n){let r=Q(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(U(u,d,Y(e,l,qt),r,c?"namespace":"named"))}return i}function rP(e,t,n){let r=Q(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(U(u,d,Y(e,l,qt),r,a?"namespace":"named"))}return i}var iP=C("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function Df(e,t){return iP.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 Rc(e,t,n){return qe(e,t,r=>sP(e,t,r),()=>oP(e,t,n),n)}function oP(e,t,n){return hP(n).flatMap(r=>SP(e,t,r.clause,r.specifier,r.start,r.end,n))}function sP(e,t,n){let r=aP(e,t,n),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))i.push(...cP(e,t,n,o,r));return i}function aP(e,t,n){let r=Q(n,new Set(["import_statement"]));if(at(t))for(let i of Df(e,t))r.add(i);return r}function cP(e,t,n,r,i){let o=fP(r);if(!o)return[];let s=st(e,t,o),a=Ne(r,"import_clause");return a?lP(n,a,s,i,mP(r.text)):[Fn("*",s)]}function lP(e,t,n,r,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(uP(s.text,n,r,i));else if(s.type==="namespace_import"){let a=dP(e,s,n,r,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...pP(s,n,r,i));return o}function uP(e,t,n,r){return U("default",e,t,n,"default",{isTypeOnly:r})}function dP(e,t,n,r,i){let s=Ne(t,"identifier")?.text??"";if(!s)return null;let a=yP(e,s);return Tn("*",n,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||r.has(s)})}function pP(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(U(c,l,t,n,"named",{isTypeOnly:r||gP(o.text)}))}return i}function fP(e){let t=Ne(e,"string");if(!t)return null;let n=Ne(t,"string_fragment");return n?n.text:null}function mP(e){return/^\s*import\s+type\b/.test(e)}function gP(e){return/^\s*type\b/.test(e.trim())}function yP(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 hP(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 SP(e,t,n,r,i,o,s){let a=st(e,t,r),c=Kt(s,i,o);return n?bP(n).map(u=>({...u,sourcePath:a})).map(u=>{if(u.kind==="namespace"){let d=tr(c,u.localName);return Tn(u.importedName,u.sourcePath,{localName:u.localName,usedMembers:d,used:d.length>0||Re(c,u.localName),isTypeOnly:u.isTypeOnly})}return u.kind==="side-effect"?Fn(u.importedName,u.sourcePath):wt(u.importedName,u.localName??"",u.sourcePath,u.localName?Re(c,u.localName):!1,u.kind,[],{isTypeOnly:u.isTypeOnly})}):[Fn("*",a)]}function bP(e){let t=e.trim(),n=/^type\b/.test(t),r=t.replace(/^type\s+/,""),[i,o]=xP(r),s=[];return i&&s.push(...Af(i,n)),o&&s.push(...Af(o,n)),s}function Af(e,t){let n=e.trim();if(!n)return[];if(n.startsWith("{")){let r=n.slice(1,-1).trim();return r?Pe(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 xP(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 Pc(e,t,n){let r=M(e,t);return r?wP(e,t,r):vP(e,t,n)}function vP(e,t,n){return[...IP(e,t,n),...EP(e,t,n),...RP(e,t,n)]}function IP(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=Pe(s).map(d=>PP(d.trim())).filter(d=>!!d),l=lr(n,o.index),u=lr(n,o.index+o[0].length-1);r.push({kind:"named",sourcePath:st(e,t,a),names:c,startLine:l,endLine:u})}return r}function EP(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=lr(n,o.index),c=lr(n,o.index+o[0].length-1);r.push({kind:"star-as",sourcePath:st(e,t,s),names:o[1]?[o[1]]:[],startLine:a,endLine:c})}return r}function RP(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=lr(n,o.index),c=lr(n,o.index+o[0].length-1);r.push({kind:"star",sourcePath:st(e,t,s),names:[],startLine:a,endLine:c})}return r}function PP(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 lr(e,t){let n=0;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function wP(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("export_statement")){let o=CP(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=FP(i,o,s,a);r.push(c)}return r}function CP(e,t,n){let r=Ne(n,"string");if(!r)return;let i=Ne(r,"string_fragment");if(i)return st(e,t,i.text)}function FP(e,t,n,r){let i=Ne(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=Ne(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 Of(e,t,n){return qo(e,t,{java:r=>TP(e,t,r),kotlin:r=>_P(e,t,r),scala:r=>NP(e,t,r)},()=>We(n,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(r,i)=>{let o=r[1]?.trim();return o?kP(e,t,o,i):[]}),n)}function TP(e,t,n){let r=Q(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(Tn("*",Y(e,l,_e)));continue}let u=l.split(".").pop()??l;i.push(U(u,u,Y(e,l,_e),r))}return i}function _P(e,t,n){let r=Q(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(Tn("*",Y(e,s.text,_e)));continue}let l=s.text,u=l.split(".").pop()??l,p=c?.namedChild(0)?.text??u;i.push(U(u,p,Y(e,l,_e),r))}return i}function NP(e,t,n){let r=Q(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(Tn("*",Y(e,c,_e)));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 m=p.text,y=f?.text??m;if(m==="_")continue;i.push(U(m,y,Y(e,`${c}.${m}`,_e),r))}else if(d.type==="identifier"){let p=d.text;i.push(U(p,p,Y(e,`${c}.${p}`,_e),r))}continue}let l=a[a.length-1]?.text??c,u=a.slice(0,-1).map(d=>d.text).join(".")||c;i.push(U(l,l,Y(e,u&&a.length>1?`${u}.${l}`:c,_e),r))}return i}function kP(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 Pe(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[Ze(e,t,r,p,u,d)]})}return[Ze(e,t,r,n,n.split(".").pop()??n,n.split(".").pop()??n)]}function jf(e,t,n){return qe(e,t,r=>LP(e,t,r),()=>We(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?Pe(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[Ze(e,t,i,u,d,p,Y(e,u.replace(/\\/g,"."),Pn))]}):[]}),n)}function LP(e,t,n){let r=Q(n,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(U(a,c,Y(e,s.replace(/\\/g,"."),Pn),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}=Mf(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}=Mf(c,"");l&&o(d,l,u)}}return i}function Mf(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 $f(e,t,n){return qe(e,t,r=>DP(e,t,r),()=>OP(n).flatMap(r=>jP(e,t,r,n)),n)}function DP(e,t,n){let r=Q(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=Bf(s);if(!a)continue;let c=er(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=AP(s);if(a===null)continue;let c=er(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=Bf(u);d&&i.push({importedName:d.qualifiedName,localName:d.localName,sourcePath:c,kind:"named",used:r.has(d.localName),usedMembers:[]})}}return i}function Bf(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 AP(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=Ne(e,"import_prefix")?.text??"",n=Ne(e,"dotted_name")?.text??"";return`${t}${n}`}return null}function OP(e){let t=e.split(`
118
+ `),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=ec(o);for(;i+1<t.length&&(u>0||c.trimEnd().endsWith("\\"));){i++;let p=t[i];c+=`
119
+ ${p}`,l+=1+p.length,u+=ec(p),r+=p.length+1}let d=MP(c);d&&n.push({...d,start:a,end:l})}return n}function MP(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 jP(e,t,n,r){let i=Kt(r,n.start,n.end),o=n.clause.replace(/\n/g," ").trim();if(n.kind==="import")return Pe(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(),m=er(e,t,p),y=tr(i,f);return[{importedName:p,localName:f,sourcePath:m,kind:"namespace",used:Re(i,f)||y.length>0,usedMembers:y}]});let s=n.module?er(e,t,n.module):null,a=[];for(let c of Pe(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:Re(i,p),usedMembers:[]})}return a}import{basename as BP}from"path";function Gf(e,t,n){return qe(e,t,r=>GP(e,t,r),()=>$P(e,t,n),n)}function $P(e,t,n){return We(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"?No(e,t,s):null;if(a){let c=Vf(s);return[wt(c,c,a,Re(i,c))]}return[Fn(s,a)]})}function GP(e,t,n){let r=Q(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"?No(e,t,d):null;if(p){let f=Vf(d);i.push(U(f,f,p,r))}else i.push(Fn(d,p))}return i}function Vf(e){return $o(BP(e).replace(/\.[^.]+$/,""),/_/)}function Hf(e,t,n){return qe(e,t,r=>VP(e,t,r),()=>We(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?HP(e,t,o,i):[]}),n)}function VP(e,t,n){let r=Q(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 ri(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=It(e,t,a.qualifiedName)??It(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(U(a.importedName,a.localName,c,r))}}return i}function ri(e,t){switch(e.type){case"identifier":case"super":case"crate":{let n=e.text;return[{qualifiedName:Ko(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:Ko(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=Ko(t,n.text),o=[];for(let s of r.namedChildren)o.push(...ri(s,i));return o}case"use_list":{let n=[];for(let r of e.namedChildren)n.push(...ri(r,t));return n}case"use_as_clause":{let n=e.namedChild(0),r=e.namedChild(1);if(!n||!r)return[];let i=ri(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:Ko(t,`${r}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Ko(e,t){return e?t?`${e}::${t}`:e:t}function HP(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 Pe(d).flatMap(p=>{let f=p.trim();if(!f)return[];if(f==="self"){let v=u.split("::").filter(Boolean).pop();return v?[Ze(e,t,r,u,v,v)]:[]}let[m,y]=f.split(/\s+as\s+/),g=m?.trim();if(!g)return[];let S=(y??g.split("::").pop()??g).trim(),h=`${u}::${g}`.replace(/::::/g,"::");return[Ze(e,t,r,h,g.split("::").pop()??g,S,It(e,t,u))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=It(e,t,a)??It(e,t,a.split("::").slice(0,-1).join("::"));return[Ze(e,t,r,a,a.split("::").pop()??a,c,l)]}function Wf(e,t,n){let r=M(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(...UP(e,t,s))}return i}function WP(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("use_declaration")){if(!qP(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of ri(o,""))s.importedName&&r.push(wc(e,t,s.qualifiedName))}return r}function qP(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function UP(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 Pe(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[wc(e,t,l)]})}return[wc(e,t,r)]}function wc(e,t,n){return{specifier:n,sourcePath:It(e,t,n)??It(e,t,n.split("::").slice(0,-1).join("::"))}}function Xt({language:e,extensions:t,imports:n,parseImports:r}){return{language:e,extensions:t,capabilities:{imports:n},parseImports:r}}function qf(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 zP={language:"javascript",extensions:Rn,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:Rc,parseReExports:Pc},KP=Xt({language:"python",extensions:wo,imports:"ast-with-regex-fallback",parseImports:$f}),JP=Xt({language:"jvm",extensions:_e,imports:"ast-dispatch-with-regex-fallback",parseImports:Of}),XP={language:"rust",extensions:Co,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:Hf,parseExports:Wf},YP=Xt({language:"ruby",extensions:Fo,imports:"ast-with-regex-fallback",parseImports:Gf}),QP=Xt({language:"c/cpp",extensions:To,imports:"ast-with-regex-fallback",parseImports:Ff}),ZP=Xt({language:"dotnet",extensions:qt,imports:"ast-dispatch-with-regex-fallback",parseImports:Lf}),ew={language:"dart",extensions:_o,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:Nf,parseExports:kf},tw=Xt({language:"php",extensions:Pn,imports:"ast-with-regex-fallback",parseImports:jf}),nw=Xt({language:"clojure",extensions:Zn,imports:"regex-only",parseImports:_f}),Uf=[zP,KP,JP,XP,YP,QP,ZP,ew,tw,nw];function ii(e){return qf(Uf,e)}function T$(e){return Uf.find(n=>n.language===e)?.capabilities??null}var Cc={clearGroups:["whole-project","source-file"]},rw=C("source-imports",Cc),iw=C("source-exports",Cc),ow=C("source-reexports",Cc),zf=ae({kind:"source-imports",invalidation:ne("source-imports"),serialize:sw,deserialize:aw}),Kf=ae({kind:"source-reexports",invalidation:ne("source-reexports"),serialize:cw,deserialize:lw});function ct(e,t){let n=X(t);return ow.get(e,n,()=>{let r=ii(n);if(!r?.parseReExports)return[];let i=F(e,n);if(!i)return[];let o=fe(e,n,i),s=Ya(e),a=Kf.read(e,n,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=r.parseReExports(e,n,i);return Kf.write(e,n,o,{resolutionFingerprint:s,reExports:c}),c})}function ue(e,t){let n=X(t);return rw.get(e,n,()=>{let r=ii(n);if(!r)return[];let i=F(e,n);return i?Jf(e,n,i,r):[]})}function Jo(e,t){let n=X(t),r=ii(n);if(!r)return[];let i;try{i=Gr(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(o){if(Vt(o))return[];throw o}return Jf(e,n,i,r)}function Jf(e,t,n,r){let i=fe(e,t,n),o=Ya(e),s=zf.read(e,t,i);if(s?.resolutionFingerprint===o)return s.imports;let a=r.parseImports(e,t,n);return zf.write(e,t,i,{parserVersion:2,resolutionFingerprint:o,imports:a}),a}function B$(e,t,n){let r=ue(e,t).filter(i=>i.kind==="named"&&i.isTypeOnly!==!0&&i.localName===n&&i.sourcePath!==null);return r.length===1?r[0]:null}function $$(e,t){let n=X(t);return iw.get(e,n,()=>{let r=ii(n);if(!r?.parseExports)return[];let i=F(e,n);return i?r.parseExports(e,n,i):[]})}function sw(e){return JSON.stringify(e)}function aw(e){try{let t=JSON.parse(e);return!Ut(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 cw(e){return JSON.stringify(e)}function lw(e){try{let t=JSON.parse(e);return!Ut(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}var Xo=dp({kind:"file-dependency-graph",invalidation:ne("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:gw}),uw=C("file-dep-graph",{clearGroups:["whole-project"]});function J$(e,t,n){if(n.length===0)return[];let r=new Set(n),i=ur(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 ur(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",o=si(t,r,i);return uw.get(e,o,()=>{let s=new Set(ge(e,{includeIgnored:!1})),a=St(e),c=0,l=0,u=null,d=!1,p=0,f=0,m=null;return J("file-dep-graph.product",()=>{if(a){let h=Xo.read(e,o,a);if(h){d=!0,m=h.construction;let v=Yf(h);return c=h.sourceFileCount,l=h.sourceEdgeCount,p=h.scipEdgeCount,f=v.size,u=h.sourceDependencyFingerprint,v}}let y=i==="none"?{files:[],edges:[],fingerprint:K("no-source-dependency-fallback")}:J("file-dep-graph.source-imports",()=>{let h=fw(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})),g=new Map,S=(h,v)=>oi(e,g,s,h,v);J("file-dep-graph.scip-edges",()=>{for(let h of Sw(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=g.size,a&&(m="full",Xo.write(e,o,a,{version:2,construction:"full",sourceDependencyFingerprint:y.fingerprint,sourceFileCount:y.files.length,sourceEdgeCount:y.edges.length,scipEdgeCount:p,edgeCount:Qf(g),graph:Xf(g)})),g},()=>({scope:t??null,available:a!==null,hit:d,construction:m,files:c,sourceEdges:l,sourceEdgeMode:i,scipEdges:p,graphFiles:f,sourceDependencyFingerprint:u}))})}function X$(e){return dw(e,"none")}function Y$(e,t="imports-only"){let n=si(void 0,"all-references",t),r=St(e);if(!r)return null;let i=Xo.read(e,n,r);return i?{cacheKey:n,sourceEdges:t,graph:Yf(i)}:null}function dw(e,t){let n=si(void 0,"all-references",t),r=ur(e,void 0,{sourceEdges:t});return{cacheKey:n,sourceEdges:t,graph:r}}function Q$(e,t,n,r){let i=t.sourceEdges??"imports-only",o=St(e);if(!o)return!1;let s=r??pw(e,t,n);if(!s)return!1;let a=new Set(ge(e,{includeIgnored:!1})),c=si(void 0,"all-references",i);return Xo.write(e,c,o,{version:2,construction:"carried",sourceDependencyFingerprint:null,sourceFileCount:a.size,sourceEdgeCount:null,scipEdgeCount:null,edgeCount:Qf(s),graph:Xf(s)}),!0}function pw(e,t,n,r=[]){let i=t.sourceEdges??"imports-only",o=si(void 0,"all-references",i);if(t.cacheKey!==o)return null;let s=J("file-dep-graph.carry.indexed-files",()=>new Set(ge(e,{includeIgnored:!1}))),a=new Set(n),c=new Map;J("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)oi(e,c,s,u,p)});let l=J("file-dep-graph.carry.scip-edges",()=>bw(e,a,"all-references"));for(let u of l)oi(e,c,s,u.from_file,u.to_file);return J("file-dep-graph.carry.source-edges",()=>{for(let u of a)if(s.has(u)){if(i!=="none")for(let d of Jo(e,u))d.sourcePath&&oi(e,c,s,u,d.sourcePath);if(i==="imports-and-reexports")for(let d of ct(e,u))d.sourcePath&&oi(e,c,s,u,d.sourcePath)}}),c}async function Z$(e,t={}){let n=ge(e,{includeIgnored:!1}),r=Math.max(1,Math.floor(t.batchSize??64)),i=t.collectGarbage??En,o=0;for(let s=0;s<n.length;s+=r){for(let a of n.slice(s,s+r))Jo(e,a),ct(e,a),o+=1;t.onBatch?.({files:o,total:n.length}),i(),await t.yieldToEventLoop?.()}return{files:o}}function fw(e,t,n,r){let i=[],o=[];for(let s of t)if(!(n&&!s.includes(n))){i.push(s);for(let a of Jo(e,s))a.sourcePath&&o.push({fromFile:s,toFile:a.sourcePath});if(r==="imports-and-reexports")for(let a of ct(e,s))a.sourcePath&&o.push({fromFile:s,toFile:a.sourcePath})}return{files:i,edges:o,fingerprint:mw(i,o)}}function mw(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return K(JSON.stringify({files:e,edges:n}))}function si(e,t,n){return`edge-mode-v4:${t}:${n}:${e??"<all>"}`}function Xf(e){return[...e].map(([t,n])=>[t,[...n].sort()]).sort(([t],[n])=>t.localeCompare(n))}function Yf(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function gw(e){let t=JSON.parse(e);return yw(t)?t:null}function yw(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(hw)}function Qf(e){let t=0;for(let n of e.values())t+=n.size;return t}function hw(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function Sw(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
120
+ d1.relative_path AS from_file,
121
+ d2.relative_path AS to_file
122
+ FROM mentions m
123
+ JOIN chunks c ON m.chunk_id = c.id
124
+ JOIN documents d1 ON c.document_id = d1.id
125
+ JOIN global_symbols gs ON m.symbol_id = gs.id
126
+ JOIN (
127
+ SELECT m2.symbol_id, c2.document_id
128
+ FROM mentions m2
129
+ JOIN chunks c2 ON m2.chunk_id = c2.id
130
+ WHERE m2.role = 1
131
+ GROUP BY m2.symbol_id
132
+ ) sym_def ON sym_def.symbol_id = gs.id
133
+ JOIN documents d2 ON sym_def.document_id = d2.id
134
+ WHERE d1.id != d2.id
135
+ ${o}
136
+ ${e.pathExclusionsFor("d1","d2")}
137
+ ${r}`,...i)}function bw(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
138
+ d1.relative_path AS from_file,
139
+ d2.relative_path AS to_file
140
+ FROM documents d1
141
+ CROSS JOIN chunks c
142
+ CROSS JOIN mentions m
143
+ CROSS JOIN global_symbols gs
144
+ CROSS JOIN chunks c2
145
+ CROSS JOIN documents d2
146
+ WHERE d1.relative_path IN (${c})
147
+ AND c.document_id = d1.id
148
+ AND m.chunk_id = c.id
149
+ AND gs.id = m.symbol_id
150
+ AND c2.id = (
151
+ SELECT m2.chunk_id
152
+ FROM mentions m2
153
+ WHERE m2.symbol_id = gs.id AND m2.role = 1
154
+ ORDER BY m2.chunk_id
155
+ LIMIT 1
156
+ )
157
+ AND d2.id = c2.document_id
158
+ AND d1.id != d2.id
159
+ ${i}
160
+ ${e.pathExclusionsFor("d1","d2")}`,...a))}return o}function oi(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 xw={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function ke(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=vw(i);return{scheme:n,manager:r,packageName:o,version:s,descriptors:c,raw:e}}function be(e){let t=ke(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 vw(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||Zf(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&&!Zf(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=xw[i];o&&t.push({name:r,suffix:o}),n+=1}}return t}function Zf(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function Yt(e){let t=ke(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=Iw(i);o&&r.push(o)}return r.join(":")}function Iw(e){let t=e.suffix==="namespace"?Ew(e.name):e.name;return t?e.suffix==="method"?`${t}()`:t:""}function Ew(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 xe(e){let t=ke(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 tG(e){let t=ke(e);if("kind"in t&&t.kind==="local")return t.id;let n=t.descriptors,r=n[n.length-1];if(!r)return"";let i=n[n.length-2];return i&&i.suffix==="type"?`${i.name} ${r.name}`:r.name}function nG(e){let t=ke(e);if("kind"in t&&t.kind==="local")return null;let n=t.descriptors,r=n[n.length-2];return r&&r.suffix==="type"?r.name:null}function _n(e){let t=ke(e);if("kind"in t&&t.kind==="local")return null;let n=t;return n.descriptors[n.descriptors.length-1]?.suffix??null}function Fc(e){return e.endsWith("().")||_n(e)==="method"}function dr(e){let t=_n(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 em(e){return _n(e)==="namespace"}var Rw=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function rG(e){return Rw.test(e)}var Pw=new Set(["test","tests","_tests"]);function iG(e){let t=ke(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&&Pw.has(r.name))return!0}return!1}function oG(e,t){let n=ke(e),r=ke(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 sG(e,t){let n=ke(e),r=ke(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 Yo(e){return{forFile(t,n){return tm(e,t,n)},forFiles(t,n){let r=new Map;for(let i of t)r.set(i,tm(e,i,n));return r}}}function tm(e,t,n){let r={file:t},i=n.facts||n.identifiers;if(n.text&&(r.text=F(e,t)),n.lines&&(r.lines=Wr(e,t)),n.ast&&(r.ast=M(e,t)),n.imports&&(r.imports=ue(e,t)),n.reexports&&(r.reexports=ct(e,t)),i){let o=pc(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 Qt(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
161
+ FROM global_symbols gs
162
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
163
+ JOIN documents d ON der.document_id = d.id
164
+ WHERE ${t.where}
165
+ ${e.pathExclusionsFor("d")}
166
+ ${rm(t.orderBy)}
167
+ ${im(t.limit)}`,...t.params??[])}function Nn(e,t){return e.all(`SELECT
168
+ gs.id,
169
+ gs.symbol,
170
+ c.document_id,
171
+ MIN(c.start_line) AS start_line,
172
+ 0 AS start_char,
173
+ MAX(c.end_line) AS end_line,
174
+ 0 AS end_char,
175
+ d.relative_path,
176
+ gs.display_name,
177
+ gs.documentation
178
+ FROM global_symbols gs
179
+ JOIN mentions m ON m.symbol_id = gs.id
180
+ JOIN chunks c ON m.chunk_id = c.id
181
+ JOIN documents d ON c.document_id = d.id
182
+ WHERE m.role = 1
183
+ AND ${t.where}
184
+ ${e.pathExclusionsFor("d")}
185
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation
186
+ ${rm(t.orderBy)}
187
+ ${im(t.limit)}`,...t.params??[])}function rm(e){return e?`ORDER BY ${e}`:""}function im(e){return typeof e=="number"?`LIMIT ${e}`:""}function Tc(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 _c(e){if(!e)return null;let t=nm(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(nm(r)??r).replace(/\n/g," ")}function nm(e){return/^```(?:\w+)?\s*\n?([\s\S]*?)\n?```/.exec(e.trimStart())?.[1]?.trim()||null}function ww(e,t={}){if(be(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 Ct(e,t,n={}){let r=new Map;for(let o of t)e.length>0&&!ww(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 NG(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 Cw=C("file-definitions",{clearGroups:["definition-catalog"]}),Fw=ot("scoped-matched-definitions",{clearGroups:["definition-catalog"]}),Tw=C("file-function-like-definitions",{clearGroups:["definition-catalog"]}),om=new WeakMap;function B(e,t,n={},r){return Hr(t),n.includeClassMemberFallbacks?Nc(e,t,void 0,{includeClassMemberFallbacks:!0},r):Cw.get(e,t,()=>{let i=lt(r,"evidence-read",()=>lm(e,t));if(i)return i;let o=Nc(e,t,void 0,n,r);return lt(r,"evidence-write",()=>{let s=St(e),a=Yo(e).forFile(t,{text:!0}).text;s&&a&&cm.write(e,t,fe(e,t,a),{projectFingerprint:s,definitions:o.map(c=>({...c}))})}),o})}function _w(e,t){return Tw.get(e,t,()=>{let n=lm(e,t);return n?n.filter(r=>r.isFunctionLike):Nc(e,t,r=>r.isFunctionLike)})}var cm=ae({kind:"file-definitions",invalidation:ne("file-definitions"),serialize:Nw,deserialize:kw});function lm(e,t){let n=St(e);if(!n)return null;let r=Yo(e).forFile(t,{text:!0}).text;if(!r)return null;let i=cm.read(e,t,fe(e,t,r));return i?Lw(i,n,t):null}function Nw(e){return JSON.stringify(e)}function kw(e){try{let t=JSON.parse(e);return!Ut(t)||typeof t.projectFingerprint!="string"||!Array.isArray(t.definitions)?null:{projectFingerprint:t.projectFingerprint,definitions:t.definitions}}catch{return null}}function Lw(e,t,n){if(e.projectFingerprint!==t)return null;let r=[];for(let i of e.definitions){let o=Dw(i,n);if(!o)return null;r.push(o)}return r}function Dw(e,t){return!Ut(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 Nc(e,t,n,r={},i){let o=lt(i,"primary-rows",()=>Aw(e,t)),s=lt(i,"fallback-rows",()=>Ow(e,t)),a=lt(i,"merge-rows",()=>Ct(o,s,{sort:!0,includeClassMemberFallbacks:r.includeClassMemberFallbacks}).map(kc));return n&&(a=a.filter(n)),lt(i,"range-correction",()=>Lc(e,t,a,i,r.rangeCorrectionEvidence))}function lt(e,t,n){return e?e(t,n):n()}function Aw(e,t){return e.all(`SELECT
188
+ gs.id,
189
+ gs.symbol,
190
+ der.document_id,
191
+ der.start_line,
192
+ der.start_char,
193
+ der.end_line,
194
+ der.end_char,
195
+ d.relative_path,
196
+ gs.display_name,
197
+ gs.kind,
198
+ gs.documentation,
199
+ gs.enclosing_symbol
200
+ FROM global_symbols gs
201
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
202
+ JOIN documents d ON der.document_id = d.id
203
+ WHERE d.relative_path = ?
204
+ ${e.symbolNoiseFor("gs")}
205
+ ORDER BY der.start_line, der.end_line`,t)}function Ow(e,t){return e.all(`SELECT
206
+ gs.id,
207
+ gs.symbol,
208
+ c.document_id,
209
+ MIN(c.start_line) AS start_line,
210
+ 0 AS start_char,
211
+ MAX(c.end_line) AS end_line,
212
+ 0 AS end_char,
213
+ d.relative_path,
214
+ gs.display_name,
215
+ gs.kind,
216
+ gs.documentation,
217
+ gs.enclosing_symbol
218
+ FROM global_symbols gs
219
+ JOIN mentions m ON m.symbol_id = gs.id
220
+ JOIN chunks c ON m.chunk_id = c.id
221
+ JOIN documents d ON c.document_id = d.id
222
+ WHERE d.relative_path = ?
223
+ AND m.role = 1
224
+ ${e.symbolNoiseFor("gs")}
225
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
226
+ ORDER BY start_line, end_line`,t)}function kc(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:xe(e.symbol),parentTypeName:be(e.symbol),isFunctionLike:dr(e.symbol),isTypeLike:_n(e.symbol)==="type",kind:e.kind??null,documentation:e.documentation??null,enclosingSymbol:e.enclosing_symbol??null}}function kG(e,t={}){return Mw(e,t.scope)}function Mw(e,t){return ge(e,{scope:t,includeIgnored:!1}).flatMap(n=>B(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function LG(e,t){return ge(e,{scope:t,includeIgnored:!1}).flatMap(n=>_w(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function DG(e,t){let n=Fw.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=sm(jw(e,t.scope,t.sqlPrefilter)),a=sm(Bw(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=Ct(s.get(u)??[],a.get(u)??[],{sort:!0}).filter(p=>t.symbolMatches(p.symbol));d.length!==0&&l.push(...Lc(e,u,d.map(kc)))}return r.set(i,l),[...l]}function jw(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${um("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
227
+ gs.id,
228
+ gs.symbol,
229
+ der.document_id,
230
+ der.start_line,
231
+ der.start_char,
232
+ der.end_line,
233
+ der.end_char,
234
+ d.relative_path,
235
+ gs.display_name,
236
+ gs.kind,
237
+ gs.documentation,
238
+ gs.enclosing_symbol
239
+ FROM global_symbols gs
240
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
241
+ JOIN documents d ON der.document_id = d.id
242
+ WHERE 1 = 1
243
+ ${e.pathExclusionsFor("d")}
244
+ ${r}
245
+ ${i}
246
+ ${e.symbolNoiseFor("gs")}
247
+ ORDER BY d.relative_path, der.start_line, der.end_line`,...o)}function Bw(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${um("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
248
+ gs.id,
249
+ gs.symbol,
250
+ c.document_id,
251
+ MIN(c.start_line) AS start_line,
252
+ 0 AS start_char,
253
+ MAX(c.end_line) AS end_line,
254
+ 0 AS end_char,
255
+ d.relative_path,
256
+ gs.display_name,
257
+ gs.kind,
258
+ gs.documentation,
259
+ gs.enclosing_symbol
260
+ FROM global_symbols gs
261
+ JOIN mentions m ON m.symbol_id = gs.id
262
+ JOIN chunks c ON m.chunk_id = c.id
263
+ JOIN documents d ON c.document_id = d.id
264
+ WHERE m.role = 1
265
+ AND NOT EXISTS (
266
+ SELECT 1
267
+ FROM defn_enclosing_ranges existing_der
268
+ WHERE existing_der.symbol_id = gs.id
269
+ )
270
+ ${e.pathExclusionsFor("d")}
271
+ ${r}
272
+ ${i}
273
+ ${e.symbolNoiseFor("gs")}
274
+ GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
275
+ ORDER BY d.relative_path, start_line, end_line`,...o)}function $w(e){return`(${e}.symbol LIKE '%().' OR ${e}.symbol LIKE '%()')`}function um(e,t){return t==="callable"?$w(e):Gw(e)}function Gw(e){return`(${e}.symbol LIKE '%.' OR ${e}.symbol LIKE '%()')`}function sm(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 AG(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:Yt(i.symbol),signature:Tc(_c(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function Vw(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 pr(e,t){let n=om.get(e);return n||(n=Vw(e),om.set(e,n)),n.get(t)??null}function Qo(e,t){let n=B(e,t.relative_path).find(r=>r.symbolId===t.id)??(be(t.symbol)===null||!dr(t.symbol)?void 0:Lc(e,t.relative_path,[kc(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 Lc(e,t,n,r,i){let o=lt(r,"range-correction.source-text",()=>i?i.source:Yo(e).forFile(t,{text:!0}).text),s=lt(r,"range-correction.callable-sites",()=>i?i.callables:ei(e,t));return s?lt(r,"range-correction.ast-correction",()=>Kw(n,s,o)):o?lt(r,"range-correction.regex-fallback",()=>Hw(n,o)):n}function Hw(e,t){let n=t.split(/\r?\n/),r=Ww(e,n),i=qw(e,r),o=Uw(i,n);return zw(e,o)}function Ww(e,t){let n=e.some(i=>Zo(i.symbol))?tC(t):null,r=new Map;for(let i of e)r.set(i.symbolId,eC(t,n,i));return r}function qw(e,t){return e.filter(n=>Zo(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 Uw(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:nC(t,i.definition,i.startLine,s)})}return n}function zw(e,t){return e.map(n=>{let r=t.get(n.symbolId);return r?{...n,startLine:r.startLine,endLine:r.endLine}:n})}function Kw(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(!Zw(i)||!i.leaf)return am(i,n);let o=r.get(i.leaf);if(!o||o.length===0)return am(i,n);let s=n?Jw(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 Jw(e,t,n){let r=Xw(e.symbol);if(!r)return null;let i=n.split(/\r?\n/),o=new RegExp(`\\b${ce(r)}\\b`);for(let s of t){let a=Yw(i,s.startLine);if(a&&o.test(a))return s}return null}function Xw(e){return e.match(/\/impl#\[([^\]]+)\]/)?.[1]??null}function Yw(e,t){for(let n=t;n>=0;n-=1){let r=e[n]?.trim()??"";if(r){if(/^impl\b/.test(r))return Qw(e,n,t);if(/^(?:struct|enum|trait|mod)\b/.test(r))return null}}return null}function Qw(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 Zw(e){return Zo(e.symbol)?!0:_n(e.symbol)==="term"&&be(e.symbol)===null}function am(e,t){if(!t||!e.leaf||_n(e.symbol)!=="term"||be(e.symbol)!==null)return e;let n=ce(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 eC(e,t,n){if(!Zo(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 tC(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 nC(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=rC(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 rC(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 Zo(e){return e.includes("().")}function OG(e){let t=ke(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 iC=C("symbol-resolution",{clearGroups:[]});function qG(e,t){return oC(e,t).match}function oC(e,t){return iC.get(e,t,()=>{let n=fm(e,t.trim()).filter(s=>!e.isIgnored(s.relative_path));if(n.length>0)return fr(e,n);let r=fC(e,t);if(r&&!e.isIgnored(r.relative_path))return fr(e,[r]);let i=sC(e,t);if(i.length>0)return fr(e,i);let o=aC(e,t);return o.length>0?fr(e,o):dC(e,t)})}function sC(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=Qt(e,{where:s,params:a,orderBy:"d.relative_path, der.start_line",limit:200}),l=c.length>0?[]:Nn(e,{where:s,params:a,orderBy:"d.relative_path, start_line",limit:200}),u=Ct(c,l).filter(d=>!e.isIgnored(d.relative_path)).filter(d=>Yt(d.symbol).replace(/\(\)$/u,"")===n);return[...new Map(u.map(d=>[`${d.symbol}\0${d.relative_path}`,d])).values()]}function aC(e,t){let n=es(t),r=Dc(n);if(!r)return[];let i=`%${r.path}%`,o=r.leaf;return cC(e,i,o,n)}function cC(e,t,n,r){let i=Ct([],[...lC(e,t,n),...uC(e,t,n)]).filter(o=>!e.isIgnored(o.relative_path)).filter(o=>mr(o,r)>1);return i.sort((o,s)=>mr(s,r)-mr(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 lC(e,t,n){return Qt(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function uC(e,t,n){return Nn(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function dC(e,t){let n=es(t),r=bC(t),i=hC(e,r),o=xC(i,t,n).filter(a=>!e.isIgnored(a.relative_path));if(o.length>0)return fr(e,o);let s=[];for(let a of i){if(e.isIgnored(a.relative_path))continue;let c=SC(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)),fr(e,s.map(a=>a.row))}function fr(e,t){let n=t.map(i=>Qo(e,i)),r=n[0]??null;return{match:r,candidates:r?pC(n,r):[],total:n.length}}function pC(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:Yt(i.symbol),relativePath:i.relativePath,startLine:i.startLine}),r.length>=5))break}return r}function fC(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/);if(!n)return;let[,r,i,o]=n,s=lp(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 mC(e,s,a,c)??gC(e,s,a,c)}function mC(e,t,n,r){return Qt(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 gC(e,t,n,r){return Nn(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 UG(e,t){let n=fm(e,t).find(r=>!e.isIgnored(r.relative_path));return n?Qo(e,n):null}function fm(e,t){let n=Qt(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, der.start_line"}),r=n.length>0?[]:Nn(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, start_line"});return Ct(n,r)}function ai(e,t){if("symbol"in t&&"relativePath"in t)return t;let n=yC(e,t.symbolId)[0];return n?Qo(e,n):null}function yC(e,t){let n=Qt(e,{where:"gs.id = ?",params:[t],orderBy:"der.start_line, der.end_line"}),r=Nn(e,{where:"gs.id = ?",params:[t],orderBy:"start_line, end_line"});return Ct(n,r)}function hC(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(`
276
+ AND `),o=Qt(e,{where:i,params:r,limit:200}),s=Nn(e,{where:i,params:r,limit:200});return Ct(o,s)}function SC(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=Yt(e.symbol),p=xe(e.symbol),f=e.display_name??"",m=e.symbol.toLowerCase(),y=d.toLowerCase(),g=p.toLowerCase(),S=f.toLowerCase(),h=e.relative_path.toLowerCase(),v=/[/:.]/.test(n),E=Dc(n),x=E?.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),(m===a||m===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),g===l&&(b+=825),(`${g}()`===a||`${g}()`===c)&&(b+=820),(y.endsWith(`:${c}`)||y.endsWith(`:${l}`)||y.endsWith(`:${l}()`))&&(b+=800),m.includes(c)&&(b+=120),y.includes(c)&&(b+=140),h.includes(c)&&(b+=140),S.includes(c)&&(b+=110),r.every(I=>{let P=I.toLowerCase();return m.includes(P)||y.includes(P)||h.includes(P)||S.includes(P)})&&(b+=100+r.length*15),E&&h.includes(E.path.toLowerCase())&&(b+=360,x&&(g===x||`${g}()`===x||`${g}()`==`${x}()`)&&(b+=700),Fc(e.symbol)&&(b+=180)),dr(e.symbol)&&g===l&&(b+=60),!v&&em(e.symbol)&&(b-=160),b-=Math.min(50,Math.max(0,e.end_line-e.start_line)),b}function Dc(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 es(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function bC(e){let t=es(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 xC(e,t,n){let r=t.trim(),i=e.filter(a=>{let c=Yt(a.symbol),l=xe(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||mr(a,n)>1||a.relative_path===r});if(i.length===0)return[];let o=n.replace(/\(\)$/u,""),s=i.filter(a=>xe(a.symbol)===o);if(s.length>0){s.sort((c,l)=>dm(c,l,n));let a=s.filter(c=>dr(c.symbol));return a.length>0?a:s}return i.sort((a,c)=>dm(a,c,n)),i}function dm(e,t,n){return mr(t,n)-mr(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 mr(e,t){let n=Dc(t);if(!n)return 0;let r=e.relative_path.toLowerCase(),i=xe(e.symbol).toLowerCase(),o=n.path.toLowerCase(),s=n.leaf.toLowerCase();return r.includes(o)?i!==s?1:Fc(e.symbol)?be(e.symbol)===null?5:4:be(e.symbol)===null?3:2:0}function zG(e,t,n=5){let r=pm(t);if(!r)return[];let i=Qt(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=Yt(s.symbol),c=xe(s.symbol),l=s.display_name??c,u=[a,c,l].filter(f=>f.trim().length>0),d=Math.min(...u.map(f=>vC(pm(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 pm(e){return es(e).toLowerCase().replace(/[^a-z0-9_]+/g,"")}function vC(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 n1(e,t){let n=mm(e);return n?t.filter(r=>mm(r.file)===n):t}function r1(e,t,n,r,i){let o=ue(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 g of d)if(mn(g,y.file))return y;if(u==="this"||u==="self"||u==="cls"){let y=n.filter(g=>g.file===t&&be(g.symbol)!==null);if(y.length===1)return y[0]}let p=IC(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)),m=n.filter(y=>p.has(be(y.symbol)??"")&&(y.file===t||[...f].some(g=>mn(g,y.file))));return m.length===1?m[0]:null}let s=n.filter(u=>be(u.symbol)===null),a=s.find(u=>u.file===t);if(a)return a;let c=xe(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&&mn(p.sourcePath,d.file)));return u.length===1?u[0]:null}return s.length===1?s[0]:null}function IC(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 mm(e){let t=le(e);return t?t==="typescript"||t==="tsx"||t==="javascript"?"javascript-family":t:null}var EC=ot("global-leaf-index",{clearGroups:["whole-project"]});function Ac(e){return EC.get(e,()=>{let t=e.all(`SELECT gs.id, gs.symbol,
277
+ COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
278
+ FROM global_symbols gs
279
+ LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
280
+ LEFT JOIN documents der_doc ON der_doc.id = der.document_id
281
+ LEFT JOIN (
282
+ SELECT m.symbol_id, MIN(d.relative_path) AS relative_path
283
+ FROM mentions m
284
+ JOIN chunks c ON m.chunk_id = c.id
285
+ JOIN documents d ON c.document_id = d.id
286
+ WHERE m.role = 1
287
+ GROUP BY m.symbol_id
288
+ ) mention_doc ON mention_doc.symbol_id = gs.id
289
+ WHERE 1 = 1
290
+ ${e.symbolNoiseFor("gs")}`),n=new Map;for(let r of t){if(!r.relative_path||e.isIgnored(r.relative_path))continue;let i=xe(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 ts(e,t,n,r={}){if(!n)return[];let i=F(e,t);return i?i.indexOf(n)===-1?[]:(Oc(e,t).get(n)??[]).filter(s=>!RC(s,r)):[]}function RC(e,t){return typeof t.excludeStartLine=="number"&&typeof t.excludeEndLine=="number"&&e>=t.excludeStartLine&&e<=t.excludeEndLine}var PC=C("file-identifiers",{clearGroups:["whole-project","source-file"]});function gm(e,t){let n=Se(e,t);return n?n.fileIdentifiers:PC.get(e,t,()=>new Set(Oc(e,t).keys()))}var wC=C("file-ident-lines",{clearGroups:["whole-project","source-file"]});function Oc(e,t){let n=Se(e,t);return n?n.identifierLineMap:wC.get(e,t,()=>FC(e,t))}var CC=C("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function l1(e,t){let n=Se(e,t);return n?n.identifiersByLine:CC.get(e,t,()=>{let r=Oc(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 FC(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=Za(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 ym=/[A-Za-z_$][A-Za-z0-9_$]*/g,hm=/^[A-Za-z_$][A-Za-z0-9_$]*$/,TC=512;function Mc(e){let t=[],n=!1;for(let r of e)r&&(n=!0,hm.test(r)||t.push(r));return{candidateNames:e,hasUsableCandidate:n,nonIdentifierNames:t}}function Sm(e,t){let n=_C(t)?t:Mc(t);if(n.candidateNames.size===0||!n.hasUsableCandidate)return!0;if(n.candidateNames.size<=TC){for(let i of n.candidateNames)if(i){if(hm.test(i)){if(NC(i).test(e))return!0;continue}if(e.includes(i))return!0}return!1}ym.lastIndex=0;let r;for(;(r=ym.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 _C(e){return"candidateNames"in e}function NC(e){return new RegExp(`(?<![A-Za-z_$0-9])${ce(e)}(?![A-Za-z_$0-9])`)}var kC=C("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function xm(e,t){let n=Gt(t);return kC.get(e,n,()=>LC(e,n))}function LC(e,t){let n=new Map;for(let r of ue(e,t)){if(!r.sourcePath)continue;let i=r.localName??r.importedName;if(i&&bm(n,i,r.sourcePath),r.kind==="namespace")for(let o of r.usedMembers)bm(n,o,r.sourcePath)}return n}function bm(e,t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n)}function jc(e,t,n){let r=Ac(e).get(n);if(!r||r.length===0)return[];if(r.length===1)return[ci(r[0])];let i=r.filter(c=>c.file===t);if(i.length>0)return i.map(ci);let o=xm(e,t),s=o.get(n);if(s)for(let c of s){let l=r.filter(u=>mn(c,u.file));if(l.length>0)return l.map(ci)}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=>mn(c,u.file));if(l.length>0&&l.length===r.length)return l.map(ci)}return[]}function C1(e,t,n){let r=jc(e,t,n);if(r.length>0)return r;let i=Ac(e).get(n);return!i||i.length===0?[]:i.map(ci)}function vm(e,t,n={}){let r=DC(e,t);if(!r)return[];let i=ai(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 ns(e,a)}}let o=new Map;for(let s of je(e)){let a=AC(e,r,s);a.length>0&&o.set(s,a)}return ns(e,o)}function DC(e,t){let n=ai(e,t);if(!n)return null;let r=xe(n.symbol);return r?{symbolId:n.symbolId,relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,identifier:r}:null}function AC(e,t,n){let r=F(e,n);return!r||r.indexOf(t.identifier)===-1?[]:n!==t.relativePath&&!jc(e,n,t.identifier).some(o=>o.symbolId===t.symbolId)?[]:ts(e,n,t.identifier,n===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{})}function F1(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=Mc(o),a=new Map;for(let c of je(e)){if(n.skipPath?.(c)||!Sm(F(e,c),s))continue;let l=gm(e,c);if(l.size!==0){for(let u of l)if(r.has(u))for(let d of jc(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 ci(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function ns(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=pr(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 _1(e,t){return is(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT
291
+ m.symbol_id,
292
+ d.relative_path,
293
+ COUNT(*) AS ref_count
294
+ FROM mentions m
295
+ JOIN chunks c ON m.chunk_id = c.id
296
+ JOIN documents d ON c.document_id = d.id
297
+ WHERE m.role != 1
298
+ ${r}
299
+ ${e.pathExclusionsFor("d")}
300
+ GROUP BY m.symbol_id, d.relative_path`,...n??[])})}function N1(e,t){return is(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
301
+ FROM mentions m
302
+ JOIN chunks c ON m.chunk_id = c.id
303
+ JOIN documents d ON c.document_id = d.id
304
+ WHERE m.role != 1
305
+ ${r}
306
+ ${e.pathExclusionsFor("d")}`,...n??[])}).filter(n=>n.symbol_id!==null)}function k1(e,t){return is(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id
307
+ FROM mentions m
308
+ WHERE m.role != 1
309
+ ${r}`,...n??[])}).filter(n=>n.symbol_id!==null)}function rs(e,t){let n=is(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,
310
+ c.start_line AS chunk_start, c.end_line AS chunk_end
311
+ FROM mentions m
312
+ JOIN chunks c ON m.chunk_id = c.id
313
+ JOIN documents d ON c.document_id = d.id
314
+ WHERE m.role != 1
315
+ ${s}
316
+ ${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 is(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 OC(e,t){return MC(e,[t]).get(t.symbolId)??[]}function MC(e,t){let n=t.map(o=>({symbolId:o.symbolId,prelude:VC(e,o)})).filter(o=>o.prelude!==null),r=BC(e,n.map(o=>o.symbolId)),i=new Map;for(let{symbolId:o,prelude:s}of n){let a=jC(e,r.get(o)??new Map,s.match,s.identifier);i.set(o,ns(e,a))}return i}function B1(e,t,n={}){return Bc(e,t,n).map(r=>({file:r.file,line:r.line,enclosingSymbol:r.enclosingSymbol}))}function Bc(e,t,n={}){let r=vm(e,t,{semantic:n.semantic,semanticEvidence:n.semanticEvidence}),i=r.length>0?Im(r,"source-attribution"):Im(OC(e,t),"scip-reference-chunk");return n.includeIgnored===!0?i:i.filter(o=>!e.isIgnored(o.file))}function Im(e,t){return e.map(n=>({...n,provenance:t}))}function jC(e,t,n,r){let i=new Map;for(let[o,s]of t)i.set(o,$C(e,o,s,n,r));return i}function BC(e,t){let n=new Map;for(let r of rs(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 $C(e,t,n,r,i){let o=t===r.relativePath?{excludeStartLine:r.startLine,excludeEndLine:r.endLine}:{},s=i?ts(e,t,i,o):[];return n.flatMap(a=>GC(s,a))}function GC(e,t){let n=e.filter(r=>r>=t.start_line&&r<=t.end_line);return n.length>0?n:[t.start_line]}function VC(e,t){let n=ai(e,t);return n?{match:n,identifier:xe(n.symbol)||null}:null}import{execFileSync as Em,spawnSync as HC}from"child_process";import{platform as WC}from"os";import{resolve as qC}from"path";var Rm=WC()==="win32";function W1(e,t=HC){try{return t(e,["--version"],{stdio:"ignore",timeout:1e4}).status===0}catch{return!1}}function Pm(e){let t=Rm?"where":"which";try{return Em(t,[e],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var UC=/\.(?:c|m)?js$/i,zC=/\.(?:exe|com)$/i;function q1(e,t){return UC.test(e)?{binary:process.execPath,args:[e,...t]}:{binary:e,args:[...t]}}function KC(e,t){return Em(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL"})}function wm(e,t={}){let n=t.isWindows??Rm,r=t.lookup??KC,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?qC(s):null}return o.find(s=>zC.test(s))??null}import{execFileSync as Fm}from"child_process";import{createHash as JC}from"crypto";import{existsSync as os,statSync as XC}from"fs";import{createRequire as YC}from"module";import{platform as QC}from"os";import{dirname as Cm,join as li}from"path";var ZC=YC(import.meta.url),nV={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function $c(e){return[e.indexerBinary,...e.binaryAliases??[]]}function eF(e){let t=$c(e);return t.length===1?t[0]:t.join(" or ")}function Gc(e){for(let t of $c(e)){let n=wm(t);if(n)return n}return nF(e)}function rV(e){return Gc(e)!==null||tF(e)}function tF(e){return Tm(e)!==null}function nF(e){let t=Tm(e);if(!t)return null;let r=JSON.parse(T(t,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return li(Cm(t),r);for(let i of $c(e)){let o=r[i];if(o)return li(Cm(t),o)}return null}function Tm(e){if(!e.bundledNpmPackage)return null;try{return ZC.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function rF(e,t){for(let n of e.projectLocalBinaries??[]){let r=li(t,n);if(os(r))return r}return null}function iF(e,t){for(let n of e.projectLocalBinaries??[]){let r=li(t,n);if(os(r))return _m(t,n,r)}return null}function iV(e,t){let n=oF(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 oF(e,t){try{return _m(e,t.relativePath,t.configuredPath)}catch{return null}}function _m(e,t,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=Jn(e,t,r),o=Io(e,t,r),s=XC(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:t,sha256:JC("sha256").update(o).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(s.mode&73)!==0}}function sF(e,t,n={}){return(n.trustProjectTools?iF(e,t)?.canonicalPath:null)??Gc(e)}function oV(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Vc(n,t))return t;let r=Nm(n,t);return r?{...t,DOTNET_ROOT:r}:t}function sV(e,t,n={}){let r=eF(e),i=t?sF(e,t,n):Gc(e);if(!i)return{language:e.language,binaryLabel:r,installed:!1,runnable:!1,resolvedBinary:null,installUrl:e.installUrl,...t&&rF(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=aF(i);return{language:e.language,binaryLabel:r,installed:!0,runnable:o.runnable,resolvedBinary:i,installUrl:e.installUrl,note:o.note}}function aF(e){if(Vc(e,process.env))return{runnable:!0};let t=Nm(e,process.env);if(t)return{runnable:!0,note:`using .NET 9 runtime from ${t}`};let n=km(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 Nm(e,t){for(let n of km(t))if(Vc(e,{...t,DOTNET_ROOT:n}))return n;return null}function km(e){let t=[],n=e.DOTNET_ROOT;if(n&&os(n)&&t.push(n),QC()==="darwin"&&Pm("brew"))try{let r=Fm("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=li(r,"libexec");os(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Vc(e,t){try{return Fm(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}function kn(e){try{return process.kill(e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}}var cF=new Set(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]);function Ft(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"||!cF.has(t.platform)||typeof t.startToken!="string"||t.startToken.trim()===""?null:{version:1,pid:t.pid,platform:t.platform,startToken:t.startToken}}function Le(e,t){return e.version===t.version&&e.pid===t.pid&&e.platform===t.platform&&e.startToken===t.startToken}import{execFileSync as lF}from"child_process";import{platform as uF}from"os";var dF=1e3,Lm=16*1024,Hc;function Tt(e,t=Am){if(!Number.isSafeInteger(e)||e<=0)return null;let n=e===process.pid&&t===Am;if(n&&Hc)return{...Hc};try{let r=pF(e,t);if(!r)return null;let i={version:1,pid:e,platform:t.platform,startToken:r};return n&&(Hc=i),{...i}}catch{return null}}function pF(e,t){if(t.platform==="linux"||t.platform==="android")return fF(t.readFile(`/proc/${e}/stat`));if(t.platform==="win32"){let n=`([DateTimeOffset](Get-Process -Id ${e} -ErrorAction Stop).StartTime).ToUnixTimeMilliseconds()`;return Dm(t.run("powershell.exe",["-NoProfile","-NonInteractive","-Command",n]))}return t.platform==="darwin"||t.platform==="freebsd"||t.platform==="openbsd"||t.platform==="netbsd"?Dm(t.run("ps",["-p",String(e),"-o","lstart="])):null}function fF(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 Dm(e){let t=e.trim();return t===""?null:t}var Am={platform:uF(),readFile(e){return ia(e,{maxBytes:Lm,inputKind:"process identity pseudo-file"})},run(e,t){return lF(e,[...t],{encoding:"utf8",timeout:dF,maxBuffer:Lm,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}};function _t(){return performance.now()}function gV(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 SF}from"crypto";import{closeSync as bF,existsSync as xF,fsyncSync as vF,linkSync as IF,mkdirSync as EF,openSync as RF,renameSync as PF,unlinkSync as wF,writeSync as CF}from"fs";import{dirname as Mm}from"path";import{chmodSync as mF,constants as gF,copyFileSync as yF}from"fs";import{dirname as hF}from"path";var Om=Object.freeze({...xn,copyFile:(e,t)=>yF(e,t,gF.COPYFILE_FICLONE),chmodFile:(e,t)=>mF(e,t)});function ui(e,t,n={}){let r=n.runtime??Om,i=hF(t),o=me(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,D(i,r))}var jm=Object.freeze({platform:process.platform,randomToken:()=>SF(),pathExists:e=>xF(e),makeDirectory:e=>EF(e,{recursive:!0}),openFile:(e,t,n)=>RF(e,t,n),writeFile:(e,t,n,r)=>CF(e,t,n,r),syncFile:e=>vF(e),closeFile:e=>bF(e),renameFile:(e,t)=>PF(e,t),linkFile:(e,t)=>IF(e,t),removeFile:e=>wF(e)});function Wc(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??jm,o=Mm(e),s=r==="durable"?me(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,bt(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,D(o,i)):"not-requested";return Bm(r,d)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function ss(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??jm;if(!i.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=Mm(e),s=r==="durable"?me(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,bt(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"?D(o,i):"not-requested";i.removeFile(a),u=!1;let p=r==="durable"?q(s,d,D(o,i)):"not-requested";return Bm(r,p)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function Bm(e,t){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":t==="synced"?"directory-durable":"file-flushed",directorySync:t}}function Zt(e,t,n={}){Wc(e,$m(t,n),{durability:"visibility",runtime:n.runtime})}function De(e,t,n={}){return Wc(e,$m(t,n),{durability:"durable",runtime:n.runtime})}function $m(e,t){let n=JSON.stringify(e,null,t.spacing);return t.trailingNewline?`${n}
317
+ `:n}import{join as as}from"path";var OV=6,MV=1e4,FF="watch.lock",TF="watch-state.json",_F="watch-activity.json",NF="watch-refresh-requests";function jV(e){return{lockPath:as(e,FF),statePath:as(e,TF),activityPath:as(e,_F),refreshRequestsPath:as(e,NF)}}function BV(e){try{return kF(JSON.parse(T(e,"watch service state")))}catch{return null}}function kF(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"||!oe(t.startedAt)||!oe(t.heartbeatAt)||!oe(t.lastActivityAt)||!LF(t.watcher)||t.idleDeadlineAt!==void 0&&!oe(t.idleDeadlineAt))return null;if(t.processIdentity!==void 0){let n=Ft(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&&!DF(t.lastError)||t.lastRefresh!==void 0&&!AF(t.lastRefresh)||t.reindexActivity!==void 0&&!OF(t.reindexActivity)||t.refreshRequests!==void 0&&!jF(t.refreshRequests)||t.typescriptSemantic!==void 0&&!BF(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!$F(t.typescriptIndex)?null:t}function oe(e){return no(e)}function LF(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return de(t.changedFiles)&&de(t.reindexAt);case"indexing":return de(t.startedAt);case"cooldown":return de(t.until)&&typeof t.dirty=="boolean";case"budget-paused":return de(t.until)&&typeof t.dirty=="boolean"&&typeof t.reason=="string"&&w(t.rebuilt)&&w(t.estimatedWriteBytes);case"draining":return de(t.startedAt)&&typeof t.reason=="string";default:return!1}}function DF(e){if(!e||typeof e!="object")return!1;let t=e;return oe(t.at)&&typeof t.message=="string"}function AF(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&oe(t.startedAt)&&oe(t.completedAt)&&de(t.durationMs)}function OF(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&&!w(t.recordsRead)||t.invalidRecords!==void 0&&!w(t.invalidRecords)||t.skippedRecords!==void 0&&!w(t.skippedRecords)||t.readErrors!==void 0&&!w(t.readErrors)||t.ignoredPartialTailBytes!==void 0&&!w(t.ignoredPartialTailBytes)||!oe(t.windowStartedAt)||!oe(t.windowEndedAt)||!w(t.runs)||!w(t.rebuilt)||t.fullRebuilds!==void 0&&!w(t.fullRebuilds)||!w(t.reused)||!w(t.failed)||!w(t.suppressed)||!de(t.estimatedLogicalOutputBytes)||t.estimatedWriteBytes!==void 0&&!w(t.estimatedWriteBytes)||t.reflinkedBytes!==void 0&&!w(t.reflinkedBytes)||t.fallbackCopiedBytes!==void 0&&!w(t.fallbackCopiedBytes)||t.oldestRebuildAt!==void 0&&!oe(t.oldestRebuildAt)||t.oldestWriteAt!==void 0&&!oe(t.oldestWriteAt)||t.languageAttribution!==void 0&&t.languageAttribution!=="complete"&&t.languageAttribution!=="partial"&&t.languageAttribution!=="unavailable"||t.attributedRuns!==void 0&&!w(t.attributedRuns)||t.unattributedRuns!==void 0&&!w(t.unattributedRuns)||t.invalidLanguageDetails!==void 0&&!w(t.invalidLanguageDetails)||t.estimatedLogicalOutputBytes<0||!t.byTrigger||typeof t.byTrigger!="object"||Array.isArray(t.byTrigger)||t.byLanguage!==void 0&&!MF(t.byLanguage)?!1:Object.values(t.byTrigger).every(n=>n===void 0||w(n))}function MF(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let[t,n]of Object.entries(e)){if(!ro.includes(t)||!n||typeof n!="object")return!1;let r=n;if(!w(r.runs)||!w(r.rebuilt)||!w(r.reused)||!w(r.producedOutputBytes)||!ju(r.durationMs)||r.rebuilt+r.reused!==r.runs)return!1}return!0}function jF(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.pending)&&w(t.claimed)&&w(t.completed)&&w(t.expired)&&w(t.invalid)&&(t.oldestPendingAt===void 0||oe(t.oldestPendingAt))}function BF(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")&&de(t.requests)&&de(t.sessionsCreated)&&de(t.sessionsReused)&&de(t.sessionsRefreshed)&&de(t.sessionsReplaced)&&de(t.projectsCreated)&&(t.lastRequestAt===void 0||oe(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||oe(t.busyUntil))&&(t.mailbox===void 0||Gm(t.mailbox))}function $F(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")&&w(t.requests)&&w(t.sessionsCreated)&&w(t.sessionsReplaced)&&(t.sessionsEvicted===void 0||w(t.sessionsEvicted))&&(t.activeSessions===void 0||w(t.activeSessions))&&(t.maxActiveSessions===void 0||w(t.maxActiveSessions))&&(t.heapUsedBytes===void 0||w(t.heapUsedBytes))&&(t.heapLimitBytes===void 0||w(t.heapLimitBytes))&&(t.softMemoryLimitBytes===void 0||w(t.softMemoryLimitBytes))&&(t.retireRequested===void 0||typeof t.retireRequested=="boolean")&&w(t.initializations)&&w(t.programUpdates)&&w(t.documentsEmitted)&&w(t.documentsRemoved)&&(t.lastRequestAt===void 0||oe(t.lastRequestAt))&&(t.lastDurationMs===void 0||de(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||oe(t.busyUntil))&&(t.mailbox===void 0||Gm(t.mailbox))}function Gm(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.pending)&&w(t.inflight)&&w(t.responses)&&w(t.deadLetters)&&w(t.invalid)&&w(t.totalItems)&&de(t.totalBytes)&&t.totalBytes>=0&&t.totalItems===t.pending+t.inflight+t.responses+t.deadLetters&&(t.oldestPendingAt===void 0||oe(t.oldestPendingAt))}function de(e){return typeof e=="number"&&Number.isFinite(e)}import{getHeapStatistics as oT}from"v8";var GF=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function cs(e){let t=e.toLowerCase();return GF.some(n=>t.endsWith(n))}function us(e){let t=ls(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=Mt(p.path,["typescript"]);return f==="config"||f==="ambient"}).map(p=>p.path),o=ls([...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=>Vm(r.get(p))),l=K(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:ls(e.snapshot.typescriptProjects),membership:t})),u,d;return{identityFor(p,f){if(!n.has(p))return gr("target-outside-project");if(a)return gr("duplicate-input-path");if(s)return gr("missing-input-fingerprint");if(c)return gr("unreadable-input");let m=[],y,g;if(e.graph===null)m.push("dependency-graph-unavailable"),g="whole-project",y=o;else{let v=p===u&&d?d:VF(p,e.graph);if(u=p,d=v,v.find(x=>!r.has(x)))return gr("missing-input-fingerprint");if(y=ls([...v,...i]),y.some(x=>Vm(r.get(x))))return gr("unreadable-input");g="dependency-closure"}let S=y.map(v=>HF(r.get(v)));return{version:1,key:K(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:f,projectIdentity:l,inputs:S})),mode:g,inputFiles:y,reasons:m}}}}function VF(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 HF(e){return e.semanticHash===void 0?{path:e.path,size:e.size,hash:e.hash}:{path:e.path,semanticHash:e.semanticHash}}function Vm(e){return e.size<0||e.hash==="unreadable"}function gr(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function ls(e){return[...new Set(e)].sort()}import{realpathSync as KF}from"fs";import{createRequire as JF}from"module";import{dirname as XF,resolve as YF}from"path";import{getHeapStatistics as WF}from"v8";var qF=2560,UF=1.25;function zF(e){let t=e/1048576;return Math.max(0,Math.floor((t-qF)/UF))}function Hm(){return zF(WF().heap_size_limit)}var Wm=JF(import.meta.url),di,ds;function QF(){if(di!==void 0)return di;try{di=Wm("ts-morph")}catch{di=null}return di}function ps(){if(ds)return ds;let e=QF();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=Wm("ts-morph/package.json").version??"unknown"}catch{}return ds=`ts-morph:${t}:typescript:${e.ts.version}`,ds}function YV(e,t,n={}){return t.map(r=>ZF(e,r,n))}function ZF(e,t,n){let r=null,i,o,s=()=>(i===void 0&&(i=qm(e,t)),i),a=()=>{if(o===void 0){let c=n.fileBudget??Hm(),l=s();o=(l===null?0:Math.ceil(l.size/2))>c*eT?"file-closure":"project"}return o};return{tsconfigPath:t,get project(){return r??=new e.Project({tsConfigFilePath:t,skipFileDependencyResolution:!0,...a()==="file-closure"?{skipAddingFilesFromTsConfig:!0}:{}}),r},get loaded(){return r!==null},get fileNames(){return s()},get scope(){return a()}}}var eT=1.35,QV="TypeScript project-wide semantics are unavailable: a compiler project is file-scoped because its tsconfig lists more files than the worker heap can hold.";function ZV(e){return e.some(t=>t.scope==="file-closure")}function eH(e,t){let n=new Set;for(let r of t)for(let i of qm(e,r)??[])n.add(i);return n}function qm(e,t){try{let n=e.ts,r=n.readConfigFile(t,n.sys.readFile);if(r.error||!r.config)return null;let i=n.parseJsonConfigFileContent(r.config,n.sys,XF(t),void 0,t),o=new Set;for(let s of i.fileNames){let a=YF(s);o.add(a);try{o.add(KF(a))}catch{}}return o}catch{return null}}function tH(e,t,n){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var tT=ot("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function pi(e,t,n){let r=tT.get(e,()=>nT(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 Ln(e){return ge(e,{includeIgnored:!1}).filter(cs).sort()}function nT(e){try{if(!e.generation.metadataRaw)return null;let t=jt(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=Fr(t.metadata.fingerprint);return n?{builder:us({projectFiles:Ln(e),snapshot:n,graph:ur(e),engineIdentity:ps()}),identities:new Map}:null}catch{return null}}function Km(e,t){let n=qc(e);for(let r of t.values())n.add(r);return n.finish()}function qc(e){let t=new Map(e.map(r=>[r.symbol,r])),n=new Map(e.map(r=>[r.symbolId,[]]));return{add(r){for(let i of r){let o=t.get(i.targetSymbol);o&&n.get(o.symbolId).push(i.location)}},finish(){for(let[r,i]of n)n.set(r,rT(i));return n}}}function Jm(e,t,n){let r=zm(e,t),i=zm(e,n),o=[...r].filter(d=>!i.has(d)).sort(),s=[...i].filter(d=>!r.has(d)).sort(),a=Um(e,t),c=Um(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 Um(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 pH(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,iT(s));return i}function zm(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 rT(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(Xm)}function iT(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)||Xm(n.location,r.location))}function Xm(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}var mi="typescript-reference-fragment-v2",Ym=128,yr=ae({kind:"typescript-reference-fragments",invalidation:ne("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:uT});function PH(e,t,n,r=e,i,o=new Set(n.keys())){let s=Ln(e),a=us({projectFiles:s,snapshot:t,graph:i??ur(e),engineIdentity:ps()}),c=[],l=0;for(let[d,p]of n){let f=a.identityFor(d,mi).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 yr.writeBatch(r,c),{affectedFiles:c.length,carriedFiles:u,skippedAffectedFiles:l}}function wH(e,t,n,r){let i=t.filter(s=>cs(s.relativePath));if(i.length===0)return fi("no TypeScript definitions");let o=fi("shadow did not run");return J("typescript.reference-fragments.shadow",()=>{try{let s=r(i[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return o=fi("TypeScript reference fragment provider is unavailable"),o;let a=Ln(e),c=new Set(a),l=new Map;for(let f of Uc(a)){let m=s.referenceFragmentsForFiles(f);if(f.some(y=>!m.has(y)))return o=fi("TypeScript reference fragment provider returned an incomplete batch"),o;for(let y of f)l.set(y,m.get(y)??[])}let u=Km(i,l),d=Jm(i,sT(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 m=pi(e,f,mi);m?.key&&p.push({relativePath:f,contentHash:m.key,value:l.get(f)??[]})}return yr.writeBatch(e,p),o={state:"passing",files:a.length,keyedFiles:p.length,writtenFiles:p.length,...d},o}catch(s){return o=fi(s instanceof Error?s.message:String(s)),o}},()=>({...o}))}function sT(e,t){return new Map([...e].map(([n,r])=>[n,r.filter(i=>t.has(i.file))]))}function CH(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 J("typescript.reference-fragments.materialize",()=>{try{let c=Ln(e);i=c.length;let l=qc(t),u=[];for(let p of c){let f=pi(e,p,mi);if(!f?.key)return null;let m=yr.read(e,p,f.key);m===null?(s+=1,u.push({file:p,contentHash:f.key})):(o+=1,l.add(m))}return s===0?(r="hit",{references:l.finish(),files:i,cacheHits:o,cacheMisses:s,computedFiles:a}):cT(e,u,n,p=>{for(let{fragments:f}of p)l.add(f);a+=p.length})?(r="computed",{references:l.finish(),files:i,cacheHits:o,cacheMisses:s,computedFiles:a}):null}catch{return null}},()=>({state:r,files:i,cacheHits:o,cacheMisses:s,computedFiles:a}))}function Uc(e){let t=[];for(let n=0;n<e.length;n+=Ym)t.push(e.slice(n,n+Ym));return t}var aT=.75;function Qm(e){return{heapUsedFraction:()=>{let t=oT();return t.heap_size_limit>0?t.used_heap_size/t.heap_size_limit:0},collect:En,release:()=>Gu(e,{groups:["semantic-provider"]})}}function Zm(e,t=aT){return e.heapUsedFraction()<t||e.collect()&&e.heapUsedFraction()<t?!1:(e.release(),!0)}function cT(e,t,n,r,i=Qm(e)){for(let o of Uc(t)){let s=eg(e,o,n);if(!s)return!1;r(s),Zm(i)}return!0}function eg(e,t,n){let r=t.map(({file:s})=>s),i=n(r[0]);if(!i.availability().available||!i.referenceFragmentsForFiles)return null;let o=i.referenceFragmentsForFiles(r);return r.some(s=>!o.has(s))?null:(yr.writeBatch(e,t.map(({file:s,contentHash:a})=>({relativePath:s,contentHash:a,value:o.get(s)??[]}))),r.map(s=>({file:s,fragments:o.get(s)??[]})))}function FH(e){let t=Ln(e),n=0;for(let r of t){let i=pi(e,r,mi);if(!i?.key)return null;yr.has(e,r,i.key)||(n+=1)}return{files:t.length,missing:n}}var lT=()=>new Promise(e=>setImmediate(e));async function TH(e,t,n={}){let r=n.yieldToEventLoop??lT,i=n.probe??Qm(e),o="fallback",s=0,a=0,c=0,l=0;return md("typescript.reference-fragments.warm",async()=>{try{let u=Ln(e),d=n.files?new Set(n.files):null,p=d?u.filter(m=>d.has(m)):u;s=p.length;let f=[];for(let m of p){let y=pi(e,m,mi);if(!y?.key)return null;yr.has(e,m,y.key)?a+=1:(c+=1,f.push({file:m,contentHash:y.key}))}if(f.length===0)return o="hit",{files:s,cacheHits:a,cacheMisses:c,computedFiles:l};for(let m of Uc(f)){let y=eg(e,m,t);if(!y)return null;l+=y.length,Zm(i),n.onBatch?.({computedFiles:l,missingFiles:f.length}),await r()}return o="computed",{files:s,cacheHits:a,cacheMisses:c,computedFiles:l}}catch{return null}},()=>({state:o,files:s,cacheHits:a,cacheMisses:c,computedFiles:l}))}function fi(e){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:e}}function uT(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(dT)?null:t}catch{return null}}function dT(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 fs(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function tg(e,t){if(e?.aborted)throw fs(e,t)}import{randomUUID as pT}from"crypto";import{closeSync as fT,fsyncSync as mT,linkSync as gT,mkdirSync as yT,openSync as hT,statSync as ST,unlinkSync as bT,writeSync as xT}from"fs";import{dirname as Yc}from"path";var Kc="scip-query-process-lock",Jc=1,ms=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:kn,readProcessIdentity:Tt,randomToken:()=>pT(),makeDirectory:e=>yT(e,{recursive:!0}),openFile:(e,t,n)=>hT(e,t,n),writeFile:(e,t,n,r)=>xT(e,t,n,r),syncFile:e=>mT(e),closeFile:e=>fT(e),linkFile:(e,t)=>gT(e,t),readFile:e=>T(e,"process lock record"),statFile:e=>{let t=ST(e);return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs}},removeFile:e=>bT(e)});function gs(e,t){let n=t.runtime??ms;n.makeDirectory(Yc(e));let r;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:ng(e,t,n),...r?{reclaimed:r}:{}}}catch(o){if(o.code!=="EEXIST")throw o;let s=hr(e,{parseLegacy:t.parseLegacy,runtime:n});if(i===0&&IT(e,s,{creationGraceMs:t.creationGraceMs,parseLegacy:t.parseLegacy,runtime:n})){r=s;continue}return{kind:"contended",observation:s}}return{kind:"contended",observation:hr(e,{parseLegacy:t.parseLegacy,runtime:n})}}function hr(e,t={}){let n=t.runtime??ms,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=vT(o);if(s)return{state:"valid",raw:i,identity:r,record:s,owner:PT(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 vT(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.protocol!==Kc||t.version!==Jc||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:Ft(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{protocol:Kc,version:Jc,kind:t.kind,pid:t.pid,token:t.token,...n?{processIdentity:n}:{},startedAt:t.startedAt,...t.detail?{detail:t.detail}:{}}}function IT(e,t,n={}){let r=n.runtime??ms;if(!Xc(t,r))return!1;let i=RT(`${e}.reclaim`,r);if(!i)return!1;try{let o=hr(e,{parseLegacy:n.parseLegacy,runtime:r});return!ig(t,o)||!Xc(o,r)?!1:Qc(e,r)}finally{i.release()}}function ng(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:Kc,version:Jc,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{bt(l,Buffer.from(`${JSON.stringify(a)}
318
+ `),n,"process lock"),n.syncFile(l)}catch(p){u=p}try{n.closeFile(l)}catch(p){u??=p}if(u!==void 0)throw zc(c,n),u;try{n.linkFile(c,e)}catch(p){throw zc(c,n),p}if(zc(c,n),r==="durable")try{og(Yc(e),n)}catch(p){throw ET(e,a,n),p}let d=!1;return{path:e,record:a,release:()=>d?!1:(d=!0,rg(e,a,n,r))}}function ET(e,t,n=ms){return rg(e,t,n,"durable")}function rg(e,t,n,r){let i=hr(e,{runtime:n});return i.state!=="valid"||!i.record||i.record.pid!==t.pid||i.record.token!==t.token||t.processIdentity&&(!i.record.processIdentity||!Le(t.processIdentity,i.record.processIdentity))?!1:Qc(e,n,r)}function RT(e,t){for(let n=0;n<2;n+=1)try{return ng(e,{kind:"reclaim-guard",runtime:t},t)}catch(r){if(r.code!=="EEXIST")return null;let i=hr(e,{runtime:t});if(n>0||!Xc(i,t))return null;let o=hr(e,{runtime:t});if(!ig(i,o)||!Qc(e,t))return null}return null}function Xc(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&&!Le(e.owner.processIdentity,n)}return!1}function ig(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 PT(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function og(e,t){let n;try{n=t.openFile(e,"r")}catch(r){if(Un(r,process.platform))return;throw r}try{t.syncFile(n)}catch(r){if(!Un(r,process.platform))throw r}finally{t.closeFile(n)}}function Qc(e,t,n="durable"){try{return t.removeFile(e),n==="durable"&&og(Yc(e),t),!0}catch{return!1}}function zc(e,t){try{t.removeFile(e)}catch{}}import{join as wT}from"path";var CT=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 sg(e,t={}){return Nt(wT(e,"gc.lock"),t)}function Nt(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??_t,o=i()+n;do{let s=ag(e,t.directoryDurability);if(s)return cg(s);let a=o-i();if(a<=0)return null;FT(Math.min(r,a))}while(i()<=o);return null}async function WH(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??_t,o=i()+n;do{tg(t.signal,"Lock acquisition was aborted.");let s=ag(e,t.directoryDurability);if(s)return cg(s);let a=o-i();if(a<=0)return null;await TT(Math.min(r,a),t.signal)}while(i()<=o);return null}function ag(e,t){let n=gs(e,{kind:"generic",parseLegacy:CT,...t?{directoryDurability:t}:{}});return n.kind==="acquired"?n.lock:null}function cg(e){return{release:()=>{e.release()}}}function FT(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function TT(e,t){return t?.aborted?Promise.reject(fs(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?fs(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}import{createHash as _T,randomUUID as NT}from"crypto";import{existsSync as Sr,mkdirSync as kT,readdirSync as LT,rmSync as ug,statSync as dg}from"fs";import{basename as DT,dirname as ys,join as Ae}from"path";var Dn=1,nl=1,yi=".scipquery-generations",hs="manifest.json",pg="readers",AT="gc.lock",OT=128,gi=new Map,fg={pid:process.pid,now:()=>new Date,randomToken:()=>NT(),isProcessAlive:kn,readProcessIdentity:Tt};function Z(e){return Ae(ys(e),yi)}function Ss(e){return Ae(Z(e),AT)}function mg(e,t=fg){let n=Nt(Ss(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=il(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=Ae(Z(e.dbPath),pg);kT(s,{recursive:!0}),r=Ae(s,`${t.pid}-${o}.json`);let a=t.readProcessIdentity(t.pid);Zt(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,ug(r,{force:!0}))}}}finally{n.release()}}function rl(e,t,n=fg,r={}){let i=Ae(Z(e),pg);if(!Sr(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 LT(i,{withFileTypes:!0})){if(!l.isFile()||!l.name.endsWith(".json"))continue;let u=Ae(i,l.name),d;try{d=MT(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(!jT(d,n)){r.removeStale!==!1&&(ug(u,{force:!0}),a+=1);continue}s+=1,o.add(d.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:c}}function MT(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.processIdentity===void 0?null:Ft(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 jT(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let n=t.readProcessIdentity(e.pid);return n===null||Le(e.processIdentity,n)}function en(e){try{let t=JSON.parse(T(Ae(Z(e),"state.json"),"SQLite generation state"));return VT(t)?t:null}catch{return null}}function hi(e,t){return Si(Z(e),t)}function Si(e,t){try{let n=JSON.parse(T(Ae(e,t,hs),"SQLite generation manifest"));return GT(n,t)?n:null}catch{return null}}function il(e){let t=en(e.dbPath);if(t){let n=BT(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(Sr(Ae(ys(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return $T(e,t?.currentGeneration)}function nW(e){let t=en(e);if(t)return t.currentGeneration;try{let n=Ae(ys(e),"meta.json"),r=Sr(n)?T(n,"reindex metadata"):void 0;return gg(e,r)}catch{return null}}function tn(e){return Bu(jt(e))??e}function BT(e,t){try{let n=Ae(Z(e.dbPath),t),r=hi(e.dbPath,t);if(!r)return null;let i=Zc(n,r.database),o=r.index?Zc(n,r.index):void 0,s=r.metadata?Zc(n,r.metadata):void 0;return!el(i,r.database)||r.index&&(!o||!el(o,r.index))||r.metadata&&(!s||!el(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 $T(e,t){let n=kt(e.dbPath),r=Ae(ys(e.dbPath),"meta.json"),i=Sr(r)?T(r,"reindex metadata"):void 0,o=Sr(e.indexPath)?e.indexPath:void 0;return{identity:t??gg(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function gg(e,t){let n=_T("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&n.update(tn(t)),n.update(`\0${kt(e)}`),n.digest("hex")}function kt(e){let t=dg(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function Zc(e,t){if(DT(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return Ae(e,t.file)}function el(e,t){if(!Sr(e))return!1;let n=lg(e);if(!n||n.size!==t.size)return!1;let r=`${e}\0${t.sha256}\0${n.identity}`;if(gi.has(r))return!0;let i=cn(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=lg(e);if(!o||o.identity!==n.identity||i!==t.sha256)return!1;for(gi.set(r,!0);gi.size>OT;){let s=gi.keys().next().value;if(s===void 0)break;gi.delete(s)}return!0}function lg(e){let t=dg(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function GT(e,t){return e.version===nl&&e.identity===t&&tl(e.database)&&(e.index===void 0||tl(e.index))&&(e.metadata===void 0||tl(e.metadata))}function tl(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 VT(e){return e.version===Dn&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&HT(e.stableMirrors)&&WT(e.previousGeneration)&&qT(e.publication)}function HT(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 WT(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 qT(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")}function iW(e){let t=e?.match(/--max[-_]old[-_]space[-_]size(?:=|\s+)(\d+)/u);if(!t)return;let n=Number.parseInt(t[1],10);return Number.isInteger(n)&&n>0?n:void 0}function oW(e,t){return[(e??"").replace(/(?:^|\s)--max[-_]old[-_]space[-_]size(?:=|\s+)\d+/gu," ").trim(),`--max-old-space-size=${t}`].filter(Boolean).join(" ")}import UT from"better-sqlite3";var zT=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],ol=class{constructor(t,n){this.connection=t;this.releaseGenerationReader=n}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let n of zT)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}},KT=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],yg=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;constructor(t,n){this.config=t,this.pathFilter=n??null;let r=QT(t),i=new ol(r.db,r.release);try{i.initialize(YT),this.generation=r.generation,this.connection=r.db,this.connectionOwnership=i,this.db=JT(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`(
319
+ EXISTS (
320
+ SELECT 1
321
+ FROM defn_enclosing_ranges local_der
322
+ JOIN documents local_d ON local_der.document_id = local_d.id
323
+ WHERE local_der.symbol_id = gs.id
324
+ ${this.pathExclusionsFor("local_d").trimStart()}
325
+ )
326
+ OR EXISTS (
327
+ SELECT 1
328
+ FROM mentions local_m
329
+ JOIN chunks local_c ON local_m.chunk_id = local_c.id
330
+ JOIN documents local_d ON local_c.document_id = local_d.id
331
+ WHERE local_m.symbol_id = gs.id
332
+ AND local_m.role = 1
333
+ ${this.pathExclusionsFor("local_d").trimStart()}
334
+ )
335
+ )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(n=>KT.flatMap(r=>[`AND ${n}.relative_path NOT LIKE '${r}/%'`,`AND ${n}.relative_path NOT LIKE '%/${r}/%'`])).join(`
336
+ `)}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 JT(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 XT(n)}})}function XT(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 YT(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)Ie(r.relative_path)}function QT(e){for(let t=0;t<4;t+=1){let n=mg(e),r=n.generation,i;try{i=new UT(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=il(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 ZT from"ignore";import{existsSync as hg,readdirSync as e_}from"fs";import{dirname as sl,isAbsolute as Sg,join as bs,relative as t_,resolve as n_}from"path";function gW(e){let t=ZT();return r_(e,t)||t.add(s_),{isIgnored:r=>al(t,e,r),filter:r=>r.filter(i=>!al(t,e,i))}}function r_(e,t){let n=new Set,r=(s,a)=>{if(!(n.has(s)||!hg(s)))try{let c=j(s,{maxBytes:z,inputKind:"gitignore file"});t.add(a?i_(c,a):c),n.add(s)}catch{}},i=sl(e),o=0;for(;i!==sl(i)&&o<5&&(r(bs(i,".gitignore"),""),!hg(bs(i,".git")));)i=sl(i),o++;return bg(e,"",t,r),n.size>0}function bg(e,t,n,r){let i=t?bs(e,t):e;r(bs(i,".gitignore"),t);let o;try{o=e_(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;al(n,e,`${a}/`)||bg(e,a,n,r)}}function i_(e,t){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return e.split(/\r?\n/).map(r=>o_(r,n)).join(`
337
+ `)}function o_(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 s_=`
338
+ # Dependencies
339
+ node_modules/
340
+ vendor/
341
+ .bundle/
342
+
343
+ # Build output
344
+ dist/
345
+ build/
346
+ out/
347
+ target/
348
+ bin/
349
+ obj/
350
+
351
+ # Python
352
+ __pycache__/
353
+ *.pyc
354
+ *.pyo
355
+ .venv/
356
+ venv/
357
+ .env/
358
+ env/
359
+ *.egg-info/
360
+
361
+ # Rust
362
+ target/
363
+
364
+ # Java / Kotlin / Scala
365
+ *.class
366
+ .gradle/
367
+ .mvn/
368
+
369
+ # C# / .NET
370
+ bin/
371
+ obj/
372
+ packages/
373
+
374
+ # Go
375
+ vendor/
376
+
377
+ # Dart
378
+ .dart_tool/
379
+ build/
380
+
381
+ # PHP
382
+ vendor/
383
+
384
+ # IDE / OS
385
+ .idea/
386
+ .vscode/
387
+ *.swp
388
+ *.swo
389
+ .DS_Store
390
+ Thumbs.db
391
+
392
+ # Type definitions (often noise in queries)
393
+ *.d.ts
394
+ `;function al(e,t,n){let r=a_(t,n);if(!r)return!1;try{return e.ignores(r)}catch{return!1}}function a_(e,t){if(!t||t===".")return null;if(!Sg(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let n=Sg(t)?t:n_(e,t),r=t_(e,n).replaceAll("\\","/");return!r||r==="."||r.startsWith("..")?null:r}import{execFileSync as c_}from"child_process";import{existsSync as l_,readdirSync as xg}from"fs";import{extname as vg,join as Ig}from"path";var Eg=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),u_=[{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 xs(e){let t=[],n=d_(e),r=g_(e);for(let i of u_){if(p_(e,i.files)){t.push(i.language);continue}if(f_(n,i.globs)){t.push(i.language);continue}h_(r,i.extensions)&&t.push(i.language)}if(t.includes("typescript")&&cl(t,"javascript"),t.includes("cpp")&&t.includes("c")){let i=r.has(".c"),o=[".cc",".cpp",".cxx"].some(s=>r.has(s));i&&!o?cl(t,"cpp"):i||cl(t,"c")}return t}function d_(e){try{return xg(e)}catch{return[]}}function p_(e,t){return t?.length?t.some(n=>l_(Ig(e,n))):!1}function f_(e,t){return t?.length?e.some(n=>t.some(r=>m_(n,r))):!1}function m_(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 g_(e){let t=y_(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=xg(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=Ig(i,s.name);if(s.isDirectory()){Eg.has(s.name)||r.push(a);continue}let c=vg(s.name).toLowerCase();c&&n.add(c)}}return n}function y_(e){try{let t=Xi(e,26214400,()=>c_("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 Yi(t)){if(r.split("/").some(o=>Eg.has(o)))continue;let i=vg(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function h_(e,t){return t?.length?t.some(n=>e.has(n)):!1}function cl(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import S_ from"better-sqlite3";var b_=25,x_=new Set(["typescript","javascript"]);function PW(e,t,n){let r=null;try{r=new S_(e,{readonly:!0,fileMustExist:!0});let i=new Set(r.prepare("SELECT relative_path FROM documents").pluck().all().map(Gt)),o=v_(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,b_),affectedLanguages:l}}catch(i){return{state:"unavailable",reason:i instanceof Error?i.message:String(i)}}finally{r?.close()}}function v_(e,t){let n=new Map,r=t.filter(i=>x_.has(i));for(let i of r)n.set(i,new Set);for(let i of e.files){let o=Gt(i.path);for(let s of r)Mt(o,[s])==="source"&&n.get(s).add(o)}return n}import{existsSync as Pg,readdirSync as wg,rmSync as Cg}from"fs";import{join as br}from"path";import{create as Tg,fromBinary as _g,toBinary as AW}from"@bufbuild/protobuf";import{deserializeSCIP as ll,DocumentSchema as Ng,IndexSchema as kg,serializeSCIP as Lg}from"@c4312/scip";import{existsSync as I_,mkdirSync as E_,renameSync as R_,writeFileSync as P_}from"fs";import{join as w_}from"path";function Rg(e){E_(e.blobDir,{recursive:!0});let t=w_(e.blobDir,`${e.blobHash}.scipdoc`);if(I_(t)){let r=H(t,{maxBytes:an,inputKind:e.inputKind});if(r.byteLength!==e.bytes.byteLength||K(r)!==e.blobHash)throw new Error(`existing ${e.inputKind} is corrupt: ${e.relativePath}`);return}let n=`${t}.${process.pid}.${Date.now()}.tmp`;P_(n,e.bytes),R_(n,t)}var ul=1,bi="typescript-scip-fragments";function BW(e){let t=new Set,n=[];for(let o of e){let s=vs(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=_g(Ng,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);n.push(a)}let r=Lg(Tg(kg,{documents:n,externalSymbols:[]})),i=ll(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function C_(e){let t=br(e,bi);return{rootDir:t,blobDir:br(t,"blobs"),generationDir:br(t,"generations")}}function Dg(e){let t=F_(e);return T_(t.baseIndex,t.completeDocuments,"assembled")}function F_(e){let t=ll(e.baseIndexBytes);L_(t.metadata,D_(e)),k_(t.externalSymbols);let n=new Map;for(let a of e.fragments){let c=vs(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=vs(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=Fg(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=Fg(a,c.bytes);i.push(l),o.push(l)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function Fg(e,t){let n=_g(Ng,t);if(n.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${n.relativePath}`);return n}function T_(e,t,n){let r=Lg(Tg(kg,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=ll(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function $W(e,t){let n=C_(e);if(!Pg(n.generationDir))return;let r=new Set(t.map(s=>N_(s))),i=wg(n.generationDir).filter(s=>s.endsWith(".json")),o=new Set;for(let s of i.filter(a=>r.has(a))){let a=__(j(br(n.generationDir,s),{maxBytes:z,inputKind:"TypeScript fragment manifest"}));for(let c of a.documents)o.add(`${c.blobHash}.scipdoc`)}for(let s of i)r.has(s)||Cg(br(n.generationDir,s),{force:!0});if(Pg(n.blobDir))for(let s of wg(n.blobDir))o.has(s)||Cg(br(n.blobDir,s),{force:!0})}function __(e){let t=JSON.parse(e);if(t.version!==ul||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(vs(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function N_(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${K(e)}.json`}function k_(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function L_(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 D_(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function vs(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 Is,readdirSync as dl,rmSync as Ag}from"fs";import{join as ut}from"path";var Es=1,xi="typescript-scip-overlays",Og="typescript-project-v3:";function JW(e){let t=jg(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(Og)&&e.projectIdentity.startsWith(Og);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=ml(s.relativePath);if(i.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);i.add(a),r.set(a,A_(e.cacheDir,s))}if(i.size===0)throw new Error("TypeScript overlay generation requires affected documents");let o={version:Es,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 O_(e.cacheDir,o),o}function XW(e){let t=jg(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=H(ut(vi(e.cacheDir),"blobs",`${r.blobHash}.scipdoc`),{maxBytes:an,inputKind:"TypeScript overlay blob"});if(i.byteLength!==r.byteLength||K(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 Dg({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function YW(e,t){let n=vi(e),r=ut(n,"generations");if(!Is(r))return;let i=new Set(t.map(fl)),o=new Set;for(let a of dl(r).filter(c=>i.has(c))){let c=pl(j(ut(r,a),{maxBytes:z,inputKind:"TypeScript overlay manifest"}));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of dl(r))i.has(a)||Ag(ut(r,a),{force:!0});let s=ut(n,"blobs");if(Is(s))for(let a of dl(s))o.has(a)||Ag(ut(s,a),{force:!0})}function jg(e,t){let n=ut(vi(e),"generations",fl(t));if(!Is(n))return null;let r=pl(j(n,{maxBytes:z,inputKind:"TypeScript overlay manifest"}));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function A_(e,t){let n=ml(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=K(r);return Rg({blobDir:ut(vi(e),"blobs"),blobHash:i,bytes:r,relativePath:n,inputKind:"TypeScript overlay blob"}),{relativePath:n,blobHash:i,byteLength:r.byteLength}}function O_(e,t){let n=ut(vi(e),"generations",fl(t.generationIdentity));if(Is(n)){let r=pl(j(n,{maxBytes:z,inputKind:"TypeScript overlay manifest"}));if(Mg(r)!==Mg(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}Zt(n,t,{spacing:2,trailingNewline:!0})}function pl(e){let t=JSON.parse(e);if(t.version!==Es||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(ml(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function vi(e){return ut(e,xi)}function fl(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${K(e)}.json`}function Mg(e){return K(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function ml(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{closeSync as $g,openSync as V_,renameSync as H_,rmSync as W_,writeSync as q_}from"fs";import{create as Gg,fromBinary as U_,toBinary as z_}from"@bufbuild/protobuf";import{DocumentSchema as yl,IndexSchema as K_,SymbolRole as Sl}from"@c4312/scip";var ze=class extends Error{},M_=0,j_=1,Bg=2,B_=5;function gl(e,t,n){let r=0,i=0;for(;t<n;){let o=e[t];if(t+=1,i<53)r+=(o&127)*2**i;else if((o&127)!==0)throw new ze("varint exceeds the safe integer range");if((o&128)===0)return{value:r,pos:t};if(i+=7,i>63)throw new ze("varint is longer than 64 bits")}throw new ze("varint runs past the end of the buffer")}function*et(e,t=0,n=e.length){let r=t;for(;r<n;){let i=r,o=gl(e,r,n);r=o.pos;let s=Math.floor(o.value/8),a=o.value%8;if(s===0)throw new ze("field number 0 is invalid");let c=r,l=0;if(a===M_){let u=gl(e,r,n);l=u.value,r=u.pos}else if(a===Bg){let u=gl(e,r,n);if(c=u.pos,r=u.pos+u.value,r>n)throw new ze("length-delimited field runs past the end of the buffer")}else if(a===j_)r+=8;else if(a===B_)r+=4;else throw new ze(`unsupported wire type ${a}`);if(r>n)throw new ze("field value runs past the end of the buffer");yield{fieldNumber:s,wireType:a,fieldStart:i,valueStart:c,valueEnd:r,fieldEnd:r,varint:l}}}function Ii(e){if(!Number.isSafeInteger(e)||e<0)throw new ze(`cannot encode varint ${e}`);let t=[],n=e;do{let r=n%128;n=Math.floor(n/128),n>0&&(r|=128),t.push(r)}while(n>0);return Uint8Array.from(t)}function Rs(e){return Ii(e*8+Bg)}var $_=1,G_=3;function Ei(e){let t=new TextDecoder,n;for(let r of et(e))if(!(r.fieldNumber!==$_||r.wireType!==2))for(let i of et(e,r.valueStart,r.valueEnd)){if(i.fieldNumber!==G_||i.wireType!==2)continue;let o=t.decode(e.subarray(i.valueStart,i.valueEnd));o&&(n=o)}return n}var hl=2,J_=3,X_=1,Y_=2,Q_=3,Z_=1,eN=2,tN=3;function sq(e){let t;try{t=H(e,{inputKind:"SCIP sanitization input",maxBytes:se})}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}try{return nN(t,e)}catch(n){if(n instanceof ze)return{removedDefinitionOccurrences:0,touchedDocuments:0};throw n}}function nN(e,t){let n=new TextDecoder,r=new Set;for(let s of et(e))if(s.wireType===2)if(s.fieldNumber===hl)for(let a of et(e,s.valueStart,s.valueEnd))a.wireType===2&&(a.fieldNumber===X_?Ie(n.decode(e.subarray(a.valueStart,a.valueEnd))):a.fieldNumber===Q_&&Vg(e,a,n,r));else s.fieldNumber===J_&&Vg(e,s,n,r);let i=0,o=[];for(let s of et(e)){if(s.wireType!==2||s.fieldNumber!==hl)continue;let a=rN(e,s,n,r);a>0&&(i+=a,o.push(s))}return i===0?{removedDefinitionOccurrences:0,touchedDocuments:0}:(iN(e,t,o,r),{removedDefinitionOccurrences:i,touchedDocuments:o.length})}function Vg(e,t,n,r){for(let i of et(e,t.valueStart,t.valueEnd)){if(i.wireType!==2||i.fieldNumber!==Z_)continue;let o=n.decode(e.subarray(i.valueStart,i.valueEnd));o&&r.add(o)}}function rN(e,t,n,r){let i=0;for(let o of et(e,t.valueStart,t.valueEnd)){if(o.wireType!==2||o.fieldNumber!==Y_)continue;let s="",a=0;for(let c of et(e,o.valueStart,o.valueEnd))c.fieldNumber===eN&&c.wireType===2?s=n.decode(e.subarray(c.valueStart,c.valueEnd)):c.fieldNumber===tN&&c.wireType===0&&(a=c.varint);(a&Sl.Definition)!==0&&!r.has(s)&&(i+=1)}return i}function iN(e,t,n,r){let i=`${t}.sanitize-tmp`,o=V_(i,"w",384);try{let s=0;for(let a of n){Ri(o,e.subarray(s,a.fieldStart));let c=U_(yl,e.subarray(a.valueStart,a.valueEnd));c.occurrences=c.occurrences.filter(u=>(u.symbolRoles&Sl.Definition)===0||r.has(u.symbol));let l=z_(yl,c);Ri(o,Rs(hl)),Ri(o,Ii(l.byteLength)),Ri(o,l),s=a.fieldEnd}Ri(o,e.subarray(s))}catch(s){throw $g(o),W_(i,{force:!0}),s}$g(o),H_(i,t)}function Ri(e,t){let n=0;for(;n<t.byteLength;)n+=q_(e,t,n,t.byteLength-n)}function Hg(e){let t=new Set;for(let o of e.documents){Ie(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&Sl.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(Gg(yl,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:Gg(K_,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{closeSync as wi,openSync as bl,readSync as oN,renameSync as sN,rmSync as Ug,statSync as aN,writeFileSync as zg,writeSync as Kg}from"fs";import{create as xl,fromBinary as cN,toBinary as lN}from"@bufbuild/protobuf";import{deserializeSCIP as Jg,serializeSCIP as Xg,DocumentSchema as uN,IndexSchema as dN,MetadataSchema as Wg,SymbolInformationSchema as pN}from"@c4312/scip";function Yg(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=fN(e),n=mN(e.flatMap(i=>i.documents??[])),r=Zg(e.flatMap(i=>i.externalSymbols??[]));return xl(dN,{metadata:t,documents:n,externalSymbols:r})}function gq(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Jg(H(i,{inputKind:"SCIP merge input",maxBytes:se}))),r=Yg(n);return zg(t,Xg(r)),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function yq(e,t){if(e.length===0)throw new Error("Cannot concatenate zero SCIP files");let n=0;for(let o of e)if(n+=aN(o).size,n>se)throw new Error(`Concatenated SCIP output exceeds the ${se}-byte artifact limit. Reduce the indexed project scope or use compatible cached generations.`);let r=Buffer.allocUnsafe(1024*1024),i=bl(t,"w",384);try{for(let o of e){let s=bl(o,"r");try{let a=0;for(;(a=oN(s,r,0,r.byteLength,null))>0;){let c=0;for(;c<a;)c+=Kg(i,r,c,a-c)}}finally{wi(s)}}}catch(o){throw wi(i),Ug(t,{force:!0}),o}wi(i)}function hq(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=J("reindex.publish.scip-output.deserialize",()=>e.map(o=>Jg(H(o,{inputKind:"SCIP merge input",maxBytes:se})))),r=J("reindex.publish.scip-output.merge",()=>Yg(n)),i=J("reindex.publish.scip-output.sanitize",()=>Hg(r));return J("reindex.publish.scip-output.serialize",()=>zg(t,Xg(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,touchedDocuments:i.touchedDocuments}}var qg=1;function Qg(e,t,n){let r=H(e,{inputKind:"SCIP normalization input",maxBytes:se}),i=Ei(r),o=[];for(let c of et(r))c.fieldNumber===qg&&c.wireType===2&&o.push(c);if(o.length===0)throw new Error("Cannot rebase a SCIP index without metadata");if((i??"")!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${i??""}`);let s=`${e}.rebase-tmp`,a=bl(s,"w",384);try{let c=0;for(let l of o){Pi(a,r.subarray(c,l.fieldStart));let u=cN(Wg,r.subarray(l.valueStart,l.valueEnd));u.projectRoot=n;let d=lN(Wg,u);Pi(a,Rs(qg)),Pi(a,Ii(d.byteLength)),Pi(a,d),c=l.fieldEnd}Pi(a,r.subarray(c))}catch(c){throw wi(a),Ug(s,{force:!0}),c}wi(a),sN(s,e)}function Pi(e,t){let n=0;for(;n<t.byteLength;)n+=Kg(e,t,n,t.byteLength-n)}function fN(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 mN(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,xl(uN,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:gN([...r.occurrences,...n.occurrences]),symbols:Zg([...r.symbols,...n.symbols]),text:hN(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function gN(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 Zg(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,xl(pN,{symbol:r.symbol,documentation:SN([...r.documentation,...n.documentation]),relationships:yN([...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 yN(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 hN(e,t){return e?t?e.length>=t.length?e:t:e:t}function SN(e){return[...new Set(e)]}import{createHash as Cl}from"crypto";import{closeSync as bN,existsSync as O,mkdirSync as xN,openSync as vN,readSync as IN,readdirSync as Fl,renameSync as Rl,rmSync as Ci,statSync as An}from"fs";import{basename as Tl,dirname as dt,join as N,relative as ey}from"path";var Pl=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function ny(e){let t=Z(e.outputDb),n=CN(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=FN(e,n),o=Nl({generationRoot:t,databasePath:e.tempOutputDb,indexPath:O(r)?r:void 0,verifiedIndexArtifact:i,metadataPath:O(e.tempMetaPath)?e.tempMetaPath:void 0}),s=(e.now??(()=>new Date))().toISOString(),a={version:Dn,currentGeneration:o.identity,artifactSet:"immutable-v1",...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:s},c=De(N(t,"state.json"),a,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||El(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),El(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),El(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let l=o.identity,u={...a,stableMirrors:_l(e.outputDb,e.outputScip)};De(N(t,"state.json"),u,{spacing:2,trailingNewline:!0});let d=ry(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 EN(e,t,n,r=()=>new Date){if(!O(e))return null;let i=en(e),o=N(Z(e),"state.json");if(i?.artifactSet==="immutable-v1"&&hi(e,i.currentGeneration))return i;let s=Z(e),a=!i&&O(o)?_N(n,e,t):void 0;if(a&&!Si(s,a))return null;let c=Nl({generationRoot:s,databasePath:e,indexPath:O(t)?t:void 0,metadataPath:O(n)?n:void 0,forcedIdentity:i?.currentGeneration??a}),l={version:Dn,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:_l(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??r().toISOString()};return De(N(s,"state.json"),l,{spacing:2,trailingNewline:!0}),l}function Tq(e,t,n=()=>new Date){if(!O(e)||!O(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=en(e),i=Z(e),o=Nl({generationRoot:i,databasePath:e,indexPath:O(N(dt(e),"index.scip"))?N(dt(e),"index.scip"):void 0,metadataPath:t}),s=r&&r.currentGeneration!==o.identity?sy(e,r.currentGeneration):void 0,a={version:Dn,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:_l(e,N(dt(e),"index.scip")),...s?{previousGeneration:s}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return De(N(Z(e),"state.json"),a,{spacing:2,trailingNewline:!0}),ry(e,{now:n}),a}function ry(e,t={}){let n=RN(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=Nt(Ss(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=en(e),a=iy(e),c=rl(e,a.map(g=>g.identity),{isProcessAlive:t.isProcessAlive??kn,readProcessIdentity:t.readProcessIdentity??Tt}),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((g,S)=>g+S.logicalBytes,0),p=0,f=0;for(let g of a){if(u<=n.maxGenerations&&d<=n.maxLogicalBytes)break;l.has(g.identity)||(t.onBeforeRemove?.(g.identity),Ci(g.path,{recursive:!0,force:!0}),u-=1,d-=g.logicalBytes,p+=1,f+=g.logicalBytes)}let m=u>n.maxGenerations||d>n.maxLogicalBytes,y={state:m?"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,...m?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return ty(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{ty(e,a)}catch{}return a}finally{o.release()}}function _q(e){let t=Z(e);if(!O(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...Pl},reason:"local immutable generation store does not exist"};let n=PN(e),r=n?.limits??{...Pl},i=Nt(Ss(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=iy(e),s=en(e),a=rl(e,o.map(l=>l.identity),{isProcessAlive:kn,readProcessIdentity:Tt},{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 RN(e={}){let t={...Pl,...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 iy(e){let t=Z(e);return O(t)?Fl(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):oy(r);return{identity:n.name,path:r,logicalBytes:o,modifiedAtMs:An(r).mtimeMs}}).sort((n,r)=>n.modifiedAtMs-r.modifiedAtMs||n.identity.localeCompare(r.identity)):[]}function oy(e){let t=0;for(let n of Fl(e,{withFileTypes:!0})){let r=N(e,n.name);n.isDirectory()?t+=oy(r):n.isFile()&&(t+=An(r).size)}return t}function ty(e,t){Zt(N(Z(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function PN(e){try{let t=JSON.parse(T(N(Z(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 ws(e,t=N(dt(e),"meta.json")){let n=N(Z(e),"state.json");if(!O(n))return{state:"legacy",statePath:n};let r=en(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=hi(e,r.currentGeneration),o=i!==null,s=i?wN(e,t,i,r):!1,a=r.previousGeneration?O(N(dt(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 wN(e,t,n,r){if(r.stableMirrors&&(r.stableMirrors.databaseFileIdentity!==kt(e)||r.stableMirrors.indexFileIdentity!==void 0&&r.stableMirrors.indexFileIdentity!==kt(N(dt(e),"index.scip")))||!wl(e,n.database))return!1;let i=N(dt(e),"index.scip");if(n.index&&!wl(i,n.index))return!1;if(!n.metadata)return!O(t);if(!O(t))return!1;let o=N(Z(e),n.identity,n.metadata.file);return O(o)&&tn(T(t,"reindex metadata"))===tn(T(o,"immutable reindex metadata"))}function wl(e,t){return O(e)&&An(e).isFile()&&An(e).size===t.size}function CN(e){let t=EN(e.outputDb,e.outputScip,e.metaPath);return t?sy(e.outputDb,t.currentGeneration):void 0}function FN(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let n=ws(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=hi(e.outputDb,t.generationIdentity);if(!r?.index||!wl(e.outputScip,r.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return r.index}function _l(e,t){return{databaseFileIdentity:kt(e),...O(t)?{indexFileIdentity:kt(t)}:{}}}function sy(e,t){let n=N(Z(e),t),r=N(n,Tl(e)),i=N(n,"meta.json");return{generationIdentity:t,databasePath:ey(dt(e),r),...O(i)?{metadataPath:ey(dt(e),i)}:{}}}function TN(e){if(O(e))for(let t of Fl(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&Ci(N(e,t.name),{recursive:!0,force:!0})}function _N(e,t,n=N(dt(t),"index.scip")){let r=Cl("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(Ps(t)),O(n)&&r.update(`\0${Ps(n)}`),O(e)&&r.update(`\0${tn(T(e,"reindex metadata"))}`),r.digest("hex")}function Nl(e){let t=vl(e.databasePath),n=e.indexPath?e.verifiedIndexArtifact?kN(e.indexPath,e.verifiedIndexArtifact):vl(e.indexPath):void 0,r=e.metadataPath?vl(e.metadataPath):void 0,i=e.forcedIdentity??NN(t,n,e.metadataPath),o=N(e.generationRoot,i),s=N(o,hs);if(O(s)){let l=Si(e.generationRoot,i);if(l&&ay(o,l.database,t)&&DN(o,l.index,n)&&AN(o,l.metadata,e.metadataPath))return{identity:i,directorySync:D(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let a=[me(e.generationRoot)];TN(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;Ci(c,{recursive:!0,force:!0}),xN(c,{recursive:!0});try{a.push(Il(e.databasePath,N(c,t.file))),n&&e.indexPath&&a.push(Il(e.indexPath,N(c,n.file))),r&&e.metadataPath&&a.push(Il(e.metadataPath,N(c,r.file)));let l=De(N(c,hs),{version:nl,identity:i,database:t,...n?{index:n}:{},...r?{metadata:r}:{}},{spacing:2,trailingNewline:!0});l.directorySync!=="not-requested"&&a.push(l.directorySync),a.push(D(c)),Rl(c,o),a.push(D(e.generationRoot))}finally{Ci(c,{recursive:!0,force:!0})}return{identity:i,directorySync:q(...a)}}function NN(e,t,n){let r=Cl("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${tn(T(n,"reindex metadata"))}`),r.digest("hex")}function vl(e){return{file:Tl(e),size:An(e).size,sha256:Ps(e)}}function kN(e,t){if(t.file!==Tl(e)||An(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function Ps(e){let t=Cl("sha256"),n=vN(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=LN(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{bN(n)}return t.digest("hex")}function LN(e,t){let n=0;for(;n<t.length;){let r=IN(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function Il(e,t){return ui(e,t,{mode:292})}function ay(e,t,n){let r=N(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&O(r)&&An(r).size===t.size&&Ps(r)===t.sha256}function DN(e,t,n){return!t||!n?t===n:ay(e,t,n)}function AN(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=N(e,t.file);return O(r)&&tn(T(r,"stored reindex metadata"))===tn(T(n,"candidate reindex metadata"))}function El(e,t){Ci(`${t}.tmp-replace`,{force:!0}),Rl(e,`${t}.tmp-replace`),Rl(`${t}.tmp-replace`,t)}import{createHash as Sy,randomUUID as VN}from"crypto";import{existsSync as ft,lstatSync as Dl,mkdirSync as xr,mkdtempSync as by,readdirSync as xy,realpathSync as vy,renameSync as On,rmSync as nn,statSync as Ns}from"fs";import{dirname as Al,join as R,resolve as Lt}from"path";import{setTimeout as HN}from"timers/promises";import{pathToFileURL as dy}from"url";import WN from"better-sqlite3";import{lstatSync as ON,readdirSync as MN}from"fs";import{join as jN,relative as BN,resolve as kl,sep as $N}from"path";var Fi=1,Ll="language-indexes",cy=["index.db","index.scip","meta.json"],ly=[Ll,bi,xi];function Cs(e){let t=[];for(let n of cy)GN(e,n),t.push(n);for(let n of ly)uy(e,n,t);return{version:Fi,files:t.sort()}}function Fs(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(!cy.includes(e)&&!ly.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function pt(e,t){let n=Fs(t),r=kl(e),i=kl(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${$N}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function uy(e,t,n){let r=jN(e,t),i;try{i=MN(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()?uy(e,s,n):o.isFile()&&n.push(Fs(s))}}function GN(e,t){let n=pt(e,t),r;try{r=ON(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(BN(kl(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Ml=1,py="SCIP_QUERY_SHARED_CACHE",qN=2,Ts=JSON.stringify({cliVersion:Zi,artifactCatalogVersion:Fi,postIndexAugmentationSchemaVersion:qN,sqliteGenerationStoreVersion:Dn,typescriptFragmentStoreVersion:ul,typescriptOverlayStoreVersion:Es}),jl="manifest.json",Iy="shared-cache.json",UN=6e4,Bl=[Ll,bi,xi];function _s(e,t){if(!e.clean||!e.treeOid)return;let n=Fy(JSON.stringify({version:Ml,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:eo(t),producerIdentity:Ts}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Ts,generationId:n,repositoryCacheDir:bo(e.repositoryId)}}function cU(e,t,n){if(!ik(n))return!1;let r=_s(e,n);if(!r)return!1;try{let i=wy(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(j(R(r.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:z}));return o.version!==1||o.repositoryId!==i.repositoryId||o.worktreeId!==i.worktreeId||Lt(o.projectRoot)!==Lt(e.projectRoot)||o.treeOid!==e.treeOid||Lt(o.localCacheDir)!==Lt(t)||o.ownershipChecksum!==ks(o)||o.baseGenerationId!==r.generationId||o.activeGenerationId!==r.generationId?!1:Dt(r,!1)!==null}catch{return!1}}function Ey(e,t,n){if(process.env[py]==="0")return`${py}=0`;if(!Fa(n))return"explicit cache or database override";if(_a(Al(t))!==_a(So(e))||t!==R(Al(t),"index.db"))return"index database is outside the managed worktree cache"}function lU(e,t,n){if(!Fa(t))return;let r=n??Lr(e);return r?R(bo(r.repositoryId),"evidence.db"):void 0}function Dt(e,t=!0){let n=$l(e),r;try{r=Py(j(R(n,jl),{inputKind:"shared-generation manifest",maxBytes:z}))}catch{return null}if(r.generationId!==e.generationId||r.repositoryId!==e.repositoryId||r.treeOid!==e.treeOid||r.producerIdentity!==e.producerIdentity||!Tr(r.fingerprint,e.fingerprint)||!QN(n))return null;if(!t)return r;try{for(let i of r.artifacts){let o=pt(n,i.path),s=Ns(o);if(!s.isFile()||s.size!==i.size||cn(o,{inputKind:"shared-generation artifact",maxBytes:se})!==i.sha256)return null}}catch{return null}return r}function fy(e,t,n,r){if(!e.treeOid)return null;let i=Yn(t,n),o=R(ho(),"repositories",e.repositoryId),s;try{let l=Dl(o);if(!l.isDirectory()||l.isSymbolicLink())return null;s=vy(o)}catch{return null}let a=R(s,"generations"),c=[];try{for(let l of xy(a)){if(!/^[a-f0-9]{64}$/.test(l))continue;let u=R(a,l),d;try{d=Dl(u)}catch{continue}if(!(!d.isDirectory()||d.isSymbolicLink()))try{let p=Py(j(R(u,jl),{inputKind:"shared-generation baseline manifest",maxBytes:z}));p.generationId===l&&p.repositoryId===e.repositoryId&&p.producerIdentity===Ts&&ZN(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 m=hy(l.fingerprint,r)-hy(u.fingerprint,r);if(m!==0)return m}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=Dt(u);if(d)return{snapshot:u,manifest:d}}return null}function Ry(e){let t=Nt(R(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 zN(e)}finally{t.release()}}function zN(e){let t=Dt(e.snapshot);if(t)return my(e.snapshot,t);if(!Li(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=yy(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=Cs(e.sourceCacheDir),i=R(e.snapshot.repositoryCacheDir,"generations"),o=[me(i)],s=by(R(i,`.tmp-${process.pid}-`));try{let a=[];for(let m of r.files){let y=pt(e.sourceCacheDir,m),g=pt(s,m);o.push(Di(y,g,292)),e.onPublicationStage?.("after-artifact-flushed",m);let S=Ns(g).size;a.push({path:m,size:S,sha256:cn(g,{inputKind:"staged shared-generation artifact",maxBytes:se})})}let c=Ei(H(R(s,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:se}));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(yy(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let u={version:Ml,artifactCatalogVersion:Fi,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((m,y)=>m.path.localeCompare(y.path))},d=De(R(s,jl),u,{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&o.push(d.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(D(s)),e.onPublicationStage?.("after-staging-directory-synced");let p=$l(e.snapshot);try{if(ft(p)&&!Dt(e.snapshot)){let m=`${p}.corrupt-${process.pid}-${Date.now()}`;On(p,m),nn(m,{recursive:!0,force:!0})}On(s,p)}catch(m){let y=Dt(e.snapshot);if(y)return my(e.snapshot,y);throw m}e.onPublicationStage?.("after-generation-renamed"),o.push(D(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{nn(s,{recursive:!0,force:!0})}}function my(e,t){let n=D(R(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:n==="synced"?"directory-durable":"file-flushed",directorySync:n}}function _i(e){let t=$l(e.snapshot);xr(e.targetCacheDir,{recursive:!0});let n=Nt(R(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=by(R(e.targetCacheDir,".shared-hydrate-")),rk(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=pt(t,c.path),u=pt(r,c.path);if(Di(l,u),Ns(u).size!==c.size||cn(u,{inputKind:"hydrated shared-generation artifact",maxBytes:se})!==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")&&Qg(pt(r,c.path),e.manifest.scipProjectRoot,s);if(!Li(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=ek(e.targetCacheDir,r),o=!0,tk(r,e.targetCacheDir,i),ny({tempOutputScip:R(r,"index.scip"),tempOutputDb:R(r,"index.db"),tempMetaPath:R(r,"meta.json"),outputScip:R(e.targetCacheDir,"index.scip"),outputDb:R(e.targetCacheDir,"index.db"),metaPath:R(e.targetCacheDir,"meta.json"),now:e.now});let a=ws(R(e.targetCacheDir,"index.db"),R(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);e.persistLease!==!1&&Ol(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&nk(e.targetCacheDir,i),s}finally{r&&nn(r,{recursive:!0,force:!0}),n.release()}}function uU(e,t,n,r){let i=Ey(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??Lr(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean){if(ft(n.dbPath))return ki(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let d=t.languages??xs(e),p=Xn(e,d,Ni(t)),f=fy(o,d,Ni(t),p);return f?(_i({snapshot:f.snapshot,manifest:f.manifest,targetCacheDir:n.cacheDir,targetProjectRoot:e,persistLease:!1,lockWaitMs:0}),gy(f.snapshot,n.cacheDir),{kind:"overlay"}):(ki(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"})}let s=t.languages??xs(e),a=Xn(e,s,Ni(t)),c=_s(o,a);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let l=Dt(c);if(l)return _i({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let u=XN(c,e);if(!u){if(!ft(n.dbPath)){let d=fy(o,s,Ni(t),a);if(d)return _i({snapshot:d.snapshot,manifest:d.manifest,targetCacheDir:n.cacheDir,targetProjectRoot:e,persistLease:!1,lockWaitMs:0}),gy(d.snapshot,n.cacheDir),{kind:"overlay"}}return ki(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,_i({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 dU(e,t,n,r){let i=Ey(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??Lr(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return ki(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??xs(e),a=Xn(e,s,Ni(t)),c=_s(o,a);if(!c)return ki(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=Dt(c);if(l)return Li(n.cacheDir,e,a)?(Ol(c,n.cacheDir,"local-fresh"),{kind:"local-fresh"}):(_i({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let u=Ls(n.cacheDir);return!u||!Tr(Fr(u.fingerprint),a)||JSON.stringify([...u.indexedLanguages??[]].sort())!==JSON.stringify([...s].sort())?{kind:"missed",reason:"local metadata does not match the clean worktree snapshot"}:Li(n.cacheDir,e,a)?(Ry({snapshot:c,sourceCacheDir:n.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let d=Lr(e);return(d?_s(d,a):void 0)?.generationId===c.generationId}}),Ol(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 pU(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??_t,o=i()+n,s=R(e.repositoryCacheDir,"locks"),a=R(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(Dt(e))return{kind:"generation-ready"};let l=gs(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 HN(Math.min(r,u))}return Dt(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Ol(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:ks(i)};return Gl(e.repositoryCacheDir,o,!0),o}function gy(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:ks(r)};return Gl(e.repositoryCacheDir,i,!0),i}function ki(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:ks(o)},a=bo(e.repositoryId),c=KN(a,s);return c||(Gl(a,s,!1),s)}function KN(e,t){try{let n=wy(t.localCacheDir);if(!n||n.repositoryId!==t.repositoryId||n.worktreeId!==t.worktreeId)return null;let r=JSON.parse(j(R(e,"worktrees",`${t.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:z})),i=Date.parse(t.lastSeenAt)-Date.parse(r.lastSeenAt);return JN(r,t)&&Number.isFinite(i)&&i<UN?r:null}catch{return null}}function JN(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 ks(e){return Fy(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:Lt(e.projectRoot),localCacheDir:Lt(e.localCacheDir)}))}function Py(e){let t=JSON.parse(e);if(t.version!==Ml||t.artifactCatalogVersion!==Fi||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!==Ts||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(Fs(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 Di(e,t,n=384){return ui(e,t,{mode:n})}function XN(e,t){for(let n of xd(t)){if(Lt(n.path)===Lt(t))continue;let r=So(n.path),i=Ls(r);if(!(!i||JSON.stringify(i.fingerprint)!==JSON.stringify(e.fingerprint)||JSON.stringify([...i.indexedLanguages??[]].sort())!==JSON.stringify([...e.fingerprint.languages].sort()))&&Li(r,n.path,e.fingerprint))try{return{manifest:Ry({snapshot:e,sourceCacheDir:r,sourceProjectRoot:n.path}).manifest,sourceProjectRoot:n.path}}catch{continue}}return null}function YN(e,t,n){xr(e,{recursive:!0}),De(R(e,Iy),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function yy(e){try{let t=Cs(e),n=Sy("sha256");for(let r of t.files){let i=pt(e,r),o=Ns(i).size;n.update(r).update("\0").update(String(o)).update("\0"),Vn(i,{inputKind:"source-generation artifact",maxBytes:se},s=>n.update(s)),n.update("\0")}return n.digest("hex")}catch{return null}}function Ls(e){try{let t=jt(j(R(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:z}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function QN(e){return Ls(e)?.scipCompanion!=="deferred"}function Ni(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function ZN(e,t){let n=Yn(e.languages,e);return JSON.stringify(n)===JSON.stringify(t)}function hy(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 $l(e){return R(e.repositoryCacheDir,"generations",e.generationId)}function wy(e){let t=JSON.parse(j(R(e,Iy),{inputKind:"worktree cache pointer",maxBytes:z}));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 Gl(e,t,n){let r=sg(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!ft(R(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=R(e,"worktrees");xr(i,{recursive:!0}),De(R(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),YN(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function ek(e,t){let n=R(t,".rollback"),r=new Map,i=new Map;xr(n,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=R(e,a),l=ft(c);r.set(a,l),l&&Di(c,R(n,"stable",a))}for(let a of Bl){let c=R(e,a),l=ft(c);if(l){let u=Dl(c);if(!u.isDirectory()||u.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=R(e,yi),s=ft(o);return s&&Cy(o,R(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:s}}function tk(e,t,n){for(let r of Bl){let i=R(t,r);if(n.managedDirectories.get(r)){let s=R(n.root,"managed",r);xr(Al(s),{recursive:!0}),On(i,s)}let o=R(e,r);ft(o)&&On(o,i)}}function nk(e,t){for(let i of Bl){let o=R(e,i),s=R(t.root,"managed",i);t.managedDirectories.get(i)?ft(s)&&(nn(o,{recursive:!0,force:!0}),On(s,o)):nn(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=R(e,i);if(!o){nn(s,{force:!0});continue}let a=`${s}.shared-restore-${VN()}`;Di(R(t.root,"stable",i),a),nn(s,{force:!0}),On(a,s)}let n=R(e,yi);nn(n,{recursive:!0,force:!0});let r=R(t.root,"sqlite-generations");t.generationStoreExisted&&ft(r)&&On(r,n)}function Cy(e,t){xr(t,{recursive:!0});for(let n of xy(e,{withFileTypes:!0})){let r=R(e,n.name),i=R(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?Cy(r,i):n.isFile()&&Di(r,i)}}function rk(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!Tr(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function Li(e,t,n,r=!0,i=!0){try{let o=Ls(e);if(!o||o.scipCompanion==="deferred"||!Tr(Fr(o.fingerprint),n)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...n.languages].sort()))return Ti("source validation rejected metadata"),!1;let s=Cs(e),a=ws(R(e,"index.db"),R(e,"meta.json"));if(r?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Ti(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new WN(R(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=Ei(H(pt(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:se}));return f!==l&&Ti(`source validation rejected SCIP root for ${p}: ${String(f)}`),f===l});return d||Ti("source validation rejected SCIP project roots"),d}catch(o){return Ti(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Ti(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function Vl(e){try{return dy(vy(e)).href}catch{return dy(Lt(e)).href}}function ik(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 Fy(e){return Sy("sha256").update(e).digest("hex")}import{spawn as lk}from"child_process";import{platform as By}from"os";import{performance as $y}from"perf_hooks";import{execFileSync as Ny}from"child_process";import{platform as ok}from"os";var ky=1e3,Ly=2*1024*1024,sk=25;function Dy(e,t,n=jy){let r=n.readIdentity(e),i=new Map;return r&&i.set(e,r),{rootPid:e,rootIdentity:r,ownsProcessGroup:t,knownMembers:i}}async function Ay(e,t,n=jy){if(!e.rootIdentity){let c=await Ai(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=Oy(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"&&!My(e,n))return{reaped:!0,reason:"terminated"};if(n.platform==="win32"){try{n.terminateWindowsTree(e.rootPid)}catch(l){let u=await Ai(e,t.forceMs,n);return{reaped:u,reason:u?"terminated":"signal-failed",detail:u?void 0:Hl(l)}}let c=await Ai(e,t.forceMs,n);return{reaped:c,reason:c?"terminated":"deadline"}}let i=Ty(e,"SIGTERM",n);if(await Ai(e,t.gracefulMs,n))return{reaped:!0,reason:"terminated"};let s=Ty(e,"SIGKILL",n);return await Ai(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 Oy(e,t){let n=t.readIdentity(e.rootPid);if(!n)return"exited";if(!e.rootIdentity||!Le(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 Ty(e,t,n){let r=Oy(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(!_y(o))return{reason:"signal-failed",detail:Hl(o)}}let i=null;for(let o of e.knownMembers.values()){let s=n.readIdentity(o.pid);if(!(!s||!Le(o,s)))try{n.signal(o.pid,t)}catch(a){!_y(a)&&i===null&&(i=Hl(a))}}return i===null?null:{reason:"signal-failed",detail:i}}async function Ai(e,t,n){let r=n.now()+t;for(;My(e,n);){if(n.now()>=r)return!1;await n.sleep(Math.min(sk,Math.max(1,r-n.now())))}return!0}function My(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&&Le(n,r))return!0}return!!(e.ownsProcessGroup&&t.isProcessGroupAlive(e.rootPid))}function ak(e){let t=ck(!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 ck(e){return Ny("ps",["-axo",e?"pid=,ppid=,rss=":"pid=,ppid="],{encoding:"utf8",timeout:ky,maxBuffer:Ly,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}function _y(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ESRCH"}function Hl(e){return e instanceof Error?e.message:String(e)}var jy={platform:ok(),now:Date.now,readIdentity:Tt,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 ak(e)}catch{return[]}},signal(e,t){process.kill(e,t)},terminateWindowsTree(e){Ny("taskkill.exe",["/PID",String(e),"/T","/F"],{timeout:ky,maxBuffer:Ly,stdio:"ignore",windowsHide:!0})},async sleep(e){await new Promise(t=>setTimeout(t,e))}};var IU={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},Mi=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 Oi(e,t){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${t} must be a positive finite number.`)}function Gy(e,t,n,r){let i=Math.max(0,r-n);i>0&&e.push(t.subarray(0,i))}function Vy(e,t,n){let r=Buffer.concat([...e,t]);e.length=0,e.push(r.subarray(Math.max(0,r.length-n)))}function EU(e){Oi(e.timeoutMs,"timeoutMs"),Oi(e.maxStdoutBytes,"maxStdoutBytes"),Oi(e.maxStderrBytes,"maxStderrBytes");let t=e.terminationGraceMs??1e3;Oi(t,"terminationGraceMs");let n=e.terminationForceMs??t;return Oi(n,"terminationForceMs"),new Promise((r,i)=>{let o=$y.now(),s=By()!=="win32"&&process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1",a=By()!=="win32"&&!s,c;try{c=lk(e.command,[...e.args??[]],{cwd:e.cwd,env:e.env,detached:a?!0:e.detached,stdio:["pipe","pipe","pipe"]})}catch(I){let P=I instanceof Error?I.message:String(I);i(new Mi("spawn",e.label,`${e.label} could not start: ${P}`,{cause:I,reaped:!0}));return}let l=[],u=[],d=0,p=0,f=!1,m=!1,y=null,g=!1,S=c.pid===void 0?null:Dy(c.pid,a),h=()=>{clearTimeout(x),e.signal?.removeEventListener("abort",b)},v=I=>{if(g||!y)return;g=!0,h();let P=Buffer.concat(l).toString("utf8"),k=Buffer.concat(u).toString("utf8"),V=I.reaped||!I.detail?"":` Process-tree cleanup failed: ${I.detail}`;i(new Mi(y.kind,e.label,`${y.message}${V}`,{timedOut:y.timedOut,reaped:I.reaped,stdout:P,stderr:k,stdoutTruncated:f,stderrTruncated:m}))},E=I=>{if(!(y||g)){if(y=I,!S){v({reaped:c.pid===void 0,reason:c.pid===void 0?"terminated":"identity-unavailable"});return}Ay(S,{gracefulMs:t,forceMs:n}).then(v,P=>{v({reaped:!1,reason:"signal-failed",detail:P instanceof Error?P.message:String(P)})})}},x=setTimeout(()=>{E({kind:"timeout",timedOut:!0,message:`${e.label} timed out after ${e.timeoutMs}ms.`})},e.timeoutMs);x.unref();let b=()=>{E({kind:"aborted",timedOut:!1,message:`${e.label} was cancelled.`})};e.signal?.addEventListener("abort",b,{once:!0}),e.signal?.aborted&&b(),c.stdout.on("data",I=>{let P=Buffer.isBuffer(I)?I:Buffer.from(I);e.outputLimitBehavior==="truncate-tail"?Vy(l,P,e.maxStdoutBytes):Gy(l,P,d,e.maxStdoutBytes),d+=P.length,d>e.maxStdoutBytes&&(f=!0,e.outputLimitBehavior!=="truncate-tail"&&E({kind:"stdout-limit",timedOut:!1,message:`${e.label} exceeded stdout limit (${e.maxStdoutBytes} bytes).`}))}),c.stderr.on("data",I=>{let P=Buffer.isBuffer(I)?I:Buffer.from(I);e.outputLimitBehavior==="truncate-tail"?Vy(u,P,e.maxStderrBytes):Gy(u,P,p,e.maxStderrBytes),p+=P.length,p>e.maxStderrBytes&&(m=!0,e.outputLimitBehavior!=="truncate-tail"&&E({kind:"stderr-limit",timedOut:!1,message:`${e.label} exceeded stderr limit (${e.maxStderrBytes} bytes).`}))}),c.on("error",I=>{if(!g&&!y){if(c.pid===void 0){h(),g=!0,i(new Mi("spawn",e.label,`${e.label} could not start: ${I.message}`,{cause:I,reaped:!0}));return}E({kind:"spawn",timedOut:!1,message:`${e.label} failed after start: ${I.message}`})}}),c.on("close",(I,P)=>{if(g||y)return;g=!0,h();let k=Buffer.concat(l).toString("utf8"),V=Buffer.concat(u).toString("utf8");r({status:I,signal:P,stdout:k,stderr:V,timedOut:!1,durationMs:$y.now()-o,stdoutTruncated:f,stderrTruncated:m})}),e.input===void 0?c.stdin.end():c.stdin.end(e.input)})}function wU(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function Hy(e){let t=X(e);return uk(t)?"test":dk(t)?"worker":pk(t)?"entry":fk(t)?"barrel":"source"}function uk(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 dk(e){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(e)}function pk(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 fk(e){return e==="index.ts"||e==="index.js"||e.endsWith("/index.ts")||e.endsWith("/index.js")||e.endsWith("/mod.rs")||e.endsWith("/__init__.py")}var mk=4;function Mn(e,t,n,r={}){return Wy(e,t,n,r.maxReexportDepth??mk,0,new Set)}function Wy(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:ct(e,t).flatMap(c=>c.sourcePath?c.kind==="named"&&!c.names.includes(n)?[]:Wy(e,c.sourcePath,n,r,i+1,new Set(o)):[])}import{createHash as Ui}from"crypto";import{setImmediate as qL}from"timers/promises";import{createRequire as UL}from"module";import{createHash as kk}from"crypto";var Ds=8;function vr(e,t,n){return Kl(qy(e,t,Ul(n),0,new Set))}function zl(e,t,n){return Wl(e,t,n,0,new Set)}function qy(e,t,n,r,i){if(r>Ds)return[];let o=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n);return o?Uy(e,t,o[1],o[2],r,i):/^[A-Za-z_$][\w$]*$/u.test(n)?zy(e,t,n,r,i):[]}function Uy(e,t,n,r,i,o){let s=[];for(let a of Wl(e,t,n,i+1,new Set(o))){let c=Ve(a.initializer);for(let l of c.namedChildren){if(l.type==="pair"){let u=l.childForFieldName("key")??l.namedChild(0);if(bk(u)!==r)continue;let d=l.childForFieldName("value")??l.namedChild(1);d&&s.push(...qy(e,a.definition.relativePath,Ul(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=hk(e,a.definition.relativePath,r,l);s.push(...d.length>0?d:[gk(a.definition,r,l)]);continue}if(l.type==="spread_element"){let u=l.namedChild(0);if(!u)continue;for(let d of Wl(e,a.definition.relativePath,Ul(u.text),i+1,new Set(o)))s.push(...Uy(e,d.definition.relativePath,d.definition.leaf,r,i+1,new Set(o)))}}}return Kl(s)}function gk(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 Wl(e,t,n,r,i){return r>Ds||!/^[A-Za-z_$][\w$]*$/u.test(n)?[]:zy(e,t,n,r,i).flatMap(o=>{let s=M(e,o.relativePath)?.rootNode,a=s?Sk(s,o.leaf):null;return a?[{definition:o,initializer:a}]:[]})}function zy(e,t,n,r,i){if(r>Ds)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=yk(e,t,n);if(a.length>0)return a;let c=ue(e,t).find(l=>l.localName===n&&l.sourcePath);if(c?.sourcePath){let l=c.kind==="namespace"||c.importedName==="default"?n:c.importedName;return ql(e,c.sourcePath,l,r+1,new Set(i))}return ql(e,t,n,r+1,new Set(i))}function yk(e,t,n){let r=e.get("SELECT id FROM documents WHERE relative_path = ?",t)?.id;return r===void 0?[]:(Se(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 ql(e,t,n,r,i){if(r>Ds)return[];let o=B(e,t).filter(s=>s.leaf===n);return o.length>0?o:Kl(ct(e,t).flatMap(s=>s.sourcePath?s.kind==="named"&&!s.names.includes(n)?[]:ql(e,s.sourcePath,n,r+1,new Set(i)):[]))}function hk(e,t,n,r){return B(e,t).filter(i=>i.leaf===n&&i.startLine<=r.startPosition.row&&i.endLine>=r.endPosition.row)}function Sk(e,t){let n=null;return ye(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 bk(e){return e?.text.replace(/^['"`]|['"`]$/gu,"")??null}function Ul(e){return e.replace(/\s+/gu,"").replace(/^\.\.\./u,"")}function Kl(e){return[...new Map(e.map(t=>[t.symbol,t])).values()]}function As(e){let t=e.replaceAll("\\","/");return Hy(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 xk=8;function nt(e,t){return t?Ir(e,t,0,new Set):null}function Ir(e,t,n,r){if(n>xk)return mt(t,"value-evaluation-depth");let i=Ve(t),o=wk(i);if(o)return Ck(e.file,i,o.term,o.value,o.precision);if(i.type==="binary_expression"&&/\+/u.test(i.text)){let c=i.namedChildren.map(l=>Ir(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 Fk(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 Rk(e,s,i,n,r);let a=Tk(i);return a?Pk(e,a.base,a.properties,i,n,r):i.type==="call_expression"||i.type==="call"?vk(e,i,n,r):mt(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=Ik(e,o);if(s.length!==1)return mt(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 mt(t,"call-return-cycle");let l=M(e.db,a.relativePath)?.rootNode;if(!l)return mt(t,"call-target-unparsed");let u=Ge(l,a.startLine,a.endLine);if(!u)return mt(t,"call-target-syntax-unavailable");let d=Ek(u);if(!d)return mt(t,"call-return-not-single-expression");let p=new Set(r);p.add(c);let f=Ir({db:e.db,file:a.relativePath,root:l},d,n+1,p);return f?Os(t,"bounded-call-return",f,a.symbol):mt(t,"call-return-unresolved")}function Ik(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=ue(e.db,e.file).find(s=>s.localName===t&&s.sourcePath&&s.kind!=="namespace");return o?.sourcePath?Mn(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=ue(e.db,e.file).find(i=>i.kind==="namespace"&&i.localName===n[1]&&i.sourcePath);return r?.sourcePath?Mn(e.db,r.sourcePath,n[2]).filter(i=>i.isFunctionLike):[]}function Ek(e){let t=e.childForFieldName("body");if(e.type==="arrow_function"&&t&&t.type!=="statement_block")return t;let n=[];return Jy(t??e,t??e,n),n.length!==1?null:n[0].childForFieldName("argument")??n[0].namedChild(0)}function Jy(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)Jy(e,r,n)}}function Rk(e,t,n,r,i){let o=`${e.file}\0${t}`;if(i.has(o))return mt(n,"value-cycle");i.add(o);let s=Jl(e.root,t);if(s){let m=Ir(e,s,r+1,i);return m?Os(n,"local-constant",m):mt(n,"non-foldable-local")}let a=ue(e.db,e.file).find(m=>m.localName===t&&m.sourcePath);if(!a?.sourcePath)return tt(n,t,"unresolved-identifier");if(a.kind==="namespace")return tt(n,t,"namespace-import-requires-property");let c=a.importedName==="default"?t:a.importedName,l=Mn(e.db,a.sourcePath,c);if(l.length!==1)return tt(n,t,l.length===0?"import-definition-missing":"import-definition-ambiguous");let u=l[0],d=M(e.db,u.relativePath)?.rootNode;if(!d)return tt(n,u.symbol,"import-definition-unparsed");let p=Jl(d,u.leaf);if(!p)return tt(n,u.symbol,"import-definition-non-value");let f=Ir({db:e.db,file:u.relativePath,root:d},p,r+1,i);return f?Os(n,"imported-constant",f,u.symbol):tt(n,u.symbol,"import-value-unresolved")}function Pk(e,t,n,r,i,o){let s=ue(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=Mn(e.db,s.sourcePath,c);if(f.length!==1)return tt(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:M(e.db,a)?.rootNode;if(!u)return tt(r,l??t,"member-definition-unparsed");let d=Jl(u,c);if(!d)return tt(r,l??t,"member-base-non-value");for(let f of n){let m=Ve(d);if(d=Nk(m,f),!d)return tt(r,l??`${t}.${n.join(".")}`,`member-property-missing:${f}`)}let p=Ir({db:e.db,file:a,root:u},d,i+1,o);return p?Os(r,"member-constant",p,l):tt(r,l??t,"member-value-unresolved")}function wk(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 Ck(e,t,n,r,i){return{value:r,evidence:"literal",term:n,precision:i,derivation:Ms("direct-literal","direct",e,t)}}function Fk(e,t,n,r,i,o){return{value:r,evidence:"constant",term:n,precision:i,derivation:{...Ms("constant-concatenation","mechanically-derived",e,t),inputFactIds:o.flatMap(s=>s.derivation.inputFactIds),sourceSpans:o.flatMap(s=>s.derivation.sourceSpans)}}}function Os(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 tt(e,t,n){return{value:e.text.trim(),evidence:"expression",term:{kind:"symbol",symbol:t},precision:"symbolic",derivation:Ms(n,"heuristic","",e)}}function mt(e,t){return{value:e.text.trim(),evidence:"expression",term:{kind:"unknown",reason:t},precision:"unknown",derivation:Ms(t,"heuristic","",e)}}function Ms(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 Tk(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}var Ky=new WeakMap;function _k(e){let t=Ky.get(e);if(t)return t;let n=new Map;return ye(e,r=>{if(r.type!=="variable_declarator")return;let o=(r.childForFieldName("name")??r.namedChild(0))?.text.trim();if(!o||n.has(o))return;let s=r.parent;if(!s||s.type!=="lexical_declaration"||!/^\s*(?:export\s+)?const\b/u.test(s.text))return;let a=r.childForFieldName("value")??r.namedChild(1);a&&n.set(o,a)}),Ky.set(e,n),n}function Jl(e,t){return _k(e).get(t)??null}function Nk(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 Lk=new WeakMap,rh=new Set(["delete","get","head","options","patch","post","put"]),Dk=/(?:^|\.)(?:app|router|server)$/u,Ak=new Set(["findFirst","findMany","findUnique","from","get","select"]),Ok=new Set(["create","delete","insert","remove","update","upsert"]),Mk=new Set(["execute","query","raw"]),Xy=/(?:\b(?:name|id)|['"`](?:name|id)['"`])\s*:/u,Yy=/(?:^\s*|[,{]\s*)(?:async\s+)?['"`]?(?:execute|handler|invoke|run)['"`]?\s*(?::|\([^)]*\)\s*\{)/mu,Qy=/\b[A-Za-z_$][\w$-]*[_-][\w$-]*\s*\(/u,Zy=/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s+[A-Za-z_$][\w$-]*\s*\(/iu,Ql=[Gk(),$k(),jk(),Vk(),Wk(),qk(),zk()],Yl=new Set(["exec","execFile","execFileSync","execSync","fork","spawn","spawnSync"]);function jk(){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=Bk(e.source),n=[];return rn(e.root,"call_expression",r=>{let i=Gi(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||!Yl.has(c))return;let l=jn(r),u=Ke(l[0],e)??{value:l[0]?.text.trim()||"<missing>",evidence:"expression"},d=["exec","execFile","execFileSync","execSync"].includes(c)?"process.exec":"process.spawn";n.push(pe(e,r,"builtin.node-child-process",d,[{name:"operation",value:c,evidence:"literal"},{name:"executable",...u}],"exact","node-child-process-import"))}),n}}}function Bk(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&&Yl.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&&Yl.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 we(e,t,n,r){let i=ji(r,"runtime-boundaries.context.ast",t,()=>n===void 0?M(e,t):ir(e,t,n));if(!i)return null;let o=i.rootNode;n!==void 0&&Lk.set(o,i);let s=n??F(e,t),a,c,l,u=()=>(c!==void 0||(c=ji(r,"runtime-boundaries.context.callable-sites",t,()=>{let d=le(t);return(d?fc(o,d):null)??ei(e,t)})),c);return{db:e,file:t,source:s,root:o,get constants(){return l??=ji(r,"runtime-boundaries.context.constants",t,()=>Zk(o)),l},ownerAt:d=>{let f=(a??=ji(r,"runtime-boundaries.context.definitions",t,()=>B(e,t,{rangeCorrectionEvidence:{source:s,callables:u()}},(g,S)=>ji(r,`runtime-boundaries.context.definitions.${g}`,t,S)))).filter(g=>g.startLine<=d&&g.endLine>=d).sort((g,S)=>g.endLine-g.startLine-(S.endLine-S.startLine)||g.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(g=>g.startLine<=d&&g.endLine>=d).sort((g,S)=>g.endLine-g.startLine-(S.endLine-S.startLine)||g.startLine-S.startLine)[0];return{file:t,symbol:null,name:y?.name??null,startLine:y?.startLine??d,endLine:y?.endLine??d}}}}function ji(e,t,n,r){return e?e(t,r,{file:n}):r()}function $k(){return{id:"builtin.effect-httpapi",supports:e=>Bi(e,"HttpApiEndpoint").size>0||Bi(e,"HttpApiBuilder").size>0,extract:e=>{let t=[],n=Bi(e.source,"HttpApiEndpoint"),r=Bi(e.source,"HttpApiGroup"),i=Bi(e.source,"HttpApiBuilder");return rn(e.root,"call_expression",o=>{let s=ih(o);if(!s)return;let a=jn(o);if(n.has(s.receiver)&&rh.has(s.member)){let y=Ke(a[0],e),g=Ke(a[1],e),S=th(o,r,"make",0,e);if(!y||!g||!S)return;let h=s.member.toUpperCase();t.push(pe(e,o,"builtin.effect-httpapi","http.handle",[{name:"method",value:h,evidence:"literal"},{name:"path",...g}],gt([{name:"path",...g}]),"effect-httpapi-endpoint-declaration")),t.push(pe(e,o,"builtin.effect-httpapi","framework.declare",Xl(S,y),gt(Xl(S,y)),"effect-httpapi-operation-declaration"));return}if(!["handle","handleRaw"].includes(s.member))return;let c=th(o,i,"group",1,e),l=Ke(a[0],e),u=a[1];if(!c||!l||!u)return;let d=Xl(c,l),p=vr(e.db,e.file,u.text),f=pe(e,o,"builtin.effect-httpapi","framework.handle",d,p.length===1?gt(d):"candidate","effect-httpapi-handler-registration"),m=p[0];p.length===1&&m&&(f.owner={file:m.relativePath,symbol:m.symbol,name:m.leaf,startLine:m.startLine,endLine:m.endLine}),t.push(f)}),t}}}function Xl(e,t){return[{name:"adapter",value:"effect-httpapi",evidence:"literal"},{name:"group",...e},{name:"operation",...t}]}function Bi(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(eh(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}`)&&eh(s)&&n.add(o[1])}return n}function eh(e){return e==="effect/unstable/httpapi"||e==="@effect/platform"||e.startsWith("@effect/platform/HttpApi")}function th(e,t,n,r,i){let o=e.parent;for(;o;){if(o.type==="call_expression"){let s=nh(o,t,n,r,i);if(s)return s;let a=o.childForFieldName("function")??o.namedChild(0),c=null;if(a&&eu(a,l=>{!c&&l.type==="call_expression"&&(c=nh(l,t,n,r,i))}),c)return c}o=o.parent}return null}function nh(e,t,n,r,i){let o=ih(e);return!o||o.member!==n||!t.has(o.receiver)?null:Ke(jn(e)[r],i)}function ih(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 Gk(){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)||$i(e,["axios"])||/\b(?:FastAPI|Flask|APIRouter|axum|Router::new)\b/u.test(e),extract:e=>{let t=[];return rn(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||!$i(e.source,["fastapi","flask"]))return;t.push(pe(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=Gi(n);if(!r)return;let i=r.split(".").at(-1)?.toLowerCase()??"",o=r.includes(".")?r.slice(0,r.lastIndexOf(".")):"",s=jn(n);if(i==="route"&&$i(e.source,["axum"])){let p=Ke(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(pe(e,n,"builtin.http","http.handle",[{name:"method",value:f.toUpperCase(),evidence:"literal"},{name:"path",...p}],gt([{name:"path",...p}]),"framework-adapter"));return}if(r==="fetch"||r.endsWith(".fetch")){let p=Ke(s[0],e);if(!p)return;let m=/\bmethod\s*:\s*['"`]([A-Za-z]+)['"`]/u.exec(s[1]?.text??"")?.[1]?.toUpperCase()??(s[1]?null:"GET"),y=[...m?[{name:"method",value:m,evidence:"literal"}]:[],{name:"path",...p}];t.push(pe(e,n,"builtin.http","http.request",y,m?gt(y):"candidate","call-expression"));return}if(!rh.has(i))return;let a=Ke(s[0],e);if(!a)return;let c=i.toUpperCase();if(Dk.test(o)&&$i(e.source,["express","fastify","hono","koa-router","@koa/router"])){t.push(pe(e,n,"builtin.http","http.handle",[{name:"method",value:c,evidence:"literal"},{name:"path",...a}],gt([{name:"path",...a}]),"framework-adapter"));return}let u=Xk(e.source,["axios"]),d=o.split(".")[0]??"";u.has(d)&&t.push(pe(e,n,"builtin.http","http.request",[{name:"method",value:c,evidence:"literal"},{name:"path",...a}],gt([{name:"path",...a}]),"client-adapter"))}),t}}}function Vk(){return{id:"builtin.capability-registry",supports:e=>Xy.test(e)&&Yy.test(e)||Qy.test(e)||Zy.test(e),extract:e=>{let t=[],n=new Set,r=[];return Xy.test(e.source)&&Yy.test(e.source)&&r.push("pair"),(Qy.test(e.source)||Zy.test(e.source))&&r.push("string","string_literal","template_string"),rn(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=oh(a,e),u=tL(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(pe(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(!Hk(o,a,s.index))continue;let c=`reference\0${a}\0${i.startPosition.row}`;n.has(c)||(n.add(c),t.push(pe(e,i,"builtin.capability-registry","registry.reference",[{name:"key",value:a,evidence:"literal"}],"exact","capability-instruction-reference")))}}),t}}}function Hk(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 Wk(){return{id:"builtin.registry",supports:e=>/(?:Handlers?|Registry|Routes?)\b/iu.test(e),extract:e=>{let t=[];return rn(e.root,["pair","call_expression"],n=>{if(n.type==="pair"){let o=eL(n);if(!o)return;let s=n.childForFieldName("key")??n.namedChild(0),a=n.childForFieldName("value")??n.namedChild(1),c=oh(s,e);if(!c||!a||!sh(a))return;let l=Zl(a)?"exact":"candidate";t.push(pe(e,n,"builtin.registry","registry.handle",[{name:"registry",value:o,evidence:"identifier"},{name:"key",...c}],gt([{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(pe(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 qk(){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=rL(e.root);return rn(e.root,"call_expression",r=>{let i=Gi(r);if(!i)return;let o=i.split("."),s=o.at(-1)??"",a=jn(r),c=a[0]?.text??"",l=nL(s,c);if(!l)return;let u=ah(o,n);if(!u)return;let d=Uk(a[0],e)??iL(c),p=oL(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(pe(e,r,"builtin.persistence",l,[{name:"resource",...p}],gt([{name:"resource",...p}]),f))}),t}}}function Uk(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}}:Ke(e,t)}function zk(){return{id:"builtin.queue",supports:e=>$i(e,["amqplib","bullmq","kafkajs","@aws-sdk/client-sqs","rabbitmq"])&&/\.(?:sendToQueue|consume|send|subscribe)\s*\(/u.test(e),extract:e=>{let t=[];return rn(e.root,"call_expression",n=>{let r=Gi(n);if(!r)return;let i=r.split(".").at(-1)??"",o=jn(n),s=i==="sendToQueue"||i==="send"?"queue.send":i==="consume"||i==="subscribe"?"queue.consume":null;if(!s)return;let a=i==="send"||i==="subscribe"?Yk(o[0],"topic",e):Ke(o[0],e);a&&t.push(pe(e,n,"builtin.queue",s,[{name:"address",...a}],gt([{name:"address",...a}]),"framework-adapter"))}),t}}}function pe(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:${kk("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:Kk(r),executionDomain:Jk(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:As(e.file)}}function Kk(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 Jk(e){let t=e.replaceAll("\\","/"),n=/^(apps|services|packages)\/([^/]+)/u.exec(t);return n?`${n[1]}/${n[2]}`:null}function $i(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 Xk(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 js(e,t,n,r,i,o,s){return pe(e,t,n,r,i,o,s)}function Gi(e){return(e.childForFieldName("function")??e.namedChild(0))?.text.replace(/\s+/gu,"")??null}function jn(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function Ke(e,t){let n=nt(t,e);return n?{value:n.value,evidence:n.evidence,term:n.term,derivation:n.derivation}:null}function Yk(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 Ke(i,n)}function oh(e,t){if(!e)return null;let n=Ke(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 gt(e,t="exact"){return t==="candidate"||e.some(n=>n.evidence==="expression")?"candidate":t==="derived"||e.some(n=>n.evidence==="constant")?"derived":"exact"}function Qk(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 Zk(e){let t=new Map;return eu(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=Qk(i);o!==null&&t.set(r.text,o)}),t}function eL(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 Zl(e){return/(?:function|lambda|method)/u.test(e.type)||e.type==="arrow_function"}function sh(e){return Zl(e)||e.type==="member_expression"?!0:e.type==="identifier"&&/(?:command|controller|dispatch|handle|handler)/iu.test(e.text)}function tL(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&&sh(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 ah(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 nL(e,t){if(Ak.has(e))return"database.read";if(Ok.has(e))return"database.write";if(!Mk.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 rL(e){let t=new Set;return rn(e,"call_expression",n=>{let r=Gi(n);if(!r)return;let i=r.split(".");if(!(i.at(-1)!=="transaction"||!ah(i)))for(let o of jn(n)){if(!Zl(o))continue;let a=(o.childForFieldName("parameters")??o.namedChildren.find(l=>/parameters/u.test(l.type)))?.namedChildren[0],c=a?Kr(a):null;c&&t.add(c)}}),t}function iL(e){let t=ch(e);return t?{value:t,evidence:"identifier",term:{kind:"symbol",symbol:t}}:null}function oL(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=ch(r.value);return i?{value:i,evidence:r.evidence}:null}function ch(e){return/\b(?:from|into|update|table)\s+(?:\$\{\s*)?['"`]?([A-Za-z_$][\w$.-]*)/iu.exec(e)?.[1]??null}function eu(e,t){t(e);for(let n of e.namedChildren)eu(n,t)}function rn(e,t,n){for(let r of zr(e,t))n(r)}var sL=C("resolved-call-syntax",{clearGroups:[]}),tu=C("resolved-call-sites",{clearGroups:[]}),aL=C("resolved-call-sites-reference-evidence",{clearGroups:[]});function nu(e,t){return tu.get(e,t.symbolId,()=>uh(e,t,cL(e,t)))}function lh(e,t){let n=[...new Map(t.map(o=>[o.symbolId,o])).values()],r=n.filter(o=>!tu.has(e,o.symbolId)),i=dh(e,r);return new Map(n.map(o=>[o.symbolId,tu.get(e,o.symbolId,()=>uh(e,o,i.get(o.symbolId)??[]))]))}function uh(e,t,n){let r=[],i=[],o=new Set,s=new Set;for(let a of n){o.add(a.file);let c=sL.get(e,a.file,()=>uL(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:pr(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 cL(e,t){return dh(e,[t]).get(t.symbolId)??[]}function dh(e,t){if(!lL(e))return new Map(t.map(r=>[r.symbolId,Bc(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 rs(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 lL(e){return aL.get(e,"project",()=>!!e.get("SELECT 1 AS present FROM mentions WHERE role != 1 LIMIT 1"))}function uL(e,t){let n=M(e,t)?.rootNode;if(!n)return null;let r=new Map;for(let i of zr(n,["call_expression","call"])){let o=i.childForFieldName("function")??i.namedChild(0);if(!o)continue;let s=Rt(o);if(!s)continue;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])}return{byLeaf:r}}var dL=C("call-parameter-value-flow",{clearGroups:[]});function Vi(e,t){let n=`${t.callee.symbolId}\0${t.file}\0${t.callNode.startIndex}\0${t.callNode.endIndex}`;return dL.get(e,n,()=>pL(e,t))}function Hi(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 pL(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=M(e,t.caller.relativePath)?.rootNode,i=r?Ge(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=Jt(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 fL=8,mL=8;function fh(e,t,n=[]){let r=[],i=gL(e,n,r),o=i.summaries,s=yL(e,t,o,r),a=hL(e,t,r);return{observations:CL([...s.observations,...a]),bodySummaries:o.size,discriminatorSummaries:s.summaries,filesInspected:i.filesInspected,errors:r}}function gL(e,t,n){let r=new Map,i=[],o=new Map,s=a=>{if(o.has(a))return o.get(a)??null;let c=we(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>=fL))try{for(let c of nu(e,a.definition).sites){if(!s(c.file))continue;let u=c.caller;if(!u)continue;let d=Hi(Vi(e,c),a.parameterIndexes);if(d.length===0)continue;let p={definition:u,parameterIndexes:bh(d),depth:a.depth+1,proofSpans:[...a.proofSpans,{file:c.file,startLine:c.startLine,endLine:c.endLine}]};vL(r,p)&&i.push(r.get(u.symbol))}}catch(c){n.push(`builtin.carrier body summary failed for ${a.definition.relativePath}: ${ou(c)}`)}}return{summaries:r,filesInspected:new Set(t.map(a=>a.definition.relativePath)).size}}function yL(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=gh(a);if(!c)continue;let l=we(e,a.source.file);if(!l)continue;let u=yh(l.root,a.source.startLine),d=u.find(h=>h.startPosition.row===a.source.startLine)??u[0];if(!d)continue;let p=iu(d);if(!p)continue;let f=vr(e,a.source.file,p.text);if(f.length!==1)continue;let m=n.get(f[0].symbol);if(!m)continue;let y=a.owner.symbol?B(e,a.owner.file).find(h=>h.symbol===a.owner.symbol):null;if(!y)continue;let g=IL(l,y),S=Bs(d);for(let h of m.parameterIndexes){let v=RL(l,S[h]);if(v)for(let E of PL(v)){let x=hh(E),b=Sh(E);if(!x||!b)continue;let I=g.indexOf(b.text.trim());if(I>=0){let k={definition:y,carrier:c,field:x,parameterIndex:I,depth:0,proofObservationIds:[a.id],proofSpans:[a.source,{file:a.source.file,startLine:E.startPosition.row,endLine:E.endPosition.row}]},V=ph(k);i.has(V)||(i.set(V,k),o.push(k));continue}let P=nt(l,b);!P||P.evidence==="expression"||s.push(ru(l,E,"carrier.publish",c,x,P.value,[a.id]))}}}for(;o.length>0;){let a=o.shift();if(!(a.depth>=mL))try{for(let c of nu(e,a.definition).sites){let l=we(e,c.file);if(!l)continue;let u=c.callNode,d=Bs(u)[a.parameterIndex];if(!d)continue;let p=nt(l,d);p&&p.evidence!=="expression"&&s.push(ru(l,u,"carrier.publish",a.carrier,a.field,p.value,a.proofObservationIds));let f=c.caller;if(!f)continue;let m=Vi(e,c).transfers.find(S=>S.calleePosition===a.parameterIndex)?.callerPosition;if(m===void 0)continue;let y={...a,definition:f,parameterIndex:m,depth:a.depth+1,proofSpans:[...a.proofSpans,{file:c.file,startLine:c.startLine,endLine:c.endLine}]},g=ph(y);i.has(g)||(i.set(g,y),o.push(y))}}catch(c){r.push(`builtin.carrier discriminator summary failed for ${a.definition.relativePath}: ${ou(c)}`)}}return{observations:s,summaries:i.size}}function hL(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=gh(o);if(!s)continue;let a=we(e,o.source.file);if(!a)continue;let c=yh(a.root,o.source.startLine)[0];if(c)for(let l of Bs(c).slice(1)){let u=vr(e,o.source.file,l.text);for(let d of u)try{let p=we(e,d.relativePath);if(!p)continue;let f=Ge(p.root,d.startLine,d.endLine);if(!f)continue;ye(f,m=>{if(m.type!=="call_expression")return;let y=iu(m);if(!y)return;let g=/^([A-Za-z_$][\w$]*)\s*\[\s*([A-Za-z_$][\w$]*)\s*\]$/u.exec(y.text.trim());if(!g)return;let S=g[1],h=g[2],v=bL(e,p,d,h);if(!v)return;let E=xL(e,d.relativePath,S);for(let x of i){let b=x.keyParts.find(V=>V.name==="registry")?.value,I=x.keyParts.find(V=>V.name==="key")?.value;if(!b||!I||!E.some(V=>V.file===x.source.file&&V.binding===b))continue;let P=we(e,x.source.file),k=P?EL(P.root,x.source.startLine):null;!P||!k||r.push(ru(P,k,"carrier.consume",s,v,I,[o.id,x.id]))}})}catch(p){n.push(`builtin.carrier consumer analysis failed for ${d.relativePath}: ${ou(p)}`)}}}return r}function mh(e){let t=B(e.db,e.file),n=new Map;return ye(e.root,r=>{if(r.type!=="pair"||hh(r)?.toLowerCase()!=="body")return;let i=Sh(r);if(!i||!/\bJSON\.stringify\s*\(/u.test(i.text))return;let o=pr(t,r.startPosition.row),s=SL(r);if(!o||!s)return;let a=Jt(s),c=new Set;wL(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 SL(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 bL(e,t,n,r){let i=Ge(t.root,n.startLine,n.endLine);if(!i)return null;let o=new RegExp(`\\.body\\??\\.${ce(r)}\\b`,"u");if(o.test(i.text))return r;let s=null;if(ye(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*${ce(r)}\\s*(?:[,}]|$)`,"u").test(d.text)||p.type==="call_expression"&&(s=iu(p)?.text??null)}),!s)return null;let a=vr(e,n.relativePath,s);if(a.length!==1)return null;let c=we(e,a[0].relativePath),l=c?Ge(c.root,a[0].startLine,a[0].endLine):null;return l&&o.test(l.text)&&new RegExp(`\\b${ce(r)}\\s*[,}]`,"u").test(l.text)?r:null}function xL(e,t,n){let r=[];for(let i of zl(e,t,n)){let o=Ve(i.initializer);if(o.type==="call_expression")for(let s of Bs(o)){let a=s.text.trim();if(/^[A-Za-z_$][\w$]*$/u.test(a))for(let c of zl(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 ru(e,t,n,r,i,o,s){let c=js(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 gh(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 vL(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=bh([...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 ph(e){return`${e.definition.symbol}\0${e.carrier}\0${e.field}\0${e.parameterIndex}`}function IL(e,t){let n=Ge(e.root,t.startLine,t.endLine);return n?Jt(n):[]}function EL(e,t){let n=null;return ye(e,r=>{r.startPosition.row>t||r.endPosition.row<t||(!n||r.endIndex-r.startIndex<n.endIndex-n.startIndex)&&(n=r)}),n}function yh(e,t){let n=[];return ye(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 iu(e){return e.childForFieldName("function")??e.namedChild(0)}function Bs(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function RL(e,t){if(!t)return null;let n=t.text.trim();if(!/^[A-Za-z_$][\w$]*$/u.test(n))return Ve(t);let r=null;return ye(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?Ve(r):Ve(t)}function PL(e){let t=Ve(e);return t.type==="object"?t.namedChildren.filter(n=>n.type==="pair"||n.type==="shorthand_property_identifier"):[]}function hh(e){return e.type==="shorthand_property_identifier"?e.text:(e.childForFieldName("key")??e.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")??null}function Sh(e){return e.type==="shorthand_property_identifier"?e:e.childForFieldName("value")??e.namedChild(1)}function wL(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 bh(e){return[...new Set(e)].sort((t,n)=>t-n)}function CL(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function ou(e){return e instanceof Error?e.message:String(e)}import{createHash as FL}from"crypto";function xh(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=TL(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=NL(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:${FL("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 TL(e){let t=[],n=je(e);for(let r of n){let i=F(e,r);if(!kL(i))continue;let o=we(e,r);o&&vh(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=LL(s);if(c.length<2)return;let l=nt(o,c[0]);if(!l||l.evidence==="expression")return;let u=_L(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 _L(e,t,n){let r=n.text.replace(/\s+/gu,""),i=/^([A-Za-z_$][\w$]*)/u.exec(r)?.[1];if(!i)return[];let o=ue(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=Mn(e,o.sourcePath,s);return[...new Set(a.map(c=>c.relativePath))]}function NL(e,t){let n=e==="/"?"":e.replace(/\/+$/u,""),r=t.startsWith("/")?t:`/${t}`;return`${n}${r}`||"/"}function kL(e){return/(?:\bfrom\s*|\brequire\s*\(\s*)['"](?:express|fastify|hono|koa-router|@koa\/router)(?:[/']|")/u.test(e)}function LL(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function vh(e,t){t(e);for(let n of e.namedChildren)vh(n,t)}import{createHash as DL}from"crypto";function $s(e){return[...new Map(e.map(t=>[t.observationId,t])).values()].sort((t,n)=>t.observationId.localeCompare(n.observationId))}var Vs=new Set(["DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT"]),AL=8,Ih=ae({kind:"runtime-boundary-http-roles",invalidation:ne("runtime-boundary-http-roles"),serialize:BL,deserialize:$L});function Ph(e,t,n){let r=n??((g,S)=>S()),i=new Map,o=[],s=[],a=new Set,c=[],l=[],u=new Map,d=new Map,p=new Map,f=g=>{if(u.has(g))return u.get(g)??null;let S=we(e,g);return u.set(g,S),S},m=g=>{let S=d.get(g);if(S)return S;let h=B(e,g);return d.set(g,h),h},y=(g,S)=>{let h=p.get(g.file);if(!h){let x=fe(e,g.file,g.source),b=Ih.read(e,g.file,x)??[];h={contentHash:x,roles:new Map(b.map(I=>[I.symbol,I])),dirty:!1},p.set(g.file,h)}let v=h.roles.get(S.symbol);if(v)return v;let E=jL(g,S);return h.roles.set(S.symbol,{symbol:S.symbol,...E}),h.dirty=!0,E};for(r("runtime-boundaries.http-summary.seed",()=>{for(let g of t){if(g.action!=="http.request"||!g.owner.symbol||g.evidence!=="call-expression"&&g.evidence!=="client-adapter")continue;let S=m(g.owner.file).find(x=>x.symbol===g.owner.symbol);if(!S)continue;let h=f(S.relativePath);if(!h)continue;let v=y(h,S),E={definition:S,...v,constantMethods:g.keyParts.flatMap(x=>x.name==="method"&&x.evidence!=="expression"&&Vs.has(x.value.toUpperCase())?[x.value.toUpperCase()]:[]),depth:0,proofObservationIds:[g.id],proofSpans:[g.source]};Rh(i,E)&&o.push(i.get(S.symbol))}});o.length>0;){let g=o.splice(0,o.length),S=r("runtime-boundaries.http-summary.resolve-call-sites",()=>lh(e,g.map(h=>h.definition)),{batchSize:g.length});r("runtime-boundaries.http-summary.process-call-sites",()=>{for(let h of g)if(!(h.depth>=AL))try{let v=S.get(h.definition.symbolId);if(!v)continue;l.push(...v.unresolved.map(E=>OL(h,E)));for(let E of v.sites){let x=f(E.file);if(!x)continue;a.add(E.file);let b=E.callNode,I=ML(h,b,x);I&&s.push(I);let P=E.caller;if(!P)continue;let k=y(x,P),V=GL(e,h,E),ve={definition:P,pathParameterIndexes:Gs([...k.pathParameterIndexes,...V.pathParameterIndexes]),methodParameterIndexes:Gs([...k.methodParameterIndexes,...V.methodParameterIndexes]),constantMethods:Er([...h.constantMethods,...k.constantMethods]),depth:h.depth+1,proofObservationIds:Er([...h.proofObservationIds,...I?[I.id]:[]]),proofSpans:[...h.proofSpans,{file:E.file,startLine:E.startLine,endLine:E.endLine}]};Rh(i,ve)&&o.push(i.get(P.symbol))}}catch(v){c.push(`builtin.http-summary failed for ${h.definition.relativePath}:${h.definition.startLine+1}: ${v instanceof Error?v.message:String(v)}`)}},{batchSize:g.length})}return Ih.writeBatch(e,[...p.entries()].flatMap(([g,S])=>S.dirty?[{relativePath:g,contentHash:S.contentHash,value:[...S.roles.values()].sort((h,v)=>h.symbol.localeCompare(v.symbol))}]:[])),{observations:s,frontiers:$s(l),summaries:i.size,filesInspected:a.size,errors:c}}function OL(e,t){let n=Er([...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:${DL("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:As(t.file)}}function ML(e,t,n){let r=wh(t),i=e.pathParameterIndexes.flatMap(d=>{let p=nt(n,r[d]);return p&&p.evidence!=="expression"&&HL(p.value)?[{index:d,value:p}]:[]}),o=e.methodParameterIndexes.flatMap(d=>{let p=nt(n,r[d]),f=p?.value.toUpperCase();return p&&f&&p.evidence!=="expression"&&Vs.has(f)?[{index:d,value:{...p,value:f}}]:[]}),s=Er([...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=js(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 jL(e,t){let n=Ge(e.root,t.startLine,t.endLine);if(!n)return{pathParameterIndexes:[],methodParameterIndexes:[],constantMethods:[]};let r=Jt(n),i=new Set,o=new Set,s=new Set;return ye(n,a=>{if(a.type==="call_expression"&&((a.childForFieldName("function")??a.namedChild(0))?.text.replace(/\s+/gu,"").split(".").at(-1)??"")==="fetch"){let f=wh(a);Wi(f[0],r,i);let m=VL(f[1],"method");if(m){Wi(m,r,o);let y=nt(e,m),g=y?.value.toUpperCase();g&&y?.evidence!=="expression"&&Vs.has(g)&&s.add(g)}else Wi(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")&&Wi(l,r,i),(u==="init"||u==="requestinit"||u==="options")&&Wi(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 BL(e){return e.map(t=>[encodeURIComponent(t.symbol),t.pathParameterIndexes.join(","),t.methodParameterIndexes.join(","),t.constantMethods.join(",")].join(" ")).join(`
395
+ `)}function $L(e){if(!e)return[];let t=[];for(let n of e.split(`
396
+ `)){let r=n.split(" ");if(r.length!==4)return null;let i=Eh(r[1]),o=Eh(r[2]),s=r[3]?r[3].split(","):[];if(i===null||o===null||s.some(a=>!Vs.has(a)))return null;t.push({symbol:decodeURIComponent(r[0]),pathParameterIndexes:i,methodParameterIndexes:o,constantMethods:s})}return t}function Eh(e){if(!e)return[];let t=e.split(",").map(Number);return t.every(n=>Number.isSafeInteger(n)&&n>=0)?t:null}function GL(e,t,n){let r=Vi(e,n);return{pathParameterIndexes:Hi(r,t.pathParameterIndexes),methodParameterIndexes:Hi(r,t.methodParameterIndexes)}}function Rh(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=Gs([...n.pathParameterIndexes,...t.pathParameterIndexes]),i=Gs([...n.methodParameterIndexes,...t.methodParameterIndexes]),o=Er([...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:Er([...n.proofObservationIds,...t.proofObservationIds]),proofSpans:[...n.proofSpans,...t.proofSpans]}),!0):!1}function VL(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 Wi(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 wh(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function HL(e){return e.startsWith("/")||/^https?:\/\//iu.test(e)}function Gs(e){return[...new Set(e)].sort((t,n)=>t-n)}function Er(e){return[...new Set(e)].sort()}import{createHash as WL}from"crypto";function Th(e){let t=Ch(e.filter(r=>r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim")),n=Ch(e.filter(r=>r.action==="database.write"&&r.evidence==="persistence-insert"));return e.flatMap(r=>r.action==="database.write"&&r.evidence==="persistence-insert"?su(r).flatMap(i=>{let o=t.get(i)?.[0];return o?[Fh(r,o,i,"queue.send")]:[]}):r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim"?su(r).flatMap(i=>{let o=n.get(i)?.[0];return o?[Fh(r,o,i,"queue.consume")]:[]}):[])}function Ch(e){let t=new Map;for(let n of e)for(let r of su(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 su(e){return e.keyParts.filter(t=>t.name==="resource").map(t=>t.value)}function Fh(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:${WL("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 zi="runtime-boundaries-v19",zL=UL(import.meta.url),ee=zL("typescript"),KL=new Set([ee.SyntaxKind.WhitespaceTrivia,ee.SyntaxKind.NewLineTrivia,ee.SyntaxKind.SingleLineCommentTrivia,ee.SyntaxKind.MultiLineCommentTrivia]),JL=new Set([ee.SyntaxKind.NoSubstitutionTemplateLiteral,ee.SyntaxKind.TemplateHead,ee.SyntaxKind.TemplateMiddle,ee.SyntaxKind.TemplateTail]),qs=[{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}],XL=64,Ah="builtin.http-summary",Us={HTTP_HANDLE:"http.handle",HTTP_REQUEST:"http.request",REGISTRY_HANDLE:"registry.handle"},au=new Set(Object.values(Us));async function YL(e,t={}){let n=je(e),r=new Set(n),i=new Set((t.affectedFiles??[]).map(SD)),o=t.previousGraph?.fileCoverage,s=i.size>0&&t.previousGraph?.extractorVersion===zi&&o!==void 0&&o.length===t.previousGraph.coverage.filesScanned,a=s?o.filter(L=>r.has(L.file)&&!i.has(L.file)):[],c=new Set(a.flatMap(L=>L.observationIds)),l=s?t.previousGraph.observations.filter(L=>c.has(L.id)&&r.has(L.source.file)):[],u=s?n.filter(L=>i.has(L)):n,d=[],p=o?.reduce((L,$)=>L+$.observationIds.length,0)??0,f=performance.now(),m=await pD(e,u,t.profileSpan);At(d,"direct-extraction",f,u.length,m.observations.length,{filesVisited:u.length,filesReused:a.length,factsReused:l.length,factsInvalidated:Math.max(0,p-l.length)});let y=[...a,...m.fileCoverage].sort((L,$)=>L.file.localeCompare($.file)),g=hD(y),S=y.flatMap(L=>L.extractionErrors),h=qi([...l,...m.observations]);if(s&&!t.forceDerivedRebuild&&t.previousGraph&&QL(o,m.fileCoverage,i)&&(!iD(e,t.previousGraph,i)||aD(o,m.fileCoverage,i)&&!cD(t.previousGraph,i))){for(let $ of t.previousGraph.coverage.extractors)g.has($.id)||g.set($.id,$);let L=uD(t.previousGraph.coverage.phases);return d.push(...L),{...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:[...g.values()],extractionErrors:t.previousGraph.coverage.extractionErrors,phases:d},fileCoverage:y}}let v=qi([...h,...Th(h)]),E=s&&t.previousGraph!==void 0?ZL(t.previousGraph,o,m.fileCoverage,i,h):{reuse:!1,shapeUnchanged:!1,proofFilesUnchanged:!1,seedUnchanged:!1},x=E.reuse;t.profileSpan?.("runtime-boundaries.http-summary.reuse-decision",()=>{},E),f=performance.now();let b;if(x){let L=t.previousGraph.coverage.phases?.find(te=>te.id==="http-summary"),$=t.previousGraph.coverage.extractors.find(te=>te.id==="builtin.wrapper");b={observations:t.previousGraph.observations.filter(te=>te.extractor===Ah),frontiers:t.previousGraph.frontiers.filter(te=>te.kind==="call-resolution"&&te.action===Us.HTTP_REQUEST),summaries:0,filesInspected:L?.filesVisited??$?.applicableFiles??0,errors:t.previousGraph.coverage.extractionErrors.filter(te=>te.startsWith("builtin.http-summary failed"))},At(d,"http-summary",f,v.length,b.observations.length,{filesVisited:0,filesReused:b.filesInspected,factsReused:b.observations.length+b.frontiers.length,factsInvalidated:0}),$&&g.set($.id,$)}else b=Ph(e,v,t.profileSpan),At(d,"http-summary",f,v.length,b.observations.length,{filesVisited:b.filesInspected}),g.set("builtin.wrapper",{id:"builtin.wrapper",applicableFiles:b.filesInspected,observations:b.observations.length,errors:b.errors.length});S.push(...b.errors);let I=qi([...v,...b.observations]);f=performance.now();let P=xh(e,I);At(d,"http-mount",f,I.length,P.observations.length,{filesVisited:P.filesInspected});let k=qi([...I,...P.observations]);f=performance.now();let V=x&&t.previousGraph!==void 0&&eD(t.previousGraph,o,m.fileCoverage,i),ve;if(V){let L=t.previousGraph.coverage.phases?.find(te=>te.id==="carrier"),$=t.previousGraph.coverage.extractors.find(te=>te.id==="builtin.carrier");ve={observations:t.previousGraph.observations.filter(te=>te.extractor==="builtin.carrier"),bodySummaries:$?.applicableFiles??0,discriminatorSummaries:0,filesInspected:L?.filesVisited??0,errors:t.previousGraph.coverage.extractionErrors.filter(te=>te.startsWith("builtin.carrier"))},At(d,"carrier",f,k.length,ve.observations.length,{filesVisited:0,filesReused:ve.filesInspected,factsReused:ve.observations.length,factsInvalidated:0}),$&&g.set($.id,$)}else ve=fh(e,k,y.flatMap(L=>L.bodySummaries??[])),At(d,"carrier",f,k.length,ve.observations.length,{filesVisited:ve.filesInspected}),g.set("builtin.carrier",{id:"builtin.carrier",applicableFiles:ve.bodySummaries,observations:ve.observations.length,errors:ve.errors.length});S.push(...ve.errors);let sn=qi([...k,...ve.observations]);f=performance.now();let Gn=bD(sn);At(d,"relations",f,sn.length,Gn.length),f=performance.now();let hu=vD(sn,Gn);At(d,"links",f,Gn.length,hu.length),ID(sn,Gn),f=performance.now();let Su=$s([...ED(sn,Gn),...b.frontiers]);return At(d,"frontiers",f,sn.length,Su.length),{schemaVersion:2,extractorVersion:zi,observations:sn,relationGroups:Gn,links:hu,frontiers:Su,coverage:{filesScanned:n.length,filesWithAst:y.filter(L=>L.hasAst).length,filesWithoutAst:y.filter(L=>!L.hasAst).length,...s?{filesReused:a.length}:{},extractors:[...g.values()],extractionErrors:S,phases:d},fileCoverage:y}}function QL(e,t,n){if(!e)return!1;let r=e.filter(o=>n.has(o.file)).filter(_h).map(Nh).sort((o,s)=>o.file.localeCompare(s.file)),i=t.filter(_h).map(Nh).sort((o,s)=>o.file.localeCompare(s.file));return JSON.stringify(r)===JSON.stringify(i)}function _h(e){return e.observationIds.length>0||e.extractionErrors.length>0}function Nh(e){let{syntaxHash:t,shapeHash:n,bodySummaries:r,...i}=e;return i}function ZL(e,t,n,r,i){let o=nD(t,n,r),s=rD(e),c=![...Oh(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=kh(e.observations,l)===kh(i,u);return{reuse:o&&c&&d,shapeUnchanged:o,proofFilesUnchanged:c,seedUnchanged:d}}function Oh(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 eD(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=Oh(t,n),a=tD(e,"builtin.carrier");return![...s].some(c=>a.has(c))}function tD(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 nD(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 rD(e){let t=new Set;for(let n of e.observations)if(n.extractor===Ah){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===Us.HTTP_REQUEST&&n.source&&t.add(n.source.file);return t}function kh(e,t){return JSON.stringify(e.filter(n=>t.has(n.id)&&n.action===Us.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 iD(e,t,n){let r=oD(t),i=sD(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
397
+ FROM mentions mention
398
+ JOIN chunks reference_chunk ON reference_chunk.id = mention.chunk_id
399
+ JOIN documents reference_document ON reference_document.id = reference_chunk.document_id
400
+ JOIN global_symbols global_symbol ON global_symbol.id = mention.symbol_id
401
+ WHERE mention.role != 1
402
+ AND reference_document.relative_path IN (${l})`,...c).some(d=>i.has(d.symbol)))return!0}return!1}function oD(e){let t=new Set;for(let n of e.observations)if(au.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||!au.has(n.action)||!n.source||t.add(n.source.file);return t}function sD(e){return new Set(e.observations.flatMap(t=>au.has(t.action)&&t.owner.symbol?[t.owner.symbol]:[]))}function aD(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 cD(e,t){let n=lD(e);return[...t].some(r=>n.has(r))}function lD(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 uD(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 At(e,t,n,r,i,o={}){e.push({id:t,durationMs:Math.max(0,performance.now()-n),inputFacts:r,outputFacts:i,...o})}var dD=256;async function pD(e,t,n){let r=[],i=[],o=n??((d,p)=>p()),s=[],a=[],c=new Map,l=d=>{let p=c.get(d);if(p!==void 0)return p;let f=fe(e,d,Ro(e,d));return c.set(d,f),f},u=0;for(let d of t){u+=1,u>=dD&&(u=0,En(),await qL());let p=o("runtime-boundaries.file.read",()=>Ro(e,d)),f=fe(e,d,p);c.set(d,f);let m=o("runtime-boundaries.file.direct-product",()=>{let x=Dh.read(e,d,f);if(!x||x.extractorVersion!==zi)return null;for(let b of x.deps)if(l(b.path)!==b.contentHash)return null;return x});if(m){r.push(...m.observations),i.push(m.coverage);continue}let y=o("runtime-boundaries.file.supports",()=>Ql.filter(x=>x.supports(p))),g=/\bJSON\.stringify\s*\(/u.test(p)&&/\bbody\s*:/u.test(p),S=o("runtime-boundaries.file.hashes",()=>{let x=Lh.read(e,d,f);if(x)return x;let b=fD(d,p);return s.push({relativePath:d,contentHash:f,value:b}),b}),h=new Set,v=[],E=pp(x=>h.add(x),()=>{let x=y.length>0||g?we(e,d,p,n):null,b={file:d,hasAst:x!==null||yD(d,p),syntaxHash:S.syntaxHash,shapeHash:S.shapeHash,bodySummaries:x&&g?mh(x):[],observationIds:[],extractors:[],extractionErrors:[]};if(x)for(let I of y){let P={id:I.id,applicableFiles:1,observations:0,errors:0};try{let k=gD(n,`runtime-boundaries.extractor.${I.id}`,d,()=>I.extract(x));P.observations=k.length,v.push(...k),b.observationIds.push(...k.map(V=>V.id))}catch(k){P.errors=1,b.extractionErrors.push(`${I.id} failed for ${d}: ${k instanceof Error?k.message:String(k)}`)}b.extractors.push(P)}return b});r.push(...v),i.push(E),E.extractionErrors.length===0&&(h.delete(d),a.push({relativePath:d,contentHash:f,value:{extractorVersion:zi,deps:[...h].sort().map(x=>({path:x,contentHash:l(x)})),observations:v,coverage:E}}))}return s.length>0&&Lh.writeBatch(e,s),a.length>0&&Dh.writeBatch(e,a),{observations:r,fileCoverage:i}}var Lh=ae({kind:"runtime-boundary-source-hashes",invalidation:ne("runtime-boundary-source-hashes"),serialize:e=>JSON.stringify(e),deserialize:e=>{try{let t=JSON.parse(e);return typeof t.syntaxHash=="string"&&typeof t.shapeHash=="string"?{syntaxHash:t.syntaxHash,shapeHash:t.shapeHash}:null}catch{return null}}}),Dh=ae({kind:"runtime-boundary-direct-extraction",invalidation:ne("runtime-boundary-direct-extraction"),serialize:e=>JSON.stringify(e),deserialize:e=>{try{let t=JSON.parse(e);return typeof t.extractorVersion!="string"||!Array.isArray(t.deps)||!Array.isArray(t.observations)||typeof t.coverage!="object"||t.coverage===null||!t.deps.every(n=>typeof n=="object"&&n!==null&&typeof n.path=="string"&&typeof n.contentHash=="string")?null:t}catch{return null}}});function fD(e,t){if(!/\.(?:[cm]?[jt]sx?)$/iu.test(e)){let l=Ui("sha256").update(t).digest("hex");return{syntaxHash:l,shapeHash:l}}let n=/\.[jt]sx$/iu.test(e)?ee.LanguageVariant.JSX:ee.LanguageVariant.Standard,r=ee.createScanner(ee.ScriptTarget.Latest,!1,n,t),i=Ui("sha256"),o=Ui("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!==ee.SyntaxKind.EndOfFileToken;l=r.scan()){if(l===ee.SyntaxKind.CloseBraceToken&&s.length>0&&s.at(-1)===0&&(l=r.reScanTemplateToken(!1)),KL.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"),!JL.has(l)&&!mD(l,u)&&o.update(u),o.update("\0"),o.update(String(c)),o.update("\0"),l===ee.SyntaxKind.TemplateHead?s.push(0):l===ee.SyntaxKind.TemplateTail?s.pop():l===ee.SyntaxKind.OpenBraceToken&&s.length>0?s[s.length-1]+=1:l===ee.SyntaxKind.CloseBraceToken&&s.length>0&&s.at(-1)>0&&(s[s.length-1]-=1)}return{syntaxHash:i.digest("hex"),shapeHash:o.digest("hex")}}function mD(e,t){if(e!==ee.SyntaxKind.StringLiteral||t.length<2)return!1;let n=t.slice(1,-1);return n.startsWith("/")||n.includes("://")}function gD(e,t,n,r){return e?e(t,r,{file:n}):r()}function yD(e,t){return t?at(e)?/<script\b/iu.test(t):le(e)!==null:!1}function hD(e){let t=new Map(Ql.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 SD(e){return e.replaceAll("\\","/").replace(/^\.\//u,"")}function bD(e){let t=new Map;for(let n of qs){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=PD(i,n.keyNames);if(!o)continue;let s=o.map(d=>`${d.name}=${jh(d.name,d.value)}`).join("\0"),a=i.sourceScope==="production"?"production":i.sourceScope,c=`${n.id}\0${a}\0${s}`,l=`boundary-group:${Ui("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(xD).sort(CD)}function xD(e){return{...e,producerIds:Hs(e.producerIds),consumerIds:Hs(e.consumerIds),declarationIds:Hs(e.declarationIds),derivation:{...e.derivation,inputFactIds:Hs(e.derivation.inputFactIds),sourceSpans:[...new Map(e.derivation.sourceSpans.map(t=>[`${t.file}:${t.startLine}:${t.endLine}`,t])).values()]}}}function vD(e,t){let n=new Map(e.map(i=>[i.id,i])),r=new Map;for(let i of t){let o=qs.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>XL))for(let a of s)for(let c of i.consumerIds){let l=n.get(a),u=n.get(c);if(!l||!u||wD(l,u))continue;let d=l.strength==="derived"||u.strength==="derived"?"derived":"exact",p=`${i.joinRule}\0${a}\0${c}`,f={id:`boundary-link:${Ui("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(FD)}function ID(e,t){let n=new Set(t.filter(Mh).flatMap(Ws)),r=new Set(t.filter(RD).flatMap(Ws));for(let i of e)i.resolution=n.has(i.id)?"locally-linked":r.has(i.id)?"ambiguous":"unresolved"}function ED(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(Ws)),i=new Set(t.filter(Mh).flatMap(Ws));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 Ws(e){return[...e.producerIds,...e.consumerIds,...e.declarationIds]}function Mh(e){let t=qs.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 RD(e){let t=qs.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 PD(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:jh(r,i.value)})}return n}function jh(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 wD(e,t){return e.source.file===t.source.file&&e.source.startLine===t.source.startLine}function qi(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 Hs(e){return[...new Set(e)].sort()}function CD(e,t){return e.joinRule.localeCompare(t.joinRule)||e.normalizedKey.localeCompare(t.normalizedKey)}function FD(e,t){return e.joinRule.localeCompare(t.joinRule)||e.from.localeCompare(t.from)||e.to.localeCompare(t.to)}import TD from"better-sqlite3";var Ks="scip_query_runtime_boundaries",Bn="scip_query_runtime_observations",Js="scip_query_runtime_relation_groups",Xs="scip_query_runtime_relation_participants";function _D(e,t){let n=new TD(e);try{n.exec(`
403
+ CREATE TABLE IF NOT EXISTS ${Ks} (
404
+ singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
405
+ schema_version INTEGER NOT NULL,
406
+ extractor_version TEXT NOT NULL,
407
+ payload TEXT NOT NULL
408
+ )
409
+ `),kD(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 ${Bn}`).run(),n.prepare(`DELETE FROM ${Xs}`).run(),n.prepare(`DELETE FROM ${Js}`).run();let r=n.prepare(`INSERT INTO ${Bn}
410
+ (id, protocol, action, role, strength, source_scope, resolution, file, start_line, end_line, owner_symbol, payload)
411
+ 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 ${Js} (id, protocol, join_rule, normalized_key, payload) VALUES (?, ?, ?, ?, ?)`),o=n.prepare(`INSERT INTO ${Xs} (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 ND(e,t={}){if(!LD(e,Bn))return Bh(e)?.observations??[];let n=[],r=[];return zs(n,r,"protocol",t.protocols),zs(n,r,"action",t.actions),zs(n,r,"source_scope",t.sourceScopes),zs(n,r,"file",t.files),e.all(`SELECT payload FROM ${Bn}${n.length>0?` WHERE ${n.join(" AND ")}`:""} ORDER BY file, start_line, id`,...r).flatMap(o=>DD(o.payload))}function kD(e){e.exec(`
412
+ CREATE TABLE IF NOT EXISTS ${Bn} (
413
+ id TEXT PRIMARY KEY,
414
+ protocol TEXT NOT NULL,
415
+ action TEXT NOT NULL,
416
+ role TEXT NOT NULL,
417
+ strength TEXT NOT NULL,
418
+ source_scope TEXT NOT NULL,
419
+ resolution TEXT NOT NULL,
420
+ file TEXT NOT NULL,
421
+ start_line INTEGER NOT NULL,
422
+ end_line INTEGER NOT NULL,
423
+ owner_symbol TEXT,
424
+ payload TEXT NOT NULL
425
+ );
426
+ CREATE INDEX IF NOT EXISTS idx_runtime_observations_protocol_action_scope
427
+ ON ${Bn}(protocol, action, source_scope);
428
+ CREATE INDEX IF NOT EXISTS idx_runtime_observations_file_line
429
+ ON ${Bn}(file, start_line);
430
+
431
+ CREATE TABLE IF NOT EXISTS ${Js} (
432
+ id TEXT PRIMARY KEY,
433
+ protocol TEXT NOT NULL,
434
+ join_rule TEXT NOT NULL,
435
+ normalized_key TEXT NOT NULL,
436
+ payload TEXT NOT NULL
437
+ );
438
+ CREATE INDEX IF NOT EXISTS idx_runtime_groups_protocol_key
439
+ ON ${Js}(protocol, join_rule, normalized_key);
440
+
441
+ CREATE TABLE IF NOT EXISTS ${Xs} (
442
+ group_id TEXT NOT NULL,
443
+ observation_id TEXT NOT NULL,
444
+ participant_role TEXT NOT NULL,
445
+ PRIMARY KEY (group_id, observation_id, participant_role)
446
+ );
447
+ CREATE INDEX IF NOT EXISTS idx_runtime_participants_observation
448
+ ON ${Xs}(observation_id, participant_role);
449
+ `)}function LD(e,t){return!!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",t)}function zs(e,t,n,r){!r||r.length===0||(e.push(`${n} IN (${r.map(()=>"?").join(", ")})`),t.push(...r))}function DD(e){try{return[JSON.parse(e)]}catch{return[]}}function Bh(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}}import{createHash as cu,randomUUID as Kh}from"crypto";import{closeSync as MD,existsSync as Ot,fstatSync as jD,lstatSync as Pr,mkdirSync as BD,openSync as $D,readdirSync as on,readSync as GD,renameSync as lu,rmSync as rt}from"fs";import{basename as Rr,dirname as uu,join as A}from"path";function $h(e){return Ys(e,AD)}function yK(e){return Ys(e,OD)}function Ys(e,t){return Array.isArray(e)?`[${e.map(n=>Ys(n,t)).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([n],[r])=>t(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${Ys(r,t)}`).join(",")}}`:JSON.stringify(e)}function AD(e,t){return e.localeCompare(t)}function OD(e,t){return e<t?-1:e>t?1:0}var du=1,VD=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}),yt=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},Jh=".owner.json",pu={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function CK(e){return{rootDir:e,pendingDir:A(e,"pending"),inflightDir:A(e,"inflight"),responseDir:A(e,"responses"),deadLetterDir:A(e,"dead-letter"),legacyRequestDir:A(e,"requests")}}function wr(e={}){let t={...VD,...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 Zs(e){let t=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(n=>me(n));return q(...t)}function FK(e,t){return cu("sha256").update($h({namespace:e,payload:t})).digest("hex")}function Xh(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function TK(e,t,n={}){let r=wr(n.limits),i=n.nowMs??Date.now(),o=Zs(e);return eA(t),mu(e,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??_t,n.durability??"durable",()=>{fu(e,i,r);let s=A(e.pendingDir,`${t.id}.json`),a=A(e.responseDir,`${t.id}.json`),c=Vh(e,t.id);if(c){let p=Hh(c,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:p.deadlineAtMs??t.deadlineAtMs}}let l=`${JSON.stringify(t)}
450
+ `,u=Buffer.byteLength(l),d=Ki(e);if(u>r.maxItemBytes)throw new yt("item-too-large",d,r,u);if(d.totalItems+1>r.maxItems)throw new yt("item-capacity",d,r,u);if(d.totalBytes+u>r.maxBytes)throw new yt("byte-capacity",d,r,u);n.onBeforePublish?.();try{let p=n.durability??"durable",f=ss(s,l,{durability:p}),m=p==="durable"?q(o,f.directorySync):"not-requested";return{disposition:"accepted",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:t.deadlineAtMs,achievedDurability:f.achievedDurability,directorySync:m}}catch(p){if(p.code!=="EEXIST")throw p;let f=Vh(e,t.id);if(!f)throw p;let m=Hh(f,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:m.deadlineAtMs??t.deadlineAtMs}}})}function HD(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=wr(t.limits),i=Zs(e);try{return mu(e,r,2e3,t.monotonicNow??_t,t.durability??"durable",()=>WD(e,t.ownerId,n,r,t.liveness??pu,t.owner??{pid:process.pid},i,t.durability??"durable",t.onClaimStage))}catch(o){if(o instanceof yt&&o.code==="admission-busy")return[];throw o}}function _K(e,t){return!Uh(e.pendingDir)&&!Uh(e.legacyRequestDir)?[]:HD(e,t)}function WD(e,t,n,r,i,o,s,a,c){fu(e,n,r,i);let l=A(e.inflightDir,Qs(t)),u=[...Wh(e.pendingDir,!1),...Wh(e.legacyRequestDir,!0)].sort((f,m)=>f.orderAtMs-m.orderAtMs||f.header.id.localeCompare(m.header.id)||f.path.localeCompare(m.path)),d=a==="durable"?s:"not-requested";u.length>0&&(a==="durable"?d=q(d,me(l)):BD(l,{recursive:!0}),c?.("after-owner-directory-durable"),QD(l,t,o,a),c?.("after-owner-record-published"));let p=[];for(let f of u){if(p.length>=r.maxBatch)break;let m=A(e.responseDir,`${f.header.id}.json`);if(Ot(m)){rt(f.path,{force:!0});continue}let y=Math.max(n+r.claimLeaseMs,(f.header.deadlineAtMs??n)+5e3),g=`${Qs(f.originalFile)}.${y}.claim`,S=A(l,g);try{lu(f.path,S)}catch(x){let b=x.code;if(b==="ENOENT"||b==="EEXIST")continue;throw x}c?.("after-claim-renamed");let h=a==="durable"?D(uu(f.path)):"not-requested";c?.("after-source-directory-synced");let v=a==="durable"?D(l):"not-requested";c?.("after-destination-directory-synced");let E=q(d,h,v);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:E})}return p}function NK(e,t={}){let n=wr(t);if(e.byteLength>n.maxItemBytes)throw new yt("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 qD(e,t,n,r={}){let i=r.nowMs??Date.now(),o=wr(r.limits),s=t.deadlineAtMs===void 0?i+o.responseRetentionMs:Math.min(i+o.responseRetentionMs,Math.max(t.deadlineAtMs,i)+Yh),a={mailboxVersion:du,operationKey:t.operationKey??`legacy-${t.requestId}`,clientId:t.clientId??"legacy",...t.deadlineAtMs===void 0?{}:{deadlineAtMs:t.deadlineAtMs},completedAtMs:i,expiresAtMs:s},c={...a,...n,...a},l=Buffer.byteLength(`${JSON.stringify(c)}
451
+ `),u=Ki(e);if(l>o.maxItemBytes)throw new yt("item-too-large",u,o,l);let d=Math.max(0,u.totalBytes-t.byteLength)+l;if(d>o.maxBytes&&d>u.totalBytes&&(zD(e,i).removed>0&&(u=Ki(e),d=Math.max(0,u.totalBytes-t.byteLength)+l),d>o.maxBytes&&d>u.totalBytes))throw new yt("byte-capacity",u,o,l);let p=r.durability??"durable";if(KD(e,t,c,p),r.onAfterResponsePublished?.(),rt(t.path,{force:!0}),p==="durable"){let f=uu(t.path);D(Ot(f)?f:e.inflightDir)}}var Yh=3e4,UD=4096;function zD(e,t){let n={removed:0,bytesFreed:0},r;try{r=on(e.responseDir)}catch{return n}for(let i of r){if(!i.endsWith(".json"))continue;let o=A(e.responseDir,i),s,a;try{let d=$D(o,"r");try{a=jD(d).size;let p=Buffer.alloc(Math.min(UD,a));GD(d,p,0,p.length,0),s=p.toString("utf8")}finally{MD(d)}}catch{continue}let c=Gh(s,"expiresAtMs"),l=Gh(s,"deadlineAtMs");if(c!==null&&c<=t||l!==null&&l+Yh<=t)try{rt(o,{force:!0}),n.removed+=1,n.bytesFreed+=a}catch{}}return n}function Gh(e,t){let n=new RegExp(`"${t}":(\\d+)`).exec(e);if(!n)return null;let r=Number(n[1]);return Number.isSafeInteger(r)?r:null}function kK(e,t,n,r,i={}){let o=i.nowMs??Date.now(),s=wr(i.limits);if(qD(e,t,n,{...i,nowMs:o,limits:s}),!Ot(t.path)){let a=A(e.deadLetterDir,`${rA(t.requestId)}.${o}.${cu("sha256").update(r).digest("hex").slice(0,12)}.json`),c={mailboxVersion:du,requestId:t.requestId,ownerId:t.ownerId,rejectedAtMs:o,reason:r,originalFile:t.originalFile},l=Buffer.byteLength(`${JSON.stringify(c,null,2)}
452
+ `),u=Ki(e);u.totalItems<s.maxItems&&u.totalBytes+l<=s.maxBytes&&De(a,c,{spacing:2,trailingNewline:!0})}}function LK(e,t={}){let n=t.nowMs??Date.now(),r=wr(t.limits);return Zs(e),mu(e,r,2e3,t.monotonicNow??_t,"durable",()=>fu(e,n,r,t.liveness??pu))}function fu(e,t,n,r=pu){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let s of yu(e.inflightDir)){if(o<=0)break;let a=A(e.responseDir,`${s.requestId}.json`);if(Ot(a)){rt(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>t||ZD(e,s.ownerId,r)!=="dead")continue;let c=A(e.pendingDir,s.originalFile);try{lu(s.path,c),i.reclaimed++}catch(l){if(l.code!=="EEXIST")throw l;rt(s.path,{force:!0})}D(uu(s.path)),D(e.pendingDir),o--}o=qh(e.responseDir,o,(s,a)=>a+n.responseRetentionMs,t,()=>{i.responsesRemoved++}),o=qh(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 Zh(s)){if(o<=0)break;if(!Rr(a).includes(".tmp-"))continue;let c;try{c=Pr(a).mtimeMs}catch(l){if(l.code==="ENOENT")continue;throw l}c+n.temporaryRetentionMs>t||(rt(a,{force:!0}),i.temporaryFilesRemoved++,o--)}}return tA(e.inflightDir),i}function Ki(e){Zs(e);let t=[...$n(e.pendingDir).map(c=>({path:c,pending:!0})),...$n(e.legacyRequestDir).map(c=>({path:c,pending:!0}))],n=yu(e.inflightDir).map(c=>({path:c.path,pending:!1})),r=$n(e.responseDir).map(c=>({path:c,pending:!1})),i=$n(e.deadLetterDir).map(c=>({path:c,pending:!1})),o=[...t,...n,...r,...i],s=0,a;for(let c of t){let l=Ji(c.path);if(!l){s++;continue}let u=l.enqueuedAtMs;if(u===void 0)try{u=Pr(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+nA(l.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function KD(e,t,n,r){let i=A(e.responseDir,`${t.requestId}.json`),o=`${JSON.stringify(n)}
453
+ `;try{ss(i,o,{durability:r})}catch(s){if(s.code!=="EEXIST")throw s;let a=Ji(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 mu(e,t,n,r,i,o){let s=A(e.rootDir,".admission.lock"),a=`${process.pid}-${Kh()}`,c=r()+Math.max(0,n);for(;!JD(e.rootDir,s,a,i);){if(XD(s),r()>=c)throw new yt("admission-busy",Ki(e),t,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{gu(s).ownerToken===a&&(rt(s,{recursive:!0,force:!0}),i==="durable"&&D(e.rootDir))}catch{}}}function JD(e,t,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
454
+ `;try{return ss(t,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{gu(t).ownerToken===n&&(rt(t,{force:!0}),r==="durable"&&D(e))}catch{}throw o}}function XD(e){let t=null;try{let r=gu(e);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(t=Number(r.pid))}catch{}if(t===null||YD(t))return;let n=`${e}.stale-${Kh()}`;try{lu(e,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}rt(n,{recursive:!0,force:!0})}function gu(e){try{return JSON.parse(T(e,"mailbox lock record"))}catch(t){if(t.code!=="EISDIR"&&!(t instanceof it&&t.reason==="not-regular"))throw t;return JSON.parse(T(A(e,"owner.json"),"mailbox lock owner record"))}}function YD(e){try{return process.kill(e,0),!0}catch(t){let n=t.code;return n==="EPERM"||n!=="ESRCH"}}function QD(e,t,n,r){let i=A(e,Jh),o=n.processIdentity,s=Qh(i);if(s&&s.ownerId===t&&s.pid===n.pid&&(!s.processIdentity&&!o||s.processIdentity&&o&&Le(s.processIdentity,o)))return;if($n(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"?De(i,a):Zt(i,a)}function ZD(e,t,n){let r=Qh(A(e.inflightDir,Qs(t),Jh));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?Le(r.processIdentity,i)?"live":"dead":"unknown"}function Qh(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:Ft(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 Vh(e,t){for(let n of[A(e.pendingDir,`${t}.json`),A(e.legacyRequestDir,`${t}.json`),A(e.responseDir,`${t}.json`)])if(Ot(n))return n;for(let n of yu(e.inflightDir))if(n.requestId===t)return n.path;return null}function Hh(e,t,n){let r=Ji(e);if(r?.operationKey===t)return r;if(Rr(e)===`${Xh(t)}.json`)return{id:n,operationKey:t};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function eA(e){if(e.mailboxVersion!==du||e.id!==Xh(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 Wh(e,t){return $n(e).filter(n=>n.endsWith(".json")).map(n=>{let r=Pr(n),i=Rr(n,".json"),o=Ji(n)??{id:i};return{path:n,originalFile:Rr(n),header:o,byteLength:r.size,orderAtMs:o.enqueuedAtMs??r.mtimeMs,legacy:t}})}function yu(e){if(!Ot(e))return[];let t=[];for(let n of on(e,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=zh(n.name);if(r===null)continue;let i=A(e,n.name);for(let o of on(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=zh(s[1]),c=Number(s[2]);if(a===null||Rr(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(c))continue;let l=A(i,o.name),u=Ji(l)??{id:Rr(a,".json")},d;try{d=Pr(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 Ji(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 qh(e,t,n,r,i){for(let o of $n(e)){if(t<=0)break;let s;try{s=Pr(o)}catch(a){if(a.code==="ENOENT")continue;throw a}n(o,s.mtimeMs)>r||(rt(o,{force:!0}),i(),t--)}return t}function $n(e){return Ot(e)?on(e,{withFileTypes:!0}).filter(t=>t.isFile()).map(t=>A(e,t.name)).sort():[]}function Uh(e){try{return on(e).some(t=>t.endsWith(".json"))}catch{return!1}}function Zh(e){if(!Ot(e))return[];let t=[];for(let n of on(e,{withFileTypes:!0})){let r=A(e,n.name);n.isFile()?t.push(r):n.isDirectory()&&t.push(...Zh(r))}return t.sort()}function tA(e){if(Ot(e))for(let t of on(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let n=A(e,t.name);on(n).some(r=>r.endsWith(".claim"))||rt(n,{recursive:!0,force:!0})}}function nA(e){try{return Pr(e).size}catch{return 0}}function Qs(e){return Buffer.from(e,"utf8").toString("base64url")}function zh(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return Qs(t)===e?t:null}catch{return null}}function rA(e){return/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)?e:`invalid-${cu("sha256").update(e).digest("hex")}`}export{Mt as a,ku as b,Fr as c,eo as d,Tr as e,mA as f,pS as g,W as h,Gt as i,X as j,mn as k,Oe as l,Ie as m,z as n,an as o,se as p,rS as q,it as r,H as s,j as t,T as u,iS as v,oS as w,cn as x,iA as y,oA as z,Ye as A,cO as B,Lr as C,ZS as D,eb as E,lO as F,uO as G,ib as H,lb as I,xd as J,dO as K,lo as L,Ee as M,fo as N,Cd as O,Fd as P,PO as Q,Td as R,_d as S,wO as T,NO as U,bt as V,Un as W,me as X,D as Y,q as Z,Zi as _,Cu as $,Ca as aa,ho as ba,So as ca,Fa as da,zO as ea,Pa as fa,KO as ga,JO as ha,_a as ia,vn as ja,Cx as ka,Jn as la,Io as ma,Fx as na,op as oa,Gr as pa,Vt as qa,Lx as ra,Dx as sa,Ax as ta,Xn as ua,yM as va,hM as wa,Yn as xa,ht as ya,no as za,yA as Aa,w as Ba,hA as Ca,SA as Da,bA as Ea,ju as Fa,ro as Ga,vA as Ha,un as Ia,jt as Ja,CA as Ka,Bu as La,gS as Ma,FA as Na,Hn as Oa,Gu as Pa,C as Qa,ot as Ra,Bt as Sa,CS as Ta,K as Ua,fe as Va,St as Wa,$A as Xa,GA as Ya,VA as Za,HA as _a,WA as $a,qA as ab,ge as bb,lp as cb,xp as db,xv as eb,Zn as fb,st as gb,ij as hb,Ut as ib,$e as jb,$t as kb,dd as lb,pd as mb,fd as nb,VS as ob,QA as pb,J as qb,md as rb,ao as sb,ae as tb,dp as ub,ne as vb,F as wb,NM as xb,Wr as yb,Jx as zb,kM as Ab,LM as Bb,ce as Cb,Za as Db,dj as Eb,pj as Fb,ec as Gb,le as Hb,at as Ib,zr as Jb,ye as Kb,Ge as Lb,Op as Mb,En as Nb,Ij as Ob,Ej as Pb,M as Qb,Gj as Rb,ef as Sb,Se as Tb,pc as Ub,uE as Vb,dE as Wb,ei as Xb,gE as Yb,yE as Zb,HM as _b,bp as $b,je as ac,WM as bc,Q0 as cc,MR as dc,Ko as ec,T$ as fc,ct as gc,ue as hc,Jo as ic,B$ as jc,$$ as kc,J$ as lc,ur as mc,X$ as nc,Y$ as oc,Q$ as pc,pw as qc,Z$ as rc,Yo as sc,ke as tc,be as uc,Yt as vc,xe as wc,tG as xc,nG as yc,_n as zc,Fc as Ac,dr as Bc,em as Cc,rG as Dc,iG as Ec,oG as Fc,sG as Gc,Tc as Hc,_c as Ic,NG as Jc,B as Kc,kG as Lc,Mw as Mc,LG as Nc,DG as Oc,AG as Pc,Vw as Qc,pr as Rc,OG as Sc,wU as Tc,Hy as Uc,As as Vc,Mn as Wc,nt as Xc,_1 as Yc,N1 as Zc,k1 as _c,rs as $c,ts as ad,Oc as bd,l1 as cd,qG as dd,oC as ed,UG as fd,zG as gd,n1 as hd,r1 as id,Ac as jd,Mc as kd,Sm as ld,xm as md,jc as nd,C1 as od,DC as pd,AC as qd,F1 as rd,OC as sd,MC as td,B1 as ud,Bc as vd,nu as wd,Vi as xd,zi as yd,YL as zd,_D as Ad,ND as Bd,Bh as Cd,W1 as Dd,Pm as Ed,q1 as Fd,wm as Gd,nV as Hd,eF as Id,Gc as Jd,rV as Kd,rF as Ld,iF as Md,iV as Nd,oV as Od,sV as Pd,kn as Qd,Ft as Rd,Le as Sd,Tt as Td,_t as Ud,gV as Vd,$h as Wd,yK as Xd,Wc as Yd,ss as Zd,Zt as _d,De as $d,du as ae,yt as be,CK as ce,Zs as de,FK as ee,Xh as fe,TK as ge,_K as he,NK as ie,qD as je,kK as ke,LK as le,Ki as me,Ay as ne,OV as oe,MV as pe,jV as qe,BV as re,oe as se,GF as te,cs as ue,qF as ve,UF as we,QF as xe,YV as ye,QV as ze,ZV as Ae,eH as Be,tH as Ce,pH as De,pi as Ee,PH as Fe,wH as Ge,CH as He,FH as Ie,TH as Je,fs as Ke,tg as Le,ms as Me,gs as Ne,hr as Oe,IT as Pe,sg as Qe,Nt as Re,WH as Se,en as Te,nW as Ue,iW as Ve,oW as We,yg as Xe,gW as Ye,xs as Ze,PW as _e,BW as $e,$W as af,JW as bf,XW as cf,YW as df,et as ef,Ii as ff,Rs as gf,sq as hf,gq as if,yq as jf,hq as kf,ny as lf,EN as mf,Tq as nf,_q as of,ws as pf,_s as qf,cU as rf,Ey as sf,lU as tf,Dt as uf,fy as vf,Ry as wf,_i as xf,uU as yf,dU as zf,pU as Af,Ol as Bf,gy as Cf,ks as Df,IU as Ef,Mi as Ff,EU as Gf};
455
+ //# sourceMappingURL=chunk-2XWIUW5Z.js.map