shadow-claw 1.54.0 → 1.55.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 (286) hide show
  1. package/.well-known/mcp/server-card.json +1 -1
  2. package/.well-known/mcp.json +1 -1
  3. package/README.md +1 -1
  4. package/dist/cli/build/build.js +1 -1
  5. package/dist/cli/{chunk-DO2t9bUI.js → chunk--IuVyWfT.js} +24 -23
  6. package/dist/cli/{chunk-2ZYd9gYC.js → chunk--JpdI-Ht.js} +1 -1
  7. package/dist/cli/{chunk-m4Ineemy.js → chunk-4O8yrQuN.js} +1 -1
  8. package/dist/cli/{chunk-BiH9IXnQ.js → chunk-7S9Ywlfy.js} +1 -1
  9. package/dist/cli/{chunk-BmMOdYvk.js → chunk-B0SqqDSK.js} +1 -1
  10. package/dist/cli/chunk-BNaWaEm-.js +1 -0
  11. package/dist/cli/chunk-BXCsxO9e.js +1 -0
  12. package/dist/cli/chunk-Bq37qDoZ.js +18 -0
  13. package/dist/cli/{chunk-C1htf-nO.js → chunk-BrEeCKIo.js} +2 -2
  14. package/dist/cli/{chunk-BI1SOTM1.js → chunk-Bu3ylrhT.js} +8 -8
  15. package/dist/cli/{chunk-3smiGQoQ.js → chunk-C1v_s0Kb.js} +1 -1
  16. package/dist/cli/{chunk-DGeysxz3.js → chunk-C44G533y.js} +1 -1
  17. package/dist/cli/{chunk-9KiBalKu.js → chunk-C7hJLmsL.js} +1 -1
  18. package/dist/cli/{chunk-BFv9XSNd.js → chunk-CAaQWd6t.js} +1 -1
  19. package/dist/cli/chunk-CIkgn5Fh.js +1 -0
  20. package/dist/cli/chunk-CWEIN2kc.js +1 -0
  21. package/dist/cli/{chunk-BDeDZ-0L.js → chunk-CYg1lO1a.js} +1 -1
  22. package/dist/cli/{chunk-DXLmEQ3i.js → chunk-Ce09lwXT.js} +1 -1
  23. package/dist/cli/{chunk-XsfHeN4m.js → chunk-CpdqRSO-.js} +1 -1
  24. package/dist/cli/chunk-DB4x5L-B.js +1 -0
  25. package/dist/cli/{chunk-DaNyMqrk.js → chunk-DBvObsBQ.js} +1 -1
  26. package/dist/cli/chunk-DGPpt7Ka.js +1 -0
  27. package/dist/cli/chunk-DGagHluH.js +1 -0
  28. package/dist/cli/chunk-DUIs23D9.js +1 -0
  29. package/dist/cli/{chunk-CyvfQV16.js → chunk-DaurYOqg.js} +1 -1
  30. package/dist/cli/{chunk-DSFrcSyA.js → chunk-DfwRL0Ue.js} +1 -1
  31. package/dist/cli/{chunk-M2tZrzY5.js → chunk-DudYQk0p.js} +1 -1
  32. package/dist/cli/chunk-DvKo50Tp.js +2 -0
  33. package/dist/cli/{chunk-H_Mw5ypp.js → chunk-Dvrqte5Q.js} +2 -2
  34. package/dist/cli/{chunk-BtNO-m9T.js → chunk-DzhSExU0.js} +1 -1
  35. package/dist/cli/{chunk-IOMO88kZ.js → chunk-ENKlt3i9.js} +1 -1
  36. package/dist/cli/{chunk-Bspgzwsm.js → chunk-FWRwAX75.js} +8 -8
  37. package/dist/cli/chunk-Lf-Z-h48.js +32 -0
  38. package/dist/cli/{chunk-BucXnZ4Z.js → chunk-VRfkSLrD.js} +1 -1
  39. package/dist/cli/chunk-uaTxD024.js +1 -0
  40. package/dist/cli/cli.js +1 -1
  41. package/dist/cli/prerender/dsd-shell/prerender-dsd-shell.js +1 -1
  42. package/dist/headless-agent.js +2 -2
  43. package/dist/lib/components/index.js +25 -25
  44. package/dist/lib/components/settings/shadow-claw-accounts.js +1 -1
  45. package/dist/lib/components/settings/shadow-claw-channel-config.js +1 -1
  46. package/dist/lib/components/settings/shadow-claw-control-plane.js +1 -1
  47. package/dist/lib/components/settings/shadow-claw-git.js +1 -1
  48. package/dist/lib/components/settings/shadow-claw-integrations.js +1 -1
  49. package/dist/lib/components/settings/shadow-claw-llm.js +1 -1
  50. package/dist/lib/components/settings/shadow-claw-mcp-remote.js +1 -1
  51. package/dist/lib/components/settings/shadow-claw-networking.js +1 -1
  52. package/dist/lib/components/settings/shadow-claw-notifications.js +1 -1
  53. package/dist/lib/components/settings/shadow-claw-peerjs.js +1 -1
  54. package/dist/lib/components/settings/shadow-claw-storage.js +1 -1
  55. package/dist/lib/components/settings/shadow-claw-task-server.js +1 -1
  56. package/dist/lib/components/settings/shadow-claw-webvm.js +1 -1
  57. package/dist/lib/components/shadow-claw/utils/get-route.d.ts +3 -0
  58. package/dist/lib/components/shadow-claw/utils/sync-slotted-sidebar-active-links.d.ts +1 -1
  59. package/dist/lib/components/shadow-claw-accounts.js +1 -1
  60. package/dist/lib/components/shadow-claw-channel-config.js +1 -1
  61. package/dist/lib/components/shadow-claw-channels.js +1 -1
  62. package/dist/lib/components/shadow-claw-chat.js +1 -1
  63. package/dist/lib/components/shadow-claw-control-plane.js +1 -1
  64. package/dist/lib/components/shadow-claw-conversations.js +1 -1
  65. package/dist/lib/components/shadow-claw-file-viewer.js +1 -1
  66. package/dist/lib/components/shadow-claw-files.js +1 -1
  67. package/dist/lib/components/shadow-claw-git.js +1 -1
  68. package/dist/lib/components/shadow-claw-integrations.js +1 -1
  69. package/dist/lib/components/shadow-claw-llm.js +1 -1
  70. package/dist/lib/components/shadow-claw-mcp-remote.js +1 -1
  71. package/dist/lib/components/shadow-claw-networking.js +1 -1
  72. package/dist/lib/components/shadow-claw-notifications.js +1 -1
  73. package/dist/lib/components/shadow-claw-page-header.js +1 -1
  74. package/dist/lib/components/shadow-claw-pages.js +1 -1
  75. package/dist/lib/components/shadow-claw-peerjs.js +1 -1
  76. package/dist/lib/components/shadow-claw-settings.js +1 -1
  77. package/dist/lib/components/shadow-claw-storage.js +1 -1
  78. package/dist/lib/components/shadow-claw-task-server.js +1 -1
  79. package/dist/lib/components/shadow-claw-tasks.js +1 -1
  80. package/dist/lib/components/shadow-claw-terminal.js +1 -1
  81. package/dist/lib/components/shadow-claw-tools.js +1 -1
  82. package/dist/lib/components/shadow-claw-webvm.js +1 -1
  83. package/dist/lib/components/shadow-claw.js +1 -1
  84. package/dist/lib/{configure-peer-js-D5jDCtLx.js → configure-peer-js-C9554Slv.js} +2 -2
  85. package/dist/lib/{configure-peer-js-D5jDCtLx.js.map → configure-peer-js-C9554Slv.js.map} +1 -1
  86. package/dist/lib/{file-viewer-B4CL4e0i.js → file-viewer-DBc5dxNy.js} +2 -2
  87. package/dist/lib/{file-viewer-B4CL4e0i.js.map → file-viewer-DBc5dxNy.js.map} +1 -1
  88. package/dist/lib/index.js +28 -27
  89. package/dist/lib/{init-control-plane-l2uFnhGV.js → init-control-plane-D-41Fm5q.js} +12 -12
  90. package/dist/lib/{init-control-plane-l2uFnhGV.js.map → init-control-plane-D-41Fm5q.js.map} +1 -1
  91. package/dist/lib/{markdown-0_p_zfxL.js → markdown-KnDWzWJJ.js} +2 -2
  92. package/dist/lib/{markdown-0_p_zfxL.js.map → markdown-KnDWzWJJ.js.map} +1 -1
  93. package/dist/lib/{orchestrator-D6wm8Sec.js → orchestrator-BEZcqgR5.js} +9 -9
  94. package/dist/lib/{orchestrator-D6wm8Sec.js.map → orchestrator-BEZcqgR5.js.map} +1 -1
  95. package/dist/lib/{orchestrator-Dh-hnIpK.js → orchestrator-Cda13e5U.js} +4 -4
  96. package/dist/lib/{orchestrator-Dh-hnIpK.js.map → orchestrator-Cda13e5U.js.map} +1 -1
  97. package/dist/lib/{peerjs-BWZnsD0B.js → peerjs-DYkUTcee.js} +5 -5
  98. package/dist/lib/{peerjs-BWZnsD0B.js.map → peerjs-DYkUTcee.js.map} +1 -1
  99. package/dist/lib/{push-client-MybDfOdi.js → push-client-CQtCFDaD.js} +3 -3
  100. package/dist/lib/{push-client-MybDfOdi.js.map → push-client-CQtCFDaD.js.map} +1 -1
  101. package/dist/lib/security/custom-element-security.d.ts +8 -4
  102. package/dist/lib/{shadow-claw-PdOpgTxH.js → shadow-claw-DYe9u6Tp.js} +142 -33
  103. package/dist/lib/shadow-claw-DYe9u6Tp.js.map +1 -0
  104. package/dist/lib/{shadow-claw-accounts-3bR76EOb.js → shadow-claw-accounts-D2URoHys.js} +2 -2
  105. package/dist/lib/{shadow-claw-accounts-3bR76EOb.js.map → shadow-claw-accounts-D2URoHys.js.map} +1 -1
  106. package/dist/lib/{shadow-claw-channel-config-ChdZ1iB8.js → shadow-claw-channel-config-buXoz2xv.js} +3 -3
  107. package/dist/lib/{shadow-claw-channel-config-ChdZ1iB8.js.map → shadow-claw-channel-config-buXoz2xv.js.map} +1 -1
  108. package/dist/lib/{shadow-claw-channels-CK9sc7h_.js → shadow-claw-channels-5yVJ1gLk.js} +3 -3
  109. package/dist/lib/{shadow-claw-channels-CK9sc7h_.js.map → shadow-claw-channels-5yVJ1gLk.js.map} +1 -1
  110. package/dist/lib/{shadow-claw-chat-B6uuZnJ7.js → shadow-claw-chat-CVc-7ycM.js} +7 -7
  111. package/dist/lib/{shadow-claw-chat-B6uuZnJ7.js.map → shadow-claw-chat-CVc-7ycM.js.map} +1 -1
  112. package/dist/lib/{shadow-claw-control-plane-BpRcl312.js → shadow-claw-control-plane-B5vsF91B.js} +6 -6
  113. package/dist/lib/{shadow-claw-control-plane-BpRcl312.js.map → shadow-claw-control-plane-B5vsF91B.js.map} +1 -1
  114. package/dist/lib/{shadow-claw-conversations-Dc_Xk2mB.js → shadow-claw-conversations-PGK5zqn3.js} +54 -12
  115. package/dist/lib/{shadow-claw-conversations-Dc_Xk2mB.js.map → shadow-claw-conversations-PGK5zqn3.js.map} +1 -1
  116. package/dist/lib/{shadow-claw-file-viewer-C4x1PtB2.js → shadow-claw-file-viewer-DSqn0hgx.js} +6 -6
  117. package/dist/lib/{shadow-claw-file-viewer-C4x1PtB2.js.map → shadow-claw-file-viewer-DSqn0hgx.js.map} +1 -1
  118. package/dist/lib/{shadow-claw-files-DhnHbXKf.js → shadow-claw-files-vOa9ZWbr.js} +6 -6
  119. package/dist/lib/{shadow-claw-files-DhnHbXKf.js.map → shadow-claw-files-vOa9ZWbr.js.map} +1 -1
  120. package/dist/lib/{shadow-claw-git-BeQ1ElUd.js → shadow-claw-git-D54Z85Bj.js} +4 -4
  121. package/dist/lib/{shadow-claw-git-BeQ1ElUd.js.map → shadow-claw-git-D54Z85Bj.js.map} +1 -1
  122. package/dist/lib/{shadow-claw-integrations-Bbdolk3w.js → shadow-claw-integrations-BTubMH9d.js} +2 -2
  123. package/dist/lib/{shadow-claw-integrations-Bbdolk3w.js.map → shadow-claw-integrations-BTubMH9d.js.map} +1 -1
  124. package/dist/lib/{shadow-claw-llm-DPda4L3C.js → shadow-claw-llm-8koGTNYs.js} +3 -3
  125. package/dist/lib/{shadow-claw-llm-DPda4L3C.js.map → shadow-claw-llm-8koGTNYs.js.map} +1 -1
  126. package/dist/lib/{shadow-claw-mcp-remote-Dn9c30WI.js → shadow-claw-mcp-remote-C2jwBsQt.js} +2 -2
  127. package/dist/lib/{shadow-claw-mcp-remote-Dn9c30WI.js.map → shadow-claw-mcp-remote-C2jwBsQt.js.map} +1 -1
  128. package/dist/lib/{shadow-claw-networking-zqNuyn3-.js → shadow-claw-networking-BV-rna16.js} +2 -2
  129. package/dist/lib/{shadow-claw-networking-zqNuyn3-.js.map → shadow-claw-networking-BV-rna16.js.map} +1 -1
  130. package/dist/lib/{shadow-claw-notifications-DFgdo33v.js → shadow-claw-notifications-Dku7VBLk.js} +2 -2
  131. package/dist/lib/{shadow-claw-notifications-DFgdo33v.js.map → shadow-claw-notifications-Dku7VBLk.js.map} +1 -1
  132. package/dist/lib/{shadow-claw-page-header-B7LFGQRf.js → shadow-claw-page-header-VPjYWfsT.js} +2 -2
  133. package/dist/lib/{shadow-claw-page-header-B7LFGQRf.js.map → shadow-claw-page-header-VPjYWfsT.js.map} +1 -1
  134. package/dist/lib/{shadow-claw-pages-DLspFqdK.js → shadow-claw-pages-DXrM6hgZ.js} +29 -19
  135. package/dist/lib/shadow-claw-pages-DXrM6hgZ.js.map +1 -0
  136. package/dist/lib/{shadow-claw-peerjs-D8xWwuWR.js → shadow-claw-peerjs-D3xonez5.js} +3 -3
  137. package/dist/lib/{shadow-claw-peerjs-D8xWwuWR.js.map → shadow-claw-peerjs-D3xonez5.js.map} +1 -1
  138. package/dist/lib/{shadow-claw-settings-NbvzXASD.js → shadow-claw-settings-DMTx6OS9.js} +5 -5
  139. package/dist/lib/{shadow-claw-settings-NbvzXASD.js.map → shadow-claw-settings-DMTx6OS9.js.map} +1 -1
  140. package/dist/lib/{shadow-claw-storage-B_NAoZmd.js → shadow-claw-storage-BJLnukxa.js} +3 -3
  141. package/dist/lib/{shadow-claw-storage-B_NAoZmd.js.map → shadow-claw-storage-BJLnukxa.js.map} +1 -1
  142. package/dist/lib/{shadow-claw-task-server-BaQJXhYJ.js → shadow-claw-task-server-DcMj20hD.js} +2 -2
  143. package/dist/lib/{shadow-claw-task-server-BaQJXhYJ.js.map → shadow-claw-task-server-DcMj20hD.js.map} +1 -1
  144. package/dist/lib/{shadow-claw-tasks-CAZua0-j.js → shadow-claw-tasks-BQBe4lVi.js} +7 -7
  145. package/dist/lib/{shadow-claw-tasks-CAZua0-j.js.map → shadow-claw-tasks-BQBe4lVi.js.map} +1 -1
  146. package/dist/lib/{shadow-claw-terminal-B2YJhkJL.js → shadow-claw-terminal-DPEzTxXv.js} +2 -2
  147. package/dist/lib/{shadow-claw-terminal-B2YJhkJL.js.map → shadow-claw-terminal-DPEzTxXv.js.map} +1 -1
  148. package/dist/lib/{shadow-claw-tools-CkZWxxTm.js → shadow-claw-tools-BCnU8FaK.js} +6 -6
  149. package/dist/lib/{shadow-claw-tools-CkZWxxTm.js.map → shadow-claw-tools-BCnU8FaK.js.map} +1 -1
  150. package/dist/lib/{shadow-claw-webvm-BL9cgrP9.js → shadow-claw-webvm-CnW-hoJ8.js} +2 -2
  151. package/dist/lib/{shadow-claw-webvm-BL9cgrP9.js.map → shadow-claw-webvm-CnW-hoJ8.js.map} +1 -1
  152. package/dist/lib/subsystems/mcp/webmcp.d.ts +15 -2
  153. package/dist/lib/{sync-web-mcp-registration-dW2MVCj4.js → sync-web-mcp-registration-DwpGjVdo.js} +10 -4
  154. package/dist/lib/sync-web-mcp-registration-DwpGjVdo.js.map +1 -0
  155. package/dist/lib/{tools-D7whby3H.js → tools-CP6G0HF7.js} +5 -6
  156. package/dist/lib/tools-CP6G0HF7.js.map +1 -0
  157. package/dist/lib/{trusted-types-d0cdkut_.js → trusted-types-0cu5Dm6M.js} +29 -4
  158. package/dist/lib/{trusted-types-d0cdkut_.js.map → trusted-types-0cu5Dm6M.js.map} +1 -1
  159. package/dist/lib/utils/index.d.ts +1 -0
  160. package/dist/lib/utils/index.js +4 -2
  161. package/dist/lib/utils/index.js.map +1 -1
  162. package/dist/lib/utils/resolve-page-script-dependencies.d.ts +19 -0
  163. package/dist/lib/utils/resolve-page-script-dependencies.js +98 -0
  164. package/dist/lib/utils/resolve-page-script-dependencies.js.map +1 -0
  165. package/dist/lib/utils/utils.js +1 -1
  166. package/dist/lib/webmcp-Bf9rT7uu.js +2001 -0
  167. package/dist/lib/webmcp-Bf9rT7uu.js.map +1 -0
  168. package/dist/public/.well-known/mcp/server-card.json +1 -1
  169. package/dist/public/.well-known/mcp.json +1 -1
  170. package/dist/public/AGENTS.md +3 -3
  171. package/dist/public/README.md +1 -1
  172. package/dist/public/agent.worker.js +2 -2
  173. package/dist/public/components/shadow-claw/shadow-claw.css +1 -1
  174. package/dist/public/components/shadow-claw/shadow-claw.html +1 -1
  175. package/dist/public/components/shadow-claw-conversations/shadow-claw-conversations.css +1 -1
  176. package/dist/public/components/shadow-claw-conversations/shadow-claw-conversations.html +1 -1
  177. package/dist/public/{configure-peer-js-WLRM7Qa7.js → configure-peer-js-OYl3V8sW.js} +1 -1
  178. package/dist/public/{custom-element-security-Cl991z-x.js → custom-element-security-BR4V40j4.js} +1 -1
  179. package/dist/public/docs/example/article/index.html +3 -3
  180. package/dist/public/docs/example/article.html +3 -3
  181. package/dist/public/docs/publishing/index.html +3 -3
  182. package/dist/public/docs/publishing.html +3 -3
  183. package/dist/public/docs/skill-creator/index.html +3 -3
  184. package/dist/public/docs/skill-creator.html +3 -3
  185. package/dist/public/docs/subsystems/custom-element-security.md +19 -5
  186. package/dist/public/docs/subsystems/pages.md +10 -2
  187. package/dist/public/docs/subsystems/tools.md +1 -2
  188. package/dist/public/docs/subsystems/webmcp.md +41 -6
  189. package/dist/public/{download-group-file-fFjoIIp4.js → download-group-file-BNmK8wac.js} +1 -1
  190. package/dist/public/e2e/README.md +2 -2
  191. package/dist/public/{e2e-bridge-CiSfBRT4.js → e2e-bridge-4phD1JUQ.js} +1 -1
  192. package/dist/public/{file-viewer-DFC3kfeO.js → file-viewer-Dbh3K9nL.js} +1 -1
  193. package/dist/public/index.html +3 -3
  194. package/dist/public/index.js +1 -1
  195. package/dist/public/{init-control-plane-BEbcwmmv.js → init-control-plane-DGOY_RNS.js} +1 -1
  196. package/dist/public/llms.txt +1 -1
  197. package/dist/public/main/index.html +3 -3
  198. package/dist/public/main/memory/index.html +3 -3
  199. package/dist/public/main/memory.html +3 -3
  200. package/dist/public/main.html +3 -3
  201. package/dist/public/{markdown-BeglYzw9.js → markdown-BPZYpfGm.js} +1 -1
  202. package/dist/public/{orchestrator-BlvEG3PO.js → orchestrator-OoUK7CF9.js} +1 -1
  203. package/dist/public/{orchestrator-DTNrntd4.js → orchestrator-a9047bGu.js} +1 -1
  204. package/dist/public/{peerjs-CnBdK94R.js → peerjs-Cbn310Tz.js} +1 -1
  205. package/dist/public/{push-client-DOHbdCyj.js → push-client-Dy4LGJy9.js} +1 -1
  206. package/dist/public/service-worker.js +1 -1
  207. package/dist/public/shadow-claw-B-HWC1uN.js +1180 -0
  208. package/dist/public/{shadow-claw-accounts-C6FXVw2K.js → shadow-claw-accounts-Di-anCZ1.js} +1 -1
  209. package/dist/public/{shadow-claw-channels-tr_r60Kq.js → shadow-claw-channels-RVwCE8pE.js} +1 -1
  210. package/dist/public/{shadow-claw-chat-BAAPhAOs.js → shadow-claw-chat-DI1q8UnX.js} +1 -1
  211. package/dist/public/{shadow-claw-control-plane-C_5VIx8E.js → shadow-claw-control-plane-KXEdLOGl.js} +2 -2
  212. package/dist/public/{shadow-claw-conversations-DGYZdDa3.js → shadow-claw-conversations-BCBGtS30.js} +40 -6
  213. package/dist/public/{shadow-claw-file-viewer-5j2-Z3fN.js → shadow-claw-file-viewer-CW3t6j-w.js} +1 -1
  214. package/dist/public/{shadow-claw-files-DKF4Yy0m.js → shadow-claw-files-JQ-o0ImX.js} +1 -1
  215. package/dist/public/{shadow-claw-git-CtUTJXKT.js → shadow-claw-git-D2M8VixW.js} +2 -2
  216. package/dist/public/{shadow-claw-integrations-CuBy9D3z.js → shadow-claw-integrations-Cgw6v9_1.js} +1 -1
  217. package/dist/public/{shadow-claw-llm-BIfNNjGL.js → shadow-claw-llm-74ieXp7i.js} +1 -1
  218. package/dist/public/{shadow-claw-mcp-remote-C17FXvrb.js → shadow-claw-mcp-remote-BX0BkSmy.js} +1 -1
  219. package/dist/public/{shadow-claw-networking-CjxQ1CLI.js → shadow-claw-networking-DNX8vaIQ.js} +1 -1
  220. package/dist/public/{shadow-claw-notifications-Brn2O3Ps.js → shadow-claw-notifications-BLTaGAny.js} +1 -1
  221. package/dist/public/{shadow-claw-page-header-Bn1P7Cxb.js → shadow-claw-page-header-CjFOdo9v.js} +1 -1
  222. package/dist/public/shadow-claw-pages-DOQqMm0_.js +645 -0
  223. package/dist/public/{shadow-claw-settings-CfDm0hVA.js → shadow-claw-settings-DFtl0Fy8.js} +2 -2
  224. package/dist/public/{shadow-claw-storage-DOOesRzw.js → shadow-claw-storage-gQGExZRq.js} +1 -1
  225. package/dist/public/{shadow-claw-task-server-H36iDDp2.js → shadow-claw-task-server-Ca45uY7S.js} +1 -1
  226. package/dist/public/{shadow-claw-tasks-4JsjSGkN.js → shadow-claw-tasks-CCTaaSdi.js} +1 -1
  227. package/dist/public/{shadow-claw-terminal-CTRTcYz-.js → shadow-claw-terminal-BfgulLkl.js} +1 -1
  228. package/dist/public/{shadow-claw-tools-Dm1LxNf4.js → shadow-claw-tools-V8NA4n18.js} +1 -1
  229. package/dist/public/{shadow-claw-webvm-JzuPe9Nr.js → shadow-claw-webvm-CxxI2bnC.js} +1 -1
  230. package/dist/public/sync-web-mcp-registration-CkCA8UFm.js +1 -0
  231. package/dist/public/{tools-FiTtOlIt.js → tools-CwQq5tJH.js} +2 -2
  232. package/dist/public/webmcp-CmtWOAFm.js +6 -0
  233. package/dist/server.js +2 -2
  234. package/package.json +3 -3
  235. package/src/cli/prerender/dsd-shell/prerender-dsd-shell.test.ts +16 -0
  236. package/src/cli/prerender/dsd-shell/prerender-dsd-shell.ts +62 -1
  237. package/src/cli/prerender/pretty-paths/prerender-pretty-paths.test.ts +277 -0
  238. package/src/cli/prerender/pretty-paths/prerender-pretty-paths.ts +28 -1
  239. package/src/cli/site-config/custom-elements/build-custom-element-script-tags.ts +13 -1
  240. package/src/components/shadow-claw/shadow-claw.css +12 -0
  241. package/src/components/shadow-claw/shadow-claw.html +12 -2
  242. package/src/components/shadow-claw/utils/bind-event-listeners.test.ts +18 -0
  243. package/src/components/shadow-claw/utils/bind-event-listeners.ts +14 -0
  244. package/src/components/shadow-claw/utils/get-route.test.ts +35 -0
  245. package/src/components/shadow-claw/utils/get-route.ts +18 -0
  246. package/src/components/shadow-claw/utils/sync-slotted-sidebar-active-links.test.ts +152 -1
  247. package/src/components/shadow-claw/utils/sync-slotted-sidebar-active-links.ts +139 -8
  248. package/src/components/shadow-claw-conversations/shadow-claw-conversations.css +11 -0
  249. package/src/components/shadow-claw-conversations/shadow-claw-conversations.html +27 -4
  250. package/src/components/shadow-claw-conversations/shadow-claw-conversations.ts +32 -4
  251. package/src/components/shadow-claw-pages/shadow-claw-pages-scripts.test.ts +266 -0
  252. package/src/components/shadow-claw-pages/shadow-claw-pages.ts +41 -17
  253. package/src/core/orchestrator/utils/sync-web-mcp-registration.test.ts +18 -1
  254. package/src/core/orchestrator/utils/sync-web-mcp-registration.ts +8 -0
  255. package/src/core/utils/init-control-plane.test.ts +9 -4
  256. package/src/security/custom-element-security.test.ts +65 -0
  257. package/src/security/custom-element-security.ts +67 -4
  258. package/src/stores/tools.test.ts +5 -3
  259. package/src/stores/tools.ts +5 -10
  260. package/src/subsystems/mcp/webmcp.test.ts +84 -13
  261. package/src/subsystems/mcp/webmcp.ts +73 -10
  262. package/src/utils/index.ts +1 -0
  263. package/src/utils/resolve-page-script-dependencies.test.ts +245 -0
  264. package/src/utils/resolve-page-script-dependencies.ts +198 -0
  265. package/dist/cli/chunk-B1hufJeO.js +0 -1
  266. package/dist/cli/chunk-BZpn8npn.js +0 -1
  267. package/dist/cli/chunk-Bw5aOTFr.js +0 -1
  268. package/dist/cli/chunk-C8nH01Gw.js +0 -32
  269. package/dist/cli/chunk-CK1ZoyoE.js +0 -17
  270. package/dist/cli/chunk-CVkhDr-7.js +0 -1
  271. package/dist/cli/chunk-Cum07Vlh.js +0 -1
  272. package/dist/cli/chunk-D3UhDDmV.js +0 -2
  273. package/dist/cli/chunk-D8GI6qj6.js +0 -1
  274. package/dist/cli/chunk-DEH-FvmP.js +0 -1
  275. package/dist/cli/chunk-DksvJ_kf.js +0 -1
  276. package/dist/cli/chunk-RGb9wM4R.js +0 -1
  277. package/dist/lib/shadow-claw-PdOpgTxH.js.map +0 -1
  278. package/dist/lib/shadow-claw-pages-DLspFqdK.js.map +0 -1
  279. package/dist/lib/sync-web-mcp-registration-dW2MVCj4.js.map +0 -1
  280. package/dist/lib/tools-D7whby3H.js.map +0 -1
  281. package/dist/lib/webmcp-CYTNZfkn.js +0 -1687
  282. package/dist/lib/webmcp-CYTNZfkn.js.map +0 -1
  283. package/dist/public/shadow-claw-CnNX-WCh.js +0 -1158
  284. package/dist/public/shadow-claw-pages-BwOOqRWW.js +0 -645
  285. package/dist/public/sync-web-mcp-registration-BnHVUjat.js +0 -1
  286. package/dist/public/webmcp-_TBqXlVW.js +0 -1
@@ -0,0 +1,198 @@
1
+ export interface PageScriptDependencySource {
2
+ src: string;
3
+ id?: string;
4
+ name?: string;
5
+ global?: boolean;
6
+ autoload?: boolean;
7
+ type?: string;
8
+ async?: boolean;
9
+ defer?: boolean;
10
+ hasInit?: boolean;
11
+ }
12
+
13
+ function stripScriptPrefix(s: string): string {
14
+ return s
15
+ .replace(/^\.?\//, "")
16
+ .replace(/^pages\/main\//, "")
17
+ .toLowerCase()
18
+ .trim();
19
+ }
20
+
21
+ function getFilename(filepath: string): string {
22
+ const parts = filepath.split("/");
23
+ return (parts.pop() || "").toLowerCase().trim();
24
+ }
25
+
26
+ function getFilenameStem(filepath: string): string {
27
+ const filename = getFilename(filepath);
28
+ return filename
29
+ .replace(/\.(js|mjs|cjs|ts)$/i, "")
30
+ .toLowerCase()
31
+ .trim();
32
+ }
33
+
34
+ /**
35
+ * Resolves script dependencies for a page given a list of approved script descriptors
36
+ * and frontmatter/dependency declarations.
37
+ *
38
+ * Always includes scripts marked as `global` or `autoload`.
39
+ * Gracefully ignores any unknown dependency IDs or missing scripts without throwing.
40
+ */
41
+ export function resolvePageScriptDependencies(
42
+ descriptors: Array<string | PageScriptDependencySource> = [],
43
+ frontmatterOrDependencies?: Record<string, any> | string[] | string | null,
44
+ content?: string | null,
45
+ ): PageScriptDependencySource[] {
46
+ if (!Array.isArray(descriptors) || descriptors.length === 0) {
47
+ return [];
48
+ }
49
+
50
+ // Normalize all descriptors to objects with at least a `src`
51
+ const normalizedDescriptors: PageScriptDependencySource[] = descriptors
52
+ .map((item) => {
53
+ if (typeof item === "string") {
54
+ return { src: item };
55
+ }
56
+ if (item && typeof item === "object" && typeof item.src === "string") {
57
+ return item;
58
+ }
59
+ return null;
60
+ })
61
+ .filter((entry): entry is PageScriptDependencySource => entry !== null);
62
+
63
+ const resolved: PageScriptDependencySource[] = [];
64
+ const addedSrcs = new Set<string>();
65
+
66
+ // 1. Automatically include all global / autoload scripts
67
+ for (const desc of normalizedDescriptors) {
68
+ if (desc.global === true || desc.autoload === true) {
69
+ if (!addedSrcs.has(desc.src)) {
70
+ addedSrcs.add(desc.src);
71
+ resolved.push(desc);
72
+ }
73
+ }
74
+ }
75
+
76
+ if (!frontmatterOrDependencies && !content) {
77
+ return resolved;
78
+ }
79
+
80
+ // 2. Extract requested dependency names / IDs / paths
81
+ const rawItems: any[] = [];
82
+ if (Array.isArray(frontmatterOrDependencies)) {
83
+ rawItems.push(...frontmatterOrDependencies);
84
+ } else if (typeof frontmatterOrDependencies === "string") {
85
+ rawItems.push(...frontmatterOrDependencies.split(/[,;\s]+/));
86
+ } else if (
87
+ typeof frontmatterOrDependencies === "object" &&
88
+ frontmatterOrDependencies !== null
89
+ ) {
90
+ const data = frontmatterOrDependencies;
91
+ if (Array.isArray(data.dependencies)) {
92
+ rawItems.push(...data.dependencies);
93
+ } else if (typeof data.dependencies === "string") {
94
+ rawItems.push(...data.dependencies.split(/[,;\s]+/));
95
+ }
96
+
97
+ if (Array.isArray(data.scripts)) {
98
+ rawItems.push(...data.scripts);
99
+ } else if (typeof data.scripts === "string") {
100
+ rawItems.push(...data.scripts.split(/[,;\s]+/));
101
+ }
102
+ }
103
+
104
+ // 2b. Auto-detect inline scripts and custom element tags from markdown content
105
+ if (typeof content === "string" && content) {
106
+ const inlineScriptMatches = content.matchAll(
107
+ /<script\b[^>]*src=["']([^"']+)["'][^>]*>/gi,
108
+ );
109
+ for (const match of inlineScriptMatches) {
110
+ if (match[1]) {
111
+ rawItems.push(match[1]);
112
+ }
113
+ }
114
+
115
+ for (const desc of normalizedDescriptors) {
116
+ const candidates = [
117
+ desc.id,
118
+ desc.name,
119
+ getFilenameStem(desc.src),
120
+ getFilename(desc.src),
121
+ ].filter(Boolean) as string[];
122
+
123
+ for (const tag of candidates) {
124
+ if (tag.includes("-")) {
125
+ const tagRegex = new RegExp(`<${tag}[\\s>/]`, "i");
126
+ if (tagRegex.test(content)) {
127
+ rawItems.push(tag);
128
+ break;
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ // Flatten and normalize tokens
136
+ const requestedKeys: string[] = [];
137
+ for (const item of rawItems) {
138
+ if (typeof item === "string") {
139
+ const trimmed = item.trim();
140
+ if (trimmed) {
141
+ requestedKeys.push(trimmed);
142
+ }
143
+ } else if (item && typeof item === "object") {
144
+ const key = item.id || item.name || item.src;
145
+ if (typeof key === "string" && key.trim()) {
146
+ requestedKeys.push(key.trim());
147
+ }
148
+ }
149
+ }
150
+
151
+ // 3. Resolve requested keys against approved descriptors
152
+ for (const key of requestedKeys) {
153
+ const keyLower = key.toLowerCase();
154
+ const keyNorm = stripScriptPrefix(key);
155
+ const keyFilename = getFilename(key);
156
+ const keyStem = getFilenameStem(key);
157
+
158
+ const match = normalizedDescriptors.find((desc) => {
159
+ if (desc.id && desc.id.toLowerCase() === keyLower) {
160
+ return true;
161
+ }
162
+ if (desc.name && desc.name.toLowerCase() === keyLower) {
163
+ return true;
164
+ }
165
+ if (desc.src === key || desc.src.toLowerCase() === keyLower) {
166
+ return true;
167
+ }
168
+ if (stripScriptPrefix(desc.src) === keyNorm) {
169
+ return true;
170
+ }
171
+ const descFilename = getFilename(desc.src);
172
+ if (
173
+ descFilename &&
174
+ (descFilename === keyFilename || descFilename === keyLower)
175
+ ) {
176
+ return true;
177
+ }
178
+ const descStem = getFilenameStem(desc.src);
179
+ if (descStem && (descStem === keyStem || descStem === keyLower)) {
180
+ return true;
181
+ }
182
+ return false;
183
+ });
184
+
185
+ if (match) {
186
+ if (!addedSrcs.has(match.src)) {
187
+ addedSrcs.add(match.src);
188
+ resolved.push(match);
189
+ }
190
+ } else {
191
+ console.warn(
192
+ `[ShadowClaw] Script dependency "${key}" declared in page frontmatter was not found in approved customElements.scripts config.`,
193
+ );
194
+ }
195
+ }
196
+
197
+ return resolved;
198
+ }
@@ -1 +0,0 @@
1
- export{t as importRemoteArtifacts}from"./chunk-DGeysxz3.js";
@@ -1 +0,0 @@
1
- export{r as orchestratorStore}from"./chunk-H_Mw5ypp.js";
@@ -1 +0,0 @@
1
- export{t as getAgentCore}from"./chunk-M2tZrzY5.js";
@@ -1,32 +0,0 @@
1
- import{t as e}from"./chunk-uAI_Zi6n.js";import{C as t,S as n,_ as r,a as i,b as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,o as p,p as m,r as ee,t as h,x as g,y as _}from"./chunk-CK1ZoyoE.js";import{c as v,l as te,o as ne,s as y,t as b}from"./chunk-C9dO1ce2.js";import{n as re}from"./chunk-kF1oe5Yi.js";import*as x from"node:fs";import S,{join as C,posix as ie,resolve as ae,win32 as w}from"node:path";import{fileURLToPath as T}from"node:url";import E,{chdir as oe,env as se,exit as ce}from"node:process";import{execSync as le}from"node:child_process";import{copyFile as D,cp as O,lstat as ue,mkdir as k,readFile as A,readdir as de,readlink as fe,realpath as pe,rm as me,stat as he,writeFile as j}from"node:fs/promises";import{chmodSync as ge,lstatSync as _e,lstatSync as ve,readdir as ye,readdirSync as be,readlinkSync as xe,realpathSync as Se,renameSync as Ce,rmSync as we,rmdirSync as Te,statSync as Ee,unlinkSync as De}from"fs";import{EventEmitter as Oe}from"node:events";import ke from"node:stream";import{StringDecoder as Ae}from"node:string_decoder";import{basename as je,parse as M,resolve as N}from"path";import{inspect as Me}from"util";import P from"fs/promises";import{setTimeout as Ne}from"timers/promises";import{tmpdir as Pe}from"os";var Fe=(e,t,n)=>{let r=e instanceof RegExp?Ie(e,n):e,i=t instanceof RegExp?Ie(t,n):t,a=r!==null&&i!=null&&Le(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},Ie=(e,t)=>{let n=t.match(e);return n?n[0]:null},Le=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},Re=`\0SLASH`+Math.random()+`\0`,ze=`\0OPEN`+Math.random()+`\0`,Be=`\0CLOSE`+Math.random()+`\0`,Ve=`\0COMMA`+Math.random()+`\0`,He=`\0PERIOD`+Math.random()+`\0`,Ue=new RegExp(Re,`g`),We=new RegExp(ze,`g`),Ge=new RegExp(Be,`g`),Ke=new RegExp(Ve,`g`),qe=new RegExp(He,`g`),Je=/\\\\/g,Ye=/\\{/g,Xe=/\\}/g,Ze=/\\,/g,Qe=/\\./g,$e=1e5;function et(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function tt(e){return e.replace(Je,Re).replace(Ye,ze).replace(Xe,Be).replace(Ze,Ve).replace(Qe,He)}function nt(e){return e.replace(Ue,`\\`).replace(We,`{`).replace(Ge,`}`).replace(Ke,`,`).replace(qe,`.`)}function rt(e){if(!e)return[``];let t=[],n=Fe(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=rt(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function it(e,t={}){if(!e)return[];let{max:n=$e}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),lt(tt(e),n,!0).map(nt)}function at(e){return`{`+e+`}`}function ot(e){return/^-?0\d/.test(e)}function st(e,t){return e<=t}function ct(e,t){return e>=t}function lt(e,t,n){let r=[],i=Fe(`{`,`}`,e);if(!i)return[e];let a=i.pre,o=i.post.length?lt(i.post,t,!1):[``];if(/\$$/.test(i.pre))for(let e=0;e<o.length&&e<t;e++){let t=a+`{`+i.body+`}`+o[e];r.push(t)}else{let s=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),l=s||c,u=i.body.indexOf(`,`)>=0;if(!l&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+`{`+i.body+Be+i.post,lt(e,t,!0)):[e];let d;if(l)d=i.body.split(/\.\./);else if(d=rt(i.body),d.length===1&&d[0]!==void 0&&(d=lt(d[0],t,!1).map(at),d.length===1))return o.map(e=>i.pre+d[0]+e);let f;if(l&&d[0]!==void 0&&d[1]!==void 0){let e=et(d[0]),t=et(d[1]),n=Math.max(d[0].length,d[1].length),r=d.length===3&&d[2]!==void 0?Math.abs(et(d[2])):1,i=st;t<e&&(r*=-1,i=ct);let a=d.some(ot);f=[];for(let o=e;i(o,t);o+=r){let e;if(c)e=String.fromCharCode(o),e===`\\`&&(e=``);else if(e=String(o),a){let t=n-e.length;if(t>0){let n=Array(t+1).join(`0`);e=o<0?`-`+n+e.slice(1):n+e}}f.push(e)}}else{f=[];for(let e=0;e<d.length;e++)f.push.apply(f,lt(d[e],t,!1))}for(let e=0;e<f.length;e++)for(let i=0;i<o.length&&r.length<t;i++){let t=a+f[e]+o[i];(!n||l||t)&&r.push(t)}}return r}var ut=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},dt={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},ft=e=>e.replace(/[[\]\\-]/g,`\\$&`),pt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),mt=e=>e.join(``),ht=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;t:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1)l=!0,a++;else{if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c)c=!0,a++;else{if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(dt))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue t}}c=!1,d?(t>d?r.push(ft(d)+`-`+ft(t)):t===d&&r.push(ft(t)),d=``,a++):e.startsWith(`-]`,a+1)?(r.push(ft(t+`-`)),a+=2):e.startsWith(`-`,a+1)?(d=t,a+=2):(r.push(ft(t)),a++)}}}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l)return[pt(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+mt(r)+`]`,p=`[`+(l?``:`^`)+mt(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},gt=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^\/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,`$1$2`).replace(/\\([^\/])/g,`$1`):t?e.replace(/\[([^\/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,`$1$2`).replace(/\\([^\/{}])/g,`$1`),_t=/* @__PURE__ */ new Set([`!`,`?`,`+`,`*`,`@`]),vt=e=>_t.has(e),yt=`(?!(?:^|/)\\.\\.?(?:$|/))`,bt=`(?!\\.)`,xt=/* @__PURE__ */ new Set([`[`,`.`]),St=/* @__PURE__ */ new Set([`..`,`.`]),Ct=/* @__PURE__ */ new Set(`().*{}+?[]^$\\!`),wt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Tt=`[^/]`,Et=Tt+`*?`,Dt=Tt+`+?`,Ot=class e{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.#l=this.type?this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...t){for(let n of t)if(n!==``){if(typeof n!=`string`&&!(n instanceof e&&n.#i===this))throw Error(`invalid part: `+n);this.#r.push(n)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let t=this.#i;for(let n=0;n<this.#a;n++){let r=t.#r[n];if(!(r instanceof e&&r.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(t){let n=new e(this.type,t);for(let e of this.#r)n.copyIn(e);return n}static#f(t,n,r,i){let a=!1,o=!1,s=-1,c=!1;if(n.type===null){let l=r,u=``;for(;l<t.length;){let r=t.charAt(l++);if(a||r===`\\`)a=!a,u+=r;else if(o)l===s+1?(r===`^`||r===`!`)&&(c=!0):r===`]`&&!(l===s+2&&c)&&(o=!1),u+=r;else if(r===`[`)o=!0,s=l,c=!1,u+=r;else if(!i.noext&&vt(r)&&t.charAt(l)===`(`){n.push(u),u=``;let a=new e(r,n);l=e.#f(t,a,l,i),n.push(a)}else u+=r}return n.push(u),l}let l=r+1,u=new e(null,n),d=[],f=``;for(;l<t.length;){let r=t.charAt(l++);if(a||r===`\\`)a=!a,f+=r;else if(o)l===s+1?(r===`^`||r===`!`)&&(c=!0):r===`]`&&!(l===s+2&&c)&&(o=!1),f+=r;else if(r===`[`)o=!0,s=l,c=!1,f+=r;else if(vt(r)&&t.charAt(l)===`(`){u.push(f),f=``;let n=new e(r,u);u.push(n),l=e.#f(t,n,l,i)}else if(r===`|`)u.push(f),f=``,d.push(u),u=new e(null,n);else{if(r===`)`)return f===``&&n.#r.length===0&&(n.#u=!0),u.push(f),f=``,n.push(...d,u),l;f+=r}}return n.type=null,n.#t=void 0,n.#r=[t.substring(r-1)],l}static fromGlob(t,n={}){let r=new e(null,void 0,n);return e.#f(t,r,0,n),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(t){let n=t??!!this.#c.dot;if(this.#e===this&&this.#d(),!this.type){let r=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),i=this.#r.map(n=>{let[i,a,o,s]=typeof n==`string`?e.#m(n,this.#t,r):n.toRegExpSource(t);return this.#t=this.#t||o,this.#n=this.#n||s,i}).join(``),a=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&St.has(this.#r[0]))){let e=xt,r=n&&e.has(i.charAt(0))||i.startsWith(`\\.`)&&e.has(i.charAt(2))||i.startsWith(`\\.\\.`)&&e.has(i.charAt(4)),o=!n&&!t&&e.has(i.charAt(0));a=r?yt:o?bt:``}let o=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(o=`(?:$|\\/)`),[a+i+o,gt(i),this.#t=!!this.#t,this.#n]}let r=this.type===`*`||this.type===`+`,i=this.type===`!`?`(?:(?!(?:`:`(?:`,a=this.#p(n);if(this.isStart()&&this.isEnd()&&!a&&this.type!==`!`){let e=this.toString();return this.#r=[e],this.type=null,this.#t=void 0,[e,gt(this.toString()),!1,!1]}let o=!r||t||n||!bt?``:this.#p(!0);o===a&&(o=``),o&&(a=`(?:${a})(?:${o})*?`);let s=``;if(this.type===`!`&&this.#u)s=(this.isStart()&&!n?bt:``)+Dt;else{let e=this.type===`!`?`))`+(this.isStart()&&!n&&!t?bt:``)+Et+`)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&o?`)`:this.type===`*`&&o?`)?`:`)${this.type}`;s=i+a+e}return[s,gt(a),this.#t=!!this.#t,this.#n]}#p(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#m(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r)r=!1,i+=(Ct.has(c)?`\\`:``)+c;else if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?Dt:Et,t=!0}else if(o=!1,c===`\\`)s===e.length-1?i+=`\\\\`:r=!0;else{if(c===`[`){let[n,r,o,c]=ht(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}c===`?`?(i+=Tt,t=!0):i+=wt(c)}}return[i,gt(e),!!t,a]}},kt=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),F=(e,t,n={})=>(ut(t),!n.nocomment&&t.charAt(0)===`#`?!1:new an(t,n).match(e)),At=/^\*+([^+@!?\*\[\(]*)$/,jt=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),Mt=e=>t=>t.endsWith(e),Nt=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),Pt=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Ft=/^\*+\.\*+$/,It=e=>!e.startsWith(`.`)&&e.includes(`.`),Lt=e=>e!==`.`&&e!==`..`&&e.includes(`.`),Rt=/^\.\*+$/,zt=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),Bt=/^\*+$/,Vt=e=>e.length!==0&&!e.startsWith(`.`),Ht=e=>e.length!==0&&e!==`.`&&e!==`..`,Ut=/^\?+([^+@!?\*\[\(]*)?$/,Wt=([e,t=``])=>{let n=Jt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Gt=([e,t=``])=>{let n=Yt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Kt=([e,t=``])=>{let n=Yt([e]);return t?e=>n(e)&&e.endsWith(t):n},qt=([e,t=``])=>{let n=Jt([e]);return t?e=>n(e)&&e.endsWith(t):n},Jt=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},Yt=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},Xt=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Zt={win32:{sep:`\\`},posix:{sep:`/`}};F.sep=Xt===`win32`?Zt.win32.sep:Zt.posix.sep;var I=Symbol(`globstar **`);F.GLOBSTAR=I;var Qt=`[^/]*?`,$t=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,en=`(?:(?!(?:\\/|^)\\.).)*?`;F.filter=(e,t={})=>n=>F(n,e,t);var L=(e,t={})=>Object.assign({},e,t);F.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return F;let t=F;return Object.assign((n,r,i={})=>t(n,r,L(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,L(e,n))}static defaults(n){return t.defaults(L(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,L(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,L(e,r))}},unescape:(n,r={})=>t.unescape(n,L(e,r)),escape:(n,r={})=>t.escape(n,L(e,r)),filter:(n,r={})=>t.filter(n,L(e,r)),defaults:n=>t.defaults(L(e,n)),makeRe:(n,r={})=>t.makeRe(n,L(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,L(e,r)),match:(n,r,i={})=>t.match(n,r,L(e,i)),sep:t.sep,GLOBSTAR:I})};var tn=(e,t={})=>(ut(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:it(e,{max:t.braceExpandMax}));F.braceExpand=tn,F.makeRe=(e,t={})=>new an(e,t).makeRe(),F.match=(e,t,n={})=>{let r=new an(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};var nn=/[?*]|[+@!]\(.*?\)|\[|\]/,rn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),an=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){ut(e),t||={},this.options=t,this.pattern=e,this.platform=t.platform||Xt,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!nn.test(e[2]))&&!nn.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)e[t][n]===`**`&&(e[t][n]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];n===1&&r===``&&e[0]===``||(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];e===1&&r===``&&n[0]===``||(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=this.options;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),r=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),i=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),a=!i&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),o=r?3:n?0:void 0,s=a?3:i?0:void 0;if(typeof o==`number`&&typeof s==`number`){let[n,r]=[e[o],t[s]];n.toLowerCase()===r.toLowerCase()&&(t[s]=n,s>o?t=t.slice(s):o>s&&(e=e.slice(o)))}}let{optimizationLevel:i=1}=this.options;i>=2&&(e=this.levelTwoFileOptimize(e)),this.debug(`matchOne`,this,{file:e,pattern:t}),this.debug(`matchOne`,e.length,t.length);for(var a=0,o=0,s=e.length,c=t.length;a<s&&o<c;a++,o++){this.debug(`matchOne loop`);var l=t[o],u=e[a];if(this.debug(t,l,u),l===!1)return!1;if(l===I){this.debug(`GLOBSTAR`,[t,l,u]);var d=a,f=o+1;if(f===c){for(this.debug(`** at the end`);a<s;a++)if(e[a]===`.`||e[a]===`..`||!r.dot&&e[a].charAt(0)===`.`)return!1;return!0}for(;d<s;){var p=e[d];if(this.debug(`
2
- globstar while`,e,d,t,f,p),this.matchOne(e.slice(d),t.slice(f),n))return this.debug(`globstar found match!`,d,s,p),!0;if(p===`.`||p===`..`||!r.dot&&p.charAt(0)===`.`){this.debug(`dot detected!`,e,d,t,f);break}this.debug(`globstar swallow a segment, and continue`),d++}return!!(n&&(this.debug(`
3
- >>> no match, partial?`,e,d,t,f),d===s))}let i;if(typeof l==`string`?(i=u===l,this.debug(`string match`,l,u,i)):(i=l.test(u),this.debug(`pattern match`,l,u,i)),!i)return!1}if(a===s&&o===c)return!0;if(a===s)return n;if(o===c)return a===s-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return tn(this.pattern,this.options)}parse(e){ut(e);let t=this.options;if(e===`**`)return I;if(e===``)return``;let n,r=null;(n=e.match(Bt))?r=t.dot?Ht:Vt:(n=e.match(At))?r=(t.nocase?t.dot?Pt:Nt:t.dot?Mt:jt)(n[1]):(n=e.match(Ut))?r=(t.nocase?t.dot?Gt:Wt:t.dot?Kt:qt)(n):(n=e.match(Ft))?r=t.dot?Lt:It:(n=e.match(Rt))&&(r=zt);let i=Ot.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?Qt:t.dot?$t:en,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?rn(e):e===I?I:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==I||a===I||(a===void 0?i!==void 0&&i!==I?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==I&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=I))});let i=t.filter(e=>e!==I);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^\/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e=0;e<i.length;e++){let o=i[e],s=r;if(n.matchBase&&o.length===1&&(s=[a]),this.matchOne(s,o,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return F.defaults(e).Minimatch}};F.AST=Ot,F.Minimatch=an,F.escape=kt,F.unescape=gt;var on=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,sn=/* @__PURE__ */ new Set,cn=typeof process==`object`&&process?process:{},ln=(e,t,n,r)=>{typeof cn.emitWarning==`function`?cn.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)},un=globalThis.AbortController,dn=globalThis.AbortSignal;if(typeof un>`u`){dn=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},un=class{constructor(){t()}signal=new dn;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e=cn.env?.LRU_CACHE_IGNORE_AC_WARNING!==`1`,t=()=>{e&&(e=!1,ln("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",`NO_ABORT_CONTROLLER`,`ENOTSUP`,t))}}var fn=e=>!sn.has(e),pn=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),mn=e=>pn(e)?e<=256?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?hn:null:null,hn=class extends Array{constructor(e){super(e),this.fill(0)}},gn=class e{heap;length;static#e=!1;static create(t){let n=mn(t);if(!n)return[];e.#e=!0;let r=new e(t,n);return e.#e=!1,r}constructor(t,n){if(!e.#e)throw TypeError(`instantiate Stack using Stack.create(n)`);this.heap=new n(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},_n=class e{#e;#t;#n;#r;#i;#a;#o;#s;get perf(){return this.#s}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;static unsafeExposeInternals(e){return{starts:e.#b,ttls:e.#x,autopurgeTimers:e.#S,sizes:e.#y,keyMap:e.#u,keyList:e.#d,valList:e.#f,next:e.#p,prev:e.#m,get head(){return e.#h},get tail(){return e.#g},free:e.#_,isBackgroundFetch:t=>e.#V(t),backgroundFetch:(t,n,r,i)=>e.#B(t,n,r,i),moveToTail:t=>e.#U(t),indexes:t=>e.#I(t),rindexes:t=>e.#L(t),isStale:t=>e.#j(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#l}get size(){return this.#c}get fetchMethod(){return this.#a}get memoMethod(){return this.#o}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#i}constructor(t){let{max:n=0,ttl:r,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:c,dispose:l,onInsert:u,disposeAfter:d,noDisposeOnSet:f,noUpdateTTL:p,maxSize:m=0,maxEntrySize:ee=0,sizeCalculation:h,fetchMethod:g,memoMethod:_,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:te,allowStaleOnFetchRejection:ne,allowStaleOnFetchAbort:y,ignoreFetchAbort:b,perf:re}=t;if(re!==void 0&&typeof re?.now!=`function`)throw TypeError(`perf option must have a now() method if specified`);if(this.#s=re??on,n!==0&&!pn(n))throw TypeError(`max option must be a nonnegative integer`);let x=n?mn(n):Array;if(!x)throw Error(`invalid max value: `+n);if(this.#e=n,this.#t=m,this.maxEntrySize=ee||this.#t,this.sizeCalculation=h,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(_!==void 0&&typeof _!=`function`)throw TypeError(`memoMethod must be a function if defined`);if(this.#o=_,g!==void 0&&typeof g!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.#a=g,this.#w=!!g,this.#u=/* @__PURE__ */ new Map,this.#d=Array(n).fill(void 0),this.#f=Array(n).fill(void 0),this.#p=new x(n),this.#m=new x(n),this.#h=0,this.#g=0,this.#_=gn.create(n),this.#c=0,this.#l=0,typeof l==`function`&&(this.#n=l),typeof u==`function`&&(this.#r=u),typeof d==`function`?(this.#i=d,this.#v=[]):(this.#i=void 0,this.#v=void 0),this.#C=!!this.#n,this.#E=!!this.#r,this.#T=!!this.#i,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!ne,this.allowStaleOnFetchAbort=!!y,this.ignoreFetchAbort=!!b,this.maxEntrySize!==0){if(this.#t!==0&&!pn(this.#t))throw TypeError(`maxSize must be a positive integer if specified`);if(!pn(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.#M()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!te,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=pn(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!pn(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.#D()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t=`LRU_CACHE_UNBOUNDED`;fn(t)&&(sn.add(t),ln(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,t,e))}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#D(){let e=new hn(this.#e),t=new hn(this.#e);this.#x=e,this.#b=t;let n=this.ttlAutopurge?Array(this.#e):void 0;this.#S=n,this.#A=(r,i,a=this.#s.now())=>{if(t[r]=i===0?0:a,e[r]=i,n?.[r]&&(clearTimeout(n[r]),n[r]=void 0),i!==0&&n){let e=setTimeout(()=>{this.#j(r)&&this.#W(this.#d[r],`expire`)},i+1);e.unref&&e.unref(),n[r]=e}},this.#O=n=>{t[n]=e[n]===0?0:this.#s.now()},this.#k=(n,a)=>{if(e[a]){let o=e[a],s=t[a];if(!o||!s)return;n.ttl=o,n.start=s,n.now=r||i(),n.remainingTTL=o-(n.now-s)}};let r=0,i=()=>{let e=this.#s.now();if(this.ttlResolution>0){r=e;let t=setTimeout(()=>r=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=n=>{let a=this.#u.get(n);if(a===void 0)return 0;let o=e[a],s=t[a];return!o||!s?1/0:o-((r||i())-s)},this.#j=n=>{let a=t[n],o=e[n];return!!o&&!!a&&(r||i())-a>o}}#O=()=>{};#k=()=>{};#A=()=>{};#j=()=>!1;#M(){let e=new hn(this.#e);this.#l=0,this.#y=e,this.#N=t=>{this.#l-=e[t],e[t]=0},this.#F=(e,t,n,r)=>{if(this.#V(t))return 0;if(!pn(n)){if(r){if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!pn(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`)}return n},this.#P=(t,n,r)=>{if(e[t]=n,this.#t){let n=this.#t-e[t];for(;this.#l>n;)this.#z(!0)}this.#l+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#N=e=>{};#P=(e,t,n)=>{};#F=(e,t,n,r)=>{if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`);return 0};*#I({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#g;!(!this.#R(t)||((e||!this.#j(t))&&(yield t),t===this.#h));)t=this.#m[t]}*#L({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#h;!(!this.#R(t)||((e||!this.#j(t))&&(yield t),t===this.#g));)t=this.#p[t]}#R(e){return e!==void 0&&this.#u.get(this.#d[e])===e}*entries(){for(let e of this.#I())this.#f[e]!==void 0&&this.#d[e]!==void 0&&!this.#V(this.#f[e])&&(yield[this.#d[e],this.#f[e]])}*rentries(){for(let e of this.#L())this.#f[e]!==void 0&&this.#d[e]!==void 0&&!this.#V(this.#f[e])&&(yield[this.#d[e],this.#f[e]])}*keys(){for(let e of this.#I()){let t=this.#d[e];t!==void 0&&!this.#V(this.#f[e])&&(yield t)}}*rkeys(){for(let e of this.#L()){let t=this.#d[e];t!==void 0&&!this.#V(this.#f[e])&&(yield t)}}*values(){for(let e of this.#I())this.#f[e]!==void 0&&!this.#V(this.#f[e])&&(yield this.#f[e])}*rvalues(){for(let e of this.#L())this.#f[e]!==void 0&&!this.#V(this.#f[e])&&(yield this.#f[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]=`LRUCache`;find(e,t={}){for(let n of this.#I()){let r=this.#f[n],i=this.#V(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.#d[n],this))return this.get(this.#d[n],t)}}forEach(e,t=this){for(let n of this.#I()){let r=this.#f[n],i=this.#V(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#d[n],this)}}rforEach(e,t=this){for(let n of this.#L()){let r=this.#f[n],i=this.#V(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#d[n],this)}}purgeStale(){let e=!1;for(let t of this.#L({allowStale:!0}))this.#j(t)&&(this.#W(this.#d[t],`expire`),e=!0);return e}info(e){let t=this.#u.get(e);if(t===void 0)return;let n=this.#f[t],r=this.#V(n)?n.__staleWhileFetching:n;if(r===void 0)return;let i={value:r};if(this.#x&&this.#b){let e=this.#x[t],n=this.#b[t];e&&n&&(i.ttl=e-(this.#s.now()-n),i.start=Date.now())}return this.#y&&(i.size=this.#y[t]),i}dump(){let e=[];for(let t of this.#I({allowStale:!0})){let n=this.#d[t],r=this.#f[t],i=this.#V(r)?r.__staleWhileFetching:r;if(i===void 0||n===void 0)continue;let a={value:i};if(this.#x&&this.#b){a.ttl=this.#x[t];let e=this.#s.now()-this.#b[t];a.start=Math.floor(Date.now()-e)}this.#y&&(a.size=this.#y[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=this.#s.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:i,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:s}=n,{noUpdateTTL:c=this.noUpdateTTL}=n,l=this.#F(e,t,n.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return s&&(s.set=`miss`,s.maxEntrySizeExceeded=!0),this.#W(e,`set`),this;let u=this.#c===0?void 0:this.#u.get(e);if(u===void 0)u=this.#c===0?this.#g:this.#_.length===0?this.#c===this.#e?this.#z(!1):this.#c:this.#_.pop(),this.#d[u]=e,this.#f[u]=t,this.#u.set(e,u),this.#p[this.#g]=u,this.#m[u]=this.#g,this.#g=u,this.#c++,this.#P(u,l,s),s&&(s.set=`add`),c=!1,this.#E&&this.#r?.(t,e,`add`);else{this.#U(u);let n=this.#f[u];if(t!==n){if(this.#w&&this.#V(n)){n.__abortController.abort(/* @__PURE__ */ Error(`replaced`));let{__staleWhileFetching:t}=n;t!==void 0&&!a&&(this.#C&&this.#n?.(t,e,`set`),this.#T&&this.#v?.push([t,e,`set`]))}else a||(this.#C&&this.#n?.(n,e,`set`),this.#T&&this.#v?.push([n,e,`set`]));if(this.#N(u),this.#P(u,l,s),this.#f[u]=t,s){s.set=`replace`;let e=n&&this.#V(n)?n.__staleWhileFetching:n;e!==void 0&&(s.oldValue=e)}}else s&&(s.set=`update`);this.#E&&this.onInsert?.(t,e,t===n?`update`:`replace`)}if(r!==0&&!this.#x&&this.#D(),this.#x&&(c||this.#A(u,r,i),s&&this.#k(s,u)),!a&&this.#T&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}return this}pop(){try{for(;this.#c;){let e=this.#f[this.#h];if(this.#z(!0),this.#V(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#T&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}}}#z(e){let t=this.#h,n=this.#d[t],r=this.#f[t];return this.#w&&this.#V(r)?r.__abortController.abort(/* @__PURE__ */ Error(`evicted`)):(this.#C||this.#T)&&(this.#C&&this.#n?.(r,n,`evict`),this.#T&&this.#v?.push([r,n,`evict`])),this.#N(t),this.#S?.[t]&&(clearTimeout(this.#S[t]),this.#S[t]=void 0),e&&(this.#d[t]=void 0,this.#f[t]=void 0,this.#_.push(t)),this.#c===1?(this.#h=this.#g=0,this.#_.length=0):this.#h=this.#p[t],this.#u.delete(n),this.#c--,t}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,i=this.#u.get(e);if(i!==void 0){let e=this.#f[i];if(this.#V(e)&&e.__staleWhileFetching===void 0)return!1;if(this.#j(i))r&&(r.has=`stale`,this.#k(r,i));else return n&&this.#O(i),r&&(r.has=`hit`,this.#k(r,i)),!0}else r&&(r.has=`miss`);return!1}peek(e,t={}){let{allowStale:n=this.allowStale}=t,r=this.#u.get(e);if(r===void 0||!n&&this.#j(r))return;let i=this.#f[r];return this.#V(i)?i.__staleWhileFetching:i}#B(e,t,n,r){let i=t===void 0?void 0:this.#f[t];if(this.#V(i))return i;let a=new un,{signal:o}=n;o?.addEventListener(`abort`,()=>a.abort(o.reason),{signal:a.signal});let s={signal:a.signal,options:n,context:r},c=(r,i=!1)=>{let{aborted:o}=a.signal,c=n.ignoreFetchAbort&&r!==void 0,l=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&r!==void 0);if(n.status&&(o&&!i?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!c&&!i)return u(a.signal.reason,l);let d=f,p=this.#f[t];return(p===f||c&&i&&p===void 0)&&(r===void 0?d.__staleWhileFetching===void 0?this.#W(e,`fetch`):this.#f[t]=d.__staleWhileFetching:(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,s.options))),r},l=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),u(e,!1)),u=(r,i)=>{let{aborted:o}=a.signal,s=o&&n.allowStaleOnFetchAbort,c=s||n.allowStaleOnFetchRejection,l=c||n.noDeleteOnFetchRejection,u=f;if(this.#f[t]===f&&(!l||!i&&u.__staleWhileFetching===void 0?this.#W(e,`fetch`):s||(this.#f[t]=u.__staleWhileFetching)),c)return n.status&&u.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw r},d=(t,r)=>{let o=this.#a?.(e,i,s);o&&o instanceof Promise&&o.then(e=>t(e===void 0?void 0:e),r),a.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let f=new Promise(d).then(c,l),p=Object.assign(f,{__abortController:a,__staleWhileFetching:i,__returned:void 0});return t===void 0?(this.set(e,p,{...s.options,status:void 0}),t=this.#u.get(e)):this.#f[t]=p,p}#V(e){if(!this.#w)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty(`__staleWhileFetching`)&&t.__abortController instanceof un}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:s=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:ee=!1,status:h,signal:g}=t;if(!this.#w)return h&&(h.fetch=`get`),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:h});let _={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:a,noDisposeOnSet:o,size:s,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:p,ignoreFetchAbort:f,status:h,signal:g},v=this.#u.get(e);if(v===void 0){h&&(h.fetch=`miss`);let t=this.#B(e,v,_,m);return t.__returned=t}{let t=this.#f[v];if(this.#V(t)){let e=n&&t.__staleWhileFetching!==void 0;return h&&(h.fetch=`inflight`,e&&(h.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#j(v);if(!ee&&!i)return h&&(h.fetch=`hit`),this.#U(v),r&&this.#O(v),h&&this.#k(h,v),t;let a=this.#B(e,v,_,m),o=a.__staleWhileFetching!==void 0&&n;return h&&(h.fetch=i?`stale`:`refresh`,o&&i&&(h.returnedStale=!0)),o?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw Error(`fetch() returned undefined`);return n}memo(e,t={}){let n=this.#o;if(!n)throw Error(`no memoMethod provided to constructor`);let{context:r,forceRefresh:i,...a}=t,o=this.get(e,a);if(!i&&o!==void 0)return o;let s=n(e,o,{options:a,context:r});return this.set(e,s,a),s}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:a}=t,o=this.#u.get(e);if(o!==void 0){let t=this.#f[o],s=this.#V(t);return a&&this.#k(a,o),this.#j(o)?(a&&(a.get=`stale`),s?(a&&n&&t.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?t.__staleWhileFetching:void 0):(i||this.#W(e,`expire`),a&&n&&(a.returnedStale=!0),n?t:void 0)):(a&&(a.get=`hit`),s?t.__staleWhileFetching:(this.#U(o),r&&this.#O(o),t))}a&&(a.get=`miss`)}#H(e,t){this.#m[t]=e,this.#p[e]=t}#U(e){e!==this.#g&&(e===this.#h?this.#h=this.#p[e]:this.#H(this.#m[e],this.#p[e]),this.#H(this.#g,e),this.#g=e)}delete(e){return this.#W(e,`delete`)}#W(e,t){let n=!1;if(this.#c!==0){let r=this.#u.get(e);if(r!==void 0){if(this.#S?.[r]&&(clearTimeout(this.#S?.[r]),this.#S[r]=void 0),n=!0,this.#c===1)this.#G(t);else{this.#N(r);let n=this.#f[r];if(this.#V(n)?n.__abortController.abort(/* @__PURE__ */ Error(`deleted`)):(this.#C||this.#T)&&(this.#C&&this.#n?.(n,e,t),this.#T&&this.#v?.push([n,e,t])),this.#u.delete(e),this.#d[r]=void 0,this.#f[r]=void 0,r===this.#g)this.#g=this.#m[r];else if(r===this.#h)this.#h=this.#p[r];else{let e=this.#m[r];this.#p[e]=this.#p[r];let t=this.#p[r];this.#m[t]=this.#m[r]}this.#c--,this.#_.push(r)}}}if(this.#T&&this.#v?.length){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}return n}clear(){return this.#G(`delete`)}#G(e){for(let t of this.#L({allowStale:!0})){let n=this.#f[t];if(this.#V(n))n.__abortController.abort(/* @__PURE__ */ Error(`deleted`));else{let r=this.#d[t];this.#C&&this.#n?.(n,r,e),this.#T&&this.#v?.push([n,r,e])}}if(this.#u.clear(),this.#f.fill(void 0),this.#d.fill(void 0),this.#x&&this.#b){this.#x.fill(0),this.#b.fill(0);for(let e of this.#S??[])e!==void 0&&clearTimeout(e);this.#S?.fill(void 0)}if(this.#y&&this.#y.fill(0),this.#h=0,this.#g=0,this.#_.length=0,this.#l=0,this.#c=0,this.#T&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}}},vn=typeof process==`object`&&process?process:{stdout:null,stderr:null},yn=e=>!!e&&typeof e==`object`&&(e instanceof er||e instanceof ke||bn(e)||xn(e)),bn=e=>!!e&&typeof e==`object`&&e instanceof Oe&&typeof e.pipe==`function`&&e.pipe!==ke.Writable.prototype.pipe,xn=e=>!!e&&typeof e==`object`&&e instanceof Oe&&typeof e.write==`function`&&typeof e.end==`function`,Sn=Symbol(`EOF`),Cn=Symbol(`maybeEmitEnd`),wn=Symbol(`emittedEnd`),Tn=Symbol(`emittingEnd`),En=Symbol(`emittedError`),Dn=Symbol(`closed`),On=Symbol(`read`),kn=Symbol(`flush`),An=Symbol(`flushChunk`),R=Symbol(`encoding`),jn=Symbol(`decoder`),z=Symbol(`flowing`),Mn=Symbol(`paused`),Nn=Symbol(`resume`),B=Symbol(`buffer`),V=Symbol(`pipes`),H=Symbol(`bufferLength`),Pn=Symbol(`bufferPush`),Fn=Symbol(`bufferShift`),U=Symbol(`objectMode`),W=Symbol(`destroyed`),In=Symbol(`error`),Ln=Symbol(`emitData`),Rn=Symbol(`emitEnd`),zn=Symbol(`emitEnd2`),Bn=Symbol(`async`),Vn=Symbol(`abort`),Hn=Symbol(`aborted`),Un=Symbol(`signal`),Wn=Symbol(`dataListeners`),G=Symbol(`discarded`),Gn=e=>Promise.resolve().then(e),Kn=e=>e(),qn=e=>e===`end`||e===`finish`||e===`prefinish`,Jn=e=>e instanceof ArrayBuffer||!!e&&typeof e==`object`&&e.constructor&&e.constructor.name===`ArrayBuffer`&&e.byteLength>=0,Yn=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Xn=class{src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[Nn](),this.dest.on(`drain`,this.ondrain)}unpipe(){this.dest.removeListener(`drain`,this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Zn=class extends Xn{unpipe(){this.src.removeListener(`error`,this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=e=>this.dest.emit(`error`,e),e.on(`error`,this.proxyErrors)}},Qn=e=>!!e.objectMode,$n=e=>!e.objectMode&&!!e.encoding&&e.encoding!==`buffer`,er=class extends Oe{[z]=!1;[Mn]=!1;[V]=[];[B]=[];[U];[R];[Bn];[jn];[Sn]=!1;[wn]=!1;[Tn]=!1;[Dn]=!1;[En]=null;[H]=0;[W]=!1;[Un];[Hn]=!1;[Wn]=0;[G]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding==`string`)throw TypeError(`Encoding and objectMode may not be used together`);Qn(t)?(this[U]=!0,this[R]=null):$n(t)?(this[R]=t.encoding,this[U]=!1):(this[U]=!1,this[R]=null),this[Bn]=!!t.async,this[jn]=this[R]?new Ae(this[R]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[B]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[V]});let{signal:n}=t;n&&(this[Un]=n,n.aborted?this[Vn]():n.addEventListener(`abort`,()=>this[Vn]()))}get bufferLength(){return this[H]}get encoding(){return this[R]}set encoding(e){throw Error(`Encoding must be set at instantiation time`)}setEncoding(e){throw Error(`Encoding must be set at instantiation time`)}get objectMode(){return this[U]}set objectMode(e){throw Error(`objectMode must be set at instantiation time`)}get async(){return this[Bn]}set async(e){this[Bn]=this[Bn]||!!e}[Vn](){this[Hn]=!0,this.emit(`abort`,this[Un]?.reason),this.destroy(this[Un]?.reason)}get aborted(){return this[Hn]}set aborted(e){}write(e,t,n){if(this[Hn])return!1;if(this[Sn])throw Error(`write after end`);if(this[W])return this.emit(`error`,Object.assign(/* @__PURE__ */ Error(`Cannot call write after a stream was destroyed`),{code:`ERR_STREAM_DESTROYED`})),!0;typeof t==`function`&&(n=t,t=`utf8`),t||=`utf8`;let r=this[Bn]?Gn:Kn;if(!this[U]&&!Buffer.isBuffer(e)){if(Yn(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Jn(e))e=Buffer.from(e);else if(typeof e!=`string`)throw Error(`Non-contiguous data written to non-objectMode stream`)}return this[U]?(this[z]&&this[H]!==0&&this[kn](!0),this[z]?this.emit(`data`,e):this[Pn](e),this[H]!==0&&this.emit(`readable`),n&&r(n),this[z]):e.length?(typeof e==`string`&&(t!==this[R]||this[jn]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[R]&&(e=this[jn].write(e)),this[z]&&this[H]!==0&&this[kn](!0),this[z]?this.emit(`data`,e):this[Pn](e),this[H]!==0&&this.emit(`readable`),n&&r(n),this[z]):(this[H]!==0&&this.emit(`readable`),n&&r(n),this[z])}read(e){if(this[W])return null;if(this[G]=!1,this[H]===0||e===0||e&&e>this[H])return this[Cn](),null;this[U]&&(e=null),this[B].length>1&&!this[U]&&(this[B]=[this[R]?this[B].join(``):Buffer.concat(this[B],this[H])]);let t=this[On](e||null,this[B][0]);return this[Cn](),t}[On](e,t){if(this[U])this[Fn]();else{let n=t;e===n.length||e===null?this[Fn]():typeof n==`string`?(this[B][0]=n.slice(e),t=n.slice(0,e),this[H]-=e):(this[B][0]=n.subarray(e),t=n.subarray(0,e),this[H]-=e)}return this.emit(`data`,t),!this[B].length&&!this[Sn]&&this.emit(`drain`),t}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=`utf8`),e!==void 0&&this.write(e,t),n&&this.once(`end`,n),this[Sn]=!0,this.writable=!1,(this[z]||!this[Mn])&&this[Cn](),this}[Nn](){this[W]||(!this[Wn]&&!this[V].length&&(this[G]=!0),this[Mn]=!1,this[z]=!0,this.emit(`resume`),this[B].length?this[kn]():this[Sn]?this[Cn]():this.emit(`drain`))}resume(){return this[Nn]()}pause(){this[z]=!1,this[Mn]=!0,this[G]=!1}get destroyed(){return this[W]}get flowing(){return this[z]}get paused(){return this[Mn]}[Pn](e){this[U]?this[H]+=1:this[H]+=e.length,this[B].push(e)}[Fn](){return this[U]?--this[H]:this[H]-=this[B][0].length,this[B].shift()}[kn](e=!1){do;while(this[An](this[Fn]())&&this[B].length);!e&&!this[B].length&&!this[Sn]&&this.emit(`drain`)}[An](e){return this.emit(`data`,e),this[z]}pipe(e,t){if(this[W])return e;this[G]=!1;let n=this[wn];return t||={},e===vn.stdout||e===vn.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,n?t.end&&e.end():(this[V].push(t.proxyErrors?new Zn(this,e,t):new Xn(this,e,t)),this[Bn]?Gn(()=>this[Nn]()):this[Nn]()),e}unpipe(e){let t=this[V].find(t=>t.dest===e);t&&(this[V].length===1?(this[z]&&this[Wn]===0&&(this[z]=!1),this[V]=[]):this[V].splice(this[V].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e===`data`)this[G]=!1,this[Wn]++,!this[V].length&&!this[z]&&this[Nn]();else if(e===`readable`&&this[H]!==0)super.emit(`readable`);else if(qn(e)&&this[wn])super.emit(e),this.removeAllListeners(e);else if(e===`error`&&this[En]){let e=t;this[Bn]?Gn(()=>e.call(this,this[En])):e.call(this,this[En])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e===`data`&&(this[Wn]=this.listeners(`data`).length,this[Wn]===0&&!this[G]&&!this[V].length&&(this[z]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e===`data`||e===void 0)&&(this[Wn]=0,!this[G]&&!this[V].length&&(this[z]=!1)),t}get emittedEnd(){return this[wn]}[Cn](){!this[Tn]&&!this[wn]&&!this[W]&&this[B].length===0&&this[Sn]&&(this[Tn]=!0,this.emit(`end`),this.emit(`prefinish`),this.emit(`finish`),this[Dn]&&this.emit(`close`),this[Tn]=!1)}emit(e,...t){let n=t[0];if(e!==`error`&&e!==`close`&&e!==W&&this[W])return!1;if(e===`data`)return!this[U]&&!n?!1:this[Bn]?(Gn(()=>this[Ln](n)),!0):this[Ln](n);if(e===`end`)return this[Rn]();if(e===`close`){if(this[Dn]=!0,!this[wn]&&!this[W])return!1;let e=super.emit(`close`);return this.removeAllListeners(`close`),e}if(e===`error`){this[En]=n,super.emit(In,n);let e=!this[Un]||this.listeners(`error`).length?super.emit(`error`,n):!1;return this[Cn](),e}if(e===`resume`){let e=super.emit(`resume`);return this[Cn](),e}if(e===`finish`||e===`prefinish`){let t=super.emit(e);return this.removeAllListeners(e),t}let r=super.emit(e,...t);return this[Cn](),r}[Ln](e){for(let t of this[V])t.dest.write(e)===!1&&this.pause();let t=!this[G]&&super.emit(`data`,e);return this[Cn](),t}[Rn](){return!this[wn]&&(this[wn]=!0,this.readable=!1,this[Bn]?(Gn(()=>this[zn]()),!0):this[zn]())}[zn](){if(this[jn]){let e=this[jn].end();if(e){for(let t of this[V])t.dest.write(e);this[G]||super.emit(`data`,e)}}for(let e of this[V])e.end();let e=super.emit(`end`);return this.removeAllListeners(`end`),e}async collect(){let e=Object.assign([],{dataLength:0});this[U]||(e.dataLength=0);let t=this.promise();return this.on(`data`,t=>{e.push(t),this[U]||(e.dataLength+=t.length)}),await t,e}async concat(){if(this[U])throw Error(`cannot concat in objectMode`);let e=await this.collect();return this[R]?e.join(``):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(W,()=>t(/* @__PURE__ */ Error(`stream destroyed`))),this.on(`error`,e=>t(e)),this.on(`end`,()=>e())})}[Symbol.asyncIterator](){this[G]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[Sn])return t();let r,i,a=e=>{this.off(`data`,o),this.off(`end`,s),this.off(W,c),t(),i(e)},o=e=>{this.off(`error`,a),this.off(`end`,s),this.off(W,c),this.pause(),r({value:e,done:!!this[Sn]})},s=()=>{this.off(`error`,a),this.off(`data`,o),this.off(W,c),t(),r({done:!0,value:void 0})},c=()=>a(/* @__PURE__ */ Error(`stream destroyed`));return new Promise((e,t)=>{i=t,r=e,this.once(W,c),this.once(`error`,a),this.once(`end`,s),this.once(`data`,o)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[G]=!1;let e=!1,t=()=>(this.pause(),this.off(In,t),this.off(W,t),this.off(`end`,t),e=!0,{done:!0,value:void 0});return this.once(`end`,t),this.once(In,t),this.once(W,t),{next:()=>{if(e)return t();let n=this.read();return n===null?t():{done:!1,value:n}},throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[W])return e?this.emit(`error`,e):this.emit(W),this;this[W]=!0,this[G]=!0,this[B].length=0,this[H]=0;let t=this;return typeof t.close==`function`&&!this[Dn]&&t.close(),e?this.emit(`error`,e):this.emit(W),this}static get isStream(){return yn}},tr=Se.native,nr={lstatSync:_e,readdir:ye,readdirSync:be,readlinkSync:xe,realpathSync:tr,promises:{lstat:ue,readdir:de,readlink:fe,realpath:pe}},rr=e=>!e||e===nr||e===x?nr:{...nr,...e,promises:{...nr.promises,...e.promises||{}}},ir=/^\\\\\?\\([a-z]:)\\?$/i,ar=e=>e.replace(/\//g,`\\`).replace(ir,`$1\\`),or=/[\\\/]/,K=0,sr=1,cr=2,lr=4,ur=6,dr=8,fr=10,pr=12,q=15,mr=~q,hr=16,gr=32,_r=64,vr=128,yr=256,br=512,xr=_r|vr|br,Sr=1023,Cr=e=>e.isFile()?dr:e.isDirectory()?lr:e.isSymbolicLink()?fr:e.isCharacterDevice()?cr:e.isBlockDevice()?ur:e.isSocket()?pr:e.isFIFO()?sr:K,wr=new _n({max:4096}),Tr=e=>{let t=wr.get(e);if(t)return t;let n=e.normalize(`NFKD`);return wr.set(e,n),n},Er=new _n({max:4096}),Dr=e=>{let t=Er.get(e);if(t)return t;let n=Tr(e.toLowerCase());return Er.set(e,n),n},Or=class extends _n{constructor(){super({max:256})}},kr=class extends _n{constructor(e=16384){super({maxSize:e,sizeCalculation:e=>e.length+1})}},Ar=Symbol(`PathScurry setAsCwd`),J=class{name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#i;get uid(){return this.#i}#a;get gid(){return this.#a}#o;get rdev(){return this.#o}#s;get blksize(){return this.#s}#c;get ino(){return this.#c}#l;get size(){return this.#l}#u;get blocks(){return this.#u}#d;get atimeMs(){return this.#d}#f;get mtimeMs(){return this.#f}#p;get ctimeMs(){return this.#p}#m;get birthtimeMs(){return this.#m}#h;get atime(){return this.#h}#g;get mtime(){return this.#g}#_;get ctime(){return this.#_}#v;get birthtime(){return this.#v}#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=K,n,r,i,a,o){this.name=e,this.#y=i?Dr(e):Tr(e),this.#T=t&Sr,this.nocase=i,this.roots=r,this.root=n||this,this.#E=a,this.#x=o.fullpath,this.#C=o.relative,this.#w=o.relativePosix,this.parent=o.parent,this.#e=this.parent?this.parent.#e:rr(o.fs)}depth(){return this.#b===void 0?this.#b=this.parent?this.parent.depth()+1:0:this.#b}childrenCache(){return this.#E}resolve(e){if(!e)return this;let t=this.getRootString(e),n=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#k(n):this.#k(n)}#k(e){let t=this;for(let n of e)t=t.child(n);return t}children(){let e=this.#E.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#E.set(this,t),this.#T&=~hr,t}child(e,t){if(e===``||e===`.`)return this;if(e===`..`)return this.parent||this;let n=this.children(),r=this.nocase?Dr(e):Tr(e);for(let e of n)if(e.#y===r)return e;let i=this.parent?this.sep:``,a=this.#x?this.#x+i+e:void 0,o=this.newChild(e,K,{...t,parent:this,fullpath:a});return this.canReaddir()||(o.#T|=vr),n.push(o),o}relative(){if(this.isCWD)return``;if(this.#C!==void 0)return this.#C;let e=this.name,t=this.parent;if(!t)return this.#C=this.name;let n=t.relative();return n+(!n||!t.parent?``:this.sep)+e}relativePosix(){if(this.sep===`/`)return this.relative();if(this.isCWD)return``;if(this.#w!==void 0)return this.#w;let e=this.name,t=this.parent;if(!t)return this.#w=this.fullpathPosix();let n=t.relativePosix();return n+(!n||!t.parent?``:`/`)+e}fullpath(){if(this.#x!==void 0)return this.#x;let e=this.name,t=this.parent;if(!t)return this.#x=this.name;let n=t.fullpath()+(t.parent?this.sep:``)+e;return this.#x=n}fullpathPosix(){if(this.#S!==void 0)return this.#S;if(this.sep===`/`)return this.#S=this.fullpath();if(!this.parent){let e=this.fullpath().replace(/\\/g,`/`);return this.#S=/^[a-z]:\//i.test(e)?`//?/${e}`:e}let e=this.parent,t=e.fullpathPosix(),n=t+(!t||!e.parent?``:`/`)+this.name;return this.#S=n}isUnknown(){return(this.#T&q)===K}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?`Unknown`:this.isDirectory()?`Directory`:this.isFile()?`File`:this.isSymbolicLink()?`SymbolicLink`:this.isFIFO()?`FIFO`:this.isCharacterDevice()?`CharacterDevice`:this.isBlockDevice()?`BlockDevice`:this.isSocket()?`Socket`:`Unknown`}isFile(){return(this.#T&q)===dr}isDirectory(){return(this.#T&q)===lr}isCharacterDevice(){return(this.#T&q)===cr}isBlockDevice(){return(this.#T&q)===ur}isFIFO(){return(this.#T&q)===sr}isSocket(){return(this.#T&q)===pr}isSymbolicLink(){return(this.#T&fr)===fr}lstatCached(){return this.#T&gr?this:void 0}readlinkCached(){return this.#D}realpathCached(){return this.#O}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#D)return!0;if(!this.parent)return!1;let e=this.#T&q;return!(e!==K&&e!==fr||this.#T&yr||this.#T&vr)}calledReaddir(){return!!(this.#T&hr)}isENOENT(){return!!(this.#T&vr)}isNamed(e){return this.nocase?this.#y===Dr(e):this.#y===Tr(e)}async readlink(){let e=this.#D;if(e)return e;if(this.canReadlink()&&this.parent)try{let e=await this.#e.promises.readlink(this.fullpath()),t=(await this.parent.realpath())?.resolve(e);if(t)return this.#D=t}catch(e){this.#L(e.code);return}}readlinkSync(){let e=this.#D;if(e)return e;if(this.canReadlink()&&this.parent)try{let e=this.#e.readlinkSync(this.fullpath()),t=this.parent.realpathSync()?.resolve(e);if(t)return this.#D=t}catch(e){this.#L(e.code);return}}#A(e){this.#T|=hr;for(let t=e.provisional;t<e.length;t++){let n=e[t];n&&n.#j()}}#j(){this.#T&vr||(this.#T=(this.#T|vr)&mr,this.#M())}#M(){let e=this.children();e.provisional=0;for(let t of e)t.#j()}#N(){this.#T|=br,this.#P()}#P(){if(this.#T&_r)return;let e=this.#T;(e&q)===lr&&(e&=mr),this.#T=e|_r,this.#M()}#F(e=``){e===`ENOTDIR`||e===`EPERM`?this.#P():e===`ENOENT`?this.#j():this.children().provisional=0}#I(e=``){e===`ENOTDIR`?this.parent.#P():e===`ENOENT`&&this.#j()}#L(e=``){let t=this.#T;t|=yr,e===`ENOENT`&&(t|=vr),(e===`EINVAL`||e===`UNKNOWN`)&&(t&=mr),this.#T=t,e===`ENOTDIR`&&this.parent&&this.parent.#P()}#R(e,t){return this.#B(e,t)||this.#z(e,t)}#z(e,t){let n=Cr(e),r=this.newChild(e.name,n,{parent:this}),i=r.#T&q;return i!==lr&&i!==fr&&i!==K&&(r.#T|=_r),t.unshift(r),t.provisional++,r}#B(e,t){for(let n=t.provisional;n<t.length;n++){let r=t[n];if((this.nocase?Dr(e.name):Tr(e.name))===r.#y)return this.#V(e,r,n,t)}}#V(e,t,n,r){let i=t.name;return t.#T=t.#T&mr|Cr(e),i!==e.name&&(t.name=e.name),n!==r.provisional&&(n===r.length-1?r.pop():r.splice(n,1),r.unshift(t)),r.provisional++,t}async lstat(){if((this.#T&vr)===0)try{return this.#H(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#I(e.code)}}lstatSync(){if((this.#T&vr)===0)try{return this.#H(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#I(e.code)}}#H(e){let{atime:t,atimeMs:n,birthtime:r,birthtimeMs:i,blksize:a,blocks:o,ctime:s,ctimeMs:c,dev:l,gid:u,ino:d,mode:f,mtime:p,mtimeMs:m,nlink:ee,rdev:h,size:g,uid:_}=e;this.#h=t,this.#d=n,this.#v=r,this.#m=i,this.#s=a,this.#u=o,this.#_=s,this.#p=c,this.#t=l,this.#a=u,this.#c=d,this.#n=f,this.#g=p,this.#f=m,this.#r=ee,this.#o=h,this.#l=g,this.#i=_;let v=Cr(e);this.#T=this.#T&mr|v|gr,v!==K&&v!==lr&&v!==fr&&(this.#T|=_r)}#U=[];#W=!1;#G(e){this.#W=!1;let t=this.#U.slice();this.#U.length=0,t.forEach(t=>t(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let n=this.children();if(this.calledReaddir()){let r=n.slice(0,n.provisional);t?e(null,r):queueMicrotask(()=>e(null,r));return}if(this.#U.push(e),this.#W)return;this.#W=!0;let r=this.fullpath();this.#e.readdir(r,{withFileTypes:!0},(e,t)=>{if(e)this.#F(e.code),n.provisional=0;else{for(let e of t)this.#R(e,n);this.#A(n)}this.#G(n.slice(0,n.provisional))})}#K;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#K)await this.#K;else{let n=()=>{};this.#K=new Promise(e=>n=e);try{for(let n of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#R(n,e);this.#A(e)}catch(t){this.#F(t.code),e.provisional=0}this.#K=void 0,n()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let n of this.#e.readdirSync(t,{withFileTypes:!0}))this.#R(n,e);this.#A(e)}catch(t){this.#F(t.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#T&xr)return!1;let e=q&this.#T;return e===K||e===lr||e===fr}shouldWalk(e,t){return(this.#T&lr)===lr&&!(this.#T&xr)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#O)return this.#O;if(!((br|yr|vr)&this.#T))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#O=this.resolve(e)}catch{this.#N()}}realpathSync(){if(this.#O)return this.#O;if(!((br|yr|vr)&this.#T))try{let e=this.#e.realpathSync(this.fullpath());return this.#O=this.resolve(e)}catch{this.#N()}}[Ar](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=/* @__PURE__ */ new Set([]),n=[],r=this;for(;r&&r.parent;)t.add(r),r.#C=n.join(this.sep),r.#w=n.join(`/`),r=r.parent,n.push(`..`);for(r=e;r&&r.parent&&!t.has(r);)r.#C=void 0,r.#w=void 0,r=r.parent}},jr=class e extends J{sep=`\\`;splitSep=or;constructor(e,t=K,n,r,i,a,o){super(e,t,n,r,i,a,o)}newChild(t,n=K,r={}){return new e(t,n,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return w.parse(e).root}getRoot(e){if(e=ar(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,n]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=n;return this.roots[e]=new Pr(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,`\\`).replace(ir,`$1\\`),e===t}},Mr=class e extends J{splitSep=`/`;sep=`/`;constructor(e,t=K,n,r,i,a,o){super(e,t,n,r,i,a,o)}getRootString(e){return e.startsWith(`/`)?`/`:``}getRoot(e){return this.root}newChild(t,n=K,r={}){return new e(t,n,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Nr=class{root;rootPath;roots;cwd;#e;#t;#n;nocase;#r;constructor(e=process.cwd(),t,n,{nocase:r,childrenCacheSize:i=16384,fs:a=nr}={}){this.#r=rr(a),(e instanceof URL||e.startsWith(`file://`))&&(e=T(e));let o=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(o),this.#e=new Or,this.#t=new Or,this.#n=new kr(i);let s=o.substring(this.rootPath.length).split(n);if(s.length===1&&!s[0]&&s.pop(),r===void 0)throw TypeError(`must provide nocase setting to PathScurryBase ctor`);this.nocase=r,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let c=this.root,l=s.length-1,u=t.sep,d=this.rootPath,f=!1;for(let e of s){let t=l--;c=c.child(e,{relative:Array(t).fill(`..`).join(u),relativePosix:Array(t).fill(`..`).join(`/`),fullpath:d+=(f?``:u)+e}),f=!0}this.cwd=c}depth(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#n}resolve(...e){let t=``;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r&&r!==`.`&&(t=t?`${r}/${t}`:r,this.isAbsolute(r)))break}let n=this.#e.get(t);if(n!==void 0)return n;let r=this.cwd.resolve(t).fullpath();return this.#e.set(t,r),r}resolvePosix(...e){let t=``;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r&&r!==`.`&&(t=t?`${r}/${t}`:r,this.isAbsolute(r)))break}let n=this.#t.get(t);if(n!==void 0)return n;let r=this.cwd.resolve(t).fullpathPosix();return this.#t.set(t,r),r}relative(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e,e=this.cwd);let{withFileTypes:n}=t;if(e.canReaddir()){let t=await e.readdir();return n?t:t.map(e=>e.name)}return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e,e=this.cwd);let{withFileTypes:n=!0}=t;return e.canReaddir()?n?e.readdirSync():e.readdirSync().map(e=>e.name):[]}async lstat(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e.withFileTypes,e=this.cwd);let n=await e.readlink();return t?n:n?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e.withFileTypes,e=this.cwd);let n=e.readlinkSync();return t?n:n?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e.withFileTypes,e=this.cwd);let n=await e.realpath();return t?n:n?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e.withFileTypes,e=this.cwd);let n=e.realpathSync();return t?n:n?.fullpath()}async walk(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t,o=[];(!i||i(e))&&o.push(n?e:e.fullpath());let s=/* @__PURE__ */ new Set,c=(e,t)=>{s.add(e),e.readdirCB((e,l)=>{if(e)return t(e);let u=l.length;if(!u)return t();let d=()=>{--u===0&&t()};for(let e of l)(!i||i(e))&&o.push(n?e:e.fullpath()),r&&e.isSymbolicLink()?e.realpath().then(e=>e?.isUnknown()?e.lstat():e).then(e=>e?.shouldWalk(s,a)?c(e,d):d()):e.shouldWalk(s,a)?c(e,d):d()},!0)},l=e;return new Promise((e,t)=>{c(l,n=>{if(n)return t(n);e(o)})})}walkSync(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t,o=[];(!i||i(e))&&o.push(n?e:e.fullpath());let s=/* @__PURE__ */ new Set([e]);for(let e of s){let t=e.readdirSync();for(let e of t){(!i||i(e))&&o.push(n?e:e.fullpath());let t=e;if(e.isSymbolicLink()){if(!(r&&(t=e.realpathSync())))continue;t.isUnknown()&&t.lstatSync()}t.shouldWalk(s,a)&&s.add(t)}}return o}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t;(!i||i(e))&&(yield n?e:e.fullpath());let o=/* @__PURE__ */ new Set([e]);for(let e of o){let t=e.readdirSync();for(let e of t){(!i||i(e))&&(yield n?e:e.fullpath());let t=e;if(e.isSymbolicLink()){if(!(r&&(t=e.realpathSync())))continue;t.isUnknown()&&t.lstatSync()}t.shouldWalk(o,a)&&o.add(t)}}}stream(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t,o=new er({objectMode:!0});(!i||i(e))&&o.write(n?e:e.fullpath());let s=/* @__PURE__ */ new Set,c=[e],l=0,u=()=>{let e=!1;for(;!e;){let t=c.shift();if(!t){l===0&&o.end();return}l++,s.add(t);let d=(t,p,m=!1)=>{if(t)return o.emit(`error`,t);if(r&&!m){let e=[];for(let t of p)t.isSymbolicLink()&&e.push(t.realpath().then(e=>e?.isUnknown()?e.lstat():e));if(e.length){Promise.all(e).then(()=>d(null,p,!0));return}}for(let t of p)t&&(!i||i(t))&&(o.write(n?t:t.fullpath())||(e=!0));l--;for(let e of p){let t=e.realpathCached()||e;t.shouldWalk(s,a)&&c.push(t)}e&&!o.flowing?o.once(`drain`,u):f||u()},f=!0;t.readdirCB(d,!0),f=!1}};return u(),o}streamSync(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof J||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t,o=new er({objectMode:!0}),s=/* @__PURE__ */ new Set;(!i||i(e))&&o.write(n?e:e.fullpath());let c=[e],l=0,u=()=>{let e=!1;for(;!e;){let t=c.shift();if(!t){l===0&&o.end();return}l++,s.add(t);let u=t.readdirSync();for(let t of u)(!i||i(t))&&(o.write(n?t:t.fullpath())||(e=!0));l--;for(let e of u){let t=e;if(e.isSymbolicLink()){if(!(r&&(t=e.realpathSync())))continue;t.isUnknown()&&t.lstatSync()}t.shouldWalk(s,a)&&c.push(t)}}e&&!o.flowing&&o.once(`drain`,u)};return u(),o}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e==`string`?this.cwd.resolve(e):e,this.cwd[Ar](t)}},Pr=class extends Nr{sep=`\\`;constructor(e=process.cwd(),t={}){let{nocase:n=!0}=t;super(e,w,`\\`,{...t,nocase:n}),this.nocase=n;for(let e=this.cwd;e;e=e.parent)e.nocase=this.nocase}parseRootPath(e){return w.parse(e).root.toUpperCase()}newRoot(e){return new jr(this.rootPath,lr,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[a-z]:(\/|\\)/i.test(e)}},Fr=class extends Nr{sep=`/`;constructor(e=process.cwd(),t={}){let{nocase:n=!1}=t;super(e,ie,`/`,{...t,nocase:n}),this.nocase=n}parseRootPath(e){return`/`}newRoot(e){return new Mr(this.rootPath,lr,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith(`/`)}},Ir=class extends Fr{constructor(e=process.cwd(),t={}){let{nocase:n=!0}=t;super(e,{...t,nocase:n})}};process.platform;var Lr=process.platform===`win32`?Pr:process.platform===`darwin`?Ir:Fr,Rr=e=>e.length>=1,zr=e=>e.length>=1,Br=Symbol.for(`nodejs.util.inspect.custom`),Vr=class e{#e;#t;#n;length;#r;#i;#a;#o;#s;#c;#l=!0;constructor(e,t,n,r){if(!Rr(e))throw TypeError(`empty pattern list`);if(!zr(t))throw TypeError(`empty glob list`);if(t.length!==e.length)throw TypeError(`mismatched pattern list and glob list lengths`);if(this.length=e.length,n<0||n>=this.length)throw TypeError(`index out of range`);if(this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#n===0){if(this.isUNC()){let[e,t,n,r,...i]=this.#e,[a,o,s,c,...l]=this.#t;i[0]===``&&(i.shift(),l.shift());let u=[e,t,n,r,``].join(`/`),d=[a,o,s,c,``].join(`/`);this.#e=[u,...i],this.#t=[d,...l],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[e,...t]=this.#e,[n,...r]=this.#t;t[0]===``&&(t.shift(),r.shift());let i=e+`/`,a=n+`/`;this.#e=[i,...t],this.#t=[a,...r],this.length=this.#e.length}}}[Br](){return`Pattern <`+this.#t.slice(this.#n).join(`/`)+`>`}pattern(){return this.#e[this.#n]}isString(){return typeof this.#e[this.#n]==`string`}isGlobstar(){return this.#e[this.#n]===I}isRegExp(){return this.#e[this.#n]instanceof RegExp}globString(){return this.#a=this.#a||(this.#n===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join(`/`):this.#t.join(`/`):this.#t.slice(this.#n).join(`/`))}hasMore(){return this.length>this.#n+1}rest(){return this.#i===void 0?this.hasMore()?(this.#i=new e(this.#e,this.#t,this.#n+1,this.#r),this.#i.#c=this.#c,this.#i.#s=this.#s,this.#i.#o=this.#o,this.#i):this.#i=null:this.#i}isUNC(){let e=this.#e;return this.#s===void 0?this.#s=this.#r===`win32`&&this.#n===0&&e[0]===``&&e[1]===``&&typeof e[2]==`string`&&!!e[2]&&typeof e[3]==`string`&&!!e[3]:this.#s}isDrive(){let e=this.#e;return this.#o===void 0?this.#o=this.#r===`win32`&&this.#n===0&&this.length>1&&typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]):this.#o}isAbsolute(){let e=this.#e;return this.#c===void 0?this.#c=e[0]===``&&e.length>1||this.isDrive()||this.isUNC():this.#c}root(){let e=this.#e[0];return typeof e==`string`&&this.isAbsolute()&&this.#n===0?e:``}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#l)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#l?!1:(this.#l=!1,!0)}},Hr=typeof process==`object`&&process&&typeof process.platform==`string`?process.platform:`linux`,Ur=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:n,noext:r,noglobstar:i,platform:a=Hr}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=a,this.mmopts={dot:!0,nobrace:t,nocase:n,noext:r,noglobstar:i,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let t of e)this.add(t)}add(e){let t=new an(e,this.mmopts);for(let e=0;e<t.set.length;e++){let n=t.set[e],r=t.globParts[e];if(!n||!r)throw Error(`invalid pattern object`);for(;n[0]===`.`&&r[0]===`.`;)n.shift(),r.shift();let i=new Vr(n,r,0,this.platform),a=new an(i.globString(),this.mmopts),o=r[r.length-1]===`**`,s=i.isAbsolute();s?this.absolute.push(a):this.relative.push(a),o&&(s?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(e){let t=e.fullpath(),n=`${t}/`,r=e.relative()||`.`,i=`${r}/`;for(let e of this.relative)if(e.match(r)||e.match(i))return!0;for(let e of this.absolute)if(e.match(t)||e.match(n))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+`/`,n=(e.relative()||`.`)+`/`;for(let e of this.relativeChildren)if(e.match(n))return!0;for(let e of this.absoluteChildren)if(e.match(t))return!0;return!1}},Wr=class e{store;constructor(e=/* @__PURE__ */ new Map){this.store=e}copy(){return new e(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let n=e.fullpath(),r=this.store.get(n);r?r.add(t.globString()):this.store.set(n,/* @__PURE__ */ new Set([t.globString()]))}},Gr=class{store=/* @__PURE__ */ new Map;add(e,t,n){let r=(t?2:0)|!!n,i=this.store.get(e);this.store.set(e,i===void 0?r:r&i)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},Kr=class{store=/* @__PURE__ */ new Map;add(e,t){if(!e.canReaddir())return;let n=this.store.get(e);n?n.find(e=>e.globString()===t.globString())||n.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw Error(`attempting to walk unknown path`);return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},qr=class e{hasWalkedCache;matches=new Gr;subwalks=new Kr;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new Wr}processPatterns(e,t){this.patterns=t;let n=t.map(t=>[e,t]);for(let[e,t]of n){this.hasWalkedCache.storeWalked(e,t);let n=t.root(),r=t.isAbsolute()&&this.opts.absolute!==!1;if(n){e=e.resolve(n===`/`&&this.opts.root!==void 0?this.opts.root:n);let r=t.rest();if(r)t=r;else{this.matches.add(e,!0,!1);continue}}if(e.isENOENT())continue;let i,a,o=!1;for(;typeof(i=t.pattern())==`string`&&(a=t.rest());)e=e.resolve(i),t=a,o=!0;if(i=t.pattern(),a=t.rest(),o){if(this.hasWalkedCache.hasWalked(e,t))continue;this.hasWalkedCache.storeWalked(e,t)}if(typeof i==`string`){let t=i===`..`||i===``||i===`.`;this.matches.add(e.resolve(i),r,t)}else if(i===I){(!e.isSymbolicLink()||this.follow||t.checkFollowGlobstar())&&this.subwalks.add(e,t);let n=a?.pattern(),i=a?.rest();if(!a||(n===``||n===`.`)&&!i)this.matches.add(e,r,n===``||n===`.`);else if(n===`..`){let t=e.parent||e;i?this.hasWalkedCache.hasWalked(t,i)||this.subwalks.add(t,i):this.matches.add(t,r,!0)}}else i instanceof RegExp&&this.subwalks.add(e,t)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e(this.opts,this.hasWalkedCache)}filterEntries(e,t){let n=this.subwalks.get(e),r=this.child();for(let e of t)for(let t of n){let n=t.isAbsolute(),i=t.pattern(),a=t.rest();i===I?r.testGlobstar(e,t,a,n):i instanceof RegExp?r.testRegExp(e,i,a,n):r.testString(e,i,a,n)}return r}testGlobstar(e,t,n,r){if((this.dot||!e.name.startsWith(`.`))&&(t.hasMore()||this.matches.add(e,r,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(n&&t.checkFollowGlobstar()?this.subwalks.add(e,n):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),n){let t=n.pattern();if(typeof t==`string`&&t!==`..`&&t!==``&&t!==`.`)this.testString(e,t,n.rest(),r);else if(t===`..`){let t=e.parent||e;this.subwalks.add(t,n)}else t instanceof RegExp&&this.testRegExp(e,t,n.rest(),r)}}testRegExp(e,t,n,r){t.test(e.name)&&(n?this.subwalks.add(e,n):this.matches.add(e,r,!1))}testString(e,t,n,r){e.isNamed(t)&&(n?this.subwalks.add(e,n):this.matches.add(e,r,!1))}},Jr=(e,t)=>typeof e==`string`?new Ur([e],t):Array.isArray(e)?new Ur(e,t):e,Yr=class{path;patterns;opts;seen=/* @__PURE__ */ new Set;paused=!1;aborted=!1;#e=[];#t;#n;signal;maxDepth;includeChildMatches;constructor(e,t,n){if(this.patterns=e,this.path=t,this.opts=n,this.#n=!n.posix&&n.platform===`win32`?`\\`:`/`,this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#t=Jr(n.ignore??[],n),!this.includeChildMatches&&typeof this.#t.add!=`function`))throw Error(`cannot ignore child matches, ignore lacks add() method.`);this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener(`abort`,()=>{this.#e.length=0}))}#r(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#i(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||await e.realpath(),!n)return;e=n}let r=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let e=await r.realpath();e&&(e.isUnknown()||this.opts.stat)&&await e.lstat()}return this.matchCheckTest(r,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#r(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||e.realpathSync(),!n)return;e=n}let r=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let e=r.realpathSync();e&&(e?.isUnknown()||this.opts.stat)&&e.lstatSync()}return this.matchCheckTest(r,t)}matchFinish(e,t){if(this.#r(e))return;if(!this.includeChildMatches&&this.#t?.add){let t=`${e.relativePosix()}/**`;this.#t.add(t)}let n=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let r=this.opts.mark&&e.isDirectory()?this.#n:``;if(this.opts.withFileTypes)this.matchEmit(e);else if(n){let t=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(t+r)}else{let t=this.opts.posix?e.relativePosix():e.relative(),n=this.opts.dotRelative&&!t.startsWith(`..`+this.#n)?`.`+this.#n:``;this.matchEmit(t?n+t+r:`.`+r)}}async match(e,t,n){let r=await this.matchCheck(e,n);r&&this.matchFinish(r,t)}matchSync(e,t,n){let r=this.matchCheckSync(e,n);r&&this.matchFinish(r,t)}walkCB(e,t,n){this.signal?.aborted&&n(),this.walkCB2(e,t,new qr(this.opts),n)}walkCB2(e,t,n,r){if(this.#i(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2(e,t,n,r));return}n.processPatterns(e,t);let i=1,a=()=>{--i===0&&r()};for(let[e,t,r]of n.matches.entries())this.#r(e)||(i++,this.match(e,t,r).then(()=>a()));for(let e of n.subwalkTargets()){if(this.maxDepth!==1/0&&e.depth()>=this.maxDepth)continue;i++;let t=e.readdirCached();e.calledReaddir()?this.walkCB3(e,t,n,a):e.readdirCB((t,r)=>this.walkCB3(e,r,n,a),!0)}a()}walkCB3(e,t,n,r){n=n.filterEntries(e,t);let i=1,a=()=>{--i===0&&r()};for(let[e,t,r]of n.matches.entries())this.#r(e)||(i++,this.match(e,t,r).then(()=>a()));for(let[e,t]of n.subwalks.entries())i++,this.walkCB2(e,t,n.child(),a);a()}walkCBSync(e,t,n){this.signal?.aborted&&n(),this.walkCB2Sync(e,t,new qr(this.opts),n)}walkCB2Sync(e,t,n,r){if(this.#i(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,n,r));return}n.processPatterns(e,t);let i=1,a=()=>{--i===0&&r()};for(let[e,t,r]of n.matches.entries())this.#r(e)||this.matchSync(e,t,r);for(let e of n.subwalkTargets()){if(this.maxDepth!==1/0&&e.depth()>=this.maxDepth)continue;i++;let t=e.readdirSync();this.walkCB3Sync(e,t,n,a)}a()}walkCB3Sync(e,t,n,r){n=n.filterEntries(e,t);let i=1,a=()=>{--i===0&&r()};for(let[e,t,r]of n.matches.entries())this.#r(e)||this.matchSync(e,t,r);for(let[e,t]of n.subwalks.entries())i++,this.walkCB2Sync(e,t,n.child(),a);a()}},Xr=class extends Yr{matches=/* @__PURE__ */ new Set;constructor(e,t,n){super(e,t,n)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Zr=class extends Yr{results;constructor(e,t,n){super(e,t,n),this.results=new er({signal:this.signal,objectMode:!0}),this.results.on(`drain`,()=>this.resume()),this.results.on(`resume`,()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},Qr=typeof process==`object`&&process&&typeof process.platform==`string`?process.platform:`linux`,$r=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw TypeError(`glob options required`);if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith(`file://`))&&(t.cwd=T(t.cwd)):this.cwd=``,this.cwd=t.cwd||``,this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth==`number`?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error(`cannot set absolute and withFileTypes:true`);if(typeof e==`string`&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(e=>e.replace(/\\/g,`/`))),this.matchBase){if(t.noglobstar)throw TypeError(`base matching requires globstar`);e=e.map(e=>e.includes(`/`)?e:`./**/${e}`)}if(this.pattern=e,this.platform=t.platform||Qr,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw Error(`nocase option contradicts provided scurry option`)}else{let e=t.platform===`win32`?Pr:t.platform===`darwin`?Ir:t.platform?Fr:Lr;this.scurry=new e(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let n=this.platform===`darwin`||this.platform===`win32`,r={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},[i,a]=this.pattern.map(e=>new an(e,r)).reduce((e,t)=>(e[0].push(...t.set),e[1].push(...t.globParts),e),[[],[]]);this.patterns=i.map((e,t)=>{let n=a[t];if(!n)throw Error(`invalid pattern object`);return new Vr(e,n,0,this.platform)})}async walk(){return[...await new Xr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth===1/0?1/0:this.maxDepth+this.scurry.cwd.depth(),platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new Xr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth===1/0?1/0:this.maxDepth+this.scurry.cwd.depth(),platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new Zr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth===1/0?1/0:this.maxDepth+this.scurry.cwd.depth(),platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new Zr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth===1/0?1/0:this.maxDepth+this.scurry.cwd.depth(),platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},ei=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let n of e)if(new an(n,t).hasMagic())return!0;return!1};function ti(e,t={}){return new $r(e,t).streamSync()}function ni(e,t={}){return new $r(e,t).stream()}function ri(e,t={}){return new $r(e,t).walkSync()}async function ii(e,t={}){return new $r(e,t).walk()}function ai(e,t={}){return new $r(e,t).iterateSync()}function oi(e,t={}){return new $r(e,t).iterate()}var si=ti,ci=Object.assign(ni,{sync:ti}),li=ai,ui=Object.assign(oi,{sync:ai}),di=Object.assign(ri,{stream:ti,iterate:ai}),fi=Object.assign(ii,{glob:ii,globSync:ri,sync:di,globStream:ni,stream:ci,globStreamSync:ti,streamSync:si,globIterate:oi,iterate:ui,globIterateSync:ai,iterateSync:li,Glob:$r,hasMagic:ei,escape:kt,unescape:gt});fi.glob=fi;const pi=(e,t)=>e===void 0||typeof e===t,mi=e=>!!e&&typeof e==`object`&&pi(e.preserveRoot,`boolean`)&&pi(e.tmp,`string`)&&pi(e.maxRetries,`number`)&&pi(e.retryDelay,`number`)&&pi(e.backoff,`number`)&&pi(e.maxBackoff,`number`)&&(pi(e.glob,`boolean`)||e.glob&&typeof e.glob==`object`)&&pi(e.filter,`function`),hi=e=>{if(!mi(e))throw Error(`invalid rimraf options`)},gi=e=>{hi(e);let{glob:t,...n}=e;if(!t)return n;let r=t===!0?e.signal?{signal:e.signal}:{}:e.signal?{signal:e.signal,...t}:t;return{...n,glob:{...r,absolute:!0,withFileTypes:!1}}},_i=(e={})=>gi(e),vi=(e={})=>gi(e),yi=(e,t={})=>{let n=typeof e;if(n!==`string`){let t=e&&n===`object`&&e.constructor,r=`The "path" argument must be of type string. Received ${t&&t.name?`an instance of ${t.name}`:n===`object`?Me(e):`type ${n} ${e}`}`;throw Object.assign(TypeError(r),{path:e,code:`ERR_INVALID_ARG_TYPE`})}if(/\0/.test(e))throw Object.assign(/* @__PURE__ */ TypeError(`path must be a string without null bytes`),{path:e,code:`ERR_INVALID_ARG_VALUE`});e=N(e);let{root:r}=M(e);if(e===r&&t.preserveRoot!==!1)throw Object.assign(/* @__PURE__ */ Error(`refusing to remove root directory without preserveRoot:false`),{path:e,code:`ERR_PRESERVE_ROOT`});if(process.platform===`win32`){let t=/[*|"<>?:]/,{root:n}=M(e);if(t.test(e.substring(n.length)))throw Object.assign(/* @__PURE__ */ Error(`Illegal characters in path.`),{path:e,code:`EINVAL`})}return e},bi=e=>be(e,{withFileTypes:!0}),xi={chmod:P.chmod,mkdir:P.mkdir,readdir:e=>P.readdir(e,{withFileTypes:!0}),rename:P.rename,rm:P.rm,rmdir:P.rmdir,stat:P.stat,lstat:P.lstat,unlink:P.unlink},{readdir:Si}=xi,Ci=e=>Si(e).catch(e=>e),wi=e=>{try{return bi(e)}catch(e){return e}},Ti=e=>!!e&&typeof e==`object`,Ei=(e,t)=>t in e&&typeof e[t]==`string`,Di=e=>Ti(e)&&Ei(e,`code`)&&Ei(e,`path`),Y=e=>Ti(e)&&Ei(e,`code`)?e.code:null,Oi=async(e,t)=>e.catch(e=>{if(Y(e)!==`ENOENT`)throw t??e}),ki=(e,t)=>{try{return e()}catch(e){if(Y(e)===`ENOENT`)return;throw t??e}},{lstat:Ai,rmdir:ji,unlink:Mi}=xi,Ni=async(e,t)=>(t?.signal?.throwIfAborted(),await Oi(Ai(e).then(n=>Fi(e,t,n)))??!0),Pi=(e,t)=>(t?.signal?.throwIfAborted(),ki(()=>Ii(e,t,ve(e)))??!0),Fi=async(e,t,n)=>{t?.signal?.throwIfAborted();let r=n.isDirectory()?await Ci(e):null;if(!Array.isArray(r)){
4
- /* c8 ignore start */
5
- if(r){if(Y(r)===`ENOENT`)return!0;if(Y(r)!==`ENOTDIR`)throw r}return t.filter&&!await t.filter(e,n)?!1:(await Oi(Mi(e)),!0)}return!(await Promise.all(r.map(n=>Fi(N(e,n.name),t,n)))).every(e=>e===!0)||t.preserveRoot===!1&&e===M(e).root||t.filter&&!await t.filter(e,n)?!1:(await Oi(ji(e)),!0)},Ii=(e,t,n)=>{t?.signal?.throwIfAborted();let r=n.isDirectory()?wi(e):null;if(!Array.isArray(r)){
6
- /* c8 ignore start */
7
- if(r){if(Y(r)===`ENOENT`)return!0;if(Y(r)!==`ENOTDIR`)throw r}return t.filter&&!t.filter(e,n)?!1:(ki(()=>De(e)),!0)}let i=!0;for(let n of r){let r=N(e,n.name);i=Ii(r,t,n)&&i}return t.preserveRoot===!1&&e===M(e).root||!i||t.filter&&!t.filter(e,n)?!1:(ki(()=>Te(e)),!0)},{chmod:Li}=xi,Ri=e=>async t=>{try{await Oi(e(t));return}catch(n){if(Y(n)===`EPERM`){if(!await Oi(Li(t,438).then(()=>!0),n))return;await e(t);return}throw n}},zi=e=>t=>{try{ki(()=>e(t));return}catch(n){if(Y(n)===`EPERM`){if(!ki(()=>(ge(t,438),!0),n))return;e(t);return}throw n}},Bi=/* @__PURE__ */ new Set([`EMFILE`,`ENFILE`,`EBUSY`]),Vi=e=>{let t=async(n,r,i=1,a=0)=>{let o=r.maxBackoff||200,s=r.backoff||1.2,c=r.maxRetries||10,l=0;for(;;)try{return await e(n)}catch(e){if(Di(e)&&e.path===n&&Bi.has(e.code)){if(i=Math.ceil(i*s),a=i+a,a<o)return await Ne(i),t(n,r,i,a);if(l<c){l++;continue}}throw e}};return t},Hi=e=>(t,n)=>{let r=n.maxRetries||10,i=0;for(;;)try{return e(t)}catch(e){if(Di(e)&&e.path===t&&Bi.has(e.code)&&i<r){i++;continue}throw e}},{stat:Ui}=xi,Wi=e=>{try{return Ee(e).isDirectory()}catch{return!1}},Gi=e=>Ui(e).then(e=>e.isDirectory(),()=>!1),Ki=async e=>{let{root:t}=M(e),n=Pe(),{root:r}=M(n);if(t.toLowerCase()===r.toLowerCase())return n;let i=N(t,`/temp`);return await Gi(i)?i:t},qi=e=>{let{root:t}=M(e),n=Pe(),{root:r}=M(n);if(t.toLowerCase()===r.toLowerCase())return n;let i=N(t,`/temp`);return Wi(i)?i:t},Ji=async()=>Pe(),Yi=()=>Pe(),Xi=process.platform===`win32`?Ki:Ji,Zi=process.platform===`win32`?qi:Yi,{lstat:Qi,rename:$i,unlink:ea,rmdir:ta}=xi,na=e=>`.${je(e)}.${Math.random()}`,ra=Ri(ea),ia=zi(De),aa=async(e,t)=>(t?.signal?.throwIfAborted(),await Oi(Qi(e).then(n=>oa(e,t,n)))??!0),oa=async(e,t,n)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return oa(e,{...t,tmp:await Xi(e)},n);if(e===t.tmp&&M(e).root!==e)throw Error(`cannot delete temp directory used for deletion`);let r=n.isDirectory()?await Ci(e):null;if(!Array.isArray(r)){
8
- /* c8 ignore start */
9
- if(r){if(Y(r)===`ENOENT`)return!0;if(Y(r)!==`ENOTDIR`)throw r}return t.filter&&!await t.filter(e,n)?!1:(await Oi(sa(e,t.tmp,ra)),!0)}return!(await Promise.all(r.map(n=>oa(N(e,n.name),t,n)))).every(e=>e===!0)||t.preserveRoot===!1&&e===M(e).root||t.filter&&!await t.filter(e,n)?!1:(await Oi(sa(e,t.tmp,ta)),!0)},sa=async(e,t,n)=>{let r=N(t,na(e));return await $i(e,r),await n(r)},ca=(e,t)=>(t?.signal?.throwIfAborted(),ki(()=>la(e,t,ve(e)))??!0),la=(e,t,n)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return la(e,{...t,tmp:Zi(e)},n);let r=t.tmp;if(e===t.tmp&&M(e).root!==e)throw Error(`cannot delete temp directory used for deletion`);let i=n.isDirectory()?wi(e):null;if(!Array.isArray(i)){
10
- /* c8 ignore start */
11
- if(i){if(Y(i)===`ENOENT`)return!0;if(Y(i)!==`ENOTDIR`)throw i}return t.filter&&!t.filter(e,n)?!1:(ki(()=>ua(e,r,ia)),!0)}let a=!0;for(let n of i){let r=N(e,n.name);a=la(r,t,n)&&a}return!a||t.preserveRoot===!1&&e===M(e).root||t.filter&&!t.filter(e,n)?!1:(ki(()=>ua(e,r,Te)),!0)},ua=(e,t,n)=>{let r=N(t,na(e));return Ce(e,r),n(r)},{unlink:da,rmdir:fa,lstat:pa}=xi,ma=Vi(Ri(da)),ha=Hi(zi(De)),ga=Vi(Ri(fa)),_a=Hi(zi(Te)),va=async(e,{filter:t,...n})=>{
12
- /* c8 ignore next */
13
- n?.signal?.throwIfAborted();try{return await ga(e,n),!0}catch(t){if(Y(t)===`ENOTEMPTY`)return aa(e,n);throw t}},ya=(e,{filter:t,...n})=>{n?.signal?.throwIfAborted();try{return _a(e,n),!0}catch(t){if(Y(t)===`ENOTEMPTY`)return ca(e,n);throw t}},ba=Symbol(`start`),xa=Symbol(`child`),Sa=Symbol(`finish`),Ca=async(e,t)=>(t?.signal?.throwIfAborted(),await Oi(pa(e).then(n=>Ta(e,t,n,ba)))??!0),wa=(e,t)=>(t?.signal?.throwIfAborted(),ki(()=>Ea(e,t,ve(e),ba))??!0),Ta=async(e,t,n,r=ba)=>{t?.signal?.throwIfAborted();let i=n.isDirectory()?await Ci(e):null;if(!Array.isArray(i)){
14
- /* c8 ignore start */
15
- if(i){if(Y(i)===`ENOENT`)return!0;if(Y(i)!==`ENOTDIR`)throw i}return t.filter&&!await t.filter(e,n)?!1:(await Oi(ma(e,t)),!0)}let a=r===ba?xa:r,o=(await Promise.all(i.map(n=>Ta(N(e,n.name),t,n,a)))).every(e=>e===!0);if(r===ba)return Ta(e,t,n,Sa);if(r===Sa){if(t.preserveRoot===!1&&e===M(e).root||!o||t.filter&&!await t.filter(e,n))return!1;await Oi(va(e,t))}return!0},Ea=(e,t,n,r=ba)=>{let i=n.isDirectory()?wi(e):null;if(!Array.isArray(i)){
16
- /* c8 ignore start */
17
- if(i){if(Y(i)===`ENOENT`)return!0;if(Y(i)!==`ENOTDIR`)throw i}return t.filter&&!t.filter(e,n)?!1:(ki(()=>ha(e,t)),!0)}let a=!0;for(let n of i){let i=r===ba?xa:r,o=N(e,n.name);a=Ea(o,t,n,i)&&a}if(r===ba)return Ea(e,t,n,Sa);if(r===Sa){if(t.preserveRoot===!1&&e===M(e).root||!a||t.filter&&!t.filter(e,n))return!1;ki(()=>ya(e,t))}return!0},Da=process.platform===`win32`?Ca:Ni,Oa=process.platform===`win32`?wa:Pi,{rm:ka}=xi,Aa=async(e,t)=>(await ka(e,{...t,force:!0,recursive:!0}),!0),ja=(e,t)=>(we(e,{...t,force:!0,recursive:!0}),!0),[Ma=0,Na=0]=process.version.replace(/^v/,``).split(`.`).map(e=>parseInt(e,10)),Pa=Ma>14||Ma===14&&Na>=14,Fa=!Pa||process.platform===`win32`?()=>!1:e=>!e?.signal&&!e?.filter,Ia=!Pa||process.platform===`win32`?()=>!1:e=>!e?.signal&&!e?.filter,La=e=>async(t,n)=>{let r=_i(n);return r.glob&&(t=await fi(t,r.glob)),Array.isArray(t)?!!(await Promise.all(t.map(t=>e(yi(t,r),r)))).reduce((e,t)=>e&&t,!0):!!await e(yi(t,r),r)},Ra=e=>(t,n)=>{let r=vi(n);return r.glob&&(t=ri(t,r.glob)),Array.isArray(t)?!!t.map(t=>e(yi(t,r),r)).reduce((e,t)=>e&&t,!0):!!e(yi(t,r),r)},za=Ra(ja),Ba=Object.assign(La(Aa),{sync:za}),Va=Ra(Oa),Ha=Object.assign(La(Da),{sync:Va}),Ua=Ra(wa),Wa=Object.assign(La(Ca),{sync:Ua}),Ga=Ra(Pi),Ka=Object.assign(La(Ni),{sync:Ga}),qa=Ra(ca),Ja=Object.assign(La(aa),{sync:qa}),Ya=Ra((e,t)=>Ia(t)?ja(e,t):Oa(e,t)),Xa=La((e,t)=>Fa(t)?Aa(e,t):Da(e,t)),Za=Object.assign(Xa,{rimraf:Xa,sync:Ya,rimrafSync:Ya,manual:Ha,manualSync:Va,native:Ba,nativeSync:za,posix:Ka,posixSync:Ga,windows:Wa,windowsSync:Ua,moveRemove:Ja,moveRemoveSync:qa});Za.rimraf=Za;async function Qa(e,t,{baseDir:n=``,readdirImpl:r=de,cpImpl:i=O,joinImpl:a=C}={}){for(let o of e){let e=n?a(n,o):o;try{let n=await r(e,{withFileTypes:!0});for(let r of n){let n=a(e,r.name),o=a(t,r.name);r.isDirectory()?await i(n,o,{recursive:!0,force:!0}):r.isFile()&&await i(n,o,{force:!0})}}catch{}}}async function $a(e,t,n={},{statImpl:r=he,cpImpl:i=O}={}){let a=Array.isArray(e)?e:[e];for(let e of a)try{return await r(e),await i(e,t,n),!0}catch{}return!1}async function eo(e,{statImpl:t=he}={}){for(let n of e)try{return await t(n),n}catch{}return null}function to({contentRoot:e=``,toolchainRoot:t=``,distPublicDir:n=`dist/public`}={}){let r=[{sources:[`pages/resources/README.md`,`pages/deps/README.md`,`resources/README.md`,`deps/README.md`,`pages/README.md`,`README.md`],dest:`dist/public/README.md`},{sources:[`pages/resources/docs`,`pages/deps/docs`,`resources/docs`,`deps/docs`,`pages/docs`,`docs`],dest:`dist/public/docs`,opts:{recursive:!0}},{sources:[`pages/resources/AGENTS.md`,`pages/deps/AGENTS.md`,`resources/AGENTS.md`,`deps/AGENTS.md`,`pages/AGENTS.md`,`AGENTS.md`],dest:`dist/public/AGENTS.md`},{sources:[`pages/resources/llms.txt`,`pages/deps/llms.txt`,`resources/llms.txt`,`deps/llms.txt`,`pages/llms.txt`,`llms.txt`],dest:`dist/public/llms.txt`},{sources:[`pages/resources/robots.txt`,`pages/deps/robots.txt`,`resources/robots.txt`,`deps/robots.txt`,`pages/robots.txt`,`robots.txt`],dest:`dist/public/robots.txt`},{sources:[`pages/resources/sitemap.xml`,`pages/deps/sitemap.xml`,`resources/sitemap.xml`,`deps/sitemap.xml`,`pages/sitemap.xml`,`pages/main/sitemap.xml`,`sitemap.xml`],dest:`dist/public/sitemap.xml`},{sources:[`pages/resources/sitemap.txt`,`pages/deps/sitemap.txt`,`resources/sitemap.txt`,`deps/sitemap.txt`,`pages/sitemap.txt`,`pages/main/sitemap.txt`,`sitemap.txt`],dest:`dist/public/sitemap.txt`},{sources:[`pages/resources/404.html`,`pages/deps/404.html`,`resources/404.html`,`deps/404.html`,`pages/404.html`,`pages/main/404.html`,`404.html`],dest:`dist/public/404.html`},{sources:[`pages/resources/manifest.json`,`pages/deps/manifest.json`,`resources/manifest.json`,`deps/manifest.json`,`pages/manifest.json`,`pages/main/manifest.json`,`manifest.json`],dest:`dist/public/manifest.json`},{sources:[`pages/resources/assets/icons/favicon.svg`,`pages/deps/assets/icons/favicon.svg`,`resources/assets/icons/favicon.svg`,`deps/assets/icons/favicon.svg`,`pages/resources/assets/favicon.svg`,`pages/resources/favicon.svg`,`pages/deps/favicon.svg`,`resources/favicon.svg`,`deps/favicon.svg`,`pages/favicon.svg`,`pages/main/favicon.svg`,`assets/icons/favicon.svg`],dest:`dist/public/favicon.svg`},{sources:[`pages/resources/assets/icons/favicon.ico`,`pages/deps/assets/icons/favicon.ico`,`resources/assets/icons/favicon.ico`,`deps/assets/icons/favicon.ico`,`pages/resources/assets/favicon.ico`,`pages/resources/favicon.ico`,`pages/deps/favicon.ico`,`resources/favicon.ico`,`deps/favicon.ico`,`pages/favicon.ico`,`pages/main/favicon.ico`,`assets/icons/favicon.ico`],dest:`dist/public/favicon.ico`}];return!e&&!t&&n===`dist/public`?r:r.map(r=>{let i=n?r.dest.replace(/^dist\/public/,n):r.dest,a=[];if(e)for(let t of r.sources)a.push(S.join(e,t));if(t&&t!==e)for(let e of r.sources)a.push(S.join(t,e));return!e&&!t&&a.push(...r.sources),{sources:a,dest:i,...r.opts?{opts:r.opts}:{}}})}function no(e){let t=[`pages/resources/routes.json`,`pages/deps/routes.json`,`resources/routes.json`,`deps/routes.json`,`pages/routes.json`,`routes.json`];return e?t.map(t=>S.join(e,t)):t}function ro(e){return e?[S.join(e,`shadow-claw-config.json`),S.join(e,`shadow-claw.config.json`),S.join(e,`shadowclaw.config.json`),S.join(e,`pages/shadow-claw-config.json`),S.join(e,`pages/shadow-claw.config.json`),S.join(e,`site-config.json`),S.join(e,`pages/site-config.json`)]:[`shadow-claw-config.json`,`shadow-claw.config.json`,`shadowclaw.config.json`,`site-config.json`]}function io(e={}){let t=e.PRERENDER_PAGES||`all`;return{isProduction:e.NODE_ENV===`production`,copyAllAssets:e.COPY_ALL_ASSETS===`true`,prerenderPages:t,prerenderMainMemory:e.PRERENDER_MAIN_MEMORY!==`false`&&t!==`none`&&t!==`0`}}function ao(e){let t=ne(e);if(t.startsWith(`pages/main/`))return t.slice(11);if(t.startsWith(`pages/br:main/`)||t.startsWith(`pages/br-main/`))return t.slice(14);if(t.startsWith(`main/`))return t.slice(5);if(t.startsWith(`pages/`)){let e=t.split(`/`);if(e.length>=3)return e.slice(2).join(`/`)}return t}function oo(e,t){let r=`<script id="shadow-claw-static-routing" type="application/json">${v(t)}<\/script>`;return/id="shadow-claw-static-routing"/iu.test(e)?e.replace(/<script\s+id="shadow-claw-static-routing"[\s\S]*?<\/script>/iu,()=>r):n(e,` ${r}`)}function so(e){let t=(e.siteTitle||``).trim(),n=e.pageTitle?te(e.pageTitle).trim():``;if(e.isHome||!n)return t;if(!t)return n;if(n.toLowerCase()===t.toLowerCase())return t;let r=e.separator==null?` - `:e.separator;r&&!r.startsWith(` `)&&!r.endsWith(` `)&&(r=` ${r} `);let i=r.trim();return RegExp(`(?:\\s*[-|—•·]\\s*|\\s+${uo(i)}\\s+)${uo(t)}$`,`i`).test(n)?n:e.titleTemplate?e.titleTemplate.replace(/%%title%%|%title%/g,n).replace(/%%sitename%%|%%site%%|%sitename%|%site%/g,t).replace(/%%sep%%|%sep%/g,i).replace(/%%sitedesc%%|%%description%%|%sitedesc%|%description%/g,(e.siteDescription||``).trim()).replace(/\s+/g,` `).trim():`${n}${r}${t}`}function co(e,t){if(!e)return t?.fallback||``;let n=t?.maxLength??160,r=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/mu,``);r=r.replace(/```[\s\S]*?```/gu,``),r=r.replace(/~~~[\s\S]*?~~~/gu,``),r=r.replace(/^#{1,6}\s+.*$/gmu,``),r=r.replace(/!\[.*?\]\(.*?\)/gu,``),r=r.replace(/\[([^\]]+)\]\([^)]+\)/gu,`$1`),r=r.replace(/^>\s*/gmu,``),r=r.replace(/\*\*([^*]+)\*\*/gu,`$1`),r=r.replace(/\*([^*]+)\*/gu,`$1`),r=r.replace(/__([^_]+)__/gu,`$1`),r=r.replace(/_([^_]+)_/gu,`$1`),r=r.replace(/`([^`]+)`/gu,`$1`);let i=r.split(/\r?\n\s*\r?\n/).map(e=>te(e).replace(/\s+/g,` `).trim()).filter(e=>e.length>0);if(i.length===0)return t?.fallback||``;let a=i[0];if(a.length<=n)return a;let o=a.slice(0,n),s=o.lastIndexOf(` `);return s>n*.7&&(o=o.slice(0,s)),o=o.replace(/[,;.:\-—]+$/u,``).trim(),`${o}...`}function lo(e){let t=(e.origin||``).trim().replace(/\/+$/,``),n=(e.basePath||``).trim(),r=e.prettyPath.trim();if(r.startsWith(`/`)||(r=`/${r}`),n&&n!==`/`){let e=`/${n.replace(/^\/+|\/+$/g,``)}`;r.startsWith(e)||t.endsWith(e)||(r=`${e}${r}`)}return t?`${t}${r}`:r}function uo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function fo(e){let t=/<!--[\s\S]*?-->|<script\b[\s\S]*?<\/script>|<style\b[\s\S]*?<\/style>|<template\b[\s\S]*?<\/template>|<\/head>/gi,n;for(;(n=t.exec(e))!==null;)if(n[0].toLowerCase().startsWith(`</head`))return n.index;return-1}function X(e,t){let n=fo(e);return n===-1?`${t}\n${e}`:`${e.slice(0,n)} ${t}\n${e.slice(n)}`}function po(e,t){let n=e;if(t.title){let e=y(t.title);n=/<title>[^<]*<\/title>/iu.test(n)?n.replace(/<title>[^<]*<\/title>/iu,`<title>${e}</title>`):X(n,`<title>${e}</title>`)}if(t.description){let e=`<meta name="description" content="${y(t.description)}" />`;n=/<meta\s+name="description"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+name="description"\s+content="[^"]*"\s*\/?>/iu,e):X(n,e)}if(t.canonicalUrl){let e=`<link rel="canonical" href="${y(t.canonicalUrl)}" />`;n=/<link\s+rel="canonical"\s+href="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<link\s+rel="canonical"\s+href="[^"]*"\s*\/?>/iu,e):X(n,e)}if(t.title){let e=`<meta property="og:title" content="${y(t.title)}" />`;n=/<meta\s+property="og:title"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+property="og:title"\s+content="[^"]*"\s*\/?>/iu,e):X(n,e)}if(t.description){let e=`<meta property="og:description" content="${y(t.description)}" />`;n=/<meta\s+property="og:description"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+property="og:description"\s+content="[^"]*"\s*\/?>/iu,e):X(n,e)}if(t.canonicalUrl){let e=`<meta property="og:url" content="${y(t.canonicalUrl)}" />`;n=/<meta\s+property="og:url"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+property="og:url"\s+content="[^"]*"\s*\/?>/iu,e):X(n,e)}if(t.siteTitle){let e=`<meta property="og:site_name" content="${y(t.siteTitle)}" />`;n=/<meta\s+property="og:site_name"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+property="og:site_name"\s+content="[^"]*"\s*\/?>/iu,e):X(n,e)}if(t.type){let e=`<meta property="og:type" content="${y(t.type)}" />`;n=/<meta\s+property="og:type"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+property="og:type"\s+content="[^"]*"\s*\/?>/iu,e):X(n,e)}if(t.title){let e=`<meta name="twitter:title" content="${y(t.title)}" />`;n=/<meta\s+name="twitter:title"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+name="twitter:title"\s+content="[^"]*"\s*\/?>/iu,e):X(n,e)}if(t.description){let e=`<meta name="twitter:description" content="${y(t.description)}" />`;n=/<meta\s+name="twitter:description"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+name="twitter:description"\s+content="[^"]*"\s*\/?>/iu,e):X(n,e)}if(t.image){let e=y(t.image),r=`<meta property="og:image" content="${e}" />`;n=/<meta\s+property="og:image"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+property="og:image"\s+content="[^"]*"\s*\/?>/iu,r):X(n,r);let i=`<meta name="twitter:image" content="${e}" />`;n=/<meta\s+name="twitter:image"\s+content="[^"]*"\s*\/?>/iu.test(n)?n.replace(/<meta\s+name="twitter:image"\s+content="[^"]*"\s*\/?>/iu,i):X(n,i)}return n}function mo(e){let t=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/mu,``).match(/^#+\s+(.+)$/m);return t?t[1].trim():``}async function ho(e={}){let n=S.resolve(e.publicDir||`dist/public`),c=S.resolve(e.routesPath||`pages/routes.json`),h=S.resolve(e.sourcePath||`pages/main`),g=S.resolve(e.indexPath||S.join(n,`index.html`)),v=e.siteConfig||{};if(!e.siteConfig){let t=[e.siteConfigPath,S.resolve(S.dirname(h),`shadow-claw.config.json`),S.resolve(S.dirname(h),`site-config.json`),S.resolve(`shadow-claw.config.json`),S.resolve(`site-config.json`),S.join(n,`shadow-claw.config.json`),S.join(n,`site-config.json`)].filter(Boolean);for(let e of t)try{let t=await A(e,`utf8`);v=JSON.parse(t);break}catch{}}let te=e.prerenderPages===void 0?E.env.PRERENDER_PAGES??1:e.prerenderPages,y=t(te),re;try{re=await A(c,`utf8`)}catch(e){if(e?.code===`ENOENT`)return{count:0,skipped:!0,reason:`No routes.json found`};throw e}let x;try{x=JSON.parse(re)}catch(e){return console.warn(`Failed to parse ${c}:`,e),{count:0,skipped:!0,reason:`Invalid JSON in routes.json`}}if(!x||typeof x!=`object`)return{count:0,skipped:!0,reason:`Invalid routes.json`};x.routes||(x.routes={});let C={...x.routes||{}},ie=/* @__PURE__ */ new Set;async function ae(e,t){if(!e.subRoutes)return;let n=Array.isArray(e.subRoutes)?e.subRoutes:Object.values(e.subRoutes);for(let e of n){let n=S.resolve(S.dirname(t),e);if(typeof e==`string`&&e.startsWith(`pages/`)&&(n=S.resolve(e)),!ie.has(n)){ie.add(n);try{let e=await A(n,`utf8`),t=JSON.parse(e);t.routes&&Object.assign(C,t.routes),await ae(t,n)}catch(e){console.warn(`Failed to read subRoute: ${n}`,e?.message)}}}}await ae(x,c),Object.assign(x.routes,C),Array.isArray(x.subRoutes)&&delete x.subRoutes;let w={allowList:v?.pages?.allowList??v?.pages?.allowlist??v?.allowList??v?.allowlist,denyList:v?.pages?.denyList??v?.pages?.denylist??v?.denyList??v?.denylist};for(let[e,t]of Object.entries(C)){let n=ao(e);(!b(n,{...w,basePathPrefix:h})||!b(e,w)||t?.prettyPath&&!b(t.prettyPath,w))&&(delete C[e],delete x.routes[e])}let T=Object.entries(C);if(T.length===0)return{count:0,skipped:!0,reason:`Empty routes table`};let oe=JSON.stringify(x,null,2),se=S.join(n,`static-routing.json`);await k(n,{recursive:!0}),await j(se,oe,`utf8`);let ce=JSON.stringify(x),le=S.join(n,`components/shadow-claw/shadow-claw.html`),D=S.join(n,`components/shadow-claw-pages/shadow-claw-pages.html`),ue=S.join(n,`components/shadow-claw-page-header/shadow-claw-page-header.html`),fe=S.join(n,`components/shadow-claw/shadow-claw.css`),pe=S.join(n,`components/shadow-claw-pages/shadow-claw-pages.css`),me=S.join(n,`components/shadow-claw-page-header/shadow-claw-page-header.css`),[ge,_e,ve,ye,be,xe,Se,Ce]=await Promise.all([A(g,`utf8`),A(le,`utf8`),A(D,`utf8`).catch(()=>``),A(ue,`utf8`).catch(()=>``),p(h,`desc`,{allowList:v?.pages?.allowList??v?.pages?.allowlist??v?.allowList??v?.allowlist,denyList:v?.pages?.denyList??v?.pages?.denylist??v?.denyList??v?.denylist}),A(fe,`utf8`).catch(()=>``),A(pe,`utf8`).catch(()=>``),A(me,`utf8`).catch(()=>``)]),we=(await Promise.all(be.map(async e=>{let t=typeof e.inlineContent==`string`?e.inlineContent:await A(e.absolutePath,`utf8`);return{...e,content:t}}))).filter(e=>!(e.displayPath.endsWith(`.md`)&&/^---\r?\n[\s\S]*?slug:\s*"shadow-claw--purge-pages"[\s\S]*?---/mu.test(e.content||``))),Te=l(oo(ge,ce)),Ee=await s(Te,n);await j(g,Ee,`utf8`);let De=d(_e),Oe=d(ve),ke=d(ye),Ae=we.map(e=>({displayPath:e.displayPath,content:e.content})),je=S.join(n,`static-main-manifest.json`),M={};try{M=JSON.parse(await A(je,`utf8`))}catch{}let N={pages:Ae,...Array.isArray(M.skills)?{skills:M.skills}:{},...Array.isArray(M.tools)?{tools:M.tools}:{},...M.skillsPurgeId?{skillsPurgeId:M.skillsPurgeId}:{},...M.preRenderedStaticPages?{preRenderedStaticPages:M.preRenderedStaticPages}:{},...M.purgeId?{purgeId:M.purgeId}:{}};await j(je,JSON.stringify(N,null,2),`utf8`);try{if((await he(h)).isDirectory()){let e=S.join(n,`static-main`);await k(e,{recursive:!0}),await O(h,e,{recursive:!0});let t=S.join(n,`files/main`);await k(t,{recursive:!0}),await O(h,t,{recursive:!0})}}catch{}let Me=[],P=0;for(let[e,t]of T){if(!t||!t.prettyPath)continue;let c=ao(e),d=we.find(e=>e.displayPath===c);if(!d)try{let e=S.join(h,c);d={absolutePath:e,displayPath:c,content:await A(e,`utf8`)}}catch{console.warn(`Could not find page file for route: ${e} (${c})`);continue}let p=we.filter(e=>e.displayPath!==d.displayPath),g=[],te=[];y===`all`?(g=[d,...p],te=g.map(e=>({displayPath:e.displayPath,content:e.content}))):typeof y==`number`&&(y===0?(g=[],te=[]):(g=[d,...p.slice(0,y-1)],te=g.map(e=>({displayPath:e.displayPath,content:e.content}))));let b=_(d.content||``),re=b.data&&b.data.title?b.data.title:``,x=(v?.customElements?.scripts||[]).map(e=>typeof e==`string`?e:e?.src).filter(Boolean),C=await r(d.content||``,d.displayPath,{approvedScripts:x}),ie;if(y===0)ie=i(De,xe,v.sidebar);else{let e=ee(Oe,g,C,ke,re,Se,Ce);ie=u(De,e,xe,v.sidebar)}let ae=o(ge,ie),w=f(ae),T=JSON.stringify({pages:te,...Array.isArray(M.skills)?{skills:M.skills}:{},...Array.isArray(M.tools)?{tools:M.tools}:{},...M.skillsPurgeId?{skillsPurgeId:M.skillsPurgeId}:{},...M.preRenderedStaticPages?{preRenderedStaticPages:M.preRenderedStaticPages}:{},...M.purgeId?{purgeId:M.purgeId}:{}}),E=a(w,T),oe=ne(t.prettyPath),se=oe===``||oe===`index.html`||t.prettyPath===`/`,le=ge.match(/<base\s+href="([^"]*)"/i),D=le?le[1]:void 0,ue=v?.branding?.siteUrl||void 0,fe=po(E,{title:so({pageTitle:t.title||b.data?.seo_title||b.data?.seoTitle||b.data?.title||mo(d.content||``),siteTitle:v?.site?.title||`ShadowClaw`,siteDescription:v?.site?.description,separator:v?.site?.titleSeparator??v?.site?.sep,titleTemplate:v?.site?.titleTemplate,isHome:se}),description:t.description||b.data?.seo_description||b.data?.seoDescription||b.data?.description||b.data?.excerpt||b.data?.summary||co(d.content||``,{fallback:v?.site?.description})||v?.site?.description,canonicalUrl:lo({origin:ue,basePath:D,prettyPath:t.prettyPath}),siteTitle:v?.site?.title||`ShadowClaw`,type:se?`website`:`article`}),pe=l(oo(fe,ce)),me=await s(pe,n),he;he=oe.endsWith(`.html`)?oe:S.join(oe,`index.html`);let _e=S.join(n,he),ve=S.dirname(_e);if(await k(ve,{recursive:!0}),await j(_e,me,`utf8`),d&&d.absolutePath)try{let e=S.dirname(d.absolutePath),t=await de(e,{withFileTypes:!0});for(let n of t)n.isFile()&&!m(n.name)&&n.name!==`routes.json`&&await O(S.join(e,n.name),S.join(ve,n.name))}catch(t){console.warn(`Failed to copy co-located assets for ${e}:`,t)}if(Me.push(he.replace(/\\/g,`/`)),!oe.endsWith(`.html`)&&oe.length>0){let e=`${oe}.html`,t=S.join(n,e);await k(S.dirname(t),{recursive:!0}),await j(t,me,`utf8`),Me.push(e.replace(/\\/g,`/`))}P++}return(e.silent??E.env.NODE_ENV===`test`)||console.log(`Prerendered ${P} pretty path page${P===1?``:`s`} from ${c} (prerender-pages: ${y}).`),{count:P,generatedPaths:Me,skipped:!1}}async function go(){let e=E.argv.slice(2).filter(e=>!e.startsWith(`--`)),t=E.argv.slice(2).filter(e=>e.startsWith(`--`)),n;for(let e of t)e.startsWith(`--prerender-pages=`)?n=e.slice(18):e.startsWith(`--pages=`)&&(n=e.slice(8));let r=e[0]||`dist/public`;await ho({publicDir:r,routesPath:e[1]||`pages/routes.json`,sourcePath:e[2]||`pages/main`,indexPath:e[3]||S.join(r,`index.html`),prerenderPages:n})}E.argv[1]&&S.resolve(E.argv[1])===S.resolve(T(import.meta.url))&&go().catch(e=>{console.error(e),E.exit(1)});const _o=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`);function vo(e){let t=e?.routes;if(!t||typeof t!=`object`)return[];let n=/* @__PURE__ */ new Set;for(let e of Object.values(t)){let t=e?.prettyPath;typeof t==`string`&&t&&n.add(t)}return[...n]}function yo(e,t){let n=t.endsWith(`/`)?t:`${t}/`,r=/* @__PURE__ */ new Set([n]);for(let t of vo(e))r.add(n+t.replace(/^\/+/,``));return`<?xml version="1.0" encoding="UTF-8"?>
18
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
19
- ${[...r].map(e=>` <url>\n <loc>${_o(e)}</loc>\n </url>`).join(`
20
- `)}
21
- </urlset>
22
- `}function bo(e={},t={}){let n=e.customElements;return{rawScripts:(typeof n==`object`&&!Array.isArray(n)?n.scripts:n)||e.scripts||t.scripts||[],allowedDomains:(typeof n==`object`&&!Array.isArray(n)?n.allowedDomains:void 0)||e.allowedCustomElementDomains||[]}}function xo(e,t){if(!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&!e.startsWith(`//`)||!t||Array.isArray(t)&&t.length===0)return!0;try{let n=new URL(e,`https://localhost`).hostname.toLowerCase();return(Array.isArray(t)?t:String(t).split(/[\n,]+/)).some(e=>{let t=e.trim().toLowerCase();return n===t||n.endsWith(`.`+t)||t===`*`})}catch{return!1}}function So(e,t){let n=JSON.parse(JSON.stringify(e));return n.customElements&&typeof n.customElements==`object`&&Array.isArray(n.customElements.scripts)&&(n.customElements.scripts=n.customElements.scripts.filter(e=>{let n=typeof e==`string`?e:e?.src;return n?xo(n,t):!1})),n}function Z(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}const Co=[`pages/resources/`,`pages/deps/`,`resources/`,`deps/`,`pages/assets/`,`pages/main/assets/`];function wo(e){for(let t of Co)if(e.startsWith(t))return e.slice(t.length);return e}async function To(e){try{return JSON.parse(await A(e,`utf8`))}catch{return null}}async function Eo(e){try{return await A(e,`utf8`)}catch{return null}}async function Do(e,t){await j(e,t,`utf8`)}function Oo(e){return!Array.isArray(e)||e.length===0?``:`<nav slot="sidebar" class="sidebar-custom-sections" aria-label="Site Navigation">\n${e.map((e,t)=>{if(e.html)return e.html;let n=e.title?`sidebar-${e.title.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}`:`sidebar-section-${t+1}`,r=e.headerHref?`<a href="${Z(e.headerHref)}" class="sidebar-link">${Z(e.title||``)}</a>`:`<span>${Z(e.title||``)}</span>`,i=e.title?` <div class="sidebar-section-header">${r}</div>`:``,a=(e.items||[]).map(e=>{let t=e.title||e.label||``,n=e.href||`#`,r=e.target?` target="${Z(e.target)}"`:``,i=e.rel?` rel="${Z(e.rel)}"`:e.target===`_blank`?` rel="noopener noreferrer"`:``,a=e.active?` active`:``,o=e.active?` aria-current="page"`:``;return` <div class="sidebar-item"><a href="${Z(n)}"${r}${i} class="sidebar-link${a}"${o}>${Z(t)}</a></div>`}).join(`
23
- `);return[` <section class="sidebar-section" id="${n}">`,i,a,` </section>`].filter(Boolean).join(`
24
- `)}).join(`
25
- `)}\n</nav>`}function ko(e,t,r){let i=e,a=t.site||{};a.title&&(i=i.replace(/<title>[^<]*<\/title>/iu,`<title>${Z(a.title)}</title>`)),a.description&&(i=i.replace(/<meta\s+name="description"\s+content="[^"]*"\s*\/?>/iu,`<meta name="description" content="${Z(a.description)}" />`)),a.themeColor&&(i=i.replace(/<meta\s+name="theme-color"\s+content="[^"]*"\s*\/?>/iu,`<meta name="theme-color" content="${Z(a.themeColor)}" />`)),a.lang&&(i=i.replace(/<html\s+lang="[^"]*"/iu,`<html lang="${a.lang}"`));let o=t.branding||{};if(o.faviconPath){let e=o.faviconPath.replace(/^pages\/main\//,``),t=e.endsWith(`.svg`)?`image/svg+xml`:e.endsWith(`.png`)?`image/png`:`image/x-icon`,r=`<link href="${Z(e)}" rel="icon" type="${t}" />`,a=!1;i=i.replace(/<link\b[^>]*\brel=["']?(?:shortcut\s+)?icon["']?[^>]*\/?>/giu,()=>a?``:(a=!0,r)),a||(i=n(i,` ${r}`))}if(o.appleTouchIconPath){let e=`<link href="${Z(o.appleTouchIconPath.replace(/^pages\/main\//,``))}" rel="apple-touch-icon" />`,t=!1;i=i.replace(/<link\b[^>]*\brel=["']?apple-touch-icon["']?[^>]*\/?>/giu,()=>t?``:(t=!0,e)),t||(i=n(i,` ${e}`))}if(o.titleText||o.siteUrl||o.logoSlotHtml!==void 0){let e=o.siteUrl||``;i=i.replace(/<a\b([^>]*\bslot="header-title-link"[^>]*)>([\s\S]*?)<\/a>/iu,(n,r,i)=>{let a=``;if(o.logoSlotHtml!==void 0){let e=typeof o.logoSlotHtml==`string`?o.logoSlotHtml.trim():``;e!==``&&e.toLowerCase()!==`none`&&(a=o.logoSlotHtml)}else{let e=i.match(/<svg\b[\s\S]*?<\/svg>/iu)||i.match(/<img\b[^>]*\bclass="[^"]*header-title-logo[^"]*"[^>]*\/?>/iu);e&&(a=e[0])}let s=i.match(/<(h1|span)\b[^>]*\bclass="[^"]*header-title[^"]*"[^>]*>([\s\S]*?)<\/\1>/iu),c=s?s[1]:/<h1\b/i.test(i)?`h1`:`span`,l=s?s[2].trim():`ShadowClaw`,u=o.titleText||t.site?.title||l;return[`<a`,` aria-label="${Z(u)}"`,` class="header-title-link"`,e?` href="${Z(e)}"`:``,` slot="header-title-link"`,` >`,a?` ${a.trim()}`:``,` <${c} class="header-title">${Z(u)}</${c}>`,` </a>`].filter(Boolean).join(`
26
- `)})}if(o.repoUrl){let e=o.repoLabel||`Project on GitHub`;i=i.replace(/<a\b[^>]*\bslot="header-actions-logo"[^>]*>[\s\S]*?<\/a>/iu,[`<a`,` aria-label="${Z(e)}"`,` class="header-actions-logo-link"`,` href="${Z(o.repoUrl)}"`,` slot="header-actions-logo"`,` >`,` <svg aria-hidden="true" focusable="false" viewBox="0 0 496 512" xmlns="http://www.w3.org/2000/svg">`,` <path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8z" fill="var(--shadow-claw-bg-primary-reverse, currentColor)"></path>`,` </svg>`,` </a>`].join(`
27
- `))}o.siteUrl&&!o.siteUrl.includes(`xt-ml.github.io`)&&(i=i.replace(/\s*<meta\s+http-equiv="origin-trial"\s+content="[^"]*"\s*\/?>\s*/iu,`
28
- `));let s=t.theme||{};if(s.stylesheet){let e=wo(s.stylesheet),t=`<link rel="stylesheet" href="${Z(e)}" />`,r=Z(e).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),o=RegExp(`<link\\s+[^>]*href=["'](?:${a}|${r})["'][^>]*>`,`iu`),c=g(i),l=(c===-1?i:i.slice(0,c)).replace(/<script\b[\s\S]*?<\/script>/gi,``);o.test(l)||(i=/<link\s+rel="stylesheet"\s+href="index\.css"\s*\/?>/iu.test(i)?i.replace(/(<link\s+rel="stylesheet"\s+href="index\.css"\s*\/?>)/iu,`$1\n ${t}`):n(i,` ${t}`))}let{allowedDomains:c}=bo(t,s),l=So(t,c),u=`<script id="shadow-claw-site-config" type="application/json">${JSON.stringify(l).replace(/</g,`\\u003c`).replace(/>/g,`\\u003e`).replace(/\//g,`\\u002f`)}<\/script>`;i=i.includes(`<script id="shadow-claw-site-config"`)?i.replace(/<script\s+id="shadow-claw-site-config"[\s\S]*?<\/script>/iu,()=>u):i.includes(`<script src="theme-init.js">`)?i.replace(`<script src="theme-init.js">`,`${u}\n <script src="theme-init.js">`):/<script\b[^>]*>\s*var\s+ShadowClawThemeInit\b/iu.test(i)?i.replace(/(<script\b[^>]*>\s*var\s+ShadowClawThemeInit\b)/iu,`${u}\n $1`):n(i,` ${u}`),i=i.replace(/\s*<meta\s+name="shadow-claw-override-prerender-skeleton"[^>]*>/giu,``),typeof t.settings?.overridePrerenderSkeleton==`boolean`&&(i=i.replace(`<script id="shadow-claw-site-config"`,`<meta name="shadow-claw-override-prerender-skeleton" content="${t.settings.overridePrerenderSkeleton}" />\n <script id="shadow-claw-site-config"`));let d=r||t.sidebar?.slotHtml||(t.sidebar?.sections?Oo(t.sidebar.sections):``);if(d){let e=d.trim();/\bslot="sidebar(?:-nav|-content|-footer)?"/iu.test(e)||(e=`<div slot="sidebar" class="sidebar-custom-sections">\n${e}\n</div>`);let t=i.match(/<[^>]+?\bslot="sidebar(?:-nav|-content|-footer)?"[^>]*>[\s\S]*?<\/[^>]+>/iu);t&&(i=i.replace(t[0],``)),i.includes(`</shadow-claw>`)?i=i.replace(`</shadow-claw>`,` ${e}\n</shadow-claw>`):i.includes(`<shadow-claw></shadow-claw>`)&&(i=i.replace(`<shadow-claw></shadow-claw>`,`<shadow-claw>\n ${e}\n</shadow-claw>`))}return t.sidebar&&(i=h(i,t.sidebar)),i}function Ao(e){let t=(e.src||``).replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),n=e.type||(t.endsWith(`.svg`)?`image/svg+xml`:t.endsWith(`.png`)?`image/png`:`image/x-icon`),r=(e.purpose||`any`).trim();return n===`image/svg+xml`||t.endsWith(`.svg`)?[{...e,src:t,type:n,purpose:`any`}]:r.includes(`any`)&&r.includes(`maskable`)?[{...e,src:t,type:n,purpose:`any`},{...e,src:t,type:n,purpose:`maskable`}]:[{...e,src:t,type:n,purpose:r}]}function jo(e,t){let n=typeof e==`string`?JSON.parse(e):e,r=t.pwa||{},i=t.site||{},a=E.env.PAGES_ORIGIN;if((r.name||i.title)&&(n.name=r.name||i.title),(r.shortName||i.title)&&(n.short_name=r.shortName||i.title),i.description&&(n.description=i.description),r.backgroundColor&&(n.background_color=r.backgroundColor),(r.themeColor||i.themeColor)&&(n.theme_color=r.themeColor||i.themeColor),r.startUrl?n.start_url=r.startUrl:a?n.start_url=a:n.start_url||=`./`,r.icons&&Array.isArray(r.icons)){let e=r.icons.flatMap(Ao),t=Array.isArray(n.icons)?n.icons.flatMap(Ao):[],i=new Set(e.map(e=>e.src));n.icons=[...e,...t.filter(e=>!i.has(e.src))]}else Array.isArray(n.icons)&&(n.icons=n.icons.flatMap(Ao));return r.screenshots&&Array.isArray(r.screenshots)&&(n.screenshots=r.screenshots.map(e=>{let t=(e.src||``).replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``);return{...e,src:t}})),JSON.stringify(n,null,2)}function Mo(e,t){if(!t)return e;let n=t.endsWith(`/`)?t:t+`/`;return/<loc>/i.test(e)?e.replace(/<loc>([^<]*)<\/loc>/giu,(e,t)=>{try{let e=new URL(t.trim()),r=new URL(n),i=r.pathname.replace(/\/$/,``);return`<loc>${Z(r.origin+i+e.pathname+e.search)}</loc>`}catch{return`<loc>${Z(n)}</loc>`}}):e.split(`
29
- `).map(e=>{let t=e.trim();if(!t)return e;if(t.startsWith(`http://`)||t.startsWith(`https://`))try{let e=new URL(t),r=new URL(n);return e.protocol=r.protocol,e.host=r.host,e.pathname=(r.pathname.endsWith(`/`)?r.pathname.slice(0,-1):r.pathname)+e.pathname,e.toString()}catch{return n}if(t.startsWith(`/`))try{return new URL(t,n).toString()}catch{return e}return e}).join(`
30
- `)}function No(e,t,n){let r=e,i=t.site||{};if(i.title&&(r=r.replace(/<title>[^<]*<\/title>/iu,`<title>${Z(i.title)} - Not Found</title>`)),n){let e=n.endsWith(`/`)?n:n+`/`;r=r.replace(/l\.replace\(["']\/shadow-claw\/["']\)/gu,`l.replace("${Z(e)}")`)}return r}function Po(e){let t=S.resolve(e),n=t.split(S.sep),r=n[n.length-1],i=n[n.length-2];return(r===`resources`||r===`deps`)&&i===`pages`?S.resolve(t,`../..`):r===`resources`||r===`deps`||r===`pages`?S.resolve(t,`..`):t}function Fo(e){let t=S.resolve(e),n=S.basename(t);return n===`resources`||n===`deps`||n===`pages`?S.resolve(t,`..`):t}function Q(e,t,n){if(!e||typeof e!=`string`)return[];if(S.isAbsolute(e))return[e];let r=e.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),i=Po(t);return[S.resolve(t,`resources`,r),S.resolve(t,`deps`,r),S.resolve(t,`main`,r),S.resolve(i,`pages`,`resources`,r),S.resolve(i,`pages`,`resources`,e),S.resolve(i,`pages`,`deps`,r),S.resolve(i,`pages`,`deps`,e),S.resolve(i,`resources`,r),S.resolve(i,`resources`,e),S.resolve(i,`deps`,r),S.resolve(i,`deps`,e),S.resolve(n,`pages`,`resources`,r),S.resolve(n,`pages`,`deps`,r),S.resolve(n,`resources`,r),S.resolve(n,`deps`,r),S.resolve(n,`pages`,e),S.resolve(n,`pages`,r),S.resolve(n,`pages`,`main`,r),S.resolve(i,`pages`,e),S.resolve(i,`pages`,r),S.resolve(i,`pages`,`main`,r),S.resolve(i,`pages`,`main`,e),S.resolve(t,e),S.resolve(t,r),S.resolve(n,e),S.resolve(n,r),S.resolve(i,e),S.resolve(i,r)]}async function Io(e,t,n){if(!n)return null;let r=await Lo([...no(e),...no(t),...no(Po(e))]);if(!r)return null;let i=await To(r);return i?yo(i,n):null}async function Lo(e){for(let t of e)if(t)try{return await he(t),t}catch{}return null}async function Ro(e,t,n){let r=n?S.dirname(S.resolve(n)):E.cwd(),i=Fo(r),a=Po(r),o=[S.resolve(r,`resources`),S.resolve(r,`deps`),S.resolve(i,`resources`),S.resolve(i,`deps`),S.resolve(i,`pages`,`resources`),S.resolve(i,`pages`,`deps`),S.resolve(a,`resources`),S.resolve(a,`deps`),S.resolve(a,`pages`,`resources`),S.resolve(a,`pages`,`deps`)];for(let e of o)try{let n=await de(e,{withFileTypes:!0});for(let r of n){let n=S.join(e,r.name),i=S.join(t,r.name);r.isDirectory()?await O(n,i,{recursive:!0,force:!0}):r.isFile()&&(await k(S.dirname(i),{recursive:!0}),await D(n,i))}}catch{}let s=await Lo([...e.pages?.notFoundPath?Q(e.pages.notFoundPath,r,i):[],...e.branding?.notFoundPath?Q(e.branding.notFoundPath,r,i):[],...e.notFoundPath?Q(e.notFoundPath,r,i):[],...Q(`404.html`,r,i)]);if(s)try{await D(s,S.join(t,`404.html`)),console.log(` Copied custom 404.html: ${s}`)}catch(e){console.warn(` Warning: Could not copy custom 404.html: ${e.message}`)}let c=await Lo([...e.pwa?.manifestPath?Q(e.pwa.manifestPath,r,i):[],...e.manifestPath?Q(e.manifestPath,r,i):[],...Q(`manifest.json`,r,i)]);if(c)try{await D(c,S.join(t,`manifest.json`)),console.log(` Copied custom manifest.json: ${c}`)}catch(e){console.warn(` Warning: Could not copy custom manifest.json: ${e.message}`)}let l=!1;if(e.sitemapPath){let n=await Lo(Q(e.sitemapPath,r,i));if(n)try{let e=S.basename(n);await D(n,S.join(t,e)),console.log(` Copied custom sitemap: ${n} → ${e}`),l=!0}catch(e){console.warn(` Warning: Could not copy custom sitemap: ${e.message}`)}}if(!l){let e=await Lo(Q(`sitemap.xml`,r,i));if(e)try{await D(e,S.join(t,`sitemap.xml`)),console.log(` Copied custom sitemap.xml: ${e}`)}catch(e){console.warn(` Warning: Could not copy custom sitemap.xml: ${e.message}`)}let n=await Lo(Q(`sitemap.txt`,r,i));if(n)try{await D(n,S.join(t,`sitemap.txt`)),console.log(` Copied custom sitemap.txt: ${n}`)}catch(e){console.warn(` Warning: Could not copy custom sitemap.txt: ${e.message}`)}}let u=e.overwriteAssets===!0||e.branding?.overwriteAssets===!0,d=Array.isArray(e.assets)?e.assets:[e.assetsDir,e.assets].filter(Boolean),f=Array.from(new Set([...d.flatMap(e=>Q(e,r,i)),...Q(`assets`,r,i)].filter(e=>e&&typeof e==`string`))),p=S.join(t,`assets`);if(u)try{await me(p,{recursive:!0,force:!0}),await k(p,{recursive:!0}),console.log(` Cleared dist public assets for complete template asset overwrite.`)}catch{}let m=/* @__PURE__ */ new Set,ee=[...f].reverse();for(let e of ee)if(!m.has(e))try{let t=await he(e);if(m.add(e),t.isDirectory())await O(e,p,{recursive:!0,force:!0}),console.log(` Copied custom assets: ${e} → ${p}`);else if(t.isFile()){let t=S.basename(e);await k(p,{recursive:!0}),await D(e,S.join(p,t)),console.log(` Copied custom asset file: ${e} → ${p}`)}}catch{}}async function zo(e,t,n){let r=e.theme||{};if(!r.stylesheet)return;let i=n?S.dirname(S.resolve(n)):E.cwd(),a=Fo(i),o=await Lo(Q(r.stylesheet,i,a));if(!o)return;let s=r.stylesheet.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),c=S.join(t,s);try{await k(S.dirname(c),{recursive:!0}),await D(o,c),console.log(` Copied theme stylesheet: ${o} → ${c}`)}catch(e){console.warn(` Warning: Could not copy theme stylesheet ${o}: ${e.message}`)}}async function Bo(e,t,n){let r=(e.customElements&&typeof e.customElements==`object`&&!Array.isArray(e.customElements)?e.customElements?.scripts:void 0)||e.scripts||[];if(!Array.isArray(r)||r.length===0)return;let i=n?S.dirname(S.resolve(n)):E.cwd(),a=Fo(i);for(let e of r){let n=typeof e==`string`?e:e?.src;if(!n||n.startsWith(`http://`)||n.startsWith(`https://`)||n.startsWith(`//`))continue;let r=await Lo(Q(n,i,a));if(r){let e=n.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),i=S.join(t,e);try{await k(S.dirname(i),{recursive:!0}),await D(r,i),console.log(` Copied custom script: ${r} → ${i}`)}catch(e){console.warn(` Warning: Could not copy custom script ${r}: ${e.message}`)}}}}async function Vo(e,t,n){let r=e.branding||{},i=e.pwa||{},a=n?S.dirname(S.resolve(n)):E.cwd(),o=Fo(a),s=[],c=await Lo(Q(i.manifestPath||e.manifestPath||`manifest.json`,a,o));if(c){let e=await To(c);e&&Array.isArray(e.icons)&&(s=e.icons.map(e=>e?.src).filter(Boolean))}let l=[r.faviconPath,r.appleTouchIconPath,`assets/icons/favicon.svg`,`assets/icons/favicon.ico`,`favicon.svg`,`favicon.ico`,`pages/resources/assets/icons/favicon.svg`,`pages/resources/assets/icons/favicon.ico`,`pages/resources/favicon.svg`,`pages/deps/favicon.svg`,`pages/main/favicon.svg`,...Array.isArray(i.icons)?i.icons.map(e=>e.src):[],...s].filter(e=>!!e&&typeof e==`string`&&!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&!e.startsWith(`//`));if(l.length===0)return;let u=/* @__PURE__ */ new Set,d=/* @__PURE__ */ new Set;for(let e of l){if(u.has(e))continue;u.add(e);let n=await Lo(Q(e,a,o));if(n){let r=e.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),i=S.join(t,r);if(d.has(i))continue;d.add(i);try{await k(S.dirname(i),{recursive:!0}),await D(n,i),console.log(` Copied branding asset: ${n} → ${i}`)}catch(e){console.warn(` Warning: Could not copy branding asset ${n}: ${e.message}`)}}}}async function Ho(e,t){let n=await To(t);if(!n)return console.log(`No site-config.json found — skipping site configuration.`),{applied:!1};console.log(`Applying site-config.json...`);let r=E.env.PAGES_ORIGIN||``,i=E.env.PAGES_BASE_PATH||``;await Ro(n,e,t);let a=t?S.dirname(S.resolve(t)):E.cwd(),o=Fo(a),s;if(n.sidebar?.slotHtml)s=n.sidebar.slotHtml;else if(n.sidebar?.sections)s=Oo(n.sidebar.sections);else{let e=await Lo([n.sidebar?.slotPath,`pages/main/sidebar.html`,`pages/sidebar.html`,`sidebar.html`,`resources/sidebar.html`].filter(Boolean).flatMap(e=>Q(e,a,o)));e&&(s=await Eo(e)??void 0,console.log(` Found slotted sidebar: ${e}`))}let c=S.join(e,`index.html`),l=await Eo(c);l&&(await Do(c,ko(l,n,s)),console.log(` Patched index.html`));let u=S.join(e,`manifest.json`),d=await Eo(u);d&&(await Do(u,jo(d,n)),console.log(` Patched manifest.json`));let f=S.join(e,`sitemap.xml`),p=!!await Eo(S.join(e,`sitemap.txt`)),m=!1;if(!await Eo(f)&&!p){let e=await Io(a,o,r||n.branding?.siteUrl||``);e&&(await Do(f,e),m=!0,console.log(` Generated sitemap.xml from routes.json`))}let ee=m?``:await Eo(f);ee&&(await Do(f,Mo(ee,r)),console.log(` Patched sitemap.xml`));let h=S.join(e,`sitemap.txt`),g=await Eo(h);g&&(await Do(h,Mo(g,r)),console.log(` Patched sitemap.txt`));let _=S.join(e,`404.html`),v=await Eo(_);return v&&(await Do(_,No(v,n,i)),console.log(` Patched 404.html`)),await zo(n,e,t),await Bo(n,e,t),await Vo(n,e,t),console.log(`Site configuration applied successfully.`),{applied:!0}}async function Uo(){let[e,t]=E.argv.slice(2);(!e||!t)&&(console.error(`Usage: node bin/site-config/apply.mjs <distPublicDir> <siteConfigPath>`),E.exit(1)),await Ho(e,t)}E.argv[1]&&S.resolve(E.argv[1])===S.resolve(T(import.meta.url))&&Uo().catch(e=>{console.error(`site-config/apply.ts failed:`,e),E.exit(1)});async function Wo(t,{writeFileImpl:n=j}={}){let r=t||C(e(import.meta.url),`dist`,`public`);await n(C(r,`.nojekyll`),``,`utf-8`)}E.argv[1]&&S.resolve(E.argv[1])===S.resolve(T(import.meta.url))&&await Wo();const Go=e(import.meta.url);async function $(e){try{return await he(e),!0}catch{return!1}}async function Ko(e={}){let t=e.quiet??(process.env.NODE_ENV===`test`&&!process.env.VERBOSE),n=e.stdio??(process.env.NODE_ENV===`test`&&!process.env.VERBOSE?`pipe`:`inherit`),r=(...e)=>{t||console.log(...e)},i=ae(e.contentRoot||se.SHADOWCLAW_CONTENT_ROOT||process.cwd()),a=ae(e.toolchainRoot||Go),o=i===a,{isProduction:s,copyAllAssets:l,prerenderPages:u,prerenderMainMemory:d}=io({...se,...e.isProduction===void 0?{}:{NODE_ENV:e.isProduction?`production`:`development`},...e.copyAllAssets===void 0?{}:{COPY_ALL_ASSETS:String(e.copyAllAssets)},...e.prerenderPages===void 0?{}:{PRERENDER_PAGES:String(e.prerenderPages)},...e.prerenderMainMemory===void 0?{}:{PRERENDER_MAIN_MEMORY:String(e.prerenderMainMemory)}});s&&(process.env.NODE_ENV=`production`);async function f(e,r={}){!t&&!r.quiet&&console.log(`> ${e}`);let i=r.stdio??n,a={...process.env,...s?{NODE_ENV:`production`}:{},...r.env||{}};le(e,{stdio:i,...r,env:a})}if(o){if(oe(Go),await Za(`dist/public`),await k(`dist/public/assets`,{recursive:!0}),l)await O(`assets`,`dist/public`,{recursive:!0});else{await O(`assets/icons`,`dist/public/assets/icons`,{recursive:!0}),await O(`assets/screenshots`,`dist/public/assets/screenshots`,{recursive:!0});try{await O(`assets/fonts`,`dist/public/assets/fonts`,{recursive:!0})}catch{}}await Qa([`pages/resources`,`pages/deps`,`resources`,`deps`,`pages/assets`,`pages/main/assets`],`dist/public`);for(let e of to())await $a(e.sources,e.dest,e.opts||{});try{await O(`e2e/README.md`,`dist/public/e2e/README.md`)}catch{}try{await O(`pages`,`dist/public/pages`,{recursive:!0})}catch{}try{await O(`pages/main`,`dist/public/files/main`,{recursive:!0})}catch{}try{await O(`pages/main`,`dist/public/static-main`,{recursive:!0})}catch{}try{await O(`.agents/skills`,`dist/public/.agents/skills`,{recursive:!0})}catch{}try{await O(`.agents/tools`,`dist/public/.agents/tools`,{recursive:!0})}catch{}try{await O(`.agents/scripts`,`dist/public/.agents/scripts`,{recursive:!0})}catch{}if(await $(`.agents/skills`))try{let{generateSkillsIndex:e}=await import(`./chunk-DiQX43Hq.js`);await e(Go)}catch(e){console.warn(`Notice: Failed to auto-generate agent-skills index:`,e)}if(await $(`.well-known`))try{await O(`.well-known`,`dist/public/.well-known`,{recursive:!0,force:!0})}catch{}await f(`npm run -s rolldown`);let t=await eo(ro())||`pages/site-config.json`;d?await c({indexPath:`dist/public/index.html`,sourcePath:`pages/main`,prerenderPages:u,siteConfigPath:t}):await c({indexPath:`dist/public/index.html`,noSeed:!0,siteConfigPath:t});try{await Ho(`dist/public`,t)}catch{}try{let e=JSON.parse(await A(`package.json`,`utf8`));if(e.version){let t=`dist/public/index.html`,n=await A(t,`utf8`);await j(t,n.replace(/<meta\s+name="version"[^>]*>/,`<meta name="version" content="${e.version}" />`),`utf8`);for(let t of[`.well-known/mcp.json`,`.well-known/mcp/server-card.json`]){let n=C(`dist/public`,t);if(await $(n))try{let t=JSON.parse(await A(n,`utf8`));t.version!==e.version&&(t.version=e.version,await j(n,JSON.stringify(t,null,2)+`
31
- `,`utf8`))}catch{}}}}catch{}if(s){r(`Running production post-build steps...`);let t=e.pagesOrigin||se.PAGES_ORIGIN,n=e.basePath||(se.PAGES_BASE_PATH??`/shadow-claw/`);if(r(` PAGES_ORIGIN : ${t||`(relative ./)`}`),r(` PAGES_BASE_PATH: ${n}`),t)try{let e=`dist/public/manifest.json`,n=await A(e,`utf8`),r=JSON.parse(n);r.start_url&&(r.start_url=t,await j(e,JSON.stringify(r,null,2),`utf8`))}catch{}try{let e=`dist/public/index.html`,t=await A(e,`utf8`);t=t.replace(/<base\s+href="[^"]*"\s*\/?>/i,`<base href="${n}" />`),await j(e,t,`utf8`)}catch{}await Wo(`dist/public`);let i=``;try{i=le(`npm run -s build:pkg:get:meta`,{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{}i&&await f(`npm run -s build:pkg:meta "${i}"`)}await ho({publicDir:`dist/public`,routesPath:await eo(no())||`pages/routes.json`,sourcePath:`pages/main`,prerenderPages:u,siteConfigPath:t}),await f(`npm run -s build:service-worker`);let n=`dist/public/service-worker.js`;await $(n)&&await re(n,{logImpl:()=>{}}),r(`Build completed successfully.`);return}let p=e.outDir||`dist/public`,m=ae(i,p);await Za(m),await k(m,{recursive:!0}),await k(C(m,`assets`),{recursive:!0});let ee=C(a,`dist/public`);await $(C(ee,`index.js`))||(r(`Building ShadowClaw core toolchain...`),await Za(C(a,`dist/public`)),await Za(C(a,`dist-electron`)),await f(`npm run -s rolldown`,{cwd:a})),await O(ee,m,{recursive:!0,filter:e=>!(e.includes(`/assets/cache/`)||e.includes(`\\assets\\cache\\`)||e.includes(`/.cache/`)||e.includes(`\\.cache\\`)||e.includes(`/cache/`)||e.includes(`\\cache\\`)||e.endsWith(`/cache`)||e.endsWith(`\\cache`))}),i!==a&&(await Za(C(m,`sitemap.xml`)),await Za(C(m,`sitemap.txt`)));let h=C(i,`assets`);await $(h)&&(l?await O(h,m,{recursive:!0,force:!0}):(await $(C(h,`icons`))&&await O(C(h,`icons`),C(m,`assets/icons`),{recursive:!0,force:!0}),await $(C(h,`screenshots`))&&await O(C(h,`screenshots`),C(m,`assets/screenshots`),{recursive:!0,force:!0}),await $(C(h,`fonts`))&&await O(C(h,`fonts`),C(m,`assets/fonts`),{recursive:!0,force:!0}))),await Qa([`pages/resources`,`pages/deps`,`resources`,`deps`,`pages/assets`,`pages/main/assets`],m,{baseDir:i});let g=to({contentRoot:i,toolchainRoot:a,distPublicDir:m});for(let e of g)await $a(e.sources,e.dest,e.opts||{});let _=C(i,`pages`);await $(_)&&await O(_,C(m,`pages`),{recursive:!0,force:!0});let v=C(i,`pages/main`);await $(v)&&(await O(v,C(m,`files/main`),{recursive:!0,force:!0}),await O(v,C(m,`static-main`),{recursive:!0,force:!0}));let te=C(i,`.agents/skills`);await $(te)&&await O(te,C(m,`.agents/skills`),{recursive:!0,force:!0});let ne=C(a,`.agents/skills`);i!==a&&await $(ne)&&await O(ne,C(m,`.agents/skills`),{recursive:!0,force:!1,errorOnExist:!1});let y=C(i,`.agents/tools`);if(await $(y))await O(y,C(m,`.agents/tools`),{recursive:!0,force:!0});else{let e=C(a,`.agents/tools`);await $(e)&&await O(e,C(m,`.agents/tools`),{recursive:!0,force:!0})}let b=C(i,`.agents/scripts`);if(await $(b))await O(b,C(m,`.agents/scripts`),{recursive:!0,force:!0});else{let e=C(a,`.agents/scripts`);await $(e)&&await O(e,C(m,`.agents/scripts`),{recursive:!0,force:!0})}let x=C(a,`.well-known`);await $(x)&&await O(x,C(m,`.well-known`),{recursive:!0,force:!0});let S=C(i,`.well-known`);if(i!==a&&await $(S)&&await O(S,C(m,`.well-known`),{recursive:!0,force:!0}),await $(C(m,`.agents/skills`)))try{let{generateSkillsIndex:e}=await import(`./chunk-DiQX43Hq.js`);if(await e(m,{metadataRoot:i,outDir:`.well-known/agent-skills`,toolchainRoot:a,includeBundled:!0}),await $(te))try{await e(i,{toolchainRoot:a,includeBundled:!0})}catch{}}catch(e){console.warn(`Notice: Failed to auto-generate agent-skills index:`,e)}let ie=await eo(ro(i)),w=ie||C(i,`pages/site-config.json`),T=d;if(e.prerenderMainMemory===void 0&&ie)try{let e=JSON.parse(await A(ie,`utf8`));e?.settings?.prerenderMainMemory===!1?(T=!1,r(` site-config: prerenderMainMemory=false — pages DSD pre-rendering disabled.`)):e?.settings?.overridePrerenderSkeleton===!1&&r(` site-config: overridePrerenderSkeleton=false — skeleton overlay disabled.`)}catch{}let E=C(m,`index.html`);T&&await $(v)?await c({indexPath:E,sourcePath:v,prerenderPages:u,siteConfigPath:w}):await c({indexPath:E,noSeed:!0,siteConfigPath:w});try{await Ho(m,w)}catch{}let ce=s?e.basePath||se.PAGES_BASE_PATH||`/`:e.basePath||`/`;try{let e=await A(E,`utf8`);e=e.replace(/<base\s+href="[^"]*"\s*\/?>/i,`<base href="${ce}" />`);let t=``;try{let e=await eo([C(i,`package.json`),C(a,`package.json`)]);e&&(t=JSON.parse(await A(e,`utf8`)).version||``)}catch{}if(t){e=e.replace(/<meta\s+name="version"[^>]*>/,`<meta name="version" content="${t}" />`);for(let e of[`.well-known/mcp.json`,`.well-known/mcp/server-card.json`]){let n=C(m,e);if(await $(n))try{let e=JSON.parse(await A(n,`utf8`));e.version!==t&&(e.version=t,await j(n,JSON.stringify(e,null,2)+`
32
- `,`utf8`))}catch{}}}await j(E,e,`utf8`)}catch{}if(s){r(`Running production post-build steps...`);let t=e.pagesOrigin||se.PAGES_ORIGIN;if(r(` PAGES_ORIGIN : ${t||`(relative ./)`}`),r(` PAGES_BASE_PATH: ${ce}`),t)try{let e=C(m,`manifest.json`),n=await A(e,`utf8`),r=JSON.parse(n);r.start_url&&(r.start_url=t,await j(e,JSON.stringify(r,null,2),`utf8`))}catch{}await j(C(m,`.nojekyll`),``,`utf8`);let n=``;try{n=le(`git rev-parse HEAD`,{cwd:i,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{try{n=le(`git rev-parse HEAD`,{cwd:a,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{}}if(n){let e=await A(E,`utf8`);await j(E,e.replace(/<meta\s+name="revision"[^>]*>/,`<meta name="revision" content="${n}" />`),`utf8`)}}await ho({publicDir:m,routesPath:await eo(no(i))||C(i,`pages/routes.json`),sourcePath:await $(v)?v:C(a,`pages/main`),prerenderPages:u,siteConfigPath:w});let D=C(m,`service-worker.js`);await $(D)&&await re(D,{logImpl:()=>{}}),r(`Build completed successfully.`)}process.argv[1]&&ae(process.argv[1])===ae(T(import.meta.url))&&Ko().catch(e=>{console.error(e),ce(1)});export{Ko as t};