scip-query 0.16.0 → 0.17.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 (246) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +40 -9
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/{chunk-WN6XEYVX.js → chunk-27YDE22N.js} +2 -2
  5. package/dist/{chunk-VLSI5MYU.js → chunk-2DBY4MO7.js} +2 -2
  6. package/dist/{chunk-YSUD2S7T.js → chunk-2HCWAL42.js} +2 -2
  7. package/dist/{chunk-YCVYOV4A.js → chunk-34RCSYMZ.js} +2 -2
  8. package/dist/{chunk-3LAKH6BV.js → chunk-3CJXFMR5.js} +2 -2
  9. package/dist/{chunk-2EU6WVR3.js → chunk-3EBDPBBU.js} +2 -2
  10. package/dist/{chunk-6EVORGCB.js → chunk-42YU6TEB.js} +2 -2
  11. package/dist/{chunk-3YAZH3JU.js → chunk-45QWQSWS.js} +2 -2
  12. package/dist/{chunk-5XDNFOAH.js → chunk-4FLF7BHJ.js} +2 -2
  13. package/dist/{chunk-JRFCWCOD.js → chunk-4L4X66GE.js} +2 -2
  14. package/dist/{chunk-NLRWGGPY.js → chunk-5CJ6AQN7.js} +2 -2
  15. package/dist/{chunk-CM4EZLW4.js → chunk-5GAUXLOE.js} +2 -2
  16. package/dist/{chunk-QB7NRST4.js → chunk-5N5ZC566.js} +2 -2
  17. package/dist/{chunk-P5QZILZ4.js → chunk-5ODF4JGH.js} +2 -2
  18. package/dist/{chunk-OYGKBDAD.js → chunk-6G3GQWTK.js} +2 -2
  19. package/dist/{chunk-IRIM3SUR.js → chunk-75H6GOND.js} +2 -2
  20. package/dist/{chunk-VSQRU3AP.js → chunk-7CHIAMKS.js} +2 -2
  21. package/dist/{chunk-L27UIF3E.js → chunk-7MT6UM4D.js} +2 -2
  22. package/dist/{chunk-OO6S4ECV.js → chunk-7XP7ZRSI.js} +2 -2
  23. package/dist/{chunk-5TVNLPUM.js → chunk-7Z5UT44B.js} +2 -2
  24. package/dist/{chunk-A46JTKTM.js → chunk-A4KRWTXD.js} +2 -2
  25. package/dist/{chunk-BFWVHD2P.js → chunk-ABRWGVC6.js} +2 -2
  26. package/dist/{chunk-7II7NFRV.js → chunk-AQ34B63A.js} +2 -2
  27. package/dist/{chunk-EVCSXWER.js → chunk-BBBZB5WY.js} +2 -2
  28. package/dist/{chunk-MZB3DTHW.js → chunk-BGUYAA3Q.js} +2 -2
  29. package/dist/{chunk-ZHGUZKJL.js → chunk-CMLHZWRS.js} +2 -2
  30. package/dist/{chunk-3I34FZ6R.js → chunk-CYDOV3AQ.js} +2 -2
  31. package/dist/{chunk-GWWYLYD3.js → chunk-DQYG5JHT.js} +2 -2
  32. package/dist/{chunk-W3ZVRLCH.js → chunk-EPDV3SQD.js} +2 -2
  33. package/dist/{chunk-U6BJVXWQ.js → chunk-GRHA5NGF.js} +2 -2
  34. package/dist/{chunk-YD37KSEK.js → chunk-H4SMB657.js} +2 -2
  35. package/dist/{chunk-XBPAJASV.js → chunk-H4T2AST4.js} +2 -2
  36. package/dist/{chunk-SOCS3467.js → chunk-HGO3D2JD.js} +2 -2
  37. package/dist/{chunk-RLB7FZKR.js → chunk-HV4N3UBV.js} +2 -2
  38. package/dist/{chunk-VZCR3VQY.js → chunk-IK2NG76R.js} +2 -2
  39. package/dist/{chunk-CS3FXTUC.js → chunk-J4HK7PQS.js} +2 -2
  40. package/dist/{chunk-QSNG3NHQ.js → chunk-J7WYG63U.js} +2 -2
  41. package/dist/{chunk-7RAS466A.js → chunk-JJAH2VLD.js} +2 -2
  42. package/dist/{chunk-NLVKD45E.js → chunk-JLZUM476.js} +2 -2
  43. package/dist/{chunk-JQ2PCFZW.js → chunk-JUADXGUH.js} +2 -2
  44. package/dist/{chunk-DKK2H4D7.js → chunk-JVTMRIKU.js} +2 -2
  45. package/dist/{chunk-YFEJIYWH.js → chunk-JYBF5CPE.js} +2 -2
  46. package/dist/{chunk-S5RZQA6V.js → chunk-K3UVTL3J.js} +2 -2
  47. package/dist/{chunk-363TZ64I.js → chunk-KAOWSWEX.js} +2 -2
  48. package/dist/{chunk-RPMT6MTX.js → chunk-KLFCCRI7.js} +2 -2
  49. package/dist/{chunk-6GZ7LM7S.js → chunk-KO2TFDIP.js} +2 -2
  50. package/dist/{chunk-S5MTSES5.js → chunk-KTZACYL6.js} +2 -2
  51. package/dist/{chunk-6DNE65QS.js → chunk-KYUYAWKA.js} +2 -2
  52. package/dist/{chunk-PCCMMI2M.js → chunk-KZ2LZBQT.js} +2 -2
  53. package/dist/chunk-L7UITWFE.js +120 -0
  54. package/dist/{chunk-CVBS2FD4.js → chunk-LC57FSPX.js} +2 -2
  55. package/dist/{chunk-S3IXCXW2.js → chunk-LG33DNTZ.js} +2 -2
  56. package/dist/chunk-M2TRDR25.js +84 -0
  57. package/dist/{chunk-2Y7YX54K.js → chunk-MVFNACWB.js} +2 -2
  58. package/dist/{chunk-Q65QYKU7.js → chunk-NJBARXRO.js} +2 -2
  59. package/dist/{chunk-5UKDCXVC.js → chunk-OP5JXGDV.js} +2 -2
  60. package/dist/{chunk-SEEJPIWG.js → chunk-OP5RO2CF.js} +2 -2
  61. package/dist/{chunk-EBSSCVR4.js → chunk-OQRMCT2N.js} +5 -5
  62. package/dist/{chunk-CKIAEVGM.js → chunk-PA2MQKXD.js} +2 -2
  63. package/dist/{chunk-XC6PUFNN.js → chunk-PVXSHZLW.js} +2 -2
  64. package/dist/{chunk-AAMZRDJT.js → chunk-PYOZHG6A.js} +2 -2
  65. package/dist/{chunk-G4KQ7S74.js → chunk-QEIGJJBC.js} +2 -2
  66. package/dist/{chunk-DA34GNNO.js → chunk-QNCVN5EH.js} +2 -2
  67. package/dist/chunk-RSZ4KX4B.js +7 -0
  68. package/dist/{chunk-HGUNWXJX.js → chunk-RUQE7DZT.js} +2 -2
  69. package/dist/{chunk-VYQY75NA.js → chunk-RZEVUYMG.js} +2 -2
  70. package/dist/chunk-SMBIGBGN.js +67 -0
  71. package/dist/{chunk-AMPN2VMF.js → chunk-SREWDA7Q.js} +2 -2
  72. package/dist/{chunk-S2FZILCF.js → chunk-TAB7AWKO.js} +2 -2
  73. package/dist/{chunk-UO4IADXJ.js → chunk-TCOWAGR2.js} +2 -2
  74. package/dist/{chunk-BVHP2B4D.js → chunk-TL2IXVGH.js} +2 -2
  75. package/dist/{chunk-MCNWCJYL.js → chunk-TLTLJ4SW.js} +2 -2
  76. package/dist/{chunk-JXAJDINF.js → chunk-TR7C5HOC.js} +2 -2
  77. package/dist/{chunk-3OPIMH42.js → chunk-U244OVE6.js} +2 -2
  78. package/dist/chunk-U3JW5AYG.js +2 -0
  79. package/dist/{chunk-2HFXPIBT.js → chunk-UWR52GNZ.js} +2 -2
  80. package/dist/{chunk-62Y3PC27.js → chunk-VCOAUTSI.js} +2 -2
  81. package/dist/{chunk-BVUA3GZC.js → chunk-VCRMI56V.js} +2 -2
  82. package/dist/{chunk-753JWTUH.js → chunk-VDHEX6YO.js} +2 -2
  83. package/dist/{chunk-RYFIRFYJ.js → chunk-VPVAQRHM.js} +2 -2
  84. package/dist/{chunk-RQWNF2RM.js → chunk-VT2KFEPG.js} +2 -2
  85. package/dist/{chunk-LT6AHYVY.js → chunk-WH65EY7U.js} +2 -2
  86. package/dist/{chunk-HLRWOFXC.js → chunk-X566NT42.js} +2 -2
  87. package/dist/{chunk-ZEKBAMCN.js → chunk-XKWEMFHP.js} +2 -2
  88. package/dist/{chunk-KI4WPR7Q.js → chunk-Y3DG4J6A.js} +2 -2
  89. package/dist/{chunk-KP2DJY7D.js → chunk-Y5BOEWAE.js} +2 -2
  90. package/dist/{chunk-2LGPMYS2.js → chunk-YD7GGLGE.js} +2 -2
  91. package/dist/{chunk-K32ZOW3P.js → chunk-ZMD4O5UP.js} +2 -2
  92. package/dist/cli.js +321 -303
  93. package/dist/{config-types-SVkUIufk.d.ts → config-types-70s7NxKB.d.ts} +2 -0
  94. package/dist/{db-CS0TuVH6.d.ts → db-BBmJ0v3b.d.ts} +1 -1
  95. package/dist/{health-Btal3mQi.d.ts → health-CWpFL_6z.d.ts} +1 -1
  96. package/dist/index.d.ts +3 -3
  97. package/dist/index.js +1 -1
  98. package/dist/queries/affected.d.ts +2 -2
  99. package/dist/queries/affected.js +1 -1
  100. package/dist/queries/bottlenecks.d.ts +2 -2
  101. package/dist/queries/bottlenecks.js +1 -1
  102. package/dist/queries/by-kind.d.ts +2 -2
  103. package/dist/queries/by-kind.js +1 -1
  104. package/dist/queries/call-graph.d.ts +2 -2
  105. package/dist/queries/call-graph.js +1 -1
  106. package/dist/queries/change-surface.d.ts +2 -2
  107. package/dist/queries/change-surface.js +1 -1
  108. package/dist/queries/cleanup-plan.d.ts +2 -2
  109. package/dist/queries/cleanup-plan.js +1 -1
  110. package/dist/queries/co-change.d.ts +2 -2
  111. package/dist/queries/co-change.js +1 -1
  112. package/dist/queries/code.d.ts +2 -2
  113. package/dist/queries/code.js +1 -1
  114. package/dist/queries/complexity-hotspots.d.ts +2 -2
  115. package/dist/queries/complexity-hotspots.js +1 -1
  116. package/dist/queries/complexity.d.ts +2 -2
  117. package/dist/queries/complexity.js +1 -1
  118. package/dist/queries/convergence.d.ts +2 -2
  119. package/dist/queries/convergence.js +1 -1
  120. package/dist/queries/coupling.d.ts +2 -2
  121. package/dist/queries/coupling.js +1 -1
  122. package/dist/queries/cycles.d.ts +2 -2
  123. package/dist/queries/cycles.js +1 -1
  124. package/dist/queries/dataflow.d.ts +2 -2
  125. package/dist/queries/dataflow.js +1 -1
  126. package/dist/queries/dead.d.ts +2 -2
  127. package/dist/queries/dead.js +1 -1
  128. package/dist/queries/decorative-checkers.d.ts +2 -2
  129. package/dist/queries/decorative-checkers.js +1 -1
  130. package/dist/queries/deep-chains.d.ts +2 -2
  131. package/dist/queries/deep-chains.js +1 -1
  132. package/dist/queries/deps.d.ts +2 -2
  133. package/dist/queries/deps.js +1 -1
  134. package/dist/queries/diff-gate.d.ts +2 -2
  135. package/dist/queries/diff-gate.js +1 -1
  136. package/dist/queries/diff-impact.d.ts +2 -2
  137. package/dist/queries/diff-impact.js +1 -1
  138. package/dist/queries/doc-drift.d.ts +2 -2
  139. package/dist/queries/doc-drift.js +1 -1
  140. package/dist/queries/drift.d.ts +2 -2
  141. package/dist/queries/drift.js +1 -1
  142. package/dist/queries/duplicate-bodies.d.ts +2 -2
  143. package/dist/queries/duplicate-bodies.js +1 -1
  144. package/dist/queries/extract-candidates.d.ts +2 -2
  145. package/dist/queries/extract-candidates.js +1 -1
  146. package/dist/queries/fan.d.ts +2 -2
  147. package/dist/queries/fan.js +1 -1
  148. package/dist/queries/files.d.ts +2 -2
  149. package/dist/queries/health.d.ts +3 -3
  150. package/dist/queries/health.js +1 -1
  151. package/dist/queries/hierarchy.d.ts +2 -2
  152. package/dist/queries/hierarchy.js +1 -1
  153. package/dist/queries/hotspots.d.ts +2 -2
  154. package/dist/queries/hotspots.js +1 -1
  155. package/dist/queries/imports.d.ts +2 -2
  156. package/dist/queries/imports.js +1 -1
  157. package/dist/queries/incomplete-migration.d.ts +2 -2
  158. package/dist/queries/incomplete-migration.js +1 -1
  159. package/dist/queries/index.d.ts +3 -3
  160. package/dist/queries/index.js +1 -1
  161. package/dist/queries/isolated.d.ts +2 -2
  162. package/dist/queries/isolated.js +1 -1
  163. package/dist/queries/locality-candidates.d.ts +2 -2
  164. package/dist/queries/locality-candidates.js +1 -1
  165. package/dist/queries/members.d.ts +2 -2
  166. package/dist/queries/members.js +1 -1
  167. package/dist/queries/methods.d.ts +2 -2
  168. package/dist/queries/methods.js +1 -1
  169. package/dist/queries/not-implemented.d.ts +2 -2
  170. package/dist/queries/not-implemented.js +1 -1
  171. package/dist/queries/outline.d.ts +2 -2
  172. package/dist/queries/outline.js +1 -1
  173. package/dist/queries/passthrough-candidates.d.ts +2 -2
  174. package/dist/queries/passthrough-candidates.js +1 -1
  175. package/dist/queries/plan-context.d.ts +2 -2
  176. package/dist/queries/plan-context.js +1 -1
  177. package/dist/queries/react-component-duplicates.d.ts +2 -2
  178. package/dist/queries/react-component-duplicates.js +1 -1
  179. package/dist/queries/react-hook-candidates.d.ts +2 -2
  180. package/dist/queries/react-hook-candidates.js +1 -1
  181. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  182. package/dist/queries/react-large-component-pressure.js +1 -1
  183. package/dist/queries/recent-duplicates.d.ts +2 -2
  184. package/dist/queries/recent-duplicates.js +1 -1
  185. package/dist/queries/redundant-reexports.d.ts +2 -2
  186. package/dist/queries/redundant-reexports.js +1 -1
  187. package/dist/queries/refs.d.ts +2 -2
  188. package/dist/queries/refs.js +1 -1
  189. package/dist/queries/self-audit.d.ts +2 -2
  190. package/dist/queries/self-audit.js +1 -1
  191. package/dist/queries/similar-chains.d.ts +2 -2
  192. package/dist/queries/similar-chains.js +1 -1
  193. package/dist/queries/similar-files.d.ts +2 -2
  194. package/dist/queries/similar-files.js +1 -1
  195. package/dist/queries/similar-signatures.d.ts +2 -2
  196. package/dist/queries/similar-signatures.js +1 -1
  197. package/dist/queries/similar.d.ts +2 -2
  198. package/dist/queries/similar.js +1 -1
  199. package/dist/queries/slice.d.ts +2 -2
  200. package/dist/queries/slice.js +1 -1
  201. package/dist/queries/stale-abstractions.d.ts +2 -2
  202. package/dist/queries/stale-abstractions.js +1 -1
  203. package/dist/queries/stats.d.ts +2 -2
  204. package/dist/queries/surface.d.ts +2 -2
  205. package/dist/queries/surface.js +1 -1
  206. package/dist/queries/symbols.d.ts +2 -2
  207. package/dist/queries/symbols.js +1 -1
  208. package/dist/queries/system.d.ts +2 -2
  209. package/dist/queries/system.js +1 -1
  210. package/dist/queries/test-quality.d.ts +2 -2
  211. package/dist/queries/test-quality.js +1 -1
  212. package/dist/queries/trace.d.ts +2 -2
  213. package/dist/queries/trace.js +1 -1
  214. package/dist/queries/twin-ab.d.ts +2 -2
  215. package/dist/queries/twin-ab.js +1 -1
  216. package/dist/queries/twin-drift.d.ts +2 -2
  217. package/dist/queries/twin-drift.js +1 -1
  218. package/dist/queries/unused-imports.d.ts +2 -2
  219. package/dist/queries/unused-imports.js +1 -1
  220. package/dist/queries/unused-params.d.ts +2 -2
  221. package/dist/queries/unused-params.js +1 -1
  222. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  223. package/dist/queries/vue-component-duplicates.js +1 -1
  224. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  225. package/dist/queries/vue-composable-candidates.js +1 -1
  226. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  227. package/dist/queries/vue-large-view-pressure.js +1 -1
  228. package/dist/queries/wrapper-candidates.d.ts +2 -2
  229. package/dist/queries/wrapper-candidates.js +1 -1
  230. package/dist/reindex-worker.js +26 -26
  231. package/dist/reindex.d.ts +3 -3
  232. package/dist/reindex.js +38 -34
  233. package/dist/runtime.d.ts +3 -3
  234. package/dist/runtime.js +1 -2
  235. package/dist/{scip-cli-BKL-26TZ.d.ts → scip-cli-CoMzb7Zu.d.ts} +1 -1
  236. package/dist/watch-server.js +4 -4
  237. package/docs/COMMAND_REFERENCE.md +1 -1
  238. package/package.json +1 -1
  239. package/skills/_shared/SKILL.md +2 -2
  240. package/skills/scip-calibrate/SKILL.md +5 -4
  241. package/skills/scip-verify/SKILL.md +3 -2
  242. package/dist/chunk-5P26M63Y.js +0 -2
  243. package/dist/chunk-FFIYGYQR.js +0 -67
  244. package/dist/chunk-WFRZGMWJ.js +0 -71
  245. package/dist/chunk-XAEU4ROB.js +0 -101
  246. package/dist/chunk-Y42DMR6F.js +0 -6
@@ -0,0 +1,120 @@
1
+ import{a as Pn,b as x,c as dt,d as kn,e as Ce,f as Rn,g as Nn}from"./chunk-SMBIGBGN.js";import{a as B,b as k}from"./chunk-3M2UCPFS.js";import{a as er,b as tr,e as rr}from"./chunk-JHK2DMUQ.js";import{spawn as bs}from"child_process";import{closeSync as xs,existsSync as vs,mkdirSync as Is,openSync as Es,readFileSync as sr,rmSync as Le,writeFileSync as ws}from"fs";import{dirname as Cs,join as nr,resolve as ar}from"path";import{fileURLToPath as qd}from"url";var Ts=3,Ps=5e3,ks="watch.lock",Rs="watch-state.json",Ns="watch-activity.json";var _s=2e3,Ds=10;function As(e){return{lockPath:nr(e,ks),statePath:nr(e,Rs),activityPath:nr(e,Ns)}}function js(e){let t=e.runtime??An,r=As(e.cacheDir),n=Fs(r.statePath),i=Me(r.lockPath);return{classification:Ls(n,{projectRoot:ar(e.projectRoot),cliVersion:e.cliVersion},t.now(),t.isProcessAlive),lock:i,lockIsLive:i!==null&&t.isProcessAlive(i.pid),paths:r}}function Jd(e){let t=e.runtime??An,r=js(e),n=Ms("stop",r.classification);return n.kind==="signal-stop"?(_n(n.state.pid,e,t),ir(r.paths,n.state.pid,t),{disposition:"stopped",pid:n.state.pid}):n.kind==="clean-stale"?(ir(r.paths,n.state.pid,t),{disposition:"stopped",pid:n.state.pid}):n.kind==="already-stopped"&&r.lockIsLive&&r.lock?(_n(r.lock.pid,e,t),ir(r.paths,r.lock.pid,t),{disposition:"stopped",pid:r.lock.pid}):{disposition:"already-stopped"}}function Fs(e){try{return Os(JSON.parse(sr(e,"utf8")))}catch{return null}}function Kd(e,t){k(e,t)}function Xd(e){try{let t=JSON.parse(sr(e,"utf8"));return t.version!==1||!I(t.at)||t.refreshRequestedAt!==void 0&&!I(t.refreshRequestedAt)||t.refreshDetail!==void 0&&typeof t.refreshDetail!="string"?null:{atMs:Date.parse(t.at),...t.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(t.refreshRequestedAt)},...t.refreshDetail===void 0?{}:{refreshDetail:t.refreshDetail}}}catch{return null}}function Qd(e,t,r={}){let n=r.pid??process.pid,i=r.isProcessAlive??B,o=()=>{},s=Me(e);if(s&&i(s.pid))return{acquired:!1,lockPath:e,message:Dn(e,t,s),release:o};s&&Le(e,{force:!0}),Is(Cs(e),{recursive:!0});let a;try{a=Es(e,"wx")}catch(p){if($s(p)==="EEXIST")return{acquired:!1,lockPath:e,message:Dn(e,t,Me(e)),release:o};throw p}let c={version:1,pid:n,projectRoot:ar(t),startedAt:(r.now??(()=>new Date))().toISOString()};ws(a,`${JSON.stringify(c)}
2
+ `);let l=!1;return{acquired:!0,lockPath:e,message:"",release:()=>{if(l)return;l=!0,xs(a);let p=Me(e);p?.pid===c.pid&&p.startedAt===c.startedAt&&Le(e,{force:!0})}}}function Me(e){try{let t=JSON.parse(sr(e,"utf-8"));return t.version!==1||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||!I(t.startedAt)?null:t}catch{return null}}function Os(e){if(!e||typeof e!="object")return null;let t=e;return t.version!==1||typeof t.protocolVersion!="number"||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||typeof t.cliVersion!="string"||!I(t.startedAt)||!I(t.heartbeatAt)||!I(t.lastActivityAt)||!Ws(t.watcher)||t.idleDeadlineAt!==void 0&&!I(t.idleDeadlineAt)||t.lastError!==void 0&&!Gs(t.lastError)||t.lastRefresh!==void 0&&!Us(t.lastRefresh)||t.typescriptSemantic!==void 0&&!Vs(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!Bs(t.typescriptIndex)?null:t}function Ls(e,t,r,n){if(!e)return{kind:"stopped"};if(e.protocolVersion!==Ts)return{kind:"incompatible",state:e,reason:"protocol"};if(e.projectRoot!==t.projectRoot)return{kind:"incompatible",state:e,reason:"project"};if(e.cliVersion!==t.cliVersion)return{kind:"incompatible",state:e,reason:"cli-version"};if(!n(e.pid))return{kind:"stale",state:e,reason:"dead-process"};let i=Date.parse(e.heartbeatAt);return r-i>Ps?{kind:"stale",state:e,reason:"old-heartbeat"}:{kind:"live",state:e}}function Ms(e,t){switch(e){case"status":return{kind:"report",classification:t};case"ensure":switch(t.kind){case"stopped":return{kind:"start"};case"stale":return t.reason==="old-heartbeat"?{kind:"replace",state:t.state}:{kind:"start"};case"live":return{kind:"reuse",state:t.state};case"incompatible":return{kind:"replace",state:t.state};default:return or(t)}case"stop":switch(t.kind){case"stopped":return{kind:"already-stopped"};case"stale":return t.reason==="old-heartbeat"?{kind:"signal-stop",state:t.state}:{kind:"clean-stale",state:t.state};case"live":case"incompatible":return{kind:"signal-stop",state:t.state};default:return or(t)}default:return or(e)}}function Zd(e){return e.idleTimeoutMs===0||e.watcher.state!=="idle"?!1:e.nowMs-e.lastActivityAtMs>=e.idleTimeoutMs}function _n(e,t,r){if(!r.isProcessAlive(e))return;r.signalProcess(e);let n=t.stopTimeoutMs??_s,i=r.now()+n;for(;r.now()<=i;){if(!r.isProcessAlive(e))return;r.sleep(Ds)}throw new Error(`scip-query watch service pid ${e} did not stop within ${n}ms.`)}function ir(e,t,r){Le(e.statePath,{force:!0}),Le(e.activityPath,{force:!0}),Me(e.lockPath)?.pid===t&&!r.isProcessAlive(t)&&Le(e.lockPath,{force:!0})}function Dn(e,t,r){return`error: scip-query watch is already running for ${ar(t)}${r?` (pid ${r.pid}, started ${r.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function $s(e){return typeof e=="object"&&e&&"code"in e?e.code:void 0}var An={now:Date.now,isProcessAlive:B,spawnServer(e,t,r,n){if(!vs(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);bs(process.execPath,[e,t,r,JSON.stringify(n)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function I(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function Ws(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return A(t.changedFiles)&&A(t.reindexAt);case"indexing":return A(t.startedAt);case"cooldown":return A(t.until)&&typeof t.dirty=="boolean";default:return!1}}function Gs(e){if(!e||typeof e!="object")return!1;let t=e;return I(t.at)&&typeof t.message=="string"}function Us(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&I(t.startedAt)&&I(t.completedAt)&&A(t.durationMs)}function Vs(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")&&A(t.requests)&&A(t.sessionsCreated)&&A(t.sessionsReused)&&A(t.sessionsRefreshed)&&A(t.sessionsReplaced)&&A(t.projectsCreated)&&(t.lastRequestAt===void 0||I(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||I(t.busyUntil))}function Bs(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")&&le(t.requests)&&le(t.sessionsCreated)&&le(t.sessionsReplaced)&&le(t.initializations)&&le(t.programUpdates)&&le(t.documentsEmitted)&&le(t.documentsRemoved)&&(t.lastRequestAt===void 0||I(t.lastRequestAt))&&(t.lastDurationMs===void 0||A(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||I(t.busyUntil))}function A(e){return typeof e=="number"&&Number.isFinite(e)}function le(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function or(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}import{readFileSync as Hs,writeFileSync as rf,existsSync as qs,mkdirSync as zs,realpathSync as Ys}from"fs";import{isAbsolute as of,join as X,relative as sf,resolve as jn}from"path";import{createHash as Js}from"crypto";import{homedir as Ks}from"os";var cr=".scipquery.json",Xs=250,Qs=0,Zs=10*6e4,ea={enabled:!1,debounceMs:Xs,cooldownMs:Qs,gitPollMs:2e3,idleTimeoutMs:Zs,autoRefresh:!0,ignore:[]},ta=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var lf=new Set(ta);function pf(e){let t=X(e,cr);if(!qs(t))return{};try{let r=Hs(t,"utf-8");return JSON.parse(r)}catch(r){let n=r instanceof Error?r.message:String(r);throw r instanceof SyntaxError?new Error(`invalid ${cr} at ${t}: ${n}`,{cause:r}):new Error(`unable to read ${cr} at ${t}: ${n}`,{cause:r})}}function uf(e){return{...ea,...e.watch}}function ra(e,t){let r=process.env.SCIP_QUERY_CACHE_DIR;if(r)return lr(r);if(t?.dbPath)return lr(jn(e,t.dbPath));let n=pr(e);return lr(n)}function Fn(){let e=process.env.XDG_CACHE_HOME;return X(e||X(Ks(),".cache"),"scip-query")}function pr(e){let t=jn(e);try{t=Ys(t)}catch{}let r=Js("sha256").update(t).digest("hex").slice(0,12);return X(Fn(),"projects",r)}function ur(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);return X(Fn(),"repositories",e)}function dr(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function df(e,t){let r=ra(e,t);return{cacheDir:r,dbPath:X(r,"index.db"),indexPath:X(r,"index.scip"),metaPath:X(r,"meta.json")}}function lr(e){return zs(e,{recursive:!0}),e}import{createHash as na}from"crypto";import{readFileSync as ia}from"fs";import{dirname as oa,join as ft}from"path";var sa=2,aa="typescript-index";function yf(e){let t=ft(e,aa);return{rootDir:t,requestDir:ft(t,"requests"),responseDir:ft(t,"responses")}}function Sf(e){let t=JSON.parse(e);if(t.protocolVersion!==sa||typeof t.id!="string"||!t.id||typeof t.baseGeneration!="string"||!t.baseGeneration||typeof t.deadlineAtMs!="number"||!Number.isFinite(t.deadlineAtMs)||!ca(t.request))throw new Error("TypeScript index service received an invalid mailbox request.");return t}function bf(e){try{let t=JSON.parse(ia(ft(oa(e),"meta.json"),"utf8"));return t.version!==2&&t.version!==3||t.status!=="complete"||typeof t.updatedAt!="string"||t.fingerprint===void 0?null:na("sha256").update(JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages})).digest("hex")}catch{return null}}function ca(e){if(!e||typeof e!="object")return!1;let t=e,r=On(t.modifiedFiles)?t.modifiedFiles:null,n=On(t.affectedFiles)?t.affectedFiles:null;return t.kind==="emit-documents"&&typeof t.tsconfigPath=="string"&&!!t.tsconfigPath&&typeof t.projectArgument=="string"&&!!t.projectArgument&&typeof t.projectIdentity=="string"&&!!t.projectIdentity&&typeof t.producerIdentity=="string"&&!!t.producerIdentity&&r!==null&&r.length>0&&new Set(r).size===r.length&&n!==null&&n.length>0&&new Set(n).size===n.length&&r.every(i=>n.includes(i))}function On(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.length>0)}import{execFileSync as la}from"child_process";import{createHash as pa}from"crypto";import{realpathSync as ua}from"fs";import{isAbsolute as da,resolve as $n}from"path";var gt={run(e,t){try{return la("git",["-C",e,...t],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}}};function fa(e,t=gt){let r=t.run(e,["rev-parse","--show-toplevel"])?.trim();return r?mt(r):void 0}function Wn(e,t=gt){let r=fa(e,t);if(!r)return;let n=t.run(r,["rev-parse","--absolute-git-dir"])?.trim(),i=t.run(r,["rev-parse","--git-common-dir"])?.trim();if(!n||!i)return;let o=mt(Ln(r,n)),s=mt(Ln(r,i)),a=fr(t.run(r,["rev-parse","--verify","HEAD"])),c=fr(t.run(r,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(r,["status","--porcelain=v1","-z","--untracked-files=all"]);if(l!==void 0)return{projectRoot:r,gitDir:o,commonDir:s,repositoryId:Mn("repository",s),worktreeId:Mn("worktree",`${r}\0${o}`),headCommit:a,treeOid:c,clean:l.length===0}}function ma(e,t=gt){let r=t.run(e,["worktree","list","--porcelain","-z"]);return r===void 0?[]:ga(r)}function ga(e){let t=[],r;for(let n of e.split("\0")){if(n===""){r&&t.push(r),r=void 0;continue}let i=n.indexOf(" "),o=i<0?n:n.slice(0,i),s=i<0?"":n.slice(i+1);if(o==="worktree"){r&&t.push(r),r={path:mt(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}r&&(o==="HEAD"?r.head=s:o==="branch"?r.branch=s:o==="detached"?r.detached=!0:o==="bare"?r.bare=!0:o==="prunable"?r.prunable=!0:o==="locked"&&(r.locked=!0))}return r&&t.push(r),t}function Cf(e,t,r=gt){return fr(r.run(e,t))}function Ln(e,t){return da(t)?t:$n(e,t)}function mt(e){try{return ua(e)}catch{return $n(e)}}function Mn(e,t){return pa("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function fr(e){return e?.trim()||void 0}import{randomUUID as Gn}from"crypto";import{closeSync as Un,mkdirSync as ha,openSync as Vn,readFileSync as Bn,unlinkSync as Hn,writeFileSync as qn}from"fs";import{dirname as ya,join as Sa}from"path";function zn(e,t={}){return mr(Sa(e,"gc.lock"),t)}function mr(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??Date.now,o=Date.now()+r;ha(ya(e),{recursive:!0});do{let s=Gn();try{let a=Vn(e,"wx");try{let c={version:1,pid:process.pid,token:s,startedAt:new Date(i()).toISOString()};qn(a,`${JSON.stringify(c)}
3
+ `)}finally{Un(a)}return{release:()=>Jn(e,s)}}catch(a){if(a.code!=="EEXIST")return null;let c=Yn(e);if(c&&(c.pid===void 0||!B(c.pid))){ba(e,c);continue}if(Date.now()>=o)return null;xa(Math.min(n,Math.max(1,o-Date.now())))}}while(Date.now()<=o);return null}function Yn(e){try{let t=Bn(e,"utf8"),r=JSON.parse(t),n=typeof r.pid=="number"&&Number.isSafeInteger(r.pid)&&r.pid>0?r.pid:void 0;return{raw:t,...n===void 0?{}:{pid:n}}}catch{return null}}function ba(e,t){let r=`${e}.reclaim`,n=Gn(),i;try{i=Vn(r,"wx")}catch{return!1}try{qn(i,`${JSON.stringify({version:1,pid:process.pid,token:n,startedAt:new Date().toISOString()})}
4
+ `)}finally{Un(i)}try{let o=Yn(e);return!o||o.raw!==t.raw||o.pid!==void 0&&B(o.pid)?!1:(Hn(e),!0)}catch{return!1}finally{Jn(r,n)}}function Jn(e,t){try{let r=JSON.parse(Bn(e,"utf8"));r.pid===process.pid&&r.token===t&&Hn(e)}catch{}}function xa(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}import va from"better-sqlite3";var Ia=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],Kn=class{db;config;pathFilter;statementCache=new Map;constructor(t,r){this.config=t,this.pathFilter=r??null,this.db=new va(t.dbPath,{readonly:!0}),this.db.pragma("busy_timeout = 5000"),this.db.pragma("query_only = ON"),this.db.pragma("temp_store = MEMORY"),this.db.pragma("cache_size = -64000"),this.db.pragma("mmap_size = 268435456")}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
5
+ EXISTS (
6
+ SELECT 1
7
+ FROM defn_enclosing_ranges local_der
8
+ JOIN documents local_d ON local_der.document_id = local_d.id
9
+ WHERE local_der.symbol_id = gs.id
10
+ ${this.pathExclusionsFor("local_d").trimStart()}
11
+ )
12
+ OR EXISTS (
13
+ SELECT 1
14
+ FROM mentions local_m
15
+ JOIN chunks local_c ON local_m.chunk_id = local_c.id
16
+ JOIN documents local_d ON local_c.document_id = local_d.id
17
+ WHERE local_m.symbol_id = gs.id
18
+ AND local_m.role = 1
19
+ ${this.pathExclusionsFor("local_d").trimStart()}
20
+ )
21
+ )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(r=>Ia.flatMap(n=>[`AND ${r}.relative_path NOT LIKE '${n}/%'`,`AND ${r}.relative_path NOT LIKE '%/${n}/%'`])).join(`
22
+ `)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...r){return this.statement(t).all(...r)}get(t,...r){return this.statement(t).get(...r)}close(){this.statementCache.clear(),this.db.close()}statement(t){let r=this.statementCache.get(t);return r||(r=this.db.prepare(t),this.statementCache.set(t,r)),r}};import{createHash as Ea}from"crypto";import{existsSync as wa,mkdirSync as Ca,readFileSync as Ta}from"fs";import{dirname as gr,join as Xn}from"path";import hr from"better-sqlite3";var Pa="evidence.db";var ka=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],yr=new Set(ka),Ra=25e4,Na=512*1024*1024;var ht=new WeakMap,_a=x("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),Da=x("evidence-project-fingerprint",{clearGroups:["whole-project"]}),Q="evidence-v1",Te="version NOT LIKE 'evidence-%'";function yt(e){return Ea("sha256").update(e).digest("hex")}function $e(e,t,r){return _a.get(e,t,()=>yt(r))}function Qn(e){return Da.get(e,"current",()=>{try{let t=JSON.parse(Ta(Xn(gr(e.config.dbPath),"meta.json"),"utf-8"));if(t.version!==2&&t.version!==3||t.status!=="complete"&&t.status!=="partial"||t.fingerprint===void 0)return null;let r=Array.isArray(t.indexedLanguages)?[...t.indexedLanguages].sort():[];return yt(JSON.stringify({fingerprint:t.fingerprint,indexedLanguages:r,status:t.status}))}catch(t){return Pe("project fingerprint unavailable",t),null}})}function Pe(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function We(e){if(ht.has(e))return ht.get(e)??null;let t=null;try{let r=new hr(Xn(gr(e.config.dbPath),Pa));r.pragma("journal_mode = WAL"),r.pragma("busy_timeout = 5000"),r.pragma("synchronous = NORMAL"),r.exec(`
23
+ CREATE TABLE IF NOT EXISTS file_evidence (
24
+ kind TEXT NOT NULL,
25
+ relative_path TEXT NOT NULL,
26
+ content_hash TEXT NOT NULL,
27
+ version TEXT NOT NULL,
28
+ payload TEXT NOT NULL,
29
+ PRIMARY KEY (kind, relative_path)
30
+ );
31
+ CREATE TABLE IF NOT EXISTS project_evidence (
32
+ kind TEXT NOT NULL,
33
+ cache_key TEXT NOT NULL,
34
+ project_fingerprint TEXT NOT NULL,
35
+ version TEXT NOT NULL,
36
+ payload TEXT NOT NULL,
37
+ PRIMARY KEY (kind, cache_key)
38
+ );
39
+ CREATE TABLE IF NOT EXISTS semantic_callees (
40
+ relative_path TEXT NOT NULL,
41
+ symbol TEXT NOT NULL,
42
+ content_hash TEXT NOT NULL,
43
+ deps_digest TEXT NOT NULL,
44
+ version TEXT NOT NULL,
45
+ payload TEXT NOT NULL,
46
+ PRIMARY KEY (relative_path, symbol)
47
+ );
48
+ CREATE TABLE IF NOT EXISTS semantic_references (
49
+ relative_path TEXT NOT NULL,
50
+ symbol TEXT NOT NULL,
51
+ project_fingerprint TEXT NOT NULL,
52
+ version TEXT NOT NULL,
53
+ payload TEXT NOT NULL,
54
+ PRIMARY KEY (relative_path, symbol)
55
+ );
56
+ CREATE TABLE IF NOT EXISTS finding_outcome_ledger (
57
+ check_name TEXT NOT NULL,
58
+ finding_id TEXT NOT NULL,
59
+ first_seen INTEGER NOT NULL,
60
+ last_seen INTEGER NOT NULL,
61
+ times_shown INTEGER NOT NULL,
62
+ outcome TEXT NOT NULL,
63
+ PRIMARY KEY (check_name, finding_id)
64
+ );
65
+ `),t={evidence:r,shared:Aa(e.config.sharedEvidenceDbPath),readFileEvidence:r.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:r.prepare(`SELECT payload FROM file_evidence
66
+ WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${Te}
67
+ ORDER BY version DESC
68
+ LIMIT 1`),writeFileEvidence:r.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),readProjectEvidence:r.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:r.prepare(`SELECT payload FROM project_evidence
69
+ WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${Te}
70
+ ORDER BY version DESC
71
+ LIMIT 1`),writeProjectEvidence:r.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),readCallees:r.prepare(`SELECT payload FROM semantic_callees
72
+ WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:r.prepare(`SELECT payload FROM semantic_callees
73
+ WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${Te}
74
+ ORDER BY version DESC
75
+ LIMIT 1`),readCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
76
+ WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
77
+ WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${Te}
78
+ ORDER BY symbol, version DESC`),writeCallees:r.prepare(`INSERT OR REPLACE INTO semantic_callees
79
+ (relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:r.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:r.prepare(`SELECT payload FROM semantic_references
80
+ WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:r.prepare(`SELECT payload FROM semantic_references
81
+ WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${Te}
82
+ ORDER BY version DESC
83
+ LIMIT 1`),readReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
84
+ WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
85
+ WHERE relative_path = ? AND project_fingerprint = ? AND ${Te}
86
+ ORDER BY symbol, version DESC`),writeReferences:r.prepare(`INSERT OR REPLACE INTO semantic_references
87
+ (relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:r.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?"),readFindingOutcomeLedger:r.prepare("SELECT check_name, finding_id, first_seen, last_seen, times_shown, outcome FROM finding_outcome_ledger"),deleteFindingOutcomeLedgerForCheck:r.prepare("DELETE FROM finding_outcome_ledger WHERE check_name = ?"),writeFindingOutcomeLedgerRow:r.prepare(`INSERT INTO finding_outcome_ledger
88
+ (check_name, finding_id, first_seen, last_seen, times_shown, outcome) VALUES (?, ?, ?, ?, ?, ?)`)}}catch(r){Pe("disabled (open failed)",r)}return ht.set(e,t),t}function Ge(e,t,r){Pe(`disabled (${t})`,r),ht.set(e,null)}function Aa(e){if(!e)return null;try{Ca(gr(e),{recursive:!0});let t=new hr(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
89
+ CREATE TABLE IF NOT EXISTS file_evidence (
90
+ kind TEXT NOT NULL,
91
+ relative_path TEXT NOT NULL,
92
+ content_hash TEXT NOT NULL,
93
+ version TEXT NOT NULL,
94
+ payload TEXT NOT NULL,
95
+ last_accessed_at INTEGER NOT NULL,
96
+ PRIMARY KEY (kind, relative_path, content_hash, version)
97
+ );
98
+ `),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
99
+ VALUES (?, ?, ?, ?, ?, ?)
100
+ ON CONFLICT(kind, relative_path, content_hash, version)
101
+ DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`)}}catch(t){return Pe("shared cache disabled (open failed)",t),null}}function Sr(e,t,r){Pe(`shared cache disabled (${t})`,r);try{e.shared?.evidence.close()}catch{}e.shared=null}function $f(e,t={}){if(!wa(e))return null;let r;try{r=new hr(e),r.pragma("busy_timeout = 50"),r.pragma("wal_checkpoint(TRUNCATE)");let n=r.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??Ra,o=t.budgetBytes??Na,s=Number(r.pragma("page_size",{simple:!0})),a=Number(r.pragma("page_count",{simple:!0})),c=Number(r.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,p=n>0&&l>o?Math.min(n,Math.ceil((l-o)/Math.max(1,l/n))):0,u=Math.max(n-i,p);return u>0&&(r.prepare(`DELETE FROM file_evidence WHERE rowid IN (
102
+ SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
103
+ )`).run(u),r.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:u,remainingRows:n-u}}catch(n){return Pe("shared cache maintenance skipped",n),null}finally{try{r?.close()}catch{}}}function Zn(e,t,r,n){let i=We(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,r,n,Q)??i.readLegacyFileEvidence.get(t,r,n);if(o?.payload!==void 0)return o.payload;if(!yr.has(t)||!i.shared)return null;try{return i.shared.readFileEvidence.get(t,r,n,Q)?.payload??null}catch(s){return Sr(i,"file_evidence read",s),null}}catch(o){return Ge(e,"file_evidence read",o),null}}function ei(e,t,r,n,i){let o=We(e);if(o)try{if(o.writeFileEvidence.run(t,r,n,Q,i),yr.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,r,n,Q,i,Date.now())}catch(s){Sr(o,"file_evidence write",s)}}catch(s){Ge(e,"file_evidence write",s)}}function ti(e,t){if(t.length===0)return;let r=We(e);if(r)try{r.evidence.transaction(()=>{for(let i of t)r.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,Q,i.payload)})();let n=t.filter(i=>yr.has(i.kind));if(n.length>0&&r.shared)try{r.shared.evidence.transaction(()=>{for(let i of n)r.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,Q,i.payload,Date.now())})()}catch(i){Sr(r,"file_evidence batch write",i)}}catch(n){Ge(e,"file_evidence batch write",n)}}function ri(e,t,r,n){let i=We(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,r,n,Q)??i.readLegacyProjectEvidence.get(t,r,n))?.payload??null}catch(o){return Ge(e,"project_evidence read",o),null}}function ni(e,t,r,n,i){let o=We(e);if(o)try{o.writeProjectEvidence.run(t,r,n,Q,i)}catch(s){Ge(e,"project_evidence write",s)}}function ke(e){return typeof e=="object"&&e!==null}function br(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}function Bf(e){return!ke(e)||typeof e.version!="number"||br(e.languages)===null||typeof e.pnpmWorkspaces!="boolean"||typeof e.typescriptProjectMode!="string"||br(e.typescriptProjects)===null||e.clojureConfigPath!==void 0&&typeof e.clojureConfigPath!="string"||!Array.isArray(e.files)||!e.files.every(ja)?null:e}function Hf(e,t){let r=new Map((e?.files??[]).map(a=>[a.path,a])),n=new Map(t.files.map(a=>[a.path,a])),i=new Set([...r.keys(),...n.keys()]),o=[];for(let a of[...i].sort()){let c=r.get(a),l=n.get(a),p=Nn(a,t.languages);!c&&l?o.push({kind:"added",path:a,inputKind:p,after:l}):c&&!l?o.push({kind:"deleted",path:a,inputKind:p,before:c}):c&&l&&(c.hash!==l.hash||c.size!==l.size)&&o.push({kind:"modified",path:a,inputKind:p,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"),(ii(e?.files??[])||ii(t.files))&&s.add("duplicate-input-path"),[...e?.files??[],...t.files].some(Fa)&&s.add("unreadable-input"),{version:1,changes:o,projectIdentityChanged:e?!Ma(e,t):!0,uncertainty:[...s].sort()}}function ii(e){return new Set(e.map(t=>t.path)).size!==e.length}function ja(e){return ke(e)&&typeof e.path=="string"&&typeof e.size=="number"&&typeof e.hash=="string"}function Fa(e){return e.hash==="unreadable"||e.size<0}function Oa(e){let t=new Set;for(let r of e.uncertainty)t.add(r);e.projectIdentityChanged&&t.add("project-identity-changed");for(let r of e.changes)r.kind==="added"&&t.add("file-added"),r.kind==="deleted"&&t.add("file-deleted"),r.inputKind==="config"&&t.add("configuration-changed"),r.inputKind==="ambient"&&t.add("ambient-declaration-changed"),r.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function qf(e,t,r){let n=e.changes.map(a=>a.path).sort();if(n.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:n,affectedFiles:[],reasons:[]};let i=new Set(r),o=Oa(e),s=new Set(o.reasons);return n.some(a=>!i.has(a))&&s.add("changed-file-outside-project"),t===null?(s.add("dependency-graph-unavailable"),oi(n,i,s)):s.size>0?oi(n,i,s):{mode:"closure",changedFiles:n,affectedFiles:La(n,t,i),reasons:[]}}function oi(e,t,r){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...r].sort()}}function La(e,t,r){let n=new Map;for(let[s,a]of t)if(r.has(s))for(let c of a){if(!r.has(c))continue;let l=n.get(c)??new Set;l.add(s),n.set(c,l)}let i=new Set(e),o=[...e];for(let s=0;s<o.length;s+=1){let a=o[s];if(a!==void 0)for(let c of n.get(a)??[])i.has(c)||(i.add(c),o.push(c))}return[...i].sort()}function Ma(e,t){return si(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&si(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function si(e,t){if(e.length!==t.length)return!1;let r=[...e].sort(),n=[...t].sort();return r.every((i,o)=>i===n[o])}import{execFileSync as $a}from"child_process";import{existsSync as Wa,readdirSync as ci}from"fs";import{extname as li,join as pi}from"path";var ui=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Ga=[{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 Xf(e){let t=[],r=Ua(e),n=qa(e);for(let i of Ga){if(Va(e,i.files)){t.push(i.language);continue}if(Ba(r,i.globs)){t.push(i.language);continue}Ya(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&ai(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&ai(t,"c"),t}function Ua(e){try{return ci(e)}catch{return[]}}function Va(e,t){return t?.length?t.some(r=>Wa(pi(e,r))):!1}function Ba(e,t){return t?.length?e.some(r=>t.some(n=>Ha(r,n))):!1}function Ha(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function qa(e){let t=za(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=ci(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=pi(i,s.name);if(s.isDirectory()){ui.has(s.name)||n.push(a);continue}let c=li(s.name).toLowerCase();c&&r.add(c)}}return r}function za(e){try{let t=$a("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),r=new Set;for(let n of t.split(`
104
+ `)){if(!n||n.split("/").some(o=>ui.has(o)))continue;let i=li(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function Ya(e,t){return t?.length?t.some(r=>e.has(r)):!1}function ai(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{readFileSync as Ja,writeFileSync as Ka}from"fs";import{create as di}from"@bufbuild/protobuf";import{deserializeSCIP as Xa,DocumentSchema as Qa,IndexSchema as Za,serializeSCIP as ec,SymbolRole as tc}from"@c4312/scip";function rm(e){let t;try{t=Xa(Ja(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=xr(t);return r.removedDefinitionOccurrences>0&&Ka(e,Buffer.from(ec(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function xr(e){let t=new Set;for(let o of e.documents)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 r=0,n=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&tc.Definition)===0||t.has(a.symbol)?!0:(r+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}n+=1,i.push(di(Qa,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:r===0?e:di(Za,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:r,touchedDocuments:n}}import{readFileSync as vr,writeFileSync as Ir}from"fs";import{create as Ue}from"@bufbuild/protobuf";import{deserializeSCIP as Er,serializeSCIP as wr,DocumentSchema as rc,IndexSchema as fi,MetadataSchema as nc,SymbolInformationSchema as ic}from"@c4312/scip";function mi(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=sc(e),r=ac(e.flatMap(i=>i.documents??[])),n=hi(e.flatMap(i=>i.externalSymbols??[]));return Ue(fi,{metadata:t,documents:r,externalSymbols:n})}function cm(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>Er(vr(i))),n=mi(r);return Ir(t,Buffer.from(wr(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function lm(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>Er(vr(i))),n=xr(mi(r));return Ir(t,Buffer.from(wr(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function oc(e,t,r){let n=e.metadata;if(!n)throw new Error("Cannot rebase a SCIP index without metadata");if(n.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${n.projectRoot}`);return Ue(fi,{metadata:Ue(nc,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function gi(e,t,r){let n=Er(vr(e)),i=oc(n,t,r);Ir(e,Buffer.from(wr(i)))}function sc(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let n of e.slice(1)){let i=n.metadata?.projectRoot;if(r&&i&&i!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${i}`)}return t}function ac(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,Ue(rc,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:cc([...n.occurrences,...r.occurrences]),symbols:hi([...n.symbols,...r.symbols]),text:pc(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function cc(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function hi(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,Ue(ic,{symbol:n.symbol,documentation:uc([...n.documentation,...r.documentation]),relationships:lc([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function lc(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function pc(e,t){return e?t?e.length>=t.length?e:t:e:t}function uc(e){return[...new Set(e)]}import{createHash as xc}from"crypto";import{existsSync as Be,mkdirSync as vc,readFileSync as qe,readdirSync as Rr,renameSync as Ic,rmSync as Di,writeFileSync as Ec}from"fs";import{join as $}from"path";import{createHash as dc}from"crypto";import{existsSync as Tr,mkdirSync as fc,readFileSync as St,readdirSync as fm,renameSync as mc,rmSync as mm,writeFileSync as gc}from"fs";import{join as Re}from"path";import{create as Si,fromBinary as bi,toBinary as hc}from"@bufbuild/protobuf";import{deserializeSCIP as bt,DocumentSchema as Pr,IndexSchema as xi,serializeSCIP as vi}from"@c4312/scip";var xt=1,Ve="typescript-scip-fragments";function bm(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,r=[];for(let o of e){let s=pe(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=bi(Pr,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);r.push(a)}let n=vi(Si(xi,{documents:r,externalSymbols:[]})),i=bt(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function vt(e){let t=Re(e,Ve);return{rootDir:t,blobDir:Re(t,"blobs"),generationDir:Re(t,"generations")}}function yc(e){let t=bt(e.indexBytes);Ni(t.metadata,_i(e)),Ri(t.externalSymbols);let r=new Set,n=[];for(let o of t.documents){let s=pe(o.relativePath);if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let a=hc(Pr,o),c=e.documentIdentities.get(s)??(e.allowUntrackedDocuments?ue(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:s,contentHash:ue(a)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${s}`);n.push(Ci(e.cacheDir,{relativePath:s,bytes:a,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Ti(e,n);return Pi(e.cacheDir,i),i}function xm(e){let t=vt(e.cacheDir);if(!Tr(kr(t,e.generationIdentity)))return yc(e);let r=Ii({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&r.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let n of r.manifest.documents){let i=e.documentIdentities.get(n.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==n.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${n.relativePath}`)}return r.manifest}function vm(e){let t=Ii({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,r=new Map(t.documents.map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=pe(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(n.add(s),!r.has(s))throw new Error(`TypeScript fragment replacement has no prior document: ${s}`);let a=e.documentIdentities.get(s);if(!a)throw new Error(`missing TypeScript document identity: ${s}`);o.bytes===null?r.delete(s):r.set(s,Ci(e.cacheDir,o,a))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Ti(e,[...r.values()]);return Pi(e.cacheDir,i),i}function Ii(e){let t=vt(e.cacheDir),r=kr(t,e.generationIdentity),n;try{n=ki(St(r,"utf8"))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(n.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&n.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&n.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of n.documents){let s=Re(t.blobDir,`${o.blobHash}.scipdoc`),a=St(s);if(a.byteLength!==o.byteLength||ue(a)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,a)}return{manifest:n,fragments:i}}function Ei(e){let t=wi(e);return Cr(t.baseIndex,t.completeDocuments,"assembled")}function Im(e){let t=wi(e);return Sc(t.deletedAffectedPaths),{completeIndexBytes:Cr(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:Cr(t.baseIndex,t.affectedDocuments,"affected")}}function wi(e){let t=bt(e.baseIndexBytes);Ni(t.metadata,_i(e)),Ri(t.externalSymbols);let r=new Map;for(let a of e.fragments){let c=pe(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,a)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=pe(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let l=r.get(c);if(!l){i.push(a);continue}if(r.delete(c),l.bytes===null){s.push(c);continue}let p=bi(Pr,l.bytes);if(p.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${p.relativePath}`);i.push(p),o.push(p)}if(r.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...r.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function Cr(e,t,r){let n=vi(Si(xi,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=bt(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function Sc(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function Ci(e,t,r){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let n=pe(t.relativePath),i=Buffer.from(t.bytes),o=ue(i),s=vt(e);fc(s.blobDir,{recursive:!0});let a=Re(s.blobDir,`${o}.scipdoc`);if(Tr(a)){let c=St(a);if(c.byteLength!==i.byteLength||ue(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${n}`)}else{let c=`${a}.${process.pid}.${Date.now()}.tmp`;gc(c,i),mc(c,a)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function Ti(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let r=[...t].sort((n,i)=>n.relativePath.localeCompare(i.relativePath));if(new Set(r.map(n=>n.relativePath)).size!==r.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:xt,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function Pi(e,t){let r=vt(e),n=kr(r,t.generationIdentity);if(Tr(n)){let i=ki(St(n,"utf8"));if(yi(i)!==yi(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}k(n,t,{spacing:2,trailingNewline:!0})}function yi(e){return ue(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function ki(e){let t=JSON.parse(e);if(t.version!==xt||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 r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(pe(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function kr(e,t){return Re(e.generationDir,bc(t))}function bc(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${ue(e)}.json`}function Ri(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Ni(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function _i(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function pe(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}function ue(e){return dc("sha256").update(e).digest("hex")}var It=1,Rm=64*1024*1024,ze="typescript-scip-overlays";function Nm(e){let t=ji(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let r=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=Dr(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);n.add(s),r.set(s,wc(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:It,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((o,s)=>o.relativePath.localeCompare(s.relativePath))};return Cc(e.cacheDir,i),i}function _m(e){let t=ji(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=qe($(Ye(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`));if(i.byteLength!==n.byteLength||He(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return Ei({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function Dm(e,t){let r=Ye(e),n=$(r,"generations");if(!Be(n))return;let i=new Set(t.map(_r)),o=new Set;for(let a of Rr(n).filter(c=>i.has(c))){let c=Nr(qe($(n,a),"utf8"));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of Rr(n))i.has(a)||Di($(n,a),{force:!0});let s=$(r,"blobs");if(Be(s))for(let a of Rr(s))o.has(a)||Di($(s,a),{force:!0})}function ji(e,t){let r=$(Ye(e),"generations",_r(t));if(!Be(r))return null;let n=Nr(qe(r,"utf8"));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function wc(e,t){let r=Dr(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=He(n),o=$(Ye(e),"blobs");vc(o,{recursive:!0});let s=$(o,`${i}.scipdoc`);if(Be(s)){let a=qe(s);if(a.byteLength!==n.byteLength||He(a)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${r}`)}else{let a=`${s}.${process.pid}.${Date.now()}.tmp`;Ec(a,n),Ic(a,s)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Cc(e,t){let r=$(Ye(e),"generations",_r(t.generationIdentity));if(Be(r)){let n=Nr(qe(r,"utf8"));if(Ai(n)!==Ai(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}k(r,t,{spacing:2,trailingNewline:!0})}function Nr(e){let t=JSON.parse(e);if(t.version!==It||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 r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(Dr(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function Ye(e){return $(e,ze)}function _r(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${He(e)}.json`}function Ai(e){return He(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function Dr(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}function He(e){return xc("sha256").update(e).digest("hex")}import{createHash as Tc}from"crypto";import{copyFileSync as Fi,existsSync as Z,linkSync as Pc,mkdirSync as Oi,readFileSync as $i,readdirSync as Li,renameSync as jr,rmSync as wt,statSync as kc}from"fs";import{basename as Et,dirname as Je,join as E,relative as Mi}from"path";var Ne=1,Ct=".scipquery-generations";function Wi(e){let t=Tt(e.outputDb),r=Rc(e,t);e.onStage?.("after-recovery-retained"),e.preserveOutputScip||Ar(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),Ar(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),Ar(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let n=Pt(e.metaPath,e.outputDb),i={version:Ne,currentGeneration:n,...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:(e.now??(()=>new Date))().toISOString()};return k(E(t,"state.json"),i,{spacing:2,trailingNewline:!0}),{currentGeneration:n,...r?{previousGeneration:r}:{}}}function Gi(e){try{let t=JSON.parse($i(E(Tt(e),"state.json"),"utf8"));return t.version!==Ne||typeof t.currentGeneration!="string"||!t.currentGeneration||typeof t.publishedAt!="string"||!Number.isFinite(Date.parse(t.publishedAt))||!Dc(t.previousGeneration)||!Ac(t.publication)?null:t}catch{return null}}function Mm(e,t,r=()=>new Date){if(!Z(e)||!Z(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=Gi(e),i={version:Ne,currentGeneration:Pt(t,e),...n?.previousGeneration?{previousGeneration:n.previousGeneration}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return k(E(Tt(e),"state.json"),i,{spacing:2,trailingNewline:!0}),i}function Fr(e,t=E(Je(e),"meta.json")){let r=E(Tt(e),"state.json");if(!Z(r))return{state:"legacy",statePath:r};let n=Gi(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=Pt(t,e),o=n.currentGeneration===i,s=n.previousGeneration?Z(E(Je(e),n.previousGeneration.databasePath)):!0;return!o||!s?{state:"drifted",statePath:r,currentMatches:o,recoveryExists:s,generation:n,reason:o?"retained recovery database is missing":"stable database or metadata no longer matches the published generation"}:{state:"current",statePath:r,currentMatches:o,recoveryExists:s,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function Tt(e){return E(Je(e),Ct)}function Rc(e,t){if(!Z(e.outputDb))return;let r=Pt(e.metaPath,e.outputDb),n=E(t,r),i=E(n,Et(e.outputDb)),o=Z(e.metaPath)?E(n,Et(e.metaPath)):void 0;if(!Z(i)){let s=`${n}.${process.pid}.${Date.now()}.tmp`;wt(s,{recursive:!0,force:!0}),Oi(s,{recursive:!0});let a=E(s,Et(e.outputDb));try{Pc(e.outputDb,a)}catch{Fi(e.outputDb,a)}o&&Fi(e.metaPath,E(s,Et(e.metaPath))),Oi(t,{recursive:!0}),jr(s,n)}return Nc(t,r),{generationIdentity:r,databasePath:Mi(Je(e.outputDb),i),...o?{metadataPath:Mi(Je(e.outputDb),o)}:{}}}function Nc(e,t){for(let r of Li(e,{withFileTypes:!0}))!r.isDirectory()||r.name===t||r.name.endsWith(".tmp")||wt(E(e,r.name),{recursive:!0,force:!0});for(let r of Li(e,{withFileTypes:!0}))r.isDirectory()&&r.name.endsWith(".tmp")&&wt(E(e,r.name),{recursive:!0,force:!0})}function Pt(e,t){let r=Tc("sha256").update(`sqlite-generation-v${Ne}\0`);Z(e)&&r.update(_c($i(e,"utf8")));let n=kc(t);return r.update(`\0${n.size}`),r.digest("hex")}function _c(e){try{let t=JSON.parse(e);if((t.version===2||t.version===3)&&t.status==="complete"&&typeof t.updatedAt=="string"&&t.fingerprint!==void 0)return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion})}catch{}return e}function Ar(e,t){wt(`${t}.tmp-replace`,{force:!0}),jr(e,`${t}.tmp-replace`),jr(`${t}.tmp-replace`,t)}function Dc(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 Ac(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=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{createHash as Ki,randomUUID as Wr}from"crypto";import{closeSync as Xi,constants as Vc,copyFileSync as qi,existsSync as te,lstatSync as Bc,mkdirSync as H,mkdtempSync as Qi,openSync as Zi,readdirSync as Hc,readFileSync as W,realpathSync as qc,renameSync as de,rmSync as ee,statSync as zc,unlinkSync as Mr,writeFileSync as eo}from"fs";import{dirname as to,join as f,resolve as Ze}from"path";import{setTimeout as Yc}from"timers/promises";import{pathToFileURL as zi}from"url";import{deserializeSCIP as ro}from"@c4312/scip";import Jc from"better-sqlite3";import{createRequire as jc}from"module";var Fc=jc(import.meta.url),Ui=Oc().version;function Oc(){for(let e of["../package.json","../../package.json"])try{return Fc(e)}catch{}return{version:"0.0.0"}}import{lstatSync as Lc,readdirSync as Mc}from"fs";import{join as $c,relative as Wc,resolve as Or,sep as Gc}from"path";var Ke=1,Lr="language-indexes",Vi=["index.db","index.scip","meta.json"],Bi=[Lr,Ve,ze];function kt(e){let t=[];for(let r of Vi)Uc(e,r),t.push(r);for(let r of Bi)Hi(e,r,t);return{version:Ke,files:t.sort()}}function Rt(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(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!Vi.includes(e)&&!Bi.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function U(e,t){let r=Rt(t),n=Or(e),i=Or(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Gc}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Hi(e,t,r){let n=$c(e,t),i;try{i=Mc(n,{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()?Hi(e,s,r):o.isFile()&&r.push(Rt(s))}}function Uc(e,t){let r=U(e,t),n;try{n=Lc(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(Wc(Or(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Gr=1,Yi="SCIP_QUERY_SHARED_CACHE",$r=JSON.stringify({cliVersion:Ui,artifactCatalogVersion:Ke,sqliteGenerationStoreVersion:Ne,typescriptFragmentStoreVersion:xt,typescriptOverlayStoreVersion:It}),no="manifest.json",Kc="shared-cache.json",Ur=[Lr,Ve,ze];function ug(e,t){if(!e.clean||!e.treeOid)return;let r=tt(JSON.stringify({version:Gr,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:$r}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:$r,generationId:r,repositoryCacheDir:ur(e.repositoryId)}}function dg(e,t,r){if(process.env[Yi]==="0")return`${Yi}=0`;if(!dr(r))return"explicit cache or database override";if(Ze(t)!==Ze(f(pr(e),"index.db")))return"index database is outside the managed worktree cache"}function fg(e,t){if(!dr(t))return;let r=Wn(e);return r?f(ur(r.repositoryId),"evidence.db"):void 0}function Qe(e,t=!0){let r=Vr(e),n;try{n=Zc(W(f(r,no),"utf8"))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||JSON.stringify(n.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return n;try{for(let i of n.artifacts){let o=U(r,i.path),s=zc(o);if(!s.isFile()||s.size!==i.size||tt(W(o))!==i.sha256)return null}}catch{return null}return n}function mg(e){let t=Qe(e.snapshot);if(t)return t;if(!so(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=Ji(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=kt(e.sourceCacheDir),i=f(e.snapshot.repositoryCacheDir,"generations");H(i,{recursive:!0});let o=Qi(f(i,`.tmp-${process.pid}-`));try{let s=[];for(let u of n.files){let d=U(e.sourceCacheDir,u),m=U(o,u);et(d,m);let h=W(m);s.push({path:u,size:h.byteLength,sha256:tt(h)})}let a=ro(W(f(o,"index.scip"))).metadata?.projectRoot;if(!a)throw new Error("shared SCIP generation has no project root metadata");let c=Br(e.sourceProjectRoot);if(a!==c)throw new Error("shared SCIP generation root does not match its source worktree");if(Ji(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:Gr,artifactCatalogVersion:Ke,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:a,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((u,d)=>u.path.localeCompare(d.path))};k(f(o,no),l,{spacing:2,trailingNewline:!0});let p=Vr(e.snapshot);try{if(te(p)&&!Qe(e.snapshot)){let u=`${p}.corrupt-${process.pid}-${Date.now()}`;de(p,u),ee(u,{recursive:!0,force:!0})}de(o,p)}catch(u){let d=Qe(e.snapshot);if(d)return d;throw u}return l}finally{ee(o,{recursive:!0,force:!0})}}function gg(e){let t=Vr(e.snapshot);H(e.targetCacheDir,{recursive:!0});let r=mr(f(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=Qi(f(e.targetCacheDir,".shared-hydrate-")),al(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=U(t,c.path),p=U(n,c.path);et(l,p);let u=W(p);if(u.byteLength!==c.size||tt(u)!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=Br(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&gi(U(n,c.path),e.manifest.scipProjectRoot,s);if(!so(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=il(e.targetCacheDir,n),o=!0,ol(n,e.targetCacheDir,i),Wi({tempOutputScip:f(n,"index.scip"),tempOutputDb:f(n,"index.db"),tempMetaPath:f(n,"meta.json"),outputScip:f(e.targetCacheDir,"index.scip"),outputDb:f(e.targetCacheDir,"index.db"),metaPath:f(e.targetCacheDir,"meta.json"),now:e.now});let a=Fr(f(e.targetCacheDir,"index.db"),f(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);Xc(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&sl(e.targetCacheDir,i),s}finally{n&&ee(n,{recursive:!0,force:!0}),r.release()}}async function hg(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??Date.now,o=i()+r,s=f(e.repositoryCacheDir,"locks"),a=f(s,`${e.generationId}.lock`);for(H(s,{recursive:!0});i()<=o;){if(Qe(e))return{kind:"generation-ready"};let c=Wr();try{let l=Zi(a,"wx");try{eo(l,`${JSON.stringify({version:1,pid:process.pid,token:c,generationId:e.generationId,startedAt:new Date(i()).toISOString()})}
105
+ `)}finally{Xi(l)}return{kind:"owner",release:()=>{try{let p=JSON.parse(W(a,"utf8"));p.pid===process.pid&&p.token===c&&Mr(a)}catch{}}}}catch(l){if(l.code!=="EEXIST")return{kind:"timeout"};let p=io(a);if(p&&(p.pid===void 0||!B(p.pid))){rl(a,p);continue}await Yc(n)}}return Qe(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Xc(e,t,r,n=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:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:Qc(i)};return nl(e.repositoryCacheDir,o,!0),o}function Qc(e){return tt(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:Ze(e.projectRoot),localCacheDir:Ze(e.localCacheDir)}))}function Zc(e){let t=JSON.parse(e);if(t.version!==Gr||t.artifactCatalogVersion!==Ke||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!==$r||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 r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(Rt(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function et(e,t){H(to(t),{recursive:!0});try{qi(e,t,Vc.COPYFILE_FICLONE)}catch{qi(e,t)}}function el(e,t,r){H(e,{recursive:!0}),k(f(e,Kc),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function Ji(e){try{let t=kt(e),r=Ki("sha256");for(let n of t.files){let i=W(U(e,n));r.update(n).update("\0").update(String(i.byteLength)).update("\0").update(i).update("\0")}return r.digest("hex")}catch{return null}}function tl(e){try{return JSON.parse(W(f(e,"meta.json"),"utf8"))}catch{return}}function Vr(e){return f(e.repositoryCacheDir,"generations",e.generationId)}function io(e){try{let t=W(e,"utf8"),r=JSON.parse(t),n=typeof r.pid=="number"&&Number.isSafeInteger(r.pid)&&r.pid>0?r.pid:void 0;return{raw:t,...n===void 0?{}:{pid:n}}}catch{return null}}function rl(e,t){let r=`${e}.reclaim`,n=Wr(),i;try{i=Zi(r,"wx")}catch{return!1}try{eo(i,`${JSON.stringify({version:1,pid:process.pid,token:n,startedAt:new Date().toISOString()})}
106
+ `)}finally{Xi(i)}try{let o=io(e);return!o||o.raw!==t.raw||o.pid!==void 0&&B(o.pid)?!1:(Mr(e),!0)}catch{return!1}finally{try{let o=JSON.parse(W(r,"utf8"));o.pid===process.pid&&o.token===n&&Mr(r)}catch{}}}function nl(e,t,r){let n=zn(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId;if(!o||!te(f(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=f(e,"worktrees");H(i,{recursive:!0}),k(f(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),el(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function il(e,t){let r=f(t,".rollback"),n=new Map,i=new Map;H(r,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=f(e,a),l=te(c);n.set(a,l),l&&et(c,f(r,"stable",a))}for(let a of Ur){let c=f(e,a),l=te(c);if(l){let p=Bc(c);if(!p.isDirectory()||p.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=f(e,Ct),s=te(o);return s&&oo(o,f(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:s}}function ol(e,t,r){for(let n of Ur){let i=f(t,n);if(r.managedDirectories.get(n)){let s=f(r.root,"managed",n);H(to(s),{recursive:!0}),de(i,s)}let o=f(e,n);te(o)&&de(o,i)}}function sl(e,t){for(let i of Ur){let o=f(e,i),s=f(t.root,"managed",i);t.managedDirectories.get(i)?te(s)&&(ee(o,{recursive:!0,force:!0}),de(s,o)):ee(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=f(e,i);if(!o){ee(s,{force:!0});continue}let a=`${s}.shared-restore-${Wr()}`;et(f(t.root,"stable",i),a),ee(s,{force:!0}),de(a,s)}let r=f(e,Ct);ee(r,{recursive:!0,force:!0});let n=f(t.root,"sqlite-generations");t.generationStoreExisted&&te(n)&&de(n,r)}function oo(e,t){H(t,{recursive:!0});for(let r of Hc(e,{withFileTypes:!0})){let n=f(e,r.name),i=f(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?oo(n,i):r.isFile()&&et(n,i)}}function al(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function so(e,t,r,n=!0,i=!0){try{let o=tl(e);if(o?.status!=="complete"||JSON.stringify(o.fingerprint)!==JSON.stringify(r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return Xe("source validation rejected metadata"),!1;let s=kt(e),a=Fr(f(e,"index.db"),f(e,"meta.json"));if(n?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Xe(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new Jc(f(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=Br(t),u=(i?s.files.filter(d=>d.endsWith(".scip")):["index.scip"]).every(d=>{let m=ro(W(U(e,d))).metadata?.projectRoot;return m!==l&&Xe(`source validation rejected SCIP root for ${d}: ${String(m)}`),m===l});return u||Xe("source validation rejected SCIP project roots"),u}catch(o){return Xe(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Xe(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function Br(e){try{return zi(qc(e)).href}catch{return zi(Ze(e)).href}}function tt(e){return Ki("sha256").update(e).digest("hex")}import{readFileSync as ao}from"fs";import{createRequire as cl}from"module";import{dirname as Yr,isAbsolute as ll,relative as uo,resolve as ne,sep as Hr}from"path";var re=cl(import.meta.url),pl=1,co="0.4.0";function ul(){try{let e=fo();if(!e.available)return e;let{packageRoot:t}=e,r=re.resolve("typescript",{paths:[t]}),n=re(r),{FileIndexer:i}=re(ne(t,"dist/src/FileIndexer.js")),{Input:o}=re(ne(t,"dist/src/Input.js")),{Packages:s}=re(ne(t,"dist/src/Packages.js")),a=re(ne(t,"dist/src/scip.js"));if(!i||!o||!s||!a.scip?.Document||!a.scip.Index)return{available:!1,reason:"scip-typescript document runtime has an unsupported module shape"};let c={packageVersion:e.packageVersion,typescript:n,Document:a.scip.Document,Index:a.scip.Index,FileIndexer:i,Input:o,Packages:s};return{available:!0,runtime:c,producerIdentity:Jr(c)}}catch(e){return{available:!1,reason:`scip-typescript document runtime unavailable: ${e instanceof Error?e.message:String(e)}`}}}function vg(){let e=fo();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function fo(){try{let e=re.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(ao(e,"utf8"));if(t.version!==co)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${co}`};let r=Yr(e),n=re.resolve("typescript/package.json",{paths:[r]}),i=JSON.parse(ao(n,"utf8"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:r,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:mo(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Ig(e){let t=e.runtime===void 0?ul():e.runtime===null?{available:!1,reason:"scip-typescript document runtime unavailable"}:{available:!0,runtime:e.runtime,producerIdentity:Jr(e.runtime)};return t.available?{available:!0,emitter:new qr(e,t.runtime)}:t}var qr=class{producerIdentity;workspaceRoot;tsconfigPath;projectRoot;maxFileByteSize;runtime;host;config=null;includedFiles=new Set;program=null;checker=null;symbolTable=new Map;constructorTable=new Map;packages;fragments=new Map;stats={initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0,sourceNodesReused:0,sourceNodesReplaced:0,symbolEntriesPruned:0};constructor(t,r){this.workspaceRoot=ne(t.workspaceRoot),this.tsconfigPath=ne(this.workspaceRoot,t.tsconfigPath),this.projectRoot=t.projectRoot??fl(this.workspaceRoot,Yr(this.tsconfigPath)),this.maxFileByteSize=t.maxFileByteSize??1024*1024,this.runtime=r,this.producerIdentity=Jr(r);let n=lo(r.typescript,this.tsconfigPath);this.config=n,this.host=new zr(r.typescript,n.options,this.workspaceRoot),this.packages=new r.Packages(this.projectRoot)}initialize(){let t=performance.now(),r=this.config??lo(this.runtime.typescript,this.tsconfigPath);this.includedFiles=new Set(r.fileNames.map(_e)),this.program=this.runtime.typescript.createProgram(r.fileNames,r.options,this.host.compilerHost),this.checker=this.program.getTypeChecker(),this.stats.initializations+=1;let n=[];for(let i of this.program.getSourceFiles())this.includedFiles.has(_e(i.fileName))&&n.push(this.emitSourceFile(i));return this.result(n,t)}advance(t){if(!this.program||!this.checker||!this.config)return this.initializeAndAdvance(t);let r=performance.now(),n=Nt(t.modifiedFiles),i=Nt(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=this.program,s=new Map;for(let c of n){let l=rt(this.workspaceRoot,c),p=o.getSourceFile(l);if(!p)throw new Error(`modified TypeScript source is unavailable: ${c}`);s.set(c,p),this.stats.symbolEntriesPruned+=po(this.symbolTable,p),this.stats.symbolEntriesPruned+=po(this.constructorTable,p),this.host.invalidate(l)}this.program=this.runtime.typescript.createProgram(this.config.fileNames,this.config.options,this.host.compilerHost,o),this.checker=this.program.getTypeChecker(),this.stats.programUpdates+=1;for(let[c,l]of s)this.program.getSourceFile(rt(this.workspaceRoot,c))===l?this.stats.sourceNodesReused+=1:this.stats.sourceNodesReplaced+=1;let a=i.map(c=>{let l=rt(this.workspaceRoot,c),p=this.program.getSourceFile(l);if(!p)throw new Error(`affected TypeScript source is unavailable: ${c}`);return this.emitSourceFile(p)});return this.result(a,r)}fragment(t){return this.fragments.get(_t(t))??null}snapshotStats(){return{...this.stats}}initializeAndAdvance(t){let r=this.initialize(),n=Nt(t.modifiedFiles),i=Nt(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=new Set(i);return{...r,fragments:r.fragments.filter(s=>o.has(s.relativePath))}}validateIncrementalPaths(t,r){if(t.length===0)throw new Error("incremental TypeScript document update requires a modified file");if(r.length===0)throw new Error("incremental TypeScript document update requires an affected file");for(let n of t){let i=rt(this.workspaceRoot,n);if(!this.includedFiles.has(_e(i)))throw new Error(`modified TypeScript file is outside the configured project: ${n}`)}for(let n of r){let i=rt(this.workspaceRoot,n);if(!this.includedFiles.has(_e(i)))throw new Error(`affected TypeScript file is outside the configured project: ${n}`)}}emitSourceFile(t){if(!this.checker)throw new Error("TypeScript document emitter is not initialized");let r=_t(uo(this.workspaceRoot,t.fileName)),n=new this.runtime.Document({relative_path:r,occurrences:[]});if(new this.runtime.FileIndexer(this.checker,{cwd:this.workspaceRoot,projectRoot:this.projectRoot,projectDisplayName:this.projectRoot,maxFileByteSizeNumber:this.maxFileByteSize},new this.runtime.Input(t.fileName,t.getText()),n,this.symbolTable,this.constructorTable,this.packages,t).index(),this.stats.documentsEmitted+=1,n.occurrences.length===0)return this.fragments.delete(r),this.stats.documentsRemoved+=1,{relativePath:r,bytes:null,occurrences:0,symbols:n.symbols.length,referenceFragments:[]};let o=n.serializeBinary();return this.fragments.set(r,o),{relativePath:r,bytes:o,occurrences:n.occurrences.length,symbols:n.symbols.length,referenceFragments:dl(r,n)}}result(t,r){return{producerIdentity:this.producerIdentity,fragments:t,durationMs:performance.now()-r,stats:this.snapshotStats()}}};function dl(e,t){let r=new Map;for(let n of t.occurrences){if(!n.symbol||(n.symbol_roles&1)!==0||n.range.length<3)continue;let i=n.range[0],o=n.range[1];if(!Number.isInteger(i)||!Number.isInteger(o))continue;let s={targetSymbol:n.symbol,location:{file:e,line:i,column:o}};r.set(`${n.symbol}\0${i}\0${o}`,s)}return[...r.values()].sort((n,i)=>n.targetSymbol.localeCompare(i.targetSymbol)||n.location.line-i.location.line||n.location.column-i.location.column)}var zr=class{compilerHost;sourceFiles=new Map;constructor(t,r,n){let i=t.createCompilerHost(r),o=i.getSourceFile.bind(i);this.compilerHost={...i,getCurrentDirectory:()=>n,getSourceFile:(s,a,c,l)=>{let p=_e(s);if(this.sourceFiles.has(p))return this.sourceFiles.get(p);let u=o(s,a,c,l);return this.sourceFiles.set(p,u),u}}}invalidate(t){this.sourceFiles.delete(_e(t))}};function lo(e,t){let r=e.readConfigFile(t,e.sys.readFile);if(r.error)throw new Error(e.formatDiagnostics([r.error],e.createCompilerHost({})));let n=e.parseJsonConfigFileContent(r.config,e.sys,Yr(t)),i=n.errors.filter(o=>o.code!==18003);if(i.length>0)throw new Error(e.formatDiagnostics(i,e.createCompilerHost({})));return n}function Jr(e){return mo(e.packageVersion,e.typescript.version)}function mo(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${pl}`}function fl(e,t){return _t(uo(e,t))||"."}function rt(e,t){if(ll(t))throw new Error(`expected a project-relative path: ${t}`);let r=ne(e,t),n=e.endsWith(Hr)?e:`${e}${Hr}`;if(r!==e&&!r.startsWith(n))throw new Error(`path escapes the project root: ${t}`);return r}function Nt(e){return[...new Set(e.map(_t))].sort()}function _t(e){return e.split(Hr).join("/").replace(/^\.\//,"")}function _e(e){return ne(e)}function po(e,t){let r=0;for(let n of e.keys())if(ml(n)){try{if(n.getSourceFile()!==t)continue}catch{continue}e.delete(n),r+=1}return r}function ml(e){return!!(e&&typeof e=="object"&&"kind"in e&&"getSourceFile"in e)}var gl=[w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),Dt("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"}),Dt("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"}),Dt("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"}),Dt("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"})];function nt(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(er()){let c=Qn(r);if(c){let l=`${c}\0${n}\0${i}`;a=t.get(l),a||(a=tr(["evidence-product-file-read-v1",e.kind,c,n,i]),t.set(l,a))}}return rr("evidence-product.file.read",()=>{let c=Zn(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){ei(r,e.kind,n,i,e.serialize(o))},writeBatch(r,n){ti(r,n.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function kg(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(er()){let c=`${i}\0${n}`;a=t.get(c),a||(a=tr(["evidence-product-project-read-v1",e.kind,i,n]),t.set(c,a))}return rr("evidence-product.project.read",()=>{let c=ri(r,e.kind,n,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(r,n,i,o){ni(r,e.kind,n,i,e.serialize(o))}}}function it(e){let t=gl.find(r=>r.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function w(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function Dt(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}import{isAbsolute as hl,relative as yl}from"path";function C(e){return e.replace(/\\/g,"/")}function _g(e,t){let r=yl(e,t);return r===""||!r.startsWith("..")&&!hl(r)}var Sl=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function Ag(e){let t=e.toLowerCase();return Sl.some(r=>t.endsWith(r))}import{createRequire as bl}from"module";var go=bl(import.meta.url),ot,At;function xl(){if(ot!==void 0)return ot;try{ot=go("ts-morph")}catch{ot=null}return ot}function Og(){if(At)return At;let e=xl();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=go("ts-morph/package.json").version??"unknown"}catch{}return At=`ts-morph:${t}:typescript:${e.ts.version}`,At}function Lg(e,t){return t.map(r=>({tsconfigPath:r,project:new e.Project({tsConfigFilePath:r,skipFileDependencyResolution:!0})}))}function Mg(e,t,r){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:r}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function Wg(e,t,r){let n=new Set(r),i=new Map(r.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])n.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,vl(s));return i}function vl(e){let t=new Map;for(let r of e){let{location:n}=r;t.set(`${r.targetSymbol}\0${n.file}\0${n.line}\0${n.column}`,r)}return[...t.values()].sort((r,n)=>r.targetSymbol.localeCompare(n.targetSymbol)||Il(r.location,n.location))}function Il(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}import{existsSync as Xr,readFileSync as Qr,readdirSync as El,statSync as wl}from"fs";import{join as De,relative as Cl}from"path";function ho(e){let t=Tl(e)??Nl(e);if(!t||t.length===0)return[];let r=[],n=new Set;for(let i of t)for(let o of _l(e,i)){if(n.has(o))continue;n.add(o);let s=Dl(e,o);s&&r.push(s)}return r}function Tl(e){let t=De(e,"pnpm-workspace.yaml");if(!Xr(t))return null;try{return Pl(Qr(t,"utf8"))}catch{return null}}function Pl(e){let t=[],r=!1;for(let n of e.split(/\r?\n/)){let i=kl(n);if(!r){/^packages\s*:\s*$/.test(i.trim())&&(r=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=Rl(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function kl(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function Rl(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Nl(e){let t=De(e,"package.json");if(!Xr(t))return null;try{let r=JSON.parse(Qr(t,"utf8"));return r.workspaces?Array.isArray(r.workspaces)?r.workspaces:r.workspaces.packages??[]:null}catch{return null}}function _l(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=De(e,t);return Kr(s)?[s]:[]}let r=t.indexOf("*"),n=t.slice(0,r).replace(/\/$/,""),i=t.slice(r+1).replace(/^\//,""),o=De(e,n||".");return Kr(o)?El(o).map(s=>De(o,s,i)).filter(Kr):[]}function Kr(e){try{return wl(e).isDirectory()}catch{return!1}}function Dl(e,t){let r=De(t,"package.json");if(!Xr(r))return null;try{let n=JSON.parse(Qr(r,"utf8"));return typeof n.name!="string"||n.name.length===0?null:{name:n.name,relativeDir:Cl(e,t).replace(/\\/g,"/"),exports:n.exports}}catch{return null}}import{createRequire as Al}from"module";import{existsSync as ge}from"fs";import{basename as yo,dirname as R,extname as q,join as j,relative as fe,resolve as b,sep as jl}from"path";var Fl=dt("indexed-paths",{clearGroups:[]}),Ol=dt("indexed-path-digest",{clearGroups:[]}),Ll=x("tsconfig-alias-config",{clearGroups:["whole-project"]}),Ml=x("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),$l=Al(import.meta.url),st;function Wl(){if(st!==void 0)return st;try{st=$l("typescript")}catch{st=null}return st}var Gl=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],Ul=dt("workspace-packages",{clearGroups:["whole-project"]}),me=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],jt=[".py",".pyi"],N=[".java",".scala",".kt",".kts"],Ft=[".rs"],Ot=[".rb"],Lt=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],ie=[".cs",".vb"],Mt=[".dart"],he=[".php"],Ae=[".clj",".cljs",".cljc"],Vl=new Set(me),Zr=new Set(jt),So=new Set(N),en=new Set(Ft),tn=new Set(Ot),bo=new Set(Lt),xo=new Set(ie),rn=new Set(Mt),vo=new Set(he),Io=new Set(Ae),Bl=[{extensions:me,lookup:Vl},{extensions:jt,lookup:Zr},{extensions:N,lookup:So},{extensions:Ft,lookup:en},{extensions:Ot,lookup:tn},{extensions:Lt,lookup:bo},{extensions:ie,lookup:xo},{extensions:Mt,lookup:rn},{extensions:he,lookup:vo},{extensions:Ae,lookup:Io}];function z(e,t){return t.has(q(e).toLowerCase())}function Hl(e){return z(e,Zr)}function ql(e){return z(e,So)}function zl(e){return z(e,en)}function Yl(e){return z(e,tn)}function Jl(e){return z(e,bo)}function Kl(e){return z(e,xo)}function Eo(e){return q(e).toLowerCase()===".vb"}function Xl(e){return z(e,rn)}function Ql(e){return z(e,vo)}function Zl(e){return z(e,Io)}function nn(e){let t=q(e).toLowerCase();for(let r of Bl)if(r.lookup.has(t))return r.extensions;return me}function ep(e){return ql(e)||Kl(e)||Ql(e)}function oe(e,t,r){return Hl(t)?je(e,t,r):zl(t)?Y(e,t,r):Yl(t)?$t(e,t,r):Jl(t)?Wt(e,t,r):ep(t)?y(e,r.replace(/\\/g,"."),nn(t)):Xl(t)?Gt(e,t,r):Zl(t)?on(e,r):tp(e,t,r)}function tp(e,t,r){if(!r.startsWith(".")&&!r.startsWith("/"))return rp(e,t,r)??ip(e,r);let n=R(j(e.config.projectRoot,t)),i=b(n,r),o=J(e);for(let s of an(i)){let a=C(fe(e.config.projectRoot,s));if(o.has(a)||ge(s))return a}return C(fe(e.config.projectRoot,i))}function rp(e,t,r){let n=pp(e,t);if(!n)return null;let i=J(e);for(let o of np(n,r)){let s=b(n.baseUrl,o);for(let a of an(s)){let c=C(fe(e.config.projectRoot,a));if(i.has(c)||ge(a))return c}}return null}function np(e,t){let r=[];for(let[n,i]of Object.entries(e.paths)){let o=n.indexOf("*");if(o===-1){if(t!==n)continue;r.push(...i);continue}let s=n.slice(0,o),a=n.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)r.push(l.includes("*")?l.replace("*",c):l)}return r}function ip(e,t){let r=sp(op(e),t);if(!r)return null;let n=J(e);for(let i of ap(r)){let o=b(e.config.projectRoot,r.pkg.relativeDir,i);for(let s of an(o)){let a=C(fe(e.config.projectRoot,s));if(n.has(a)||ge(s))return a}}return null}function op(e){return Ul.get(e,()=>ho(e.config.projectRoot))}function sp(e,t){let r=null;for(let n of e){let i=null;t===n.name?i="":t.startsWith(`${n.name}/`)&&(i=t.slice(n.name.length+1)),i!==null&&(!r||n.name.length>r.pkg.name.length)&&(r={pkg:n,subpath:i})}return r}function ap(e){let t=[],r=cp(e.pkg.exports,e.subpath);if(r){let n=lp(r);n&&t.push(n)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function cp(e,t){if(!e||typeof e!="object")return null;let r=t===""?".":`./${t}`;return wo(e[r])}function wo(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let r of["types","import","default","require","node"]){let n=wo(t[r]);if(n)return n}return null}function lp(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function pp(e,t){let r=C(R(t));return Ml.get(e,r,()=>up(e,r))}function up(e,t){let r=Wl();if(!r)return null;let n=b(e.config.projectRoot),i=b(n,t);for(;i===n||i.startsWith(n+jl);){for(let s of Gl){let a=j(i,s);if(!ge(a))continue;let c=Ll.get(e,a,()=>dp(r,a));if(c)return c}let o=R(i);if(o===i)break;i=o}return null}function dp(e,t){try{let r=e.readConfigFile(t,e.sys.readFile);if(r.error||!r.config)return null;let n=e.parseJsonConfigFileContent(r.config,e.sys,R(t)),i=n.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:n.options.baseUrl?b(R(t),n.options.baseUrl):R(t),paths:i}}catch{return null}}function je(e,t,r){let n=J(e),i;if(r.startsWith(".")){let o=r.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=R(j(e.config.projectRoot,t));for(let l=1;l<s;l++)c=R(c);i=a?b(c,a.replace(/\./g,"/")):c}else i=b(e.config.projectRoot,r.replace(/\./g,"/"));for(let o of fp(i)){let s=C(fe(e.config.projectRoot,o));if(n.has(s)||ge(o))return s}return null}function Y(e,t,r){if(!r)return null;let n=r.replace(/\s+as\s+.+$/,"").trim();if(!n.startsWith("crate::")&&!n.startsWith("self::")&&!n.startsWith("super::"))return null;let i=R(j(e.config.projectRoot,t)),o;return n.startsWith("crate::")?o=b(e.config.projectRoot,"src",n.slice(7).replace(/::/g,"/")):n.startsWith("self::")?o=b(i,n.slice(6).replace(/::/g,"/")):o=b(R(i),n.slice(7).replace(/::/g,"/")),sn(e,mp(o))}function $t(e,t,r){let n=R(j(e.config.projectRoot,t)),i=b(n,r);return sn(e,gp(i))}function Wt(e,t,r){let n=R(j(e.config.projectRoot,t)),i=[b(n,r),b(e.config.projectRoot,r),b(e.config.projectRoot,"include",r),b(e.config.projectRoot,"src",r)];return sn(e,i)}function y(e,t,r){let n=J(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of r){let l=`${o}${c}`,p=[...n].find(u=>u.endsWith(l));if(p)return p}for(let c of r){let l=[...n].find(p=>yo(p)===`${s}${c}`);if(l)return l}let a=[...n].filter(c=>r.includes(q(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Gt(e,t,r){let n=J(e);if(r.startsWith("package:")){let s=r.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=C(c.startsWith("lib/")?c:`lib/${c}`);return n.has(l)?l:null}let i=R(j(e.config.projectRoot,t)),o=b(i,r);for(let s of hp(o)){let a=C(fe(e.config.projectRoot,s));if(n.has(a)||ge(s))return a}return null}function on(e,t){let r=t.replace(/-/g,"_").replace(/\./g,"/"),n=J(e);for(let i of Ae){let o=`${r}${i}`,s=[...n].find(a=>a.endsWith(o));if(s)return s}for(let i of Ae){let o=[...n].find(s=>yo(s)===`${r.split("/").pop()}${i}`);if(o)return o}return null}function fp(e){let t=q(e);return Zr.has(t)?[e]:[`${e}.py`,`${e}.pyi`,j(e,"__init__.py"),j(e,"__init__.pyi")]}function sn(e,t){let r=J(e);for(let n of t){let i=C(fe(e.config.projectRoot,n));if(r.has(i)||ge(n))return i}return null}function mp(e){let t=q(e);return en.has(t)?[e]:[`${e}.rs`,j(e,"mod.rs")]}function gp(e){let t=q(e);return tn.has(t)?[e]:[`${e}.rb`,j(e,"index.rb")]}function hp(e){let t=q(e);return rn.has(t)?[e]:[`${e}.dart`,e]}function an(e){let t=q(e),r=new Set;if(t){r.add(e);for(let n of me)r.add(e.slice(0,-t.length)+n)}else for(let n of me)r.add(`${e}${n}`),r.add(j(e,`index${n}`));return[...r]}function J(e){return Fl.get(e,()=>new Set(Rn(e,{includeIgnored:!1}).map(C)))}function cn(e){return Ol.get(e,()=>yt([...J(e)].sort().join(`
107
+ `)))}import{readFileSync as yp}from"fs";import{join as Sp}from"path";var bp=x("source-text",{clearGroups:["whole-project","source-file"]}),xp=x("source-lines",{clearGroups:["whole-project","source-file"]});function _(e,t){let r=t.replace(/\\/g,"/");return bp.get(e,r,()=>{let n=Sp(e.config.projectRoot,r);try{return yp(n,"utf-8")}catch(i){if(vp(i))return"";throw i}})}function vp(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function nh(e,t){let r=t.replace(/\\/g,"/");return xp.get(e,r,()=>{let n=_(e,r);return n?n.split(`
108
+ `):[]})}import{basename as Ko}from"path";function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ip(e){return e.replace(/'''[\s\S]*?'''/g,se).replace(/"""[\s\S]*?"""/g,se).replace(/#.*$/gm,se).replace(/\/\/.*$/gm,se).replace(/\/\*[\s\S]*?\*\//g,se).replace(/`(?:\\[\s\S]|[^`])*`/g,se).replace(/'(?:\\.|[^'\\\r\n])*'/g,se).replace(/"(?:\\.|[^"\\\r\n])*"/g,se)}function se(e){return e.replace(/[^\r\n]/g," ")}var lh=Ce("stripped-lines",{clearGroups:["whole-project","source-file"]});Pn({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{Ut=null,at=""},clearFile:()=>{Ut=null,at=""}});var Ut=null,at="";function Ep(e){return Ut===e||(Ut=e,at=Ip(e)),at}function ae(e,t,r){let n=Ep(e);return`${n.slice(0,t)}${" ".repeat(r-t)}${n.slice(r)}`}function T(e,t){return new RegExp(`\\b${ye(t)}\\b`,"m").test(e)}function Fe(e,t){let r=new Set,n=new RegExp(`\\b${ye(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function ln(e){let t=0;for(let r of e)r==="("&&(t+=1),r===")"&&(t-=1);return t}import{extname as Co}from"path";var wp={".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 Se(e){return wp[Co(e).toLowerCase()]??null}function be(e){return Co(e).toLowerCase()===".vue"}import{createRequire as Cp}from"module";var v=Cp(import.meta.url),Vt=null,To=!1;function Tp(){if(To)return null;if(Vt)return Vt;try{return Vt=v("tree-sitter"),Vt}catch{return To=!0,null}}var Po=new Map,Bt=new Set;function Pp(e){if(Bt.has(e))return null;let t=Po.get(e);if(t)return t;let r;try{switch(e){case"rust":r=v("tree-sitter-rust");break;case"typescript":r=v("tree-sitter-typescript").typescript;break;case"tsx":r=v("tree-sitter-typescript").tsx;break;case"javascript":r=v("tree-sitter-javascript");break;case"python":r=v("tree-sitter-python");break;case"java":r=v("tree-sitter-java");break;case"kotlin":r=v("tree-sitter-kotlin");break;case"scala":r=v("tree-sitter-scala");break;case"ruby":r=v("tree-sitter-ruby");break;case"c":r=v("tree-sitter-c");break;case"cpp":r=v("tree-sitter-cpp");break;case"csharp":r=v("tree-sitter-c-sharp");break;case"php":r=v("tree-sitter-php").php;break;case"vb":{let n=v("tree-sitter-vb-dotnet");r=n.language??n;break}case"clojure":return Bt.add(e),null}}catch{return Bt.add(e),null}return Po.set(e,r),r}var ko=new Map;function kp(e){let t=ko.get(e);if(t)return t;let r=Pp(e);if(!r)return null;let n=Tp();if(!n)return null;let i=new n;try{i.setLanguage(r)}catch{return Bt.add(e),null}return ko.set(e,i),i}function Rp(e,t){return e.parse(n=>n>=t.length?null:t.slice(n,Math.min(t.length,n+16384)))}function pn(e,t){let r=kp(e);if(!r)return null;try{return Rp(r,t)}catch{return null}}import{posix as un}from"path";import{parse as Np}from"@vue/compiler-sfc";var bh=kn("vue-sfc-units");function _p(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function Dp(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function _o(e,t,r){let n={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!r)return n;let i;try{i=Np(r,{filename:t})}catch(s){return n.errors.push(No(s)),n}n.errors.push(...i.errors.map(No));let{descriptor:o}=i;return o.template&&(n.template=Ht(e,t,"template",o.template)),o.script&&n.scripts.push(Ro(e,t,o.script,!1)),o.scriptSetup&&n.scripts.push(Ro(e,t,o.scriptSetup,!0)),n.styles=o.styles.map(s=>Ht(e,t,"style",s)),n.customBlocks=o.customBlocks.map(s=>Ht(e,t,"custom",s)),n.errors.push(...[n.template,...n.scripts,...n.styles,...n.customBlocks].flatMap(s=>s?.errors??[])),n}function Ro(e,t,r,n){let i=Ht(e,t,"script",r);return{...i,kind:"script",setup:n,astLanguage:Dp(i.lang)}}function Ht(e,t,r,n){let i=jp(n.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof n.src=="string"?n.src:void 0;if(s){let c=Ap(t,s);if(!c)return{kind:r,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${r} block source: ${s}`]};let l=_(e,c),p=l?Math.max(0,l.split(`
109
+ `).length-1):0;return{kind:r,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:p,errors:l?[]:[`Vue ${r} block source not found: ${c}`]}}let a=Math.max(0,n.loc.start.line-1);return{kind:r,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:n.content,startLine:a,endLine:Math.max(a,n.loc.end.line-1),errors:[]}}function Ap(e,t){let r=t.split(/[?#]/,1)[0];if(!r||r.startsWith("/")||r.includes("://"))return null;let n=_p(un.normalize(un.join(un.dirname(e),r)));return n===".."||n.startsWith("../")?null:n}function jp(e){return{...e}}function No(e){return e instanceof Error?e.message:String(e)}function qt(e,t,r){let i=_o(e,t,r).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
110
+ `.repeat(s.startLine)}${s.body}`).join(`
111
+ `),startLine:0,language:o}:null}var Do=Ce("ast-trees",{clearGroups:["whole-project","source-file"]});function V(e,t){if(be(t))return Fp(e,t);let r=Se(t);if(!r)return null;let n=_(e,t);return n?Do.get(e,t,n,()=>pn(r,n)):null}function Fp(e,t){let r=_(e,t);return r?Do.get(e,t,r,()=>{let n=qt(e,t,r);if(!n)return null;let i=`
112
+ `.repeat(n.startLine)+n.body;return pn(n.language,i)}):null}function Ao(e,t){let r=Op(e,t);if(!r)return null;let n=xe(r);return n?{calleeLeaf:n,memberAccess:Lp(r),line:e.startPosition.row}:null}function Op(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 Lp(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}function xe(e){switch(e.type){case"identifier":case"type_identifier":case"field_identifier":case"property_identifier":case"shorthand_property_identifier":return e.text;case"field_expression":case"member_expression":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?xe(t):null}case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?xe(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?xe(t):null}case"super":case"self":case"this":return null;default:return null}}function ct(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var Mp=new Set(["function_declaration","method_definition","method_signature","function_signature"]);function Mo(e,t){let r=Wp(e,t);if(r)return{name:r.name,startLine:r.definitionNode.startPosition.row,endLine:r.definitionNode.endPosition.row,paramCount:Oo(r.functionNode),params:jo(r.functionNode),paramsEndLine:Fo(r.functionNode),isLiteralPassthrough:Lo(r.functionNode,t)};if(!$p(e.type,t))return null;let n=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return n?{name:n.text,startLine:e.startPosition.row,endLine:e.endPosition.row,paramCount:Oo(e),params:jo(e),paramsEndLine:Fo(e),isLiteralPassthrough:Lo(e,t)}:null}function $o(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function jo(e){let t=$o(e);if(!t)return[];let r=[];for(let n of t.namedChildren){if(ct(n))continue;if(n.type==="identifier"){r.push({name:n.text,simple:!0});continue}let i=n.namedChildren.some(a=>a.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(n.text),o=n.childForFieldName("pattern");if(!i&&o&&o.type==="identifier"){r.push({name:o.text,simple:!0});continue}let s=n.namedChildren.find(a=>a.type==="identifier");r.push({name:o?.type==="identifier"?o.text:s?.text??"",simple:!1})}return r}function Fo(e){let t=$o(e);return t?t.endPosition.row:e.startPosition.row}function $p(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?Mp.has(e):!1}function Wp(e,t){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript")return null;if(e.type==="variable_declarator"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}if(e.type==="public_field_definition"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}return null}function Oo(e){let t=e.namedChildren.find(n=>n.type==="parameters"||n.type==="formal_parameters");if(!t)return 0;let r=0;for(let n of t.namedChildren)ct(n)||(r+=1);return r}function Lo(e,t){let r=e.namedChildren.find(u=>u.type==="block"||u.type==="statement_block");if(!r)return!1;let n=r.namedChildren.filter(u=>!ct(u));if(n.length!==1)return!1;let i=n[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(u=>u.type==="arguments"||u.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(u=>!ct(u)),l=e.namedChildren.find(u=>u.type==="parameters"||u.type==="formal_parameters");if(!l)return!1;let p=[];for(let u of l.namedChildren){if(u.type==="identifier"){p.push(u.text);continue}let d=u.namedChildren.find(m=>m.type==="identifier");d&&p.push(d.text)}if(c.length!==p.length)return!1;for(let u=0;u<p.length;u+=1){let d=c[u];if(d.type!=="identifier"||d.text!==p[u])return!1}return!0}var Gp=new Set(["identifier","type_identifier","field_identifier"]),Up=new Set(["identifier"]),Vp=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),Bp=new Set(["rust","python"]),Hp=/\{([^{}]*)\}/g,qp=/\b([A-Za-z_][\w]*)\b/g;function Wo(e,t){return zp(t).has(e.type)}function Go(e,t){return Bp.has(t)&&e.type==="string_content"}function dn(e){let t=0;for(let n of e.values()){let i=n[n.length-1];i!==void 0&&i>t&&(t=i)}let r=new Array(t+1);for(let n=0;n<=t;n+=1)r[n]=new Set;for(let[n,i]of e)for(let o of i)r[o].add(n);return r}function zp(e){return e==="rust"?Gp:e==="python"?Up:Vp}function Uo(e,t){let r=e.startPosition.row;for(let n of e.text.matchAll(Hp)){let i=n[1]??"";for(let o of i.matchAll(qp))o[1]&&t(o[1],r)}}var Yp=[/\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],Jp=/^#!?\[\s*serde\s*\(/,Kp=/^#!?\[\s*schemars\s*\(/,Xp=/^#!?\[\s*validate\s*\(/,Qp=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function Vo(e,t,r){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript"||e.type!=="call_expression")return;let n=e.childForFieldName("function")??e.namedChild(0);if(!n)return;let i=xe(n);if(!i||!Qp.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&&r.add(a.text)}function Bo(e,t){let r=Jp.test(e),n=Kp.test(e),i=Xp.test(e);if(!(!r&&!n&&!i))for(let o of Yp){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 Ho(e,t){let r=new Map,n=(s,a)=>{if(s===a)return;let c=r.get(s);c||(c=new Set,r.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&&n(l.text,a);for(let p of l.children)c(p)};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(p=>p.type==="identifier")?.text;if(!a)continue;let c=s.childForFieldName("superclasses");c&&o(c,a);let l=s.namedChildren.find(p=>p.type==="block");if(l)for(let p of l.descendantsOfType("type"))for(let u of p.descendantsOfType("identifier"))u.text!==a&&n(u.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 r}var Zp=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),fn=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 qo(e){let t=[],r=[],n=[],i=new Map,o=[],s=0,a=0,c=(l,p)=>{let u=i.get(l);if(!u){i.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)};for(;a<e.length;){let l=e[a];if(l===`
113
+ `){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=Yt(e,a);continue}if(l==='"'){let h=pt(e,a,s);s=h.line,a=h.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 h=o.pop();h&&(h.endLine=s,eu(h,{callables:t,callSites:r,clojureMembers:n,recordIdentifier:c}),o[o.length-1]?.children.push(h)),a+=1;continue}if(mn(l)){a+=1;continue}let p=s,u=a;for(;a<e.length&&!gn(e[a]);)a+=1;let d=e.slice(u,a);if(!d)continue;let m={text:d,line:p};tu(o[o.length-1],m),c(F(d),p)}return{language:"clojure",callables:t,callSites:r,clojureMembers:n,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:su(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function eu(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let r=e.headTokens[0],n=F(r.text),i=Zp.get(r.text);if(i){let s=e.headTokens[1];if(s){let a=F(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(ru(e,t),!n||fn.has(r.text)||fn.has(n)||n.startsWith(":"))return;let o=ou(r.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:r.line})}function tu(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function ru(e,t){let r=F(e.tokens[0]?.text??"");if(r==="defprotocol"){let n=F(e.tokens[1]?.text??"");if(!n)return;for(let i of zt(e))lt(t,n,"protocol",i,"protocol-method");return}if(r==="defrecord"||r==="deftype"){let n=F(e.tokens[1]?.text??"");if(!n)return;let i=r==="defrecord"?"record":"type",o=r==="defrecord"?"record-method":"type-method";for(let s of zt(e))lt(t,n,i,s,o);return}if(r==="extend-type"){let n=F(e.tokens[1]?.text??"");if(!n)return;for(let i of zt(e))lt(t,n,"extension",i,"extension-method");return}if(r==="extend-protocol"){let n=F(e.tokens[1]?.text??"");for(let i of zt(e)){n&&lt(t,n,"extension",i,"extension-method");let o=iu(e,i.startLine);o&&o!==n&&lt(t,o,"extension",i,"extension-method")}}}function zt(e){return e.children.filter(nu)}function nu(e){if(e.kind!=="(")return!1;let t=F(e.tokens[0]?.text??"");return!!(t&&!fn.has(t)&&!t.startsWith(":"))}function lt(e,t,r,n,i){let o=n.tokens[0],s=F(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:r,memberName:s,memberKind:i,startLine:n.startLine,endLine:n.endLine}))}function iu(e,t){let r=null;for(let n=2;n<e.tokens.length;n+=1){let i=e.tokens[n];if(i.line>t)break;let o=F(i.text);o&&!o.startsWith(":")&&(r=o)}return r}function F(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function ou(e){let t=e.replace(/^#?['`~@]+/,""),r=t.lastIndexOf("/"),n=F(t);if(r<=0)return{leaf:n,text:t};let i=t.slice(0,r);return{leaf:n,qualifier:i,text:t}}function Yt(e,t){let r=t;for(;r<e.length&&e[r]!==`
114
+ `;)r+=1;return r}function pt(e,t,r){let n=t+1,i=r;for(;n<e.length;){let o=e[n];if(o==="\\"){n+=2;continue}if(o===`
115
+ `&&(i+=1),n+=1,o==='"')break}return{index:n,line:i}}function mn(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function gn(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function su(e){let t=[];for(let[r,n]of e)for(let i of n)t[i]??=new Set,t[i].add(r);return t}var zo=3,au=Ce("source-facts",{clearGroups:["whole-project","source-file"]}),hn=nt({kind:"source-facts",invalidation:it("source-facts"),serialize:uu,deserialize:du});function Yo(e,t){return cu(e,t).facts}function cu(e,t){let r=_(e,t);if(!r)return{facts:null};let n=lu(e,t,r);return n?au.get(e,t,r,()=>pu(e,t,n,r)):{facts:null}}function lu(e,t,r){return be(t)?qt(e,t,r)?.language??null:Se(t)}function pu(e,t,r,n){let i=$e(e,t,n),o=hn.read(e,t,i);if(o&&o.language===r)return{facts:o};if(r==="clojure"){let c=qo(n);return hn.write(e,t,i,c),{facts:c}}let s=V(e,t);if(!s)return{facts:null,unavailable:{language:r,reason:"parser-unavailable"}};let a=fu(s,r);return hn.write(e,t,i,a),{facts:a}}function uu(e){let t={version:zo,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([r,n])=>[r,[...n]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function du(e){try{let t=JSON.parse(e);if(t.version!==zo||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(n=>n.calleeText===void 0)))return null;let r=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([n,i])=>[n,new Set(i)])),identifierLineMap:r,identifiersByLine:dn(r),fileIdentifiers:new Set(r.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function fu(e,t){let r=[],n=[],i=new Set,o=new Set,s=new Map,a=(l,p)=>{let u=s.get(l);if(!u){s.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)},c=l=>{let p=Mo(l,t);p&&r.push(p);let u=Ao(l,t);u&&n.push(u),Vo(l,t,o),t==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&Bo(l.text,i),Wo(l,t)&&a(l.text,l.startPosition.row),Go(l,t)&&Uo(l,a);for(let d of l.children)c(d)};return c(e.rootNode),{language:t,callables:r,callSites:n,clojureMembers:[],typeContainerMap:Ho(e,t),identifierLineMap:s,identifiersByLine:dn(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var mu=new Set(["rust","typescript","tsx","javascript","python","clojure"]);function gu(e,t){let r=Yo(e,t);return!r||!mu.has(r.language)?null:r.callables.map(n=>({name:n.name,startLine:n.startLine,endLine:n.endLine}))}function Jo(e,t){return e.split(t).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")}var hu=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function P(e){let t=[],r=0,n=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&r++,(o==="}"||o==="]"||o===")")&&r--,o===","&&r===0&&(t.push(e.slice(n,i)),n=i+1)}return t.push(e.slice(n)),t}function D(e,t){for(let r of e.namedChildren)if(r.type===t)return r;return null}function S(e,t){let r=new Set,n=(i,o)=>{let s=o||t.has(i.type);!s&&hu.has(i.type)&&r.add(i.text);for(let a of i.children)n(a,s)};return n(e.rootNode,!1),r}function G(e,t,r,n,i,o,s){return{importedName:i,localName:o,sourcePath:s??y(e,n,nn(t)),kind:"named",used:T(r,o),usedMembers:[]}}function g(e,t,r,n,i="named",o={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function K(e,t,r,n,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n,usedMembers:o,isTypeOnly:s.isTypeOnly}}function ve(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function Ie(e,t,r={}){return{importedName:e,localName:r.localName??null,sourcePath:t,kind:"namespace",used:r.used??!0,usedMembers:r.usedMembers??[],isTypeOnly:r.isTypeOnly}}function O(e,t,r){let n=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=ae(e,i.index,i.index+o.length);for(let a of r(i,s))n.push(a)}return n}function L(e,t,r,n){let i=V(e,t);if(i){let o=r(i);if(o)return o}return n()}function Jt(e,t,r,n){let i=V(e,t),o=Se(t),s=o?r[o]:void 0;return i&&s?s(i):n()}function Xo(e,t,r){return L(e,t,n=>Su(e,t,n),()=>yu(e,t,r))}function yu(e,t,r){return O(r,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(n,i)=>{let o=n[1]?.trim();if(!o)return[];let s=Ko(o).replace(/\.[^.]+$/,"");return[K(o,s,Wt(e,t,o),T(i,s))]})}function Su(e,t,r){let n=S(r,new Set(["preproc_include"])),i=[];for(let o of r.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(p=>p.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=Ko(s).replace(/\.[^.]+$/,"");i.push(g(s,a,Wt(e,t,s),n))}return i}var bu=new Set([":require",":require-macros",":use"]),bn=String.raw`A-Za-z0-9_$*+!?.<>=-`;function Zo(e,t,r){let n=Nu(r);if(!n)return[];let i=Ru(r,n.start,n.end),o=[];for(let s of n.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=M(s.children[0]);if(a){if(bu.has(a)){for(let c of Iu(s.children.slice(1)))o.push(...vu(e,c,i));continue}if(a===":import")for(let c of wu(s.children.slice(1)))o.push(c)}}return o}function xu(e){return e.type==="list"&&M(e.children[0])==="ns"}function vu(e,t,r){let n=on(e,t.namespace),i=t.alias??t.namespace,o=Tu(r,i),s=[{importedName:t.namespace,localName:i,sourcePath:n,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||Pu(r,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:n,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:n,kind:"named",used:ku(r,a),usedMembers:[]});return s}function Iu(e){return e.flatMap(t=>Kt(t,null))}function Kt(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:Sn(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&M(e.children[0])===null?e.children.flatMap(r=>Kt(r,t)):Eu(e,t);if(e.type==="list"&&e.children.length>0){let r=M(e.children[0]);return r?!r||r.startsWith(":")?[]:e.children.slice(1).flatMap(n=>Kt(n,Sn(t,r))):e.children.flatMap(n=>Kt(n,t))}return[]}function Eu(e,t){let r=M(e.children[0]);if(!r||r.startsWith(":"))return[];let n={namespace:Sn(t,r),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=M(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){n.alias=M(s),i+=1;continue}o===":refer"&&s&&(M(s)===":all"?n.referAll=!0:(s.type==="vector"||s.type==="list")&&n.refers.push(...s.children.map(M).filter(Cu)),i+=1)}return[n]}function wu(e){let t=[];for(let r of e){if(r.type==="atom"){let i=r.text.split(".").pop()??r.text;t.push(K(i,i,null,!0));continue}if(r.type!=="vector")continue;let n=M(r.children[0]);if(n)for(let i of r.children.slice(1)){let o=M(i);o&&t.push(K(`${n}.${o}`,o,null,!0))}}return t}function Sn(e,t){return e?`${e}.${t}`:t}function M(e){return e?.type==="atom"?e.text:null}function Cu(e){return!!(e&&!e.startsWith(":"))}function Tu(e,t){let r=new Set,n=new RegExp(`${xn()}${ye(t)}\\s*/\\s*([${bn}]+)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function Pu(e,t){return new RegExp(`${xn()}${ye(t)}\\s*/`,"m").test(e)}function ku(e,t){return new RegExp(`${xn()}${ye(t)}(?![${bn}])`,"m").test(e)}function xn(){return`(?<![${bn}])`}function Ru(e,t,r){let n="",i=0;for(;i<e.length;){if(i>=t&&i<r){n+=e[i]===`
116
+ `?`
117
+ `:" ",i+=1;continue}let o=e[i];if(o===";"){let s=Yt(e,i);n+=Qo(e.slice(i,s)),i=s;continue}if(o==='"'){let s=pt(e,i,0).index;n+=Qo(e.slice(i,s)),i=s;continue}n+=o,i+=1}return n}function Nu(e){let t=0;for(;t<e.length&&(t=vn(e,t),!(t>=e.length));){let r=Xt(e,t);if(!r){t+=1;continue}if(xu(r.form))return r.form;t=r.index}return null}function Xt(e,t){let r=vn(e,t);if(e.startsWith("#?@",r)||e.startsWith("#?",r))return _u(e,r);if(e.startsWith("#_",r)){let i=Xt(e,r+2);return i?{form:{type:"atom",text:"",start:r,end:i.index},index:i.index}:null}for(;mn(e[r]);)r+=1;let n=e[r];return n?n==="("?yn(e,r,"list",")"):n==="["?yn(e,r,"vector","]"):n==="{"?yn(e,r,"map","}"):n==='"'?{form:{type:"atom",text:"",start:r,end:pt(e,r,0).index},index:pt(e,r,0).index}:Au(e,r):null}function _u(e,t){let r=e.startsWith("#?@",t)?3:2,n=Xt(e,t+r);return n?{form:{type:"list",children:n.form.type==="list"||n.form.type==="vector"||n.form.type==="map"?Du(n.form.children):[],start:t,end:n.index},index:n.index}:null}function Du(e){let t=[];for(let r=0;r<e.length;r+=2){let n=M(e[r]),i=e[r+1];n?.startsWith(":")&&i&&t.push(i)}return t}function yn(e,t,r,n){let i=[],o=t+1;for(;o<e.length;){if(o=vn(e,o),e[o]===n)return{form:{type:r,children:i,start:t,end:o+1},index:o+1};let s=Xt(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:r,children:i,start:t,end:e.length},index:e.length}}function Au(e,t){let r=t;for(;r<e.length&&!gn(e[r]);)r+=1;return{form:{type:"atom",text:e.slice(t,r),start:t,end:r},index:r}}function vn(e,t){let r=t;for(;r<e.length;){let n=e[r];if(/\s|,/.test(n)){r+=1;continue}if(n===";"){r=Yt(e,r);continue}break}return r}function Qo(e){return e.replace(/[^\r\n]/g," ")}function es(e,t,r){let n=[];for(let i of r.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=ae(r,i.index,i.index+a.length);n.push({importedName:o,localName:s,sourcePath:Gt(e,t,o),kind:s?"namespace":"side-effect",used:s?T(c,s):!0,usedMembers:s?Fe(c,s):[]})}return n}function ts(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&n.push({specifier:o,sourcePath:Gt(e,t,o)})}return n}function rs(e,t,r){return Jt(e,t,{csharp:n=>Fu(e,t,n),vb:n=>ju(e,t,n)},()=>{let n=Eo(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return O(r,n,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,p=(l?c:a)?.trim()??s,u=p.split(".").pop()??p,d=l?a?.trim()??u:u;return[G(e,t,o,p,u,d,y(e,p,ie))]})})}function ju(e,t,r){let n=S(r,new Set(["imports_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(d=>d.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,p=l.split(".").pop()??l,u=c?.text??p;i.push(g(p,u,y(e,l,ie),n,c?"namespace":"named"))}return i}function Fu(e,t,r){let n=S(r,new Set(["using_directive"])),i=[];for(let o of r.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,p=l.split(".").pop()??l,u=a?.text??p;i.push(g(p,u,y(e,l,ie),n,a?"namespace":"named"))}return i}var Ou=x("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function ns(e,t){return Ou.get(e,t,()=>{let r=new Set,n=_(e,t);if(!n)return r;let o=n.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))r.add(s[0]);return r})}function In(e,t,r){return L(e,t,n=>Mu(e,t,n),()=>Lu(e,t,r))}function Lu(e,t,r){return Ju(r).flatMap(n=>Ku(e,t,n.clause,n.specifier,n.start,n.end,r))}function Mu(e,t,r){let n=$u(e,t,r),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))i.push(...Wu(e,t,r,o,n));return i}function $u(e,t,r){let n=S(r,new Set(["import_statement"]));if(be(t))for(let i of ns(e,t))n.add(i);return n}function Wu(e,t,r,n,i){let o=Hu(n);if(!o)return[];let s=oe(e,t,o),a=D(n,"import_clause");return a?Gu(r,a,s,i,qu(n.text)):[ve("*",s)]}function Gu(e,t,r,n,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(Uu(s.text,r,n,i));else if(s.type==="namespace_import"){let a=Vu(e,s,r,n,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...Bu(s,r,n,i));return o}function Uu(e,t,r,n){return g("default",e,t,r,"default",{isTypeOnly:n})}function Vu(e,t,r,n,i){let s=D(t,"identifier")?.text??"";if(!s)return null;let a=Yu(e,s);return Ie("*",r,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||n.has(s)})}function Bu(e,t,r,n){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(g(c,l,t,r,"named",{isTypeOnly:n||zu(o.text)}))}return i}function Hu(e){let t=D(e,"string");if(!t)return null;let r=D(t,"string_fragment");return r?r.text:null}function qu(e){return/^\s*import\s+type\b/.test(e)}function zu(e){return/^\s*type\b/.test(e.trim())}function Yu(e,t){let r=new Set;for(let n of e.rootNode.descendantsOfType("member_expression")){let i=n.namedChild(0),o=n.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&r.add(o.text)}return[...r]}function Ju(e){let t=[],r=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){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 n=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){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 Ku(e,t,r,n,i,o,s){let a=oe(e,t,n),c=ae(s,i,o);return r?Xu(r).map(p=>({...p,sourcePath:a})).map(p=>{if(p.kind==="namespace"){let u=Fe(c,p.localName);return Ie(p.importedName,p.sourcePath,{localName:p.localName,usedMembers:u,used:u.length>0||T(c,p.localName),isTypeOnly:p.isTypeOnly})}return p.kind==="side-effect"?ve(p.importedName,p.sourcePath):K(p.importedName,p.localName??"",p.sourcePath,p.localName?T(c,p.localName):!1,p.kind,[],{isTypeOnly:p.isTypeOnly})}):[ve("*",a)]}function Xu(e){let t=e.trim(),r=/^type\b/.test(t),n=t.replace(/^type\s+/,""),[i,o]=Qu(n),s=[];return i&&s.push(...is(i,r)),o&&s.push(...is(o,r)),s}function is(e,t){let r=e.trim();if(!r)return[];if(r.startsWith("{")){let n=r.slice(1,-1).trim();return n?P(n).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 r.startsWith("* as ")?[{importedName:"*",localName:r.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:r,kind:"default",isTypeOnly:t}]}function Qu(e){let t=0;for(let r=0;r<e.length;r++){let n=e[r];if(n==="{"&&t++,n==="}"&&t--,n===","&&t===0)return[e.slice(0,r).trim(),e.slice(r+1).trim()]}return[e.trim(),null]}function En(e,t,r){let n=V(e,t);return n?id(e,t,n):Zu(e,t,r)}function Zu(e,t,r){return[...ed(e,t,r),...td(e,t,r),...rd(e,t,r)]}function ed(e,t,r){let n=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=P(s).map(u=>nd(u.trim())).filter(u=>!!u),l=Oe(r,o.index),p=Oe(r,o.index+o[0].length-1);n.push({kind:"named",sourcePath:oe(e,t,a),names:c,startLine:l,endLine:p})}return n}function td(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=Oe(r,o.index),c=Oe(r,o.index+o[0].length-1);n.push({kind:"star-as",sourcePath:oe(e,t,s),names:[],startLine:a,endLine:c})}return n}function rd(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=Oe(r,o.index),c=Oe(r,o.index+o[0].length-1);n.push({kind:"star",sourcePath:oe(e,t,s),names:[],startLine:a,endLine:c})}return n}function nd(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let r=t.match(/^(\w+)\s+as\s+(\w+)$/);if(r)return r[2]??null;let n=t.match(/^(\w+)$/);return n?n[1]??null:null}function Oe(e,t){let r=0;for(let n=0;n<t&&n<e.length;n++)e.charCodeAt(n)===10&&r++;return r}function id(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("export_statement")){let o=od(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=sd(i,o,s,a);n.push(c)}return n}function od(e,t,r){let n=D(r,"string");if(!n)return;let i=D(n,"string_fragment");if(i)return oe(e,t,i.text)}function sd(e,t,r,n){let i=D(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:r,endLine:n}}return D(e,"namespace_export")?{kind:"star-as",sourcePath:t,names:[],startLine:r,endLine:n}:{kind:"star",sourcePath:t,names:[],startLine:r,endLine:n}}function os(e,t,r){return Jt(e,t,{java:n=>ad(e,t,n),kotlin:n=>cd(e,t,n),scala:n=>ld(e,t,n)},()=>O(r,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(n,i)=>{let o=n[1]?.trim();return o?pd(e,t,o,i):[]}))}function ad(e,t,r){let n=S(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(u=>u.type==="asterisk"),c=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(Ie("*",y(e,l,N)));continue}let p=l.split(".").pop()??l;i.push(g(p,p,y(e,l,N),n))}return i}function cd(e,t,r){let n=S(r,new Set(["import_header","import_list"])),i=[];for(let o of r.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(m=>m.type==="identifier");if(!s)continue;let a=o.namedChildren.some(m=>m.type==="wildcard_import"),c=o.namedChildren.find(m=>m.type==="import_alias");if(a){i.push(Ie("*",y(e,s.text,N)));continue}let l=s.text,p=l.split(".").pop()??l,d=c?.namedChild(0)?.text??p;i.push(g(p,d,y(e,l,N),n))}return i}function ld(e,t,r){let n=S(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),a=o.namedChildren.filter(u=>u!==s&&(u.type==="identifier"||u.type==="stable_identifier")),c=a.map(u=>u.text).join(".");if(!c)continue;if(s?.type==="namespace_wildcard"){i.push(Ie("*",y(e,c,N)));continue}if(s?.type==="namespace_selectors"){for(let u of s.namedChildren)if(u.type==="arrow_renamed_identifier"){let[d,m]=u.namedChildren;if(!d)continue;let h=d.text,Ee=m?.text??h;if(h==="_")continue;i.push(g(h,Ee,y(e,`${c}.${h}`,N),n))}else if(u.type==="identifier"){let d=u.text;i.push(g(d,d,y(e,`${c}.${d}`,N),n))}continue}let l=a[a.length-1]?.text??c,p=a.slice(0,-1).map(u=>u.text).join(".")||c;i.push(g(l,l,y(e,p&&a.length>1?`${p}.${l}`:c,N),n))}return i}function pd(e,t,r,n){if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/\.$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return P(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),p=c?.trim();if(!p||p==="_")return[];let u=(l??p.split(".").pop()??p).trim(),d=p==="_"?i:`${i}.${p}`.replace(/\.\./g,".");return[G(e,t,n,d,p,u)]})}return[G(e,t,n,r,r.split(".").pop()??r,r.split(".").pop()??r)]}function as(e,t,r){return L(e,t,n=>ud(e,t,n),()=>O(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?P(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),p=c?.trim()??a,u=p.split("\\").pop()??p,d=(l??u).trim();return[G(e,t,i,p,u,d,y(e,p.replace(/\\/g,"."),he))]}):[]}))}function ud(e,t,r){let n=S(r,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(g(a,c,y(e,s.replace(/\\/g,"."),he),n))};for(let s of r.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:p,localName:u,qualified:d}=ss(l,c);p&&o(d,p,u)}continue}for(let c of s.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:p,qualified:u}=ss(c,"");l&&o(u,l,p)}}return i}function ss(e,t){let r=e.namedChildren.find(l=>l.type==="qualified_name"),n=e.namedChildren.filter(l=>l.type==="name"),i="";r?i=r.text:n.length>=1&&(i=n[0].text);let o=r&&n.length>0?n[n.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 ls(e,t,r){return L(e,t,n=>dd(e,t,n),()=>md(r).flatMap(n=>hd(e,t,n,r)))}function dd(e,t,r){let n=S(r,new Set(["import_statement","import_from_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=cs(s);if(!a)continue;let c=je(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:n.has(a.localName),usedMembers:[]})}for(let o of r.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=fd(s);if(a===null)continue;let c=je(e,t,a);for(let l=1;l<o.namedChildCount;l+=1){let p=o.namedChild(l);if(p.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=cs(p);u&&i.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:c,kind:"named",used:n.has(u.localName),usedMembers:[]})}}return i}function cs(e){if(e.type==="aliased_import"){let t=e.namedChild(0),r=e.namedChild(1);return!t||!r?null:{qualifiedName:t.text,localName:r.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 fd(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=D(e,"import_prefix")?.text??"",r=D(e,"dotted_name")?.text??"";return`${t}${r}`}return null}function md(e){let t=e.split(`
118
+ `),r=[],n=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=n;if(n+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,p=ln(o);for(;i+1<t.length&&(p>0||c.trimEnd().endsWith("\\"));){i++;let d=t[i];c+=`
119
+ ${d}`,l+=1+d.length,p+=ln(d),n+=d.length+1}let u=gd(c);u&&r.push({...u,start:a,end:l})}return r}function gd(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let r=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!r)return null;let n=r[2].trim();return n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim()),{kind:"from",module:r[1],clause:n}}function hd(e,t,r,n){let i=ae(n,r.start,r.end),o=r.clause.replace(/\n/g," ").trim();if(r.kind==="import")return P(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[p,u]=l.split(/\s+as\s+/),d=p.trim(),m=(u??d.split(".")[0]??d).trim(),h=je(e,t,d),Ee=Fe(i,m);return[{importedName:d,localName:m,sourcePath:h,kind:"namespace",used:T(i,m)||Ee.length>0,usedMembers:Ee}]});let s=r.module?je(e,t,r.module):null,a=[];for(let c of P(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[p,u]=l.split(/\s+as\s+/),d=(u??p).trim();a.push({importedName:p.trim(),localName:d,sourcePath:s,kind:"named",used:T(i,d),usedMembers:[]})}return a}import{basename as yd}from"path";function ps(e,t,r){return L(e,t,n=>bd(e,t,n),()=>Sd(e,t,r))}function Sd(e,t,r){return O(r,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(n,i)=>{let o=n[1],s=n[2];if(!o||!s)return[];let a=o==="require_relative"?$t(e,t,s):null;if(a){let c=us(s);return[K(c,c,a,T(i,c))]}return[ve(s,a)]})}function bd(e,t,r){let n=S(r,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of r.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=s.namedChildren.find(m=>m.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let u=l.namedChildren.find(m=>m.type==="string_content")?.text;if(!u)continue;let d=a.text==="require_relative"?$t(e,t,u):null;if(d){let m=us(u);i.push(g(m,m,d,n))}else i.push(ve(u,d))}return i}function us(e){return Jo(yd(e).replace(/\.[^.]+$/,""),/_/)}function ds(e,t,r){return L(e,t,n=>xd(e,t,n),()=>O(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?vd(e,t,o,i):[]}))}function xd(e,t,r){let n=S(r,new Set(["use_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of ut(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=Y(e,t,a.qualifiedName)??Y(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(g(a.importedName,a.localName,c,n))}}return i}function ut(e,t){switch(e.type){case"identifier":case"super":case"crate":{let r=e.text;return[{qualifiedName:Qt(t,r),importedName:r,localName:r}]}case"self":{let r=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:r,localName:r}]}case"scoped_identifier":{let r=e.text,n=r.split("::").pop()??r;return[{qualifiedName:Qt(t,r),importedName:n,localName:n}]}case"scoped_use_list":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=Qt(t,r.text),o=[];for(let s of n.namedChildren)o.push(...ut(s,i));return o}case"use_list":{let r=[];for(let n of e.namedChildren)r.push(...ut(n,t));return r}case"use_as_clause":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=ut(r,t),o=n.text;return i.map(s=>({...s,localName:o}))}case"use_wildcard":{let r=e.namedChild(0),n=r?r.text:"";return[{qualifiedName:Qt(t,`${n}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Qt(e,t){return e?t?`${e}::${t}`:e:t}function vd(e,t,r,n){let i=r.trim();if(i.includes("{")&&i.includes("}")){let p=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),u=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return P(u).flatMap(d=>{let m=d.trim();if(!m)return[];if(m==="self"){let Zt=p.split("::").filter(Boolean).pop();return Zt?[G(e,t,n,p,Zt,Zt)]:[]}let[h,Ee]=m.split(/\s+as\s+/),we=h?.trim();if(!we)return[];let ys=(Ee??we.split("::").pop()??we).trim(),Ss=`${p}::${we}`.replace(/::::/g,"::");return[G(e,t,n,Ss,we.split("::").pop()??we,ys,Y(e,t,p))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=Y(e,t,a)??Y(e,t,a.split("::").slice(0,-1).join("::"));return[G(e,t,n,a,a.split("::").pop()??a,c,l)]}function fs(e,t,r){let n=V(e,t);if(n)return Id(e,t,n);let i=[];for(let o of r.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...wd(e,t,s))}return i}function Id(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("use_declaration")){if(!Ed(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of ut(o,""))s.importedName&&n.push(wn(e,t,s.qualifiedName))}return n}function Ed(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function wd(e,t,r){let n=r.trim();if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/::$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return P(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[wn(e,t,l)]})}return[wn(e,t,n)]}function wn(e,t,r){return{specifier:r,sourcePath:Y(e,t,r)??Y(e,t,r.split("::").slice(0,-1).join("::"))}}function ce({language:e,extensions:t,imports:r,parseImports:n}){return{language:e,extensions:t,capabilities:{imports:r},parseImports:n}}function ms(e,t){let r=t.toLowerCase();for(let n of e)for(let i of n.extensions)if(r.endsWith(i))return n;return null}var Cd={language:"javascript",extensions:me,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:In,parseReExports:En},Td=ce({language:"python",extensions:jt,imports:"ast-with-regex-fallback",parseImports:ls}),Pd=ce({language:"jvm",extensions:N,imports:"ast-dispatch-with-regex-fallback",parseImports:os}),kd={language:"rust",extensions:Ft,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:ds,parseExports:fs},Rd=ce({language:"ruby",extensions:Ot,imports:"ast-with-regex-fallback",parseImports:ps}),Nd=ce({language:"c/cpp",extensions:Lt,imports:"ast-with-regex-fallback",parseImports:Xo}),_d=ce({language:"dotnet",extensions:ie,imports:"ast-dispatch-with-regex-fallback",parseImports:rs}),Dd={language:"dart",extensions:Mt,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:es,parseExports:ts},Ad=ce({language:"php",extensions:he,imports:"ast-with-regex-fallback",parseImports:as}),jd=ce({language:"clojure",extensions:Ae,imports:"regex-only",parseImports:Zo}),Fd=[Cd,Td,Pd,kd,Rd,Nd,_d,Dd,Ad,jd];function Cn(e){return ms(Fd,e)}var Tn={clearGroups:["whole-project","source-file"]},Od=x("source-imports",Tn),_S=x("source-exports",Tn),Ld=x("source-reexports",Tn),gs=nt({kind:"source-imports",invalidation:it("source-imports"),serialize:Md,deserialize:$d}),hs=nt({kind:"source-reexports",invalidation:it("source-reexports"),serialize:Wd,deserialize:Gd});function DS(e,t){let r=C(t);return Ld.get(e,r,()=>{let n=Cn(r);if(!n?.parseReExports)return[];let i=_(e,r);if(!i)return[];let o=$e(e,r,i),s=cn(e),a=hs.read(e,r,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=n.parseReExports(e,r,i);return hs.write(e,r,o,{resolutionFingerprint:s,reExports:c}),c})}function AS(e,t){let r=C(t);return Od.get(e,r,()=>{let n=Cn(r);if(!n)return[];let i=_(e,r);if(!i)return[];let o=$e(e,r,i),s=cn(e),a=gs.read(e,r,o);if(a?.resolutionFingerprint===s)return a.imports;let c=n.parseImports(e,r,i);return gs.write(e,r,o,{resolutionFingerprint:s,imports:c}),c})}function Md(e){return JSON.stringify(e)}function $d(e){try{let t=JSON.parse(e);return!ke(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function Wd(e){return JSON.stringify(e)}function Gd(e){try{let t=JSON.parse(e);return!ke(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}export{Wn as a,ma as b,Cf as c,zn as d,mr as e,Kn as f,yt as g,$e as h,Qn as i,$f as j,nt as k,kg as l,it as m,_ as n,nh as o,V as p,cu as q,gu as r,_g as s,ho as t,_l as u,oe as v,ke as w,br as x,ye as y,DS as z,AS as A,Ts as B,Ps as C,As as D,Jd as E,Fs as F,Kd as G,Xd as H,Qd as I,Zd as J,Sl as K,Ag as L,xl as M,Og as N,Lg as O,Mg as P,Wg as Q,Bf as R,Hf as S,Oa as T,qf as U,Xf as V,rm as W,cm as X,lm as Y,pf as Z,uf as _,Fn as $,pr as aa,dr as ba,df as ca,bm as da,xm as ea,vm as fa,Im as ga,Rm as ha,Nm as ia,_m as ja,Dm as ka,Wi as la,Mm as ma,Fr as na,ug as oa,dg as pa,fg as qa,Qe as ra,mg as sa,gg as ta,hg as ua,Xc as va,Qc as wa,vg as xa,Ig as ya,sa as za,yf as Aa,Sf as Ba,bf as Ca};
120
+ //# sourceMappingURL=chunk-L7UITWFE.js.map
@@ -1,2 +1,2 @@
1
- import{j as I}from"./chunk-DA34GNNO.js";import{a as y,e as g}from"./chunk-OO6S4ECV.js";import{B as v}from"./chunk-MCNWCJYL.js";import{c as b,h as D,i as _,q as F,s as p,v as E,x}from"./chunk-WFRZGMWJ.js";import{spawnSync as O}from"child_process";import{createHash as U}from"crypto";import{existsSync as k}from"fs";import{dirname as L,join as T}from"path";import{fileURLToPath as j}from"url";var N=b("definition-consumer-file-usage",{clearGroups:["whole-project","source-file"]}),M=E({kind:"consumer-file-usage",invalidation:x("consumer-file-usage"),serialize:Q,deserialize:W});function Le(e,n){return{forDefinitions(r,i){return V(e,n,r,i)}}}function Me(e){let n=new Map;for(let[r,i]of e)n.set(r,new Set(i.files.map(t=>t.file)));return n}function Re(e,n,r){return w(e,n,r).partition}function V(e,n,r,i){let t=h(r.length),s=F()?_(e):null,a=s?B(r,i,s):void 0,o=a?{workIdentity:a,workOutcome:"computed"}:{};return p("consumer-evidence.product",()=>{let l=p("consumer-evidence.provenance",()=>z(e,n,r,i),()=>({...o,definitions:r.length,semantic:i.semantic,sourceFallback:i.sourceFallback!==!1})),u=new Map;t={...t,...l.counters};let c=Y(r,l.sources);return p("consumer-evidence.classify",()=>{let f=q(e,r,l.sources,c);for(let d of r){let m=f.get(d.symbolId)??H();t.realFiles+=m.partition.realConsumers.length,t.reexportOnlyFiles+=m.partition.barrelConsumers,t.importOnlyFiles+=m.partition.importOnlyConsumers,u.set(d.symbolId,{definition:d,files:m.files,...m.partition})}},()=>({...o,...c,realFiles:t.realFiles,reexportOnlyFiles:t.reexportOnlyFiles,importOnlyFiles:t.importOnlyFiles})),u},()=>({...o,...t}))}function B(e,n,r){let i=U("sha256").update("consumer-evidence-v1\0").update(r).update("\0").update(n.semantic?"semantic\0":"indexed\0").update(n.sourceFallback===!1?"no-source-fallback":"source-fallback");for(let t of e.map(s=>s.symbol).sort())i.update("\0").update(t);return i.digest("hex").slice(0,24)}function h(e){return{definitions:e,indexedFiles:0,semanticFiles:0,fallbackFiles:0,totalFiles:0,realFiles:0,reexportOnlyFiles:0,importOnlyFiles:0}}function z(e,n,r,i){let t=h(r.length),s=new Map;return S(s,t,"indexed",n.crossFileCallerMap(r,{semantic:!1})),i.semantic&&S(s,t,"semantic",I(e,r)),i.sourceFallback!==!1&&S(s,t,"source-fallback",n.sourceFallbackCallerFiles(r)),t.totalFiles=[...s.values()].reduce((a,o)=>a+o.size,0),{sources:s,counters:t}}function Y(e,n){return{definitions:e.length,consumerFiles:[...n.values()].reduce((r,i)=>r+i.size,0),nativeAttempted:!1,nativeUsed:!1,nativeReason:"not-attempted"}}function S(e,n,r,i){let t=0;for(let[s,a]of i){let o=e.get(s);o||(o=new Map,e.set(s,o));for(let l of a){t++;let u=o.get(l)??new Set;u.add(r),o.set(l,u)}}r==="indexed"?n.indexedFiles+=t:r==="semantic"?n.semanticFiles+=t:n.fallbackFiles+=t}function q(e,n,r,i){let t=re(e,n,r,i);return t||$(e,n,r)}function $(e,n,r){let i=new Map;for(let t of n){let s=r.get(t.symbolId)??new Map;i.set(t.symbolId,w(e,t,[...s.keys()],s))}return i}function w(e,n,r,i=new Map){let t=[],s=0,a=0,o=g(n.symbol),l=[];for(let u of r){let c;X(e,u,n.relativePath,o)?(s++,c="reexport-only"):J(e,u,o)?(a++,c="import-only"):(t.push(u),c="real"),l.push({file:u,sources:[...i.get(u)??[]],classification:c})}return{partition:{realConsumers:t,barrelConsumers:s,importOnlyConsumers:a},files:l}}function H(){return{partition:{realConsumers:[],barrelConsumers:0,importOnlyConsumers:0},files:[]}}function J(e,n,r){if(!r)return!1;let i=v(n);if(!i)return!1;let t=N.get(e,n,()=>A(e,n,i));return t.importedLeaves.has(r)&&!t.usedLeaves.has(r)}function A(e,n,r){let i=y(e).forFile(n,{text:!0,ast:!0}),t=i.text;if(!t)return G();let s=D(e,n,t),a=M.read(e,n,s);if(a)return a;let o=K(i.ast,r);return M.write(e,n,s,o),o}function K(e,n){let r=new Set,i=new Set;if(!e)return{importedLeaves:r,usedLeaves:i};let t=n==="rust"?new Set(["use_declaration"]):n==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),s=(a,o)=>{let l=o||t.has(a.type);(a.type==="identifier"||a.type==="type_identifier"||a.type==="property_identifier"||a.type==="field_identifier")&&(l?r.add(a.text):i.add(a.text));for(let u of a.children)s(u,l)};return s(e.rootNode,!1),{importedLeaves:r,usedLeaves:i}}function G(){return{importedLeaves:new Set,usedLeaves:new Set}}function Q(e){return JSON.stringify({importedLeaves:[...e.importedLeaves],usedLeaves:[...e.usedLeaves]})}function W(e){try{let n=JSON.parse(e);return!Array.isArray(n.importedLeaves)||!Array.isArray(n.usedLeaves)?null:{importedLeaves:new Set(n.importedLeaves.filter(r=>typeof r=="string")),usedLeaves:new Set(n.usedLeaves.filter(r=>typeof r=="string"))}}catch{return null}}function X(e,n,r,i){if(!i)return!1;let t=y(e).forFile(n,{lines:!0,reexports:!0}),s=t.lines??[];if(s.length===0)return!1;let a=t.reexports??[];return P(s,a,i)}function P(e,n,r){if(e.length===0||n.length===0)return!1;let i=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),t=new RegExp(`\\b${i}\\b`),s=0;for(let a=0;a<e.length;a++){if(!t.test(e[a]??""))continue;if(s++,!n.find(l=>l.startLine<=a&&a<=l.endLine))return!1}return s>0}var Z="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY",ee="SCIP_QUERY_NATIVE_KERNELS_BIN",ne="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY_MIN_FILES",R=1e3,ie=5e3,te=64*1024*1024,C;function re(e,n,r,i){let t=process.env[Z]?.toLowerCase();if(t!=="1"&&t!=="true")return i.nativeReason=t==="0"||t==="false"?"disabled":"opt-in-required",null;if(i.consumerFiles<fe())return i.nativeReason="below-threshold",null;let s=me();if(!s)return i.nativeReason="binary-missing",null;i.nativeAttempted=!0;let a=se(e,n,r),o=O(s,["consumer-classify"],{input:JSON.stringify(a),encoding:"utf8",timeout:ie,maxBuffer:te});if(o.status!==0||o.error)return i.nativeReason=o.error?`spawn-error:${o.error.message}`:`exit-${o.status??"null"}`,null;try{let l=JSON.parse(o.stdout),u=ae(l,n);return u?(i.nativeUsed=!0,i.nativeReason="used",u):(i.nativeReason="invalid-response",null)}catch{return i.nativeReason="invalid-json",null}}function se(e,n,r){let i=new Map,t=[];for(let o of n){let l=g(o.symbol),c=[...(r.get(o.symbolId)??new Map).entries()].map(([f,d])=>{let m=i.get(f)??new Set;return l&&m.add(l),i.set(f,m),{file:f,sources:[...d]}});t.push({symbol_id:o.symbolId,leaf:l,consumer_files:c})}let s={},a={};for(let[o,l]of i){let u=v(o);if(u){let f=N.get(e,o,()=>A(e,o,u));s[o]={imported_leaves:[...f.importedLeaves],used_leaves:[...f.usedLeaves]}}let c=oe(e,o,l);c.length>0&&(a[o]=c)}return{definitions:t,file_usages:s,reexport_only_leaves:a}}function oe(e,n,r){if(r.size===0)return[];let i=y(e).forFile(n,{lines:!0,reexports:!0}),t=i.lines??[],s=i.reexports??[];return t.length===0||s.length===0?[]:[...r].filter(a=>P(t,s,a))}function ae(e,n){if(!Array.isArray(e.entries)||e.entries.length!==n.length)return null;let r=new Set(n.map(t=>t.symbolId)),i=new Map;for(let t of e.entries){let s=le(t);if(!s||!r.has(s.symbol_id))return null;i.set(s.symbol_id,{partition:{realConsumers:s.real_consumers,barrelConsumers:s.barrel_consumers,importOnlyConsumers:s.import_only_consumers},files:s.files})}for(let t of r)if(!i.has(t))return null;return i}function le(e){if(!e||typeof e!="object")return null;let n=e;if(typeof n.symbol_id!="number"||!Array.isArray(n.real_consumers)||typeof n.barrel_consumers!="number"||typeof n.import_only_consumers!="number"||!Array.isArray(n.files)||!n.real_consumers.every(i=>typeof i=="string"))return null;let r=[];for(let i of n.files){if(!i||typeof i!="object")return null;let t=i;if(typeof t.file!="string"||!Array.isArray(t.sources)||!t.sources.every(ue)||!ce(t.classification))return null;r.push({file:t.file,sources:t.sources,classification:t.classification})}return{symbol_id:n.symbol_id,real_consumers:n.real_consumers,barrel_consumers:n.barrel_consumers,import_only_consumers:n.import_only_consumers,files:r}}function ue(e){return e==="indexed"||e==="semantic"||e==="source-fallback"}function ce(e){return e==="real"||e==="reexport-only"||e==="import-only"}function fe(){let e=process.env[ne];if(!e)return R;let n=Number(e);return Number.isFinite(n)&&n>=0?n:R}function me(){if(C!==void 0)return C;let e=process.env[ee],n=process.platform==="win32"?"scip-query-kernels.exe":"scip-query-kernels";return C=[...e?[e]:[],...de().map(i=>T(i,"target","release",n))].find(i=>k(i))??null,C}function de(){let e=new Set,n=L(j(import.meta.url));for(let r=0;r<5;r++)e.add(n),n=L(n);return[...e]}export{Le as a,Me as b,Re as c,J as d};
2
- //# sourceMappingURL=chunk-CVBS2FD4.js.map
1
+ import{j as I}from"./chunk-QNCVN5EH.js";import{a as y,e as g}from"./chunk-7XP7ZRSI.js";import{B as v}from"./chunk-TLTLJ4SW.js";import{c as b,h as D,i as _,q as F,s as p,v as E,x}from"./chunk-M2TRDR25.js";import{spawnSync as O}from"child_process";import{createHash as U}from"crypto";import{existsSync as k}from"fs";import{dirname as L,join as T}from"path";import{fileURLToPath as j}from"url";var N=b("definition-consumer-file-usage",{clearGroups:["whole-project","source-file"]}),M=E({kind:"consumer-file-usage",invalidation:x("consumer-file-usage"),serialize:Q,deserialize:W});function Le(e,n){return{forDefinitions(r,i){return V(e,n,r,i)}}}function Me(e){let n=new Map;for(let[r,i]of e)n.set(r,new Set(i.files.map(t=>t.file)));return n}function Re(e,n,r){return w(e,n,r).partition}function V(e,n,r,i){let t=h(r.length),s=F()?_(e):null,a=s?B(r,i,s):void 0,o=a?{workIdentity:a,workOutcome:"computed"}:{};return p("consumer-evidence.product",()=>{let l=p("consumer-evidence.provenance",()=>z(e,n,r,i),()=>({...o,definitions:r.length,semantic:i.semantic,sourceFallback:i.sourceFallback!==!1})),u=new Map;t={...t,...l.counters};let c=Y(r,l.sources);return p("consumer-evidence.classify",()=>{let f=q(e,r,l.sources,c);for(let d of r){let m=f.get(d.symbolId)??H();t.realFiles+=m.partition.realConsumers.length,t.reexportOnlyFiles+=m.partition.barrelConsumers,t.importOnlyFiles+=m.partition.importOnlyConsumers,u.set(d.symbolId,{definition:d,files:m.files,...m.partition})}},()=>({...o,...c,realFiles:t.realFiles,reexportOnlyFiles:t.reexportOnlyFiles,importOnlyFiles:t.importOnlyFiles})),u},()=>({...o,...t}))}function B(e,n,r){let i=U("sha256").update("consumer-evidence-v1\0").update(r).update("\0").update(n.semantic?"semantic\0":"indexed\0").update(n.sourceFallback===!1?"no-source-fallback":"source-fallback");for(let t of e.map(s=>s.symbol).sort())i.update("\0").update(t);return i.digest("hex").slice(0,24)}function h(e){return{definitions:e,indexedFiles:0,semanticFiles:0,fallbackFiles:0,totalFiles:0,realFiles:0,reexportOnlyFiles:0,importOnlyFiles:0}}function z(e,n,r,i){let t=h(r.length),s=new Map;return S(s,t,"indexed",n.crossFileCallerMap(r,{semantic:!1})),i.semantic&&S(s,t,"semantic",I(e,r)),i.sourceFallback!==!1&&S(s,t,"source-fallback",n.sourceFallbackCallerFiles(r)),t.totalFiles=[...s.values()].reduce((a,o)=>a+o.size,0),{sources:s,counters:t}}function Y(e,n){return{definitions:e.length,consumerFiles:[...n.values()].reduce((r,i)=>r+i.size,0),nativeAttempted:!1,nativeUsed:!1,nativeReason:"not-attempted"}}function S(e,n,r,i){let t=0;for(let[s,a]of i){let o=e.get(s);o||(o=new Map,e.set(s,o));for(let l of a){t++;let u=o.get(l)??new Set;u.add(r),o.set(l,u)}}r==="indexed"?n.indexedFiles+=t:r==="semantic"?n.semanticFiles+=t:n.fallbackFiles+=t}function q(e,n,r,i){let t=re(e,n,r,i);return t||$(e,n,r)}function $(e,n,r){let i=new Map;for(let t of n){let s=r.get(t.symbolId)??new Map;i.set(t.symbolId,w(e,t,[...s.keys()],s))}return i}function w(e,n,r,i=new Map){let t=[],s=0,a=0,o=g(n.symbol),l=[];for(let u of r){let c;X(e,u,n.relativePath,o)?(s++,c="reexport-only"):J(e,u,o)?(a++,c="import-only"):(t.push(u),c="real"),l.push({file:u,sources:[...i.get(u)??[]],classification:c})}return{partition:{realConsumers:t,barrelConsumers:s,importOnlyConsumers:a},files:l}}function H(){return{partition:{realConsumers:[],barrelConsumers:0,importOnlyConsumers:0},files:[]}}function J(e,n,r){if(!r)return!1;let i=v(n);if(!i)return!1;let t=N.get(e,n,()=>A(e,n,i));return t.importedLeaves.has(r)&&!t.usedLeaves.has(r)}function A(e,n,r){let i=y(e).forFile(n,{text:!0,ast:!0}),t=i.text;if(!t)return G();let s=D(e,n,t),a=M.read(e,n,s);if(a)return a;let o=K(i.ast,r);return M.write(e,n,s,o),o}function K(e,n){let r=new Set,i=new Set;if(!e)return{importedLeaves:r,usedLeaves:i};let t=n==="rust"?new Set(["use_declaration"]):n==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),s=(a,o)=>{let l=o||t.has(a.type);(a.type==="identifier"||a.type==="type_identifier"||a.type==="property_identifier"||a.type==="field_identifier")&&(l?r.add(a.text):i.add(a.text));for(let u of a.children)s(u,l)};return s(e.rootNode,!1),{importedLeaves:r,usedLeaves:i}}function G(){return{importedLeaves:new Set,usedLeaves:new Set}}function Q(e){return JSON.stringify({importedLeaves:[...e.importedLeaves],usedLeaves:[...e.usedLeaves]})}function W(e){try{let n=JSON.parse(e);return!Array.isArray(n.importedLeaves)||!Array.isArray(n.usedLeaves)?null:{importedLeaves:new Set(n.importedLeaves.filter(r=>typeof r=="string")),usedLeaves:new Set(n.usedLeaves.filter(r=>typeof r=="string"))}}catch{return null}}function X(e,n,r,i){if(!i)return!1;let t=y(e).forFile(n,{lines:!0,reexports:!0}),s=t.lines??[];if(s.length===0)return!1;let a=t.reexports??[];return P(s,a,i)}function P(e,n,r){if(e.length===0||n.length===0)return!1;let i=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),t=new RegExp(`\\b${i}\\b`),s=0;for(let a=0;a<e.length;a++){if(!t.test(e[a]??""))continue;if(s++,!n.find(l=>l.startLine<=a&&a<=l.endLine))return!1}return s>0}var Z="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY",ee="SCIP_QUERY_NATIVE_KERNELS_BIN",ne="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY_MIN_FILES",R=1e3,ie=5e3,te=64*1024*1024,C;function re(e,n,r,i){let t=process.env[Z]?.toLowerCase();if(t!=="1"&&t!=="true")return i.nativeReason=t==="0"||t==="false"?"disabled":"opt-in-required",null;if(i.consumerFiles<fe())return i.nativeReason="below-threshold",null;let s=me();if(!s)return i.nativeReason="binary-missing",null;i.nativeAttempted=!0;let a=se(e,n,r),o=O(s,["consumer-classify"],{input:JSON.stringify(a),encoding:"utf8",timeout:ie,maxBuffer:te});if(o.status!==0||o.error)return i.nativeReason=o.error?`spawn-error:${o.error.message}`:`exit-${o.status??"null"}`,null;try{let l=JSON.parse(o.stdout),u=ae(l,n);return u?(i.nativeUsed=!0,i.nativeReason="used",u):(i.nativeReason="invalid-response",null)}catch{return i.nativeReason="invalid-json",null}}function se(e,n,r){let i=new Map,t=[];for(let o of n){let l=g(o.symbol),c=[...(r.get(o.symbolId)??new Map).entries()].map(([f,d])=>{let m=i.get(f)??new Set;return l&&m.add(l),i.set(f,m),{file:f,sources:[...d]}});t.push({symbol_id:o.symbolId,leaf:l,consumer_files:c})}let s={},a={};for(let[o,l]of i){let u=v(o);if(u){let f=N.get(e,o,()=>A(e,o,u));s[o]={imported_leaves:[...f.importedLeaves],used_leaves:[...f.usedLeaves]}}let c=oe(e,o,l);c.length>0&&(a[o]=c)}return{definitions:t,file_usages:s,reexport_only_leaves:a}}function oe(e,n,r){if(r.size===0)return[];let i=y(e).forFile(n,{lines:!0,reexports:!0}),t=i.lines??[],s=i.reexports??[];return t.length===0||s.length===0?[]:[...r].filter(a=>P(t,s,a))}function ae(e,n){if(!Array.isArray(e.entries)||e.entries.length!==n.length)return null;let r=new Set(n.map(t=>t.symbolId)),i=new Map;for(let t of e.entries){let s=le(t);if(!s||!r.has(s.symbol_id))return null;i.set(s.symbol_id,{partition:{realConsumers:s.real_consumers,barrelConsumers:s.barrel_consumers,importOnlyConsumers:s.import_only_consumers},files:s.files})}for(let t of r)if(!i.has(t))return null;return i}function le(e){if(!e||typeof e!="object")return null;let n=e;if(typeof n.symbol_id!="number"||!Array.isArray(n.real_consumers)||typeof n.barrel_consumers!="number"||typeof n.import_only_consumers!="number"||!Array.isArray(n.files)||!n.real_consumers.every(i=>typeof i=="string"))return null;let r=[];for(let i of n.files){if(!i||typeof i!="object")return null;let t=i;if(typeof t.file!="string"||!Array.isArray(t.sources)||!t.sources.every(ue)||!ce(t.classification))return null;r.push({file:t.file,sources:t.sources,classification:t.classification})}return{symbol_id:n.symbol_id,real_consumers:n.real_consumers,barrel_consumers:n.barrel_consumers,import_only_consumers:n.import_only_consumers,files:r}}function ue(e){return e==="indexed"||e==="semantic"||e==="source-fallback"}function ce(e){return e==="real"||e==="reexport-only"||e==="import-only"}function fe(){let e=process.env[ne];if(!e)return R;let n=Number(e);return Number.isFinite(n)&&n>=0?n:R}function me(){if(C!==void 0)return C;let e=process.env[ee],n=process.platform==="win32"?"scip-query-kernels.exe":"scip-query-kernels";return C=[...e?[e]:[],...de().map(i=>T(i,"target","release",n))].find(i=>k(i))??null,C}function de(){let e=new Set,n=L(j(import.meta.url));for(let r=0;r<5;r++)e.add(n),n=L(n);return[...e]}export{Le as a,Me as b,Re as c,J as d};
2
+ //# sourceMappingURL=chunk-LC57FSPX.js.map
@@ -1,4 +1,4 @@
1
- import{a as r}from"./chunk-QB7NRST4.js";function _(e,n,d){let i=r(e,n)??n,o=r(e,d)??d,t=e.get(`SELECT COUNT(DISTINCT gs.id) AS shared
1
+ import{a as r}from"./chunk-5N5ZC566.js";function _(e,n,d){let i=r(e,n)??n,o=r(e,d)??d,t=e.get(`SELECT COUNT(DISTINCT gs.id) AS shared
2
2
  FROM global_symbols gs
3
3
  WHERE (
4
4
  -- Defined in file1, referenced in file2
@@ -53,4 +53,4 @@ import{a as r}from"./chunk-QB7NRST4.js";function _(e,n,d){let i=r(e,n)??n,o=r(e,
53
53
  GROUP BY def_d.id, ref_d.id
54
54
  ORDER BY shared DESC
55
55
  LIMIT ?`,...t,d).filter(s=>!e.isIgnored(s.file1)&&!e.isIgnored(s.file2)).map(s=>c(s.file1,s.file2,s.shared))}function c(e,n,d){return{file1:e,file2:n,sharedSymbols:d,actionTier:"signal",couplingKind:"shared-symbol-coupling",evidenceReasons:[`${d} symbol(s) are defined in one file and referenced by the other`],recommendation:"Review whether the shared symbol surface is an intentional boundary or hidden coordination pressure before moving code."}}export{_ as a,a as b};
56
- //# sourceMappingURL=chunk-S3IXCXW2.js.map
56
+ //# sourceMappingURL=chunk-LG33DNTZ.js.map