scip-query 0.22.0 → 0.23.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 (386) hide show
  1. package/CHANGELOG.md +257 -0
  2. package/README.md +11 -0
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-XI2CSWEY.js +2 -0
  5. package/dist/call-graph-UONR6JR5.js +2 -0
  6. package/dist/{chunk-FGNCOQUX.js → chunk-2E7CX53V.js} +2 -2
  7. package/dist/chunk-2GRUZAQF.js +43 -0
  8. package/dist/{chunk-DPWKKNKI.js → chunk-2LDBDR6J.js} +2 -2
  9. package/dist/{chunk-JHH5SCZ3.js → chunk-2OOY75BW.js} +2 -2
  10. package/dist/{chunk-XGGBK66W.js → chunk-2R3V3PSD.js} +2 -2
  11. package/dist/chunk-2WC2OEDO.js +4 -0
  12. package/dist/{chunk-57N6LN2A.js → chunk-3AF4TUFK.js} +2 -2
  13. package/dist/{chunk-2RE5OCHZ.js → chunk-3D3QG236.js} +2 -2
  14. package/dist/{chunk-D2MVJSP4.js → chunk-3FHOF22C.js} +2 -2
  15. package/dist/{chunk-7XZGZBSQ.js → chunk-3JKSW6LJ.js} +2 -2
  16. package/dist/chunk-3L2ZBPEX.js +133 -0
  17. package/dist/{chunk-NVSZNESQ.js → chunk-3PJABJSU.js} +2 -2
  18. package/dist/{chunk-WOOAY3PA.js → chunk-3SVF22I5.js} +2 -2
  19. package/dist/{chunk-YAGYMBEX.js → chunk-3WR4E3A3.js} +2 -2
  20. package/dist/chunk-4FTZ4P5G.js +2 -0
  21. package/dist/{chunk-F24G5NBE.js → chunk-4ILJCCXV.js} +2 -2
  22. package/dist/chunk-4UX2F3JX.js +2 -0
  23. package/dist/chunk-4WNW27SX.js +2 -0
  24. package/dist/chunk-5ENOG4VP.js +61 -0
  25. package/dist/{chunk-RHHCLWQ6.js → chunk-64BFSI5I.js} +2 -2
  26. package/dist/chunk-66DVSJQG.js +455 -0
  27. package/dist/{chunk-ISWFRGJ6.js → chunk-6HFCYNYE.js} +2 -2
  28. package/dist/{chunk-Y2VM4CJC.js → chunk-6I6L7Z62.js} +2 -2
  29. package/dist/{chunk-CKRWA452.js → chunk-6PQNKL3G.js} +2 -2
  30. package/dist/{chunk-GPGRZJ3R.js → chunk-6V5CNXL6.js} +2 -2
  31. package/dist/chunk-6VVV4WRR.js +4 -0
  32. package/dist/{chunk-BDGTPN27.js → chunk-7BWFZPPZ.js} +2 -2
  33. package/dist/{chunk-25GWKRUZ.js → chunk-7CYG22FH.js} +2 -2
  34. package/dist/chunk-7F45LJKI.js +2 -0
  35. package/dist/{chunk-4TQU4TX2.js → chunk-7IWV2EG3.js} +2 -2
  36. package/dist/{chunk-UDY7MIAW.js → chunk-AFHTBORT.js} +2 -2
  37. package/dist/chunk-AVRYW5OZ.js +2 -0
  38. package/dist/chunk-B3PYOSCX.js +2 -0
  39. package/dist/{chunk-RNKPYYYE.js → chunk-B5D7QPBE.js} +2 -2
  40. package/dist/{chunk-FFJQZG6J.js → chunk-BBCIS4DX.js} +2 -2
  41. package/dist/chunk-BDUVI7TO.js +3 -0
  42. package/dist/{chunk-BVFYEEBH.js → chunk-BE7ZZTMC.js} +2 -2
  43. package/dist/{chunk-NEIQPFBI.js → chunk-BHVUJOCQ.js} +2 -2
  44. package/dist/chunk-BKVWUP7Y.js +2 -0
  45. package/dist/{chunk-IJMD6BRI.js → chunk-BQGB4HBD.js} +2 -2
  46. package/dist/{chunk-ERCYGVAM.js → chunk-BRV7PIFF.js} +2 -2
  47. package/dist/chunk-CEEZJXEF.js +2 -0
  48. package/dist/{chunk-BTVKZGWT.js → chunk-CIYLO6SI.js} +2 -2
  49. package/dist/chunk-CJZXN4NU.js +2 -0
  50. package/dist/{chunk-VXJJTQYE.js → chunk-CNO7TOKL.js} +2 -2
  51. package/dist/{chunk-ZZ3Z7D56.js → chunk-COF23M5F.js} +2 -2
  52. package/dist/{chunk-ZGW4HLPD.js → chunk-CWFP7GM5.js} +2 -2
  53. package/dist/chunk-D2DHWI3D.js +2 -0
  54. package/dist/{chunk-Q55NF3ZG.js → chunk-D4N5SQ2M.js} +2 -2
  55. package/dist/{chunk-LXQUF2RP.js → chunk-DBRSYFXR.js} +2 -2
  56. package/dist/{chunk-PXXYQK55.js → chunk-DHUIOLDT.js} +2 -2
  57. package/dist/{chunk-KZYID5KV.js → chunk-DIRJWYBM.js} +2 -2
  58. package/dist/{chunk-IKVNEGTW.js → chunk-DIUFNHRJ.js} +2 -2
  59. package/dist/{chunk-CLG6DWVS.js → chunk-DTZCKZEU.js} +2 -2
  60. package/dist/{chunk-Z2PZVKPR.js → chunk-DULC3QFP.js} +2 -2
  61. package/dist/{chunk-AYPDH2LU.js → chunk-DYGHBZ2N.js} +2 -2
  62. package/dist/{chunk-JJ62MTQH.js → chunk-E5R6AQ73.js} +2 -2
  63. package/dist/{chunk-BWVQP3LB.js → chunk-E73UNJTF.js} +2 -2
  64. package/dist/{chunk-GVOMSPGL.js → chunk-EG2CPZMJ.js} +2 -2
  65. package/dist/{chunk-56NQAEPJ.js → chunk-EKV5HX33.js} +2 -2
  66. package/dist/{chunk-GDRJB3SB.js → chunk-EQHFIL6T.js} +2 -2
  67. package/dist/{chunk-EWWY2ZFL.js → chunk-ESIQ66Z7.js} +2 -2
  68. package/dist/chunk-EVFUMY4R.js +3 -0
  69. package/dist/{chunk-ZYM4HOFA.js → chunk-F7DY272B.js} +2 -2
  70. package/dist/chunk-FBN2FGXG.js +2 -0
  71. package/dist/{chunk-AZS7YPCB.js → chunk-FDLOBR6P.js} +2 -2
  72. package/dist/chunk-FESCRNVV.js +5 -0
  73. package/dist/{chunk-URSGGIZX.js → chunk-FFRKR4EQ.js} +2 -2
  74. package/dist/chunk-FGA2U4OR.js +8 -0
  75. package/dist/{chunk-7YQOCABQ.js → chunk-FIQRSHVM.js} +2 -2
  76. package/dist/{chunk-KFVSJX25.js → chunk-FPYLNQPT.js} +2 -2
  77. package/dist/{chunk-FELGD32K.js → chunk-FRUSVINH.js} +2 -2
  78. package/dist/chunk-GAS2LJMP.js +3 -0
  79. package/dist/{chunk-OTSPRVNW.js → chunk-GSP44ENC.js} +2 -2
  80. package/dist/{chunk-K3XFWJI2.js → chunk-GUFSG5TX.js} +2 -2
  81. package/dist/chunk-GYIZ4NXB.js +2 -0
  82. package/dist/{chunk-2OXVP5U5.js → chunk-GZIUDL6G.js} +2 -2
  83. package/dist/chunk-HCXEQRFF.js +18 -0
  84. package/dist/{chunk-LO5JSW2C.js → chunk-HEHOQQKH.js} +2 -2
  85. package/dist/{chunk-U2N2KE7A.js → chunk-HKGFPJ4T.js} +2 -2
  86. package/dist/chunk-HLZTEXRA.js +2 -0
  87. package/dist/{chunk-EELPBR7E.js → chunk-HOENASQM.js} +2 -2
  88. package/dist/{chunk-VTCIYFEK.js → chunk-HVF5VBG6.js} +2 -2
  89. package/dist/{chunk-TH6IC56G.js → chunk-HYO3NP5Q.js} +2 -2
  90. package/dist/{chunk-OPSAW5DT.js → chunk-I55I7XXP.js} +2 -2
  91. package/dist/{chunk-DEAB5TGT.js → chunk-IDFEUFKS.js} +2 -2
  92. package/dist/{chunk-DJAO2OZJ.js → chunk-IHGQTTVW.js} +2 -2
  93. package/dist/{chunk-XU75YQN4.js → chunk-IICPE7B2.js} +2 -2
  94. package/dist/{chunk-GY7CCCEZ.js → chunk-IL676XCC.js} +2 -2
  95. package/dist/{chunk-4HE7MVWD.js → chunk-ILTDAWEF.js} +2 -2
  96. package/dist/chunk-IZDPJ2QI.js +2 -0
  97. package/dist/{chunk-5YRQIE2B.js → chunk-J66VOFW6.js} +2 -2
  98. package/dist/{chunk-SB25YMEQ.js → chunk-JFMEXGFE.js} +2 -2
  99. package/dist/{chunk-QLBSG7U5.js → chunk-JGKUET5J.js} +2 -2
  100. package/dist/{chunk-VZ7NXSHV.js → chunk-JS4PGXMV.js} +2 -2
  101. package/dist/{chunk-ZAZGGSM3.js → chunk-JTQVMR42.js} +2 -2
  102. package/dist/chunk-JWTGMPIT.js +80 -0
  103. package/dist/{chunk-5ZMBRQFC.js → chunk-JYR66JN5.js} +2 -2
  104. package/dist/chunk-KLFEXGQA.js +2 -0
  105. package/dist/chunk-KYSDI3GE.js +5 -0
  106. package/dist/{chunk-MSR2QRUE.js → chunk-L6PJPETJ.js} +2 -2
  107. package/dist/{chunk-VU6LIWHT.js → chunk-LDVT66YM.js} +2 -2
  108. package/dist/chunk-LEECKFCJ.js +2 -0
  109. package/dist/{chunk-H7CG6LOE.js → chunk-LMZ5PRUV.js} +2 -2
  110. package/dist/{chunk-ZPASRBLF.js → chunk-LQRQN2XA.js} +2 -2
  111. package/dist/{chunk-HISEUIL2.js → chunk-LXABEJX3.js} +2 -2
  112. package/dist/{chunk-WHADK6OS.js → chunk-M2O5NY6W.js} +2 -2
  113. package/dist/{chunk-Y334QQU5.js → chunk-MNV5FSBW.js} +2 -2
  114. package/dist/{chunk-RYOYJMGF.js → chunk-MPQ4OTBM.js} +2 -2
  115. package/dist/{chunk-6NC3YSPY.js → chunk-MV3CDXPI.js} +2 -2
  116. package/dist/{chunk-NRBNAECH.js → chunk-MWN53KRN.js} +2 -2
  117. package/dist/chunk-N2ZSIIGR.js +117 -0
  118. package/dist/chunk-N5B2NILC.js +5 -0
  119. package/dist/{chunk-Q6T2CAJL.js → chunk-NJITK2GP.js} +2 -2
  120. package/dist/{chunk-ENWQWA2R.js → chunk-NOGJXYFO.js} +2 -2
  121. package/dist/{chunk-V4NG5OMS.js → chunk-NOYBFVJA.js} +106 -106
  122. package/dist/chunk-NWQXSFFU.js +3 -0
  123. package/dist/chunk-ODDUPDP7.js +13 -0
  124. package/dist/{chunk-A77SCPW2.js → chunk-OLIWTZI3.js} +2 -2
  125. package/dist/{chunk-XFMVKFSF.js → chunk-OLNV6I6U.js} +2 -2
  126. package/dist/{chunk-QKT4UI2Y.js → chunk-OR2E3AGZ.js} +2 -2
  127. package/dist/chunk-OSR2GEHQ.js +2 -0
  128. package/dist/{chunk-5H5WTJSD.js → chunk-OSSESPDX.js} +2 -2
  129. package/dist/{chunk-KQHJEU6V.js → chunk-OWOOWNJ5.js} +2 -2
  130. package/dist/{chunk-GRX7JOXQ.js → chunk-P42EIXTA.js} +2 -2
  131. package/dist/{chunk-AQ2PORIO.js → chunk-PJFGPYTU.js} +2 -2
  132. package/dist/{chunk-LRI5OMPE.js → chunk-PP7KNN7L.js} +2 -2
  133. package/dist/{chunk-PLJUQFQN.js → chunk-PU7T5QYQ.js} +2 -2
  134. package/dist/{chunk-JUN5DOAK.js → chunk-PWWAJSKV.js} +2 -2
  135. package/dist/{chunk-7IQXARSQ.js → chunk-PZL5T7SU.js} +2 -2
  136. package/dist/{chunk-UAQ4T73O.js → chunk-QBE3YX64.js} +2 -2
  137. package/dist/{chunk-3TJY6M3B.js → chunk-QGVTFRY2.js} +2 -2
  138. package/dist/chunk-QOJONDS7.js +2 -0
  139. package/dist/chunk-QU5XRYB5.js +4 -0
  140. package/dist/{chunk-2KVU55CW.js → chunk-QUU5OBVK.js} +2 -2
  141. package/dist/{chunk-Q5TA4OY4.js → chunk-RBLQNW26.js} +2 -2
  142. package/dist/chunk-RTQ7NEKG.js +81 -0
  143. package/dist/{chunk-F24QUEQP.js → chunk-SQXRS7BG.js} +2 -2
  144. package/dist/chunk-SSK6LDPC.js +2 -0
  145. package/dist/chunk-SZHGTCPP.js +7 -0
  146. package/dist/chunk-T4N4P2K5.js +16 -0
  147. package/dist/chunk-TA3QKLLU.js +2 -0
  148. package/dist/chunk-TEBQMNVI.js +43 -0
  149. package/dist/{chunk-NK3JMP22.js → chunk-TPFHAQ2G.js} +2 -2
  150. package/dist/chunk-TQPCBMWT.js +5 -0
  151. package/dist/{chunk-HG722PO7.js → chunk-TRNAEQ6P.js} +2 -2
  152. package/dist/chunk-TY7CRN3Z.js +2 -0
  153. package/dist/{chunk-7XA3OM44.js → chunk-UHFYCMZO.js} +2 -2
  154. package/dist/{chunk-ARVO6TTW.js → chunk-UICY4GTQ.js} +2 -2
  155. package/dist/{chunk-SWK4XPUS.js → chunk-UVGEWT4Y.js} +2 -2
  156. package/dist/{chunk-GIQ6CSL4.js → chunk-UXW33INU.js} +2 -2
  157. package/dist/{chunk-RDULNRSJ.js → chunk-VMPRET3I.js} +2 -2
  158. package/dist/{chunk-I6UTXNHU.js → chunk-VNLGKHS6.js} +2 -2
  159. package/dist/{chunk-44T4DUAA.js → chunk-VQILFTEH.js} +2 -2
  160. package/dist/{chunk-N7FP5H5U.js → chunk-VUPHCS7Y.js} +8 -8
  161. package/dist/{chunk-JAT6C3VX.js → chunk-VVZSBTSU.js} +2 -2
  162. package/dist/{chunk-FBCVASUG.js → chunk-VZRNID6A.js} +2 -2
  163. package/dist/{chunk-TUQIPUDS.js → chunk-W5OXRYGE.js} +2 -2
  164. package/dist/chunk-W6STWDQI.js +57 -0
  165. package/dist/chunk-W7CXK74K.js +2 -0
  166. package/dist/chunk-WB3WYIRE.js +4 -0
  167. package/dist/{chunk-C76O5MDS.js → chunk-WDNVY4E7.js} +2 -2
  168. package/dist/{chunk-TAYD3AE7.js → chunk-WIWY3CRX.js} +2 -2
  169. package/dist/chunk-WK46TNUM.js +3 -0
  170. package/dist/chunk-WNTFFKAX.js +12 -0
  171. package/dist/{chunk-JFQBRL3J.js → chunk-WOIKCX6A.js} +2 -2
  172. package/dist/{chunk-PIFTZEEM.js → chunk-WUN6KBHV.js} +2 -2
  173. package/dist/chunk-WYCTJDVR.js +2 -0
  174. package/dist/chunk-WYPL7GF7.js +2 -0
  175. package/dist/{chunk-XN22RGSR.js → chunk-XBGWL66K.js} +2 -2
  176. package/dist/{chunk-R6M456QG.js → chunk-XDQMU3BT.js} +2 -2
  177. package/dist/{chunk-XJX6LGHL.js → chunk-XFA4SSO3.js} +2 -2
  178. package/dist/{chunk-2YC7YNKT.js → chunk-XGZEP6GR.js} +2 -2
  179. package/dist/chunk-XPDPNWTQ.js +368 -0
  180. package/dist/chunk-XRYABF57.js +8 -0
  181. package/dist/{chunk-YIHNPKWD.js → chunk-YBGKCQIS.js} +2 -2
  182. package/dist/{chunk-2XCGSDIT.js → chunk-YEN6CYC7.js} +2 -2
  183. package/dist/{chunk-VMWUV6WB.js → chunk-YF5IB2LF.js} +2 -2
  184. package/dist/{chunk-TNG2FYS5.js → chunk-YI2AWIHC.js} +2 -2
  185. package/dist/{chunk-EELG7D3Q.js → chunk-YPWBKGFU.js} +2 -2
  186. package/dist/{chunk-GQIDEID3.js → chunk-YPWHBBIS.js} +2 -2
  187. package/dist/{chunk-TKDNDQA7.js → chunk-YSH6U3L4.js} +2 -2
  188. package/dist/{chunk-BUTEIZKP.js → chunk-YU5DZUZI.js} +2 -2
  189. package/dist/chunk-YWO5DDRC.js +16 -0
  190. package/dist/{chunk-6HRZQLOI.js → chunk-Z4CDXYNQ.js} +2 -2
  191. package/dist/{chunk-XSWYJCAK.js → chunk-ZF5KHH7C.js} +2 -2
  192. package/dist/chunk-ZOHS7AQV.js +21 -0
  193. package/dist/{chunk-7U2YQSDE.js → chunk-ZTI4SBFV.js} +2 -2
  194. package/dist/cli-main.js +2 -2
  195. package/dist/code-MI6F2TTU.js +2 -0
  196. package/dist/code-result-json-FXALY4HE.js +2 -0
  197. package/dist/{command-descriptors-ORNTVNYV.js → command-descriptors-P34VABY5.js} +136 -135
  198. package/dist/dataflow-4KEMJPC6.js +2 -0
  199. package/dist/dependence-slice-R7FPWD5M.js +2 -0
  200. package/dist/deps-7EMQUYUT.js +2 -0
  201. package/dist/direct-navigation-6YO234F2.js +3 -0
  202. package/dist/entry-map-KOOLR26E.js +2 -0
  203. package/dist/files-OPIPJIGZ.js +2 -0
  204. package/dist/hierarchy-QPD2CAER.js +2 -0
  205. package/dist/imports-M6HUXRXC.js +2 -0
  206. package/dist/index.js +1 -1
  207. package/dist/members-I5MEFOCT.js +2 -0
  208. package/dist/methods-5JYGGHXA.js +2 -0
  209. package/dist/output-continuation-command-UPQAAKBP.js +3 -0
  210. package/dist/postinstall.js +1 -1
  211. package/dist/project-reindex-UKKQ5PLS.js +3 -0
  212. package/dist/queries/affected.js +1 -1
  213. package/dist/queries/anchors.js +1 -1
  214. package/dist/queries/architecture.js +1 -1
  215. package/dist/queries/bottlenecks.js +1 -1
  216. package/dist/queries/by-kind.js +1 -1
  217. package/dist/queries/call-graph.js +1 -1
  218. package/dist/queries/change-surface.js +1 -1
  219. package/dist/queries/cleanup-plan.js +1 -1
  220. package/dist/queries/co-change.js +1 -1
  221. package/dist/queries/code.js +1 -1
  222. package/dist/queries/complexity-hotspots.js +1 -1
  223. package/dist/queries/complexity.js +1 -1
  224. package/dist/queries/context.js +1 -1
  225. package/dist/queries/convergence.js +1 -1
  226. package/dist/queries/coupling.js +1 -1
  227. package/dist/queries/cycles.js +1 -1
  228. package/dist/queries/dataflow.js +1 -1
  229. package/dist/queries/dead.js +1 -1
  230. package/dist/queries/decorative-checkers.js +1 -1
  231. package/dist/queries/deep-chains.js +1 -1
  232. package/dist/queries/dependence-slice.js +1 -1
  233. package/dist/queries/dependency-depth.js +1 -1
  234. package/dist/queries/deps.js +1 -1
  235. package/dist/queries/diff-impact.d.ts +9 -0
  236. package/dist/queries/diff-impact.js +1 -1
  237. package/dist/queries/doc-drift.js +1 -1
  238. package/dist/queries/drift.js +1 -1
  239. package/dist/queries/duplicate-bodies.js +1 -1
  240. package/dist/queries/entry-map.js +1 -1
  241. package/dist/queries/evidence.js +1 -1
  242. package/dist/queries/extract-candidates.js +1 -1
  243. package/dist/queries/fan.js +1 -1
  244. package/dist/queries/files.js +1 -1
  245. package/dist/queries/health.js +1 -1
  246. package/dist/queries/hierarchy.js +1 -1
  247. package/dist/queries/hotspots.js +1 -1
  248. package/dist/queries/imports.js +1 -1
  249. package/dist/queries/incomplete-migration.js +1 -1
  250. package/dist/queries/index.js +1 -1
  251. package/dist/queries/isolated.js +1 -1
  252. package/dist/queries/locality-candidates.js +1 -1
  253. package/dist/queries/members.js +1 -1
  254. package/dist/queries/methods.js +1 -1
  255. package/dist/queries/not-implemented.js +1 -1
  256. package/dist/queries/outline.js +1 -1
  257. package/dist/queries/passthrough-candidates.js +1 -1
  258. package/dist/queries/plan-context.js +1 -1
  259. package/dist/queries/react-component-duplicates.js +1 -1
  260. package/dist/queries/react-hook-candidates.js +1 -1
  261. package/dist/queries/react-large-component-pressure.js +1 -1
  262. package/dist/queries/recent-duplicates.js +1 -1
  263. package/dist/queries/redundant-reexports.js +1 -1
  264. package/dist/queries/reference-neighborhood.js +1 -1
  265. package/dist/queries/reference-reachability.js +1 -1
  266. package/dist/queries/refs.js +1 -1
  267. package/dist/queries/self-audit.js +1 -1
  268. package/dist/queries/similar-chains.js +1 -1
  269. package/dist/queries/similar-files.js +1 -1
  270. package/dist/queries/similar-signatures.js +1 -1
  271. package/dist/queries/similar.js +1 -1
  272. package/dist/queries/slice.js +1 -1
  273. package/dist/queries/source-inspection.js +1 -1
  274. package/dist/queries/source-search.js +1 -1
  275. package/dist/queries/stale-abstractions.js +1 -1
  276. package/dist/queries/surface.js +1 -1
  277. package/dist/queries/symbols.js +1 -1
  278. package/dist/queries/system-map.js +1 -1
  279. package/dist/queries/system.js +1 -1
  280. package/dist/queries/test-quality.js +1 -1
  281. package/dist/queries/trace.js +1 -1
  282. package/dist/queries/twin-ab.js +1 -1
  283. package/dist/queries/twin-drift.js +1 -1
  284. package/dist/queries/unused-imports.js +1 -1
  285. package/dist/queries/unused-params.js +1 -1
  286. package/dist/queries/value-flow.js +1 -1
  287. package/dist/queries/vue-component-duplicates.js +1 -1
  288. package/dist/queries/vue-composable-candidates.js +1 -1
  289. package/dist/queries/vue-large-view-pressure.js +1 -1
  290. package/dist/queries/wrapper-candidates.js +1 -1
  291. package/dist/query-service-server.js +3 -3
  292. package/dist/refs-PSU4JZZW.js +2 -0
  293. package/dist/refs-pagination-JG6CJMRC.js +2 -0
  294. package/dist/reindex-worker.js +25 -25
  295. package/dist/reindex.d.ts +3 -2
  296. package/dist/reindex.js +35 -35
  297. package/dist/runtime.d.ts +34 -2
  298. package/dist/runtime.js +4 -4
  299. package/dist/rust-semantic-session-server.js +1 -1
  300. package/dist/rust-semantic-session-worker.js +1 -1
  301. package/dist/rust-semantic-worker.js +1 -1
  302. package/dist/{scip-cli-H-n59izO.d.ts → scip-cli-DOerTq-R.d.ts} +42 -4
  303. package/dist/slice-HYRATV64.js +2 -0
  304. package/dist/surface-VTGDYWF5.js +2 -0
  305. package/dist/symbol-resolution-WD5EU5JE.js +2 -0
  306. package/dist/system-LRQNFOR2.js +2 -0
  307. package/dist/trace-F4B6OLL4.js +2 -0
  308. package/dist/typescript-mailbox-worker.js +1 -1
  309. package/dist/value-flow-VRPZY72V.js +2 -0
  310. package/dist/watch-server.js +3 -3
  311. package/package.json +1 -1
  312. package/dist/by-kind-4IYG2SKW.js +0 -2
  313. package/dist/call-graph-WQNXMNNN.js +0 -2
  314. package/dist/chunk-2BTJALUS.js +0 -454
  315. package/dist/chunk-3QXC54FQ.js +0 -3
  316. package/dist/chunk-42W3LFUK.js +0 -13
  317. package/dist/chunk-4GAQ6FI4.js +0 -43
  318. package/dist/chunk-6VEFRPTD.js +0 -5
  319. package/dist/chunk-7C26EKLZ.js +0 -4
  320. package/dist/chunk-7JYHQAH2.js +0 -22
  321. package/dist/chunk-7KSO2OAP.js +0 -2
  322. package/dist/chunk-AK3PYTIK.js +0 -5
  323. package/dist/chunk-AMIMMNA4.js +0 -11
  324. package/dist/chunk-AUY5BL74.js +0 -2
  325. package/dist/chunk-BDHFVH2M.js +0 -18
  326. package/dist/chunk-BECZLYNU.js +0 -8
  327. package/dist/chunk-BYDAFMSR.js +0 -57
  328. package/dist/chunk-BZYSGZRK.js +0 -2
  329. package/dist/chunk-C7IJMOFP.js +0 -134
  330. package/dist/chunk-CBBHFNLX.js +0 -2
  331. package/dist/chunk-D35XIZGN.js +0 -2
  332. package/dist/chunk-DKM723YF.js +0 -79
  333. package/dist/chunk-E44IVWIJ.js +0 -367
  334. package/dist/chunk-EDMB6SSO.js +0 -7
  335. package/dist/chunk-EETGXQY7.js +0 -3
  336. package/dist/chunk-FKGQOTKD.js +0 -2
  337. package/dist/chunk-GH5YSGZL.js +0 -5
  338. package/dist/chunk-HCVJR2V4.js +0 -3
  339. package/dist/chunk-HXOU4XNH.js +0 -3
  340. package/dist/chunk-IMKZEXZG.js +0 -2
  341. package/dist/chunk-ISIQLPJ2.js +0 -61
  342. package/dist/chunk-IXESDH3J.js +0 -2
  343. package/dist/chunk-JT6XX7QY.js +0 -8
  344. package/dist/chunk-MHIEP7EG.js +0 -4
  345. package/dist/chunk-OJNK5ALA.js +0 -2
  346. package/dist/chunk-OXYAWIEA.js +0 -2
  347. package/dist/chunk-OZETODHH.js +0 -2
  348. package/dist/chunk-PBUH2P5S.js +0 -3
  349. package/dist/chunk-PLYUVM4F.js +0 -2
  350. package/dist/chunk-Q7GBK5T7.js +0 -81
  351. package/dist/chunk-QWKHW6VZ.js +0 -2
  352. package/dist/chunk-RPL3ARU7.js +0 -16
  353. package/dist/chunk-SVHTMVA4.js +0 -4
  354. package/dist/chunk-T6QD2ZQB.js +0 -43
  355. package/dist/chunk-TD7VKJ2Y.js +0 -117
  356. package/dist/chunk-TUSPIVZ3.js +0 -4
  357. package/dist/chunk-UT7TADJX.js +0 -2
  358. package/dist/chunk-VUSKPCUB.js +0 -2
  359. package/dist/chunk-WN3TCGJ4.js +0 -2
  360. package/dist/chunk-WSLEJSFR.js +0 -2
  361. package/dist/chunk-WYZIHUPZ.js +0 -16
  362. package/dist/chunk-XE33FV5W.js +0 -2
  363. package/dist/chunk-Z2AWCTN6.js +0 -2
  364. package/dist/chunk-ZOXKSQQB.js +0 -2
  365. package/dist/code-EQJFDT6I.js +0 -2
  366. package/dist/code-result-json-7UWIWBOO.js +0 -2
  367. package/dist/dataflow-6VL54GX5.js +0 -2
  368. package/dist/dependence-slice-DT2NUHD2.js +0 -2
  369. package/dist/deps-DB7H5IKC.js +0 -2
  370. package/dist/direct-navigation-O3LUAYWQ.js +0 -3
  371. package/dist/entry-map-6K62RV3D.js +0 -2
  372. package/dist/files-MSLD7MO6.js +0 -2
  373. package/dist/hierarchy-IVBXAKFA.js +0 -2
  374. package/dist/imports-FRAVZ3Y2.js +0 -2
  375. package/dist/members-KJOJDYGO.js +0 -2
  376. package/dist/methods-2AYABBT3.js +0 -2
  377. package/dist/output-continuation-command-JHMPH6NC.js +0 -3
  378. package/dist/project-reindex-HYO4WD7Z.js +0 -3
  379. package/dist/refs-ARMA6XUJ.js +0 -2
  380. package/dist/refs-pagination-VUGIWN6U.js +0 -2
  381. package/dist/slice-YOB5YFAM.js +0 -2
  382. package/dist/surface-VY5EFWTW.js +0 -2
  383. package/dist/symbol-resolution-DGQN4XIV.js +0 -2
  384. package/dist/system-2KQ3QD2P.js +0 -2
  385. package/dist/trace-HTIPTXAE.js +0 -2
  386. package/dist/value-flow-5FV3VQI7.js +0 -2
@@ -0,0 +1,455 @@
1
+ #!/usr/bin/env node
2
+ var hu=Symbol.for("scip-query.project-file-listing-context.v1"),Su=globalThis,Qs=Su[hu],G=Qs&&typeof Qs=="object"?Qs:{};Su[hu]=G;function MD(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 jD(){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 bu(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 xu(){return G.sequence??0}function Ki(e,t,n){let r=G.active,i=r?.get(e);if(i&&i.pathBytes<=t)return i;let o=Wh(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 vu(e,t){let n=G.active?.get(e);return n&&n.sequence>t?n.indexAllowsTreeFingerprintReuse:void 0}function*Ji(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 Wh(e,t){let n=0,r=0,i=!0;for(;n<e.length;){let o=e.indexOf("\0",n);if(o<0||o<=n+2||e[n+1]!==" ")throw new Error("Git returned a malformed tagged project file listing.");let s=e[n];i&&=s==="H"||s==="?",r+=1,n=o+1}return{taggedOutput:e,pathBytes:Buffer.byteLength(e,"utf8")-r*2,indexAllowsTreeFingerprintReuse:i,sequence:t}}import{createRequire as qh}from"module";var Uh=qh(import.meta.url),Xi=zh().version;function zh(){for(let e of["../package.json","../../package.json"])try{return Uh(e)}catch{}return{version:"0.0.0"}}import{createHash as aS}from"crypto";import{existsSync as cS,mkdirSync as lS}from"fs";import{dirname as Gu,join as uS}from"path";import ra from"better-sqlite3";function Mt(e,t,n=[]){let r=ea(e);if(Cu.has(r)||n.some(o=>Qi(r,o))||t.some(o=>Fu(r,o)))return"config";if(t.some(Nu)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return"ambient";let i=Tu(r);return t.some(o=>(_u[o]??[]).includes(i))?"source":"other"}function wu(e,t,n){let r=ea(e);if(Cu.has(r)||n?.some(o=>Qi(r,o))||Fu(r,t)||Nu(t)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return!0;let i=Tu(r);return(_u[t]??[]).includes(i)}function Cr(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.version!="number"||!Iu(t.languages)||typeof t.pnpmWorkspaces!="boolean"||typeof t.typescriptProjectMode!="string"||!Iu(t.typescriptProjects)||t.clojureConfigPath!==void 0&&typeof t.clojureConfigPath!="string"||!Array.isArray(t.files)||!t.files.every(Zs)?null:t}function Yi(e){return{...e,files:e.files.map(({semanticHash:t,...n})=>n)}}function Fr(e,t){return!e||!t?e===t:JSON.stringify(Yi(e))===JSON.stringify(Yi(t))}function VD(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"),(Eu(e?.files??[])||Eu(t.files))&&s.add("duplicate-input-path"),[...e?.files??[],...t.files].some(Kh)&&s.add("unreadable-input"),{version:1,changes:o,projectIdentityChanged:e?!Jh(e,t):!0,uncertainty:[...s].sort()}}function Iu(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Eu(e){return new Set(e.map(t=>t.path)).size!==e.length}function Zs(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 Kh(e){return e.hash==="unreadable"||e.size<0}function Jh(e,t){return Ru(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&Ru(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function Ru(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 Cu=new Set([".scipquery.json"]),Xh={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"]},Yh={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:[]},Pu=new Map;function Fu(e,t){return Xh[t].some(n=>Qi(e,n))||Yh[t].some(n=>Qi(e,n))}function Qi(e,t){let n=ea(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=Pu.get(n);if(!o){let s=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]");o=new RegExp(`^${s}$`),Pu.set(n,o)}return o.test(i)}function ea(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Tu(e){return e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:""}function Nu(e){return e==="typescript"||e==="javascript"}var _u={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 Zi(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function WD(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 qD(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var Qh=/^[a-f0-9]{64}$/u;function UD(e){return typeof e=="string"&&Qh.test(e)}function zD(e){return typeof e=="string"&&e.length>0&&e.length<=256&&!/[\0\r\n]/u.test(e)}function ku(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}var eo=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],JD=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var ta=2,on=3;var na=new Set(eo);function jt(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${oS(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!==ta&&n!==on)return{kind:"unsupported",version:n,direction:n<ta?"older":"future"};let r=eS(t,n);if(r)return{kind:"malformed",reason:r};let i=t,o={metadata:i,capabilities:Zh(i)};return n===ta?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function tA(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function Lu(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===on?t.sqliteLayoutVersion:void 0})}function Zh(e){let t=e.fingerprint!==void 0,n=ht(e.fingerprint),r=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===on?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 eS(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!Zi(e.updatedAt))return"updatedAt must be a valid timestamp";for(let n of["requestedLanguages","indexedLanguages"])if(e[n]!==void 0&&!tS(e[n]))return`${n} must contain unique supported languages`;return e.skipped!==void 0&&!nS(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===on&&e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":t===on&&e.languageFingerprints!==void 0&&!rS(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===on&&e.typescriptProjectShards!==void 0&&!iS(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function nA(e){return e.version===on&&e.sqliteLayoutVersion===1}function tS(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&na.has(t))?!1:new Set(e).size===e.length}function nS(e){return Array.isArray(e)&&e.every(t=>ht(t)&&typeof t.language=="string"&&na.has(t.language)&&typeof t.reason=="string")}function rS(e){return ht(e)&&Object.entries(e).every(([t,n])=>na.has(t)&&ht(n))}function iS(e){return ht(e)&&Object.values(e).every(t=>ht(t)&&Array.isArray(t.files)&&t.files.every(Zs))}function oS(e){return e instanceof Error?e.message:String(e)}var Du=[];function Vn(e){e.groups.length>0&&Du.push(e)}function Au(e,t){let n=new Set(t.groups);for(let r of Du)r.groups.some(i=>n.has(i))&&(t.file!==void 0&&r.clearFile?r.clearFile(e,t.file):r.clearAll(e))}var Ou=256;function Mu(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")?Ou:void 0}function ju(e,t,n){e.delete(t),e.set(t,n)}function Bu(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 $u(){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}=$u(),i=Mu(t),o={get(s,a,c){let l=r(s);if(l.has(a)){let d=l.get(a);return ju(l,a,d),d}let u=c();return l.set(a,u),Bu(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 Vn({name:e,groups:t.clearGroups,clearAll:s=>o.invalidateAll(s),clearFile:(s,a)=>o.invalidate(s,a)}),o}function it(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 Vn({name:e,groups:t.clearGroups,clearAll:i=>r.invalidate(i)}),r}var sS={clearGroups:["whole-project","source-file"],maxEntries:Ou};function Bt(e){return sn(e,sS)}function sn(e,t){let{cache:n,ensure:r}=$u(),i=Mu(t),o={get(s,a,c,l){let u=r(s),d=u.get(a);if(d&&d.source===c)return ju(u,a,d),d.value;let p=l();return u.set(a,{source:c,value:p}),Bu(u,i),p},invalidate(s,a){n.get(s)?.delete(a)},invalidateAll(s){n.delete(s)}};return Vn({name:e,groups:t.clearGroups,clearAll:s=>o.invalidateAll(s),clearFile:(s,a)=>o.invalidate(s,a)}),o}var dS="evidence.db";var pS=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],no=new Set(pS),fS=25e4,mS=512*1024*1024,gS=6e4,to=new WeakMap,yS=C("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),hS=C("evidence-project-fingerprint",{clearGroups:["whole-project"]}),se="evidence-v1",an="version NOT LIKE 'evidence-%'";function U(e){return aS("sha256").update(e).digest("hex")}function me(e,t,n){return yS.get(e,t,()=>U(n))}function St(e){return hS.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 U(JSON.stringify({fingerprint:n.fingerprint,indexedLanguages:r,status:n.status}))}catch(t){return cn("project fingerprint unavailable",t),null}})}function cn(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function Ke(e){if(to.has(e))return to.get(e)??null;let t=null;try{let n=new ra(e.config.evidenceDbPath??uS(Gu(e.config.dbPath),dS));n.pragma("journal_mode = WAL"),n.pragma("busy_timeout = 5000"),n.pragma("synchronous = NORMAL"),n.exec(`
3
+ CREATE TABLE IF NOT EXISTS file_evidence (
4
+ kind TEXT NOT NULL,
5
+ relative_path TEXT NOT NULL,
6
+ content_hash TEXT NOT NULL,
7
+ version TEXT NOT NULL,
8
+ payload TEXT NOT NULL,
9
+ PRIMARY KEY (kind, relative_path)
10
+ );
11
+ CREATE TABLE IF NOT EXISTS project_evidence (
12
+ kind TEXT NOT NULL,
13
+ cache_key TEXT NOT NULL,
14
+ project_fingerprint TEXT NOT NULL,
15
+ version TEXT NOT NULL,
16
+ payload TEXT NOT NULL,
17
+ PRIMARY KEY (kind, cache_key)
18
+ );
19
+ CREATE TABLE IF NOT EXISTS semantic_callees (
20
+ relative_path TEXT NOT NULL,
21
+ symbol TEXT NOT NULL,
22
+ content_hash TEXT NOT NULL,
23
+ deps_digest TEXT NOT NULL,
24
+ version TEXT NOT NULL,
25
+ payload TEXT NOT NULL,
26
+ PRIMARY KEY (relative_path, symbol)
27
+ );
28
+ CREATE TABLE IF NOT EXISTS semantic_references (
29
+ relative_path TEXT NOT NULL,
30
+ symbol TEXT NOT NULL,
31
+ project_fingerprint TEXT NOT NULL,
32
+ version TEXT NOT NULL,
33
+ payload TEXT NOT NULL,
34
+ PRIMARY KEY (relative_path, symbol)
35
+ );
36
+ `),t={evidence:n,shared:SS(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 ${an}
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 ${an}
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 ${an}
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 ${an}
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 ${an}
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 ${an}
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 ${an}
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){cn("disabled (open failed)",n)}return to.set(e,t),t}function Je(e,t,n){cn(`disabled (${t})`,n),to.set(e,null)}function SS(e){if(!e)return null;try{lS(Gu(e),{recursive:!0});let t=new ra(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 cn("shared cache disabled (open failed)",t),null}}function ro(e,t,n){cn(`shared cache disabled (${t})`,n);try{e.shared?.evidence.close()}catch{}e.shared=null}function fA(e,t={}){if(!cS(e))return null;let n;try{n=new ra(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??fS,o=t.budgetBytes??mS,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 cn("shared cache maintenance skipped",r),null}finally{try{n?.close()}catch{}}}function Vu(e,t,n,r){let i=Ke(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,n,r,se)??i.readLegacyFileEvidence.get(t,n,r);if(o?.payload!==void 0)return o.payload;if(!no.has(t)||!i.shared)return null;try{let s=i.shared.readFileEvidence.get(t,n,r,se);return s?.payload!==void 0&&Wu(i.shared,t,n,r),s?.payload??null}catch(s){return ro(i,"file_evidence read",s),null}}catch(o){return Je(e,"file_evidence read",o),null}}function Hu(e,t,n,r){let i=Ke(e);if(!i)return!1;try{if((i.existsFileEvidence.get(t,n,r,se)??i.existsLegacyFileEvidence.get(t,n,r))?.present!==void 0)return!0;if(!no.has(t)||!i.shared)return!1;try{return i.shared.existsFileEvidence.get(t,n,r,se)?.present===void 0?!1:(Wu(i.shared,t,n,r),!0)}catch(s){return ro(i,"file_evidence exists",s),!1}}catch(o){return Je(e,"file_evidence exists",o),!1}}function Wu(e,t,n,r){let i=Date.now();try{e.touchFileEvidence.run(i,t,n,r,se,i-gS)}catch(o){cn("shared file_evidence recency touch skipped",o)}}function qu(e,t,n,r,i){let o=Ke(e);if(o)try{if(o.writeFileEvidence.run(t,n,r,se,i),no.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,n,r,se,i,Date.now())}catch(s){ro(o,"file_evidence write",s)}}catch(s){Je(e,"file_evidence write",s)}}function Uu(e,t){if(t.length===0)return;let n=Ke(e);if(n)try{n.evidence.transaction(()=>{for(let i of t)n.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,se,i.payload)})();try{n.evidence.pragma("wal_checkpoint(TRUNCATE)")}catch{}let r=t.filter(i=>no.has(i.kind));if(r.length>0&&n.shared)try{n.shared.evidence.transaction(()=>{for(let i of r)n.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,se,i.payload,Date.now())})()}catch(i){ro(n,"file_evidence batch write",i)}}catch(r){Je(e,"file_evidence batch write",r)}}function zu(e,t,n,r){let i=Ke(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,n,r,se)??i.readLegacyProjectEvidence.get(t,n,r))?.payload??null}catch(o){return Je(e,"project_evidence read",o),null}}function Ku(e,t,n,r,i){let o=Ke(e);if(o)try{o.writeProjectEvidence.run(t,n,r,se,i)}catch(s){Je(e,"project_evidence write",s)}}function mA(e,t,n,r){if(n===r)return 0;let i=Ke(e);if(!i)return 0;try{return i.rekeyProjectEvidenceKind.run(r,se,t,n).changes}catch(o){return Je(e,"project_evidence kind rekey",o),0}}function gA(e,t,n,r){let i=Ke(e);if(!i)return new Map;try{let o=i.readCalleesForFile.all(t,n,r,se),s=i.readLegacyCalleesForFile.all(t,n,r);return Ju([...s,...o])}catch(o){return Je(e,"semantic_callees bulk read",o),new Map}}function yA(e,t,n){let r=Ke(e);if(!r)return new Map;try{let i=r.readReferencesForFile.all(t,n,se),o=r.readLegacyReferencesForFile.all(t,n);return Ju([...o,...i])}catch(i){return Je(e,"semantic_references bulk read",i),new Map}}function Ju(e){let t=new Map;for(let n of e)t.set(n.symbol,n.payload);return t}function hA(e,t){if(t.length===0)return;let n=Ke(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.contentHash}`;r.has(o)||(r.add(o),n.dropStaleCallees.run(i.relativePath,i.contentHash)),n.writeCallees.run(i.relativePath,i.symbol,i.contentHash,i.depsDigest,se,i.payload)}})()}catch(r){Je(e,"semantic_callees write",r)}}function SA(e,t){if(t.length===0)return;let n=Ke(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.projectFingerprint}`;r.has(o)||(r.add(o),n.dropStaleReferences.run(i.relativePath,i.projectFingerprint)),n.writeReferences.run(i.relativePath,i.symbol,i.projectFingerprint,se,i.payload)}})()}catch(r){Je(e,"semantic_references write",r)}}import{appendFileSync as bS,mkdirSync as xS}from"fs";import{createHash as vS,randomUUID as IS}from"crypto";import{dirname as ES}from"path";import{performance as Hn}from"perf_hooks";var Zu="SCIP_QUERY_PROFILE",ed="SCIP_QUERY_PROFILE_OUT",td="SCIP_QUERY_PROFILE_COMMAND",nd="SCIP_QUERY_PROFILE_CACHE_STATE",ia="SCIP_QUERY_PROFILE_RUN_ID",oa="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY",sa="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND",rd=[Zu,ed,td,nd,ia,oa,sa],RA=new Set(rd),Xu=new Set,Yu=new Map,Qu=!1;function $t(){let e=process.env[Zu];return e==="1"||e==="true"}function RS(){return process.env[ed]}function id(){return process.env[td]}function PS(){return process.env[nd]}function od(){let e=process.env[ia];if(e)return e;if(!$t())return;let t=IS();return process.env[ia]=t,t}function sd(){return process.env[oa]}function wS(e){let t=sd();if(t)return t;if(!$t())return;let n=od();if(!n)return;let r=e.projectFingerprint?"published-project":"run-only",i=Tr(["profile-workload-v1",e.toolVersion,e.command,e.projectFingerprint??n]);return process.env[oa]=i,process.env[sa]=r,i}function Tr(e){return vS("sha256").update(JSON.stringify(e)).digest("hex").slice(0,24)}function PA(){return Object.fromEntries(rd.flatMap(e=>{let t=process.env[e];return t===void 0?[]:[[e,t]]}))}function z(e,t,n){if(!$t())return t();let r=Hn.now();try{let i=t();return io({type:"span",name:e,durationMs:Math.round(Hn.now()-r),ok:!0,...oo(n)??{}}),i}catch(i){throw io({type:"span",name:e,durationMs:Math.round(Hn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...oo(n)??{}}),i}}async function ad(e,t,n){if(!$t())return t();let r=Hn.now();try{let i=await t();return io({type:"span",name:e,durationMs:Math.round(Hn.now()-r),ok:!0,...oo(n)??{}}),i}catch(i){throw io({type:"span",name:e,durationMs:Math.round(Hn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...oo(n)??{}}),i}}function io(e,t=RS()){let n=CS(e),r={timestamp:new Date().toISOString(),pid:process.pid,runId:od(),command:id(),cacheState:PS(),...n,...e},i=`${JSON.stringify(r)}
82
+ `;if(t)try{let o=ES(t);Xu.has(o)||(xS(o,{recursive:!0}),Xu.add(o)),bS(t,i);return}catch(o){Qu||(Qu=!0,process.stderr.write(`[profile] failed to write ${t}: ${o instanceof Error?o.message:String(o)}
83
+ `));return}$t()&&process.stderr.write(i)}function CS(e){let t=sd()??wS({command:id()??"unknown",toolVersion:"unknown",projectFingerprint:null});if(!t)return{};let n=process.env[sa],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=Yu.get(o);return s||(s=Tr(["profile-subsystem-v1",t,r]),Yu.set(o,s)),{workloadIdentity:t,workloadIdentityKind:n,subsystem:i,subsystemWorkIdentity:s}}function oo(e){return typeof e=="function"?e():e}import{isAbsolute as cd,relative as FS}from"path";var H=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 Z(e){return e.replace(/\\/g,"/")}function ln(e,t){return Gt(e)===Gt(t)}function Ae(e,t){let n=FS(e,t);return n===""||!n.startsWith("..")&&!cd(n)}function Ee(e){if(!e)throw new H(e,"empty-path");if(e.includes("\0"))throw new H(e,"nul-byte");if(cd(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new H(e,"absolute-path");let t=Gt(e);if(t.split("/").some(r=>r===".."))throw new H(e,"parent-traversal");if(!t||t===".")throw new H(e,"empty-path");return t}import{closeSync as aa,fstatSync as so,openSync as ca,readFileSync as TS,readSync as ld}from"fs";import{createHash as NS}from"crypto";var ne=8*1024*1024,un=64*1024*1024,ae=512*1024*1024,_S=256*1024*1024,ot=class extends Error{constructor(n,r,i,o,s){let a=i==="too-large"?`is ${o} bytes; the safety limit is ${s} bytes`:i==="not-regular"?"is not a regular file":"changed while it was being read";super(`${n} ${JSON.stringify(r)} ${a}`);this.inputKind=n;this.inputPath=r;this.reason=i;this.observedBytes=o;this.limitBytes=s;this.name="BoundedFileReadError"}inputKind;inputPath;reason;observedBytes;limitBytes;code="SCIP_QUERY_BOUNDED_FILE_READ"};function ee(e,t){pn(t.maxBytes);let n=String(e),r=ca(e,"r");try{let i=so(r);dd(i,t,n);let o=TS(r),s=so(r);if(s.dev!==i.dev||s.ino!==i.ino||s.size!==i.size||o.byteLength!==i.size)throw new ot(t.inputKind,n,"changed-during-read",s.size,t.maxBytes);return o}finally{aa(r)}}function j(e,t,n="utf8"){return ee(e,t).toString(n)}function T(e,t){return j(e,{maxBytes:ne,inputKind:t})}function kS(e,t){return j(e,{maxBytes:un,inputKind:t})}function la(e,t){pn(t.maxBytes);let n=[],r=Buffer.allocUnsafe(64*1024),i=0;for(;;){let o=ld(e,r,0,r.length,null);if(o===0)break;if(i+=o,!Number.isSafeInteger(i)||i>t.maxBytes)throw new ot(t.inputKind,`file descriptor ${e}`,"too-large",i,t.maxBytes);n.push(Buffer.from(r.subarray(0,o)))}return Buffer.concat(n,i)}function LS(e,t,n="utf8"){return la(e,t).toString(n)}function ud(e,t){let n=ca(e,"r");try{return la(n,t)}finally{aa(n)}}function ua(e,t,n="utf8"){return ud(e,t).toString(n)}function Wn(e,t,n){pn(t.maxBytes);let r=String(e),i=ca(e,"r");try{let o=so(i);dd(o,t,r);let s=Buffer.allocUnsafe(Math.min(1024*1024,Math.max(1,o.size))),a=0;for(;a<o.size;){let l=ld(i,s,0,Math.min(s.length,o.size-a),a);if(l===0)break;n(s.subarray(0,l)),a+=l}let c=so(i);if(c.dev!==o.dev||c.ino!==o.ino||c.size!==o.size||a!==o.size)throw new ot(t.inputKind,r,"changed-during-read",c.size,t.maxBytes);return a}finally{aa(i)}}function dn(e,t){let n=NS("sha256");return Wn(e,t,r=>n.update(r)),n.digest("hex")}function dd(e,t,n){if(!e.isFile())throw new ot(t.inputKind,n,"not-regular",Number(e.size),t.maxBytes);if(e.size>t.maxBytes)throw new ot(t.inputKind,n,"too-large",Number(e.size),t.maxBytes)}function pn(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}import{spawnSync as DS}from"child_process";import{createHash as AS}from"crypto";import{existsSync as OS,lstatSync as co,realpathSync as MS}from"fs";import{dirname as jS,isAbsolute as fd,join as fa,relative as BS,resolve as fn,sep as $S}from"path";var Xe={run(e,t){let n=pd(e,t);return n.kind==="success"?n.output:void 0},runResult:pd},GS=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],ma=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],qn=/^[0-9a-f]{40,64}$/;function jA(e,t,n=Xe){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 _r(e,t=Xe){return VS(e,t)?.context}function VS(e,t=Xe){let n=t.runResult(e,GS);if(n.kind==="success"){let i=WS(n.output);if(i){let o=qS(i,t);if(o)return da(o)}}let r=US(e,t);return r?da(r):void 0}function HS(e,t=Xe){if(!e.headCommit)return;let n=t.run(e.projectRoot,ma);if(n===void 0)return;let r=ga(n);if(!(!r?.headCommit||r.headCommit!==e.headCommit))return{...e,clean:r.clean}}function BA(e,t,n=Xe){if(!t.headCommit||!t.treeOid||!qn.test(t.headCommit)||!qn.test(t.treeOid)||n===Xe&&!QS()||!KS(e,t))return;let r=HS({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?da(r):void 0}function $A(e,t=Xe,n={}){let r=t===Xe&&n.cachedInventoryAfterSequence!==void 0?vu(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 da(e){return{context:e,projectFileInventorySequence:xu()}}function ga(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 WS(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=Re(n);return{root:a,gitDir:Re(ao(a,r)),commonDir:Re(ao(a,i)),headCommit:o,treeOid:s}}function qS(e,t){let n=t.run(e.root,ma);if(n===void 0)return;let r=ga(n);return r?.headCommit!==e.headCommit?void 0:{...md(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:Nr("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.clean}}function US(e,t){let n=zS(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=Re(ao(i,o)),a=pa(t.run(i,["rev-parse","--verify","HEAD"])),c=pa(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,ma);if(l===void 0)return;let u=ga(l);if(!(!u||u.headCommit!==a))return{...r,commonDir:s,repositoryId:Nr("repository",s),headCommit:a,treeOid:c,clean:u.clean}}function zS(e,t=Xe){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=Re(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=Re(ao(i,o));return{kind:"worktree",identity:md(i,s)}}function md(e,t){return{projectRoot:e,gitDir:t,worktreeId:Nr("worktree",`${e}\0${t}`)}}function KS(e,t){try{let n=Re(t.projectRoot),r=fn(e)===n?n:Re(e);if(t.projectRoot!==n||!YS(n,r))return!1;let i=fa(n,".git"),o=co(i);if(o.isSymbolicLink())return!1;let s=o.isDirectory()?Re(i):o.isFile()?JS(i,n,o):void 0;if(!s||s!==t.gitDir)return!1;let a=XS(s);return!a||a!==t.commonDir?!1:t.worktreeId===Nr("worktree",`${n}\0${s}`)&&t.repositoryId===Nr("repository",a)}catch{return!1}}function JS(e,t,n){let r=gd(e,"gitdir: ",n);return r?Re(fn(t,r)):void 0}function XS(e){let t=fa(e,"commondir");try{let n=co(t);if(n.isSymbolicLink()||!n.isFile())return;let r=gd(t,"",n);return r?Re(fn(e,r)):void 0}catch(n){let r=n.code;return r==="ENOENT"||r==="ENOTDIR"?e:void 0}}function gd(e,t="",n=co(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 YS(e,t){let n=BS(e,t);return n===""||!n.startsWith(`..${$S}`)&&n!==".."&&!fd(n)}function QS(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 yd(e,t=Xe){let n=t.run(e,["worktree","list","--porcelain","-z"]);return n===void 0?[]:ZS(n)}function ZS(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:Re(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 GA(e,t,n=Xe){return pa(n.run(e,t))}function ao(e,t){return fd(t)?t:fn(e,t)}function Re(e){try{return MS(e)}catch{return fn(e)}}function Nr(e,t){return AS("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function pa(e){return e?.trim()||void 0}function pd(e,t){let n=DS("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"&&OS(fn(e)))&&!eb(e)?{kind:"not-repository"}:{kind:"error",message:i}}function eb(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=fn(e);for(;;){try{return co(fa(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 rb}from"module";import{existsSync as ib,lstatSync as Sd,readdirSync as ob,statSync as sb}from"fs";import N from"path";import{AsyncLocalStorage as tb}from"async_hooks";var nb=new tb;function mn(e,t){let n=lo(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 gn(e,t){let n=lo(e);if(n)return n.missing.has(t)?"missing":n.paths.includes(t)?"present":"missing"}function hd(e,t){return lo(e)?.fingerprints.get(t)}function yn(e){return lo(e)?.paths}function lo(e){let t=nb.getStore();if(t)return t.projectRoot===Re(e)?t:void 0}var ab=rb(import.meta.url),bd=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]),cb=18003;function uo(e,t=[]){let n=N.resolve(e),r=t.flatMap(c=>db(n,c));if(r.length>0)return xd(n,Id(r));let i=ub(n),o=Id(i),s=pb(n,o)?[n,...o]:o,a=s.length>0?s:[n];return xd(n,a)}function Ed(e){return new Set(e.map(t=>t==="."?"tsconfig.json":`${t.replace(/\/$/u,"")}/tsconfig.json`))}function Rd(e){let t=e.split("/").at(-1)?.toLowerCase();return t?.startsWith("tsconfig")===!0&&t.endsWith(".json")}var lb=/^\.scipquery-compiler-shard-\d+\.tsconfig\.json$/;function tO(e){return`.scipquery-compiler-shard-${e}.tsconfig.json`}function Pd(e){return lb.test(e)}function wd(e,t,n=[]){let r;try{r=ab("@ts-morph/common/dist/typescript.js")}catch{return null}let i=N.resolve(e),o=t==="workspace"?uo(i,n):["."],s=new Set;for(let a of o){let c=a==="."?i:N.join(i,a),l=N.join(c,"tsconfig.json"),u=mb(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!==cb))return null;for(let f of p.fileNames){let g=N.resolve(f);Ae(i,g)&&s.add(N.relative(i,g).split(N.sep).join("/"))}}return s}function nO(e,t,n,r){let i=N.resolve(e),o=new Set(r);for(let a of n){let c=N.resolve(i,a);if(Ae(i,c))try{let l=Sd(c);if(l.isSymbolicLink()||l.isFile()&&!o.has(hn(i,c)))return!1}catch{}}let s=t==="workspace"?uo(i,n):["."];for(let a of s){let c=a==="."?i:N.join(i,a),l=N.join(c,"tsconfig.json");if(!Fd(i,l))continue;let u=hn(i,l);if(!o.has(u))return!1;try{if(Sd(l).isSymbolicLink())return!1;let d=Td(i,l);if(d.includes("extends")||d.includes("\\"))return!1}catch{return!1}}return!0}function xd(e,t){return[...new Set(t.map(n=>hn(e,n)))].sort((n,r)=>n.localeCompare(r))}function ub(e){let t=yn(e);if(t)return t.flatMap(i=>{if(i.split("/").some(s=>bd.has(s)))return[];let o=N.join(e,...i.split("/"));return vd(e,o)?[N.dirname(o)]:[]});let n=[],r=[e];for(;r.length>0;){let i=r.pop(),o;try{o=ob(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=N.join(i,s.name);if(s.isDirectory()){!bd.has(s.name)&&!s.name.startsWith(".")&&r.push(a);continue}s.isFile()&&vd(e,a)&&n.push(N.dirname(a))}}return n}function db(e,t){let n=t.trim();if(!n)return[];let r=N.resolve(e,n);if(!Ae(e,r))return[];let i=yn(e);if(i){let o=hn(e,r);if(i.includes(o)&&ya(N.basename(r)))return[N.dirname(r)];let s=o==="."?"":`${o}/`;return i.some(a=>a.startsWith(s))?[r]:[]}try{let o=sb(r);if(o.isDirectory())return[r];if(o.isFile()&&ya(N.basename(r)))return[N.dirname(r)]}catch{return[]}return[]}function vd(e,t){if(!ya(N.basename(t)))return!1;let n=Cd(e,t);return n?N.basename(t)==="tsconfig.json"||"include"in n||"files"in n||"references"in n:!1}function ya(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Id(e){let t=[...new Set(e.map(n=>N.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&yb(n,r)))}function pb(e,t){if(t.length===0||t.some(r=>N.resolve(r)===e))return!1;let n=N.join(e,"tsconfig.json");return Fd(e,n)&&fb(e,n)}function fb(e,t){let r=Cd(e,t)?.include;return Array.isArray(r)?r.some(i=>typeof i=="string"&&i.trim()!==""&&!i.startsWith("!")&&(i.includes("/")||i.includes("**")||!N.extname(i))):!1}function Cd(e,t){try{let n=JSON.parse(Td(e,t));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Fd(e,t){let n=hn(e,t),r=gn(e,n);return r?r==="present":ib(t)}function Td(e,t){let n=hn(e,t);if(yn(e)){let i=mn(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 mb(e,t){let n=yn(t);if(!n)return e.sys;let r=N.resolve(t),i=new Set(n),o=gb(r,n),s=e,a=c=>{let l=N.resolve(c);return Ae(r,l)?hn(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):mn(r,l)?.content.toString("utf8")},readDirectory(c,l,u,d,p){let f=N.resolve(c);return Ae(r,f)?s.matchFiles(f,l,u,d,e.sys.useCaseSensitiveFileNames,r,p,g=>o.get(N.resolve(g))??{files:[],directories:[]},g=>g):e.sys.readDirectory(c,l,u,d,p)}}}function gb(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=N.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 hn(e,t){let n=N.relative(e,t);return n?n.split(N.sep).join("/"):"."}function yb(e,t){let n=N.relative(e,t);return!!n&&!n.startsWith("..")&&!N.isAbsolute(n)}import{createHash as ba}from"crypto";import{execFileSync as Nd}from"child_process";import{createRequire as hb}from"module";var Sb=hb(import.meta.url),bb=/\.(?:[cm]?[jt]sx?)$/iu,xb=/\.[jt]sx$/iu,_d=/(?:^|\/)package\.json$/iu,kr,ha=new Map;function kd(e,t){if(!xa(e))return;let n=vb();if(n)try{let r=typeof t=="string"?t:t.toString("utf8"),i=xb.test(e)?n.LanguageVariant.JSX:n.LanguageVariant.Standard,o=n.createScanner(n.ScriptTarget.Latest,!1,i,r),s=ba("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 xa(e){return bb.test(e)}function va(e,t){if(_d.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 ba("sha256").update("typescript-package-json-v1\0").update(Sa(i)).digest("hex")}catch{return}}function Ia(e){return _d.test(e)}function aO(e,t,n){if(!Ia(t)||!/^[a-f0-9]{64}$/u.test(n))return;let r=`${e}\0${t}\0${n}`;if(ha.has(r))return ha.get(r);let i;try{let o=Nd("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=Nd("git",["-C",e,"show",`${s}:${t}`],{encoding:null,maxBuffer:4194304,timeout:5e3});if(ba("sha256").update(a).digest("hex")===n){i=va(t,a);break}}}catch{i=void 0}return ha.set(r,i),i}function vb(){if(kr!==void 0)return kr;try{kr=Sb("typescript")}catch{kr=null}return kr}function Sa(e){return Array.isArray(e)?`[${e.map(Sa).join(",")}]`:typeof e=="object"&&e!==null?`{${Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${JSON.stringify(t)}:${Sa(n)}`).join(",")}}`:JSON.stringify(e)}import{createHash as Od,randomUUID as Cb}from"crypto";import{chmodSync as Md,existsSync as zn,linkSync as Fb,lstatSync as Lr,readdirSync as Ra,realpathSync as Oe,unlinkSync as Tb,writeSync as Nb}from"fs";import{homedir as _b}from"os";import{basename as kb,dirname as fo,isAbsolute as Dd,join as Fe,resolve as mo}from"path";import{closeSync as Ib,existsSync as Eb,fsyncSync as Rb,mkdirSync as Pb,openSync as wb}from"fs";import{dirname as Ld}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 Sn=Object.freeze({platform:process.platform,pathExists:e=>Eb(e),makeDirectory:e=>Pb(e,{recursive:!0}),openFile:(e,t,n)=>wb(e,t,n),syncFile:e=>Rb(e),closeFile:e=>Ib(e)});function ge(e,t=Sn){let n=[],r=e;for(;!t.pathExists(r);){n.push(r);let o=Ld(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=W(i,D(Ld(o),t));return i}function D(e,t=Sn){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 W(...e){return e.every(t=>t==="not-requested")?"not-requested":e.includes("unsupported")?"unsupported":"synced"}var jd=1,Ar=".scip-query-cache-owner.json",Lb=16*1024,Bd=Object.freeze({...Sn,randomToken:()=>Cb(),linkFile:(e,t)=>Fb(e,t),removeFile:e=>Tb(e),writeFile:(e,t,n,r)=>Nb(e,t,n,r)});function po(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 Ye(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 Db(e,t){let n=Oe(e);return Ab(n,Pa(n,t))}function Pa(e,t){let n=Oe(e),r=process.env.SCIP_QUERY_CACHE_DIR;return r?mo(r):t?.dbPath?Mb(n,t.dbPath):yo(n)}function go(){let e=process.env.XDG_CACHE_HOME;return Fe(e||Fe(_b(),".cache"),"scip-query")}function yo(e){let t=mo(e);try{t=Oe(t)}catch{}let n=Od("sha256").update(t).digest("hex").slice(0,12);return Fe(go(),"projects",n)}function ho(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let t=Fe(go(),"repositories",e);return Hd(t),Oe(t)}function wa(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function EO(e,t){let n=Db(e,t);return{cacheDir:n,dbPath:Fe(n,"index.db"),indexPath:Fe(n,"index.scip"),metaPath:Fe(n,"meta.json")}}function Ab(e,t,n=Bd){return Ob(e,t,n).cacheDir}function Ob(e,t,n=Bd){let r=Oe(e),i=zn(t)?"synced":Hd(t,n),o=Oe(t),s=Fe(o,Ar);if(zn(s))return Ea(r,o),Ca(s),Dr(o),{kind:"existing",cacheDir:o};Ad(o),Gb(o),Ad(o);let c=`${JSON.stringify({schemaVersion:jd,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:Xi},null,2)}
85
+ `;try{let l=Vb(s,c,n),u=W(i,l);return{kind:"published",cacheDir:o,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}catch(l){if(Wb(l))return Ea(r,o),{kind:"existing",cacheDir:o};throw l}}function Ea(e,t){let n=Oe(e),r=Oe(t);return $d(r,n,r)}function RO(e){let t=Lr(e);if(t.isSymbolicLink()||!t.isDirectory())throw Ye(e,"cache path is not a regular directory");let n=Oe(e);return $d(n,void 0,n)}function PO(e,t){return zn(Fe(t,Ar))?(Ea(e,t),Gd(t),!0):!1}function Mb(e,t){let n;try{n=Ee(t)}catch(s){throw s instanceof H?po(t,s.reason):s}let r=mo(e,...n.split("/"));if(r===e||!Ae(e,r))throw po(t,"outside-project");let i=jb(r),o=Oe(i);if(!Ae(e,o)&&o!==e)throw po(t,"symlink-escape");return r}function jb(e){let t=e;for(;!zn(t);){let n=fo(t);if(n===t)throw po(e,"no-existing-ancestor");t=n}return t}function $d(e,t,n){let r=Fe(e,Ar);if(!zn(r)||Lr(r).isSymbolicLink())throw Ye(e,"missing regular ownership record");let i=Lr(r);if(!i.isFile()||i.size>Lb)throw Ye(e,"invalid ownership record file");let o=T(r,"cache ownership record"),s=Bb(o,e);if(t!==void 0&&s.canonicalProjectRoot!==t)throw Ye(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw Ye(e,"ownership record names a different cache directory");return{record:s,ownerSha256:Od("sha256").update(o).digest("hex"),physicalCacheDir:e}}function Bb(e,t){try{let n=JSON.parse(e);if(n.schemaVersion!==jd||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!Dd(n.canonicalProjectRoot)||!Dd(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw Ye(t,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function Ad(e){let t=Ra(e).filter(n=>n!==Ar&&!$b(n));if(t.length>0)throw Ye(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function $b(e){return e.startsWith(`${Ar}.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 Gb(e){for(let t of Ra(e)){let n=Fe(e,t);try{let r=Lr(n);if(r.isSymbolicLink())throw Ye(e,`legacy cache entry ${t} is a symlink`);if(r.isDirectory())Dr(n);else if(r.isFile())Ca(n);else throw Ye(e,`legacy cache entry ${t} is not a file or directory`)}catch(r){if(Vd(r))continue;throw r}}Dr(e)}function Gd(e,t=!1){try{let n=Lr(e);if(n.isSymbolicLink())throw Ye(e,"managed cache tree contains a symlink");if(n.isFile()){Ca(e);return}if(!n.isDirectory())throw Ye(e,"managed cache tree contains a special file");Dr(e);for(let r of Ra(e))Gd(Fe(e,r),!0)}catch(n){if(t&&Vd(n))return;throw n}}function Vd(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function Hd(e,t=Sn){let n=ge(e,t);return Dr(e),n}function Vb(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(fo(e),n);return n.removeFile(r),o=!1,W(s,D(fo(e),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function Dr(e){process.platform!=="win32"&&Md(e,448)}function Ca(e){process.platform!=="win32"&&Md(e,384)}function Hb(e){if(zn(e))return Oe(e);let t=Oe(fo(e));return Fe(t,kb(e))}function Fa(e){return Hb(mo(e))}function Wb(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{execFileSync as sx}from"child_process";import{isUtf8 as Xd}from"buffer";import{createHash as Da}from"crypto";import{closeSync as Zd,fstatSync as Or,lstatSync as Oa,openSync as ep,readdirSync as ax,readFileSync as cx,readSync as Yd,readlinkSync as lx,realpathSync as jr}from"fs";import{isAbsolute as ux,join as Ma,relative as dx,resolve as px,sep as fx}from"path";import{closeSync as Wd,existsSync as Na,openSync as qb,realpathSync as Ub,renameSync as zb,unlinkSync as qd,writeSync as Kb}from"fs";import{dirname as Jb,join as Xb}from"path";var Yb="fingerprint-stat-cache.json",Ud=1,Qb=8*1024*1024,Ta=new Map;function _a(e,t,n,r){let i=zd(e),o=i.files.get(t);if(!(!o||!Kd(o,n,r)))return i.hits+=1,{hash:o.hash,size:o.fingerprintSize,...o.semanticHash===void 0?{}:{semanticHash:o.semanticHash}}}function ka(e,t,n,r,i){if(i.hash==="unreadable"||i.size<0||!Number.isFinite(i.size))return;let o=zd(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&&ix(a,s)||(o.files.set(t,s),o.stores+=1,o.dirty=!0)}function La(e){let t=Ta.get(Jd(e));if(!(!t?.dirty||!t.cachePath))try{let n=Jb(t.cachePath);if(!Na(n))return;ox(t.cachePath,tx(t)),t.dirty=!1}catch{}}function zd(e){let t=Jd(e),n=Ta.get(t);if(n)return n;let r=Zb(t),i=ex(r),o={cachePath:r,files:i,dirty:!1,hits:0,stores:0};return Ta.set(t,o),o}function Zb(e){try{let t=Pa(e);return Na(t)?Xb(t,Yb):null}catch{return null}}function ex(e){let t=new Map;if(!e||!Na(e))return t;try{let n=JSON.parse(ee(e,{inputKind:"fingerprint stat cache",maxBytes:Qb}).toString("utf8"));if(!nx(n))return t;for(let[r,i]of Object.entries(n.files))i&&t.set(r,i)}catch{return t}return t}function tx(e){return{version:Ud,files:Object.fromEntries(e.files)}}function nx(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.version!==Ud||typeof t.files!="object"||t.files===null?!1:Object.values(t.files).every(rx)}function rx(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 Kd(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 ix(e,t){return Kd(e,t.kind,t)&&e.hash===t.hash&&e.fingerprintSize===t.fingerprintSize&&e.semanticHash===t.semanticHash}function ox(e,t){let n=`${e}.${process.pid}.tmp`;try{qd(n)}catch{}let r=Buffer.from(`${JSON.stringify(t)}
86
+ `,"utf8"),i=qb(n,"wx",384);try{bt(i,r,{writeFile:(o,s,a,c)=>Kb(o,s,a,c)},"fingerprint stat cache")}catch(o){throw Wd(i),qd(n),o}Wd(i),zb(n,e)}function Jd(e){return Ub(e)}var Kn=64*1024*1024,mx=1024*1024,gx=1024,bn=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 yx(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function Jn(e,t,n={}){let r=Ee(t),i=bu(e,()=>jr(e)),o=px(i,...r.split("/"));if(!Ae(i,o)||o===i)throw new H(t,"outside-project");let s=jr(o);if(!Ae(i,s)||s===i)throw new H(t,"outside-project");let a=Oa(s);if(!a.isFile())throw new H(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(pn(l),c.size>l)throw new bn(n.inputKind??"project file",c.relativePath,c.size,l);return c}function xo(e,t,n={}){let r=Ee(t),i=gn(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=mn(e,r);if(!c)throw new H(r,"changed-during-read");let l=n.maxBytes??Kn;if(pn(l),c.size>l)throw new bn(n.inputKind??"project file",r,c.size,l);return Buffer.from(c.content)}let o=Jn(e,t,n),s=n.maxBytes??Kn,a=ep(o.absolutePath,"r");try{let c=Or(a);if(Mr(c,o,t),c.size>s)throw new bn(n.inputKind??"project file",o.relativePath,c.size,s);let l=cx(a),u=Or(a);if(Mr(u,o,t),l.byteLength!==c.size)throw new H(t,"changed-during-read");return l}finally{Zd(a)}}function hx(e,t,n,r={}){if(n.byteLength===0)throw new Error("Project file probe literal must not be empty.");let{matchedLiteralIndexes:i,...o}=tp(e,t,[n],r);return{...o,includesLiteral:i.length>0}}function tp(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=Ee(t),o=gn(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=mn(e,i);if(!c)throw new H(i,"changed-during-read");let l=r.maxBytes??Kn;if(pn(l),c.size>l)throw new bn(r.inputKind??"project file",i,c.size,l);let u=!c.content.includes(0)&&Xd(c.content),d=n.map(Qd),p=u?bx(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=ep(s.absolutePath,"r");try{let c=Or(a);Mr(c,s,t);let l=r.computeSha256?Da("sha256"):null,u=r.scratchBuffer??Buffer.allocUnsafe(mx);if(u.byteLength===0)throw new Error("Project file probe scratch buffer must not be empty.");let d=0,p=n.map(()=>!1),f=!1,g=!0,y=Buffer.alloc(0),m=n.map(()=>Buffer.alloc(0)),S=n.map(Qd);for(;d<c.size;){let x=Yd(a,u,0,Math.min(u.byteLength,c.size-d),d);if(x<=0)throw new H(t,"changed-during-read");let b=u.subarray(0,x);if(l?.update(b),f||=b.includes(0),g){let I=y.byteLength>0?Buffer.concat([y,b]):b,P=Sx(I);g=Xd(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=m[I];p[I]=xx(b,P,k,S[I]),m[I]=vx(b,P,k)}d+=x}g&&=y.byteLength===0,Mr(Or(a),s,t);let h=!f&&g,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=Yd(a,E,x,E.byteLength-x,x);if(b<=0)throw new H(t,"changed-during-read");x+=b}Mr(Or(a),s,t)}return{byteLength:c.size,isUtf8Text:h,matchedLiteralIndexes:v,bytes:E,...l?{sha256:l.digest("hex")}:{}}}finally{Zd(a)}}function Br(e,t,n={}){return xo(e,t,n).toString("utf8")}function Mr(e,t,n){if(!e.isFile()||e.dev!==t.device||e.ino!==t.inode||e.size!==t.size)throw new H(n,"changed-during-read")}function Sx(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 bx(e,t,n){return t.flatMap((r,i)=>Aa(e,r,n[i])?[i]:[])}function xx(e,t,n,r){if(Aa(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 Aa(Buffer.concat([n,i]),t,r)}function Aa(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>gx)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 Qd(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 vx(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 Ix(e,t){try{return Jn(e,t),!0}catch(n){if(Vt(n))return!1;throw n}}function Ex(e){let t=yn(e);return t?t.filter(n=>n&&!bo(n)).sort():(Tx(e)??Nx(e)).filter(n=>n&&!bo(n)).sort()}function Rx(e,t={}){let n=(t.includePaths??[]).map(Ee),r=[...new Set([...Ex(e),...n])].filter(s=>!bo(s)).filter(s=>!t.language||wu(s,t.language,t.markerFiles)).filter(s=>!t.includePath||t.includePath(s)).sort((s,a)=>s.localeCompare(a)),i=jr(e),o=r.flatMap(s=>np(e,i,s));return La(i),o}function np(e,t,n){let r=hd(e,n);if(r)return[{path:n,size:r.fingerprintSize??r.size,hash:r.sha256}];if(gn(e,n)==="present"){let o=mn(e,n);if(o)return[{path:n,size:o.fingerprintSize??o.size,hash:o.sha256}]}let i=Ma(e,n);try{let o=Oa(i);if(o.isSymbolicLink()){let y=_a(t,n,"symlink",So(o));if(y)return[{path:n,size:y.size,hash:y.hash}];let m=jr(i),S=dx(t,m);if(S===".."||S.startsWith(`..${fx}`)||ux(S))throw new Error("external symlink");let h=lx(i),v=Da("sha256").update("symlink\0").update(h).digest("hex"),E=Buffer.byteLength(h);return ka(t,n,"symlink",So(o),{hash:v,size:E}),[{path:n,size:E,hash:v}]}let s=xa(n)||Ia(n),a=_a(t,n,"file",So(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=Da("sha256"),l=s,u=[],d=Wn(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,g=f?kd(n,f)??va(n,f):void 0;return ka(t,n,"file",So(o),{hash:p,size:d,...g===void 0?{}:{semanticHash:g}}),[{path:n,size:d,hash:p,...g===void 0?{}:{semanticHash:g}}]}catch(o){return Vt(o)?[]:[{path:n,size:-1,hash:"unreadable"}]}}function So(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=>Cx(e,c)),...r.clojureConfigPath?[r.clojureConfigPath]:[]],o=r.languages.includes("typescript")?wd(e,r.typescriptProjectMode,r.typescriptProjects):null,s=r.languages.includes("typescript")?r.typescriptProjectMode==="workspace"?uo(e,r.typescriptProjects):["."]:[],a=Ed(s);return{...r,files:Rx(e,{includePath:c=>{if(c===".scipquery.json")return!1;let l=Mt(c,t,i);return l==="other"||l==="config"&&Rd(c)&&!a.has(c)?!1:l!=="source"||!wx(c)||!o?!0:o.has(c)},includePaths:i})}}function UO(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 zO(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(!Px(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=jr(e);for(let d of i.entries){let p=np(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 La(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 Px(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 wx(e){return/\.(?:[cm]?[jt]sx?|vue)$/iu.test(e)}function Cx(e,t){let n;try{n=Ee(t)}catch{return!1}let r=gn(e,n);if(r)return r==="present";try{return Oa(Ma(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:yx(t.typescriptProjects),clojureConfigPath:Fx(t.clojureConfigPath)}}function Fx(e){return e?.trim()||void 0}function Tx(e){try{let t=Ki(e,52428800,()=>sx("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:104857600,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}));return[...Ji(t)]}catch{return null}}function Nx(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?Ma(e,r):e,o;try{o=ax(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){bo(a)||n.push(a);continue}t.push(a)}}return t}function bo(e){let t=e.split("/");return e==="meta.json"||Pd(e)||t[0]===".scipquery"&&(t[1]==="events"||t[1]==="ledger"||t[1]==="releases"||t[1]==="suppressions")||t.some(n=>_x.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var _x=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{basename as rp}from"path";var kx=C("indexed-document-paths",{clearGroups:["whole-project"]});function ye(e,t={}){let n=Lx(t);return[...kx.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 Lx(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 op(e,t,n){let r=sp(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:ip(c.relative_path,r)}));if(i.length>0)return i;let o=ye(e,{includeIgnored:!1}).map(c=>({relativePath:c,score:ip(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 ip(e,t){let n=sp(e),r=rp(n),i=rp(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 sp(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}var Dx=[re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),re("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"}),$r("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"}),$r("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"}),$r("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"}),$r("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"}),$r("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 ce(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=Tr(["evidence-product-file-read-v1",e.kind,c,r,i]),t.set(l,a))}}return z("evidence-product.file.read",()=>{let c=Vu(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 Hu(n,e.kind,r,i)},write(n,r,i,o){qu(n,e.kind,r,i,e.serialize(o))},writeBatch(n,r){Uu(n,r.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function ap(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=Tr(["evidence-product-project-read-v1",e.kind,i,r]),t.set(c,a))}return z("evidence-product.project.read",()=>{let c=zu(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){Ku(n,e.kind,r,i,e.serialize(o))}}}function te(e){let t=Dx.find(n=>n.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function re(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function $r(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}var vo=null;function Gr(e){vo?.(e)}function cp(e,t){let n=vo;vo=e;try{return t()}finally{vo=n}}var Ax=C("source-text",{clearGroups:["whole-project","source-file"]}),Ox=C("source-lines",{clearGroups:["whole-project","source-file"]});function F(e,t){let n=t.replace(/\\/g,"/");return Gr(n),Ax.get(e,n,()=>Io(e,n))}function Io(e,t){let n=t.replace(/\\/g,"/");Gr(n);try{return Br(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(r){if(Vt(r))return"";throw r}}function aM(e){if(e.length===0)return[];let t=e.split(`
96
+ `);return e.endsWith(`
97
+ `)&&t.pop(),t}function Vr(e,t){let n=t.replace(/\\/g,"/");return Ox.get(e,n,()=>{let r=F(e,n);return r?r.split(`
98
+ `):[]})}var Mx=/^\s*(?:\/\/|#|\/\*+|\*)\s*scip-query[\s:-]*ignore(?:[\s:-]+(dead(?:-code)?|stale|wrapper|passthrough|drift|extract|similar|twin))?\b/i;function jx(e){let t=Mx.exec(e);return t?t[1]??"":null}function cM(e,t,n){return lp(e,t,n).length>0}function lM(e,t,n,r){let i=r.toLowerCase();return lp(e,t,n).some(o=>o.toLowerCase()===i)}function lp(e,t,n){if(n<=0)return[];let r=Vr(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 up}from"v8";import{runInNewContext as Bx}from"vm";var xn;function $x(){if(xn!==void 0)return xn;let e=globalThis.gc;if(typeof e=="function")return xn=e,xn;try{up("--expose_gc");let t=Bx("gc");up("--no-expose_gc"),xn=typeof t=="function"?t:null}catch{xn=null}return xn}function vn(){let e=$x();return e?(e(),!0):!1}var Gx=512*1024*1024,ja=0;function dp(e,t=vn){!Number.isFinite(e)||e<=0||(ja+=e,!(ja<Gx)&&(ja=0,t()))}import{readdirSync as Vx}from"fs";import{execFileSync as Hx}from"child_process";import{extname as Eo,join as Wx}from"path";var qx=[".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"],bM=[".vue"],pp=[".tsx",".jsx"],fp=[".vue"],Ux=[...pp,...fp],zx=new Set(pp),Kx=new Set(fp),mp=new Set(qx.map(e=>e.toLowerCase())),Jx=[...mp].sort().join(","),gp=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);function Me(e,t={}){let n=t.includeIndexed??!0,r=t.includeAuxiliary??!0,i=t.extensions?.map(c=>c.toLowerCase()),o=i?new Set(i):mp,s=i?[...o].sort().join(","):Jx,a=`${n?"1":"0"}|${r?"1":"0"}|${s}`;return Xx.get(e,a,()=>{let c=new Set;if(n)for(let l of ye(e,{includeIgnored:!1}))o.has(Eo(l).toLowerCase())&&c.add(l);if(r)for(let l of Yx(e.config.projectRoot,o))e.isIgnored(l)||n&&c.has(l)||c.add(l);return[...c].sort()})}function xM(e,t={}){let n=!1,r=!1;for(let i of Me(e,{extensions:Ux})){if(t.scope&&!i.includes(t.scope))continue;let o=Eo(i).toLowerCase();if(n||=zx.has(o),r||=Kx.has(o),n&&r)break}return{react:n,vue:r}}var Xx=C("source-files",{clearGroups:[]});function Yx(e,t){return Qx(e,t)??ev(e,t)}function Qx(e,t){try{let n=Hx("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&&(Zx(o)||t.has(Eo(o).toLowerCase())&&r.add(o))}return r}catch{return null}}function Zx(e){return e.split("/").some(t=>gp.has(t))}function ev(e,t){let n=new Set,r=i=>{let o=i?Wx(e,i):e,s;try{s=Vx(o,{withFileTypes:!0})}catch{return}for(let a of s)if(!gp.has(a.name)){if(a.isDirectory()){r(i?`${i}/${a.name}`:a.name);continue}t.has(Eo(a.name).toLowerCase())&&n.add(i?`${i}/${a.name}`:a.name)}};return r(""),n}import{createRequire as dv}from"module";import{existsSync as Rn}from"fs";import{basename as hp,dirname as Te,extname as xt,join as je,relative as In,resolve as ie,sep as pv}from"path";import{existsSync as $a,readdirSync as tv,statSync as nv}from"fs";import{join as Qn,relative as rv}from"path";function yp(e){let t=iv(e)??cv(e);if(!t||t.length===0)return[];let n=[],r=new Set;for(let i of t)for(let o of lv(e,i)){if(r.has(o))continue;r.add(o);let s=uv(e,o);s&&n.push(s)}return n}function iv(e){let t=Qn(e,"pnpm-workspace.yaml");if(!$a(t))return null;try{return ov(T(t,"pnpm workspace manifest"))}catch{return null}}function ov(e){let t=[],n=!1;for(let r of e.split(/\r?\n/)){let i=sv(r);if(!n){/^packages\s*:\s*$/.test(i.trim())&&(n=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=av(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function sv(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function av(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function cv(e){let t=Qn(e,"package.json");if(!$a(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 lv(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=Qn(e,t);return Ba(s)?[s]:[]}let n=t.indexOf("*"),r=t.slice(0,n).replace(/\/$/,""),i=t.slice(n+1).replace(/^\//,""),o=Qn(e,r||".");return Ba(o)?tv(o).map(s=>Qn(o,s,i)).filter(Ba):[]}function Ba(e){try{return nv(e).isDirectory()}catch{return!1}}function uv(e,t){let n=Qn(t,"package.json");if(!$a(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:rv(e,t).replace(/\\/g,"/"),exports:r.exports}}catch{return null}}var fv=it("indexed-paths",{clearGroups:[]}),mv=it("indexed-path-digest",{clearGroups:[]}),gv=C("tsconfig-alias-config",{clearGroups:["whole-project"]}),yv=C("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),hv=dv(import.meta.url),Hr;function Sv(){if(Hr!==void 0)return Hr;try{Hr=hv("typescript")}catch{Hr=null}return Hr}var bv=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],xv=it("workspace-packages",{clearGroups:["whole-project"]}),En=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],Ro=[".py",".pyi"],Ne=[".java",".scala",".kt",".kts"],Po=[".rs"],wo=[".rb"],Co=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],Ht=[".cs",".vb"],Fo=[".dart"],Pn=[".php"],Zn=[".clj",".cljs",".cljc"],vv=new Set(En),Ga=new Set(Ro),Sp=new Set(Ne),Va=new Set(Po),Ha=new Set(wo),bp=new Set(Co),xp=new Set(Ht),Wa=new Set(Fo),vp=new Set(Pn),Ip=new Set(Zn),Iv=[{extensions:En,lookup:vv},{extensions:Ro,lookup:Ga},{extensions:Ne,lookup:Sp},{extensions:Po,lookup:Va},{extensions:wo,lookup:Ha},{extensions:Co,lookup:bp},{extensions:Ht,lookup:xp},{extensions:Fo,lookup:Wa},{extensions:Pn,lookup:vp},{extensions:Zn,lookup:Ip}];function vt(e,t){return t.has(xt(e).toLowerCase())}function Ev(e){return vt(e,Ga)}function Rv(e){return vt(e,Sp)}function Pv(e){return vt(e,Va)}function wv(e){return vt(e,Ha)}function Cv(e){return vt(e,bp)}function Fv(e){return vt(e,xp)}function Ep(e){return xt(e).toLowerCase()===".vb"}function Tv(e){return vt(e,Wa)}function Nv(e){return vt(e,vp)}function _v(e){return vt(e,Ip)}function qa(e){let t=xt(e).toLowerCase();for(let n of Iv)if(n.lookup.has(t))return n.extensions;return En}function kv(e){return Rv(e)||Fv(e)||Nv(e)}function st(e,t,n){return Ev(t)?er(e,t,n):Pv(t)?It(e,t,n):wv(t)?To(e,t,n):Cv(t)?No(e,t,n):kv(t)?K(e,n.replace(/\\/g,"."),qa(t)):Tv(t)?_o(e,t,n):_v(t)?Ua(e,n):Lv(e,t,n)}function Lv(e,t,n){if(!n.startsWith(".")&&!n.startsWith("/"))return Dv(e,t,n)??Ov(e,n);let r=Te(je(e.config.projectRoot,t)),i=ie(r,n),o=Et(e);for(let s of Ka(i)){let a=Z(In(e.config.projectRoot,s));if(o.has(a)||Rn(s))return a}return Z(In(e.config.projectRoot,i))}function Dv(e,t,n){let r=Vv(e,t);if(!r)return null;let i=Et(e);for(let o of Av(r,n)){let s=ie(r.baseUrl,o);for(let a of Ka(s)){let c=Z(In(e.config.projectRoot,a));if(i.has(c)||Rn(a))return c}}return null}function Av(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 Ov(e,t){let n=jv(Mv(e),t);if(!n)return null;let r=Et(e);for(let i of Bv(n)){let o=ie(e.config.projectRoot,n.pkg.relativeDir,i);for(let s of Ka(o)){let a=Z(In(e.config.projectRoot,s));if(r.has(a)||Rn(s))return a}}return null}function Mv(e){return xv.get(e,()=>yp(e.config.projectRoot))}function jv(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 Bv(e){let t=[],n=$v(e.pkg.exports,e.subpath);if(n){let r=Gv(n);r&&t.push(r)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function $v(e,t){if(!e||typeof e!="object")return null;let n=t===""?".":`./${t}`;return Rp(e[n])}function Rp(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=Rp(t[n]);if(r)return r}return null}function Gv(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function Vv(e,t){let n=Z(Te(t));return yv.get(e,n,()=>Hv(e,n))}function Hv(e,t){let n=Sv();if(!n)return null;let r=ie(e.config.projectRoot),i=ie(r,t);for(;i===r||i.startsWith(r+pv);){for(let s of bv){let a=je(i,s);if(!Rn(a))continue;let c=gv.get(e,a,()=>Wv(n,a));if(c)return c}let o=Te(i);if(o===i)break;i=o}return null}function Wv(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?ie(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(je(e.config.projectRoot,t));for(let l=1;l<s;l++)c=Te(c);i=a?ie(c,a.replace(/\./g,"/")):c}else i=ie(e.config.projectRoot,n.replace(/\./g,"/"));for(let o of qv(i)){let s=Z(In(e.config.projectRoot,o));if(r.has(s)||Rn(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(je(e.config.projectRoot,t)),o;return r.startsWith("crate::")?o=ie(e.config.projectRoot,"src",r.slice(7).replace(/::/g,"/")):r.startsWith("self::")?o=ie(i,r.slice(6).replace(/::/g,"/")):o=ie(Te(i),r.slice(7).replace(/::/g,"/")),za(e,Uv(o))}function To(e,t,n){let r=Te(je(e.config.projectRoot,t)),i=ie(r,n);return za(e,zv(i))}function No(e,t,n){let r=Te(je(e.config.projectRoot,t)),i=[ie(r,n),ie(e.config.projectRoot,n),ie(e.config.projectRoot,"include",n),ie(e.config.projectRoot,"src",n)];return za(e,i)}function K(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=>hp(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 _o(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=Z(c.startsWith("lib/")?c:`lib/${c}`);return r.has(l)?l:null}let i=Te(je(e.config.projectRoot,t)),o=ie(i,n);for(let s of Kv(o)){let a=Z(In(e.config.projectRoot,s));if(r.has(a)||Rn(s))return a}return null}function Ua(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=>hp(s)===`${n.split("/").pop()}${i}`);if(o)return o}return null}function qv(e){let t=xt(e);return Ga.has(t)?[e]:[`${e}.py`,`${e}.pyi`,je(e,"__init__.py"),je(e,"__init__.pyi")]}function za(e,t){let n=Et(e);for(let r of t){let i=Z(In(e.config.projectRoot,r));if(n.has(i)||Rn(r))return i}return null}function Uv(e){let t=xt(e);return Va.has(t)?[e]:[`${e}.rs`,je(e,"mod.rs")]}function zv(e){let t=xt(e);return Ha.has(t)?[e]:[`${e}.rb`,je(e,"index.rb")]}function Kv(e){let t=xt(e);return Wa.has(t)?[e]:[`${e}.dart`,e]}function Ka(e){let t=xt(e),n=new Set;if(t){n.add(e);for(let r of En)n.add(e.slice(0,-t.length)+r)}else for(let r of En)n.add(`${e}${r}`),n.add(je(e,`index${r}`));return[...n]}function Et(e){return fv.get(e,()=>new Set(ye(e,{includeIgnored:!1}).map(Z)))}function Ja(e){return mv.get(e,()=>U([...Et(e)].sort().join(`
100
+ `)))}function Wt(e){return typeof e=="object"&&e!==null}function Be(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{basename as bf}from"path";function le(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ya(e){return e.replace(/'''[\s\S]*?'''/g,qt).replace(/"""[\s\S]*?"""/g,qt).replace(/#.*$/gm,qt).replace(/\/\/.*$/gm,qt).replace(/\/\*[\s\S]*?\*\//g,qt).replace(/`(?:\\[\s\S]|[^`])*`/g,qt).replace(/'(?:\\.|[^'\\\r\n])*'/g,qt).replace(/"(?:\\.|[^"\\\r\n])*"/g,qt)}function $M(e){return Pp(e,{maskStrings:!1})}function GM(e){return Pp(e,{maskStrings:!0})}function Pp(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+=Xa(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+=Xa(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?Xa(e,r,a):e.slice(r,a),r=a;continue}n+=o,r+=1}return n}function Xa(e,t,n){let r="";for(let i=t;i<n;i+=1)r+=e[i]===`
103
+ `?`
104
+ `:" ";return r}function qt(e){return e.replace(/[^\r\n]/g," ")}var VM=sn("stripped-lines",{clearGroups:["whole-project","source-file"]});Vn({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{ko=null,Wr=""},clearFile:()=>{ko=null,Wr=""}});var ko=null,Wr="";function Jv(e){return ko===e||(ko=e,Wr=Ya(e)),Wr}function Ut(e,t,n){let r=Jv(e);return`${r.slice(0,t)}${" ".repeat(n-t)}${r.slice(n)}`}function Pe(e,t){return new RegExp(`\\b${le(t)}\\b`,"m").test(e)}function tr(e,t){let n=new Set,r=new RegExp(`\\b${le(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 Qa(e){let t=0;for(let n of e)n==="("&&(t+=1),n===")"&&(t-=1);return t}import{extname as wp}from"path";var Xv={".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 ue(e){return Xv[wp(e).toLowerCase()]??null}function at(e){return wp(e).toLowerCase()===".vue"}var Cp=new WeakMap,Fp=new Set(["call_expression","call","decorator","pair","string","string_literal","template_string","variable_declarator"]);function qr(e,t){let n=Array.isArray(t)?t:[t];if(!n.every(o=>Fp.has(o)))return e.descendantsOfType(t);let r=Yv(e);return n.length===1?r.get(n[0])??[]:n.flatMap(o=>r.get(o)??[]).sort((o,s)=>o.startIndex-s.startIndex)}function Za(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 Yv(e){let t=Cp.get(e);if(t)return t;let n=new Map;return Za(e,r=>{let i=r.nodeType;if(!Fp.has(i))return;let o=n.get(i);o?o.push(r.currentNode):n.set(i,[r.currentNode])}),Cp.set(e,n),n}function he(e,t){t(e);for(let n of e.namedChildren)he(n,t)}var Qv=/(?:function|method|lambda)/u,Tp=new WeakMap;function Zv(e){let t=Tp.get(e);if(t)return t;let n=[];return Za(e,r=>{if(!r.nodeIsNamed)return;let i=r.nodeType;(i==="arrow_function"||Qv.test(i))&&n.push(r.currentNode)}),Tp.set(e,n),n}function $e(e,t,n){let r=null;for(let i of Zv(e))i.startPosition.row>t||i.endPosition.row<n||(!r||i.endIndex-i.startIndex<r.endIndex-r.startIndex)&&(r=i);return r}function Np(e,t,n){if(e.startPosition.row>t||e.endPosition.row<n)return null;for(let r of e.namedChildren){let i=Np(r,t,n);if(i)return i}return e}function Ge(e){let t=e;for(;["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(t.type)&&t.namedChildren.length>0;)t=t.namedChildren[0];return t}function Ur(e){if(e.type==="identifier")return e.text;let t=e.childForFieldName("name")??e.childForFieldName("pattern");return t?Ur(t):e.namedChildren.find(n=>n.type==="identifier")?.text??null}function zt(e){return(e.childForFieldName("parameters")??e.namedChildren.find(n=>/parameters/u.test(n.type)))?.namedChildren.map(Ur)??[]}import{createRequire as eI}from"module";var Se=eI(import.meta.url),zr=null,ec=!1;function _p(){if(ec)return null;if(zr)return zr;try{return zr=Se("tree-sitter"),zr}catch{return ec=!0,null}}function YM(e){if(e==="clojure")return"reader";let t=_p();if(!t)return"unavailable";let n=kp(e);if(!n)return"unavailable";try{return new t().setLanguage(n),"ast"}catch{return nr.add(e),"unavailable"}}var tc=new Map,nr=new Set;function kp(e){if(nr.has(e))return null;let t=tc.get(e);if(t)return t;let n;try{switch(e){case"rust":n=Se("tree-sitter-rust");break;case"typescript":n=Se("tree-sitter-typescript").typescript;break;case"tsx":n=Se("tree-sitter-typescript").tsx;break;case"javascript":n=Se("tree-sitter-javascript");break;case"python":n=Se("tree-sitter-python");break;case"java":n=Se("tree-sitter-java");break;case"kotlin":n=Se("tree-sitter-kotlin");break;case"scala":n=Se("tree-sitter-scala");break;case"ruby":n=Se("tree-sitter-ruby");break;case"c":n=Se("tree-sitter-c");break;case"cpp":n=Se("tree-sitter-cpp");break;case"csharp":n=Se("tree-sitter-c-sharp");break;case"php":n=Se("tree-sitter-php").php;break;case"vb":{let r=Se("tree-sitter-vb-dotnet");n=r.language??r;break}case"clojure":return nr.add(e),null}}catch{return nr.add(e),null}return tc.set(e,n),n}var nc=new Map;function QM(){zr=null,ec=!1,tc.clear(),nr.clear(),nc.clear(),iI.clear()}function tI(e){let t=nc.get(e);if(t)return t;let n=kp(e);if(!n)return null;let r=_p();if(!r)return null;let i=new r;try{i.setLanguage(n)}catch{return nr.add(e),null}return nc.set(e,i),i}function nI(e,t){return e.parse(r=>r>=t.length?null:t.slice(r,Math.min(t.length,r+16384)))}var rI=24;function wn(e,t){let n=tI(e);if(!n)return null;try{let r=nI(n,t);return dp(t.length*rI),r}catch{return null}}var iI=new Map;import{createRequire as oI}from"module";import{posix as rc}from"path";var sI=Bt("vue-sfc-units"),aI=oI(import.meta.url),cI;function lI(){return cI??=aI("@vue/compiler-sfc")}function Ap(...e){return lI().parse(...e)}function rr(e,t){let n=Op(t),r=F(e,n);return sI.get(e,n,r,()=>ic(e,n,r))}function Op(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function uI(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 ic(e,t,n){let r={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!n)return r;let i;try{i=Ap(n,{filename:t})}catch(s){return r.errors.push(Dp(s)),r}r.errors.push(...i.errors.map(Dp));let{descriptor:o}=i;return o.template&&(r.template=Lo(e,t,"template",o.template)),o.script&&r.scripts.push(Lp(e,t,o.script,!1)),o.scriptSetup&&r.scripts.push(Lp(e,t,o.scriptSetup,!0)),r.styles=o.styles.map(s=>Lo(e,t,"style",s)),r.customBlocks=o.customBlocks.map(s=>Lo(e,t,"custom",s)),r.errors.push(...[r.template,...r.scripts,...r.styles,...r.customBlocks].flatMap(s=>s?.errors??[])),r}function Lp(e,t,n,r){let i=Lo(e,t,"script",n);return{...i,kind:"script",setup:r,astLanguage:uI(i.lang)}}function Lo(e,t,n,r){let i=pI(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=dI(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 dI(e,t){let n=t.split(/[?#]/,1)[0];if(!n||n.startsWith("/")||n.includes("://"))return null;let r=Op(rc.normalize(rc.join(rc.dirname(e),n)));return r===".."||r.startsWith("../")?null:r}function pI(e){return{...e}}function Dp(e){return e instanceof Error?e.message:String(e)}function Kr(e,t,n){let i=ic(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 Do=sn("ast-trees",{clearGroups:["whole-project","source-file"]});function M(e,t){if(at(t))return fI(e,t);let n=ue(t);if(!n)return null;let r=F(e,t);return r?Do.get(e,t,r,()=>wn(n,r)):null}function ir(e,t,n){if(at(t))return Do.get(e,t,n,()=>{let i=Kr(e,t,n);return i?wn(i.language,`
109
+ `.repeat(i.startLine)+i.body):null});let r=ue(t);return r?Do.get(e,t,n,()=>wn(r,n)):null}function fI(e,t){let n=F(e,t);return n?Do.get(e,t,n,()=>{let r=Kr(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=gI(e,t);if(!n)return null;let r=Rt(n);if(!r)return null;let i=yI(n);return{calleeLeaf:r,calleeQualifier:i?mI(n):void 0,calleeText:n.text,memberAccess:i,line:e.startPosition.row}}function mI(e){return(e.childForFieldName("object")??e.childForFieldName("value")??e.namedChild(0)??void 0)?.text||void 0}function gI(e,t){if(t==="rust")return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null;if(t==="python")return e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0);if(t==="typescript"||t==="tsx"||t==="javascript"){if(e.type==="call_expression")return e.childForFieldName("function")??e.namedChild(0);if(e.type==="new_expression")return e.childForFieldName("constructor")??e.namedChild(0)}return null}function yI(e){switch(e.type){case"field_expression":case"member_expression":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"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?Rt(t):null}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 Jr(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var Hp=["function_declaration","generator_function_declaration","method_definition","method_signature","function_signature"],hI=new Set(Hp),SI=[...Hp,"variable_declarator","public_field_definition"],bI=["function_item","function_signature_item"],xI=["function_definition"],vI=[],Mp=new Set(["arrow_function","function_expression","generator_function"]);function Wp(e){return e==="rust"?bI:e==="python"?xI:e==="typescript"||e==="tsx"||e==="javascript"?SI:vI}function sr(e,t){let n=EI(e,t);if(n)return{name:n.name,startLine:n.definitionNode.startPosition.row,endLine:n.definitionNode.endPosition.row,paramCount:Gp(n.functionNode),params:jp(n.functionNode),paramsEndLine:Bp(n.functionNode),isLiteralPassthrough:Vp(n.functionNode,t),branches:0};if(!II(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:Gp(e),params:jp(e),paramsEndLine:Bp(e),isLiteralPassthrough:Vp(e,t),branches:0}:null}function qp(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function jp(e){let t=qp(e);if(!t)return[];let n=[];for(let r of t.namedChildren){if(Jr(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 Bp(e){let t=qp(e);return t?t.endPosition.row:e.startPosition.row}function II(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?hI.has(e):!1}function EI(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=$p(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=$p(r);return i?{name:n.text,definitionNode:e,functionNode:i}:null}return null}function $p(e){if(Mp.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=>Mp.has(i.type));return r.length===1?r[0]:null}function Gp(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)Jr(r)||(n+=1);return n}function Vp(e,t){let n=e.namedChildren.find(d=>d.type==="block"||d.type==="statement_block");if(!n)return!1;let r=n.namedChildren.filter(d=>!Jr(d));if(r.length!==1)return!1;let i=r[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:t==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let s=t==="python"?"call":"call_expression";if(o.type!==s)return!1;let a=o.namedChildren.find(d=>d.type==="arguments"||d.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(d=>!Jr(d)),l=e.namedChildren.find(d=>d.type==="parameters"||d.type==="formal_parameters");if(!l)return!1;let u=[];for(let d of l.namedChildren){if(d.type==="identifier"){u.push(d.text);continue}let p=d.namedChildren.find(f=>f.type==="identifier");p&&u.push(p.text)}if(c.length!==u.length)return!1;for(let d=0;d<u.length;d+=1){let p=c[d];if(p.type!=="identifier"||p.text!==u[d])return!1}return!0}function yj(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 RI=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 Up(e){return RI.has(e.type)?1:e.type==="binary_expression"&&e.parent?.type!=="binary_expression"&&(e.text.includes("&&")||e.text.includes("||"))?PI(e.text):0}function PI(e){return(e.match(/&&|\|\|/g)??[]).length}var wI=new Set(["identifier","type_identifier","field_identifier"]),CI=new Set(["identifier"]),FI=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),TI=new Set(["rust","python"]),NI=/\{([^{}]*)\}/g,_I=/\b([A-Za-z_][\w]*)\b/g;function zp(e,t){return kI(t).has(e.type)}function Kp(e,t){return TI.has(t)&&e.type==="string_content"}function oc(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 kI(e){return e==="rust"?wI:e==="python"?CI:FI}function Jp(e,t){let n=e.startPosition.row;for(let r of e.text.matchAll(NI)){let i=r[1]??"";for(let o of i.matchAll(_I))o[1]&&t(o[1],n)}}var LI=[/\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],DI=/^#!?\[\s*serde\s*\(/,AI=/^#!?\[\s*schemars\s*\(/,OI=/^#!?\[\s*validate\s*\(/,MI=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function Xp(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||!MI.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 Yp(e,t){let n=DI.test(e),r=AI.test(e),i=OI.test(e);if(!(!n&&!r&&!i))for(let o of LI){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 Qp(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 jI=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),sc=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 Zp(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=Oo(e,a);continue}if(l==='"'){let g=Yr(e,a,s);s=g.line,a=g.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:s,endLine:s,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let g=o.pop();g&&(g.endLine=s,BI(g,{callables:t,callSites:n,clojureMembers:r,recordIdentifier:c}),o[o.length-1]?.children.push(g)),a+=1;continue}if(ac(l)){a+=1;continue}let u=s,d=a;for(;a<e.length&&!cc(e[a]);)a+=1;let p=e.slice(d,a);if(!p)continue;let f={text:p,line:u};$I(o[o.length-1],f),c(Ve(p),u)}return{language:"clojure",callables:t,callSites:n,clojureMembers:r,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:qI(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function BI(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let n=e.headTokens[0],r=Ve(n.text),i=jI.get(n.text);if(i){let s=e.headTokens[1];if(s){let a=Ve(s.text);t.recordIdentifier(a,s.line),t.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:s.line,isLiteralPassthrough:!1,clojureKind:i})}}if(GI(e,t),!r||sc.has(n.text)||sc.has(r)||r.startsWith(":"))return;let o=WI(n.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:n.line})}function $I(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function GI(e,t){let n=Ve(e.tokens[0]?.text??"");if(n==="defprotocol"){let r=Ve(e.tokens[1]?.text??"");if(!r)return;for(let i of Ao(e))Xr(t,r,"protocol",i,"protocol-method");return}if(n==="defrecord"||n==="deftype"){let r=Ve(e.tokens[1]?.text??"");if(!r)return;let i=n==="defrecord"?"record":"type",o=n==="defrecord"?"record-method":"type-method";for(let s of Ao(e))Xr(t,r,i,s,o);return}if(n==="extend-type"){let r=Ve(e.tokens[1]?.text??"");if(!r)return;for(let i of Ao(e))Xr(t,r,"extension",i,"extension-method");return}if(n==="extend-protocol"){let r=Ve(e.tokens[1]?.text??"");for(let i of Ao(e)){r&&Xr(t,r,"extension",i,"extension-method");let o=HI(e,i.startLine);o&&o!==r&&Xr(t,o,"extension",i,"extension-method")}}}function Ao(e){return e.children.filter(VI)}function VI(e){if(e.kind!=="(")return!1;let t=Ve(e.tokens[0]?.text??"");return!!(t&&!sc.has(t)&&!t.startsWith(":"))}function Xr(e,t,n,r,i){let o=r.tokens[0],s=Ve(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:n,memberName:s,memberKind:i,startLine:r.startLine,endLine:r.endLine}))}function HI(e,t){let n=null;for(let r=2;r<e.tokens.length;r+=1){let i=e.tokens[r];if(i.line>t)break;let o=Ve(i.text);o&&!o.startsWith(":")&&(n=o)}return n}function Ve(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function WI(e){let t=e.replace(/^#?['`~@]+/,""),n=t.lastIndexOf("/"),r=Ve(t);if(n<=0)return{leaf:r,text:t};let i=t.slice(0,n);return{leaf:r,qualifier:i,text:t}}function Oo(e,t){let n=t;for(;n<e.length&&e[n]!==`
112
+ `;)n+=1;return n}function Yr(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 ac(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function cc(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function qI(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 ef=7,zI=sn("source-facts",{clearGroups:["whole-project","source-file"]}),lc=ce({kind:"source-facts",invalidation:te("source-facts"),serialize:XI,deserialize:YI});function be(e,t){return uc(e,t).facts}function uc(e,t){let n=F(e,t);if(!n)return{facts:null};let r=KI(e,t,n);return r?zI.get(e,t,n,()=>JI(e,t,r,n)):{facts:null}}function KI(e,t,n){return at(t)?Kr(e,t,n)?.language??null:ue(t)}function JI(e,t,n,r){let i=me(e,t,r),o=lc.read(e,t,i);if(o&&o.language===n)return{facts:o};if(n==="clojure"){let c=Zp(r);return lc.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=tE(s,n);return lc.write(e,t,i,a),{facts:a}}function XI(e){let t={version:ef,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 YI(e){try{let t=JSON.parse(e);if(t.version!==ef||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:oc(n),fileIdentifiers:new Set(n.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function QI(e,t,n,r){let i=be(e,t);return i?eE(i,n,r)?.isLiteralPassthrough??!0:!0}function ZI(e,t){return t.relativePath.includes(".clj-kondo/hooks/")?!0:be(e,t.relativePath)?.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine)?.clojureKind==="macro"}function eE(e,t,n){return e.callables.find(r=>r.startLine===t&&r.endLine===n)??null}function tE(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=Up(u);if(p>0)for(let g of c)g.branches=(g.branches??0)+p;let f=or(u,t);f&&r.push(f),Xp(u,t,o),t==="rust"&&(u.type==="attribute_item"||u.type==="inner_attribute_item")&&Yp(u.text,i),zp(u,t)&&a(u.text,u.startPosition.row),Kp(u,t)&&Jp(u,a);for(let g of u.children)l(g);d&&c.pop()};return l(e.rootNode),{language:t,callables:n,callSites:r,clojureMembers:[],typeContainerMap:Qp(e,t),identifierLineMap:s,identifiersByLine:oc(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var tf=new Set(["rust","typescript","tsx","javascript","python","clojure"]),nE=new Set(["rust","typescript","tsx","javascript","python"]);function Qr(e,t){let n=be(e,t);return!n||!tf.has(n.language)?null:n.callables.map(r=>({name:r.name,startLine:r.startLine,endLine:r.endLine}))}function dc(e,t){if(!nE.has(t))return null;let n=[];for(let r of e.descendantsOfType([...Wp(t)])){let i=sr(r,t);i&&n.push({name:i.name,startLine:i.startLine,endLine:i.endLine})}return n}function rE(e,t){let n=be(e,t);return!n||!tf.has(n.language)?null:n.callSites}function iE(e,t){return be(e,t)?.typeContainerMap??new Map}import{createRequire as sE}from"module";var oE=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 Mo(e){return e.length<=2||oE.has(e)}function jo(e,t){return e.split(t).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}var aE=Bt("vue-template-facts"),cE=sE(import.meta.url),lE;function Zr(){return lE??=cE("@vue/compiler-dom")}var uE=new Set(["component","keep-alive","slot","suspense","teleport","template","transition","transition-group"]),dE=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"]),pE=new Set(["div","span","template"]),fE=new Set(["as","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","from","function","if","import","in","instanceof","let","new","null","of","return","super","switch","this","throw","true","try","typeof","undefined","var","void","while","with","yield"]);function Bo(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n);return aE.get(e,n,r,()=>mE(n,rr(e,n).template))}function mE(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=Zr().parse(t.body,{comments:!1})}catch{return n}let i=new Set,o=s=>{s.trim()&&i.add(s)};return rf(r.children,t.startLine,n,o),n.structuralTokens=[...i].sort(),n}function rf(e,t,n,r){for(let i of e)if(i.type===Zr().NodeTypes.ELEMENT)gE(i,t,n,r),rf(i.children,t,n,r);else if(i.type===Zr().NodeTypes.INTERPOLATION){r("interpolation");let o=pc(i.content);o&&of(o,t,i.loc.start.line,n,r)}}function gE(e,t,n,r){let i=IE(e.tag),o={tag:e.tag,normalized:i,kind:vE(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),pE.has(e.tag)||r(`native:${e.tag}`));for(let s of e.props)yE(s,t,n,r)}function yE(e,t,n,r){if(e.type===Zr().NodeTypes.ATTRIBUTE){let a=e.value?.content??null,c=nf("prop",e.name,a,t,e.loc.start.line,e.loc.end.line);n.props.push(c),r(`prop:${e.name}`);return}let i=SE(e),o=pc(e.exp),s=nf(hE(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&&of(o,t,e.loc.start.line,n,r)}function nf(e,t,n,r,i,o){return{kind:e,name:t,value:n,startLine:ar(r,i),endLine:ar(r,o)}}function hE(e){switch(e){case"bind":case"model":return"prop";case"on":return"event";case"slot":return"slot";default:return"directive"}}function SE(e){let t=pc(e.arg);return t||e.name}function pc(e){if(!e)return null;let t=("content"in e&&typeof e.content=="string"?e.content:e.loc.source).trim();return t||null}function of(e,t,n,r,i){for(let o of bE(e)){let s={name:o,startLine:ar(t,n),endLine:ar(t,n)};r.expressionIdentifiers.push(s),i(`id:${o}`)}}function bE(e){let t=new Set,n=xE(e),r=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,i;for(;i=r.exec(n);){let o=i[0];fE.has(o)||Mo(o)||/^[A-Z_]+$/.test(o)||t.add(o)}return[...t].sort()}function xE(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 vE(e){let t=e.tag;return e.tagType===Zr().ElementTypes.COMPONENT?"component":uE.has(t)?"builtin":dE.has(t)?"native":/^[A-Z]/.test(t)||t.includes("-")?"component":"native"}function IE(e){return jo(e,/[-_:]/)}function ar(e,t){return e+Math.max(0,t-1)}var EE=new Set(["ref","shallowRef","reactive","computed","watch","watchEffect"]),RE=new Set(["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured"]),PE=new Set(["axios","fetch","runRequest","useAsyncData","useFetch","useResource"]),wE=new Set(["defineEmits","defineExpose","defineModel","defineOptions","defineProps","withDefaults"]),CE=new Set(["catch","for","function","if","return","switch","while"]);function Go(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(..._E(n));let r=wn(n.astLanguage,n.body);r?TE(n,r.rootNode,t):NE(n,t)}return FE(t),t.externalScriptPaths=af(t.externalScriptPaths),t}function FE(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 af(e.calls.filter(n=>n.categories.includes(t)).map(n=>n.name))}function TE(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:sf(c.calleeLeaf),setup:e.setup}))}for(let l of s.children)o(l)};o(t)}function NE(e,t){for(let n of e.body.matchAll(/\b([A-Za-z_$][\w$]*)\s*\(/g)){let r=n[1];!r||CE.has(r)||t.calls.push({name:r,sourcePath:e.sourcePath,line:e.startLine+$o(e.body,n.index??0),categories:sf(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+$o(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+$o(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}}function _E(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+$o(e.body,n.index??0);for(let s of kE(r))t.push({local:s,source:i,sourcePath:e.sourcePath,line:o,setup:e.setup})}return t}function kE(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 sf(e){let t=["call"];return/^use[A-Z0-9_]/.test(e)&&t.push("composable"),/^use[A-Z0-9_].*Store$/.test(e)&&t.push("store"),EE.has(e)&&t.push("reactivity"),RE.has(e)&&t.push("lifecycle"),PE.has(e)&&t.push("request"),wE.has(e)&&t.push("macro"),t}function $o(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 af(e){return[...new Set(e)].sort()}var LE=new Set(["in","key","of"]),DE=new Set(["computed","defineEmits","defineProps","reactive","ref","watch","watchEffect"]),AE=Bt("vue-component-behavior-profiles");function cf(e,t={}){let n=Me(e,{extensions:[".vue"]}).filter(i=>!t.scope||i.includes(t.scope)).sort();return(typeof t.scanLimit=="number"&&t.scanLimit>0?n.slice(0,t.scanLimit):n).map(i=>fc(e,i)).filter(i=>(t.minTemplateTokens===void 0||i.templateTokens.size>=t.minTemplateTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function fc(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n),i=AE.get(e,n,r,()=>OE(e,n,r));return jE(i)}function OE(e,t,n){let r=rr(e,t),i=Bo(e,t),o=Go(r),s=GE(i),a=i.expressionIdentifiers.map(m=>m.name).filter(m=>!s.includes(m)).filter((m,S,h)=>h.indexOf(m)===S).sort(),c=i.componentTags.map(m=>m.normalized).filter((m,S,h)=>h.indexOf(m)===S).sort(),l=n?n.split(`
114
+ `).length:0,u=Cn(r.template),d=o.lineCount,p=r.styles.reduce((m,S)=>m+Cn(S),0),f=r.customBlocks.reduce((m,S)=>m+Cn(S),0),{lines:g,paths:y}=ME(e,t,o);return{file:t,sfc:r,templateFacts:i,scriptFacts:o,templateTokens:new Set(i.structuralTokens),behaviorTokens:$E(i,o,a),templateBindingNames:a,templateLocalNames:s,componentNames:c,sfcLines:l,totalLines:l+o.externalLineCount,templateLines:u,scriptLines:d,styleLines:p,externalScriptLines:o.externalLineCount,externalScriptPaths:o.externalScriptPaths,customBlockLines:f,delegatedComposableLines:g,delegatedComposablePaths:y}}function ME(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 jE(e){let t=BE(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 BE(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 $E(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(DE.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 GE(e){let t=new Set;for(let n of e.directives)if(n.name==="for"&&n.value)for(let r of VE(n.value))t.add(r);for(let n of e.slots)if(n.value)for(let r of lf(n.value))t.add(r);return[...t].sort()}function VE(e){let t=/^(.*?)\s+(?:in|of)\s+/.exec(e.trim());return t?lf(t[1]??""):[]}function lf(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];LE.has(r)||t.push(r)}return t}import{extname as HE}from"path";var WE=[".tsx",".jsx"],uf=new Set(["useActionState","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useOptimistic","useReducer","useRef","useState","useSyncExternalStore","useTransition"]),qE=new Set(["useEffect","useInsertionEffect","useLayoutEffect"]),UE=new Set(["useActionState","useOptimistic","useReducer","useRef","useState"]),zE=new Set(["useLocation","useNavigate","useParams","useSearchParams","useTranslation"]),KE=new Set(["axios","fetch","gql","graphql","mutate","query","request","useMutation","useQuery","useSuspenseQuery"]),JE=new Set(["add","apply","cancel","change","clear","close","create","delete","fetch","filter","handle","load","open","refresh","remove","render","reset","save","select","submit","toggle","update"]),XE=new Set(["aria-hidden","className","clipRule","d","fill","fillRule","height","role","stroke","strokeLinecap","strokeLinejoin","strokeWidth","style","viewBox","width","xmlns"]),YE=Bt("react-component-behavior-profiles"),df=ce({kind:"react-component-behavior-profiles",invalidation:te("react-component-behavior-profiles"),serialize:tR,deserialize:nR});function gf(e,t={}){let n=Me(e,{extensions:WE}).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=>gc(e,i)).filter(i=>(t.minJsxTokens===void 0||i.jsxTokens.size>=t.minJsxTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function gc(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n);return YE.get(e,n,r,()=>QE(e,n,r)).map(eR)}function QE(e,t,n){let r=me(e,t,n),i=df.read(e,t,r);if(i)return i;let o=ZE(e,t);return df.write(e,t,r,o),o}function ZE(e,t){let n=iR(t);if(!n)return[];let r=M(e,t);if(!r)return[];let i=Vr(e,t).length;return oR(r.rootNode,n).filter(s=>s.kind==="hook"||yc(s.bodyNode)).map(s=>{let a=pR(s.bodyNode),c=hR(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 eR(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 tR(e){return JSON.stringify(e.map(t=>({...t,jsxTokens:[...t.jsxTokens],behaviorTokens:[...t.behaviorTokens]})))}function nR(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=[];for(let r of t){let i=rR(r);if(!i)return null;n.push(i)}return n}catch{return null}}function rR(e){if(!Wt(e))return null;let{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:c,behaviorTokens:l,componentNames:u,nativeTags:d,propNames:p,eventNames:f,hookNames:g,requestNames:y,stateNames:m,effectNames:S,handlerNames:h}=e;if(typeof t!="string"||typeof n!="string"||r!=="component"&&r!=="hook"||!Vo(i)||!Vo(o)||!Vo(s)||!Vo(a))return null;let v={jsxTokens:Be(c),behaviorTokens:Be(l),componentNames:Be(u),nativeTags:Be(d),propNames:Be(p),eventNames:Be(f),hookNames:Be(g),requestNames:Be(y),stateNames:Be(m),effectNames:Be(S),handlerNames:Be(h)};return Object.values(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 Vo(e){return typeof e=="number"&&Number.isFinite(e)}function iR(e){let t=HE(e).toLowerCase();return t!==".tsx"&&t!==".jsx"?null:ue(e)}function oR(e,t){let n=[],r=new Set,i=o=>{let s=sR(o);if(s&&(!uR(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=mc(e);if(!o||!/^[A-Z]/.test(o))return null;let s=aR(e);return!s||!cR(e)&&!yc(s)?null:{name:o,kind:"component",node:e,bodyNode:s}}if(e.type==="function_declaration"){let o=mc(e);return!o||!pf(o)?null:{name:o,kind:ff(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=ei(t);if(!r||!n||!pf(r))return null;let i=lR(n);return i?{name:r,kind:ff(r),node:e,bodyNode:i}:null}function aR(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 cR(e){return/\b(?:React\.)?(?:Pure)?Component\b/.test(e.text)}function pf(e){return/^[A-Z]/.test(e)||/^use[A-Z0-9_]/.test(e)}function ff(e){return/^use[A-Z0-9_]/.test(e)?"hook":"component"}function lR(e){if(e.type==="arrow_function"||e.type==="function_expression")return e;if(e.type!=="call_expression")return null;let t=dR(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 uR(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 mc(e){return ei(e.childForFieldName("name")??e.namedChild(0))}function dR(e){let t=e.childForFieldName("function")??e.namedChild(0);return t?t.text.split(".").pop()??t.text:null}function yc(e){return e.type.startsWith("jsx_")?!0:e.namedChildren.some(yc)}function pR(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"?fR(r,t):r.type==="jsx_element"&&r.text.trimStart().startsWith("<>")?t.tokens.add("jsx:fragment"):r.type==="jsx_expression"?mR(r,t):r.type==="jsx_fragment"&&t.tokens.add("jsx:fragment");for(let i of r.children)n(i)};return n(e),t}function fR(e,t){let n=gR(e),r=!1;if(n){let i=mf(n),o=i==="Fragment"||i==="React.Fragment";r=IR(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=yR(i);if(!o)continue;let s=mf(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 XE.has(s)||(t.propNames.add(s),t.tokens.add(`${r?"prop":"native-prop"}:${s}`))}else i.type==="jsx_spread_attribute"&&t.tokens.add(yf(i))}function mR(e,t){let n=e.text;/^\{\s*\.\.\./.test(n)&&t.tokens.add(yf(e)),hf(e)&&t.tokens.add("jsx:conditional"),(n.includes(".map(")||n.includes(".flatMap("))&&t.tokens.add("jsx:list");for(let r of ER(n))Mo(r)||t.tokens.add(`binding:${r}`)}function yf(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 hf(e){return e.type==="ternary_expression"||e.type==="conditional_expression"?!0:e.namedChildren.some(hf)}function gR(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 yR(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 hR(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&&SR(o.calleeLeaf,n)}else if(i.type==="variable_declarator")xR(i,n);else if(i.type==="function_declaration"){let o=mc(i);o&&Sf(o,n)}for(let o of i.namedChildren)r(o)};return r(e),n}function SR(e,t){/^use[A-Z0-9_]/.test(e)&&(t.hookNames.add(e),!uf.has(e)&&!zE.has(e)&&t.tokens.add(`hook:${e}`)),uf.has(e)&&t.tokens.add(`react-hook:${e}`),qE.has(e)&&(t.effectNames.add(e),t.tokens.add(`effect:${e}`)),UE.has(e)&&t.tokens.add(`state-hook:${e}`),bR(e)&&(t.requestNames.add(e),t.tokens.add(`request:${e}`))}function bR(e){if(KE.has(e))return!0;let t=/^use([A-Z0-9_].*)$/.exec(e)?.[1];return t?/(Query|Mutation|Fetch|Resource)$/.test(t):!1}function xR(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=>ei(a)),s=ei(o);s&&(t.stateNames.add(s),t.tokens.add(`state:${s}`))}let i=ei(n);i&&Sf(i,t)}function Sf(e,t){let n=vR(e);!n||!JE.has(n)||(t.handlerNames.add(e),t.tokens.add(`handler:${e}`),t.tokens.add(`handler-verb:${n}`))}function vR(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 IR(e){return/^[A-Z]/.test(e)||e.includes(".")}function mf(e){return e.replace(/^this\./,"").replace(/\$/g,".")}function ei(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 ER(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 C0(e){return{capability:(t,n)=>RR(t,n),reactProfiles:(t={})=>gf(e,t),reactProfilesForFile:t=>gc(e,t),vueProfiles:(t={})=>cf(e,t),vueProfileForFile:t=>fc(e,t),vueTemplateFacts:t=>Bo(e,t),vueScriptFacts:t=>Go(rr(e,t))}}function RR(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 PR(e,t,n={}){let r=be(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 wR=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function we(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 _e(e,t){for(let n of e.namedChildren)if(n.type===t)return n;return null}function J(e,t){let n=new Set,r=(i,o)=>{let s=o||t.has(i.type);!s&&wR.has(i.type)&&n.add(i.text);for(let a of i.children)r(a,s)};return r(e.rootNode,!1),n}function Qe(e,t,n,r,i,o,s){return{importedName:i,localName:o,sourcePath:s??K(e,r,qa(t)),kind:"named",used:Pe(n,o),usedMembers:[]}}function q(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 He(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=Ut(e,i.index,i.index+o.length);for(let a of n(i,s))r.push(a)}return r}function We(e,t,n,r,i){let o=ir(e,t,i);if(o){let s=n(o);if(s)return s}return r()}function Ho(e,t,n,r,i){let o=ir(e,t,i),s=ue(t),a=s?n[s]:void 0;return o&&a?a(o):r()}function xf(e,t,n){return We(e,t,r=>FR(e,t,r),()=>CR(e,t,n),n)}function CR(e,t,n){return He(n,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(r,i)=>{let o=r[1]?.trim();if(!o)return[];let s=bf(o).replace(/\.[^.]+$/,"");return[wt(o,s,No(e,t,o),Pe(i,s))]})}function FR(e,t,n){let r=J(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=bf(s).replace(/\.[^.]+$/,"");i.push(q(s,a,No(e,t,s),r))}return i}var TR=new Set([":require",":require-macros",":use"]),bc=String.raw`A-Za-z0-9_$*+!?.<>=-`;function If(e,t,n){let r=$R(n);if(!r)return[];let i=BR(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=qe(s.children[0]);if(a){if(TR.has(a)){for(let c of kR(s.children.slice(1)))o.push(..._R(e,c,i));continue}if(a===":import")for(let c of DR(s.children.slice(1)))o.push(c)}}return o}function NR(e){return e.type==="list"&&qe(e.children[0])==="ns"}function _R(e,t,n){let r=Ua(e,t.namespace),i=t.alias??t.namespace,o=OR(n,i),s=[{importedName:t.namespace,localName:i,sourcePath:r,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||MR(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:jR(n,a),usedMembers:[]});return s}function kR(e){return e.flatMap(t=>Wo(t,null))}function Wo(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:Sc(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&qe(e.children[0])===null?e.children.flatMap(n=>Wo(n,t)):LR(e,t);if(e.type==="list"&&e.children.length>0){let n=qe(e.children[0]);return n?!n||n.startsWith(":")?[]:e.children.slice(1).flatMap(r=>Wo(r,Sc(t,n))):e.children.flatMap(r=>Wo(r,t))}return[]}function LR(e,t){let n=qe(e.children[0]);if(!n||n.startsWith(":"))return[];let r={namespace:Sc(t,n),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=qe(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){r.alias=qe(s),i+=1;continue}o===":refer"&&s&&(qe(s)===":all"?r.referAll=!0:(s.type==="vector"||s.type==="list")&&r.refers.push(...s.children.map(qe).filter(AR)),i+=1)}return[r]}function DR(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=qe(n.children[0]);if(r)for(let i of n.children.slice(1)){let o=qe(i);o&&t.push(wt(`${r}.${o}`,o,null,!0))}}return t}function Sc(e,t){return e?`${e}.${t}`:t}function qe(e){return e?.type==="atom"?e.text:null}function AR(e){return!!(e&&!e.startsWith(":"))}function OR(e,t){let n=new Set,r=new RegExp(`${xc()}${le(t)}\\s*/\\s*([${bc}]+)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function MR(e,t){return new RegExp(`${xc()}${le(t)}\\s*/`,"m").test(e)}function jR(e,t){return new RegExp(`${xc()}${le(t)}(?![${bc}])`,"m").test(e)}function xc(){return`(?<![${bc}])`}function BR(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=Oo(e,i);r+=vf(e.slice(i,s)),i=s;continue}if(o==='"'){let s=Yr(e,i,0).index;r+=vf(e.slice(i,s)),i=s;continue}r+=o,i+=1}return r}function $R(e){let t=0;for(;t<e.length&&(t=vc(e,t),!(t>=e.length));){let n=qo(e,t);if(!n){t+=1;continue}if(NR(n.form))return n.form;t=n.index}return null}function qo(e,t){let n=vc(e,t);if(e.startsWith("#?@",n)||e.startsWith("#?",n))return GR(e,n);if(e.startsWith("#_",n)){let i=qo(e,n+2);return i?{form:{type:"atom",text:"",start:n,end:i.index},index:i.index}:null}for(;ac(e[n]);)n+=1;let r=e[n];return r?r==="("?hc(e,n,"list",")"):r==="["?hc(e,n,"vector","]"):r==="{"?hc(e,n,"map","}"):r==='"'?{form:{type:"atom",text:"",start:n,end:Yr(e,n,0).index},index:Yr(e,n,0).index}:HR(e,n):null}function GR(e,t){let n=e.startsWith("#?@",t)?3:2,r=qo(e,t+n);return r?{form:{type:"list",children:r.form.type==="list"||r.form.type==="vector"||r.form.type==="map"?VR(r.form.children):[],start:t,end:r.index},index:r.index}:null}function VR(e){let t=[];for(let n=0;n<e.length;n+=2){let r=qe(e[n]),i=e[n+1];r?.startsWith(":")&&i&&t.push(i)}return t}function hc(e,t,n,r){let i=[],o=t+1;for(;o<e.length;){if(o=vc(e,o),e[o]===r)return{form:{type:n,children:i,start:t,end:o+1},index:o+1};let s=qo(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 HR(e,t){let n=t;for(;n<e.length&&!cc(e[n]);)n+=1;return{form:{type:"atom",text:e.slice(t,n),start:t,end:n},index:n}}function vc(e,t){let n=t;for(;n<e.length;){let r=e[n];if(/\s|,/.test(r)){n+=1;continue}if(r===";"){n=Oo(e,n);continue}break}return n}function vf(e){return e.replace(/[^\r\n]/g," ")}function Ef(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=Ut(n,i.index,i.index+a.length);r.push({importedName:o,localName:s,sourcePath:_o(e,t,o),kind:s?"namespace":"side-effect",used:s?Pe(c,s):!0,usedMembers:s?tr(c,s):[]})}return r}function Rf(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:_o(e,t,o)})}return r}function Pf(e,t,n){return Ho(e,t,{csharp:r=>qR(e,t,r),vb:r=>WR(e,t,r)},()=>{let r=Ep(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return He(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[Qe(e,t,o,u,d,p,K(e,u,Ht))]})},n)}function WR(e,t,n){let r=J(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(q(u,d,K(e,l,Ht),r,c?"namespace":"named"))}return i}function qR(e,t,n){let r=J(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(q(u,d,K(e,l,Ht),r,a?"namespace":"named"))}return i}var UR=C("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function wf(e,t){return UR.get(e,t,()=>{let n=new Set,r=F(e,t);if(!r)return n;let o=r.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,s=>s.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,s=>s.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,s=>s.replace(/[^\r\n]/g," "));for(let s of o.matchAll(/[A-Za-z_$][\w$]*/g))n.add(s[0]);return n})}function Ic(e,t,n){return We(e,t,r=>KR(e,t,r),()=>zR(e,t,n),n)}function zR(e,t,n){return oP(n).flatMap(r=>sP(e,t,r.clause,r.specifier,r.start,r.end,n))}function KR(e,t,n){let r=JR(e,t,n),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))i.push(...XR(e,t,n,o,r));return i}function JR(e,t,n){let r=J(n,new Set(["import_statement"]));if(at(t))for(let i of wf(e,t))r.add(i);return r}function XR(e,t,n,r,i){let o=tP(r);if(!o)return[];let s=st(e,t,o),a=_e(r,"import_clause");return a?YR(n,a,s,i,nP(r.text)):[Fn("*",s)]}function YR(e,t,n,r,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(QR(s.text,n,r,i));else if(s.type==="namespace_import"){let a=ZR(e,s,n,r,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...eP(s,n,r,i));return o}function QR(e,t,n,r){return q("default",e,t,n,"default",{isTypeOnly:r})}function ZR(e,t,n,r,i){let s=_e(t,"identifier")?.text??"";if(!s)return null;let a=iP(e,s);return Tn("*",n,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||r.has(s)})}function eP(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(q(c,l,t,n,"named",{isTypeOnly:r||rP(o.text)}))}return i}function tP(e){let t=_e(e,"string");if(!t)return null;let n=_e(t,"string_fragment");return n?n.text:null}function nP(e){return/^\s*import\s+type\b/.test(e)}function rP(e){return/^\s*type\b/.test(e.trim())}function iP(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 oP(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=Ut(s,i,o);return n?aP(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||Pe(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?Pe(c,u.localName):!1,u.kind,[],{isTypeOnly:u.isTypeOnly})}):[Fn("*",a)]}function aP(e){let t=e.trim(),n=/^type\b/.test(t),r=t.replace(/^type\s+/,""),[i,o]=cP(r),s=[];return i&&s.push(...Cf(i,n)),o&&s.push(...Cf(o,n)),s}function Cf(e,t){let n=e.trim();if(!n)return[];if(n.startsWith("{")){let r=n.slice(1,-1).trim();return r?we(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 cP(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 Ec(e,t,n){let r=M(e,t);return r?mP(e,t,r):lP(e,t,n)}function lP(e,t,n){return[...uP(e,t,n),...dP(e,t,n),...pP(e,t,n)]}function uP(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=we(s).map(d=>fP(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 dP(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 pP(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 fP(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 mP(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("export_statement")){let o=gP(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=yP(i,o,s,a);r.push(c)}return r}function gP(e,t,n){let r=_e(n,"string");if(!r)return;let i=_e(r,"string_fragment");if(i)return st(e,t,i.text)}function yP(e,t,n,r){let i=_e(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=_e(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 Ff(e,t,n){return Ho(e,t,{java:r=>hP(e,t,r),kotlin:r=>SP(e,t,r),scala:r=>bP(e,t,r)},()=>He(n,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(r,i)=>{let o=r[1]?.trim();return o?xP(e,t,o,i):[]}),n)}function hP(e,t,n){let r=J(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("*",K(e,l,Ne)));continue}let u=l.split(".").pop()??l;i.push(q(u,u,K(e,l,Ne),r))}return i}function SP(e,t,n){let r=J(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("*",K(e,s.text,Ne)));continue}let l=s.text,u=l.split(".").pop()??l,p=c?.namedChild(0)?.text??u;i.push(q(u,p,K(e,l,Ne),r))}return i}function bP(e,t,n){let r=J(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("*",K(e,c,Ne)));continue}if(s?.type==="namespace_selectors"){for(let d of s.namedChildren)if(d.type==="arrow_renamed_identifier"){let[p,f]=d.namedChildren;if(!p)continue;let g=p.text,y=f?.text??g;if(g==="_")continue;i.push(q(g,y,K(e,`${c}.${g}`,Ne),r))}else if(d.type==="identifier"){let p=d.text;i.push(q(p,p,K(e,`${c}.${p}`,Ne),r))}continue}let l=a[a.length-1]?.text??c,u=a.slice(0,-1).map(d=>d.text).join(".")||c;i.push(q(l,l,K(e,u&&a.length>1?`${u}.${l}`:c,Ne),r))}return i}function xP(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 we(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[Qe(e,t,r,p,u,d)]})}return[Qe(e,t,r,n,n.split(".").pop()??n,n.split(".").pop()??n)]}function Nf(e,t,n){return We(e,t,r=>vP(e,t,r),()=>He(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?we(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[Qe(e,t,i,u,d,p,K(e,u.replace(/\\/g,"."),Pn))]}):[]}),n)}function vP(e,t,n){let r=J(n,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(q(a,c,K(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}=Tf(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}=Tf(c,"");l&&o(d,l,u)}}return i}function Tf(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 kf(e,t,n){return We(e,t,r=>IP(e,t,r),()=>RP(n).flatMap(r=>wP(e,t,r,n)),n)}function IP(e,t,n){let r=J(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=_f(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=EP(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=_f(u);d&&i.push({importedName:d.qualifiedName,localName:d.localName,sourcePath:c,kind:"named",used:r.has(d.localName),usedMembers:[]})}}return i}function _f(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 EP(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=_e(e,"import_prefix")?.text??"",n=_e(e,"dotted_name")?.text??"";return`${t}${n}`}return null}function RP(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=Qa(o);for(;i+1<t.length&&(u>0||c.trimEnd().endsWith("\\"));){i++;let p=t[i];c+=`
119
+ ${p}`,l+=1+p.length,u+=Qa(p),r+=p.length+1}let d=PP(c);d&&n.push({...d,start:a,end:l})}return n}function PP(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 wP(e,t,n,r){let i=Ut(r,n.start,n.end),o=n.clause.replace(/\n/g," ").trim();if(n.kind==="import")return we(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[u,d]=l.split(/\s+as\s+/),p=u.trim(),f=(d??p.split(".")[0]??p).trim(),g=er(e,t,p),y=tr(i,f);return[{importedName:p,localName:f,sourcePath:g,kind:"namespace",used:Pe(i,f)||y.length>0,usedMembers:y}]});let s=n.module?er(e,t,n.module):null,a=[];for(let c of we(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:Pe(i,p),usedMembers:[]})}return a}import{basename as CP}from"path";function Lf(e,t,n){return We(e,t,r=>TP(e,t,r),()=>FP(e,t,n),n)}function FP(e,t,n){return He(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"?To(e,t,s):null;if(a){let c=Df(s);return[wt(c,c,a,Pe(i,c))]}return[Fn(s,a)]})}function TP(e,t,n){let r=J(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"?To(e,t,d):null;if(p){let f=Df(d);i.push(q(f,f,p,r))}else i.push(Fn(d,p))}return i}function Df(e){return jo(CP(e).replace(/\.[^.]+$/,""),/_/)}function Af(e,t,n){return We(e,t,r=>NP(e,t,r),()=>He(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?_P(e,t,o,i):[]}),n)}function NP(e,t,n){let r=J(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 ti(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(q(a.importedName,a.localName,c,r))}}return i}function ti(e,t){switch(e.type){case"identifier":case"super":case"crate":{let n=e.text;return[{qualifiedName:Uo(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:Uo(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=Uo(t,n.text),o=[];for(let s of r.namedChildren)o.push(...ti(s,i));return o}case"use_list":{let n=[];for(let r of e.namedChildren)n.push(...ti(r,t));return n}case"use_as_clause":{let n=e.namedChild(0),r=e.namedChild(1);if(!n||!r)return[];let i=ti(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:Uo(t,`${r}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Uo(e,t){return e?t?`${e}::${t}`:e:t}function _P(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 we(d).flatMap(p=>{let f=p.trim();if(!f)return[];if(f==="self"){let v=u.split("::").filter(Boolean).pop();return v?[Qe(e,t,r,u,v,v)]:[]}let[g,y]=f.split(/\s+as\s+/),m=g?.trim();if(!m)return[];let S=(y??m.split("::").pop()??m).trim(),h=`${u}::${m}`.replace(/::::/g,"::");return[Qe(e,t,r,h,m.split("::").pop()??m,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[Qe(e,t,r,a,a.split("::").pop()??a,c,l)]}function Of(e,t,n){let r=M(e,t);if(r)return kP(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(...DP(e,t,s))}return i}function kP(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("use_declaration")){if(!LP(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of ti(o,""))s.importedName&&r.push(Rc(e,t,s.qualifiedName))}return r}function LP(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function DP(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 we(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[Rc(e,t,l)]})}return[Rc(e,t,r)]}function Rc(e,t,n){return{specifier:n,sourcePath:It(e,t,n)??It(e,t,n.split("::").slice(0,-1).join("::"))}}function Kt({language:e,extensions:t,imports:n,parseImports:r}){return{language:e,extensions:t,capabilities:{imports:n},parseImports:r}}function Mf(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 AP={language:"javascript",extensions:En,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:Ic,parseReExports:Ec},OP=Kt({language:"python",extensions:Ro,imports:"ast-with-regex-fallback",parseImports:kf}),MP=Kt({language:"jvm",extensions:Ne,imports:"ast-dispatch-with-regex-fallback",parseImports:Ff}),jP={language:"rust",extensions:Po,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:Af,parseExports:Of},BP=Kt({language:"ruby",extensions:wo,imports:"ast-with-regex-fallback",parseImports:Lf}),$P=Kt({language:"c/cpp",extensions:Co,imports:"ast-with-regex-fallback",parseImports:xf}),GP=Kt({language:"dotnet",extensions:Ht,imports:"ast-dispatch-with-regex-fallback",parseImports:Pf}),VP={language:"dart",extensions:Fo,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:Ef,parseExports:Rf},HP=Kt({language:"php",extensions:Pn,imports:"ast-with-regex-fallback",parseImports:Nf}),WP=Kt({language:"clojure",extensions:Zn,imports:"regex-only",parseImports:If}),jf=[AP,OP,MP,jP,BP,$P,GP,VP,HP,WP];function ni(e){return Mf(jf,e)}function i$(e){return jf.find(n=>n.language===e)?.capabilities??null}var Pc={clearGroups:["whole-project","source-file"]},qP=C("source-imports",Pc),UP=C("source-exports",Pc),zP=C("source-reexports",Pc),Bf=ce({kind:"source-imports",invalidation:te("source-imports"),serialize:KP,deserialize:JP}),$f=ce({kind:"source-reexports",invalidation:te("source-reexports"),serialize:XP,deserialize:YP});function ct(e,t){let n=Z(t);return zP.get(e,n,()=>{let r=ni(n);if(!r?.parseReExports)return[];let i=F(e,n);if(!i)return[];let o=me(e,n,i),s=Ja(e),a=$f.read(e,n,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=r.parseReExports(e,n,i);return $f.write(e,n,o,{resolutionFingerprint:s,reExports:c}),c})}function de(e,t){let n=Z(t);return qP.get(e,n,()=>{let r=ni(n);if(!r)return[];let i=F(e,n);return i?Gf(e,n,i,r):[]})}function zo(e,t){let n=Z(t),r=ni(n);if(!r)return[];let i;try{i=Br(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(o){if(Vt(o))return[];throw o}return Gf(e,n,i,r)}function Gf(e,t,n,r){let i=me(e,t,n),o=Ja(e),s=Bf.read(e,t,i);if(s?.resolutionFingerprint===o)return s.imports;let a=r.parseImports(e,t,n);return Bf.write(e,t,i,{parserVersion:2,resolutionFingerprint:o,imports:a}),a}function m$(e,t,n){let r=de(e,t).filter(i=>i.kind==="named"&&i.isTypeOnly!==!0&&i.localName===n&&i.sourcePath!==null);return r.length===1?r[0]:null}function g$(e,t){let n=Z(t);return UP.get(e,n,()=>{let r=ni(n);if(!r?.parseExports)return[];let i=F(e,n);return i?r.parseExports(e,n,i):[]})}function KP(e){return JSON.stringify(e)}function JP(e){try{let t=JSON.parse(e);return!Wt(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 XP(e){return JSON.stringify(e)}function YP(e){try{let t=JSON.parse(e);return!Wt(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}var Ko=ap({kind:"file-dependency-graph",invalidation:te("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:rw}),QP=C("file-dep-graph",{clearGroups:["whole-project"]});function R$(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=ii(t,r,i);return QP.get(e,o,()=>{let s=new Set(ye(e,{includeIgnored:!1})),a=St(e),c=0,l=0,u=null,d=!1,p=0,f=0,g=null;return z("file-dep-graph.product",()=>{if(a){let h=Ko.read(e,o,a);if(h){d=!0,g=h.construction;let v=Hf(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:U("no-source-dependency-fallback")}:z("file-dep-graph.source-imports",()=>{let h=tw(e,s,t,i);return c=h.files.length,l=h.edges.length,u=h.fingerprint,h},()=>({scope:t??null,sourceEdges:i,files:c,edges:l})),m=new Map,S=(h,v)=>ri(e,m,s,h,v);z("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=m.size,a&&(g="full",Ko.write(e,o,a,{version:2,construction:"full",sourceDependencyFingerprint:y.fingerprint,sourceFileCount:y.files.length,sourceEdgeCount:y.edges.length,scipEdgeCount:p,edgeCount:Wf(m),graph:Vf(m)})),m},()=>({scope:t??null,available:a!==null,hit:d,construction:g,files:c,sourceEdges:l,sourceEdgeMode:i,scipEdges:p,graphFiles:f,sourceDependencyFingerprint:u}))})}function P$(e){return ZP(e,"none")}function w$(e,t="imports-only"){let n=ii(void 0,"all-references",t),r=St(e);if(!r)return null;let i=Ko.read(e,n,r);return i?{cacheKey:n,sourceEdges:t,graph:Hf(i)}:null}function ZP(e,t){let n=ii(void 0,"all-references",t),r=ur(e,void 0,{sourceEdges:t});return{cacheKey:n,sourceEdges:t,graph:r}}function C$(e,t,n,r){let i=t.sourceEdges??"imports-only",o=St(e);if(!o)return!1;let s=r??ew(e,t,n);if(!s)return!1;let a=new Set(ye(e,{includeIgnored:!1})),c=ii(void 0,"all-references",i);return Ko.write(e,c,o,{version:2,construction:"carried",sourceDependencyFingerprint:null,sourceFileCount:a.size,sourceEdgeCount:null,scipEdgeCount:null,edgeCount:Wf(s),graph:Vf(s)}),!0}function ew(e,t,n,r=[]){let i=t.sourceEdges??"imports-only",o=ii(void 0,"all-references",i);if(t.cacheKey!==o)return null;let s=z("file-dep-graph.carry.indexed-files",()=>new Set(ye(e,{includeIgnored:!1}))),a=new Set(n),c=new Map;z("file-dep-graph.carry.reuse",()=>{if(r.length===0)for(let[u,d]of t.graph)a.has(u)||c.set(u,d);else for(let[u,d]of t.graph)if(!(a.has(u)||!s.has(u)))for(let p of d)ri(e,c,s,u,p)});let l=z("file-dep-graph.carry.scip-edges",()=>aw(e,a,"all-references"));for(let u of l)ri(e,c,s,u.from_file,u.to_file);return z("file-dep-graph.carry.source-edges",()=>{for(let u of a)if(s.has(u)){if(i!=="none")for(let d of zo(e,u))d.sourcePath&&ri(e,c,s,u,d.sourcePath);if(i==="imports-and-reexports")for(let d of ct(e,u))d.sourcePath&&ri(e,c,s,u,d.sourcePath)}}),c}async function F$(e,t={}){let n=ye(e,{includeIgnored:!1}),r=Math.max(1,Math.floor(t.batchSize??64)),i=t.collectGarbage??vn,o=0;for(let s=0;s<n.length;s+=r){for(let a of n.slice(s,s+r))zo(e,a),ct(e,a),o+=1;t.onBatch?.({files:o,total:n.length}),i(),await t.yieldToEventLoop?.()}return{files:o}}function tw(e,t,n,r){let i=[],o=[];for(let s of t)if(!(n&&!s.includes(n))){i.push(s);for(let a of zo(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:nw(i,o)}}function nw(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return U(JSON.stringify({files:e,edges:n}))}function ii(e,t,n){return`edge-mode-v4:${t}:${n}:${e??"<all>"}`}function Vf(e){return[...e].map(([t,n])=>[t,[...n].sort()]).sort(([t],[n])=>t.localeCompare(n))}function Hf(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function rw(e){let t=JSON.parse(e);return iw(t)?t:null}function iw(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(ow)}function Wf(e){let t=0;for(let n of e.values())t+=n.size;return t}function ow(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 aw(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 ri(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 cw={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function Ze(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=lw(i);return{scheme:n,manager:r,packageName:o,version:s,descriptors:c,raw:e}}function xe(e){let t=Ze(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 lw(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||qf(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&&!qf(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=cw[i];o&&t.push({name:r,suffix:o}),n+=1}}return t}function qf(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function Jt(e){let t=Ze(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=uw(i);o&&r.push(o)}return r.join(":")}function uw(e){let t=e.suffix==="namespace"?dw(e.name):e.name;return t?e.suffix==="method"?`${t}()`:t:""}function dw(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 ve(e){let t=Ze(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 Nn(e){let t=Ze(e);if("kind"in t&&t.kind==="local")return null;let n=t;return n.descriptors[n.descriptors.length-1]?.suffix??null}function wc(e){return e.endsWith("().")||Nn(e)==="method"}function dr(e){let t=Nn(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 Uf(e){return Nn(e)==="namespace"}var pw=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function N$(e){return pw.test(e)}var fw=new Set(["test","tests","_tests"]);function _$(e){let t=Ze(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&&fw.has(r.name))return!0}return!1}function k$(e,t){let n=Ze(e),r=Ze(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 L$(e,t){let n=Ze(e),r=Ze(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 Jo(e){return{forFile(t,n){return zf(e,t,n)},forFiles(t,n){let r=new Map;for(let i of t)r.set(i,zf(e,i,n));return r}}}function zf(e,t,n){let r={file:t},i=n.facts||n.identifiers;if(n.text&&(r.text=F(e,t)),n.lines&&(r.lines=Vr(e,t)),n.ast&&(r.ast=M(e,t)),n.imports&&(r.imports=de(e,t)),n.reexports&&(r.reexports=ct(e,t)),i){let o=uc(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 Xt(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
+ ${Jf(t.orderBy)}
167
+ ${Xf(t.limit)}`,...t.params??[])}function _n(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
+ ${Jf(t.orderBy)}
187
+ ${Xf(t.limit)}`,...t.params??[])}function Jf(e){return e?`ORDER BY ${e}`:""}function Xf(e){return typeof e=="number"?`LIMIT ${e}`:""}function Cc(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 Fc(e){if(!e)return null;let t=Kf(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(Kf(r)??r).replace(/\n/g," ")}function Kf(e){return/^```(?:\w+)?\s*\n?([\s\S]*?)\n?```/.exec(e.trimStart())?.[1]?.trim()||null}function mw(e,t={}){if(xe(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&&!mw(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 iG(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 gw=C("file-definitions",{clearGroups:["definition-catalog"]}),yw=it("scoped-matched-definitions",{clearGroups:["definition-catalog"]}),hw=C("file-function-like-definitions",{clearGroups:["definition-catalog"]}),Yf=new WeakMap;function B(e,t,n={},r){return Gr(t),n.includeClassMemberFallbacks?Tc(e,t,void 0,{includeClassMemberFallbacks:!0},r):gw.get(e,t,()=>{let i=lt(r,"evidence-read",()=>tm(e,t));if(i)return i;let o=Tc(e,t,void 0,n,r);return lt(r,"evidence-write",()=>{let s=St(e),a=Jo(e).forFile(t,{text:!0}).text;s&&a&&em.write(e,t,me(e,t,a),{projectFingerprint:s,definitions:o.map(c=>({...c}))})}),o})}function Sw(e,t){return hw.get(e,t,()=>{let n=tm(e,t);return n?n.filter(r=>r.isFunctionLike):Tc(e,t,r=>r.isFunctionLike)})}var em=ce({kind:"file-definitions",invalidation:te("file-definitions"),serialize:bw,deserialize:xw});function tm(e,t){let n=St(e);if(!n)return null;let r=Jo(e).forFile(t,{text:!0}).text;if(!r)return null;let i=em.read(e,t,me(e,t,r));return i?vw(i,n,t):null}function bw(e){return JSON.stringify(e)}function xw(e){try{let t=JSON.parse(e);return!Wt(t)||typeof t.projectFingerprint!="string"||!Array.isArray(t.definitions)?null:{projectFingerprint:t.projectFingerprint,definitions:t.definitions}}catch{return null}}function vw(e,t,n){if(e.projectFingerprint!==t)return null;let r=[];for(let i of e.definitions){let o=Iw(i,n);if(!o)return null;r.push(o)}return r}function Iw(e,t){return!Wt(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 Tc(e,t,n,r={},i){let o=lt(i,"primary-rows",()=>Ew(e,t)),s=lt(i,"fallback-rows",()=>Rw(e,t)),a=lt(i,"merge-rows",()=>Ct(o,s,{sort:!0,includeClassMemberFallbacks:r.includeClassMemberFallbacks}).map(Nc));return n&&(a=a.filter(n)),lt(i,"range-correction",()=>_c(e,t,a,i,r.rangeCorrectionEvidence))}function lt(e,t,n){return e?e(t,n):n()}function Ew(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 Rw(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 Nc(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:ve(e.symbol),parentTypeName:xe(e.symbol),isFunctionLike:dr(e.symbol),isTypeLike:Nn(e.symbol)==="type",kind:e.kind??null,documentation:e.documentation??null,enclosingSymbol:e.enclosing_symbol??null}}function oG(e,t={}){return Pw(e,t.scope)}function Pw(e,t){return ye(e,{scope:t,includeIgnored:!1}).flatMap(n=>B(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function sG(e,t){return ye(e,{scope:t,includeIgnored:!1}).flatMap(n=>Sw(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function aG(e,t){let n=yw.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=Qf(ww(e,t.scope,t.sqlPrefilter)),a=Qf(Cw(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(..._c(e,u,d.map(Nc)))}return r.set(i,l),[...l]}function ww(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${nm("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 Cw(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${nm("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 Fw(e){return`(${e}.symbol LIKE '%().' OR ${e}.symbol LIKE '%()')`}function nm(e,t){return t==="callable"?Fw(e):Tw(e)}function Tw(e){return`(${e}.symbol LIKE '%.' OR ${e}.symbol LIKE '%()')`}function Qf(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 cG(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:Jt(i.symbol),signature:Cc(Fc(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function Nw(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=Yf.get(e);return n||(n=Nw(e),Yf.set(e,n)),n.get(t)??null}function Xo(e,t){let n=B(e,t.relative_path).find(r=>r.symbolId===t.id)??(xe(t.symbol)===null||!dr(t.symbol)?void 0:_c(e,t.relative_path,[Nc(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 _c(e,t,n,r,i){let o=lt(r,"range-correction.source-text",()=>i?i.source:Jo(e).forFile(t,{text:!0}).text),s=lt(r,"range-correction.callable-sites",()=>i?i.callables:Qr(e,t));return s?lt(r,"range-correction.ast-correction",()=>Ow(n,s,o)):o?lt(r,"range-correction.regex-fallback",()=>_w(n,o)):n}function _w(e,t){let n=t.split(/\r?\n/),r=kw(e,n),i=Lw(e,r),o=Dw(i,n);return Aw(e,o)}function kw(e,t){let n=e.some(i=>Yo(i.symbol))?Hw(t):null,r=new Map;for(let i of e)r.set(i.symbolId,Vw(t,n,i));return r}function Lw(e,t){return e.filter(n=>Yo(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 Dw(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:Ww(t,i.definition,i.startLine,s)})}return n}function Aw(e,t){return e.map(n=>{let r=t.get(n.symbolId);return r?{...n,startLine:r.startLine,endLine:r.endLine}:n})}function Ow(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(!Gw(i)||!i.leaf)return Zf(i,n);let o=r.get(i.leaf);if(!o||o.length===0)return Zf(i,n);let s=n?Mw(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 Mw(e,t,n){let r=jw(e.symbol);if(!r)return null;let i=n.split(/\r?\n/),o=new RegExp(`\\b${le(r)}\\b`);for(let s of t){let a=Bw(i,s.startLine);if(a&&o.test(a))return s}return null}function jw(e){return e.match(/\/impl#\[([^\]]+)\]/)?.[1]??null}function Bw(e,t){for(let n=t;n>=0;n-=1){let r=e[n]?.trim()??"";if(r){if(/^impl\b/.test(r))return $w(e,n,t);if(/^(?:struct|enum|trait|mod)\b/.test(r))return null}}return null}function $w(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 Gw(e){return Yo(e.symbol)?!0:Nn(e.symbol)==="term"&&xe(e.symbol)===null}function Zf(e,t){if(!t||!e.leaf||Nn(e.symbol)!=="term"||xe(e.symbol)!==null)return e;let n=le(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 Vw(e,t,n){if(!Yo(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 Hw(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 Ww(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=qw(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 qw(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 Yo(e){return e.includes("().")}function lG(e){let t=Ze(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 Uw=C("symbol-resolution",{clearGroups:[]});function SG(e,t){return zw(e,t).match}function zw(e,t){return Uw.get(e,t,()=>{let n=om(e,t.trim()).filter(s=>!e.isIgnored(s.relative_path));if(n.length>0)return fr(e,n);let r=tC(e,t);if(r&&!e.isIgnored(r.relative_path))return fr(e,[r]);let i=Kw(e,t);if(i.length>0)return fr(e,i);let o=Jw(e,t);return o.length>0?fr(e,o):Zw(e,t)})}function Kw(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=Xt(e,{where:s,params:a,orderBy:"d.relative_path, der.start_line",limit:200}),l=c.length>0?[]:_n(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=>Jt(d.symbol).replace(/\(\)$/u,"")===n);return[...new Map(u.map(d=>[`${d.symbol}\0${d.relative_path}`,d])).values()]}function Jw(e,t){let n=Qo(t),r=kc(n);if(!r)return[];let i=`%${r.path}%`,o=r.leaf;return Xw(e,i,o,n)}function Xw(e,t,n,r){let i=Ct([],[...Yw(e,t,n),...Qw(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 Yw(e,t,n){return Xt(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function Qw(e,t,n){return _n(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function Zw(e,t){let n=Qo(t),r=aC(t),i=oC(e,r),o=cC(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=>Xo(e,i)),r=n[0]??null;return{match:r,candidates:r?eC(n,r):[],total:n.length}}function eC(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:Jt(i.symbol),relativePath:i.relativePath,startLine:i.startLine}),r.length>=5))break}return r}function tC(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/);if(!n)return;let[,r,i,o]=n,s=op(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 nC(e,s,a,c)??rC(e,s,a,c)}function nC(e,t,n,r){return Xt(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 rC(e,t,n,r){return _n(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 bG(e,t){let n=om(e,t).find(r=>!e.isIgnored(r.relative_path));return n?Xo(e,n):null}function om(e,t){let n=Xt(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, der.start_line"}),r=n.length>0?[]:_n(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, start_line"});return Ct(n,r)}function oi(e,t){if("symbol"in t&&"relativePath"in t)return t;let n=iC(e,t.symbolId)[0];return n?Xo(e,n):null}function iC(e,t){let n=Xt(e,{where:"gs.id = ?",params:[t],orderBy:"der.start_line, der.end_line"}),r=_n(e,{where:"gs.id = ?",params:[t],orderBy:"start_line, end_line"});return Ct(n,r)}function oC(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=Xt(e,{where:i,params:r,limit:200}),s=_n(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=Jt(e.symbol),p=ve(e.symbol),f=e.display_name??"",g=e.symbol.toLowerCase(),y=d.toLowerCase(),m=p.toLowerCase(),S=f.toLowerCase(),h=e.relative_path.toLowerCase(),v=/[/:.]/.test(n),E=kc(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),(g===a||g===c)&&(b+=1e3),(y===a||y===c)&&(b+=950),(h===a||h===c)&&(b+=925),(h.endsWith(`/${c}`)||h.endsWith(`/${a}`))&&(b+=875),S===l&&(b+=850),m===l&&(b+=825),(`${m}()`===a||`${m}()`===c)&&(b+=820),(y.endsWith(`:${c}`)||y.endsWith(`:${l}`)||y.endsWith(`:${l}()`))&&(b+=800),g.includes(c)&&(b+=120),y.includes(c)&&(b+=140),h.includes(c)&&(b+=140),S.includes(c)&&(b+=110),r.every(I=>{let P=I.toLowerCase();return g.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&&(m===x||`${m}()`===x||`${m}()`==`${x}()`)&&(b+=700),wc(e.symbol)&&(b+=180)),dr(e.symbol)&&m===l&&(b+=60),!v&&Uf(e.symbol)&&(b-=160),b-=Math.min(50,Math.max(0,e.end_line-e.start_line)),b}function kc(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 Qo(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function aC(e){let t=Qo(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 cC(e,t,n){let r=t.trim(),i=e.filter(a=>{let c=Jt(a.symbol),l=ve(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=>ve(a.symbol)===o);if(s.length>0){s.sort((c,l)=>rm(c,l,n));let a=s.filter(c=>dr(c.symbol));return a.length>0?a:s}return i.sort((a,c)=>rm(a,c,n)),i}function rm(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=kc(t);if(!n)return 0;let r=e.relative_path.toLowerCase(),i=ve(e.symbol).toLowerCase(),o=n.path.toLowerCase(),s=n.leaf.toLowerCase();return r.includes(o)?i!==s?1:wc(e.symbol)?xe(e.symbol)===null?5:4:xe(e.symbol)===null?3:2:0}function xG(e,t,n=5){let r=im(t);if(!r)return[];let i=Xt(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=Jt(s.symbol),c=ve(s.symbol),l=s.display_name??c,u=[a,c,l].filter(f=>f.trim().length>0),d=Math.min(...u.map(f=>lC(im(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 im(e){return Qo(e).toLowerCase().replace(/[^a-z0-9_]+/g,"")}function lC(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 TG(e,t){let n=sm(e);return n?t.filter(r=>sm(r.file)===n):t}function NG(e,t,n,r,i){let o=de(e,t);if(r){let u=i?.match(/^[A-Za-z_$][\w$]*/u)?.[0];if(!u)return null;let d=new Set(o.filter(y=>y.localName===u||y.importedName===u).map(y=>y.sourcePath).filter(y=>!!y));for(let y of n)for(let m of d)if(ln(m,y.file))return y;if(u==="this"||u==="self"||u==="cls"){let y=n.filter(m=>m.file===t&&xe(m.symbol)!==null);if(y.length===1)return y[0]}let p=uC(F(e,t)??"",u);if(p.size===0)return null;let f=new Set(o.filter(y=>p.has(y.localName??y.importedName)).map(y=>y.sourcePath).filter(y=>!!y)),g=n.filter(y=>p.has(xe(y.symbol)??"")&&(y.file===t||[...f].some(m=>ln(m,y.file))));return g.length===1?g[0]:null}let s=n.filter(u=>xe(u.symbol)===null),a=s.find(u=>u.file===t);if(a)return a;let c=ve(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&&ln(p.sourcePath,d.file)));return u.length===1?u[0]:null}return s.length===1?s[0]:null}function uC(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 sm(e){let t=ue(e);return t?t==="typescript"||t==="tsx"||t==="javascript"?"javascript-family":t:null}var dC=it("global-leaf-index",{clearGroups:["whole-project"]});function Lc(e){return dC.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=ve(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 Zo(e,t,n,r={}){if(!n)return[];let i=F(e,t);return i?i.indexOf(n)===-1?[]:(Dc(e,t).get(n)??[]).filter(s=>!pC(s,r)):[]}function pC(e,t){return typeof t.excludeStartLine=="number"&&typeof t.excludeEndLine=="number"&&e>=t.excludeStartLine&&e<=t.excludeEndLine}var fC=C("file-identifiers",{clearGroups:["whole-project","source-file"]});function am(e,t){let n=be(e,t);return n?n.fileIdentifiers:fC.get(e,t,()=>new Set(Dc(e,t).keys()))}var mC=C("file-ident-lines",{clearGroups:["whole-project","source-file"]});function Dc(e,t){let n=be(e,t);return n?n.identifierLineMap:mC.get(e,t,()=>yC(e,t))}var gC=C("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function OG(e,t){let n=be(e,t);return n?n.identifiersByLine:gC.get(e,t,()=>{let r=Dc(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 yC(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=Ya(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 cm=/[A-Za-z_$][A-Za-z0-9_$]*/g,lm=/^[A-Za-z_$][A-Za-z0-9_$]*$/,hC=512;function Ac(e){let t=[],n=!1;for(let r of e)r&&(n=!0,lm.test(r)||t.push(r));return{candidateNames:e,hasUsableCandidate:n,nonIdentifierNames:t}}function um(e,t){let n=SC(t)?t:Ac(t);if(n.candidateNames.size===0||!n.hasUsableCandidate)return!0;if(n.candidateNames.size<=hC){for(let i of n.candidateNames)if(i){if(lm.test(i)){if(bC(i).test(e))return!0;continue}if(e.includes(i))return!0}return!1}cm.lastIndex=0;let r;for(;(r=cm.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 SC(e){return"candidateNames"in e}function bC(e){return new RegExp(`(?<![A-Za-z_$0-9])${le(e)}(?![A-Za-z_$0-9])`)}var xC=C("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function pm(e,t){let n=Gt(t);return xC.get(e,n,()=>vC(e,n))}function vC(e,t){let n=new Map;for(let r of de(e,t)){if(!r.sourcePath)continue;let i=r.localName??r.importedName;if(i&&dm(n,i,r.sourcePath),r.kind==="namespace")for(let o of r.usedMembers)dm(n,o,r.sourcePath)}return n}function dm(e,t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n)}function Oc(e,t,n){let r=Lc(e).get(n);if(!r||r.length===0)return[];if(r.length===1)return[si(r[0])];let i=r.filter(c=>c.file===t);if(i.length>0)return i.map(si);let o=pm(e,t),s=o.get(n);if(s)for(let c of s){let l=r.filter(u=>ln(c,u.file));if(l.length>0)return l.map(si)}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=>ln(c,u.file));if(l.length>0&&l.length===r.length)return l.map(si)}return[]}function e1(e,t,n){let r=Oc(e,t,n);if(r.length>0)return r;let i=Lc(e).get(n);return!i||i.length===0?[]:i.map(si)}function fm(e,t,n={}){let r=IC(e,t);if(!r)return[];let i=oi(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 es(e,a)}}let o=new Map;for(let s of Me(e)){let a=EC(e,r,s);a.length>0&&o.set(s,a)}return es(e,o)}function IC(e,t){let n=oi(e,t);if(!n)return null;let r=ve(n.symbol);return r?{symbolId:n.symbolId,relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,identifier:r}:null}function EC(e,t,n){let r=F(e,n);return!r||r.indexOf(t.identifier)===-1?[]:n!==t.relativePath&&!Oc(e,n,t.identifier).some(o=>o.symbolId===t.symbolId)?[]:Zo(e,n,t.identifier,n===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{})}function t1(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=Ac(o),a=new Map;for(let c of Me(e)){if(n.skipPath?.(c)||!um(F(e,c),s))continue;let l=am(e,c);if(l.size!==0){for(let u of l)if(r.has(u))for(let d of Oc(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 si(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function es(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 r1(e,t){return ns(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 i1(e,t){return ns(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 o1(e,t){return ns(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 ts(e,t){let n=ns(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 ns(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 RC(e,t){return PC(e,[t]).get(t.symbolId)??[]}function PC(e,t){let n=t.map(o=>({symbolId:o.symbolId,prelude:NC(e,o)})).filter(o=>o.prelude!==null),r=CC(e,n.map(o=>o.symbolId)),i=new Map;for(let{symbolId:o,prelude:s}of n){let a=wC(e,r.get(o)??new Map,s.match,s.identifier);i.set(o,es(e,a))}return i}function p1(e,t,n={}){return Mc(e,t,n).map(r=>({file:r.file,line:r.line,enclosingSymbol:r.enclosingSymbol}))}function Mc(e,t,n={}){let r=fm(e,t,{semantic:n.semantic,semanticEvidence:n.semanticEvidence}),i=r.length>0?mm(r,"source-attribution"):mm(RC(e,t),"scip-reference-chunk");return n.includeIgnored===!0?i:i.filter(o=>!e.isIgnored(o.file))}function mm(e,t){return e.map(n=>({...n,provenance:t}))}function wC(e,t,n,r){let i=new Map;for(let[o,s]of t)i.set(o,FC(e,o,s,n,r));return i}function CC(e,t){let n=new Map;for(let r of ts(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 FC(e,t,n,r,i){let o=t===r.relativePath?{excludeStartLine:r.startLine,excludeEndLine:r.endLine}:{},s=i?Zo(e,t,i,o):[];return n.flatMap(a=>TC(s,a))}function TC(e,t){let n=e.filter(r=>r>=t.start_line&&r<=t.end_line);return n.length>0?n:[t.start_line]}function NC(e,t){let n=oi(e,t);return n?{match:n,identifier:ve(n.symbol)||null}:null}import{execFileSync as gm,spawnSync as _C}from"child_process";import{platform as kC}from"os";import{resolve as LC}from"path";var ym=kC()==="win32";function h1(e,t=_C){try{return t(e,["--version"],{stdio:"ignore",timeout:1e4}).status===0}catch{return!1}}function hm(e){let t=ym?"where":"which";try{return gm(t,[e],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var DC=/\.(?:c|m)?js$/i,AC=/\.(?:exe|com)$/i;function S1(e,t){return DC.test(e)?{binary:process.execPath,args:[e,...t]}:{binary:e,args:[...t]}}function OC(e,t){return gm(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL"})}function Sm(e,t={}){let n=t.isWindows??ym,r=t.lookup??OC,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?LC(s):null}return o.find(s=>AC.test(s))??null}import{execFileSync as xm}from"child_process";import{createHash as MC}from"crypto";import{existsSync as rs,statSync as jC}from"fs";import{createRequire as BC}from"module";import{platform as $C}from"os";import{dirname as bm,join as ai}from"path";var GC=BC(import.meta.url),T1={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function jc(e){return[e.indexerBinary,...e.binaryAliases??[]]}function VC(e){let t=jc(e);return t.length===1?t[0]:t.join(" or ")}function Bc(e){for(let t of jc(e)){let n=Sm(t);if(n)return n}return WC(e)}function N1(e){return Bc(e)!==null||HC(e)}function HC(e){return vm(e)!==null}function WC(e){let t=vm(e);if(!t)return null;let r=JSON.parse(T(t,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return ai(bm(t),r);for(let i of jc(e)){let o=r[i];if(o)return ai(bm(t),o)}return null}function vm(e){if(!e.bundledNpmPackage)return null;try{return GC.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function qC(e,t){for(let n of e.projectLocalBinaries??[]){let r=ai(t,n);if(rs(r))return r}return null}function UC(e,t){for(let n of e.projectLocalBinaries??[]){let r=ai(t,n);if(rs(r))return Im(t,n,r)}return null}function _1(e,t){let n=zC(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 zC(e,t){try{return Im(e,t.relativePath,t.configuredPath)}catch{return null}}function Im(e,t,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=Jn(e,t,r),o=xo(e,t,r),s=jC(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:t,sha256:MC("sha256").update(o).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(s.mode&73)!==0}}function KC(e,t,n={}){return(n.trustProjectTools?UC(e,t)?.canonicalPath:null)??Bc(e)}function k1(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||$c(n,t))return t;let r=Em(n,t);return r?{...t,DOTNET_ROOT:r}:t}function L1(e,t,n={}){let r=VC(e),i=t?KC(e,t,n):Bc(e);if(!i)return{language:e.language,binaryLabel:r,installed:!1,runnable:!1,resolvedBinary:null,installUrl:e.installUrl,...t&&qC(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=JC(i);return{language:e.language,binaryLabel:r,installed:!0,runnable:o.runnable,resolvedBinary:i,installUrl:e.installUrl,note:o.note}}function JC(e){if($c(e,process.env))return{runnable:!0};let t=Em(e,process.env);if(t)return{runnable:!0,note:`using .NET 9 runtime from ${t}`};let n=Rm(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 Em(e,t){for(let n of Rm(t))if($c(e,{...t,DOTNET_ROOT:n}))return n;return null}function Rm(e){let t=[],n=e.DOTNET_ROOT;if(n&&rs(n)&&t.push(n),$C()==="darwin"&&hm("brew"))try{let r=xm("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=ai(r,"libexec");rs(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function $c(e,t){try{return xm(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 XC=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"||!XC.has(t.platform)||typeof t.startToken!="string"||t.startToken.trim()===""?null:{version:1,pid:t.pid,platform:t.platform,startToken:t.startToken}}function ke(e,t){return e.version===t.version&&e.pid===t.pid&&e.platform===t.platform&&e.startToken===t.startToken}import{execFileSync as YC}from"child_process";import{platform as QC}from"os";var ZC=1e3,Pm=16*1024,Gc;function Tt(e,t=Cm){if(!Number.isSafeInteger(e)||e<=0)return null;let n=e===process.pid&&t===Cm;if(n&&Gc)return{...Gc};try{let r=eF(e,t);if(!r)return null;let i={version:1,pid:e,platform:t.platform,startToken:r};return n&&(Gc=i),{...i}}catch{return null}}function eF(e,t){if(t.platform==="linux"||t.platform==="android")return tF(t.readFile(`/proc/${e}/stat`));if(t.platform==="win32"){let n=`([DateTimeOffset](Get-Process -Id ${e} -ErrorAction Stop).StartTime).ToUnixTimeMilliseconds()`;return wm(t.run("powershell.exe",["-NoProfile","-NonInteractive","-Command",n]))}return t.platform==="darwin"||t.platform==="freebsd"||t.platform==="openbsd"||t.platform==="netbsd"?wm(t.run("ps",["-p",String(e),"-o","lstart="])):null}function tF(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 wm(e){let t=e.trim();return t===""?null:t}var Cm={platform:QC(),readFile(e){return ua(e,{maxBytes:Pm,inputKind:"process identity pseudo-file"})},run(e,t){return YC(e,[...t],{encoding:"utf8",timeout:ZC,maxBuffer:Pm,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}};function Nt(){return performance.now()}function V1(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 aF,existsSync as cF,fsyncSync as lF,linkSync as uF,mkdirSync as dF,openSync as pF,renameSync as fF,unlinkSync as mF,writeSync as gF}from"fs";import{dirname as Tm}from"path";import{chmodSync as nF,constants as rF,copyFileSync as iF}from"fs";import{dirname as oF}from"path";var Fm=Object.freeze({...Sn,copyFile:(e,t)=>iF(e,t,rF.COPYFILE_FICLONE),chmodFile:(e,t)=>nF(e,t)});function ci(e,t,n={}){let r=n.runtime??Fm,i=oF(t),o=ge(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 W(o,D(i,r))}var Nm=Object.freeze({platform:process.platform,randomToken:()=>sF(),pathExists:e=>cF(e),makeDirectory:e=>dF(e,{recursive:!0}),openFile:(e,t,n)=>pF(e,t,n),writeFile:(e,t,n,r)=>gF(e,t,n,r),syncFile:e=>lF(e),closeFile:e=>aF(e),renameFile:(e,t)=>fF(e,t),linkFile:(e,t)=>uF(e,t),removeFile:e=>mF(e)});function Vc(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??Nm,o=Tm(e),s=r==="durable"?ge(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"?W(s,D(o,i)):"not-requested";return _m(r,d)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function is(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??Nm;if(!i.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=Tm(e),s=r==="durable"?ge(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"?W(s,d,D(o,i)):"not-requested";return _m(r,p)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function _m(e,t){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":t==="synced"?"directory-durable":"file-flushed",directorySync:t}}function Yt(e,t,n={}){Vc(e,km(t,n),{durability:"visibility",runtime:n.runtime})}function Le(e,t,n={}){return Vc(e,km(t,n),{durability:"durable",runtime:n.runtime})}function km(e,t){let n=JSON.stringify(e,null,t.spacing);return t.trailingNewline?`${n}
317
+ `:n}import{join as os}from"path";var lV=6,uV=1e4,yF="watch.lock",hF="watch-state.json",SF="watch-activity.json",bF="watch-refresh-requests";function dV(e){return{lockPath:os(e,yF),statePath:os(e,hF),activityPath:os(e,SF),refreshRequestsPath:os(e,bF)}}function pV(e){try{return xF(JSON.parse(T(e,"watch service state")))}catch{return null}}function xF(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)||!vF(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&&!IF(t.lastError)||t.lastRefresh!==void 0&&!EF(t.lastRefresh)||t.reindexActivity!==void 0&&!RF(t.reindexActivity)||t.refreshRequests!==void 0&&!wF(t.refreshRequests)||t.typescriptSemantic!==void 0&&!CF(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!FF(t.typescriptIndex)?null:t}function oe(e){return Zi(e)}function vF(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return pe(t.changedFiles)&&pe(t.reindexAt);case"indexing":return pe(t.startedAt);case"cooldown":return pe(t.until)&&typeof t.dirty=="boolean";case"budget-paused":return pe(t.until)&&typeof t.dirty=="boolean"&&typeof t.reason=="string"&&w(t.rebuilt)&&w(t.estimatedWriteBytes);case"draining":return pe(t.startedAt)&&typeof t.reason=="string";default:return!1}}function IF(e){if(!e||typeof e!="object")return!1;let t=e;return oe(t.at)&&typeof t.message=="string"}function EF(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)&&pe(t.durationMs)}function RF(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)||!pe(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&&!PF(t.byLanguage)?!1:Object.values(t.byTrigger).every(n=>n===void 0||w(n))}function PF(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let[t,n]of Object.entries(e)){if(!eo.includes(t)||!n||typeof n!="object")return!1;let r=n;if(!w(r.runs)||!w(r.rebuilt)||!w(r.reused)||!w(r.producedOutputBytes)||!ku(r.durationMs)||r.rebuilt+r.reused!==r.runs)return!1}return!0}function wF(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 CF(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")&&pe(t.requests)&&pe(t.sessionsCreated)&&pe(t.sessionsReused)&&pe(t.sessionsRefreshed)&&pe(t.sessionsReplaced)&&pe(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||Lm(t.mailbox))}function FF(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||pe(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||oe(t.busyUntil))&&(t.mailbox===void 0||Lm(t.mailbox))}function Lm(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)&&pe(t.totalBytes)&&t.totalBytes>=0&&t.totalItems===t.pending+t.inflight+t.responses+t.deadLetters&&(t.oldestPendingAt===void 0||oe(t.oldestPendingAt))}function pe(e){return typeof e=="number"&&Number.isFinite(e)}import{getHeapStatistics as jF}from"v8";var TF=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function ss(e){let t=e.toLowerCase();return TF.some(n=>t.endsWith(n))}function cs(e){let t=as(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=as([...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=>Dm(r.get(p))),l=U(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:as(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 g=[],y,m;if(e.graph===null)g.push("dependency-graph-unavailable"),m="whole-project",y=o;else{let v=p===u&&d?d:NF(p,e.graph);if(u=p,d=v,v.find(x=>!r.has(x)))return gr("missing-input-fingerprint");if(y=as([...v,...i]),y.some(x=>Dm(r.get(x))))return gr("unreadable-input");m="dependency-closure"}let S=y.map(v=>_F(r.get(v)));return{version:1,key:U(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:f,projectIdentity:l,inputs:S})),mode:m,inputFiles:y,reasons:g}}}}function NF(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 _F(e){return e.semanticHash===void 0?{path:e.path,size:e.size,hash:e.hash}:{path:e.path,semanticHash:e.semanticHash}}function Dm(e){return e.size<0||e.hash==="unreadable"}function gr(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function as(e){return[...new Set(e)].sort()}import{createRequire as kF}from"module";var Am=kF(import.meta.url),li,ls;function LF(){if(li!==void 0)return li;try{li=Am("ts-morph")}catch{li=null}return li}function us(){if(ls)return ls;let e=LF();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=Am("ts-morph/package.json").version??"unknown"}catch{}return ls=`ts-morph:${t}:typescript:${e.ts.version}`,ls}function bV(e,t){return t.map(n=>({tsconfigPath:n,project:new e.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function xV(e,t,n){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var DF=it("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function ui(e,t,n){let r=DF.get(e,()=>AF(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 ye(e,{includeIgnored:!1}).filter(ss).sort()}function AF(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=Cr(t.metadata.fingerprint);return n?{builder:cs({projectFiles:Ln(e),snapshot:n,graph:ur(e),engineIdentity:us()}),identities:new Map}:null}catch{return null}}function jm(e,t){let n=Hc(e);for(let r of t.values())n.add(r);return n.finish()}function Hc(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,OF(i));return n}}}function Bm(e,t,n){let r=Mm(e,t),i=Mm(e,n),o=[...r].filter(d=>!i.has(d)).sort(),s=[...i].filter(d=>!r.has(d)).sort(),a=Om(e,t),c=Om(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 Om(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 _V(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,MF(s));return i}function Mm(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 OF(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($m)}function MF(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)||$m(n.location,r.location))}function $m(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}var pi="typescript-reference-fragment-v2",Gm=128,yr=ce({kind:"typescript-reference-fragments",invalidation:te("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:HF});function WV(e,t,n,r=e,i,o=new Set(n.keys())){let s=Ln(e),a=cs({projectFiles:s,snapshot:t,graph:i??ur(e),engineIdentity:us()}),c=[],l=0;for(let[d,p]of n){let f=a.identityFor(d,pi).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 qV(e,t,n,r){let i=t.filter(s=>ss(s.relativePath));if(i.length===0)return di("no TypeScript definitions");let o=di("shadow did not run");return z("typescript.reference-fragments.shadow",()=>{try{let s=r(i[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return o=di("TypeScript reference fragment provider is unavailable"),o;let a=Ln(e),c=new Set(a),l=new Map;for(let f of Wc(a)){let g=s.referenceFragmentsForFiles(f);if(f.some(y=>!g.has(y)))return o=di("TypeScript reference fragment provider returned an incomplete batch"),o;for(let y of f)l.set(y,g.get(y)??[])}let u=jm(i,l),d=Bm(i,BF(n,c),u);if(!d.passed)return o={state:"failing",files:a.length,keyedFiles:0,writtenFiles:0,...d},o;let p=[];for(let f of a){let g=ui(e,f,pi);g?.key&&p.push({relativePath:f,contentHash:g.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=di(s instanceof Error?s.message:String(s)),o}},()=>({...o}))}function BF(e,t){return new Map([...e].map(([n,r])=>[n,r.filter(i=>t.has(i.file))]))}function UV(e,t,n){if(t.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let r="fallback",i=0,o=0,s=0,a=0;return z("typescript.reference-fragments.materialize",()=>{try{let c=Ln(e);i=c.length;let l=Hc(t),u=[];for(let p of c){let f=ui(e,p,pi);if(!f?.key)return null;let g=yr.read(e,p,f.key);g===null?(s+=1,u.push({file:p,contentHash:f.key})):(o+=1,l.add(g))}return s===0?(r="hit",{references:l.finish(),files:i,cacheHits:o,cacheMisses:s,computedFiles:a}):GF(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 Wc(e){let t=[];for(let n=0;n<e.length;n+=Gm)t.push(e.slice(n,n+Gm));return t}var $F=.75;function Vm(e){return{heapUsedFraction:()=>{let t=jF();return t.heap_size_limit>0?t.used_heap_size/t.heap_size_limit:0},collect:vn,release:()=>Au(e,{groups:["semantic-provider"]})}}function Hm(e,t=$F){return e.heapUsedFraction()<t||e.collect()&&e.heapUsedFraction()<t?!1:(e.release(),!0)}function GF(e,t,n,r,i=Vm(e)){for(let o of Wc(t)){let s=Wm(e,o,n);if(!s)return!1;r(s),Hm(i)}return!0}function Wm(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 zV(e){let t=Ln(e),n=0;for(let r of t){let i=ui(e,r,pi);if(!i?.key)return null;yr.has(e,r,i.key)||(n+=1)}return{files:t.length,missing:n}}var VF=()=>new Promise(e=>setImmediate(e));async function KV(e,t,n={}){let r=n.yieldToEventLoop??VF,i=n.probe??Vm(e),o="fallback",s=0,a=0,c=0,l=0;return ad("typescript.reference-fragments.warm",async()=>{try{let u=Ln(e),d=n.files?new Set(n.files):null,p=d?u.filter(g=>d.has(g)):u;s=p.length;let f=[];for(let g of p){let y=ui(e,g,pi);if(!y?.key)return null;yr.has(e,g,y.key)?a+=1:(c+=1,f.push({file:g,contentHash:y.key}))}if(f.length===0)return o="hit",{files:s,cacheHits:a,cacheMisses:c,computedFiles:l};for(let g of Wc(f)){let y=Wm(e,g,t);if(!y)return null;l+=y.length,Hm(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 di(e){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:e}}function HF(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(WF)?null:t}catch{return null}}function WF(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 XV(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 YV(e,t){return[(e??"").replace(/(?:^|\s)--max[-_]old[-_]space[-_]size(?:=|\s+)\d+/gu," ").trim(),`--max-old-space-size=${t}`].filter(Boolean).join(" ")}function ds(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function qm(e,t){if(e?.aborted)throw ds(e,t)}import{randomUUID as qF}from"crypto";import{closeSync as UF,fsyncSync as zF,linkSync as KF,mkdirSync as JF,openSync as XF,statSync as YF,unlinkSync as QF,writeSync as ZF}from"fs";import{dirname as Jc}from"path";var Uc="scip-query-process-lock",zc=1,ps=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:kn,readProcessIdentity:Tt,randomToken:()=>qF(),makeDirectory:e=>JF(e,{recursive:!0}),openFile:(e,t,n)=>XF(e,t,n),writeFile:(e,t,n,r)=>ZF(e,t,n,r),syncFile:e=>zF(e),closeFile:e=>UF(e),linkFile:(e,t)=>KF(e,t),readFile:e=>T(e,"process lock record"),statFile:e=>{let t=YF(e);return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs}},removeFile:e=>QF(e)});function fs(e,t){let n=t.runtime??ps;n.makeDirectory(Jc(e));let r;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:Um(e,t,n),...r?{reclaimed:r}:{}}}catch(o){if(o.code!=="EEXIST")throw o;let s=hr(e,{parseLegacy:t.parseLegacy,runtime:n});if(i===0&&tT(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??ps,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=eT(o);if(s)return{state:"valid",raw:i,identity:r,record:s,owner:iT(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 eT(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.protocol!==Uc||t.version!==zc||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:Uc,version:zc,kind:t.kind,pid:t.pid,token:t.token,...n?{processIdentity:n}:{},startedAt:t.startedAt,...t.detail?{detail:t.detail}:{}}}function tT(e,t,n={}){let r=n.runtime??ps;if(!Kc(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!Km(t,o)||!Kc(o,r)?!1:Xc(e,r)}finally{i.release()}}function Um(e,t,n){let r=t.directoryDurability??"durable",i=t.pid??process.pid,o=n.randomToken(),s=t.processIdentity===void 0?n.readProcessIdentity(i):t.processIdentity,a={protocol:Uc,version:zc,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 qc(c,n),u;try{n.linkFile(c,e)}catch(p){throw qc(c,n),p}if(qc(c,n),r==="durable")try{Jm(Jc(e),n)}catch(p){throw nT(e,a,n),p}let d=!1;return{path:e,record:a,release:()=>d?!1:(d=!0,zm(e,a,n,r))}}function nT(e,t,n=ps){return zm(e,t,n,"durable")}function zm(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||!ke(t.processIdentity,i.record.processIdentity))?!1:Xc(e,n,r)}function rT(e,t){for(let n=0;n<2;n+=1)try{return Um(e,{kind:"reclaim-guard",runtime:t},t)}catch(r){if(r.code!=="EEXIST")return null;let i=hr(e,{runtime:t});if(n>0||!Kc(i,t))return null;let o=hr(e,{runtime:t});if(!Km(i,o)||!Xc(e,t))return null}return null}function Kc(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&&!ke(e.owner.processIdentity,n)}return!1}function Km(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 iT(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function Jm(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 Xc(e,t,n="durable"){try{return t.removeFile(e),n==="durable"&&Jm(Jc(e),t),!0}catch{return!1}}function qc(e,t){try{t.removeFile(e)}catch{}}import{join as oT}from"path";var sT=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 Xm(e,t={}){return _t(oT(e,"gc.lock"),t)}function _t(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??Nt,o=i()+n;do{let s=Ym(e,t.directoryDurability);if(s)return Qm(s);let a=o-i();if(a<=0)return null;aT(Math.min(r,a))}while(i()<=o);return null}async function pH(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??Nt,o=i()+n;do{qm(t.signal,"Lock acquisition was aborted.");let s=Ym(e,t.directoryDurability);if(s)return Qm(s);let a=o-i();if(a<=0)return null;await cT(Math.min(r,a),t.signal)}while(i()<=o);return null}function Ym(e,t){let n=fs(e,{kind:"generic",parseLegacy:sT,...t?{directoryDurability:t}:{}});return n.kind==="acquired"?n.lock:null}function Qm(e){return{release:()=>{e.release()}}}function aT(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function cT(e,t){return t?.aborted?Promise.reject(ds(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?ds(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}import{createHash as lT,randomUUID as uT}from"crypto";import{existsSync as Sr,mkdirSync as dT,readdirSync as pT,rmSync as eg,statSync as tg}from"fs";import{basename as fT,dirname as ms,join as De}from"path";var Dn=1,el=1,mi=".scipquery-generations",gs="manifest.json",ng="readers",mT="gc.lock",gT=128,fi=new Map,rg={pid:process.pid,now:()=>new Date,randomToken:()=>uT(),isProcessAlive:kn,readProcessIdentity:Tt};function X(e){return De(ms(e),mi)}function ys(e){return De(X(e),mT)}function ig(e,t=rg){let n=_t(ys(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=nl(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=De(X(e.dbPath),ng);dT(s,{recursive:!0}),r=De(s,`${t.pid}-${o}.json`);let a=t.readProcessIdentity(t.pid);Yt(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,eg(r,{force:!0}))}}}finally{n.release()}}function tl(e,t,n=rg,r={}){let i=De(X(e),ng);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 pT(i,{withFileTypes:!0})){if(!l.isFile()||!l.name.endsWith(".json"))continue;let u=De(i,l.name),d;try{d=yT(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(!hT(d,n)){r.removeStale!==!1&&(eg(u,{force:!0}),a+=1);continue}s+=1,o.add(d.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:c}}function yT(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 hT(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let n=t.readProcessIdentity(e.pid);return n===null||ke(e.processIdentity,n)}function Qt(e){try{let t=JSON.parse(T(De(X(e),"state.json"),"SQLite generation state"));return vT(t)?t:null}catch{return null}}function gi(e,t){return yi(X(e),t)}function yi(e,t){try{let n=JSON.parse(T(De(e,t,gs),"SQLite generation manifest"));return xT(n,t)?n:null}catch{return null}}function nl(e){let t=Qt(e.dbPath);if(t){let n=ST(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(De(ms(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return bT(e,t?.currentGeneration)}function RH(e){let t=Qt(e);if(t)return t.currentGeneration;try{let n=De(ms(e),"meta.json"),r=Sr(n)?T(n,"reindex metadata"):void 0;return og(e,r)}catch{return null}}function Zt(e){return Lu(jt(e))??e}function ST(e,t){try{let n=De(X(e.dbPath),t),r=gi(e.dbPath,t);if(!r)return null;let i=Yc(n,r.database),o=r.index?Yc(n,r.index):void 0,s=r.metadata?Yc(n,r.metadata):void 0;return!Qc(i,r.database)||r.index&&(!o||!Qc(o,r.index))||r.metadata&&(!s||!Qc(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 bT(e,t){let n=kt(e.dbPath),r=De(ms(e.dbPath),"meta.json"),i=Sr(r)?T(r,"reindex metadata"):void 0,o=Sr(e.indexPath)?e.indexPath:void 0;return{identity:t??og(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function og(e,t){let n=lT("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&n.update(Zt(t)),n.update(`\0${kt(e)}`),n.digest("hex")}function kt(e){let t=tg(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function Yc(e,t){if(fT(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return De(e,t.file)}function Qc(e,t){if(!Sr(e))return!1;let n=Zm(e);if(!n||n.size!==t.size)return!1;let r=`${e}\0${t.sha256}\0${n.identity}`;if(fi.has(r))return!0;let i=dn(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=Zm(e);if(!o||o.identity!==n.identity||i!==t.sha256)return!1;for(fi.set(r,!0);fi.size>gT;){let s=fi.keys().next().value;if(s===void 0)break;fi.delete(s)}return!0}function Zm(e){let t=tg(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function xT(e,t){return e.version===el&&e.identity===t&&Zc(e.database)&&(e.index===void 0||Zc(e.index))&&(e.metadata===void 0||Zc(e.metadata))}function Zc(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")&&IT(e.stableMirrors)&&ET(e.previousGeneration)&&RT(e.publication)}function IT(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 ET(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 RT(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,n=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(r=>r!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import PT from"better-sqlite3";var wT=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],rl=class{constructor(t,n){this.connection=t;this.releaseGenerationReader=n}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let n of wT)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}},CT=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],sg=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;constructor(t,n){this.config=t,this.pathFilter=n??null;let r=_T(t),i=new rl(r.db,r.release);try{i.initialize(NT),this.generation=r.generation,this.connection=r.db,this.connectionOwnership=i,this.db=FT(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=>CT.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 FT(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 TT(n)}})}function TT(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 NT(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)Ee(r.relative_path)}function _T(e){for(let t=0;t<4;t+=1){let n=ig(e),r=n.generation,i;try{i=new PT(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=nl(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 kT from"ignore";import{existsSync as ag,readdirSync as LT}from"fs";import{dirname as il,isAbsolute as cg,join as hs,relative as DT,resolve as AT}from"path";function DH(e){let t=kT();return OT(e,t)||t.add(BT),{isIgnored:r=>ol(t,e,r),filter:r=>r.filter(i=>!ol(t,e,i))}}function OT(e,t){let n=new Set,r=(s,a)=>{if(!(n.has(s)||!ag(s)))try{let c=j(s,{maxBytes:ne,inputKind:"gitignore file"});t.add(a?MT(c,a):c),n.add(s)}catch{}},i=il(e),o=0;for(;i!==il(i)&&o<5&&(r(hs(i,".gitignore"),""),!ag(hs(i,".git")));)i=il(i),o++;return lg(e,"",t,r),n.size>0}function lg(e,t,n,r){let i=t?hs(e,t):e;r(hs(i,".gitignore"),t);let o;try{o=LT(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;ol(n,e,`${a}/`)||lg(e,a,n,r)}}function MT(e,t){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return e.split(/\r?\n/).map(r=>jT(r,n)).join(`
337
+ `)}function jT(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 BT=`
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 ol(e,t,n){let r=$T(t,n);if(!r)return!1;try{return e.ignores(r)}catch{return!1}}function $T(e,t){if(!t||t===".")return null;if(!cg(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let n=cg(t)?t:AT(e,t),r=DT(e,n).replaceAll("\\","/");return!r||r==="."||r.startsWith("..")?null:r}import{execFileSync as GT}from"child_process";import{existsSync as VT,readdirSync as ug}from"fs";import{extname as dg,join as pg}from"path";var fg=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),HT=[{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 Ss(e){let t=[],n=WT(e),r=KT(e);for(let i of HT){if(qT(e,i.files)){t.push(i.language);continue}if(UT(n,i.globs)){t.push(i.language);continue}XT(r,i.extensions)&&t.push(i.language)}if(t.includes("typescript")&&sl(t,"javascript"),t.includes("cpp")&&t.includes("c")){let i=r.has(".c"),o=[".cc",".cpp",".cxx"].some(s=>r.has(s));i&&!o?sl(t,"cpp"):i||sl(t,"c")}return t}function WT(e){try{return ug(e)}catch{return[]}}function qT(e,t){return t?.length?t.some(n=>VT(pg(e,n))):!1}function UT(e,t){return t?.length?e.some(n=>t.some(r=>zT(n,r))):!1}function zT(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 KT(e){let t=JT(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=ug(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=pg(i,s.name);if(s.isDirectory()){fg.has(s.name)||r.push(a);continue}let c=dg(s.name).toLowerCase();c&&n.add(c)}}return n}function JT(e){try{let t=Ki(e,26214400,()=>GT("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 Ji(t)){if(r.split("/").some(o=>fg.has(o)))continue;let i=dg(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function XT(e,t){return t?.length?t.some(n=>e.has(n)):!1}function sl(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import YT from"better-sqlite3";var QT=25,ZT=new Set(["typescript","javascript"]);function WH(e,t,n){let r=null;try{r=new YT(e,{readonly:!0,fileMustExist:!0});let i=new Set(r.prepare("SELECT relative_path FROM documents").pluck().all().map(Gt)),o=eN(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,QT),affectedLanguages:l}}catch(i){return{state:"unavailable",reason:i instanceof Error?i.message:String(i)}}finally{r?.close()}}function eN(e,t){let n=new Map,r=t.filter(i=>ZT.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 gg,readdirSync as yg,rmSync as hg}from"fs";import{join as br}from"path";import{create as bg,fromBinary as xg,toBinary as eW}from"@bufbuild/protobuf";import{deserializeSCIP as al,DocumentSchema as vg,IndexSchema as Ig,serializeSCIP as Eg}from"@c4312/scip";import{existsSync as tN,mkdirSync as nN,renameSync as rN,writeFileSync as iN}from"fs";import{join as oN}from"path";function mg(e){nN(e.blobDir,{recursive:!0});let t=oN(e.blobDir,`${e.blobHash}.scipdoc`);if(tN(t)){let r=ee(t,{maxBytes:un,inputKind:e.inputKind});if(r.byteLength!==e.bytes.byteLength||U(r)!==e.blobHash)throw new Error(`existing ${e.inputKind} is corrupt: ${e.relativePath}`);return}let n=`${t}.${process.pid}.${Date.now()}.tmp`;iN(n,e.bytes),rN(n,t)}var cl=1,hi="typescript-scip-fragments";function iW(e){let t=new Set,n=[];for(let o of e){let s=bs(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=xg(vg,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);n.push(a)}let r=Eg(bg(Ig,{documents:n,externalSymbols:[]})),i=al(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function sN(e){let t=br(e,hi);return{rootDir:t,blobDir:br(t,"blobs"),generationDir:br(t,"generations")}}function Rg(e){let t=aN(e);return cN(t.baseIndex,t.completeDocuments,"assembled")}function aN(e){let t=al(e.baseIndexBytes);pN(t.metadata,fN(e)),dN(t.externalSymbols);let n=new Map;for(let a of e.fragments){let c=bs(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=bs(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=Sg(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=Sg(a,c.bytes);i.push(l),o.push(l)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function Sg(e,t){let n=xg(vg,t);if(n.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${n.relativePath}`);return n}function cN(e,t,n){let r=Eg(bg(Ig,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=al(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function oW(e,t){let n=sN(e);if(!gg(n.generationDir))return;let r=new Set(t.map(s=>uN(s))),i=yg(n.generationDir).filter(s=>s.endsWith(".json")),o=new Set;for(let s of i.filter(a=>r.has(a))){let a=lN(j(br(n.generationDir,s),{maxBytes:ne,inputKind:"TypeScript fragment manifest"}));for(let c of a.documents)o.add(`${c.blobHash}.scipdoc`)}for(let s of i)r.has(s)||hg(br(n.generationDir,s),{force:!0});if(gg(n.blobDir))for(let s of yg(n.blobDir))o.has(s)||hg(br(n.blobDir,s),{force:!0})}function lN(e){let t=JSON.parse(e);if(t.version!==cl||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(bs(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function uN(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${U(e)}.json`}function dN(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function pN(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 fN(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function bs(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 xs,readdirSync as ll,rmSync as Pg}from"fs";import{join as ut}from"path";var vs=1,Si="typescript-scip-overlays",wg="typescript-project-v3:";function mW(e){let t=Fg(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(wg)&&e.projectIdentity.startsWith(wg);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=pl(s.relativePath);if(i.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);i.add(a),r.set(a,mN(e.cacheDir,s))}if(i.size===0)throw new Error("TypeScript overlay generation requires affected documents");let o={version:vs,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 gN(e.cacheDir,o),o}function gW(e){let t=Fg(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let n=t.overlays.map(r=>{if(r.blobHash===null)return{relativePath:r.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=ee(ut(bi(e.cacheDir),"blobs",`${r.blobHash}.scipdoc`),{maxBytes:un,inputKind:"TypeScript overlay blob"});if(i.byteLength!==r.byteLength||U(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 Rg({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function yW(e,t){let n=bi(e),r=ut(n,"generations");if(!xs(r))return;let i=new Set(t.map(dl)),o=new Set;for(let a of ll(r).filter(c=>i.has(c))){let c=ul(j(ut(r,a),{maxBytes:ne,inputKind:"TypeScript overlay manifest"}));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of ll(r))i.has(a)||Pg(ut(r,a),{force:!0});let s=ut(n,"blobs");if(xs(s))for(let a of ll(s))o.has(a)||Pg(ut(s,a),{force:!0})}function Fg(e,t){let n=ut(bi(e),"generations",dl(t));if(!xs(n))return null;let r=ul(j(n,{maxBytes:ne,inputKind:"TypeScript overlay manifest"}));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function mN(e,t){let n=pl(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=U(r);return mg({blobDir:ut(bi(e),"blobs"),blobHash:i,bytes:r,relativePath:n,inputKind:"TypeScript overlay blob"}),{relativePath:n,blobHash:i,byteLength:r.byteLength}}function gN(e,t){let n=ut(bi(e),"generations",dl(t.generationIdentity));if(xs(n)){let r=ul(j(n,{maxBytes:ne,inputKind:"TypeScript overlay manifest"}));if(Cg(r)!==Cg(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}Yt(n,t,{spacing:2,trailingNewline:!0})}function ul(e){let t=JSON.parse(e);if(t.version!==vs||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(pl(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function bi(e){return ut(e,Si)}function dl(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${U(e)}.json`}function Cg(e){return U(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function pl(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 Ng,openSync as vN,renameSync as IN,rmSync as EN,writeSync as RN}from"fs";import{create as _g,fromBinary as PN,toBinary as wN}from"@bufbuild/protobuf";import{DocumentSchema as ml,IndexSchema as CN,SymbolRole as yl}from"@c4312/scip";var Ue=class extends Error{},yN=0,hN=1,Tg=2,SN=5;function fl(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 Ue("varint exceeds the safe integer range");if((o&128)===0)return{value:r,pos:t};if(i+=7,i>63)throw new Ue("varint is longer than 64 bits")}throw new Ue("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=fl(e,r,n);r=o.pos;let s=Math.floor(o.value/8),a=o.value%8;if(s===0)throw new Ue("field number 0 is invalid");let c=r,l=0;if(a===yN){let u=fl(e,r,n);l=u.value,r=u.pos}else if(a===Tg){let u=fl(e,r,n);if(c=u.pos,r=u.pos+u.value,r>n)throw new Ue("length-delimited field runs past the end of the buffer")}else if(a===hN)r+=8;else if(a===SN)r+=4;else throw new Ue(`unsupported wire type ${a}`);if(r>n)throw new Ue("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 xi(e){if(!Number.isSafeInteger(e)||e<0)throw new Ue(`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 Is(e){return xi(e*8+Tg)}var bN=1,xN=3;function vi(e){let t=new TextDecoder,n;for(let r of et(e))if(!(r.fieldNumber!==bN||r.wireType!==2))for(let i of et(e,r.valueStart,r.valueEnd)){if(i.fieldNumber!==xN||i.wireType!==2)continue;let o=t.decode(e.subarray(i.valueStart,i.valueEnd));o&&(n=o)}return n}var gl=2,FN=3,TN=1,NN=2,_N=3,kN=1,LN=2,DN=3;function PW(e){let t;try{t=ee(e,{inputKind:"SCIP sanitization input",maxBytes:ae})}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}try{return AN(t,e)}catch(n){if(n instanceof Ue)return{removedDefinitionOccurrences:0,touchedDocuments:0};throw n}}function AN(e,t){let n=new TextDecoder,r=new Set;for(let s of et(e))if(s.wireType===2)if(s.fieldNumber===gl)for(let a of et(e,s.valueStart,s.valueEnd))a.wireType===2&&(a.fieldNumber===TN?Ee(n.decode(e.subarray(a.valueStart,a.valueEnd))):a.fieldNumber===_N&&kg(e,a,n,r));else s.fieldNumber===FN&&kg(e,s,n,r);let i=0,o=[];for(let s of et(e)){if(s.wireType!==2||s.fieldNumber!==gl)continue;let a=ON(e,s,n,r);a>0&&(i+=a,o.push(s))}return i===0?{removedDefinitionOccurrences:0,touchedDocuments:0}:(MN(e,t,o,r),{removedDefinitionOccurrences:i,touchedDocuments:o.length})}function kg(e,t,n,r){for(let i of et(e,t.valueStart,t.valueEnd)){if(i.wireType!==2||i.fieldNumber!==kN)continue;let o=n.decode(e.subarray(i.valueStart,i.valueEnd));o&&r.add(o)}}function ON(e,t,n,r){let i=0;for(let o of et(e,t.valueStart,t.valueEnd)){if(o.wireType!==2||o.fieldNumber!==NN)continue;let s="",a=0;for(let c of et(e,o.valueStart,o.valueEnd))c.fieldNumber===LN&&c.wireType===2?s=n.decode(e.subarray(c.valueStart,c.valueEnd)):c.fieldNumber===DN&&c.wireType===0&&(a=c.varint);(a&yl.Definition)!==0&&!r.has(s)&&(i+=1)}return i}function MN(e,t,n,r){let i=`${t}.sanitize-tmp`,o=vN(i,"w",384);try{let s=0;for(let a of n){Ii(o,e.subarray(s,a.fieldStart));let c=PN(ml,e.subarray(a.valueStart,a.valueEnd));c.occurrences=c.occurrences.filter(u=>(u.symbolRoles&yl.Definition)===0||r.has(u.symbol));let l=wN(ml,c);Ii(o,Is(gl)),Ii(o,xi(l.byteLength)),Ii(o,l),s=a.fieldEnd}Ii(o,e.subarray(s))}catch(s){throw Ng(o),EN(i,{force:!0}),s}Ng(o),IN(i,t)}function Ii(e,t){let n=0;for(;n<t.byteLength;)n+=RN(e,t,n,t.byteLength-n)}function Lg(e){let t=new Set;for(let o of e.documents){Ee(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&yl.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(_g(ml,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:_g(CN,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{closeSync as Ri,openSync as hl,readSync as jN,renameSync as BN,rmSync as Og,statSync as $N,writeFileSync as Mg,writeSync as jg}from"fs";import{create as Sl,fromBinary as GN,toBinary as VN}from"@bufbuild/protobuf";import{deserializeSCIP as Bg,serializeSCIP as $g,DocumentSchema as HN,IndexSchema as WN,MetadataSchema as Dg,SymbolInformationSchema as qN}from"@c4312/scip";function Gg(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=UN(e),n=zN(e.flatMap(i=>i.documents??[])),r=Hg(e.flatMap(i=>i.externalSymbols??[]));return Sl(WN,{metadata:t,documents:n,externalSymbols:r})}function DW(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Bg(ee(i,{inputKind:"SCIP merge input",maxBytes:ae}))),r=Gg(n);return Mg(t,$g(r)),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function AW(e,t){if(e.length===0)throw new Error("Cannot concatenate zero SCIP files");let n=0;for(let o of e)if(n+=$N(o).size,n>ae)throw new Error(`Concatenated SCIP output exceeds the ${ae}-byte artifact limit. Reduce the indexed project scope or use compatible cached generations.`);let r=Buffer.allocUnsafe(1024*1024),i=hl(t,"w",384);try{for(let o of e){let s=hl(o,"r");try{let a=0;for(;(a=jN(s,r,0,r.byteLength,null))>0;){let c=0;for(;c<a;)c+=jg(i,r,c,a-c)}}finally{Ri(s)}}}catch(o){throw Ri(i),Og(t,{force:!0}),o}Ri(i)}function OW(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=z("reindex.publish.scip-output.deserialize",()=>e.map(o=>Bg(ee(o,{inputKind:"SCIP merge input",maxBytes:ae})))),r=z("reindex.publish.scip-output.merge",()=>Gg(n)),i=z("reindex.publish.scip-output.sanitize",()=>Lg(r));return z("reindex.publish.scip-output.serialize",()=>Mg(t,$g(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,touchedDocuments:i.touchedDocuments}}var Ag=1;function Vg(e,t,n){let r=ee(e,{inputKind:"SCIP normalization input",maxBytes:ae}),i=vi(r),o=[];for(let c of et(r))c.fieldNumber===Ag&&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=hl(s,"w",384);try{let c=0;for(let l of o){Ei(a,r.subarray(c,l.fieldStart));let u=GN(Dg,r.subarray(l.valueStart,l.valueEnd));u.projectRoot=n;let d=VN(Dg,u);Ei(a,Is(Ag)),Ei(a,xi(d.byteLength)),Ei(a,d),c=l.fieldEnd}Ei(a,r.subarray(c))}catch(c){throw Ri(a),Og(s,{force:!0}),c}Ri(a),BN(s,e)}function Ei(e,t){let n=0;for(;n<t.byteLength;)n+=jg(e,t,n,t.byteLength-n)}function UN(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 zN(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,Sl(HN,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:KN([...r.occurrences,...n.occurrences]),symbols:Hg([...r.symbols,...n.symbols]),text:XN(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function KN(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 Hg(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,Sl(qN,{symbol:r.symbol,documentation:YN([...r.documentation,...n.documentation]),relationships:JN([...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 JN(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 XN(e,t){return e?t?e.length>=t.length?e:t:e:t}function YN(e){return[...new Set(e)]}import{createHash as Pl}from"crypto";import{closeSync as QN,existsSync as O,mkdirSync as ZN,openSync as e_,readSync as t_,readdirSync as wl,renameSync as Il,rmSync as Pi,statSync as An}from"fs";import{basename as Cl,dirname as dt,join as _,relative as Wg}from"path";var El=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Ug(e){let t=X(e.outputDb),n=s_(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=a_(e,n),o=Tl({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=Le(_(t,"state.json"),a,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||vl(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),vl(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),vl(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let l=o.identity,u={...a,stableMirrors:Fl(e.outputDb,e.outputScip)};Le(_(t,"state.json"),u,{spacing:2,trailingNewline:!0});let d=zg(e.outputDb,{now:e.now}),p=W(o.directorySync,c.directorySync);return{currentGeneration:l,...n?{previousGeneration:n}:{},retention:d,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}function n_(e,t,n,r=()=>new Date){if(!O(e))return null;let i=Qt(e),o=_(X(e),"state.json");if(i?.artifactSet==="immutable-v1"&&gi(e,i.currentGeneration))return i;let s=X(e),a=!i&&O(o)?l_(n,e,t):void 0;if(a&&!yi(s,a))return null;let c=Tl({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:Fl(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??r().toISOString()};return Le(_(s,"state.json"),l,{spacing:2,trailingNewline:!0}),l}function KW(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=Qt(e),i=X(e),o=Tl({generationRoot:i,databasePath:e,indexPath:O(_(dt(e),"index.scip"))?_(dt(e),"index.scip"):void 0,metadataPath:t}),s=r&&r.currentGeneration!==o.identity?Xg(e,r.currentGeneration):void 0,a={version:Dn,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:Fl(e,_(dt(e),"index.scip")),...s?{previousGeneration:s}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return Le(_(X(e),"state.json"),a,{spacing:2,trailingNewline:!0}),zg(e,{now:n}),a}function zg(e,t={}){let n=r_(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=_t(ys(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=Qt(e),a=Kg(e),c=tl(e,a.map(m=>m.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((m,S)=>m+S.logicalBytes,0),p=0,f=0;for(let m of a){if(u<=n.maxGenerations&&d<=n.maxLogicalBytes)break;l.has(m.identity)||(t.onBeforeRemove?.(m.identity),Pi(m.path,{recursive:!0,force:!0}),u-=1,d-=m.logicalBytes,p+=1,f+=m.logicalBytes)}let g=u>n.maxGenerations||d>n.maxLogicalBytes,y={state:g?"protected":p>0?"collected":"within-bounds",generationCount:u,logicalBytes:d,protectedGenerations:l.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:p,removedLogicalBytes:f,limits:n,at:i,...g?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return qg(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{qg(e,a)}catch{}return a}finally{o.release()}}function JW(e){let t=X(e);if(!O(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...El},reason:"local immutable generation store does not exist"};let n=i_(e),r=n?.limits??{...El},i=_t(ys(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=Kg(e),s=Qt(e),a=tl(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 r_(e={}){let t={...El,...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 Kg(e){let t=X(e);return O(t)?wl(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^[a-f0-9]{64}$/.test(n.name)).map(n=>{let r=_(t,n.name),i=yi(t,n.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):Jg(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 Jg(e){let t=0;for(let n of wl(e,{withFileTypes:!0})){let r=_(e,n.name);n.isDirectory()?t+=Jg(r):n.isFile()&&(t+=An(r).size)}return t}function qg(e,t){Yt(_(X(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function i_(e){try{let t=JSON.parse(T(_(X(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 Rs(e,t=_(dt(e),"meta.json")){let n=_(X(e),"state.json");if(!O(n))return{state:"legacy",statePath:n};let r=Qt(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=gi(e,r.currentGeneration),o=i!==null,s=i?o_(e,t,i,r):!1,a=r.previousGeneration?O(_(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 o_(e,t,n,r){if(r.stableMirrors&&(r.stableMirrors.databaseFileIdentity!==kt(e)||r.stableMirrors.indexFileIdentity!==void 0&&r.stableMirrors.indexFileIdentity!==kt(_(dt(e),"index.scip")))||!Rl(e,n.database))return!1;let i=_(dt(e),"index.scip");if(n.index&&!Rl(i,n.index))return!1;if(!n.metadata)return!O(t);if(!O(t))return!1;let o=_(X(e),n.identity,n.metadata.file);return O(o)&&Zt(T(t,"reindex metadata"))===Zt(T(o,"immutable reindex metadata"))}function Rl(e,t){return O(e)&&An(e).isFile()&&An(e).size===t.size}function s_(e){let t=n_(e.outputDb,e.outputScip,e.metaPath);return t?Xg(e.outputDb,t.currentGeneration):void 0}function a_(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let n=Rs(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=gi(e.outputDb,t.generationIdentity);if(!r?.index||!Rl(e.outputScip,r.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return r.index}function Fl(e,t){return{databaseFileIdentity:kt(e),...O(t)?{indexFileIdentity:kt(t)}:{}}}function Xg(e,t){let n=_(X(e),t),r=_(n,Cl(e)),i=_(n,"meta.json");return{generationIdentity:t,databasePath:Wg(dt(e),r),...O(i)?{metadataPath:Wg(dt(e),i)}:{}}}function c_(e){if(O(e))for(let t of wl(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&Pi(_(e,t.name),{recursive:!0,force:!0})}function l_(e,t,n=_(dt(t),"index.scip")){let r=Pl("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(Es(t)),O(n)&&r.update(`\0${Es(n)}`),O(e)&&r.update(`\0${Zt(T(e,"reindex metadata"))}`),r.digest("hex")}function Tl(e){let t=bl(e.databasePath),n=e.indexPath?e.verifiedIndexArtifact?d_(e.indexPath,e.verifiedIndexArtifact):bl(e.indexPath):void 0,r=e.metadataPath?bl(e.metadataPath):void 0,i=e.forcedIdentity??u_(t,n,e.metadataPath),o=_(e.generationRoot,i),s=_(o,gs);if(O(s)){let l=yi(e.generationRoot,i);if(l&&Yg(o,l.database,t)&&f_(o,l.index,n)&&m_(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=[ge(e.generationRoot)];c_(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;Pi(c,{recursive:!0,force:!0}),ZN(c,{recursive:!0});try{a.push(xl(e.databasePath,_(c,t.file))),n&&e.indexPath&&a.push(xl(e.indexPath,_(c,n.file))),r&&e.metadataPath&&a.push(xl(e.metadataPath,_(c,r.file)));let l=Le(_(c,gs),{version:el,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)),Il(c,o),a.push(D(e.generationRoot))}finally{Pi(c,{recursive:!0,force:!0})}return{identity:i,directorySync:W(...a)}}function u_(e,t,n){let r=Pl("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${Zt(T(n,"reindex metadata"))}`),r.digest("hex")}function bl(e){return{file:Cl(e),size:An(e).size,sha256:Es(e)}}function d_(e,t){if(t.file!==Cl(e)||An(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function Es(e){let t=Pl("sha256"),n=e_(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=p_(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{QN(n)}return t.digest("hex")}function p_(e,t){let n=0;for(;n<t.length;){let r=t_(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function xl(e,t){return ci(e,t,{mode:292})}function Yg(e,t,n){let r=_(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&O(r)&&An(r).size===t.size&&Es(r)===t.sha256}function f_(e,t,n){return!t||!n?t===n:Yg(e,t,n)}function m_(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=_(e,t.file);return O(r)&&Zt(T(r,"stored reindex metadata"))===Zt(T(n,"candidate reindex metadata"))}function vl(e,t){Pi(`${t}.tmp-replace`,{force:!0}),Il(e,`${t}.tmp-replace`),Il(`${t}.tmp-replace`,t)}import{createHash as cy,randomUUID as v_}from"crypto";import{existsSync as ft,lstatSync as kl,mkdirSync as xr,mkdtempSync as ly,readdirSync as uy,realpathSync as dy,renameSync as On,rmSync as en,statSync as Ts}from"fs";import{dirname as Ll,join as R,resolve as Lt}from"path";import{setTimeout as I_}from"timers/promises";import{pathToFileURL as ty}from"url";import E_ from"better-sqlite3";import{lstatSync as g_,readdirSync as y_}from"fs";import{join as h_,relative as S_,resolve as Nl,sep as b_}from"path";var wi=1,_l="language-indexes",Qg=["index.db","index.scip","meta.json"],Zg=[_l,hi,Si];function Ps(e){let t=[];for(let n of Qg)x_(e,n),t.push(n);for(let n of Zg)ey(e,n,t);return{version:wi,files:t.sort()}}function ws(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(!Qg.includes(e)&&!Zg.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function pt(e,t){let n=ws(t),r=Nl(e),i=Nl(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${b_}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function ey(e,t,n){let r=h_(e,t),i;try{i=y_(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()?ey(e,s,n):o.isFile()&&n.push(ws(s))}}function x_(e,t){let n=pt(e,t),r;try{r=g_(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(S_(Nl(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Al=1,ny="SCIP_QUERY_SHARED_CACHE",R_=2,Cs=JSON.stringify({cliVersion:Xi,artifactCatalogVersion:wi,postIndexAugmentationSchemaVersion:R_,sqliteGenerationStoreVersion:Dn,typescriptFragmentStoreVersion:cl,typescriptOverlayStoreVersion:vs}),Ol="manifest.json",py="shared-cache.json",P_=6e4,Ml=[_l,hi,Si];function Fs(e,t){if(!e.clean||!e.treeOid)return;let n=Sy(JSON.stringify({version:Al,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:Yi(t),producerIdentity:Cs}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Cs,generationId:n,repositoryCacheDir:ho(e.repositoryId)}}function Cq(e,t,n){if(!M_(n))return!1;let r=Fs(e,n);if(!r)return!1;try{let i=yy(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:ne}));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!==Ns(o)||o.baseGenerationId!==r.generationId||o.activeGenerationId!==r.generationId?!1:Dt(r,!1)!==null}catch{return!1}}function fy(e,t,n){if(process.env[ny]==="0")return`${ny}=0`;if(!wa(n))return"explicit cache or database override";if(Fa(Ll(t))!==Fa(yo(e))||t!==R(Ll(t),"index.db"))return"index database is outside the managed worktree cache"}function Fq(e,t,n){if(!wa(t))return;let r=n??_r(e);return r?R(ho(r.repositoryId),"evidence.db"):void 0}function Dt(e,t=!0){let n=jl(e),r;try{r=gy(j(R(n,Ol),{inputKind:"shared-generation manifest",maxBytes:ne}))}catch{return null}if(r.generationId!==e.generationId||r.repositoryId!==e.repositoryId||r.treeOid!==e.treeOid||r.producerIdentity!==e.producerIdentity||!Fr(r.fingerprint,e.fingerprint)||!__(n))return null;if(!t)return r;try{for(let i of r.artifacts){let o=pt(n,i.path),s=Ts(o);if(!s.isFile()||s.size!==i.size||dn(o,{inputKind:"shared-generation artifact",maxBytes:ae})!==i.sha256)return null}}catch{return null}return r}function ry(e,t,n,r){if(!e.treeOid)return null;let i=Yn(t,n),o=R(go(),"repositories",e.repositoryId),s;try{let l=kl(o);if(!l.isDirectory()||l.isSymbolicLink())return null;s=dy(o)}catch{return null}let a=R(s,"generations"),c=[];try{for(let l of uy(a)){if(!/^[a-f0-9]{64}$/.test(l))continue;let u=R(a,l),d;try{d=kl(u)}catch{continue}if(!(!d.isDirectory()||d.isSymbolicLink()))try{let p=gy(j(R(u,Ol),{inputKind:"shared-generation baseline manifest",maxBytes:ne}));p.generationId===l&&p.repositoryId===e.repositoryId&&p.producerIdentity===Cs&&k_(p.fingerprint,i)&&c.push(p)}catch{continue}}}catch{return null}c.sort((l,u)=>{let d=l.treeOid===e.treeOid?0:1,p=u.treeOid===e.treeOid?0:1;if(d!==p)return d-p;if(r){let g=ay(l.fingerprint,r)-ay(u.fingerprint,r);if(g!==0)return g}return Date.parse(u.createdAt)-Date.parse(l.createdAt)||l.generationId.localeCompare(u.generationId)});for(let l of c){let u={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:l.treeOid,fingerprint:l.fingerprint,producerIdentity:l.producerIdentity,generationId:l.generationId,repositoryCacheDir:s},d=Dt(u);if(d)return{snapshot:u,manifest:d}}return null}function my(e){let t=_t(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 w_(e)}finally{t.release()}}function w_(e){let t=Dt(e.snapshot);if(t)return iy(e.snapshot,t);if(!_i(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=sy(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=Ps(e.sourceCacheDir),i=R(e.snapshot.repositoryCacheDir,"generations"),o=[ge(i)],s=ly(R(i,`.tmp-${process.pid}-`));try{let a=[];for(let g of r.files){let y=pt(e.sourceCacheDir,g),m=pt(s,g);o.push(ki(y,m,292)),e.onPublicationStage?.("after-artifact-flushed",g);let S=Ts(m).size;a.push({path:g,size:S,sha256:dn(m,{inputKind:"staged shared-generation artifact",maxBytes:ae})})}let c=vi(ee(R(s,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:ae}));if(!c)throw new Error("shared SCIP generation has no project root metadata");let l=$l(e.sourceProjectRoot);if(c!==l)throw new Error("shared SCIP generation root does not match its source worktree");if(sy(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let u={version:Al,artifactCatalogVersion:wi,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:a.sort((g,y)=>g.path.localeCompare(y.path))},d=Le(R(s,Ol),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=jl(e.snapshot);try{if(ft(p)&&!Dt(e.snapshot)){let g=`${p}.corrupt-${process.pid}-${Date.now()}`;On(p,g),en(g,{recursive:!0,force:!0})}On(s,p)}catch(g){let y=Dt(e.snapshot);if(y)return iy(e.snapshot,y);throw g}e.onPublicationStage?.("after-generation-renamed"),o.push(D(i)),e.onPublicationStage?.("after-generations-directory-synced");let f=W(...o);return{kind:"published",manifest:u,achievedDurability:f==="synced"?"directory-durable":"file-flushed",directorySync:f}}finally{en(s,{recursive:!0,force:!0})}}function iy(e,t){let n=D(R(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:n==="synced"?"directory-durable":"file-flushed",directorySync:n}}function Fi(e){let t=jl(e.snapshot);xr(e.targetCacheDir,{recursive:!0});let n=_t(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=ly(R(e.targetCacheDir,".shared-hydrate-")),O_(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=pt(t,c.path),u=pt(r,c.path);if(ki(l,u),Ts(u).size!==c.size||dn(u,{inputKind:"hydrated shared-generation artifact",maxBytes:ae})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=$l(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Vg(pt(r,c.path),e.manifest.scipProjectRoot,s);if(!_i(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=L_(e.targetCacheDir,r),o=!0,D_(r,e.targetCacheDir,i),Ug({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=Rs(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&&Dl(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&A_(e.targetCacheDir,i),s}finally{r&&en(r,{recursive:!0,force:!0}),n.release()}}function Tq(e,t,n,r){let i=fy(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??_r(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean){if(ft(n.dbPath))return Ni(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let d=t.languages??Ss(e),p=Xn(e,d,Ti(t)),f=ry(o,d,Ti(t),p);return f?(Fi({snapshot:f.snapshot,manifest:f.manifest,targetCacheDir:n.cacheDir,targetProjectRoot:e,persistLease:!1,lockWaitMs:0}),oy(f.snapshot,n.cacheDir),{kind:"overlay"}):(Ni(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"})}let s=t.languages??Ss(e),a=Xn(e,s,Ti(t)),c=Fs(o,a);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let l=Dt(c);if(l)return Fi({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let u=T_(c,e);if(!u){if(!ft(n.dbPath)){let d=ry(o,s,Ti(t),a);if(d)return Fi({snapshot:d.snapshot,manifest:d.manifest,targetCacheDir:n.cacheDir,targetProjectRoot:e,persistLease:!1,lockWaitMs:0}),oy(d.snapshot,n.cacheDir),{kind:"overlay"}}return Ni(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,Fi({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 Nq(e,t,n,r){let i=fy(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??_r(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return Ni(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??Ss(e),a=Xn(e,s,Ti(t)),c=Fs(o,a);if(!c)return Ni(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 _i(n.cacheDir,e,a)?(Dl(c,n.cacheDir,"local-fresh"),{kind:"local-fresh"}):(Fi({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let u=_s(n.cacheDir);return!u||!Fr(Cr(u.fingerprint),a)||JSON.stringify([...u.indexedLanguages??[]].sort())!==JSON.stringify([...s].sort())?{kind:"missed",reason:"local metadata does not match the clean worktree snapshot"}:_i(n.cacheDir,e,a)?(my({snapshot:c,sourceCacheDir:n.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let d=_r(e);return(d?Fs(d,a):void 0)?.generationId===c.generationId}}),Dl(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 _q(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??Nt,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=fs(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 I_(Math.min(r,u))}return Dt(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Dl(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:Ns(i)};return Bl(e.repositoryCacheDir,o,!0),o}function oy(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:Ns(r)};return Bl(e.repositoryCacheDir,i,!0),i}function Ni(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:Ns(o)},a=ho(e.repositoryId),c=C_(a,s);return c||(Bl(a,s,!1),s)}function C_(e,t){try{let n=yy(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:ne})),i=Date.parse(t.lastSeenAt)-Date.parse(r.lastSeenAt);return F_(r,t)&&Number.isFinite(i)&&i<P_?r:null}catch{return null}}function F_(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 Ns(e){return Sy(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:Lt(e.projectRoot),localCacheDir:Lt(e.localCacheDir)}))}function gy(e){let t=JSON.parse(e);if(t.version!==Al||t.artifactCatalogVersion!==wi||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!==Cs||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(ws(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 ki(e,t,n=384){return ci(e,t,{mode:n})}function T_(e,t){for(let n of yd(t)){if(Lt(n.path)===Lt(t))continue;let r=yo(n.path),i=_s(r);if(!(!i||JSON.stringify(i.fingerprint)!==JSON.stringify(e.fingerprint)||JSON.stringify([...i.indexedLanguages??[]].sort())!==JSON.stringify([...e.fingerprint.languages].sort()))&&_i(r,n.path,e.fingerprint))try{return{manifest:my({snapshot:e,sourceCacheDir:r,sourceProjectRoot:n.path}).manifest,sourceProjectRoot:n.path}}catch{continue}}return null}function N_(e,t,n){xr(e,{recursive:!0}),Le(R(e,py),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function sy(e){try{let t=Ps(e),n=cy("sha256");for(let r of t.files){let i=pt(e,r),o=Ts(i).size;n.update(r).update("\0").update(String(o)).update("\0"),Wn(i,{inputKind:"source-generation artifact",maxBytes:ae},s=>n.update(s)),n.update("\0")}return n.digest("hex")}catch{return null}}function _s(e){try{let t=jt(j(R(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:ne}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function __(e){return _s(e)?.scipCompanion!=="deferred"}function Ti(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function k_(e,t){let n=Yn(e.languages,e);return JSON.stringify(n)===JSON.stringify(t)}function ay(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 jl(e){return R(e.repositoryCacheDir,"generations",e.generationId)}function yy(e){let t=JSON.parse(j(R(e,py),{inputKind:"worktree cache pointer",maxBytes:ne}));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 Bl(e,t,n){let r=Xm(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}),Le(R(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),N_(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function L_(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&&ki(c,R(n,"stable",a))}for(let a of Ml){let c=R(e,a),l=ft(c);if(l){let u=kl(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,mi),s=ft(o);return s&&hy(o,R(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:s}}function D_(e,t,n){for(let r of Ml){let i=R(t,r);if(n.managedDirectories.get(r)){let s=R(n.root,"managed",r);xr(Ll(s),{recursive:!0}),On(i,s)}let o=R(e,r);ft(o)&&On(o,i)}}function A_(e,t){for(let i of Ml){let o=R(e,i),s=R(t.root,"managed",i);t.managedDirectories.get(i)?ft(s)&&(en(o,{recursive:!0,force:!0}),On(s,o)):en(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=R(e,i);if(!o){en(s,{force:!0});continue}let a=`${s}.shared-restore-${v_()}`;ki(R(t.root,"stable",i),a),en(s,{force:!0}),On(a,s)}let n=R(e,mi);en(n,{recursive:!0,force:!0});let r=R(t.root,"sqlite-generations");t.generationStoreExisted&&ft(r)&&On(r,n)}function hy(e,t){xr(t,{recursive:!0});for(let n of uy(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()?hy(r,i):n.isFile()&&ki(r,i)}}function O_(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!Fr(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function _i(e,t,n,r=!0,i=!0){try{let o=_s(e);if(!o||o.scipCompanion==="deferred"||!Fr(Cr(o.fingerprint),n)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...n.languages].sort()))return Ci("source validation rejected metadata"),!1;let s=Ps(e),a=Rs(R(e,"index.db"),R(e,"meta.json"));if(r?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Ci(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new E_(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=$l(t),d=(i?s.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let f=vi(ee(pt(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:ae}));return f!==l&&Ci(`source validation rejected SCIP root for ${p}: ${String(f)}`),f===l});return d||Ci("source validation rejected SCIP project roots"),d}catch(o){return Ci(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Ci(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function $l(e){try{return ty(dy(e)).href}catch{return ty(Lt(e)).href}}function M_(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 Sy(e){return cy("sha256").update(e).digest("hex")}import{spawn as V_}from"child_process";import{platform as Ty}from"os";import{performance as Ny}from"perf_hooks";import{execFileSync as vy}from"child_process";import{platform as j_}from"os";var Iy=1e3,Ey=2*1024*1024,B_=25;function Ry(e,t,n=Fy){let r=n.readIdentity(e),i=new Map;return r&&i.set(e,r),{rootPid:e,rootIdentity:r,ownsProcessGroup:t,knownMembers:i}}async function Py(e,t,n=Fy){if(!e.rootIdentity){let c=await Li(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=wy(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"&&!Cy(e,n))return{reaped:!0,reason:"terminated"};if(n.platform==="win32"){try{n.terminateWindowsTree(e.rootPid)}catch(l){let u=await Li(e,t.forceMs,n);return{reaped:u,reason:u?"terminated":"signal-failed",detail:u?void 0:Gl(l)}}let c=await Li(e,t.forceMs,n);return{reaped:c,reason:c?"terminated":"deadline"}}let i=by(e,"SIGTERM",n);if(await Li(e,t.gracefulMs,n))return{reaped:!0,reason:"terminated"};let s=by(e,"SIGKILL",n);return await Li(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 wy(e,t){let n=t.readIdentity(e.rootPid);if(!n)return"exited";if(!e.rootIdentity||!ke(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 by(e,t,n){let r=wy(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(!xy(o))return{reason:"signal-failed",detail:Gl(o)}}let i=null;for(let o of e.knownMembers.values()){let s=n.readIdentity(o.pid);if(!(!s||!ke(o,s)))try{n.signal(o.pid,t)}catch(a){!xy(a)&&i===null&&(i=Gl(a))}}return i===null?null:{reason:"signal-failed",detail:i}}async function Li(e,t,n){let r=n.now()+t;for(;Cy(e,n);){if(n.now()>=r)return!1;await n.sleep(Math.min(B_,Math.max(1,r-n.now())))}return!0}function Cy(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&&ke(n,r))return!0}return!!(e.ownsProcessGroup&&t.isProcessGroupAlive(e.rootPid))}function $_(e){let t=G_(!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 G_(e){return vy("ps",["-axo",e?"pid=,ppid=,rss=":"pid=,ppid="],{encoding:"utf8",timeout:Iy,maxBuffer:Ey,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}function xy(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ESRCH"}function Gl(e){return e instanceof Error?e.message:String(e)}var Fy={platform:j_(),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 $_(e)}catch{return[]}},signal(e,t){process.kill(e,t)},terminateWindowsTree(e){vy("taskkill.exe",["/PID",String(e),"/T","/F"],{timeout:Iy,maxBuffer:Ey,stdio:"ignore",windowsHide:!0})},async sleep(e){await new Promise(t=>setTimeout(t,e))}};var Gq={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},Ai=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 Di(e,t){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${t} must be a positive finite number.`)}function _y(e,t,n,r){let i=Math.max(0,r-n);i>0&&e.push(t.subarray(0,i))}function ky(e,t,n){let r=Buffer.concat([...e,t]);e.length=0,e.push(r.subarray(Math.max(0,r.length-n)))}function Vq(e){Di(e.timeoutMs,"timeoutMs"),Di(e.maxStdoutBytes,"maxStdoutBytes"),Di(e.maxStderrBytes,"maxStderrBytes");let t=e.terminationGraceMs??1e3;Di(t,"terminationGraceMs");let n=e.terminationForceMs??t;return Di(n,"terminationForceMs"),new Promise((r,i)=>{let o=Ny.now(),s=Ty()!=="win32"&&process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1",a=Ty()!=="win32"&&!s,c;try{c=V_(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 Ai("spawn",e.label,`${e.label} could not start: ${P}`,{cause:I,reaped:!0}));return}let l=[],u=[],d=0,p=0,f=!1,g=!1,y=null,m=!1,S=c.pid===void 0?null:Ry(c.pid,a),h=()=>{clearTimeout(x),e.signal?.removeEventListener("abort",b)},v=I=>{if(m||!y)return;m=!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 Ai(y.kind,e.label,`${y.message}${V}`,{timedOut:y.timedOut,reaped:I.reaped,stdout:P,stderr:k,stdoutTruncated:f,stderrTruncated:g}))},E=I=>{if(!(y||m)){if(y=I,!S){v({reaped:c.pid===void 0,reason:c.pid===void 0?"terminated":"identity-unavailable"});return}Py(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"?ky(l,P,e.maxStdoutBytes):_y(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"?ky(u,P,e.maxStderrBytes):_y(u,P,p,e.maxStderrBytes),p+=P.length,p>e.maxStderrBytes&&(g=!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(!m&&!y){if(c.pid===void 0){h(),m=!0,i(new Ai("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(m||y)return;m=!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:Ny.now()-o,stdoutTruncated:f,stderrTruncated:g})}),e.input===void 0?c.stdin.end():c.stdin.end(e.input)})}function qq(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function Ly(e){let t=Z(e);return H_(t)?"test":W_(t)?"worker":q_(t)?"entry":U_(t)?"barrel":"source"}function H_(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 W_(e){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(e)}function q_(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 U_(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 z_=4;function Mn(e,t,n,r={}){return Dy(e,t,n,r.maxReexportDepth??z_,0,new Set)}function Dy(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)?[]:Dy(e,c.sourcePath,n,r,i+1,new Set(o)):[])}import{createHash as Wi}from"crypto";import{setImmediate as RL}from"timers/promises";import{createRequire as PL}from"module";import{createHash as dk}from"crypto";var ks=8;function vr(e,t,n){return Ul(Ay(e,t,Wl(n),0,new Set))}function ql(e,t,n){return Vl(e,t,n,0,new Set)}function Ay(e,t,n,r,i){if(r>ks)return[];let o=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n);return o?Oy(e,t,o[1],o[2],r,i):/^[A-Za-z_$][\w$]*$/u.test(n)?My(e,t,n,r,i):[]}function Oy(e,t,n,r,i,o){let s=[];for(let a of Vl(e,t,n,i+1,new Set(o))){let c=Ge(a.initializer);for(let l of c.namedChildren){if(l.type==="pair"){let u=l.childForFieldName("key")??l.namedChild(0);if(Q_(u)!==r)continue;let d=l.childForFieldName("value")??l.namedChild(1);d&&s.push(...Ay(e,a.definition.relativePath,Wl(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=X_(e,a.definition.relativePath,r,l);s.push(...d.length>0?d:[K_(a.definition,r,l)]);continue}if(l.type==="spread_element"){let u=l.namedChild(0);if(!u)continue;for(let d of Vl(e,a.definition.relativePath,Wl(u.text),i+1,new Set(o)))s.push(...Oy(e,d.definition.relativePath,d.definition.leaf,r,i+1,new Set(o)))}}}return Ul(s)}function K_(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 Vl(e,t,n,r,i){return r>ks||!/^[A-Za-z_$][\w$]*$/u.test(n)?[]:My(e,t,n,r,i).flatMap(o=>{let s=M(e,o.relativePath)?.rootNode,a=s?Y_(s,o.leaf):null;return a?[{definition:o,initializer:a}]:[]})}function My(e,t,n,r,i){if(r>ks)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=J_(e,t,n);if(a.length>0)return a;let c=de(e,t).find(l=>l.localName===n&&l.sourcePath);if(c?.sourcePath){let l=c.kind==="namespace"||c.importedName==="default"?n:c.importedName;return Hl(e,c.sourcePath,l,r+1,new Set(i))}return Hl(e,t,n,r+1,new Set(i))}function J_(e,t,n){let r=e.get("SELECT id FROM documents WHERE relative_path = ?",t)?.id;return r===void 0?[]:(be(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 Hl(e,t,n,r,i){if(r>ks)return[];let o=B(e,t).filter(s=>s.leaf===n);return o.length>0?o:Ul(ct(e,t).flatMap(s=>s.sourcePath?s.kind==="named"&&!s.names.includes(n)?[]:Hl(e,s.sourcePath,n,r+1,new Set(i)):[]))}function X_(e,t,n,r){return B(e,t).filter(i=>i.leaf===n&&i.startLine<=r.startPosition.row&&i.endLine>=r.endPosition.row)}function Y_(e,t){let n=null;return he(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 Q_(e){return e?.text.replace(/^['"`]|['"`]$/gu,"")??null}function Wl(e){return e.replace(/\s+/gu,"").replace(/^\.\.\./u,"")}function Ul(e){return[...new Map(e.map(t=>[t.symbol,t])).values()]}function Ls(e){let t=e.replaceAll("\\","/");return Ly(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 Z_=8;function nt(e,t){return t?Ir(e,t,0,new Set):null}function Ir(e,t,n,r){if(n>Z_)return mt(t,"value-evaluation-depth");let i=Ge(t),o=ok(i);if(o)return sk(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 ak(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=ck(i);return a?ik(e,a.base,a.properties,i,n,r):i.type==="call_expression"||i.type==="call"?ek(e,i,n,r):mt(i,`unsupported-expression:${i.type}`)}function ek(e,t,n,r){let o=(t.childForFieldName("function")??t.namedChild(0))?.text.replace(/\s+/gu,"").replace(/<.*>$/u,"")??"",s=tk(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=$e(l,a.startLine,a.endLine);if(!u)return mt(t,"call-target-syntax-unavailable");let d=nk(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?Ds(t,"bounded-call-return",f,a.symbol):mt(t,"call-return-unresolved")}function tk(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=de(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=de(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 nk(e){let t=e.childForFieldName("body");if(e.type==="arrow_function"&&t&&t.type!=="statement_block")return t;let n=[];return By(t??e,t??e,n),n.length!==1?null:n[0].childForFieldName("argument")??n[0].namedChild(0)}function By(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)By(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=zl(e.root,t);if(s){let g=Ir(e,s,r+1,i);return g?Ds(n,"local-constant",g):mt(n,"non-foldable-local")}let a=de(e.db,e.file).find(g=>g.localName===t&&g.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=zl(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?Ds(n,"imported-constant",f,u.symbol):tt(n,u.symbol,"import-value-unresolved")}function ik(e,t,n,r,i,o){let s=de(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=zl(u,c);if(!d)return tt(r,l??t,"member-base-non-value");for(let f of n){let g=Ge(d);if(d=uk(g,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?Ds(r,"member-constant",p,l):tt(r,l??t,"member-value-unresolved")}function ok(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 sk(e,t,n,r,i){return{value:r,evidence:"literal",term:n,precision:i,derivation:As("direct-literal","direct",e,t)}}function ak(e,t,n,r,i,o){return{value:r,evidence:"constant",term:n,precision:i,derivation:{...As("constant-concatenation","mechanically-derived",e,t),inputFactIds:o.flatMap(s=>s.derivation.inputFactIds),sourceSpans:o.flatMap(s=>s.derivation.sourceSpans)}}}function Ds(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:As(n,"heuristic","",e)}}function mt(e,t){return{value:e.text.trim(),evidence:"expression",term:{kind:"unknown",reason:t},precision:"unknown",derivation:As(t,"heuristic","",e)}}function As(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 ck(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 jy=new WeakMap;function lk(e){let t=jy.get(e);if(t)return t;let n=new Map;return he(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)}),jy.set(e,n),n}function zl(e,t){return lk(e).get(t)??null}function uk(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 pk=new WeakMap,zy=new Set(["delete","get","head","options","patch","post","put"]),fk=/(?:^|\.)(?:app|router|server)$/u,mk=new Set(["findFirst","findMany","findUnique","from","get","select"]),gk=new Set(["create","delete","insert","remove","update","upsert"]),yk=new Set(["execute","query","raw"]),$y=/(?:\b(?:name|id)|['"`](?:name|id)['"`])\s*:/u,Gy=/(?:^\s*|[,{]\s*)(?:async\s+)?['"`]?(?:execute|handler|invoke|run)['"`]?\s*(?::|\([^)]*\)\s*\{)/mu,Vy=/\b[A-Za-z_$][\w$-]*[_-][\w$-]*\s*\(/u,Hy=/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s+[A-Za-z_$][\w$-]*\s*\(/iu,Xl=[xk(),bk(),hk(),vk(),Ek(),Rk(),wk()],Jl=new Set(["exec","execFile","execFileSync","execSync","fork","spawn","spawnSync"]);function hk(){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=Sk(e.source),n=[];return tn(e.root,"call_expression",r=>{let i=Bi(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||!Jl.has(c))return;let l=jn(r),u=ze(l[0],e)??{value:l[0]?.text.trim()||"<missing>",evidence:"expression"},d=["exec","execFile","execFileSync","execSync"].includes(c)?"process.exec":"process.spawn";n.push(fe(e,r,"builtin.node-child-process",d,[{name:"operation",value:c,evidence:"literal"},{name:"executable",...u}],"exact","node-child-process-import"))}),n}}}function Sk(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&&Jl.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&&Jl.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 Ce(e,t,n,r){let i=Oi(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&&pk.set(o,i);let s=n??F(e,t),a,c,l,u=()=>(c!==void 0||(c=Oi(r,"runtime-boundaries.context.callable-sites",t,()=>{let d=ue(t);return(d?dc(o,d):null)??Qr(e,t)})),c);return{db:e,file:t,source:s,root:o,get constants(){return l??=Oi(r,"runtime-boundaries.context.constants",t,()=>kk(o)),l},ownerAt:d=>{let f=(a??=Oi(r,"runtime-boundaries.context.definitions",t,()=>B(e,t,{rangeCorrectionEvidence:{source:s,callables:u()}},(m,S)=>Oi(r,`runtime-boundaries.context.definitions.${m}`,t,S)))).filter(m=>m.startLine<=d&&m.endLine>=d).sort((m,S)=>m.endLine-m.startLine-(S.endLine-S.startLine)||m.startLine-S.startLine)[0];if(f)return{file:t,symbol:f.symbol,name:f.leaf,startLine:f.startLine,endLine:f.endLine};let y=(u()??[]).filter(m=>m.startLine<=d&&m.endLine>=d).sort((m,S)=>m.endLine-m.startLine-(S.endLine-S.startLine)||m.startLine-S.startLine)[0];return{file:t,symbol:null,name:y?.name??null,startLine:y?.startLine??d,endLine:y?.endLine??d}}}}function Oi(e,t,n,r){return e?e(t,r,{file:n}):r()}function bk(){return{id:"builtin.effect-httpapi",supports:e=>Mi(e,"HttpApiEndpoint").size>0||Mi(e,"HttpApiBuilder").size>0,extract:e=>{let t=[],n=Mi(e.source,"HttpApiEndpoint"),r=Mi(e.source,"HttpApiGroup"),i=Mi(e.source,"HttpApiBuilder");return tn(e.root,"call_expression",o=>{let s=Ky(o);if(!s)return;let a=jn(o);if(n.has(s.receiver)&&zy.has(s.member)){let y=ze(a[0],e),m=ze(a[1],e),S=qy(o,r,"make",0,e);if(!y||!m||!S)return;let h=s.member.toUpperCase();t.push(fe(e,o,"builtin.effect-httpapi","http.handle",[{name:"method",value:h,evidence:"literal"},{name:"path",...m}],gt([{name:"path",...m}]),"effect-httpapi-endpoint-declaration")),t.push(fe(e,o,"builtin.effect-httpapi","framework.declare",Kl(S,y),gt(Kl(S,y)),"effect-httpapi-operation-declaration"));return}if(!["handle","handleRaw"].includes(s.member))return;let c=qy(o,i,"group",1,e),l=ze(a[0],e),u=a[1];if(!c||!l||!u)return;let d=Kl(c,l),p=vr(e.db,e.file,u.text),f=fe(e,o,"builtin.effect-httpapi","framework.handle",d,p.length===1?gt(d):"candidate","effect-httpapi-handler-registration"),g=p[0];p.length===1&&g&&(f.owner={file:g.relativePath,symbol:g.symbol,name:g.leaf,startLine:g.startLine,endLine:g.endLine}),t.push(f)}),t}}}function Kl(e,t){return[{name:"adapter",value:"effect-httpapi",evidence:"literal"},{name:"group",...e},{name:"operation",...t}]}function Mi(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(Wy(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}`)&&Wy(s)&&n.add(o[1])}return n}function Wy(e){return e==="effect/unstable/httpapi"||e==="@effect/platform"||e.startsWith("@effect/platform/HttpApi")}function qy(e,t,n,r,i){let o=e.parent;for(;o;){if(o.type==="call_expression"){let s=Uy(o,t,n,r,i);if(s)return s;let a=o.childForFieldName("function")??o.namedChild(0),c=null;if(a&&Ql(a,l=>{!c&&l.type==="call_expression"&&(c=Uy(l,t,n,r,i))}),c)return c}o=o.parent}return null}function Uy(e,t,n,r,i){let o=Ky(e);return!o||o.member!==n||!t.has(o.receiver)?null:ze(jn(e)[r],i)}function Ky(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 xk(){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)||ji(e,["axios"])||/\b(?:FastAPI|Flask|APIRouter|axum|Router::new)\b/u.test(e),extract:e=>{let t=[];return tn(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||!ji(e.source,["fastapi","flask"]))return;t.push(fe(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=Bi(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"&&ji(e.source,["axum"])){let p=ze(s[0],e),f=/^\s*(get|post|put|patch|delete|options|head)\s*\(/iu.exec(s[1]?.text??"")?.[1];if(!p||!f)return;t.push(fe(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=ze(s[0],e);if(!p)return;let g=/\bmethod\s*:\s*['"`]([A-Za-z]+)['"`]/u.exec(s[1]?.text??"")?.[1]?.toUpperCase()??(s[1]?null:"GET"),y=[...g?[{name:"method",value:g,evidence:"literal"}]:[],{name:"path",...p}];t.push(fe(e,n,"builtin.http","http.request",y,g?gt(y):"candidate","call-expression"));return}if(!zy.has(i))return;let a=ze(s[0],e);if(!a)return;let c=i.toUpperCase();if(fk.test(o)&&ji(e.source,["express","fastify","hono","koa-router","@koa/router"])){t.push(fe(e,n,"builtin.http","http.handle",[{name:"method",value:c,evidence:"literal"},{name:"path",...a}],gt([{name:"path",...a}]),"framework-adapter"));return}let u=Tk(e.source,["axios"]),d=o.split(".")[0]??"";u.has(d)&&t.push(fe(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=>$y.test(e)&&Gy.test(e)||Vy.test(e)||Hy.test(e),extract:e=>{let t=[],n=new Set,r=[];return $y.test(e.source)&&Gy.test(e.source)&&r.push("pair"),(Vy.test(e.source)||Hy.test(e.source))&&r.push("string","string_literal","template_string"),tn(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=Jy(a,e),u=Dk(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(fe(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(!Ik(o,a,s.index))continue;let c=`reference\0${a}\0${i.startPosition.row}`;n.has(c)||(n.add(c),t.push(fe(e,i,"builtin.capability-registry","registry.reference",[{name:"key",value:a,evidence:"literal"}],"exact","capability-instruction-reference")))}}),t}}}function Ik(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 Ek(){return{id:"builtin.registry",supports:e=>/(?:Handlers?|Registry|Routes?)\b/iu.test(e),extract:e=>{let t=[];return tn(e.root,["pair","call_expression"],n=>{if(n.type==="pair"){let o=Lk(n);if(!o)return;let s=n.childForFieldName("key")??n.namedChild(0),a=n.childForFieldName("value")??n.namedChild(1),c=Jy(s,e);if(!c||!a||!Xy(a))return;let l=Yl(a)?"exact":"candidate";t.push(fe(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(fe(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 Rk(){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=Ok(e.root);return tn(e.root,"call_expression",r=>{let i=Bi(r);if(!i)return;let o=i.split("."),s=o.at(-1)??"",a=jn(r),c=a[0]?.text??"",l=Ak(s,c);if(!l)return;let u=Yy(o,n);if(!u)return;let d=Pk(a[0],e)??Mk(c),p=jk(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(fe(e,r,"builtin.persistence",l,[{name:"resource",...p}],gt([{name:"resource",...p}]),f))}),t}}}function Pk(e,t){if(!e)return null;let n=e.text.replace(/\s+/gu,"");return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/u.test(n)?{value:n.split(".").at(-1),evidence:"identifier",term:{kind:"symbol",symbol:n}}:ze(e,t)}function wk(){return{id:"builtin.queue",supports:e=>ji(e,["amqplib","bullmq","kafkajs","@aws-sdk/client-sqs","rabbitmq"])&&/\.(?:sendToQueue|consume|send|subscribe)\s*\(/u.test(e),extract:e=>{let t=[];return tn(e.root,"call_expression",n=>{let r=Bi(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"?Nk(o[0],"topic",e):ze(o[0],e);a&&t.push(fe(e,n,"builtin.queue",s,[{name:"address",...a}],gt([{name:"address",...a}]),"framework-adapter"))}),t}}}function fe(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:${dk("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:Ck(r),executionDomain:Fk(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:Ls(e.file)}}function Ck(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 Fk(e){let t=e.replaceAll("\\","/"),n=/^(apps|services|packages)\/([^/]+)/u.exec(t);return n?`${n[1]}/${n[2]}`:null}function ji(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 Tk(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 Os(e,t,n,r,i,o,s){return fe(e,t,n,r,i,o,s)}function Bi(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 ze(e,t){let n=nt(t,e);return n?{value:n.value,evidence:n.evidence,term:n.term,derivation:n.derivation}:null}function Nk(e,t,n){if(!e)return null;let r=e.namedChildren.find(o=>o.type!=="pair"?!1:(o.childForFieldName("key")??o.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")===t),i=r?.childForFieldName("value")??r?.namedChild(1);return ze(i,n)}function Jy(e,t){if(!e)return null;let n=ze(e,t);if(n?.evidence==="literal"||n?.evidence==="constant")return n;let r=e.text.trim();return/^[A-Za-z_$][\w$]*$/u.test(r)?{value:r,evidence:"identifier",term:{kind:"symbol",symbol:r}}:n}function 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 _k(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 kk(e){let t=new Map;return Ql(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=_k(i);o!==null&&t.set(r.text,o)}),t}function Lk(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 Yl(e){return/(?:function|lambda|method)/u.test(e.type)||e.type==="arrow_function"}function Xy(e){return Yl(e)||e.type==="member_expression"?!0:e.type==="identifier"&&/(?:command|controller|dispatch|handle|handler)/iu.test(e.text)}function Dk(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&&Xy(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 Yy(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 Ak(e,t){if(mk.has(e))return"database.read";if(gk.has(e))return"database.write";if(!yk.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 Ok(e){let t=new Set;return tn(e,"call_expression",n=>{let r=Bi(n);if(!r)return;let i=r.split(".");if(!(i.at(-1)!=="transaction"||!Yy(i)))for(let o of jn(n)){if(!Yl(o))continue;let a=(o.childForFieldName("parameters")??o.namedChildren.find(l=>/parameters/u.test(l.type)))?.namedChildren[0],c=a?Ur(a):null;c&&t.add(c)}}),t}function Mk(e){let t=Qy(e);return t?{value:t,evidence:"identifier",term:{kind:"symbol",symbol:t}}:null}function jk(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=Qy(r.value);return i?{value:i,evidence:r.evidence}:null}function Qy(e){return/\b(?:from|into|update|table)\s+(?:\$\{\s*)?['"`]?([A-Za-z_$][\w$.-]*)/iu.exec(e)?.[1]??null}function Ql(e,t){t(e);for(let n of e.namedChildren)Ql(n,t)}function tn(e,t,n){for(let r of qr(e,t))n(r)}var Bk=C("resolved-call-syntax",{clearGroups:[]}),Zl=C("resolved-call-sites",{clearGroups:[]}),$k=C("resolved-call-sites-reference-evidence",{clearGroups:[]});function eu(e,t){return Zl.get(e,t.symbolId,()=>eh(e,t,Gk(e,t)))}function Zy(e,t){let n=[...new Map(t.map(o=>[o.symbolId,o])).values()],r=n.filter(o=>!Zl.has(e,o.symbolId)),i=th(e,r);return new Map(n.map(o=>[o.symbolId,Zl.get(e,o.symbolId,()=>eh(e,o,i.get(o.symbolId)??[]))]))}function eh(e,t,n){let r=[],i=[],o=new Set,s=new Set;for(let a of n){o.add(a.file);let c=Bk.get(e,a.file,()=>Hk(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 Gk(e,t){return th(e,[t]).get(t.symbolId)??[]}function th(e,t){if(!Vk(e))return new Map(t.map(r=>[r.symbolId,Mc(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 ts(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 Vk(e){return $k.get(e,"project",()=>!!e.get("SELECT 1 AS present FROM mentions WHERE role != 1 LIMIT 1"))}function Hk(e,t){let n=M(e,t)?.rootNode;if(!n)return null;let r=new Map;for(let i of qr(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 Wk=C("call-parameter-value-flow",{clearGroups:[]});function $i(e,t){let n=`${t.callee.symbolId}\0${t.file}\0${t.callNode.startIndex}\0${t.callNode.endIndex}`;return Wk.get(e,n,()=>qk(e,t))}function Gi(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 qk(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?$e(r,t.caller.startLine,t.caller.endLine):null;if(!i)return{callee:t.callee,caller:t.caller,call:n,transfers:[],unknown:t.arguments.map((c,l)=>({calleePosition:l,argumentText:c.text.trim(),reason:"caller-syntax-unavailable",proof:n}))};let o=zt(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 Uk=8,zk=8;function rh(e,t,n=[]){let r=[],i=Kk(e,n,r),o=i.summaries,s=Jk(e,t,o,r),a=Xk(e,t,r);return{observations:sL([...s.observations,...a]),bodySummaries:o.size,discriminatorSummaries:s.summaries,filesInspected:i.filesInspected,errors:r}}function Kk(e,t,n){let r=new Map,i=[],o=new Map,s=a=>{if(o.has(a))return o.get(a)??null;let c=Ce(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>=Uk))try{for(let c of eu(e,a.definition).sites){if(!s(c.file))continue;let u=c.caller;if(!u)continue;let d=Gi($i(e,c),a.parameterIndexes);if(d.length===0)continue;let p={definition:u,parameterIndexes:lh(d),depth:a.depth+1,proofSpans:[...a.proofSpans,{file:c.file,startLine:c.startLine,endLine:c.endLine}]};eL(r,p)&&i.push(r.get(u.symbol))}}catch(c){n.push(`builtin.carrier body summary failed for ${a.definition.relativePath}: ${ru(c)}`)}}return{summaries:r,filesInspected:new Set(t.map(a=>a.definition.relativePath)).size}}function Jk(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=oh(a);if(!c)continue;let l=Ce(e,a.source.file);if(!l)continue;let u=sh(l.root,a.source.startLine),d=u.find(h=>h.startPosition.row===a.source.startLine)??u[0];if(!d)continue;let p=nu(d);if(!p)continue;let f=vr(e,a.source.file,p.text);if(f.length!==1)continue;let g=n.get(f[0].symbol);if(!g)continue;let y=a.owner.symbol?B(e,a.owner.file).find(h=>h.symbol===a.owner.symbol):null;if(!y)continue;let m=tL(l,y),S=Ms(d);for(let h of g.parameterIndexes){let v=rL(l,S[h]);if(v)for(let E of iL(v)){let x=ah(E),b=ch(E);if(!x||!b)continue;let I=m.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=nh(k);i.has(V)||(i.set(V,k),o.push(k));continue}let P=nt(l,b);!P||P.evidence==="expression"||s.push(tu(l,E,"carrier.publish",c,x,P.value,[a.id]))}}}for(;o.length>0;){let a=o.shift();if(!(a.depth>=zk))try{for(let c of eu(e,a.definition).sites){let l=Ce(e,c.file);if(!l)continue;let u=c.callNode,d=Ms(u)[a.parameterIndex];if(!d)continue;let p=nt(l,d);p&&p.evidence!=="expression"&&s.push(tu(l,u,"carrier.publish",a.carrier,a.field,p.value,a.proofObservationIds));let f=c.caller;if(!f)continue;let g=$i(e,c).transfers.find(S=>S.calleePosition===a.parameterIndex)?.callerPosition;if(g===void 0)continue;let y={...a,definition:f,parameterIndex:g,depth:a.depth+1,proofSpans:[...a.proofSpans,{file:c.file,startLine:c.startLine,endLine:c.endLine}]},m=nh(y);i.has(m)||(i.set(m,y),o.push(y))}}catch(c){r.push(`builtin.carrier discriminator summary failed for ${a.definition.relativePath}: ${ru(c)}`)}}return{observations:s,summaries:i.size}}function Xk(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=oh(o);if(!s)continue;let a=Ce(e,o.source.file);if(!a)continue;let c=sh(a.root,o.source.startLine)[0];if(c)for(let l of Ms(c).slice(1)){let u=vr(e,o.source.file,l.text);for(let d of u)try{let p=Ce(e,d.relativePath);if(!p)continue;let f=$e(p.root,d.startLine,d.endLine);if(!f)continue;he(f,g=>{if(g.type!=="call_expression")return;let y=nu(g);if(!y)return;let m=/^([A-Za-z_$][\w$]*)\s*\[\s*([A-Za-z_$][\w$]*)\s*\]$/u.exec(y.text.trim());if(!m)return;let S=m[1],h=m[2],v=Qk(e,p,d,h);if(!v)return;let E=Zk(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=Ce(e,x.source.file),k=P?nL(P.root,x.source.startLine):null;!P||!k||r.push(tu(P,k,"carrier.consume",s,v,I,[o.id,x.id]))}})}catch(p){n.push(`builtin.carrier consumer analysis failed for ${d.relativePath}: ${ru(p)}`)}}}return r}function ih(e){let t=B(e.db,e.file),n=new Map;return he(e.root,r=>{if(r.type!=="pair"||ah(r)?.toLowerCase()!=="body")return;let i=ch(r);if(!i||!/\bJSON\.stringify\s*\(/u.test(i.text))return;let o=pr(t,r.startPosition.row),s=Yk(r);if(!o||!s)return;let a=zt(s),c=new Set;oL(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 Yk(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 Qk(e,t,n,r){let i=$e(t.root,n.startLine,n.endLine);if(!i)return null;let o=new RegExp(`\\.body\\??\\.${le(r)}\\b`,"u");if(o.test(i.text))return r;let s=null;if(he(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*${le(r)}\\s*(?:[,}]|$)`,"u").test(d.text)||p.type==="call_expression"&&(s=nu(p)?.text??null)}),!s)return null;let a=vr(e,n.relativePath,s);if(a.length!==1)return null;let c=Ce(e,a[0].relativePath),l=c?$e(c.root,a[0].startLine,a[0].endLine):null;return l&&o.test(l.text)&&new RegExp(`\\b${le(r)}\\s*[,}]`,"u").test(l.text)?r:null}function Zk(e,t,n){let r=[];for(let i of ql(e,t,n)){let o=Ge(i.initializer);if(o.type==="call_expression")for(let s of Ms(o)){let a=s.text.trim();if(/^[A-Za-z_$][\w$]*$/u.test(a))for(let c of ql(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 tu(e,t,n,r,i,o,s){let c=Os(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 oh(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 eL(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=lh([...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 nh(e){return`${e.definition.symbol}\0${e.carrier}\0${e.field}\0${e.parameterIndex}`}function tL(e,t){let n=$e(e.root,t.startLine,t.endLine);return n?zt(n):[]}function nL(e,t){let n=null;return he(e,r=>{r.startPosition.row>t||r.endPosition.row<t||(!n||r.endIndex-r.startIndex<n.endIndex-n.startIndex)&&(n=r)}),n}function sh(e,t){let n=[];return he(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 nu(e){return e.childForFieldName("function")??e.namedChild(0)}function Ms(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 Ge(t);let r=null;return he(e.root,i=>{r||i.type!=="variable_declarator"||(i.childForFieldName("name")??i.namedChild(0))?.text.trim()!==n||(r=i.childForFieldName("value")??i.namedChild(1))}),r?Ge(r):Ge(t)}function iL(e){let t=Ge(e);return t.type==="object"?t.namedChildren.filter(n=>n.type==="pair"||n.type==="shorthand_property_identifier"):[]}function ah(e){return e.type==="shorthand_property_identifier"?e.text:(e.childForFieldName("key")??e.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")??null}function ch(e){return e.type==="shorthand_property_identifier"?e:e.childForFieldName("value")??e.namedChild(1)}function oL(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 lh(e){return[...new Set(e)].sort((t,n)=>t-n)}function sL(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function ru(e){return e instanceof Error?e.message:String(e)}import{createHash as aL}from"crypto";function uh(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=cL(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=uL(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:${aL("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 cL(e){let t=[],n=Me(e);for(let r of n){let i=F(e,r);if(!dL(i))continue;let o=Ce(e,r);o&&dh(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=pL(s);if(c.length<2)return;let l=nt(o,c[0]);if(!l||l.evidence==="expression")return;let u=lL(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 lL(e,t,n){let r=n.text.replace(/\s+/gu,""),i=/^([A-Za-z_$][\w$]*)/u.exec(r)?.[1];if(!i)return[];let o=de(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 uL(e,t){let n=e==="/"?"":e.replace(/\/+$/u,""),r=t.startsWith("/")?t:`/${t}`;return`${n}${r}`||"/"}function dL(e){return/(?:\bfrom\s*|\brequire\s*\(\s*)['"](?:express|fastify|hono|koa-router|@koa\/router)(?:[/']|")/u.test(e)}function pL(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function dh(e,t){t(e);for(let n of e.namedChildren)dh(n,t)}import{createHash as fL}from"crypto";function js(e){return[...new Map(e.map(t=>[t.observationId,t])).values()].sort((t,n)=>t.observationId.localeCompare(n.observationId))}var $s=new Set(["DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT"]),mL=8,ph=ce({kind:"runtime-boundary-http-roles",invalidation:te("runtime-boundary-http-roles"),serialize:SL,deserialize:bL});function gh(e,t,n){let r=n??((m,S)=>S()),i=new Map,o=[],s=[],a=new Set,c=[],l=[],u=new Map,d=new Map,p=new Map,f=m=>{if(u.has(m))return u.get(m)??null;let S=Ce(e,m);return u.set(m,S),S},g=m=>{let S=d.get(m);if(S)return S;let h=B(e,m);return d.set(m,h),h},y=(m,S)=>{let h=p.get(m.file);if(!h){let x=me(e,m.file,m.source),b=ph.read(e,m.file,x)??[];h={contentHash:x,roles:new Map(b.map(I=>[I.symbol,I])),dirty:!1},p.set(m.file,h)}let v=h.roles.get(S.symbol);if(v)return v;let E=hL(m,S);return h.roles.set(S.symbol,{symbol:S.symbol,...E}),h.dirty=!0,E};for(r("runtime-boundaries.http-summary.seed",()=>{for(let m of t){if(m.action!=="http.request"||!m.owner.symbol||m.evidence!=="call-expression"&&m.evidence!=="client-adapter")continue;let S=g(m.owner.file).find(x=>x.symbol===m.owner.symbol);if(!S)continue;let h=f(S.relativePath);if(!h)continue;let v=y(h,S),E={definition:S,...v,constantMethods:m.keyParts.flatMap(x=>x.name==="method"&&x.evidence!=="expression"&&$s.has(x.value.toUpperCase())?[x.value.toUpperCase()]:[]),depth:0,proofObservationIds:[m.id],proofSpans:[m.source]};mh(i,E)&&o.push(i.get(S.symbol))}});o.length>0;){let m=o.splice(0,o.length),S=r("runtime-boundaries.http-summary.resolve-call-sites",()=>Zy(e,m.map(h=>h.definition)),{batchSize:m.length});r("runtime-boundaries.http-summary.process-call-sites",()=>{for(let h of m)if(!(h.depth>=mL))try{let v=S.get(h.definition.symbolId);if(!v)continue;l.push(...v.unresolved.map(E=>gL(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=yL(h,b,x);I&&s.push(I);let P=E.caller;if(!P)continue;let k=y(x,P),V=xL(e,h,E),Ie={definition:P,pathParameterIndexes:Bs([...k.pathParameterIndexes,...V.pathParameterIndexes]),methodParameterIndexes:Bs([...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}]};mh(i,Ie)&&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:m.length})}return ph.writeBatch(e,[...p.entries()].flatMap(([m,S])=>S.dirty?[{relativePath:m,contentHash:S.contentHash,value:[...S.roles.values()].sort((h,v)=>h.symbol.localeCompare(v.symbol))}]:[])),{observations:s,frontiers:js(l),summaries:i.size,filesInspected:a.size,errors:c}}function gL(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:${fL("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:Ls(t.file)}}function yL(e,t,n){let r=yh(t),i=e.pathParameterIndexes.flatMap(d=>{let p=nt(n,r[d]);return p&&p.evidence!=="expression"&&IL(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"&&$s.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=Os(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 hL(e,t){let n=$e(e.root,t.startLine,t.endLine);if(!n)return{pathParameterIndexes:[],methodParameterIndexes:[],constantMethods:[]};let r=zt(n),i=new Set,o=new Set,s=new Set;return he(n,a=>{if(a.type==="call_expression"&&((a.childForFieldName("function")??a.namedChild(0))?.text.replace(/\s+/gu,"").split(".").at(-1)??"")==="fetch"){let f=yh(a);Vi(f[0],r,i);let g=vL(f[1],"method");if(g){Vi(g,r,o);let y=nt(e,g),m=y?.value.toUpperCase();m&&y?.evidence!=="expression"&&$s.has(m)&&s.add(m)}else Vi(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")&&Vi(l,r,i),(u==="init"||u==="requestinit"||u==="options")&&Vi(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 SL(e){return e.map(t=>[encodeURIComponent(t.symbol),t.pathParameterIndexes.join(","),t.methodParameterIndexes.join(","),t.constantMethods.join(",")].join(" ")).join(`
395
+ `)}function bL(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=fh(r[1]),o=fh(r[2]),s=r[3]?r[3].split(","):[];if(i===null||o===null||s.some(a=>!$s.has(a)))return null;t.push({symbol:decodeURIComponent(r[0]),pathParameterIndexes:i,methodParameterIndexes:o,constantMethods:s})}return t}function fh(e){if(!e)return[];let t=e.split(",").map(Number);return t.every(n=>Number.isSafeInteger(n)&&n>=0)?t:null}function xL(e,t,n){let r=$i(e,n);return{pathParameterIndexes:Gi(r,t.pathParameterIndexes),methodParameterIndexes:Gi(r,t.methodParameterIndexes)}}function mh(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=Bs([...n.pathParameterIndexes,...t.pathParameterIndexes]),i=Bs([...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 Vi(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 yh(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function IL(e){return e.startsWith("/")||/^https?:\/\//iu.test(e)}function Bs(e){return[...new Set(e)].sort((t,n)=>t-n)}function Er(e){return[...new Set(e)].sort()}import{createHash as EL}from"crypto";function bh(e){let t=hh(e.filter(r=>r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim")),n=hh(e.filter(r=>r.action==="database.write"&&r.evidence==="persistence-insert"));return e.flatMap(r=>r.action==="database.write"&&r.evidence==="persistence-insert"?iu(r).flatMap(i=>{let o=t.get(i)?.[0];return o?[Sh(r,o,i,"queue.send")]:[]}):r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim"?iu(r).flatMap(i=>{let o=n.get(i)?.[0];return o?[Sh(r,o,i,"queue.consume")]:[]}):[])}function hh(e){let t=new Map;for(let n of e)for(let r of iu(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 iu(e){return e.keyParts.filter(t=>t.name==="resource").map(t=>t.value)}function Sh(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:${EL("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 qi="runtime-boundaries-v19",wL=PL(import.meta.url),Y=wL("typescript"),CL=new Set([Y.SyntaxKind.WhitespaceTrivia,Y.SyntaxKind.NewLineTrivia,Y.SyntaxKind.SingleLineCommentTrivia,Y.SyntaxKind.MultiLineCommentTrivia]),FL=new Set([Y.SyntaxKind.NoSubstitutionTemplateLiteral,Y.SyntaxKind.TemplateHead,Y.SyntaxKind.TemplateMiddle,Y.SyntaxKind.TemplateTail]),Hs=[{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}],TL=64,Ph="builtin.http-summary",Ws={HTTP_HANDLE:"http.handle",HTTP_REQUEST:"http.request",REGISTRY_HANDLE:"registry.handle"},ou=new Set(Object.values(Ws));async function NL(e,t={}){let n=Me(e),r=new Set(n),i=new Set((t.affectedFiles??[]).map(YL)),o=t.previousGraph?.fileCoverage,s=i.size>0&&t.previousGraph?.extractorVersion===qi&&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(),g=await qL(e,u,t.profileSpan);At(d,"direct-extraction",f,u.length,g.observations.length,{filesVisited:u.length,filesReused:a.length,factsReused:l.length,factsInvalidated:Math.max(0,p-l.length)});let y=[...a,...g.fileCoverage].sort((L,$)=>L.file.localeCompare($.file)),m=XL(y),S=y.flatMap(L=>L.extractionErrors),h=Hi([...l,...g.observations]);if(s&&!t.forceDerivedRebuild&&t.previousGraph&&_L(o,g.fileCoverage,i)&&(!ML(e,t.previousGraph,i)||$L(o,g.fileCoverage,i)&&!GL(t.previousGraph,i))){for(let $ of t.previousGraph.coverage.extractors)m.has($.id)||m.set($.id,$);let L=HL(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:[...m.values()],extractionErrors:t.previousGraph.coverage.extractionErrors,phases:d},fileCoverage:y}}let v=Hi([...h,...bh(h)]),E=s&&t.previousGraph!==void 0?kL(t.previousGraph,o,g.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(Q=>Q.id==="http-summary"),$=t.previousGraph.coverage.extractors.find(Q=>Q.id==="builtin.wrapper");b={observations:t.previousGraph.observations.filter(Q=>Q.extractor===Ph),frontiers:t.previousGraph.frontiers.filter(Q=>Q.kind==="call-resolution"&&Q.action===Ws.HTTP_REQUEST),summaries:0,filesInspected:L?.filesVisited??$?.applicableFiles??0,errors:t.previousGraph.coverage.extractionErrors.filter(Q=>Q.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}),$&&m.set($.id,$)}else b=gh(e,v,t.profileSpan),At(d,"http-summary",f,v.length,b.observations.length,{filesVisited:b.filesInspected}),m.set("builtin.wrapper",{id:"builtin.wrapper",applicableFiles:b.filesInspected,observations:b.observations.length,errors:b.errors.length});S.push(...b.errors);let I=Hi([...v,...b.observations]);f=performance.now();let P=uh(e,I);At(d,"http-mount",f,I.length,P.observations.length,{filesVisited:P.filesInspected});let k=Hi([...I,...P.observations]);f=performance.now();let V=x&&t.previousGraph!==void 0&&LL(t.previousGraph,o,g.fileCoverage,i),Ie;if(V){let L=t.previousGraph.coverage.phases?.find(Q=>Q.id==="carrier"),$=t.previousGraph.coverage.extractors.find(Q=>Q.id==="builtin.carrier");Ie={observations:t.previousGraph.observations.filter(Q=>Q.extractor==="builtin.carrier"),bodySummaries:$?.applicableFiles??0,discriminatorSummaries:0,filesInspected:L?.filesVisited??0,errors:t.previousGraph.coverage.extractionErrors.filter(Q=>Q.startsWith("builtin.carrier"))},At(d,"carrier",f,k.length,Ie.observations.length,{filesVisited:0,filesReused:Ie.filesInspected,factsReused:Ie.observations.length,factsInvalidated:0}),$&&m.set($.id,$)}else Ie=rh(e,k,y.flatMap(L=>L.bodySummaries??[])),At(d,"carrier",f,k.length,Ie.observations.length,{filesVisited:Ie.filesInspected}),m.set("builtin.carrier",{id:"builtin.carrier",applicableFiles:Ie.bodySummaries,observations:Ie.observations.length,errors:Ie.errors.length});S.push(...Ie.errors);let rn=Hi([...k,...Ie.observations]);f=performance.now();let Gn=QL(rn);At(d,"relations",f,rn.length,Gn.length),f=performance.now();let gu=eD(rn,Gn);At(d,"links",f,Gn.length,gu.length),tD(rn,Gn),f=performance.now();let yu=js([...nD(rn,Gn),...b.frontiers]);return At(d,"frontiers",f,rn.length,yu.length),{schemaVersion:2,extractorVersion:qi,observations:rn,relationGroups:Gn,links:gu,frontiers:yu,coverage:{filesScanned:n.length,filesWithAst:y.filter(L=>L.hasAst).length,filesWithoutAst:y.filter(L=>!L.hasAst).length,...s?{filesReused:a.length}:{},extractors:[...m.values()],extractionErrors:S,phases:d},fileCoverage:y}}function _L(e,t,n){if(!e)return!1;let r=e.filter(o=>n.has(o.file)).filter(xh).map(vh).sort((o,s)=>o.file.localeCompare(s.file)),i=t.filter(xh).map(vh).sort((o,s)=>o.file.localeCompare(s.file));return JSON.stringify(r)===JSON.stringify(i)}function xh(e){return e.observationIds.length>0||e.extractionErrors.length>0}function vh(e){let{syntaxHash:t,shapeHash:n,bodySummaries:r,...i}=e;return i}function kL(e,t,n,r,i){let o=AL(t,n,r),s=OL(e),c=![...wh(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=Ih(e.observations,l)===Ih(i,u);return{reuse:o&&c&&d,shapeUnchanged:o,proofFilesUnchanged:c,seedUnchanged:d}}function wh(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 LL(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=wh(t,n),a=DL(e,"builtin.carrier");return![...s].some(c=>a.has(c))}function DL(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 AL(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 OL(e){let t=new Set;for(let n of e.observations)if(n.extractor===Ph){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===Ws.HTTP_REQUEST&&n.source&&t.add(n.source.file);return t}function Ih(e,t){return JSON.stringify(e.filter(n=>t.has(n.id)&&n.action===Ws.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 ML(e,t,n){let r=jL(t),i=BL(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 jL(e){let t=new Set;for(let n of e.observations)if(ou.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||!ou.has(n.action)||!n.source||t.add(n.source.file);return t}function BL(e){return new Set(e.observations.flatMap(t=>ou.has(t.action)&&t.owner.symbol?[t.owner.symbol]:[]))}function $L(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 GL(e,t){let n=VL(e);return[...t].some(r=>n.has(r))}function VL(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 HL(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 WL=256;async function qL(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=me(e,d,Io(e,d));return c.set(d,f),f},u=0;for(let d of t){u+=1,u>=WL&&(u=0,vn(),await RL());let p=o("runtime-boundaries.file.read",()=>Io(e,d)),f=me(e,d,p);c.set(d,f);let g=o("runtime-boundaries.file.direct-product",()=>{let x=Rh.read(e,d,f);if(!x||x.extractorVersion!==qi)return null;for(let b of x.deps)if(l(b.path)!==b.contentHash)return null;return x});if(g){r.push(...g.observations),i.push(g.coverage);continue}let y=o("runtime-boundaries.file.supports",()=>Xl.filter(x=>x.supports(p))),m=/\bJSON\.stringify\s*\(/u.test(p)&&/\bbody\s*:/u.test(p),S=o("runtime-boundaries.file.hashes",()=>{let x=Eh.read(e,d,f);if(x)return x;let b=UL(d,p);return s.push({relativePath:d,contentHash:f,value:b}),b}),h=new Set,v=[],E=cp(x=>h.add(x),()=>{let x=y.length>0||m?Ce(e,d,p,n):null,b={file:d,hasAst:x!==null||JL(d,p),syntaxHash:S.syntaxHash,shapeHash:S.shapeHash,bodySummaries:x&&m?ih(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=KL(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:qi,deps:[...h].sort().map(x=>({path:x,contentHash:l(x)})),observations:v,coverage:E}}))}return s.length>0&&Eh.writeBatch(e,s),a.length>0&&Rh.writeBatch(e,a),{observations:r,fileCoverage:i}}var Eh=ce({kind:"runtime-boundary-source-hashes",invalidation:te("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}}}),Rh=ce({kind:"runtime-boundary-direct-extraction",invalidation:te("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 UL(e,t){if(!/\.(?:[cm]?[jt]sx?)$/iu.test(e)){let l=Wi("sha256").update(t).digest("hex");return{syntaxHash:l,shapeHash:l}}let n=/\.[jt]sx$/iu.test(e)?Y.LanguageVariant.JSX:Y.LanguageVariant.Standard,r=Y.createScanner(Y.ScriptTarget.Latest,!1,n,t),i=Wi("sha256"),o=Wi("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!==Y.SyntaxKind.EndOfFileToken;l=r.scan()){if(l===Y.SyntaxKind.CloseBraceToken&&s.length>0&&s.at(-1)===0&&(l=r.reScanTemplateToken(!1)),CL.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"),!FL.has(l)&&!zL(l,u)&&o.update(u),o.update("\0"),o.update(String(c)),o.update("\0"),l===Y.SyntaxKind.TemplateHead?s.push(0):l===Y.SyntaxKind.TemplateTail?s.pop():l===Y.SyntaxKind.OpenBraceToken&&s.length>0?s[s.length-1]+=1:l===Y.SyntaxKind.CloseBraceToken&&s.length>0&&s.at(-1)>0&&(s[s.length-1]-=1)}return{syntaxHash:i.digest("hex"),shapeHash:o.digest("hex")}}function zL(e,t){if(e!==Y.SyntaxKind.StringLiteral||t.length<2)return!1;let n=t.slice(1,-1);return n.startsWith("/")||n.includes("://")}function KL(e,t,n,r){return e?e(t,r,{file:n}):r()}function JL(e,t){return t?at(e)?/<script\b/iu.test(t):ue(e)!==null:!1}function XL(e){let t=new Map(Xl.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 YL(e){return e.replaceAll("\\","/").replace(/^\.\//u,"")}function QL(e){let t=new Map;for(let n of Hs){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=iD(i,n.keyNames);if(!o)continue;let s=o.map(d=>`${d.name}=${Fh(d.name,d.value)}`).join("\0"),a=i.sourceScope==="production"?"production":i.sourceScope,c=`${n.id}\0${a}\0${s}`,l=`boundary-group:${Wi("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(ZL).sort(sD)}function ZL(e){return{...e,producerIds:Gs(e.producerIds),consumerIds:Gs(e.consumerIds),declarationIds:Gs(e.declarationIds),derivation:{...e.derivation,inputFactIds:Gs(e.derivation.inputFactIds),sourceSpans:[...new Map(e.derivation.sourceSpans.map(t=>[`${t.file}:${t.startLine}:${t.endLine}`,t])).values()]}}}function eD(e,t){let n=new Map(e.map(i=>[i.id,i])),r=new Map;for(let i of t){let o=Hs.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>TL))for(let a of s)for(let c of i.consumerIds){let l=n.get(a),u=n.get(c);if(!l||!u||oD(l,u))continue;let d=l.strength==="derived"||u.strength==="derived"?"derived":"exact",p=`${i.joinRule}\0${a}\0${c}`,f={id:`boundary-link:${Wi("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(aD)}function tD(e,t){let n=new Set(t.filter(Ch).flatMap(Vs)),r=new Set(t.filter(rD).flatMap(Vs));for(let i of e)i.resolution=n.has(i.id)?"locally-linked":r.has(i.id)?"ambiguous":"unresolved"}function nD(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(Vs)),i=new Set(t.filter(Ch).flatMap(Vs));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 Vs(e){return[...e.producerIds,...e.consumerIds,...e.declarationIds]}function Ch(e){let t=Hs.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=Hs.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 iD(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:Fh(r,i.value)})}return n}function Fh(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 oD(e,t){return e.source.file===t.source.file&&e.source.startLine===t.source.startLine}function Hi(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 Gs(e){return[...new Set(e)].sort()}function sD(e,t){return e.joinRule.localeCompare(t.joinRule)||e.normalizedKey.localeCompare(t.normalizedKey)}function aD(e,t){return e.joinRule.localeCompare(t.joinRule)||e.from.localeCompare(t.from)||e.to.localeCompare(t.to)}import cD from"better-sqlite3";var Us="scip_query_runtime_boundaries",Bn="scip_query_runtime_observations",zs="scip_query_runtime_relation_groups",Ks="scip_query_runtime_relation_participants";function lD(e,t){let n=new cD(e);try{n.exec(`
403
+ CREATE TABLE IF NOT EXISTS ${Us} (
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
+ `),dD(n),n.transaction(()=>{n.prepare(`INSERT OR REPLACE INTO ${Us} (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 ${Ks}`).run(),n.prepare(`DELETE FROM ${zs}`).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 ${zs} (id, protocol, join_rule, normalized_key, payload) VALUES (?, ?, ?, ?, ?)`),o=n.prepare(`INSERT INTO ${Ks} (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 uD(e,t={}){if(!pD(e,Bn))return Th(e)?.observations??[];let n=[],r=[];return qs(n,r,"protocol",t.protocols),qs(n,r,"action",t.actions),qs(n,r,"source_scope",t.sourceScopes),qs(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=>fD(o.payload))}function dD(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 ${zs} (
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 ${zs}(protocol, join_rule, normalized_key);
440
+
441
+ CREATE TABLE IF NOT EXISTS ${Ks} (
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 ${Ks}(observation_id, participant_role);
449
+ `)}function pD(e,t){return!!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",t)}function qs(e,t,n,r){!r||r.length===0||(e.push(`${n} IN (${r.map(()=>"?").join(", ")})`),t.push(...r))}function fD(e){try{return[JSON.parse(e)]}catch{return[]}}function Th(e){if(!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",Us))return null;let n=e.get(`SELECT schema_version, payload FROM ${Us} 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 su,randomUUID as jh}from"crypto";import{closeSync as yD,existsSync as Ot,fstatSync as hD,lstatSync as Pr,mkdirSync as SD,openSync as bD,readdirSync as nn,readSync as xD,renameSync as au,rmSync as rt}from"fs";import{basename as Rr,dirname as cu,join as A}from"path";function Nh(e){return Js(e,mD)}function Az(e){return Js(e,gD)}function Js(e,t){return Array.isArray(e)?`[${e.map(n=>Js(n,t)).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([n],[r])=>t(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${Js(r,t)}`).join(",")}}`:JSON.stringify(e)}function mD(e,t){return e.localeCompare(t)}function gD(e,t){return e<t?-1:e>t?1:0}var lu=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},Bh=".owner.json",uu={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function Uz(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 Ys(e){let t=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(n=>ge(n));return W(...t)}function zz(e,t){return su("sha256").update(Nh({namespace:e,payload:t})).digest("hex")}function $h(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function Kz(e,t,n={}){let r=wr(n.limits),i=n.nowMs??Date.now(),o=Ys(e);return LD(t),pu(e,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??Nt,n.durability??"durable",()=>{du(e,i,r);let s=A(e.pendingDir,`${t.id}.json`),a=A(e.responseDir,`${t.id}.json`),c=kh(e,t.id);if(c){let p=Lh(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=Ui(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=is(s,l,{durability:p}),g=p==="durable"?W(o,f.directorySync):"not-requested";return{disposition:"accepted",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:t.deadlineAtMs,achievedDurability:f.achievedDurability,directorySync:g}}catch(p){if(p.code!=="EEXIST")throw p;let f=kh(e,t.id);if(!f)throw p;let g=Lh(f,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:g.deadlineAtMs??t.deadlineAtMs}}})}function ID(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=Ys(e);try{return pu(e,r,2e3,t.monotonicNow??Nt,t.durability??"durable",()=>ED(e,t.ownerId,n,r,t.liveness??uu,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 Jz(e,t){return!Oh(e.pendingDir)&&!Oh(e.legacyRequestDir)?[]:ID(e,t)}function ED(e,t,n,r,i,o,s,a,c){du(e,n,r,i);let l=A(e.inflightDir,Xs(t)),u=[...Dh(e.pendingDir,!1),...Dh(e.legacyRequestDir,!0)].sort((f,g)=>f.orderAtMs-g.orderAtMs||f.header.id.localeCompare(g.header.id)||f.path.localeCompare(g.path)),d=a==="durable"?s:"not-requested";u.length>0&&(a==="durable"?d=W(d,ge(l)):SD(l,{recursive:!0}),c?.("after-owner-directory-durable"),_D(l,t,o,a),c?.("after-owner-record-published"));let p=[];for(let f of u){if(p.length>=r.maxBatch)break;let g=A(e.responseDir,`${f.header.id}.json`);if(Ot(g)){rt(f.path,{force:!0});continue}let y=Math.max(n+r.claimLeaseMs,(f.header.deadlineAtMs??n)+5e3),m=`${Xs(f.originalFile)}.${y}.claim`,S=A(l,m);try{au(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(cu(f.path)):"not-requested";c?.("after-source-directory-synced");let v=a==="durable"?D(l):"not-requested";c?.("after-destination-directory-synced");let E=W(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 Xz(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 RD(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)+Gh),a={mailboxVersion:lu,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=Ui(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&&(wD(e,i).removed>0&&(u=Ui(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(CD(e,t,c,p),r.onAfterResponsePublished?.(),rt(t.path,{force:!0}),p==="durable"){let f=cu(t.path);D(Ot(f)?f:e.inflightDir)}}var Gh=3e4,PD=4096;function wD(e,t){let n={removed:0,bytesFreed:0},r;try{r=nn(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=bD(o,"r");try{a=hD(d).size;let p=Buffer.alloc(Math.min(PD,a));xD(d,p,0,p.length,0),s=p.toString("utf8")}finally{yD(d)}}catch{continue}let c=_h(s,"expiresAtMs"),l=_h(s,"deadlineAtMs");if(c!==null&&c<=t||l!==null&&l+Gh<=t)try{rt(o,{force:!0}),n.removed+=1,n.bytesFreed+=a}catch{}}return n}function _h(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 Yz(e,t,n,r,i={}){let o=i.nowMs??Date.now(),s=wr(i.limits);if(RD(e,t,n,{...i,nowMs:o,limits:s}),!Ot(t.path)){let a=A(e.deadLetterDir,`${OD(t.requestId)}.${o}.${su("sha256").update(r).digest("hex").slice(0,12)}.json`),c={mailboxVersion:lu,requestId:t.requestId,ownerId:t.ownerId,rejectedAtMs:o,reason:r,originalFile:t.originalFile},l=Buffer.byteLength(`${JSON.stringify(c,null,2)}
452
+ `),u=Ui(e);u.totalItems<s.maxItems&&u.totalBytes+l<=s.maxBytes&&Le(a,c,{spacing:2,trailingNewline:!0})}}function Qz(e,t={}){let n=t.nowMs??Date.now(),r=wr(t.limits);return Ys(e),pu(e,r,2e3,t.monotonicNow??Nt,"durable",()=>du(e,n,r,t.liveness??uu))}function du(e,t,n,r=uu){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let s of mu(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||kD(e,s.ownerId,r)!=="dead")continue;let c=A(e.pendingDir,s.originalFile);try{au(s.path,c),i.reclaimed++}catch(l){if(l.code!=="EEXIST")throw l;rt(s.path,{force:!0})}D(cu(s.path)),D(e.pendingDir),o--}o=Ah(e.responseDir,o,(s,a)=>a+n.responseRetentionMs,t,()=>{i.responsesRemoved++}),o=Ah(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 Hh(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 DD(e.inflightDir),i}function Ui(e){Ys(e);let t=[...$n(e.pendingDir).map(c=>({path:c,pending:!0})),...$n(e.legacyRequestDir).map(c=>({path:c,pending:!0}))],n=mu(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=zi(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+AD(l.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function CD(e,t,n,r){let i=A(e.responseDir,`${t.requestId}.json`),o=`${JSON.stringify(n)}
453
+ `;try{is(i,o,{durability:r})}catch(s){if(s.code!=="EEXIST")throw s;let a=zi(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 pu(e,t,n,r,i,o){let s=A(e.rootDir,".admission.lock"),a=`${process.pid}-${jh()}`,c=r()+Math.max(0,n);for(;!FD(e.rootDir,s,a,i);){if(TD(s),r()>=c)throw new yt("admission-busy",Ui(e),t,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{fu(s).ownerToken===a&&(rt(s,{recursive:!0,force:!0}),i==="durable"&&D(e.rootDir))}catch{}}}function FD(e,t,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
454
+ `;try{return is(t,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{fu(t).ownerToken===n&&(rt(t,{force:!0}),r==="durable"&&D(e))}catch{}throw o}}function TD(e){let t=null;try{let r=fu(e);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(t=Number(r.pid))}catch{}if(t===null||ND(t))return;let n=`${e}.stale-${jh()}`;try{au(e,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}rt(n,{recursive:!0,force:!0})}function fu(e){try{return JSON.parse(T(e,"mailbox lock record"))}catch(t){if(t.code!=="EISDIR"&&!(t instanceof ot&&t.reason==="not-regular"))throw t;return JSON.parse(T(A(e,"owner.json"),"mailbox lock owner record"))}}function ND(e){try{return process.kill(e,0),!0}catch(t){let n=t.code;return n==="EPERM"||n!=="ESRCH"}}function _D(e,t,n,r){let i=A(e,Bh),o=n.processIdentity,s=Vh(i);if(s&&s.ownerId===t&&s.pid===n.pid&&(!s.processIdentity&&!o||s.processIdentity&&o&&ke(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"?Le(i,a):Yt(i,a)}function kD(e,t,n){let r=Vh(A(e.inflightDir,Xs(t),Bh));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?ke(r.processIdentity,i)?"live":"dead":"unknown"}function Vh(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 kh(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 mu(e.inflightDir))if(n.requestId===t)return n.path;return null}function Lh(e,t,n){let r=zi(e);if(r?.operationKey===t)return r;if(Rr(e)===`${$h(t)}.json`)return{id:n,operationKey:t};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function LD(e){if(e.mailboxVersion!==lu||e.id!==$h(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 Dh(e,t){return $n(e).filter(n=>n.endsWith(".json")).map(n=>{let r=Pr(n),i=Rr(n,".json"),o=zi(n)??{id:i};return{path:n,originalFile:Rr(n),header:o,byteLength:r.size,orderAtMs:o.enqueuedAtMs??r.mtimeMs,legacy:t}})}function mu(e){if(!Ot(e))return[];let t=[];for(let n of nn(e,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=Mh(n.name);if(r===null)continue;let i=A(e,n.name);for(let o of nn(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=Mh(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=zi(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 zi(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 Ah(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)?nn(e,{withFileTypes:!0}).filter(t=>t.isFile()).map(t=>A(e,t.name)).sort():[]}function Oh(e){try{return nn(e).some(t=>t.endsWith(".json"))}catch{return!1}}function Hh(e){if(!Ot(e))return[];let t=[];for(let n of nn(e,{withFileTypes:!0})){let r=A(e,n.name);n.isFile()?t.push(r):n.isDirectory()&&t.push(...Hh(r))}return t.sort()}function DD(e){if(Ot(e))for(let t of nn(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let n=A(e,t.name);nn(n).some(r=>r.endsWith(".claim"))||rt(n,{recursive:!0,force:!0})}}function AD(e){try{return Pr(e).size}catch{return 0}}function Xs(e){return Buffer.from(e,"utf8").toString("base64url")}function Mh(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return Xs(t)===e?t:null}catch{return null}}function OD(e){return/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)?e:`invalid-${su("sha256").update(e).digest("hex")}`}export{Mt as a,wu as b,Cr as c,Yi as d,Fr as e,VD as f,Xh as g,H as h,Gt as i,Z as j,ln as k,Ae as l,Ee as m,ne as n,un as o,ae as p,_S as q,ot as r,ee as s,j as t,T as u,kS as v,LS as w,dn as x,MD as y,jD as z,Xe as A,jA as B,_r as C,VS as D,HS as E,BA as F,$A as G,zS as H,QS as I,yd as J,GA as K,ao as L,Re as M,uo as N,Ed as O,Rd as P,tO as Q,Pd as R,wd as S,nO as T,aO as U,bt as V,Un as W,ge as X,D as Y,W as Z,Xi as _,Pa as $,go as aa,yo as ba,wa as ca,EO as da,Ea as ea,RO as fa,PO as ga,Fa as ha,bn as ia,yx as ja,Jn as ka,xo as la,hx as ma,tp as na,Br as oa,Vt as pa,Ix as qa,Ex as ra,Rx as sa,Xn as ta,UO as ua,zO as va,Yn as wa,ht as xa,Zi as ya,WD as za,w as Aa,qD as Ba,UD as Ca,zD as Da,ku as Ea,eo as Fa,JD as Ga,on as Ha,jt as Ia,tA as Ja,Lu as Ka,Zh as La,nA as Ma,Vn as Na,Au as Oa,C as Pa,it as Qa,Bt as Ra,dS as Sa,U as Ta,me as Ua,St as Va,fA as Wa,mA as Xa,gA as Ya,yA as Za,hA as _a,SA as $a,ye as ab,op as bb,yp as cb,lv as db,Zn as eb,st as fb,Wt as gb,Be as hb,$t as ib,id as jb,od as kb,sd as lb,wS as mb,PA as nb,z as ob,ad as pb,io as qb,ce as rb,ap as sb,te as tb,F as ub,aM as vb,Vr as wb,jx as xb,cM as yb,lM as zb,le as Ab,Ya as Bb,$M as Cb,GM as Db,Qa as Eb,ue as Fb,at as Gb,qr as Hb,he as Ib,$e as Jb,Np as Kb,vn as Lb,YM as Mb,QM as Nb,M as Ob,yj as Pb,Up as Qb,be as Rb,uc as Sb,QI as Tb,ZI as Ub,Qr as Vb,rE as Wb,iE as Xb,bM as Yb,gp as Zb,Me as _b,xM as $b,C0 as ac,PR as bc,Uo as cc,i$ as dc,ct as ec,de as fc,zo as gc,m$ as hc,g$ as ic,R$ as jc,ur as kc,P$ as lc,w$ as mc,C$ as nc,ew as oc,F$ as pc,Jo as qc,Ze as rc,xe as sc,Jt as tc,ve as uc,Nn as vc,wc,dr as xc,Uf as yc,N$ as zc,_$ as Ac,k$ as Bc,L$ as Cc,Cc as Dc,Fc as Ec,iG as Fc,B as Gc,oG as Hc,Pw as Ic,sG as Jc,aG as Kc,cG as Lc,Nw as Mc,pr as Nc,lG as Oc,qq as Pc,Ly as Qc,Ls as Rc,Mn as Sc,nt as Tc,r1 as Uc,i1 as Vc,o1 as Wc,ts as Xc,Zo as Yc,Dc as Zc,OG as _c,SG as $c,zw as ad,bG as bd,xG as cd,TG as dd,NG as ed,Lc as fd,Ac as gd,um as hd,pm as id,Oc as jd,e1 as kd,IC as ld,EC as md,t1 as nd,RC as od,PC as pd,p1 as qd,Mc as rd,eu as sd,$i as td,qi as ud,NL as vd,lD as wd,uD as xd,Th as yd,h1 as zd,hm as Ad,S1 as Bd,Sm as Cd,T1 as Dd,VC as Ed,Bc as Fd,N1 as Gd,qC as Hd,UC as Id,_1 as Jd,k1 as Kd,L1 as Ld,kn as Md,Ft as Nd,ke as Od,Tt as Pd,Nt as Qd,V1 as Rd,Nh as Sd,Az as Td,Vc as Ud,is as Vd,Yt as Wd,Le as Xd,lu as Yd,yt as Zd,Uz as _d,Ys as $d,zz as ae,$h as be,Kz as ce,Jz as de,Xz as ee,RD as fe,Yz as ge,Qz as he,Ui as ie,Py as je,lV as ke,uV as le,dV as me,pV as ne,oe,TF as pe,ss as qe,LF as re,bV as se,xV as te,_V as ue,ui as ve,WV as we,qV as xe,UV as ye,zV as ze,KV as Ae,XV as Be,YV as Ce,ds as De,qm as Ee,ps as Fe,fs as Ge,hr as He,tT as Ie,Xm as Je,_t as Ke,pH as Le,RH as Me,sg as Ne,DH as Oe,Ss as Pe,WH as Qe,iW as Re,oW as Se,mW as Te,gW as Ue,yW as Ve,et as We,xi as Xe,Is as Ye,PW as Ze,DW as _e,AW as $e,OW as af,Ug as bf,n_ as cf,KW as df,JW as ef,Rs as ff,Fs as gf,Cq as hf,fy as if,Fq as jf,Dt as kf,ry as lf,my as mf,Fi as nf,Tq as of,Nq as pf,_q as qf,Dl as rf,oy as sf,Ns as tf,Gq as uf,Ai as vf,Vq as wf};
455
+ //# sourceMappingURL=chunk-66DVSJQG.js.map