@namzu/cli 48.0.0 → 49.1.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 (375) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/chunks/{acp-QUCU36XL.js → acp-YPJ27JQK.js} +53 -47
  4. package/dist/chunks/{acp-QUCU36XL.js.map → acp-YPJ27JQK.js.map} +1 -1
  5. package/dist/chunks/{activity-command-W6575T4W.js → activity-command-5XZJLJH5.js} +12 -12
  6. package/dist/chunks/{add-GLFGOQVN.js → add-37AHNBYS.js} +19 -19
  7. package/dist/chunks/{agent-VBCJRRQU.js → agent-PNIZE5HR.js} +35 -35
  8. package/dist/chunks/agent-session-ONKOQQ5Y.js +69 -0
  9. package/dist/chunks/{archive-QEPJAF7T.js → archive-A7SSRR76.js} +10 -10
  10. package/dist/chunks/{bin-main-D4Q3AFND.js → bin-main-G4E4SR4J.js} +7 -7
  11. package/dist/chunks/{binding-CEZSAC3K.js → binding-AIMTFLZW.js} +3 -3
  12. package/dist/chunks/{browser-XZZSBZG7.js → browser-F5Y3IT6U.js} +6 -6
  13. package/dist/chunks/{chat-ESJVUJKJ.js → chat-DIF26XMR.js} +15 -15
  14. package/dist/chunks/{chunk-BYQSDH2F.js → chunk-2LZA3UMD.js} +2 -2
  15. package/dist/chunks/{chunk-YRBLDFMI.js → chunk-2PMNQ6HR.js} +788 -230
  16. package/dist/chunks/chunk-2PMNQ6HR.js.map +6 -0
  17. package/dist/chunks/{chunk-QKE5HLHV.js → chunk-2WJQTSRQ.js} +12 -12
  18. package/dist/chunks/{chunk-WUSDW5Z5.js → chunk-37AR6YJQ.js} +2 -2
  19. package/dist/chunks/{chunk-YVV5ZHID.js → chunk-4AZTZXPQ.js} +4 -4
  20. package/dist/chunks/{chunk-MHF4AD7R.js → chunk-4IOUN4SV.js} +5 -5
  21. package/dist/chunks/{chunk-E7STKX6D.js → chunk-4L3LPJ4M.js} +2 -2
  22. package/dist/chunks/{chunk-5BA47MKJ.js → chunk-4PF6DIYU.js} +2 -2
  23. package/dist/chunks/{chunk-QSIMY7WM.js → chunk-4Z5ONGFB.js} +2 -2
  24. package/dist/chunks/{chunk-5NOMF3HN.js → chunk-5I4QGJER.js} +9 -9
  25. package/dist/chunks/{chunk-K5IWQLOE.js → chunk-6COUMXPW.js} +3 -3
  26. package/dist/chunks/{chunk-HF22LWEO.js → chunk-6KBZJBBN.js} +6 -6
  27. package/dist/chunks/{chunk-RXUDOOPL.js → chunk-6MEYPHDQ.js} +954 -172
  28. package/dist/chunks/chunk-6MEYPHDQ.js.map +6 -0
  29. package/dist/chunks/{chunk-HAYKZJ4W.js → chunk-6PURQMHH.js} +3 -3
  30. package/dist/chunks/{chunk-IQCUP4GF.js → chunk-6QOP2PHC.js} +2 -2
  31. package/dist/chunks/{chunk-ZKBZZ4SV.js → chunk-7HU7BYTT.js} +3 -3
  32. package/dist/chunks/{chunk-SJTDYH2Q.js → chunk-7TWA4BQX.js} +1897 -1667
  33. package/dist/chunks/chunk-7TWA4BQX.js.map +6 -0
  34. package/dist/chunks/{chunk-6EP5UWMA.js → chunk-7VF7HGMF.js} +3 -3
  35. package/dist/chunks/{chunk-CKAVXPSD.js → chunk-7X2NHTHU.js} +3 -3
  36. package/dist/chunks/{chunk-XD26GMKP.js → chunk-A425M7RP.js} +2 -2
  37. package/dist/chunks/{chunk-A3H6DYWZ.js → chunk-AHM54PGY.js} +3 -3
  38. package/dist/chunks/{chunk-FXPGZQWX.js → chunk-BERMCELL.js} +2 -2
  39. package/dist/chunks/{chunk-HLJHOUY5.js → chunk-BWOSM4EO.js} +3 -3
  40. package/dist/chunks/{chunk-UXYOP32R.js → chunk-C4C4Y2VT.js} +2 -2
  41. package/dist/chunks/{chunk-XRNUFV7Q.js → chunk-C5YVEX36.js} +2 -2
  42. package/dist/chunks/{chunk-A7RJ323Z.js → chunk-CBIXPHOV.js} +4 -4
  43. package/dist/chunks/{chunk-X4XZVFAV.js → chunk-D4DY4FZX.js} +4 -4
  44. package/dist/chunks/{chunk-JIUBDOX4.js → chunk-DJZ5W4ML.js} +2 -2
  45. package/dist/chunks/{chunk-VRO3BSVC.js → chunk-DLPWM4YC.js} +9 -9
  46. package/dist/chunks/{chunk-5EIUKBFJ.js → chunk-DXEAJL7W.js} +5 -2
  47. package/dist/chunks/chunk-DXEAJL7W.js.map +6 -0
  48. package/dist/chunks/{chunk-2FHIHK3T.js → chunk-EGPWQL55.js} +3 -3
  49. package/dist/chunks/{chunk-BFBE2M7Q.js → chunk-ESHBGSXA.js} +3 -3
  50. package/dist/chunks/{chunk-6YIA342V.js → chunk-GKPKHFMK.js} +4 -4
  51. package/dist/chunks/{chunk-7M3ACGKA.js → chunk-HD74DQ3Z.js} +2 -2
  52. package/dist/chunks/{chunk-QQM7JSEY.js → chunk-HREKLDJP.js} +4 -4
  53. package/dist/chunks/{chunk-C3F76W74.js → chunk-HYF3OKB7.js} +4 -4
  54. package/dist/chunks/{chunk-AHSWXUMT.js → chunk-IDJTFYNK.js} +12 -110
  55. package/dist/chunks/chunk-IDJTFYNK.js.map +6 -0
  56. package/dist/chunks/{chunk-UT5XJ2JQ.js → chunk-J65SOO5P.js} +3 -3
  57. package/dist/chunks/chunk-JBBB5EG2.js +3039 -0
  58. package/dist/chunks/chunk-JBBB5EG2.js.map +6 -0
  59. package/dist/chunks/{chunk-V3MC2IFR.js → chunk-JDUZFFX3.js} +2 -2
  60. package/dist/chunks/{chunk-UVR7C4T5.js → chunk-JRX5IIMR.js} +5 -5
  61. package/dist/chunks/{chunk-ZSJUNNOB.js → chunk-KEMOXQGR.js} +10 -10
  62. package/dist/chunks/{chunk-X3YRAYJU.js → chunk-KMTM4NNH.js} +4 -4
  63. package/dist/chunks/{chunk-66YF5N2J.js → chunk-NPH7ZTH4.js} +2 -2
  64. package/dist/chunks/{chunk-HZU57YBL.js → chunk-NQSEDCTH.js} +114 -2
  65. package/dist/chunks/{chunk-HZU57YBL.js.map → chunk-NQSEDCTH.js.map} +2 -2
  66. package/dist/chunks/{chunk-26JTVEWV.js → chunk-O6DNY5EM.js} +3 -3
  67. package/dist/chunks/{chunk-N47CNO6M.js → chunk-OBDGNMPB.js} +7 -7
  68. package/dist/chunks/{chunk-LHCRLCMO.js → chunk-PPVNYNKK.js} +2 -2
  69. package/dist/chunks/{chunk-HMAF5UAO.js → chunk-QIVWFRYO.js} +4 -4
  70. package/dist/chunks/{chunk-MGLG65W5.js → chunk-QSGYZU46.js} +10 -10
  71. package/dist/chunks/{chunk-F3ZHJSWR.js → chunk-RAPB7HY3.js} +6 -6
  72. package/dist/chunks/{chunk-ONLVC5X5.js → chunk-RNMU75CI.js} +2 -2
  73. package/dist/chunks/{chunk-JHDNGNQT.js → chunk-SF5VE66A.js} +2 -2
  74. package/dist/chunks/{chunk-GYIRPQFB.js → chunk-SIYXJ6PT.js} +2 -2
  75. package/dist/chunks/{chunk-SPLCWH4W.js → chunk-STEWNJWS.js} +42 -11
  76. package/dist/chunks/chunk-STEWNJWS.js.map +6 -0
  77. package/dist/chunks/{chunk-AWRDGYDV.js → chunk-SVH5P7TU.js} +13 -13
  78. package/dist/chunks/{chunk-7R42TMRR.js → chunk-SY2AJ6LM.js} +2 -2
  79. package/dist/chunks/{chunk-QROBMHWX.js → chunk-TVBD2LZV.js} +3 -3
  80. package/dist/chunks/{chunk-YJV5ARUB.js → chunk-TWEFDQ7C.js} +2 -2
  81. package/dist/chunks/{chunk-6E63NHFK.js → chunk-TWZ5PJH2.js} +5 -5
  82. package/dist/chunks/{chunk-6DTG2DJM.js → chunk-UANL44QG.js} +2 -2
  83. package/dist/chunks/{chunk-ESXU3WTP.js → chunk-UH7EP7TA.js} +2 -2
  84. package/dist/chunks/{chunk-NLVUDQEQ.js → chunk-USTCATWP.js} +4 -4
  85. package/dist/chunks/{chunk-2EPEWMI7.js → chunk-UXFW6KD7.js} +2 -2
  86. package/dist/chunks/{chunk-U6LKWLSO.js → chunk-VIBYGZFX.js} +2 -2
  87. package/dist/chunks/{chunk-RBH5ZABR.js → chunk-W27IOJQ5.js} +6 -6
  88. package/dist/chunks/{chunk-XX6ZE5ZO.js → chunk-WCJBKSGT.js} +2 -2
  89. package/dist/chunks/{chunk-UYP5QIPH.js → chunk-WVLBFEBP.js} +3 -3
  90. package/dist/chunks/{chunk-WYT7R7OV.js → chunk-XPW3PSVI.js} +3 -3
  91. package/dist/chunks/{chunk-JHGICKYH.js → chunk-Y2RIV5UX.js} +225 -16
  92. package/dist/chunks/chunk-Y2RIV5UX.js.map +6 -0
  93. package/dist/chunks/{chunk-JWMBGGFY.js → chunk-Y67ML2IN.js} +2 -2
  94. package/dist/chunks/{chunk-ZEHU7KPN.js → chunk-YWZ3IMAS.js} +2 -2
  95. package/dist/chunks/{chunk-DDXZZ7TR.js → chunk-Z43EXCUP.js} +3 -3
  96. package/dist/chunks/{chunk-KCVKLMKN.js → chunk-ZKLDG2CM.js} +3 -3
  97. package/dist/chunks/{chunk-LE4QZ6HS.js → chunk-ZWJPQH5F.js} +3 -3
  98. package/dist/chunks/{chunk-T5MEHPLZ.js → chunk-ZYIPLUWS.js} +41 -34
  99. package/dist/chunks/chunk-ZYIPLUWS.js.map +6 -0
  100. package/dist/chunks/{cli-runtime-YLIWHNME.js → cli-runtime-KHIX5OG4.js} +11 -10
  101. package/dist/chunks/cli-runtime-KHIX5OG4.js.map +6 -0
  102. package/dist/chunks/{commands-WT4OLTGL.js → commands-OGOMUDPT.js} +5 -5
  103. package/dist/chunks/{crash-report-BTL3U5HH.js → crash-report-VXC7CJDY.js} +6 -6
  104. package/dist/chunks/{dist-4TCR3HDF.js → dist-AA4JNWT2.js} +2 -2
  105. package/dist/chunks/{dist-3R6SQ3VB.js → dist-EL2RMYNK.js} +4 -2
  106. package/dist/chunks/{dist-X7K5G5NH.js → dist-LUUDW6KE.js} +2 -2
  107. package/dist/chunks/{dist-LRK6JYLM.js → dist-O4Y5VCRK.js} +2 -2
  108. package/dist/chunks/{dist-3PNUHQCO.js → dist-POXH7TX7.js} +2 -2
  109. package/dist/chunks/{dist-N4TBL3SN.js → dist-Q5YPDPOH.js} +2 -2
  110. package/dist/chunks/{dist-2NYSROLX.js → dist-Q7Z5SE4S.js} +294 -40
  111. package/dist/chunks/dist-Q7Z5SE4S.js.map +6 -0
  112. package/dist/chunks/{dist-OHQWXZ7N.js → dist-Z62XBGQ7.js} +2 -2
  113. package/dist/chunks/{doctor-5JQK6UNK.js → doctor-5IRXJ7DK.js} +17 -17
  114. package/dist/chunks/{drain-EHO3BUHW.js → drain-A44YWORN.js} +9 -9
  115. package/dist/chunks/{entry-F2EIOWAT.js → entry-ODCHCJ3O.js} +6 -6
  116. package/dist/chunks/{eval-7YEMHHIB.js → eval-35ZBHZLK.js} +2 -2
  117. package/dist/chunks/{exec-WV7BS5UD.js → exec-TPOW33QE.js} +34 -34
  118. package/dist/chunks/{home-GOMDEEXP.js → home-F4YAXKWJ.js} +3 -3
  119. package/dist/chunks/{host-MNPHBQWG.js → host-V7LVA7QU.js} +10 -10
  120. package/dist/chunks/{host-queries-SKWE7PF5.js → host-queries-2HRJZ2TH.js} +15 -15
  121. package/dist/chunks/{install-LVQAT4QP.js → install-F6PU4SYH.js} +2 -2
  122. package/dist/chunks/{learn-BUEAUHTD.js → learn-NLECFL5B.js} +11 -11
  123. package/dist/chunks/{learn-builtin-XZFBPA3W.js → learn-builtin-XLID77I3.js} +14 -14
  124. package/dist/chunks/{lifecycle-HMSOBI6F.js → lifecycle-UQL62JPO.js} +28 -28
  125. package/dist/chunks/{list-HNSWMLVN.js → list-4PS7WAPI.js} +11 -10
  126. package/dist/chunks/list-4PS7WAPI.js.map +6 -0
  127. package/dist/chunks/{live-ER3OZKC6.js → live-GBK7RIX2.js} +16 -16
  128. package/dist/chunks/{login-EBEFMEA2.js → login-7LGGUBI5.js} +13 -13
  129. package/dist/chunks/{logs-5UJZYNN2.js → logs-VYY2CWAN.js} +4 -4
  130. package/dist/chunks/{mcp-BLERKK2H.js → mcp-QL4TOTV5.js} +33 -22
  131. package/dist/chunks/mcp-QL4TOTV5.js.map +6 -0
  132. package/dist/chunks/{message-command-XH2M4BTB.js → message-command-SCSTDFSA.js} +41 -41
  133. package/dist/chunks/{open-ZYWPDOR6.js → open-QSZFHDIW.js} +8 -8
  134. package/dist/chunks/{operator-tools-CZ2SXR3G.js → operator-tools-WF2UGZ5G.js} +13 -13
  135. package/dist/chunks/{output-schema-MFZZP7GF.js → output-schema-P3WXODDE.js} +3 -3
  136. package/dist/chunks/{pal-7OYQHUKF.js → pal-JLSBOTEO.js} +16 -16
  137. package/dist/chunks/{peers-V3Z3ZQSN.js → peers-HDPCIVBY.js} +7 -7
  138. package/dist/chunks/{peers-FCVTBNI5.js → peers-IMCPUY6R.js} +6 -6
  139. package/dist/chunks/{providers-43RE2SWA.js → providers-YXH2C5HE.js} +11 -11
  140. package/dist/chunks/{pty-QSS3UQ7C.js → pty-74F5BMD3.js} +3 -3
  141. package/dist/chunks/resume-M63SJGJ4.js +23 -0
  142. package/dist/chunks/{resume-command-WZY42BAB.js → resume-command-LFK2PQYH.js} +4 -4
  143. package/dist/chunks/{schedule-LHXNUQHJ.js → schedule-5ZYAZJIM.js} +8 -8
  144. package/dist/chunks/{service-ZU5YIBW4.js → service-LTYPMKWG.js} +28 -28
  145. package/dist/chunks/{skills-K2MFIY4H.js → skills-KUT4QD3K.js} +8 -8
  146. package/dist/chunks/{start-check-AODGFYJD.js → start-check-SYGALC5U.js} +2 -2
  147. package/dist/chunks/{startup-failure-B6ESBTLZ.js → startup-failure-YKREQTPO.js} +2 -2
  148. package/dist/chunks/{state-ZWXVSLS2.js → state-MQXTG6O3.js} +2 -2
  149. package/dist/chunks/{store-JAI2RWQT.js → store-EO3HNNFC.js} +3 -3
  150. package/dist/chunks/{store-NKISDMPC.js → store-J4UP5MJ3.js} +10 -10
  151. package/dist/chunks/{store-MNI5IJHC.js → store-KC43NWR4.js} +6 -6
  152. package/dist/chunks/{store-U6SG2CON.js → store-KW3NJHWV.js} +4 -4
  153. package/dist/chunks/{tui-TM5QW6KY.js → tui-DPTVVKBE.js} +3009 -1199
  154. package/dist/chunks/tui-DPTVVKBE.js.map +6 -0
  155. package/dist/chunks/{undici-LWANNIOV.js → undici-RMBWH37N.js} +999 -445
  156. package/dist/chunks/undici-RMBWH37N.js.map +6 -0
  157. package/dist/chunks/{upgrade-27ZDBTX7.js → upgrade-WI5CFBGG.js} +7 -7
  158. package/dist/chunks/{workspaces-X7W7ZQU3.js → workspaces-VQ7VHN7N.js} +16 -16
  159. package/dist/chunks/{worktree-SIA6C5NS.js → worktree-KSDU4MTM.js} +12 -12
  160. package/dist/cli.d.ts.map +1 -1
  161. package/dist/commands/acp.d.ts +10 -1
  162. package/dist/commands/acp.d.ts.map +1 -1
  163. package/dist/commands/mcp-oauth-login.d.ts.map +1 -1
  164. package/dist/config/load.d.ts.map +1 -1
  165. package/dist/config/schema.d.ts +10 -0
  166. package/dist/config/schema.d.ts.map +1 -1
  167. package/dist/index.js +20 -20
  168. package/dist/integrations/decision/connection.d.ts +89 -0
  169. package/dist/integrations/decision/connection.d.ts.map +1 -0
  170. package/dist/integrations/decision/model.d.ts +21 -8
  171. package/dist/integrations/decision/model.d.ts.map +1 -1
  172. package/dist/integrations/decision/openrouter.d.ts +68 -0
  173. package/dist/integrations/decision/openrouter.d.ts.map +1 -0
  174. package/dist/integrations/decision/paste.d.ts +19 -0
  175. package/dist/integrations/decision/paste.d.ts.map +1 -0
  176. package/dist/integrations/decision/setup.d.ts +62 -0
  177. package/dist/integrations/decision/setup.d.ts.map +1 -0
  178. package/dist/integrations/decision/token.d.ts +34 -0
  179. package/dist/integrations/decision/token.d.ts.map +1 -0
  180. package/dist/integrations/mcp/servers.d.ts.map +1 -1
  181. package/dist/memory/curation-runtime.d.ts +8 -1
  182. package/dist/memory/curation-runtime.d.ts.map +1 -1
  183. package/dist/memory/lifecycle.d.ts +62 -0
  184. package/dist/memory/lifecycle.d.ts.map +1 -0
  185. package/dist/memory/manage.d.ts +37 -2
  186. package/dist/memory/manage.d.ts.map +1 -1
  187. package/dist/memory/sweep.d.ts +66 -0
  188. package/dist/memory/sweep.d.ts.map +1 -0
  189. package/dist/memory/usage.d.ts +79 -0
  190. package/dist/memory/usage.d.ts.map +1 -0
  191. package/dist/tui/App.d.ts +28 -1
  192. package/dist/tui/App.d.ts.map +1 -1
  193. package/dist/tui/StatusBar.d.ts +5 -1
  194. package/dist/tui/StatusBar.d.ts.map +1 -1
  195. package/dist/tui/agent.d.ts +15 -2
  196. package/dist/tui/agent.d.ts.map +1 -1
  197. package/dist/tui/decision-setup-flow.d.ts +57 -0
  198. package/dist/tui/decision-setup-flow.d.ts.map +1 -0
  199. package/dist/tui/fast-mode.d.ts +24 -0
  200. package/dist/tui/fast-mode.d.ts.map +1 -0
  201. package/dist/tui/fullscreen/FullscreenTranscript.d.ts +30 -2
  202. package/dist/tui/fullscreen/FullscreenTranscript.d.ts.map +1 -1
  203. package/dist/tui/fullscreen/cells.d.ts +26 -0
  204. package/dist/tui/fullscreen/cells.d.ts.map +1 -0
  205. package/dist/tui/fullscreen/joiners.d.ts +17 -0
  206. package/dist/tui/fullscreen/joiners.d.ts.map +1 -0
  207. package/dist/tui/fullscreen/layout.d.ts +16 -3
  208. package/dist/tui/fullscreen/layout.d.ts.map +1 -1
  209. package/dist/tui/fullscreen/markdown-rows.d.ts +24 -0
  210. package/dist/tui/fullscreen/markdown-rows.d.ts.map +1 -0
  211. package/dist/tui/fullscreen/mouse-wheel.d.ts +16 -7
  212. package/dist/tui/fullscreen/mouse-wheel.d.ts.map +1 -1
  213. package/dist/tui/fullscreen/paint.d.ts +19 -0
  214. package/dist/tui/fullscreen/paint.d.ts.map +1 -0
  215. package/dist/tui/fullscreen/rows.d.ts +35 -0
  216. package/dist/tui/fullscreen/rows.d.ts.map +1 -0
  217. package/dist/tui/fullscreen/search.d.ts +69 -0
  218. package/dist/tui/fullscreen/search.d.ts.map +1 -0
  219. package/dist/tui/fullscreen/selection.d.ts +66 -0
  220. package/dist/tui/fullscreen/selection.d.ts.map +1 -0
  221. package/dist/tui/fullscreen/viewport.d.ts +5 -0
  222. package/dist/tui/fullscreen/viewport.d.ts.map +1 -1
  223. package/dist/tui/index.d.ts.map +1 -1
  224. package/dist/tui/keymap.d.ts +2 -0
  225. package/dist/tui/keymap.d.ts.map +1 -1
  226. package/dist/tui/launch-settings.d.ts +2 -0
  227. package/dist/tui/launch-settings.d.ts.map +1 -1
  228. package/dist/tui/model-refusal.d.ts +3 -1
  229. package/dist/tui/model-refusal.d.ts.map +1 -1
  230. package/dist/tui/slashCommands.d.ts +9 -0
  231. package/dist/tui/slashCommands.d.ts.map +1 -1
  232. package/dist/tui/transcript-scroll.d.ts +2 -0
  233. package/dist/tui/transcript-scroll.d.ts.map +1 -1
  234. package/package.json +11 -11
  235. package/dist/chunks/agent-session-FZI6GVBH.js +0 -69
  236. package/dist/chunks/chunk-5EIUKBFJ.js.map +0 -6
  237. package/dist/chunks/chunk-AHSWXUMT.js.map +0 -6
  238. package/dist/chunks/chunk-JHGICKYH.js.map +0 -6
  239. package/dist/chunks/chunk-RXUDOOPL.js.map +0 -6
  240. package/dist/chunks/chunk-SJTDYH2Q.js.map +0 -6
  241. package/dist/chunks/chunk-SPLCWH4W.js.map +0 -6
  242. package/dist/chunks/chunk-T5MEHPLZ.js.map +0 -6
  243. package/dist/chunks/chunk-YBRLTSWM.js +0 -680
  244. package/dist/chunks/chunk-YBRLTSWM.js.map +0 -6
  245. package/dist/chunks/chunk-YRBLDFMI.js.map +0 -6
  246. package/dist/chunks/cli-runtime-YLIWHNME.js.map +0 -6
  247. package/dist/chunks/dist-2NYSROLX.js.map +0 -6
  248. package/dist/chunks/list-HNSWMLVN.js.map +0 -6
  249. package/dist/chunks/mcp-BLERKK2H.js.map +0 -6
  250. package/dist/chunks/resume-WN2TIOQK.js +0 -23
  251. package/dist/chunks/tui-TM5QW6KY.js.map +0 -6
  252. package/dist/chunks/undici-LWANNIOV.js.map +0 -6
  253. /package/dist/chunks/{activity-command-W6575T4W.js.map → activity-command-5XZJLJH5.js.map} +0 -0
  254. /package/dist/chunks/{add-GLFGOQVN.js.map → add-37AHNBYS.js.map} +0 -0
  255. /package/dist/chunks/{agent-VBCJRRQU.js.map → agent-PNIZE5HR.js.map} +0 -0
  256. /package/dist/chunks/{agent-session-FZI6GVBH.js.map → agent-session-ONKOQQ5Y.js.map} +0 -0
  257. /package/dist/chunks/{archive-QEPJAF7T.js.map → archive-A7SSRR76.js.map} +0 -0
  258. /package/dist/chunks/{bin-main-D4Q3AFND.js.map → bin-main-G4E4SR4J.js.map} +0 -0
  259. /package/dist/chunks/{binding-CEZSAC3K.js.map → binding-AIMTFLZW.js.map} +0 -0
  260. /package/dist/chunks/{browser-XZZSBZG7.js.map → browser-F5Y3IT6U.js.map} +0 -0
  261. /package/dist/chunks/{chat-ESJVUJKJ.js.map → chat-DIF26XMR.js.map} +0 -0
  262. /package/dist/chunks/{chunk-BYQSDH2F.js.map → chunk-2LZA3UMD.js.map} +0 -0
  263. /package/dist/chunks/{chunk-QKE5HLHV.js.map → chunk-2WJQTSRQ.js.map} +0 -0
  264. /package/dist/chunks/{chunk-WUSDW5Z5.js.map → chunk-37AR6YJQ.js.map} +0 -0
  265. /package/dist/chunks/{chunk-YVV5ZHID.js.map → chunk-4AZTZXPQ.js.map} +0 -0
  266. /package/dist/chunks/{chunk-MHF4AD7R.js.map → chunk-4IOUN4SV.js.map} +0 -0
  267. /package/dist/chunks/{chunk-E7STKX6D.js.map → chunk-4L3LPJ4M.js.map} +0 -0
  268. /package/dist/chunks/{chunk-5BA47MKJ.js.map → chunk-4PF6DIYU.js.map} +0 -0
  269. /package/dist/chunks/{chunk-QSIMY7WM.js.map → chunk-4Z5ONGFB.js.map} +0 -0
  270. /package/dist/chunks/{chunk-5NOMF3HN.js.map → chunk-5I4QGJER.js.map} +0 -0
  271. /package/dist/chunks/{chunk-K5IWQLOE.js.map → chunk-6COUMXPW.js.map} +0 -0
  272. /package/dist/chunks/{chunk-HF22LWEO.js.map → chunk-6KBZJBBN.js.map} +0 -0
  273. /package/dist/chunks/{chunk-HAYKZJ4W.js.map → chunk-6PURQMHH.js.map} +0 -0
  274. /package/dist/chunks/{chunk-IQCUP4GF.js.map → chunk-6QOP2PHC.js.map} +0 -0
  275. /package/dist/chunks/{chunk-ZKBZZ4SV.js.map → chunk-7HU7BYTT.js.map} +0 -0
  276. /package/dist/chunks/{chunk-6EP5UWMA.js.map → chunk-7VF7HGMF.js.map} +0 -0
  277. /package/dist/chunks/{chunk-CKAVXPSD.js.map → chunk-7X2NHTHU.js.map} +0 -0
  278. /package/dist/chunks/{chunk-XD26GMKP.js.map → chunk-A425M7RP.js.map} +0 -0
  279. /package/dist/chunks/{chunk-A3H6DYWZ.js.map → chunk-AHM54PGY.js.map} +0 -0
  280. /package/dist/chunks/{chunk-FXPGZQWX.js.map → chunk-BERMCELL.js.map} +0 -0
  281. /package/dist/chunks/{chunk-HLJHOUY5.js.map → chunk-BWOSM4EO.js.map} +0 -0
  282. /package/dist/chunks/{chunk-UXYOP32R.js.map → chunk-C4C4Y2VT.js.map} +0 -0
  283. /package/dist/chunks/{chunk-XRNUFV7Q.js.map → chunk-C5YVEX36.js.map} +0 -0
  284. /package/dist/chunks/{chunk-A7RJ323Z.js.map → chunk-CBIXPHOV.js.map} +0 -0
  285. /package/dist/chunks/{chunk-X4XZVFAV.js.map → chunk-D4DY4FZX.js.map} +0 -0
  286. /package/dist/chunks/{chunk-JIUBDOX4.js.map → chunk-DJZ5W4ML.js.map} +0 -0
  287. /package/dist/chunks/{chunk-VRO3BSVC.js.map → chunk-DLPWM4YC.js.map} +0 -0
  288. /package/dist/chunks/{chunk-2FHIHK3T.js.map → chunk-EGPWQL55.js.map} +0 -0
  289. /package/dist/chunks/{chunk-BFBE2M7Q.js.map → chunk-ESHBGSXA.js.map} +0 -0
  290. /package/dist/chunks/{chunk-6YIA342V.js.map → chunk-GKPKHFMK.js.map} +0 -0
  291. /package/dist/chunks/{chunk-7M3ACGKA.js.map → chunk-HD74DQ3Z.js.map} +0 -0
  292. /package/dist/chunks/{chunk-QQM7JSEY.js.map → chunk-HREKLDJP.js.map} +0 -0
  293. /package/dist/chunks/{chunk-C3F76W74.js.map → chunk-HYF3OKB7.js.map} +0 -0
  294. /package/dist/chunks/{chunk-UT5XJ2JQ.js.map → chunk-J65SOO5P.js.map} +0 -0
  295. /package/dist/chunks/{chunk-V3MC2IFR.js.map → chunk-JDUZFFX3.js.map} +0 -0
  296. /package/dist/chunks/{chunk-UVR7C4T5.js.map → chunk-JRX5IIMR.js.map} +0 -0
  297. /package/dist/chunks/{chunk-ZSJUNNOB.js.map → chunk-KEMOXQGR.js.map} +0 -0
  298. /package/dist/chunks/{chunk-X3YRAYJU.js.map → chunk-KMTM4NNH.js.map} +0 -0
  299. /package/dist/chunks/{chunk-66YF5N2J.js.map → chunk-NPH7ZTH4.js.map} +0 -0
  300. /package/dist/chunks/{chunk-26JTVEWV.js.map → chunk-O6DNY5EM.js.map} +0 -0
  301. /package/dist/chunks/{chunk-N47CNO6M.js.map → chunk-OBDGNMPB.js.map} +0 -0
  302. /package/dist/chunks/{chunk-LHCRLCMO.js.map → chunk-PPVNYNKK.js.map} +0 -0
  303. /package/dist/chunks/{chunk-HMAF5UAO.js.map → chunk-QIVWFRYO.js.map} +0 -0
  304. /package/dist/chunks/{chunk-MGLG65W5.js.map → chunk-QSGYZU46.js.map} +0 -0
  305. /package/dist/chunks/{chunk-F3ZHJSWR.js.map → chunk-RAPB7HY3.js.map} +0 -0
  306. /package/dist/chunks/{chunk-ONLVC5X5.js.map → chunk-RNMU75CI.js.map} +0 -0
  307. /package/dist/chunks/{chunk-JHDNGNQT.js.map → chunk-SF5VE66A.js.map} +0 -0
  308. /package/dist/chunks/{chunk-GYIRPQFB.js.map → chunk-SIYXJ6PT.js.map} +0 -0
  309. /package/dist/chunks/{chunk-AWRDGYDV.js.map → chunk-SVH5P7TU.js.map} +0 -0
  310. /package/dist/chunks/{chunk-7R42TMRR.js.map → chunk-SY2AJ6LM.js.map} +0 -0
  311. /package/dist/chunks/{chunk-QROBMHWX.js.map → chunk-TVBD2LZV.js.map} +0 -0
  312. /package/dist/chunks/{chunk-YJV5ARUB.js.map → chunk-TWEFDQ7C.js.map} +0 -0
  313. /package/dist/chunks/{chunk-6E63NHFK.js.map → chunk-TWZ5PJH2.js.map} +0 -0
  314. /package/dist/chunks/{chunk-6DTG2DJM.js.map → chunk-UANL44QG.js.map} +0 -0
  315. /package/dist/chunks/{chunk-ESXU3WTP.js.map → chunk-UH7EP7TA.js.map} +0 -0
  316. /package/dist/chunks/{chunk-NLVUDQEQ.js.map → chunk-USTCATWP.js.map} +0 -0
  317. /package/dist/chunks/{chunk-2EPEWMI7.js.map → chunk-UXFW6KD7.js.map} +0 -0
  318. /package/dist/chunks/{chunk-U6LKWLSO.js.map → chunk-VIBYGZFX.js.map} +0 -0
  319. /package/dist/chunks/{chunk-RBH5ZABR.js.map → chunk-W27IOJQ5.js.map} +0 -0
  320. /package/dist/chunks/{chunk-XX6ZE5ZO.js.map → chunk-WCJBKSGT.js.map} +0 -0
  321. /package/dist/chunks/{chunk-UYP5QIPH.js.map → chunk-WVLBFEBP.js.map} +0 -0
  322. /package/dist/chunks/{chunk-WYT7R7OV.js.map → chunk-XPW3PSVI.js.map} +0 -0
  323. /package/dist/chunks/{chunk-JWMBGGFY.js.map → chunk-Y67ML2IN.js.map} +0 -0
  324. /package/dist/chunks/{chunk-ZEHU7KPN.js.map → chunk-YWZ3IMAS.js.map} +0 -0
  325. /package/dist/chunks/{chunk-DDXZZ7TR.js.map → chunk-Z43EXCUP.js.map} +0 -0
  326. /package/dist/chunks/{chunk-KCVKLMKN.js.map → chunk-ZKLDG2CM.js.map} +0 -0
  327. /package/dist/chunks/{chunk-LE4QZ6HS.js.map → chunk-ZWJPQH5F.js.map} +0 -0
  328. /package/dist/chunks/{commands-WT4OLTGL.js.map → commands-OGOMUDPT.js.map} +0 -0
  329. /package/dist/chunks/{crash-report-BTL3U5HH.js.map → crash-report-VXC7CJDY.js.map} +0 -0
  330. /package/dist/chunks/{dist-4TCR3HDF.js.map → dist-AA4JNWT2.js.map} +0 -0
  331. /package/dist/chunks/{dist-3R6SQ3VB.js.map → dist-EL2RMYNK.js.map} +0 -0
  332. /package/dist/chunks/{dist-X7K5G5NH.js.map → dist-LUUDW6KE.js.map} +0 -0
  333. /package/dist/chunks/{dist-LRK6JYLM.js.map → dist-O4Y5VCRK.js.map} +0 -0
  334. /package/dist/chunks/{dist-3PNUHQCO.js.map → dist-POXH7TX7.js.map} +0 -0
  335. /package/dist/chunks/{dist-N4TBL3SN.js.map → dist-Q5YPDPOH.js.map} +0 -0
  336. /package/dist/chunks/{dist-OHQWXZ7N.js.map → dist-Z62XBGQ7.js.map} +0 -0
  337. /package/dist/chunks/{doctor-5JQK6UNK.js.map → doctor-5IRXJ7DK.js.map} +0 -0
  338. /package/dist/chunks/{drain-EHO3BUHW.js.map → drain-A44YWORN.js.map} +0 -0
  339. /package/dist/chunks/{entry-F2EIOWAT.js.map → entry-ODCHCJ3O.js.map} +0 -0
  340. /package/dist/chunks/{eval-7YEMHHIB.js.map → eval-35ZBHZLK.js.map} +0 -0
  341. /package/dist/chunks/{exec-WV7BS5UD.js.map → exec-TPOW33QE.js.map} +0 -0
  342. /package/dist/chunks/{home-GOMDEEXP.js.map → home-F4YAXKWJ.js.map} +0 -0
  343. /package/dist/chunks/{host-MNPHBQWG.js.map → host-V7LVA7QU.js.map} +0 -0
  344. /package/dist/chunks/{host-queries-SKWE7PF5.js.map → host-queries-2HRJZ2TH.js.map} +0 -0
  345. /package/dist/chunks/{install-LVQAT4QP.js.map → install-F6PU4SYH.js.map} +0 -0
  346. /package/dist/chunks/{learn-BUEAUHTD.js.map → learn-NLECFL5B.js.map} +0 -0
  347. /package/dist/chunks/{learn-builtin-XZFBPA3W.js.map → learn-builtin-XLID77I3.js.map} +0 -0
  348. /package/dist/chunks/{lifecycle-HMSOBI6F.js.map → lifecycle-UQL62JPO.js.map} +0 -0
  349. /package/dist/chunks/{live-ER3OZKC6.js.map → live-GBK7RIX2.js.map} +0 -0
  350. /package/dist/chunks/{login-EBEFMEA2.js.map → login-7LGGUBI5.js.map} +0 -0
  351. /package/dist/chunks/{logs-5UJZYNN2.js.map → logs-VYY2CWAN.js.map} +0 -0
  352. /package/dist/chunks/{message-command-XH2M4BTB.js.map → message-command-SCSTDFSA.js.map} +0 -0
  353. /package/dist/chunks/{open-ZYWPDOR6.js.map → open-QSZFHDIW.js.map} +0 -0
  354. /package/dist/chunks/{operator-tools-CZ2SXR3G.js.map → operator-tools-WF2UGZ5G.js.map} +0 -0
  355. /package/dist/chunks/{output-schema-MFZZP7GF.js.map → output-schema-P3WXODDE.js.map} +0 -0
  356. /package/dist/chunks/{pal-7OYQHUKF.js.map → pal-JLSBOTEO.js.map} +0 -0
  357. /package/dist/chunks/{peers-V3Z3ZQSN.js.map → peers-HDPCIVBY.js.map} +0 -0
  358. /package/dist/chunks/{peers-FCVTBNI5.js.map → peers-IMCPUY6R.js.map} +0 -0
  359. /package/dist/chunks/{providers-43RE2SWA.js.map → providers-YXH2C5HE.js.map} +0 -0
  360. /package/dist/chunks/{pty-QSS3UQ7C.js.map → pty-74F5BMD3.js.map} +0 -0
  361. /package/dist/chunks/{resume-WN2TIOQK.js.map → resume-M63SJGJ4.js.map} +0 -0
  362. /package/dist/chunks/{resume-command-WZY42BAB.js.map → resume-command-LFK2PQYH.js.map} +0 -0
  363. /package/dist/chunks/{schedule-LHXNUQHJ.js.map → schedule-5ZYAZJIM.js.map} +0 -0
  364. /package/dist/chunks/{service-ZU5YIBW4.js.map → service-LTYPMKWG.js.map} +0 -0
  365. /package/dist/chunks/{skills-K2MFIY4H.js.map → skills-KUT4QD3K.js.map} +0 -0
  366. /package/dist/chunks/{start-check-AODGFYJD.js.map → start-check-SYGALC5U.js.map} +0 -0
  367. /package/dist/chunks/{startup-failure-B6ESBTLZ.js.map → startup-failure-YKREQTPO.js.map} +0 -0
  368. /package/dist/chunks/{state-ZWXVSLS2.js.map → state-MQXTG6O3.js.map} +0 -0
  369. /package/dist/chunks/{store-JAI2RWQT.js.map → store-EO3HNNFC.js.map} +0 -0
  370. /package/dist/chunks/{store-MNI5IJHC.js.map → store-J4UP5MJ3.js.map} +0 -0
  371. /package/dist/chunks/{store-NKISDMPC.js.map → store-KC43NWR4.js.map} +0 -0
  372. /package/dist/chunks/{store-U6SG2CON.js.map → store-KW3NJHWV.js.map} +0 -0
  373. /package/dist/chunks/{upgrade-27ZDBTX7.js.map → upgrade-WI5CFBGG.js.map} +0 -0
  374. /package/dist/chunks/{workspaces-X7W7ZQU3.js.map → workspaces-VQ7VHN7N.js.map} +0 -0
  375. /package/dist/chunks/{worktree-SIA6C5NS.js.map → worktree-KSDU4MTM.js.map} +0 -0
@@ -0,0 +1,3039 @@
1
+ import { createRequire as __namzuCreateRequire } from 'node:module';
2
+ const require = __namzuCreateRequire(import.meta.url);
3
+ import {
4
+ cliLogger
5
+ } from "./chunk-JDUZFFX3.js";
6
+ import {
7
+ PERMISSION_MODE_NAMES
8
+ } from "./chunk-WMEZTDLT.js";
9
+ import {
10
+ AuthorizationGate,
11
+ NOOP_LOGGER,
12
+ builtinCommandArguments,
13
+ getBuiltinTools,
14
+ permissionPatternToRegExpSource
15
+ } from "./chunk-7TWA4BQX.js";
16
+ import {
17
+ __name
18
+ } from "./chunk-76FLAFCG.js";
19
+
20
+ // src/permissions/rules.ts
21
+ import { dirname as dirname2, resolve as resolve2 } from "node:path";
22
+
23
+ // src/permissions/settings.ts
24
+ var PERMISSION_SETTING_KEYS = [
25
+ "defaultMode",
26
+ "disableBypassMode",
27
+ "disableAutoMode",
28
+ "autoMode"
29
+ ];
30
+ var AUTO_MODE_KEYS = ["model", "allow", "softDeny", "hardDeny", "environment"];
31
+ var LIST_KEYS = ["allow", "softDeny", "hardDeny", "environment"];
32
+ function isPermissionSettingKey(key) {
33
+ return PERMISSION_SETTING_KEYS.includes(key);
34
+ }
35
+ __name(isPermissionSettingKey, "isPermissionSettingKey");
36
+ var OPERATOR_ONLY_DEFAULTS = ["bypass", "auto"];
37
+ function permissionSettingsProblem(table) {
38
+ const mode = table.defaultMode;
39
+ if (mode !== void 0 && !PERMISSION_MODE_NAMES.includes(mode)) {
40
+ return {
41
+ path: ["defaultMode"],
42
+ message: `must be one of: ${PERMISSION_MODE_NAMES.join(", ")}`
43
+ };
44
+ }
45
+ for (const key of ["disableBypassMode", "disableAutoMode"]) {
46
+ if (table[key] !== void 0 && typeof table[key] !== "boolean") {
47
+ return { path: [key], message: "must be true or false" };
48
+ }
49
+ }
50
+ const auto = table.autoMode;
51
+ if (auto === void 0) return void 0;
52
+ if (typeof auto !== "object" || auto === null || Array.isArray(auto)) {
53
+ return { path: ["autoMode"], message: "must be a mapping" };
54
+ }
55
+ const entries = auto;
56
+ for (const key of Object.keys(entries)) {
57
+ if (!AUTO_MODE_KEYS.includes(key)) {
58
+ return {
59
+ path: ["autoMode", key],
60
+ message: `is not an auto mode setting (${AUTO_MODE_KEYS.join(", ")})`
61
+ };
62
+ }
63
+ }
64
+ if (entries.model !== void 0 && (typeof entries.model !== "string" || !entries.model.trim())) {
65
+ return { path: ["autoMode", "model"], message: "must be a model name" };
66
+ }
67
+ for (const key of LIST_KEYS) {
68
+ const value = entries[key];
69
+ if (value !== void 0 && !(Array.isArray(value) && value.every((v) => typeof v === "string"))) {
70
+ return { path: ["autoMode", key], message: "must be a list of sentences" };
71
+ }
72
+ }
73
+ return void 0;
74
+ }
75
+ __name(permissionSettingsProblem, "permissionSettingsProblem");
76
+ function splitPermissionsTable(table, authority, where) {
77
+ const rules = {};
78
+ for (const [key, value] of Object.entries(table)) {
79
+ if (!isPermissionSettingKey(key)) rules[key] = value;
80
+ }
81
+ const raw = table;
82
+ const ignored = [];
83
+ let defaultMode;
84
+ if (typeof raw.defaultMode === "string") {
85
+ const mode = raw.defaultMode;
86
+ if (authority === "workspace" && OPERATOR_ONLY_DEFAULTS.includes(mode)) {
87
+ ignored.push(
88
+ `permissions.defaultMode: "${mode}" in ${where} is ignored; a mode that stops asking is set in your own config file (~/.namzu/config.yaml).`
89
+ );
90
+ } else {
91
+ defaultMode = mode;
92
+ }
93
+ }
94
+ let autoMode;
95
+ if (raw.autoMode !== void 0) {
96
+ if (authority === "workspace") {
97
+ ignored.push(
98
+ `permissions.autoMode in ${where} is ignored; the auto mode classifier is set in your own config file (~/.namzu/config.yaml).`
99
+ );
100
+ } else {
101
+ autoMode = raw.autoMode;
102
+ }
103
+ }
104
+ return {
105
+ rules,
106
+ settings: {
107
+ ...defaultMode ? { defaultMode } : {},
108
+ ...raw.disableBypassMode === true ? { disableBypassMode: true } : {},
109
+ ...raw.disableAutoMode === true ? { disableAutoMode: true } : {},
110
+ ...autoMode ? { autoMode } : {},
111
+ ...ignored.length > 0 ? { ignored } : {}
112
+ }
113
+ };
114
+ }
115
+ __name(splitPermissionsTable, "splitPermissionsTable");
116
+ function mergePermissionSettings(base, next) {
117
+ const ignored = [...base?.ignored ?? [], ...next.ignored ?? []];
118
+ const autoMode = base?.autoMode || next.autoMode ? { ...base?.autoMode, ...next.autoMode } : void 0;
119
+ const defaultMode = next.defaultMode ?? base?.defaultMode;
120
+ return {
121
+ ...defaultMode ? { defaultMode } : {},
122
+ ...base?.disableBypassMode || next.disableBypassMode ? { disableBypassMode: true } : {},
123
+ ...base?.disableAutoMode || next.disableAutoMode ? { disableAutoMode: true } : {},
124
+ ...autoMode ? { autoMode } : {},
125
+ ...ignored.length > 0 ? { ignored } : {}
126
+ };
127
+ }
128
+ __name(mergePermissionSettings, "mergePermissionSettings");
129
+
130
+ // src/permissions/checks.ts
131
+ function asEffect(decision) {
132
+ return decision === "review" ? "ask" : decision;
133
+ }
134
+ __name(asEffect, "asEffect");
135
+ function verifyPermissionChecks(rules, checks) {
136
+ if (!checks || checks.length === 0) return [];
137
+ const diagnostics = [];
138
+ const gate = new AuthorizationGate(
139
+ {
140
+ enabled: true,
141
+ rules: [...rules],
142
+ allowReadOnlyTools: false,
143
+ // Off on purpose; see the note at the top of this file.
144
+ denyDangerousPatterns: false,
145
+ logDecisions: false
146
+ },
147
+ NOOP_LOGGER
148
+ );
149
+ for (const [index, check] of checks.entries()) {
150
+ const where = `permissionChecks[${index}]`;
151
+ if (typeof check?.tool !== "string" || check.tool === "") {
152
+ diagnostics.push({ tool: where, message: 'expected a "tool" naming the tool to evaluate' });
153
+ continue;
154
+ }
155
+ if (typeof check.input !== "object" || check.input === null || Array.isArray(check.input)) {
156
+ diagnostics.push({
157
+ tool: where,
158
+ message: `expected an "input" object for ${check.tool}; got ${describe(check.input)}`
159
+ });
160
+ continue;
161
+ }
162
+ if (!isPermissionEffect(check.expect)) {
163
+ diagnostics.push({
164
+ tool: where,
165
+ message: `expected "expect" to be "allow", "ask" or "deny"; got ${JSON.stringify(check.expect)}`
166
+ });
167
+ continue;
168
+ }
169
+ const builtin = getBuiltinTools().find((tool) => tool.name === check.tool);
170
+ const commandDialect = builtin?.commandDialect?.({ sandboxed: false });
171
+ const verdict = gate.evaluate({
172
+ toolName: check.tool,
173
+ toolInput: check.input,
174
+ toolDef: void 0,
175
+ ...commandDialect !== void 0 ? { commandDialect } : {}
176
+ });
177
+ const actual = asEffect(verdict.decision);
178
+ if (actual === check.expect) continue;
179
+ diagnostics.push({
180
+ tool: where,
181
+ message: `${check.tool} ${JSON.stringify(check.input)} is "${actual}", not the expected "${check.expect}" \u2014 ${verdict.reason}`
182
+ });
183
+ }
184
+ return diagnostics;
185
+ }
186
+ __name(verifyPermissionChecks, "verifyPermissionChecks");
187
+ function describe(value) {
188
+ if (value === null) return "null";
189
+ return Array.isArray(value) ? "an array" : typeof value;
190
+ }
191
+ __name(describe, "describe");
192
+
193
+ // src/permissions/path-rules.ts
194
+ import { realpathSync } from "node:fs";
195
+ import { homedir } from "node:os";
196
+ import { dirname, join, posix, resolve } from "node:path";
197
+
198
+ // ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
199
+ var balanced = /* @__PURE__ */ __name((a, b, str) => {
200
+ const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
201
+ const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
202
+ const r = ma !== null && mb != null && range(ma, mb, str);
203
+ return r && {
204
+ start: r[0],
205
+ end: r[1],
206
+ pre: str.slice(0, r[0]),
207
+ body: str.slice(r[0] + ma.length, r[1]),
208
+ post: str.slice(r[1] + mb.length)
209
+ };
210
+ }, "balanced");
211
+ var maybeMatch = /* @__PURE__ */ __name((reg, str) => {
212
+ const m = str.match(reg);
213
+ return m ? m[0] : null;
214
+ }, "maybeMatch");
215
+ var range = /* @__PURE__ */ __name((a, b, str) => {
216
+ let begs, beg, left, right = void 0, result;
217
+ let ai = str.indexOf(a);
218
+ let bi = str.indexOf(b, ai + 1);
219
+ let i = ai;
220
+ if (ai >= 0 && bi > 0) {
221
+ if (a === b) {
222
+ return [ai, bi];
223
+ }
224
+ begs = [];
225
+ left = str.length;
226
+ while (i >= 0 && !result) {
227
+ if (i === ai) {
228
+ begs.push(i);
229
+ ai = str.indexOf(a, i + 1);
230
+ } else if (begs.length === 1) {
231
+ const r = begs.pop();
232
+ if (r !== void 0)
233
+ result = [r, bi];
234
+ } else {
235
+ beg = begs.pop();
236
+ if (beg !== void 0 && beg < left) {
237
+ left = beg;
238
+ right = bi;
239
+ }
240
+ bi = str.indexOf(b, i + 1);
241
+ }
242
+ i = ai < bi && ai >= 0 ? ai : bi;
243
+ }
244
+ if (begs.length && right !== void 0) {
245
+ result = [left, right];
246
+ }
247
+ }
248
+ return result;
249
+ }, "range");
250
+
251
+ // ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
252
+ var escSlash = "\0SLASH" + Math.random() + "\0";
253
+ var escOpen = "\0OPEN" + Math.random() + "\0";
254
+ var escClose = "\0CLOSE" + Math.random() + "\0";
255
+ var escComma = "\0COMMA" + Math.random() + "\0";
256
+ var escPeriod = "\0PERIOD" + Math.random() + "\0";
257
+ var escSlashPattern = new RegExp(escSlash, "g");
258
+ var escOpenPattern = new RegExp(escOpen, "g");
259
+ var escClosePattern = new RegExp(escClose, "g");
260
+ var escCommaPattern = new RegExp(escComma, "g");
261
+ var escPeriodPattern = new RegExp(escPeriod, "g");
262
+ var slashPattern = /\\\\/g;
263
+ var openPattern = /\\{/g;
264
+ var closePattern = /\\}/g;
265
+ var commaPattern = /\\,/g;
266
+ var periodPattern = /\\\./g;
267
+ var EXPANSION_MAX = 1e5;
268
+ var EXPANSION_MAX_LENGTH = 4e6;
269
+ var EXPANSION_MAX_DEPTH = 1e3;
270
+ var EXPANSION_MAX_REWRITES = 1e3;
271
+ function numeric(str) {
272
+ return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
273
+ }
274
+ __name(numeric, "numeric");
275
+ function escapeBraces(str) {
276
+ return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
277
+ }
278
+ __name(escapeBraces, "escapeBraces");
279
+ function unescapeBraces(str) {
280
+ return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
281
+ }
282
+ __name(unescapeBraces, "unescapeBraces");
283
+ function pushAll(target, items) {
284
+ for (let i = 0; i < items.length; i++) {
285
+ target.push(items[i]);
286
+ }
287
+ }
288
+ __name(pushAll, "pushAll");
289
+ function parseCommaParts(str) {
290
+ const parts = [];
291
+ let carry = "";
292
+ for (; ; ) {
293
+ const m = balanced("{", "}", str);
294
+ if (!m) {
295
+ const tail = str.split(",");
296
+ tail[0] = carry + tail[0];
297
+ pushAll(parts, tail);
298
+ return parts;
299
+ }
300
+ const { pre, body, post } = m;
301
+ const p = pre.split(",");
302
+ p[0] = carry + p[0];
303
+ p[p.length - 1] += "{" + body + "}";
304
+ if (!post.length) {
305
+ pushAll(parts, p);
306
+ return parts;
307
+ }
308
+ carry = p.pop();
309
+ pushAll(parts, p);
310
+ str = post;
311
+ }
312
+ }
313
+ __name(parseCommaParts, "parseCommaParts");
314
+ function expand(str, options = {}) {
315
+ if (!str) {
316
+ return [];
317
+ }
318
+ const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES } = options;
319
+ if (str.slice(0, 2) === "{}") {
320
+ str = "\\{\\}" + str.slice(2);
321
+ }
322
+ return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
323
+ }
324
+ __name(expand, "expand");
325
+ function embrace(str) {
326
+ return "{" + str + "}";
327
+ }
328
+ __name(embrace, "embrace");
329
+ function isPadded(el) {
330
+ return /^-?0\d/.test(el);
331
+ }
332
+ __name(isPadded, "isPadded");
333
+ function lte(i, y) {
334
+ return i <= y;
335
+ }
336
+ __name(lte, "lte");
337
+ function gte(i, y) {
338
+ return i >= y;
339
+ }
340
+ __name(gte, "gte");
341
+ function combine(acc, pre, values, max, maxLength, dropEmpties) {
342
+ const out = [];
343
+ let length = 0;
344
+ for (let a = 0; a < acc.length; a++) {
345
+ for (let v = 0; v < values.length; v++) {
346
+ if (out.length >= max)
347
+ return out;
348
+ const expansion = acc[a] + pre + values[v];
349
+ if (dropEmpties && !expansion)
350
+ continue;
351
+ if (length + expansion.length > maxLength)
352
+ return out;
353
+ out.push(expansion);
354
+ length += expansion.length;
355
+ }
356
+ }
357
+ return out;
358
+ }
359
+ __name(combine, "combine");
360
+ function expandSequence(body, isAlphaSequence, max, maxLength) {
361
+ const n = body.split(/\.\./);
362
+ const N = [];
363
+ if (n[0] === void 0 || n[1] === void 0) {
364
+ return N;
365
+ }
366
+ const x = numeric(n[0]);
367
+ const y = numeric(n[1]);
368
+ const width = Math.max(n[0].length, n[1].length);
369
+ let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
370
+ let test = lte;
371
+ const reverse = y < x;
372
+ if (reverse) {
373
+ incr *= -1;
374
+ test = gte;
375
+ }
376
+ const pad = n.some(isPadded);
377
+ let length = 0;
378
+ for (let i = x; test(i, y) && N.length < max; i += incr) {
379
+ let c;
380
+ if (isAlphaSequence) {
381
+ c = String.fromCharCode(i);
382
+ if (c === "\\") {
383
+ c = "";
384
+ }
385
+ } else {
386
+ c = String(i);
387
+ if (pad) {
388
+ const need = width - c.length;
389
+ if (need > 0) {
390
+ const z = new Array(need + 1).join("0");
391
+ if (i < 0) {
392
+ c = "-" + z + c.slice(1);
393
+ } else {
394
+ c = z + c;
395
+ }
396
+ }
397
+ }
398
+ }
399
+ if (length + c.length > maxLength)
400
+ break;
401
+ N.push(c);
402
+ length += c.length;
403
+ }
404
+ return N;
405
+ }
406
+ __name(expandSequence, "expandSequence");
407
+ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
408
+ if (depth > maxDepth) {
409
+ return [str];
410
+ }
411
+ let acc = [""];
412
+ let rewrites = 0;
413
+ let dropEmpties = false;
414
+ let firstGroup = true;
415
+ for (; ; ) {
416
+ const m = balanced("{", "}", str);
417
+ if (!m) {
418
+ return combine(acc, str, [""], max, maxLength, dropEmpties);
419
+ }
420
+ const pre = m.pre;
421
+ if (/\$$/.test(pre)) {
422
+ acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
423
+ firstGroup = false;
424
+ if (!m.post.length)
425
+ break;
426
+ str = m.post;
427
+ continue;
428
+ }
429
+ const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
430
+ const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
431
+ const isSequence = isNumericSequence || isAlphaSequence;
432
+ const isOptions = m.body.indexOf(",") >= 0;
433
+ if (!isSequence && !isOptions) {
434
+ if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
435
+ rewrites++;
436
+ str = m.pre + "{" + m.body + escClose + m.post;
437
+ isTop = true;
438
+ continue;
439
+ }
440
+ return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
441
+ }
442
+ if (firstGroup) {
443
+ dropEmpties = isTop && !isSequence;
444
+ firstGroup = false;
445
+ }
446
+ let values;
447
+ if (isSequence) {
448
+ values = expandSequence(m.body, isAlphaSequence, max, maxLength);
449
+ } else {
450
+ let n = parseCommaParts(m.body);
451
+ if (n.length === 1 && n[0] !== void 0) {
452
+ n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
453
+ if (n.length === 1) {
454
+ acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
455
+ if (!m.post.length)
456
+ break;
457
+ str = m.post;
458
+ continue;
459
+ }
460
+ }
461
+ let dropsEmpties = dropEmpties && !m.post.length && !pre;
462
+ for (let d = 0; dropsEmpties && d < acc.length; d++) {
463
+ if (acc[d]) {
464
+ dropsEmpties = false;
465
+ }
466
+ }
467
+ values = [];
468
+ let valuesLength = 0;
469
+ outer: for (let j = 0; j < n.length; j++) {
470
+ const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
471
+ for (let k = 0; k < expanded.length; k++) {
472
+ const v = expanded[k];
473
+ if (dropsEmpties && !v)
474
+ continue;
475
+ if (values.length >= max || valuesLength + v.length > maxLength) {
476
+ break outer;
477
+ }
478
+ values.push(v);
479
+ valuesLength += v.length;
480
+ }
481
+ }
482
+ }
483
+ acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
484
+ if (!m.post.length)
485
+ break;
486
+ str = m.post;
487
+ }
488
+ return acc;
489
+ }
490
+ __name(expand_, "expand_");
491
+
492
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/numeric-range.js
493
+ var digit = /* @__PURE__ */ __name((a, b) => a === b ? { t: "lit", ch: String(a) } : { t: "class", re: new RegExp(`^[${a}-${b}]$`) }, "digit");
494
+ var prefix = /* @__PURE__ */ __name((d, alts) => alts.map((s) => [digit(d, d), ...s]), "prefix");
495
+ var fixed = /* @__PURE__ */ __name((a, b) => {
496
+ if (!a)
497
+ return [[]];
498
+ let lo = +a[0];
499
+ let hi = +b[0];
500
+ const ra = a.slice(1);
501
+ const rb = b.slice(1);
502
+ if (lo === hi)
503
+ return prefix(lo, fixed(ra, rb));
504
+ const zeros = "0".repeat(ra.length);
505
+ const nines = "9".repeat(ra.length);
506
+ const out = [];
507
+ if (ra !== zeros)
508
+ out.push(...prefix(lo++, fixed(ra, nines)));
509
+ const last = rb === nines ? [] : prefix(hi--, fixed(zeros, rb));
510
+ if (lo <= hi) {
511
+ out.push([digit(lo, hi), ...Array.from(ra, () => digit(0, 9))]);
512
+ }
513
+ out.push(...last);
514
+ return out;
515
+ }, "fixed");
516
+ var nonneg = /* @__PURE__ */ __name((a, b, width) => {
517
+ if (width) {
518
+ return fixed(String(a).padStart(width, "0"), String(b).padStart(width, "0"));
519
+ }
520
+ const out = [];
521
+ for (let len = String(a).length; len <= String(b).length; len++) {
522
+ const lo = Math.max(a, len === 1 ? 0 : 10 ** (len - 1));
523
+ const hi = Math.min(b, 10 ** len - 1);
524
+ out.push(...fixed(String(lo), String(hi)));
525
+ }
526
+ return out;
527
+ }, "nonneg");
528
+ var numericRange = /* @__PURE__ */ __name((loStr, hiStr) => {
529
+ let lo = Number(loStr);
530
+ let hi = Number(hiStr);
531
+ if (!Number.isSafeInteger(lo) || !Number.isSafeInteger(hi))
532
+ return;
533
+ if (lo > hi)
534
+ [lo, hi] = [hi, lo];
535
+ const padded = /^-?0\d/.test(loStr) || /^-?0\d/.test(hiStr);
536
+ const width = padded ? Math.max(loStr.length, hiStr.length) : 0;
537
+ const out = [];
538
+ if (lo < 0) {
539
+ const neg = nonneg(Math.max(-hi, 1), -lo, width && width - 1);
540
+ out.push(...neg.map((s) => [{ t: "lit", ch: "-" }, ...s]));
541
+ }
542
+ if (hi >= 0)
543
+ out.push(...nonneg(Math.max(lo, 0), hi, width));
544
+ return out;
545
+ }, "numericRange");
546
+
547
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js
548
+ var posixClasses = {
549
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
550
+ "[:alpha:]": ["\\p{L}\\p{Nl}"],
551
+ "[:ascii:]": ["\\x00-\\x7f"],
552
+ "[:blank:]": ["\\p{Zs}\\t"],
553
+ "[:cntrl:]": ["\\p{Cc}"],
554
+ "[:digit:]": ["\\p{Nd}"],
555
+ "[:graph:]": ["\\p{Z}\\p{C}", true],
556
+ "[:lower:]": ["\\p{Ll}"],
557
+ "[:print:]": ["\\p{C}", true],
558
+ "[:punct:]": ["\\p{P}\\p{S}"],
559
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
560
+ "[:upper:]": ["\\p{Lu}"],
561
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
562
+ "[:xdigit:]": ["A-Fa-f0-9"]
563
+ };
564
+ var braceEscape = /* @__PURE__ */ __name((s) => s.replace(/[[\]\\-]/g, "\\$&"), "braceEscape");
565
+ var noMatch = /$./;
566
+ var parseClass = /* @__PURE__ */ __name((glob, position, nocase = false, form) => {
567
+ const norm = /* @__PURE__ */ __name((c) => {
568
+ const n = form ? c.normalize(form) : c;
569
+ return [...n].length === 1 ? n : c;
570
+ }, "norm");
571
+ const pos = position;
572
+ if (glob.charAt(pos) !== "[") {
573
+ throw new Error("not in a brace expression");
574
+ }
575
+ const ranges = [];
576
+ const negs = [];
577
+ let i = pos + 1;
578
+ let sawStart = false;
579
+ let escaping = false;
580
+ let negate = false;
581
+ let endPos = pos;
582
+ let rangeStart = "";
583
+ WHILE: while (i < glob.length) {
584
+ const c = String.fromCodePoint(glob.codePointAt(i));
585
+ if ((c === "!" || c === "^") && i === pos + 1) {
586
+ negate = true;
587
+ i++;
588
+ continue;
589
+ }
590
+ if (c === "]" && sawStart && !escaping) {
591
+ endPos = i + 1;
592
+ break;
593
+ }
594
+ sawStart = true;
595
+ if (c === "\\") {
596
+ if (!escaping) {
597
+ escaping = true;
598
+ i++;
599
+ continue;
600
+ }
601
+ }
602
+ if (c === "[" && !escaping) {
603
+ for (const [cls, [unip, neg]] of Object.entries(posixClasses)) {
604
+ if (glob.startsWith(cls, i)) {
605
+ if (rangeStart) {
606
+ return [noMatch, glob.length - pos];
607
+ }
608
+ i += cls.length;
609
+ if (neg)
610
+ negs.push(unip);
611
+ else
612
+ ranges.push(unip);
613
+ continue WHILE;
614
+ }
615
+ }
616
+ }
617
+ escaping = false;
618
+ const n = norm(c);
619
+ if (rangeStart) {
620
+ if (n.codePointAt(0) > rangeStart.codePointAt(0)) {
621
+ ranges.push(braceEscape(rangeStart) + "-" + braceEscape(n));
622
+ } else if (n === rangeStart) {
623
+ ranges.push(braceEscape(n));
624
+ }
625
+ rangeStart = "";
626
+ i += c.length;
627
+ continue;
628
+ }
629
+ if (glob.startsWith("-]", i + c.length)) {
630
+ ranges.push(braceEscape(n + "-"));
631
+ i += c.length + 1;
632
+ continue;
633
+ }
634
+ if (glob.startsWith("-", i + c.length)) {
635
+ rangeStart = n;
636
+ i += c.length + 1;
637
+ continue;
638
+ }
639
+ ranges.push(braceEscape(n));
640
+ i += c.length;
641
+ }
642
+ if (endPos < i) {
643
+ return [noMatch, 0];
644
+ }
645
+ if (!ranges.length && !negs.length) {
646
+ return [noMatch, glob.length - pos];
647
+ }
648
+ const sranges = "[" + (negate ? "^" : "") + ranges.join("") + "]";
649
+ const snegs = "[" + (negate ? "" : "^") + negs.join("") + "]";
650
+ const comb = "^" + (ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs);
651
+ return [new RegExp(comb, nocase ? "iu" : "u"), endPos - pos];
652
+ }, "parseClass");
653
+
654
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js
655
+ var MATCH = { t: "match", id: 0 };
656
+ var extTypes = "!?+*@";
657
+ var lit = /* @__PURE__ */ __name((ch) => ({ t: "lit", ch }), "lit");
658
+ var reEscape = /* @__PURE__ */ __name((s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&"), "reEscape");
659
+ var newFoldRe = /* @__PURE__ */ __name((s) => new RegExp(`^${reEscape(s)}$`, "iu"), "newFoldRe");
660
+ var foldCache = /* @__PURE__ */ new Map();
661
+ var foldRe = /* @__PURE__ */ __name((ch) => {
662
+ let re = foldCache.get(ch);
663
+ if (!re) {
664
+ re = newFoldRe(ch);
665
+ if (foldCache.size >= 1e3)
666
+ foldCache.clear();
667
+ foldCache.set(ch, re);
668
+ }
669
+ return re;
670
+ }, "foldRe");
671
+ var litMatch = /* @__PURE__ */ __name((l, c) => {
672
+ if (c === l.ch)
673
+ return true;
674
+ if (!l.re)
675
+ return false;
676
+ const code = c.charCodeAt(0);
677
+ if (code >= 128)
678
+ return l.re.test(c);
679
+ const ascii = l.ascii ??= new Uint8Array(128);
680
+ ascii[code] ||= l.re.test(c) ? 1 : 2;
681
+ return ascii[code] === 1;
682
+ }, "litMatch");
683
+ var tokenize = /* @__PURE__ */ __name((p, nocase, noext, form, mark) => {
684
+ const toks = [];
685
+ for (let i = 0; i < p.length; ) {
686
+ const c = String.fromCodePoint(p.codePointAt(i));
687
+ if (mark) {
688
+ const m = c === "\\" && p.startsWith(mark, i + 1) ? 1 : 0;
689
+ if (m || c === mark) {
690
+ const start = i + m + mark.length;
691
+ const end = p.indexOf(mark, start);
692
+ const r = /^(-?\d+)\.\.(-?\d+)$/.exec(p.slice(start, end));
693
+ const alts = end !== -1 && r && numericRange(r[1], r[2]);
694
+ if (alts) {
695
+ toks.push({ t: "ext", type: "@", alts });
696
+ i = end + mark.length;
697
+ continue;
698
+ }
699
+ }
700
+ }
701
+ if (c === "\\") {
702
+ const e = p.codePointAt(i + 1);
703
+ const ch = e === void 0 ? c : String.fromCodePoint(e);
704
+ toks.push(lit(ch));
705
+ i += 1 + ch.length;
706
+ continue;
707
+ }
708
+ if (c === "[") {
709
+ const [re, consumed] = parseClass(p, i, nocase, form);
710
+ if (consumed) {
711
+ toks.push({ t: "class", re });
712
+ i += consumed;
713
+ continue;
714
+ }
715
+ }
716
+ if (!noext && extTypes.includes(c) && p[i + 1] === "(") {
717
+ toks.push({ t: "open", type: c });
718
+ i += 2;
719
+ continue;
720
+ }
721
+ toks.push(!noext && c === "|" ? { t: "bar" } : !noext && c === ")" ? { t: "close" } : c === "*" ? { t: "star" } : c === "?" ? { t: "any" } : lit(c));
722
+ i += c.length;
723
+ }
724
+ return toks;
725
+ }, "tokenize");
726
+ var pair = /* @__PURE__ */ __name((toks) => {
727
+ const pairs = /* @__PURE__ */ new Map();
728
+ const stack = [];
729
+ toks.forEach((tok, i) => {
730
+ if (tok.t === "open")
731
+ stack.push(i);
732
+ else if (tok.t === "close" && stack.length)
733
+ pairs.set(stack.pop(), i);
734
+ });
735
+ return pairs;
736
+ }, "pair");
737
+ var build = /* @__PURE__ */ __name((toks, pairs, start, end, top) => {
738
+ let seq = [];
739
+ const alts = [seq];
740
+ for (let i = start; i < end; i++) {
741
+ const tok = toks[i];
742
+ const close = pairs.get(i);
743
+ if (tok.t === "open" && close !== void 0) {
744
+ const sub = build(toks, pairs, i + 1, close, false);
745
+ seq.push({ t: "ext", type: tok.type, alts: sub });
746
+ i = close;
747
+ } else if (tok.t === "bar" && !top) {
748
+ alts.push(seq = []);
749
+ } else if (tok.t === "open") {
750
+ seq.push(lit(tok.type), lit("("));
751
+ } else if (tok.t === "bar") {
752
+ seq.push(lit("|"));
753
+ } else if (tok.t === "close") {
754
+ seq.push(lit(")"));
755
+ } else {
756
+ seq.push(tok);
757
+ }
758
+ }
759
+ return alts;
760
+ }, "build");
761
+ var normalize = /* @__PURE__ */ __name((items, form) => {
762
+ const out = [];
763
+ let run = "";
764
+ const flush = /* @__PURE__ */ __name(() => {
765
+ for (const ch of run.normalize(form))
766
+ out.push(lit(ch));
767
+ run = "";
768
+ }, "flush");
769
+ for (const it of items) {
770
+ if (it.t === "lit") {
771
+ run += it.ch;
772
+ continue;
773
+ }
774
+ flush();
775
+ out.push(it.t === "ext" ? { ...it, alts: it.alts.map((a) => normalize(a, form)) } : it);
776
+ }
777
+ flush();
778
+ return out;
779
+ }, "normalize");
780
+ var compile = /* @__PURE__ */ __name((items, nocase) => {
781
+ let id = 1;
782
+ const split = /* @__PURE__ */ __name((out) => ({ t: "split", id: id++, out }), "split");
783
+ const seq = /* @__PURE__ */ __name((items2, next) => items2.reduceRight((next2, it) => item(it, next2), next), "seq");
784
+ const item = /* @__PURE__ */ __name((it, next) => {
785
+ switch (it.t) {
786
+ case "lit":
787
+ const re = nocase ? foldRe(it.ch) : void 0;
788
+ return { t: "lit", id: id++, ch: it.ch, re, next };
789
+ case "any":
790
+ case "star":
791
+ return { t: it.t, id: id++, next };
792
+ case "class":
793
+ return { t: "class", id: id++, re: it.re, next };
794
+ }
795
+ const alts = /* @__PURE__ */ __name((next2) => it.alts.map((a) => seq(a, next2)), "alts");
796
+ switch (it.type) {
797
+ case "@":
798
+ return split(alts(next));
799
+ case "?":
800
+ return split([next, ...alts(next)]);
801
+ case "!":
802
+ return { t: "neg", id: id++, sub: split(alts(MATCH)), next };
803
+ }
804
+ const after = split([]);
805
+ const entry = split(alts(after));
806
+ after.out.push(next, entry);
807
+ return it.type === "*" ? after : entry;
808
+ }, "item");
809
+ const start = seq(items, MATCH);
810
+ return [start, id];
811
+ }, "compile");
812
+ var show = /* @__PURE__ */ __name((start) => {
813
+ const lines = [];
814
+ const seen = /* @__PURE__ */ new Set();
815
+ const ref = /* @__PURE__ */ __name((n) => n.t === "match" ? "match" : String(n.id), "ref");
816
+ const walk = /* @__PURE__ */ __name((n, indent) => {
817
+ if (n.t === "match" || seen.has(n))
818
+ return;
819
+ seen.add(n);
820
+ const line = /* @__PURE__ */ __name((desc) => lines.push(`${indent}${n.id}: ${desc}`), "line");
821
+ switch (n.t) {
822
+ case "split":
823
+ line(`split -> ${n.out.map(ref).join(", ")}`);
824
+ for (const o of n.out)
825
+ walk(o, indent);
826
+ return;
827
+ case "neg":
828
+ line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
829
+ walk(n.sub, indent + " ");
830
+ return walk(n.next, indent);
831
+ case "lit":
832
+ line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
833
+ break;
834
+ case "class":
835
+ line(`${n.re} -> ${ref(n.next)}`);
836
+ break;
837
+ default:
838
+ line(`${n.t === "any" ? "?" : "*"} -> ${ref(n.next)}`);
839
+ }
840
+ walk(n.next, indent);
841
+ }, "walk");
842
+ walk(start, "");
843
+ return [`start -> ${ref(start)}`, ...lines].join("\n");
844
+ }, "show");
845
+ var State = class {
846
+ static {
847
+ __name(this, "State");
848
+ }
849
+ // set by the Sim, to mark the nodes that this state has
850
+ gen;
851
+ threads = [];
852
+ match = false;
853
+ runs = [];
854
+ // the sorted ids of the threads, with 0 for a match, once the
855
+ // state is done
856
+ ids = [];
857
+ constructor(gen) {
858
+ this.gen = gen;
859
+ }
860
+ // no threads, so nothing more can match
861
+ get dead() {
862
+ return !this.threads.length && !this.match && !this.runs.length;
863
+ }
864
+ };
865
+ var sameState = /* @__PURE__ */ __name((a, b) => {
866
+ if (a.ids.length !== b.ids.length)
867
+ return false;
868
+ if (a.runs.length !== b.runs.length)
869
+ return false;
870
+ if (a.ids.some((id, i) => id !== b.ids[i]))
871
+ return false;
872
+ return a.runs.every((r) => b.runs.some((o) => o.neg === r.neg && sameState(o.state, r.state)));
873
+ }, "sameState");
874
+ var marks = /* @__PURE__ */ __name((size) => ({
875
+ has: new Float64Array(size),
876
+ seen: new Float64Array(size),
877
+ gen: 0
878
+ }), "marks");
879
+ var Sim = class {
880
+ static {
881
+ __name(this, "Sim");
882
+ }
883
+ // `.` and `..` only match literal dots, even with `dot:true`
884
+ dots;
885
+ // the string starts with `.`, and `dot:true` is not set
886
+ dotStart;
887
+ #marks;
888
+ constructor(dots, dotStart, marks2) {
889
+ this.dots = dots;
890
+ this.dotStart = dotStart;
891
+ this.#marks = marks2;
892
+ }
893
+ state() {
894
+ return new State(++this.#marks.gen);
895
+ }
896
+ // sort the ids of a state, once it has all of its threads
897
+ done(state) {
898
+ state.ids = state.threads.map((n) => n.id).sort((a, b) => a - b);
899
+ if (state.match)
900
+ state.ids.unshift(MATCH.id);
901
+ return state;
902
+ }
903
+ // true the first time that the state walks through the node, so
904
+ // that loops in the graph stop
905
+ #visit(state, node) {
906
+ const { seen } = this.#marks;
907
+ if (seen[node.id] === state.gen)
908
+ return false;
909
+ seen[node.id] = state.gen;
910
+ return true;
911
+ }
912
+ #addThread(state, node) {
913
+ const { has } = this.#marks;
914
+ if (has[node.id] === state.gen)
915
+ return false;
916
+ has[node.id] = state.gen;
917
+ state.threads.push(node);
918
+ return true;
919
+ }
920
+ // wildcards only match a leading dot if `dot:true`. In a negated
921
+ // sub-pattern, this does not apply, because the negation itself
922
+ // can not match a leading dot.
923
+ restricted(i, top) {
924
+ return top && (this.dots || this.dotStart && i === 0);
925
+ }
926
+ add(state, node, i, top) {
927
+ switch (node.t) {
928
+ case "split":
929
+ if (!this.#visit(state, node))
930
+ return;
931
+ for (const o of node.out)
932
+ this.add(state, o, i, top);
933
+ return;
934
+ case "neg":
935
+ if (!this.#visit(state, node))
936
+ return;
937
+ const sub = this.state();
938
+ this.add(sub, node.sub, i, false);
939
+ this.done(sub);
940
+ return this.addRun(state, { t: "run", neg: node, state: sub }, i, top);
941
+ case "star":
942
+ if (this.restricted(i, top))
943
+ return;
944
+ if (this.#addThread(state, node))
945
+ this.add(state, node.next, i, top);
946
+ return;
947
+ case "match":
948
+ state.match = true;
949
+ return;
950
+ default:
951
+ this.#addThread(state, node);
952
+ }
953
+ }
954
+ addRun(state, run, i, top) {
955
+ for (const r of state.runs) {
956
+ if (r.neg === run.neg && sameState(r.state, run.state))
957
+ return;
958
+ }
959
+ state.runs.push(run);
960
+ if (!run.state.match) {
961
+ this.add(state, run.neg.next, i, top);
962
+ }
963
+ }
964
+ // the threads after char `c`, at index `i`
965
+ step(state, c, i, top) {
966
+ const next = this.state();
967
+ for (const th of state.threads) {
968
+ switch (th.t) {
969
+ case "lit":
970
+ if (litMatch(th, c)) {
971
+ this.add(next, th.next, i + 1, top);
972
+ }
973
+ break;
974
+ case "any":
975
+ if (!this.restricted(i, top))
976
+ this.add(next, th.next, i + 1, top);
977
+ break;
978
+ case "class":
979
+ if (!this.restricted(i, top) && th.re.test(c)) {
980
+ this.add(next, th.next, i + 1, top);
981
+ }
982
+ break;
983
+ case "star":
984
+ if (!this.restricted(i, top))
985
+ this.add(next, th, i + 1, top);
986
+ }
987
+ }
988
+ if (!this.restricted(i, top)) {
989
+ for (const run of state.runs) {
990
+ if (run.state.dead) {
991
+ this.addRun(next, run, i + 1, top);
992
+ continue;
993
+ }
994
+ const sub = this.step(run.state, c, i, false);
995
+ this.addRun(next, { t: "run", neg: run.neg, state: sub }, i + 1, top);
996
+ }
997
+ }
998
+ return this.done(next);
999
+ }
1000
+ };
1001
+ var stateKey = /* @__PURE__ */ __name((state) => {
1002
+ const ids = state.ids.join();
1003
+ if (!state.runs.length)
1004
+ return ids;
1005
+ const runs = state.runs.map((r) => `${r.neg.id}(${stateKey(r.state)})`);
1006
+ return `${ids}|${runs.sort().join("|")}`;
1007
+ }, "stateKey");
1008
+ var DFA_BUDGET = 1 << 18;
1009
+ var Dfa = class {
1010
+ static {
1011
+ __name(this, "Dfa");
1012
+ }
1013
+ #start;
1014
+ #states = /* @__PURE__ */ new Map();
1015
+ #size = 0;
1016
+ #plain;
1017
+ #dotStart;
1018
+ #sim;
1019
+ #dotSim;
1020
+ constructor(start, marks2) {
1021
+ this.#start = start;
1022
+ this.#sim = new Sim(false, false, marks2);
1023
+ this.#dotSim = new Sim(false, true, marks2);
1024
+ }
1025
+ #make(state) {
1026
+ return {
1027
+ state,
1028
+ match: state.match,
1029
+ dead: state.dead,
1030
+ next: /* @__PURE__ */ new Map()
1031
+ };
1032
+ }
1033
+ #intern(state) {
1034
+ const key = stateKey(state);
1035
+ const found = this.#states.get(key);
1036
+ if (found)
1037
+ return found;
1038
+ if (this.#size > DFA_BUDGET)
1039
+ this.#clear();
1040
+ const d = this.#make(state);
1041
+ this.#states.set(key, d);
1042
+ this.#size += key.length + 1;
1043
+ return d;
1044
+ }
1045
+ #clear() {
1046
+ this.#states.clear();
1047
+ this.#size = 0;
1048
+ this.#plain = void 0;
1049
+ this.#dotStart = void 0;
1050
+ }
1051
+ start(dotStart) {
1052
+ if (dotStart) {
1053
+ if (this.#dotStart)
1054
+ return this.#dotStart;
1055
+ const state2 = this.#dotSim.state();
1056
+ this.#dotSim.add(state2, this.#start, 0, true);
1057
+ return this.#dotStart = this.#make(this.#dotSim.done(state2));
1058
+ }
1059
+ if (this.#plain)
1060
+ return this.#plain;
1061
+ const state = this.#sim.state();
1062
+ this.#sim.add(state, this.#start, 0, true);
1063
+ return this.#plain = this.#intern(this.#sim.done(state));
1064
+ }
1065
+ // the next state, after a miss in `d.ascii`
1066
+ next(d, c) {
1067
+ const code = c.charCodeAt(0);
1068
+ const found = code < 128 ? void 0 : d.next.get(c);
1069
+ if (found)
1070
+ return found;
1071
+ const n = d === this.#dotStart ? this.#intern(this.#dotSim.step(d.state, c, 0, true)) : this.#intern(this.#sim.step(d.state, c, 1, true));
1072
+ if (code < 128) {
1073
+ if (!d.ascii) {
1074
+ d.ascii = new Array(128);
1075
+ this.#size += 128;
1076
+ }
1077
+ d.ascii[code] = n;
1078
+ } else {
1079
+ d.next.set(c, n);
1080
+ }
1081
+ this.#size++;
1082
+ return n;
1083
+ }
1084
+ };
1085
+ var linear = /* @__PURE__ */ __name((start) => {
1086
+ const nodes = [];
1087
+ for (let n = start; n.t !== "match"; n = n.next) {
1088
+ if (n.t === "split" || n.t === "neg")
1089
+ return void 0;
1090
+ nodes.push(n);
1091
+ }
1092
+ return nodes;
1093
+ }, "linear");
1094
+ var testLinear = /* @__PURE__ */ __name((nodes, chars, start, end) => {
1095
+ let ni = 0;
1096
+ let ci = start;
1097
+ let starNi = -1;
1098
+ let starCi = 0;
1099
+ while (ci < end) {
1100
+ const n = nodes[ni];
1101
+ if (n?.t === "star") {
1102
+ starNi = ni++;
1103
+ starCi = ci;
1104
+ continue;
1105
+ }
1106
+ const c = chars[ci];
1107
+ if (n && (n.t === "any" || n.t === "lit" && litMatch(n, c) || n.t === "class" && n.re.test(c))) {
1108
+ ni++;
1109
+ ci++;
1110
+ continue;
1111
+ }
1112
+ if (starNi === -1)
1113
+ return false;
1114
+ ni = starNi + 1;
1115
+ ci = ++starCi;
1116
+ }
1117
+ while (nodes[ni]?.t === "star")
1118
+ ni++;
1119
+ return ni === nodes.length;
1120
+ }, "testLinear");
1121
+ var lengths = /* @__PURE__ */ __name((items) => {
1122
+ let min = 0;
1123
+ let max = 0;
1124
+ for (const it of items) {
1125
+ const [lo, hi] = itemLengths(it);
1126
+ min += lo;
1127
+ max += hi;
1128
+ }
1129
+ return [min, max];
1130
+ }, "lengths");
1131
+ var itemLengths = /* @__PURE__ */ __name((it) => {
1132
+ if (it.t === "star")
1133
+ return [0, Infinity];
1134
+ if (it.t !== "ext")
1135
+ return [1, 1];
1136
+ if (it.type === "!")
1137
+ return [0, Infinity];
1138
+ const alts = it.alts.map(lengths);
1139
+ const min = Math.min(...alts.map((a) => a[0]));
1140
+ const max = Math.max(...alts.map((a) => a[1]));
1141
+ const loop = max === 0 ? 0 : Infinity;
1142
+ return it.type === "@" ? [min, max] : it.type === "?" ? [0, max] : it.type === "*" ? [0, loop] : [min, loop];
1143
+ }, "itemLengths");
1144
+ var hasAffix = /* @__PURE__ */ __name((lits, chars, start) => {
1145
+ for (let j = 0; j < lits.length; j++) {
1146
+ if (!litMatch(lits[j], chars[start + j]))
1147
+ return false;
1148
+ }
1149
+ return true;
1150
+ }, "hasAffix");
1151
+ var slashOrSurrogate = /[/\ud800-\udfff]/;
1152
+ var surrogate = /[\ud800-\udfff]/;
1153
+ var codePoints = /* @__PURE__ */ __name((s) => surrogate.test(s) ? [...s] : s, "codePoints");
1154
+ var noSlash = /* @__PURE__ */ __name((s) => {
1155
+ if (s.includes("/")) {
1156
+ throw new Error("can only match a single path portion, got: " + s);
1157
+ }
1158
+ }, "noSlash");
1159
+ var Matcher = class {
1160
+ static {
1161
+ __name(this, "Matcher");
1162
+ }
1163
+ pattern;
1164
+ options;
1165
+ #start;
1166
+ // the number of node ids
1167
+ #size;
1168
+ #marks;
1169
+ // the Sim for strings that are only `.` or `..`
1170
+ #dotsSim;
1171
+ // the string to compare, if the pattern has no magic. With
1172
+ // `nocase:true`, the RegExp that folds case is made when it is
1173
+ // first used.
1174
+ #literal;
1175
+ #literalFold = false;
1176
+ #literalRe;
1177
+ // the nodes between the prefix and suffix, if the graph is a
1178
+ // single chain
1179
+ #linear;
1180
+ // the linear nodes are only `*` and `?`, so the length bounds and
1181
+ // the prefix and suffix decide the match
1182
+ #wild = false;
1183
+ // the least and most chars that a match can have
1184
+ #min = 0;
1185
+ #max = Infinity;
1186
+ // the literals that a match must start and end with. Each one
1187
+ // matches exactly one char, and they are distinct items in the
1188
+ // pattern, so a string that does not have them can not match.
1189
+ #prefix = [];
1190
+ #suffix = [];
1191
+ // the prefix and suffix as strings, if they do not fold case
1192
+ #prefixStr;
1193
+ #suffixStr;
1194
+ // there is a prefix or suffix to check
1195
+ #affix = false;
1196
+ #dfa;
1197
+ #form;
1198
+ constructor(pattern, options = {}) {
1199
+ if (pattern.includes("/")) {
1200
+ throw new Error("can only match a single path portion, got pattern: " + pattern);
1201
+ }
1202
+ this.pattern = pattern;
1203
+ this.options = options;
1204
+ const { nocase = false, noext = false, normalize: n } = options;
1205
+ this.#form = n === true ? "NFC" : n || void 0;
1206
+ const literal2 = /^[?*+@]\(\)$/.test(pattern);
1207
+ const toks = tokenize(pattern, nocase, noext || literal2, this.#form, options.rangeMark);
1208
+ let [items] = build(toks, pair(toks), 0, toks.length, true);
1209
+ if (this.#form)
1210
+ items = normalize(items, this.#form);
1211
+ const [start, size] = compile(items, nocase);
1212
+ this.#start = start;
1213
+ this.#size = size;
1214
+ if (items.every((it) => it.t === "lit")) {
1215
+ this.#literal = items.map((it) => it.ch).join("");
1216
+ this.#literalFold = nocase;
1217
+ } else {
1218
+ const lit2 = /* @__PURE__ */ __name((it) => it.t !== "lit" ? void 0 : nocase ? { ch: it.ch, re: foldRe(it.ch) } : { ch: it.ch }, "lit");
1219
+ for (const it of items) {
1220
+ const l = lit2(it);
1221
+ if (!l)
1222
+ break;
1223
+ this.#prefix.push(l);
1224
+ }
1225
+ for (let j = items.length - 1; j >= 0; j--) {
1226
+ const l = lit2(items[j]);
1227
+ if (!l)
1228
+ break;
1229
+ this.#suffix.unshift(l);
1230
+ }
1231
+ this.#affix = !!(this.#prefix.length || this.#suffix.length);
1232
+ if (!nocase) {
1233
+ this.#prefixStr = this.#prefix.map((l) => l.ch).join("");
1234
+ this.#suffixStr = this.#suffix.map((l) => l.ch).join("");
1235
+ }
1236
+ this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || void 0);
1237
+ this.#wild = !!this.#linear?.every((n2) => n2.t === "star" || n2.t === "any");
1238
+ const [min, max] = lengths(items);
1239
+ this.#min = min;
1240
+ this.#max = max;
1241
+ }
1242
+ }
1243
+ test(s) {
1244
+ if (this.#form) {
1245
+ noSlash(s);
1246
+ return this.#test(s.normalize(this.#form));
1247
+ }
1248
+ if (slashOrSurrogate.test(s)) {
1249
+ noSlash(s);
1250
+ return this.#test(s, [...s]);
1251
+ }
1252
+ return this.#test(s, s);
1253
+ }
1254
+ /**
1255
+ * The same as {@link Matcher#test}, but the string is not checked
1256
+ * for `/` chars, so the result for a string that has one is not
1257
+ * defined. Only use it for a string that is known to be one path
1258
+ * portion, such as a part of a path that was split on `/`. It can
1259
+ * be faster, because some patterns do not need to look at each char
1260
+ * of the string.
1261
+ */
1262
+ testUnchecked(s) {
1263
+ return this.#test(this.#form ? s.normalize(this.#form) : s);
1264
+ }
1265
+ // Test a string that has no `/`. `chars` indexes it by code point.
1266
+ // If it is not given, it is only found if a step needs it.
1267
+ #test(s, chars) {
1268
+ if (this.#literal !== void 0) {
1269
+ return this.#literalFold ? (this.#literalRe ??= newFoldRe(this.#literal)).test(s) : s === this.#literal;
1270
+ }
1271
+ const min = this.#min;
1272
+ const max = this.#max;
1273
+ if (chars === void 0) {
1274
+ const most = s.length;
1275
+ const least = most + 1 >> 1;
1276
+ if (most < min || least > max)
1277
+ return false;
1278
+ if (least < min || most > max)
1279
+ chars = codePoints(s);
1280
+ }
1281
+ if (chars !== void 0 && (chars.length < min || chars.length > max)) {
1282
+ return false;
1283
+ }
1284
+ const prefix2 = this.#prefix.length;
1285
+ if (this.#affix) {
1286
+ if (this.#prefixStr !== void 0 && this.#suffixStr !== void 0) {
1287
+ if (!s.startsWith(this.#prefixStr) || !s.endsWith(this.#suffixStr)) {
1288
+ return false;
1289
+ }
1290
+ } else {
1291
+ chars ??= codePoints(s);
1292
+ const end = chars.length - this.#suffix.length;
1293
+ if (!hasAffix(this.#prefix, chars, 0) || !hasAffix(this.#suffix, chars, end)) {
1294
+ return false;
1295
+ }
1296
+ }
1297
+ }
1298
+ const dotStart = !this.options.dot && s.startsWith(".");
1299
+ if (this.#linear) {
1300
+ if (s === "." || s === "..")
1301
+ return false;
1302
+ if (dotStart && !prefix2)
1303
+ return false;
1304
+ if (this.#wild)
1305
+ return true;
1306
+ chars ??= codePoints(s);
1307
+ const end = chars.length - this.#suffix.length;
1308
+ return testLinear(this.#linear, chars, prefix2, end);
1309
+ }
1310
+ chars ??= codePoints(s);
1311
+ if (s === "." || s === "..") {
1312
+ this.#marks ??= marks(this.#size);
1313
+ const sim = this.#dotsSim ??= new Sim(true, false, this.#marks);
1314
+ const start = sim.state();
1315
+ sim.add(start, this.#start, 0, true);
1316
+ let state = sim.done(start);
1317
+ for (let i = 0; i < chars.length; i++) {
1318
+ state = sim.step(state, chars[i], i, true);
1319
+ }
1320
+ return state.match;
1321
+ }
1322
+ this.#marks ??= marks(this.#size);
1323
+ const dfa = this.#dfa ??= new Dfa(this.#start, this.#marks);
1324
+ let d = dfa.start(dotStart);
1325
+ const str = chars === s;
1326
+ for (let i = 0; i < chars.length; i++) {
1327
+ if (d.dead)
1328
+ return false;
1329
+ const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
1330
+ d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
1331
+ }
1332
+ return d.match;
1333
+ }
1334
+ /** a readable listing of the state machine */
1335
+ toString() {
1336
+ return show(this.#start);
1337
+ }
1338
+ };
1339
+
1340
+ // ../../node_modules/.pnpm/minimatch@11.0.5/node_modules/minimatch/dist/esm/assert-valid-pattern.js
1341
+ var MAX_PATTERN_LENGTH = 1024 * 64;
1342
+ var assertValidPattern = /* @__PURE__ */ __name((pattern) => {
1343
+ if (typeof pattern !== "string") {
1344
+ throw new TypeError("invalid pattern");
1345
+ }
1346
+ if (pattern.length > MAX_PATTERN_LENGTH) {
1347
+ throw new TypeError("pattern is too long");
1348
+ }
1349
+ }, "assertValidPattern");
1350
+
1351
+ // ../../node_modules/.pnpm/minimatch@11.0.5/node_modules/minimatch/dist/esm/escape.js
1352
+ var escape = /* @__PURE__ */ __name((s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
1353
+ if (magicalBraces) {
1354
+ return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
1355
+ }
1356
+ return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
1357
+ }, "escape");
1358
+
1359
+ // ../../node_modules/.pnpm/minimatch@11.0.5/node_modules/minimatch/dist/esm/unescape.js
1360
+ var unescape = /* @__PURE__ */ __name((s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
1361
+ if (magicalBraces) {
1362
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
1363
+ }
1364
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
1365
+ }, "unescape");
1366
+
1367
+ // ../../node_modules/.pnpm/minimatch@11.0.5/node_modules/minimatch/dist/esm/index.js
1368
+ var minimatch = /* @__PURE__ */ __name((p, pattern, options = {}) => {
1369
+ assertValidPattern(pattern);
1370
+ if (!options.nocomment && pattern.charAt(0) === "#") {
1371
+ return false;
1372
+ }
1373
+ return cachedMinimatch(pattern, options).match(p);
1374
+ }, "minimatch");
1375
+ var cache = /* @__PURE__ */ new Map();
1376
+ var cacheMax = 256;
1377
+ var cachedMinimatch = /* @__PURE__ */ __name((pattern, options) => {
1378
+ const key = pattern + "\0" + JSON.stringify(options);
1379
+ let mm = cache.get(key);
1380
+ if (mm) {
1381
+ cache.delete(key);
1382
+ } else {
1383
+ mm = new Minimatch(pattern, { ...options });
1384
+ if (cache.size >= cacheMax) {
1385
+ cache.delete(cache.keys().next().value);
1386
+ }
1387
+ }
1388
+ cache.set(key, mm);
1389
+ return mm;
1390
+ }, "cachedMinimatch");
1391
+ var defaultPlatform = typeof process === "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
1392
+ var path = {
1393
+ win32: { sep: "\\" },
1394
+ posix: { sep: "/" }
1395
+ };
1396
+ var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
1397
+ minimatch.sep = sep;
1398
+ var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
1399
+ minimatch.GLOBSTAR = GLOBSTAR;
1400
+ var filter = /* @__PURE__ */ __name((pattern, options = {}) => (p) => minimatch(p, pattern, options), "filter");
1401
+ minimatch.filter = filter;
1402
+ var ext = /* @__PURE__ */ __name((a, b = {}) => Object.assign({}, a, b), "ext");
1403
+ var defaults = /* @__PURE__ */ __name((def) => {
1404
+ if (!def || typeof def !== "object" || !Object.keys(def).length) {
1405
+ return minimatch;
1406
+ }
1407
+ const orig = minimatch;
1408
+ const m = /* @__PURE__ */ __name((p, pattern, options = {}) => orig(p, pattern, ext(def, options)), "m");
1409
+ return Object.assign(m, {
1410
+ Minimatch: class Minimatch extends orig.Minimatch {
1411
+ static {
1412
+ __name(this, "Minimatch");
1413
+ }
1414
+ constructor(pattern, options = {}) {
1415
+ super(pattern, ext(def, options));
1416
+ }
1417
+ static defaults(options) {
1418
+ return orig.defaults(ext(def, options)).Minimatch;
1419
+ }
1420
+ },
1421
+ unescape: /* @__PURE__ */ __name((s, options = {}) => orig.unescape(s, ext(def, options)), "unescape"),
1422
+ escape: /* @__PURE__ */ __name((s, options = {}) => orig.escape(s, ext(def, options)), "escape"),
1423
+ filter: /* @__PURE__ */ __name((pattern, options = {}) => orig.filter(pattern, ext(def, options)), "filter"),
1424
+ defaults: /* @__PURE__ */ __name((options) => orig.defaults(ext(def, options)), "defaults"),
1425
+ braceExpand: /* @__PURE__ */ __name((pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)), "braceExpand"),
1426
+ match: /* @__PURE__ */ __name((list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)), "match"),
1427
+ sep: orig.sep,
1428
+ GLOBSTAR
1429
+ });
1430
+ }, "defaults");
1431
+ minimatch.defaults = defaults;
1432
+ var braceExpand = /* @__PURE__ */ __name((pattern, options = {}) => {
1433
+ assertValidPattern(pattern);
1434
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
1435
+ return [pattern];
1436
+ }
1437
+ return expand(pattern, { max: options.braceExpandMax });
1438
+ }, "braceExpand");
1439
+ minimatch.braceExpand = braceExpand;
1440
+ var RANGE_MIN = 100;
1441
+ var rangeRe = /(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g;
1442
+ var match = /* @__PURE__ */ __name((list, pattern, options = {}) => {
1443
+ const mm = new Minimatch(pattern, options);
1444
+ list = list.filter((f) => mm.match(f));
1445
+ if (mm.options.nonull && !list.length) {
1446
+ list.push(pattern);
1447
+ }
1448
+ return list;
1449
+ }, "match");
1450
+ minimatch.match = match;
1451
+ var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
1452
+ var classEnd = /* @__PURE__ */ __name((pattern, start) => {
1453
+ let i = start + 1;
1454
+ if (pattern.charAt(i) === "!" || pattern.charAt(i) === "^")
1455
+ i++;
1456
+ let sawStart = false;
1457
+ for (; i < pattern.length; i++) {
1458
+ const c = pattern.charAt(i);
1459
+ if (c === "]" && sawStart)
1460
+ return i;
1461
+ sawStart = true;
1462
+ if (c === "\\")
1463
+ i++;
1464
+ }
1465
+ return -1;
1466
+ }, "classEnd");
1467
+ var literal = /* @__PURE__ */ __name((pattern, noext) => {
1468
+ if (!noext && (pattern === "+()" || pattern === "@()"))
1469
+ return pattern;
1470
+ let lit2 = "";
1471
+ for (let i = 0; i < pattern.length; i++) {
1472
+ const c = pattern.charAt(i);
1473
+ if (c === "\\") {
1474
+ lit2 += pattern.charAt(++i) || c;
1475
+ } else if (c === "*" || c === "?") {
1476
+ return void 0;
1477
+ } else if (c === "[") {
1478
+ const close = classEnd(pattern, i);
1479
+ if (close === -1) {
1480
+ lit2 += c;
1481
+ continue;
1482
+ }
1483
+ let body = pattern.slice(i + 1, close);
1484
+ if (body.startsWith("\\"))
1485
+ body = body.slice(1);
1486
+ if ([...body].length !== 1 || "!^".includes(pattern.charAt(i + 1))) {
1487
+ return void 0;
1488
+ }
1489
+ lit2 += body;
1490
+ i = close;
1491
+ } else if (!noext && "+@!".includes(c) && pattern.charAt(i + 1) === "(" && pattern.includes(")", i + 2)) {
1492
+ return void 0;
1493
+ } else {
1494
+ lit2 += c;
1495
+ }
1496
+ }
1497
+ return lit2;
1498
+ }, "literal");
1499
+ var extSafe = /* @__PURE__ */ __name((pattern) => {
1500
+ if (/^[?*+@]\(\)$/.test(pattern) || pattern.includes("[:"))
1501
+ return false;
1502
+ let depth = 0;
1503
+ for (let i = 0; i < pattern.length; i++) {
1504
+ const c = pattern.charAt(i);
1505
+ if (c === "\\") {
1506
+ if (++i === pattern.length)
1507
+ return false;
1508
+ } else if (c === "[") {
1509
+ const close = classEnd(pattern, i);
1510
+ if (close !== -1)
1511
+ i = close;
1512
+ } else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
1513
+ depth++;
1514
+ i++;
1515
+ } else if (c === ")") {
1516
+ if (!depth--)
1517
+ return false;
1518
+ } else if (c === "|" && !depth) {
1519
+ return false;
1520
+ }
1521
+ }
1522
+ return !depth;
1523
+ }, "extSafe");
1524
+ var lastSplit;
1525
+ var lastChecked;
1526
+ var portionMatch = /* @__PURE__ */ __name((p, f) => typeof p === "string" ? f === p : f !== "" && p.testUnchecked(f), "portionMatch");
1527
+ var endIndex = /* @__PURE__ */ __name((p, last, lastStart, prev, prevStart) => portionMatch(p, last) ? lastStart : prev !== void 0 && portionMatch(p, prev) ? prevStart : -1, "endIndex");
1528
+ var isDots = /* @__PURE__ */ __name((p) => p === "." || p === "..", "isDots");
1529
+ var isDrive = /* @__PURE__ */ __name((p) => typeof p === "string" && /^[a-z]:$/i.test(p), "isDrive");
1530
+ var isLongUNC = /* @__PURE__ */ __name((p) => typeof p === "string" && /^unc$/i.test(p), "isLongUNC");
1531
+ var uncHost = /* @__PURE__ */ __name((p) => {
1532
+ if (p[0] !== "" || p[1] !== "")
1533
+ return -1;
1534
+ const h = p[2] !== "?" ? 2 : isLongUNC(p[3]) ? 4 : -1;
1535
+ const host = p[h];
1536
+ const share = p[h + 1];
1537
+ return h !== -1 && host !== void 0 && host !== "" && host !== GLOBSTAR && share !== void 0 && share !== "" && share !== GLOBSTAR ? h : -1;
1538
+ }, "uncHost");
1539
+ var walkable = /* @__PURE__ */ __name((p, dot) => !isDots(p) && (dot || !p.startsWith(".")), "walkable");
1540
+ var dotPortion = /* @__PURE__ */ __name((f, start, end, dot, sep2) => {
1541
+ for (let k = start; k < end; ) {
1542
+ if (f.charCodeAt(k) === 46) {
1543
+ if (!dot)
1544
+ return true;
1545
+ const n = f.charCodeAt(k + 1) === 46 ? k + 2 : k + 1;
1546
+ if (n >= end || isSep(f.charCodeAt(n), sep2))
1547
+ return true;
1548
+ }
1549
+ const s = nextSep(f, k, sep2);
1550
+ if (s === -1)
1551
+ return false;
1552
+ k = s + 1;
1553
+ while (k < end && isSep(f.charCodeAt(k), sep2))
1554
+ k++;
1555
+ }
1556
+ return false;
1557
+ }, "dotPortion");
1558
+ var isSep = /* @__PURE__ */ __name((c, sep2) => sep2 === "/" ? c === 47 : sep2 === "\\" ? c === 92 : c === 47 || c === 92, "isSep");
1559
+ var nextSep = /* @__PURE__ */ __name((f, from, sep2) => {
1560
+ if (sep2 !== "both")
1561
+ return f.indexOf(sep2, from);
1562
+ const s = f.indexOf("/", from);
1563
+ const b = f.indexOf("\\", from);
1564
+ return s === -1 ? b : b === -1 ? s : Math.min(s, b);
1565
+ }, "nextSep");
1566
+ var lastSep = /* @__PURE__ */ __name((f, from, sep2) => sep2 !== "both" ? f.lastIndexOf(sep2, from) : Math.max(f.lastIndexOf("/", from), f.lastIndexOf("\\", from)), "lastSep");
1567
+ var PENDING = {};
1568
+ var Minimatch = class {
1569
+ static {
1570
+ __name(this, "Minimatch");
1571
+ }
1572
+ options;
1573
+ set;
1574
+ pattern;
1575
+ windowsPathsNoEscape;
1576
+ nonegate;
1577
+ negate;
1578
+ comment;
1579
+ empty;
1580
+ preserveMultipleSlashes;
1581
+ partial;
1582
+ globSet;
1583
+ globParts;
1584
+ nocase;
1585
+ isWindows;
1586
+ platform;
1587
+ windowsNoMagicRoot;
1588
+ maxGlobstarRecursion;
1589
+ // the path can be checked against the last portion, and the string
1590
+ // portions, of each row before it is split. See #canMatch.
1591
+ #endCheck;
1592
+ #literalCheck;
1593
+ // level 2 resolves `.` and `..` portions in the path
1594
+ #level2;
1595
+ // the unicode normalization form, if any
1596
+ #form;
1597
+ // the string portions of each row in the set
1598
+ #literals = [];
1599
+ // the rows that #canMatch can match without splitting the path
1600
+ #shapes = [];
1601
+ // the rows whose last portion can be checked against the path's
1602
+ #endRows = [];
1603
+ // brace expansion can make the same portion in many rows, so they
1604
+ // share one Matcher, and the states that it caches
1605
+ #matchers = /* @__PURE__ */ new Map();
1606
+ // parse() returns PENDING in place of a Matcher
1607
+ #pending = false;
1608
+ // the char that marks numeric ranges in globSet, if any
1609
+ #rangeMark;
1610
+ // the GlobstarParts of each pattern row, by start index and partial
1611
+ #globstarParts = /* @__PURE__ */ new WeakMap();
1612
+ constructor(pattern, options = {}) {
1613
+ assertValidPattern(pattern);
1614
+ options = options || {};
1615
+ this.options = options;
1616
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
1617
+ this.pattern = pattern;
1618
+ this.platform = options.platform || defaultPlatform;
1619
+ this.isWindows = this.platform === "win32";
1620
+ const awe = "allowWindowsEscape";
1621
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
1622
+ if (this.windowsPathsNoEscape) {
1623
+ this.pattern = this.pattern.replace(/\\/g, "/");
1624
+ }
1625
+ this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
1626
+ this.negate = false;
1627
+ this.nonegate = !!options.nonegate;
1628
+ this.comment = false;
1629
+ this.empty = false;
1630
+ this.partial = !!options.partial;
1631
+ this.nocase = !!this.options.nocase;
1632
+ this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
1633
+ this.globSet = [];
1634
+ this.globParts = [];
1635
+ this.set = [];
1636
+ this.#endCheck = !this.preserveMultipleSlashes;
1637
+ this.#level2 = (options.optimizationLevel ?? 1) >= 2;
1638
+ const n = options.normalize;
1639
+ this.#form = n === true ? "NFC" : n || void 0;
1640
+ this.make();
1641
+ const drives = this.set.map((row) => this.#rootIndex(row));
1642
+ this.#endRows = this.set.map((row, r) => this.#endCheck && row.length - 1 > drives[r]);
1643
+ this.#literals = this.set.map((row, r) => {
1644
+ const end = this.#endRows[r] ? row.length - 1 : row.length;
1645
+ const lits = row.slice(drives[r] + 1, end).filter((p) => typeof p === "string" && !!p);
1646
+ return [...new Set(lits)];
1647
+ });
1648
+ this.#literalCheck = this.#literals.some((l) => l.length);
1649
+ this.#shapes = this.set.map((row, r) => {
1650
+ const [p0, p1, p2] = row;
1651
+ if (this.#endRows[r] && row.length === 2) {
1652
+ if (p0 === GLOBSTAR && p1 !== GLOBSTAR)
1653
+ return "tail";
1654
+ }
1655
+ if (this.#endRows[r] && options.matchBase && row.length === 1 && p0 !== GLOBSTAR && p0 !== "") {
1656
+ return "base";
1657
+ }
1658
+ if (!this.#endCheck || drives[r] !== -1)
1659
+ return void 0;
1660
+ if (row.length === 3 && p0 === GLOBSTAR && p2 === GLOBSTAR && p1 !== GLOBSTAR && p1 !== "" && // the portion between is only matched below this limit
1661
+ this.maxGlobstarRecursion > 0) {
1662
+ return "mid";
1663
+ }
1664
+ if (row.length === 2 && p1 === GLOBSTAR && p0 !== GLOBSTAR && p0 !== "") {
1665
+ return "head";
1666
+ }
1667
+ return void 0;
1668
+ });
1669
+ }
1670
+ // a string portion of a pattern, normalized if the option is set
1671
+ #norm(p) {
1672
+ return this.#form ? p.normalize(this.#form) : p;
1673
+ }
1674
+ // On Windows, the index of the last root portion of a row, as
1675
+ // #matchRow finds it: 0 for `c:/...`, 3 for `//?/c:/...` and
1676
+ // `//host/share/...`, and 5 for `//?/UNC/host/share/...`. Otherwise
1677
+ // -1.
1678
+ #rootIndex(row) {
1679
+ if (!this.isWindows)
1680
+ return -1;
1681
+ if (isDrive(row[0]))
1682
+ return 0;
1683
+ const uncDrive = row[0] === "" && row[1] === "" && row[2] === "?" && isDrive(row[3]);
1684
+ if (uncDrive)
1685
+ return 3;
1686
+ const h = uncHost(row);
1687
+ return h === -1 ? -1 : h + 1;
1688
+ }
1689
+ hasMagic() {
1690
+ if (this.options.magicalBraces && this.set.length > 1) {
1691
+ return true;
1692
+ }
1693
+ for (const pattern of this.set) {
1694
+ for (const part of pattern) {
1695
+ if (typeof part !== "string")
1696
+ return true;
1697
+ }
1698
+ }
1699
+ return false;
1700
+ }
1701
+ make() {
1702
+ const pattern = this.pattern;
1703
+ const options = this.options;
1704
+ if (!options.nocomment && pattern.charAt(0) === "#") {
1705
+ this.comment = true;
1706
+ return;
1707
+ }
1708
+ if (!pattern) {
1709
+ this.empty = true;
1710
+ return;
1711
+ }
1712
+ this.parseNegate();
1713
+ this.globSet = [...new Set(this.#expandBraces())];
1714
+ const rawGlobParts = this.globSet.map((s) => this.#slashSplit(s));
1715
+ this.globParts = this.preprocess(rawGlobParts);
1716
+ this.#pending = true;
1717
+ let set = this.globParts.map((s, _, __) => {
1718
+ if (this.isWindows && this.windowsNoMagicRoot) {
1719
+ const n = s[2] === "?" && isLongUNC(s[3]) ? 6 : 4;
1720
+ const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && s.slice(3, n).every((p) => !globMagic.test(p));
1721
+ const isDrive2 = /^[a-z]:/i.test(s[0]);
1722
+ if (isUNC) {
1723
+ return [
1724
+ ...s.slice(0, n).map((p) => this.#norm(p)),
1725
+ ...s.slice(n).map((ss) => this.parse(ss))
1726
+ ];
1727
+ } else if (isDrive2) {
1728
+ return [
1729
+ this.#norm(s[0]),
1730
+ ...s.slice(1).map((ss) => this.parse(ss))
1731
+ ];
1732
+ }
1733
+ }
1734
+ return s.map((ss) => this.parse(ss));
1735
+ });
1736
+ this.set = set.filter((s) => s.indexOf(false) === -1);
1737
+ if (this.isWindows) {
1738
+ for (let i = 0; i < this.set.length; i++) {
1739
+ const p = this.set[i];
1740
+ if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && (isDrive(p[3]) || isLongUNC(this.globParts[i][3]))) {
1741
+ if (isLongUNC(this.globParts[i][3]))
1742
+ p[3] = "UNC";
1743
+ p[2] = "?";
1744
+ }
1745
+ }
1746
+ }
1747
+ if (!options.noext)
1748
+ this.mergeRows();
1749
+ this.#pending = false;
1750
+ this.set.forEach((row, i) => {
1751
+ for (let k = 0; k < row.length; k++) {
1752
+ if (row[k] === PENDING) {
1753
+ row[k] = this.parse(this.globParts[i][k]);
1754
+ }
1755
+ }
1756
+ });
1757
+ }
1758
+ // Merge rows that only differ in one portion, where each of them
1759
+ // is a Matcher, into one row that matches any of them with
1760
+ // `@(a|b|...)`. Then a path is only walked once for all of them,
1761
+ // for example with `**/*.{js,ts}`.
1762
+ mergeRows() {
1763
+ let merged = true;
1764
+ while (merged) {
1765
+ merged = false;
1766
+ const len = Math.max(0, ...this.set.map((r) => r.length));
1767
+ for (let k = 0; k < len; k++) {
1768
+ const groups = /* @__PURE__ */ new Map();
1769
+ this.set.forEach((row, i) => {
1770
+ if (!(row[k] instanceof Matcher || row[k] === PENDING) || !extSafe(this.globParts[i][k])) {
1771
+ return;
1772
+ }
1773
+ const parts = [...this.globParts[i]];
1774
+ parts[k] = "";
1775
+ const key = `${row.length}/${parts.join("/")}`;
1776
+ const g = groups.get(key);
1777
+ if (g)
1778
+ g.push(i);
1779
+ else
1780
+ groups.set(key, [i]);
1781
+ });
1782
+ const drop = /* @__PURE__ */ new Set();
1783
+ for (const g of groups.values()) {
1784
+ if (g.length < 2)
1785
+ continue;
1786
+ const [first, ...rest] = g;
1787
+ const alts = g.map((i) => this.globParts[i][k]);
1788
+ const glob = `@(${alts.join("|")})`;
1789
+ this.globParts[first][k] = glob;
1790
+ this.set[first][k] = this.parse(glob);
1791
+ for (const i of rest)
1792
+ drop.add(i);
1793
+ }
1794
+ if (drop.size) {
1795
+ merged = true;
1796
+ this.set = this.set.filter((_, i) => !drop.has(i));
1797
+ this.globParts = this.globParts.filter((_, i) => !drop.has(i));
1798
+ }
1799
+ }
1800
+ }
1801
+ }
1802
+ // various transforms to equivalent pattern sets that are
1803
+ // faster to process in a filesystem walk. The goal is to
1804
+ // eliminate what we can, and push all ** patterns as far
1805
+ // to the right as possible, even if it increases the number
1806
+ // of patterns that we have to process.
1807
+ preprocess(globParts) {
1808
+ if (this.options.noglobstar) {
1809
+ for (const partset of globParts) {
1810
+ for (let j = 0; j < partset.length; j++) {
1811
+ if (partset[j] === "**") {
1812
+ partset[j] = "*";
1813
+ }
1814
+ }
1815
+ }
1816
+ }
1817
+ const { optimizationLevel = 1 } = this.options;
1818
+ if (optimizationLevel >= 2) {
1819
+ globParts = this.firstPhasePreProcess(globParts);
1820
+ globParts = this.secondPhasePreProcess(globParts);
1821
+ } else if (optimizationLevel >= 1) {
1822
+ globParts = this.levelOneOptimize(globParts);
1823
+ } else {
1824
+ globParts = this.adjascentGlobstarOptimize(globParts);
1825
+ }
1826
+ return globParts;
1827
+ }
1828
+ // just get rid of adjascent ** portions
1829
+ adjascentGlobstarOptimize(globParts) {
1830
+ return globParts.map((parts) => {
1831
+ let gs = -1;
1832
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1833
+ let i = gs;
1834
+ while (parts[i + 1] === "**") {
1835
+ i++;
1836
+ }
1837
+ if (i !== gs) {
1838
+ parts.splice(gs, i - gs);
1839
+ }
1840
+ }
1841
+ return parts;
1842
+ });
1843
+ }
1844
+ // get rid of adjascent ** and resolve .. portions
1845
+ levelOneOptimize(globParts) {
1846
+ return globParts.map((parts) => {
1847
+ const root = this.#rootIndex(parts) + 1;
1848
+ parts = parts.reduce((set, part) => {
1849
+ const prev = set[set.length - 1];
1850
+ if (part === "**" && prev === "**") {
1851
+ return set;
1852
+ }
1853
+ if (part === "..") {
1854
+ if (set.length > root && prev && prev !== ".." && prev !== "." && prev !== "**") {
1855
+ set.pop();
1856
+ return set;
1857
+ }
1858
+ }
1859
+ set.push(part);
1860
+ return set;
1861
+ }, []);
1862
+ return parts.length === 0 ? [""] : parts;
1863
+ });
1864
+ }
1865
+ // Check the path against each row before it is split. 'no' if no
1866
+ // row can match, so it does not need to be split. 'yes' if a row of
1867
+ // `**` and one more portion matches. 'maybe' if it must be split to
1868
+ // know. None of this applies with partial, where the path can end
1869
+ // before the row does.
1870
+ //
1871
+ // On Windows, `\` is a separator in the path too, and the portions of
1872
+ // a row up to its drive letter or UNC share are not checked (see
1873
+ // #rootIndex).
1874
+ //
1875
+ // Each string portion of a row must be a portion of the path, so the
1876
+ // path must contain it. Level 2 can only take portions out of the
1877
+ // path, so this is still true then.
1878
+ //
1879
+ // The last portion of a row must match the last portion of the path,
1880
+ // or the one before a trailing `/` (as a/* and a/**/* match a/b/).
1881
+ // This does not apply to rows that end in **, rows that end in a
1882
+ // root, or preserveMultipleSlashes (which can leave more
1883
+ // than one '' at the end). At level 2, it does not apply if that
1884
+ // portion is `.` or `..`, which can be
1885
+ // resolved away. Level 2 only takes other portions out of the
1886
+ // middle of the path.
1887
+ //
1888
+ // A row of `**/x` then matches if the ** can walk the portions
1889
+ // before the one that x matches, the same as #matchGlobstar. At
1890
+ // level 2, this is only known if none of them are `.` or `..`, so
1891
+ // that the path does not change when it is resolved.
1892
+ #canMatch(f) {
1893
+ const sep2 = !this.isWindows || !f.includes("\\") ? "/" : f.includes("/") ? "both" : "\\";
1894
+ let ends = this.#endCheck ? 0 : -1;
1895
+ let last = "";
1896
+ let lastStart = 0;
1897
+ let prev;
1898
+ let prevStart = 0;
1899
+ const dot = !!this.options.dot;
1900
+ ROWS: for (let r = 0; r < this.set.length; r++) {
1901
+ const row = this.set[r];
1902
+ const p = row[row.length - 1];
1903
+ let end = ends !== -1 && this.#endRows[r] && p !== GLOBSTAR;
1904
+ if (end && ends === 0) {
1905
+ const i = lastSep(f, f.length, sep2);
1906
+ lastStart = i + 1;
1907
+ last = f.slice(lastStart);
1908
+ if (last === "" && i >= 0) {
1909
+ let j = i;
1910
+ while (j > 0 && isSep(f.charCodeAt(j - 1), sep2))
1911
+ j--;
1912
+ prevStart = j === 0 ? 0 : lastSep(f, j - 1, sep2) + 1;
1913
+ prev = f.slice(prevStart, j);
1914
+ }
1915
+ const resolves = this.#level2 && (isDots(last) || last === "" && prev !== void 0 && isDots(prev));
1916
+ ends = resolves ? -1 : 1;
1917
+ end = !resolves;
1918
+ }
1919
+ let tailStart = -1;
1920
+ if (end && typeof p === "string") {
1921
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
1922
+ if (tailStart === -1)
1923
+ continue;
1924
+ }
1925
+ if (this.#literalCheck) {
1926
+ for (const l of this.#literals[r]) {
1927
+ if (!f.includes(l))
1928
+ continue ROWS;
1929
+ }
1930
+ }
1931
+ if (end && typeof p === "object") {
1932
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
1933
+ if (tailStart === -1)
1934
+ continue;
1935
+ }
1936
+ const shape = this.#shapes[r];
1937
+ if (shape === "base" && end)
1938
+ return "yes";
1939
+ if (shape === "tail" && end) {
1940
+ if (this.#level2 && dotPortion(f, 0, tailStart, true, sep2)) {
1941
+ return "maybe";
1942
+ }
1943
+ if (!dotPortion(f, 0, tailStart, dot, sep2))
1944
+ return "yes";
1945
+ continue;
1946
+ }
1947
+ if (shape === "mid" || shape === "head") {
1948
+ const m = this.#walk(f, row, shape === "head", dot, sep2);
1949
+ if (m !== "no")
1950
+ return m;
1951
+ continue;
1952
+ }
1953
+ return "maybe";
1954
+ }
1955
+ return "no";
1956
+ }
1957
+ // Match a row of a known shape against the split path, the same as
1958
+ // #matchGlobstar and #matchGlobStarBodySections do. None of these
1959
+ // rows have a drive letter, so they start at the first portion.
1960
+ #matchShape(file, row, shape) {
1961
+ const dot = !!this.options.dot;
1962
+ const n = file.length;
1963
+ if (shape === "head") {
1964
+ if (n < 2 || !portionMatch(row[0], file[0])) {
1965
+ return false;
1966
+ }
1967
+ for (let i = 1; i < n; i++)
1968
+ if (!walkable(file[i], dot))
1969
+ return false;
1970
+ return true;
1971
+ }
1972
+ const x = row[1];
1973
+ if (shape === "tail") {
1974
+ let t = n - 1;
1975
+ if (!portionMatch(x, file[t])) {
1976
+ if (file[t] !== "" || n === 1 || !portionMatch(x, file[--t])) {
1977
+ return false;
1978
+ }
1979
+ }
1980
+ for (let i = 0; i < t; i++)
1981
+ if (!walkable(file[i], dot))
1982
+ return false;
1983
+ return true;
1984
+ }
1985
+ for (let k = 0; k < n; k++) {
1986
+ if (portionMatch(x, file[k]) && k + 1 < n) {
1987
+ let i = k + 1;
1988
+ while (i < n && walkable(file[i], dot))
1989
+ i++;
1990
+ if (i === n)
1991
+ return true;
1992
+ }
1993
+ if (!walkable(file[k], dot))
1994
+ return false;
1995
+ }
1996
+ return false;
1997
+ }
1998
+ // Match a row of `**/x/**` or `x/**` against the path, the same as
1999
+ // #matchGlobstar and #matchGlobStarBodySections do once it is split.
2000
+ // x must match a portion (the first one, for `x/**`), the ** before
2001
+ // it must be able to walk the portions before that one, and there
2002
+ // must be a portion after it, which the ** after it can walk. At
2003
+ // level 2, this is only known if no portion is `.` or `..`.
2004
+ #walk(f, row, head, dot, sep2) {
2005
+ if (this.#level2 && dotPortion(f, 0, f.length, true, sep2))
2006
+ return "maybe";
2007
+ const x = row[head ? 0 : 1];
2008
+ let s = 0;
2009
+ for (let e = nextSep(f, s, sep2); e !== -1; e = nextSep(f, s, sep2)) {
2010
+ let next = e + 1;
2011
+ while (next < f.length && isSep(f.charCodeAt(next), sep2))
2012
+ next++;
2013
+ const hit = typeof x === "string" ? e - s === x.length && f.startsWith(x, s) : e > s && x.testUnchecked(f.slice(s, e));
2014
+ if (hit && !dotPortion(f, next, f.length, dot, sep2))
2015
+ return "yes";
2016
+ if (head || dotPortion(f, s, next, dot, sep2))
2017
+ return "no";
2018
+ s = next;
2019
+ }
2020
+ return "no";
2021
+ }
2022
+ // the last split, if it was the same path with the same split
2023
+ // settings
2024
+ #cachedSplit(f) {
2025
+ const last = lastSplit;
2026
+ return last?.f === f && last.isWindows === this.isWindows && last.preserveMultipleSlashes === this.preserveMultipleSlashes && last.normalize === this.#form ? last : void 0;
2027
+ }
2028
+ // split a path for match(), and keep the parts for the next call
2029
+ #split(f) {
2030
+ const { isWindows, preserveMultipleSlashes } = this;
2031
+ let parts = this.#slashSplit(isWindows ? f.split("\\").join("/") : f);
2032
+ const normalize2 = this.#form;
2033
+ if (normalize2)
2034
+ parts = parts.map((p) => p.normalize(normalize2));
2035
+ lastSplit = {
2036
+ f,
2037
+ isWindows,
2038
+ preserveMultipleSlashes,
2039
+ normalize: normalize2,
2040
+ parts
2041
+ };
2042
+ return lastSplit;
2043
+ }
2044
+ // resolve `.` and `..` portions of a path, for level 2
2045
+ #levelTwoFileOptimize(file) {
2046
+ const parts = [...file];
2047
+ let didSomething = false;
2048
+ do {
2049
+ didSomething = false;
2050
+ if (!this.preserveMultipleSlashes) {
2051
+ for (let i = 1; i < parts.length - 1; i++) {
2052
+ const p = parts[i];
2053
+ if (i === 1 && p === "" && parts[0] === "")
2054
+ continue;
2055
+ if (p === "." || p === "") {
2056
+ didSomething = true;
2057
+ parts.splice(i, 1);
2058
+ i--;
2059
+ }
2060
+ }
2061
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
2062
+ didSomething = true;
2063
+ parts.pop();
2064
+ }
2065
+ }
2066
+ const root = this.#rootIndex(parts) + 1;
2067
+ let dd = root;
2068
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2069
+ const p = parts[dd - 1];
2070
+ if (p && p !== "." && p !== ".." && p !== "**") {
2071
+ didSomething = true;
2072
+ parts.splice(dd - 1, 2);
2073
+ dd = Math.max(dd - 2, root);
2074
+ }
2075
+ }
2076
+ } while (didSomething);
2077
+ return parts.length === 0 ? [""] : parts;
2078
+ }
2079
+ // First phase: single-pattern processing
2080
+ // <pre> is 1 or more portions
2081
+ // <rest> is 1 or more portions
2082
+ // <p> is any portion other than ., .., '', or **
2083
+ // <e> is . or ''
2084
+ //
2085
+ // **/.. is *brutal* for filesystem walking performance, because
2086
+ // it effectively resets the recursive walk each time it occurs,
2087
+ // and ** cannot be reduced out by a .. pattern part like a regexp
2088
+ // or most strings (other than .., ., and '') can be.
2089
+ //
2090
+ // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
2091
+ // <pre>/<e>/<rest> -> <pre>/<rest>
2092
+ // <pre>/<p>/../<rest> -> <pre>/<rest>
2093
+ // **/**/<rest> -> **/<rest>
2094
+ //
2095
+ // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
2096
+ // this WOULD be allowed if ** did follow symlinks, or * didn't
2097
+ firstPhasePreProcess(globParts) {
2098
+ const { braceExpandMax = 1e5 } = this.options;
2099
+ let splitCells = 0;
2100
+ const maxSplitCells = 1e6;
2101
+ let didSomething = false;
2102
+ do {
2103
+ didSomething = false;
2104
+ for (let parts of globParts) {
2105
+ let gs = -1;
2106
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
2107
+ let gss = gs;
2108
+ while (parts[gss + 1] === "**") {
2109
+ gss++;
2110
+ }
2111
+ if (gss > gs) {
2112
+ parts.splice(gs + 1, gss - gs);
2113
+ }
2114
+ let next = parts[gs + 1];
2115
+ const p = parts[gs + 2];
2116
+ const p2 = parts[gs + 3];
2117
+ if (next !== "..")
2118
+ continue;
2119
+ if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
2120
+ continue;
2121
+ }
2122
+ const addedCells = parts.length - 1;
2123
+ if (globParts.length >= braceExpandMax || splitCells + addedCells > maxSplitCells) {
2124
+ throw new RangeError(`optimizationLevel 2: too many patterns from '**/..'`);
2125
+ }
2126
+ didSomething = true;
2127
+ parts.splice(gs, 1);
2128
+ const other = parts.slice(0);
2129
+ other[gs] = "**";
2130
+ splitCells += addedCells;
2131
+ globParts.push(other);
2132
+ gs--;
2133
+ }
2134
+ if (!this.preserveMultipleSlashes) {
2135
+ for (let i = 1; i < parts.length - 1; i++) {
2136
+ const p = parts[i];
2137
+ if (i === 1 && p === "" && parts[0] === "")
2138
+ continue;
2139
+ if (p === "." || p === "") {
2140
+ didSomething = true;
2141
+ parts.splice(i, 1);
2142
+ i--;
2143
+ }
2144
+ }
2145
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
2146
+ didSomething = true;
2147
+ parts.pop();
2148
+ }
2149
+ }
2150
+ const root = this.#rootIndex(parts) + 1;
2151
+ let dd = root;
2152
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2153
+ const p = parts[dd - 1];
2154
+ if (p && p !== "." && p !== ".." && p !== "**") {
2155
+ didSomething = true;
2156
+ const needDot = dd === 1 && parts[dd + 1] === "**";
2157
+ const splin = needDot ? ["."] : [];
2158
+ parts.splice(dd - 1, 2, ...splin);
2159
+ if (parts.length === 0)
2160
+ parts.push("");
2161
+ dd = Math.max(dd - 2, root);
2162
+ }
2163
+ }
2164
+ }
2165
+ } while (didSomething);
2166
+ return globParts;
2167
+ }
2168
+ // second phase: multi-pattern dedupes
2169
+ // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
2170
+ // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
2171
+ secondPhasePreProcess(globParts) {
2172
+ const keys = /* @__PURE__ */ new Set();
2173
+ const rows = globParts.filter((parts) => {
2174
+ const key = parts.join("/");
2175
+ if (keys.has(key))
2176
+ return false;
2177
+ keys.add(key);
2178
+ return true;
2179
+ });
2180
+ const stars = /* @__PURE__ */ new Map();
2181
+ for (const parts of rows) {
2182
+ const s = [];
2183
+ for (let i = 0; i < parts.length; i++) {
2184
+ if (parts[i] === "*")
2185
+ s.push(i);
2186
+ }
2187
+ if (s.length)
2188
+ stars.set(s.join(","), s);
2189
+ }
2190
+ if (!stars.size || rows.length * stars.size > 1e5)
2191
+ return rows;
2192
+ const { dot } = this.options;
2193
+ return rows.filter((parts) => {
2194
+ for (const s of stars.values()) {
2195
+ if (s[s.length - 1] >= parts.length)
2196
+ continue;
2197
+ const c = [...parts];
2198
+ let ok = true;
2199
+ let changed = false;
2200
+ for (const i of s) {
2201
+ const p = parts[i];
2202
+ if (p === "*")
2203
+ continue;
2204
+ if (!p || p === "**" || !dot && p.startsWith(".")) {
2205
+ ok = false;
2206
+ break;
2207
+ }
2208
+ c[i] = "*";
2209
+ changed = true;
2210
+ }
2211
+ if (ok && changed && keys.has(c.join("/")))
2212
+ return false;
2213
+ }
2214
+ return true;
2215
+ });
2216
+ }
2217
+ parseNegate() {
2218
+ if (this.nonegate)
2219
+ return;
2220
+ const pattern = this.pattern;
2221
+ let negate = false;
2222
+ let negateOffset = 0;
2223
+ for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
2224
+ negate = !negate;
2225
+ negateOffset++;
2226
+ }
2227
+ if (negateOffset)
2228
+ this.pattern = pattern.slice(negateOffset);
2229
+ this.negate = negate;
2230
+ }
2231
+ // Match the parts of a path against one row of the set. `resolved`
2232
+ // is the parts after level 2 resolves `.` and `..` in them, or the
2233
+ // same parts below level 2. Set partial to true to test if, for
2234
+ // example, "/a/b" matches the start of "/*/b/*/d". Partial means, if
2235
+ // you run out of file before you run out of pattern, then that's
2236
+ // fine, as long as all the parts match.
2237
+ #matchRow(file, resolved, pattern, partial) {
2238
+ let fileStartIndex = 0;
2239
+ let patternStartIndex = 0;
2240
+ const fh = this.isWindows ? uncHost(resolved) : -1;
2241
+ const ph = fh === -1 ? -1 : uncHost(pattern);
2242
+ if (ph !== -1) {
2243
+ const host = pattern[ph];
2244
+ const share = pattern[ph + 1];
2245
+ if (typeof host !== "string" || typeof share !== "string") {
2246
+ fileStartIndex = fh;
2247
+ patternStartIndex = ph;
2248
+ } else if (resolved[fh].toLowerCase() === host.toLowerCase() && resolved[fh + 1].toLowerCase() === share.toLowerCase()) {
2249
+ fileStartIndex = fh + 2;
2250
+ patternStartIndex = ph + 2;
2251
+ }
2252
+ } else if (this.isWindows) {
2253
+ const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
2254
+ const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
2255
+ const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
2256
+ const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
2257
+ const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
2258
+ const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
2259
+ if (typeof fdi === "number" && typeof pdi === "number") {
2260
+ const [fd, pd] = [
2261
+ file[fdi],
2262
+ pattern[pdi]
2263
+ ];
2264
+ if (fd.toLowerCase() === pd.toLowerCase()) {
2265
+ patternStartIndex = pdi + 1;
2266
+ fileStartIndex = fdi + 1;
2267
+ }
2268
+ }
2269
+ }
2270
+ file = resolved;
2271
+ if (pattern.includes(GLOBSTAR)) {
2272
+ return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
2273
+ }
2274
+ return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
2275
+ }
2276
+ #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
2277
+ const { head, body, tail, segments } = this.#getGlobstarParts(pattern, partial, patternIndex);
2278
+ if (head.length) {
2279
+ const headEnd = fileIndex + head.length;
2280
+ if (!this.#matchOne(file, head, partial, fileIndex, 0, headEnd)) {
2281
+ return false;
2282
+ }
2283
+ fileIndex += head.length;
2284
+ patternIndex += head.length;
2285
+ }
2286
+ let fileTailMatch = 0;
2287
+ if (tail.length) {
2288
+ if (tail.length + fileIndex > file.length)
2289
+ return false;
2290
+ let tailStart = file.length - tail.length;
2291
+ if (this.#matchOne(file, tail, partial, tailStart, 0)) {
2292
+ fileTailMatch = tail.length;
2293
+ } else {
2294
+ if (file[file.length - 1] !== "" || fileIndex + tail.length === file.length) {
2295
+ return false;
2296
+ }
2297
+ tailStart--;
2298
+ if (!this.#matchOne(file, tail, partial, tailStart, 0)) {
2299
+ return false;
2300
+ }
2301
+ fileTailMatch = tail.length + 1;
2302
+ }
2303
+ }
2304
+ if (!body.length) {
2305
+ let sawSome = !!fileTailMatch;
2306
+ for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
2307
+ const f = String(file[i]);
2308
+ sawSome = true;
2309
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
2310
+ return false;
2311
+ }
2312
+ }
2313
+ return partial || sawSome;
2314
+ }
2315
+ return !!this.#matchGlobStarBodySections(file, segments, file.length - fileTailMatch, fileIndex, 0, partial, 0, !!fileTailMatch, /* @__PURE__ */ new Set());
2316
+ }
2317
+ // Split the pattern into head, tail, and middle of ** delimited
2318
+ // parts. The tail has to be at the end, and the others just have to
2319
+ // be found in order from the head. These only depend on the pattern
2320
+ // row, so they are kept for the next path.
2321
+ #getGlobstarParts(pattern, partial, patternIndex) {
2322
+ let byStart = this.#globstarParts.get(pattern);
2323
+ if (!byStart) {
2324
+ byStart = [];
2325
+ this.#globstarParts.set(pattern, byStart);
2326
+ }
2327
+ const key = patternIndex * 2 + (partial ? 1 : 0);
2328
+ const found = byStart[key];
2329
+ if (found)
2330
+ return found;
2331
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
2332
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
2333
+ const head = pattern.slice(patternIndex, firstgs);
2334
+ const body = pattern.slice(firstgs + 1, partial ? void 0 : lastgs);
2335
+ const tail = partial ? [] : pattern.slice(lastgs + 1);
2336
+ const segments = [[[], 0]];
2337
+ let current = segments[0];
2338
+ let nonGsParts = 0;
2339
+ const nonGsPartsSums = [0];
2340
+ for (const b of body) {
2341
+ if (b === GLOBSTAR) {
2342
+ nonGsPartsSums.push(nonGsParts);
2343
+ current = [[], 0];
2344
+ segments.push(current);
2345
+ } else {
2346
+ current[0].push(b);
2347
+ nonGsParts++;
2348
+ }
2349
+ }
2350
+ segments.forEach((b, i) => {
2351
+ b[1] = nonGsParts - nonGsPartsSums[i];
2352
+ });
2353
+ const parts = { head, body, tail, segments };
2354
+ byStart[key] = parts;
2355
+ return parts;
2356
+ }
2357
+ // return false for "nope, not matching"
2358
+ // return null for "not matching, cannot keep trying"
2359
+ #matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex, bodyIndex, partial, globStarDepth, sawTail, tried) {
2360
+ const bs = bodySegments[bodyIndex];
2361
+ if (!bs) {
2362
+ if (partial) {
2363
+ return fileIndex >= fileLength || fileIndex === fileLength - 1 && file[fileIndex] === "";
2364
+ }
2365
+ for (let i = fileIndex; i < fileLength; i++) {
2366
+ sawTail = true;
2367
+ const f = file[i];
2368
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
2369
+ return false;
2370
+ }
2371
+ }
2372
+ return sawTail;
2373
+ }
2374
+ const [body, need] = bs;
2375
+ const after = partial ? fileLength : fileLength - need;
2376
+ while (fileIndex <= after) {
2377
+ const key = bodyIndex * (file.length + 1) + fileIndex;
2378
+ if (tried.has(key))
2379
+ return false;
2380
+ tried.add(key);
2381
+ const m = this.#matchOne(file, body, partial, fileIndex, 0, fileIndex + body.length);
2382
+ if (m && globStarDepth < this.maxGlobstarRecursion) {
2383
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail, tried);
2384
+ if (sub !== false) {
2385
+ return sub;
2386
+ }
2387
+ }
2388
+ if (fileIndex === after)
2389
+ break;
2390
+ const f = file[fileIndex];
2391
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
2392
+ return false;
2393
+ }
2394
+ fileIndex++;
2395
+ }
2396
+ return partial || null;
2397
+ }
2398
+ #matchOne(file, pattern, partial, fileIndex, patternIndex, fileEnd = file.length) {
2399
+ let fi;
2400
+ let pi;
2401
+ let pl;
2402
+ let fl;
2403
+ for (fi = fileIndex, pi = patternIndex, fl = Math.min(fileEnd, file.length), pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
2404
+ let p = pattern[pi];
2405
+ let f = file[fi];
2406
+ if (p === false || p === GLOBSTAR) {
2407
+ return false;
2408
+ }
2409
+ if (!portionMatch(p, f))
2410
+ return false;
2411
+ }
2412
+ if (fi === fl && pi === pl) {
2413
+ return true;
2414
+ } else if (fi === fl) {
2415
+ return partial;
2416
+ } else if (pi === pl) {
2417
+ return fi === fl - 1 && file[fi] === "";
2418
+ } else {
2419
+ throw new Error("wtf?");
2420
+ }
2421
+ }
2422
+ braceExpand() {
2423
+ return braceExpand(this.pattern, this.options);
2424
+ }
2425
+ // Expand braces, except numeric ranges such as {0..999} with at
2426
+ // least RANGE_MIN values. Each of those stays in its pattern as
2427
+ // `<mark>0..999<mark>`, for the Matcher to test. If a range might
2428
+ // be inside a [...] class, expand all of them instead.
2429
+ #expandBraces() {
2430
+ const { pattern } = this;
2431
+ if (this.options.nobrace)
2432
+ return this.braceExpand();
2433
+ let code = 57344;
2434
+ while (pattern.includes(String.fromCharCode(code))) {
2435
+ if (++code > 63743)
2436
+ return this.braceExpand();
2437
+ }
2438
+ const mark = String.fromCharCode(code);
2439
+ let found = false;
2440
+ const marked = pattern.replace(rangeRe, (m, lo, hi) => {
2441
+ const a = Number(lo);
2442
+ const b = Number(hi);
2443
+ if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b) || Math.abs(a - b) + 1 < RANGE_MIN) {
2444
+ return m;
2445
+ }
2446
+ found = true;
2447
+ return `${mark}${lo}..${hi}${mark}`;
2448
+ });
2449
+ if (!found)
2450
+ return this.braceExpand();
2451
+ const set = braceExpand(marked, this.options);
2452
+ for (const p of set) {
2453
+ for (const portion of p.split("/")) {
2454
+ const c = portion.indexOf("[");
2455
+ if (c !== -1 && c < portion.lastIndexOf(mark)) {
2456
+ return this.braceExpand();
2457
+ }
2458
+ }
2459
+ }
2460
+ this.#rangeMark = mark;
2461
+ return set;
2462
+ }
2463
+ parse(pattern) {
2464
+ assertValidPattern(pattern);
2465
+ const options = this.options;
2466
+ if (pattern === "**")
2467
+ return GLOBSTAR;
2468
+ if (pattern === "")
2469
+ return "";
2470
+ const { nocase, nocaseMagicOnly, noext = false, dot, normalize: normalize2 } = options;
2471
+ const rangeMark = this.#rangeMark;
2472
+ const lit2 = rangeMark && pattern.includes(rangeMark) ? void 0 : literal(pattern, noext);
2473
+ if (lit2 !== void 0 && !(nocase && !nocaseMagicOnly && pattern.toUpperCase() !== pattern.toLowerCase())) {
2474
+ return this.#norm(lit2);
2475
+ }
2476
+ if (this.#pending)
2477
+ return PENDING;
2478
+ let m = this.#matchers.get(pattern);
2479
+ if (!m) {
2480
+ m = new Matcher(pattern, {
2481
+ nocase,
2482
+ noext,
2483
+ dot,
2484
+ normalize: normalize2,
2485
+ ...rangeMark && { rangeMark }
2486
+ });
2487
+ this.#matchers.set(pattern, m);
2488
+ }
2489
+ return m;
2490
+ }
2491
+ #slashSplit(p) {
2492
+ if (this.preserveMultipleSlashes) {
2493
+ return p.split("/");
2494
+ } else if (this.isWindows && /^\/\/[^/]+/.test(p)) {
2495
+ return ["", ...p.split(/\/+/)];
2496
+ } else {
2497
+ return p.split(/\/+/);
2498
+ }
2499
+ }
2500
+ match(f, partial = this.partial) {
2501
+ if (this.comment) {
2502
+ return false;
2503
+ }
2504
+ if (this.empty) {
2505
+ return f === "";
2506
+ }
2507
+ if (f === "/" && partial) {
2508
+ return true;
2509
+ }
2510
+ const options = this.options;
2511
+ let split = this.#cachedSplit(f);
2512
+ if (!split) {
2513
+ if (!partial && !this.#form && (this.#endCheck || this.#literalCheck) && lastChecked !== f) {
2514
+ lastChecked = f;
2515
+ const can = this.#canMatch(f);
2516
+ if (can === "no")
2517
+ return options.flipNegate ? false : this.negate;
2518
+ if (can === "yes")
2519
+ return options.flipNegate ? true : !this.negate;
2520
+ }
2521
+ split = this.#split(f);
2522
+ }
2523
+ const ff = split.parts;
2524
+ const resolved = this.#level2 ? split.resolved ??= this.#levelTwoFileOptimize(ff) : ff;
2525
+ const set = this.set;
2526
+ let filename = ff[ff.length - 1];
2527
+ if (!filename) {
2528
+ for (let i = ff.length - 2; !filename && i >= 0; i--) {
2529
+ filename = ff[i];
2530
+ }
2531
+ }
2532
+ for (let r = 0; r < set.length; r++) {
2533
+ const pattern = set[r];
2534
+ const shape = partial ? void 0 : this.#shapes[r];
2535
+ const hit = shape === "base" ? portionMatch(pattern[0], filename) : shape ? this.#matchShape(resolved, pattern, shape) : options.matchBase && pattern.length === 1 ? this.#matchRow([filename], [filename], pattern, partial) : this.#matchRow(ff, resolved, pattern, partial);
2536
+ if (hit) {
2537
+ if (options.flipNegate) {
2538
+ return true;
2539
+ }
2540
+ return !this.negate;
2541
+ }
2542
+ }
2543
+ if (options.flipNegate) {
2544
+ return false;
2545
+ }
2546
+ return this.negate;
2547
+ }
2548
+ static defaults(def) {
2549
+ return minimatch.defaults(def).Minimatch;
2550
+ }
2551
+ };
2552
+ minimatch.Minimatch = Minimatch;
2553
+ minimatch.escape = escape;
2554
+ minimatch.unescape = unescape;
2555
+
2556
+ // src/permissions/path-rules.ts
2557
+ var PATH_RULE_TOOLS = {
2558
+ read: ["read", "grep", "glob", "ls"],
2559
+ edit: ["edit", "write"],
2560
+ write: ["write"],
2561
+ grep: ["grep"],
2562
+ glob: ["glob"],
2563
+ ls: ["ls"]
2564
+ };
2565
+ function isPathRuleTool(tool) {
2566
+ return Object.hasOwn(PATH_RULE_TOOLS, tool);
2567
+ }
2568
+ __name(isPathRuleTool, "isPathRuleTool");
2569
+ var PATH_ARGUMENT = "path";
2570
+ var WINDOWS = process.platform === "win32";
2571
+ function slashed(value) {
2572
+ return value.replaceAll("\\", "/");
2573
+ }
2574
+ __name(slashed, "slashed");
2575
+ function realOf(path2) {
2576
+ try {
2577
+ return slashed(realpathSync(path2));
2578
+ } catch {
2579
+ return slashed(path2);
2580
+ }
2581
+ }
2582
+ __name(realOf, "realOf");
2583
+ function physical(path2) {
2584
+ let current = path2;
2585
+ const tail = [];
2586
+ for (; ; ) {
2587
+ try {
2588
+ return slashed(join(realpathSync(current), ...tail));
2589
+ } catch {
2590
+ const parent = dirname(current);
2591
+ if (parent === current) return slashed(path2);
2592
+ tail.unshift(current.slice(parent.length).replace(/^[\\/]+/, ""));
2593
+ current = parent;
2594
+ }
2595
+ }
2596
+ }
2597
+ __name(physical, "physical");
2598
+ function expandHome(value, home) {
2599
+ if (value === "~") return home;
2600
+ if (value.startsWith("~/") || value.startsWith("~\\")) return join(home, value.slice(2));
2601
+ return value;
2602
+ }
2603
+ __name(expandHome, "expandHome");
2604
+ function globsOf(pattern, base) {
2605
+ const spell = /* @__PURE__ */ __name((cwd, home) => {
2606
+ const text = slashed(pattern.trim());
2607
+ if (text.startsWith("//")) return posix.normalize(text.slice(1));
2608
+ if (text === "~" || text.startsWith("~/")) {
2609
+ return posix.join(minimatch.escape(slashed(home)), text.slice(2));
2610
+ }
2611
+ if (text.startsWith("/") && !/^\/[A-Za-z]:/.test(text)) {
2612
+ return posix.join(minimatch.escape(slashed(cwd)), text.slice(1));
2613
+ }
2614
+ if (/^[A-Za-z]:\//.test(text)) return posix.normalize(text);
2615
+ return posix.join(minimatch.escape(slashed(cwd)), text);
2616
+ }, "spell");
2617
+ const spellings = /* @__PURE__ */ new Set([spell(base.cwd, base.home)]);
2618
+ spellings.add(spell(realOf(base.cwd), realOf(base.home)));
2619
+ return [...spellings].map((glob) => glob.length > 1 ? glob.replace(/\/+$/, "") : glob);
2620
+ }
2621
+ __name(globsOf, "globsOf");
2622
+ function candidatesOf(value, base) {
2623
+ const logical = slashed(resolve(base.cwd, expandHome(value.trim(), base.home)));
2624
+ const onDisk = physical(logical);
2625
+ return onDisk === logical ? [logical] : [logical, onDisk];
2626
+ }
2627
+ __name(candidatesOf, "candidatesOf");
2628
+ function covers(glob, path2) {
2629
+ const options = {
2630
+ dot: true,
2631
+ nocase: WINDOWS,
2632
+ nonegate: true,
2633
+ nocomment: true
2634
+ };
2635
+ let current = path2;
2636
+ for (; ; ) {
2637
+ if (minimatch(current, glob, options) || glob.endsWith("/**") && minimatch(current, glob.slice(0, -3), options))
2638
+ return true;
2639
+ const parent = posix.dirname(current);
2640
+ if (parent === current) return false;
2641
+ current = parent;
2642
+ }
2643
+ }
2644
+ __name(covers, "covers");
2645
+ function pathRule(tool, pattern, effect, context = {}) {
2646
+ const names = [...PATH_RULE_TOOLS[tool] ?? [tool]];
2647
+ const decision = effect === "ask" ? "review" : effect;
2648
+ const base = {
2649
+ cwd: resolve(context.cwd ?? process.cwd()),
2650
+ home: context.home ?? homedir()
2651
+ };
2652
+ const ruleBase = { ...base, cwd: context.ruleRoot ?? base.cwd };
2653
+ const verdict = /* @__PURE__ */ __name((toolName, input) => {
2654
+ if (!names.includes(toolName)) return void 0;
2655
+ if (typeof input !== "object" || input === null) return void 0;
2656
+ const written = input[PATH_ARGUMENT];
2657
+ const value = (written === void 0 || written === "") && ["grep", "glob", "ls"].includes(toolName) ? "." : written;
2658
+ if (typeof value !== "string" || value === "") return void 0;
2659
+ const globs = globsOf(pattern, ruleBase);
2660
+ const candidates = candidatesOf(value, base);
2661
+ const named = /* @__PURE__ */ __name((path2) => globs.some((glob) => covers(glob, path2)), "named");
2662
+ const hit = decision === "allow" ? candidates.every(named) : candidates.some(named);
2663
+ return hit ? candidates[0] : void 0;
2664
+ }, "verdict");
2665
+ const verb = decision === "deny" ? "denied" : decision === "review" ? "sent for review" : "allowed";
2666
+ return {
2667
+ type: "predicate",
2668
+ description: `${verb} by a path rule for ${names.join(", ")}: ${pattern}`,
2669
+ decide: /* @__PURE__ */ __name((call) => verdict(call.toolName, call.toolInput) === void 0 ? null : decision, "decide"),
2670
+ describe: /* @__PURE__ */ __name((call) => {
2671
+ const path2 = verdict(call.toolName, call.toolInput);
2672
+ return path2 === void 0 ? `${verb} by a path rule: ${pattern}` : `${verb} because ${path2} matches the path rule ${pattern} (this rule applies to ${names.join(", ")})`;
2673
+ }, "describe")
2674
+ };
2675
+ }
2676
+ __name(pathRule, "pathRule");
2677
+ function descendantPathBoundary(tool, pattern, effect, context = {}) {
2678
+ const searchTools = tool === "read" && effect === "deny" ? ["ls"] : ["grep", "glob", "ls"];
2679
+ const names = (PATH_RULE_TOOLS[tool] ?? []).filter((name) => searchTools.includes(name));
2680
+ if (names.length === 0) return void 0;
2681
+ const base = {
2682
+ cwd: resolve(context.cwd ?? process.cwd()),
2683
+ home: context.home ?? homedir()
2684
+ };
2685
+ const ruleBase = { ...base, cwd: context.ruleRoot ?? base.cwd };
2686
+ const decision = effect === "ask" ? "review" : "deny";
2687
+ return {
2688
+ type: "predicate",
2689
+ description: `search may expose a descendant restricted by ${tool}(${pattern}); narrow the search path`,
2690
+ decide: /* @__PURE__ */ __name((call) => {
2691
+ if (!names.includes(call.toolName)) return null;
2692
+ if (typeof call.toolInput !== "object" || call.toolInput === null) return null;
2693
+ const written = call.toolInput[PATH_ARGUMENT];
2694
+ const value = written === void 0 || written === "" ? "." : written;
2695
+ if (typeof value !== "string") return null;
2696
+ const globs = globsOf(pattern, ruleBase);
2697
+ const candidates = candidatesOf(value, base);
2698
+ const exposes = candidates.some(
2699
+ (candidate) => globs.some(
2700
+ (glob) => !covers(glob, candidate) && minimatch(candidate, glob, {
2701
+ dot: true,
2702
+ nocase: WINDOWS,
2703
+ nonegate: true,
2704
+ nocomment: true,
2705
+ partial: true
2706
+ })
2707
+ )
2708
+ );
2709
+ return exposes ? decision : null;
2710
+ }, "decide")
2711
+ };
2712
+ }
2713
+ __name(descendantPathBoundary, "descendantPathBoundary");
2714
+
2715
+ // src/permissions/rules.ts
2716
+ var EFFECTS = /* @__PURE__ */ new Set(["allow", "ask", "deny"]);
2717
+ function isPermissionEffect(value) {
2718
+ return typeof value === "string" && EFFECTS.has(value);
2719
+ }
2720
+ __name(isPermissionEffect, "isPermissionEffect");
2721
+ var permissionRuleRoots = /* @__PURE__ */ new WeakMap();
2722
+ var permissionRuleSources = /* @__PURE__ */ new WeakMap();
2723
+ function permissionTableSource(table) {
2724
+ return permissionRuleSources.get(table);
2725
+ }
2726
+ __name(permissionTableSource, "permissionTableSource");
2727
+ function bindPermissionTableToSource(table, settingsPath, editableLocal = false) {
2728
+ const bound = { ...table };
2729
+ permissionRuleRoots.set(bound, dirname2(resolve2(settingsPath)));
2730
+ if (editableLocal) permissionRuleSources.set(bound, resolve2(settingsPath));
2731
+ return bound;
2732
+ }
2733
+ __name(bindPermissionTableToSource, "bindPermissionTableToSource");
2734
+ function legacyMcpPermissionNames(config) {
2735
+ return Object.keys(config ?? {}).filter((name) => /^mcp_(?!_)[^_]+_.+/.test(name));
2736
+ }
2737
+ __name(legacyMcpPermissionNames, "legacyMcpPermissionNames");
2738
+ var warnedLegacyMcpNames = /* @__PURE__ */ new Set();
2739
+ function warnLegacyMcpPermissionNames(config, log = cliLogger()) {
2740
+ for (const name of legacyMcpPermissionNames(config)) {
2741
+ if (warnedLegacyMcpNames.has(name)) continue;
2742
+ warnedLegacyMcpNames.add(name);
2743
+ log.warn(
2744
+ "Former MCP permission name does not match the current mcp__<server>__<tool> naming scheme",
2745
+ {
2746
+ "namzu.permission.tool_name": name
2747
+ }
2748
+ );
2749
+ }
2750
+ }
2751
+ __name(warnLegacyMcpPermissionNames, "warnLegacyMcpPermissionNames");
2752
+ function patternToRegExpSource(pattern) {
2753
+ return permissionPatternToRegExpSource(pattern);
2754
+ }
2755
+ __name(patternToRegExpSource, "patternToRegExpSource");
2756
+ function toolScopedPattern(tool, pattern, decision = "deny") {
2757
+ const toolPart = escapeRegExp(tool);
2758
+ const argPart = patternToRegExpSource(pattern).slice(1, -1);
2759
+ const anchorToValue = decision === "allow" && pattern.replaceAll("*", "") !== "";
2760
+ return anchorToValue ? `^${toolPart} .*"${argPart}.*$` : `^${toolPart} .*${argPart}.*$`;
2761
+ }
2762
+ __name(toolScopedPattern, "toolScopedPattern");
2763
+ function commandRule(tool, argument, pattern, decision) {
2764
+ if (pattern.replaceAll("*", "") === "") {
2765
+ return decision === "allow" ? { type: "allow_by_name", toolNames: [tool] } : { type: "deny_by_name", toolNames: [tool] };
2766
+ }
2767
+ const anchored = patternToRegExpSource(pattern);
2768
+ return {
2769
+ type: "argument_pattern",
2770
+ toolNames: [tool],
2771
+ argument,
2772
+ pattern: decision === "allow" ? anchored : anchored.slice(1, -1),
2773
+ decision
2774
+ };
2775
+ }
2776
+ __name(commandRule, "commandRule");
2777
+ function escapeRegExp(value) {
2778
+ return value.replace(/[.*+^${}()|[\]\\?]/g, "\\$&");
2779
+ }
2780
+ __name(escapeRegExp, "escapeRegExp");
2781
+ function bySpecificity(a, b) {
2782
+ if (a === "*" && b !== "*") return 1;
2783
+ if (b === "*" && a !== "*") return -1;
2784
+ const literal2 = /* @__PURE__ */ __name((p) => {
2785
+ const star = p.search(/[*?]/);
2786
+ return star === -1 ? p.length : star;
2787
+ }, "literal");
2788
+ const diff = literal2(b) - literal2(a);
2789
+ if (diff !== 0) return diff;
2790
+ return a < b ? -1 : a > b ? 1 : 0;
2791
+ }
2792
+ __name(bySpecificity, "bySpecificity");
2793
+ function compilePermissions(config, checks, context) {
2794
+ const rules = [];
2795
+ const descendantDenials = [];
2796
+ const descendantReviews = [];
2797
+ const sourceDenials = [];
2798
+ const sourceReviews = [];
2799
+ const sourceAllowances = [];
2800
+ const diagnostics = [];
2801
+ if (!config) return { rules, diagnostics: verifyPermissionChecks(rules, checks) };
2802
+ const commandArguments = builtinCommandArguments();
2803
+ const ruleRoot = permissionRuleRoots.get(config);
2804
+ const pathContext = ruleRoot === void 0 ? context : { ...context, ruleRoot };
2805
+ for (const [tool, permission] of Object.entries(config)) {
2806
+ if (isPermissionSettingKey(tool)) continue;
2807
+ if (tool === "sources") {
2808
+ if (typeof permission !== "object" || permission === null || Array.isArray(permission)) {
2809
+ diagnostics.push({ tool, message: "expected a table of source id globs and effects" });
2810
+ continue;
2811
+ }
2812
+ for (const source of Object.keys(permission).sort(bySpecificity)) {
2813
+ const effect = permission[source];
2814
+ if (!source) {
2815
+ diagnostics.push({ tool, pattern: source, message: "source id glob must not be empty" });
2816
+ continue;
2817
+ }
2818
+ if (!isPermissionEffect(effect)) {
2819
+ diagnostics.push({
2820
+ tool,
2821
+ pattern: source,
2822
+ message: `expected "allow", "ask" or "deny"; got ${JSON.stringify(effect)}`
2823
+ });
2824
+ continue;
2825
+ }
2826
+ const rule = {
2827
+ type: "by_source",
2828
+ sources: [source],
2829
+ decision: effect === "ask" ? "review" : effect
2830
+ };
2831
+ if (effect === "allow") sourceAllowances.push(rule);
2832
+ else if (effect === "deny") sourceDenials.push(rule);
2833
+ else sourceReviews.push(rule);
2834
+ }
2835
+ continue;
2836
+ }
2837
+ if (isPermissionEffect(permission)) {
2838
+ if (permission === "allow") rules.push({ type: "allow_by_name", toolNames: [tool] });
2839
+ if (permission === "deny") rules.push({ type: "deny_by_name", toolNames: [tool] });
2840
+ if (permission === "ask") {
2841
+ rules.push({
2842
+ type: "custom_pattern",
2843
+ pattern: `^${escapeRegExp(tool)}$`,
2844
+ target: "name",
2845
+ decision: "review"
2846
+ });
2847
+ }
2848
+ continue;
2849
+ }
2850
+ if (typeof permission !== "object" || permission === null) {
2851
+ diagnostics.push({
2852
+ tool,
2853
+ message: `expected "allow", "ask", "deny", or a table of patterns; got ${typeof permission}`
2854
+ });
2855
+ continue;
2856
+ }
2857
+ for (const pattern of Object.keys(permission).sort(bySpecificity)) {
2858
+ const effect = permission[pattern];
2859
+ if (!isPermissionEffect(effect)) {
2860
+ diagnostics.push({
2861
+ tool,
2862
+ pattern,
2863
+ message: `expected "allow", "ask" or "deny"; got ${JSON.stringify(effect)}`
2864
+ });
2865
+ continue;
2866
+ }
2867
+ try {
2868
+ new RegExp(patternToRegExpSource(pattern));
2869
+ } catch (err) {
2870
+ diagnostics.push({
2871
+ tool,
2872
+ pattern,
2873
+ message: `pattern is not usable: ${err instanceof Error ? err.message : String(err)}`
2874
+ });
2875
+ continue;
2876
+ }
2877
+ if (isPathRuleTool(tool) && pattern.replaceAll("*", "") !== "") {
2878
+ rules.push(pathRule(tool, pattern, effect, pathContext));
2879
+ if (effect !== "allow") {
2880
+ const boundary = descendantPathBoundary(tool, pattern, effect, pathContext);
2881
+ if (boundary !== void 0) {
2882
+ if (effect === "deny") descendantDenials.push(boundary);
2883
+ else descendantReviews.push(boundary);
2884
+ }
2885
+ }
2886
+ continue;
2887
+ }
2888
+ if (effect === "ask") {
2889
+ rules.push({
2890
+ type: "custom_pattern",
2891
+ pattern: toolScopedPattern(tool, pattern),
2892
+ target: "both",
2893
+ decision: "review"
2894
+ });
2895
+ continue;
2896
+ }
2897
+ const argument = commandArguments.get(tool);
2898
+ if (argument === void 0) {
2899
+ rules.push({
2900
+ type: "custom_pattern",
2901
+ pattern: toolScopedPattern(tool, pattern, effect),
2902
+ target: "both",
2903
+ decision: effect
2904
+ });
2905
+ continue;
2906
+ }
2907
+ rules.push(commandRule(tool, argument, pattern, effect));
2908
+ }
2909
+ }
2910
+ const toolDenialBeforeSourceReview = [];
2911
+ if ((sourceReviews.length > 0 || descendantReviews.length > 0) && rules.length > 0) {
2912
+ const toolGate = new AuthorizationGate(
2913
+ {
2914
+ enabled: true,
2915
+ rules: [...rules],
2916
+ allowReadOnlyTools: false,
2917
+ denyDangerousPatterns: false,
2918
+ logDecisions: false
2919
+ },
2920
+ NOOP_LOGGER
2921
+ );
2922
+ const toolDecision = /* @__PURE__ */ __name((call) => toolGate.evaluate(call), "toolDecision");
2923
+ toolDenialBeforeSourceReview.push({
2924
+ type: "predicate",
2925
+ description: "denied by a tool-specific permission rule",
2926
+ decide: /* @__PURE__ */ __name((call) => toolDecision(call).decision === "deny" ? "deny" : null, "decide"),
2927
+ describe: /* @__PURE__ */ __name((call) => toolDecision(call).reason, "describe")
2928
+ });
2929
+ }
2930
+ const orderedRules = [
2931
+ ...descendantDenials,
2932
+ ...sourceDenials,
2933
+ ...toolDenialBeforeSourceReview,
2934
+ ...descendantReviews,
2935
+ ...sourceReviews,
2936
+ ...rules,
2937
+ ...sourceAllowances
2938
+ ];
2939
+ diagnostics.push(...verifyPermissionChecks(orderedRules, checks));
2940
+ return { rules: orderedRules, diagnostics };
2941
+ }
2942
+ __name(compilePermissions, "compilePermissions");
2943
+ var RESTRICTION = { allow: 1, ask: 2, deny: 3 };
2944
+ function stricter(a, b) {
2945
+ return RESTRICTION[b] > RESTRICTION[a] ? b : a;
2946
+ }
2947
+ __name(stricter, "stricter");
2948
+ function patternTable(permission) {
2949
+ return isPermissionEffect(permission) ? { "*": permission } : { ...permission };
2950
+ }
2951
+ __name(patternTable, "patternTable");
2952
+ function mergeToolPermission(lower, higher) {
2953
+ if (lower === void 0) return higher;
2954
+ const usable = /* @__PURE__ */ __name((value) => isPermissionEffect(value) || typeof value === "object" && value !== null, "usable");
2955
+ if (!usable(lower)) return higher;
2956
+ if (!usable(higher)) return lower;
2957
+ if (isPermissionEffect(lower) && isPermissionEffect(higher)) return stricter(lower, higher);
2958
+ const merged = patternTable(lower);
2959
+ for (const [pattern, effect] of Object.entries(patternTable(higher))) {
2960
+ const existing = merged[pattern];
2961
+ merged[pattern] = existing !== void 0 && isPermissionEffect(existing) && isPermissionEffect(effect) ? stricter(existing, effect) : effect;
2962
+ }
2963
+ return merged;
2964
+ }
2965
+ __name(mergeToolPermission, "mergeToolPermission");
2966
+ function mergePermissionTables(tables) {
2967
+ const out = {};
2968
+ for (const table of tables) {
2969
+ if (!table) continue;
2970
+ for (const [tool, permission] of Object.entries(table)) {
2971
+ out[tool] = mergeToolPermission(out[tool], permission);
2972
+ }
2973
+ }
2974
+ return out;
2975
+ }
2976
+ __name(mergePermissionTables, "mergePermissionTables");
2977
+ function permissionLayersOf(config) {
2978
+ if (config.permissionLayers !== void 0) return config.permissionLayers;
2979
+ return config.permissions ? [config.permissions] : [];
2980
+ }
2981
+ __name(permissionLayersOf, "permissionLayersOf");
2982
+ function compilePermissionLayers(layers, checks, context) {
2983
+ const present = layers.filter((layer) => layer !== void 0);
2984
+ if (present.length <= 1) return compilePermissions(present[0], checks, context);
2985
+ const diagnostics = [];
2986
+ const withRules = [];
2987
+ for (const layer of present) {
2988
+ const compiled = compilePermissions(layer, void 0, context);
2989
+ diagnostics.push(...compiled.diagnostics);
2990
+ if (compiled.rules.length > 0) withRules.push(compiled.rules);
2991
+ }
2992
+ if (withRules.length <= 1) {
2993
+ const rules2 = withRules[0] ?? [];
2994
+ diagnostics.push(...verifyPermissionChecks(rules2, checks));
2995
+ return { rules: rules2, diagnostics };
2996
+ }
2997
+ const gates = withRules.map(
2998
+ (rules2) => new AuthorizationGate(
2999
+ {
3000
+ enabled: true,
3001
+ rules: [...rules2],
3002
+ allowReadOnlyTools: false,
3003
+ denyDangerousPatterns: false,
3004
+ logDecisions: false
3005
+ },
3006
+ NOOP_LOGGER
3007
+ )
3008
+ );
3009
+ const verdicts = /* @__PURE__ */ __name((call, want) => gates.map((gate) => gate.evaluate(call)).find((result) => result.matchedRule !== null && result.decision === want), "verdicts");
3010
+ const layered = /* @__PURE__ */ __name((want, description) => ({
3011
+ type: "predicate",
3012
+ description,
3013
+ decide: /* @__PURE__ */ __name((call) => verdicts(call, want) ? want : null, "decide"),
3014
+ describe: /* @__PURE__ */ __name((call) => verdicts(call, want)?.reason ?? description, "describe")
3015
+ }), "layered");
3016
+ const rules = [
3017
+ layered("deny", "denied by a permission rule in one of the config layers"),
3018
+ layered("review", "asked about by a permission rule in one of the config layers"),
3019
+ layered("allow", "allowed by a permission rule in the config layers")
3020
+ ];
3021
+ diagnostics.push(...verifyPermissionChecks(rules, checks));
3022
+ return { rules, diagnostics };
3023
+ }
3024
+ __name(compilePermissionLayers, "compilePermissionLayers");
3025
+
3026
+ export {
3027
+ permissionSettingsProblem,
3028
+ splitPermissionsTable,
3029
+ mergePermissionSettings,
3030
+ isPermissionEffect,
3031
+ permissionTableSource,
3032
+ bindPermissionTableToSource,
3033
+ warnLegacyMcpPermissionNames,
3034
+ compilePermissions,
3035
+ mergePermissionTables,
3036
+ permissionLayersOf,
3037
+ compilePermissionLayers
3038
+ };
3039
+ //# sourceMappingURL=chunk-JBBB5EG2.js.map