sliccy 6.185.0 → 6.186.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/ui/.vite/manifest.json +212 -212
  2. package/dist/ui/assets/{SKILL-wvtABi3i.js → SKILL-nEVBLbup.js} +1 -1
  3. package/dist/ui/assets/__vite-browser-external-dhDtpJGG.js +1 -0
  4. package/dist/ui/assets/{account-store-C41qiTs8.js → account-store-6v1bQDLQ.js} +1 -1
  5. package/dist/ui/assets/{account-store-CdWvtLK5.js → account-store-CcHr-RmX.js} +1 -1
  6. package/dist/ui/assets/{adobe-pJP3L2S1.js → adobe-CuedqrHU.js} +1 -1
  7. package/dist/ui/assets/{adobe-Cuq2cJ2f.js → adobe-bNmHv86x.js} +1 -1
  8. package/dist/ui/assets/{agent-panels-Ca0HA81F.js → agent-panels-Ay3la2gk.js} +1 -1
  9. package/dist/ui/assets/{almost-bash-shell-headless-3-QEOXc2.js → almost-bash-shell-headless-B0d_S9Oq.js} +33 -33
  10. package/dist/ui/assets/{apply-layout-CKuJgZ53.js → apply-layout-Byhwt2rW.js} +1 -1
  11. package/dist/ui/assets/{apps-DZhY4wWQ.js → apps-DgZ3EWPl.js} +1 -1
  12. package/dist/ui/assets/{azure-openai-DR1sAgZg.js → azure-openai-CRm40REo.js} +1 -1
  13. package/dist/ui/assets/{azure-openai-BWRYpShR.js → azure-openai-RJkx-u-g.js} +1 -1
  14. package/dist/ui/assets/{backend-hostfs-Bgb_DsUT.js → backend-hostfs-Cgvl-SCd.js} +1 -1
  15. package/dist/ui/assets/{bunny-probe-DwyMiB71.js → bunny-probe-8V1ePOla.js} +1 -1
  16. package/dist/ui/assets/{bunny-run-COGwXgvg.js → bunny-run-DYRf1zOt.js} +1 -1
  17. package/dist/ui/assets/{cdp-D8ppMyya.js → cdp-BBxx0ATR.js} +1 -1
  18. package/dist/ui/assets/{cerebras-Drhn15WH.js → cerebras-BId3sDRD.js} +1 -1
  19. package/dist/ui/assets/{cerebras-C_6PRb_m.js → cerebras-DDSDu3Od.js} +1 -1
  20. package/dist/ui/assets/{composer-speech-CJ5WxRmi.js → composer-speech-DZ3MG1aE.js} +1 -1
  21. package/dist/ui/assets/{connect-surface-B25ziPK_.js → connect-surface-PX6umLpO.js} +1 -1
  22. package/dist/ui/assets/{directed-approval-CHjy_veK.js → directed-approval-BGA8yp7A.js} +1 -1
  23. package/dist/ui/assets/{dist-BpNPANbz.js → dist-BMDfry7W.js} +1 -1
  24. package/dist/ui/assets/{dist-C-tO1Skg.js → dist-CaPMlUXZ.js} +1 -1
  25. package/dist/ui/assets/{dist-BX7il2y2.js → dist-Djwo0SK2.js} +1 -1
  26. package/dist/ui/assets/{dist-5YOibBa4.js → dist-RJwZ5Bse.js} +1 -1
  27. package/dist/ui/assets/{emscripten-vfs-hook-Dydz8mUS.js → emscripten-vfs-hook-C0ChBXC3.js} +1 -1
  28. package/dist/ui/assets/{emscripten-vfs-hook-BgKVsuWf.js → emscripten-vfs-hook-P-OE6hwk.js} +1 -1
  29. package/dist/ui/assets/{ensure-speech-assets-JOVdeAED.js → ensure-speech-assets-DtFEp33q.js} +1 -1
  30. package/dist/ui/assets/{fast-path-CG_eXz0M.js → fast-path-CriOTZyu.js} +1 -1
  31. package/dist/ui/assets/{frozen-archive-writer-XUf0GMRR.js → frozen-archive-writer-Dh8_Z5_n.js} +1 -1
  32. package/dist/ui/assets/{fs-CfJdpL5x.js → fs-CGiTiKri.js} +1 -1
  33. package/dist/ui/assets/{fs-DyrFPUp2.js → fs-CO_lYoFl.js} +2 -2
  34. package/dist/ui/assets/{gelatiere-store-DCvfmki0.js → gelatiere-store-C5B5_A_I.js} +1 -1
  35. package/dist/ui/assets/{gelatiere-unit-DcQlQ9QA.js → gelatiere-unit-DDoIdKsN.js} +1 -1
  36. package/dist/ui/assets/{github-J3Pos7xW.js → github-DQXgF3NF.js} +2 -2
  37. package/dist/ui/assets/{github-BH0fYYDC.js → github-Dpnp7Zzn.js} +1 -1
  38. package/dist/ui/assets/{github-auth-C0PAZtLa.js → github-auth-BpyLhcfb.js} +1 -1
  39. package/dist/ui/assets/{github-copilot-r7THpGrf.js → github-copilot-CThRDdd8.js} +1 -1
  40. package/dist/ui/assets/{github-copilot-GnnngJgc.js → github-copilot-DP5pe7qj.js} +1 -1
  41. package/dist/ui/assets/{github-install-bXSPtrJ8.js → github-install-BA-6no8b.js} +1 -1
  42. package/dist/ui/assets/{github-zip-CQ8Hranj.js → github-zip-a7OaDnVX.js} +1 -1
  43. package/dist/ui/assets/{hear-vBH6fz6J.js → hear-BZ0-BQlF.js} +1 -1
  44. package/dist/ui/assets/{help-BIRVuAQg.js → help-Pr1ZdIJh.js} +1 -1
  45. package/dist/ui/assets/icons-dEBJiC8z.js +1 -0
  46. package/dist/ui/assets/{installer-BIr2X4ZR.js → installer-CYYRFwXA.js} +1 -1
  47. package/dist/ui/assets/{js-realm-worker-xXM5hNmY.js → js-realm-worker-aPccyhNo.js} +7 -7
  48. package/dist/ui/assets/{jsh-executor-Sq-_s17Z.js → jsh-executor-B9v2eMrF.js} +3 -3
  49. package/dist/ui/assets/{jsh-runtime-extensions-DOE4hLxi.js → jsh-runtime-extensions-DiQ9SvKe.js} +1 -1
  50. package/dist/ui/assets/{kernel-worker-BfQfWWGY.js → kernel-worker-cLHttpvD.js} +10 -10
  51. package/dist/ui/assets/{lick-ws-bridge-1KGk00fU.js → lick-ws-bridge-BYJXmx3P.js} +1 -1
  52. package/dist/ui/assets/{lick-ws-bridge-Cb_x25TH.js → lick-ws-bridge-CDZEfnko.js} +1 -1
  53. package/dist/ui/assets/{live-session-curation-D2302oBw.js → live-session-curation-CEoLLRWg.js} +1 -1
  54. package/dist/ui/assets/{live-session-snapshot-MSEMhtzT.js → live-session-snapshot-BtgL_jlA.js} +1 -1
  55. package/dist/ui/assets/{local-llm-Drx0Pf5F.js → local-llm-BJq2Bcn4.js} +1 -1
  56. package/dist/ui/assets/{local-llm-C1bXK5E_.js → local-llm-Br1qdgFU.js} +1 -1
  57. package/dist/ui/assets/{main-ke7UzEyb.js → main-DGILx2J0.js} +3 -3
  58. package/dist/ui/assets/{main-cherry-DMGXCqlk.js → main-cherry-C38UDlPe.js} +1 -1
  59. package/dist/ui/assets/{memory-curation-seam-BQ0ag4HS.js → memory-curation-seam-CAzXvlEq.js} +1 -1
  60. package/dist/ui/assets/{memory-health-DOBolAoU.js → memory-health-ChAZtjeC.js} +1 -1
  61. package/dist/ui/assets/{memory-write-execute-iB7MTIuf.js → memory-write-execute-ct1TB2H5.js} +1 -1
  62. package/dist/ui/assets/{mount-C8_YWxvL.js → mount-7-ndJ7j_.js} +1 -1
  63. package/dist/ui/assets/{mount-sN1zOOQO.js → mount-Boe1RyV1.js} +3 -3
  64. package/dist/ui/assets/{new-session-Chf2aTIb.js → new-session-DaYVjckX.js} +2 -2
  65. package/dist/ui/assets/{oauth-bootstrap-DhxqRx6M.js → oauth-bootstrap-3Rp69xJf.js} +2 -2
  66. package/dist/ui/assets/{onboarding-orchestrator-CSUMNTNq.js → onboarding-orchestrator-BaNbt51M.js} +1 -1
  67. package/dist/ui/assets/{openai-codex-E3c2zrJK.js → openai-codex-CBECd3Ml.js} +1 -1
  68. package/dist/ui/assets/{openai-codex-LJJS3BN5.js → openai-codex-DRECU62x.js} +1 -1
  69. package/dist/ui/assets/{openrouter-HCWd3_Dv.js → openrouter-B6NE-wjS.js} +1 -1
  70. package/dist/ui/assets/{openrouter-B47ePBty.js → openrouter-BzFndudE.js} +1 -1
  71. package/dist/ui/assets/{openrouter-free-CndCA5W5.js → openrouter-free-BmWaYf2I.js} +1 -1
  72. package/dist/ui/assets/{openrouter-free-DEOSmXMR.js → openrouter-free-DypV34af.js} +1 -1
  73. package/dist/ui/assets/{openrouter-oauth-uaZxqhE3.js → openrouter-oauth-CeOxyshu.js} +1 -1
  74. package/dist/ui/assets/{openrouter-oauth-BN42fHf7.js → openrouter-oauth-H5pX0S04.js} +1 -1
  75. package/dist/ui/assets/{opfs-mount-DmHtfJvm.js → opfs-mount-7AGHXIll.js} +1 -1
  76. package/dist/ui/assets/{panel-rpc-handlers-DxnZUmep.js → panel-rpc-handlers-BC6MoTQL.js} +2 -2
  77. package/dist/ui/assets/{panelize-shell-S-7afGEn.js → panelize-shell-Bg6ZMkim.js} +1 -1
  78. package/dist/ui/assets/{pi-edit-execution-Y4T_bzrT.js → pi-edit-execution-C-LpdIZ8.js} +1 -1
  79. package/dist/ui/assets/{provider-Cz1V2WqO.js → provider-C0S6DmOh.js} +1 -1
  80. package/dist/ui/assets/{provider-DTffpEWN.js → provider-C2XK7sYM.js} +2 -2
  81. package/dist/ui/assets/{provider-settings-CxqviYt8.js → provider-settings-Dbll0xUg.js} +1 -1
  82. package/dist/ui/assets/provider-store-access-BrbtSBpX.js +1 -0
  83. package/dist/ui/assets/provider-store-access-vekyMcol.js +1 -0
  84. package/dist/ui/assets/{providers-jnPvVe9y.js → providers-LZyqU4Ib.js} +1 -1
  85. package/dist/ui/assets/{providers-DRo5rfSc.js → providers-rIBVxdW-.js} +2 -2
  86. package/dist/ui/assets/{py-live-vfs-Dm8bBjqR.js → py-live-vfs-BMEF0ECU.js} +1 -1
  87. package/dist/ui/assets/{py-live-vfs-DMc0LhCg.js → py-live-vfs-CvcPOToj.js} +1 -1
  88. package/dist/ui/assets/{py-realm-worker-BaO89JAR.js → py-realm-worker-CFlFWZqx.js} +1 -1
  89. package/dist/ui/assets/{pyodide-DY17DXNV.js → pyodide-BJoTGv9f.js} +2 -2
  90. package/dist/ui/assets/{quick-llm-DYIT2ufv.js → quick-llm-DDWR41Vn.js} +1 -1
  91. package/dist/ui/assets/{realm-inprocess-JkVFNdN8.js → realm-inprocess-Cwqt5DZc.js} +4 -4
  92. package/dist/ui/assets/realm-sync-transport-QD3YPwXN.js +1 -0
  93. package/dist/ui/assets/{recovery-screen-C_VP_tQT.js → recovery-screen-ci0gn_2f.js} +1 -1
  94. package/dist/ui/assets/{remote-terminal-view-Dhc7yeLL.js → remote-terminal-view-CPIeJDc7.js} +1 -1
  95. package/dist/ui/assets/{require-guards-DPf5QETL.js → require-guards-CHKfdRAj.js} +1 -1
  96. package/dist/ui/assets/{restore-Bc04Ic3P.js → restore-DvPL6e_R.js} +1 -1
  97. package/dist/ui/assets/{run-C1e4W7pJ.js → run-B-b1oASQ.js} +1 -1
  98. package/dist/ui/assets/{run-D-ECpM63.js → run-BXtEkg8U.js} +2 -2
  99. package/dist/ui/assets/{run-DjWLQRmi.js → run-ChZe2ZA3.js} +1 -1
  100. package/dist/ui/assets/{run-L6Ylv9dF.js → run-CvD6Q-4G.js} +1 -1
  101. package/dist/ui/assets/{run-D65zpTOz.js → run-D8WG-d7m.js} +2 -2
  102. package/dist/ui/assets/{run-D4l6XlAu.js → run-DCB_d0xn.js} +2 -2
  103. package/dist/ui/assets/{run-Bd-jYaDM.js → run-DwEWu4jG.js} +2 -2
  104. package/dist/ui/assets/{run-BRPVL491.js → run-LhNhUI2h.js} +1 -1
  105. package/dist/ui/assets/{run-CG3zbaSU.js → run-LzvzEQ4r.js} +1 -1
  106. package/dist/ui/assets/{session-command-memory-Ci1Zf9vr.js → session-command-memory-o34mvSgm.js} +2 -2
  107. package/dist/ui/assets/{session-jsonl-COpl-CLY.js → session-jsonl-BVDdqbYt.js} +1 -1
  108. package/dist/ui/assets/{session-jsonl-BA0osLaK.js → session-jsonl-BmvWBXUE.js} +1 -1
  109. package/dist/ui/assets/{session-search-index-CdHuMIG2.js → session-search-index-BYp76BAQ.js} +1 -1
  110. package/dist/ui/assets/{setup-feature-flags-remote-DtQ886Eg.js → setup-feature-flags-remote-wwQtgwUA.js} +1 -1
  111. package/dist/ui/assets/{setup-model-catalog-CZ582M7C.js → setup-model-catalog-Dp_LwFlS.js} +1 -1
  112. package/dist/ui/assets/{signed-fetch-BR0AMgn_.js → signed-fetch-D_xzSHY9.js} +1 -1
  113. package/dist/ui/assets/{silent-renew-backoff-CYQP7u_w.js → silent-renew-backoff-bHmQ4VIv.js} +1 -1
  114. package/dist/ui/assets/slicc-editor-Bwxbi0cp.js +1 -0
  115. package/dist/ui/assets/slicc-editor-DZXa2pZw.js +23 -0
  116. package/dist/ui/assets/slicc-version-Zk7JuEi9.js +1 -0
  117. package/dist/ui/assets/{snapshot-DkZ54_ve.js → snapshot-BMRjMbaC.js} +1 -1
  118. package/dist/ui/assets/{snapshot-features-tcAtohfL.js → snapshot-features-9wIqroXe.js} +1 -1
  119. package/dist/ui/assets/{soundscape-DxCVDpTl.js → soundscape-CFr9AkiH.js} +1 -1
  120. package/dist/ui/assets/{speak-BqdHQaW1.js → speak-DHMYZvDt.js} +1 -1
  121. package/dist/ui/assets/{sprinkle-manager-BuTuVoeH.js → sprinkle-manager-XUIO_g_c.js} +1 -1
  122. package/dist/ui/assets/{sprinkle-renderer-PPC5klpl.js → sprinkle-renderer-D7mLTT1E.js} +3 -3
  123. package/dist/ui/assets/src-C6UBnSGT.js +575 -0
  124. package/dist/ui/assets/{ssh-9Y3S-Bha.js → ssh-Ca0IyfQK.js} +1 -1
  125. package/dist/ui/assets/{state-4HAkKcwp.js → state-CzWGT6_Z.js} +1 -1
  126. package/dist/ui/assets/{store-DoauiqkB.js → store-CT2H_Utj.js} +1 -1
  127. package/dist/ui/assets/{store-BQov__WY.js → store-jUC9SIV1.js} +1 -1
  128. package/dist/ui/assets/{sudo-ChMUrnDt.js → sudo-D85dIcKO.js} +1 -1
  129. package/dist/ui/assets/{supervisor-B8SqOt_K.js → supervisor-BoHW4rOe.js} +1 -1
  130. package/dist/ui/assets/{sync-dialog-DpyNUkDH.js → sync-dialog-DR-cxxqt.js} +1 -1
  131. package/dist/ui/assets/{sync-exec-dispatch-CEbwf9Az.js → sync-exec-dispatch-D80ElZ8u.js} +1 -1
  132. package/dist/ui/assets/{transformers-env-BENPPudh.js → transformers-env-U4g1z6G9.js} +1 -1
  133. package/dist/ui/assets/{tray-leader-BA4ZTTff.js → tray-leader-Du_rjKF6.js} +1 -1
  134. package/dist/ui/assets/{tray-leave-runtime-CBTb4mlH.js → tray-leave-runtime-S0Z5urne.js} +1 -1
  135. package/dist/ui/assets/{tray-sidecar-CnZgpbOI.js → tray-sidecar-B2M1EFqY.js} +1 -1
  136. package/dist/ui/assets/{upgrade-detection-Dq2MUoOD.js → upgrade-detection-ygU03Y3v.js} +1 -1
  137. package/dist/ui/assets/{upskill-lick-skip-DUIw4OcH.js → upskill-lick-skip-D5zmqLJP.js} +1 -1
  138. package/dist/ui/assets/{voice-reply-CEwRhiYz.js → voice-reply-BUM3xqcQ.js} +1 -1
  139. package/dist/ui/assets/{wc-attach-2TSX-inX.js → wc-attach-pLEPz5YT.js} +2 -2
  140. package/dist/ui/assets/{wc-browser-DJxUV8of.js → wc-browser-CkckI0pE.js} +1 -1
  141. package/dist/ui/assets/{wc-computers-BHu_7f-5.js → wc-computers-CES9Pphl.js} +1 -1
  142. package/dist/ui/assets/{wc-detached-BFnPmR0d.js → wc-detached-BSVjRXLI.js} +1 -1
  143. package/dist/ui/assets/{wc-extension-BYUYa6KS.js → wc-extension-n5iYaURR.js} +2 -2
  144. package/dist/ui/assets/wc-follower-CaoqYR86.js +17 -0
  145. package/dist/ui/assets/{wc-follower-oauth-DHAss7Bl.js → wc-follower-oauth-IaFFbCQS.js} +1 -1
  146. package/dist/ui/assets/{wc-gelatiere-Cr6JuzRn.js → wc-gelatiere-DKzp4XnZ.js} +1 -1
  147. package/dist/ui/assets/{wc-live-qHNanIrf.js → wc-live--Vy3x-eA.js} +5 -5
  148. package/dist/ui/assets/{wc-nav-X6D6V6gK.js → wc-nav-pzcR6z49.js} +2 -2
  149. package/dist/ui/assets/{wc-onboarding-Bt5oCUsn.js → wc-onboarding-CTepvpbC.js} +2 -2
  150. package/dist/ui/assets/{wc-permissions-BisFwUlJ.js → wc-permissions-C3L7ziQi.js} +2 -2
  151. package/dist/ui/assets/{wc-placeholder-mnzIda5e.js → wc-placeholder-aUPxA3ac.js} +3 -3
  152. package/dist/ui/assets/{wc-secret-request-EQCdKc1f.js → wc-secret-request-Ca5k4-UQ.js} +1 -1
  153. package/dist/ui/assets/{wc-settings-DnUvuaLB.js → wc-settings-BRvIAeOQ.js} +3 -3
  154. package/dist/ui/assets/{wc-shell-BtEykt-v.js → wc-shell-DOWfUNbp.js} +193 -193
  155. package/dist/ui/assets/{wc-shortcut-config-BQmt9XFF.js → wc-shortcut-config-CrTfgcob.js} +1 -1
  156. package/dist/ui/assets/wc-sprinkles-Ck7Nd-9D.js +2 -0
  157. package/dist/ui/assets/{wc-transcript-export-Cv0T-WSY.js → wc-transcript-export-CLUiuu3B.js} +2 -2
  158. package/dist/ui/assets/{wc-tray-DXzaLMSR.js → wc-tray-CQ7pP6rg.js} +4 -4
  159. package/dist/ui/assets/{wc-unit-context-CS4hSDi7.js → wc-unit-context-DbQt1MsQ.js} +1 -1
  160. package/dist/ui/assets/welcome-detection-kgddSjS0.js +1 -0
  161. package/dist/ui/assets/{whisper-session-C7baPCyL.js → whisper-session-CIgrXgZA.js} +2 -2
  162. package/dist/ui/assets/{xai-grok-11wZ6TYi.js → xai-grok-83B2QPil.js} +1 -1
  163. package/dist/ui/assets/{xai-grok-pbhR-Op4.js → xai-grok-MDczX8T9.js} +1 -1
  164. package/dist/ui/index.html +3 -3
  165. package/dist/ui/llm-proxy-sw.js +1 -1
  166. package/dist/ui/lucide-icons.js +249 -239
  167. package/dist/ui/packages/webapp/index.html +3 -3
  168. package/dist/ui/slicc-editor.js +1 -1
  169. package/package.json +2 -1
  170. package/dist/ui/assets/__vite-browser-external-CJkRLpJ-.js +0 -1
  171. package/dist/ui/assets/icons-jrIi5FYk.js +0 -1
  172. package/dist/ui/assets/provider-store-access-DVcoprAg.js +0 -1
  173. package/dist/ui/assets/provider-store-access-Des62vG8.js +0 -1
  174. package/dist/ui/assets/realm-sync-transport-Bii99lU6.js +0 -1
  175. package/dist/ui/assets/slicc-editor-BwV9b9S6.js +0 -23
  176. package/dist/ui/assets/slicc-editor-abxGgeUl.js +0 -1
  177. package/dist/ui/assets/slicc-version-idHB6nsN.js +0 -1
  178. package/dist/ui/assets/src-BfoZU01X.js +0 -575
  179. package/dist/ui/assets/wc-follower-BwhkRRX4.js +0 -17
  180. package/dist/ui/assets/wc-sprinkles-CjPNiNB5.js +0 -2
  181. package/dist/ui/assets/welcome-detection-miHs8L-e.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./compat-qQM4gjF_.js";import{t as n}from"./logger-DDBAeTLF.js";import{A as r,D as i,g as a,k as o}from"./account-store-C41qiTs8.js";import{t as s}from"./llm-session-id-bZQs6gBN.js";import{i as c,t as l}from"./icons-jrIi5FYk.js";var u=e({lucideIconNames:()=>h,pickLucideIcon:()=>g,quickLabel:()=>f}),d=n(`quick-llm`);async function f(e){let n=a();if(!n)return d.debug(`No API key for active provider — skipping`),null;let i=r(),s=o(),c;if(c=e.modelId?b(i,e.modelId)??b(i,s):_(i,s),!c)return d.debug(`No model available for provider`,{providerId:i}),null;let l={role:`user`,content:e.prompt,timestamp:Date.now()},u={};c.provider===`adobe`&&(u[`X-Session-Id`]=S());try{let r=(await t(c,{systemPrompt:e.system,messages:[l]},{apiKey:n,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(u).length>0?u:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return r.length>0?r:null}catch(e){return d.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}var p=null;function m(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,`$1-$2`).replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Za-z])(\d)/g,`$1-$2`).toLowerCase()}function h(){return p||=Object.keys(c).map(m).sort(),p}async function g(e){let t=h(),n=await(e.labelFn??f)({system:`You pick ONE icon for a UI element. Respond with exactly one icon name from the provided list — lowercase, no quotes, no punctuation, nothing else.`,prompt:`Pick the single most fitting icon for: ${e.subject}\n\nValid icon names:\n${t.join(` `)}`,maxTokens:16,temperature:.2,signal:e.signal});if(!n)return null;let r=n.trim().toLowerCase().replace(/[^a-z0-9-]/g,``);return l(r)?r:null}function _(e,t){let n=i(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],a=y(r.id),o=n.filter(e=>v(e,r,a));return o.length===0?r:(o.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),o[0])}function v(e,t,n){if(e.id===t.id)return!1;let r=t.cost?.input??1/0;if((e.cost?.input??1/0)>=r)return!1;let i=e.id.toLowerCase();switch(n){case`claude`:return i.includes(`haiku`);case`gpt`:return/(^|-)mini(-|$)|(^|-)nano(-|$)/.test(i);case`gemini`:return i.includes(`flash`);case`grok`:return/(^|-)mini(-|$)|(^|-)fast(-|$)/.test(i);case`unknown`:return!0}}function y(e){let t=e.toLowerCase();return t.includes(`claude`)?`claude`:t.includes(`gemini`)?`gemini`:t.includes(`grok`)?`grok`:/^(gpt|o\d)/.test(t)?`gpt`:`unknown`}function b(e,t){return i(e).find(e=>e.id===t)}var x=`ui-quick-llm`;function S(){return s(x)}export{u as n,f as t};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./compat-qQM4gjF_.js";import{t as n}from"./logger-DDBAeTLF.js";import{A as r,D as i,g as a,k as o}from"./account-store-6v1bQDLQ.js";import{t as s}from"./llm-session-id-bZQs6gBN.js";import{i as c,t as l}from"./icons-dEBJiC8z.js";var u=e({lucideIconNames:()=>h,pickLucideIcon:()=>g,quickLabel:()=>f}),d=n(`quick-llm`);async function f(e){let n=a();if(!n)return d.debug(`No API key for active provider — skipping`),null;let i=r(),s=o(),c;if(c=e.modelId?b(i,e.modelId)??b(i,s):_(i,s),!c)return d.debug(`No model available for provider`,{providerId:i}),null;let l={role:`user`,content:e.prompt,timestamp:Date.now()},u={};c.provider===`adobe`&&(u[`X-Session-Id`]=S());try{let r=(await t(c,{systemPrompt:e.system,messages:[l]},{apiKey:n,maxTokens:e.maxTokens??60,temperature:e.temperature??.3,signal:e.signal,headers:Object.keys(u).length>0?u:void 0})).content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim();return r.length>0?r:null}catch(e){return d.debug(`Quick label call failed`,{error:e instanceof Error?e.message:String(e)}),null}}var p=null;function m(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,`$1-$2`).replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Za-z])(\d)/g,`$1-$2`).toLowerCase()}function h(){return p||=Object.keys(c).map(m).sort(),p}async function g(e){let t=h(),n=await(e.labelFn??f)({system:`You pick ONE icon for a UI element. Respond with exactly one icon name from the provided list — lowercase, no quotes, no punctuation, nothing else.`,prompt:`Pick the single most fitting icon for: ${e.subject}\n\nValid icon names:\n${t.join(` `)}`,maxTokens:16,temperature:.2,signal:e.signal});if(!n)return null;let r=n.trim().toLowerCase().replace(/[^a-z0-9-]/g,``);return l(r)?r:null}function _(e,t){let n=i(e);if(n.length===0)return;let r=n.find(e=>e.id===t)??n[0],a=y(r.id),o=n.filter(e=>v(e,r,a));return o.length===0?r:(o.sort((e,t)=>(e.cost?.input??0)-(t.cost?.input??0)),o[0])}function v(e,t,n){if(e.id===t.id)return!1;let r=t.cost?.input??1/0;if((e.cost?.input??1/0)>=r)return!1;let i=e.id.toLowerCase();switch(n){case`claude`:return i.includes(`haiku`);case`gpt`:return/(^|-)mini(-|$)|(^|-)nano(-|$)/.test(i);case`gemini`:return i.includes(`flash`);case`grok`:return/(^|-)mini(-|$)|(^|-)fast(-|$)/.test(i);case`unknown`:return!0}}function y(e){let t=e.toLowerCase();return t.includes(`claude`)?`claude`:t.includes(`gemini`)?`gemini`:t.includes(`grok`)?`grok`:/^(gpt|o\d)/.test(t)?`gpt`:`unknown`}function b(e,t){return i(e).find(e=>e.id===t)}var x=`ui-quick-llm`;function S(){return s(x)}export{u as n,f as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./__vite-browser-external-5eBdwsFd.js";import{r as n,t as r}from"./multipart-form-data-DopbgwRR.js";import{n as i}from"./slicc-version-idHB6nsN.js";import{t as a}from"./buffer-polyfill-BccMjOKj.js";import{t as o}from"./buffer-B5d1xHaH.js";import{F as s,I as c,N as l,P as u}from"./shared-DfMXB1pm.js";import{c as d,n as f,o as p,t as m}from"./require-guards-DPf5QETL.js";import{t as h}from"./tmpdir-env-ate4iNcK.js";import{i as g,n as _,r as v,t as y}from"./realm-sync-transport-Bii99lU6.js";import{t as b}from"./realm-browser-fetch-V3uggGbM.js";function x(e){let t=typeof e==`string`?e:e.href;if(!t.startsWith(`file:`))throw TypeError(`fileURLToPath: not a file URL`);let n=new URL(t);if(n.hostname!==``&&n.hostname!==`localhost`)throw Object.assign(TypeError(`File URL host must be "localhost" or empty on posix`),{code:`ERR_INVALID_FILE_URL_HOST`});if(/%2f/i.test(n.pathname))throw Object.assign(TypeError(`File URL path must not include encoded / characters`),{code:`ERR_INVALID_FILE_URL_PATH`});return decodeURIComponent(n.pathname)}function S(e){let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return new URL(`file://${t}`)}const C={URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams,fileURLToPath:x,pathToFileURL:S};function w(e,t){return Object.assign(TypeError(`The "${e}" argument must be of type string or an instance of Buffer or URL. Received ${t===null?`null`:typeof t}`),{code:`ERR_INVALID_ARG_TYPE`})}function T(e){return typeof e==`object`&&!!e&&typeof e.href==`string`&&typeof e.protocol==`string`}function E(e,t=`path`){if(typeof e==`string`)return e;if(T(e)){if(e.protocol!==`file:`)throw Object.assign(TypeError(`The URL must be of scheme file`),{code:`ERR_INVALID_URL_SCHEME`});return C.fileURLToPath(e.href)}if(e instanceof Uint8Array)return new TextDecoder().decode(e);throw w(t,e)}function D(e,t){let n=[...t];switch(e){case`path`:n[0]=E(n[0]);break;case`fd`:typeof n[0]!=`number`&&(n[0]=E(n[0]));break;case`pair`:n[0]=E(n[0],`src`),n[1]=E(n[1],`dest`);break;case`second`:n[1]=E(n[1])}return n}function O(e,t,n={}){let r=e;for(let i of Object.keys(t)){let a=t[i],o=r[i];!a||typeof o!=`function`||(r[i]=((...t)=>{let r;try{r=D(a,t)}catch(e){if(n.promises)return Promise.reject(e);throw e}return o.apply(e,r)}))}}function k(e,t){return Object.assign(Error(`EBADF: bad file descriptor, ${e} ${String(t)}`),{code:`EBADF`})}function A(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ee(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return t}function te(){return{readSync:e=>{throw k(`read`,e)},writeSync:e=>{throw k(`write`,e)}}}function ne(e){let t=0;return{readSync(n,r,i,a){if(n!==0)throw k(`read`,n);let o=A(r),s=typeof i==`object`&&i?i:{offset:i,length:a},c=s.offset??0,l=s.length??o.length-c,u=e.readStdinBytes(),d=Math.max(0,Math.min(l,u.length-t));return o.set(u.subarray(t,t+d),c),t+=d,d},writeSync(t,n,r,i){let a=t===1?e.writeStdout:t===2?e.writeStderr:void 0;if(!a)throw k(`write`,t);if(typeof n==`string`)return a(n),new TextEncoder().encode(n).length;if(!ArrayBuffer.isView(n))throw TypeError(`writeSync: data must be a string or buffer`);let o=A(n),s=typeof r==`number`?r:0,c=o.subarray(s,i===void 0?void 0:s+i);return a(ee(c)),c.length}}}function j(e){if(!e||e===`/`)return`/`;e.startsWith(`/`)||(e=`/`+e);let t=e.split(`/`),n=[];for(let e of t)e!==``&&e!==`.`&&(e===`..`?n.pop():n.push(e));return`/`+n.join(`/`)}function re(e){let t=j(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return n===0?`/`:t.slice(0,n)}function M(e){return Object.assign(Error(`ENOENT: no such file or directory, '${e}'`),{code:`ENOENT`})}function ie(e){return Object.assign(Error(`ENOSYNC: file too large for sync access, '${e}' — use async readFile() instead`),{code:`ENOSYNC`})}function ae(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var oe=class{tree=new Map;initialPaths=new Set;initialContent=new Map;initialKind=new Map;mkdtempCounter=0;tombstones=new Set;removedDirs=new Set;touched=!1;constructor(e){this.loadSnapshot(e)}loadSnapshot(e){this.tree=new Map,this.tombstones=new Set,this.removedDirs=new Set,this.initialPaths=new Set,this.initialContent=new Map,this.initialKind=new Map,this.tree.set(`/`,{content:new Uint8Array,isDirectory:!0}),this.initialPaths.add(`/`),this.initialKind.set(`/`,`directory`);for(let t of e.entries){let e=j(t.path);this.tree.set(e,{content:t.content,isDirectory:t.isDirectory,isSymbolicLink:t.isSymbolicLink,symlinkTarget:t.symlinkTarget,truncated:t.truncated,size:t.size}),this.initialPaths.add(e),this.initialKind.set(e,this.entryKind(t)),!t.isDirectory&&!t.isSymbolicLink&&this.initialContent.set(e,t.content)}for(let t of e.entries){let e=re(j(t.path));for(;e!==`/`&&!this.tree.has(e);)this.tree.set(e,{content:new Uint8Array,isDirectory:!0}),this.initialPaths.add(e),this.initialKind.set(e,`directory`),e=re(e)}}wasUsed(){return this.touched}applySnapshot(e){this.loadSnapshot(e)}applySnapshotPreservingMutations(e){let t=this.getMutations();this.loadSnapshot(e);for(let e of t.deleted){if(this.tree.get(e)?.isDirectory){let t=e===`/`?`/`:e+`/`;for(let n of Array.from(this.tree.keys()))n!==e&&n.startsWith(t)&&this.tree.delete(n)}this.tree.delete(e)}for(let e of t.created)this.ensureParentDirs(e.path),this.tree.set(e.path,{content:e.content,isDirectory:e.isDirectory,isSymbolicLink:e.isSymbolicLink,symlinkTarget:e.symlinkTarget});for(let e of t.modified)this.ensureParentDirs(e.path),this.tree.set(e.path,{content:e.content,isDirectory:!1})}invalidate(){this.loadSnapshot({entries:[]})}resetBaseline(){this.initialPaths=new Set,this.initialContent=new Map,this.initialKind=new Map;for(let[e,t]of this.tree.entries())this.initialPaths.add(e),this.initialKind.set(e,this.entryKind(t)),!t.isDirectory&&!t.isSymbolicLink&&this.initialContent.set(e,t.content)}entryKind(e){return e.isSymbolicLink?`symlink`:e.isDirectory?`directory`:`file`}resolveEntry(e,t=!1){let n=j(e),r=n.split(`/`).filter(Boolean),i=[],a=new Set,o=0;if(r.length===0){let e=this.tree.get(`/`);return e?{path:`/`,entry:e}:void 0}for(;r.length>0;){let e=r.shift(),s=`/${[...i,e].join(`/`)}`,c=this.tree.get(s);if(!c)return;let l=r.length===0;if(c.isSymbolicLink&&!(t&&l)){if(a.has(s)||o++===40)throw Object.assign(Error(`ELOOP: too many symbolic links, '${n}'`),{code:`ELOOP`});a.add(s);let e=c.symlinkTarget??``;r=[...j(e.startsWith(`/`)?e:`${re(s)}/${e}`).split(`/`).filter(Boolean),...r],i=[];continue}if(!l&&!c.isDirectory)return;if(i.push(e),l)return{path:s,entry:c}}}ensureParentDirs(e){let t=re(e);t!==`/`&&(this.tree.has(t)||this.mkdir(t,!0,!0))}isPartial(e){return this.tree.get(j(e))?.partial===!0}commitWrite(e,t){this.writeFile(e,t);let n=j(e);for(this.initialContent.set(n,t);n!==`/`;){let e=this.tree.get(n);e&&(this.initialPaths.add(n),this.initialKind.set(n,this.entryKind(e))),n=re(n)}}readFile(e){this.touched=!0;let t=j(e),n=this.resolveEntry(t)?.entry;if(!n||n.isDirectory)throw M(t);if(n.truncated)throw ie(t);return n.content}writeFile(e,t){this.touched=!0;let n=j(e);this.ensureParentDirs(n),this.tree.set(n,{content:t,isDirectory:!1}),this.tombstones.delete(n),this.removedDirs.delete(n)}exists(e){this.touched=!0;let t=j(e);return this.tree.has(t)}stat(e){this.touched=!0;let t=j(e),n=this.resolveEntry(t);if(!n)throw M(t);return this.toStat(n.entry)}lstat(e){this.touched=!0;let t=j(e),n=this.resolveEntry(t,!0);if(!n)throw M(t);return this.toStat(n.entry)}toStat(e){return{isFile:!e.isDirectory&&!e.isSymbolicLink,isDirectory:e.isDirectory,isSymbolicLink:e.isSymbolicLink===!0,size:e.isDirectory?0:e.size??e.content.byteLength}}readdir(e){this.touched=!0;let t=j(e),n=this.resolveEntry(t);if(!n?.entry.isDirectory)throw M(t);let r=n.path===`/`?`/`:n.path+`/`,i=new Set;for(let e of this.tree.keys()){if(e===t||e===`/`||!e.startsWith(r))continue;let n=e.slice(r.length).split(`/`)[0];n&&i.add(n)}return Array.from(i)}mkdir(e,t,n=!1){this.touched=!0;let r=j(e);if(this.tree.has(r)){if(this.tree.get(r).isDirectory)return;throw Object.assign(Error(`EEXIST: file already exists, '${r}'`),{code:`EEXIST`})}let i=re(r);if(i!==`/`&&!this.tree.has(i)){if(!t)throw M(r);this.mkdir(i,!0,n)}this.tree.set(r,{content:new Uint8Array,isDirectory:!0,...n?{partial:!0}:{}}),this.tombstones.delete(r),this.removedDirs.delete(r)}rm(e,t){this.touched=!0;let n=j(e),r=this.tree.get(n);if(!r)throw M(n);if(r.isDirectory&&!r.isSymbolicLink){let e=n===`/`?`/`:n+`/`,r=Array.from(this.tree.keys()).filter(t=>t!==n&&t.startsWith(e));if(r.length>0&&!t)throw Object.assign(Error(`ENOTEMPTY: directory not empty, '${n}'`),{code:`ENOTEMPTY`});for(let e of r)this.tree.delete(e),this.tombstones.add(e);t&&this.removedDirs.add(n)}this.tree.delete(n),this.tombstones.add(n)}copyFile(e,t){this.touched=!0;let n=j(e),r=this.tree.get(n);if(!r||r.isDirectory)throw M(n);if(r.truncated)throw ie(n);let i=j(t);this.ensureParentDirs(i),this.tree.set(i,{content:r.content.slice(),isDirectory:!1}),this.tombstones.delete(i),this.removedDirs.delete(i)}rename(e,t){this.touched=!0;let n=j(e),r=this.tree.get(n);if(!r)throw M(n);let i=j(t);if(r.isDirectory){let e=n===`/`?`/`:n+`/`,t=Array.from(this.tree.keys()).filter(t=>t!==n&&t.startsWith(e));this.ensureParentDirs(i),this.tree.set(i,r),this.tree.delete(n);for(let e of t){let t=this.tree.get(e),r=i+e.slice(n.length);this.tree.set(r,t),this.tree.delete(e)}this.tombstones.add(n),this.removedDirs.add(n),this.tombstones.delete(i),this.removedDirs.delete(i);return}this.ensureParentDirs(i),this.tree.set(i,r),this.tree.delete(n),this.tombstones.add(n),this.tombstones.delete(i),this.removedDirs.delete(i)}unlink(e){this.touched=!0;let t=j(e),n=this.tree.get(t);if(!n)throw M(t);if(n.isDirectory&&!n.isSymbolicLink)throw Object.assign(Error(`EISDIR: illegal operation on a directory, unlink '${t}'`),{code:`EISDIR`});this.tree.delete(t),this.tombstones.add(t)}markRemoved(e,t=!1){this.touched=!0;let n=j(e);this.tombstones.add(n),t&&this.removedDirs.add(n)}isTombstoned(e){let t=j(e);if(this.tombstones.has(t))return!0;for(let e of this.removedDirs)if(t===e||t.startsWith(`${e}/`))return!0;return!1}mkdtemp(e){this.touched=!0;for(let t=0;t<100;t++){let t=`_${String(this.mkdtempCounter).padStart(6,`0`)}`;this.mkdtempCounter++;let n=j(e+t);if(!this.tree.has(n))return this.mkdir(n,!0),n}throw Error(`mkdtemp: failed to create unique directory after 100 attempts`)}getMutations(){let e=[],t=[],n=[];for(let[r,i]of this.tree.entries()){if(r===`/`)continue;if(!this.initialPaths.has(r)){e.push({path:r,content:i.content,isDirectory:i.isDirectory,isSymbolicLink:i.isSymbolicLink,symlinkTarget:i.symlinkTarget});continue}let a=this.initialKind.get(r);if(a!==void 0&&a!==this.entryKind(i)){n.push(r),e.push({path:r,content:i.content,isDirectory:i.isDirectory,isSymbolicLink:i.isSymbolicLink,symlinkTarget:i.symlinkTarget});continue}if(!i.isDirectory&&!i.isSymbolicLink){let e=this.initialContent.get(r);e&&!ae(e,i.content)&&t.push({path:r,content:i.content})}}for(let e of this.initialPaths)e!==`/`&&(this.tree.has(e)||n.push(e));return{created:e,modified:t,deleted:n}}};function se(){return globalThis.Buffer}function ce(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function le(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return t}function ue(e,t){return Object.assign(Error(`EBADF: bad file descriptor, ${e} ${String(t)}`),{code:`EBADF`})}function de(e){return e===`/dev/stdin`||e===`/dev/stdout`||e===`/dev/stderr`}function fe(e){if(e===0||e===`/dev/stdin`)return 0;if(e===1||e===`/dev/stdout`)return 1;if(e===2||e===`/dev/stderr`)return 2}function pe(e,t){let n=fe(e);if(n===0)return!0;if(n!==void 0||typeof e==`number`)throw ue(t,e);return!1}function me(e,t,n){let r=fe(t);if(r===1)return e.writeStdout;if(r===2)return e.writeStderr;if(r!==void 0||typeof t==`number`)throw ue(n,t)}function he(e){return typeof e==`string`?e:le(Oe(e))}function ge(e,t){if(t===`utf8`||t===`utf-8`)return new TextDecoder().decode(e);let n=se();return n?n.from(e):e}function _e(e){return typeof e==`string`?e:e?.encoding}function ve(){return{isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1,isCharacterDevice:()=>!0,size:0}}function ye(e,t){if(!t)return;let n={readFile:e.readFile,readFileBinary:e.readFileBinary,writeFile:e.writeFile,writeFileBinary:e.writeFileBinary,appendFile:e.appendFile,access:e.access,exists:e.exists,stat:e.stat};e.readFile=async(e,r)=>{if(!pe(e,`read`))return n.readFile(e,r);let i=_e(r);if(i===null||i===`buffer`){let e=se(),n=t.readStdinBytes();return e?e.from(n):n}return new TextDecoder().decode(t.readStdinBytes())},e.readFileBinary=async e=>pe(e,`read`)?t.readStdinBytes():n.readFileBinary(e),e.writeFile=async(e,r)=>{let i=me(t,e,`write`);return i?(i(he(r)),!0):n.writeFile(e,r)},e.writeFileBinary=async(e,r)=>{let i=me(t,e,`write`);return i?(i(le(r)),!0):n.writeFileBinary(e,r)},e.appendFile=async(e,r)=>{let i=me(t,e,`append`);if(!i)return n.appendFile(e,r);i(he(r))},e.access=async e=>{if(!de(e))return n.access(e)},e.exists=async e=>de(e)||n.exists(e),e.stat=async e=>de(e)?{isFile:!0,isDirectory:!1,size:0}:n.stat(e)}function be(e,t,n){function r(e){if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}return e instanceof ArrayBuffer?new Uint8Array(e):new TextEncoder().encode(typeof e==`string`?e:String(e))}async function i(t,n){let r=typeof n==`string`?n:n?.encoding;if(r===null||r===`buffer`){let n=await e.call(`vfs`,`readFileBinary`,[t]),r=se();return r?r.from(n instanceof Uint8Array?n:new Uint8Array(n)):n}return e.call(`vfs`,`readFile`,[t])}async function a(t,n){return typeof n==`string`?e.call(`vfs`,`writeFile`,[t,n]):e.call(`vfs`,`writeFileBinary`,[t,r(n)])}async function o(t,n){if(typeof n==`string`){await e.call(`vfs`,`appendFile`,[t,n]);return}await e.call(`vfs`,`appendFile`,[t,r(n)])}async function s(t,n,r){let i=await e.call(`vfs`,`stat`,[t]);if(i.isFile){let r=await e.call(`vfs`,`readFileBinary`,[t]);await e.call(`vfs`,`writeFileBinary`,[n,r]);return}if(!i.isDirectory||!r?.recursive)throw Error(`cp: '${t}' is a directory (use {recursive: true})`);await l(n);let a=await e.call(`vfs`,`readDir`,[t]);for(let e of a)await s(`${t}/${e}`,`${n}/${e}`,r)}async function c(t,n){if(n?.force&&!await e.call(`vfs`,`exists`,[t]))return!0;if((await e.call(`vfs`,`stat`,[t])).isFile)return e.call(`vfs`,`rm`,[t]);if(!n?.recursive)throw Error(`rm: '${t}' is a directory (use {recursive: true})`);let r=await e.call(`vfs`,`readDir`,[t]);for(let e of r)await c(`${t}/${e}`,n);return e.call(`vfs`,`rm`,[t])}async function l(t){await e.call(`vfs`,`mkdir`,[t])}async function u(t){for(let n=0;n<5;n++){let n=`${t}${Math.random().toString(36).slice(2,10)+Math.random().toString(36).slice(2,6)}`;if(!await e.call(`vfs`,`exists`,[n]))return await e.call(`vfs`,`mkdir`,[n]),n}throw Error(`mkdtemp: failed to create unique directory after 5 attempts`)}async function d(t,n){try{await e.call(`vfs`,`rename`,[t,n])}catch{let r=await e.call(`vfs`,`readFileBinary`,[t]);await e.call(`vfs`,`writeFileBinary`,[n,r]),await e.call(`vfs`,`rm`,[t])}}async function f(t){if(!await e.call(`vfs`,`exists`,[t]))throw Object.assign(Error(`ENOENT: no such file or directory, access '${t}'`),{code:`ENOENT`})}let p={readFile:i,readFileBinary:t=>e.call(`vfs`,`readFileBinary`,[t]),writeFile:a,writeFileBinary:(t,n)=>e.call(`vfs`,`writeFileBinary`,[t,n]),appendFile:o,cp:s,rm:c,readDir:t=>e.call(`vfs`,`readDir`,[t]),readdir:t=>e.call(`vfs`,`readDir`,[t]),exists:t=>e.call(`vfs`,`exists`,[t]),stat:t=>e.call(`vfs`,`stat`,[t]),mkdir:(t,n)=>e.call(`vfs`,`mkdir`,[t]),mkdtemp:u,rename:d,access:f,unlink:t=>e.call(`vfs`,`rm`,[t]),rmdir:t=>e.call(`vfs`,`rm`,[t]),copyFile:async(t,n)=>{let r=await e.call(`vfs`,`readFileBinary`,[t]);await e.call(`vfs`,`writeFileBinary`,[n,r])},fetchToFile:async(n,r)=>{let i=await t(n);if(!i.ok)throw Error(`fetch ${i.status} ${i.statusText}`);let a=new Uint8Array(await i.arrayBuffer());return await e.call(`vfs`,`writeFileBinary`,[r,a]),a.byteLength},promises:null};return ye(p,n),O(p,xe,{promises:!0}),p.promises=p,p}const xe={readFile:`fd`,readFileBinary:`fd`,writeFile:`fd`,writeFileBinary:`fd`,appendFile:`fd`,cp:`pair`,rm:`path`,readDir:`path`,readdir:`path`,exists:`path`,stat:`path`,mkdir:`path`,mkdtemp:`path`,rename:`pair`,access:`path`,unlink:`path`,rmdir:`path`,copyFile:`pair`,fetchToFile:`second`},Se={readFileSync:`fd`,writeFileSync:`fd`,appendFileSync:`fd`,truncateSync:`path`,existsSync:`path`,accessSync:`path`,mkdirSync:`path`,statSync:`path`,lstatSync:`path`,realpathSync:`path`,readdirSync:`path`,copyFileSync:`pair`,cpSync:`pair`,chmodSync:`path`,mkdtempSync:`path`,rmSync:`path`,rmdirSync:`path`,unlinkSync:`path`,renameSync:`pair`};function N(e,t,n=``){return Object.assign(Error(`${e}: sync-fs, ${n?`${n} `:``}'${t}'`),{code:e})}function Ce(e,t,n,r={},i){let a=r.recursive===!0;try{return r.requireFile?e.unlink(n):e.rm(n,a),i?.(n),!0}catch(e){if(e?.code!==`ENOENT`)throw e}let o=t;if(!o?.rm||e.isTombstoned(n))return!1;try{if(!o.exists(n))return!1}catch{return!1}return o.rm(n),e.markRemoved(n,a),!0}function we(e){let{syncFs:t,bridge:n,resolve:r,existsResolved:i,lstatResolved:a,statResolved:o,readBytes:s,writeThrough:c,persistDelete:l}=e,u=(e,r)=>Ce(t,n,e,r,l);return{rmSync(e,t){let n=r(e);if(!(t?.force&&!i(n))&&!u(n,{recursive:t?.recursive===!0})&&!t?.force)throw N(`ENOENT`,n,`rm`)},rmdirSync(e,t){let n=r(e);if(i(n)&&!a(n).isDirectory)throw N(`ENOTDIR`,n,`rmdir`);if(!u(n,{recursive:t?.recursive===!0}))throw N(`ENOENT`,n,`rmdir`)},unlinkSync(e){let t=r(e);if(!u(t,{requireFile:!0}))throw N(`ENOENT`,t,`unlink`)},renameSync(e,i){let a=r(e),l=r(i);try{t.rename(a,l);return}catch(e){if(e?.code!==`ENOENT`)throw e}if(!n||t.isTombstoned(a))throw N(`ENOENT`,a,`rename`);if(o(a).isDirectory)throw N(`EISDIR`,a,`rename`);if(c(l,s(a)),!u(a,{requireFile:!0}))throw N(`ENOENT`,a,`rename`)}}}function Te(e,t){if(!t)return;let n={readFileSync:e.readFileSync,writeFileSync:e.writeFileSync,appendFileSync:e.appendFileSync,existsSync:e.existsSync,accessSync:e.accessSync,statSync:e.statSync,lstatSync:e.lstatSync};e.readFileSync=(e,r)=>pe(e,`read`)?ge(t.readStdinBytes(),_e(r)):n.readFileSync(e,r),e.writeFileSync=(e,r)=>{let i=me(t,e,`write`);i?i(he(r)):n.writeFileSync(e,r)},e.appendFileSync=(e,r)=>{let i=me(t,e,`append`);i?i(he(r)):n.appendFileSync(e,r)},e.existsSync=e=>de(e)||n.existsSync(e),e.accessSync=e=>{de(e)||n.accessSync(e)},e.statSync=e=>de(e)?ve():n.statSync(e),e.lstatSync=e=>de(e)?ve():n.lstatSync(e),Object.assign(e,ne(t))}function Ee(e,t,n,r){let i=t=>e===`/`?`/${t}`:`${e}/${t}`,a=new Set(n);for(let e of t)a.add(e);for(let e of a)r(i(e))&&a.delete(e);return[...a]}function De(e,t,n){let r=t=>e.isTombstoned(t);try{let i=e.readdir(n);if(!t||!e.isPartial(n)||r(n))return i;try{return Ee(n,i,t.readdir(n),r)}catch(e){if(e?.code===`ENOENT`)return i;throw e}}catch(e){let i=e?.code;if(!t||r(n)||i!==`ENOENT`)throw e;return Ee(n,[],t.readdir(n),r)}}function Oe(e){if(typeof e==`string`)return new TextEncoder().encode(e);if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}return new TextEncoder().encode(String(e))}function ke(e,t,n,r,i){t?(t.writeFile(r,i),e.commitWrite(r,i)):(e.writeFile(r,i),n?.write?.(r,i))}function Ae(e,t,n,r,i){function a(e){return j(e.startsWith(`/`)?e:t+(t.endsWith(`/`)?``:`/`)+e)}function o(t){try{return e.readFile(t)}catch(r){let i=r?.code;if(n&&!e.isTombstoned(t)&&(i===`ENOENT`||i===`ENOSYNC`))return n.readFile(t);throw r}}let s=(t,r)=>ke(e,n,i,t,r);function c(t){if(e.exists(t))return!0;if(!n||e.isTombstoned(t))return!1;try{return n.exists(t)}catch{return!1}}function l(t){try{return e.stat(t)}catch(r){let i=r?.code;if(!n||e.isTombstoned(t)||i!==`ENOENT`)throw r;return n.stat(t)}}function u(t){try{return e.lstat(t)}catch(r){let i=r?.code;if(!n||e.isTombstoned(t)||i!==`ENOENT`)throw r;return n.lstat(t)}}let d=e=>({isFile:()=>e.isFile,isDirectory:()=>e.isDirectory,isSymbolicLink:()=>e.isSymbolicLink===!0,isCharacterDevice:()=>!1,size:e.size}),f=(e,t)=>e===`/`?`/${t}`:`${e}/${t}`;function p(t,r){if(!l(t).isDirectory){s(r,o(t));return}e.mkdir(r,!0);for(let i of De(e,n,t))p(f(t,i),f(r,i))}let m={...we({syncFs:e,bridge:n,persistDelete:i?.delete,resolve:a,existsResolved:c,statResolved:l,lstatResolved:u,readBytes:o,writeThrough:s}),readFileSync(e,t){return ge(o(a(e)),_e(t))},writeFileSync(e,t){s(a(e),Oe(t))},appendFileSync(e,t){let n=a(e),r=new Uint8Array;try{r=o(n)}catch(e){if(e?.code!==`ENOENT`)throw e}let i=Oe(t),c=new Uint8Array(r.byteLength+i.byteLength);c.set(r),c.set(i,r.byteLength),s(n,c)},truncateSync(e,t=0){let n=a(e),r=o(n),i=new Uint8Array(t);i.set(r.subarray(0,Math.min(t,r.byteLength))),s(n,i)},existsSync(e){return c(a(e))},accessSync(e){let t=a(e);if(!c(t))throw N(`ENOENT`,t,`access`)},mkdirSync(t,n){e.mkdir(a(t),n?.recursive)},statSync:e=>d(l(a(e))),lstatSync:e=>d(u(a(e))),realpathSync(e){let t=a(e);if(!c(t))throw N(`ENOENT`,t,`realpath`);return t},readdirSync(t){return De(e,n,a(t))},copyFileSync(e,t){s(a(t),o(a(e)))},cpSync(e,t){p(a(e),a(t))},chmodSync(e){let t=a(e);if(!c(t))throw N(`ENOENT`,t,`chmod`)},mkdtempSync(t){return e.mkdtemp(a(t))}},h=Object.assign(m,te());Te(h,r),O(h,Se);let g=h.existsSync;return h.existsSync=e=>{try{return g(e)}catch{return!1}},h}var je=class{_events=new Map;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}addListener(e,t){return this.on(e,t)}off(e,t){let n=this._events.get(e);if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1),n.length===0&&this._events.delete(e)}return this}removeListener(e,t){return this.off(e,t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}removeAllListeners(e){return e===void 0?this._events.clear():this._events.delete(e),this}listenerCount(e){return this._events.get(e)?.length??0}listeners(e){return[...this._events.get(e)??[]]}};const Me=Object.assign(je,{EventEmitter:je,default:je});function Ne(e){let t=e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;if(e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},n=(e,t,n)=>t===void 0?`${e(`Error:`)} ${n}\n`:t===``?`${e(n)}\n`:`${e(`${t}:`)} ${n}\n`,r=(t,n)=>t===void 0?`${e.color.yellow(`Warning:`)} ${n}\n`:t===``?`${e.color.yellow(n)}\n`:`${e.color.yellow(`${t}:`)} ${n}\n`;return{die(r,i){let a=typeof i==`number`?i:i?.exitCode??1,o=typeof i==`object`&&i&&`prefix`in i?i.prefix:void 0,s=t(r);throw e.writeStderr(n(e.color.red,o,s)),e.exit(a),Error(`unreachable`)},out(t){if(typeof t==`string`){e.writeStdout(t.endsWith(`
1
+ import{t as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./__vite-browser-external-5eBdwsFd.js";import{r as n,t as r}from"./multipart-form-data-DopbgwRR.js";import{n as i}from"./slicc-version-Zk7JuEi9.js";import{t as a}from"./buffer-polyfill-BccMjOKj.js";import{t as o}from"./buffer-B5d1xHaH.js";import{F as s,I as c,N as l,P as u}from"./shared-DfMXB1pm.js";import{c as d,n as f,o as p,t as m}from"./require-guards-CHKfdRAj.js";import{t as h}from"./tmpdir-env-ate4iNcK.js";import{i as g,n as _,r as v,t as y}from"./realm-sync-transport-QD3YPwXN.js";import{t as b}from"./realm-browser-fetch-V3uggGbM.js";function x(e){let t=typeof e==`string`?e:e.href;if(!t.startsWith(`file:`))throw TypeError(`fileURLToPath: not a file URL`);let n=new URL(t);if(n.hostname!==``&&n.hostname!==`localhost`)throw Object.assign(TypeError(`File URL host must be "localhost" or empty on posix`),{code:`ERR_INVALID_FILE_URL_HOST`});if(/%2f/i.test(n.pathname))throw Object.assign(TypeError(`File URL path must not include encoded / characters`),{code:`ERR_INVALID_FILE_URL_PATH`});return decodeURIComponent(n.pathname)}function S(e){let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return new URL(`file://${t}`)}const C={URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams,fileURLToPath:x,pathToFileURL:S};function w(e,t){return Object.assign(TypeError(`The "${e}" argument must be of type string or an instance of Buffer or URL. Received ${t===null?`null`:typeof t}`),{code:`ERR_INVALID_ARG_TYPE`})}function T(e){return typeof e==`object`&&!!e&&typeof e.href==`string`&&typeof e.protocol==`string`}function E(e,t=`path`){if(typeof e==`string`)return e;if(T(e)){if(e.protocol!==`file:`)throw Object.assign(TypeError(`The URL must be of scheme file`),{code:`ERR_INVALID_URL_SCHEME`});return C.fileURLToPath(e.href)}if(e instanceof Uint8Array)return new TextDecoder().decode(e);throw w(t,e)}function D(e,t){let n=[...t];switch(e){case`path`:n[0]=E(n[0]);break;case`fd`:typeof n[0]!=`number`&&(n[0]=E(n[0]));break;case`pair`:n[0]=E(n[0],`src`),n[1]=E(n[1],`dest`);break;case`second`:n[1]=E(n[1])}return n}function O(e,t,n={}){let r=e;for(let i of Object.keys(t)){let a=t[i],o=r[i];!a||typeof o!=`function`||(r[i]=((...t)=>{let r;try{r=D(a,t)}catch(e){if(n.promises)return Promise.reject(e);throw e}return o.apply(e,r)}))}}function k(e,t){return Object.assign(Error(`EBADF: bad file descriptor, ${e} ${String(t)}`),{code:`EBADF`})}function A(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ee(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return t}function te(){return{readSync:e=>{throw k(`read`,e)},writeSync:e=>{throw k(`write`,e)}}}function ne(e){let t=0;return{readSync(n,r,i,a){if(n!==0)throw k(`read`,n);let o=A(r),s=typeof i==`object`&&i?i:{offset:i,length:a},c=s.offset??0,l=s.length??o.length-c,u=e.readStdinBytes(),d=Math.max(0,Math.min(l,u.length-t));return o.set(u.subarray(t,t+d),c),t+=d,d},writeSync(t,n,r,i){let a=t===1?e.writeStdout:t===2?e.writeStderr:void 0;if(!a)throw k(`write`,t);if(typeof n==`string`)return a(n),new TextEncoder().encode(n).length;if(!ArrayBuffer.isView(n))throw TypeError(`writeSync: data must be a string or buffer`);let o=A(n),s=typeof r==`number`?r:0,c=o.subarray(s,i===void 0?void 0:s+i);return a(ee(c)),c.length}}}function j(e){if(!e||e===`/`)return`/`;e.startsWith(`/`)||(e=`/`+e);let t=e.split(`/`),n=[];for(let e of t)e!==``&&e!==`.`&&(e===`..`?n.pop():n.push(e));return`/`+n.join(`/`)}function re(e){let t=j(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return n===0?`/`:t.slice(0,n)}function M(e){return Object.assign(Error(`ENOENT: no such file or directory, '${e}'`),{code:`ENOENT`})}function ie(e){return Object.assign(Error(`ENOSYNC: file too large for sync access, '${e}' — use async readFile() instead`),{code:`ENOSYNC`})}function ae(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var oe=class{tree=new Map;initialPaths=new Set;initialContent=new Map;initialKind=new Map;mkdtempCounter=0;tombstones=new Set;removedDirs=new Set;touched=!1;constructor(e){this.loadSnapshot(e)}loadSnapshot(e){this.tree=new Map,this.tombstones=new Set,this.removedDirs=new Set,this.initialPaths=new Set,this.initialContent=new Map,this.initialKind=new Map,this.tree.set(`/`,{content:new Uint8Array,isDirectory:!0}),this.initialPaths.add(`/`),this.initialKind.set(`/`,`directory`);for(let t of e.entries){let e=j(t.path);this.tree.set(e,{content:t.content,isDirectory:t.isDirectory,isSymbolicLink:t.isSymbolicLink,symlinkTarget:t.symlinkTarget,truncated:t.truncated,size:t.size}),this.initialPaths.add(e),this.initialKind.set(e,this.entryKind(t)),!t.isDirectory&&!t.isSymbolicLink&&this.initialContent.set(e,t.content)}for(let t of e.entries){let e=re(j(t.path));for(;e!==`/`&&!this.tree.has(e);)this.tree.set(e,{content:new Uint8Array,isDirectory:!0}),this.initialPaths.add(e),this.initialKind.set(e,`directory`),e=re(e)}}wasUsed(){return this.touched}applySnapshot(e){this.loadSnapshot(e)}applySnapshotPreservingMutations(e){let t=this.getMutations();this.loadSnapshot(e);for(let e of t.deleted){if(this.tree.get(e)?.isDirectory){let t=e===`/`?`/`:e+`/`;for(let n of Array.from(this.tree.keys()))n!==e&&n.startsWith(t)&&this.tree.delete(n)}this.tree.delete(e)}for(let e of t.created)this.ensureParentDirs(e.path),this.tree.set(e.path,{content:e.content,isDirectory:e.isDirectory,isSymbolicLink:e.isSymbolicLink,symlinkTarget:e.symlinkTarget});for(let e of t.modified)this.ensureParentDirs(e.path),this.tree.set(e.path,{content:e.content,isDirectory:!1})}invalidate(){this.loadSnapshot({entries:[]})}resetBaseline(){this.initialPaths=new Set,this.initialContent=new Map,this.initialKind=new Map;for(let[e,t]of this.tree.entries())this.initialPaths.add(e),this.initialKind.set(e,this.entryKind(t)),!t.isDirectory&&!t.isSymbolicLink&&this.initialContent.set(e,t.content)}entryKind(e){return e.isSymbolicLink?`symlink`:e.isDirectory?`directory`:`file`}resolveEntry(e,t=!1){let n=j(e),r=n.split(`/`).filter(Boolean),i=[],a=new Set,o=0;if(r.length===0){let e=this.tree.get(`/`);return e?{path:`/`,entry:e}:void 0}for(;r.length>0;){let e=r.shift(),s=`/${[...i,e].join(`/`)}`,c=this.tree.get(s);if(!c)return;let l=r.length===0;if(c.isSymbolicLink&&!(t&&l)){if(a.has(s)||o++===40)throw Object.assign(Error(`ELOOP: too many symbolic links, '${n}'`),{code:`ELOOP`});a.add(s);let e=c.symlinkTarget??``;r=[...j(e.startsWith(`/`)?e:`${re(s)}/${e}`).split(`/`).filter(Boolean),...r],i=[];continue}if(!l&&!c.isDirectory)return;if(i.push(e),l)return{path:s,entry:c}}}ensureParentDirs(e){let t=re(e);t!==`/`&&(this.tree.has(t)||this.mkdir(t,!0,!0))}isPartial(e){return this.tree.get(j(e))?.partial===!0}commitWrite(e,t){this.writeFile(e,t);let n=j(e);for(this.initialContent.set(n,t);n!==`/`;){let e=this.tree.get(n);e&&(this.initialPaths.add(n),this.initialKind.set(n,this.entryKind(e))),n=re(n)}}readFile(e){this.touched=!0;let t=j(e),n=this.resolveEntry(t)?.entry;if(!n||n.isDirectory)throw M(t);if(n.truncated)throw ie(t);return n.content}writeFile(e,t){this.touched=!0;let n=j(e);this.ensureParentDirs(n),this.tree.set(n,{content:t,isDirectory:!1}),this.tombstones.delete(n),this.removedDirs.delete(n)}exists(e){this.touched=!0;let t=j(e);return this.tree.has(t)}stat(e){this.touched=!0;let t=j(e),n=this.resolveEntry(t);if(!n)throw M(t);return this.toStat(n.entry)}lstat(e){this.touched=!0;let t=j(e),n=this.resolveEntry(t,!0);if(!n)throw M(t);return this.toStat(n.entry)}toStat(e){return{isFile:!e.isDirectory&&!e.isSymbolicLink,isDirectory:e.isDirectory,isSymbolicLink:e.isSymbolicLink===!0,size:e.isDirectory?0:e.size??e.content.byteLength}}readdir(e){this.touched=!0;let t=j(e),n=this.resolveEntry(t);if(!n?.entry.isDirectory)throw M(t);let r=n.path===`/`?`/`:n.path+`/`,i=new Set;for(let e of this.tree.keys()){if(e===t||e===`/`||!e.startsWith(r))continue;let n=e.slice(r.length).split(`/`)[0];n&&i.add(n)}return Array.from(i)}mkdir(e,t,n=!1){this.touched=!0;let r=j(e);if(this.tree.has(r)){if(this.tree.get(r).isDirectory)return;throw Object.assign(Error(`EEXIST: file already exists, '${r}'`),{code:`EEXIST`})}let i=re(r);if(i!==`/`&&!this.tree.has(i)){if(!t)throw M(r);this.mkdir(i,!0,n)}this.tree.set(r,{content:new Uint8Array,isDirectory:!0,...n?{partial:!0}:{}}),this.tombstones.delete(r),this.removedDirs.delete(r)}rm(e,t){this.touched=!0;let n=j(e),r=this.tree.get(n);if(!r)throw M(n);if(r.isDirectory&&!r.isSymbolicLink){let e=n===`/`?`/`:n+`/`,r=Array.from(this.tree.keys()).filter(t=>t!==n&&t.startsWith(e));if(r.length>0&&!t)throw Object.assign(Error(`ENOTEMPTY: directory not empty, '${n}'`),{code:`ENOTEMPTY`});for(let e of r)this.tree.delete(e),this.tombstones.add(e);t&&this.removedDirs.add(n)}this.tree.delete(n),this.tombstones.add(n)}copyFile(e,t){this.touched=!0;let n=j(e),r=this.tree.get(n);if(!r||r.isDirectory)throw M(n);if(r.truncated)throw ie(n);let i=j(t);this.ensureParentDirs(i),this.tree.set(i,{content:r.content.slice(),isDirectory:!1}),this.tombstones.delete(i),this.removedDirs.delete(i)}rename(e,t){this.touched=!0;let n=j(e),r=this.tree.get(n);if(!r)throw M(n);let i=j(t);if(r.isDirectory){let e=n===`/`?`/`:n+`/`,t=Array.from(this.tree.keys()).filter(t=>t!==n&&t.startsWith(e));this.ensureParentDirs(i),this.tree.set(i,r),this.tree.delete(n);for(let e of t){let t=this.tree.get(e),r=i+e.slice(n.length);this.tree.set(r,t),this.tree.delete(e)}this.tombstones.add(n),this.removedDirs.add(n),this.tombstones.delete(i),this.removedDirs.delete(i);return}this.ensureParentDirs(i),this.tree.set(i,r),this.tree.delete(n),this.tombstones.add(n),this.tombstones.delete(i),this.removedDirs.delete(i)}unlink(e){this.touched=!0;let t=j(e),n=this.tree.get(t);if(!n)throw M(t);if(n.isDirectory&&!n.isSymbolicLink)throw Object.assign(Error(`EISDIR: illegal operation on a directory, unlink '${t}'`),{code:`EISDIR`});this.tree.delete(t),this.tombstones.add(t)}markRemoved(e,t=!1){this.touched=!0;let n=j(e);this.tombstones.add(n),t&&this.removedDirs.add(n)}isTombstoned(e){let t=j(e);if(this.tombstones.has(t))return!0;for(let e of this.removedDirs)if(t===e||t.startsWith(`${e}/`))return!0;return!1}mkdtemp(e){this.touched=!0;for(let t=0;t<100;t++){let t=`_${String(this.mkdtempCounter).padStart(6,`0`)}`;this.mkdtempCounter++;let n=j(e+t);if(!this.tree.has(n))return this.mkdir(n,!0),n}throw Error(`mkdtemp: failed to create unique directory after 100 attempts`)}getMutations(){let e=[],t=[],n=[];for(let[r,i]of this.tree.entries()){if(r===`/`)continue;if(!this.initialPaths.has(r)){e.push({path:r,content:i.content,isDirectory:i.isDirectory,isSymbolicLink:i.isSymbolicLink,symlinkTarget:i.symlinkTarget});continue}let a=this.initialKind.get(r);if(a!==void 0&&a!==this.entryKind(i)){n.push(r),e.push({path:r,content:i.content,isDirectory:i.isDirectory,isSymbolicLink:i.isSymbolicLink,symlinkTarget:i.symlinkTarget});continue}if(!i.isDirectory&&!i.isSymbolicLink){let e=this.initialContent.get(r);e&&!ae(e,i.content)&&t.push({path:r,content:i.content})}}for(let e of this.initialPaths)e!==`/`&&(this.tree.has(e)||n.push(e));return{created:e,modified:t,deleted:n}}};function se(){return globalThis.Buffer}function ce(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function le(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return t}function ue(e,t){return Object.assign(Error(`EBADF: bad file descriptor, ${e} ${String(t)}`),{code:`EBADF`})}function de(e){return e===`/dev/stdin`||e===`/dev/stdout`||e===`/dev/stderr`}function fe(e){if(e===0||e===`/dev/stdin`)return 0;if(e===1||e===`/dev/stdout`)return 1;if(e===2||e===`/dev/stderr`)return 2}function pe(e,t){let n=fe(e);if(n===0)return!0;if(n!==void 0||typeof e==`number`)throw ue(t,e);return!1}function me(e,t,n){let r=fe(t);if(r===1)return e.writeStdout;if(r===2)return e.writeStderr;if(r!==void 0||typeof t==`number`)throw ue(n,t)}function he(e){return typeof e==`string`?e:le(Oe(e))}function ge(e,t){if(t===`utf8`||t===`utf-8`)return new TextDecoder().decode(e);let n=se();return n?n.from(e):e}function _e(e){return typeof e==`string`?e:e?.encoding}function ve(){return{isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1,isCharacterDevice:()=>!0,size:0}}function ye(e,t){if(!t)return;let n={readFile:e.readFile,readFileBinary:e.readFileBinary,writeFile:e.writeFile,writeFileBinary:e.writeFileBinary,appendFile:e.appendFile,access:e.access,exists:e.exists,stat:e.stat};e.readFile=async(e,r)=>{if(!pe(e,`read`))return n.readFile(e,r);let i=_e(r);if(i===null||i===`buffer`){let e=se(),n=t.readStdinBytes();return e?e.from(n):n}return new TextDecoder().decode(t.readStdinBytes())},e.readFileBinary=async e=>pe(e,`read`)?t.readStdinBytes():n.readFileBinary(e),e.writeFile=async(e,r)=>{let i=me(t,e,`write`);return i?(i(he(r)),!0):n.writeFile(e,r)},e.writeFileBinary=async(e,r)=>{let i=me(t,e,`write`);return i?(i(le(r)),!0):n.writeFileBinary(e,r)},e.appendFile=async(e,r)=>{let i=me(t,e,`append`);if(!i)return n.appendFile(e,r);i(he(r))},e.access=async e=>{if(!de(e))return n.access(e)},e.exists=async e=>de(e)||n.exists(e),e.stat=async e=>de(e)?{isFile:!0,isDirectory:!1,size:0}:n.stat(e)}function be(e,t,n){function r(e){if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}return e instanceof ArrayBuffer?new Uint8Array(e):new TextEncoder().encode(typeof e==`string`?e:String(e))}async function i(t,n){let r=typeof n==`string`?n:n?.encoding;if(r===null||r===`buffer`){let n=await e.call(`vfs`,`readFileBinary`,[t]),r=se();return r?r.from(n instanceof Uint8Array?n:new Uint8Array(n)):n}return e.call(`vfs`,`readFile`,[t])}async function a(t,n){return typeof n==`string`?e.call(`vfs`,`writeFile`,[t,n]):e.call(`vfs`,`writeFileBinary`,[t,r(n)])}async function o(t,n){if(typeof n==`string`){await e.call(`vfs`,`appendFile`,[t,n]);return}await e.call(`vfs`,`appendFile`,[t,r(n)])}async function s(t,n,r){let i=await e.call(`vfs`,`stat`,[t]);if(i.isFile){let r=await e.call(`vfs`,`readFileBinary`,[t]);await e.call(`vfs`,`writeFileBinary`,[n,r]);return}if(!i.isDirectory||!r?.recursive)throw Error(`cp: '${t}' is a directory (use {recursive: true})`);await l(n);let a=await e.call(`vfs`,`readDir`,[t]);for(let e of a)await s(`${t}/${e}`,`${n}/${e}`,r)}async function c(t,n){if(n?.force&&!await e.call(`vfs`,`exists`,[t]))return!0;if((await e.call(`vfs`,`stat`,[t])).isFile)return e.call(`vfs`,`rm`,[t]);if(!n?.recursive)throw Error(`rm: '${t}' is a directory (use {recursive: true})`);let r=await e.call(`vfs`,`readDir`,[t]);for(let e of r)await c(`${t}/${e}`,n);return e.call(`vfs`,`rm`,[t])}async function l(t){await e.call(`vfs`,`mkdir`,[t])}async function u(t){for(let n=0;n<5;n++){let n=`${t}${Math.random().toString(36).slice(2,10)+Math.random().toString(36).slice(2,6)}`;if(!await e.call(`vfs`,`exists`,[n]))return await e.call(`vfs`,`mkdir`,[n]),n}throw Error(`mkdtemp: failed to create unique directory after 5 attempts`)}async function d(t,n){try{await e.call(`vfs`,`rename`,[t,n])}catch{let r=await e.call(`vfs`,`readFileBinary`,[t]);await e.call(`vfs`,`writeFileBinary`,[n,r]),await e.call(`vfs`,`rm`,[t])}}async function f(t){if(!await e.call(`vfs`,`exists`,[t]))throw Object.assign(Error(`ENOENT: no such file or directory, access '${t}'`),{code:`ENOENT`})}let p={readFile:i,readFileBinary:t=>e.call(`vfs`,`readFileBinary`,[t]),writeFile:a,writeFileBinary:(t,n)=>e.call(`vfs`,`writeFileBinary`,[t,n]),appendFile:o,cp:s,rm:c,readDir:t=>e.call(`vfs`,`readDir`,[t]),readdir:t=>e.call(`vfs`,`readDir`,[t]),exists:t=>e.call(`vfs`,`exists`,[t]),stat:t=>e.call(`vfs`,`stat`,[t]),mkdir:(t,n)=>e.call(`vfs`,`mkdir`,[t]),mkdtemp:u,rename:d,access:f,unlink:t=>e.call(`vfs`,`rm`,[t]),rmdir:t=>e.call(`vfs`,`rm`,[t]),copyFile:async(t,n)=>{let r=await e.call(`vfs`,`readFileBinary`,[t]);await e.call(`vfs`,`writeFileBinary`,[n,r])},fetchToFile:async(n,r)=>{let i=await t(n);if(!i.ok)throw Error(`fetch ${i.status} ${i.statusText}`);let a=new Uint8Array(await i.arrayBuffer());return await e.call(`vfs`,`writeFileBinary`,[r,a]),a.byteLength},promises:null};return ye(p,n),O(p,xe,{promises:!0}),p.promises=p,p}const xe={readFile:`fd`,readFileBinary:`fd`,writeFile:`fd`,writeFileBinary:`fd`,appendFile:`fd`,cp:`pair`,rm:`path`,readDir:`path`,readdir:`path`,exists:`path`,stat:`path`,mkdir:`path`,mkdtemp:`path`,rename:`pair`,access:`path`,unlink:`path`,rmdir:`path`,copyFile:`pair`,fetchToFile:`second`},Se={readFileSync:`fd`,writeFileSync:`fd`,appendFileSync:`fd`,truncateSync:`path`,existsSync:`path`,accessSync:`path`,mkdirSync:`path`,statSync:`path`,lstatSync:`path`,realpathSync:`path`,readdirSync:`path`,copyFileSync:`pair`,cpSync:`pair`,chmodSync:`path`,mkdtempSync:`path`,rmSync:`path`,rmdirSync:`path`,unlinkSync:`path`,renameSync:`pair`};function N(e,t,n=``){return Object.assign(Error(`${e}: sync-fs, ${n?`${n} `:``}'${t}'`),{code:e})}function Ce(e,t,n,r={},i){let a=r.recursive===!0;try{return r.requireFile?e.unlink(n):e.rm(n,a),i?.(n),!0}catch(e){if(e?.code!==`ENOENT`)throw e}let o=t;if(!o?.rm||e.isTombstoned(n))return!1;try{if(!o.exists(n))return!1}catch{return!1}return o.rm(n),e.markRemoved(n,a),!0}function we(e){let{syncFs:t,bridge:n,resolve:r,existsResolved:i,lstatResolved:a,statResolved:o,readBytes:s,writeThrough:c,persistDelete:l}=e,u=(e,r)=>Ce(t,n,e,r,l);return{rmSync(e,t){let n=r(e);if(!(t?.force&&!i(n))&&!u(n,{recursive:t?.recursive===!0})&&!t?.force)throw N(`ENOENT`,n,`rm`)},rmdirSync(e,t){let n=r(e);if(i(n)&&!a(n).isDirectory)throw N(`ENOTDIR`,n,`rmdir`);if(!u(n,{recursive:t?.recursive===!0}))throw N(`ENOENT`,n,`rmdir`)},unlinkSync(e){let t=r(e);if(!u(t,{requireFile:!0}))throw N(`ENOENT`,t,`unlink`)},renameSync(e,i){let a=r(e),l=r(i);try{t.rename(a,l);return}catch(e){if(e?.code!==`ENOENT`)throw e}if(!n||t.isTombstoned(a))throw N(`ENOENT`,a,`rename`);if(o(a).isDirectory)throw N(`EISDIR`,a,`rename`);if(c(l,s(a)),!u(a,{requireFile:!0}))throw N(`ENOENT`,a,`rename`)}}}function Te(e,t){if(!t)return;let n={readFileSync:e.readFileSync,writeFileSync:e.writeFileSync,appendFileSync:e.appendFileSync,existsSync:e.existsSync,accessSync:e.accessSync,statSync:e.statSync,lstatSync:e.lstatSync};e.readFileSync=(e,r)=>pe(e,`read`)?ge(t.readStdinBytes(),_e(r)):n.readFileSync(e,r),e.writeFileSync=(e,r)=>{let i=me(t,e,`write`);i?i(he(r)):n.writeFileSync(e,r)},e.appendFileSync=(e,r)=>{let i=me(t,e,`append`);i?i(he(r)):n.appendFileSync(e,r)},e.existsSync=e=>de(e)||n.existsSync(e),e.accessSync=e=>{de(e)||n.accessSync(e)},e.statSync=e=>de(e)?ve():n.statSync(e),e.lstatSync=e=>de(e)?ve():n.lstatSync(e),Object.assign(e,ne(t))}function Ee(e,t,n,r){let i=t=>e===`/`?`/${t}`:`${e}/${t}`,a=new Set(n);for(let e of t)a.add(e);for(let e of a)r(i(e))&&a.delete(e);return[...a]}function De(e,t,n){let r=t=>e.isTombstoned(t);try{let i=e.readdir(n);if(!t||!e.isPartial(n)||r(n))return i;try{return Ee(n,i,t.readdir(n),r)}catch(e){if(e?.code===`ENOENT`)return i;throw e}}catch(e){let i=e?.code;if(!t||r(n)||i!==`ENOENT`)throw e;return Ee(n,[],t.readdir(n),r)}}function Oe(e){if(typeof e==`string`)return new TextEncoder().encode(e);if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e)){let t=e;return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}return new TextEncoder().encode(String(e))}function ke(e,t,n,r,i){t?(t.writeFile(r,i),e.commitWrite(r,i)):(e.writeFile(r,i),n?.write?.(r,i))}function Ae(e,t,n,r,i){function a(e){return j(e.startsWith(`/`)?e:t+(t.endsWith(`/`)?``:`/`)+e)}function o(t){try{return e.readFile(t)}catch(r){let i=r?.code;if(n&&!e.isTombstoned(t)&&(i===`ENOENT`||i===`ENOSYNC`))return n.readFile(t);throw r}}let s=(t,r)=>ke(e,n,i,t,r);function c(t){if(e.exists(t))return!0;if(!n||e.isTombstoned(t))return!1;try{return n.exists(t)}catch{return!1}}function l(t){try{return e.stat(t)}catch(r){let i=r?.code;if(!n||e.isTombstoned(t)||i!==`ENOENT`)throw r;return n.stat(t)}}function u(t){try{return e.lstat(t)}catch(r){let i=r?.code;if(!n||e.isTombstoned(t)||i!==`ENOENT`)throw r;return n.lstat(t)}}let d=e=>({isFile:()=>e.isFile,isDirectory:()=>e.isDirectory,isSymbolicLink:()=>e.isSymbolicLink===!0,isCharacterDevice:()=>!1,size:e.size}),f=(e,t)=>e===`/`?`/${t}`:`${e}/${t}`;function p(t,r){if(!l(t).isDirectory){s(r,o(t));return}e.mkdir(r,!0);for(let i of De(e,n,t))p(f(t,i),f(r,i))}let m={...we({syncFs:e,bridge:n,persistDelete:i?.delete,resolve:a,existsResolved:c,statResolved:l,lstatResolved:u,readBytes:o,writeThrough:s}),readFileSync(e,t){return ge(o(a(e)),_e(t))},writeFileSync(e,t){s(a(e),Oe(t))},appendFileSync(e,t){let n=a(e),r=new Uint8Array;try{r=o(n)}catch(e){if(e?.code!==`ENOENT`)throw e}let i=Oe(t),c=new Uint8Array(r.byteLength+i.byteLength);c.set(r),c.set(i,r.byteLength),s(n,c)},truncateSync(e,t=0){let n=a(e),r=o(n),i=new Uint8Array(t);i.set(r.subarray(0,Math.min(t,r.byteLength))),s(n,i)},existsSync(e){return c(a(e))},accessSync(e){let t=a(e);if(!c(t))throw N(`ENOENT`,t,`access`)},mkdirSync(t,n){e.mkdir(a(t),n?.recursive)},statSync:e=>d(l(a(e))),lstatSync:e=>d(u(a(e))),realpathSync(e){let t=a(e);if(!c(t))throw N(`ENOENT`,t,`realpath`);return t},readdirSync(t){return De(e,n,a(t))},copyFileSync(e,t){s(a(t),o(a(e)))},cpSync(e,t){p(a(e),a(t))},chmodSync(e){let t=a(e);if(!c(t))throw N(`ENOENT`,t,`chmod`)},mkdtempSync(t){return e.mkdtemp(a(t))}},h=Object.assign(m,te());Te(h,r),O(h,Se);let g=h.existsSync;return h.existsSync=e=>{try{return g(e)}catch{return!1}},h}var je=class{_events=new Map;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}addListener(e,t){return this.on(e,t)}off(e,t){let n=this._events.get(e);if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1),n.length===0&&this._events.delete(e)}return this}removeListener(e,t){return this.off(e,t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}removeAllListeners(e){return e===void 0?this._events.clear():this._events.delete(e),this}listenerCount(e){return this._events.get(e)?.length??0}listeners(e){return[...this._events.get(e)??[]]}};const Me=Object.assign(je,{EventEmitter:je,default:je});function Ne(e){let t=e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;if(e==null)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},n=(e,t,n)=>t===void 0?`${e(`Error:`)} ${n}\n`:t===``?`${e(n)}\n`:`${e(`${t}:`)} ${n}\n`,r=(t,n)=>t===void 0?`${e.color.yellow(`Warning:`)} ${n}\n`:t===``?`${e.color.yellow(n)}\n`:`${e.color.yellow(`${t}:`)} ${n}\n`;return{die(r,i){let a=typeof i==`number`?i:i?.exitCode??1,o=typeof i==`object`&&i&&`prefix`in i?i.prefix:void 0,s=t(r);throw e.writeStderr(n(e.color.red,o,s)),e.exit(a),Error(`unreachable`)},out(t){if(typeof t==`string`){e.writeStdout(t.endsWith(`
2
2
  `)?t:`${t}\n`);return}try{e.writeStdout(`${JSON.stringify(t,null,2)}\n`)}catch{e.writeStdout(`${String(t)}\n`)}},warn(n,i){let a=typeof i==`object`&&i&&`prefix`in i?i.prefix:void 0;e.writeStderr(r(a,t(n)))},help(t){throw e.writeStdout(t.endsWith(`
3
3
  `)?t:`${t}\n`),e.exit(0),Error(`unreachable`)}}}const P={reset:`\x1B[0m`,green:`\x1B[32m`,red:`\x1B[31m`,yellow:`\x1B[33m`,gray:`\x1B[90m`,bold:`\x1B[1m`,cyan:`\x1B[36m`,dim:`\x1B[2m`};function Pe(e){let t=e.isTTY&&!e.noColor,n=e=>n=>t?`${e}${n}${P.reset}`:String(n);return{enabled:t,green:n(P.green),red:n(P.red),yellow:n(P.yellow),gray:n(P.gray),bold:n(P.bold),cyan:n(P.cyan),dim:n(P.dim)}}const Fe=/\u001b\[[0-9;]*m/g;function Ie(e){return e.replace(Fe,``)}function Le(e){return Ie(e).length}function Re(e,t){let n=String(e??``);return t<=0?``:Le(n)<=t?n:t<=1?n.slice(0,t):`${Ie(n).slice(0,t-1)}…`}function ze(e,t){let n=String(e??``),r=Le(n);return r===t?n:r>t?Re(n,t):n+` `.repeat(t-r)}function Be(e,t){if(!e.length)return``;let n=Math.max(...e.map(e=>e.length)),r=[];for(let i=0;i<n;i++)if(t&&t[i]!==void 0)r[i]=t[i];else{let t=0;for(let n of e){let e=i<n.length?String(n[i]??``):``;t=Math.max(t,Le(e))}r[i]=t}return e.map(e=>r.map((t,n)=>ze(n<e.length?String(e[n]??``):``,t)).join(` `).replace(/\s+$/,``)).join(`
4
4
  `)}function Ve(e){return e instanceof Date?e:new Date(e)}function He(e){return e<10?`0${e}`:String(e)}function Ue(e,t=`short`){let n=Ve(e);if(Number.isNaN(n.getTime()))return String(e);if(t===`iso`)return n.toISOString();if(t===`locale`)return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(n);if(t===`human`){let e=Date.now()-n.getTime(),t=Math.abs(e);if(t<6e4)return e>=0?`just now`:`in a moment`;let r=(t,n)=>e>=0?`${t} ${n}${t===1?``:`s`} ago`:`in ${t} ${n}${t===1?``:`s`}`;return t<36e5?r(Math.round(t/6e4),`minute`):t<864e5?r(Math.round(t/36e5),`hour`):t<26298e5?r(Math.round(t/864e5),`day`):t<315576e5?r(Math.round(t/26298e5),`month`):r(Math.round(t/315576e5),`year`)}return`${n.getFullYear()}-${He(n.getMonth()+1)}-${He(n.getDate())}`}const We={trunc:Re,col:ze,table:Be,date:Ue};var F=class extends Error{actual;expected;operator;generatedMessage;code;constructor(e={}){let t=!e.message;super(e.message||`${Ge(e.actual)} ${e.operator||`!=`} ${Ge(e.expected)}`),this.name=`AssertionError`,this.actual=e.actual,this.expected=e.expected,this.operator=e.operator||``,this.generatedMessage=t,this.code=`ERR_ASSERTION`}};function Ge(e){if(typeof e==`string`)return JSON.stringify(e);if(e==null)return String(e);if(typeof e==`object`)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function I(e,t){return e instanceof Error?e:typeof e==`string`?new F({message:e}):t()}function Ke(e,t,n,r){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Je(e[i],t[i],n,r))return!1;return!0}function qe(e,t,n,r){let i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(let a of i)if(!Object.prototype.hasOwnProperty.call(t,a)||!Je(Reflect.get(e,a),Reflect.get(t,a),n,r))return!1;return!0}function Je(e,t,n,r){if((n?Object.is(e,t):e===t)||!n&&e==t)return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;let i=e,a=t;return n&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(a)?!1:r.get(i)===a||(r.set(i,a),Array.isArray(e)===Array.isArray(t)?Array.isArray(e)&&Array.isArray(t)?Ke(e,t,n,r):qe(i,a,n,r):!1)}function Ye(e,t){try{if(e instanceof t)return!0}catch{}try{return!!t(e)}catch{return!1}}function Xe(e,t){for(let[n,r]of Object.entries(t)){let t=Reflect.get(e,n);if(r instanceof RegExp){if(typeof t!=`string`||!r.test(t))return!1}else if(t!==r)return!1}return!0}function Ze(e,t){if(t===void 0)return!0;if(t instanceof RegExp){let n=e instanceof Error?e.message:String(e);return t.test(n)}return typeof t==`function`?Ye(e,t):t&&typeof t==`object`?!e||typeof e!=`object`?!1:Xe(e,t):!1}function Qe(e){let t=(e,t)=>{if(!e)throw I(t,()=>new F({message:`The expression evaluated to a falsy value`,actual:e,expected:!0,operator:`==`}))},n=((e,n)=>t(e,n)),r=(e,t,n)=>{if(!Object.is(e,t))throw I(n,()=>new F({actual:e,expected:t,operator:`strictEqual`}))},i=(t,n,i)=>{if(e){r(t,n,i);return}if(t!=n)throw I(i,()=>new F({actual:t,expected:n,operator:`==`}))},a=(e,t,n)=>{if(Object.is(e,t))throw I(n,()=>new F({actual:e,expected:t,operator:`notStrictEqual`}))},o=(t,n,r)=>{if(e){a(t,n,r);return}if(t==n)throw I(r,()=>new F({actual:t,expected:n,operator:`!=`}))},s=(e,t,n)=>{if(!Je(e,t,!0,new WeakMap))throw I(n,()=>new F({actual:e,expected:t,operator:`deepStrictEqual`}))},c=(t,n,r)=>{if(e){s(t,n,r);return}if(!Je(t,n,!1,new WeakMap))throw I(r,()=>new F({actual:t,expected:n,operator:`deepEqual`}))},l=(e,t,n)=>{if(Je(e,t,!0,new WeakMap))throw I(n,()=>new F({actual:e,expected:t,operator:`notDeepStrictEqual`}))};return n.ok=t,n.equal=i,n.notEqual=o,n.strictEqual=r,n.notStrictEqual=a,n.deepEqual=c,n.deepStrictEqual=s,n.notDeepEqual=(t,n,r)=>{if(e){l(t,n,r);return}if(Je(t,n,!1,new WeakMap))throw I(r,()=>new F({actual:t,expected:n,operator:`notDeepEqual`}))},n.notDeepStrictEqual=l,n.throws=(e,t,n)=>{let r,i=!1;try{e()}catch(e){r=e,i=!0}if(!i)throw I(typeof t==`string`?t:n,()=>new F({message:`Missing expected exception`,operator:`throws`}));if(!(typeof t==`string`||t instanceof Error)&&!Ze(r,t))throw I(n,()=>new F({message:`Got unwanted exception`,actual:r,operator:`throws`}))},n.doesNotThrow=(e,t)=>{try{e()}catch(e){throw I(t,()=>new F({message:`Got unwanted exception`,actual:e,operator:`doesNotThrow`}))}},n.fail=e=>{throw I(e,()=>new F({message:`Failed`,operator:`fail`}))},n.AssertionError=F,n}const $e=Qe(!0);$e.strict=$e;const et=Qe(!1);et.strict=$e;function tt(e,t){let n=globalThis.Buffer;if(!n)throw Error(`crypto.createHash: Buffer is unavailable in this environment`);return t?n.from(e,t):n.from(e)}var nt=class{_events=new Map;closeScheduled=!1;writable=!0;readable=!0;on(e,t){let n=this._events.get(e);return n?n.push(t):this._events.set(e,[t]),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this._events.get(e);if(n){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}return this}emit(e,...t){let n=this._events.get(e);if(!n||n.length===0)return!1;for(let e of[...n])e(...t);return!0}pipe(e){return this.on(`data`,t=>e.write(t)),this.once(`end`,()=>e.end()),e}closeOnDestroy(){return this.closeScheduled?this:(this.closeScheduled=!0,queueMicrotask(()=>this.emit(`close`)),this)}removeListener(e,t){return this.off(e,t)}removeAllListeners(){return this._events.clear(),this}},rt=class extends nt{read(){return null}destroy(){return this.closeOnDestroy()}},it=class extends nt{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}destroy(){return this.closeOnDestroy()}},at=class extends nt{write(e,t,n){return n&&queueMicrotask(n),!0}end(e){return e&&queueMicrotask(e),this}read(){return null}destroy(){return this.closeOnDestroy()}};const ot={Readable:rt,Writable:it,Transform:at,PassThrough:class extends at{},Stream:nt};function st(e,t){return Object.assign(TypeError(t),{code:e})}const ct=e=>e.startsWith(`--`)&&e.length>2,lt=e=>/^-[^-]/.test(e);function ut(e,t,n){let r=[];for(let i=1;i<e.length;i++)if(t[n(e[i])]?.type!==`string`||i===e.length-1)r.push(`-${e[i]}`);else{r.push(`-${e.slice(i)}`);break}return r}function dt(e,t,n){let r=[],i=[...e],a=-1,o=0,s=(e,t,n,r)=>({kind:`option`,name:e,rawName:t,index:a,value:n,inlineValue:r}),c=e=>t[e]?.type===`string`;for(;i.length>0;){let e=i.shift(),l=i[0];if(o>0?o--:a++,e===`--`){r.push({kind:`option-terminator`,index:a});for(let e of i)r.push({kind:`positional`,index:++a,value:e});break}if(lt(e)&&e.length===2){let t=n(e[1]);c(t)&&l!==void 0?(i.shift(),r.push(s(t,e,l,!1)),a++):r.push(s(t,e,void 0,void 0));continue}if(lt(e)){let a=n(e[1]);if(c(a))r.push(s(a,`-${e[1]}`,e.slice(2),!0));else{let r=ut(e,t,n);i.unshift(...r),o=r.length}continue}if(ct(e)){let t=e.indexOf(`=`);if(t!==-1){r.push(s(e.slice(2,t),e.slice(0,t),e.slice(t+1),!0));continue}let n=e.slice(2);c(n)&&l!==void 0?(i.shift(),r.push(s(n,e,l,!1)),a++):r.push(s(n,e,void 0,void 0));continue}r.push({kind:`positional`,index:a,value:e})}return r}function ft(e,t){let n=t?.short?`'-${t.short}, --${e.name}'`:`'--${e.name}'`;if(!t)throw st(`ERR_PARSE_ARGS_UNKNOWN_OPTION`,`Unknown option '${e.rawName}'${e.rawName.startsWith(`--`)?``:`. To specify a positional argument starting with a '-', place it at the end of the command after '--', as in '-- "-"'`}`);if(t.type===`string`&&typeof e.value!=`string`)throw st(`ERR_PARSE_ARGS_INVALID_OPTION_VALUE`,`Option ${n.replace(/'$/,` <value>'`)} argument missing`);if(t.type===`boolean`&&e.value!==void 0)throw st(`ERR_PARSE_ARGS_INVALID_OPTION_VALUE`,`Option ${n} does not take an argument`);let r=e.value!==void 0&&e.value.length>1&&e.value[0]===`-`;if(t.type===`string`&&e.inlineValue===!1&&r)throw st(`ERR_PARSE_ARGS_INVALID_OPTION_VALUE`,`Option '${e.rawName}' argument is ambiguous.\nDid you forget to specify the option argument for '${e.rawName}'?\nTo specify an option argument starting with a dash use '${e.rawName.startsWith(`--`)?`${e.rawName}=-XYZ`:`--${e.name}=-XYZ' or '${e.rawName}-XYZ`}'.`)}function pt(e,t,n,r){if(!r){e[t]=n;return}let i=e[t];e[t]=Array.isArray(i)?[...i,n]:[n]}function mt(e,t,n){let r=e.slice(3);return n&&e.startsWith(`no-`)?{name:r,negated:!0}:{name:e,negated:!1}}function ht(e,t,n,r,i){let{name:a,negated:o}=mt(t.name,n,i);t.name=a;let s=n[a];r&&ft(t,o&&s?.type!==`boolean`?void 0:s),pt(e,a,o?!1:t.value??!0,s?.multiple===!0)}function gt(e={},t=()=>[]){let n=e.args??t(),r=e.options??{},i=e.strict??!0,a=e.allowPositionals??!i,o=e.allowNegative??!1,s=e=>Object.keys(r).find(t=>r[t].short===e)??e,c=Object.create(null),l=[],u=dt(n,r,s);for(let e of u){if(e.kind===`positional`){if(i&&!a)throw st(`ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL`,`Unexpected argument '${e.value}'. This command does not take positional arguments`);l.push(e.value);continue}e.kind===`option`&&ht(c,e,r,i,o)}for(let[e,t]of Object.entries(r))t.default!==void 0&&c[e]===void 0&&(c[e]=t.default);return e.tokens?{values:c,positionals:l,tokens:u}:{values:c,positionals:l}}const _t=Symbol.for(`nodejs.util.inspect.custom`),vt=Symbol.for(`nodejs.util.promisify.custom`);function yt(e){return`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`)}'`}function bt(e){if(e===null)return`null`;let t=typeof e;if(t===`string`)return yt(e);if(t===`number`)return Object.is(e,-0)?`-0`:String(e);if(t===`bigint`)return`${String(e)}n`;if(t===`boolean`||t===`undefined`)return String(e);if(t===`symbol`)return e.toString();if(t===`function`){let t=e.name;return t?`[Function: ${t}]`:`[Function (anonymous)]`}return null}function xt(e){return e instanceof RegExp?e.toString():e instanceof Date?Number.isNaN(e.getTime())?`Invalid Date`:e.toISOString():e instanceof Error?e.stack||`${e.name}: ${e.message}`:null}function St(e,t,n){if(Array.isArray(e))return e.length===0?`[]`:`[ ${e.map(e=>Ct(e,t+1,n)).join(`, `)} ]`;if(e instanceof Map){let r=[...e].map(([e,r])=>`${Ct(e,t+1,n)} => ${Ct(r,t+1,n)}`);return`Map(${e.size}) {${r.length?` ${r.join(`, `)} `:``}}`}if(e instanceof Set){let r=[...e].map(e=>Ct(e,t+1,n));return`Set(${e.size}) {${r.length?` ${r.join(`, `)} `:``}}`}let r=Object.keys(e),i=e.constructor?e.constructor.name:``,a=i&&i!==`Object`?`${i} `:``;return r.length===0?`${a}{}`:`${a}{ ${r.map(r=>`${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(r)?r:yt(r)}: ${Ct(e[r],t+1,n)}`).join(`, `)} }`}function Ct(e,t,n){let r=bt(e);if(r!==null)return r;let i=e,a=xt(i);if(a!==null)return a;let o=i[_t];if(typeof o==`function`)try{return String(o.call(i,n.maxDepth,n.opts))}catch{}if(n.seen.has(e))return`[Circular *1]`;if(n.maxDepth!==null&&t>n.maxDepth)return Array.isArray(e)?`[Array]`:`[Object]`;n.seen.add(e);try{return St(i,t,n)}finally{n.seen.delete(e)}}function wt(e,t={}){let n=t.depth===void 0?2:t.depth;return Ct(e,0,{seen:new Set,maxDepth:n,opts:t})}function Tt(e,t,n,r){if(e===`%%`)return`%`;if(n.i>=t.length)return e;let i=t[n.i];switch(e){case`%s`:return n.i++,typeof i==`string`?i:typeof i==`bigint`?`${String(i)}n`:i==null||typeof i==`number`||typeof i==`boolean`?String(i):wt(i,{depth:r.depth===void 0?2:r.depth});case`%d`:return n.i++,typeof i==`bigint`?`${String(i)}n`:Number.isNaN(Number(i))?`NaN`:String(Number(i));case`%i`:return n.i++,typeof i==`bigint`?`${String(i)}n`:String(Number.parseInt(i,10));case`%f`:return n.i++,String(typeof i==`bigint`?i:Number.parseFloat(i));case`%j`:n.i++;try{return JSON.stringify(i)??`undefined`}catch{return`[Circular]`}case`%o`:return n.i++,wt(i,{depth:4});case`%O`:return n.i++,wt(i,{depth:null});case`%c`:return n.i++,``;default:return e}}function Et(e,...t){let n=t[0];if(typeof n!=`string`)return t.map(e=>typeof e==`string`?e:wt(e)).join(` `);let r={i:1},i=n.replace(/%[sdifjoOc%]/g,n=>Tt(n,t,r,e));for(;r.i<t.length;r.i++){let e=t[r.i];i+=` ${typeof e==`string`?e:wt(e)}`}return i}function Dt(...e){return Et({},...e)}function Ot(e,t){if(e==null)throw TypeError(`The constructor to "inherits" must not be null or undefined`);if(t==null)throw TypeError(`The super constructor to "inherits" must not be null or undefined`);if(t.prototype===void 0)throw TypeError(`The super constructor to "inherits" must have a prototype`);e.super_=t,Object.setPrototypeOf(e.prototype,t.prototype)}function kt(e){if(typeof e!=`function`)throw TypeError(`The "original" argument must be of type function`);let t=e[vt];if(t){if(typeof t!=`function`)throw TypeError(`The [util.promisify.custom] property must be of type function`);return t}function n(...t){return new Promise((n,r)=>{e.call(this,...t,(e,...t)=>{if(e){r(e);return}n(t.length>1?t:t[0])})})}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)),n}function At(e){return function(t,n,r){if(typeof t!=`function`)throw TypeError(`The "fn" argument must be of type function`);let i=!1;function a(...a){return i||(i=!0,e(r?`[${r}] DeprecationWarning: ${n}`:`DeprecationWarning: ${n}`)),new.target?Reflect.construct(t,a,new.target):t.apply(this,a)}return Object.setPrototypeOf(a,Object.getPrototypeOf(t)),t.prototype&&(a.prototype=t.prototype),a}}const jt=wt;jt.custom=_t;const Mt=kt;Mt.custom=vt;function Nt(e,t=()=>[]){return{parseArgs:e=>gt(e,t),format:Dt,formatWithOptions:Et,inspect:jt,inherits:Ot,promisify:Mt,deprecate:At(e)}}const Pt=Nt(()=>{});let Ft=1;function It(e){if(typeof e==`string`)return e;if(ArrayBuffer.isView(e)){let t=e;return new TextDecoder().decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}return e==null?``:String(e)}function Lt(e,t,n){return Object.assign(TypeError(`The "${e}" argument must be of type ${t}. Received ${n===null?`null`:Array.isArray(n)?`array`:typeof n}`),{code:`ERR_INVALID_ARG_TYPE`})}function Rt(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))throw Lt(`options.env`,`object`,e);let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(typeof r!=`string`)throw Lt(`options.env[${n}]`,`string`,r);t[n]=r}return t}function zt(e){if(e!==void 0){if(typeof e==`string`)return e;if(typeof e==`object`&&e&&typeof e.href==`string`)try{return C.fileURLToPath(e.href)}catch{throw Lt(`options.cwd`,`string or an instance of URL (file:)`,e)}throw Lt(`options.cwd`,`string or an instance of URL`,e)}}function Bt(e,t){return t===void 0||t===`utf8`||t===`utf-8`?e:t===`buffer`||t===null?tt(e):tt(e).toString(t)}function Vt(e,t){if(e.length===0)return Bt(``,t);if(typeof e[0]==`string`)return e.join(``);let n=globalThis.Buffer;return n?n.concat(e):e[0]}function Ht(e,t,n){t.length>0&&e.emit(`data`,Bt(t,n)),e.readable=!1,e.emit(`end`)}function Ut(e){let t=e=>{typeof e==`function`&&queueMicrotask(e)};return{writable:!0,write(n,r,i){return e.stdin.write(It(n)),t(typeof r==`function`?r:i),!0},end(n,r,i){n!==void 0&&typeof n!=`function`&&e.stdin.write(It(n)),e.stdin.end(),this.writable=!1,t(typeof n==`function`?n:typeof r==`function`?r:i)}}}var Wt=class extends je{stdout;stderr;stdin;pid;exitCode=null;signalCode=null;killed=!1;spawnfile;spawnargs;handle;constructor(e,t,n,r){super(),this.handle=e,this.pid=Ft++,this.spawnfile=n,this.spawnargs=r,this.stdout=new rt,this.stderr=new rt,this.stdin=Ut(e),e.done.then(e=>this.finish(e,t),e=>this.emit(`error`,e instanceof Error?e:Error(String(e))))}finish(e,t){Ht(this.stdout,e.stdout,t),Ht(this.stderr,e.stderr,t),this.exitCode=e.exitCode;let n=this.killed?null:e.exitCode,r=this.killed?this.signalCode:null;this.emit(`exit`,n,r),this.emit(`close`,n,r)}kill(e=`SIGTERM`){return this.killed=!0,this.signalCode=e,this.handle.kill(e).catch(()=>{}),!0}};function Gt(e){let t=(t,n,r)=>{if(!e)throw Error(`child_process.${t} is not available in this browser realm (no synchronous bridge — the page has no controlling Service Worker). Use the async form instead: await promisify(${t.replace(/Sync$/,``)})(…).`);return e.run(n,r)},n=e=>{let t=zt(e.cwd),n=Rt(e.env);return{...e.input===void 0?{}:{input:It(e.input)},...e.timeout===void 0?{}:{timeout:e.timeout},...t===void 0?{}:{cwd:t},...n===void 0?{}:{env:n}}},r=(e,r,i,a)=>{let o=a.encoding===void 0?`buffer`:a.encoding,s=t(e,r,n(a)),c=Bt(s.stdout,o),l=Bt(s.stderr,o);if(s.exitCode===0)return c;throw Object.assign(Error(`Command failed: ${i}\n${s.stderr}`),{status:s.exitCode,signal:null,stdout:c,stderr:l,output:[null,c,l],pid:Ft++})},i=(e,t)=>({args:Array.isArray(e)?e:[],options:(Array.isArray(e)?t:e)??{}});return{execSync:(e,t={})=>r(`execSync`,e,e,t),execFileSync:(e,t,n)=>{let{args:a,options:o}=i(t,n),s=[e,...a];return r(`execFileSync`,s,s.join(` `),o)},spawnSync:(e,r,a)=>{let{args:o,options:s}=i(r,a),c=s.encoding===void 0?`buffer`:s.encoding,l=Ft++,u=s.shell?`${e}${o.length?` ${o.join(` `)}`:``}`:[e,...o],d;try{d=t(`spawnSync`,u,n(s))}catch(e){if(e instanceof TypeError)throw e;let t=Bt(``,c);return{pid:l,status:null,signal:null,stdout:t,stderr:t,output:[null,t,t],error:e instanceof Error?e:Error(String(e))}}let f=Bt(d.stdout,c),p=Bt(d.stderr,c);return{pid:l,status:d.exitCode,signal:null,stdout:f,stderr:p,output:[null,f,p]}}}}function Kt(e,t){let n=(t,n,r,i,a)=>{let o=zt(n.cwd),s=Rt(n.env),c={...o===void 0?{}:{cwd:o},...s===void 0?{}:{env:s}},l=e.start(t,c),u=new Wt(l,r,i,a);return n.input!==void 0&&u.stdin.write(It(n.input)),queueMicrotask(()=>l.stdin.end()),u},r=(e,t,n,r)=>{if(typeof r!=`function`)return;let i=[],a=[];e.stdout.on(`data`,e=>i.push(e)),e.stderr.on(`data`,e=>a.push(e)),e.once(`error`,e=>r(e,Vt(i,t),Vt(a,t))),e.once(`close`,(o,s)=>{let c=Vt(i,t),l=Vt(a,t);if(o===0){r(null,c,l);return}r(Object.assign(Error(`Command failed: ${n}\n${It(l)}`),{code:o===null?void 0:o,killed:e.killed,signal:s??null,cmd:n}),c,l)})},i=(e,t,i)=>{let a=typeof t==`function`?t:i,o=t&&typeof t==`object`?t:{},s=o.encoding===void 0?`utf8`:o.encoding,c=n(e,o,s,e,[]);return r(c,s,e,a),c},a=(e,t,i,a)=>{let o=[],s={},c;Array.isArray(t)?(o=t,typeof i==`function`?c=i:(s=i??{},c=typeof a==`function`?a:void 0)):typeof t==`function`?c=t:t&&typeof t==`object`&&(s=t,c=typeof i==`function`?i:void 0);let l=s.encoding===void 0?`utf8`:s.encoding,u=[e,...o],d=n(u,s,l,e,o);return r(d,l,u.join(` `),c),d},o=(e,t,r)=>{let i=[],a={};Array.isArray(t)?(i=t,a=r??{}):t&&typeof t==`object`&&(a=t);let o=a.encoding===void 0?`buffer`:a.encoding,s=a.shell?`${e}${i.length?` ${i.join(` `)}`:``}`:[e,...i];return n(s,a,o,e,i)},s=(e,t)=>new Promise((n,r)=>{i(e,t,(e,t,i)=>{if(e){r(Object.assign(e,{stdout:t,stderr:i}));return}n({stdout:t,stderr:i})})}),c=(e,t,n)=>new Promise((r,i)=>{a(e,Array.isArray(t)?t:[],Array.isArray(t)?n:t,(e,t,n)=>{if(e){i(Object.assign(e,{stdout:t,stderr:n}));return}r({stdout:t,stderr:n})})}),l=e=>()=>{throw Error(`child_process.${e} is not available in the browser realm`)},u=Gt(t),d=(e,t)=>{Object.defineProperty(e,vt,{value:t,enumerable:!1,configurable:!0})};return d(i,s),d(a,c),{exec:i,execFile:a,spawn:o,execSync:u.execSync,spawnSync:u.spawnSync,execFileSync:u.execFileSync,fork:l(`fork`),ChildProcess:Wt}}function qt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Jt={exports:{}};
@@ -28,6 +28,6 @@ for (var __vm_i = 0; __vm_i < __vm_fns.length; __vm_i++) {
28
28
  `).slice(3).join(`
29
29
  `);if(!a)return;let o=a.endsWith(`
30
30
  `)?a:`${a}\n`;t(n>0?`${` `.repeat(n)}${o}`:o)}function Go(e,t,n){let r=zo(n);if(e.has(r)){t(`Label '${r}' already exists for console.time()`);return}e.set(r,Bo())}function Ko(e,t,n,r){let i=zo(r),a=e.get(i);if(a===void 0){t(`No such label '${i}' for console.timeEnd()`);return}e.delete(i),n(`${i}: ${Vo(Bo()-a)}`)}function qo(e,t,n,r,i){let a=zo(r),o=e.get(a);if(o===void 0){t(`No such label '${a}' for console.timeLog()`);return}let s=`${a}: ${Vo(Bo()-o)}`;i.length===0?n(s):n(s,...i)}function Jo(e,t,n){let r=zo(n),i=(e.get(r)??0)+1;e.set(r,i),t(`${r}: ${i}`)}function Yo(e,t,n){let r=zo(n);if(!e.has(r)){t(`Count for '${r}' does not exist`);return}e.set(r,0)}function Xo(e,t,n){n.length>0&&t(...n),e.depth+=1}function Zo(e){e.depth>0&&--e.depth}function Qo(e,t){let n=new Map,r=new Map,i={depth:0},a=(...t)=>Ho(e,i.depth,t),o=(...e)=>Ho(t,i.depth,e),s=(...e)=>Xo(i,a,e);return{log:a,info:a,debug:a,dirxml:a,table:a,warn:o,error:o,dir:(e,t)=>a(e),clear:()=>void 0,group:s,groupCollapsed:s,groupEnd:()=>Zo(i),assert:(e,...t)=>Uo(o,e,t),trace:(...e)=>Wo(o,t,i.depth,e),time:e=>Go(r,o,e),timeEnd:e=>Ko(r,o,a,e),timeLog:(e,...t)=>qo(r,o,a,e,t),count:e=>Jo(n,a,e),countReset:e=>Yo(n,o,e)}}function $o(e,t){return e.process===void 0?(e.process=t,()=>{e.process===t&&delete e.process}):()=>void 0}function es(e,t,n){return Object.assign(new je,{fd:e,write:e=>(t(e),!0),end:()=>void 0,isTTY:n})}function ts(e,t,n){let r=!!e.env?.NO_COLOR,i=!1,a,o,c=e=>{i=!0,o=e,a=e},l=rs(e.stdin??``,c),u=wo(e.argv),d=es(1,t,!r),f=es(2,n,!r);return{processShim:{argv:u,env:e.env,versions:{node:s},version:`v${s}`,platform:`linux`,arch:`x64`,cwd:()=>e.cwd,get exitCode(){return a},set exitCode(e){a=Io(e)},exit:(...e)=>{if(e.length===0){let e=Mo(a);throw c(e),new jo(e)}a=Io(e[0]);let t=Mo(a);throw c(t),new jo(t)},stdin:l,stdout:d,stderr:f},getDidCallProcessExit:()=>i,getExitCode:()=>Mo(i?o:a),recordExit:c}}var ns=class extends ot.Stream{isTTY=!1;fd=0;consumed=!1;flowScheduled=!1;paused=!1;buffer;onExit;constructor(e,t){super(),this.buffer=e,this.onExit=t}read(){return this.consumed?null:(this.consumed=!0,this.buffer.length>0?this.buffer:null)}toString(){return this.buffer}setEncoding(e){return this}pause(){return this.paused=!0,this}resume(){return this.paused=!1,this.scheduleFlow(),this}on(e,t){return super.on(e,t),e===`data`&&this.scheduleFlow(),this}addListener(e,t){return this.on(e,t)}once(e,t){return super.once(e,t),e===`data`&&this.scheduleFlow(),this}scheduleFlow(){this.flowScheduled||(this.flowScheduled=!0,queueMicrotask(()=>this.flush()))}flush(){if(this.paused){this.flowScheduled=!1;return}try{this.consumed||(this.consumed=!0,this.buffer.length>0&&this.emit(`data`,this.buffer)),this.readable=!1,this.emit(`end`),this.emit(`close`)}catch(e){if(e instanceof jo){this.onExit(e.code);return}throw e}}[Symbol.asyncIterator](){return{next:async()=>this.consumed?{value:void 0,done:!0}:(this.consumed=!0,{value:this.buffer,done:!1})}}};function rs(e,t){return new ns(e,t)}function is(e){if(e===``)return[];let t=e.split(`
31
- `);return t[t.length-1]===``&&t.pop(),t.map(e=>e.endsWith(`\r`)?e.slice(0,-1):e)}function as(e){if(typeof e==`string`)return e;if(e&&typeof e.read==`function`){let t=e.read();return typeof t==`string`?t:``}return``}function os(e){return new TextDecoder(`utf-8`).decode(ce(e))}function ss(e){if(e&&typeof e.write==`function`)return e}var cs=class extends je{terminal=!1;lines;cursor=0;closed=!1;flushScheduled=!1;output;onExit;constructor(e,t,n){super(),this.lines=is(os(as(e))),this.output=t??n.output,this.onExit=n.onExit}on(e,t){return super.on(e,t),e===`line`&&this.scheduleFlush(),this}once(e,t){return super.once(e,t),e===`line`&&this.scheduleFlush(),this}pause(){return this}resume(){return this}close(){this.closed||(this.closed=!0,this.emit(`close`))}question(e,t,n){let r=typeof t==`function`?t:typeof n==`function`?n:void 0;this.output?.write(String(e));let i=this.cursor<this.lines.length?this.lines[this.cursor++]:``;if(r){queueMicrotask(()=>this.runHandler(()=>r(i)));return}return Promise.resolve(i)}[Symbol.asyncIterator](){return{next:async()=>!this.closed&&this.cursor<this.lines.length?{value:this.lines[this.cursor++],done:!1}:(this.close(),{value:void 0,done:!0})}}scheduleFlush(){this.flushScheduled||this.closed||(this.flushScheduled=!0,queueMicrotask(()=>this.flush()))}flush(){this.flushScheduled=!1,this.runHandler(()=>{for(;!this.closed&&this.cursor<this.lines.length;)this.emit(`line`,this.lines[this.cursor++]);this.close()})}runHandler(e){try{e()}catch(e){if(e instanceof jo&&this.onExit){this.closed=!0,this.onExit(e.code);return}throw e}}};function ls(e){let t=(t,n)=>{let r,i;if(t&&typeof t==`object`&&`input`in t){let e=t;r=e.input,i=ss(e.output)}else r=t,i=ss(n);if(r==null)throw TypeError(`readline.createInterface: an 'input' stream is required`);return new cs(r,i,e)},n=(...e)=>{let t=e[e.length-1];return typeof t==`function`&&queueMicrotask(()=>t()),!0},r={createInterface:t,Interface:cs,emitKeypressEvents:()=>void 0,cursorTo:n,moveCursor:n,clearLine:n,clearScreenDown:n};return{...r,promises:r}}var us=class extends Error{status;statusText;url;body;constructor(e,t,n,r){let i=typeof r==`string`&&r?`: ${r.slice(0,200)}`:r&&typeof r==`object`?`: ${ds(r).slice(0,200)}`:``;super(`HTTP ${e} ${t} ${n}${i}`),this.status=e,this.statusText=t,this.url=n,this.body=r,this.name=`HttpError`}};function ds(e){try{return JSON.stringify(e)}catch{return String(e)}}function fs(e){return new Promise(t=>setTimeout(t,e))}function ps(e,t){let n=[];for(let[e,r]of Object.entries(t))if(r!=null){if(Array.isArray(r))for(let t of r)t!=null&&n.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`);else n.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(r))}`)}return n.length===0?e:e+(e.includes(`?`)?`&`:`?`)+n.join(`&`)}function ms(e,t,n){let r;return r=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:e?`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`:t,n?ps(r,n):r}function hs(e,t){let n={};if(e)for(let[t,r]of Object.entries(e))n[t]=r;if(t)for(let[e,r]of Object.entries(t))n[e]=r;return n}function gs(e){if(!e)return!1;let t=e.toLowerCase();return t.startsWith(`application/json`)||/[+/]json(;|$|\s)/.test(t)}function _s(e){if(!e)return null;let t=e.trim();if(!t)return null;if(/^\d+(\.\d+)?$/.test(t)){let e=Number(t);if(Number.isFinite(e)&&e>=0)return Math.round(e*1e3)}let n=Date.parse(t);if(Number.isFinite(n)){let e=n-Date.now();return e>0?e:0}return null}async function vs(e){if(gs(e.headers.get(`content-type`))){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}return e.text()}function ys(e,t){if(e!=null)return typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<`u`&&e instanceof Blob||typeof FormData<`u`&&e instanceof FormData||typeof URLSearchParams<`u`&&e instanceof URLSearchParams||typeof ReadableStream<`u`&&e instanceof ReadableStream?e:typeof e==`object`?(Object.keys(t).some(e=>e.toLowerCase()===`content-type`)||(t[`Content-Type`]=`application/json`),JSON.stringify(e)):String(e)}function bs(e,t){return Object.keys(e).some(e=>e.toLowerCase()===t.toLowerCase())}async function xs(e,t,n){let r=await t(n);r&&!bs(e,`authorization`)&&(e.Authorization=`Bearer ${r}`)}function Ss(e,t){if(!t)return{signal:e,clearTimeout:null};let n=new AbortController,r=setTimeout(()=>n.abort(Error(`timeout`)),t),i=()=>clearTimeout(r);return e?{signal:AbortSignal.any([e,n.signal]),clearTimeout:i}:{signal:n.signal,clearTimeout:i}}function Cs(e,t){return{body:t,headers:Object.fromEntries(e.headers.entries()),status:e.status}}async function ws(e,t){let n=await vs(e);return t?Cs(e,n):n}async function Ts(e,t){let n=await vs(e).catch(()=>null);throw new us(e.status,e.statusText,t,n)}function Es(e,t){let n=_s(e.headers.get(`retry-after`));return n===null?500*2**t:n}async function Ds(e,t,n,r){let i=null;for(let a=0;a<e.maxAttempts;a++){let{signal:o,clearTimeout:s}=Ss(r.signal,e.timeoutMs),c=o?{...n,signal:o}:n,l;try{l=await e.fetch(t,c)}finally{s?.()}if(i=l,l.ok)return ws(l,r.raw);if(!(a+1<e.maxAttempts&&e.retryOn.has(l.status)))return Ts(l,t);await e.sleep(Es(l,a))}if(i)return Ts(i,t);throw Error(`http: no attempts made for ${n.method??`GET`} ${t}`)}function Os(e){let t=e.sleep??fs;function n(n){let r=new Set(n.retry?.on??[]),i=Math.max(1,Math.trunc(n.retry?.maxAttempts??1));async function a(a,o,s={}){let c=ms(n.baseUrl,o,s.params),l=hs(n.headers,s.headers);n.token&&await xs(l,n.token,{method:a,path:o,url:c});let u=ys(s.body,l),d={method:a,headers:l};return u!==void 0&&(d.body=u),Ds({fetch:e.fetch,sleep:t,maxAttempts:i,retryOn:r,timeoutMs:n.timeoutMs},c,d,s)}return Object.freeze({get:((e,t)=>a(`GET`,e,t)),post:((e,t)=>a(`POST`,e,t)),put:((e,t)=>a(`PUT`,e,t)),patch:((e,t)=>a(`PATCH`,e,t)),delete:((e,t)=>a(`DELETE`,e,t))})}return Object.freeze({client:n})}function ks(e){let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function As(e,t,n){let r=[];t.model&&r.push(`--model`,String(t.model)),t.thinking&&r.push(`--thinking`,String(t.thinking)),t.schema&&r.push(`--schema-b64`,ks(JSON.stringify(t.schema))),t.readOnly!==void 0&&r.push(`--read-only`,Array.isArray(t.readOnly)?t.readOnly.join(`,`):String(t.readOnly));let i=t.cwd===void 0?n||`.`:String(t.cwd),a=t.allowedCommands===void 0?`*`:String(t.allowedCommands);return[`agent`,...r,i,a,String(e)]}function js(e,t){let n=t.cwd,r=async(t,r)=>{let i=r??{},a=await e.spawn(As(t,i,n)),o=typeof a.exitCode==`number`?a.exitCode:0;return{finalText:String(a.stdout??``).replace(/\n+$/,``),exitCode:o,stderr:String(a.stderr??``).replace(/\n+$/,``)}},i=(async(e,t)=>{let n=t??{},i=await r(e,n);if(i.exitCode!==0)throw Error(`agent: exited with code ${i.exitCode}${i.stderr?`: ${i.stderr}`:``}`);if(n.schema)try{return JSON.parse(i.finalText)}catch{throw Error(`agent: schema response was not valid JSON (exit ${i.exitCode}): ${i.finalText.slice(0,200)}`)}return i.finalText});return i.spawn=r,i}function $(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`&&typeof e.targetId==`string`)return e.targetId;throw TypeError(`browser: expected a tab handle or targetId string`)}function Ms(e){function t(t){return{...t,async update(n){let r={};return n.urlMatch!==void 0&&(r.urlMatch=n.urlMatch===null?null:n.urlMatch instanceof RegExp?n.urlMatch.source:n.urlMatch),n.filter!==void 0&&(r.filter=n.filter),e.call(`browser`,`wsUpdate`,[t.id,r])},async close(){return e.call(`browser`,`wsClose`,[t.id])}}}return{on(n,r={}){let i=$(n),a=r.urlMatch===void 0?void 0:r.urlMatch instanceof RegExp?r.urlMatch.source:r.urlMatch,o,s={filter(e){if(typeof e==`function`||typeof e==`string`)throw TypeError(`browser.websocket: filter must be a declarative JSON object, not a function or string`);return o=e,s},async forward(n){return t(await e.call(`browser`,`wsObserve`,[{targetId:i,urlMatch:a,filter:o,forward:n}]))}};return s},async list(){return e.call(`browser`,`wsList`,[])}}}async function Ns(e,t){if(!e&&!(t instanceof Request))return;let n=t instanceof Request?t:null,r=(e?.method??n?.method??`GET`).toUpperCase(),i={};if(e?.headers){if(e.headers instanceof Headers)e.headers.forEach((e,t)=>{i[t]=e});else if(Array.isArray(e.headers))for(let[t,n]of e.headers)i[t]=n;else Object.assign(i,e.headers)}else n&&n.headers.forEach((e,t)=>{i[t]=e});let a,o;if(r!==`GET`&&r!==`HEAD`&&e?.body!==void 0&&e?.body!==null&&e?.body!==``){let t=await Ps(e.body);a=t.body,o=t.defaultContentType}return o&&!Object.keys(i).some(e=>e.toLowerCase()===`content-type`)&&(i[`Content-Type`]=o),{method:r,headers:i,body:a}}async function Ps(e){if(typeof e==`string`)return{body:e};if(e instanceof URLSearchParams)return{body:e.toString(),defaultContentType:`application/x-www-form-urlencoded;charset=UTF-8`};if(e instanceof Blob)return{body:new Uint8Array(await e.arrayBuffer()),defaultContentType:e.type||`application/octet-stream`};if(e instanceof ArrayBuffer)return{body:new Uint8Array(e).slice(),defaultContentType:`application/octet-stream`};if(ArrayBuffer.isView(e))return{body:new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice(),defaultContentType:`application/octet-stream`};if(n(e)){let t=await r(e);return{body:t.bytes,defaultContentType:t.contentType}}throw typeof ReadableStream<`u`&&e instanceof ReadableStream?Error(`node fetch shim: ReadableStream request bodies are not supported (collect into a Uint8Array or string before calling fetch)`):Error(`node fetch shim: unsupported request body type (${Object.prototype.toString.call(e)}); use a string, Uint8Array, ArrayBuffer, Blob, FormData, or URLSearchParams`)}function Fs(e){return{findTab:t=>e.call(`browser`,`findTab`,[Ls(t)]),ensureTab:(t,n={})=>e.call(`browser`,`ensureTab`,[t,Rs(n)]),openWindow:(t,n={})=>e.call(`browser`,`openWindow`,[t,n]),windowBounds:t=>e.call(`browser`,`windowBounds`,[$(t)]),setWindowBounds:(t,n)=>e.call(`browser`,`setWindowBounds`,[$(t),n]),eval:(t,n)=>e.call(`browser`,`eval`,[$(t),Is(n,!1)]),evalAsync:(t,n)=>e.call(`browser`,`evalAsync`,[$(t),Is(n,!0)]),cookie:(t,n)=>e.call(`browser`,`cookie`,[$(t),n]),localStorage:(t,n)=>e.call(`browser`,`localStorage`,[$(t),n]),fetch:(t,n,r={})=>b(n,r).then(n=>e.call(`browser`,`evalAsync`,[$(t),n])),websocket:Ms(e)}}function Is(e,t){if(typeof e==`function`)return`(${e.toString()})()`;if(typeof e==`string`)return e;throw TypeError(`browser.eval/evalAsync: source must be a function or string`)}function Ls(e){let t={};return e.domain!==void 0&&(t.domain=e.domain),e.urlMatch!==void 0&&(t.urlMatch=e.urlMatch instanceof RegExp?e.urlMatch.source:e.urlMatch),t}function Rs(e){return e.matchUrl===void 0?{}:{matchUrl:e.matchUrl instanceof RegExp?e.matchUrl.source:e.matchUrl}}function zs(e){return{register(t){let n=null,r=e.onEvent(`computer-call`,r=>{let i=r;i.id===t.id&&Vs(e,t,i,{getStop:()=>n,setStop:e=>{n=e}})}),i=Bs(t);return e.call(`computer`,`register`,[i]).catch(()=>{}),()=>{n?.(),n=null,r(),e.call(`computer`,`unregister`,[t.id]).catch(()=>{})}}}}function Bs(e){return{id:e.id,kind:`jsh`,title:e.title??e.id,size:e.size??null,state:`live`,capabilities:e.capabilities,pid:null,...e.softKeys?{softKeys:e.softKeys}:{}}}async function Vs(e,t,n,r){let i;try{i=await Hs(e,t,n,r)}catch(e){i={error:e instanceof Error?e.message:String(e)}}try{await e.call(`computer`,`reply`,[n.requestId,i])}catch{}}async function Hs(e,t,n,r){switch(n.op){case`screenshot`:return t.screenshot(n.args[0]??{format:`jpeg`});case`text`:return t.text?t.text():null;case`input`:return await t.input(n.args[0]??[]),{ok:!0};case`exec`:if(!t.exec)throw Error(`exec is not supported`);return t.exec(String(n.args[0]??``));case`subscribe`:return Us(e,t,Number(n.args[0])||2,Number(n.args[1])||void 0,r);case`unsubscribe`:return r.getStop()?.(),r.setStop(null),{ok:!0};default:{let e=n.op;throw Error(`unknown computer op '${String(e)}'`)}}}function Us(e,t,n,r,i){if(i.getStop()?.(),!t.subscribe)throw Error(`subscribe is not supported`);let a=t.subscribe(n,n=>{e.call(`computer`,`frame`,[t.id,n]).catch(()=>{})},r);return i.setStop(()=>{try{a()}catch{}}),{ok:!0}}function Ws(e){return e===`SIGKILL`?137:e===`SIGINT`?130:143}function Gs(e,t,n,r){let i=async()=>{if(!t?.wasUsed())return;let n=t.getMutations();if(n.created.length||n.modified.length||n.deleted.length)try{await e.call(`vfs`,`flushWrites`,[n])}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[realm-exec] pre-exec sync-fs flush failed (will retry at exit): ${t}`);return}t.resetBaseline()},a=async(i=!1)=>{if(t?.wasUsed())try{let r=await e.call(`vfs`,`snapshot`,[n]);i?t.applySnapshotPreservingMutations(r):t.applySnapshot(r)}catch(e){let t=e instanceof Error?e.message:String(e);r?.(`[sync-fs] re-snapshot after exec failed: ${t}\n`)}},o=async t=>{await i();try{return await e.call(`exec`,`run`,[t])}finally{await a()}},s=async t=>{await i();try{return await e.call(`exec`,`spawn`,[t])}finally{await a()}},c=1,l=Object.assign(o,{spawn:s,start:(t,n)=>{let r=c++,o=[],s=!1,l=!1,u=!1,d,f,p=new Promise((e,t)=>{d=e,f=t}),m=()=>{if(s||u||l)return;l=!0;let c=o.length>0?o.join(``):n?.stdin,p={};c!==void 0&&(p.stdin=c),n?.stdinKind!==void 0&&(p.stdinKind=n.stdinKind),n?.args!==void 0&&(p.args=n.args),n?.cwd!==void 0&&(p.cwd=n.cwd),n?.env!==void 0&&(p.env=n.env),(async()=>{try{if(await i(),u){await a(!0);return}s=!0;let n=await e.call(`exec`,`start`,[r,t,p]);await a(!0),d(n)}catch(e){await a(!0),f(e)}})()};return{kill:t=>s?e.call(`exec`,`kill`,[r,t]):(u=!0,d({stdout:``,stderr:``,exitCode:Ws(t)}),Promise.resolve(!0)),stdin:{write:e=>{!s&&!u&&o.push(e)},end:()=>m()},done:p}}});return l.exec=l,l}const Ks=new Set([204,205,304]),qs=new Set([`content-encoding`,`transfer-encoding`,`content-length`]);function Js(e,t){let n=Ys(e.body),r=Xs(e.headers),i=Ks.has(e.status)||n.byteLength===0,a=new Response(i?null:n,{status:e.status,statusText:e.statusText,headers:r});try{Object.defineProperty(a,"url",{value:e.url||t,writable:!1,configurable:!0,enumerable:!1})}catch{}return Qs(a,n),a}function Ys(e){return e.byteLength===0?new Uint8Array:e.slice()}function Xs(e){let t=new Headers;for(let[n,r]of Object.entries(e))if(!qs.has(n.toLowerCase()))try{t.set(n,r)}catch{}return t}const Zs=Symbol(`slicc.realmBufferedBody`);function Qs(e,t){if(Zs in e)return;Object.defineProperty(e,Zs,{value:!0,configurable:!0});let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),`bodyUsed`),r=!1,i=()=>{if(r)throw TypeError(`Failed to read response body: body already used`);return r=!0,$s(e),t},a=async()=>new TextDecoder().decode(i()),o=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);Object.defineProperties(e,{bodyUsed:{configurable:!0,enumerable:!1,get(){return r?!0:n?.get?!!n.get.call(e):!1}},text:{value:a,configurable:!0},json:{value:async()=>JSON.parse(await a()),configurable:!0},arrayBuffer:{value:async()=>o(i()),configurable:!0},blob:{value:async()=>new Blob([o(i())]),configurable:!0},bytes:{value:async()=>i(),configurable:!0}})}function $s(e){try{let t=e.body;t&&!t.locked&&t.getReader()}catch{}}function ec(e){if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return new Uint8Array(e);throw TypeError(`expected an ArrayBuffer or typed array`)}function tc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function nc(e){return e==null?[]:Array.isArray(e)?e:[e]}function rc(e,t){let n=t.handle,r=new Set,i=new Set,a=!1,o=null,s=e=>{let t=e;if(!t||t.handle!==n)return;let i={reportId:t.reportId,data:tc(t.bytes)};for(let e of[...r])try{e(i)}catch{}},c=()=>{a||(a=!0,o=e.onEvent?e.onEvent(`hid-input-report`,s):null,e.call(`hid`,`subscribeInputReports`,[n]).catch(()=>{a=!1,o?.(),o=null}))},l=()=>{!a||r.size>0||(a=!1,o?.(),o=null,e.call(`hid`,`unsubscribeInputReports`,[n]).catch(()=>{}))};return{...t,open:()=>e.call(`hid`,`open`,[n]),close:()=>e.call(`hid`,`close`,[n]),sendReport:(t,r)=>e.call(`hid`,`sendReport`,[n,t,ec(r)]),sendFeatureReport:(t,r)=>e.call(`hid`,`sendFeatureReport`,[n,t,ec(r)]),receiveFeatureReport:async t=>tc((await e.call(`hid`,`receiveFeatureReport`,[n,t])).bytes),addEventListener(e,t){if(e===`inputreport`)r.add(t),c();else if(e===`disconnect`)i.add(t);else throw TypeError(`hid device: unknown event type '${String(e)}'`)},removeEventListener(e,t){e===`inputreport`?(r.delete(t),l()):e===`disconnect`&&i.delete(t)},onInputReport(e){r.add(e),c()}}}function ic(e){return{list:async()=>(await e.call(`hid`,`list`,[])).map(t=>rc(e,t)),request:async t=>{let n=(await e.call(`hid`,`request`,[nc(t)]))[0];if(!n)throw Error(`No device selected.`);return rc(e,n)}}}function ac(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var oc=class{rpc;targetId;selector;index;constructor(e,t,n,r){this.rpc=e,this.targetId=t,this.selector=n,this.index=r}evalOnElement(e){let t=`(() => { const els = document.querySelectorAll(${JSON.stringify(this.selector)}); const el = els[${this.index}]; ${e} })()`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,t])}async textContent(){return this.evalOnElement(`return el ? el.textContent : null;`)}async getAttribute(e){return this.evalOnElement(`return el ? el.getAttribute(${JSON.stringify(e)}) : null;`)}async isVisible(){return this.evalOnElement(`if (!el) return false; const s = getComputedStyle(el); if (s.display === 'none' || s.visibility === 'hidden' || s.opacity === '0') return false; const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0;`)}async boundingBox(){return this.evalOnElement(`if (!el) return null; const r = el.getBoundingClientRect(); return { x: r.x, y: r.y, width: r.width, height: r.height };`)}},sc=class{rpc;targetId;onClose;closed=!1;constructor(e,t,n){this.rpc=e,this.targetId=t,this.onClose=n}async goto(e,t){await this.rpc.call(`browser`,`navigateTab`,[this.targetId,e])}async waitForLoadState(e){await this.rpc.call(`browser`,`waitForLoadState`,[this.targetId,e??`load`])}async waitForTimeout(e){await new Promise(t=>setTimeout(t,e))}async evaluate(e,...t){let n=typeof e==`string`?e:`(${e.toString()}).apply(null, JSON.parse(${JSON.stringify(JSON.stringify(t))}))`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,n])}async screenshot(e){let t={};e?.fullPage!==void 0&&(t.fullPage=e.fullPage);let n=ac(await this.rpc.call(`browser`,`screenshotTab`,[this.targetId,t]));return e?.path&&await this.rpc.call(`vfs`,`writeFileBinary`,[e.path,n]),n}async $(e){return await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`!!document.querySelector(${JSON.stringify(e)})`])?new oc(this.rpc,this.targetId,e,0):null}async $$(e){let t=await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.querySelectorAll(${JSON.stringify(e)}).length`]),n=[];for(let r=0;r<t;r++)n.push(new oc(this.rpc,this.targetId,e,r));return n}async $$eval(e,t,...n){if(typeof t==`string`)return this.rpc.call(`browser`,`evalAsync`,[this.targetId,t]);let r=`(${t.toString()}).apply(null, [Array.from(document.querySelectorAll(${JSON.stringify(e)}))].concat(JSON.parse(${JSON.stringify(JSON.stringify(n))})))`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,r])}async content(){return this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.documentElement.outerHTML`])}async setViewportSize(e){await this.rpc.call(`browser`,`setViewport`,[this.targetId,e.width,e.height])}async close(){this.closed||(this.closed=!0,await this.rpc.call(`browser`,`closeTab`,[this.targetId]),this.onClose?.())}},cc=class{rpc;openPages=[];constructor(e){this.rpc=e}async newPage(e){let t=await this.rpc.call(`browser`,`createTab`,[`about:blank`]);e?.viewport&&await this.rpc.call(`browser`,`setViewport`,[t,e.viewport.width,e.viewport.height]);let n=new sc(this.rpc,t,()=>{let e=this.openPages.indexOf(n);e!==-1&&this.openPages.splice(e,1)});return this.openPages.push(n),n}pages(){return[...this.openPages]}async close(){let e=this.openPages.splice(0,this.openPages.length);for(let t of e)await t.close()}},lc=class{rpc;openPages=[];openContexts=[];constructor(e){this.rpc=e}async newPage(e){let t=await this.rpc.call(`browser`,`createTab`,[`about:blank`]);e?.viewport&&await this.rpc.call(`browser`,`setViewport`,[t,e.viewport.width,e.viewport.height]);let n=new sc(this.rpc,t,()=>{let e=this.openPages.indexOf(n);e!==-1&&this.openPages.splice(e,1)});return this.openPages.push(n),n}async newContext(e){let t=new cc(this.rpc);return this.openContexts.push(t),t}contexts(){return[...this.openContexts]}async close(){let e=this.openPages.splice(0,this.openPages.length);for(let t of e)await t.close();let t=this.openContexts.splice(0,this.openContexts.length);for(let e of t)await e.close()}};function uc(e){let t=async t=>new lc(e),n=async(t,n)=>new lc(e);return{chromium:{launch:t,connect:n,connectOverCDP:n},firefox:{launch:t,connect:n},webkit:{launch:t,connect:n}}}function dc(e){return{...e,time:ko,fmt:We,pool:To}}function fc(e,t){return e?.startsWith(`/`)?Ao(e):t}function pc(e){return e.includes(`require`)||e.includes(`import`)||/(?:^|[;\n}])\s*export\b/.test(e)}async function mc(e,t,n,r){return pc(t)?e.call(`module`,`buildGraph`,[t,fc(r,n),r]):{files:[],entryMap:{},edges:{},edgeErrors:{},errors:{}}}function hc(e){if(typeof e!=`object`||!e)return;let t=e;if(t.__esModule&&!Object.prototype.hasOwnProperty.call(t,`default`)&&Object.isExtensible(t))try{Object.defineProperty(t,"default",{value:t,enumerable:!1,configurable:!0})}catch{}}function gc(e){return{playwright:uc(e)}}function _c(e){let{graph:t,fsBridge:n,processShim:r,childProcess:i,nodeConsole:a,sliccyModules:o,shimmedPackages:s={},nodeReadline:l,nodeOsModule:d=Fn,nodeUtilModule:p=Pt}=e,h=new Map(t.files.map(e=>[e.path,e.cjsSource])),g=new Map(t.files.map(e=>[e.path,e.kind])),_=new Map,v=An({requireFrom:(e,t)=>T(e,t),resolveFrom:(e,t)=>w(e,t)}),y=bn(()=>{let e=r?.cwd?.();return typeof e==`string`&&e.length>0?e:`/`}),b=e=>{if(typeof e==`string`&&e.startsWith(`sliccy:`))return{hit:!0,value:bc(e,o)};let t=e.startsWith(`node:`)?e.slice(5):e,a=vc(t,{fsBridge:n,processShim:r,childProcess:i,nodeOsModule:d,nodeUtilModule:p,nodePathModule:y,nodeReadline:l,nodeModule:v});if(a.hit)return a;if(m.has(t))throw f(e,t);if(u.has(t))throw Sc(e,t);return t in s?{hit:!0,value:s[t]}:{hit:!1}},x=(e,n,r)=>{let i=b(n);if(i.hit)return i.value;let a=e?.[n];if(a)return S(a);let o=r===null?t.errors[n]:t.edgeErrors?.[r]?.[n];throw o?Error(o):yc(n)};function S(e){let n=_.get(e);if(n)return n.exports;let i=h.get(e);if(i===void 0)throw Error(`Cannot find module '${e}'`);let o={exports:{}};_.set(e,o);let s=n=>x(t.edges[e],n,e),c=[`module`,`exports`,`require`,`process`,`console`,`Buffer`,`global`],l=[o,o.exports,s,r,a,globalThis.Buffer,globalThis];return g.get(e)!==`esm`&&(c.push(`__dirname`,`__filename`),l.push(Ao(e),e)),Function(...c,i)(...l),g.get(e)===`cjs`&&hc(o.exports),o.exports}function C(e){return h.has(e)}function w(e,n){if(c(n))return n;let r=t.edges[e]?.[n];if(r)return r;let i=Ao(e);if(kn(n)){let e=Dn(i,n,C);if(e)return e}else{let e=On(i,n,C);if(e)return e}let a=t.edgeErrors?.[e]?.[n];throw a?Error(a):yc(n)}function T(e,t){let n=b(t);return n.hit?n.value:S(w(e,t))}return{require:e=>x(t.entryMap,e,null)}}function vc(e,t){let{fsBridge:n,processShim:r,childProcess:i,nodeOsModule:a,nodeUtilModule:o,nodePathModule:s,nodeReadline:c,nodeModule:l}=t;return e===`fs`||e===`fs/promises`?{hit:!0,value:n}:e===`path`?{hit:!0,value:s}:e===`crypto`?{hit:!0,value:cn}:e===`child_process`?{hit:!0,value:i}:e===`process`?{hit:!0,value:r}:e===`buffer`?{hit:!0,value:{Buffer:globalThis.Buffer}}:e===`assert`?{hit:!0,value:et}:e===`assert/strict`?{hit:!0,value:$e}:e===`util`?{hit:!0,value:o}:e===`events`?{hit:!0,value:Me}:e===`os`?{hit:!0,value:a}:e===`tty`?{hit:!0,value:In}:e===`stream`?{hit:!0,value:ot}:e===`url`?{hit:!0,value:C}:e===`zlib`?{hit:!0,value:So}:e===`vm`?{hit:!0,value:nr}:e===`readline`&&c?{hit:!0,value:c}:e===`readline/promises`&&c?{hit:!0,value:c.promises}:e===`module`&&l?{hit:!0,value:l}:{hit:!1}}function yc(e){if(e.startsWith(`.`)||e.startsWith(`/`)||e.startsWith(`node:`))return Error(`Cannot find module '${e}'`);let t=e.startsWith(`@`)?e.split(`/`).slice(0,2).join(`/`):e.split(`/`)[0];return Error(`Cannot find module '${e}' (run: ipk install ${t})`)}function bc(e,t){let n=e.slice(7);if(n===``)throw Error(`require('sliccy:'): empty sliccy: module name`);if(!Object.prototype.hasOwnProperty.call(t,n))throw Error(`require('${e}'): unknown sliccy: module '${n}'. Known names: ${Object.keys(t).sort().join(`, `)}`);return t[n]}const xc={http:` Use fetch() instead.`,https:` Use fetch() instead.`,crypto:` Use globalThis.crypto (Web Crypto API) instead.`};function Sc(e,t){return Error(`require('${e}'): Node built-in '${t}' is not available in the browser environment.${xc[t]||``}`)}async function Cc(e,t,n,r){let i=Object.keys(t),a=i.map(e=>t[e]),o=Object.getPrototypeOf(async function(){}).constructor,s=new o(...i,`${r?`"use strict";
32
- `:``}${e}`);try{return await s(...a),0}catch(e){return e instanceof jo?e.code:(n(`${e instanceof Error?e.stack??e.message:String(e)}\n`),1)}}function wc(e,t){let n=t.handle;return{...t,open:t=>e.call(`serial`,`open`,[n,t]),close:()=>e.call(`serial`,`close`,[n]),read:(t={})=>e.call(`serial`,`read`,[n,{maxBytes:t.maxBytes??t.bytes,until:t.until?ec(t.until):void 0,timeoutMs:t.timeoutMs}]),write:t=>e.call(`serial`,`write`,[n,ec(t)]),getSignals:()=>e.call(`serial`,`getSignals`,[n]),setSignals:t=>e.call(`serial`,`setSignals`,[n,t])}}function Tc(e){return{list:async()=>(await e.call(`serial`,`list`,[])).map(t=>wc(e,t)),request:async t=>wc(e,await e.call(`serial`,`request`,[nc(t)]))}}function Ec(e=globalThis,t){let n=e.setTimeout,r=e.clearTimeout,i=e.setInterval,a=e.clearInterval,o=n.bind(e),s=r.bind(e),c=i.bind(e),l=a.bind(e),u=new Set,d=new Set,f=new Set,p=!1,m=()=>{if(f.size===0)return;let e=[...f];f.clear();for(let t of e)t()},h=e=>{if(e==null)return!1;let t=u.delete(e),n=d.delete(e);return t||n},g=(e,n)=>{try{e(...n)}catch(e){if(t?.onCallbackError?.(e),!t?.onCallbackError)throw e}finally{m()}};return{get pendingCount(){return u.size+d.size},install(){p||(p=!0,e.setTimeout=((e,t,...n)=>{if(typeof e!=`function`)return o(e,t,...n);let r=o(()=>{u.delete(r),g(e,n)},t);return u.add(r),r}),e.clearTimeout=(e=>{let t=h(e);s(e),t&&m()}),e.setInterval=((e,t,...n)=>{if(typeof e!=`function`)return c(e,t,...n);let r=c(()=>{g(e,n)},t);return d.add(r),r}),e.clearInterval=(e=>{let t=h(e);l(e),t&&m()}))},restore(){p&&(p=!1,e.setTimeout=n,e.clearTimeout=r,e.setInterval=i,e.clearInterval=a)},clearPending(){for(let e of u)s(e);u.clear();for(let e of d)l(e);d.clear(),m()},tick(){return new Promise(e=>{o(e,0)})},waitForProgress(){return u.size+d.size===0?Promise.resolve():new Promise(e=>{f.add(e)})}}}function Dc(e,t){let n=t.handle,r=e=>({status:e.status,data:tc(e.bytes)}),i=new Set,a=new Set,o=!1,s=null,c=e=>{let t=e;if(!t||t.handle!==n)return;let r=t.type===`disconnect`?i:a;for(let e of[...r])try{e(t)}catch{}},l=()=>{o||(o=!0,s=e.onEvent?e.onEvent(`usb-claim-event`,c):null,e.call(`usb`,`subscribeClaimEvents`,[n]).catch(()=>{o=!1,s?.(),s=null}))},u=()=>{!o||i.size>0||a.size>0||(o=!1,s?.(),s=null,e.call(`usb`,`unsubscribeClaimEvents`,[n]).catch(()=>{}))};return{...t,open:()=>e.call(`usb`,`open`,[n]),close:t=>e.call(`usb`,`close`,t?.force?[n,{force:!0}]:[n]),reset:t=>e.call(`usb`,`reset`,t?.force?[n,{force:!0}]:[n]),clearHalt:(t,r)=>e.call(`usb`,`clearHalt`,[n,t,r]),selectConfiguration:t=>e.call(`usb`,`selectConfig`,[n,t]),claimInterface:(t,r)=>e.call(`usb`,`claim`,r?.wait?[n,t,{wait:!0}]:[n,t]),releaseInterface:t=>e.call(`usb`,`release`,[n,t]),controlTransferIn:async(t,i)=>r(await e.call(`usb`,`controlIn`,[n,t,i])),controlTransferOut:(t,r)=>e.call(`usb`,`controlOut`,[n,t,ec(r)]),transferIn:async(t,i)=>r(await e.call(`usb`,`transferIn`,[n,t,i])),transferOut:(t,r)=>e.call(`usb`,`transferOut`,[n,t,ec(r)]),addEventListener(e,t){if(e===`disconnect`)i.add(t);else if(e===`claim-lost`)a.add(t);else throw TypeError(`usb device: unknown event type '${String(e)}'`);l()},removeEventListener(e,t){e===`disconnect`?i.delete(t):e===`claim-lost`&&a.delete(t),u()}}}function Oc(e){return{list:async()=>(await e.call(`usb`,`list`,[])).map(t=>Dc(e,t)),request:async t=>Dc(e,await e.call(`usb`,`request`,[nc(t)]))}}function kc(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t<0?``:t===0?`/`:e.substring(0,t)}function Ac(e){if(!e)return e;let t=e.startsWith(`/`),n=e.split(`/`).filter(e=>e.length>0),r=n.indexOf(`scripts`);if(r<0)return e;let i=n.slice(0,r);return i.length===0?t?`/`:``:(t?`/`:``)+i.join(`/`)}function jc(e){return/^[A-Za-z0-9_\-./:@]+$/.test(e)?e:`'`+e.replace(/'/g,`'\\''`)+`'`}function Mc(e,t){return e===``?t:e===`/`?`/${t}`:`${e}/${t}`}function Nc(e){let t=kc(e.argv[1]??``),n=Ac(t),r=Mc(n,`references`),i=Mc(n,`assets`),a=Mc(t,`.config`);async function o(){let t;try{t=await e.fs.exists(a)}catch{return null}if(!t)return null;let n;try{n=await e.fs.readFile(a)}catch{return null}let r=typeof n==`string`?n:String(n);if(!r.trim())return null;let i;try{i=JSON.parse(r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`skill.config(): failed to parse ${a}: ${t}`)}if(i&&typeof i==`object`&&!Array.isArray(i))return i;throw Error(`skill.config(): ${a} must contain a JSON object`)}async function s(t){let n=await o();if(t===void 0)return n;if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`skill.config(updates): updates must be a plain object`);let r={...n??{},...t};return await e.fs.writeFile(a,JSON.stringify(r,null,2)+`
33
- `),r}async function c(t){if(typeof t!=`string`||!t.trim())throw TypeError(`skill.token(providerId): providerId must be a non-empty string`);let n=`oauth-token ${jc(t)}`,{stdout:r,stderr:i,exitCode:a}=await e.exec(n);if(a!==0){let e=i.trim()||`oauth-token exited with code ${a}`;throw Error(`skill.token('${t}'): ${e}`)}return r.replace(/\r?\n+$/,``)}return Object.freeze({dir:t,root:n,refs:r,assets:i,config:s,token:c})}const Pc=65536;function Fc(e,t){if(!t)return e;let n=e+t;return n.length<=Pc?n:n.slice(n.length-Pc)}async function Ic(e,t,n){let r;try{r=await e.call(`vfs`,`snapshot`,[t])}catch(e){n?.(e instanceof Error?e.message:String(e)),r={entries:[]}}return new oe(r)}function Lc(e,t){if(e.syncFsToken)return e=>t(`[sync-fs] snapshot failed, sync metadata will be incomplete: ${e}\n`)}function Rc(e,t,n,r){globalThis.__slicc_mountVfs=async(i,a)=>{let{mountVfsIntoEmscripten:o}=await import(`./emscripten-vfs-hook-Dydz8mUS.js`);return o(i,{bridge:e,syncFs:t,cwd:n,warn:e=>r.writeStderr(`slicc: ${e}\n`)},a)}}function zc(e,t,n,r,i){let a=_(e,t),o=y(e,a);if(Object.assign(r,Ae(n,e.cwd,o,i,{write:(e,n)=>{t.postMessage({type:`realm-fs-write`,path:e,bytes:n})},delete:e=>{t.postMessage({type:`realm-fs-delete`,path:e})}})),o&&Rc(o,n,e.cwd,i),e.syncFsToken)return g(e.syncFsToken,{syncFs:n,...o?{fsBridge:o}:{},...a?{transport:v(a)}:{}})}function Bc(e=globalThis){Object.prototype.hasOwnProperty.call(e,`SLICC_VERSION`)||Object.defineProperty(e,"SLICC_VERSION",{value:i().version,writable:!1,enumerable:!1,configurable:!1})}function Vc(e,t,n){let r=Pe({isTTY:!e,noColor:e});return{colorApi:r,cliApi:Ne({writeStdout:t,writeStderr:n,exit:e=>{throw new jo(e)},color:r})}}function Hc(e,t,n){return{readStdinBytes:()=>ce(e.stdin??``),writeStdout:t,writeStderr:n}}function Uc(e){return{usbBridge:Oc(e),serialBridge:Tc(e),hidBridge:ic(e),computerBridge:zs(e)}}async function Wc(e,t){let n=e.captureOutput!==!1,r={stdout:``,stderr:``},i=(e,i)=>{let a=typeof i==`string`?i:String(i);e===`stdout`?r.stdout=n?r.stdout+a:Fc(r.stdout,a):r.stderr=n?r.stderr+a:Fc(r.stderr,a),t.postMessage({type:`realm-output`,stream:e,chunk:a})},a=e=>{i(`stdout`,e)},o=e=>{i(`stderr`,e)},s=Qo(a,o),c=ts(e,a,o),{colorApi:l,cliApi:u}=Vc(!!e.env?.NO_COLOR,a,o),f=new d(t),p=Hc(e,a,o),m=be(f,E,p),h=await Ic(f,e.cwd,Lc(e,o)),g=zc(e,t,h,m,p),_=Gs(f,h,e.cwd,o),v=js(_,{cwd:e.cwd}),y=Nc({argv:e.argv,fs:m,exec:_}),b=Fs(f),{usbBridge:x,serialBridge:S,hidBridge:C,computerBridge:w}=Uc(f),T=Os({fetch:E});async function E(e,t){let n=e instanceof Request?e.url:e instanceof URL?e.toString():String(e);return Js(await f.call(`fetch`,`request`,[n,await Ns(t,e)]),n)}let D=dc({exec:_,agent:v,skill:y,http:T,browser:b,usb:x,serial:S,hid:C,computer:w,cli:u,color:l}),O=e.filename,k=Ao(O),A=await mc(f,e.code,e.cwd,O),ee=_c({graph:A,fsBridge:m,processShim:c.processShim,childProcess:Kt(_,g),nodeConsole:s,sliccyModules:D,shimmedPackages:gc(f),nodeReadline:ls({output:{write:a},onExit:c.recordExit}),nodeOsModule:Pn(e.env),nodeUtilModule:Nt(e=>o(`${e}\n`),()=>c.processShim.argv.slice(2))}).require,te={exports:{},filename:e.filename},ne=A.entrySource!==void 0;await Gc({entryCode:A.entrySource??e.code,isEsmEntry:ne,entryIsModule:A.entryIsModule===!0,filename:O,dirname:k,proc:c,nodeConsole:s,requireShim:ee,moduleShim:te,realmFetch:E,writeStderr:o,rpc:f,syncFs:h,output:r,port:t})}async function Gc(e){let t=globalThis;Bc(),t.__slicc_compileWasm=t=>e.rpc.call(`wasm`,`compile`,[t]);let n=Ec(globalThis,{onCallbackError(e){if(!(e instanceof jo))throw e}}),{createBodyReadHandleTracker:r}=await import(`./realm-body-handles-DtLxL_rB.js`),i=r(globalThis);n.install(),i.install();let a=$o(globalThis,e.proc.processShim);try{let r=await Kc({entryCode:e.entryCode,bridges:{process:e.proc.processShim,console:e.nodeConsole,require:e.requireShim,module:e.moduleShim,exports:e.moduleShim.exports,fetch:e.realmFetch,...e.entryIsModule?{}:{__dirname:e.dirname,__filename:e.filename}},writeStderr:e.writeStderr,isEsmEntry:e.isEsmEntry,rpc:e.rpc,syncFs:e.syncFs,proc:e.proc,timers:n,bodyReads:i});delete t.__slicc_compileWasm,delete t.__slicc_mountVfs,e.rpc.dispose(),e.port.postMessage({type:`realm-done`,stdout:e.output.stdout,stderr:e.output.stderr,exitCode:r})}finally{n.clearPending(),n.restore(),i.restore(),a()}}async function Kc(e){let t=await Cc(e.entryCode,e.bridges,e.writeStderr,e.isEsmEntry);return await qc(e.rpc,e.syncFs,e.writeStderr),e.proc.getDidCallProcessExit()?(e.timers.clearPending(),e.proc.getExitCode()):(await Jc(e.rpc,e.timers,e.bodyReads,e.proc),e.proc.getDidCallProcessExit()&&e.timers.clearPending(),await qc(e.rpc,e.syncFs,e.writeStderr),e.proc.getDidCallProcessExit()||t===0?e.proc.getExitCode():t)}async function qc(e,t,n){let r=t.getMutations();if(r.created.length||r.modified.length||r.deleted.length)try{await e.call(`vfs`,`flushWrites`,[r]),t.resetBaseline()}catch(e){let t=e instanceof Error?e.message:String(e);n(`[sync-fs] ERROR: flush failed — ${r.created.length+r.modified.length} write(s) + ${r.deleted.length} delete(s) were NOT persisted: ${t}\n`)}}async function Jc(e,t,n,r){for(await t.tick();!r.getDidCallProcessExit()&&(e.pendingCount>0||t.pendingCount>0||n.pendingCount>0);){let i=[];if(e.pendingCount>0&&i.push(e.waitForProgress()),t.pendingCount>0&&i.push(t.waitForProgress()),n.pendingCount>0&&i.push(n.waitForProgress()),i.length===0)break;await Promise.race(i),r.getDidCallProcessExit()||await t.tick()}}function Yc(){let e=new Set,t=new Set;return{realmSide:{postMessage:e=>{queueMicrotask(()=>{for(let n of[...t])n({data:e})})},addEventListener:(t,n)=>{e.add(n)},removeEventListener:(t,n)=>{e.delete(n)}},hostSide:{postMessage:t=>{queueMicrotask(()=>{for(let n of[...e])n({data:t})})},addEventListener:(e,n)=>{t.add(n)},removeEventListener:(e,n)=>{t.delete(n)}}}}function Xc(){return async({kind:e})=>{if(e!==`js`)throw Error(`createInProcessJsRealmFactory: only kind:js is supported`);let{realmSide:t,hostSide:n}=Yc(),r=e=>{if(e.data?.type!==`realm-init`)return;t.removeEventListener(`message`,r);let n=e.data;n.kind===`js`&&Wc(n,t).catch(e=>{let n={type:`realm-error`,message:e instanceof Error?e.message:String(e)};t.postMessage(n)})};return t.addEventListener(`message`,r),{controlPort:n,terminate(){t.removeEventListener(`message`,r)}}}}function Zc(){return async({kind:e})=>{if(e!==`py`)throw Error(`createInProcessPyRealmFactory: only kind:py is supported`);let{realmSide:t,hostSide:n}=Yc(),r=e=>{if(e.data?.type!==`realm-init`)return;t.removeEventListener(`message`,r);let n=e.data;n.kind===`py`&&p(n,t).catch(e=>{let n={type:`realm-error`,message:e instanceof Error?e.message:String(e)};t.postMessage(n)})};return t.addEventListener(`message`,r),{controlPort:n,terminate(){t.removeEventListener(`message`,r)}}}}export{Xc as createInProcessJsRealmFactory,Zc as createInProcessPyRealmFactory};
31
+ `);return t[t.length-1]===``&&t.pop(),t.map(e=>e.endsWith(`\r`)?e.slice(0,-1):e)}function as(e){if(typeof e==`string`)return e;if(e&&typeof e.read==`function`){let t=e.read();return typeof t==`string`?t:``}return``}function os(e){return new TextDecoder(`utf-8`).decode(ce(e))}function ss(e){if(e&&typeof e.write==`function`)return e}var cs=class extends je{terminal=!1;lines;cursor=0;closed=!1;flushScheduled=!1;output;onExit;constructor(e,t,n){super(),this.lines=is(os(as(e))),this.output=t??n.output,this.onExit=n.onExit}on(e,t){return super.on(e,t),e===`line`&&this.scheduleFlush(),this}once(e,t){return super.once(e,t),e===`line`&&this.scheduleFlush(),this}pause(){return this}resume(){return this}close(){this.closed||(this.closed=!0,this.emit(`close`))}question(e,t,n){let r=typeof t==`function`?t:typeof n==`function`?n:void 0;this.output?.write(String(e));let i=this.cursor<this.lines.length?this.lines[this.cursor++]:``;if(r){queueMicrotask(()=>this.runHandler(()=>r(i)));return}return Promise.resolve(i)}[Symbol.asyncIterator](){return{next:async()=>!this.closed&&this.cursor<this.lines.length?{value:this.lines[this.cursor++],done:!1}:(this.close(),{value:void 0,done:!0})}}scheduleFlush(){this.flushScheduled||this.closed||(this.flushScheduled=!0,queueMicrotask(()=>this.flush()))}flush(){this.flushScheduled=!1,this.runHandler(()=>{for(;!this.closed&&this.cursor<this.lines.length;)this.emit(`line`,this.lines[this.cursor++]);this.close()})}runHandler(e){try{e()}catch(e){if(e instanceof jo&&this.onExit){this.closed=!0,this.onExit(e.code);return}throw e}}};function ls(e){let t=(t,n)=>{let r,i;if(t&&typeof t==`object`&&`input`in t){let e=t;r=e.input,i=ss(e.output)}else r=t,i=ss(n);if(r==null)throw TypeError(`readline.createInterface: an 'input' stream is required`);return new cs(r,i,e)},n=(...e)=>{let t=e[e.length-1];return typeof t==`function`&&queueMicrotask(()=>t()),!0},r={createInterface:t,Interface:cs,emitKeypressEvents:()=>void 0,cursorTo:n,moveCursor:n,clearLine:n,clearScreenDown:n};return{...r,promises:r}}var us=class extends Error{status;statusText;url;body;constructor(e,t,n,r){let i=typeof r==`string`&&r?`: ${r.slice(0,200)}`:r&&typeof r==`object`?`: ${ds(r).slice(0,200)}`:``;super(`HTTP ${e} ${t} ${n}${i}`),this.status=e,this.statusText=t,this.url=n,this.body=r,this.name=`HttpError`}};function ds(e){try{return JSON.stringify(e)}catch{return String(e)}}function fs(e){return new Promise(t=>setTimeout(t,e))}function ps(e,t){let n=[];for(let[e,r]of Object.entries(t))if(r!=null){if(Array.isArray(r))for(let t of r)t!=null&&n.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`);else n.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(r))}`)}return n.length===0?e:e+(e.includes(`?`)?`&`:`?`)+n.join(`&`)}function ms(e,t,n){let r;return r=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:e?`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`:t,n?ps(r,n):r}function hs(e,t){let n={};if(e)for(let[t,r]of Object.entries(e))n[t]=r;if(t)for(let[e,r]of Object.entries(t))n[e]=r;return n}function gs(e){if(!e)return!1;let t=e.toLowerCase();return t.startsWith(`application/json`)||/[+/]json(;|$|\s)/.test(t)}function _s(e){if(!e)return null;let t=e.trim();if(!t)return null;if(/^\d+(\.\d+)?$/.test(t)){let e=Number(t);if(Number.isFinite(e)&&e>=0)return Math.round(e*1e3)}let n=Date.parse(t);if(Number.isFinite(n)){let e=n-Date.now();return e>0?e:0}return null}async function vs(e){if(gs(e.headers.get(`content-type`))){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}return e.text()}function ys(e,t){if(e!=null)return typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<`u`&&e instanceof Blob||typeof FormData<`u`&&e instanceof FormData||typeof URLSearchParams<`u`&&e instanceof URLSearchParams||typeof ReadableStream<`u`&&e instanceof ReadableStream?e:typeof e==`object`?(Object.keys(t).some(e=>e.toLowerCase()===`content-type`)||(t[`Content-Type`]=`application/json`),JSON.stringify(e)):String(e)}function bs(e,t){return Object.keys(e).some(e=>e.toLowerCase()===t.toLowerCase())}async function xs(e,t,n){let r=await t(n);r&&!bs(e,`authorization`)&&(e.Authorization=`Bearer ${r}`)}function Ss(e,t){if(!t)return{signal:e,clearTimeout:null};let n=new AbortController,r=setTimeout(()=>n.abort(Error(`timeout`)),t),i=()=>clearTimeout(r);return e?{signal:AbortSignal.any([e,n.signal]),clearTimeout:i}:{signal:n.signal,clearTimeout:i}}function Cs(e,t){return{body:t,headers:Object.fromEntries(e.headers.entries()),status:e.status}}async function ws(e,t){let n=await vs(e);return t?Cs(e,n):n}async function Ts(e,t){let n=await vs(e).catch(()=>null);throw new us(e.status,e.statusText,t,n)}function Es(e,t){let n=_s(e.headers.get(`retry-after`));return n===null?500*2**t:n}const Ds=new Set([`GET`,`HEAD`,`OPTIONS`,`TRACE`,`PUT`,`DELETE`]),Os=new Set([429]);function ks(e,t,n){return Os.has(e)?!0:n.has(t.toUpperCase())}async function As(e,t,n,r){let i=null;for(let a=0;a<e.maxAttempts;a++){let{signal:o,clearTimeout:s}=Ss(r.signal,e.timeoutMs),c=o?{...n,signal:o}:n,l;try{l=await e.fetch(t,c)}finally{s?.()}if(i=l,l.ok)return ws(l,r.raw);let u=n.method??`GET`;if(!(a+1<e.maxAttempts&&e.retryOn.has(l.status)&&ks(l.status,u,e.retryMethods)))return Ts(l,t);await e.sleep(Es(l,a))}if(i)return Ts(i,t);throw Error(`http: no attempts made for ${n.method??`GET`} ${t}`)}function js(e){let t=e.sleep??fs;function n(n){let r=new Set(n.retry?.on??[]),i=Math.max(1,Math.trunc(n.retry?.maxAttempts??1)),a=n.retry?.methods?new Set(n.retry.methods.map(e=>e.toUpperCase())):new Set(Ds);async function o(o,s,c={}){let l=ms(n.baseUrl,s,c.params),u=hs(n.headers,c.headers);n.token&&await xs(u,n.token,{method:o,path:s,url:l});let d=ys(c.body,u),f={method:o,headers:u};return d!==void 0&&(f.body=d),As({fetch:e.fetch,sleep:t,maxAttempts:i,retryOn:r,retryMethods:a,timeoutMs:n.timeoutMs},l,f,c)}return Object.freeze({get:((e,t)=>o(`GET`,e,t)),post:((e,t)=>o(`POST`,e,t)),put:((e,t)=>o(`PUT`,e,t)),patch:((e,t)=>o(`PATCH`,e,t)),delete:((e,t)=>o(`DELETE`,e,t))})}return Object.freeze({client:n})}function Ms(e){let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function Ns(e,t,n){let r=[];t.model&&r.push(`--model`,String(t.model)),t.thinking&&r.push(`--thinking`,String(t.thinking)),t.schema&&r.push(`--schema-b64`,Ms(JSON.stringify(t.schema))),t.readOnly!==void 0&&r.push(`--read-only`,Array.isArray(t.readOnly)?t.readOnly.join(`,`):String(t.readOnly));let i=t.cwd===void 0?n||`.`:String(t.cwd),a=t.allowedCommands===void 0?`*`:String(t.allowedCommands);return[`agent`,...r,i,a,String(e)]}function Ps(e,t){let n=t.cwd,r=async(t,r)=>{let i=r??{},a=await e.spawn(Ns(t,i,n)),o=typeof a.exitCode==`number`?a.exitCode:0;return{finalText:String(a.stdout??``).replace(/\n+$/,``),exitCode:o,stderr:String(a.stderr??``).replace(/\n+$/,``)}},i=(async(e,t)=>{let n=t??{},i=await r(e,n);if(i.exitCode!==0)throw Error(`agent: exited with code ${i.exitCode}${i.stderr?`: ${i.stderr}`:``}`);if(n.schema)try{return JSON.parse(i.finalText)}catch{throw Error(`agent: schema response was not valid JSON (exit ${i.exitCode}): ${i.finalText.slice(0,200)}`)}return i.finalText});return i.spawn=r,i}function $(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`&&typeof e.targetId==`string`)return e.targetId;throw TypeError(`browser: expected a tab handle or targetId string`)}function Fs(e){function t(t){return{...t,async update(n){let r={};return n.urlMatch!==void 0&&(r.urlMatch=n.urlMatch===null?null:n.urlMatch instanceof RegExp?n.urlMatch.source:n.urlMatch),n.filter!==void 0&&(r.filter=n.filter),e.call(`browser`,`wsUpdate`,[t.id,r])},async close(){return e.call(`browser`,`wsClose`,[t.id])}}}return{on(n,r={}){let i=$(n),a=r.urlMatch===void 0?void 0:r.urlMatch instanceof RegExp?r.urlMatch.source:r.urlMatch,o,s={filter(e){if(typeof e==`function`||typeof e==`string`)throw TypeError(`browser.websocket: filter must be a declarative JSON object, not a function or string`);return o=e,s},async forward(n){return t(await e.call(`browser`,`wsObserve`,[{targetId:i,urlMatch:a,filter:o,forward:n}]))}};return s},async list(){return e.call(`browser`,`wsList`,[])}}}async function Is(e,t){if(!e&&!(t instanceof Request))return;let n=t instanceof Request?t:null,r=(e?.method??n?.method??`GET`).toUpperCase(),i={};if(e?.headers){if(e.headers instanceof Headers)e.headers.forEach((e,t)=>{i[t]=e});else if(Array.isArray(e.headers))for(let[t,n]of e.headers)i[t]=n;else Object.assign(i,e.headers)}else n&&n.headers.forEach((e,t)=>{i[t]=e});let a,o;if(r!==`GET`&&r!==`HEAD`&&e?.body!==void 0&&e?.body!==null&&e?.body!==``){let t=await Ls(e.body);a=t.body,o=t.defaultContentType}return o&&!Object.keys(i).some(e=>e.toLowerCase()===`content-type`)&&(i[`Content-Type`]=o),{method:r,headers:i,body:a}}async function Ls(e){if(typeof e==`string`)return{body:e};if(e instanceof URLSearchParams)return{body:e.toString(),defaultContentType:`application/x-www-form-urlencoded;charset=UTF-8`};if(e instanceof Blob)return{body:new Uint8Array(await e.arrayBuffer()),defaultContentType:e.type||`application/octet-stream`};if(e instanceof ArrayBuffer)return{body:new Uint8Array(e).slice(),defaultContentType:`application/octet-stream`};if(ArrayBuffer.isView(e))return{body:new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice(),defaultContentType:`application/octet-stream`};if(n(e)){let t=await r(e);return{body:t.bytes,defaultContentType:t.contentType}}throw typeof ReadableStream<`u`&&e instanceof ReadableStream?Error(`node fetch shim: ReadableStream request bodies are not supported (collect into a Uint8Array or string before calling fetch)`):Error(`node fetch shim: unsupported request body type (${Object.prototype.toString.call(e)}); use a string, Uint8Array, ArrayBuffer, Blob, FormData, or URLSearchParams`)}function Rs(e){return{findTab:t=>e.call(`browser`,`findTab`,[Bs(t)]),ensureTab:(t,n={})=>e.call(`browser`,`ensureTab`,[t,Vs(n)]),openWindow:(t,n={})=>e.call(`browser`,`openWindow`,[t,n]),windowBounds:t=>e.call(`browser`,`windowBounds`,[$(t)]),setWindowBounds:(t,n)=>e.call(`browser`,`setWindowBounds`,[$(t),n]),eval:(t,n)=>e.call(`browser`,`eval`,[$(t),zs(n,!1)]),evalAsync:(t,n)=>e.call(`browser`,`evalAsync`,[$(t),zs(n,!0)]),cookie:(t,n)=>e.call(`browser`,`cookie`,[$(t),n]),localStorage:(t,n)=>e.call(`browser`,`localStorage`,[$(t),n]),fetch:(t,n,r={})=>b(n,r).then(n=>e.call(`browser`,`evalAsync`,[$(t),n])),websocket:Fs(e)}}function zs(e,t){if(typeof e==`function`)return`(${e.toString()})()`;if(typeof e==`string`)return e;throw TypeError(`browser.eval/evalAsync: source must be a function or string`)}function Bs(e){let t={};return e.domain!==void 0&&(t.domain=e.domain),e.urlMatch!==void 0&&(t.urlMatch=e.urlMatch instanceof RegExp?e.urlMatch.source:e.urlMatch),t}function Vs(e){return e.matchUrl===void 0?{}:{matchUrl:e.matchUrl instanceof RegExp?e.matchUrl.source:e.matchUrl}}function Hs(e){return{register(t){let n=null,r=e.onEvent(`computer-call`,r=>{let i=r;i.id===t.id&&Ws(e,t,i,{getStop:()=>n,setStop:e=>{n=e}})}),i=Us(t);return e.call(`computer`,`register`,[i]).catch(()=>{}),()=>{n?.(),n=null,r(),e.call(`computer`,`unregister`,[t.id]).catch(()=>{})}}}}function Us(e){return{id:e.id,kind:`jsh`,title:e.title??e.id,size:e.size??null,state:`live`,capabilities:e.capabilities,pid:null,...e.softKeys?{softKeys:e.softKeys}:{}}}async function Ws(e,t,n,r){let i;try{i=await Gs(e,t,n,r)}catch(e){i={error:e instanceof Error?e.message:String(e)}}try{await e.call(`computer`,`reply`,[n.requestId,i])}catch{}}async function Gs(e,t,n,r){switch(n.op){case`screenshot`:return t.screenshot(n.args[0]??{format:`jpeg`});case`text`:return t.text?t.text():null;case`input`:return await t.input(n.args[0]??[]),{ok:!0};case`exec`:if(!t.exec)throw Error(`exec is not supported`);return t.exec(String(n.args[0]??``));case`subscribe`:return Ks(e,t,Number(n.args[0])||2,Number(n.args[1])||void 0,r);case`unsubscribe`:return r.getStop()?.(),r.setStop(null),{ok:!0};default:{let e=n.op;throw Error(`unknown computer op '${String(e)}'`)}}}function Ks(e,t,n,r,i){if(i.getStop()?.(),!t.subscribe)throw Error(`subscribe is not supported`);let a=t.subscribe(n,n=>{e.call(`computer`,`frame`,[t.id,n]).catch(()=>{})},r);return i.setStop(()=>{try{a()}catch{}}),{ok:!0}}function qs(e){return e===`SIGKILL`?137:e===`SIGINT`?130:143}function Js(e,t,n,r){let i=async()=>{if(!t?.wasUsed())return;let n=t.getMutations();if(n.created.length||n.modified.length||n.deleted.length)try{await e.call(`vfs`,`flushWrites`,[n])}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[realm-exec] pre-exec sync-fs flush failed (will retry at exit): ${t}`);return}t.resetBaseline()},a=async(i=!1)=>{if(t?.wasUsed())try{let r=await e.call(`vfs`,`snapshot`,[n]);i?t.applySnapshotPreservingMutations(r):t.applySnapshot(r)}catch(e){let t=e instanceof Error?e.message:String(e);r?.(`[sync-fs] re-snapshot after exec failed: ${t}\n`)}},o=async t=>{await i();try{return await e.call(`exec`,`run`,[t])}finally{await a()}},s=async t=>{await i();try{return await e.call(`exec`,`spawn`,[t])}finally{await a()}},c=1,l=Object.assign(o,{spawn:s,start:(t,n)=>{let r=c++,o=[],s=!1,l=!1,u=!1,d,f,p=new Promise((e,t)=>{d=e,f=t}),m=()=>{if(s||u||l)return;l=!0;let c=o.length>0?o.join(``):n?.stdin,p={};c!==void 0&&(p.stdin=c),n?.stdinKind!==void 0&&(p.stdinKind=n.stdinKind),n?.args!==void 0&&(p.args=n.args),n?.cwd!==void 0&&(p.cwd=n.cwd),n?.env!==void 0&&(p.env=n.env),(async()=>{try{if(await i(),u){await a(!0);return}s=!0;let n=await e.call(`exec`,`start`,[r,t,p]);await a(!0),d(n)}catch(e){await a(!0),f(e)}})()};return{kill:t=>s?e.call(`exec`,`kill`,[r,t]):(u=!0,d({stdout:``,stderr:``,exitCode:qs(t)}),Promise.resolve(!0)),stdin:{write:e=>{!s&&!u&&o.push(e)},end:()=>m()},done:p}}});return l.exec=l,l}const Ys=new Set([204,205,304]),Xs=new Set([`content-encoding`,`transfer-encoding`,`content-length`]);function Zs(e,t){let n=Qs(e.body),r=$s(e.headers),i=Ys.has(e.status)||n.byteLength===0,a=new Response(i?null:n,{status:e.status,statusText:e.statusText,headers:r});try{Object.defineProperty(a,"url",{value:e.url||t,writable:!1,configurable:!0,enumerable:!1})}catch{}return tc(a,n),a}function Qs(e){return e.byteLength===0?new Uint8Array:e.slice()}function $s(e){let t=new Headers;for(let[n,r]of Object.entries(e))if(!Xs.has(n.toLowerCase()))try{t.set(n,r)}catch{}return t}const ec=Symbol(`slicc.realmBufferedBody`);function tc(e,t){if(ec in e)return;Object.defineProperty(e,ec,{value:!0,configurable:!0});let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),`bodyUsed`),r=!1,i=()=>{if(r)throw TypeError(`Failed to read response body: body already used`);return r=!0,nc(e),t},a=async()=>new TextDecoder().decode(i()),o=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);Object.defineProperties(e,{bodyUsed:{configurable:!0,enumerable:!1,get(){return r?!0:n?.get?!!n.get.call(e):!1}},text:{value:a,configurable:!0},json:{value:async()=>JSON.parse(await a()),configurable:!0},arrayBuffer:{value:async()=>o(i()),configurable:!0},blob:{value:async()=>new Blob([o(i())]),configurable:!0},bytes:{value:async()=>i(),configurable:!0}})}function nc(e){try{let t=e.body;t&&!t.locked&&t.getReader()}catch{}}function rc(e){if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return new Uint8Array(e);throw TypeError(`expected an ArrayBuffer or typed array`)}function ic(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ac(e){return e==null?[]:Array.isArray(e)?e:[e]}function oc(e,t){let n=t.handle,r=new Set,i=new Set,a=!1,o=null,s=e=>{let t=e;if(!t||t.handle!==n)return;let i={reportId:t.reportId,data:ic(t.bytes)};for(let e of[...r])try{e(i)}catch{}},c=()=>{a||(a=!0,o=e.onEvent?e.onEvent(`hid-input-report`,s):null,e.call(`hid`,`subscribeInputReports`,[n]).catch(()=>{a=!1,o?.(),o=null}))},l=()=>{!a||r.size>0||(a=!1,o?.(),o=null,e.call(`hid`,`unsubscribeInputReports`,[n]).catch(()=>{}))};return{...t,open:()=>e.call(`hid`,`open`,[n]),close:()=>e.call(`hid`,`close`,[n]),sendReport:(t,r)=>e.call(`hid`,`sendReport`,[n,t,rc(r)]),sendFeatureReport:(t,r)=>e.call(`hid`,`sendFeatureReport`,[n,t,rc(r)]),receiveFeatureReport:async t=>ic((await e.call(`hid`,`receiveFeatureReport`,[n,t])).bytes),addEventListener(e,t){if(e===`inputreport`)r.add(t),c();else if(e===`disconnect`)i.add(t);else throw TypeError(`hid device: unknown event type '${String(e)}'`)},removeEventListener(e,t){e===`inputreport`?(r.delete(t),l()):e===`disconnect`&&i.delete(t)},onInputReport(e){r.add(e),c()}}}function sc(e){return{list:async()=>(await e.call(`hid`,`list`,[])).map(t=>oc(e,t)),request:async t=>{let n=(await e.call(`hid`,`request`,[ac(t)]))[0];if(!n)throw Error(`No device selected.`);return oc(e,n)}}}function cc(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var lc=class{rpc;targetId;selector;index;constructor(e,t,n,r){this.rpc=e,this.targetId=t,this.selector=n,this.index=r}evalOnElement(e){let t=`(() => { const els = document.querySelectorAll(${JSON.stringify(this.selector)}); const el = els[${this.index}]; ${e} })()`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,t])}async textContent(){return this.evalOnElement(`return el ? el.textContent : null;`)}async getAttribute(e){return this.evalOnElement(`return el ? el.getAttribute(${JSON.stringify(e)}) : null;`)}async isVisible(){return this.evalOnElement(`if (!el) return false; const s = getComputedStyle(el); if (s.display === 'none' || s.visibility === 'hidden' || s.opacity === '0') return false; const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0;`)}async boundingBox(){return this.evalOnElement(`if (!el) return null; const r = el.getBoundingClientRect(); return { x: r.x, y: r.y, width: r.width, height: r.height };`)}},uc=class{rpc;targetId;onClose;closed=!1;constructor(e,t,n){this.rpc=e,this.targetId=t,this.onClose=n}async goto(e,t){await this.rpc.call(`browser`,`navigateTab`,[this.targetId,e])}async waitForLoadState(e){await this.rpc.call(`browser`,`waitForLoadState`,[this.targetId,e??`load`])}async waitForTimeout(e){await new Promise(t=>setTimeout(t,e))}async evaluate(e,...t){let n=typeof e==`string`?e:`(${e.toString()}).apply(null, JSON.parse(${JSON.stringify(JSON.stringify(t))}))`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,n])}async screenshot(e){let t={};e?.fullPage!==void 0&&(t.fullPage=e.fullPage);let n=cc(await this.rpc.call(`browser`,`screenshotTab`,[this.targetId,t]));return e?.path&&await this.rpc.call(`vfs`,`writeFileBinary`,[e.path,n]),n}async $(e){return await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`!!document.querySelector(${JSON.stringify(e)})`])?new lc(this.rpc,this.targetId,e,0):null}async $$(e){let t=await this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.querySelectorAll(${JSON.stringify(e)}).length`]),n=[];for(let r=0;r<t;r++)n.push(new lc(this.rpc,this.targetId,e,r));return n}async $$eval(e,t,...n){if(typeof t==`string`)return this.rpc.call(`browser`,`evalAsync`,[this.targetId,t]);let r=`(${t.toString()}).apply(null, [Array.from(document.querySelectorAll(${JSON.stringify(e)}))].concat(JSON.parse(${JSON.stringify(JSON.stringify(n))})))`;return this.rpc.call(`browser`,`evalAsync`,[this.targetId,r])}async content(){return this.rpc.call(`browser`,`evalAsync`,[this.targetId,`document.documentElement.outerHTML`])}async setViewportSize(e){await this.rpc.call(`browser`,`setViewport`,[this.targetId,e.width,e.height])}async close(){this.closed||(this.closed=!0,await this.rpc.call(`browser`,`closeTab`,[this.targetId]),this.onClose?.())}},dc=class{rpc;openPages=[];constructor(e){this.rpc=e}async newPage(e){let t=await this.rpc.call(`browser`,`createTab`,[`about:blank`]);e?.viewport&&await this.rpc.call(`browser`,`setViewport`,[t,e.viewport.width,e.viewport.height]);let n=new uc(this.rpc,t,()=>{let e=this.openPages.indexOf(n);e!==-1&&this.openPages.splice(e,1)});return this.openPages.push(n),n}pages(){return[...this.openPages]}async close(){let e=this.openPages.splice(0,this.openPages.length);for(let t of e)await t.close()}},fc=class{rpc;openPages=[];openContexts=[];constructor(e){this.rpc=e}async newPage(e){let t=await this.rpc.call(`browser`,`createTab`,[`about:blank`]);e?.viewport&&await this.rpc.call(`browser`,`setViewport`,[t,e.viewport.width,e.viewport.height]);let n=new uc(this.rpc,t,()=>{let e=this.openPages.indexOf(n);e!==-1&&this.openPages.splice(e,1)});return this.openPages.push(n),n}async newContext(e){let t=new dc(this.rpc);return this.openContexts.push(t),t}contexts(){return[...this.openContexts]}async close(){let e=this.openPages.splice(0,this.openPages.length);for(let t of e)await t.close();let t=this.openContexts.splice(0,this.openContexts.length);for(let e of t)await e.close()}};function pc(e){let t=async t=>new fc(e),n=async(t,n)=>new fc(e);return{chromium:{launch:t,connect:n,connectOverCDP:n},firefox:{launch:t,connect:n},webkit:{launch:t,connect:n}}}function mc(e){return{...e,time:ko,fmt:We,pool:To}}function hc(e,t){return e?.startsWith(`/`)?Ao(e):t}function gc(e){return e.includes(`require`)||e.includes(`import`)||/(?:^|[;\n}])\s*export\b/.test(e)}async function _c(e,t,n,r){return gc(t)?e.call(`module`,`buildGraph`,[t,hc(r,n),r]):{files:[],entryMap:{},edges:{},edgeErrors:{},errors:{}}}function vc(e){if(typeof e!=`object`||!e)return;let t=e;if(t.__esModule&&!Object.prototype.hasOwnProperty.call(t,`default`)&&Object.isExtensible(t))try{Object.defineProperty(t,"default",{value:t,enumerable:!1,configurable:!0})}catch{}}function yc(e){return{playwright:pc(e)}}function bc(e){let{graph:t,fsBridge:n,processShim:r,childProcess:i,nodeConsole:a,sliccyModules:o,shimmedPackages:s={},nodeReadline:l,nodeOsModule:d=Fn,nodeUtilModule:p=Pt}=e,h=new Map(t.files.map(e=>[e.path,e.cjsSource])),g=new Map(t.files.map(e=>[e.path,e.kind])),_=new Map,v=An({requireFrom:(e,t)=>T(e,t),resolveFrom:(e,t)=>w(e,t)}),y=bn(()=>{let e=r?.cwd?.();return typeof e==`string`&&e.length>0?e:`/`}),b=e=>{if(typeof e==`string`&&e.startsWith(`sliccy:`))return{hit:!0,value:Cc(e,o)};let t=e.startsWith(`node:`)?e.slice(5):e,a=xc(t,{fsBridge:n,processShim:r,childProcess:i,nodeOsModule:d,nodeUtilModule:p,nodePathModule:y,nodeReadline:l,nodeModule:v});if(a.hit)return a;if(m.has(t))throw f(e,t);if(u.has(t))throw Tc(e,t);return t in s?{hit:!0,value:s[t]}:{hit:!1}},x=(e,n,r)=>{let i=b(n);if(i.hit)return i.value;let a=e?.[n];if(a)return S(a);let o=r===null?t.errors[n]:t.edgeErrors?.[r]?.[n];throw o?Error(o):Sc(n)};function S(e){let n=_.get(e);if(n)return n.exports;let i=h.get(e);if(i===void 0)throw Error(`Cannot find module '${e}'`);let o={exports:{}};_.set(e,o);let s=n=>x(t.edges[e],n,e),c=[`module`,`exports`,`require`,`process`,`console`,`Buffer`,`global`],l=[o,o.exports,s,r,a,globalThis.Buffer,globalThis];return g.get(e)!==`esm`&&(c.push(`__dirname`,`__filename`),l.push(Ao(e),e)),Function(...c,i)(...l),g.get(e)===`cjs`&&vc(o.exports),o.exports}function C(e){return h.has(e)}function w(e,n){if(c(n))return n;let r=t.edges[e]?.[n];if(r)return r;let i=Ao(e);if(kn(n)){let e=Dn(i,n,C);if(e)return e}else{let e=On(i,n,C);if(e)return e}let a=t.edgeErrors?.[e]?.[n];throw a?Error(a):Sc(n)}function T(e,t){let n=b(t);return n.hit?n.value:S(w(e,t))}return{require:e=>x(t.entryMap,e,null)}}function xc(e,t){let{fsBridge:n,processShim:r,childProcess:i,nodeOsModule:a,nodeUtilModule:o,nodePathModule:s,nodeReadline:c,nodeModule:l}=t;return e===`fs`||e===`fs/promises`?{hit:!0,value:n}:e===`path`?{hit:!0,value:s}:e===`crypto`?{hit:!0,value:cn}:e===`child_process`?{hit:!0,value:i}:e===`process`?{hit:!0,value:r}:e===`buffer`?{hit:!0,value:{Buffer:globalThis.Buffer}}:e===`assert`?{hit:!0,value:et}:e===`assert/strict`?{hit:!0,value:$e}:e===`util`?{hit:!0,value:o}:e===`events`?{hit:!0,value:Me}:e===`os`?{hit:!0,value:a}:e===`tty`?{hit:!0,value:In}:e===`stream`?{hit:!0,value:ot}:e===`url`?{hit:!0,value:C}:e===`zlib`?{hit:!0,value:So}:e===`vm`?{hit:!0,value:nr}:e===`readline`&&c?{hit:!0,value:c}:e===`readline/promises`&&c?{hit:!0,value:c.promises}:e===`module`&&l?{hit:!0,value:l}:{hit:!1}}function Sc(e){if(e.startsWith(`.`)||e.startsWith(`/`)||e.startsWith(`node:`))return Error(`Cannot find module '${e}'`);let t=e.startsWith(`@`)?e.split(`/`).slice(0,2).join(`/`):e.split(`/`)[0];return Error(`Cannot find module '${e}' (run: ipk install ${t})`)}function Cc(e,t){let n=e.slice(7);if(n===``)throw Error(`require('sliccy:'): empty sliccy: module name`);if(!Object.prototype.hasOwnProperty.call(t,n))throw Error(`require('${e}'): unknown sliccy: module '${n}'. Known names: ${Object.keys(t).sort().join(`, `)}`);return t[n]}const wc={http:` Use fetch() instead.`,https:` Use fetch() instead.`,crypto:` Use globalThis.crypto (Web Crypto API) instead.`};function Tc(e,t){return Error(`require('${e}'): Node built-in '${t}' is not available in the browser environment.${wc[t]||``}`)}async function Ec(e,t,n,r){let i=Object.keys(t),a=i.map(e=>t[e]),o=Object.getPrototypeOf(async function(){}).constructor,s=new o(...i,`${r?`"use strict";
32
+ `:``}${e}`);try{return await s(...a),0}catch(e){return e instanceof jo?e.code:(n(`${e instanceof Error?e.stack??e.message:String(e)}\n`),1)}}function Dc(e,t){let n=t.handle;return{...t,open:t=>e.call(`serial`,`open`,[n,t]),close:()=>e.call(`serial`,`close`,[n]),read:(t={})=>e.call(`serial`,`read`,[n,{maxBytes:t.maxBytes??t.bytes,until:t.until?rc(t.until):void 0,timeoutMs:t.timeoutMs}]),write:t=>e.call(`serial`,`write`,[n,rc(t)]),getSignals:()=>e.call(`serial`,`getSignals`,[n]),setSignals:t=>e.call(`serial`,`setSignals`,[n,t])}}function Oc(e){return{list:async()=>(await e.call(`serial`,`list`,[])).map(t=>Dc(e,t)),request:async t=>Dc(e,await e.call(`serial`,`request`,[ac(t)]))}}function kc(e=globalThis,t){let n=e.setTimeout,r=e.clearTimeout,i=e.setInterval,a=e.clearInterval,o=n.bind(e),s=r.bind(e),c=i.bind(e),l=a.bind(e),u=new Set,d=new Set,f=new Set,p=!1,m=()=>{if(f.size===0)return;let e=[...f];f.clear();for(let t of e)t()},h=e=>{if(e==null)return!1;let t=u.delete(e),n=d.delete(e);return t||n},g=(e,n)=>{try{e(...n)}catch(e){if(t?.onCallbackError?.(e),!t?.onCallbackError)throw e}finally{m()}};return{get pendingCount(){return u.size+d.size},install(){p||(p=!0,e.setTimeout=((e,t,...n)=>{if(typeof e!=`function`)return o(e,t,...n);let r=o(()=>{u.delete(r),g(e,n)},t);return u.add(r),r}),e.clearTimeout=(e=>{let t=h(e);s(e),t&&m()}),e.setInterval=((e,t,...n)=>{if(typeof e!=`function`)return c(e,t,...n);let r=c(()=>{g(e,n)},t);return d.add(r),r}),e.clearInterval=(e=>{let t=h(e);l(e),t&&m()}))},restore(){p&&(p=!1,e.setTimeout=n,e.clearTimeout=r,e.setInterval=i,e.clearInterval=a)},clearPending(){for(let e of u)s(e);u.clear();for(let e of d)l(e);d.clear(),m()},tick(){return new Promise(e=>{o(e,0)})},waitForProgress(){return u.size+d.size===0?Promise.resolve():new Promise(e=>{f.add(e)})}}}function Ac(e,t){let n=t.handle,r=e=>({status:e.status,data:ic(e.bytes)}),i=new Set,a=new Set,o=!1,s=null,c=e=>{let t=e;if(!t||t.handle!==n)return;let r=t.type===`disconnect`?i:a;for(let e of[...r])try{e(t)}catch{}},l=()=>{o||(o=!0,s=e.onEvent?e.onEvent(`usb-claim-event`,c):null,e.call(`usb`,`subscribeClaimEvents`,[n]).catch(()=>{o=!1,s?.(),s=null}))},u=()=>{!o||i.size>0||a.size>0||(o=!1,s?.(),s=null,e.call(`usb`,`unsubscribeClaimEvents`,[n]).catch(()=>{}))};return{...t,open:()=>e.call(`usb`,`open`,[n]),close:t=>e.call(`usb`,`close`,t?.force?[n,{force:!0}]:[n]),reset:t=>e.call(`usb`,`reset`,t?.force?[n,{force:!0}]:[n]),clearHalt:(t,r)=>e.call(`usb`,`clearHalt`,[n,t,r]),selectConfiguration:t=>e.call(`usb`,`selectConfig`,[n,t]),claimInterface:(t,r)=>e.call(`usb`,`claim`,r?.wait?[n,t,{wait:!0}]:[n,t]),releaseInterface:t=>e.call(`usb`,`release`,[n,t]),controlTransferIn:async(t,i)=>r(await e.call(`usb`,`controlIn`,[n,t,i])),controlTransferOut:(t,r)=>e.call(`usb`,`controlOut`,[n,t,rc(r)]),transferIn:async(t,i)=>r(await e.call(`usb`,`transferIn`,[n,t,i])),transferOut:(t,r)=>e.call(`usb`,`transferOut`,[n,t,rc(r)]),addEventListener(e,t){if(e===`disconnect`)i.add(t);else if(e===`claim-lost`)a.add(t);else throw TypeError(`usb device: unknown event type '${String(e)}'`);l()},removeEventListener(e,t){e===`disconnect`?i.delete(t):e===`claim-lost`&&a.delete(t),u()}}}function jc(e){return{list:async()=>(await e.call(`usb`,`list`,[])).map(t=>Ac(e,t)),request:async t=>Ac(e,await e.call(`usb`,`request`,[ac(t)]))}}function Mc(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t<0?``:t===0?`/`:e.substring(0,t)}function Nc(e){if(!e)return e;let t=e.startsWith(`/`),n=e.split(`/`).filter(e=>e.length>0),r=n.indexOf(`scripts`);if(r<0)return e;let i=n.slice(0,r);return i.length===0?t?`/`:``:(t?`/`:``)+i.join(`/`)}function Pc(e){return/^[A-Za-z0-9_\-./:@]+$/.test(e)?e:`'`+e.replace(/'/g,`'\\''`)+`'`}function Fc(e,t){return e===``?t:e===`/`?`/${t}`:`${e}/${t}`}function Ic(e){let t=Mc(e.argv[1]??``),n=Nc(t),r=Fc(n,`references`),i=Fc(n,`assets`),a=Fc(t,`.config`);async function o(){let t;try{t=await e.fs.exists(a)}catch{return null}if(!t)return null;let n;try{n=await e.fs.readFile(a)}catch{return null}let r=typeof n==`string`?n:String(n);if(!r.trim())return null;let i;try{i=JSON.parse(r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`skill.config(): failed to parse ${a}: ${t}`)}if(i&&typeof i==`object`&&!Array.isArray(i))return i;throw Error(`skill.config(): ${a} must contain a JSON object`)}async function s(t){let n=await o();if(t===void 0)return n;if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`skill.config(updates): updates must be a plain object`);let r={...n??{},...t};return await e.fs.writeFile(a,JSON.stringify(r,null,2)+`
33
+ `),r}async function c(t){if(typeof t!=`string`||!t.trim())throw TypeError(`skill.token(providerId): providerId must be a non-empty string`);let n=`oauth-token ${Pc(t)}`,{stdout:r,stderr:i,exitCode:a}=await e.exec(n);if(a!==0){let e=i.trim()||`oauth-token exited with code ${a}`;throw Error(`skill.token('${t}'): ${e}`)}return r.replace(/\r?\n+$/,``)}return Object.freeze({dir:t,root:n,refs:r,assets:i,config:s,token:c})}const Lc=65536;function Rc(e,t){if(!t)return e;let n=e+t;return n.length<=Lc?n:n.slice(n.length-Lc)}async function zc(e,t,n){let r;try{r=await e.call(`vfs`,`snapshot`,[t])}catch(e){n?.(e instanceof Error?e.message:String(e)),r={entries:[]}}return new oe(r)}function Bc(e,t){if(e.syncFsToken)return e=>t(`[sync-fs] snapshot failed, sync metadata will be incomplete: ${e}\n`)}function Vc(e,t,n,r){globalThis.__slicc_mountVfs=async(i,a)=>{let{mountVfsIntoEmscripten:o}=await import(`./emscripten-vfs-hook-C0ChBXC3.js`);return o(i,{bridge:e,syncFs:t,cwd:n,warn:e=>r.writeStderr(`slicc: ${e}\n`)},a)}}function Hc(e,t,n,r,i){let a=_(e,t),o=y(e,a);if(Object.assign(r,Ae(n,e.cwd,o,i,{write:(e,n)=>{t.postMessage({type:`realm-fs-write`,path:e,bytes:n})},delete:e=>{t.postMessage({type:`realm-fs-delete`,path:e})}})),o&&Vc(o,n,e.cwd,i),e.syncFsToken)return g(e.syncFsToken,{syncFs:n,...o?{fsBridge:o}:{},...a?{transport:v(a)}:{}})}function Uc(e=globalThis){Object.prototype.hasOwnProperty.call(e,`SLICC_VERSION`)||Object.defineProperty(e,"SLICC_VERSION",{value:i().version,writable:!1,enumerable:!1,configurable:!1})}function Wc(e,t,n){let r=Pe({isTTY:!e,noColor:e});return{colorApi:r,cliApi:Ne({writeStdout:t,writeStderr:n,exit:e=>{throw new jo(e)},color:r})}}function Gc(e,t,n){return{readStdinBytes:()=>ce(e.stdin??``),writeStdout:t,writeStderr:n}}function Kc(e){return{usbBridge:jc(e),serialBridge:Oc(e),hidBridge:sc(e),computerBridge:Hs(e)}}async function qc(e,t){let n=e.captureOutput!==!1,r={stdout:``,stderr:``},i=(e,i)=>{let a=typeof i==`string`?i:String(i);e===`stdout`?r.stdout=n?r.stdout+a:Rc(r.stdout,a):r.stderr=n?r.stderr+a:Rc(r.stderr,a),t.postMessage({type:`realm-output`,stream:e,chunk:a})},a=e=>{i(`stdout`,e)},o=e=>{i(`stderr`,e)},s=Qo(a,o),c=ts(e,a,o),{colorApi:l,cliApi:u}=Wc(!!e.env?.NO_COLOR,a,o),f=new d(t),p=Gc(e,a,o),m=be(f,E,p),h=await zc(f,e.cwd,Bc(e,o)),g=Hc(e,t,h,m,p),_=Js(f,h,e.cwd,o),v=Ps(_,{cwd:e.cwd}),y=Ic({argv:e.argv,fs:m,exec:_}),b=Rs(f),{usbBridge:x,serialBridge:S,hidBridge:C,computerBridge:w}=Kc(f),T=js({fetch:E});async function E(e,t){let n=e instanceof Request?e.url:e instanceof URL?e.toString():String(e);return Zs(await f.call(`fetch`,`request`,[n,await Is(t,e)]),n)}let D=mc({exec:_,agent:v,skill:y,http:T,browser:b,usb:x,serial:S,hid:C,computer:w,cli:u,color:l}),O=e.filename,k=Ao(O),A=await _c(f,e.code,e.cwd,O),ee=bc({graph:A,fsBridge:m,processShim:c.processShim,childProcess:Kt(_,g),nodeConsole:s,sliccyModules:D,shimmedPackages:yc(f),nodeReadline:ls({output:{write:a},onExit:c.recordExit}),nodeOsModule:Pn(e.env),nodeUtilModule:Nt(e=>o(`${e}\n`),()=>c.processShim.argv.slice(2))}).require,te={exports:{},filename:e.filename},ne=A.entrySource!==void 0;await Jc({entryCode:A.entrySource??e.code,isEsmEntry:ne,entryIsModule:A.entryIsModule===!0,filename:O,dirname:k,proc:c,nodeConsole:s,requireShim:ee,moduleShim:te,realmFetch:E,writeStderr:o,rpc:f,syncFs:h,output:r,port:t})}async function Jc(e){let t=globalThis;Uc(),t.__slicc_compileWasm=t=>e.rpc.call(`wasm`,`compile`,[t]);let n=kc(globalThis,{onCallbackError(e){if(!(e instanceof jo))throw e}}),{createBodyReadHandleTracker:r}=await import(`./realm-body-handles-DtLxL_rB.js`),i=r(globalThis);n.install(),i.install();let a=$o(globalThis,e.proc.processShim);try{let r=await Yc({entryCode:e.entryCode,bridges:{process:e.proc.processShim,console:e.nodeConsole,require:e.requireShim,module:e.moduleShim,exports:e.moduleShim.exports,fetch:e.realmFetch,...e.entryIsModule?{}:{__dirname:e.dirname,__filename:e.filename}},writeStderr:e.writeStderr,isEsmEntry:e.isEsmEntry,rpc:e.rpc,syncFs:e.syncFs,proc:e.proc,timers:n,bodyReads:i});delete t.__slicc_compileWasm,delete t.__slicc_mountVfs,e.rpc.dispose(),e.port.postMessage({type:`realm-done`,stdout:e.output.stdout,stderr:e.output.stderr,exitCode:r})}finally{n.clearPending(),n.restore(),i.restore(),a()}}async function Yc(e){let t=await Ec(e.entryCode,e.bridges,e.writeStderr,e.isEsmEntry);return await Xc(e.rpc,e.syncFs,e.writeStderr),e.proc.getDidCallProcessExit()?(e.timers.clearPending(),e.proc.getExitCode()):(await Zc(e.rpc,e.timers,e.bodyReads,e.proc),e.proc.getDidCallProcessExit()&&e.timers.clearPending(),await Xc(e.rpc,e.syncFs,e.writeStderr),e.proc.getDidCallProcessExit()||t===0?e.proc.getExitCode():t)}async function Xc(e,t,n){let r=t.getMutations();if(r.created.length||r.modified.length||r.deleted.length)try{await e.call(`vfs`,`flushWrites`,[r]),t.resetBaseline()}catch(e){let t=e instanceof Error?e.message:String(e);n(`[sync-fs] ERROR: flush failed — ${r.created.length+r.modified.length} write(s) + ${r.deleted.length} delete(s) were NOT persisted: ${t}\n`)}}async function Zc(e,t,n,r){for(await t.tick();!r.getDidCallProcessExit()&&(e.pendingCount>0||t.pendingCount>0||n.pendingCount>0);){let i=[];if(e.pendingCount>0&&i.push(e.waitForProgress()),t.pendingCount>0&&i.push(t.waitForProgress()),n.pendingCount>0&&i.push(n.waitForProgress()),i.length===0)break;await Promise.race(i),r.getDidCallProcessExit()||await t.tick()}}function Qc(){let e=new Set,t=new Set;return{realmSide:{postMessage:e=>{queueMicrotask(()=>{for(let n of[...t])n({data:e})})},addEventListener:(t,n)=>{e.add(n)},removeEventListener:(t,n)=>{e.delete(n)}},hostSide:{postMessage:t=>{queueMicrotask(()=>{for(let n of[...e])n({data:t})})},addEventListener:(e,n)=>{t.add(n)},removeEventListener:(e,n)=>{t.delete(n)}}}}function $c(){return async({kind:e})=>{if(e!==`js`)throw Error(`createInProcessJsRealmFactory: only kind:js is supported`);let{realmSide:t,hostSide:n}=Qc(),r=e=>{if(e.data?.type!==`realm-init`)return;t.removeEventListener(`message`,r);let n=e.data;n.kind===`js`&&qc(n,t).catch(e=>{let n={type:`realm-error`,message:e instanceof Error?e.message:String(e)};t.postMessage(n)})};return t.addEventListener(`message`,r),{controlPort:n,terminate(){t.removeEventListener(`message`,r)}}}}function el(){return async({kind:e})=>{if(e!==`py`)throw Error(`createInProcessPyRealmFactory: only kind:py is supported`);let{realmSide:t,hostSide:n}=Qc(),r=e=>{if(e.data?.type!==`realm-init`)return;t.removeEventListener(`message`,r);let n=e.data;n.kind===`py`&&p(n,t).catch(e=>{let n={type:`realm-error`,message:e instanceof Error?e.message:String(e)};t.postMessage(n)})};return t.addEventListener(`message`,r),{controlPort:n,terminate(){t.removeEventListener(`message`,r)}}}}export{$c as createInProcessJsRealmFactory,el as createInProcessPyRealmFactory};
@@ -0,0 +1 @@
1
+ import{_ as e,l as t,o as n,t as r,u as i,v as a}from"./sync-exec-dispatch-D80ElZ8u.js";import{i as o,n as s,r as c,s as l}from"./sync-sab-wire-D_d0fd3b.js";function u(e,t){return Object.assign(Error(`${e}: ${t}`),{code:e})}function d(e){let t=p(e);if(m(t))return new Uint8Array(t.response);if(t.status>=200&&t.status<300)throw u(`EIO`,e.label);h(t,e.label)}function f(e){let t=d(e);try{return JSON.parse(new TextDecoder().decode(t))}catch{throw u(`EIO`,e.label)}}function p(e){let t=new XMLHttpRequest;try{t.open(e.method,e.url,!1),t.responseType=`arraybuffer`,t.timeout=e.timeoutMs,t.setRequestHeader(a,e.token),e.body?t.send(new Uint8Array(e.body)):t.send()}catch{throw u(`EIO`,e.label)}return t}function m(e){return e.status>=200&&e.status<300&&e.getResponseHeader(`x-slicc-fs`)===`1`}function h(e,t){throw u(e.getResponseHeader(`x-slicc-fs`)===`1`&&e.getResponseHeader(`x-slicc-fs-errno`)||`EIO`,t)}function g(e){return(r,a,o)=>{let s=f({method:`POST`,url:t,token:e,body:new TextEncoder().encode(JSON.stringify({...r,channel:n})),timeoutMs:a+i,label:o});if(!s||typeof s.stdout!=`string`||typeof s.stderr!=`string`||typeof s.exitCode!=`number`)throw u(`EIO`,o);return{stdout:s.stdout,stderr:s.stderr,exitCode:s.exitCode}}}function _(e,t){let n=e.getMutations();for(let e of n.deleted)t.rm(e);for(let e of n.created)e.isDirectory?t.mkdir(e.path):t.writeFile(e.path,e.content);for(let e of n.modified)t.writeFile(e.path,e.content);e.resetBaseline()}function v(e,t={}){let n=t.timeoutMs??12e4,{syncFs:i,fsBridge:a}=t,o=t.transport??g(e);return{run(e,t={}){let s=i?.wasUsed()===!0&&a!==void 0;s&&_(i,a);let c=`sync-exec bridge, '${Array.isArray(e)?e.join(` `):e}'`,l=r(t.timeout,n),u={command:e,...t.args===void 0?{}:{args:t.args},...t.input===void 0?{}:{stdin:t.input},...t.cwd===void 0?{}:{cwd:t.cwd},...t.env===void 0?{}:{env:t.env},timeoutMs:l};try{return o(u,l,c)}finally{s&&i.invalidate()}}}}function y(e){let t=e;return!t||typeof t.isFile!=`boolean`||typeof t.isDirectory!=`boolean`||typeof t.size!=`number`?null:{isFile:t.isFile,isDirectory:t.isDirectory,isSymbolicLink:t.isSymbolicLink,size:t.size,...typeof t.mode==`number`?{mode:t.mode}:{},...typeof t.mtimeMs==`number`?{mtimeMs:t.mtimeMs}:{}}}function b(e,t){return u(e,`sync-fs bridge, '${t}'`)}function x(t,n){let r=t.startsWith(`/`)?t:`/${t}`,i=e+r.split(`/`).map(encodeURIComponent).join(`/`);return n?`${i}?op=${n}`:i}function S(e,t={}){let n=t.timeoutMs??3e4;function r(t,r,i,a){return{method:t,url:x(r,a),token:e,...i?{body:i}:{},timeoutMs:n,label:`sync-fs bridge, '${r}'`}}return{readFile(e){return d(r(`GET`,e))},writeFile(e,t){d(r(`POST`,e,t))},stat(e){let t=y(f(r(`GET`,e,void 0,`stat`)));if(!t)throw b(`EIO`,e);return t},lstat(e){let t=y(f(r(`GET`,e,void 0,`lstat`)));if(!t)throw b(`EIO`,e);return t},readdir(e){let t=f(r(`GET`,e,void 0,`readdir`));if(!Array.isArray(t)||!t.every(e=>typeof e==`string`))throw b(`EIO`,e);return t},exists(e){let t=f(r(`GET`,e,void 0,`exists`));if(typeof t!=`boolean`)throw b(`EIO`,e);return t},mkdir(e){d(r(`POST`,e,void 0,`mkdir`))},rm(e){d(r(`POST`,e,void 0,`rm`))},rename(e,t){d(r(`POST`,e,C({arg2:t}),`rename`))},unlink(e){d(r(`POST`,e,C({}),`unlink`))},rmdir(e){d(r(`POST`,e,C({}),`rmdir`))},symlink(e,t){d(r(`POST`,t,C({arg2:e}),`symlink`))},readlink(e){let t=f(r(`GET`,e,void 0,`readlink`));if(typeof t!=`string`)throw b(`EIO`,e);return t},chmod(e,t){d(r(`POST`,e,C({mode:t}),`chmod`))},utimes(e,t,n){d(r(`POST`,e,C({atimeMs:t,mtimeMs:n}),`utimes`))}}}function C(e){return new TextEncoder().encode(JSON.stringify(e))}function w(e,t,n={}){let{header:r,window:i}=l(e),a=n.wait??((e,t,n,r)=>Atomics.wait(e,t,n,r)),d=n.now??(()=>performance.now()),f=0;function p(e,t,n){for(;;){let i=t-d();if(i<=0)throw u(`ETIMEDOUT`,n);if(a(r,0,1,i),Atomics.load(r,0)===2&&Atomics.load(r,1)===e)return;Atomics.load(r,0)===2&&Atomics.store(r,0,1)}}return{call(e,n,a){let l=++f,m=d()+n,h=null,g=0,_=0;try{for(;;){Atomics.store(r,0,1);let n=_===0?{type:c,id:l,req:e}:{type:s,id:l,offset:_};try{t.postMessage(n)}catch{throw u(`EIO`,a)}p(l,m,a);let o=Atomics.load(r,3),d=Atomics.load(r,4);if(Atomics.load(r,5)!==_||d<0||o<0||_+d>o)throw u(`EIO`,a);if(h===null&&(g=Atomics.load(r,2),h=new Uint8Array(o)),h.set(i.subarray(0,d),_),_+=d,_>=o)break;if(d===0)throw u(`EIO`,a)}}finally{Atomics.store(r,0,0)}return o(g,h)}}}function T(e,t){return u(e,`sync-sab bridge, '${t}'`)}function E(e,t={}){let n=t.timeoutMs??25e3;function r(t,r){let i=e.call(t,n,`sync-sab bridge, '${r}'`);if(!i.ok)throw T(i.errno,r);return i}function i(e,t){let n=r(e,t);if(n.ok&&n.kind===`bytes`)return n.bytes;throw T(`EIO`,t)}function a(e,t){let n=r(e,t);if(n.ok&&n.kind===`json`)return n.json;throw T(`EIO`,t)}return{readFile:e=>i({op:`read`,path:e},e),writeFile:(e,t)=>{r({op:`write`,path:e,body:t},e)},stat:e=>{let t=y(a({op:`stat`,path:e},e));if(!t)throw T(`EIO`,e);return t},lstat:e=>{let t=y(a({op:`lstat`,path:e},e));if(!t)throw T(`EIO`,e);return t},readdir:e=>{let t=a({op:`readdir`,path:e},e);if(!Array.isArray(t)||!t.every(e=>typeof e==`string`))throw T(`EIO`,e);return t},exists:e=>{let t=a({op:`exists`,path:e},e);if(typeof t!=`boolean`)throw T(`EIO`,e);return t},mkdir:e=>{r({op:`mkdir`,path:e},e)},rm:e=>{r({op:`rm`,path:e},e)},rename:(e,t)=>{r({op:`rename`,path:e,arg2:t},e)},unlink:e=>{r({op:`unlink`,path:e},e)},rmdir:e=>{r({op:`rmdir`,path:e},e)},symlink:(e,t)=>{r({op:`symlink`,path:t,arg2:e},t)},readlink:e=>{let t=a({op:`readlink`,path:e},e);if(typeof t!=`string`)throw T(`EIO`,e);return t},chmod:(e,t)=>{r({op:`chmod`,path:e,mode:t},e)},utimes:(e,t,n)=>{r({op:`utimes`,path:e,atimeMs:t,mtimeMs:n},e)}}}function D(e){return(t,r,a)=>{let o=e.call({...t,channel:n},r+i,a);if(!o.ok)throw u(o.errno,a);let s=o.kind===`json`?o.json:null;if(!s||typeof s.stdout!=`string`||typeof s.stderr!=`string`||typeof s.exitCode!=`number`)throw u(`EIO`,a);return{stdout:s.stdout,stderr:s.stderr,exitCode:s.exitCode}}}function O(e,t){if(!(!e.syncSab||typeof Atomics>`u`||typeof Atomics.wait!=`function`))return w(e.syncSab,t)}function k(e,t){return t?E(t):e.syncFsToken?S(e.syncFsToken):void 0}export{_ as a,v as i,O as n,D as r,k as t};
@@ -1 +1 @@
1
- import{o as e}from"./api-endpoint-DuEQRZ4g.js";import{h as t}from"./main-ke7UzEyb.js";async function n(){try{let e=await navigator.serviceWorker?.getRegistrations?.();e&&await Promise.all(e.map(e=>e.unregister().catch(()=>!1)))}catch{}try{let e=await indexedDB.databases();await Promise.all(e.filter(e=>!!e.name).map(e=>new Promise(t=>{let n=indexedDB.deleteDatabase(e.name);n.onsuccess=()=>t(),n.onerror=()=>t(),n.onblocked=()=>t()})))}catch{}try{let e=navigator.storage;if(typeof e?.getDirectory==`function`){let t=await e.getDirectory(),n=[];for await(let e of t.keys())n.push(e);await Promise.all(n.map(e=>t.removeEntry(e,{recursive:!0}).catch(()=>{})))}}catch{}}function r(r,i,a={}){if(r.dataset.recoveryBusy===`1`)return;let o=a.wipe??n,s=a.reload??(()=>location.reload()),c=i instanceof Error?i.message:String(i),l=a.verdict===`browser-wedged`,u=e(i),d=l||u,f=document.createElement(`div`);f.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let p=document.createElement(`h1`);p.style.color=`var(--s2-negative, #e34850)`,p.textContent=l?`Your browser needs a restart`:`Failed to start`;let m=document.createElement(`p`);m.style.color=`var(--s2-content-tertiary, #717171)`,m.textContent=c;let h=document.createElement(`div`);h.style.cssText=`display:flex;gap:0.75rem;justify-content:center;flex-wrap:wrap;margin-top:1.5rem;`;let g=document.createElement(`button`);g.type=`button`,g.textContent=`Reset local data & reload`,g.dataset.variant=d?`demoted`:`destructive`,g.style.cssText=d?`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;`:`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-negative, #e34850);background:var(--s2-negative, #e34850);color:#fff;border-radius:4px;`;let _=document.createElement(`button`);if(_.type=`button`,_.textContent=`Reload`,_.style.cssText=l?`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-accent, #0265dc);background:var(--s2-accent, #0265dc);color:#fff;border-radius:4px;`:`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;`,g.addEventListener(`click`,()=>{g.disabled=!0,_.disabled=!0,g.textContent=`Resetting…`,r.dataset.recoveryBusy=`1`,(async()=>{try{await o()}catch{}for(let e of t)try{localStorage.removeItem(e)}catch{}s()})()}),_.addEventListener(`click`,()=>{s()}),l){let e=document.createElement(`p`);e.style.cssText=`max-width:34rem;margin:1rem auto 0;`,e.textContent=`This browser has stopped starting web workers — a browser process issue, not a problem with your data. Quit the browser completely, reopen it, and come back. Your local data is intact; resetting it will not fix this.`,f.append(p,m,e),h.append(_,g)}else f.append(p,m),h.append(g,_);for(f.append(h);r.firstChild;)r.removeChild(r.firstChild);r.appendChild(f)}export{r as renderBootRecoveryScreen};
1
+ import{o as e}from"./api-endpoint-DuEQRZ4g.js";import{h as t}from"./main-DGILx2J0.js";async function n(){try{let e=await navigator.serviceWorker?.getRegistrations?.();e&&await Promise.all(e.map(e=>e.unregister().catch(()=>!1)))}catch{}try{let e=await indexedDB.databases();await Promise.all(e.filter(e=>!!e.name).map(e=>new Promise(t=>{let n=indexedDB.deleteDatabase(e.name);n.onsuccess=()=>t(),n.onerror=()=>t(),n.onblocked=()=>t()})))}catch{}try{let e=navigator.storage;if(typeof e?.getDirectory==`function`){let t=await e.getDirectory(),n=[];for await(let e of t.keys())n.push(e);await Promise.all(n.map(e=>t.removeEntry(e,{recursive:!0}).catch(()=>{})))}}catch{}}function r(r,i,a={}){if(r.dataset.recoveryBusy===`1`)return;let o=a.wipe??n,s=a.reload??(()=>location.reload()),c=i instanceof Error?i.message:String(i),l=a.verdict===`browser-wedged`,u=e(i),d=l||u,f=document.createElement(`div`);f.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let p=document.createElement(`h1`);p.style.color=`var(--s2-negative, #e34850)`,p.textContent=l?`Your browser needs a restart`:`Failed to start`;let m=document.createElement(`p`);m.style.color=`var(--s2-content-tertiary, #717171)`,m.textContent=c;let h=document.createElement(`div`);h.style.cssText=`display:flex;gap:0.75rem;justify-content:center;flex-wrap:wrap;margin-top:1.5rem;`;let g=document.createElement(`button`);g.type=`button`,g.textContent=`Reset local data & reload`,g.dataset.variant=d?`demoted`:`destructive`,g.style.cssText=d?`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;`:`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-negative, #e34850);background:var(--s2-negative, #e34850);color:#fff;border-radius:4px;`;let _=document.createElement(`button`);if(_.type=`button`,_.textContent=`Reload`,_.style.cssText=l?`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-accent, #0265dc);background:var(--s2-accent, #0265dc);color:#fff;border-radius:4px;`:`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;`,g.addEventListener(`click`,()=>{g.disabled=!0,_.disabled=!0,g.textContent=`Resetting…`,r.dataset.recoveryBusy=`1`,(async()=>{try{await o()}catch{}for(let e of t)try{localStorage.removeItem(e)}catch{}s()})()}),_.addEventListener(`click`,()=>{s()}),l){let e=document.createElement(`p`);e.style.cssText=`max-width:34rem;margin:1rem auto 0;`,e.textContent=`This browser has stopped starting web workers — a browser process issue, not a problem with your data. Quit the browser completely, reopen it, and come back. Your local data is intact; resetting it will not fix this.`,f.append(p,m,e),h.append(_,g)}else f.append(p,m),h.append(g,_);for(f.append(h);r.firstChild;)r.removeChild(r.firstChild);r.appendChild(f)}export{r as renderBootRecoveryScreen};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/readline-BOCWRKSR.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/xterm-B5LH8GIb.css"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./preload-helper-Czpn1I53.js";import{ht as n,mt as r}from"./wc-shell-BtEykt-v.js";import"./tool-ui-eSQ1g2I1.js";import{t as i}from"./permissions-surface-registry-CilCRwhh.js";import{storePendingHandle as a}from"./mount-picker-popup-qcWGbpG5.js";import{r as o,t as s}from"./hid-device-registry-B2R-0rNt.js";import"./browser-DGwroBSO.js";import{a as c,n as l}from"./serial-port-registry-CCqklAEr.js";import{a as u,t as d}from"./usb-device-registry--JwKRTYp.js";import"./usb-operations-v1mGAdRY.js";import{t as f}from"./terminal-session-client-ADzaWGFd.js";function p(e,t){let n=[],r=new Map,i=new Set;for(let a=0;a<e.length;a++){let o=e[a];o.startsWith(`-`)?t.has(o)?r.set(o,e[++a]??``):i.add(o):n.push(o)}return{positionals:n,flags:r,bools:i}}new TextDecoder(`utf-8`,{fatal:!1}),new TextEncoder;var m=new Set([`--vid`,`--pid`,`--baud`,`--data-bits`,`--stop-bits`,`--parity`,`--flow-control`,`--buffer-size`,`--bytes`,`--until`,`--timeout-ms`,`--dtr`,`--rts`,`--break`,`--__resolved`]);function h(e){return p(e,m)}function g(e,t){let n=/^0x/i.test(e)?parseInt(e,16):parseInt(e,10);if(!Number.isFinite(n)||Number.isNaN(n))throw Error(`invalid ${t}: '${e}'`);return n}function _(e){let t={};return e.has(`--vid`)&&(t.usbVendorId=g(e.get(`--vid`),`vid`)),e.has(`--pid`)&&(t.usbProductId=g(e.get(`--pid`),`pid`)),Object.keys(t).length>0?[t]:[]}`${l}${l}`;var v=new Set([`--port`,`--baud`,`--vid`,`--pid`]),y=115200;function b(e){return p(e,v)}`${y}`;var x=new Set([`--vid`,`--pid`,`--usage-page`,`--usage`,`--__resolved`,`--timeout`]);function S(e){return p(e,x)}function C(e,t){let n=/^0x/i.test(e)?parseInt(e,16):parseInt(e,10);if(!Number.isFinite(n)||Number.isNaN(n))throw Error(`invalid ${t}: '${e}'`);return n}function w(e){let t={};return e.has(`--vid`)&&(t.vendorId=C(e.get(`--vid`),`vid`)),e.has(`--pid`)&&(t.productId=C(e.get(`--pid`),`pid`)),e.has(`--usage-page`)&&(t.usagePage=C(e.get(`--usage-page`),`usage-page`)),e.has(`--usage`)&&(t.usage=C(e.get(`--usage`),`usage`)),Object.keys(t).length>0?[t]:[]}`${s}`;var T=new Set([`--vid`,`--pid`,`--class`,`--subclass`,`--protocol`,`--serial`,`--request-type`,`--recipient`,`--request`,`--value`,`--index`,`--__resolved`]);function E(e){return p(e,T)}function D(e,t){let n=/^0x/i.test(e)?parseInt(e,16):parseInt(e,10);if(!Number.isFinite(n)||Number.isNaN(n))throw Error(`invalid ${t}: '${e}'`);return n}function O(e){let t={};return e.has(`--vid`)&&(t.vendorId=D(e.get(`--vid`),`vid`)),e.has(`--pid`)&&(t.productId=D(e.get(`--pid`),`pid`)),e.has(`--class`)&&(t.classCode=D(e.get(`--class`),`class`)),e.has(`--subclass`)&&(t.subclassCode=D(e.get(`--subclass`),`subclass`)),e.has(`--protocol`)&&(t.protocolCode=D(e.get(`--protocol`),`protocol`)),e.has(`--serial`)&&(t.serialNumber=e.get(`--serial`)),Object.keys(t).length>0?[t]:[]}`${d}`;function k(e){let{border:t,...n}=r(e);return n}var A=`\x1B[34m/\x1B[0m \x1B[90m$\x1B[0m `,j=class{options;client;terminal=null;fitAddon=null;terminalHost=null;previewHost=null;previewUrls=[];hasPreview=!1;previewStateListener=null;resizeObserver=null;unwatchTheme=null;mountRoot=null;readline=null;disposed=!1;abortPromptLoop=null;programmaticResolve=null;isExecuting=!1;suppressOutput=!1;tabBusy=!1;constructor(e){this.options=e;let t=e.sid??`panel-terminal-${Date.now()}`;this.client=new f({client:e.client,sid:t,onEvent:e=>this.handleEvent(e)})}async mount(r){let{Terminal:i}=await t(async()=>{let{Terminal:e}=await import(`./xterm-C3BHN0de.js`);return{Terminal:e}},[]),{FitAddon:a}=await t(async()=>{let{FitAddon:e}=await import(`./addon-fit-DIOBYJe3.js`);return{FitAddon:e}},[]),{Readline:o}=await t(async()=>{let{Readline:t}=await import(`./readline-BOCWRKSR.js`).then(t=>e(t.default,1));return{Readline:t}},__vite__mapDeps([0,1]));await t(()=>Promise.resolve({}),__vite__mapDeps([2])),this.mountRoot=r,this.terminal=new i({cursorBlink:!0,fontSize:11,fontFamily:`'Source Code Pro', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace`,theme:k(r),convertEol:!0}),this.unwatchTheme?.(),this.unwatchTheme=n(r,()=>{this.terminal&&(this.terminal.options.theme=k(this.mountRoot))}),this.fitAddon=new a,this.terminal.loadAddon(this.fitAddon),r.replaceChildren(),this.terminalHost=document.createElement(`div`),this.terminalHost.className=`terminal-panel__terminal-host`,r.appendChild(this.terminalHost),this.previewHost=document.createElement(`div`),this.previewHost.className=`terminal-panel__preview`,r.appendChild(this.previewHost),this.terminal.open(this.terminalHost),this.fitAddon.fit(),this.resizeObserver=new ResizeObserver(()=>this.refit()),this.resizeObserver.observe(this.terminalHost),this.readline=new o,this.neutralizeReadlineHistoryPersistence(),this.terminal.loadAddon(this.readline),this.readline.setCtrlCHandler(()=>this.signalInterruptDuringExec()),this.setupInput(),this.terminal.writeln(`\x1B[1mslicc\x1B[0m \x1B[90mshell (kernel)\x1B[0m`),this.terminal.writeln(`\x1B[90mType "help" for available commands.\x1B[0m
2
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./preload-helper-Czpn1I53.js";import{ht as n,mt as r}from"./wc-shell-DOWfUNbp.js";import"./tool-ui-eSQ1g2I1.js";import{t as i}from"./permissions-surface-registry-CilCRwhh.js";import{storePendingHandle as a}from"./mount-picker-popup-qcWGbpG5.js";import{r as o,t as s}from"./hid-device-registry-B2R-0rNt.js";import"./browser-DGwroBSO.js";import{a as c,n as l}from"./serial-port-registry-CCqklAEr.js";import{a as u,t as d}from"./usb-device-registry--JwKRTYp.js";import"./usb-operations-v1mGAdRY.js";import{t as f}from"./terminal-session-client-ADzaWGFd.js";function p(e,t){let n=[],r=new Map,i=new Set;for(let a=0;a<e.length;a++){let o=e[a];o.startsWith(`-`)?t.has(o)?r.set(o,e[++a]??``):i.add(o):n.push(o)}return{positionals:n,flags:r,bools:i}}new TextDecoder(`utf-8`,{fatal:!1}),new TextEncoder;var m=new Set([`--vid`,`--pid`,`--baud`,`--data-bits`,`--stop-bits`,`--parity`,`--flow-control`,`--buffer-size`,`--bytes`,`--until`,`--timeout-ms`,`--dtr`,`--rts`,`--break`,`--__resolved`]);function h(e){return p(e,m)}function g(e,t){let n=/^0x/i.test(e)?parseInt(e,16):parseInt(e,10);if(!Number.isFinite(n)||Number.isNaN(n))throw Error(`invalid ${t}: '${e}'`);return n}function _(e){let t={};return e.has(`--vid`)&&(t.usbVendorId=g(e.get(`--vid`),`vid`)),e.has(`--pid`)&&(t.usbProductId=g(e.get(`--pid`),`pid`)),Object.keys(t).length>0?[t]:[]}`${l}${l}`;var v=new Set([`--port`,`--baud`,`--vid`,`--pid`]),y=115200;function b(e){return p(e,v)}`${y}`;var x=new Set([`--vid`,`--pid`,`--usage-page`,`--usage`,`--__resolved`,`--timeout`]);function S(e){return p(e,x)}function C(e,t){let n=/^0x/i.test(e)?parseInt(e,16):parseInt(e,10);if(!Number.isFinite(n)||Number.isNaN(n))throw Error(`invalid ${t}: '${e}'`);return n}function w(e){let t={};return e.has(`--vid`)&&(t.vendorId=C(e.get(`--vid`),`vid`)),e.has(`--pid`)&&(t.productId=C(e.get(`--pid`),`pid`)),e.has(`--usage-page`)&&(t.usagePage=C(e.get(`--usage-page`),`usage-page`)),e.has(`--usage`)&&(t.usage=C(e.get(`--usage`),`usage`)),Object.keys(t).length>0?[t]:[]}`${s}`;var T=new Set([`--vid`,`--pid`,`--class`,`--subclass`,`--protocol`,`--serial`,`--request-type`,`--recipient`,`--request`,`--value`,`--index`,`--__resolved`]);function E(e){return p(e,T)}function D(e,t){let n=/^0x/i.test(e)?parseInt(e,16):parseInt(e,10);if(!Number.isFinite(n)||Number.isNaN(n))throw Error(`invalid ${t}: '${e}'`);return n}function O(e){let t={};return e.has(`--vid`)&&(t.vendorId=D(e.get(`--vid`),`vid`)),e.has(`--pid`)&&(t.productId=D(e.get(`--pid`),`pid`)),e.has(`--class`)&&(t.classCode=D(e.get(`--class`),`class`)),e.has(`--subclass`)&&(t.subclassCode=D(e.get(`--subclass`),`subclass`)),e.has(`--protocol`)&&(t.protocolCode=D(e.get(`--protocol`),`protocol`)),e.has(`--serial`)&&(t.serialNumber=e.get(`--serial`)),Object.keys(t).length>0?[t]:[]}`${d}`;function k(e){let{border:t,...n}=r(e);return n}var A=`\x1B[34m/\x1B[0m \x1B[90m$\x1B[0m `,j=class{options;client;terminal=null;fitAddon=null;terminalHost=null;previewHost=null;previewUrls=[];hasPreview=!1;previewStateListener=null;resizeObserver=null;unwatchTheme=null;mountRoot=null;readline=null;disposed=!1;abortPromptLoop=null;programmaticResolve=null;isExecuting=!1;suppressOutput=!1;tabBusy=!1;constructor(e){this.options=e;let t=e.sid??`panel-terminal-${Date.now()}`;this.client=new f({client:e.client,sid:t,onEvent:e=>this.handleEvent(e)})}async mount(r){let{Terminal:i}=await t(async()=>{let{Terminal:e}=await import(`./xterm-C3BHN0de.js`);return{Terminal:e}},[]),{FitAddon:a}=await t(async()=>{let{FitAddon:e}=await import(`./addon-fit-DIOBYJe3.js`);return{FitAddon:e}},[]),{Readline:o}=await t(async()=>{let{Readline:t}=await import(`./readline-BOCWRKSR.js`).then(t=>e(t.default,1));return{Readline:t}},__vite__mapDeps([0,1]));await t(()=>Promise.resolve({}),__vite__mapDeps([2])),this.mountRoot=r,this.terminal=new i({cursorBlink:!0,fontSize:11,fontFamily:`'Source Code Pro', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace`,theme:k(r),convertEol:!0}),this.unwatchTheme?.(),this.unwatchTheme=n(r,()=>{this.terminal&&(this.terminal.options.theme=k(this.mountRoot))}),this.fitAddon=new a,this.terminal.loadAddon(this.fitAddon),r.replaceChildren(),this.terminalHost=document.createElement(`div`),this.terminalHost.className=`terminal-panel__terminal-host`,r.appendChild(this.terminalHost),this.previewHost=document.createElement(`div`),this.previewHost.className=`terminal-panel__preview`,r.appendChild(this.previewHost),this.terminal.open(this.terminalHost),this.fitAddon.fit(),this.resizeObserver=new ResizeObserver(()=>this.refit()),this.resizeObserver.observe(this.terminalHost),this.readline=new o,this.neutralizeReadlineHistoryPersistence(),this.terminal.loadAddon(this.readline),this.readline.setCtrlCHandler(()=>this.signalInterruptDuringExec()),this.setupInput(),this.terminal.writeln(`\x1B[1mslicc\x1B[0m \x1B[90mshell (kernel)\x1B[0m`),this.terminal.writeln(`\x1B[90mType "help" for available commands.\x1B[0m
3
3
  `),await this.client.open({cwd:this.options.cwd,env:this.options.env}),this.runPromptLoop()}refit(){this.fitAddon?.fit()}clearTerminal(){this.terminal?.clear()}async executeCommandInTerminal(e){let t=e.trim();if(!t)return{stdout:``,stderr:``,exitCode:0};if(!this.terminal||!this.readline)return this.client.exec(t);if(this.isExecuting||this.programmaticResolve||this.readline.getLine().length>0)return{stdout:``,stderr:`terminal is busy; finish current input first
4
4
  `,exitCode:1};let n=new Promise(e=>{this.programmaticResolve=e});return this.readline.updateLine(t),this.terminal.input(`\r`),n}setPreviewStateListener(e){this.previewStateListener=e,e?.(this.hasPreview)}dispose(){this.disposed=!0,this.abortPromptLoop?.(Error(`terminal disposed`)),this.abortPromptLoop=null,this.clearMediaPreview(),this.unwatchTheme?.(),this.unwatchTheme=null,this.mountRoot=null,this.resizeObserver?.disconnect(),this.resizeObserver=null,this.terminal?.dispose(),this.terminal=null,this.readline=null,this.fitAddon=null,this.terminalHost=null,this.previewHost=null,this.client.close(),this.client.dispose()}renderMediaPreview(e){if(!this.previewHost)return;let t=Uint8Array.from(atob(e.data),e=>e.charCodeAt(0)),n=URL.createObjectURL(new Blob([t],{type:e.mediaType}));this.previewUrls.push(n);let r=document.createElement(`div`);r.className=`terminal-panel__preview-item`;let i=document.createElement(`div`);i.className=`terminal-panel__preview-label`;let a=e.path.split(`/`).pop()??e.path;if(i.textContent=`${a} · ${e.mediaType}`,r.appendChild(i),e.mediaType.startsWith(`video/`)){let e=document.createElement(`video`);e.className=`terminal-panel__preview-media`,e.controls=!0,e.autoplay=!0,e.loop=!0,e.muted=!0,e.playsInline=!0,e.src=n,e.addEventListener(`loadedmetadata`,()=>this.refit(),{once:!0}),r.appendChild(e)}else{let e=document.createElement(`img`);e.className=`terminal-panel__preview-media`,e.alt=a,e.src=n,e.addEventListener(`load`,()=>this.refit(),{once:!0}),r.appendChild(e)}this.previewHost.appendChild(r),this.previewHost.classList.add(`terminal-panel__preview--visible`),this.hasPreview=!0,this.previewStateListener?.(!0)}clearMediaPreview(){for(let e of this.previewUrls)URL.revokeObjectURL(e);this.previewUrls=[],this.previewHost&&(this.previewHost.replaceChildren(),this.previewHost.classList.remove(`terminal-panel__preview--visible`)),this.hasPreview=!1,this.previewStateListener?.(!1)}async runPromptLoop(){for(;!this.disposed&&this.readline&&this.terminal;){let e;try{e=await this.readNextLine()}catch{break}finally{this.abortPromptLoop=null}let t=this.programmaticResolve!==null,n=await this.processLine(e,t);this.programmaticResolve&&=(this.programmaticResolve(n),null)}}readNextLine(){let e=this.terminal,t=this.readline;if(!e||!t)return Promise.reject(Error(`terminal not mounted`));let n=new Promise((e,t)=>{this.abortPromptLoop=t}),r=new Promise((n,r)=>{e.write(``,()=>{e.buffer.active.cursorX>0&&e.write(`\x1B[7m%\x1B[0m\r
5
5
  `),t.read(A).then(n,r)})});return Promise.race([r,n])}async processLine(e,t=!1){let n=e.trim();return!n||!t&&await this.tryRunPicker(n)?{stdout:``,stderr:``,exitCode:0}:this.runRemote(n)}async tryRunPicker(e){let t=M(e);if(t)return await this.runRemoteWithLocalPicker(e,t),!0;let n=z(e);if(n)return await this.runRemoteWithUsbPicker(n),!0;let r=B(e);if(r)return await this.runRemoteWithHidPicker(r),!0;let i=H(e);if(i)return await this.runRemoteWithSerialPicker(i),!0;let a=U(e);if(a)return await this.runRemoteWithEsptoolPicker(e,a),!0;let o=R(e);return o?(await this.runRemoteWithScreenShare(o.name),!0):!1}setupInput(){this.terminal&&(this.terminal.onData(e=>{e===` `&&this.handleTab()}),this.terminal.attachCustomKeyEventHandler(e=>!(e.type===`keydown`&&e.key===`Enter`&&this.tabBusy)))}signalInterruptDuringExec(){this.isExecuting&&(this.terminal?.writeln(`^C`),this.client.signal(`SIGINT`))}neutralizeReadlineHistoryPersistence(){let e=this.readline.history;e&&(e.entries=[],e.cursor=-1,e.saveToLocalStorage=()=>void 0,e.restoreFromLocalStorage=()=>void 0)}reanchorReadline(){if(!this.terminal||!this.readline)return;let e=this.readline.state;e&&(e.getTty().anchorRow=this.terminal.buffer.active.cursorY,e.refresh())}async handleTab(){if(!(!this.terminal||!this.readline)&&!(this.isExecuting||this.tabBusy)){this.tabBusy=!0,this.isExecuting=!0;try{let{currentWord:e,isFirstWord:t,compgenCmd:n}=G(this.readline.getLine());this.suppressOutput=!0;let r=``;try{r=(await this.client.exec(n)).stdout}finally{this.suppressOutput=!1}let i=r.split(`
@@ -227,7 +227,7 @@ import _slicc_fs_js as _bridge
227
227
  _build_slicc_module(_bridge)
228
228
  del _build_slicc_module
229
229
  del _bridge
230
- `)}const W=a(`pyodide`,`314.0.6`),G=`https://cdn.jsdelivr.net/pyodide/v${W}/full/`,K=`pyodide is not installed in node_modules: run \`ipk add pyodide@${W}\` (no network fallback)`,q={asmJs:`pyodide.asm.mjs`,asmWasm:`pyodide.asm.wasm`,stdlibZip:`python_stdlib.zip`,lockJson:`pyodide-lock.json`};async function ke(e){let t;try{t=await i(`pyodide/package.json`,e.fromDir,e.reader)}catch{return null}if(t.type!==`file`)return null;let r=n(t.path).dir;for(let t of Object.values(q))if(!await e.reader.exists(`${r}/${t}`))return null;return r}async function Ae(e,t){try{let[n,r,i,a]=await Promise.all([e.call(`vfs`,`readFile`,[`${t}/${q.asmJs}`]),e.call(`vfs`,`readFileBinary`,[`${t}/${q.asmWasm}`]),e.call(`vfs`,`readFileBinary`,[`${t}/${q.stdlibZip}`]),e.call(`vfs`,`readFile`,[`${t}/${q.lockJson}`])]);return{asmJsSource:n,asmWasmBytes:r instanceof Uint8Array?r:new Uint8Array(r),stdlibBytes:i instanceof Uint8Array?i:new Uint8Array(i),lockJsonString:a}}catch{return null}}function je(e,t){let n=e+q.asmWasm,r=globalThis.fetch,i=!0,a=(e,i)=>(typeof e==`string`?e:e instanceof URL?e.href:e.url)===n?Promise.resolve(new Response(t,{headers:{"Content-Type":`application/wasm`}})):r(e,i);return globalThis.fetch=a,{restore:()=>{i&&(i=!1,globalThis.fetch===a&&(globalThis.fetch=r))}}}async function Me(e,t,n){let r=await Ae(n,t);if(!r)throw Error(K);let i=URL.createObjectURL(new Blob([r.asmJsSource],{type:`text/javascript`})),a=URL.createObjectURL(new Blob([r.stdlibBytes],{type:`application/zip`})),s=`slicc-pyodide://local/${crypto.randomUUID()}/`,c=je(s,r.asmWasmBytes);try{let t=await import(i);return await e.loadPyodide({indexURL:s,lockFileContents:r.lockJsonString,stdLibURL:a,createPyodideModule:t.default,packageBaseUrl:o(`/workspace/python_wheels/`)})}finally{c.restore(),URL.revokeObjectURL(i),URL.revokeObjectURL(a)}}async function Ne(e,t,n=()=>import(`./pyodide-65Z_RapY.js`)){let r=[],i=[],a=new U(t),o;try{let t=await n();o=e.pyodideAssetRoot?await Me(t,e.pyodideAssetRoot,a):await t.loadPyodide({indexURL:e.pyodideIndexURL})}catch(e){a.dispose();let n={type:`realm-error`,message:`loadPyodide: ${e instanceof Error?e.message:String(e)}`};t.postMessage(n);return}let s=e=>{i.push(`Warning: ${e}\n`)},c=[],l,u;try{await Pe(o,a,s,Fe(e.pyodideAssetRoot));let{mountPyLiveVfs:n}=await import(`./py-live-vfs-DMc0LhCg.js`);l=n(o,e,t,s),l||(c=await Ue(o,e,s),await We(o,e,s)),await Ve(o,a,e,s),await Ge(o,a,s);try{o.FS.chdir(e.cwd)}catch{}Ke(o,e,r,i),u=await Ye(o,i),l?Je(l,s):await Xe(c,e,a,s)}catch(e){a.dispose();let n={type:`realm-error`,message:`${e instanceof Error?e.message:String(e)}${i.length?`\n${i.join(``)}`:``}`};t.postMessage(n);return}a.dispose();let d={type:`realm-done`,stdout:r.join(``),stderr:i.join(``),exitCode:u};t.postMessage(d)}const J=`/workspace/python_wheels`;async function Pe(e,t,n,r){await Ie(t,n,r);try{await e.loadPackage([`micropip`])}catch(e){n(`micropip preload failed: ${Z(e)}`)}}function Fe(e){return e?`${e}/${q.lockJson}`:`/workspace/node_modules/pyodide/pyodide-lock.json`}const Y=1e4,X=new WeakMap;function Ie(e,t,n){let r=X.get(e);if(r)return r;let i=Le(e,t,n);return X.set(e,i),i}async function Le(e,t,n){let r;try{if(!await e.call(`vfs`,`exists`,[n]))return;let t=await e.call(`vfs`,`readFile`,[n]),i=JSON.parse(t);for(let[e,t]of Object.entries(i.packages??{}))if(t?.file_name&&g(t.name??e)===`micropip`){r=t;break}}catch(e){t(`micropip wheel staging skipped: ${Z(e)}`);return}if(!r?.file_name||!r.sha256)return;let i=`${J}/${r.file_name}`;try{if(await e.call(`vfs`,`exists`,[i]))return;let t=await f(Re(e),{url:`${G}${r.file_name}`,sha256:r.sha256,label:`micropip wheel`,timeoutMs:Y});await e.call(`vfs`,`mkdir`,[J]),await e.call(`vfs`,`writeFileBinary`,[i,t])}catch(e){t(`micropip wheel staging failed: ${Z(e)}`)}}function Re(e){return async(t,n)=>{let r={method:n?.method??`GET`,...n?.headers?{headers:n.headers}:{},...n?.body===void 0?{}:{body:n.body}},i=await ze(e.call(`fetch`,`request`,[t,r]),n?.timeoutMs??Y,t);return{status:i.status,statusText:i.statusText,headers:i.headers,body:i.body instanceof Uint8Array?i.body:new Uint8Array(i.body),url:i.url}}}function ze(e,t,n){let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(`request to ${n} timed out after ${t}ms`)),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))}function Be(e){return{exists:t=>e.call(`vfs`,`exists`,[t]),readFile:t=>e.call(`vfs`,`readFile`,[t])}}async function Ve(e,t,n,r){let i=Be(t),a;try{a=await y(i,n.cwd)}catch(e){r(`manifest discovery failed: ${Z(e)}`);return}if(a===null)return;let o,s;try{let[e,t]=await Promise.all([E(i,a),D(i,a)]);o=e.dependencies,s=t}catch(e){r(`manifest read failed: ${Z(e)}`);return}let c=new Map;for(let e of s)c.set(g(e.name),e);for(let t of o){let{name:n}=v(t);if(!n)continue;let i=c.get(g(n));if(!i){r(`no integrity pin for \`${n}\`; run \`di sync\` to repair`);continue}await He(e,i,r)}}async function He(e,t,n){switch(t.source){case`pyodide-cdn`:try{await e.loadPackage([t.name])}catch(e){n(`activation of \`${t.name}\` failed: ${Z(e)}`)}return;case`pypi`:try{let n=`${J}/${t.fileName}`;await e.runPythonAsync(`import micropip; await micropip.install('emfs:${n}')`)}catch(e){n(`activation of \`${t.name}\` failed: ${Z(e)}`)}return;default:n(`unknown source \`${t.source}\` for \`${t.name}\`; skipping`)}}async function Ue(e,t,n){if(t.opfsMountDbName===void 0)return[];let r=t.pyodideMountDirs??[t.cwd,`/tmp`],i=t.mountPoints??[],a=new Set(i.map(e=>e.path));try{return(await Qe(e,r,t.opfsMountDbName,n,{skipMountPaths:a})).mounts}catch(e){return n(`VFS→Pyodide OPFS mount failed: ${Z(e)}`),[]}}async function We(e,t,n){let r=t.mountPoints??[];if(r.length!==0){try{we(e.FS,r.map(e=>e.path),n)}catch(e){n(`bomb overlay install failed: ${Z(e)}`)}try{await Ee(e,r.map(e=>e.path))}catch(e){n(`python mount guard install failed: ${Z(e)}`)}}}async function Ge(e,t,n){try{await Oe(e,t)}catch(e){n(`slicc.fs registration failed: ${Z(e)}`)}}function Ke(e,t,n,r){e.setStdout({batched:e=>n.push(e+`
230
+ `)}const W=a(`pyodide`,`314.0.6`),G=`https://cdn.jsdelivr.net/pyodide/v${W}/full/`,K=`pyodide is not installed in node_modules: run \`ipk add pyodide@${W}\` (no network fallback)`,q={asmJs:`pyodide.asm.mjs`,asmWasm:`pyodide.asm.wasm`,stdlibZip:`python_stdlib.zip`,lockJson:`pyodide-lock.json`};async function ke(e){let t;try{t=await i(`pyodide/package.json`,e.fromDir,e.reader)}catch{return null}if(t.type!==`file`)return null;let r=n(t.path).dir;for(let t of Object.values(q))if(!await e.reader.exists(`${r}/${t}`))return null;return r}async function Ae(e,t){try{let[n,r,i,a]=await Promise.all([e.call(`vfs`,`readFile`,[`${t}/${q.asmJs}`]),e.call(`vfs`,`readFileBinary`,[`${t}/${q.asmWasm}`]),e.call(`vfs`,`readFileBinary`,[`${t}/${q.stdlibZip}`]),e.call(`vfs`,`readFile`,[`${t}/${q.lockJson}`])]);return{asmJsSource:n,asmWasmBytes:r instanceof Uint8Array?r:new Uint8Array(r),stdlibBytes:i instanceof Uint8Array?i:new Uint8Array(i),lockJsonString:a}}catch{return null}}function je(e,t){let n=e+q.asmWasm,r=globalThis.fetch,i=!0,a=(e,i)=>(typeof e==`string`?e:e instanceof URL?e.href:e.url)===n?Promise.resolve(new Response(t,{headers:{"Content-Type":`application/wasm`}})):r(e,i);return globalThis.fetch=a,{restore:()=>{i&&(i=!1,globalThis.fetch===a&&(globalThis.fetch=r))}}}async function Me(e,t,n){let r=await Ae(n,t);if(!r)throw Error(K);let i=URL.createObjectURL(new Blob([r.asmJsSource],{type:`text/javascript`})),a=URL.createObjectURL(new Blob([r.stdlibBytes],{type:`application/zip`})),s=`slicc-pyodide://local/${crypto.randomUUID()}/`,c=je(s,r.asmWasmBytes);try{let t=await import(i);return await e.loadPyodide({indexURL:s,lockFileContents:r.lockJsonString,stdLibURL:a,createPyodideModule:t.default,packageBaseUrl:o(`/workspace/python_wheels/`)})}finally{c.restore(),URL.revokeObjectURL(i),URL.revokeObjectURL(a)}}async function Ne(e,t,n=()=>import(`./pyodide-65Z_RapY.js`)){let r=[],i=[],a=new U(t),o;try{let t=await n();o=e.pyodideAssetRoot?await Me(t,e.pyodideAssetRoot,a):await t.loadPyodide({indexURL:e.pyodideIndexURL})}catch(e){a.dispose();let n={type:`realm-error`,message:`loadPyodide: ${e instanceof Error?e.message:String(e)}`};t.postMessage(n);return}let s=e=>{i.push(`Warning: ${e}\n`)},c=[],l,u;try{await Pe(o,a,s,Fe(e.pyodideAssetRoot));let{mountPyLiveVfs:n}=await import(`./py-live-vfs-CvcPOToj.js`);l=n(o,e,t,s),l||(c=await Ue(o,e,s),await We(o,e,s)),await Ve(o,a,e,s),await Ge(o,a,s);try{o.FS.chdir(e.cwd)}catch{}Ke(o,e,r,i),u=await Ye(o,i),l?Je(l,s):await Xe(c,e,a,s)}catch(e){a.dispose();let n={type:`realm-error`,message:`${e instanceof Error?e.message:String(e)}${i.length?`\n${i.join(``)}`:``}`};t.postMessage(n);return}a.dispose();let d={type:`realm-done`,stdout:r.join(``),stderr:i.join(``),exitCode:u};t.postMessage(d)}const J=`/workspace/python_wheels`;async function Pe(e,t,n,r){await Ie(t,n,r);try{await e.loadPackage([`micropip`])}catch(e){n(`micropip preload failed: ${Z(e)}`)}}function Fe(e){return e?`${e}/${q.lockJson}`:`/workspace/node_modules/pyodide/pyodide-lock.json`}const Y=1e4,X=new WeakMap;function Ie(e,t,n){let r=X.get(e);if(r)return r;let i=Le(e,t,n);return X.set(e,i),i}async function Le(e,t,n){let r;try{if(!await e.call(`vfs`,`exists`,[n]))return;let t=await e.call(`vfs`,`readFile`,[n]),i=JSON.parse(t);for(let[e,t]of Object.entries(i.packages??{}))if(t?.file_name&&g(t.name??e)===`micropip`){r=t;break}}catch(e){t(`micropip wheel staging skipped: ${Z(e)}`);return}if(!r?.file_name||!r.sha256)return;let i=`${J}/${r.file_name}`;try{if(await e.call(`vfs`,`exists`,[i]))return;let t=await f(Re(e),{url:`${G}${r.file_name}`,sha256:r.sha256,label:`micropip wheel`,timeoutMs:Y});await e.call(`vfs`,`mkdir`,[J]),await e.call(`vfs`,`writeFileBinary`,[i,t])}catch(e){t(`micropip wheel staging failed: ${Z(e)}`)}}function Re(e){return async(t,n)=>{let r={method:n?.method??`GET`,...n?.headers?{headers:n.headers}:{},...n?.body===void 0?{}:{body:n.body}},i=await ze(e.call(`fetch`,`request`,[t,r]),n?.timeoutMs??Y,t);return{status:i.status,statusText:i.statusText,headers:i.headers,body:i.body instanceof Uint8Array?i.body:new Uint8Array(i.body),url:i.url}}}function ze(e,t,n){let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(`request to ${n} timed out after ${t}ms`)),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))}function Be(e){return{exists:t=>e.call(`vfs`,`exists`,[t]),readFile:t=>e.call(`vfs`,`readFile`,[t])}}async function Ve(e,t,n,r){let i=Be(t),a;try{a=await y(i,n.cwd)}catch(e){r(`manifest discovery failed: ${Z(e)}`);return}if(a===null)return;let o,s;try{let[e,t]=await Promise.all([E(i,a),D(i,a)]);o=e.dependencies,s=t}catch(e){r(`manifest read failed: ${Z(e)}`);return}let c=new Map;for(let e of s)c.set(g(e.name),e);for(let t of o){let{name:n}=v(t);if(!n)continue;let i=c.get(g(n));if(!i){r(`no integrity pin for \`${n}\`; run \`di sync\` to repair`);continue}await He(e,i,r)}}async function He(e,t,n){switch(t.source){case`pyodide-cdn`:try{await e.loadPackage([t.name])}catch(e){n(`activation of \`${t.name}\` failed: ${Z(e)}`)}return;case`pypi`:try{let n=`${J}/${t.fileName}`;await e.runPythonAsync(`import micropip; await micropip.install('emfs:${n}')`)}catch(e){n(`activation of \`${t.name}\` failed: ${Z(e)}`)}return;default:n(`unknown source \`${t.source}\` for \`${t.name}\`; skipping`)}}async function Ue(e,t,n){if(t.opfsMountDbName===void 0)return[];let r=t.pyodideMountDirs??[t.cwd,`/tmp`],i=t.mountPoints??[],a=new Set(i.map(e=>e.path));try{return(await Qe(e,r,t.opfsMountDbName,n,{skipMountPaths:a})).mounts}catch(e){return n(`VFS→Pyodide OPFS mount failed: ${Z(e)}`),[]}}async function We(e,t,n){let r=t.mountPoints??[];if(r.length!==0){try{we(e.FS,r.map(e=>e.path),n)}catch(e){n(`bomb overlay install failed: ${Z(e)}`)}try{await Ee(e,r.map(e=>e.path))}catch(e){n(`python mount guard install failed: ${Z(e)}`)}}}async function Ge(e,t,n){try{await Oe(e,t)}catch(e){n(`slicc.fs registration failed: ${Z(e)}`)}}function Ke(e,t,n,r){e.setStdout({batched:e=>n.push(e+`
231
231
  `)}),e.setStderr({batched:e=>r.push(e+`
232
232
  `)});let i=!1;e.setStdin({stdin:()=>i||!t.stdin?null:(i=!0,t.stdin)}),qe(e,t.env),e.globals.set(`__slicc_code`,t.code),e.globals.set(`__slicc_filename`,t.filename),e.globals.set(`__slicc_argv`,t.argv)}function qe(e,t){if(!(!t||Object.keys(t).length===0)){e.globals.set(`__slicc_env`,e.toPy(t));try{e.runPython(`import os; os.environ.update(__slicc_env)`)}finally{e.runPython(`del __slicc_env`)}}}function Je(e,t){try{e.flush()}catch(e){t(`Pyodide→VFS flush failed: ${Z(e)}`)}}async function Ye(e,t){let n;try{await e.runPythonAsync(`
233
233
  import sys
@@ -1 +1 @@
1
- import{l as e,n as t,t as n}from"./almost-bash-shell-headless-3-QEOXc2.js";import{n as r}from"./browser-Cja95Zor.js";import{c as i}from"./sudoers-BdBYQPUn.js";import{r as a}from"./sudo-fs-C6r_MIIY.js";import{n as o}from"./jsh-discovery-CnvNKojr.js";import{o as s}from"./just-bash-compat-B-SPHuh_.js";import{n as c,r as l}from"./supervisor-B8SqOt_K.js";function u(t,n){return new Map(Object.entries({HOME:e,PATH:o,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t.cwd,...n,...t.env}))}function d(e,t,n,i){let a=u(t,i);return r({fs:e,cwd:t.cwd,env:a,stdin:s(``),exec:(e,r)=>n.exec(e,{env:r?.env??Object.fromEntries(a),cwd:r?.cwd??t.cwd,args:r?.args,...r?.env===void 0?{}:{replaceEnv:!0}})})}const f={requestApproval:async()=>({decision:`deny`})};async function p(e){let r=h(e.fs,e.sudo),i=new t(r),a=new n({fs:r,cwd:`/workspace`,processManager:e.processManager,processOwner:{kind:`jshd`}}),o={exec:(e,t)=>a.getBash().exec(e,{env:t?.env??a.getEnv(),cwd:t?.cwd??`/workspace`,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})},s=c({fs:e.fs,processManager:e.processManager,lickManager:e.lickManager,...e.realmFactory?{realmFactory:e.realmFactory}:{},buildContext:e=>m(i,e,o)}),u=(await l(e.fs)).filter(e=>e.enabled);if(u.length===0)return[];let d=[];for(let e of u)try{await s.start(e),d.push(e.name)}catch{}return d}function m(e,t,n){return d(e,t,n)}function h(e,t){return a(e,{broker:t?.broker??f,getPolicy:t?.getPolicy??i,defaultDisposition:`allow`})}export{p as restoreEnabledJshdUnits};
1
+ import{l as e,n as t,t as n}from"./almost-bash-shell-headless-B0d_S9Oq.js";import{n as r}from"./browser-Cja95Zor.js";import{c as i}from"./sudoers-BdBYQPUn.js";import{r as a}from"./sudo-fs-C6r_MIIY.js";import{n as o}from"./jsh-discovery-CnvNKojr.js";import{o as s}from"./just-bash-compat-B-SPHuh_.js";import{n as c,r as l}from"./supervisor-BoHW4rOe.js";function u(t,n){return new Map(Object.entries({HOME:e,PATH:o,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:t.cwd,...n,...t.env}))}function d(e,t,n,i){let a=u(t,i);return r({fs:e,cwd:t.cwd,env:a,stdin:s(``),exec:(e,r)=>n.exec(e,{env:r?.env??Object.fromEntries(a),cwd:r?.cwd??t.cwd,args:r?.args,...r?.env===void 0?{}:{replaceEnv:!0}})})}const f={requestApproval:async()=>({decision:`deny`})};async function p(e){let r=h(e.fs,e.sudo),i=new t(r),a=new n({fs:r,cwd:`/workspace`,processManager:e.processManager,processOwner:{kind:`jshd`}}),o={exec:(e,t)=>a.getBash().exec(e,{env:t?.env??a.getEnv(),cwd:t?.cwd??`/workspace`,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})},s=c({fs:e.fs,processManager:e.processManager,lickManager:e.lickManager,...e.realmFactory?{realmFactory:e.realmFactory}:{},buildContext:e=>m(i,e,o)}),u=(await l(e.fs)).filter(e=>e.enabled);if(u.length===0)return[];let d=[];for(let e of u)try{await s.start(e),d.push(e.name)}catch{}return d}function m(e,t,n){return d(e,t,n)}function h(e,t){return a(e,{broker:t?.broker??f,getPolicy:t?.getPolicy??i,defaultDisposition:`allow`})}export{p as restoreEnabledJshdUnits};
@@ -88,4 +88,4 @@ Notes:
88
88
  `)),extraFiles:l}}function Te(e){return e.format===`lavfi`}async function Ee(e,t,n,r=()=>{}){let i=[];for(let[a,o]of e.inputs.entries()){if(Te(o)){i.push({ffmpegName:o.path,data:null,virtual:!0});continue}let e=n.fs.resolvePath(n.cwd,o.path);if(!await n.fs.exists(e))return{error:{stdout:``,stderr:`ffmpeg: input file not found: ${o.path}\n`,exitCode:1}};let s=x(t,ce(o,a));if(ve(o)){let c=await we(e,await n.fs.readFileBuffer(e),a,Ce(o),t,n,r);if(`error`in c){let{kind:e,file:t}=c.error,n=e===`unsafe`?`unsafe file name: ${t} (pass -safe 0 to allow it)`:`file not found: ${t}`;return{error:{stdout:``,stderr:`ffmpeg: concat list ${o.path}: ${n}\n`,exitCode:1}}}i.push({ffmpegName:s,data:_(c.listBytes),virtual:!1,extraFiles:c.extraFiles});continue}i.push({ffmpegName:s,data:await m(n.fs,e,r),virtual:!1})}return{inputs:i}}const De={threads:8,filterThreads:2};function Z(e){return e.some(e=>e===`-threads`||e.startsWith(`-threads:`))}function Oe(e,t=De,n=typeof navigator<`u`?navigator.hardwareConcurrency:void 0){let r=String(Math.max(1,Math.min(t.threads,n??t.threads))),i=[...e.inputs.flatMap(e=>e.raw),...e.outputOpts],a=[];i.includes(`-filter_threads`)||a.push(`-filter_threads`,String(t.filterThreads)),i.includes(`-filter_complex_threads`)||a.push(`-filter_complex_threads`,String(t.filterThreads));let o=e.inputs.map((e,t)=>{let n=[...t===0?a:[],...Z(e.raw)?[]:[`-threads`,r]];return n.length>0?{...e,raw:[...n,...e.raw]}:e}),s=Z(e.outputOpts)?e.outputOpts:[`-threads`,r,...e.outputOpts];return{...e,inputs:o,outputOpts:s}}function Q(e){return{stdout:``,stderr:`${e}ffmpeg: the multi-threaded core deadlocks with more than one input (ffmpeg starts a demux thread per input; emscripten proxies their pthread_create to a main thread blocked in exec; see #2810). Run without FFMPEG_CORE=mt so the single-threaded @ffmpeg/core handles this job.
89
89
  `,exitCode:1}}function ke(e,t,n){let r=[];for(let[n,i]of e.inputs.entries()){let e=t[n],a=i.raw;for(let t=0;t<a.length;t++){if(a[t]===`-i`){r.push(`-i`,e.virtual?a[t+1]:e.ffmpegName),t+=1;continue}r.push(a[t])}}return r.push(...e.outputOpts),r.push(n),r}function Ae(e){let t=[];for(let n of e)if(n.data!==null){for(let e of n.extraFiles??[])t.push({name:S(e.ffmpegName),data:e.data});t.push({name:S(n.ffmpegName),data:n.data})}return t}async function je(e){let t=`__health_probe`;try{await e.writeFile(t,new Uint8Array([0])),await e.deleteFile(t)}catch(e){if(s(e))throw e}}async function Me(e,t,n){await T(e,t),await E(e,n)}async function Ne(e,t,n,r){let i;try{i=await e.readFile(t)}catch(e){if(s(e))throw e;return{error:{stdout:``,stderr:r()||`ffmpeg: produced no output file for ${n}\n`,exitCode:1}}}let a=i instanceof Uint8Array?i:new TextEncoder().encode(typeof i==`string`?i:``);return a.byteLength===0?{error:{stdout:``,stderr:r()||`ffmpeg: produced an empty output file for ${n}\n`,exitCode:1}}:{bytes:a}}function Pe(e,t,n){return n?`__null_sink${e.id}`:C(e,t)}function $(e,t){return{stdout:``,stderr:`${e}ffmpeg: ${t instanceof Error?t.message:String(t)}\nffmpeg: the wasm core faulted and was recycled; retry the command (a large input may need to be split into smaller passes)
90
90
  `,exitCode:1}}async function Fe(e){let{ffmpeg:t,parsed:n,resolvedInputs:r,stage:i,outputName:a,outputPath:s,analysisSink:c,readStderr:u}=e,d=l()===o;if(d&&n.inputs.length>1)return{early:Q(u()),outputBytes:null};await w(t,i,Ae(r));let f=c?{...n,outputOpts:U(n.outputOpts)}:n,p=ke(d?Oe(f):f,r,a),m=await t.exec(p);if(m!==0)return{early:{stdout:``,stderr:u()||`ffmpeg: exited with code ${m}\n`,exitCode:m||1},outputBytes:null};if(c)return await je(t),{early:{stdout:``,stderr:u(),exitCode:0},outputBytes:null};let h=await Ne(t,a,s,u);return`error`in h?{early:h.error,outputBytes:null}:{early:null,outputBytes:h.bytes}}async function Ie(e){let{ffmpeg:t,logHandler:n,stage:i,outputName:a,readStderr:o,faulted:c}=e;try{t.off(`log`,n)}catch{}if(c)return null;try{return await Me(t,i,a),null}catch(e){return s(e)?(r(t),$(o(),e)):null}}async function Le(e,t,n,r,i){let{ffmpegEngineFromEnv:a}=await import(`./engine-CzMNXd8U.js`).then(e=>e.n),o=a(i.env),s=t.length===1?t[0].data:null;if(o===`wasm`||r||s===null)return o===`mediabunny`?{result:{stdout:``,stderr:`ffmpeg: FFMPEG_ENGINE=mediabunny cannot run this: analysis sinks, lavfi and concat inputs are wasm-only
91
- `,exitCode:1}}:{fallback:!0,note:null};let{runFfmpegFastPath:c}=await import(`./fast-path-CG_eXz0M.js`);return c({parsed:e,input:s,outputPath:i.fs.resolvePath(i.cwd,n),fs:i.fs,engine:o})}async function Re(e,t){let n=b(),r=[],i=await Ee(e,n,t,e=>r.push(e));if(`error`in i)return i.error;let a=i.inputs,o=e.outputPath,s=H(e),c=await Le(e,a,o,s,t);if(`result`in c)return c.result;let l=await ze({parsed:e,ctx:t,stage:n,resolvedInputs:a,outputPath:o,analysisSink:s}),u=[...c.note?[`ffmpeg: ${c.note}`]:[],...r].map(e=>`${e}\n`).join(``);return u?{...l,stderr:`${u}${l.stderr}`}:l}async function ze(e){let{parsed:t,ctx:i,stage:a,resolvedInputs:o,outputPath:s,analysisSink:c}=e,l=Pe(a,s,c),u=``,f;try{f=await n({onProgress:e=>{u+=`${e}\n`},ipk:W(i),preferMt:d(i.env)===`mt`})}catch(e){return{stdout:``,stderr:`${u}ffmpeg: failed to load wasm: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}let p=e=>{u+=`${e.message}\n`};f.on(`log`,p);let m=!1,h=null,g=null;try{let e=await Fe({ffmpeg:f,parsed:t,resolvedInputs:o,stage:a,outputName:l,outputPath:s,analysisSink:c,readStderr:()=>u});h=e.early,g=e.outputBytes}catch(e){m=!0,r(f),h=$(u,e)}finally{let e=await Ie({ffmpeg:f,logHandler:p,stage:a,outputName:l,readStderr:()=>u,faulted:m});e&&(h=e)}if(h)return h;try{await i.fs.writeFile(i.fs.resolvePath(i.cwd,s),g??new Uint8Array)}catch(e){return{stdout:``,stderr:`${u}ffmpeg: cannot write ${s}: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return{stdout:``,stderr:u,exitCode:0}}export{m as a,W as createIpkContextFromCtx,T as i,b as n,x as r,le as runFfmpeg,w as t};
91
+ `,exitCode:1}}:{fallback:!0,note:null};let{runFfmpegFastPath:c}=await import(`./fast-path-CriOTZyu.js`);return c({parsed:e,input:s,outputPath:i.fs.resolvePath(i.cwd,n),fs:i.fs,engine:o})}async function Re(e,t){let n=b(),r=[],i=await Ee(e,n,t,e=>r.push(e));if(`error`in i)return i.error;let a=i.inputs,o=e.outputPath,s=H(e),c=await Le(e,a,o,s,t);if(`result`in c)return c.result;let l=await ze({parsed:e,ctx:t,stage:n,resolvedInputs:a,outputPath:o,analysisSink:s}),u=[...c.note?[`ffmpeg: ${c.note}`]:[],...r].map(e=>`${e}\n`).join(``);return u?{...l,stderr:`${u}${l.stderr}`}:l}async function ze(e){let{parsed:t,ctx:i,stage:a,resolvedInputs:o,outputPath:s,analysisSink:c}=e,l=Pe(a,s,c),u=``,f;try{f=await n({onProgress:e=>{u+=`${e}\n`},ipk:W(i),preferMt:d(i.env)===`mt`})}catch(e){return{stdout:``,stderr:`${u}ffmpeg: failed to load wasm: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}let p=e=>{u+=`${e.message}\n`};f.on(`log`,p);let m=!1,h=null,g=null;try{let e=await Fe({ffmpeg:f,parsed:t,resolvedInputs:o,stage:a,outputName:l,outputPath:s,analysisSink:c,readStderr:()=>u});h=e.early,g=e.outputBytes}catch(e){m=!0,r(f),h=$(u,e)}finally{let e=await Ie({ffmpeg:f,logHandler:p,stage:a,outputName:l,readStderr:()=>u,faulted:m});e&&(h=e)}if(h)return h;try{await i.fs.writeFile(i.fs.resolvePath(i.cwd,s),g??new Uint8Array)}catch(e){return{stdout:``,stderr:`${u}ffmpeg: cannot write ${s}: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}return{stdout:``,stderr:u,exitCode:0}}export{m as a,W as createIpkContextFromCtx,T as i,b as n,x as r,le as runFfmpeg,w as t};