@readmagic/workmate 0.0.24 → 0.0.26

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 (436) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-mS8iUoWY.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-BHBkysy0.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-DuStmCjj.js +1 -0
  4. package/dist/chunks/App-D--vtCyq.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-mcDuiNGs.js +2 -0
  6. package/dist/chunks/BypassPermissionsModeDialog-DyqI98d2.js +1 -0
  7. package/dist/chunks/CustomSelect-CpMbxYbt.js +1 -0
  8. package/dist/chunks/DiffDialog-BQAU2pJx.js +6 -0
  9. package/dist/chunks/Doctor-BU69VQzw.js +1 -0
  10. package/dist/chunks/Doctor-DJOMbSDE.js +3 -0
  11. package/dist/chunks/ExitFlow-xBOnvhiW.js +2 -0
  12. package/dist/chunks/InvalidConfigDialog-NiuhcaG5.js +1 -0
  13. package/dist/chunks/{InvalidSettingsDialog-iwh8H52b.js → InvalidSettingsDialog-DrromC1I.js} +1 -1
  14. package/dist/chunks/KeybindingProviderSetup-CSUkJHTT.js +1 -0
  15. package/dist/chunks/MCPConnectionManager-Bn1PDn3R.js +1 -0
  16. package/dist/chunks/MCPToolListView-BRxjOaOL.js +1 -0
  17. package/dist/chunks/McpParsingWarnings-BYG2yqjO.js +1 -0
  18. package/dist/chunks/MessageSelector-B7xAQqZI.js +3 -0
  19. package/dist/chunks/Messages-CxMsfjOa.js +10 -0
  20. package/dist/chunks/Onboarding-CkATe87e.js +1 -0
  21. package/dist/chunks/{PermissionDialog-BaibiQae.js → PermissionDialog-tEMMa5-a.js} +1 -1
  22. package/dist/chunks/{PressEnterToContinue-DZc_s_pE.js → PressEnterToContinue-CPOaYnym.js} +1 -1
  23. package/dist/chunks/PromptInputFooterSuggestions-CwqAsTI2.js +1 -0
  24. package/dist/chunks/PromptInputHelpMenu-krq-hiFO.js +1 -0
  25. package/dist/chunks/{ProviderSetup-BCSPsvfv.js → ProviderSetup-J6Ty-Wj8.js} +1 -1
  26. package/dist/chunks/QueryEngine-Mdi_kUaL.js +1 -0
  27. package/dist/chunks/REPL-BgzQtSFF.js +1 -0
  28. package/dist/chunks/REPL-rirm6s_7.js +124 -0
  29. package/dist/chunks/ResumeConversation-Cmsbo5m7.js +1 -0
  30. package/dist/chunks/{SearchBox-C9xxQzh1.js → SearchBox-DQBLKyzJ.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-D1-7C04z.js +1 -0
  32. package/dist/chunks/{SelectMulti-BQRHed-d.js → SelectMulti-BpAjjhsn.js} +1 -1
  33. package/dist/chunks/Settings-B6DImvca.js +2 -0
  34. package/dist/chunks/Spinner-DhhSOFcN.js +1 -0
  35. package/dist/chunks/{SpinnerGlyph-CmkRUvHe.js → SpinnerGlyph-CmVXC-_9.js} +1 -1
  36. package/dist/chunks/TextInput-BboKIug2.js +22 -0
  37. package/dist/chunks/ThemePicker-DTpXbEY0.js +1 -0
  38. package/dist/chunks/TrustDialog-CZ8JpySm.js +1 -0
  39. package/dist/chunks/{ValidationErrorsList-DgNzJQUP.js → ValidationErrorsList-C_gDQfm1.js} +1 -1
  40. package/dist/chunks/_baseEach-DGbaIpJA.js +1 -0
  41. package/dist/chunks/_baseSlice-D67_NpZ1.js +1 -0
  42. package/dist/chunks/add-dir-B576wzi9.js +1 -0
  43. package/dist/chunks/{agentDisplay-M4pfwbMC.js → agentDisplay-ZuFoBZYu.js} +1 -1
  44. package/dist/chunks/{agents-DddX7lLX.js → agents-Dy4_hDic.js} +1 -1
  45. package/dist/chunks/agents-HIOBiw4w.js +101 -0
  46. package/dist/chunks/allErrors-CxPNR2WN.js +1 -0
  47. package/dist/chunks/analytics-COpjZpvd.js +1 -0
  48. package/dist/chunks/appleTerminalBackup-C9kjzdM9.js +1 -0
  49. package/dist/chunks/backgroundHousekeeping-PyLNnGdw.js +1 -0
  50. package/dist/chunks/backgroundHousekeeping-ZCMPmQuU.js +1 -0
  51. package/dist/chunks/banner-DqFectPg.js +2 -0
  52. package/dist/chunks/branch-B_BL5N9N.js +2 -0
  53. package/dist/chunks/{break-cache-BMXqFTeS.js → break-cache-DL95nKZl.js} +2 -2
  54. package/dist/chunks/btw-Y44ctueB.js +1 -0
  55. package/dist/chunks/bundledMode-BxyD5cqq.js +1 -0
  56. package/dist/chunks/caches-5xZ4dSXt.js +1 -0
  57. package/dist/chunks/caches-Be9saXxV.js +1 -0
  58. package/dist/chunks/{claudeDesktop-D8ml2767.js → claudeDesktop-g8eUUY2E.js} +1 -1
  59. package/dist/chunks/{clear-B8ZtFPOK.js → clear-DtTkA707.js} +1 -1
  60. package/dist/chunks/{client-CpTCeWba.js → client-Bw_L3lSc.js} +1 -1
  61. package/dist/chunks/{client-4iqhC8xq.js → client-aJ2Nr_sh.js} +1 -1
  62. package/dist/chunks/client-mnUISv_N.js +1 -0
  63. package/dist/chunks/client-wPqIdEVm.js +1 -0
  64. package/dist/chunks/commands-wfE12a4L.js +1 -0
  65. package/dist/chunks/compact-CvNOtu7J.js +2 -0
  66. package/dist/chunks/config-D3K87Mm1.js +3 -0
  67. package/dist/chunks/config-DTga6Ku8.js +1 -0
  68. package/dist/chunks/config-DtmqWusU.js +1 -0
  69. package/dist/chunks/context-Opu4E8dL.js +1 -0
  70. package/dist/chunks/{context-noninteractive-C7wrRZnM.js → context-noninteractive-B1V2Mp26.js} +5 -5
  71. package/dist/chunks/context-noninteractive-eIlneYiL.js +1 -0
  72. package/dist/chunks/conversation-CG_z7TLE.js +1 -0
  73. package/dist/chunks/conversation-CHesBfFZ.js +1 -0
  74. package/dist/chunks/conversationRecovery-OhitW-7g.js +1 -0
  75. package/dist/chunks/crossProjectResume-mmYx8PrZ.js +40 -0
  76. package/dist/chunks/cwd-BH2f3u0o.js +1 -0
  77. package/dist/chunks/cwd-DrEEb4f5.js +1 -0
  78. package/dist/chunks/debug-kBjDaVkQ.js +39 -0
  79. package/dist/chunks/{detectRepository-CfX8Lc0A.js → detectRepository-M6K2wc7h.js} +1 -1
  80. package/dist/chunks/{diff-DdpHThJ7.js → diff-Cv7tX2-P.js} +1 -1
  81. package/dist/chunks/{directoryCompletion-D_Rtg-4j.js → directoryCompletion-BHyjyKAM.js} +1 -1
  82. package/dist/chunks/doctor-DeBG5SL5.js +1 -0
  83. package/dist/chunks/entry-CbhyIWgj.js +13 -0
  84. package/dist/chunks/envUtils-DZ_SvEVz.js +1 -0
  85. package/dist/chunks/{esm-CGx9qY3q.js → esm-DUH16IqH.js} +1 -1
  86. package/dist/chunks/execAsync-D6SA-YsV.js +1 -0
  87. package/dist/chunks/execFileNoThrow-BfZFnCGa.js +1 -0
  88. package/dist/chunks/execa-CBhG1doD.js +34 -0
  89. package/dist/chunks/exit-OKEV_ddw.js +1 -0
  90. package/dist/chunks/extraUsage-BlRL3yeb.js +1 -0
  91. package/dist/chunks/extractMemories-jnsv-_n_.js +1 -0
  92. package/dist/chunks/fast-4I_qPJCd.js +1 -0
  93. package/dist/chunks/fast-DiolM1M7.js +1 -0
  94. package/dist/chunks/fetchModelList-BRFTQim4.js +1 -0
  95. package/dist/chunks/fetchModelList-qPKAuu4m.js +1 -0
  96. package/dist/chunks/fileSuggestions-iWVXvvLB.js +3 -0
  97. package/dist/chunks/firstPartyEventLogger-CN9UOmEC.js +1 -0
  98. package/dist/chunks/firstPartyEventLogger-RR5rvDtk.js +1 -0
  99. package/dist/chunks/{fpsMetrics-wxj9GAsd.js → fpsMetrics-Ixd0J4CH.js} +1 -1
  100. package/dist/chunks/{gemini-C_ApXgwc.js → gemini-BfVyavwQ.js} +2 -2
  101. package/dist/chunks/generateSessionName-CGaTTXCA.js +1 -0
  102. package/dist/chunks/genericProcessUtils-CVtQOTO2.js +12 -0
  103. package/dist/chunks/getMachineId-bsd-DTYGimUN.js +1 -0
  104. package/dist/chunks/getMachineId-darwin-DqIFUVvd.js +2 -0
  105. package/dist/chunks/getMachineId-linux-CnCTmdzd.js +1 -0
  106. package/dist/chunks/getMachineId-unsupported-Cx21ssu1.js +1 -0
  107. package/dist/chunks/getMachineId-win-vZhex7KX.js +1 -0
  108. package/dist/chunks/goal-BidR-GFa.js +3 -0
  109. package/dist/chunks/grok-DLcuI-U7.js +1 -0
  110. package/dist/chunks/help-CZuvYhXj.js +1 -0
  111. package/dist/chunks/history-BxPGftQw.js +1 -0
  112. package/dist/chunks/hooks-Bg9WIjZQ.js +1 -0
  113. package/dist/chunks/{hooks-DR3IYPJ3.js → hooks-ehqfAM5F.js} +2 -2
  114. package/dist/chunks/install-ACGY0vhM.js +1 -0
  115. package/dist/chunks/instrumentation-B9bfF2mA.js +21 -0
  116. package/dist/chunks/{job-YhJQWgE0.js → job-Coztdn6A.js} +1 -1
  117. package/dist/chunks/keybindings-DwSdLpaE.js +1 -0
  118. package/dist/chunks/launchLocalMemory-DRzfpIOB.js +3 -0
  119. package/dist/chunks/launchOnboarding-D2zFCJf-.js +8 -0
  120. package/dist/chunks/{loadAgentsDir-B0Anodo0.js → loadAgentsDir-DR5PVAc3.js} +590 -594
  121. package/dist/chunks/loadAgentsDir-DqAbnpB-.js +1 -0
  122. package/dist/chunks/{loadPluginHooks-BSwCtQ6T.js → loadPluginHooks-BiQgGfUJ.js} +1 -1
  123. package/dist/chunks/{loader-CICGtLp2.js → loader-6MqzNGmV.js} +1 -1
  124. package/dist/chunks/{localSearch-BxLYi6w_.js → localSearch-CzkxDuOR.js} +1 -1
  125. package/dist/chunks/localSearch-DW3JT2MA.js +1 -0
  126. package/dist/chunks/lockfile-D_9vif6E.js +1 -0
  127. package/dist/chunks/{log-D2TIwHBV.js → log-DWZny1vM.js} +1 -1
  128. package/dist/chunks/logoUtils-DR5T0pr3.js +1 -0
  129. package/dist/chunks/{magicDocs-Bkz7ZcmL.js → magicDocs-BwBxjfLo.js} +2 -2
  130. package/dist/chunks/main-Ryi27wYq.js +345 -0
  131. package/dist/chunks/managedEnv-DCEJh3z3.js +1 -0
  132. package/dist/chunks/managedEnv-Do9fgLpk.js +1 -0
  133. package/dist/chunks/managedEnvConstants-CWcT7nYr.js +1 -0
  134. package/dist/chunks/mcp-BCpnF6wD.js +1 -0
  135. package/dist/chunks/mcp-CJ6SDJEK.js +6 -0
  136. package/dist/chunks/mcp-CZBTxbhu.js +2 -0
  137. package/dist/chunks/memory-BQO6Y0ak.js +1 -0
  138. package/dist/chunks/{modalContext-DDZdU1J8.js → modalContext-CBE8xuck.js} +1 -1
  139. package/dist/chunks/mode-wq70cR44.js +2 -0
  140. package/dist/chunks/model-D42epddJ.js +1 -0
  141. package/dist/chunks/model-DVk9-2dk.js +1 -0
  142. package/dist/chunks/modelOptions-beLgXORr.js +1 -0
  143. package/dist/chunks/nativeInstaller-ChGSz1lb.js +1 -0
  144. package/dist/chunks/{notifications-Bc6k-Ozy.js → notifications-dGBuNvFj.js} +1 -1
  145. package/dist/chunks/onChangeAppState-B4K-rSaF.js +1 -0
  146. package/dist/chunks/open-Cyrr4E5x.js +1 -0
  147. package/dist/chunks/openai-DAwnAV9K.js +2 -0
  148. package/dist/chunks/overlayContext-B6i_6y_0.js +1 -0
  149. package/dist/chunks/{panel-CVS4SK_E.js → panel-C0CF3noE.js} +1 -1
  150. package/dist/chunks/parser-BZt0VFd_.js +1 -0
  151. package/dist/chunks/{parser-Cg6hSCmn.js → parser-DThLwgdM.js} +1 -1
  152. package/dist/chunks/partition-BRQHofxD.js +1 -0
  153. package/dist/chunks/{pasteStore-P0zP-ch0.js → pasteStore-BmehVo5j.js} +1 -1
  154. package/dist/chunks/permissions-DkfWKN-B.js +3 -0
  155. package/dist/chunks/pidLock-YvAaIrIY.js +3 -0
  156. package/dist/chunks/plan-B6U3ioer.js +1 -0
  157. package/dist/chunks/platform-Vl9IynC3.js +2 -0
  158. package/dist/chunks/plugin-CTA2_-F7.js +17 -0
  159. package/dist/chunks/{pluginAutoupdate-ennb9k8_.js → pluginAutoupdate-Dy5W3HWE.js} +1 -1
  160. package/dist/chunks/{pluginBlocklist-9OrNEh--.js → pluginBlocklist-DAoUENwc.js} +1 -1
  161. package/dist/chunks/pluginCliCommands-CaHnj0C_.js +1 -0
  162. package/dist/chunks/{pluginFlagging-js_-WmYj.js → pluginFlagging-BCj9LJP3.js} +1 -1
  163. package/dist/chunks/pluginOperations-ClXNOOG6.js +2 -0
  164. package/dist/chunks/pluginStartupCheck-CiwMKGjx.js +1 -0
  165. package/dist/chunks/{pluginStartupCheck-SRXOyqr7.js → pluginStartupCheck-U8_xk25t.js} +1 -1
  166. package/dist/chunks/plugins-D7zyI9c4.js +4 -0
  167. package/dist/chunks/{poller-CpLBoB-N.js → poller-BeyVwHAf.js} +1 -1
  168. package/dist/chunks/poorMode-DtzWNhsY.js +1 -0
  169. package/dist/chunks/poorMode-Ocff_UT1.js +1 -0
  170. package/dist/chunks/print-BzljdXem.js +13 -0
  171. package/dist/chunks/processBashCommand-RUkmyAl4.js +1 -0
  172. package/dist/chunks/processSlashCommand-DRLO-jNV.js +5 -0
  173. package/dist/chunks/{projectContext-5fmRr6Sd.js → projectContext-COeHKDrk.js} +1 -1
  174. package/dist/chunks/{projectContext-DhtjLv3k.js → projectContext-QN5U3Ggr.js} +1 -1
  175. package/dist/chunks/{projectOnboardingState-B5YATuc6.js → projectOnboardingState-KqcpRXls.js} +1 -1
  176. package/dist/chunks/{prompt-CJ1l3XXk.js → prompt-CTByhpUI.js} +21 -21
  177. package/dist/chunks/prompt-DTpfW6yP.js +1 -0
  178. package/dist/chunks/prompt-D__eHY_5.js +1 -0
  179. package/dist/chunks/promptEditor-CpUFgGzc.js +4 -0
  180. package/dist/chunks/protocolHandler-BQSLVGnG.js +13 -0
  181. package/dist/chunks/{proxy-CDBfZjO7.js → proxy-BtWuysHM.js} +2 -2
  182. package/dist/chunks/reconciler-D6BUq8WB.js +1 -0
  183. package/dist/chunks/refresh-B4pqFp12.js +1 -0
  184. package/dist/chunks/reject-C6IvUvBt.js +1 -0
  185. package/dist/chunks/{reload-plugins-CQZFQLWP.js → reload-plugins-DXQqk7q6.js} +1 -1
  186. package/dist/chunks/rename-D4XBmTBI.js +1 -0
  187. package/dist/chunks/{renderOptions-DV0dn0IW.js → renderOptions-DkP98P_d.js} +1 -1
  188. package/dist/chunks/resume-DzIev0JI.js +2 -0
  189. package/dist/chunks/ripgrep-CYP26Fhg.js +1 -0
  190. package/dist/chunks/ripgrep-D1f1pbCz.js +5 -0
  191. package/dist/chunks/{runtimeObserver-PJ1o8GRA.js → runtimeObserver-BPqlbu0B.js} +4 -4
  192. package/dist/chunks/{runtimeObserver-DEuR8z0f.js → runtimeObserver-BUHs3qjs.js} +1 -1
  193. package/dist/chunks/sandbox-adapter-CumL75tU.js +1 -0
  194. package/dist/chunks/sandbox-toggle-CTtET6Xq.js +1 -0
  195. package/dist/chunks/searchExtraTools-BMCU2zEf.js +1 -0
  196. package/dist/chunks/select-FrwoTzuc.js +1 -0
  197. package/dist/chunks/sessionFileAccessHooks-WO8WTdT9.js +1 -0
  198. package/dist/chunks/{sessionObserver-BtKjvteq.js → sessionObserver-B6xzxckA.js} +2 -2
  199. package/dist/chunks/sessionObserver-CBrM4opL.js +1 -0
  200. package/dist/chunks/sessionStorage-C1EAxDWG.js +1 -0
  201. package/dist/chunks/sessionTracing-UFK96PxT.js +11 -0
  202. package/dist/chunks/settings-BK6gCko-.js +1 -0
  203. package/dist/chunks/settings-YIDksG5Z.js +24 -0
  204. package/dist/chunks/setup-BBvZyrfz.js +3 -0
  205. package/dist/chunks/{shadowedRuleDetection-Bg_aIc5Z.js → shadowedRuleDetection-D6R2OeoH.js} +1 -1
  206. package/dist/chunks/{sideQuestion-D49GsfH7.js → sideQuestion-5jcbOMsR.js} +3 -3
  207. package/dist/chunks/sinks-B-kFqjjd.js +1 -0
  208. package/dist/chunks/sinks-DB_D4lmu.js +1 -0
  209. package/dist/chunks/skillChangeDetector-103-nEle.js +1 -0
  210. package/dist/chunks/{skillGapStore-CcFoHNLl.js → skillGapStore-DOz1KCqo.js} +2 -2
  211. package/dist/chunks/{skillLifecycle-Bnz_4wE5.js → skillLifecycle-D9NkIwFQ.js} +2 -2
  212. package/dist/chunks/{skillSearchPanel-C_5yUhqn.js → skillSearchPanel-DFiSZaJ4.js} +4 -4
  213. package/dist/chunks/skills-DgeLr52a.js +1 -0
  214. package/dist/chunks/sleep-BbWr_FL1.js +1 -0
  215. package/dist/chunks/{src-CiJCsqUl.js → src-C8gyNm5a.js} +1 -1
  216. package/dist/chunks/{src-9vmGsuSI.js → src-Cy5_qH26.js} +1 -1
  217. package/dist/chunks/src-Db7K3F_i.js +3 -0
  218. package/dist/chunks/{src-DL3w8VPk.js → src-WZ94ZKI3.js} +4 -4
  219. package/dist/chunks/startupProfiler-DIM_Ihyp.js +3 -0
  220. package/dist/chunks/startupProfiler-FpGsKWYk.js +1 -0
  221. package/dist/chunks/{state-B4jiUise.js → state-CXY-q5gr.js} +1 -1
  222. package/dist/chunks/state-DXt6rahM.js +1 -0
  223. package/dist/chunks/{staticRender-BVWx0IM1.js → staticRender-RHUIg5ln.js} +1 -1
  224. package/dist/chunks/status-CKLecQZV.js +1 -0
  225. package/dist/chunks/statusNoticeHelpers-DI45AH-c.js +1 -0
  226. package/dist/chunks/stringUtils-D_xPrwGQ.js +4 -0
  227. package/dist/chunks/switcher-D2Z2ZNQ0.js +1 -0
  228. package/dist/chunks/switcher-DhZCaAun.js +1 -0
  229. package/dist/chunks/{tasks-DdcUQEeD.js → tasks-6suPhqsK.js} +1 -1
  230. package/dist/chunks/{templateJobs-C8qsPrLj.js → templateJobs-BKVEWCsb.js} +1 -1
  231. package/dist/chunks/{terminalSetup-qc2PlvOm.js → terminalSetup-7PUR4hfo.js} +1 -1
  232. package/dist/chunks/{terminalSetup-B_10N_gE.js → terminalSetup-Cqy5_PhJ.js} +4 -4
  233. package/dist/chunks/{theme-f1h2QI8J.js → theme-B-HG2PUs.js} +1 -1
  234. package/dist/chunks/tipRegistry-BR_lSGRw.js +2 -0
  235. package/dist/chunks/{toolEventObserver-7QP38x4t.js → toolEventObserver-BY3QVnr6.js} +1 -1
  236. package/dist/chunks/toolPool-BcwIF8Q_.js +1 -0
  237. package/dist/chunks/{types-Dx7P7JLQ.js → types-CD25a50S.js} +16 -16
  238. package/dist/chunks/udsClient-CCxgLiZy.js +1 -0
  239. package/dist/chunks/urlHandler-BNsQKqba.js +1 -0
  240. package/dist/chunks/{use-select-navigation-hWL5VHnL.js → use-select-navigation-CW5alA9r.js} +1 -1
  241. package/dist/chunks/{useDoublePress-C9xxQzh1.js → useDoublePress-DQBLKyzJ.js} +1 -1
  242. package/dist/chunks/useExitOnCtrlCDWithKeybindings-BgJrnuDl.js +1 -0
  243. package/dist/chunks/useMainLoopModel-BVgJo4hN.js +1 -0
  244. package/dist/chunks/useManagePlugins-CrWjzESW.js +1 -0
  245. package/dist/chunks/useMergedTools-r6GQq5mI.js +1 -0
  246. package/dist/chunks/useSearchInput-BITV_Txn.js +1 -0
  247. package/dist/chunks/useSettingsErrors-CO0fTNzn.js +1 -0
  248. package/dist/chunks/util-_zo3I1y8.js +1 -0
  249. package/dist/chunks/validatePlugin-DFGdRhA-.js +1 -0
  250. package/dist/chunks/vim-qgMS88ss.js +1 -0
  251. package/dist/chunks/worktree-CR_M6Qfy.js +1 -0
  252. package/dist/cli.js +1 -1
  253. package/package.json +1 -12
  254. package/scripts/postinstall.cjs +16 -16
  255. package/dist/chunks/AddWorkspaceDirectory-Ch8IcWXO.js +0 -1
  256. package/dist/chunks/AgentsMdExternalIncludesDialog-Cyia0s4g.js +0 -1
  257. package/dist/chunks/AgentsMdExternalIncludesDialog-LjI_H_Au.js +0 -1
  258. package/dist/chunks/App-BOqh_1tN.js +0 -1
  259. package/dist/chunks/BackgroundTasksDialog-CSEuuoq9.js +0 -2
  260. package/dist/chunks/BypassPermissionsModeDialog-CwfCwUr9.js +0 -1
  261. package/dist/chunks/CustomSelect-wmZ9jz0W.js +0 -1
  262. package/dist/chunks/DiffDialog-BpXIEWiE.js +0 -6
  263. package/dist/chunks/Doctor-CMpr7tdf.js +0 -1
  264. package/dist/chunks/Doctor-DqW6j3_B.js +0 -3
  265. package/dist/chunks/ExitFlow-DacaBTlk.js +0 -2
  266. package/dist/chunks/Grove-CNqYPWI6.js +0 -11
  267. package/dist/chunks/InvalidConfigDialog-0TMJItCC.js +0 -1
  268. package/dist/chunks/KeybindingProviderSetup-D49HHTXD.js +0 -1
  269. package/dist/chunks/MCPConnectionManager-Cie77ZAK.js +0 -1
  270. package/dist/chunks/MCPToolListView-B4ehtkXd.js +0 -1
  271. package/dist/chunks/McpParsingWarnings-Bff66RtJ.js +0 -1
  272. package/dist/chunks/MessageSelector-Dpd6Iywp.js +0 -3
  273. package/dist/chunks/Messages-DN7M3oS_.js +0 -10
  274. package/dist/chunks/Onboarding-CQmE3rUf.js +0 -1
  275. package/dist/chunks/PromptInputFooterSuggestions-HI6HH3TP.js +0 -1
  276. package/dist/chunks/PromptInputHelpMenu-3QNUC2Cg.js +0 -1
  277. package/dist/chunks/QueryEngine-DdLWvJv6.js +0 -1
  278. package/dist/chunks/REPL-BqO9KcK_.js +0 -124
  279. package/dist/chunks/REPL-CmZmypfF.js +0 -1
  280. package/dist/chunks/ResumeConversation-DBqX7gva.js +0 -1
  281. package/dist/chunks/SearchExtraToolsTool-BsSoILFj.js +0 -1
  282. package/dist/chunks/Settings-B-7yBewS.js +0 -3
  283. package/dist/chunks/Spinner-ByQXTvAA.js +0 -1
  284. package/dist/chunks/TextInput-B8ruWRf2.js +0 -22
  285. package/dist/chunks/ThemePicker-BQErFFW1.js +0 -1
  286. package/dist/chunks/TrustDialog-BIhz6AZE.js +0 -1
  287. package/dist/chunks/_baseEach-CsIRoaTH.js +0 -1
  288. package/dist/chunks/add-dir-CrUDs19x.js +0 -1
  289. package/dist/chunks/agents-CGaCQeLw.js +0 -101
  290. package/dist/chunks/allErrors-BF73lon8.js +0 -1
  291. package/dist/chunks/analytics-DJobLaWP.js +0 -1
  292. package/dist/chunks/appleTerminalBackup-BArZWB21.js +0 -1
  293. package/dist/chunks/backgroundHousekeeping-Bq3LMsVR.js +0 -17
  294. package/dist/chunks/backgroundHousekeeping-Cl3Ox7Qh.js +0 -1
  295. package/dist/chunks/banner-Cu2-XUek.js +0 -2
  296. package/dist/chunks/branch-Yg_taNlT.js +0 -2
  297. package/dist/chunks/btw-udbprVvu.js +0 -1
  298. package/dist/chunks/caches-ChjIEcdd.js +0 -1
  299. package/dist/chunks/caches-DLJ6urv-.js +0 -1
  300. package/dist/chunks/client-BiqbIkwr.js +0 -1
  301. package/dist/chunks/client-CZ8nyVh5.js +0 -1
  302. package/dist/chunks/commands-CVCpJo7M.js +0 -1
  303. package/dist/chunks/compact-izk6RKHQ.js +0 -2
  304. package/dist/chunks/config-C-Y2qtB2.js +0 -3
  305. package/dist/chunks/config-CFqpXMFX.js +0 -1
  306. package/dist/chunks/config-DD8fCYXn.js +0 -1
  307. package/dist/chunks/context-BbVm4SWK.js +0 -1
  308. package/dist/chunks/context-noninteractive-x0HAzWhc.js +0 -1
  309. package/dist/chunks/conversation-DouVzO0K.js +0 -1
  310. package/dist/chunks/conversation-DrVkifKy.js +0 -1
  311. package/dist/chunks/conversationRecovery-DliPBo_z.js +0 -1
  312. package/dist/chunks/crossProjectResume-DxMy05_P.js +0 -40
  313. package/dist/chunks/cwd-Dc3NV7s8.js +0 -1
  314. package/dist/chunks/cwd-Pa83R95t.js +0 -1
  315. package/dist/chunks/datadog-Cu3s7P48.js +0 -1
  316. package/dist/chunks/debug-Bglx1aTu.js +0 -39
  317. package/dist/chunks/doctor-D_kV_D_l.js +0 -1
  318. package/dist/chunks/entry-Bxseqbi_.js +0 -13
  319. package/dist/chunks/envUtils-DfkgIdYf.js +0 -1
  320. package/dist/chunks/esm-BXTZz3av.js +0 -1
  321. package/dist/chunks/execAsync-Bv2yxuGe.js +0 -1
  322. package/dist/chunks/execFileNoThrow-BTachNBI.js +0 -34
  323. package/dist/chunks/exit-C_R_FgzR.js +0 -1
  324. package/dist/chunks/extraUsage-xMuDiNKh.js +0 -1
  325. package/dist/chunks/extractMemories-D4Dl1itt.js +0 -1
  326. package/dist/chunks/fast-DH-C5IZs.js +0 -1
  327. package/dist/chunks/fast-bopOPrtf.js +0 -1
  328. package/dist/chunks/fetchModelList-DC4VQpqa.js +0 -1
  329. package/dist/chunks/fetchModelList-FE8tzTDc.js +0 -1
  330. package/dist/chunks/fileSuggestions-C-9unnoJ.js +0 -3
  331. package/dist/chunks/firstPartyEventLogger-QmjjQmgt.js +0 -3
  332. package/dist/chunks/firstPartyEventLogger-lFeqhtfh.js +0 -1
  333. package/dist/chunks/generateSessionName-CQ03xlYI.js +0 -1
  334. package/dist/chunks/genericProcessUtils-DwQFuna9.js +0 -23
  335. package/dist/chunks/getMachineId-bsd-Cut1kHoA.js +0 -1
  336. package/dist/chunks/getMachineId-darwin-CsRhaP3y.js +0 -2
  337. package/dist/chunks/getMachineId-linux-Bd7UBNRQ.js +0 -1
  338. package/dist/chunks/getMachineId-unsupported-vFGP8E_8.js +0 -1
  339. package/dist/chunks/getMachineId-win-DamF2CH_.js +0 -1
  340. package/dist/chunks/goal-CdL29Y8C.js +0 -3
  341. package/dist/chunks/grok-C6WAslUT.js +0 -1
  342. package/dist/chunks/grove-O6qp7ITR.js +0 -1
  343. package/dist/chunks/help-DxanITNN.js +0 -1
  344. package/dist/chunks/history-BMycjPTT.js +0 -1
  345. package/dist/chunks/hooks-D9ApLkBp.js +0 -1
  346. package/dist/chunks/install-0D9u2dZw.js +0 -1
  347. package/dist/chunks/instrumentation-BFiGwntt.js +0 -21
  348. package/dist/chunks/keybindings-DZrF9iNd.js +0 -1
  349. package/dist/chunks/launchLocalMemory-DhJ56KDc.js +0 -3
  350. package/dist/chunks/launchOnboarding-DmMoZwv5.js +0 -8
  351. package/dist/chunks/loadAgentsDir-BbUR6pqH.js +0 -1
  352. package/dist/chunks/localSearch-zfn7jgrh.js +0 -1
  353. package/dist/chunks/logoUtils-CRxTutvr.js +0 -1
  354. package/dist/chunks/main-9ksgUUY_.js +0 -345
  355. package/dist/chunks/managedEnv-BEqrGqn1.js +0 -1
  356. package/dist/chunks/managedEnv-OPlzUPbJ.js +0 -1
  357. package/dist/chunks/managedEnvConstants-BPwL2aWI.js +0 -1
  358. package/dist/chunks/mcp-ChF12reQ.js +0 -1
  359. package/dist/chunks/mcp-DoEl5uah.js +0 -2
  360. package/dist/chunks/mcp-hp9qqjAy.js +0 -6
  361. package/dist/chunks/memory-Qv-wGNQ5.js +0 -1
  362. package/dist/chunks/mode-bFXPCR2P.js +0 -2
  363. package/dist/chunks/model-6lkW4o2c.js +0 -1
  364. package/dist/chunks/model-BvQFFOf8.js +0 -1
  365. package/dist/chunks/modelOptions-BBvF3wHK.js +0 -1
  366. package/dist/chunks/nativeInstaller-CdjmE9Zy.js +0 -1
  367. package/dist/chunks/onChangeAppState-DLjZ1x95.js +0 -1
  368. package/dist/chunks/open-BtQHzzL9.js +0 -1
  369. package/dist/chunks/openai-D46QvESE.js +0 -2
  370. package/dist/chunks/overlayContext-8--_fbvY.js +0 -1
  371. package/dist/chunks/parser-CG5RuOCK.js +0 -1
  372. package/dist/chunks/partition-DznN4XZH.js +0 -1
  373. package/dist/chunks/permissions-DmGFViHI.js +0 -3
  374. package/dist/chunks/pidLock-Cm4sW35f.js +0 -3
  375. package/dist/chunks/plan-CzGBz_87.js +0 -1
  376. package/dist/chunks/platform-BacQ6ACS.js +0 -2
  377. package/dist/chunks/plugin-CluR79xX.js +0 -17
  378. package/dist/chunks/pluginCliCommands-CJv5uhOG.js +0 -1
  379. package/dist/chunks/pluginOperations-CcUSHAIa.js +0 -2
  380. package/dist/chunks/pluginStartupCheck-CRBUO9gP.js +0 -1
  381. package/dist/chunks/plugins-IwwaCDba.js +0 -4
  382. package/dist/chunks/poorMode-B0QGV6Ci.js +0 -1
  383. package/dist/chunks/poorMode-G-pnu6NM.js +0 -1
  384. package/dist/chunks/print-CgszM1ea.js +0 -13
  385. package/dist/chunks/processBashCommand-D098WsqY.js +0 -1
  386. package/dist/chunks/processSlashCommand-DOQFjJ88.js +0 -5
  387. package/dist/chunks/prompt-BKPmDAuL.js +0 -1
  388. package/dist/chunks/prompt-CgOklk7z.js +0 -1
  389. package/dist/chunks/promptEditor-DoGHJN_W.js +0 -4
  390. package/dist/chunks/protocolHandler-DjQALaU2.js +0 -13
  391. package/dist/chunks/reconciler-ykkSPR-i.js +0 -1
  392. package/dist/chunks/refresh-Dn_I1R4v.js +0 -1
  393. package/dist/chunks/registerProtocol-CAsDme_E.js +0 -1
  394. package/dist/chunks/reject-DtcCfuZV.js +0 -1
  395. package/dist/chunks/rename-DyEfsZiq.js +0 -1
  396. package/dist/chunks/resume-BcXEDUqZ.js +0 -2
  397. package/dist/chunks/ripgrep-DLs8MraF.js +0 -1
  398. package/dist/chunks/ripgrep-Dl3y5r4m.js +0 -5
  399. package/dist/chunks/sandbox-adapter-DfB9kgQD.js +0 -1
  400. package/dist/chunks/sandbox-toggle-D9GDUsTl.js +0 -1
  401. package/dist/chunks/searchExtraTools-D4gMMQv0.js +0 -1
  402. package/dist/chunks/select-DIxfl_VN.js +0 -1
  403. package/dist/chunks/sessionFileAccessHooks-lbgHnVvi.js +0 -1
  404. package/dist/chunks/sessionObserver-D6qzEdGJ.js +0 -1
  405. package/dist/chunks/sessionStorage-C_7gow_z.js +0 -1
  406. package/dist/chunks/sessionTracing-CtbeAD0s.js +0 -11
  407. package/dist/chunks/settings-B2jvL8Dp.js +0 -24
  408. package/dist/chunks/settings-CisDe8DB.js +0 -1
  409. package/dist/chunks/setup-qecdf-ES.js +0 -3
  410. package/dist/chunks/sinks-C-lP7uyO.js +0 -1
  411. package/dist/chunks/sinks-De-B1lPQ.js +0 -1
  412. package/dist/chunks/skillChangeDetector-DkOJoNhT.js +0 -1
  413. package/dist/chunks/skills-BE5scC-g.js +0 -1
  414. package/dist/chunks/src-CHw1lvBc.js +0 -3
  415. package/dist/chunks/startupProfiler-BH0FoI66.js +0 -1
  416. package/dist/chunks/startupProfiler-CJdr3SxP.js +0 -3
  417. package/dist/chunks/state-BhOKSFi5.js +0 -1
  418. package/dist/chunks/status-Dw09WZLd.js +0 -1
  419. package/dist/chunks/statusNoticeHelpers-BRQpUIlH.js +0 -1
  420. package/dist/chunks/stringUtils-C718f5ey.js +0 -4
  421. package/dist/chunks/switcher-CgZVah7U.js +0 -1
  422. package/dist/chunks/switcher-DZwUo5Ed.js +0 -1
  423. package/dist/chunks/tipRegistry-B71o4qWr.js +0 -2
  424. package/dist/chunks/toolPool-V-7Yv0GA.js +0 -1
  425. package/dist/chunks/udsClient-cQz6nJ_T.js +0 -1
  426. package/dist/chunks/urlHandler-DLz3FZm1.js +0 -1
  427. package/dist/chunks/useExitOnCtrlCDWithKeybindings-BKwzUpgb.js +0 -1
  428. package/dist/chunks/useMainLoopModel-DxvV70Ru.js +0 -1
  429. package/dist/chunks/useManagePlugins-BXLXazrR.js +0 -1
  430. package/dist/chunks/useMergedTools-CCgnBJzO.js +0 -1
  431. package/dist/chunks/useSearchInput-CzopttqC.js +0 -1
  432. package/dist/chunks/useSettingsErrors-SFPWfxsA.js +0 -1
  433. package/dist/chunks/util-Cbb3S6SX.js +0 -1
  434. package/dist/chunks/validatePlugin-BMSoeb_b.js +0 -1
  435. package/dist/chunks/vim-CoRp9lY1.js +0 -1
  436. package/dist/chunks/worktree-Vm-SNY5x.js +0 -1
@@ -0,0 +1 @@
1
+ import{Qb as e,ix as t}from"./loadAgentsDir-DR5PVAc3.js";t();export{e as clearPromptCache};
@@ -0,0 +1 @@
1
+ import{i as e,r as t}from"./prompt-CTByhpUI.js";t();export{e as isDeferredTool};
@@ -0,0 +1,4 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{Rn as r,t as i}from"./src-WZ94ZKI3.js";import{T as a,c as o,f as s,i as c,u as l,x as u}from"./debug-kBjDaVkQ.js";import{c as d,i as f,o as p,s as m}from"./bundledMode-BxyD5cqq.js";import{i as h,n as g,o as _,s as v}from"./history-BxPGftQw.js";import{n as y,t as b}from"./tempfile-CHO5wXsV.js";import{basename as x}from"path";import{spawn as S,spawnSync as C}from"child_process";function w(e){return!!p(e)}function T(e){let t=x(e.split(` `)[0]??``);return O.find(e=>t.includes(e))}function E(e,t,n){return n?A.has(e)?[`-g`,`${t}:${n}`]:e===`subl`?[`${t}:${n}`]:[t]:[t]}function D(e,t){let n=j();if(!n)return!1;let i=n.split(` `),a=i[0]??n,s=i.slice(1),c=T(n);if(c){let r=E(c,e,t),i={detached:!0,stdio:`ignore`},l;return l=process.platform===`win32`?S(`${n} ${r.map(e=>`"${e}"`).join(` `)}`,{...i,shell:!0}):S(a,[...s,...r],i),l.on(`error`,e=>o(`editor spawn failed: ${e}`,{level:`error`})),l.unref(),!0}let l=r.get(process.stdout);if(!l)return!1;let u=t&&k.test(x(a));l.enterAlternateScreen();try{let r={stdio:`inherit`},i;return i=process.platform===`win32`?C(`${n} ${u?`+${t} `:``}"${e}"`,{...r,shell:!0}):C(a,[...s,...u?[`+${t}`,e]:[e]],r),i.error?(o(`editor spawn failed: ${i.error}`,{level:`error`}),!1):!0}finally{l.exitAlternateScreen()}}var O,k,A,j,M=e((()=>{n(),i(),c(),f(),O=[`code`,`cursor`,`windsurf`,`codium`,`subl`,`atom`,`gedit`,`notepad++`,`notepad`],k=/\b(vi|vim|nvim|nano|emacs|pico|micro|helix|hx)\b/,A=new Set([`code`,`cursor`,`windsurf`,`codium`]),j=t(()=>process.env.VISUAL?.trim()?process.env.VISUAL.trim():process.env.EDITOR?.trim()?process.env.EDITOR.trim():process.platform===`win32`?`start /wait notepad`:[`code`,`vi`,`nano`].find(e=>w(e)))}));function N(e){return T(e)!==void 0}function P(e){let t=l(),n=r.get(process.stdout);if(!n)throw Error(`Ink instance not found - cannot pause rendering`);let i=j();if(!i)return{content:null};try{t.statSync(e)}catch{return{content:null}}let a=!N(i);a?n.enterAlternateScreen():(n.pause(),n.suspendStdin());try{return m(`${L[i]??i} "${e}"`,{stdio:`inherit`}),{content:t.readFileSync(e,{encoding:`utf-8`})}}catch(e){if(typeof e==`object`&&e&&`status`in e&&typeof e.status==`number`){let t=e.status;if(t!==0)return{content:null,error:`${i} exited with code ${t}`}}return{content:null}}finally{a?n.exitAlternateScreen():(n.resumeStdin(),n.resume())}}function F(e,t,n){let r=e;for(let[e,t]of Object.entries(n))if(t.type===`text`){let n=parseInt(e,10),i=t.content,a=r.indexOf(i);if(a!==-1){let e=h(n,_(i));r=r.slice(0,a)+e+r.slice(a+i.length)}}return r}function I(e,t){let n=l(),r=b();try{a(r,t?g(e,t):e,{encoding:`utf-8`,flush:!0});let n=P(r);if(n.content===null)return n;let i=n.content;return i.endsWith(`
2
+ `)&&!i.endsWith(`
3
+
4
+ `)&&(i=i.slice(0,-1)),t&&(i=F(i,e,t)),{content:i}}finally{try{n.unlinkSync(r)}catch{}}}var L,R=e((()=>{v(),i(),M(),d(),s(),u(),y(),L={code:`code -w`,subl:`subl --wait`}}));export{M as a,j as i,I as n,D as o,R as r,P as t};
@@ -0,0 +1,13 @@
1
+ import{C as e,c as t,i as n,x as r}from"./debug-kBjDaVkQ.js";import{d as i,o as a}from"./config-D3K87Mm1.js";import{i as o,t as s}from"./execFileNoThrow-BfZFnCGa.js";import{a as c,i as l}from"./bundledMode-BxyD5cqq.js";import{n as u,t as d}from"./sanitization-DV-94a9Z.js";import{i as f,n as p,r as m}from"./banner-DqFectPg.js";import{homedir as h}from"os";import{basename as g}from"path";import{spawn as _}from"child_process";d();var v=`claude-cli`;function y(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=31||n===127)return!0}return!1}var b=/^[\w.-]+\/[\w.-]+$/,x=5e3,S=4096;function C(e){let t=e.startsWith(`claude-cli://`)?e:e.startsWith(`claude-cli:`)?e.replace(`${v}:`,`${v}://`):null;if(!t)throw Error(`Invalid deep link: expected ${v}:// scheme, got "${e}"`);let n;try{n=new URL(t)}catch{throw Error(`Invalid deep link URL: "${e}"`)}if(n.hostname!==`open`)throw Error(`Unknown deep link action: "${n.hostname}"`);let r=n.searchParams.get(`cwd`)??void 0,i=n.searchParams.get(`repo`)??void 0,a=n.searchParams.get(`q`);if(r&&!r.startsWith(`/`)&&!/^[a-zA-Z]:[/\\]/.test(r))throw Error(`Invalid cwd in deep link: must be an absolute path, got "${r}"`);if(r&&y(r))throw Error(`Deep link cwd contains disallowed control characters`);if(r&&r.length>S)throw Error(`Deep link cwd exceeds ${S} characters (got ${r.length})`);if(i&&!b.test(i))throw Error(`Invalid repo in deep link: expected "owner/repo", got "${i}"`);let o;if(a&&a.trim().length>0){if(o=u(a.trim()),y(o))throw Error(`Deep link query contains disallowed control characters`);if(o.length>x)throw Error(`Deep link query exceeds ${x} characters (got ${o.length})`)}return{query:o,cwd:r,repo:i}}r(),n(),i(),o(),l();var w=[{name:`iTerm2`,bundleId:`com.googlecode.iterm2`,app:`iTerm`},{name:`Ghostty`,bundleId:`com.mitchellh.ghostty`,app:`Ghostty`},{name:`Kitty`,bundleId:`net.kovidgoyal.kitty`,app:`kitty`},{name:`Alacritty`,bundleId:`org.alacritty`,app:`Alacritty`},{name:`WezTerm`,bundleId:`com.github.wez.wezterm`,app:`WezTerm`},{name:`Terminal.app`,bundleId:`com.apple.Terminal`,app:`Terminal`}],T=[`ghostty`,`kitty`,`alacritty`,`wezterm`,`gnome-terminal`,`konsole`,`xfce4-terminal`,`mate-terminal`,`tilix`,`xterm`];async function E(){let e=a().deepLinkTerminal;if(e){let t=w.find(t=>t.app===e);if(t)return{name:t.name,command:t.app}}let t=process.env.TERM_PROGRAM;if(t){let e=t.replace(/\.app$/i,``).toLowerCase(),n=w.find(t=>t.app.toLowerCase()===e||t.name.toLowerCase()===e);if(n)return{name:n.name,command:n.app}}for(let e of w){let{code:t,stdout:n}=await s(`mdfind`,[`kMDItemCFBundleIdentifier == "${e.bundleId}"`],{timeout:5e3,useCwd:!1});if(t===0&&n.trim().length>0)return{name:e.name,command:e.app}}for(let e of w){let{code:t}=await s(`ls`,[`/Applications/${e.app}.app`],{timeout:1e3,useCwd:!1});if(t===0)return{name:e.name,command:e.app}}return{name:`Terminal.app`,command:`Terminal`}}async function D(){let e=process.env.TERMINAL;if(e){let t=await c(e);if(t)return{name:g(e),command:t}}let t=await c(`x-terminal-emulator`);if(t)return{name:`x-terminal-emulator`,command:t};for(let e of T){let t=await c(e);if(t)return{name:e,command:t}}return null}async function O(){let e=await c(`wt.exe`);if(e)return{name:`Windows Terminal`,command:e};let t=await c(`pwsh.exe`);if(t)return{name:`PowerShell`,command:t};let n=await c(`powershell.exe`);return n?{name:`PowerShell`,command:n}:{name:`Command Prompt`,command:`cmd.exe`}}async function k(){switch(process.platform){case`darwin`:return E();case`linux`:return D();case`win32`:return O();default:return null}}async function A(e,n){let r=await k();if(!r)return t(`No terminal emulator detected`,{level:`error`}),!1;t(`Launching in terminal: ${r.name} (${r.command})`);let i=[`--deep-link-origin`];switch(n.repo&&(i.push(`--deep-link-repo`,n.repo),n.lastFetchMs!==void 0&&i.push(`--deep-link-last-fetch`,String(n.lastFetchMs))),n.query&&i.push(`--prefill`,n.query),process.platform){case`darwin`:return j(r,e,i,n.cwd);case`linux`:return M(r,e,i,n.cwd);case`win32`:return N(r,e,i,n.cwd);default:return!1}}async function j(e,n,r,i){switch(e.command){case`iTerm`:{let{code:e}=await s(`osascript`,[`-e`,`tell application "iTerm"
2
+ if running then
3
+ create window with default profile
4
+ else
5
+ activate
6
+ end if
7
+ tell current session of current window
8
+ write text ${L(F(n,r,i))}
9
+ end tell
10
+ end tell`],{useCwd:!1});if(e===0)return!0;break}case`Terminal`:{let{code:e}=await s(`osascript`,[`-e`,`tell application "Terminal"
11
+ do script ${L(F(n,r,i))}
12
+ activate
13
+ end tell`],{useCwd:!1});return e===0}case`Ghostty`:{let t=[`-na`,e.command,`--args`,`--window-save-state=never`];i&&t.push(`--working-directory=${i}`),t.push(`-e`,n,...r);let{code:a}=await s(`open`,t,{useCwd:!1});if(a===0)return!0;break}case`Alacritty`:{let t=[`-na`,e.command,`--args`];i&&t.push(`--working-directory`,i),t.push(`-e`,n,...r);let{code:a}=await s(`open`,t,{useCwd:!1});if(a===0)return!0;break}case`kitty`:{let t=[`-na`,e.command,`--args`];i&&t.push(`--directory`,i),t.push(n,...r);let{code:a}=await s(`open`,t,{useCwd:!1});if(a===0)return!0;break}case`WezTerm`:{let t=[`-na`,e.command,`--args`,`start`];i&&t.push(`--cwd`,i),t.push(`--`,n,...r);let{code:a}=await s(`open`,t,{useCwd:!1});if(a===0)return!0;break}}return t(`Failed to launch ${e.name}, falling back to Terminal.app`),j({name:`Terminal.app`,command:`Terminal`},n,r,i)}async function M(e,t,n,r){let i,a;switch(e.name){case`gnome-terminal`:i=r?[`--working-directory=${r}`,`--`]:[`--`],i.push(t,...n);break;case`konsole`:i=r?[`--workdir`,r,`-e`]:[`-e`],i.push(t,...n);break;case`kitty`:i=r?[`--directory`,r]:[],i.push(t,...n);break;case`wezterm`:i=r?[`start`,`--cwd`,r,`--`]:[`start`,`--`],i.push(t,...n);break;case`alacritty`:i=r?[`--working-directory`,r,`-e`]:[`-e`],i.push(t,...n);break;case`ghostty`:i=r?[`--working-directory=${r}`,`-e`]:[`-e`],i.push(t,...n);break;case`xfce4-terminal`:case`mate-terminal`:i=r?[`--working-directory=${r}`,`-x`]:[`-x`],i.push(t,...n);break;case`tilix`:i=r?[`--working-directory=${r}`,`-e`]:[`-e`],i.push(t,...n);break;default:i=[`-e`,t,...n],a=r;break}return P(e.command,i,{cwd:a})}async function N(e,t,n,r){let i=[];switch(e.name){case`Windows Terminal`:r&&i.push(`-d`,r),i.push(`--`,t,...n);break;case`PowerShell`:{let e=r?`Set-Location ${R(r)}; `:``;i.push(`-NoExit`,`-Command`,`${e}& ${R(t)} ${n.map(R).join(` `)}`);break}default:{let e=r?`cd /d ${z(r)} && `:``;i.push(`/k`,`${e}${z(t)} ${n.map(e=>z(e)).join(` `)}`);break}}return P(e.command,i,{windowsVerbatimArguments:e.name===`Command Prompt`})}function P(e,n,r={}){return new Promise(i=>{let a=_(e,n,{detached:!0,stdio:`ignore`,cwd:r.cwd,windowsVerbatimArguments:r.windowsVerbatimArguments});a.once(`error`,n=>{t(`Failed to spawn ${e}: ${n.message}`,{level:`error`}),i(!1)}),a.once(`spawn`,()=>{a.unref(),i(!0)})})}function F(e,t,n){return`${n?`cd ${I(n)} && `:``}${[e,...t].map(I).join(` `)}`}function I(e){return`'${e.replace(/'/g,`'\\''`)}'`}function L(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function R(e){return`'${e.replace(/'/g,`''`)}'`}function z(e){return`"${e.replace(/"/g,``).replace(/%/g,`%%`).replace(/(\\+)$/,`$1$1`)}"`}n();async function B(n){t(`Handling deep link URI: ${n}`);let r;try{r=C(n)}catch(e){let t=e instanceof Error?e.message:String(e);return console.error(`Deep link error: ${t}`),1}t(`Parsed deep link action: ${e(r)}`);let{cwd:i,resolvedRepo:a}=await H(r),o=a?await p(i):void 0;return await A(process.execPath,{query:r.query,cwd:i,repo:a,lastFetchMs:o?.getTime()})?0:(console.error(`Failed to open a terminal. Make sure a supported terminal emulator is installed.`),1)}async function V(){if(process.env.__CFBundleIdentifier!==`com.workmate.url-handler`)return null;try{let{waitForUrlEvent:e}=await import(`./urlHandler-BNsQKqba.js`),t=await e(5e3);return t?await B(t):null}catch{return null}}async function H(e){if(e.cwd)return{cwd:e.cwd};if(e.repo){let n=await m(f(e.repo));if(n[0])return t(`Resolved repo ${e.repo} → ${n[0]}`),{cwd:n[0],resolvedRepo:e.repo};t(`No local clone found for repo ${e.repo}, falling back to home`)}return{cwd:h()}}export{B as handleDeepLinkUri,V as handleUrlSchemeLaunch};
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,o as n,t as r}from"./rolldown-runtime-DaDcL9Zw.js";import{n as i,t as a}from"./memoize-BK3gG5ob.js";import{a as o,l as s,o as c}from"./envUtils-DfkgIdYf.js";import{i as l,n as u,r as d,t as f}from"./defineProperty-C-QyHrDq.js";import{a as p,c as m,i as h,n as g,o as _,r as v,s as y,t as b}from"./classPrivateFieldSet2-D4U5K-I3.js";import{n as x,t as S}from"./classPrivateMethodInitSpec-BXQD0Vh4.js";import{t as C}from"./src-DCUgdrYl.js";import{n as w,t as T}from"./axios-DaWTGg7G.js";import{c as E,f as D,i as O,u as k}from"./debug-Bglx1aTu.js";import A from"assert";import{Agent as j}from"https";import*as M from"http";import{URL as N}from"url";import*as P from"net";import*as F from"tls";var I=t((()=>{})),L,R,z=t((()=>{I(),L=Symbol(`AgentBaseInternalState`),R=class extends M.Agent{constructor(e){super(e),this[L]={}}isSecureEndpoint(e){if(e){if(typeof e.secureEndpoint==`boolean`)return e.secureEndpoint;if(typeof e.protocol==`string`)return e.protocol===`https:`}let{stack:t}=Error();return typeof t==`string`&&t.split(`
1
+ import{i as e,n as t,o as n,t as r}from"./rolldown-runtime-DaDcL9Zw.js";import{n as i,t as a}from"./memoize-BK3gG5ob.js";import{a as o,l as s,o as c}from"./envUtils-DZ_SvEVz.js";import{i as l,n as u,r as d,t as f}from"./defineProperty-C-QyHrDq.js";import{a as p,c as m,i as h,n as g,o as _,r as v,s as y,t as b}from"./classPrivateFieldSet2-D4U5K-I3.js";import{n as x,t as S}from"./classPrivateMethodInitSpec-BXQD0Vh4.js";import{t as C}from"./src-DCUgdrYl.js";import{n as w,t as T}from"./axios-DaWTGg7G.js";import{c as E,f as D,i as O,u as k}from"./debug-kBjDaVkQ.js";import A from"assert";import{Agent as j}from"https";import*as M from"http";import{URL as N}from"url";import*as P from"net";import*as F from"tls";var I=t((()=>{})),L,R,z=t((()=>{I(),L=Symbol(`AgentBaseInternalState`),R=class extends M.Agent{constructor(e){super(e),this[L]={}}isSecureEndpoint(e){if(e){if(typeof e.secureEndpoint==`boolean`)return e.secureEndpoint;if(typeof e.protocol==`string`)return e.protocol===`https:`}let{stack:t}=Error();return typeof t==`string`&&t.split(`
2
2
  `).some(e=>e.indexOf(`(https.js:`)!==-1||e.indexOf(`node:https:`)!==-1)}incrementSockets(e){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;this.sockets[e]||(this.sockets[e]=[]);let t=new P.Socket({writable:!1});return this.sockets[e].push(t),this.totalSocketCount++,t}decrementSockets(e,t){if(!this.sockets[e]||t===null)return;let n=this.sockets[e],r=n.indexOf(t);r!==-1&&(n.splice(r,1),this.totalSocketCount--,n.length===0&&delete this.sockets[e])}getName(e){return this.isSecureEndpoint(e)?j.prototype.getName.call(this,e):super.getName(e)}createSocket(e,t,n){let r={...t,secureEndpoint:this.isSecureEndpoint(t)},i=this.getName(r),a=this.incrementSockets(i);Promise.resolve().then(()=>this.connect(e,r)).then(o=>{if(this.decrementSockets(i,a),o instanceof M.Agent)try{return o.addRequest(e,r)}catch(e){return n(e)}this[L].currentSocket=o,super.createSocket(e,t,n)},e=>{this.decrementSockets(i,a),n(e)})}createConnection(){let e=this[L].currentSocket;if(this[L].currentSocket=void 0,!e)throw Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[L].defaultPort??(this.protocol===`https:`?443:80)}set defaultPort(e){this[L]&&(this[L].defaultPort=e)}get protocol(){return this[L].protocol??(this.isSecureEndpoint()?`https:`:`http:`)}set protocol(e){this[L]&&(this[L].protocol=e)}}}));function B(e){return new Promise((t,n)=>{let r=0,i=[];function a(){let t=e.read();t?l(t):e.once(`readable`,a)}function o(){e.removeListener(`end`,s),e.removeListener(`error`,c),e.removeListener(`readable`,a)}function s(){o(),H(`onend`),n(Error(`Proxy connection ended before receiving CONNECT response`))}function c(e){o(),H(`onerror %o`,e),n(e)}function l(s){i.push(s),r+=s.length;let c=Buffer.concat(i,r),l=c.indexOf(`\r
3
3
  \r
4
4
  `);if(l===-1){H(`have not received end of HTTP headers yet...`),a();return}let u=c.slice(0,l).toString(`ascii`).split(`\r
@@ -96,4 +96,4 @@ Content-Type: ${s.type||`application/octet-stream`}\r\n\r\n`);a.push(e,s,o),type
96
96
  )
97
97
  `))}close(){v(a,this).close()}get(e){T(e);let t=p(C,this,M).call(this,e);return t?{body:t.body?Buffer.from(t.body.buffer,t.body.byteOffset,t.body.byteLength):void 0,statusCode:t.statusCode,statusMessage:t.statusMessage,headers:t.headers?JSON.parse(t.headers):void 0,etag:t.etag?t.etag:void 0,vary:t.vary?JSON.parse(t.vary):void 0,cacheControlDirectives:t.cacheControlDirectives?JSON.parse(t.cacheControlDirectives):void 0,cachedAt:t.cachedAt,staleAt:t.staleAt,deleteAt:t.deleteAt}:void 0}set(e,t){T(e);let n=p(C,this,j).call(this,e),i=Array.isArray(t.body)?Buffer.concat(t.body):t.body,a=i?.byteLength;if(a&&a>v(r,this))return;let o=p(C,this,M).call(this,e,!0);o?v(s,this).run(i,t.deleteAt,t.statusCode,t.statusMessage,t.headers?JSON.stringify(t.headers):null,t.etag?t.etag:null,t.cacheControlDirectives?JSON.stringify(t.cacheControlDirectives):null,t.cachedAt,t.staleAt,o.id):(v(c,this).run(n,e.method,i,t.deleteAt,t.statusCode,t.statusMessage,t.headers?JSON.stringify(t.headers):null,t.etag?t.etag:null,t.cacheControlDirectives?JSON.stringify(t.cacheControlDirectives):null,t.vary?JSON.stringify(t.vary):null,t.cachedAt,t.staleAt),p(C,this,A).call(this))}createWriteStream(e,t){T(e),E(t);let n=0,i=[],a=this;return new w({decodeStrings:!0,write(e,t,o){n+=e.byteLength,n<v(r,a)?i.push(e):this.destroy(),o()},final(n){a.set(e,{...t,body:i}),n()}})}delete(e){if(typeof e!=`object`)throw TypeError(`expected key to be object, got ${typeof e}`);v(u,this).run(p(C,this,j).call(this,e))}get size(){let{total:e}=v(d,this).get();return e}});function A(){if(Number.isFinite(v(i,this))&&this.size<=v(i,this))return 0;{let e=v(l,this).run(Date.now()).changes;if(e)return e}{let e=v(f,this)?.run(Math.max(Math.floor(v(i,this)*.1),1)).changes;if(e)return e}return 0}function j(e){return`${e.origin}/${e.path}`}function M(e,t=!1){let n=p(C,this,j).call(this,e),{headers:r,method:i}=e,a=v(o,this).all(n,i);if(a.length===0)return;let s=Date.now();for(let e of a){if(s>=e.deleteAt&&!t)continue;let n=!0;if(e.vary){let t=JSON.parse(e.vary);for(let e in t)if(!N(r[e],t[e])){n=!1;break}}if(n)return e}}function N(e,t){return e==null&&t==null?!0:e==null&&t!=null||e!=null&&t==null?!1:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}})),Vt=r(((t,n)=>{u(),m(),g(),h();var r,i,{kConstruct:a}=X(),{kEnumerableProperty:o}=Q(),{iteratorMixin:s,isValidHeaderName:c,isValidHeaderValue:l}=De(),{webidl:d}=Ee(),p=e(`node:assert`),_=e(`node:util`);function x(e){return e===10||e===13||e===9||e===32}function S(e){let t=0,n=e.length;for(;n>t&&x(e.charCodeAt(n-1));)--n;for(;n>t&&x(e.charCodeAt(t));)++t;return t===0&&n===e.length?e:e.substring(t,n)}function C(e,t){if(Array.isArray(t))for(let n=0;n<t.length;++n){let r=t[n];if(r.length!==2)throw d.errors.exception({header:`Headers constructor`,message:`expected name/value pair to be length 2, found ${r.length}.`});w(e,r[0],r[1])}else if(typeof t==`object`&&t){let n=Object.keys(t);for(let r=0;r<n.length;++r)w(e,n[r],t[n[r]])}else throw d.errors.conversionFailed({prefix:`Headers constructor`,argument:`Argument 1`,types:[`sequence<sequence<ByteString>>`,`record<ByteString, ByteString>`]})}function w(e,t,n){if(n=S(n),!c(t))throw d.errors.invalidArgument({prefix:`Headers.append`,value:t,type:`header name`});if(!l(n))throw d.errors.invalidArgument({prefix:`Headers.append`,value:n,type:`header value`});if(j(e)===`immutable`)throw TypeError(`immutable`);return N(e).append(t,n,!1)}function T(e){let t=N(e);if(!t)return[];if(t.sortedMap)return t.sortedMap;let n=[],r=t.toSortedArray(),i=t.cookies;if(i===null||i.length===1)return t.sortedMap=r;for(let e=0;e<r.length;++e){let{0:t,1:a}=r[e];if(t===`set-cookie`)for(let e=0;e<i.length;++e)n.push([t,i[e]]);else n.push([t,a])}return t.sortedMap=n}function E(e,t){return e[0]<t[0]?-1:1}r=Symbol.iterator;var D=class e{constructor(t){f(this,`cookies`,null),f(this,`sortedMap`,void 0),f(this,`headersMap`,void 0),t instanceof e?(this.headersMap=new Map(t.headersMap),this.sortedMap=t.sortedMap,this.cookies=t.cookies===null?null:[...t.cookies]):(this.headersMap=new Map(t),this.sortedMap=null)}contains(e,t){return this.headersMap.has(t?e:e.toLowerCase())}clear(){this.headersMap.clear(),this.sortedMap=null,this.cookies=null}append(e,t,n){this.sortedMap=null;let r=n?e:e.toLowerCase(),i=this.headersMap.get(r);if(i){let e=r===`cookie`?`; `:`, `;this.headersMap.set(r,{name:i.name,value:`${i.value}${e}${t}`})}else this.headersMap.set(r,{name:e,value:t});r===`set-cookie`&&(this.cookies??(this.cookies=[])).push(t)}set(e,t,n){this.sortedMap=null;let r=n?e:e.toLowerCase();r===`set-cookie`&&(this.cookies=[t]),this.headersMap.set(r,{name:e,value:t})}delete(e,t){this.sortedMap=null,t||(e=e.toLowerCase()),e===`set-cookie`&&(this.cookies=null),this.headersMap.delete(e)}get(e,t){return this.headersMap.get(t?e:e.toLowerCase())?.value??null}*[r](){for(let{0:e,1:{value:t}}of this.headersMap)yield[e,t]}get entries(){let e={};if(this.headersMap.size!==0)for(let{name:t,value:n}of this.headersMap.values())e[t]=n;return e}rawValues(){return this.headersMap.values()}get entriesList(){let e=[];if(this.headersMap.size!==0)for(let{0:t,1:{name:n,value:r}}of this.headersMap)if(t===`set-cookie`)for(let t of this.cookies)e.push([n,t]);else e.push([n,r]);return e}toSortedArray(){let e=this.headersMap.size,t=Array(e);if(e<=32){if(e===0)return t;let n=this.headersMap[Symbol.iterator](),r=n.next().value;t[0]=[r[0],r[1].value],p(r[1].value!==null);for(let r=1,i=0,a=0,o=0,s=0,c,l;r<e;++r){for(l=n.next().value,c=t[r]=[l[0],l[1].value],p(c[1]!==null),o=0,a=r;o<a;)s=o+(a-o>>1),t[s][0]<=c[0]?o=s+1:a=s;if(r!==s){for(i=r;i>o;)t[i]=t[--i];t[o]=c}}if(!n.next().done)throw TypeError(`Unreachable`);return t}else{let e=0;for(let{0:n,1:{value:r}}of this.headersMap)t[e++]=[n,r],p(r!==null);return t.sort(E)}}},O=new WeakMap,k=new WeakMap;i=_.inspect.custom;var A=class e{constructor(e=void 0){y(this,O,void 0),y(this,k,void 0),d.util.markAsUncloneable(this),e!==a&&(b(k,this,new D),b(O,this,`none`),e!==void 0&&(e=d.converters.HeadersInit(e,`Headers constructor`,`init`),C(this,e)))}append(t,n){d.brandCheck(this,e),d.argumentLengthCheck(arguments,2,`Headers.append`);let r=`Headers.append`;return t=d.converters.ByteString(t,r,`name`),n=d.converters.ByteString(n,r,`value`),w(this,t,n)}delete(t){if(d.brandCheck(this,e),d.argumentLengthCheck(arguments,1,`Headers.delete`),t=d.converters.ByteString(t,`Headers.delete`,`name`),!c(t))throw d.errors.invalidArgument({prefix:`Headers.delete`,value:t,type:`header name`});if(v(O,this)===`immutable`)throw TypeError(`immutable`);v(k,this).contains(t,!1)&&v(k,this).delete(t,!1)}get(t){d.brandCheck(this,e),d.argumentLengthCheck(arguments,1,`Headers.get`);let n=`Headers.get`;if(t=d.converters.ByteString(t,n,`name`),!c(t))throw d.errors.invalidArgument({prefix:n,value:t,type:`header name`});return v(k,this).get(t,!1)}has(t){d.brandCheck(this,e),d.argumentLengthCheck(arguments,1,`Headers.has`);let n=`Headers.has`;if(t=d.converters.ByteString(t,n,`name`),!c(t))throw d.errors.invalidArgument({prefix:n,value:t,type:`header name`});return v(k,this).contains(t,!1)}set(t,n){d.brandCheck(this,e),d.argumentLengthCheck(arguments,2,`Headers.set`);let r=`Headers.set`;if(t=d.converters.ByteString(t,r,`name`),n=d.converters.ByteString(n,r,`value`),n=S(n),!c(t))throw d.errors.invalidArgument({prefix:r,value:t,type:`header name`});if(!l(n))throw d.errors.invalidArgument({prefix:r,value:n,type:`header value`});if(v(O,this)===`immutable`)throw TypeError(`immutable`);v(k,this).set(t,n,!1)}getSetCookie(){d.brandCheck(this,e);let t=v(k,this).cookies;return t?[...t]:[]}[i](e,t){return t.depth??(t.depth=e),`Headers ${_.formatWithOptions(t,v(k,this).entries)}`}static getHeadersGuard(e){return v(O,e)}static setHeadersGuard(e,t){b(O,e,t)}static getHeadersList(e){return v(k,e)}static setHeadersList(e,t){b(k,e,t)}},{getHeadersGuard:j,setHeadersGuard:M,getHeadersList:N,setHeadersList:P}=A;Reflect.deleteProperty(A,`getHeadersGuard`),Reflect.deleteProperty(A,`setHeadersGuard`),Reflect.deleteProperty(A,`getHeadersList`),Reflect.deleteProperty(A,`setHeadersList`),s(`Headers`,A,T,0,1),Object.defineProperties(A.prototype,{append:o,delete:o,get:o,has:o,set:o,getSetCookie:o,[Symbol.toStringTag]:{value:`Headers`,configurable:!0},[_.inspect.custom]:{enumerable:!1}}),d.converters.HeadersInit=function(e,t,n){if(d.util.Type(e)===d.util.Types.OBJECT){let r=Reflect.get(e,Symbol.iterator);if(!_.types.isProxy(e)&&r===A.prototype.entries)try{return N(e).entriesList}catch{}return typeof r==`function`?d.converters[`sequence<sequence<ByteString>>`](e,t,n,r.bind(e)):d.converters[`record<ByteString, ByteString>`](e,t,n)}throw d.errors.conversionFailed({prefix:`Headers constructor`,argument:`Argument 1`,types:[`sequence<sequence<ByteString>>`,`record<ByteString, ByteString>`]})},n.exports={fill:C,compareHeaderName:E,Headers:A,HeadersList:D,getHeadersGuard:j,setHeadersGuard:M,setHeadersList:P,getHeadersList:N}})),Ht=r(((t,n)=>{m(),h(),g();var r,{Headers:i,HeadersList:a,fill:o,getHeadersGuard:s,setHeadersGuard:c,setHeadersList:l}=Vt(),{extractBody:u,cloneBody:d,mixinBody:f,streamRegistry:p,bodyUnusable:_}=je(),x=Q(),S=e(`node:util`),{kEnumerableProperty:C}=x,{isValidReasonPhrase:w,isCancelled:T,isAborted:E,isErrorLike:D,environmentSettingsObject:O}=De(),{redirectStatusSet:k,nullBodyStatus:A}=be(),{webidl:j}=Ee(),{URLSerializer:M}=we(),{kConstruct:N}=X(),P=e(`node:assert`),{isomorphicEncode:F,serializeJavascriptValueToJSONString:I}=Ce(),L=new TextEncoder(`utf-8`),R=new WeakMap,z=new WeakMap;r=S.inspect.custom;var B=class e{static error(){return Y(K(),`immutable`)}static json(e,t=void 0){j.argumentLengthCheck(arguments,1,`Response.json`),t!==null&&(t=j.converters.ResponseInit(t));let n=u(L.encode(I(e))),r=Y(G({}),`response`);return re(r,t,{body:n[0],type:`application/json`}),r}static redirect(e,t=302){j.argumentLengthCheck(arguments,1,`Response.redirect`),e=j.converters.USVString(e),t=j.converters[`unsigned short`](t);let n;try{n=new URL(e,O.settingsObject.baseUrl)}catch(t){throw TypeError(`Failed to parse URL from ${e}`,{cause:t})}if(!k.has(t))throw RangeError(`Invalid status code ${t}`);let r=Y(G({}),`immutable`);v(z,r).status=t;let i=F(M(n));return v(z,r).headersList.append(`location`,i,!0),r}constructor(e=null,t=void 0){if(y(this,R,void 0),y(this,z,void 0),j.util.markAsUncloneable(this),e===N)return;e!==null&&(e=j.converters.BodyInit(e,`Response`,`body`)),t=j.converters.ResponseInit(t),b(z,this,G({})),b(R,this,new i(N)),c(v(R,this),`response`),l(v(R,this),v(z,this).headersList);let n=null;if(e!=null){let[t,r]=u(e);n={body:t,type:r}}re(this,t,n)}get type(){return j.brandCheck(this,e),v(z,this).type}get url(){j.brandCheck(this,e);let t=v(z,this).urlList,n=t[t.length-1]??null;return n===null?``:M(n,!0)}get redirected(){return j.brandCheck(this,e),v(z,this).urlList.length>1}get status(){return j.brandCheck(this,e),v(z,this).status}get ok(){return j.brandCheck(this,e),v(z,this).status>=200&&v(z,this).status<=299}get statusText(){return j.brandCheck(this,e),v(z,this).statusText}get headers(){return j.brandCheck(this,e),v(R,this)}get body(){return j.brandCheck(this,e),v(z,this).body?v(z,this).body.stream:null}get bodyUsed(){return j.brandCheck(this,e),!!v(z,this).body&&x.isDisturbed(v(z,this).body.stream)}clone(){if(j.brandCheck(this,e),_(v(z,this)))throw j.errors.exception({header:`Response.clone`,message:`Body has already been consumed.`});let t=W(v(z,this));return v(z,this).urlList.length!==0&&v(z,this).body?.stream&&p.register(this,new WeakRef(v(z,this).body.stream)),Y(t,s(v(R,this)))}[r](e,t){t.depth===null&&(t.depth=2),t.colors??(t.colors=!0);let n={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${S.formatWithOptions(t,n)}`}static getResponseHeaders(e){return v(R,e)}static setResponseHeaders(e,t){b(R,e,t)}static getResponseState(e){return v(z,e)}static setResponseState(e,t){b(z,e,t)}},{getResponseHeaders:V,setResponseHeaders:H,getResponseState:ee,setResponseState:U}=B;Reflect.deleteProperty(B,`getResponseHeaders`),Reflect.deleteProperty(B,`setResponseHeaders`),Reflect.deleteProperty(B,`getResponseState`),Reflect.deleteProperty(B,`setResponseState`),f(B,ee),Object.defineProperties(B.prototype,{type:C,url:C,status:C,ok:C,redirected:C,statusText:C,headers:C,clone:C,body:C,bodyUsed:C,[Symbol.toStringTag]:{value:`Response`,configurable:!0}}),Object.defineProperties(B,{json:C,redirect:C,error:C});function W(e){if(e.internalResponse)return J(W(e.internalResponse),e.type);let t=G({...e,body:null});return e.body!=null&&(t.body=d(e.body)),t}function G(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:`default`,status:200,timingInfo:null,cacheState:``,statusText:``,...e,headersList:e?.headersList?new a(e?.headersList):new a,urlList:e?.urlList?[...e.urlList]:[]}}function K(e){return G({type:`error`,status:0,error:D(e)?e:Error(e&&String(e)),aborted:e&&e.name===`AbortError`})}function te(e){return e.type===`error`&&e.status===0}function q(e,t){return t={internalResponse:e,...t},new Proxy(e,{get(e,n){return n in t?t[n]:e[n]},set(e,n,r){return P(!(n in t)),e[n]=r,!0}})}function J(e,t){if(t===`basic`)return q(e,{type:`basic`,headersList:e.headersList});if(t===`cors`)return q(e,{type:`cors`,headersList:e.headersList});if(t===`opaque`)return q(e,{type:`opaque`,urlList:[],status:0,statusText:``,body:null});if(t===`opaqueredirect`)return q(e,{type:`opaqueredirect`,status:0,statusText:``,headersList:[],body:null});P(!1)}function ne(e,t=null){return P(T(e)),E(e)?K(Object.assign(new DOMException(`The operation was aborted.`,`AbortError`),{cause:t})):K(Object.assign(new DOMException(`Request was cancelled.`),{cause:t}))}function re(e,t,n){if(t.status!==null&&(t.status<200||t.status>599))throw RangeError(`init["status"] must be in the range of 200 to 599, inclusive.`);if(`statusText`in t&&t.statusText!=null&&!w(String(t.statusText)))throw TypeError(`Invalid statusText`);if(`status`in t&&t.status!=null&&(ee(e).status=t.status),`statusText`in t&&t.statusText!=null&&(ee(e).statusText=t.statusText),`headers`in t&&t.headers!=null&&o(V(e),t.headers),n){if(A.includes(e.status))throw j.errors.exception({header:`Response constructor`,message:`Invalid response status code ${e.status}`});ee(e).body=n.body,n.type!=null&&!ee(e).headersList.contains(`content-type`,!0)&&ee(e).headersList.append(`content-type`,n.type,!0)}}function Y(e,t){let n=new B(N);U(n,e);let r=new i(N);return H(n,r),l(r,e.headersList),c(r,t),e.urlList.length!==0&&e.body?.stream&&p.register(n,new WeakRef(e.body.stream)),n}j.converters.XMLHttpRequestBodyInit=function(e,t,n){return typeof e==`string`?j.converters.USVString(e,t,n):j.is.Blob(e)||j.is.BufferSource(e)||j.is.FormData(e)||j.is.URLSearchParams(e)?e:j.converters.DOMString(e,t,n)},j.converters.BodyInit=function(e,t,n){return j.is.ReadableStream(e)||e?.[Symbol.asyncIterator]?e:j.converters.XMLHttpRequestBodyInit(e,t,n)},j.converters.ResponseInit=j.dictionaryConverter([{key:`status`,converter:j.converters[`unsigned short`],defaultValue:()=>200},{key:`statusText`,converter:j.converters.ByteString,defaultValue:()=>``},{key:`headers`,converter:j.converters.HeadersInit}]),j.is.Response=j.util.MakeTypeAssertion(B),n.exports={isNetworkError:te,makeNetworkError:K,makeResponse:G,makeAppropriateNetworkError:ne,filterResponse:J,Response:B,cloneResponse:W,fromInnerResponse:Y,getResponseState:ee}})),Ut=r(((t,n)=>{m(),g(),h();var r,{extractBody:i,mixinBody:a,cloneBody:o,bodyUnusable:s}=je(),{Headers:c,fill:l,HeadersList:u,setHeadersGuard:d,getHeadersGuard:f,setHeadersList:p,getHeadersList:_}=Vt(),x=Q(),S=e(`node:util`),{isValidHTTPToken:C,sameOrigin:w,environmentSettingsObject:T}=De(),{forbiddenMethodsSet:E,corsSafeListedMethodsSet:D,referrerPolicy:O,requestRedirect:k,requestMode:A,requestCredentials:j,requestCache:M,requestDuplex:N}=be(),{kEnumerableProperty:P,normalizedMethodRecordsBase:F,normalizedMethodRecords:I}=x,{webidl:L}=Ee(),{URLSerializer:R}=we(),{kConstruct:z}=X(),B=e(`node:assert`),{getMaxListeners:V,setMaxListeners:H,defaultMaxListeners:ee}=e(`node:events`),U=Symbol(`abortController`),W=new FinalizationRegistry(({signal:e,abort:t})=>{e.removeEventListener(`abort`,t)}),G=new WeakMap,K;try{K=V(new AbortController().signal)>0}catch{K=!1}function te(e){return t;function t(){let n=e.deref();if(n!==void 0){W.unregister(t),this.removeEventListener(`abort`,t),n.abort(this.reason);let e=G.get(n.signal);if(e!==void 0){if(e.size!==0){for(let t of e){let e=t.deref();e!==void 0&&e.abort(this.reason)}e.clear()}G.delete(n.signal)}}}}var q=!1,J=new WeakMap,ne=new WeakMap,re=new WeakMap,Y=new WeakMap;r=S.inspect.custom;var ie=class e{constructor(e,t=void 0){if(y(this,J,void 0),y(this,ne,void 0),y(this,re,void 0),y(this,Y,void 0),L.util.markAsUncloneable(this),e===z)return;L.argumentLengthCheck(arguments,1,`Request constructor`),e=L.converters.RequestInfo(e),t=L.converters.RequestInit(t);let n=null,r=null,a=T.settingsObject.baseUrl,o=null;if(typeof e==`string`){b(ne,this,t.dispatcher);let i;try{i=new URL(e,a)}catch(t){throw TypeError(`Failed to parse URL from `+e,{cause:t})}if(i.username||i.password)throw TypeError(`Request cannot be constructed from a URL that includes credentials: `+e);n=ue({urlList:[i]}),r=`cors`}else B(L.is.Request(e)),n=v(Y,e),o=v(J,e),b(ne,this,t.dispatcher||v(ne,e));let f=T.settingsObject.origin,m=`client`;if(n.window?.constructor?.name===`EnvironmentSettingsObject`&&w(n.window,f)&&(m=n.window),t.window!=null)throw TypeError(`'window' option '${m}' must be null`);`window`in t&&(m=`no-window`),n=ue({method:n.method,headersList:n.headersList,unsafeRequest:n.unsafeRequest,client:T.settingsObject,window:m,priority:n.priority,origin:n.origin,referrer:n.referrer,referrerPolicy:n.referrerPolicy,mode:n.mode,credentials:n.credentials,cache:n.cache,redirect:n.redirect,integrity:n.integrity,keepalive:n.keepalive,reloadNavigation:n.reloadNavigation,historyNavigation:n.historyNavigation,urlList:[...n.urlList]});let h=Object.keys(t).length!==0;if(h&&(n.mode===`navigate`&&(n.mode=`same-origin`),n.reloadNavigation=!1,n.historyNavigation=!1,n.origin=`client`,n.referrer=`client`,n.referrerPolicy=``,n.url=n.urlList[n.urlList.length-1],n.urlList=[n.url]),t.referrer!==void 0){let e=t.referrer;if(e===``)n.referrer=`no-referrer`;else{let t;try{t=new URL(e,a)}catch(t){throw TypeError(`Referrer "${e}" is not a valid URL.`,{cause:t})}t.protocol===`about:`&&t.hostname===`client`||f&&!w(t,T.settingsObject.baseUrl)?n.referrer=`client`:n.referrer=t}}t.referrerPolicy!==void 0&&(n.referrerPolicy=t.referrerPolicy);let g;if(g=t.mode===void 0?r:t.mode,g===`navigate`)throw L.errors.exception({header:`Request constructor`,message:`invalid request mode navigate.`});if(g!=null&&(n.mode=g),t.credentials!==void 0&&(n.credentials=t.credentials),t.cache!==void 0&&(n.cache=t.cache),n.cache===`only-if-cached`&&n.mode!==`same-origin`)throw TypeError(`'only-if-cached' can be set only with 'same-origin' mode`);if(t.redirect!==void 0&&(n.redirect=t.redirect),t.integrity!=null&&(n.integrity=String(t.integrity)),t.keepalive!==void 0&&(n.keepalive=!!t.keepalive),t.method!==void 0){let e=t.method,r=I[e];if(r!==void 0)n.method=r;else{if(!C(e))throw TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(E.has(t))throw TypeError(`'${e}' HTTP method is unsupported.`);e=F[t]??e,n.method=e}!q&&n.method===`patch`&&(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:`UNDICI-FETCH-patch`}),q=!0)}t.signal!==void 0&&(o=t.signal),b(Y,this,n);let S=new AbortController;if(b(J,this,S.signal),o!=null)if(o.aborted)S.abort(o.reason);else{this[U]=S;let e=te(new WeakRef(S));K&&V(o)===ee&&H(1500,o),x.addAbortListener(o,e),W.register(S,{signal:o,abort:e},e)}if(b(re,this,new c(z)),p(v(re,this),n.headersList),d(v(re,this),`request`),g===`no-cors`){if(!D.has(n.method))throw TypeError(`'${n.method} is unsupported in no-cors mode.`);d(v(re,this),`request-no-cors`)}if(h){let e=_(v(re,this)),n=t.headers===void 0?new u(e):t.headers;if(e.clear(),n instanceof u){for(let{name:t,value:r}of n.rawValues())e.append(t,r,!1);e.cookies=n.cookies}else l(v(re,this),n)}let O=L.is.Request(e)?v(Y,e).body:null;if((t.body!=null||O!=null)&&(n.method===`GET`||n.method===`HEAD`))throw TypeError(`Request with GET/HEAD method cannot have body.`);let k=null;if(t.body!=null){let[e,r]=i(t.body,n.keepalive);k=e,r&&!_(v(re,this)).contains(`content-type`,!0)&&v(re,this).append(`content-type`,r,!0)}let A=k??O;if(A!=null&&A.source==null){if(k!=null&&t.duplex==null)throw TypeError(`RequestInit: duplex option is required when sending a body.`);if(n.mode!==`same-origin`&&n.mode!==`cors`)throw TypeError(`If request is made from ReadableStream, mode should be "same-origin" or "cors"`);n.useCORSPreflightFlag=!0}let j=A;if(k==null&&O!=null){if(s(v(Y,e)))throw TypeError(`Cannot construct a Request with a Request object that has already been used.`);let t=new TransformStream;O.stream.pipeThrough(t),j={source:O.source,length:O.length,stream:t.readable}}v(Y,this).body=j}get method(){return L.brandCheck(this,e),v(Y,this).method}get url(){return L.brandCheck(this,e),R(v(Y,this).url)}get headers(){return L.brandCheck(this,e),v(re,this)}get destination(){return L.brandCheck(this,e),v(Y,this).destination}get referrer(){return L.brandCheck(this,e),v(Y,this).referrer===`no-referrer`?``:v(Y,this).referrer===`client`?`about:client`:v(Y,this).referrer.toString()}get referrerPolicy(){return L.brandCheck(this,e),v(Y,this).referrerPolicy}get mode(){return L.brandCheck(this,e),v(Y,this).mode}get credentials(){return L.brandCheck(this,e),v(Y,this).credentials}get cache(){return L.brandCheck(this,e),v(Y,this).cache}get redirect(){return L.brandCheck(this,e),v(Y,this).redirect}get integrity(){return L.brandCheck(this,e),v(Y,this).integrity}get keepalive(){return L.brandCheck(this,e),v(Y,this).keepalive}get isReloadNavigation(){return L.brandCheck(this,e),v(Y,this).reloadNavigation}get isHistoryNavigation(){return L.brandCheck(this,e),v(Y,this).historyNavigation}get signal(){return L.brandCheck(this,e),v(J,this)}get body(){return L.brandCheck(this,e),v(Y,this).body?v(Y,this).body.stream:null}get bodyUsed(){return L.brandCheck(this,e),!!v(Y,this).body&&x.isDisturbed(v(Y,this).body.stream)}get duplex(){return L.brandCheck(this,e),`half`}clone(){if(L.brandCheck(this,e),s(v(Y,this)))throw TypeError(`unusable`);let t=$(v(Y,this)),n=new AbortController;if(this.signal.aborted)n.abort(this.signal.reason);else{let e=G.get(this.signal);e===void 0&&(e=new Set,G.set(this.signal,e));let t=new WeakRef(n);e.add(t),x.addAbortListener(n.signal,te(t))}return de(t,v(ne,this),n.signal,f(v(re,this)))}[r](e,t){t.depth===null&&(t.depth=2),t.colors??(t.colors=!0);let n={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${S.formatWithOptions(t,n)}`}static setRequestSignal(e,t){return b(J,e,t),e}static getRequestDispatcher(e){return v(ne,e)}static setRequestDispatcher(e,t){b(ne,e,t)}static setRequestHeaders(e,t){b(re,e,t)}static getRequestState(e){return v(Y,e)}static setRequestState(e,t){b(Y,e,t)}},{setRequestSignal:Z,getRequestDispatcher:ae,setRequestDispatcher:oe,setRequestHeaders:se,getRequestState:ce,setRequestState:le}=ie;Reflect.deleteProperty(ie,`setRequestSignal`),Reflect.deleteProperty(ie,`getRequestDispatcher`),Reflect.deleteProperty(ie,`setRequestDispatcher`),Reflect.deleteProperty(ie,`setRequestHeaders`),Reflect.deleteProperty(ie,`getRequestState`),Reflect.deleteProperty(ie,`setRequestState`),a(ie,ce);function ue(e){return{method:e.method??`GET`,localURLsOnly:e.localURLsOnly??!1,unsafeRequest:e.unsafeRequest??!1,body:e.body??null,client:e.client??null,reservedClient:e.reservedClient??null,replacesClientId:e.replacesClientId??``,window:e.window??`client`,keepalive:e.keepalive??!1,serviceWorkers:e.serviceWorkers??`all`,initiator:e.initiator??``,destination:e.destination??``,priority:e.priority??null,origin:e.origin??`client`,policyContainer:e.policyContainer??`client`,referrer:e.referrer??`client`,referrerPolicy:e.referrerPolicy??``,mode:e.mode??`no-cors`,useCORSPreflightFlag:e.useCORSPreflightFlag??!1,credentials:e.credentials??`same-origin`,useCredentials:e.useCredentials??!1,cache:e.cache??`default`,redirect:e.redirect??`follow`,integrity:e.integrity??``,cryptoGraphicsNonceMetadata:e.cryptoGraphicsNonceMetadata??``,parserMetadata:e.parserMetadata??``,reloadNavigation:e.reloadNavigation??!1,historyNavigation:e.historyNavigation??!1,userActivation:e.userActivation??!1,taintedOrigin:e.taintedOrigin??!1,redirectCount:e.redirectCount??0,responseTainting:e.responseTainting??`basic`,preventNoCacheCacheControlHeaderModification:e.preventNoCacheCacheControlHeaderModification??!1,done:e.done??!1,timingAllowFailed:e.timingAllowFailed??!1,useURLCredentials:e.useURLCredentials??void 0,traversableForUserPrompts:e.traversableForUserPrompts??`client`,urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new u(e.headersList):new u}}function $(e){let t=ue({...e,body:null});return e.body!=null&&(t.body=o(e.body)),t}function de(e,t,n,r){let i=new ie(z);le(i,e),oe(i,t),Z(i,n);let a=new c(z);return se(i,a),p(a,e.headersList),d(a,r),i}Object.defineProperties(ie.prototype,{method:P,url:P,headers:P,redirect:P,clone:P,signal:P,duplex:P,destination:P,body:P,bodyUsed:P,isHistoryNavigation:P,isReloadNavigation:P,keepalive:P,integrity:P,cache:P,credentials:P,attribute:P,referrerPolicy:P,referrer:P,mode:P,[Symbol.toStringTag]:{value:`Request`,configurable:!0}}),L.is.Request=L.util.MakeTypeAssertion(ie),L.converters.RequestInfo=function(e){return typeof e==`string`?L.converters.USVString(e):L.is.Request(e)?e:L.converters.USVString(e)},L.converters.RequestInit=L.dictionaryConverter([{key:`method`,converter:L.converters.ByteString},{key:`headers`,converter:L.converters.HeadersInit},{key:`body`,converter:L.nullableConverter(L.converters.BodyInit)},{key:`referrer`,converter:L.converters.USVString},{key:`referrerPolicy`,converter:L.converters.DOMString,allowedValues:O},{key:`mode`,converter:L.converters.DOMString,allowedValues:A},{key:`credentials`,converter:L.converters.DOMString,allowedValues:j},{key:`cache`,converter:L.converters.DOMString,allowedValues:M},{key:`redirect`,converter:L.converters.DOMString,allowedValues:k},{key:`integrity`,converter:L.converters.DOMString},{key:`keepalive`,converter:L.converters.boolean},{key:`signal`,converter:L.nullableConverter(e=>L.converters.AbortSignal(e,`RequestInit`,`signal`))},{key:`window`,converter:L.converters.any},{key:`duplex`,converter:L.converters.DOMString,allowedValues:N},{key:`dispatcher`,converter:L.converters.any},{key:`priority`,converter:L.converters.DOMString,allowedValues:[`high`,`low`,`auto`],defaultValue:()=>`auto`}]),n.exports={Request:ie,makeRequest:ue,fromInnerRequest:de,cloneRequest:$,getRequestDispatcher:ae,getRequestState:ce}})),Wt=r(((t,n)=>{var r=e(`node:assert`),{runtimeFeatures:i}=Te(),a=new Map([[`sha256`,0],[`sha384`,1],[`sha512`,2]]),o;if(i.has(`crypto`)){o=e(`node:crypto`);let t=o.getHashes();t.length===0&&a.clear();for(let e of a.keys())t.includes(e)===!1&&a.delete(e)}else a.clear();var s=Map.prototype.get.bind(a),c=Map.prototype.has.bind(a),l=i.has(`crypto`)===!1||a.size===0?()=>!0:(e,t)=>{let n=d(t);if(n.length===0)return!0;let r=u(n);for(let t of r){let n=t.alg,r=t.val;if(p(f(n,e),r))return!0}return!1};function u(e){let t=[],n=null;for(let i of e){if(r(c(i.alg),`Invalid SRI hash algorithm token`),t.length===0){t.push(i),n=i;continue}let e=n.alg,a=s(e),o=i.alg,l=s(o);l<a||(l>a?(n=i,t[0]=i,t.length=1):t.push(i))}return t}function d(e){let t=[];for(let n of e.split(` `)){let e=n.split(`?`,1)[0],r=``,i=[e.slice(0,6),e.slice(7)],a=i[0];if(!c(a))continue;i[1]&&(r=i[1]);let o={alg:a,val:r};t.push(o)}return t}var f=(e,t)=>o.hash(e,t,`base64`);function p(e,t){let n=e.length;n!==0&&e[n-1]===`=`&&--n,n!==0&&e[n-1]===`=`&&--n;let r=t.length;if(r!==0&&t[r-1]===`=`&&--r,r!==0&&t[r-1]===`=`&&--r,n!==r)return!1;for(let r=0;r<n;++r)if(!(e[r]===t[r]||e[r]===`+`&&t[r]===`-`||e[r]===`/`&&t[r]===`_`))return!1;return!0}n.exports={applyAlgorithmToBytes:f,bytesMatch:l,caseSensitiveMatch:p,isValidSRIHashAlgorithm:c,getStrongestMetadata:u,parseMetadata:d}})),Gt=r(((t,n)=>{var{makeNetworkError:r,makeAppropriateNetworkError:i,filterResponse:a,makeResponse:o,fromInnerResponse:s,getResponseState:c}=Ht(),{HeadersList:l}=Vt(),{Request:u,cloneRequest:d,getRequestDispatcher:f,getRequestState:p}=Ut(),m=e(`node:zlib`),{makePolicyContainer:h,clonePolicyContainer:g,requestBadPort:_,TAOCheck:v,appendRequestOriginHeader:y,responseLocationURL:b,requestCurrentURL:x,setRequestReferrerPolicyOnRedirect:S,tryUpgradeRequestToAPotentiallyTrustworthyURL:C,createOpaqueTimingInfo:w,appendFetchMetadata:T,corsCheck:E,crossOriginResourcePolicyCheck:D,determineRequestsReferrer:O,coarsenedSharedCurrentTime:k,sameOrigin:A,isCancelled:j,isAborted:M,isErrorLike:N,fullyReadBody:P,readableStreamClose:F,urlIsLocal:I,urlIsHttpHttpsScheme:L,urlHasHttpsScheme:R,clampAndCoarsenConnectionTimingInfo:z,simpleRangeHeaderValue:B,buildContentRange:V,createInflate:H,extractMimeType:ee,hasAuthenticationEntry:U,includesCredentials:W,isTraversableNavigable:G}=De(),K=e(`node:assert`),{safelyExtractBody:te,extractBody:q}=je(),{redirectStatusSet:J,nullBodyStatus:ne,safeMethodsSet:re,requestBodyHeader:Y,subresourceSet:X}=be(),ie=e(`node:events`),{Readable:Z,pipeline:ae,finished:oe,isErrored:se,isReadable:ce}=e(`node:stream`),{addAbortListener:le,bufferToLowerCasedHeaderName:ue}=Q(),{dataURLProcessor:$,serializeAMimeType:de,minimizeSupportedMimeType:fe}=we(),{getGlobalDispatcher:pe}=ht(),{webidl:me}=Ee(),{STATUS_CODES:he}=e(`node:http`),{bytesMatch:ge}=Wt(),{createDeferredPromise:_e}=Ae(),{isomorphicEncode:ve}=Ce(),{runtimeFeatures:ye}=Te(),xe=ye.has(`zstd`),Se=[`GET`,`HEAD`],Oe=typeof __UNDICI_IS_NODE__<`u`||typeof esbuildDetection<`u`?`node`:`undici`,ke,Me=class extends ie{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state=`ongoing`}terminate(e){this.state===`ongoing`&&(this.state=`terminated`,this.connection?.destroy(e),this.emit(`terminated`,e))}abort(e){this.state===`ongoing`&&(this.state=`aborted`,e||(e=new DOMException(`The operation was aborted.`,`AbortError`)),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit(`terminated`,e))}};function Ne(e){Fe(e,`fetch`)}function Pe(e,t=void 0){me.argumentLengthCheck(arguments,1,`globalThis.fetch`);let n=_e(),r;try{r=new u(e,t)}catch(e){return n.reject(e),n.promise}let i=p(r);if(r.signal.aborted)return Le(n,i,null,r.signal.reason,null),n.promise;i.client.globalObject?.constructor?.name===`ServiceWorkerGlobalScope`&&(i.serviceWorkers=`none`);let a=null,o=!1,c=null;return le(r.signal,()=>{o=!0,K(c!=null),c.abort(r.signal.reason);let e=a?.deref();Le(n,i,e,r.signal.reason,c.controller)}),c=Re({request:i,processResponseEndOfBody:Ne,processResponse:e=>{if(!o){if(e.aborted){Le(n,i,a,c.serializedAbortReason,c.controller);return}if(e.type===`error`){n.reject(TypeError(`fetch failed`,{cause:e.error}));return}a=new WeakRef(s(e,`immutable`)),n.resolve(a.deref()),n=null}},dispatcher:f(r),requestObject:r}),n.promise}function Fe(e,t=`other`){if(e.type===`error`&&e.aborted||!e.urlList?.length)return;let n=e.urlList[0],r=e.timingInfo,i=e.cacheState;L(n)&&r!==null&&(e.timingAllowPassed||(r=w({startTime:r.startTime}),i=``),r.endTime=k(),e.timingInfo=r,Ie(r,n.href,t,globalThis,i,``,e.status))}var Ie=performance.markResourceTiming;function Le(e,t,n,r,i){if(e&&e.reject(r),t.body?.stream!=null&&ce(t.body.stream)&&t.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e}),n==null)return;let a=c(n);a.body?.stream!=null&&ce(a.body.stream)&&i.error(r)}function Re({request:e,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseEndOfBody:i,processResponseConsumeBody:a,useParallelQueue:o=!1,dispatcher:s=pe(),requestObject:c=null}){K(s);let l=null,u=!1;e.client!=null&&(l=e.client.globalObject,u=e.client.crossOriginIsolatedCapability);let d=w({startTime:k(u)}),f={controller:new Me(s),request:e,timingInfo:d,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseConsumeBody:a,processResponseEndOfBody:i,taskDestination:l,crossOriginIsolatedCapability:u,requestObject:c};return K(!e.body||e.body.stream),e.window===`client`&&(e.window=e.client?.globalObject?.constructor?.name===`Window`?e.client:`no-window`),e.origin===`client`&&(e.origin=e.client.origin),e.policyContainer===`client`&&(e.client==null?e.policyContainer=h():e.policyContainer=g(e.client.policyContainer)),e.headersList.contains(`accept`,!0)||e.headersList.append(`accept`,`*/*`,!0),e.headersList.contains(`accept-language`,!0)||e.headersList.append(`accept-language`,`*`,!0),e.priority,X.has(e.destination),ze(f,!1),f.controller}async function ze(e,t){try{let n=e.request,i=null;if(n.localURLsOnly&&!I(x(n))&&(i=r(`local URLs only`)),C(n),_(n)===`blocked`&&(i=r(`bad port`)),n.referrerPolicy===``&&(n.referrerPolicy=n.policyContainer.referrerPolicy),n.referrer!==`no-referrer`&&(n.referrer=O(n)),i===null){let t=x(n);A(t,n.url)&&n.responseTainting===`basic`||t.protocol===`data:`||n.mode===`navigate`||n.mode===`websocket`?(n.responseTainting=`basic`,i=await Be(e)):n.mode===`same-origin`?i=r(`request mode cannot be "same-origin"`):n.mode===`no-cors`?n.redirect===`follow`?(n.responseTainting=`opaque`,i=await Be(e)):i=r(`redirect mode cannot be "follow" for "no-cors" request`):L(x(n))?(n.responseTainting=`cors`,i=await Ue(e)):i=r(`URL scheme must be a HTTP(S) scheme`)}if(t)return i;i.status!==0&&!i.internalResponse&&(n.responseTainting,n.responseTainting===`basic`?i=a(i,`basic`):n.responseTainting===`cors`?i=a(i,`cors`):n.responseTainting===`opaque`?i=a(i,`opaque`):K(!1));let o=i.status===0?i:i.internalResponse;if(o.urlList.length===0&&o.urlList.push(...n.urlList),n.timingAllowFailed||(i.timingAllowPassed=!0),i.type===`opaque`&&o.status===206&&o.rangeRequested&&!n.headers.contains(`range`,!0)&&(i=o=r()),i.status!==0&&(n.method===`HEAD`||n.method===`CONNECT`||ne.includes(o.status))&&(o.body=null,e.controller.dump=!0),n.integrity){let t=t=>He(e,r(t));if(n.responseTainting===`opaque`||i.body==null){t(i.error);return}P(i.body,r=>{if(!ge(r,n.integrity)){t(`integrity mismatch`);return}i.body=te(r)[0],He(e,i)},t)}else He(e,i)}catch(t){e.controller.terminate(t)}}function Be(t){if(j(t)&&t.request.redirectCount===0)return Promise.resolve(i(t));let{request:n}=t,{protocol:a}=x(n);switch(a){case`about:`:return Promise.resolve(r(`about scheme is not supported`));case`blob:`:{ke||(ke=e(`node:buffer`).resolveObjectURL);let t=x(n);if(t.search.length!==0)return Promise.resolve(r(`NetworkError when attempting to fetch resource.`));let i=ke(t.toString());if(n.method!==`GET`||!me.is.Blob(i))return Promise.resolve(r(`invalid method`));let a=o(),s=i.size,c=ve(`${s}`),l=i.type;if(n.headersList.contains(`range`,!0)){a.rangeRequested=!0;let e=B(n.headersList.get(`range`,!0),!0);if(e===`failure`)return Promise.resolve(r(`failed to fetch the data URL`));let{rangeStartValue:t,rangeEndValue:o}=e;if(t===null)t=s-o,o=t+o-1;else{if(t>=s)return Promise.resolve(r(`Range start is greater than the blob's size.`));(o===null||o>=s)&&(o=s-1)}let c=i.slice(t,o+1,l);a.body=q(c)[0];let u=ve(`${c.size}`),d=V(t,o,s);a.status=206,a.statusText=`Partial Content`,a.headersList.set(`content-length`,u,!0),a.headersList.set(`content-type`,l,!0),a.headersList.set(`content-range`,d,!0)}else{let e=q(i);a.statusText=`OK`,a.body=e[0],a.headersList.set(`content-length`,c,!0),a.headersList.set(`content-type`,l,!0)}return Promise.resolve(a)}case`data:`:{let e=$(x(n));if(e===`failure`)return Promise.resolve(r(`failed to fetch the data URL`));let t=de(e.mimeType);return Promise.resolve(o({statusText:`OK`,headersList:[[`content-type`,{name:`Content-Type`,value:t}]],body:te(e.body)[0]}))}case`file:`:return Promise.resolve(r(`not implemented... yet...`));case`http:`:case`https:`:return Ue(t).catch(e=>r(e));default:return Promise.resolve(r(`unknown scheme`))}}function Ve(e,t){e.request.done=!0,e.processResponseDone!=null&&queueMicrotask(()=>e.processResponseDone(t))}function He(e,t){let n=e.timingInfo,r=()=>{let r=Date.now();e.request.destination===`document`&&(e.controller.fullTimingInfo=n),e.controller.reportTimingSteps=()=>{if(!L(e.request.url))return;n.endTime=r;let i=t.cacheState,a=t.bodyInfo;t.timingAllowPassed||(n=w(n),i=``);let o=0;if(e.request.mode!==`navigate`||!t.hasCrossOriginRedirects){o=t.status;let e=ee(t.headersList);e!==`failure`&&(a.contentType=fe(e))}e.request.initiatorType!=null&&Ie(n,e.request.url.href,e.request.initiatorType,globalThis,i,a,o)};let i=()=>{e.request.done=!0,e.processResponseEndOfBody!=null&&queueMicrotask(()=>e.processResponseEndOfBody(t)),e.request.initiatorType!=null&&e.controller.reportTimingSteps()};queueMicrotask(()=>i())};e.processResponse!=null&&queueMicrotask(()=>{e.processResponse(t),e.processResponse=null});let i=t.type===`error`?t:t.internalResponse??t;i.body==null?r():oe(i.body.stream,()=>{r()})}async function Ue(e){let t=e.request,n=null,i=null,a=e.timingInfo;if(t.serviceWorkers,n===null){if(t.redirect===`follow`&&(t.serviceWorkers=`none`),i=n=await Ge(e),t.responseTainting===`cors`&&E(t,n)===`failure`)return r(`cors failure`);v(t,n)===`failure`&&(t.timingAllowFailed=!0)}return(t.responseTainting===`opaque`||n.type===`opaque`)&&D(t.origin,t.client,t.destination,i)===`blocked`?r(`blocked`):(J.has(i.status)&&(t.redirect!==`manual`&&e.controller.connection.destroy(void 0,!1),t.redirect===`error`?n=r(`unexpected redirect`):t.redirect===`manual`?n=i:t.redirect===`follow`?n=await We(e,n):K(!1)),n.timingInfo=a,n)}function We(e,t){let n=e.request,i=t.internalResponse?t.internalResponse:t,a;try{if(a=b(i,x(n).hash),a==null)return t}catch(e){return Promise.resolve(r(e))}if(!L(a))return Promise.resolve(r(`URL scheme must be a HTTP(S) scheme`));if(n.redirectCount===20)return Promise.resolve(r(`redirect count exceeded`));if(n.redirectCount+=1,n.mode===`cors`&&(a.username||a.password)&&!A(n,a))return Promise.resolve(r(`cross origin not allowed for request mode "cors"`));if(n.responseTainting===`cors`&&(a.username||a.password))return Promise.resolve(r(`URL cannot contain credentials for request mode "cors"`));if(i.status!==303&&n.body!=null&&n.body.source==null)return Promise.resolve(r());if([301,302].includes(i.status)&&n.method===`POST`||i.status===303&&!Se.includes(n.method)){n.method=`GET`,n.body=null;for(let e of Y)n.headersList.delete(e)}A(x(n),a)||(n.headersList.delete(`authorization`,!0),n.headersList.delete(`proxy-authorization`,!0),n.headersList.delete(`cookie`,!0),n.headersList.delete(`host`,!0)),n.body!=null&&(K(n.body.source!=null),n.body=te(n.body.source)[0]);let o=e.timingInfo;return o.redirectEndTime=o.postRedirectStartTime=k(e.crossOriginIsolatedCapability),o.redirectStartTime===0&&(o.redirectStartTime=o.startTime),n.urlList.push(a),S(n,i),ze(e,!0)}async function Ge(e,t=!1,n=!1){let a=e.request,o=null,s=null,c=null;a.window===`no-window`&&a.redirect===`error`?(o=e,s=a):(s=d(a),o={...e},o.request=s);let l=a.credentials===`include`||a.credentials===`same-origin`&&a.responseTainting===`basic`,u=s.body?s.body.length:null,f=null;if(s.body==null&&[`POST`,`PUT`].includes(s.method)&&(f=`0`),u!=null&&(f=ve(`${u}`)),f!=null&&!s.headersList.contains(`content-length`,!0)&&s.headersList.append(`content-length`,f,!0),u!=null&&s.keepalive,me.is.URL(s.referrer)&&s.headersList.append(`referer`,ve(s.referrer.href),!0),y(s),T(s),s.headersList.contains(`user-agent`,!0)||s.headersList.append(`user-agent`,Oe,!0),s.cache==="default"&&(s.headersList.contains(`if-modified-since`,!0)||s.headersList.contains(`if-none-match`,!0)||s.headersList.contains(`if-unmodified-since`,!0)||s.headersList.contains(`if-match`,!0)||s.headersList.contains(`if-range`,!0))&&(s.cache=`no-store`),s.cache===`no-cache`&&!s.preventNoCacheCacheControlHeaderModification&&!s.headersList.contains(`cache-control`,!0)&&s.headersList.append(`cache-control`,`max-age=0`,!0),(s.cache===`no-store`||s.cache===`reload`)&&(s.headersList.contains(`pragma`,!0)||s.headersList.append(`pragma`,`no-cache`,!0),s.headersList.contains(`cache-control`,!0)||s.headersList.append(`cache-control`,`no-cache`,!0)),s.headersList.contains(`range`,!0)&&s.headersList.append(`accept-encoding`,`identity`,!0),s.headersList.contains(`accept-encoding`,!0)||(R(x(s))?s.headersList.append(`accept-encoding`,`br, gzip, deflate`,!0):s.headersList.append(`accept-encoding`,`gzip, deflate`,!0)),s.headersList.delete(`host`,!0),l&&!s.headersList.contains(`authorization`,!0)){let e=null;if(!(U(s)&&(s.useURLCredentials===void 0||!W(x(s))))&&W(x(s))&&t){let{username:t,password:n}=x(s);e=`Basic ${Buffer.from(`${t}:${n}`).toString(`base64`)}`}e!==null&&s.headersList.append(`Authorization`,e,!1)}if(s.cache=`no-store`,s.cache!==`no-store`&&s.cache,c==null){if(s.cache===`only-if-cached`)return r(`only if cached`);let e=await Ke(o,l,n);!re.has(s.method)&&e.status>=200&&e.status,c??(c=e)}if(c.urlList=[...s.urlList],s.headersList.contains(`range`,!0)&&(c.rangeRequested=!0),c.requestIncludesCredentials=l,c.status===401&&s.responseTainting!==`cors`&&l&&(a.useURLCredentials!==void 0||G(a.traversableForUserPrompts))){if(a.body!=null){if(a.body.source==null)return c;a.body=te(a.body.source)[0]}if(a.useURLCredentials===void 0||t)return j(e)?i(e):c;e.controller.connection.destroy(),c=await Ge(e,!0)}if(c.status===407)return a.window===`no-window`?r():j(e)?i(e):r(`proxy authentication required`);if(c.status===421&&!n&&(a.body==null||a.body.source!=null)){if(j(e))return i(e);e.controller.connection.destroy(),c=await Ge(e,t,!0)}return c}async function Ke(e,t=!1,n=!1){K(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(e,t=!0){this.destroyed||(this.destroyed=!0,t&&this.abort?.(e??new DOMException(`The operation was aborted.`,`AbortError`)))}};let a=e.request,s=null,c=e.timingInfo;a.cache=`no-store`,a.mode;let u=null;if(a.body==null&&e.processRequestEndOfBody)queueMicrotask(()=>e.processRequestEndOfBody());else if(a.body!=null){let t=async function*(t){j(e)||(yield t,e.processRequestBodyChunkLength?.(t.byteLength))},n=()=>{j(e)||e.processRequestEndOfBody&&e.processRequestEndOfBody()},r=t=>{j(e)||(t.name===`AbortError`?e.controller.abort():e.controller.terminate(t))};u=(async function*(){try{for await(let e of a.body.stream)yield*t(e);n()}catch(e){r(e)}})()}try{let{body:t,status:n,statusText:r,headersList:i,socket:a}=await p({body:u});if(a)s=o({status:n,statusText:r,headersList:i,socket:a});else{let a=t[Symbol.asyncIterator]();e.controller.next=()=>a.next(),s=o({status:n,statusText:r,headersList:i})}}catch(t){return t.name===`AbortError`?(e.controller.connection.destroy(),i(e,t)):r(t)}let d=new ReadableStream({start(t){e.controller.controller=t},pull:()=>e.controller.resume(),cancel:t=>{j(e)||e.controller.abort(t)},type:`bytes`});s.body={stream:d,source:null,length:null},e.controller.resume||e.controller.on(`terminated`,f),e.controller.resume=async()=>{for(;;){let t,n;try{let{done:n,value:r}=await e.controller.next();if(M(e))break;t=n?void 0:r}catch(r){e.controller.ended&&!c.encodedBodySize?t=void 0:(t=r,n=!0)}if(t===void 0){F(e.controller.controller),Ve(e,s);return}if(c.decodedBodySize+=t?.byteLength??0,n){e.controller.terminate(t);return}let r=new Uint8Array(t);if(r.byteLength&&e.controller.controller.enqueue(r),se(d)){e.controller.terminate();return}if(e.controller.controller.desiredSize<=0)return}};function f(t){M(e)?(s.aborted=!0,ce(d)&&e.controller.controller.error(e.controller.serializedAbortReason)):ce(d)&&e.controller.controller.error(TypeError(`terminated`,{cause:N(t)?t:void 0})),e.controller.connection.destroy()}return s;function p({body:t}){let n=x(a),r=e.controller.dispatcher,i=n.pathname+n.search,o=n.search.length===0&&n.href[n.href.length-n.hash.length-1]===`?`;return new Promise((s,u)=>r.dispatch({path:o?`${i}?`:i,origin:n.origin,method:a.method,body:r.isMockActive?a.body&&(a.body.source||a.body.stream):t,headers:a.headersList.entries,maxRedirections:0,upgrade:a.mode===`websocket`?`websocket`:void 0},{body:null,abort:null,onConnect(t){let{connection:n}=e.controller;c.finalConnectionTimingInfo=z(void 0,c.postRedirectStartTime,e.crossOriginIsolatedCapability),n.destroyed?t(new DOMException(`The operation was aborted.`,`AbortError`)):(e.controller.on(`terminated`,t),this.abort=n.abort=t),c.finalNetworkRequestStartTime=k(e.crossOriginIsolatedCapability)},onResponseStarted(){c.finalNetworkResponseStartTime=k(e.crossOriginIsolatedCapability)},onHeaders(e,t,n,r){if(e<200)return!1;let i=new l;for(let e=0;e<t.length;e+=2){let n=ue(t[e]),r=t[e+1];if(Array.isArray(r)&&!Buffer.isBuffer(t[e+1]))for(let e of r)i.append(n,e.toString(`latin1`),!0);else i.append(n,r.toString(`latin1`),!0)}let o=i.get(`location`,!0);this.body=new Z({read:n});let c=o&&a.redirect===`follow`&&J.has(e),d=[];if(a.method!==`HEAD`&&a.method!==`CONNECT`&&!ne.includes(e)&&!c){let e=i.get(`content-encoding`,!0),t=e?e.toLowerCase().split(`,`):[];if(t.length>5)return u(Error(`too many content-encodings in response: ${t.length}, maximum allowed is 5`)),!0;for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n===`x-gzip`||n===`gzip`)d.push(m.createGunzip({flush:m.constants.Z_SYNC_FLUSH,finishFlush:m.constants.Z_SYNC_FLUSH}));else if(n===`deflate`)d.push(H({flush:m.constants.Z_SYNC_FLUSH,finishFlush:m.constants.Z_SYNC_FLUSH}));else if(n===`br`)d.push(m.createBrotliDecompress({flush:m.constants.BROTLI_OPERATION_FLUSH,finishFlush:m.constants.BROTLI_OPERATION_FLUSH}));else if(n===`zstd`&&xe)d.push(m.createZstdDecompress({flush:m.constants.ZSTD_e_continue,finishFlush:m.constants.ZSTD_e_end}));else{d.length=0;break}}}let f=this.onError.bind(this);return s({status:e,statusText:r,headersList:i,body:d.length?ae(this.body,...d,e=>{e&&this.onError(e)}).on(`error`,f):this.body.on(`error`,f)}),!0},onData(t){if(e.controller.dump)return;let n=t;return c.encodedBodySize+=n.byteLength,this.body.push(n)},onComplete(){this.abort&&e.controller.off(`terminated`,this.abort),e.controller.ended=!0,this.body.push(null)},onError(t){this.abort&&e.controller.off(`terminated`,this.abort),this.body?.destroy(t),e.controller.terminate(t),u(t)},onRequestUpgrade(e,t,n,r){if(r.session!=null&&t!==200||r.session==null&&t!==101)return!1;let i=new l;for(let[e,t]of Object.entries(n)){if(t==null)continue;let n=e.toLowerCase();if(Array.isArray(t))for(let e of t)i.append(n,String(e),!0);else i.append(n,String(t),!0)}return s({status:t,statusText:he[t],headersList:i,socket:r}),!0},onUpgrade(e,t,n){if(n.session!=null&&e!==200||n.session==null&&e!==101)return!1;let r=new l;for(let e=0;e<t.length;e+=2){let n=ue(t[e]),i=t[e+1];if(Array.isArray(i)&&!Buffer.isBuffer(t[e+1]))for(let e of i)r.append(n,e.toString(`latin1`),!0);else r.append(n,i.toString(`latin1`),!0)}return s({status:e,statusText:he[e],headersList:r,socket:n}),!0}}))}}n.exports={fetch:Pe,Fetch:Me,fetching:Re,finalizeAndReportTiming:Fe}})),Kt=r(((t,n)=>{var r=e(`node:assert`),{URLSerializer:i}=we(),{isValidHeaderName:a}=De();function o(e,t,n=!1){return i(e,n)===i(t,n)}function s(e){r(e!==null);let t=[];for(let n of e.split(`,`))n=n.trim(),a(n)&&t.push(n);return t}n.exports={urlEquals:o,getFieldValues:s}})),qt=r(((t,n)=>{x(),m(),g(),_(),h();var r=e(`node:assert`),{kConstruct:i}=X(),{urlEquals:a,getFieldValues:o}=Kt(),{kEnumerableProperty:s,isDisturbed:c}=Q(),{webidl:l}=Ee(),{cloneResponse:u,fromInnerResponse:d,getResponseState:f}=Ht(),{Request:C,fromInnerRequest:w,getRequestState:T}=Ut(),{fetching:E}=Gt(),{urlIsHttpHttpsScheme:D,readAllBytes:O}=De(),{createDeferredPromise:k}=Ae(),A=new WeakMap,j=new WeakSet,M=class e{constructor(){S(this,j),y(this,A,void 0),arguments[0]!==i&&l.illegalConstructor(),l.util.markAsUncloneable(this),b(A,this,arguments[1])}async match(t,n={}){l.brandCheck(this,e);let r=`Cache.match`;l.argumentLengthCheck(arguments,1,r),t=l.converters.RequestInfo(t),n=l.converters.CacheQueryOptions(n,r,`options`);let i=p(j,this,I).call(this,t,n,1);if(i.length!==0)return i[0]}async matchAll(t=void 0,n={}){return l.brandCheck(this,e),t!==void 0&&(t=l.converters.RequestInfo(t)),n=l.converters.CacheQueryOptions(n,`Cache.matchAll`,`options`),p(j,this,I).call(this,t,n)}async add(t){l.brandCheck(this,e),l.argumentLengthCheck(arguments,1,`Cache.add`),t=l.converters.RequestInfo(t);let n=[t];return await this.addAll(n)}async addAll(t){l.brandCheck(this,e);let n=`Cache.addAll`;l.argumentLengthCheck(arguments,1,n);let r=[],i=[];for(let e of t){if(e===void 0)throw l.errors.conversionFailed({prefix:n,argument:`Argument 1`,types:[`undefined is not allowed`]});if(e=l.converters.RequestInfo(e),typeof e==`string`)continue;let t=T(e);if(!D(t.url)||t.method!==`GET`)throw l.errors.exception({header:n,message:`Expected http/s scheme when method is not GET.`})}let a=[];for(let e of t){let t=T(new C(e));if(!D(t.url))throw l.errors.exception({header:n,message:`Expected http/s scheme.`});t.initiator=`fetch`,t.destination=`subresource`,i.push(t);let s=k();a.push(E({request:t,processResponse(e){if(e.type===`error`||e.status===206||e.status<200||e.status>299)s.reject(l.errors.exception({header:`Cache.addAll`,message:`Received an invalid status code or the request failed.`}));else if(e.headersList.contains(`vary`)){let t=o(e.headersList.get(`vary`));for(let e of t)if(e===`*`){s.reject(l.errors.exception({header:`Cache.addAll`,message:`invalid vary field value`}));for(let e of a)e.abort();return}}},processResponseEndOfBody(e){if(e.aborted){s.reject(new DOMException(`aborted`,`AbortError`));return}s.resolve(e)}})),r.push(s.promise)}let s=await Promise.all(r),c=[],u=0;for(let e of s){let t={type:`put`,request:i[u],response:e};c.push(t),u++}let d=k(),f=null;try{p(j,this,N).call(this,c)}catch(e){f=e}return queueMicrotask(()=>{f===null?d.resolve(void 0):d.reject(f)}),d.promise}async put(t,n){l.brandCheck(this,e);let r=`Cache.put`;l.argumentLengthCheck(arguments,2,r),t=l.converters.RequestInfo(t),n=l.converters.Response(n,r,`response`);let i=null;if(i=l.is.Request(t)?T(t):T(new C(t)),!D(i.url)||i.method!==`GET`)throw l.errors.exception({header:r,message:`Expected an http/s scheme when method is not GET`});let a=f(n);if(a.status===206)throw l.errors.exception({header:r,message:`Got 206 status`});if(a.headersList.contains(`vary`)){let e=o(a.headersList.get(`vary`));for(let t of e)if(t===`*`)throw l.errors.exception({header:r,message:`Got * vary field value`})}if(a.body&&(c(a.body.stream)||a.body.stream.locked))throw l.errors.exception({header:r,message:`Response body is locked or disturbed`});let s=u(a),d=k();a.body==null?d.resolve(void 0):O(a.body.stream.getReader(),d.resolve,d.reject);let m=[],h={type:`put`,request:i,response:s};m.push(h);let g=await d.promise;s.body!=null&&(s.body.source=g);let _=k(),v=null;try{p(j,this,N).call(this,m)}catch(e){v=e}return queueMicrotask(()=>{v===null?_.resolve():_.reject(v)}),_.promise}async delete(t,n={}){l.brandCheck(this,e);let i=`Cache.delete`;l.argumentLengthCheck(arguments,1,i),t=l.converters.RequestInfo(t),n=l.converters.CacheQueryOptions(n,i,`options`);let a=null;if(l.is.Request(t)){if(a=T(t),a.method!==`GET`&&!n.ignoreMethod)return!1}else r(typeof t==`string`),a=T(new C(t));let o=[],s={type:`delete`,request:a,options:n};o.push(s);let c=k(),u=null,d;try{d=p(j,this,N).call(this,o)}catch(e){u=e}return queueMicrotask(()=>{u===null?c.resolve(!!d?.length):c.reject(u)}),c.promise}async keys(t=void 0,n={}){l.brandCheck(this,e),t!==void 0&&(t=l.converters.RequestInfo(t)),n=l.converters.CacheQueryOptions(n,`Cache.keys`,`options`);let r=null;if(t!==void 0)if(l.is.Request(t)){if(r=T(t),r.method!==`GET`&&!n.ignoreMethod)return[]}else typeof t==`string`&&(r=T(new C(t)));let i=k(),a=[];if(t===void 0)for(let e of v(A,this))a.push(e[0]);else{let e=p(j,this,P).call(this,r,n);for(let t of e)a.push(t[0])}return queueMicrotask(()=>{let e=[];for(let t of a){let n=w(t,void 0,new AbortController().signal,`immutable`);e.push(n)}i.resolve(Object.freeze(e))}),i.promise}};function N(e){let t=v(A,this),n=[...t],i=[],a=[];try{for(let n of e){if(n.type!==`delete`&&n.type!==`put`)throw l.errors.exception({header:`Cache.#batchCacheOperations`,message:`operation type does not match "delete" or "put"`});if(n.type===`delete`&&n.response!=null)throw l.errors.exception({header:`Cache.#batchCacheOperations`,message:`delete operation should not have an associated response`});if(p(j,this,P).call(this,n.request,n.options,i).length)throw new DOMException(`???`,`InvalidStateError`);let e;if(n.type===`delete`){if(e=p(j,this,P).call(this,n.request,n.options),e.length===0)return[];for(let n of e){let e=t.indexOf(n);r(e!==-1),t.splice(e,1)}}else if(n.type===`put`){if(n.response==null)throw l.errors.exception({header:`Cache.#batchCacheOperations`,message:`put operation should have an associated response`});let a=n.request;if(!D(a.url))throw l.errors.exception({header:`Cache.#batchCacheOperations`,message:`expected http or https scheme`});if(a.method!==`GET`)throw l.errors.exception({header:`Cache.#batchCacheOperations`,message:`not get method`});if(n.options!=null)throw l.errors.exception({header:`Cache.#batchCacheOperations`,message:`options must not be defined`});e=p(j,this,P).call(this,n.request);for(let n of e){let e=t.indexOf(n);r(e!==-1),t.splice(e,1)}t.push([n.request,n.response]),i.push([n.request,n.response])}a.push([n.request,n.response])}return a}catch(e){throw v(A,this).length=0,b(A,this,n),e}}function P(e,t,n){let r=[],i=n??v(A,this);for(let n of i){let[i,a]=n;p(j,this,F).call(this,e,i,a,t)&&r.push(n)}return r}function F(e,t,n=null,r){let i=new URL(e.url),s=new URL(t.url);if(r?.ignoreSearch&&(s.search=``,i.search=``),!a(i,s,!0))return!1;if(n==null||r?.ignoreVary||!n.headersList.contains(`vary`))return!0;let c=o(n.headersList.get(`vary`));for(let n of c)if(n===`*`||t.headersList.get(n)!==e.headersList.get(n))return!1;return!0}function I(e,t,n=1/0){let r=null;if(e!==void 0)if(l.is.Request(e)){if(r=T(e),r.method!==`GET`&&!t.ignoreMethod)return[]}else typeof e==`string`&&(r=T(new C(e)));let i=[];if(e===void 0)for(let e of v(A,this))i.push(e[1]);else{let e=p(j,this,P).call(this,r,t);for(let t of e)i.push(t[1])}let a=[];for(let e of i){let t=d(u(e),`immutable`);if(a.push(t),a.length>=n)break}return Object.freeze(a)}Object.defineProperties(M.prototype,{[Symbol.toStringTag]:{value:`Cache`,configurable:!0},match:s,matchAll:s,add:s,addAll:s,put:s,delete:s,keys:s});var L=[{key:`ignoreSearch`,converter:l.converters.boolean,defaultValue:()=>!1},{key:`ignoreMethod`,converter:l.converters.boolean,defaultValue:()=>!1},{key:`ignoreVary`,converter:l.converters.boolean,defaultValue:()=>!1}];l.converters.CacheQueryOptions=l.dictionaryConverter(L),l.converters.MultiCacheQueryOptions=l.dictionaryConverter([...L,{key:`cacheName`,converter:l.converters.DOMString}]),l.converters.Response=l.interfaceConverter(l.is.Response,`Response`),l.converters[`sequence<RequestInfo>`]=l.sequenceConverter(l.converters.RequestInfo),n.exports={Cache:M}})),Jt=r(((e,t)=>{m(),h();var{Cache:n}=qt(),{webidl:r}=Ee(),{kEnumerableProperty:i}=Q(),{kConstruct:a}=X(),o=new WeakMap,s=class e{constructor(){y(this,o,new Map),arguments[0]!==a&&r.illegalConstructor(),r.util.markAsUncloneable(this)}async match(t,i={}){if(r.brandCheck(this,e),r.argumentLengthCheck(arguments,1,`CacheStorage.match`),t=r.converters.RequestInfo(t),i=r.converters.MultiCacheQueryOptions(i),i.cacheName!=null){if(v(o,this).has(i.cacheName))return await new n(a,v(o,this).get(i.cacheName)).match(t,i)}else for(let e of v(o,this).values()){let r=await new n(a,e).match(t,i);if(r!==void 0)return r}}async has(t){r.brandCheck(this,e);let n=`CacheStorage.has`;return r.argumentLengthCheck(arguments,1,n),t=r.converters.DOMString(t,n,`cacheName`),v(o,this).has(t)}async open(t){r.brandCheck(this,e);let i=`CacheStorage.open`;if(r.argumentLengthCheck(arguments,1,i),t=r.converters.DOMString(t,i,`cacheName`),v(o,this).has(t))return new n(a,v(o,this).get(t));let s=[];return v(o,this).set(t,s),new n(a,s)}async delete(t){r.brandCheck(this,e);let n=`CacheStorage.delete`;return r.argumentLengthCheck(arguments,1,n),t=r.converters.DOMString(t,n,`cacheName`),v(o,this).delete(t)}async keys(){return r.brandCheck(this,e),[...v(o,this).keys()]}};Object.defineProperties(s.prototype,{[Symbol.toStringTag]:{value:`CacheStorage`,configurable:!0},match:i,has:i,open:i,delete:i,keys:i}),t.exports={CacheStorage:s}})),Yt=r(((e,t)=>{t.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}})),Xt=r(((e,t)=>{function n(e){for(let t=0;t<e.length;++t){let n=e.charCodeAt(t);if(n>=0&&n<=8||n>=10&&n<=31||n===127)return!0}return!1}function r(e){for(let t=0;t<e.length;++t){let n=e.charCodeAt(t);if(n<33||n>126||n===34||n===40||n===41||n===60||n===62||n===64||n===44||n===59||n===58||n===92||n===47||n===91||n===93||n===63||n===61||n===123||n===125)throw Error(`Invalid cookie name`)}}function i(e){let t=e.length,n=0;if(e[0]===`"`){if(t===1||e[t-1]!==`"`)throw Error(`Invalid cookie value`);--t,++n}for(;n<t;){let t=e.charCodeAt(n++);if(t<33||t>126||t===34||t===44||t===59||t===92)throw Error(`Invalid cookie value`)}}function a(e){for(let t=0;t<e.length;++t){let n=e.charCodeAt(t);if(n<32||n===127||n===59)throw Error(`Invalid cookie path`)}}function o(e){if(e.startsWith(`-`)||e.endsWith(`.`)||e.endsWith(`-`))throw Error(`Invalid cookie domain`)}var s=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],c=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],l=Array(61).fill(0).map((e,t)=>t.toString().padStart(2,`0`));function u(e){return typeof e==`number`&&(e=new Date(e)),`${s[e.getUTCDay()]}, ${l[e.getUTCDate()]} ${c[e.getUTCMonth()]} ${e.getUTCFullYear()} ${l[e.getUTCHours()]}:${l[e.getUTCMinutes()]}:${l[e.getUTCSeconds()]} GMT`}function d(e){if(e<0)throw Error(`Invalid cookie max-age`)}function f(e){if(e.name.length===0)return null;r(e.name),i(e.value);let t=[`${e.name}=${e.value}`];e.name.startsWith(`__Secure-`)&&(e.secure=!0),e.name.startsWith(`__Host-`)&&(e.secure=!0,e.domain=null,e.path=`/`),e.secure&&t.push(`Secure`),e.httpOnly&&t.push(`HttpOnly`),typeof e.maxAge==`number`&&(d(e.maxAge),t.push(`Max-Age=${e.maxAge}`)),e.domain&&(o(e.domain),t.push(`Domain=${e.domain}`)),e.path&&(a(e.path),t.push(`Path=${e.path}`)),e.expires&&e.expires.toString()!==`Invalid Date`&&t.push(`Expires=${u(e.expires)}`),e.sameSite&&t.push(`SameSite=${e.sameSite}`);for(let n of e.unparsed){if(!n.includes(`=`))throw Error(`Invalid unparsed`);let[e,...r]=n.split(`=`);t.push(`${e.trim()}=${r.join(`=`)}`)}return t.join(`; `)}t.exports={isCTLExcludingHtab:n,validateCookieName:r,validateCookiePath:a,validateCookieValue:i,toIMFDate:u,stringify:f}})),Zt=r(((t,n)=>{var{collectASequenceOfCodePointsFast:r}=Ce(),{maxNameValuePairSize:i,maxAttributeValueSize:a}=Yt(),{isCTLExcludingHtab:o}=Xt(),s=e(`node:assert`);function c(e){if(o(e))return null;let t=``,n=``,a=``,s=``;if(e.includes(`;`)){let i={position:0};t=r(`;`,e,i),n=e.slice(i.position)}else t=e;if(!t.includes(`=`))s=t;else{let e={position:0};a=r(`=`,t,e),s=t.slice(e.position+1)}return a=a.trim(),s=s.trim(),a.length+s.length>i?null:{name:a,value:s,...l(n)}}function l(e,t={}){if(e.length===0)return t;s(e[0]===`;`),e=e.slice(1);let n=``;e.includes(`;`)?(n=r(`;`,e,{position:0}),e=e.slice(n.length)):(n=e,e=``);let i=``,o=``;if(n.includes(`=`)){let e={position:0};i=r(`=`,n,e),o=n.slice(e.position+1)}else i=n;if(i=i.trim(),o=o.trim(),o.length>a)return l(e,t);let c=i.toLowerCase();if(c===`expires`)t.expires=new Date(o);else if(c===`max-age`){let n=o.charCodeAt(0);if((n<48||n>57)&&o[0]!==`-`||!/^\d+$/.test(o))return l(e,t);t.maxAge=Number(o)}else if(c===`domain`){let e=o;e[0]===`.`&&(e=e.slice(1)),e=e.toLowerCase(),t.domain=e}else if(c===`path`){let e=``;e=o.length===0||o[0]!==`/`?`/`:o,t.path=e}else if(c===`secure`)t.secure=!0;else if(c===`httponly`)t.httpOnly=!0;else if(c===`samesite`){let e=o.toLowerCase();e===`none`?t.sameSite=`None`:e===`strict`?t.sameSite=`Strict`:e===`lax`&&(t.sameSite=`Lax`)}else t.unparsed??(t.unparsed=[]),t.unparsed.push(`${i}=${o}`);return l(e,t)}n.exports={parseSetCookie:c,parseUnparsedAttributes:l}})),Qt=r(((e,t)=>{var{parseSetCookie:n}=Zt(),{stringify:r}=Xt(),{webidl:i}=Ee(),{Headers:a}=Vt(),o=i.brandCheckMultiple([a,globalThis.Headers].filter(Boolean));function s(e){i.argumentLengthCheck(arguments,1,`getCookies`),o(e);let t=e.get(`cookie`),n={};if(!t)return n;for(let e of t.split(`;`)){let[t,...r]=e.split(`=`);n[t.trim()]=r.join(`=`)}return n}function c(e,t,n){o(e);let r=`deleteCookie`;i.argumentLengthCheck(arguments,2,r),t=i.converters.DOMString(t,r,`name`),n=i.converters.DeleteCookieAttributes(n),d(e,{name:t,value:``,expires:new Date(0),...n})}function l(e){i.argumentLengthCheck(arguments,1,`getSetCookies`),o(e);let t=e.getSetCookie();return t?t.map(e=>n(e)):[]}function u(e){return e=i.converters.DOMString(e),n(e)}function d(e,t){i.argumentLengthCheck(arguments,2,`setCookie`),o(e),t=i.converters.Cookie(t);let n=r(t);n&&e.append(`set-cookie`,n,!0)}i.converters.DeleteCookieAttributes=i.dictionaryConverter([{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null}]),i.converters.Cookie=i.dictionaryConverter([{converter:i.converters.DOMString,key:`name`},{converter:i.converters.DOMString,key:`value`},{converter:i.nullableConverter(e=>typeof e==`number`?i.converters[`unsigned long long`](e):new Date(e)),key:`expires`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters[`long long`]),key:`maxAge`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`secure`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`httpOnly`,defaultValue:()=>null},{converter:i.converters.USVString,key:`sameSite`,allowedValues:[`Strict`,`Lax`,`None`]},{converter:i.sequenceConverter(i.converters.DOMString),key:`unparsed`,defaultValue:()=>[]}]),t.exports={getCookies:s,deleteCookie:c,getSetCookies:l,setCookie:d,parseCookie:u}})),$t=r(((e,t)=>{m(),g(),h();var{webidl:n}=Ee(),{kEnumerableProperty:r}=Q(),{kConstruct:i}=X(),a=new WeakMap,o=class e extends Event{constructor(e,t={}){var r=(...e)=>(super(...e),y(this,a,void 0),this);if(e===i){r(arguments[1],arguments[2]),n.util.markAsUncloneable(this);return}let o=`MessageEvent constructor`;n.argumentLengthCheck(arguments,1,o),e=n.converters.DOMString(e,o,`type`),t=n.converters.MessageEventInit(t,o,`eventInitDict`),r(e,t),b(a,this,t),n.util.markAsUncloneable(this)}get data(){return n.brandCheck(this,e),v(a,this).data}get origin(){return n.brandCheck(this,e),v(a,this).origin}get lastEventId(){return n.brandCheck(this,e),v(a,this).lastEventId}get source(){return n.brandCheck(this,e),v(a,this).source}get ports(){return n.brandCheck(this,e),Object.isFrozen(v(a,this).ports)||Object.freeze(v(a,this).ports),v(a,this).ports}initMessageEvent(t,r=!1,i=!1,a=null,o=``,s=``,c=null,l=[]){return n.brandCheck(this,e),n.argumentLengthCheck(arguments,1,`MessageEvent.initMessageEvent`),new e(t,{bubbles:r,cancelable:i,data:a,origin:o,lastEventId:s,source:c,ports:l})}static createFastMessageEvent(t,n){var r,o,s,c,l;let u=new e(i,t,n);return b(a,u,n),(r=v(a,u)).data??(r.data=null),(o=v(a,u)).origin??(o.origin=``),(s=v(a,u)).lastEventId??(s.lastEventId=``),(c=v(a,u)).source??(c.source=null),(l=v(a,u)).ports??(l.ports=[]),u}},{createFastMessageEvent:s}=o;delete o.createFastMessageEvent;var c=new WeakMap,l=class e extends Event{constructor(e,t={}){let r=`CloseEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.CloseEventInit(t),super(e,t),y(this,c,void 0),b(c,this,t),n.util.markAsUncloneable(this)}get wasClean(){return n.brandCheck(this,e),v(c,this).wasClean}get code(){return n.brandCheck(this,e),v(c,this).code}get reason(){return n.brandCheck(this,e),v(c,this).reason}},u=new WeakMap,d=class e extends Event{constructor(e,t){let r=`ErrorEvent constructor`;n.argumentLengthCheck(arguments,1,r),super(e,t),y(this,u,void 0),n.util.markAsUncloneable(this),e=n.converters.DOMString(e,r,`type`),t=n.converters.ErrorEventInit(t??{}),b(u,this,t)}get message(){return n.brandCheck(this,e),v(u,this).message}get filename(){return n.brandCheck(this,e),v(u,this).filename}get lineno(){return n.brandCheck(this,e),v(u,this).lineno}get colno(){return n.brandCheck(this,e),v(u,this).colno}get error(){return n.brandCheck(this,e),v(u,this).error}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`MessageEvent`,configurable:!0},data:r,origin:r,lastEventId:r,source:r,ports:r,initMessageEvent:r}),Object.defineProperties(l.prototype,{[Symbol.toStringTag]:{value:`CloseEvent`,configurable:!0},reason:r,code:r,wasClean:r}),Object.defineProperties(d.prototype,{[Symbol.toStringTag]:{value:`ErrorEvent`,configurable:!0},message:r,filename:r,lineno:r,colno:r,error:r}),n.converters.MessagePort=n.interfaceConverter(n.is.MessagePort,`MessagePort`),n.converters[`sequence<MessagePort>`]=n.sequenceConverter(n.converters.MessagePort);var f=[{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}];n.converters.MessageEventInit=n.dictionaryConverter([...f,{key:`data`,converter:n.converters.any,defaultValue:()=>null},{key:`origin`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lastEventId`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`source`,converter:n.nullableConverter(n.converters.MessagePort),defaultValue:()=>null},{key:`ports`,converter:n.converters[`sequence<MessagePort>`],defaultValue:()=>[]}]),n.converters.CloseEventInit=n.dictionaryConverter([...f,{key:`wasClean`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`code`,converter:n.converters[`unsigned short`],defaultValue:()=>0},{key:`reason`,converter:n.converters.USVString,defaultValue:()=>``}]),n.converters.ErrorEventInit=n.dictionaryConverter([...f,{key:`message`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`filename`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lineno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`colno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`error`,converter:n.converters.any}]),t.exports={MessageEvent:o,CloseEvent:l,ErrorEvent:d,createFastMessageEvent:s}})),en=r(((e,t)=>{t.exports={uid:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,sentCloseFrameState:{SENT:1,RECEIVED:2},staticPropertyDescriptors:{enumerable:!0,writable:!1,configurable:!1},states:{CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},opcodes:{CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},maxUnsigned16Bit:65535,parserStates:{INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},emptyBuffer:Buffer.allocUnsafe(0),sendHints:{text:1,typedArray:2,arrayBuffer:3,blob:4}}})),tn=r(((t,n)=>{var{states:r,opcodes:i}=en(),{isUtf8:a}=e(`node:buffer`),{removeHTTPWhitespace:o}=we(),{collectASequenceOfCodePointsFast:s}=Ce();function c(e){return e===r.CONNECTING}function l(e){return e===r.OPEN}function u(e){return e===r.CLOSING}function d(e){return e===r.CLOSED}function f(e,t,n=(e,t)=>new Event(e,t),r={}){let i=n(e,r);t.dispatchEvent(i)}function p(e,t,n){e.onMessage(t,n)}function m(e){return e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function h(e){if(e.length===0)return!1;for(let t=0;t<e.length;++t){let n=e.charCodeAt(t);if(n<33||n>126||n===34||n===40||n===41||n===44||n===47||n===58||n===59||n===60||n===61||n===62||n===63||n===64||n===91||n===92||n===93||n===123||n===125)return!1}return!0}function g(e){return e>=1e3&&e<1015?e!==1004&&e!==1005&&e!==1006:e>=3e3&&e<=4999}function _(e){return e===i.CLOSE||e===i.PING||e===i.PONG}function v(e){return e===i.CONTINUATION}function y(e){return e===i.TEXT||e===i.BINARY}function b(e){return y(e)||v(e)||_(e)}function x(e){let t={position:0},n=new Map;for(;t.position<e.length;){let[r,i=``]=s(`;`,e,t).split(`=`,2);n.set(o(r,!0,!1),o(i,!1,!0)),t.position++}return n}function S(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}let t=Number.parseInt(e,10);return t>=8&&t<=15}function C(e,t){let n;try{n=new URL(e,t)}catch(e){throw new DOMException(e,`SyntaxError`)}if(n.protocol===`http:`?n.protocol=`ws:`:n.protocol===`https:`&&(n.protocol=`wss:`),n.protocol!==`ws:`&&n.protocol!==`wss:`)throw new DOMException(`expected a ws: or wss: url`,`SyntaxError`);if(n.hash.length||n.href.endsWith(`#`))throw new DOMException(`hash`,`SyntaxError`);return n}function w(e,t){if(e!==null&&e!==1e3&&(e<3e3||e>4999))throw new DOMException(`invalid code`,`InvalidAccessError`);if(t!==null){let e=Buffer.byteLength(t);if(e>123)throw new DOMException(`Reason must be less than 123 bytes; received ${e}`,`SyntaxError`)}}n.exports={isConnecting:c,isEstablished:l,isClosing:u,isClosed:d,fireEvent:f,isValidSubprotocol:h,isValidStatusCode:g,websocketMessageReceived:p,utf8Decode:(()=>{if(typeof process.versions.icu==`string`){let e=new TextDecoder(`utf-8`,{fatal:!0});return e.decode.bind(e)}return function(e){if(a(e))return e.toString(`utf-8`);throw TypeError(`Invalid utf-8 received.`)}})(),isControlFrame:_,isContinuationFrame:v,isTextBinaryFrame:y,isValidOpcode:b,parseExtensions:x,isValidClientWindowBits:S,toArrayBuffer:m,getURLRecord:C,validateCloseCodeAndReason:w}})),nn=r(((t,n)=>{var{runtimeFeatures:r}=Te(),{maxUnsigned16Bit:i,opcodes:a}=en(),o=8*1024,s=null,c=o,l=r.has(`crypto`)?e(`node:crypto`).randomFillSync:function(e,t,n){for(let t=0;t<e.length;++t)e[t]=Math.random()*255|0;return e};function u(){return c===o&&(c=0,l(s??(s=Buffer.allocUnsafeSlow(o)),0,o)),[s[c++],s[c++],s[c++],s[c++]]}n.exports={WebsocketFrameSend:class{constructor(e){this.frameData=e}createFrame(e){let t=this.frameData,n=u(),r=t?.byteLength??0,a=r,o=6;r>i?(o+=8,a=127):r>125&&(o+=2,a=126);let s=Buffer.allocUnsafe(r+o);s[0]=s[1]=0,s[0]|=128,s[0]=(s[0]&240)+e,s[o-4]=n[0],s[o-3]=n[1],s[o-2]=n[2],s[o-1]=n[3],s[1]=a,a===126?s.writeUInt16BE(r,2):a===127&&(s[2]=s[3]=0,s.writeUIntBE(r,4,6)),s[1]|=128;for(let e=0;e<r;++e)s[o+e]=t[e]^n[e&3];return s}static createFastTextFrame(e){let t=u(),n=e.length;for(let r=0;r<n;++r)e[r]^=t[r&3];let r=n,o=6;n>i?(o+=8,r=127):n>125&&(o+=2,r=126);let s=Buffer.allocUnsafeSlow(o);return s[0]=128|a.TEXT,s[1]=r|128,s[o-4]=t[0],s[o-3]=t[1],s[o-2]=t[2],s[o-1]=t[3],r===126?s.writeUInt16BE(n,2):r===127&&(s[2]=s[3]=0,s.writeUIntBE(n,4,6)),[s,e]}},generateMask:u}})),rn=r(((t,n)=>{var{uid:r,states:i,sentCloseFrameState:a,emptyBuffer:o,opcodes:s}=en(),{parseExtensions:c,isClosed:l,isClosing:u,isEstablished:d,isConnecting:f,validateCloseCodeAndReason:p}=tn(),{makeRequest:m}=Ut(),{fetching:h}=Gt(),{Headers:g,getHeadersList:_}=Vt(),{getDecodeSplit:v}=De(),{WebsocketFrameSend:y}=nn(),b=e(`node:assert`),{runtimeFeatures:x}=Te(),S=x.has(`crypto`)?e(`node:crypto`):null,C=!1;function w(e,t,n,i,a){let o=e;o.protocol=e.protocol===`ws:`?`http:`:`https:`;let s=m({urlList:[o],client:n,serviceWorkers:`none`,referrer:`no-referrer`,mode:`websocket`,credentials:`include`,cache:`no-store`,redirect:`error`,useURLCredentials:!0});a.headers&&(s.headersList=_(new g(a.headers)));let l=S.randomBytes(16).toString(`base64`);s.headersList.append(`sec-websocket-key`,l,!0),s.headersList.append(`sec-websocket-version`,`13`,!0);for(let e of t)s.headersList.append(`sec-websocket-protocol`,e,!0);return s.headersList.append(`sec-websocket-extensions`,`permessage-deflate; client_max_window_bits`,!0),h({request:s,useParallelQueue:!0,dispatcher:a.dispatcher,processResponse(e){if(e.type===`error`||e.status!==101){if(e.socket?.session==null){E(i,1002,`Received network error or non-101 status code.`,e.error);return}if(e.status!==200){E(i,1002,`Received network error or non-200 status code.`,e.error);return}}if(C===!1&&e.socket?.session!=null&&(process.emitWarning(`WebSocket over HTTP2 is experimental, and subject to change.`,`ExperimentalWarning`),C=!0),t.length!==0&&!e.headersList.get(`Sec-WebSocket-Protocol`)){E(i,1002,`Server did not respond with sent protocols.`);return}if(e.socket.session==null&&e.headersList.get(`Upgrade`)?.toLowerCase()!==`websocket`){E(i,1002,`Server did not set Upgrade header to "websocket".`);return}if(e.socket.session==null&&e.headersList.get(`Connection`)?.toLowerCase()!==`upgrade`){E(i,1002,`Server did not set Connection header to "upgrade".`);return}if(e.headersList.get(`Sec-WebSocket-Accept`)!==S.hash(`sha1`,l+r,`base64`)){E(i,1002,`Incorrect hash received in Sec-WebSocket-Accept header.`);return}let n=e.headersList.get(`Sec-WebSocket-Extensions`),a;if(n!==null&&(a=c(n),!a.has(`permessage-deflate`))){E(i,1002,`Sec-WebSocket-Extensions header does not match.`);return}let o=e.headersList.get(`Sec-WebSocket-Protocol`);if(o!==null&&!v(`sec-websocket-protocol`,s.headersList).includes(o)){E(i,1002,`Protocol was not set in the opening handshake.`);return}e.socket.on(`data`,i.onSocketData),e.socket.on(`close`,i.onSocketClose),e.socket.on(`error`,i.onSocketError),i.wasEverConnected=!0,i.onConnectionEstablished(e,a)}})}function T(e,t,n,r=!1){if(t??(t=null),n??(n=``),r&&p(t,n),!(l(e.readyState)||u(e.readyState)))if(!d(e.readyState))E(e),e.readyState=i.CLOSING;else if(!e.closeState.has(a.SENT)&&!e.closeState.has(a.RECEIVED)){let r=new y;n.length!==0&&t===null&&(t=1e3),b(t===null||Number.isInteger(t)),t===null&&n.length===0?r.frameData=o:t!==null&&n===null?(r.frameData=Buffer.allocUnsafe(2),r.frameData.writeUInt16BE(t,0)):t!==null&&n!==null?(r.frameData=Buffer.allocUnsafe(2+Buffer.byteLength(n)),r.frameData.writeUInt16BE(t,0),r.frameData.write(n,2,`utf-8`)):r.frameData=o,e.socket.write(r.createFrame(s.CLOSE)),e.closeState.add(a.SENT),e.readyState=i.CLOSING}else e.readyState=i.CLOSING}function E(e,t,n,r){d(e.readyState)&&T(e,t,n,!1),e.controller.abort(),f(e.readyState)?e.onSocketClose():e.socket?.destroyed===!1&&e.socket.destroy()}n.exports={establishWebSocketConnection:w,failWebsocketConnection:E,closeWebSocketConnection:T}})),an=r(((t,n)=>{m(),h(),g();var{createInflateRaw:r,Z_DEFAULT_WINDOWBITS:i}=e(`node:zlib`),{isValidClientWindowBits:a}=tn(),{MessageSizeExceededError:o}=Z(),s=Buffer.from([0,0,255,255]),c=Symbol(`kBuffer`),l=Symbol(`kLength`),u=new WeakMap,d=new WeakMap,f=new WeakMap;n.exports={PerMessageDeflate:class{constructor(e,t){y(this,u,void 0),y(this,d,{}),y(this,f,0),v(d,this).serverNoContextTakeover=e.has(`server_no_context_takeover`),v(d,this).serverMaxWindowBits=e.get(`server_max_window_bits`),b(f,this,t.maxPayloadSize)}decompress(e,t,n){if(!v(u,this)){let e=i;if(v(d,this).serverMaxWindowBits){if(!a(v(d,this).serverMaxWindowBits)){n(Error(`Invalid server_max_window_bits`));return}e=Number.parseInt(v(d,this).serverMaxWindowBits)}try{b(u,this,r({windowBits:e}))}catch(e){n(e);return}v(u,this)[c]=[],v(u,this)[l]=0,v(u,this).on(`data`,e=>{if(v(u,this)[l]+=e.length,v(f,this)>0&&v(u,this)[l]>v(f,this)){n(new o),v(u,this).removeAllListeners(),b(u,this,null);return}v(u,this)[c].push(e)}),v(u,this).on(`error`,e=>{b(u,this,null),n(e)})}v(u,this).write(e),t&&v(u,this).write(s),v(u,this).flush(()=>{if(!v(u,this))return;let e=Buffer.concat(v(u,this)[c],v(u,this)[l]);v(u,this)[c].length=0,v(u,this)[l]=0,n(null,e)})}}}})),on=r(((t,n)=>{x(),m(),g(),h(),_();var{Writable:r}=e(`node:stream`),i=e(`node:assert`),{parserStates:a,opcodes:o,states:s,emptyBuffer:c,sentCloseFrameState:l}=en(),{isValidStatusCode:u,isValidOpcode:d,websocketMessageReceived:f,utf8Decode:C,isControlFrame:w,isTextBinaryFrame:T,isContinuationFrame:E}=tn(),{failWebsocketConnection:D}=rn(),{WebsocketFrameSend:O}=nn(),{PerMessageDeflate:k}=an(),{MessageSizeExceededError:A}=Z(),j=new WeakMap,M=new WeakMap,N=new WeakMap,P=new WeakMap,F=new WeakMap,I=new WeakMap,L=new WeakMap,R=new WeakMap,z=new WeakMap,B=new WeakMap,V=new WeakMap,H=new WeakSet,ee=class extends r{constructor(e,t,n={}){super(),S(this,H),y(this,j,[]),y(this,M,0),y(this,N,0),y(this,P,!1),y(this,F,a.INFO),y(this,I,{}),y(this,L,[]),y(this,R,void 0),y(this,z,void 0),y(this,B,void 0),y(this,V,void 0),b(z,this,e),b(R,this,t??new Map),b(B,this,n.maxFragments??0),b(V,this,n.maxPayloadSize??0),v(R,this).has(`permessage-deflate`)&&v(R,this).set(`permessage-deflate`,new k(t,n))}_write(e,t,n){v(j,this).push(e),b(N,this,v(N,this)+e.length),b(P,this,!0),this.run(n)}run(e){for(;v(P,this);)if(v(F,this)===a.INFO){if(v(N,this)<2)return e();let t=this.consume(2),n=(t[0]&128)!=0,r=t[0]&15,i=(t[1]&128)==128,s=!n&&r!==o.CONTINUATION,c=t[1]&127,l=t[0]&64,u=t[0]&32,f=t[0]&16;if(!d(r))return D(v(z,this),1002,`Invalid opcode received`),e();if(i)return D(v(z,this),1002,`Frame cannot be masked`),e();if(l!==0&&!v(R,this).has(`permessage-deflate`)){D(v(z,this),1002,`Expected RSV1 to be clear.`);return}if(u!==0||f!==0){D(v(z,this),1002,`RSV1, RSV2, RSV3 must be clear`);return}if(s&&!T(r)){D(v(z,this),1002,`Invalid frame type was fragmented.`);return}if(T(r)&&v(L,this).length>0){D(v(z,this),1002,`Expected continuation frame`);return}if(v(I,this).fragmented&&s){D(v(z,this),1002,`Fragmented frame exceeded 125 bytes.`);return}if((c>125||s)&&w(r)){D(v(z,this),1002,`Control frame either too large or fragmented`);return}if(E(r)&&v(L,this).length===0&&!v(I,this).compressed){D(v(z,this),1002,`Unexpected continuation frame`);return}if(c<=125){if(v(I,this).payloadLength=c,b(F,this,a.READ_DATA),!p(H,this,U).call(this))return}else c===126?b(F,this,a.PAYLOADLENGTH_16):c===127&&b(F,this,a.PAYLOADLENGTH_64);T(r)&&(v(I,this).binaryType=r,v(I,this).compressed=l!==0),v(I,this).opcode=r,v(I,this).masked=i,v(I,this).fin=n,v(I,this).fragmented=s}else if(v(F,this)===a.PAYLOADLENGTH_16){if(v(N,this)<2)return e();let t=this.consume(2);if(v(I,this).payloadLength=t.readUInt16BE(0),b(F,this,a.READ_DATA),!p(H,this,U).call(this))return}else if(v(F,this)===a.PAYLOADLENGTH_64){if(v(N,this)<8)return e();let t=this.consume(8),n=t.readUInt32BE(0),r=t.readUInt32BE(4);if(n!==0||r>2**31-1){D(v(z,this),1009,`Received payload length > 2^31 bytes.`);return}if(v(I,this).payloadLength=r,b(F,this,a.READ_DATA),!p(H,this,U).call(this))return}else if(v(F,this)===a.READ_DATA){if(v(N,this)<v(I,this).payloadLength)return e();let t=this.consume(v(I,this).payloadLength);if(w(v(I,this).opcode))b(P,this,this.parseControlFrame(t)),b(F,this,a.INFO);else if(v(I,this).compressed){v(R,this).get(`permessage-deflate`).decompress(t,v(I,this).fin,(t,n)=>{if(t){let e=t instanceof A?1009:1007;D(v(z,this),e,t.message);return}if(this.writeFragments(n)){if(v(V,this)>0&&v(M,this)>v(V,this)){D(v(z,this),1009,new A().message);return}if(!v(I,this).fin){b(F,this,a.INFO),b(P,this,!0),this.run(e);return}f(v(z,this),v(I,this).binaryType,this.consumeFragments()),b(P,this,!0),b(F,this,a.INFO),this.run(e)}},v(M,this)),b(P,this,!1);break}else{if(!this.writeFragments(t))return;!v(I,this).fragmented&&v(I,this).fin&&f(v(z,this),v(I,this).binaryType,this.consumeFragments()),b(F,this,a.INFO)}}}consume(e){if(e>v(N,this))throw Error(`Called consume() before buffers satiated.`);if(e===0)return c;b(N,this,v(N,this)-e);let t=v(j,this)[0];if(t.length>e)return v(j,this)[0]=t.subarray(e,t.length),t.subarray(0,e);if(t.length===e)return v(j,this).shift();{let t=0,n=Buffer.allocUnsafeSlow(e);for(;t!==e;){let r=v(j,this)[0],i=r.length;if(i+t===e){n.set(v(j,this).shift(),t);break}else if(i+t>e){n.set(r.subarray(0,e-t),t),v(j,this)[0]=r.subarray(e-t);break}else n.set(v(j,this).shift(),t),t+=i}return n}}writeFragments(e){return v(B,this)>0&&v(L,this).length===v(B,this)?(D(v(z,this),1008,`Too many message fragments`),!1):(b(M,this,v(M,this)+e.length),v(L,this).push(e),!0)}consumeFragments(){let e=v(L,this);if(e.length===1)return b(M,this,0),e.shift();let t=0,n=Buffer.allocUnsafeSlow(v(M,this));for(let r=0;r<e.length;++r){let i=e[r];n.set(i,t),t+=i.length}return b(L,this,[]),b(M,this,0),n}parseCloseBody(e){i(e.length!==1);let t;if(e.length>=2&&(t=e.readUInt16BE(0)),t!==void 0&&!u(t))return{code:1002,reason:`Invalid status code`,error:!0};let n=e.subarray(2);n[0]===239&&n[1]===187&&n[2]===191&&(n=n.subarray(3));try{n=C(n)}catch{return{code:1007,reason:`Invalid UTF-8`,error:!0}}return{code:t,reason:n,error:!1}}parseControlFrame(e){let{opcode:t,payloadLength:n}=v(I,this);if(t===o.CLOSE){if(n===1)return D(v(z,this),1002,`Received close frame with a 1-byte body.`),!1;if(v(I,this).closeInfo=this.parseCloseBody(e),v(I,this).closeInfo.error){let{code:e,reason:t}=v(I,this).closeInfo;return D(v(z,this),e,t),!1}if(!v(z,this).closeState.has(l.SENT)&&!v(z,this).closeState.has(l.RECEIVED)){let e=c;v(I,this).closeInfo.code&&(e=Buffer.allocUnsafe(2),e.writeUInt16BE(v(I,this).closeInfo.code,0));let t=new O(e);v(z,this).socket.write(t.createFrame(o.CLOSE)),v(z,this).closeState.add(l.SENT)}return v(z,this).readyState=s.CLOSING,v(z,this).closeState.add(l.RECEIVED),!1}else if(t===o.PING){if(!v(z,this).closeState.has(l.RECEIVED)){let t=new O(e);v(z,this).socket.write(t.createFrame(o.PONG)),v(z,this).onPing(e)}}else t===o.PONG&&v(z,this).onPong(e);return!0}get closingInfo(){return v(I,this).closeInfo}};function U(){return v(V,this)>0&&!w(v(I,this).opcode)&&v(I,this).payloadLength+v(M,this)>v(V,this)?(D(v(z,this),1009,`Payload size exceeds maximum allowed size`),!1):!0}n.exports={ByteParser:ee}})),sn=r(((e,t)=>{x(),m(),g(),h(),_();var{WebsocketFrameSend:n}=nn(),{opcodes:r,sendHints:i}=en(),a=Fe(),o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakSet,u=class{constructor(e){S(this,l),y(this,o,new a),y(this,s,!1),y(this,c,void 0),b(c,this,e)}add(e,t,r){if(r!==i.blob){if(v(s,this)){let n={promise:null,callback:t,frame:f(e,r)};v(o,this).push(n)}else if(r===i.text){let{0:r,1:i}=n.createFastTextFrame(e);v(c,this).cork(),v(c,this).write(r),v(c,this).write(i,t),v(c,this).uncork()}else v(c,this).write(f(e,r),t);return}let a={promise:e.arrayBuffer().then(e=>{a.promise=null,a.frame=f(e,r)}),callback:t,frame:null};v(o,this).push(a),v(s,this)||p(l,this,d).call(this)}};async function d(){b(s,this,!0);let e=v(o,this);for(;!e.isEmpty();){let t=e.shift();t.promise!==null&&await t.promise,v(c,this).write(t.frame,t.callback),t.callback=t.frame=null}b(s,this,!1)}function f(e,t){return new n(C(e,t)).createFrame(t===i.text?r.TEXT:r.BINARY)}function C(e,t){switch(t){case i.text:case i.typedArray:return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);case i.arrayBuffer:case i.blob:return new Uint8Array(e)}}t.exports={SendQueue:u}})),cn=r(((t,n)=>{x(),m(),_(),h(),g();var{isArrayBuffer:r}=e(`node:util/types`),{webidl:i}=Ee(),{URLSerializer:a}=we(),{environmentSettingsObject:o}=De(),{staticPropertyDescriptors:s,states:c,sentCloseFrameState:l,sendHints:u,opcodes:d}=en(),{isConnecting:f,isEstablished:C,isClosing:w,isClosed:T,isValidSubprotocol:E,fireEvent:D,utf8Decode:O,toArrayBuffer:k,getURLRecord:A}=tn(),{establishWebSocketConnection:j,closeWebSocketConnection:M,failWebsocketConnection:N}=rn(),{ByteParser:P}=on(),{kEnumerableProperty:F}=Q(),{getGlobalDispatcher:I}=ht(),{ErrorEvent:L,CloseEvent:R,createFastMessageEvent:z}=$t(),{SendQueue:B}=sn(),{WebsocketFrameSend:V}=nn(),{channels:H}=ce();function ee(e){return typeof e?.address==`function`?e.address():typeof e?.session?.socket?.address==`function`?e.session.socket.address():null}var U=new WeakMap,W=new WeakMap,G=new WeakMap,K=new WeakMap,te=new WeakMap,q=new WeakMap,J=new WeakMap,ne=new WeakMap,re=new WeakMap,Y=new WeakSet,X=class e extends EventTarget{constructor(t,n=[]){super(),S(this,Y),y(this,U,{open:null,error:null,close:null,message:null}),y(this,W,0),y(this,G,``),y(this,K,``),y(this,te,void 0),y(this,q,{onConnectionEstablished:(e,t)=>p(Y,this,ie).call(this,e,t),onMessage:(e,t)=>p(Y,this,Z).call(this,e,t),onParserError:e=>N(v(q,this),null,e.message),onParserDrain:()=>p(Y,this,ae).call(this),onSocketData:e=>{v(re,this).write(e)||v(q,this).socket.pause()},onSocketError:e=>{v(q,this).readyState=c.CLOSING,H.socketError.hasSubscribers&&H.socketError.publish(e),v(q,this).socket.destroy()},onSocketClose:()=>p(Y,this,oe).call(this),onPing:e=>{H.ping.hasSubscribers&&H.ping.publish({payload:e,websocket:this})},onPong:e=>{H.pong.hasSubscribers&&H.pong.publish({payload:e,websocket:this})},readyState:c.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1}),y(this,J,void 0),y(this,ne,void 0),y(this,re,void 0),i.util.markAsUncloneable(this);let r=`WebSocket constructor`;i.argumentLengthCheck(arguments,1,r);let a=i.converters[`DOMString or sequence<DOMString> or WebSocketInit`](n,r,`options`);t=i.converters.USVString(t),n=a.protocols;let s=o.settingsObject.baseUrl,l=A(t,s);if(typeof n==`string`&&(n=[n]),n.length!==new Set(n.map(e=>e.toLowerCase())).size||n.length>0&&!n.every(e=>E(e)))throw new DOMException(`Invalid Sec-WebSocket-Protocol value`,`SyntaxError`);b(J,this,new URL(l.href));let u=o.settingsObject;v(q,this).controller=j(l,n,u,v(q,this),a),v(q,this).readyState=e.CONNECTING,b(ne,this,`blob`)}close(t=void 0,n=void 0){i.brandCheck(this,e),t!==void 0&&(t=i.converters[`unsigned short`](t,`WebSocket.close`,`code`,i.attributes.Clamp)),n!==void 0&&(n=i.converters.USVString(n)),t??(t=null),n??(n=``),M(v(q,this),t,n,!0)}send(t){i.brandCheck(this,e);let n=`WebSocket.send`;if(i.argumentLengthCheck(arguments,1,n),t=i.converters.WebSocketSendData(t,n,`data`),f(v(q,this).readyState))throw new DOMException(`Sent before connected.`,`InvalidStateError`);if(!(!C(v(q,this).readyState)||w(v(q,this).readyState)))if(typeof t==`string`){let e=Buffer.from(t);b(W,this,v(W,this)+e.byteLength),v(te,this).add(e,()=>{b(W,this,v(W,this)-e.byteLength)},u.text)}else r(t)?(b(W,this,v(W,this)+t.byteLength),v(te,this).add(t,()=>{b(W,this,v(W,this)-t.byteLength)},u.arrayBuffer)):ArrayBuffer.isView(t)?(b(W,this,v(W,this)+t.byteLength),v(te,this).add(t,()=>{b(W,this,v(W,this)-t.byteLength)},u.typedArray)):i.is.Blob(t)&&(b(W,this,v(W,this)+t.size),v(te,this).add(t,()=>{b(W,this,v(W,this)-t.size)},u.blob))}get readyState(){return i.brandCheck(this,e),v(q,this).readyState}get bufferedAmount(){return i.brandCheck(this,e),v(W,this)}get url(){return i.brandCheck(this,e),a(v(J,this))}get extensions(){return i.brandCheck(this,e),v(K,this)}get protocol(){return i.brandCheck(this,e),v(G,this)}get onopen(){return i.brandCheck(this,e),v(U,this).open}set onopen(t){i.brandCheck(this,e),v(U,this).open&&this.removeEventListener(`open`,v(U,this).open);let n=i.converters.EventHandlerNonNull(t);n===null?v(U,this).open=null:(this.addEventListener(`open`,n),v(U,this).open=t)}get onerror(){return i.brandCheck(this,e),v(U,this).error}set onerror(t){i.brandCheck(this,e),v(U,this).error&&this.removeEventListener(`error`,v(U,this).error);let n=i.converters.EventHandlerNonNull(t);n===null?v(U,this).error=null:(this.addEventListener(`error`,n),v(U,this).error=t)}get onclose(){return i.brandCheck(this,e),v(U,this).close}set onclose(t){i.brandCheck(this,e),v(U,this).close&&this.removeEventListener(`close`,v(U,this).close);let n=i.converters.EventHandlerNonNull(t);n===null?v(U,this).close=null:(this.addEventListener(`close`,n),v(U,this).close=t)}get onmessage(){return i.brandCheck(this,e),v(U,this).message}set onmessage(t){i.brandCheck(this,e),v(U,this).message&&this.removeEventListener(`message`,v(U,this).message);let n=i.converters.EventHandlerNonNull(t);n===null?v(U,this).message=null:(this.addEventListener(`message`,n),v(U,this).message=t)}get binaryType(){return i.brandCheck(this,e),v(ne,this)}set binaryType(t){i.brandCheck(this,e),t!==`blob`&&t!==`arraybuffer`?b(ne,this,`blob`):b(ne,this,t)}static ping(e,t){if(Buffer.isBuffer(t)){if(t.length>125)throw TypeError(`A PING frame cannot have a body larger than 125 bytes.`)}else if(t!==void 0)throw TypeError(`Expected buffer payload`);let n=v(q,e).readyState;if(C(n)&&!w(n)&&!T(n)){let n=new V(t);v(q,e).socket.write(n.createFrame(d.PING))}}};function ie(e,t){v(q,this).socket=e.socket;let n=v(q,this).controller.dispatcher?.webSocketOptions,r=n?.maxFragments,i=n?.maxPayloadSize,a=new P(v(q,this),t,{maxFragments:r,maxPayloadSize:i});a.on(`drain`,()=>v(q,this).onParserDrain()),a.on(`error`,e=>v(q,this).onParserError(e)),b(re,this,a),b(te,this,new B(e.socket)),v(q,this).readyState=c.OPEN;let o=e.headersList.get(`sec-websocket-extensions`);o!==null&&b(K,this,o);let s=e.headersList.get(`sec-websocket-protocol`);if(s!==null&&b(G,this,s),D(`open`,this),H.open.hasSubscribers){let t=e.headersList.entries;H.open.publish({address:ee(e.socket),protocol:v(G,this),extensions:v(K,this),websocket:this,handshakeResponse:{status:e.status,statusText:e.statusText,headers:t}})}}function Z(e,t){if(v(q,this).readyState!==c.OPEN)return;let n;if(e===d.TEXT)try{n=O(t)}catch{N(v(q,this),1007,`Received invalid UTF-8 in text frame.`);return}else e===d.BINARY&&(n=v(ne,this)===`blob`?new Blob([t]):k(t));D(`message`,this,z,{origin:v(J,this).origin,data:n})}function ae(){v(q,this).socket.resume()}function oe(){let e=v(q,this).closeState.has(l.SENT)&&v(q,this).closeState.has(l.RECEIVED),t=1005,n=``,r=v(re,this)?.closingInfo;r&&!r.error&&(t=r.code??1005,n=r.reason),v(q,this).readyState=c.CLOSED,v(q,this).closeState.has(l.RECEIVED)||(t=1006,D(`error`,this,(e,t)=>new L(e,t),{error:TypeError(n)})),D(`close`,this,(e,t)=>new R(e,t),{wasClean:e,code:t,reason:n}),H.close.hasSubscribers&&H.close.publish({websocket:this,code:t,reason:n})}var{ping:se}=X;Reflect.deleteProperty(X,`ping`),X.CONNECTING=X.prototype.CONNECTING=c.CONNECTING,X.OPEN=X.prototype.OPEN=c.OPEN,X.CLOSING=X.prototype.CLOSING=c.CLOSING,X.CLOSED=X.prototype.CLOSED=c.CLOSED,Object.defineProperties(X.prototype,{CONNECTING:s,OPEN:s,CLOSING:s,CLOSED:s,url:F,readyState:F,bufferedAmount:F,onopen:F,onerror:F,onclose:F,close:F,onmessage:F,binaryType:F,send:F,extensions:F,protocol:F,[Symbol.toStringTag]:{value:`WebSocket`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(X,{CONNECTING:s,OPEN:s,CLOSING:s,CLOSED:s}),i.converters[`sequence<DOMString>`]=i.sequenceConverter(i.converters.DOMString),i.converters[`DOMString or sequence<DOMString>`]=function(e,t,n){return i.util.Type(e)===i.util.Types.OBJECT&&Symbol.iterator in e?i.converters[`sequence<DOMString>`](e):i.converters.DOMString(e,t,n)},i.converters.WebSocketInit=i.dictionaryConverter([{key:`protocols`,converter:i.converters[`DOMString or sequence<DOMString>`],defaultValue:()=>[]},{key:`dispatcher`,converter:i.converters.any,defaultValue:()=>I()},{key:`headers`,converter:i.nullableConverter(i.converters.HeadersInit)}]),i.converters[`DOMString or sequence<DOMString> or WebSocketInit`]=function(e){return i.util.Type(e)===i.util.Types.OBJECT&&!(Symbol.iterator in e)?i.converters.WebSocketInit(e):{protocols:i.converters[`DOMString or sequence<DOMString>`](e)}},i.converters.WebSocketSendData=function(e){return i.util.Type(e)===i.util.Types.OBJECT&&(i.is.Blob(e)||i.is.BufferSource(e))?e:i.converters.USVString(e)},n.exports={WebSocket:X,ping:se}})),ln=r(((e,t)=>{m(),g(),h();var{webidl:n}=Ee(),{validateCloseCodeAndReason:r}=tn(),{kConstruct:i}=X(),{kEnumerableProperty:a}=Q();function o(){class e extends DOMException{get reason(){return``}}return new e().reason===void 0?new Proxy(DOMException,{construct(e,t,n){let r=Reflect.construct(e,t,e);return Object.setPrototypeOf(r,n.prototype),r}}):DOMException}var s=new WeakMap,c=new WeakMap,l=class e extends o(){constructor(e=``,t=void 0){if(e=n.converters.DOMString(e,`WebSocketError`,`message`),super(e,`WebSocketError`),y(this,s,void 0),y(this,c,void 0),t===i)return;t!==null&&(t=n.converters.WebSocketCloseInfo(t));let a=t.closeCode??null,o=t.reason??``;r(a,o),o.length!==0&&a===null&&(a=1e3),b(s,this,a),b(c,this,o)}get closeCode(){return v(s,this)}get reason(){return v(c,this)}static createUnvalidatedWebSocketError(t,n,r){let a=new e(t,i);return b(s,a,n),b(c,a,r),a}},{createUnvalidatedWebSocketError:u}=l;delete l.createUnvalidatedWebSocketError,Object.defineProperties(l.prototype,{closeCode:a,reason:a,[Symbol.toStringTag]:{value:`WebSocketError`,writable:!1,enumerable:!1,configurable:!0}}),n.is.WebSocketError=n.util.MakeTypeAssertion(l),t.exports={WebSocketError:l,createUnvalidatedWebSocketError:u}})),un=r(((e,t)=>{x(),m(),_(),h(),g();var{createDeferredPromise:n}=Ae(),{environmentSettingsObject:r}=De(),{states:i,opcodes:a,sentCloseFrameState:o}=en(),{webidl:s}=Ee(),{getURLRecord:c,isValidSubprotocol:l,isEstablished:u,utf8Decode:d}=tn(),{establishWebSocketConnection:f,failWebsocketConnection:C,closeWebSocketConnection:w}=rn(),{channels:T}=ce(),{WebsocketFrameSend:E}=nn(),{ByteParser:D}=on(),{WebSocketError:O,createUnvalidatedWebSocketError:k}=ln(),{kEnumerableProperty:A}=Q(),{utf8DecodeBytes:j}=Se(),M=!1,N=new WeakMap,P=new WeakMap,F=new WeakMap,I=new WeakMap,L=new WeakMap,R=new WeakMap,z=new WeakMap,B=new WeakMap,V=new WeakMap,H=new WeakSet,ee=class{constructor(e,t=void 0){S(this,H),y(this,N,void 0),y(this,P,void 0),y(this,F,void 0),y(this,I,void 0),y(this,L,void 0),y(this,R,void 0),y(this,z,!1),y(this,B,{onConnectionEstablished:(e,t)=>p(H,this,W).call(this,e,t),onMessage:(e,t)=>p(H,this,G).call(this,e,t),onParserError:e=>C(v(B,this),null,e.message),onParserDrain:()=>v(B,this).socket.resume(),onSocketData:e=>{v(V,this).write(e)||v(B,this).socket.pause()},onSocketError:e=>{v(B,this).readyState=i.CLOSING,T.socketError.hasSubscribers&&T.socketError.publish(e),v(B,this).socket.destroy()},onSocketClose:()=>p(H,this,K).call(this),onPing:()=>{},onPong:()=>{},readyState:i.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1}),y(this,V,void 0),M||(process.emitWarning(`WebSocketStream is experimental! Expect it to change at any time.`,{code:`UNDICI-WSS`}),M=!0),s.argumentLengthCheck(arguments,1,`WebSocket`),e=s.converters.USVString(e),t!==null&&(t=s.converters.WebSocketStreamOptions(t));let a=r.settingsObject.baseUrl,o=c(e,a),d=t.protocols;if(d.length!==new Set(d.map(e=>e.toLowerCase())).size||d.length>0&&!d.every(e=>l(e)))throw new DOMException(`Invalid Sec-WebSocket-Protocol value`,`SyntaxError`);if(b(N,this,o.toString()),b(P,this,n()),b(F,this,n()),t.signal!=null){let e=t.signal;if(e.aborted){v(P,this).reject(e.reason),v(F,this).reject(e.reason);return}e.addEventListener(`abort`,()=>{u(v(B,this).readyState)||(C(v(B,this)),v(B,this).readyState=i.CLOSING,v(P,this).reject(e.reason),v(F,this).reject(e.reason),b(z,this,!0))},{once:!0})}let m=r.settingsObject;v(B,this).controller=f(o,d,m,v(B,this),t)}get url(){return v(N,this).toString()}get opened(){return v(P,this).promise}get closed(){return v(F,this).promise}close(e=void 0){e!==null&&(e=s.converters.WebSocketCloseInfo(e));let t=e.closeCode??null,n=e.reason;w(v(B,this),t,n,!0)}};function U(e){e=s.converters.WebSocketStreamWrite(e);let t=n(),r=null,i=null;if(s.is.BufferSource(e))r=new Uint8Array(ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.slice()),i=a.BINARY;else{let n;try{n=s.converters.DOMString(e)}catch(e){return t.reject(e),t.promise}r=new TextEncoder().encode(n),i=a.TEXT}if(!v(B,this).closeState.has(o.SENT)&&!v(B,this).closeState.has(o.RECEIVED)){let e=new E(r);v(B,this).socket.write(e.createFrame(i),()=>{t.resolve(void 0)})}return t.promise}function W(e,t){v(B,this).socket=e.socket;let n=v(B,this).controller.dispatcher?.webSocketOptions?.maxFragments,r=v(B,this).controller.dispatcher?.webSocketOptions?.maxPayloadSize,a=new D(v(B,this),t,{maxFragments:n,maxPayloadSize:r});a.on(`drain`,()=>v(B,this).onParserDrain()),a.on(`error`,e=>v(B,this).onParserError(e)),b(V,this,a),v(B,this).readyState=i.OPEN;let o=t??``,s=e.headersList.get(`sec-websocket-protocol`)??``,c=new ReadableStream({start:e=>{b(L,this,e)},cancel:e=>p(H,this,q).call(this,e)}),l=new WritableStream({write:e=>p(H,this,U).call(this,e),close:()=>w(v(B,this),null,null),abort:e=>p(H,this,te).call(this,e)});b(I,this,c),b(R,this,l),v(P,this).resolve({extensions:o,protocol:s,readable:c,writable:l})}function G(e,t){if(v(B,this).readyState!==i.OPEN)return;let n;if(e===a.TEXT)try{n=d(t)}catch{C(v(B,this),1007,`Received invalid UTF-8 in text frame.`);return}else e===a.BINARY&&(n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength));v(L,this).enqueue(n)}function K(){let e=v(B,this).closeState.has(o.SENT)&&v(B,this).closeState.has(o.RECEIVED);if(v(B,this).readyState=i.CLOSED,v(z,this))return;v(B,this).wasEverConnected||v(P,this).reject(new O(`Socket never opened`));let t=v(V,this)?.closingInfo,n=t?.code??1005;!v(B,this).closeState.has(o.SENT)&&!v(B,this).closeState.has(o.RECEIVED)&&(n=1006);let r=t?.reason==null?``:j(Buffer.from(t.reason));if(e)v(L,this).close(),v(R,this).locked||v(R,this).abort(new DOMException(`A closed WebSocketStream cannot be written to`,`InvalidStateError`)),v(F,this).resolve({closeCode:n,reason:r});else{let e=k(`unclean close`,n,r);v(L,this)?.error(e),v(R,this)?.abort(e),v(F,this).reject(e)}}function te(e){let t=null,n=``;s.is.WebSocketError(e)&&(t=e.closeCode,n=e.reason),w(v(B,this),t,n)}function q(e){p(H,this,te).call(this,e)}Object.defineProperties(ee.prototype,{url:A,opened:A,closed:A,close:A,[Symbol.toStringTag]:{value:`WebSocketStream`,writable:!1,enumerable:!1,configurable:!0}}),s.converters.WebSocketStreamOptions=s.dictionaryConverter([{key:`protocols`,converter:s.sequenceConverter(s.converters.USVString),defaultValue:()=>[]},{key:`signal`,converter:s.nullableConverter(s.converters.AbortSignal),defaultValue:()=>null}]),s.converters.WebSocketCloseInfo=s.dictionaryConverter([{key:`closeCode`,converter:e=>s.converters[`unsigned short`](e,s.attributes.EnforceRange)},{key:`reason`,converter:s.converters.USVString,defaultValue:()=>``}]),s.converters.WebSocketStreamWrite=function(e){return typeof e==`string`?s.converters.USVString(e):s.converters.BufferSource(e)},t.exports={WebSocketStream:ee}})),dn=r(((e,t)=>{function n(e){return e.indexOf(`\0`)===-1}function r(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(e.charCodeAt(t)<48||e.charCodeAt(t)>57)return!1;return!0}t.exports={isValidLastEventId:n,isASCIINumber:r}})),fn=r(((t,n)=>{u();var{Transform:r}=e(`node:stream`),{isASCIINumber:i,isValidLastEventId:a}=dn(),o=[239,187,191],s=10,c=13,l=58,d=32;n.exports={EventSourceStream:class extends r{constructor(e={}){e.readableObjectMode=!0,super(e),f(this,`state`,void 0),f(this,`checkBOM`,!0),f(this,`crlfCheck`,!1),f(this,`eventEndCheck`,!1),f(this,`buffer`,null),f(this,`pos`,0),f(this,`event`,{data:void 0,event:void 0,id:void 0,retry:void 0}),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,t,n){if(e.length===0){n();return}if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:if(this.buffer[0]===o[0]){n();return}this.checkBOM=!1,n();return;case 2:if(this.buffer[0]===o[0]&&this.buffer[1]===o[1]){n();return}this.checkBOM=!1;break;case 3:if(this.buffer[0]===o[0]&&this.buffer[1]===o[1]&&this.buffer[2]===o[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,n();return}this.checkBOM=!1;break;default:this.buffer[0]===o[0]&&this.buffer[1]===o[1]&&this.buffer[2]===o[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1;break}for(;this.pos<this.buffer.length;){if(this.eventEndCheck){if(this.crlfCheck){if(this.buffer[this.pos]===s){this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.crlfCheck=!1;continue}this.crlfCheck=!1}if(this.buffer[this.pos]===s||this.buffer[this.pos]===c){this.buffer[this.pos]===c&&(this.crlfCheck=!0),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,(this.event.data!==void 0||this.event.event||this.event.id!==void 0||this.event.retry)&&this.processEvent(this.event),this.clearEvent();continue}this.eventEndCheck=!1;continue}if(this.buffer[this.pos]===s||this.buffer[this.pos]===c){this.buffer[this.pos]===c&&(this.crlfCheck=!0),this.parseLine(this.buffer.subarray(0,this.pos),this.event),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.eventEndCheck=!0;continue}this.pos++}n()}parseLine(e,t){if(e.length===0)return;let n=e.indexOf(l);if(n===0)return;let r=``,o=``;if(n!==-1){r=e.subarray(0,n).toString(`utf8`);let t=n+1;e[t]===d&&++t,o=e.subarray(t).toString(`utf8`)}else r=e.toString(`utf8`),o=``;switch(r){case`data`:t[r]===void 0?t[r]=o:t[r]+=`\n${o}`;break;case`retry`:i(o)&&(t[r]=o);break;case`id`:a(o)&&(t[r]=o);break;case`event`:o.length>0&&(t[r]=o);break}}processEvent(e){e.retry&&i(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id!==void 0&&a(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||`message`,options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}}}})),pn=r(((t,n)=>{x(),m(),g(),h(),_();var{pipeline:r}=e(`node:stream`),{fetching:i}=Gt(),{makeRequest:a}=Ut(),{webidl:o}=Ee(),{EventSourceStream:s}=fn(),{parseMIMEType:c}=we(),{createFastMessageEvent:l}=$t(),{isNetworkError:u}=Ht(),{kEnumerableProperty:d}=Q(),{environmentSettingsObject:f}=De(),C=!1,w=3e3,T=0,E=1,D=2,O=`anonymous`,k=`use-credentials`,A=new WeakMap,j=new WeakMap,M=new WeakMap,N=new WeakMap,P=new WeakMap,F=new WeakMap,I=new WeakMap,L=new WeakMap,R=new WeakSet,z=class e extends EventTarget{constructor(e,t={}){super(),S(this,R),y(this,A,{open:null,error:null,message:null}),y(this,j,void 0),y(this,M,!1),y(this,N,T),y(this,P,null),y(this,F,null),y(this,I,void 0),y(this,L,void 0),o.util.markAsUncloneable(this);let n=`EventSource constructor`;o.argumentLengthCheck(arguments,1,n),C||(C=!0,process.emitWarning(`EventSource is experimental, expect them to change at any time.`,{code:`UNDICI-ES`})),e=o.converters.USVString(e),t=o.converters.EventSourceInitDict(t,n,`eventSourceInitDict`),b(I,this,t.node.dispatcher||t.dispatcher),b(L,this,{lastEventId:``,reconnectionTime:t.node.reconnectionTime});let r=f,i;try{i=new URL(e,r.settingsObject.baseUrl),v(L,this).origin=i.origin}catch(e){throw new DOMException(e,`SyntaxError`)}b(j,this,i.href);let s=O;t.withCredentials===!0&&(s=k,b(M,this,!0));let c={redirect:`follow`,keepalive:!0,mode:`cors`,credentials:s===`anonymous`?`same-origin`:`omit`,referrer:`no-referrer`};c.client=f.settingsObject,c.headersList=[[`accept`,{name:`accept`,value:`text/event-stream`}]],c.cache=`no-store`,c.initiator=`other`,c.urlList=[new URL(v(j,this))],b(P,this,a(c)),p(R,this,B).call(this)}get readyState(){return v(N,this)}get url(){return v(j,this)}get withCredentials(){return v(M,this)}close(){o.brandCheck(this,e),v(N,this)!==D&&(b(N,this,D),v(F,this).abort(),b(P,this,null))}get onopen(){return v(A,this).open}set onopen(e){v(A,this).open&&this.removeEventListener(`open`,v(A,this).open);let t=o.converters.EventHandlerNonNull(e);t===null?v(A,this).open=null:(this.addEventListener(`open`,t),v(A,this).open=e)}get onmessage(){return v(A,this).message}set onmessage(e){v(A,this).message&&this.removeEventListener(`message`,v(A,this).message);let t=o.converters.EventHandlerNonNull(e);t===null?v(A,this).message=null:(this.addEventListener(`message`,t),v(A,this).message=e)}get onerror(){return v(A,this).error}set onerror(e){v(A,this).error&&this.removeEventListener(`error`,v(A,this).error);let t=o.converters.EventHandlerNonNull(e);t===null?v(A,this).error=null:(this.addEventListener(`error`,t),v(A,this).error=e)}};function B(){if(v(N,this)===D)return;b(N,this,T);let e={request:v(P,this),dispatcher:v(I,this)};e.processResponseEndOfBody=e=>{if(!u(e))return p(R,this,V).call(this)},e.processResponse=e=>{if(u(e))if(e.aborted){this.close(),this.dispatchEvent(new Event(`error`));return}else{p(R,this,V).call(this);return}let t=e.headersList.get(`content-type`,!0),n=t===null?`failure`:c(t),i=n!==`failure`&&n.essence===`text/event-stream`;if(e.status!==200||i===!1){this.close(),this.dispatchEvent(new Event(`error`));return}b(N,this,E),this.dispatchEvent(new Event(`open`)),v(L,this).origin=e.urlList[e.urlList.length-1].origin;let a=new s({eventSourceSettings:v(L,this),push:e=>{this.dispatchEvent(l(e.type,e.options))}});r(e.body.stream,a,e=>{e?.aborted===!1&&(this.close(),this.dispatchEvent(new Event(`error`)))})},b(F,this,i(e))}function V(){v(N,this)!==D&&(b(N,this,T),this.dispatchEvent(new Event(`error`)),setTimeout(()=>{v(N,this)===T&&(v(L,this).lastEventId.length&&v(P,this).headersList.set(`last-event-id`,v(L,this).lastEventId,!0),p(R,this,B).call(this))},v(L,this).reconnectionTime)?.unref())}var H={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:T,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:E,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:D,writable:!1}};Object.defineProperties(z,H),Object.defineProperties(z.prototype,H),Object.defineProperties(z.prototype,{close:d,onerror:d,onmessage:d,onopen:d,readyState:d,url:d,withCredentials:d}),o.converters.EventSourceInitDict=o.dictionaryConverter([{key:`withCredentials`,converter:o.converters.boolean,defaultValue:()=>!1},{key:`dispatcher`,converter:o.converters.any},{key:`node`,converter:o.dictionaryConverter([{key:`reconnectionTime`,converter:o.converters[`unsigned long`],defaultValue:()=>w},{key:`dispatcher`,converter:o.converters.any}]),defaultValue:()=>({})}]),n.exports={EventSource:z,defaultReconnectionTime:w}})),mn=r(((e,t)=>{var n=Pe(),r=$(),i=Le(),a=Re(),o=ze(),s=Be(),c=We(),l=Ue(),u=Ge(),d=qe(),f=Je(),p=Z(),m=Q(),{InvalidArgumentError:h}=p,g=nt(),_=pe(),v=st(),{MockCallHistory:y,MockCallHistoryLog:b}=ct(),x=dt(),S=lt(),C=mt(),w=rt(),T=Ke(),{getGlobalDispatcher:E,setGlobalDispatcher:D}=ht(),O=gt(),k=_t();Object.assign(r.prototype,g),t.exports.Dispatcher=r,t.exports.Client=n,t.exports.Pool=i,t.exports.BalancedPool=a,t.exports.RoundRobinPool=o,t.exports.Agent=s,t.exports.ProxyAgent=c,t.exports.Socks5ProxyAgent=l,t.exports.EnvHttpProxyAgent=u,t.exports.RetryAgent=d,t.exports.H2CClient=f,t.exports.RetryHandler=T,t.exports.DecoratorHandler=O,t.exports.RedirectHandler=k,t.exports.interceptors={redirect:vt(),responseError:yt(),retry:bt(),dump:xt(),dns:St(),cache:Ot(),decompress:Lt(),deduplicate:zt()},t.exports.cacheStores={MemoryCacheStore:Et()};var A=Bt();t.exports.cacheStores.SqliteCacheStore=A,t.exports.buildConnector=_,t.exports.errors=p,t.exports.util={parseHeaders:m.parseHeaders,headerNameToString:m.headerNameToString};function j(e){return(t,n,r)=>{if(typeof n==`function`&&(r=n,n=null),!t||typeof t!=`string`&&typeof t!=`object`&&!(t instanceof URL))throw new h(`invalid url`);if(n!=null&&typeof n!=`object`)throw new h(`invalid opts`);if(n&&n.path!=null){if(typeof n.path!=`string`)throw new h(`invalid opts.path`);let e=n.path;n.path.startsWith(`/`)||(e=`/${e}`),t=new URL(m.parseOrigin(t).origin+e)}else n||(n=typeof t==`object`?t:{}),t=m.parseURL(t);let{agent:i,dispatcher:a=E()}=n;if(i)throw new h(`unsupported opts.agent. Did you mean opts.client?`);return e.call(a,{...n,origin:t.origin,path:t.search?`${t.pathname}${t.search}`:t.pathname,method:n.method||(n.body?`PUT`:`GET`)},r)}}t.exports.setGlobalDispatcher=D,t.exports.getGlobalDispatcher=E;var M=Gt().fetch,N=typeof __filename<`u`?__filename:void 0;function P(e,t){if(!e||typeof e!=`object`)return;let n=typeof e.stack==`string`?e.stack:``,r=t.replace(/\\/g,`/`);if(n&&(n.includes(t)||n.includes(r)))return;let i={};if(Error.captureStackTrace(i,P),!i.stack)return;let a=i.stack.split(`
98
98
  `).slice(1).join(`
99
- `);e.stack=n?`${n}\n${a}`:i.stack}t.exports.fetch=function(e,n=void 0){return M(e,n).catch(e=>{throw N?P(e,N):e&&typeof e==`object`&&Error.captureStackTrace(e,t.exports.fetch),e})},t.exports.Headers=Vt().Headers,t.exports.Response=Ht().Response,t.exports.Request=Ut().Request,t.exports.FormData=Oe().FormData;var{setGlobalOrigin:F,getGlobalOrigin:I}=xe();t.exports.setGlobalOrigin=F,t.exports.getGlobalOrigin=I;var{CacheStorage:L}=Jt(),{kConstruct:R}=X();t.exports.caches=new L(R);var{deleteCookie:z,getCookies:B,getSetCookies:V,setCookie:H,parseCookie:ee}=Qt();t.exports.deleteCookie=z,t.exports.getCookies=B,t.exports.getSetCookies=V,t.exports.setCookie=H,t.exports.parseCookie=ee;var{parseMIMEType:U,serializeAMimeType:W}=we();t.exports.parseMIMEType=U,t.exports.serializeAMimeType=W;var{CloseEvent:G,ErrorEvent:K,MessageEvent:te}=$t(),{WebSocket:q,ping:J}=cn();t.exports.WebSocket=q,t.exports.CloseEvent=G,t.exports.ErrorEvent=K,t.exports.MessageEvent=te,t.exports.ping=J,t.exports.WebSocketStream=un().WebSocketStream,t.exports.WebSocketError=ln().WebSocketError,t.exports.request=j(g.request),t.exports.stream=j(g.stream),t.exports.pipeline=j(g.pipeline),t.exports.connect=j(g.connect),t.exports.upgrade=j(g.upgrade),t.exports.MockClient=v,t.exports.MockCallHistory=y,t.exports.MockCallHistoryLog=b,t.exports.MockPool=S,t.exports.MockAgent=x,t.exports.SnapshotAgent=C,t.exports.mockErrors=w;var{EventSource:ne}=pn();t.exports.EventSource=ne;function re(){globalThis.fetch=t.exports.fetch,globalThis.Headers=t.exports.Headers,globalThis.Response=t.exports.Response,globalThis.Request=t.exports.Request,globalThis.FormData=t.exports.FormData,globalThis.WebSocket=t.exports.WebSocket,globalThis.CloseEvent=t.exports.CloseEvent,globalThis.ErrorEvent=t.exports.ErrorEvent,globalThis.MessageEvent=t.exports.MessageEvent,globalThis.EventSource=t.exports.EventSource}t.exports.install=re}));function hn(){let e=yn(),t=re();if(!(!e&&!t))return{...e,...t&&{ca:t}}}function gn(){let e=yn(),t=re();if(!e&&!t)return{};let n={...e,...t&&{ca:t}};return typeof Bun<`u`?{tls:n}:(E(`TLS: Created undici agent with custom certificates`),{dispatcher:new(mn()).Agent({connect:{cert:n.cert,key:n.key,passphrase:n.passphrase,...n.ca&&{ca:n.ca}},pipelining:1})})}function _n(){yn.cache.clear?.(),bn.cache.clear?.(),E(`Cleared mTLS configuration cache`)}function vn(){yn()&&process.env.NODE_EXTRA_CA_CERTS&&E(`NODE_EXTRA_CA_CERTS detected - Node.js will automatically append to built-in CAs`)}var yn,bn,xn=t((()=>{a(),Y(),O(),D(),yn=i(()=>{let e={};if(process.env.CLAUDE_CODE_CLIENT_CERT)try{e.cert=k().readFileSync(process.env.CLAUDE_CODE_CLIENT_CERT,{encoding:`utf8`}),E(`mTLS: Loaded client certificate from CLAUDE_CODE_CLIENT_CERT`)}catch(e){E(`mTLS: Failed to load client certificate: ${e}`,{level:`error`})}if(process.env.CLAUDE_CODE_CLIENT_KEY)try{e.key=k().readFileSync(process.env.CLAUDE_CODE_CLIENT_KEY,{encoding:`utf8`}),E(`mTLS: Loaded client key from CLAUDE_CODE_CLIENT_KEY`)}catch(e){E(`mTLS: Failed to load client key: ${e}`,{level:`error`})}if(process.env.CLAUDE_CODE_CLIENT_KEY_PASSPHRASE&&(e.passphrase=process.env.CLAUDE_CODE_CLIENT_KEY_PASSPHRASE,E(`mTLS: Using client key passphrase`)),Object.keys(e).length!==0)return e}),bn=i(()=>{let e=yn(),t=re();if(!e&&!t)return;let n={...e,...t&&{ca:t},keepAlive:!0};return E(`mTLS: Creating HTTPS agent with custom certificates`),new j(n)})}));function Sn(e){switch(e.family){case 0:case 4:case 6:return e.family;case`IPv6`:return 6;case`IPv4`:case void 0:return 4;default:throw Error(`Unsupported address family: ${e.family}`)}}function Cn(e=process.env){return e.https_proxy||e.HTTPS_PROXY||e.http_proxy||e.HTTP_PROXY}function wn(e=process.env){return e.no_proxy||e.NO_PROXY}function Tn(e,t=wn()){if(!t)return!1;if(t===`*`)return!0;try{let n=new URL(e),r=n.hostname.toLowerCase(),i=`${r}:${n.port||(n.protocol===`https:`?`443`:`80`)}`;return t.split(/[,\s]+/).filter(Boolean).some(e=>{if(e=e.toLowerCase().trim(),e.includes(`:`))return i===e;if(e.startsWith(`.`)){let t=e;return r===e.substring(1)||r.endsWith(t)}return r===e})}catch{return!1}}function En(e,t={}){let n=yn(),r=re(),i={...n&&{cert:n.cert,key:n.key,passphrase:n.passphrase},...r&&{ca:r}};return s(process.env.CLAUDE_CODE_PROXY_RESOLVES_HOSTS)&&(i.lookup=(e,t,n)=>{n(null,e,Sn(t))}),new q(e,{...i,...t})}function Dn(e){let t=Cn();if(t&&!Tn(e))return En(t)}function On(e){let t=Cn();if(t&&!Tn(e))return t}function kn(e){let t=Nn?{keepalive:!1}:{};if(e?.forAnthropicAPI){let e=process.env.ANTHROPIC_UNIX_SOCKET;if(e&&typeof Bun<`u`)return{...t,unix:e}}let n=Cn();return n?typeof Bun<`u`?{...t,proxy:n,...gn()}:{...t,dispatcher:Pn(n)}:{...t,...gn()}}function An(){let e=Cn(),t=bn();if(Fn!==void 0&&(w.interceptors.request.eject(Fn),Fn=void 0),w.defaults.proxy=void 0,w.defaults.httpAgent=void 0,w.defaults.httpsAgent=void 0,e){w.defaults.proxy=!1;let n=En(e);Fn=w.interceptors.request.use(e=>(e.url&&Tn(e.url)?t?(e.httpsAgent=t,e.httpAgent=t):(delete e.httpsAgent,delete e.httpAgent):(e.httpsAgent=n,e.httpAgent=n),e)),mn().setGlobalDispatcher(Pn(e))}else if(t){w.defaults.httpsAgent=t;let e=gn();e.dispatcher&&mn().setGlobalDispatcher(e.dispatcher)}}async function jn(){let e=Cn();if(!e)return{};let[{NodeHttpHandler:t},{defaultProvider:n}]=await Promise.all([import(`./dist-es-C7vygWzp.js`),import(`./dist-es-DSkyibcN.js`)]),r=En(e),i=new t({httpAgent:r,httpsAgent:r});return{requestHandler:i,credentials:n({clientConfig:{requestHandler:i}})}}function Mn(){Pn.cache.clear?.(),E(`Cleared proxy agent cache`)}var Nn,Pn,Fn,In=t((()=>{T(),J(),a(),Y(),O(),c(),xn(),Nn=!1,Pn=i(e=>{let t=mn(),n=yn(),r=re(),i={httpProxy:e,httpsProxy:e,noProxy:process.env.NO_PROXY||process.env.no_proxy};if(n||r){let e={...n&&{cert:n.cert,key:n.key,passphrase:n.passphrase},...r&&{ca:r}};i.connect=e,i.requestTls=e}return new t.EnvHttpProxyAgent(i)})}));export{Y as _,Cn as a,In as c,vn as d,yn as f,re as g,ne as h,kn as i,Tn as l,xn as m,An as n,Dn as o,hn as p,jn as r,On as s,Mn as t,_n as u,q as v,J as y};
99
+ `);e.stack=n?`${n}\n${a}`:i.stack}t.exports.fetch=function(e,n=void 0){return M(e,n).catch(e=>{throw N?P(e,N):e&&typeof e==`object`&&Error.captureStackTrace(e,t.exports.fetch),e})},t.exports.Headers=Vt().Headers,t.exports.Response=Ht().Response,t.exports.Request=Ut().Request,t.exports.FormData=Oe().FormData;var{setGlobalOrigin:F,getGlobalOrigin:I}=xe();t.exports.setGlobalOrigin=F,t.exports.getGlobalOrigin=I;var{CacheStorage:L}=Jt(),{kConstruct:R}=X();t.exports.caches=new L(R);var{deleteCookie:z,getCookies:B,getSetCookies:V,setCookie:H,parseCookie:ee}=Qt();t.exports.deleteCookie=z,t.exports.getCookies=B,t.exports.getSetCookies=V,t.exports.setCookie=H,t.exports.parseCookie=ee;var{parseMIMEType:U,serializeAMimeType:W}=we();t.exports.parseMIMEType=U,t.exports.serializeAMimeType=W;var{CloseEvent:G,ErrorEvent:K,MessageEvent:te}=$t(),{WebSocket:q,ping:J}=cn();t.exports.WebSocket=q,t.exports.CloseEvent=G,t.exports.ErrorEvent=K,t.exports.MessageEvent=te,t.exports.ping=J,t.exports.WebSocketStream=un().WebSocketStream,t.exports.WebSocketError=ln().WebSocketError,t.exports.request=j(g.request),t.exports.stream=j(g.stream),t.exports.pipeline=j(g.pipeline),t.exports.connect=j(g.connect),t.exports.upgrade=j(g.upgrade),t.exports.MockClient=v,t.exports.MockCallHistory=y,t.exports.MockCallHistoryLog=b,t.exports.MockPool=S,t.exports.MockAgent=x,t.exports.SnapshotAgent=C,t.exports.mockErrors=w;var{EventSource:ne}=pn();t.exports.EventSource=ne;function re(){globalThis.fetch=t.exports.fetch,globalThis.Headers=t.exports.Headers,globalThis.Response=t.exports.Response,globalThis.Request=t.exports.Request,globalThis.FormData=t.exports.FormData,globalThis.WebSocket=t.exports.WebSocket,globalThis.CloseEvent=t.exports.CloseEvent,globalThis.ErrorEvent=t.exports.ErrorEvent,globalThis.MessageEvent=t.exports.MessageEvent,globalThis.EventSource=t.exports.EventSource}t.exports.install=re}));function hn(){let e=yn(),t=re();if(!(!e&&!t))return{...e,...t&&{ca:t}}}function gn(){let e=yn(),t=re();if(!e&&!t)return{};let n={...e,...t&&{ca:t}};return typeof Bun<`u`?{tls:n}:(E(`TLS: Created undici agent with custom certificates`),{dispatcher:new(mn()).Agent({connect:{cert:n.cert,key:n.key,passphrase:n.passphrase,...n.ca&&{ca:n.ca}},pipelining:1})})}function _n(){yn.cache.clear?.(),bn.cache.clear?.(),E(`Cleared mTLS configuration cache`)}function vn(){yn()&&process.env.NODE_EXTRA_CA_CERTS&&E(`NODE_EXTRA_CA_CERTS detected - Node.js will automatically append to built-in CAs`)}var yn,bn,xn=t((()=>{a(),Y(),O(),D(),yn=i(()=>{let e={};if(process.env.WORKMATE_CLIENT_CERT)try{e.cert=k().readFileSync(process.env.WORKMATE_CLIENT_CERT,{encoding:`utf8`}),E(`mTLS: Loaded client certificate from WORKMATE_CLIENT_CERT`)}catch(e){E(`mTLS: Failed to load client certificate: ${e}`,{level:`error`})}if(process.env.WORKMATE_CLIENT_KEY)try{e.key=k().readFileSync(process.env.WORKMATE_CLIENT_KEY,{encoding:`utf8`}),E(`mTLS: Loaded client key from WORKMATE_CLIENT_KEY`)}catch(e){E(`mTLS: Failed to load client key: ${e}`,{level:`error`})}if(process.env.WORKMATE_CLIENT_KEY_PASSPHRASE&&(e.passphrase=process.env.WORKMATE_CLIENT_KEY_PASSPHRASE,E(`mTLS: Using client key passphrase`)),Object.keys(e).length!==0)return e}),bn=i(()=>{let e=yn(),t=re();if(!e&&!t)return;let n={...e,...t&&{ca:t},keepAlive:!0};return E(`mTLS: Creating HTTPS agent with custom certificates`),new j(n)})}));function Sn(e){switch(e.family){case 0:case 4:case 6:return e.family;case`IPv6`:return 6;case`IPv4`:case void 0:return 4;default:throw Error(`Unsupported address family: ${e.family}`)}}function Cn(e=process.env){return e.https_proxy||e.HTTPS_PROXY||e.http_proxy||e.HTTP_PROXY}function wn(e=process.env){return e.no_proxy||e.NO_PROXY}function Tn(e,t=wn()){if(!t)return!1;if(t===`*`)return!0;try{let n=new URL(e),r=n.hostname.toLowerCase(),i=`${r}:${n.port||(n.protocol===`https:`?`443`:`80`)}`;return t.split(/[,\s]+/).filter(Boolean).some(e=>{if(e=e.toLowerCase().trim(),e.includes(`:`))return i===e;if(e.startsWith(`.`)){let t=e;return r===e.substring(1)||r.endsWith(t)}return r===e})}catch{return!1}}function En(e,t={}){let n=yn(),r=re(),i={...n&&{cert:n.cert,key:n.key,passphrase:n.passphrase},...r&&{ca:r}};return s(process.env.WORKMATE_PROXY_RESOLVES_HOSTS)&&(i.lookup=(e,t,n)=>{n(null,e,Sn(t))}),new q(e,{...i,...t})}function Dn(e){let t=Cn();if(t&&!Tn(e))return En(t)}function On(e){let t=Cn();if(t&&!Tn(e))return t}function kn(e){let t=Nn?{keepalive:!1}:{};if(e?.forAnthropicAPI){let e=process.env.ANTHROPIC_UNIX_SOCKET;if(e&&typeof Bun<`u`)return{...t,unix:e}}let n=Cn();return n?typeof Bun<`u`?{...t,proxy:n,...gn()}:{...t,dispatcher:Pn(n)}:{...t,...gn()}}function An(){let e=Cn(),t=bn();if(Fn!==void 0&&(w.interceptors.request.eject(Fn),Fn=void 0),w.defaults.proxy=void 0,w.defaults.httpAgent=void 0,w.defaults.httpsAgent=void 0,e){w.defaults.proxy=!1;let n=En(e);Fn=w.interceptors.request.use(e=>(e.url&&Tn(e.url)?t?(e.httpsAgent=t,e.httpAgent=t):(delete e.httpsAgent,delete e.httpAgent):(e.httpsAgent=n,e.httpAgent=n),e)),mn().setGlobalDispatcher(Pn(e))}else if(t){w.defaults.httpsAgent=t;let e=gn();e.dispatcher&&mn().setGlobalDispatcher(e.dispatcher)}}async function jn(){let e=Cn();if(!e)return{};let[{NodeHttpHandler:t},{defaultProvider:n}]=await Promise.all([import(`./dist-es-C7vygWzp.js`),import(`./dist-es-DSkyibcN.js`)]),r=En(e),i=new t({httpAgent:r,httpsAgent:r});return{requestHandler:i,credentials:n({clientConfig:{requestHandler:i}})}}function Mn(){Pn.cache.clear?.(),E(`Cleared proxy agent cache`)}var Nn,Pn,Fn,In=t((()=>{T(),J(),a(),Y(),O(),c(),xn(),Nn=!1,Pn=i(e=>{let t=mn(),n=yn(),r=re(),i={httpProxy:e,httpsProxy:e,noProxy:process.env.NO_PROXY||process.env.no_proxy};if(n||r){let e={...n&&{cert:n.cert,key:n.key,passphrase:n.passphrase},...r&&{ca:r}};i.connect=e,i.requestTls=e}return new t.EnvHttpProxyAgent(i)})}));export{Y as _,Cn as a,In as c,vn as d,yn as f,re as g,ne as h,kn as i,Tn as l,xn as m,An as n,Dn as o,hn as p,jn as r,On as s,Mn as t,_n as u,q as v,J as y};
@@ -0,0 +1 @@
1
+ import{Pt as e,q as t}from"./state-CXY-q5gr.js";import{do as n,io as r,oo as i,uo as a}from"./loadAgentsDir-DR5PVAc3.js";import{I as o,M as s,c,i as l}from"./debug-kBjDaVkQ.js";import{Cn as u,On as d,Pr as f,Tr as p,_t as m,gt as h}from"./settings-YIDksG5Z.js";import{o as g,s as _}from"./log-DWZny1vM.js";import{ht as v,mt as y}from"./model-D42epddJ.js";import{isAbsolute as b,resolve as x}from"path";y(),e(),l(),o(),u(),f(),g(),a(),h();function S(e,t,n){let r=[],i=[],a=[];for(let[o,s]of Object.entries(e)){let e=t[o],c=w(s.source,n?.projectRoot);e?s.sourceIsFallback||v(c,e.source)?a.push(o):i.push({name:o,declaredSource:c,materializedSource:e.source}):r.push(o)}return{missing:r,sourceChanged:i,upToDate:a}}async function C(e){let a=i();if(Object.keys(a).length===0)return{installed:[],updated:[],failed:[],upToDate:[],skipped:[]};let o;try{o=await n()}catch(e){_(e),o={}}let l=S(a,o,{projectRoot:t()}),u=[...l.missing.map(e=>({name:e,source:w(a[e].source),action:`install`})),...l.sourceChanged.map(({name:e,declaredSource:t})=>({name:e,source:t,action:`update`}))],f=[],p=[];for(let t of u){if(e?.skip?.(t.name,t.source)){f.push(t.name);continue}if(t.action===`update`&&m(t.source)&&!await d(t.source.path)){c(`[reconcile] '${t.name}' declared path does not exist; keeping materialized entry`),f.push(t.name);continue}p.push(t)}if(p.length===0)return{installed:[],updated:[],failed:[],upToDate:l.upToDate,skipped:f};c(`[reconcile] ${p.length} marketplace(s): ${p.map(e=>`${e.name}(${e.action})`).join(`, `)}`);let h=[],g=[],v=[];for(let t=0;t<p.length;t++){let{name:n,source:i,action:a}=p[t];e?.onProgress?.({type:`installing`,name:n,action:a,index:t+1,total:p.length});try{let t=await r(i);a===`install`?h.push(n):g.push(n),e?.onProgress?.({type:`installed`,name:n,alreadyMaterialized:t.alreadyMaterialized})}catch(t){let r=s(t);v.push({name:n,error:r}),e?.onProgress?.({type:`failed`,name:n,error:r}),_(t)}}return{installed:h,updated:g,failed:v,upToDate:l.upToDate,skipped:f}}function w(e,n){if((e.source===`directory`||e.source===`file`)&&!b(e.path)){let r=n??t(),i=p(r);return{...e,path:x(i??r,e.path)}}return e}export{C as n,S as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Pt as t,q as n}from"./state-CXY-q5gr.js";import{Fa as r,Fm as i,Go as a,Hm as o,Km as s,Ko as c,Lm as l,Mo as u,No as d,Pa as f,Wm as p,_f as m,c_ as h,i as g,o as _,qm as v,s_ as y,vf as b}from"./loadAgentsDir-DR5PVAc3.js";import{I as x,M as S,c as C,i as w}from"./debug-kBjDaVkQ.js";import{o as T,s as E}from"./log-DWZny1vM.js";async function D(e){C(`refreshActivePlugins: clearing all plugin caches`),u(),i();let t=await r(),[o,s]=await Promise.all([a(),g(n())]),{enabled:c,disabled:l,errors:d}=t,[f,m]=await Promise.all([Promise.all(c.map(async e=>{if(e.mcpServers)return Object.keys(e.mcpServers).length;let t=await b(e,d);return t&&(e.mcpServers=t),t?Object.keys(t).length:0})),Promise.all(c.map(async e=>{if(e.lspServers)return Object.keys(e.lspServers).length;let t=await v(e,d);return t&&(e.lspServers=t),t?Object.keys(t).length:0}))]),_=f.reduce((e,t)=>e+t,0),y=m.reduce((e,t)=>e+t,0);e(e=>({...e,plugins:{...e.plugins,enabled:c,disabled:l,commands:o,errors:O(e.plugins.errors,d),needsRefresh:!1},agentDefinitions:s,mcp:{...e.mcp,pluginReconnectKey:e.mcp.pluginReconnectKey+1}})),p();let x=!1;try{await h()}catch(e){x=!0,E(e),C(`refreshActivePlugins: loadPluginHooks failed: ${S(e)}`)}let w=c.reduce((e,t)=>t.hooksConfig?e+Object.values(t.hooksConfig).reduce((e,t)=>e+(t?.reduce((e,t)=>e+t.hooks.length,0)??0),0):e,0);return C(`refreshActivePlugins: ${c.length} enabled, ${o.length} commands, ${s.allAgents.length} agents, ${w} hooks, ${_} MCP, ${y} LSP`),{enabled_count:c.length,disabled_count:l.length,command_count:o.length,agent_count:s.allAgents.length,hook_count:w,mcp_count:_,lsp_count:y,error_count:d.length+ +!!x,agentDefinitions:s,pluginCommands:o}}function O(e,t){let n=e.filter(e=>e.source===`lsp-manager`||e.source.startsWith(`plugin:`)),r=new Set(t.map(k));return[...n.filter(e=>!r.has(k(e))),...t]}function k(e){return e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`}var A=e((()=>{t(),o(),_(),w(),x(),T(),d(),c(),y(),s(),m(),l(),f()}));export{D as n,A as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,o as n}from"./isObject-C6qM3WEW.js";import{$r as r,Kr as i,Qr as a,_r as o,ai as s,ar as ee,cr as c,dr as l,fr as u,gr as te,ii as d,ir as ne,lr as f,ni as p,pr as m,qr as re,ri as h,ur as ie}from"./state-CXY-q5gr.js";import{Cw as ae,Sw as g,_C as _,vC as v}from"./loadAgentsDir-DR5PVAc3.js";import{Gn as y,Jn as b,Kn as x,Un as S,Wn as C,li as w,qn as T,ui as E}from"./settings-YIDksG5Z.js";import{D,O}from"./config-D3K87Mm1.js";import{n as k,t as A}from"./_baseSlice-D67_NpZ1.js";import{n as j,t as M}from"./_baseEach-DGbaIpJA.js";function N(e){return h(e)||re(e)||!!(P&&e&&e[P])}var P,F=e((()=>{n(),i(),p(),P=t?t.isConcatSpreadable:void 0}));function I(e,t,n,r,i){var a=-1,o=e.length;for(n||(n=N),i||(i=[]);++a<o;){var s=e[a];t>0&&n(s)?t>1?I(s,t-1,n,r,i):d(i,s):r||(i[i.length]=s)}return i}var L=e((()=>{s(),F()}));function R(e){return e!=null&&e.length?I(e,1):[]}var z=e((()=>{L()}));function B(e){return C(x(e,void 0,R),e+``)}var V=e((()=>{z(),y(),S()}));function H(e,t){var n=[];return M(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}var U=e((()=>{j()}));function W(e,t){return t.length<2?e:c(e,A(t,0,-1))}var G=e((()=>{f(),k()}));function K(e){if(typeof e!=`function`)throw TypeError(q);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var q,J=e((()=>{q=`Expected a function`}));function oe(e,t){t=u(t,e);var n=-1,r=t.length;if(!r)return!0;for(;++n<r;){var i=l(t[n]);if(i===`__proto__`&&!Y.call(e,`__proto__`)||(i===`constructor`||i===`prototype`)&&n<r-1)return!1}var a=W(e,t);return a==null||delete a[l(v(t))]}var Y,se=e((()=>{m(),_(),G(),ie(),Y=Object.prototype.hasOwnProperty}));function ce(e){return b(e)?void 0:e}var le=e((()=>{T()})),X,Z,Q,$,ue=e((()=>{o(),ae(),se(),m(),E(),le(),V(),O(),X=1,Z=2,Q=4,$=B(function(e,t){var n={};if(e==null)return n;var r=!1;t=te(t,function(t){return t=u(t,e),r||(r=t.length>1),t}),w(e,D(e),n),r&&(n=g(n,X|Z|Q,ce));for(var i=t.length;i--;)oe(n,t[i]);return n})}));function de(e,t){return(h(e)?a:H)(e,K(ne(t,3)))}var fe=e((()=>{r(),U(),ee(),p(),J()}));export{$ as i,de as n,ue as r,fe as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./stringUtils-C718f5ey.js";import{n as r,t as i}from"./refresh-Dn_I1R4v.js";function a(e,n){return`${e} ${t(e,n)}`}var o;e((()=>{i(),n(),o=async(e,t)=>{let n=await r(t.setAppState),i=`Reloaded: ${[a(n.enabled_count,`plugin`),a(n.command_count,`skill`),a(n.agent_count,`agent`),a(n.hook_count,`hook`),a(n.mcp_count,`plugin MCP server`),a(n.lsp_count,`plugin LSP server`)].join(` · `)}`;return n.error_count>0&&(i+=`\n${a(n.error_count,`error`)} during load. Run /doctor for details.`),{type:`text`,value:i}}}))();export{o as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./stringUtils-D_xPrwGQ.js";import{n as r,t as i}from"./refresh-B4pqFp12.js";function a(e,n){return`${e} ${t(e,n)}`}var o;e((()=>{i(),n(),o=async(e,t)=>{let n=await r(t.setAppState),i=`Reloaded: ${[a(n.enabled_count,`plugin`),a(n.command_count,`skill`),a(n.agent_count,`agent`),a(n.hook_count,`hook`),a(n.mcp_count,`plugin MCP server`),a(n.lsp_count,`plugin LSP server`)].join(` · `)}`;return n.error_count>0&&(i+=`\n${a(n.error_count,`error`)} during load. Run /doctor for details.`),{type:`text`,value:i}}}))();export{o as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Pt as t,at as n}from"./state-CXY-q5gr.js";import{Ji as r,Rx as i,Zr as a,ei as o,fr as s,gr as c}from"./loadAgentsDir-DR5PVAc3.js";import{n as l,t as u}from"./generateSessionName-CGaTTXCA.js";async function d(e,t,r){let c;if(!r||r.trim()===``){let n=await u(i(t.messages),t.abortController.signal);if(!n)return e(`Could not generate a name: no conversation context yet. Usage: /rename <name>`,{display:`system`}),null;c=n}else c=r.trim();let l=n(),d=s();return await o(l,c,d),await a(l,c,d),t.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:c}})),e(`Session renamed to: ${c}`,{display:`system`}),null}e((()=>{t(),r(),c(),l()}))();export{d as call};
@@ -1 +1 @@
1
- import{l as e,o as t}from"./envUtils-DfkgIdYf.js";import{o as n,s as r}from"./log-D2TIwHBV.js";import{ReadStream as i}from"tty";import{openSync as a}from"fs";t(),n();var o=null;function s(){if(o!==null)return o;if(process.stdin.isTTY){o=void 0;return}if(e(process.env.CI)){o=void 0;return}if(process.argv.includes(`mcp`)){o=void 0;return}if(process.platform===`win32`){o=void 0;return}try{let e=new i(a(`/dev/tty`,`r`));return e.isTTY=!0,o=e,o}catch(e){r(e),o=void 0;return}}function c(e=!1){let t=s(),n={exitOnCtrlC:e};return t&&(n.stdin=t),n}export{c as t};
1
+ import{l as e,o as t}from"./envUtils-DZ_SvEVz.js";import{o as n,s as r}from"./log-DWZny1vM.js";import{ReadStream as i}from"tty";import{openSync as a}from"fs";t(),n();var o=null;function s(){if(o!==null)return o;if(process.stdin.isTTY){o=void 0;return}if(e(process.env.CI)){o=void 0;return}if(process.argv.includes(`mcp`)){o=void 0;return}if(process.platform===`win32`){o=void 0;return}try{let e=new i(a(`/dev/tty`,`r`));return e.isTTY=!0,o=e,o}catch(e){r(e),o=void 0;return}}function c(e=!1){let t=s(),n={exitOnCtrlC:e};return t&&(n.stdin=t),n}export{c as t};
@@ -0,0 +1,2 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{I as i,P as a,ai as o,di as s,dr as c,fi as l,ot as u,t as d}from"./src-WZ94ZKI3.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as p,at as m,q as h}from"./state-CXY-q5gr.js";import{Ar as g,Ep as _,Or as v,Tp as y,Tr as b,Uy as x,Wy as S,bi as C,br as w,gr as T,lr as E,nr as D,oi as O,sb as k,vr as A,yi as j}from"./loadAgentsDir-DR5PVAc3.js";import{o as M,s as N}from"./log-DWZny1vM.js";import{r as P,t as F}from"./Spinner-DhhSOFcN.js";import{n as I,r as L}from"./modalContext-CBE8xuck.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./crossProjectResume-mmYx8PrZ.js";function W(e){switch(e.resultType){case`sessionNotFound`:return`Session ${s.bold(e.arg)} was not found. Run ${s.bold(`/resume`)} without arguments to browse all sessions.`;case`multipleMatches`:return`Found ${e.count} sessions matching ${s.bold(e.arg)}. Run ${s.bold(`/resume`)} to pick one from the list.`}}function G({message:e,args:t,onDone:n}){return J.useEffect(()=>{let e=setTimeout(n,0);return()=>clearTimeout(e)},[n]),(0,Y.jsxs)(i,{flexDirection:`column`,children:[(0,Y.jsxs)(a,{dimColor:!0,children:[r.pointer,` /resume `,t]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(a,{children:e})})]})}function K({onDone:e,onResume:t}){let[n,r]=J.useState([]),[o,s]=J.useState([]),[l,d]=J.useState(!0),[f,p]=J.useState(!1),[y,x]=J.useState(!1),{rows:S}=u(),C=L(),T=J.useCallback(async(t,n)=>{d(!0);try{let i=q(t?await b():await g(n),m());if(i.length===0){e(`No conversations found to resume`);return}r(i)}catch{e(`Failed to load conversations`)}finally{d(!1)}},[e]);J.useEffect(()=>{async function e(){let e=await j(h());s(e),T(!1,e)}e()},[T]);let D=J.useCallback(()=>{let e=!y;x(e),T(e,o)},[y,T,o]);async function O(n){let r=_(E(n));if(!r){e(`Failed to resume conversation`);return}let i=w(n)?await v(n):n,a=U(i,y);if(a.isCrossProject){if(a.isSameRepoWorktree){p(!0),t(r,i,`slash_command_picker`);return}let n=await c(a.command);n&&process.stdout.write(n),e([``,`This conversation is from a different directory.`,``,`To resume, run:`,` ${a.command}`,``,`(Command copied to clipboard)`,``].join(`
2
+ `),{display:`user`});return}p(!0),t(r,i,`slash_command_picker`)}function k(){e(`Resume cancelled`,{display:`system`})}return l?(0,Y.jsxs)(i,{children:[(0,Y.jsx)(F,{}),(0,Y.jsx)(a,{children:` Loading conversations…`})]}):f?(0,Y.jsxs)(i,{children:[(0,Y.jsx)(F,{}),(0,Y.jsx)(a,{children:` Resuming conversation…`})]}):(0,Y.jsx)(R,{logs:n,maxHeight:C?Math.floor(S/2):S-2,onCancel:k,onSelect:O,onLogsChanged:()=>T(y,o),showAllProjects:y,onToggleAllProjects:D,onAgenticSearch:H})}function q(e,t){return e.filter(e=>!e.isSidechain&&E(e)!==t)}var J,Y,X;e((()=>{l(),n(),J=t(o(),1),p(),V(),S(),P(),I(),k(),d(),z(),B(),C(),M(),T(),y(),Y=f(),X=async(e,t,n)=>{let r=async(n,r,i)=>{try{await t.resume?.(n,r,i),e(void 0,{display:`skip`})}catch(t){N(t),e(`Failed to resume: ${t.message}`)}},i=n?.trim();if(!i)return(0,Y.jsx)(K,{onDone:e,onResume:r},Date.now());let a=await g(await j(h()));if(a.length===0){let t=`No conversations found to resume.`;return(0,Y.jsx)(G,{message:t,args:i,onDone:()=>e(t)})}let o=_(i);if(o){let e=a.filter(e=>E(e)===o).sort((e,t)=>t.modified.getTime()-e.modified.getTime());if(e.length>0){let t=e[0];return r(o,w(t)?await v(t):t,`slash_command_session_id`),null}let t=await D(o);if(t)return r(o,t,`slash_command_session_id`),null}if(A()){let t=await O(i,{exact:!0});if(t.length===1){let e=t[0],n=E(e);if(n)return r(n,w(e)?await v(e):e,`slash_command_title`),null}if(t.length>1){let n=W({resultType:`multipleMatches`,arg:i,count:t.length});return(0,Y.jsx)(G,{message:n,args:i,onDone:()=>e(n)})}}let s=W({resultType:`sessionNotFound`,arg:i});return(0,Y.jsx)(G,{message:s,args:i,onDone:()=>e(s)})}}))();export{X as call,q as filterResumableSessions};
@@ -0,0 +1 @@
1
+ import{a as e,i as t}from"./ripgrep-D1f1pbCz.js";e();export{t as getRipgrepStatus};
@@ -0,0 +1,5 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{c as r,o as i}from"./envUtils-DZ_SvEVz.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{c as s,i as c}from"./debug-kBjDaVkQ.js";import{o as l,s as u}from"./log-DWZny1vM.js";import{i as d,t as f}from"./execFileNoThrow-BfZFnCGa.js";import{n as p,t as m}from"./bundledMode-BxyD5cqq.js";import{i as h,n as g}from"./platform-Vl9IynC3.js";import{n as _}from"./analytics-COpjZpvd.js";import{f as v,o as y,p as b,r as x}from"./stringUtils-D_xPrwGQ.js";import{homedir as S}from"os";import*as C from"path";import{existsSync as w}from"fs";import{execFile as T,spawn as E}from"child_process";import{fileURLToPath as D}from"url";var O,k,A,j=e((()=>{O=D(import.meta.url),k=C.dirname(O),A=(()=>{let e=k.split(C.sep),t=e.lastIndexOf(`dist`);if(t!==-1)return e.slice(0,t+1).join(C.sep);let n=e.lastIndexOf(`src`);return n===-1?k:e.slice(0,n).join(C.sep)})()}));function M(e,t,n){let r=n??process.platform;return w(e)?{mode:`builtin`,command:e,args:[]}:(t===void 0?v(`rg`,[]).cmd:t??`rg`)===`rg`?{mode:`builtin`,command:e,args:[],note:`no ripgrep available on ${r}; install ripgrep via apt/pkg/brew`}:{mode:`system`,command:`rg`,args:[]}}function N(){let e=V();return{rgPath:e.command,rgArgs:e.args,argv0:e.argv0}}function P(e){return e.includes(`os error 11`)||e.includes(`Resource temporarily unavailable`)}function F(e,t,n,r,i=!1){let{rgPath:a,rgArgs:o,argv0:s}=N(),c=i?[`-j`,`1`]:[],l=[...o,...c,...e,t],u=g()===`wsl`?6e4:2e4,d=parseInt(process.env.WORKMATE_GLOB_TIMEOUT_SECONDS||``,10)||0,f=d>0?d*1e3:u;if(s){let e=E(a,l,{argv0:s,signal:n,windowsHide:!0}),t=``,i=``,o=!1,c=!1;e.stdout?.on(`data`,e=>{o||(t+=e.toString(),t.length>H&&(t=t.slice(0,H),o=!0))}),e.stderr?.on(`data`,e=>{c||(i+=e.toString(),i.length>H&&(i=i.slice(0,H),c=!0))});let u,d=setTimeout(()=>{process.platform===`win32`?e.kill():(e.kill(`SIGTERM`),u=setTimeout(e=>e.kill(`SIGKILL`),5e3,e))},f),p=!1;return e.on(`close`,(e,n)=>{if(!p)if(p=!0,clearTimeout(d),clearTimeout(u),e===0||e===1)r(null,t,i);else{let a=Error(`ripgrep exited with code ${e}`);a.code=e??void 0,a.signal=n??void 0,r(a,t,i)}}),e.on(`error`,e=>{p||(p=!0,clearTimeout(d),clearTimeout(u),r(e,t,i))}),e}return T(a,l,{maxBuffer:H,signal:n,timeout:f,killSignal:process.platform===`win32`?void 0:`SIGKILL`},r)}async function I(e,t,n){await z();let{rgPath:r,rgArgs:i,argv0:a}=N();return new Promise((o,s)=>{let c=E(r,[...i,...e,t],{argv0:a,signal:n,windowsHide:!0,stdio:[`ignore`,`pipe`,`ignore`]}),l=0;c.stdout?.on(`data`,e=>{l+=x(e,`
2
+ `)});let u=!1;c.on(`close`,e=>{u||(u=!0,e===0||e===1?o(l):s(Error(`rg --files exited ${e}`)))}),c.on(`error`,e=>{u||(u=!0,s(e))})})}async function L(e,t,n){return await z(),K().catch(e=>{u(e)}),new Promise((r,i)=>{let a=(o,c,l,d)=>{if(!o){r(c.trim().split(`
3
+ `).map(e=>e.replace(/\r$/,``)).filter(Boolean));return}if(o.code===1){r([]);return}if([`ENOENT`,`EACCES`,`EPERM`].includes(o.code)){i(o);return}if(!d&&P(l)){s(`rg EAGAIN error detected, retrying with single-threaded mode (-j 1)`),F(e,t,n,(e,t,n)=>{a(e,t,n,!0)},!0);return}let f=c&&c.trim().length>0,p=o.signal===`SIGTERM`||o.signal===`SIGKILL`||o.code===`ABORT_ERR`,m=o.code===`ERR_CHILD_PROCESS_STDIO_MAXBUFFER`,h=[];if(f&&(h=c.trim().split(`
4
+ `).map(e=>e.replace(/\r$/,``)).filter(Boolean),h.length>0&&(p||m)&&(h=h.slice(0,-1))),s(`rg error (signal=${o.signal}, code=${o.code}, stderr: ${l}), ${h.length} results`),o.code!==2&&o.code!==`ABORT_ERR`&&u(o),p&&h.length===0){i(new U(`Ripgrep search timed out after ${g()===`wsl`?60:20} seconds. The search may have matched files but did not complete in time. Try searching a more specific path or pattern.`,h));return}r(h)};F(e,t,n,(e,t,n)=>{a(e,t,n,!1)})})}function R(){let e=V();return{mode:e.mode,path:e.command,working:G?.working??null,note:G?.note??e.note}}async function z(){if(process.platform!==`darwin`||q)return;q=!0;let e=V();if(e.mode!==`builtin`)return;let t=e.command;if((await f(`codesign`,[`-vv`,`-d`,t],{preserveOutputOnError:!1})).stdout.split(`
5
+ `).find(e=>e.includes(`linker-signed`)))try{let e=await f(`codesign`,[`--sign`,`-`,`--force`,`--preserve-metadata=entitlements,requirements,flags,runtime`,t]);e.code!==0&&u(Error(`Failed to sign ripgrep: ${e.stdout} ${e.stderr}`));let n=await f(`xattr`,[`-d`,`com.apple.quarantine`,t]);n.code!==0&&u(Error(`Failed to remove quarantine: ${n.stdout} ${n.stderr}`))}catch(e){u(e)}}var B,V,H,U,W,G,K,q,J=e((()=>{n(),_(),m(),c(),j(),i(),d(),b(),l(),h(),y(),a(),B=A,V=t(()=>{if(r(process.env.USE_BUILTIN_RIPGREP)){let{cmd:e}=v(`rg`,[]);if(e!==`rg`)return{mode:`system`,command:`rg`,args:[]}}if(p())return{mode:`embedded`,command:process.execPath,args:[`--no-config`],argv0:`rg`};let e=C.resolve(B,`vendor`,`ripgrep`);return M(process.platform===`win32`?C.resolve(e,`${process.arch}-win32`,`rg.exe`):C.resolve(e,`${process.arch}-${process.platform}`,`rg`))}),H=2e7,U=class extends Error{constructor(e,t){super(e),o(this,`partialResults`,void 0),this.partialResults=t,this.name=`RipgrepTimeoutError`}},W=t(async(e,t,n=[])=>{if(C.resolve(e)!==C.resolve(S()))try{let r=[`--files`,`--hidden`];n.forEach(e=>{r.push(`--glob`,`!${e}`)});let i=await I(r,e,t);if(i===0)return 0;let a=10**Math.floor(Math.log10(i));return Math.round(i/a)*a}catch(e){e?.name!==`AbortError`&&u(e)}},(e,t,n=[])=>`${e}|${n.join(`,`)}`),G=null,K=t(async()=>{if(G!==null)return;let e=V();try{let t;if(e.argv0){let n=Bun.spawn([e.command,`--version`],{argv0:e.argv0,stderr:`ignore`,stdout:`pipe`}),[r,i]=await Promise.all([n.stdout.text(),n.exited]);t={code:i,stdout:r}}else t=await f(e.command,[...e.args,`--version`],{timeout:5e3});let n=t.code===0&&!!t.stdout&&t.stdout.startsWith(`ripgrep `);G={working:n,lastTested:Date.now(),config:e,note:e.note},s(`Ripgrep first use test: ${n?`PASSED`:`FAILED`} (mode=${e.mode}, path=${e.command})`),+(e.mode===`system`)}catch(t){G={working:!1,lastTested:Date.now(),config:e,note:e.note},u(t)}}),q=!1}));export{J as a,N as c,R as i,W as n,M as o,V as r,L as s,U as t};
@@ -1,10 +1,10 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DfkgIdYf.js";import{Jd as r,Ni as i,Yd as a,wi as o}from"./loadAgentsDir-B0Anodo0.js";import{n as s,t as c}from"./featureCheck-D6FjD-nt.js";import{a as l,s as u}from"./projectContext-DhtjLv3k.js";import{a as d,c as ee,i as f,l as p,n as m,o as h,r as te,s as ne,u as g}from"./instinctParser-Dt-lqnDe.js";import{a as re,i as ie,n as _,o as v,r as y,t as ae}from"./observationStore-D0rm3GhP.js";import{a as oe,i as se,o as ce,r as le}from"./sessionObserver-BtKjvteq.js";import{a as ue,d as b,i as de,l as x,n as S,r as fe,s as C,t as pe,u as w}from"./skillLifecycle-Bnz_4wE5.js";import{join as T}from"node:path";import{existsSync as E}from"node:fs";import{randomBytes as me}from"node:crypto";import{mkdir as D,readFile as he,readdir as O,rename as ge,unlink as _e,writeFile as k}from"node:fs/promises";function A(e){let t=_(e),n=e?.project;return(e?.scope??n?.scope??`project`)===`global`||!n||n.projectId===`global`?T(t,`global`,`instincts`,`personal`):T(t,`projects`,n.projectId,`instincts`,`personal`)}async function j(e,t){let n=h(e);await D(A(t),{recursive:!0});let r=N(n.id,t),i=`${r}.${me(6).toString(`hex`)}.tmp`;return await k(i,ee(n)),await ge(i,r),n}async function M(e){let t=A(e),n=[];try{n=await O(t)}catch(e){if(e.code===`ENOENT`)return[];throw e}let r=[];for(let e of n.filter(e=>e.endsWith(`.json`))){let n=await he(T(t,e),`utf8`);r.push(ne(n))}return r.sort((e,t)=>e.id.localeCompare(t.id))}function ve(e,t){let n=P.then(()=>ye(e,t));return P=n.catch(()=>{}),n}async function ye(e,t){let n=await M(t),r=n.find(t=>t.id===e.id)??n.find(t=>t.trigger.toLowerCase()===e.trigger.toLowerCase()&&d(t,e)),i=new Date().toISOString();if(!r)return j(e,t);let a=d(r,e),o=a?-.1:Se(e.evidenceOutcome),s=m(r.confidence+o),c=be(r.status,s,a);return j(h({...r,confidence:s,evidence:[...r.evidence,...e.evidence],evidenceOutcome:e.evidenceOutcome??r.evidenceOutcome,observationIds:[...r.observationIds??[],...e.observationIds??[]],updatedAt:i,status:c}),t)}function be(e,t,n){return n&&t<.3?`conflict-hold`:e===`conflict-hold`&&t>=.5||e===`pending`&&t>=.8?`active`:e}async function xe(e){let t=await M(e),n=Date.now(),r=0;for(let i of t){if(i.status!==`pending`&&i.status!==`active`)continue;let t=Date.parse(i.updatedAt);if(Number.isNaN(t))continue;let a=Math.floor((n-t)/F);if(a<1)continue;let o=-.02*a,s=m(i.confidence+o);s!==i.confidence&&(await j(h({...i,confidence:s,updatedAt:new Date(n).toISOString()}),e),r+=1)}return r}function Se(e){return e===`failure`?-.05:.05}async function Ce(e,t){let n=await M(t),r=Date.now()-e*24*60*60*1e3,i=[];for(let e of n)e.status===`pending`&&Date.parse(e.updatedAt)<r&&(await _e(N(e.id,t)),i.push(e));return i}function N(e,t){return T(A(t),`${e}.json`)}var P,F,I=e((()=>{y(),f(),P=Promise.resolve(),F=10080*60*1e3}));function we(e,t){if(e.length===0)throw Error(`Cannot generate a command draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=w(t?.name??De(e)),i=Ae(e),a=t?.description??Oe(e),o=Ee(r,n,t),s=ke({name:r,description:a,confidence:i,instincts:e});return{name:r,description:a,scope:n,sourceInstinctIds:e.map(e=>e.id),confidence:Number(i.toFixed(2)),content:s,outputPath:o}}async function Te(e){await D(e.outputPath,{recursive:!0});let t=T(e.outputPath,`${e.name}.md`);return E(t)?t:(await k(t,e.content,`utf8`),o(),t)}function Ee(e,n,r){return r?.outputRoot?r.outputRoot:n===`project`?T(r?.cwd??process.cwd(),`.workmate`,`commands`):r?.globalCommandsDir??T(t(),`commands`)}function De(e){return w([`learned`,...je(e,4)].join(`-`))||`learned-command`}function Oe(e){return(e[0]?.trigger??`Reuse the learned workflow`).replace(/\s+/g,` `).slice(0,120)}function ke(e){let{name:t,description:n,confidence:r,instincts:i}=e;return[`---`,`name: ${t}`,`description: ${JSON.stringify(n)}`,`origin: skill-learning`,`confidence: ${Number(r.toFixed(2))}`,`evolved_from: [${i.map(e=>JSON.stringify(e.id)).join(`, `)}]`,`---`,``,`# /${t}`,``,`## When to use`,``,i.map(e=>`- ${e.trigger}`).join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DZ_SvEVz.js";import{Ci as r,Lp as i,Mi as a,Rp as o}from"./loadAgentsDir-DR5PVAc3.js";import{n as s,t as c}from"./featureCheck-D6FjD-nt.js";import{a as l,s as u}from"./projectContext-QN5U3Ggr.js";import{a as d,c as ee,i as f,l as p,n as m,o as h,r as te,s as ne,u as g}from"./instinctParser-Dt-lqnDe.js";import{a as re,i as ie,n as _,o as v,r as y,t as ae}from"./observationStore-D0rm3GhP.js";import{a as oe,i as se,o as ce,r as le}from"./sessionObserver-B6xzxckA.js";import{a as ue,d as b,i as de,l as x,n as S,r as fe,s as C,t as pe,u as w}from"./skillLifecycle-D9NkIwFQ.js";import{join as T}from"node:path";import{existsSync as E}from"node:fs";import{randomBytes as me}from"node:crypto";import{mkdir as D,readFile as he,readdir as O,rename as ge,unlink as _e,writeFile as k}from"node:fs/promises";function A(e){let t=_(e),n=e?.project;return(e?.scope??n?.scope??`project`)===`global`||!n||n.projectId===`global`?T(t,`global`,`instincts`,`personal`):T(t,`projects`,n.projectId,`instincts`,`personal`)}async function j(e,t){let n=h(e);await D(A(t),{recursive:!0});let r=N(n.id,t),i=`${r}.${me(6).toString(`hex`)}.tmp`;return await k(i,ee(n)),await ge(i,r),n}async function M(e){let t=A(e),n=[];try{n=await O(t)}catch(e){if(e.code===`ENOENT`)return[];throw e}let r=[];for(let e of n.filter(e=>e.endsWith(`.json`))){let n=await he(T(t,e),`utf8`);r.push(ne(n))}return r.sort((e,t)=>e.id.localeCompare(t.id))}function ve(e,t){let n=P.then(()=>ye(e,t));return P=n.catch(()=>{}),n}async function ye(e,t){let n=await M(t),r=n.find(t=>t.id===e.id)??n.find(t=>t.trigger.toLowerCase()===e.trigger.toLowerCase()&&d(t,e)),i=new Date().toISOString();if(!r)return j(e,t);let a=d(r,e),o=a?-.1:Se(e.evidenceOutcome),s=m(r.confidence+o),c=be(r.status,s,a);return j(h({...r,confidence:s,evidence:[...r.evidence,...e.evidence],evidenceOutcome:e.evidenceOutcome??r.evidenceOutcome,observationIds:[...r.observationIds??[],...e.observationIds??[]],updatedAt:i,status:c}),t)}function be(e,t,n){return n&&t<.3?`conflict-hold`:e===`conflict-hold`&&t>=.5||e===`pending`&&t>=.8?`active`:e}async function xe(e){let t=await M(e),n=Date.now(),r=0;for(let i of t){if(i.status!==`pending`&&i.status!==`active`)continue;let t=Date.parse(i.updatedAt);if(Number.isNaN(t))continue;let a=Math.floor((n-t)/F);if(a<1)continue;let o=-.02*a,s=m(i.confidence+o);s!==i.confidence&&(await j(h({...i,confidence:s,updatedAt:new Date(n).toISOString()}),e),r+=1)}return r}function Se(e){return e===`failure`?-.05:.05}async function Ce(e,t){let n=await M(t),r=Date.now()-e*24*60*60*1e3,i=[];for(let e of n)e.status===`pending`&&Date.parse(e.updatedAt)<r&&(await _e(N(e.id,t)),i.push(e));return i}function N(e,t){return T(A(t),`${e}.json`)}var P,F,I=e((()=>{y(),f(),P=Promise.resolve(),F=10080*60*1e3}));function we(e,t){if(e.length===0)throw Error(`Cannot generate a command draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=w(t?.name??De(e)),i=Ae(e),a=t?.description??Oe(e),o=Ee(r,n,t),s=ke({name:r,description:a,confidence:i,instincts:e});return{name:r,description:a,scope:n,sourceInstinctIds:e.map(e=>e.id),confidence:Number(i.toFixed(2)),content:s,outputPath:o}}async function Te(e){await D(e.outputPath,{recursive:!0});let t=T(e.outputPath,`${e.name}.md`);return E(t)?t:(await k(t,e.content,`utf8`),r(),t)}function Ee(e,n,r){return r?.outputRoot?r.outputRoot:n===`project`?T(r?.cwd??process.cwd(),`.workmate`,`commands`):r?.globalCommandsDir??T(t(),`commands`)}function De(e){return w([`learned`,...je(e,4)].join(`-`))||`learned-command`}function Oe(e){return(e[0]?.trigger??`Reuse the learned workflow`).replace(/\s+/g,` `).slice(0,120)}function ke(e){let{name:t,description:n,confidence:r,instincts:i}=e;return[`---`,`name: ${t}`,`description: ${JSON.stringify(n)}`,`origin: skill-learning`,`confidence: ${Number(r.toFixed(2))}`,`evolved_from: [${i.map(e=>JSON.stringify(e.id)).join(`, `)}]`,`---`,``,`# /${t}`,``,`## When to use`,``,i.map(e=>`- ${e.trigger}`).join(`
2
2
  `),``,`## Steps`,``,i.map(e=>`- ${e.action}`).join(`
3
3
  `),``,`## Evidence`,``,i.flatMap(e=>e.evidence.map(e=>`- ${e}`)).join(`
4
4
  `),``].join(`
5
- `)}function Ae(e){return e.reduce((e,t)=>e+t.confidence,0)/e.length}function je(e,t){let n=new Set([`when`,`with`,`this`,`that`,`user`,`asks`,`for`,`the`,`and`,`run`,`use`,`prefer`,`avoid`]),r=[];for(let i of e)for(let e of`${i.trigger} ${i.action}`.toLowerCase().split(/[^a-z0-9]+/))if(e.length>2&&!n.has(e)&&!r.includes(e)&&r.push(e),r.length>=t)return r;return r}var L=e((()=>{n(),i(),x()}));function Me(e,t){if(e.length===0)throw Error(`Cannot generate an agent draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=w(t?.name??Fe(e)),i=Re(e),a=t?.description??Ie(e),o=Pe(r,n,t),s=Le({name:r,description:a,confidence:i,instincts:e});return{name:r,description:a,scope:n,sourceInstinctIds:e.map(e=>e.id),confidence:Number(i.toFixed(2)),content:s,outputPath:o}}async function Ne(e){await D(e.outputPath,{recursive:!0});let t=T(e.outputPath,`${e.name}.md`);return E(t)?t:(await k(t,e.content,`utf8`),o(),t)}function Pe(e,n,r){return r?.outputRoot?r.outputRoot:n===`project`?T(r?.cwd??process.cwd(),`.workmate`,`agents`):r?.globalAgentsDir??T(t(),`agents`)}function Fe(e){return w([`learned`,`agent`,...ze(e,4)].join(`-`))||`learned-agent`}function Ie(e){return(e[0]?.trigger??`Run the learned multi-step workflow`).replace(/\s+/g,` `).slice(0,120)}function Le(e){let{name:t,description:n,confidence:r,instincts:i}=e;return[`---`,`name: ${t}`,`description: ${JSON.stringify(n)}`,`origin: skill-learning`,`confidence: ${Number(r.toFixed(2))}`,`evolved_from: [${i.map(e=>JSON.stringify(e.id)).join(`, `)}]`,`---`,``,`You are the ${t} learned agent.`,``,`## Triggers`,``,i.map(e=>`- ${e.trigger}`).join(`
5
+ `)}function Ae(e){return e.reduce((e,t)=>e+t.confidence,0)/e.length}function je(e,t){let n=new Set([`when`,`with`,`this`,`that`,`user`,`asks`,`for`,`the`,`and`,`run`,`use`,`prefer`,`avoid`]),r=[];for(let i of e)for(let e of`${i.trigger} ${i.action}`.toLowerCase().split(/[^a-z0-9]+/))if(e.length>2&&!n.has(e)&&!r.includes(e)&&r.push(e),r.length>=t)return r;return r}var L=e((()=>{n(),a(),x()}));function Me(e,t){if(e.length===0)throw Error(`Cannot generate an agent draft without instincts`);let n=t?.scope??e[0]?.scope??`project`,r=w(t?.name??Fe(e)),i=Re(e),a=t?.description??Ie(e),o=Pe(r,n,t),s=Le({name:r,description:a,confidence:i,instincts:e});return{name:r,description:a,scope:n,sourceInstinctIds:e.map(e=>e.id),confidence:Number(i.toFixed(2)),content:s,outputPath:o}}async function Ne(e){await D(e.outputPath,{recursive:!0});let t=T(e.outputPath,`${e.name}.md`);return E(t)?t:(await k(t,e.content,`utf8`),r(),t)}function Pe(e,n,r){return r?.outputRoot?r.outputRoot:n===`project`?T(r?.cwd??process.cwd(),`.workmate`,`agents`):r?.globalAgentsDir??T(t(),`agents`)}function Fe(e){return w([`learned`,`agent`,...ze(e,4)].join(`-`))||`learned-agent`}function Ie(e){return(e[0]?.trigger??`Run the learned multi-step workflow`).replace(/\s+/g,` `).slice(0,120)}function Le(e){let{name:t,description:n,confidence:r,instincts:i}=e;return[`---`,`name: ${t}`,`description: ${JSON.stringify(n)}`,`origin: skill-learning`,`confidence: ${Number(r.toFixed(2))}`,`evolved_from: [${i.map(e=>JSON.stringify(e.id)).join(`, `)}]`,`---`,``,`You are the ${t} learned agent.`,``,`## Triggers`,``,i.map(e=>`- ${e.trigger}`).join(`
6
6
  `),``,`## Playbook`,``,i.map(e=>`- ${e.action}`).join(`
7
7
  `),``,`## Evidence`,``,i.flatMap(e=>e.evidence.map(e=>`- ${e}`)).slice(0,20).join(`
8
8
  `),``].join(`
9
- `)}function Re(e){return e.reduce((e,t)=>e+t.confidence,0)/e.length}function ze(e,t){let n=new Set([`when`,`with`,`this`,`that`,`user`,`asks`,`for`,`the`,`and`,`debug`,`investigate`,`research`]),r=[];for(let i of e)for(let e of`${i.trigger} ${i.action}`.toLowerCase().split(/[^a-z0-9]+/))if(e.length>2&&!n.has(e)&&!r.includes(e)&&r.push(e),r.length>=t)return r;return r}var R=e((()=>{n(),i(),x()}));function z(e){let t=new Map;for(let n of e){if(n.status!==`active`&&n.status!==`pending`)continue;let e=`${n.domain}:${Ue(n.trigger)}`,r=t.get(e)??[];r.push(n),t.set(e,r)}return Array.from(t.values()).filter(e=>e.length>=p().minClusterSize).map(e=>{let t=e.reduce((e,t)=>e+t.confidence,0)/e.length;return{target:Be(e),trigger:e[0]?.trigger??`learned pattern`,domain:e[0]?.domain??`project`,instincts:e,averageConfidence:Number(t.toFixed(2))}}).sort((e,t)=>t.averageConfidence-e.averageConfidence)}function Be(e){let t=Array.isArray(e)?e:e.instincts,n=t.map(e=>`${e.trigger} ${e.action}`).join(` `).toLowerCase();return/user asks|explicitly request|command|run /.test(n)?`command`:t.length>=4&&/(debug|investigate|research|multi-step)/.test(n)?`agent`:`skill`}function Ve(e,t){return z(e).filter(e=>e.target===`command`&&b(e.instincts)).map(e=>we(e.instincts,{...t,scope:e.instincts[0]?.scope??`project`}))}function He(e,t){return z(e).filter(e=>e.target===`agent`&&b(e.instincts)).map(e=>Me(e.instincts,{...t,scope:e.instincts[0]?.scope??`project`}))}function Ue(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,` `).split(/\s+/).filter(Boolean).slice(0,6).join(` `)}var We=e((()=>{x(),C(),L(),R(),g()}));function Ge(e){if(H.add(e),H.size>B){let e=H.size-V,t=H.values();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;H.delete(e.value)}}}function Ke(e,t=2,n=.8){let r=new Map;for(let t of e){if(t.scope!==`project`)continue;let e=r.get(t.id)??[];e.push(t),r.set(t.id,e)}return Array.from(r.entries()).flatMap(([e,r])=>{let i=Array.from(new Set(r.map(e=>e.projectId).filter(Boolean))),a=r.reduce((e,t)=>e+t.confidence,0)/r.length;return i.length>=t&&a>=n?[{instinctId:e,projectIds:i,averageConfidence:Number(a.toFixed(2))}]:[]})}async function qe(e={}){let t=e.minProjects??2,n=e.minConfidence??.8,r=await Je(e.rootDir),i=Ke(r,t,n),a=[];for(let t of i){if(H.has(t.instinctId))continue;let n=r.find(e=>e.id===t.instinctId);n&&(await j({...n,scope:`global`,projectId:void 0,projectName:void 0,confidence:t.averageConfidence,updatedAt:new Date().toISOString()},{rootDir:e.rootDir,scope:`global`,project:Ye(e.rootDir)}),Ge(t.instinctId),a.push(t))}return a}async function Je(e){let t=T(_(e?{rootDir:e}:void 0),`projects`);if(!E(t))return[];let n=await O(t,{withFileTypes:!0}),r=[];for(let i of n){if(!i.isDirectory())continue;let n=await M({rootDir:e,project:{projectId:i.name,projectName:i.name,scope:`project`,source:`git_root`,cwd:t,storageDir:T(t,i.name)},scope:`project`});r.push(...n)}return r}function Ye(e){let t=_(e?{rootDir:e}:void 0);return{projectId:`global`,projectName:`Global`,scope:`global`,source:`global`,cwd:t,storageDir:T(t,`global`)}}var B,V,H,Xe=e((()=>{I(),y(),B=256,V=192,H=new Set}));function U(){X=0,Z=0,Q.clear()}function Ze(){return J}function Qe(){if(!q){q=!0;try{ce()}catch{}a(W),$e().catch(()=>{})}}async function $e(){if(!s()||process.env.CLAUDE_SKILL_LEARNING_DISABLE)return;let e={project:u(process.cwd())};await Promise.allSettled([xe(e),ie(e),Ce(30,e)])}function et(e){try{let t=_();return e.startsWith(t)}catch{return!1}}async function W(e){if(!s()||process.env.CLAUDE_SKILL_LEARNING_DISABLE||!e.querySource?.startsWith(`repl_main_thread`)||e.toolUseContext.agentId)return;let t=process.cwd();if(et(t))return;let n=u(t),r={project:n};++J;let i=[];for(let t of rt(e.messages,n))i.push(await ae(t,r));let a=(await re(r)).filter(e=>e.source===`tool-hook`&&e.sessionId===`runtime-session`&&typeof e.timestamp==`string`&&e.timestamp>Y);i.push(...a);for(let e of a)e.timestamp>Y&&(Y=e.timestamp);if(i.length===0)return;let o=Date.now(),{llm:c}=p(),l=i.length>=5&&X<c.maxCallsPerSession&&o-Z>=c.cooldownMs,d;if(l)X++,Z=o,d=await se(i,{project:n});else{let{heuristicObserverBackend:e}=await import(`./sessionObserver-D6qzEdGJ.js`),t=e.analyze(i,{project:n});d=Array.isArray(t)?t:await t}for(let e of d)await ve(te(e),r);await nt(r)}function tt(){J=0,Y=``,U()}async function nt(e){let n=await M(e),r=process.cwd(),i=[T(r,`.workmate`,`skills`),T(t(),`skills`)],a=z(n).filter(e=>e.target===`skill`&&b(e.instincts));for(let e of a){let t=await ue(e.instincts,{cwd:r,scope:e.instincts[0]?.scope??`project`},i);if(t.action===`append-evidence`)continue;let n=t.draft;E(T(n.outputPath,`SKILL.md`))||await pe(fe(n,await S(`skill`,n,i)))}let o=Ve(n,{cwd:r});for(let e of o)(await S(`command`,e,[T(r,`.workmate`,`commands`),T(t(),`commands`)])).length>0||await Te(e);let s=He(n,{cwd:r});for(let e of s)(await S(`agent`,e,[T(r,`.workmate`,`agents`),T(t(),`agents`)])).length>0||await Ne(e);await qe()}function rt(e,t){let n=K,r={sessionId:n,projectId:t.projectId,projectName:t.projectName,cwd:t.cwd,timestamp:new Date().toISOString(),source:`hook`};return e.flatMap(e=>{let t=`${n}:${String(e.uuid)}`;if(Q.has(t))return[];if(Q.add(t),Q.size>$){let e=Q.size-ot,t=Q.values();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;Q.delete(e.value)}}if(e.type===`user`){let t=at(e.message?.content);if(t.length>0)return t.map(e=>({...r,id:crypto.randomUUID(),event:`tool_complete`,toolName:e.toolName,toolOutput:e.output,outcome:e.isError?`failure`:`success`}));let n=G(e.message?.content);return n.trim()?[{...r,id:crypto.randomUUID(),event:`user_message`,messageText:n}]:[]}if(e.type===`assistant`){let t=it(e.message?.content),n=G(e.message?.content);return[...t.map(e=>({...r,id:crypto.randomUUID(),event:`tool_start`,toolName:e.toolName,toolInput:e.input})),...n.trim()?[{...r,id:crypto.randomUUID(),event:`assistant_message`,messageText:n}]:[]]}return[]})}function G(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
10
- `):``}function it(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_use`?[{toolName:String(t.name??`unknown_tool`),input:v(t.input)}]:[]}):[]}function at(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_result`?[{toolName:String(t.name??t.tool_name??`unknown_tool`),output:v(t.content),isError:t.is_error===!0}]:[]}):[]}var K,q,J,Y,X,Z,Q,$,ot,st=e((()=>{r(),g(),c(),y(),l(),le(),f(),oe(),I(),de(),We(),C(),x(),L(),R(),Xe(),n(),K=`runtime-session`,q=!1,J=0,Y=``,X=0,Z=0,Q=new Set,$=1e3,ot=500}));export{U as a,st as i,Ze as n,tt as o,Qe as r,W as s,K as t};
9
+ `)}function Re(e){return e.reduce((e,t)=>e+t.confidence,0)/e.length}function ze(e,t){let n=new Set([`when`,`with`,`this`,`that`,`user`,`asks`,`for`,`the`,`and`,`debug`,`investigate`,`research`]),r=[];for(let i of e)for(let e of`${i.trigger} ${i.action}`.toLowerCase().split(/[^a-z0-9]+/))if(e.length>2&&!n.has(e)&&!r.includes(e)&&r.push(e),r.length>=t)return r;return r}var R=e((()=>{n(),a(),x()}));function z(e){let t=new Map;for(let n of e){if(n.status!==`active`&&n.status!==`pending`)continue;let e=`${n.domain}:${Ue(n.trigger)}`,r=t.get(e)??[];r.push(n),t.set(e,r)}return Array.from(t.values()).filter(e=>e.length>=p().minClusterSize).map(e=>{let t=e.reduce((e,t)=>e+t.confidence,0)/e.length;return{target:Be(e),trigger:e[0]?.trigger??`learned pattern`,domain:e[0]?.domain??`project`,instincts:e,averageConfidence:Number(t.toFixed(2))}}).sort((e,t)=>t.averageConfidence-e.averageConfidence)}function Be(e){let t=Array.isArray(e)?e:e.instincts,n=t.map(e=>`${e.trigger} ${e.action}`).join(` `).toLowerCase();return/user asks|explicitly request|command|run /.test(n)?`command`:t.length>=4&&/(debug|investigate|research|multi-step)/.test(n)?`agent`:`skill`}function Ve(e,t){return z(e).filter(e=>e.target===`command`&&b(e.instincts)).map(e=>we(e.instincts,{...t,scope:e.instincts[0]?.scope??`project`}))}function He(e,t){return z(e).filter(e=>e.target===`agent`&&b(e.instincts)).map(e=>Me(e.instincts,{...t,scope:e.instincts[0]?.scope??`project`}))}function Ue(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,` `).split(/\s+/).filter(Boolean).slice(0,6).join(` `)}var We=e((()=>{x(),C(),L(),R(),g()}));function Ge(e){if(H.add(e),H.size>B){let e=H.size-V,t=H.values();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;H.delete(e.value)}}}function Ke(e,t=2,n=.8){let r=new Map;for(let t of e){if(t.scope!==`project`)continue;let e=r.get(t.id)??[];e.push(t),r.set(t.id,e)}return Array.from(r.entries()).flatMap(([e,r])=>{let i=Array.from(new Set(r.map(e=>e.projectId).filter(Boolean))),a=r.reduce((e,t)=>e+t.confidence,0)/r.length;return i.length>=t&&a>=n?[{instinctId:e,projectIds:i,averageConfidence:Number(a.toFixed(2))}]:[]})}async function qe(e={}){let t=e.minProjects??2,n=e.minConfidence??.8,r=await Je(e.rootDir),i=Ke(r,t,n),a=[];for(let t of i){if(H.has(t.instinctId))continue;let n=r.find(e=>e.id===t.instinctId);n&&(await j({...n,scope:`global`,projectId:void 0,projectName:void 0,confidence:t.averageConfidence,updatedAt:new Date().toISOString()},{rootDir:e.rootDir,scope:`global`,project:Ye(e.rootDir)}),Ge(t.instinctId),a.push(t))}return a}async function Je(e){let t=T(_(e?{rootDir:e}:void 0),`projects`);if(!E(t))return[];let n=await O(t,{withFileTypes:!0}),r=[];for(let i of n){if(!i.isDirectory())continue;let n=await M({rootDir:e,project:{projectId:i.name,projectName:i.name,scope:`project`,source:`git_root`,cwd:t,storageDir:T(t,i.name)},scope:`project`});r.push(...n)}return r}function Ye(e){let t=_(e?{rootDir:e}:void 0);return{projectId:`global`,projectName:`Global`,scope:`global`,source:`global`,cwd:t,storageDir:T(t,`global`)}}var B,V,H,Xe=e((()=>{I(),y(),B=256,V=192,H=new Set}));function U(){X=0,Z=0,Q.clear()}function Ze(){return J}function Qe(){if(!q){q=!0;try{ce()}catch{}o(W),$e().catch(()=>{})}}async function $e(){if(!s()||process.env.CLAUDE_SKILL_LEARNING_DISABLE)return;let e={project:u(process.cwd())};await Promise.allSettled([xe(e),ie(e),Ce(30,e)])}function et(e){try{let t=_();return e.startsWith(t)}catch{return!1}}async function W(e){if(!s()||process.env.CLAUDE_SKILL_LEARNING_DISABLE||!e.querySource?.startsWith(`repl_main_thread`)||e.toolUseContext.agentId)return;let t=process.cwd();if(et(t))return;let n=u(t),r={project:n};++J;let i=[];for(let t of rt(e.messages,n))i.push(await ae(t,r));let a=(await re(r)).filter(e=>e.source===`tool-hook`&&e.sessionId===`runtime-session`&&typeof e.timestamp==`string`&&e.timestamp>Y);i.push(...a);for(let e of a)e.timestamp>Y&&(Y=e.timestamp);if(i.length===0)return;let o=Date.now(),{llm:c}=p(),l=i.length>=5&&X<c.maxCallsPerSession&&o-Z>=c.cooldownMs,d;if(l)X++,Z=o,d=await se(i,{project:n});else{let{heuristicObserverBackend:e}=await import(`./sessionObserver-CBrM4opL.js`),t=e.analyze(i,{project:n});d=Array.isArray(t)?t:await t}for(let e of d)await ve(te(e),r);await nt(r)}function tt(){J=0,Y=``,U()}async function nt(e){let n=await M(e),r=process.cwd(),i=[T(r,`.workmate`,`skills`),T(t(),`skills`)],a=z(n).filter(e=>e.target===`skill`&&b(e.instincts));for(let e of a){let t=await ue(e.instincts,{cwd:r,scope:e.instincts[0]?.scope??`project`},i);if(t.action===`append-evidence`)continue;let n=t.draft;E(T(n.outputPath,`SKILL.md`))||await pe(fe(n,await S(`skill`,n,i)))}let o=Ve(n,{cwd:r});for(let e of o)(await S(`command`,e,[T(r,`.workmate`,`commands`),T(t(),`commands`)])).length>0||await Te(e);let s=He(n,{cwd:r});for(let e of s)(await S(`agent`,e,[T(r,`.workmate`,`agents`),T(t(),`agents`)])).length>0||await Ne(e);await qe()}function rt(e,t){let n=K,r={sessionId:n,projectId:t.projectId,projectName:t.projectName,cwd:t.cwd,timestamp:new Date().toISOString(),source:`hook`};return e.flatMap(e=>{let t=`${n}:${String(e.uuid)}`;if(Q.has(t))return[];if(Q.add(t),Q.size>$){let e=Q.size-ot,t=Q.values();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;Q.delete(e.value)}}if(e.type===`user`){let t=at(e.message?.content);if(t.length>0)return t.map(e=>({...r,id:crypto.randomUUID(),event:`tool_complete`,toolName:e.toolName,toolOutput:e.output,outcome:e.isError?`failure`:`success`}));let n=G(e.message?.content);return n.trim()?[{...r,id:crypto.randomUUID(),event:`user_message`,messageText:n}]:[]}if(e.type===`assistant`){let t=it(e.message?.content),n=G(e.message?.content);return[...t.map(e=>({...r,id:crypto.randomUUID(),event:`tool_start`,toolName:e.toolName,toolInput:e.input})),...n.trim()?[{...r,id:crypto.randomUUID(),event:`assistant_message`,messageText:n}]:[]]}return[]})}function G(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
10
+ `):``}function it(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_use`?[{toolName:String(t.name??`unknown_tool`),input:v(t.input)}]:[]}):[]}function at(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_result`?[{toolName:String(t.name??t.tool_name??`unknown_tool`),output:v(t.content),isError:t.is_error===!0}]:[]}):[]}var K,q,J,Y,X,Z,Q,$,ot,st=e((()=>{i(),g(),c(),y(),l(),le(),f(),oe(),I(),de(),We(),C(),x(),L(),R(),Xe(),n(),K=`runtime-session`,q=!1,J=0,Y=``,X=0,Z=0,Q=new Set,$=1e3,ot=500}));export{U as a,st as i,Ze as n,tt as o,Qe as r,W as s,K as t};
@@ -1 +1 @@
1
- import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./runtimeObserver-PJ1o8GRA.js";t();export{o as RUNTIME_SESSION_ID,n as getRuntimeTurn,i as initSkillLearning,e as resetRuntimeLLMBookkeeping,r as resetRuntimeObserverForTest,a as runSkillLearningPostSampling};
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./runtimeObserver-BPqlbu0B.js";t();export{o as RUNTIME_SESSION_ID,n as getRuntimeTurn,i as initSkillLearning,e as resetRuntimeLLMBookkeeping,r as resetRuntimeObserverForTest,a as runSkillLearningPostSampling};
@@ -0,0 +1 @@
1
+ import{aC as e,sC as t}from"./loadAgentsDir-DR5PVAc3.js";t();export{e as SandboxManager};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Gt as t,H as n,I as r,Lt as i,P as a,a as o,j as s,n as c,r as l,t as u,x as d}from"./src-WZ94ZKI3.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as p,T as m}from"./state-CXY-q5gr.js";import{aC as h,cC as g,oC as _,sC as v,tb as y}from"./loadAgentsDir-DR5PVAc3.js";import{d as b,m as x,o as S}from"./settings-YIDksG5Z.js";import{i as C,n as w}from"./platform-Vl9IynC3.js";import{n as T,t as E}from"./select-FrwoTzuc.js";import{relative as D}from"path";function O(){let e=h.isSandboxingEnabled(),t=h.checkDependencies(),n=t.warnings.length>0?(0,k.jsx)(r,{marginTop:1,flexDirection:`column`,children:t.warnings.map((e,t)=>(0,k.jsx)(a,{dimColor:!0,children:e},t))}):null;if(!e)return(0,k.jsxs)(r,{flexDirection:`column`,paddingY:1,children:[(0,k.jsx)(a,{color:`subtle`,children:`Sandbox is not enabled`}),n]});let i=h.getFsReadConfig(),o=h.getFsWriteConfig(),s=h.getNetworkRestrictionConfig(),c=h.getAllowUnixSockets(),l=h.getExcludedCommands(),u=h.getLinuxGlobPatternWarnings();return(0,k.jsxs)(r,{flexDirection:`column`,paddingY:1,children:[(0,k.jsxs)(r,{flexDirection:`column`,children:[(0,k.jsx)(a,{bold:!0,color:`permission`,children:`Excluded Commands:`}),(0,k.jsx)(a,{dimColor:!0,children:l.length>0?l.join(`, `):`None`})]}),i.denyOnly.length>0&&(0,k.jsxs)(r,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(a,{bold:!0,color:`permission`,children:`Filesystem Read Restrictions:`}),(0,k.jsxs)(a,{dimColor:!0,children:[`Denied: `,i.denyOnly.join(`, `)]}),i.allowWithinDeny&&i.allowWithinDeny.length>0&&(0,k.jsxs)(a,{dimColor:!0,children:[`Allowed within denied: `,i.allowWithinDeny.join(`, `)]})]}),o.allowOnly.length>0&&(0,k.jsxs)(r,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(a,{bold:!0,color:`permission`,children:`Filesystem Write Restrictions:`}),(0,k.jsxs)(a,{dimColor:!0,children:[`Allowed: `,o.allowOnly.join(`, `)]}),o.denyWithinAllow.length>0&&(0,k.jsxs)(a,{dimColor:!0,children:[`Denied within allowed: `,o.denyWithinAllow.join(`, `)]})]}),(s.allowedHosts&&s.allowedHosts.length>0||s.deniedHosts&&s.deniedHosts.length>0)&&(0,k.jsxs)(r,{marginTop:1,flexDirection:`column`,children:[(0,k.jsxs)(a,{bold:!0,color:`permission`,children:[`Network Restrictions`,g()?` (Managed)`:``,`:`]}),s.allowedHosts&&s.allowedHosts.length>0&&(0,k.jsxs)(a,{dimColor:!0,children:[`Allowed: `,s.allowedHosts.join(`, `)]}),s.deniedHosts&&s.deniedHosts.length>0&&(0,k.jsxs)(a,{dimColor:!0,children:[`Denied: `,s.deniedHosts.join(`, `)]})]}),c&&c.length>0&&(0,k.jsxs)(r,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(a,{bold:!0,color:`permission`,children:`Allowed Unix Sockets:`}),(0,k.jsx)(a,{dimColor:!0,children:c.join(`, `)})]}),u.length>0&&(0,k.jsxs)(r,{marginTop:1,flexDirection:`column`,children:[(0,k.jsx)(a,{bold:!0,color:`warning`,children:`⚠ Warning: Glob patterns not fully supported on Linux`}),(0,k.jsxs)(a,{dimColor:!0,children:[`The following patterns will be ignored: `,u.slice(0,3).join(`, `),u.length>3&&` (${u.length-3} more)`]})]}),n]})}var k,A=e((()=>{u(),v(),k=f()}));function j({depCheck:e}){let t=w()===`macos`,n=e.errors.some(e=>e.includes(`ripgrep`)),i=e.errors.some(e=>e.includes(`bwrap`)),o=e.errors.some(e=>e.includes(`socat`)),s=e.warnings.length>0,c=e.errors.filter(e=>!e.includes(`ripgrep`)&&!e.includes(`bwrap`)&&!e.includes(`socat`));return(0,M.jsxs)(r,{flexDirection:`column`,paddingY:1,gap:1,children:[t&&(0,M.jsx)(r,{flexDirection:`column`,children:(0,M.jsxs)(a,{children:[`seatbelt: `,(0,M.jsx)(a,{color:`success`,children:`built-in (macOS)`})]})}),(0,M.jsxs)(r,{flexDirection:`column`,children:[(0,M.jsxs)(a,{children:[`ripgrep (rg): `,n?(0,M.jsx)(a,{color:`error`,children:`not found`}):(0,M.jsx)(a,{color:`success`,children:`found`})]}),n&&(0,M.jsxs)(a,{dimColor:!0,children:[` `,`· `,t?`brew install ripgrep`:`apt install ripgrep`]})]}),!t&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(r,{flexDirection:`column`,children:[(0,M.jsxs)(a,{children:[`bubblewrap (bwrap):`,` `,i?(0,M.jsx)(a,{color:`error`,children:`not installed`}):(0,M.jsx)(a,{color:`success`,children:`installed`})]}),i&&(0,M.jsxs)(a,{dimColor:!0,children:[` `,`· apt install bubblewrap`]})]}),(0,M.jsxs)(r,{flexDirection:`column`,children:[(0,M.jsxs)(a,{children:[`socat: `,o?(0,M.jsx)(a,{color:`error`,children:`not installed`}):(0,M.jsx)(a,{color:`success`,children:`installed`})]}),o&&(0,M.jsxs)(a,{dimColor:!0,children:[` `,`· apt install socat`]})]}),(0,M.jsxs)(r,{flexDirection:`column`,children:[(0,M.jsxs)(a,{children:[`seccomp filter:`,` `,s?(0,M.jsx)(a,{color:`warning`,children:`not installed`}):(0,M.jsx)(a,{color:`success`,children:`installed`}),s&&(0,M.jsx)(a,{dimColor:!0,children:` (required to block unix domain sockets)`})]}),s&&(0,M.jsxs)(r,{flexDirection:`column`,children:[(0,M.jsxs)(a,{dimColor:!0,children:[` `,`· npm install -g @anthropic-ai/sandbox-runtime`]}),(0,M.jsxs)(a,{dimColor:!0,children:[` `,`· or copy vendor/seccomp/* from sandbox-runtime and set`]}),(0,M.jsxs)(a,{dimColor:!0,children:[` `,`sandbox.seccomp.bpfPath and applyPath in settings.json`]})]})]})]}),c.map(e=>(0,M.jsx)(a,{color:`error`,children:e},e))]})}var M,N=e((()=>{u(),C(),M=f()}));function P({onComplete:e}){let t=h.isSandboxingEnabled(),n=h.areSandboxSettingsLockedByPolicy(),i=h.areUnsandboxedCommandsAllowed();return t?n?(0,I.jsxs)(r,{flexDirection:`column`,paddingY:1,children:[(0,I.jsx)(a,{color:`subtle`,children:`Override settings are managed by a higher-priority configuration and cannot be changed locally.`}),(0,I.jsx)(r,{marginTop:1,children:(0,I.jsxs)(a,{dimColor:!0,children:[`Current setting: `,i?`Allow unsandboxed fallback`:`Strict sandbox mode`]})})]}):(0,I.jsx)(F,{onComplete:e,currentMode:i?`open`:`closed`}):(0,I.jsx)(r,{flexDirection:`column`,paddingY:1,children:(0,I.jsx)(a,{color:`subtle`,children:`Sandbox is not enabled. Enable sandbox to configure override settings.`})})}function F({onComplete:e,currentMode:t}){let[c]=n(),{headerFocused:l,focusHeader:u}=o(),d=s(`success`,c)(`(current)`),f=[{label:t===`open`?`Allow unsandboxed fallback ${d}`:`Allow unsandboxed fallback`,value:`open`},{label:t===`closed`?`Strict sandbox mode ${d}`:`Strict sandbox mode`,value:`closed`}];async function p(t){let n=t;await h.setSandboxSettings({allowUnsandboxedCommands:n===`open`}),e(n===`open`?`✓ Unsandboxed fallback allowed - commands can run outside sandbox when necessary`:"✓ Strict sandbox mode - all commands must run in sandbox or be excluded via the `excludedCommands` option")}return(0,I.jsxs)(r,{flexDirection:`column`,paddingY:1,children:[(0,I.jsx)(r,{marginBottom:1,children:(0,I.jsx)(a,{bold:!0,children:`Configure Overrides:`})}),(0,I.jsx)(E,{options:f,onChange:p,onCancel:()=>e(void 0,{display:`skip`}),onUpFromFirstItem:u,isDisabled:l}),(0,I.jsxs)(r,{flexDirection:`column`,marginTop:1,gap:1,children:[(0,I.jsxs)(a,{dimColor:!0,children:[(0,I.jsx)(a,{bold:!0,dimColor:!0,children:`Allow unsandboxed fallback:`}),` `,`When a command fails due to sandbox restrictions, Work Mate can retry with dangerouslyDisableSandbox to run outside the sandbox (falling back to default permissions).`]}),(0,I.jsxs)(a,{dimColor:!0,children:[(0,I.jsx)(a,{bold:!0,dimColor:!0,children:`Strict sandbox mode:`}),` `,`All bash commands invoked by the model must run in the sandbox unless they are explicitly listed in excludedCommands.`]}),(0,I.jsxs)(a,{dimColor:!0,children:[`Learn more:`,` `,(0,I.jsx)(i,{url:`https://code.workmate.com/docs/en/sandboxing#configure-sandboxing`,children:`code.workmate.com/docs/en/sandboxing#configure-sandboxing`})]})]})]})}var I,L=e((()=>{u(),v(),T(),I=f()}));function R({onComplete:e,depCheck:r}){let[i]=n(),a=h.isSandboxingEnabled(),o=h.isAutoAllowBashIfSandboxedEnabled(),u=r.warnings.length>0,f=b().sandbox?.network?.allowAllUnixSockets,p=u&&!f,m=a?o?`auto-allow`:`regular`:`disabled`,g=s(`success`,i)(`(current)`),_=[{label:m===`auto-allow`?`Sandbox BashTool, with auto-allow ${g}`:`Sandbox BashTool, with auto-allow`,value:`auto-allow`},{label:m===`regular`?`Sandbox BashTool, with regular permissions ${g}`:`Sandbox BashTool, with regular permissions`,value:`regular`},{label:m===`disabled`?`No Sandbox ${g}`:`No Sandbox`,value:`disabled`}];async function v(t){switch(t){case`auto-allow`:await h.setSandboxSettings({enabled:!0,autoAllowBashIfSandboxed:!0}),e(`✓ Sandbox enabled with auto-allow for bash commands`);break;case`regular`:await h.setSandboxSettings({enabled:!0,autoAllowBashIfSandboxed:!1}),e(`✓ Sandbox enabled with regular bash permissions`);break;case`disabled`:await h.setSandboxSettings({enabled:!1,autoAllowBashIfSandboxed:!1}),e(`○ Sandbox disabled`);break}}t({"confirm:no":()=>e(void 0,{display:`skip`})},{context:`Settings`});let y=(0,B.jsx)(c,{title:`Mode`,children:(0,B.jsx)(z,{showSocketWarning:p,options:_,onSelect:v,onComplete:e})},`mode`),x=(0,B.jsx)(c,{title:`Overrides`,children:(0,B.jsx)(P,{onComplete:e})},`overrides`),S=(0,B.jsx)(c,{title:`Config`,children:(0,B.jsx)(O,{})},`config`);return(0,B.jsx)(d,{color:`permission`,children:(0,B.jsx)(l,{title:`Sandbox:`,color:`permission`,defaultTab:`Mode`,children:r.errors.length>0?[(0,B.jsx)(c,{title:`Dependencies`,children:(0,B.jsx)(j,{depCheck:r})},`dependencies`)]:[y,...u?[(0,B.jsx)(c,{title:`Dependencies`,children:(0,B.jsx)(j,{depCheck:r})},`dependencies`)]:[],x,S]})})}function z({showSocketWarning:e,options:t,onSelect:n,onComplete:s}){let{headerFocused:c,focusHeader:l}=o();return(0,B.jsxs)(r,{flexDirection:`column`,paddingY:1,children:[e&&(0,B.jsx)(r,{marginBottom:1,children:(0,B.jsx)(a,{color:`warning`,children:`Cannot block unix domain sockets (see Dependencies tab)`})}),(0,B.jsx)(r,{marginBottom:1,children:(0,B.jsx)(a,{bold:!0,children:`Configure Mode:`})}),(0,B.jsx)(E,{options:t,onChange:n,onCancel:()=>s(void 0,{display:`skip`}),onUpFromFirstItem:l,isDisabled:c}),(0,B.jsxs)(r,{flexDirection:`column`,marginTop:1,gap:1,children:[(0,B.jsxs)(a,{dimColor:!0,children:[(0,B.jsx)(a,{bold:!0,dimColor:!0,children:`Auto-allow mode:`}),` `,`Commands will try to run in the sandbox automatically, and attempts to run outside of the sandbox fallback to regular permissions. Explicit ask/deny rules are always respected.`]}),(0,B.jsxs)(a,{dimColor:!0,children:[`Learn more:`,` `,(0,B.jsx)(i,{url:`https://code.workmate.com/docs/en/sandboxing`,children:`code.workmate.com/docs/en/sandboxing`})]})]})]})}var B,V=e((()=>{u(),y(),v(),x(),T(),A(),N(),L(),B=f()}));async function H(e,t,n){let r=b().theme||`light`,i=w();if(!h.isSupportedPlatform()){let t=i===`wsl`?`Error: Sandboxing requires WSL2. WSL1 is not supported.`:`Error: Sandboxing is currently only supported on macOS, Linux, and WSL2.`;return e(s(`error`,r)(t)),null}let a=h.checkDependencies();if(!h.isPlatformInEnabledList())return e(s(`error`,r)(`Error: Sandboxing is disabled for this platform (${i}) via the enabledPlatforms setting.`)),null;if(h.areSandboxSettingsLockedByPolicy())return e(s(`error`,r)(`Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.`)),null;let o=n?.trim()||``;if(!o)return(0,U.jsx)(R,{onComplete:e,depCheck:a});if(o){let t=o.split(` `)[0];if(t===`exclude`){let t=o.slice(8).trim();if(!t)return e(s(`error`,r)(`Error: Please provide a command pattern to exclude (e.g., /sandbox exclude "npm run test:*")`)),null;let n=t.replace(/^["']|["']$/g,``);_(n);let i=S(`localSettings`),a=i?D(m(),i):`.workmate/settings.local.json`;return e(s(`success`,r)(`Added "${n}" to excluded commands in ${a}`)),null}else return e(s(`error`,r)(`Error: Unknown subcommand "${t}". Available subcommand: exclude`)),null}return null}var U;e((()=>{p(),V(),u(),C(),v(),x(),U=f()}))();export{H as call};
@@ -0,0 +1 @@
1
+ import{S_ as e,b_ as t}from"./loadAgentsDir-DR5PVAc3.js";t();export{e as isSearchExtraToolsEnabled};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Ft as i,G as a,Gr as o,Gt as s,I as c,P as l,ai as u,hn as d,t as f}from"./src-WZ94ZKI3.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{tb as m}from"./loadAgentsDir-DR5PVAc3.js";import{Bn as h,zn as g}from"./settings-YIDksG5Z.js";import{c as _,o as v,s as y}from"./stringUtils-D_xPrwGQ.js";import{a as b,i as x,n as S,o as C,r as w,t as T}from"./use-select-navigation-CW5alA9r.js";import{i as E,t as D}from"./overlayContext-B6i_6y_0.js";var O,k,A=e((()=>{O=t(u(),1),D(),f(),m(),v(),k=({isDisabled:e=!1,disableSelection:t=!1,state:n,options:r,isMultiSelect:i=!1,onUpFromFirstItem:a,onDownFromLastItem:o,onInputModeToggle:c,inputValues:l,imagesSelected:u=!1,onEnterImageSelection:f})=>{E(`select`,!!n.onCancel);let p=(0,O.useMemo)(()=>r.find(e=>e.value===n.focusedValue)?.type===`input`,[r,n.focusedValue]);s((0,O.useMemo)(()=>{let e={};return p||(e[`select:next`]=()=>{if(o){let e=r[r.length-1];if(e&&n.focusedValue===e.value){o();return}}n.focusNextOption()},e[`select:previous`]=()=>{if(a&&n.visibleFromIndex===0){let e=r[0];if(e&&n.focusedValue===e.value){a();return}}n.focusPreviousOption()},e[`select:accept`]=()=>{t!==!0&&n.focusedValue!==void 0&&r.find(e=>e.value===n.focusedValue)?.disabled!==!0&&(n.selectFocusedOption?.(),n.onChange?.(n.focusedValue))}),n.onCancel&&(e[`select:cancel`]=()=>{n.onCancel()}),e},[r,n,o,a,p,t]),{context:`Select`,isActive:!e}),d((e,s,d)=>{let p=y(e),m=r.find(e=>e.value===n.focusedValue),h=m?.type===`input`;if(s.tab&&c&&n.focusedValue!==void 0){c(n.focusedValue);return}if(h){if(u)return;if(s.downArrow&&f?.()){d.stopImmediatePropagation();return}if(s.downArrow||s.ctrl&&e===`n`){if(o){let e=r[r.length-1];if(e&&n.focusedValue===e.value){o(),d.stopImmediatePropagation();return}}n.focusNextOption(),d.stopImmediatePropagation();return}if(s.upArrow||s.ctrl&&e===`p`){if(a&&n.visibleFromIndex===0){let e=r[0];if(e&&n.focusedValue===e.value){a(),d.stopImmediatePropagation();return}}n.focusPreviousOption(),d.stopImmediatePropagation();return}return}if(s.pageDown&&n.focusNextPage(),s.pageUp&&n.focusPreviousPage(),t!==!0&&(i&&_(e)===` `&&n.focusedValue!==void 0&&m?.disabled!==!0&&(n.selectFocusedOption?.(),n.onChange?.(n.focusedValue)),t!==`numeric`&&/^[0-9]+$/.test(p))){let e=parseInt(p,10)-1;if(e>=0&&e<n.options.length){let t=n.options[e];if(t.disabled===!0)return;if(t.type===`input`){if((l?.get(t.value)??``).trim()){n.onChange?.(t.value);return}if(t.allowEmptySubmitToCancel){n.onChange?.(t.value);return}n.focusOption(t.value);return}n.onChange?.(t.value);return}}},{isActive:!e})}}));function j({visibleOptionCount:e=5,options:t,defaultValue:n,onChange:r,onCancel:i,onFocus:a,focusValue:o}){let[s,c]=(0,M.useState)(n),l=S({visibleOptionCount:e,options:t,initialFocusValue:void 0,onFocus:a,focusValue:o}),u=(0,M.useCallback)(()=>{c(l.focusedValue)},[l.focusedValue]);return{...l,value:s,selectFocusedOption:u,onChange:r,onCancel:i}}var M,N=e((()=>{M=t(u(),1),T()}));function P(e){return typeof e==`string`?e:typeof e==`number`?String(e):e?Array.isArray(e)?e.map(P).join(``):L.isValidElement(e)?P(e.props.children):``:``}function F({isDisabled:e=!1,hideIndexes:t=!1,visibleOptionCount:n=5,highlightText:a,options:s,defaultValue:u,onCancel:d,onChange:f,onFocus:p,defaultFocusValue:m,layout:h=`compact`,disableSelection:_=!1,inlineDescriptions:v=!1,onUpFromFirstItem:y,onDownFromLastItem:x,onInputModeToggle:S,onOpenEditor:C,onImagePaste:T,pastedContents:E,onRemoveImage:D}){let[O,A]=(0,L.useState)(!1),[M,N]=(0,L.useState)(0),[F,z]=(0,L.useState)(()=>{let e=new Map;return s.forEach(t=>{t.type===`input`&&t.initialValue&&e.set(t.value,t.initialValue)}),e}),B=(0,L.useRef)(new Map);(0,L.useEffect)(()=>{for(let e of s)if(e.type===`input`&&e.initialValue!==void 0){let t=B.current.get(e.value)??``,n=F.get(e.value)??``,r=e.initialValue;r!==t&&n===t&&z(t=>{let n=new Map(t);return n.set(e.value,r),n}),B.current.set(e.value,r)}},[s,F]);let V=j({visibleOptionCount:n,options:s,defaultValue:u,onChange:f,onCancel:d,onFocus:p,focusValue:m});k({isDisabled:e,disableSelection:_||(t?`numeric`:!1),state:V,options:s,isMultiSelect:!1,onUpFromFirstItem:y,onDownFromLastItem:x,onInputModeToggle:S,inputValues:F,imagesSelected:O,onEnterImageSelection:()=>{if(E&&Object.values(E).some(e=>e.type===`image`)){let e=g(Object.values(E),e=>e.type===`image`);return A(!0),N(e-1),!0}return!1}});let H={container:()=>({flexDirection:`column`}),highlightedText:()=>({bold:!0})};if(h===`expanded`){let t=V.options.length.toString().length;return(0,R.jsx)(c,{...H.container(),children:V.visibleOptions.map((n,r)=>{let o=n.index===V.visibleFromIndex,u=n.index===V.visibleToIndex-1,p=V.visibleToIndex<s.length,m=V.visibleFromIndex>0,h=V.visibleFromIndex+r+1,g=!e&&V.focusedValue===n.value,_=V.value===n.value;if(n.type===`input`){let e=F.has(n.value)?F.get(n.value):n.initialValue||``;return(0,R.jsx)(w,{option:n,isFocused:g,isSelected:_,shouldShowDownArrow:p&&u,shouldShowUpArrow:m&&o,maxIndexWidth:t,index:h,inputValue:e,onInputChange:e=>{z(t=>{let r=new Map(t);return r.set(n.value,e),r})},onSubmit:e=>{let t=E&&Object.values(E).some(e=>e.type===`image`);e.trim()||t||n.allowEmptySubmitToCancel?f?.(n.value):d?.()},onExit:d,layout:`expanded`,showLabel:v,onOpenEditor:C,resetCursorOnUpdate:n.resetCursorOnUpdate,onImagePaste:T,pastedContents:E,onRemoveImage:D,imagesSelected:O,selectedImageIndex:M,onImagesSelectedChange:A,onSelectedImageIndexChange:N},String(n.value))}let y=n.label;if(typeof n.label==`string`&&a&&n.label.includes(a)){let e=n.label,t=e.indexOf(a);y=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,t),(0,R.jsx)(l,{...H.highlightedText(),children:a}),e.slice(t+a.length)]})}let x=n.disabled===!0,S=x?void 0:_?`success`:g?`suggestion`:void 0;return(0,R.jsxs)(c,{flexDirection:`column`,flexShrink:0,children:[(0,R.jsx)(b,{isFocused:g,isSelected:_,shouldShowDownArrow:p&&u,shouldShowUpArrow:m&&o,children:(0,R.jsx)(l,{dimColor:x,color:S,children:y})}),n.description&&(0,R.jsx)(c,{paddingLeft:2,children:(0,R.jsx)(l,{dimColor:x||n.dimDescription!==!1,color:S,children:(0,R.jsx)(i,{children:n.description})})}),(0,R.jsx)(l,{children:` `})]},String(n.value))})})}if(h===`compact-vertical`){let n=t?0:V.options.length.toString().length;return(0,R.jsx)(c,{...H.container(),children:V.visibleOptions.map((r,o)=>{let u=r.index===V.visibleFromIndex,p=r.index===V.visibleToIndex-1,m=V.visibleToIndex<s.length,h=V.visibleFromIndex>0,g=V.visibleFromIndex+o+1,_=!e&&V.focusedValue===r.value,y=V.value===r.value;if(r.type===`input`){let e=F.has(r.value)?F.get(r.value):r.initialValue||``;return(0,R.jsx)(w,{option:r,isFocused:_,isSelected:y,shouldShowDownArrow:m&&p,shouldShowUpArrow:h&&u,maxIndexWidth:n,index:g,inputValue:e,onInputChange:e=>{z(t=>{let n=new Map(t);return n.set(r.value,e),n})},onSubmit:e=>{let t=E&&Object.values(E).some(e=>e.type===`image`);e.trim()||t||r.allowEmptySubmitToCancel?f?.(r.value):d?.()},onExit:d,layout:`compact`,showLabel:v,onOpenEditor:C,resetCursorOnUpdate:r.resetCursorOnUpdate,onImagePaste:T,pastedContents:E,onRemoveImage:D,imagesSelected:O,selectedImageIndex:M,onImagesSelectedChange:A,onSelectedImageIndexChange:N},String(r.value))}let x=r.label;if(typeof r.label==`string`&&a&&r.label.includes(a)){let e=r.label,t=e.indexOf(a);x=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,t),(0,R.jsx)(l,{...H.highlightedText(),children:a}),e.slice(t+a.length)]})}let S=r.disabled===!0;return(0,R.jsxs)(c,{flexDirection:`column`,flexShrink:0,children:[(0,R.jsxs)(b,{isFocused:_,isSelected:y,shouldShowDownArrow:m&&p,shouldShowUpArrow:h&&u,children:[!t&&(0,R.jsx)(l,{dimColor:!0,children:`${g}.`.padEnd(n+1)}),(0,R.jsx)(l,{dimColor:S,color:S?void 0:y?`success`:_?`suggestion`:void 0,children:x})]}),r.description&&(0,R.jsx)(c,{paddingLeft:t?4:n+4,children:(0,R.jsx)(l,{dimColor:S||r.dimDescription!==!1,color:S?void 0:y?`success`:_?`suggestion`:void 0,children:(0,R.jsx)(i,{children:r.description})})})]},String(r.value))})})}let U=t?0:V.options.length.toString().length,W=V.visibleOptions.some(e=>e.type===`input`),G=!v&&!W&&V.visibleOptions.some(e=>e.description),K=V.visibleOptions.map((t,n)=>{let r=t.index===V.visibleFromIndex,i=t.index===V.visibleToIndex-1,o=V.visibleToIndex<s.length,c=V.visibleFromIndex>0,u=V.visibleFromIndex+n+1,d=!e&&V.focusedValue===t.value,f=V.value===t.value,p=t.disabled===!0,m=t.label;if(typeof t.label==`string`&&a&&t.label.includes(a)){let e=t.label,n=e.indexOf(a);m=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,n),(0,R.jsx)(l,{...H.highlightedText(),children:a}),e.slice(n+a.length)]})}return{option:t,index:u,label:m,isFocused:d,isSelected:f,isOptionDisabled:p,shouldShowDownArrow:o&&i,shouldShowUpArrow:c&&r}});if(G){let e=Math.max(...K.map(e=>{if(e.option.type===`input`)return 0;let n=P(e.option.label),r=t?0:U+2,i=e.isSelected?2:0;return 2+r+o(n)+i}));return(0,R.jsx)(c,{...H.container(),children:K.map(n=>{if(n.option.type===`input`)return null;let a=P(n.option.label),s=t?0:U+2,u=n.isSelected?2:0,d=2+s+o(a)+u,f=e-d;return(0,R.jsxs)(I,{isFocused:n.isFocused,children:[(0,R.jsxs)(c,{flexDirection:`row`,flexShrink:0,children:[n.isFocused?(0,R.jsx)(l,{color:`suggestion`,children:r.pointer}):n.shouldShowDownArrow?(0,R.jsx)(l,{dimColor:!0,children:r.arrowDown}):n.shouldShowUpArrow?(0,R.jsx)(l,{dimColor:!0,children:r.arrowUp}):(0,R.jsx)(l,{children:` `}),(0,R.jsx)(l,{children:` `}),(0,R.jsxs)(l,{dimColor:n.isOptionDisabled,color:n.isOptionDisabled?void 0:n.isSelected?`success`:n.isFocused?`suggestion`:void 0,children:[!t&&(0,R.jsx)(l,{dimColor:!0,children:`${n.index}.`.padEnd(U+2)}),n.label]}),n.isSelected&&(0,R.jsxs)(l,{color:`success`,children:[` `,r.tick]}),f>0&&(0,R.jsx)(l,{children:` `.repeat(f)})]}),(0,R.jsx)(c,{flexGrow:1,marginLeft:2,children:(0,R.jsx)(l,{wrap:`wrap`,dimColor:n.isOptionDisabled||n.option.dimDescription!==!1,color:n.isOptionDisabled?void 0:n.isSelected?`success`:n.isFocused?`suggestion`:void 0,children:(0,R.jsx)(i,{children:n.option.description||` `})})})]},String(n.option.value))})})}return(0,R.jsx)(c,{...H.container(),children:V.visibleOptions.map((n,r)=>{if(n.type===`input`){let t=F.has(n.value)?F.get(n.value):n.initialValue||``,i=n.index===V.visibleFromIndex,a=n.index===V.visibleToIndex-1,o=V.visibleToIndex<s.length,c=V.visibleFromIndex>0,l=V.visibleFromIndex+r+1;return(0,R.jsx)(w,{option:n,isFocused:!e&&V.focusedValue===n.value,isSelected:V.value===n.value,shouldShowDownArrow:o&&a,shouldShowUpArrow:c&&i,maxIndexWidth:U,index:l,inputValue:t,onInputChange:e=>{z(t=>{let r=new Map(t);return r.set(n.value,e),r})},onSubmit:e=>{let t=E&&Object.values(E).some(e=>e.type===`image`);e.trim()||t||n.allowEmptySubmitToCancel?f?.(n.value):d?.()},onExit:d,layout:`compact`,showLabel:v,onOpenEditor:C,resetCursorOnUpdate:n.resetCursorOnUpdate,onImagePaste:T,pastedContents:E,onRemoveImage:D,imagesSelected:O,selectedImageIndex:M,onImagesSelectedChange:A,onSelectedImageIndexChange:N},String(n.value))}let o=n.label;if(typeof n.label==`string`&&a&&n.label.includes(a)){let e=n.label,t=e.indexOf(a);o=(0,R.jsxs)(R.Fragment,{children:[e.slice(0,t),(0,R.jsx)(l,{...H.highlightedText(),children:a}),e.slice(t+a.length)]})}let u=n.index===V.visibleFromIndex,p=n.index===V.visibleToIndex-1,m=V.visibleToIndex<s.length,h=V.visibleFromIndex>0,g=V.visibleFromIndex+r+1,_=!e&&V.focusedValue===n.value,y=V.value===n.value,x=n.disabled===!0;return(0,R.jsxs)(b,{isFocused:_,isSelected:y,shouldShowDownArrow:m&&p,shouldShowUpArrow:h&&u,children:[(0,R.jsxs)(c,{flexDirection:`row`,flexShrink:0,children:[!t&&(0,R.jsx)(l,{dimColor:!0,children:`${g}.`.padEnd(U+2)}),(0,R.jsxs)(l,{dimColor:x,color:x?void 0:y?`success`:_?`suggestion`:void 0,children:[o,v&&n.description&&(0,R.jsxs)(l,{dimColor:x||n.dimDescription!==!1,children:[` `,n.description]})]})]}),!v&&n.description&&(0,R.jsx)(c,{flexShrink:99,marginLeft:2,children:(0,R.jsx)(l,{wrap:`wrap-trim`,dimColor:x||n.dimDescription!==!1,color:x?void 0:y?`success`:_?`suggestion`:void 0,children:(0,R.jsx)(i,{children:n.description})})})]},String(n.value))})})}function I({isFocused:e,children:t}){return(0,R.jsx)(c,{ref:a({line:0,column:0,active:e}),flexDirection:`row`,children:t})}var L,R,z=e((()=>{n(),L=t(u(),1),f(),h(),x(),C(),A(),N(),R=p()}));export{z as n,F as t};