@vantran-se/openchamber-web 1.24.4 → 2.0.1

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 (367) hide show
  1. package/README.md +2 -8
  2. package/bin/lib/commands-connect-url.js +3 -8
  3. package/bin/lib/commands-tunnel.js +3 -0
  4. package/dist/assets/{CodeMirrorCommentWidgets-B4a0JkUz.js → CodeMirrorCommentWidgets-ntXIbhV2.js} +1 -1
  5. package/dist/assets/DiffView-CjxUovbM.js +4 -0
  6. package/dist/assets/FilesView-DFWD0RQR.js +17 -0
  7. package/dist/assets/{GitView-Byu2DY7s.js → GitView-BWa7e5vw.js} +4 -4
  8. package/dist/assets/{GuestAttachDialog-B808E0-d.js → GuestAttachDialog-DdOuyZzp.js} +1 -1
  9. package/dist/assets/GuestSurfacePane-DDfzid3U.js +1 -0
  10. package/dist/assets/{JsonTreeView-VW_7czo3.js → JsonTreeView-3sGwqexh.js} +1 -1
  11. package/dist/assets/LinearIssuesView-C6dpIdjw.js +1 -0
  12. package/dist/assets/MarkdownImageGallery-Q7YR_tl4.js +1 -0
  13. package/dist/assets/MarkdownRendererImpl-DxDV56bL.js +12 -0
  14. package/dist/assets/OnboardingScreen-rK4Stg__.js +1 -0
  15. package/dist/assets/{PatchDiff-DCjGhlYV.js → PatchDiff-DS-IMU1j.js} +1 -1
  16. package/dist/assets/{PierreDiffViewer-CEDZNkU2.js → PierreDiffViewer-DW23KWKZ.js} +1 -1
  17. package/dist/assets/PlanView-BCk_VobP.js +5 -0
  18. package/dist/assets/PluginPane-BPP1dbck.js +3 -0
  19. package/dist/assets/SettingsView-kMmrpn43.js +29 -0
  20. package/dist/assets/SettingsWindow-BpvD6IYQ.js +1 -0
  21. package/dist/assets/SubmoduleDiffSummary-BLttSS1X.js +1 -0
  22. package/dist/assets/ToolOutputDialog-CtqDqbyr.js +15 -0
  23. package/dist/assets/ToolPartDiffPreview-5FcKdyRy.js +8 -0
  24. package/dist/assets/{VirtualizedFileDiff-NU0FHFhT.js → VirtualizedFileDiff-C763hNCR.js} +4 -4
  25. package/dist/assets/{WalkthroughView-BZyjhqHv.js → WalkthroughView-lap5btCF.js} +2 -2
  26. package/dist/assets/appThemeRegistry-u4zw1l0B.js +1 -0
  27. package/dist/assets/{commitAndPush-BDftrjr6.js → commitAndPush-CwGJfJG-.js} +1 -1
  28. package/dist/assets/{computeVirtualFileMetrics-DlWlEM3x.js → computeVirtualFileMetrics-DW5jjX4n.js} +1 -1
  29. package/dist/assets/de-CndEg67T.js +10 -0
  30. package/dist/assets/es-DglvPlaC.js +16 -0
  31. package/dist/assets/fr-DejPCpbS.js +14 -0
  32. package/dist/assets/index-C2r64QfD.js +1 -0
  33. package/dist/assets/index-CLcM8HKx.css +1 -0
  34. package/dist/assets/index-CvLgnuNI.js +41 -0
  35. package/dist/assets/{isDiffPlainText-CO4e5J_S.js → isDiffPlainText-D47a6hMP.js} +1 -1
  36. package/dist/assets/{isFilePlainText-ue6kCou7.js → isFilePlainText-B-mGgeKl.js} +1 -1
  37. package/dist/assets/ja-CVpQawCd.js +16 -0
  38. package/dist/assets/ko-Bw446h9j.js +16 -0
  39. package/dist/assets/main-Bz4WWXbr.js +2 -0
  40. package/dist/assets/main-oreqDsOV.js +896 -0
  41. package/dist/assets/{markdownCore-CK48LG0z.js → markdownCore-D2e5sp9y.js} +4 -4
  42. package/dist/assets/miniChat-D1v2gsBI.js +2 -0
  43. package/dist/assets/mobile-DBj3lCf2.js +2 -0
  44. package/dist/assets/{patchFileDiff-D7QVlovD.js → patchFileDiff-BpeUOV91.js} +3 -3
  45. package/dist/assets/pl-BYNlPdhm.js +16 -0
  46. package/dist/assets/pt-BR-CL-Yfv9H.js +16 -0
  47. package/dist/assets/renderElectronMiniChatApp-DVtfEB2z.js +2 -0
  48. package/dist/assets/renderMobileApp-DFp9-xbG.js +25 -0
  49. package/dist/assets/runtimeEndpointReset-CsIpUep1.js +27 -0
  50. package/dist/assets/scheduledTasksApi-B5OHVpPM.js +1 -0
  51. package/dist/assets/{shikiHighlight-BPu3JiQs.js → shikiHighlight-DNm2Z_Jc.js} +1 -1
  52. package/dist/assets/{textMateThemeFromAppTheme-DWqRPo9A.js → textMateThemeFromAppTheme-DGF2kG7g.js} +1 -1
  53. package/dist/assets/tr-DzmbxLy-.js +7 -0
  54. package/dist/assets/uk-C7vQnwro.js +16 -0
  55. package/dist/assets/useAppFontEffects-Ci3FEaPf.js +7337 -0
  56. package/dist/assets/{useInlineCommentController-CgS0fnw_.js → useInlineCommentController-CuUuakrt.js} +2 -2
  57. package/dist/assets/useRootScrollLock-CQIsyERq.js +2 -0
  58. package/dist/assets/{vendor-codemirror-language-data-Bx2EHc1O.js → vendor-codemirror-language-data-CQa7_1cr.js} +2 -2
  59. package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
  60. package/dist/assets/vendor-opencode-client-_BAHQo4R.js +12 -0
  61. package/dist/assets/{vendor-remixicon-react-BDmGmFCA.js → vendor-remixicon-react-D6dZ0UwF.js} +1 -1
  62. package/dist/assets/{vendor-zod-CgAdXWZO.js → vendor-zod-Gea9uBlY.js} +1 -1
  63. package/dist/assets/{web-components-DxX8bZ1o.js → web-components-B6tKQyJN.js} +2 -2
  64. package/dist/assets/zh-CN-Cl0srS-z.js +16 -0
  65. package/dist/assets/zh-TW-DtII5bDb.js +16 -0
  66. package/dist/index.html +13 -7
  67. package/dist/mini-chat.html +5 -5
  68. package/dist/mobile.html +5 -5
  69. package/package.json +6 -5
  70. package/server/index.d.ts +1 -0
  71. package/server/index.js +246 -91
  72. package/server/lib/agent-tool/DOCUMENTATION.md +32 -15
  73. package/server/lib/agent-tool/runtime.js +135 -54
  74. package/server/lib/agent-tool/runtime.test.js +155 -87
  75. package/server/lib/browser-control/DOCUMENTATION.md +37 -2
  76. package/server/lib/browser-control/provider.js +217 -0
  77. package/server/lib/browser-control/provider.test.js +251 -0
  78. package/server/lib/context-obligatory/runtime.js +61 -50
  79. package/server/lib/context-obligatory/runtime.test.js +62 -162
  80. package/server/lib/event-stream/DOCUMENTATION.md +12 -1
  81. package/server/lib/event-stream/delta-coalescer.js +0 -0
  82. package/server/lib/event-stream/delta-coalescer.test.js +68 -57
  83. package/server/lib/event-stream/directory-ws-bridge.js +1 -1
  84. package/server/lib/event-stream/global-hub.js +10 -1
  85. package/server/lib/event-stream/global-hub.test.js +27 -26
  86. package/server/lib/event-stream/index.js +6 -0
  87. package/server/lib/event-stream/protocol.js +26 -19
  88. package/server/lib/event-stream/protocol.test.js +18 -7
  89. package/server/lib/event-stream/rebind.test.js +5 -5
  90. package/server/lib/event-stream/runtime.test.js +17 -15
  91. package/server/lib/event-stream/translate-v2.js +313 -0
  92. package/server/lib/event-stream/translate-v2.test.js +209 -0
  93. package/server/lib/event-stream/upstream-reader.test.js +16 -16
  94. package/server/lib/fs/DOCUMENTATION.md +4 -2
  95. package/server/lib/fs/byte-range.js +35 -0
  96. package/server/lib/fs/byte-range.test.js +31 -0
  97. package/server/lib/fs/routes.js +47 -42
  98. package/server/lib/fs/routes.test.js +123 -18
  99. package/server/lib/git/service.js +12 -0
  100. package/server/lib/github/DOCUMENTATION.md +1 -1
  101. package/server/lib/github/pr-status.js +22 -2
  102. package/server/lib/github/pr-status.test.js +27 -14
  103. package/server/lib/guests/DOCUMENTATION.md +13 -0
  104. package/server/lib/guests/catalog.js +12 -0
  105. package/server/lib/guests/catalog.test.js +33 -0
  106. package/server/lib/guests/routes.js +10 -1
  107. package/server/lib/guests/service.js +192 -14
  108. package/server/lib/guests/service.test.js +201 -1
  109. package/server/lib/guests/surface.js +630 -0
  110. package/server/lib/guests/surface.test.js +486 -0
  111. package/server/lib/markdown-image-grants/routes.js +18 -5
  112. package/server/lib/markdown-image-grants/routes.test.js +9 -6
  113. package/server/lib/message-queue/DOCUMENTATION.md +33 -22
  114. package/server/lib/message-queue/runtime.js +155 -100
  115. package/server/lib/message-queue/runtime.test.js +168 -82
  116. package/server/lib/notifications/DOCUMENTATION.md +28 -0
  117. package/server/lib/notifications/control-stream.http.test.js +68 -0
  118. package/server/lib/notifications/emitter-runtime.js +15 -0
  119. package/server/lib/notifications/emitter-runtime.test.js +32 -0
  120. package/server/lib/notifications/push-runtime.js +5 -1
  121. package/server/lib/notifications/push-runtime.test.js +2 -2
  122. package/server/lib/notifications/routes.js +1 -1
  123. package/server/lib/notifications/runtime.js +115 -26
  124. package/server/lib/notifications/template-runtime.js +13 -15
  125. package/server/lib/notifications/template-runtime.test.js +16 -9
  126. package/server/lib/notifications/trigger-runtime.test.js +187 -0
  127. package/server/lib/openchamber-control/DOCUMENTATION.md +10 -0
  128. package/server/lib/openchamber-control/actions.js +3 -2
  129. package/server/lib/openchamber-control/error.js +1 -1
  130. package/server/lib/openchamber-control/file-open.js +59 -0
  131. package/server/lib/openchamber-control/file-open.test.js +57 -0
  132. package/server/lib/openchamber-control/routes.test.js +12 -0
  133. package/server/lib/openchamber-control/service.js +102 -49
  134. package/server/lib/openchamber-control/service.test.js +84 -44
  135. package/server/lib/openchamber-sessions/archive-store.js +224 -0
  136. package/server/lib/openchamber-sessions/archive-store.test.js +187 -0
  137. package/server/lib/openchamber-sessions/opencode-client.js +22 -0
  138. package/server/lib/openchamber-sessions/routes.js +398 -328
  139. package/server/lib/openchamber-sessions/routes.test.js +777 -740
  140. package/server/lib/openchamber-sessions/session-metadata-store.js +285 -0
  141. package/server/lib/openchamber-sessions/session-metadata-store.test.js +259 -0
  142. package/server/lib/opencode/DOCUMENTATION.md +449 -29
  143. package/server/lib/opencode/agents.js +233 -327
  144. package/server/lib/opencode/auth.js +41 -44
  145. package/server/lib/opencode/auth.test.js +92 -0
  146. package/server/lib/opencode/cli-upgrade.d.ts +4 -0
  147. package/server/lib/opencode/cli-upgrade.js +18 -0
  148. package/server/lib/opencode/cli-upgrade.test.js +36 -0
  149. package/server/lib/opencode/commands.js +164 -145
  150. package/server/lib/opencode/compatibility.d.ts +16 -0
  151. package/server/lib/opencode/compatibility.js +88 -0
  152. package/server/lib/opencode/compatibility.test.js +62 -0
  153. package/server/lib/opencode/config-entity-routes.js +58 -29
  154. package/server/lib/opencode/config-entity-v2.test.js +290 -0
  155. package/server/lib/opencode/config-mutation-response.js +17 -7
  156. package/server/lib/opencode/config-mutation-response.test.js +4 -7
  157. package/server/lib/opencode/config-paths.test.js +2 -2
  158. package/server/lib/opencode/config-v2.d.ts +183 -0
  159. package/server/lib/opencode/config-v2.js +801 -0
  160. package/server/lib/opencode/config-v2.test.js +466 -0
  161. package/server/lib/opencode/credential-db.js +144 -0
  162. package/server/lib/opencode/credential-db.test.js +104 -0
  163. package/server/lib/opencode/env-runtime.js +48 -9
  164. package/server/lib/opencode/env-runtime.test.js +45 -0
  165. package/server/lib/opencode/feature-routes-runtime.js +15 -5
  166. package/server/lib/opencode/lifecycle-process.test.js +7 -4
  167. package/server/lib/opencode/lifecycle.js +85 -30
  168. package/server/lib/opencode/lifecycle.test.js +80 -8
  169. package/server/lib/opencode/login-shell-env.js +27 -0
  170. package/server/lib/opencode/managed-config-file.js +119 -0
  171. package/server/lib/opencode/managed-config-file.test.js +152 -0
  172. package/server/lib/opencode/managed-plugin-config.js +33 -13
  173. package/server/lib/opencode/mcp.js +43 -149
  174. package/server/lib/opencode/network-runtime.js +6 -7
  175. package/server/lib/opencode/openchamber-routes.test.js +2 -5
  176. package/server/lib/opencode/plugin-routes.js +3 -3
  177. package/server/lib/opencode/plugin-routes.test.js +6 -24
  178. package/server/lib/opencode/plugins.js +91 -40
  179. package/server/lib/opencode/plugins.test.js +28 -15
  180. package/server/lib/opencode/providers.js +63 -83
  181. package/server/lib/opencode/providers.test.js +128 -59
  182. package/server/lib/opencode/proxy-agent-wiring.test.js +4 -2
  183. package/server/lib/opencode/proxy.js +179 -129
  184. package/server/lib/opencode/pwa-manifest-routes.js +4 -2
  185. package/server/lib/opencode/pwa-manifest-routes.test.js +3 -2
  186. package/server/lib/opencode/response-envelope.js +14 -0
  187. package/server/lib/opencode/response-envelope.test.js +23 -0
  188. package/server/lib/opencode/routes-upgrade.test.js +73 -116
  189. package/server/lib/opencode/routes.js +121 -428
  190. package/server/lib/opencode/server-utils-runtime.js +10 -4
  191. package/server/lib/opencode/session-activity.js +78 -0
  192. package/server/lib/opencode/session-runtime.js +21 -10
  193. package/server/lib/opencode/session-runtime.test.js +9 -9
  194. package/server/lib/opencode/settings-helpers.js +9 -9
  195. package/server/lib/opencode/settings-helpers.test.js +7 -12
  196. package/server/lib/opencode/settings-registry.json +6 -8
  197. package/server/lib/opencode/settings-runtime.js +18 -1
  198. package/server/lib/opencode/settings-runtime.test.js +31 -2
  199. package/server/lib/opencode/shared.js +54 -22
  200. package/server/lib/opencode/shared.test.js +8 -4
  201. package/server/lib/opencode/shutdown-runtime.js +54 -7
  202. package/server/lib/opencode/shutdown-runtime.test.js +224 -30
  203. package/server/lib/opencode/skill-routes.js +23 -24
  204. package/server/lib/opencode/skills.js +7 -5
  205. package/server/lib/opencode/tunnel-wiring-runtime.js +2 -1
  206. package/server/lib/opencode/upgrade-capability.test.js +1 -1
  207. package/server/lib/opencode/v1-migration-topup.js +288 -0
  208. package/server/lib/opencode/v1-migration-topup.test.js +266 -0
  209. package/server/lib/opencode/v2-install.d.ts +8 -0
  210. package/server/lib/opencode/v2-install.js +158 -0
  211. package/server/lib/opencode/v2-install.test.js +124 -0
  212. package/server/lib/opencode/watcher.js +10 -3
  213. package/server/lib/opencode/watcher.test.js +17 -21
  214. package/server/lib/opencode/websearch-config.js +66 -0
  215. package/server/lib/package-manager.js +55 -68
  216. package/server/lib/package-manager.test.js +241 -75
  217. package/server/lib/permission-auto-accept/runtime.js +38 -22
  218. package/server/lib/permission-auto-accept/runtime.test.js +39 -17
  219. package/server/lib/quota/DOCUMENTATION.md +4 -0
  220. package/server/lib/quota/providers/xai.js +4 -4
  221. package/server/lib/relay/tunnel-host.js +4 -1
  222. package/server/lib/relay/tunnel-host.test.js +7 -0
  223. package/server/lib/routing/DOCUMENTATION.md +52 -21
  224. package/server/lib/routing/defaults.js +23 -6
  225. package/server/lib/routing/jev.js +17 -7
  226. package/server/lib/routing/routes.http.test.js +68 -33
  227. package/server/lib/routing/routes.js +65 -22
  228. package/server/lib/routing/runtime.js +145 -48
  229. package/server/lib/routing/runtime.test.js +79 -55
  230. package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -0
  231. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +51 -46
  232. package/server/lib/scheduled-tasks/runtime.js +81 -74
  233. package/server/lib/scheduled-tasks/runtime.test.js +53 -1
  234. package/server/lib/session-assist/DOCUMENTATION.md +8 -3
  235. package/server/lib/session-assist/context.js +122 -46
  236. package/server/lib/session-assist/context.test.js +117 -49
  237. package/server/lib/session-assist/runtime.js +52 -22
  238. package/server/lib/session-assist/runtime.test.js +145 -173
  239. package/server/lib/session-goal/DOCUMENTATION.md +23 -15
  240. package/server/lib/session-goal/create.js +9 -12
  241. package/server/lib/session-goal/create.test.js +27 -28
  242. package/server/lib/session-goal/runtime.js +164 -77
  243. package/server/lib/session-goal/runtime.test.js +271 -519
  244. package/server/lib/session-knowledge/DOCUMENTATION.md +5 -0
  245. package/server/lib/session-knowledge/runtime.js +59 -41
  246. package/server/lib/session-knowledge/runtime.test.js +90 -20
  247. package/server/lib/small-model/DOCUMENTATION.md +154 -208
  248. package/server/lib/small-model/client.js +113 -0
  249. package/server/lib/small-model/index.js +296 -158
  250. package/server/lib/small-model/index.test.js +423 -256
  251. package/server/lib/small-model/routes.js +1 -1
  252. package/server/lib/spaces/DOCUMENTATION.md +807 -0
  253. package/server/lib/spaces/code-in-bait.js +185 -0
  254. package/server/lib/spaces/code-in.js +641 -0
  255. package/server/lib/spaces/code-in.test.js +1048 -0
  256. package/server/lib/spaces/errors.js +8 -0
  257. package/server/lib/spaces/exec-http.js +94 -0
  258. package/server/lib/spaces/gatekeeper-channel.js +202 -0
  259. package/server/lib/spaces/gatekeeper-channel.test.js +215 -0
  260. package/server/lib/spaces/gatekeeper-program.cjs +914 -0
  261. package/server/lib/spaces/gatekeeper-program.test.js +1391 -0
  262. package/server/lib/spaces/hardening.js +457 -0
  263. package/server/lib/spaces/hardening.test.js +368 -0
  264. package/server/lib/spaces/host-git.js +127 -0
  265. package/server/lib/spaces/host-git.test.js +137 -0
  266. package/server/lib/spaces/labels.js +234 -0
  267. package/server/lib/spaces/labels.test.js +219 -0
  268. package/server/lib/spaces/layout.js +184 -0
  269. package/server/lib/spaces/layout.test.js +30 -0
  270. package/server/lib/spaces/manager.js +82 -0
  271. package/server/lib/spaces/manager.test.js +114 -0
  272. package/server/lib/spaces/places/code-in.docker.live.test.js +216 -0
  273. package/server/lib/spaces/places/contract-suite.js +156 -0
  274. package/server/lib/spaces/places/contract.docker.live.test.js +7 -0
  275. package/server/lib/spaces/places/contract.test.js +6 -0
  276. package/server/lib/spaces/places/docker-engine.js +126 -0
  277. package/server/lib/spaces/places/docker-live-support.js +202 -0
  278. package/server/lib/spaces/places/docker-tools.js +186 -0
  279. package/server/lib/spaces/places/docker.js +587 -0
  280. package/server/lib/spaces/places/docker.test.js +1610 -0
  281. package/server/lib/spaces/places/escape-suite.js +1018 -0
  282. package/server/lib/spaces/places/escape.docker.live.test.js +7 -0
  283. package/server/lib/spaces/places/fake-docker.js +375 -0
  284. package/server/lib/spaces/places/memory-place.js +103 -0
  285. package/server/lib/spaces/places/packed.docker.live.test.js +77 -0
  286. package/server/lib/spaces/places/registry.js +43 -0
  287. package/server/lib/spaces/places/registry.test.js +50 -0
  288. package/server/lib/spaces/places/server.docker.live.test.js +225 -0
  289. package/server/lib/spaces/run-command.js +261 -0
  290. package/server/lib/spaces/run-command.test.js +396 -0
  291. package/server/lib/spaces/space-server.js +190 -0
  292. package/server/lib/spaces/space-server.test.js +335 -0
  293. package/server/lib/spaces/tools-filler.js +82 -0
  294. package/server/lib/spaces/tools-filler.test.js +148 -0
  295. package/server/lib/spaces/tools-pack.js +49 -0
  296. package/server/lib/spaces/tools-pack.test.js +57 -0
  297. package/server/lib/spaces/tools.js +138 -0
  298. package/server/lib/spaces/tools.test.js +153 -0
  299. package/server/lib/tts/openai-sdk.js +11 -0
  300. package/server/lib/tts/service.js +7 -5
  301. package/server/lib/tts/stt.js +3 -2
  302. package/server/lib/tunnels/DOCUMENTATION.md +2 -0
  303. package/server/lib/tunnels/routes.js +7 -0
  304. package/server/lib/tunnels/routes.test.js +55 -0
  305. package/server/lib/ui-auth/ui-auth.js +38 -2
  306. package/server/lib/ui-auth/ui-auth.test.js +42 -0
  307. package/server/lib/ui-auth/ui-passkeys.js +12 -10
  308. package/server/lib/walkthrough/DOCUMENTATION.md +10 -1
  309. package/server/lib/walkthrough/pull-request.js +61 -8
  310. package/server/lib/walkthrough/pull-request.test.js +54 -1
  311. package/server/lib/walkthrough/routes.js +20 -0
  312. package/server/lib/walkthrough/routes.test.js +19 -0
  313. package/server/opencode-proxy.test.js +190 -166
  314. package/server/opencode-worktree-readiness.test.js +5 -4
  315. package/dist/assets/DiffView-B2CD9wC8.js +0 -4
  316. package/dist/assets/FilesView-C4vMFclc.js +0 -13
  317. package/dist/assets/LinearIssuesView-EzGNCGrd.js +0 -1
  318. package/dist/assets/MarkdownImageGallery-B2YUDFaB.js +0 -1
  319. package/dist/assets/MarkdownRendererImpl-B4ikIzR3.js +0 -12
  320. package/dist/assets/OnboardingScreen-CQHBSTEi.js +0 -1
  321. package/dist/assets/PlanView-D3x-pTkZ.js +0 -5
  322. package/dist/assets/PluginPane-DEcgDQ9h.js +0 -3
  323. package/dist/assets/SettingsView-CSinuH-1.js +0 -29
  324. package/dist/assets/SettingsWindow-B5CHoJFZ.js +0 -1
  325. package/dist/assets/SubmoduleDiffSummary-oxeACCWs.js +0 -1
  326. package/dist/assets/ToolOutputDialog-tLNWmfcW.js +0 -15
  327. package/dist/assets/ToolPartDiffPreview-CflzmK-x.js +0 -8
  328. package/dist/assets/appThemeRegistry-DLicw4dH.js +0 -1
  329. package/dist/assets/de-Bro6_zyl.js +0 -10
  330. package/dist/assets/es-Bb9XQZvd.js +0 -16
  331. package/dist/assets/fr-Dgfzn-IL.js +0 -14
  332. package/dist/assets/index-CtQNmqUL.js +0 -1
  333. package/dist/assets/index-DqaMWNrC.css +0 -1
  334. package/dist/assets/index-Dqc6USl3.js +0 -40
  335. package/dist/assets/ja-BYsakGFh.js +0 -16
  336. package/dist/assets/ko-BSaQz9aN.js +0 -16
  337. package/dist/assets/main-B62_pjL5.js +0 -2
  338. package/dist/assets/main-BEdcOI2P.js +0 -896
  339. package/dist/assets/miniChat-LT8Rqofr.js +0 -2
  340. package/dist/assets/mobile-CqarEynh.js +0 -2
  341. package/dist/assets/pl-OIviPdoj.js +0 -16
  342. package/dist/assets/pt-BR-Cltg-E6s.js +0 -16
  343. package/dist/assets/renderElectronMiniChatApp-COyLTtZx.js +0 -2
  344. package/dist/assets/renderMobileApp-BC1MHg6g.js +0 -25
  345. package/dist/assets/runtimeEndpointReset-DdrazOVH.js +0 -25
  346. package/dist/assets/scheduledTasksApi-B2SWMGEU.js +0 -1
  347. package/dist/assets/tr-CQI-KPre.js +0 -7
  348. package/dist/assets/uk-CqW7R4DA.js +0 -16
  349. package/dist/assets/useAppFontEffects-ne84JBVL.js +0 -7333
  350. package/dist/assets/useRootScrollLock-Cpf1qoGp.js +0 -2
  351. package/dist/assets/vendor-cron-parser-CUcP7OfX.js +0 -2
  352. package/dist/assets/vendor-opencode-sdk-BJ73u-bH.js +0 -7
  353. package/dist/assets/zh-CN-CVZG_o_J.js +0 -16
  354. package/dist/assets/zh-TW-D5ZxzCZp.js +0 -16
  355. package/server/lib/opencode/mcp-oauth-callback.test.js +0 -111
  356. package/server/lib/routing/feature-flag.js +0 -11
  357. package/server/lib/small-model/call.js +0 -851
  358. package/server/lib/small-model/call.test.js +0 -1292
  359. package/server/lib/small-model/catalog.js +0 -13
  360. package/server/lib/small-model/resolve.js +0 -131
  361. package/server/lib/small-model/resolve.test.js +0 -197
  362. package/server/lib/small-model/runtime-providers.js +0 -164
  363. package/server/lib/small-model/runtime-providers.test.js +0 -118
  364. package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
  365. package/server/lib/system-prompt/runtime.js +0 -49
  366. package/server/lib/system-prompt/runtime.test.js +0 -76
  367. package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
@@ -0,0 +1,12 @@
1
+ import{R as E,f as ae,j as re}from"./vendor-react-BUCujlKS.js";import{m as zt}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ht,a as Vt}from"./vendor-beautiful-mermaid-DztCUpLZ.js";import{gJ as at,gK as Kt,gL as Ut,gM as jt,gN as Xt,gO as Zt,g as we,bp as Gt,bs as Yt,gP as Jt,gQ as Qt,_ as lt,ai as ct,gR as dt,f as ut,h as mt,eE as en,eF as qe,gS as tn,gT as nn,gU as rn,gV as on,gW as sn,gX as an,o as ln}from"./useAppFontEffects-Ci3FEaPf.js";import{h as cn,O as pt,L as oe,c_ as dn,u as Y,a as un,b8 as mn}from"./index-CvLgnuNI.js";import{getCachedMarkdownBlocks as Be,renderMarkdownSync as pn,renderMarkdownBlocks as fn}from"./markdownCore-D2e5sp9y.js";import{b as hn,r as gn}from"./textMateThemeFromAppTheme-DGF2kG7g.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-elkjs-BRwcR927.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CQa7_1cr.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-marked-linkify-it-CXI_LHIE.js";import"./vendor-linkify-it-DZCzzDkK.js";import"./vendor-uc.micro-BAd0H0z4.js";import"./vendor-remend-BWYYytN3.js";import"./vendor-katex-CHD9BdDO.js";import"./vendor-dompurify-r8glNMJW.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";const ft=t=>{const e=t.target;if(!(e instanceof Element))return null;const n=e.closest("a[href]");return!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true"?null:n},Ne=(t,e)=>{if(t.defaultPrevented)return!1;const r=ft(t)?.getAttribute("href")??"";return Kt(r)?(t.preventDefault(),t.stopPropagation(),e?.(r),!0):!1},bn=t=>t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey,wn=(t,e)=>{const n=o=>{if(Ne(o,e.openAppLink)||!e.allowExternalHttp||o.defaultPrevented||!bn(o))return;const s=ft(o)?.getAttribute("href")??"";at(s)&&(o.preventDefault(),o.stopPropagation(),e.openExternalHttp(s))},r=o=>{o.button===1&&Ne(o,e.openAppLink)},i=o=>{Ne(o)};return t.addEventListener("click",n),t.addEventListener("auxclick",r),t.addEventListener("dragstart",i),()=>{t.removeEventListener("click",n),t.removeEventListener("auxclick",r),t.removeEventListener("dragstart",i)}},ht="openchamber-md",ye={background:"transparent",foreground:"var(--md-syntax-foreground)",comment:"var(--md-syntax-comment)",keyword:"var(--md-syntax-keyword)",string:"var(--md-syntax-string)",number:"var(--md-syntax-number)",function:"var(--md-syntax-function)",variable:"var(--md-syntax-variable)",type:"var(--md-syntax-type)",operator:"var(--md-syntax-operator)"},yn=Object.fromEntries(Object.keys(Ut({base:ye})).map(t=>[t,`var(--md-token-${t})`])),An={name:ht,colors:{"editor.background":"transparent","editor.foreground":ye.foreground},tokenColors:[...hn({base:ye,tokens:yn}),{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:ye.keyword,fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted","invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let $e=!1;const vn=()=>{$e||($e=!0,gn(ht,()=>Promise.resolve(An)))},R=t=>Number.isFinite(t)&&t>0,ze=t=>{if(t==null)return null;const e=String(t).trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const n=Number(e[1]);return R(n)?n:null},Te=(t,e,n)=>Math.min(n,Math.max(e,t)),kn=6,He=1.25,En=1.0015,Cn=.5,Sn=12,Ve=3,Ln=400,ie='[data-markdown="mermaid-block"]',F=t=>t.querySelector(ie)!==null,Mn=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(kn));return Object.is(n,-0)?"0":String(n)}).join(" "),Nn=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(i=>Number.parseFloat(i));if(e?.length===4){const[i,o,s,a]=e;if(Number.isFinite(i)&&Number.isFinite(o)&&R(s)&&R(a))return{x:i,y:o,width:s,height:a}}const n=ze(t.width),r=ze(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Tn=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},Rn=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(i=>i!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,Tn(n)].join(":")},gt=(t,e)=>{if(!R(e.width)||!R(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const o=t.width/r;return{x:t.x,y:t.y-(o-t.height)/2,width:t.width,height:o}}const i=t.height*r;return{x:t.x-(i-t.width)/2,y:t.y,width:i,height:t.height}},_n=({currentBox:t,viewport:e,delta:n})=>!R(e.width)||!R(e.height)||!R(t.width)||!R(t.height)?t:{x:t.x-n.x/e.width*t.width,y:t.y-n.y/e.height*t.height,width:t.width,height:t.height},xn=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>Ve*Ve},Pn=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:i,minScale:o,maxScale:s})=>{if(!R(n.width)||!R(n.height)||!R(i)||!R(t.width)||!R(t.height)||!R(e.width)||!R(e.height)||!R(o)||!R(s))return t;const a=Math.min(o,s),l=Math.max(o,s),c=gt(e,n),u=c.width/t.width,f=Te(u*i,a,l),m=c.width/f,g=m/(t.width/t.height),y=Te(r.x/n.width,0,1),v=Te(r.y/n.height,0,1),S=t.x+y*t.width,p=t.y+v*t.height;return{x:S-y*m,y:p-v*g,width:m,height:g}},Ae=new WeakMap,Fe=new WeakMap,U=new Set,se=new Set;let K=null,ne=null,Q=null;const In=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),bt=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return Rn({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},G=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},Fn=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},Dn=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),wt=t=>{const e=t.map(n=>G(n.viewport));t.forEach((n,r)=>{const i=e[r];i&&n.fitToViewport(i)})},yt=()=>{Q!==null||U.size===0||(Q=window.requestAnimationFrame(()=>{Q=null,wt(Array.from(U))}))},On=()=>{if(K)return K;const t=globalThis.ResizeObserver;return t?(K=new t(e=>{for(const n of e)n.target instanceof HTMLElement&&Fe.get(n.target)?.fitToViewport({width:n.contentRect.width,height:n.contentRect.height})}),K):null},Wn=t=>{if(U.has(t))return;const e=U.size===0;U.add(t),Fe.set(t.viewport,t),On()?.observe(t.viewport),e&&window.addEventListener("resize",yt)},qn=t=>{U.delete(t)&&(K?.unobserve(t.viewport),Fe.delete(t.viewport),!(U.size>0)&&(K?.disconnect(),K=null,window.removeEventListener("resize",yt),Q!==null&&(window.cancelAnimationFrame(Q),Q=null)))},Bn=t=>{const e=In(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=Nn({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let i=r,o=null,s=null,a=null,l=null;const c=d=>{i=d,n.setAttribute("viewBox",Mn(d)),n.removeAttribute("width"),n.removeAttribute("height")},u=d=>{c(gt(r,d))},f=()=>{u(G(e))},m=(d,b)=>{c(Pn({currentBox:i,contentBox:r,viewport:G(e),pointer:d,zoomFactor:b,minScale:Cn,maxScale:Sn}))},g=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},He)},y=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},1/He)},v=d=>{!d.ctrlKey&&!d.metaKey||(d.preventDefault(),d.stopPropagation(),m(Fn(d,e),Math.pow(En,-d.deltaY)))},S=d=>{d.button!==0||Dn(d.target)||(o=d.pointerId,s={x:d.clientX,y:d.clientY},a=s,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(d.pointerId),t.setAttribute("data-mermaid-panning","true"),d.preventDefault())},p=d=>{if(o!==d.pointerId||!a)return;const b={x:d.clientX,y:d.clientY};c(_n({currentBox:i,viewport:G(e),delta:{x:b.x-a.x,y:b.y-a.y}})),a=b,s&&xn(s,b)&&t.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault()},h=d=>{o===d.pointerId&&(e.releasePointerCapture?.(d.pointerId),o=null,s=null,a=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),l=null},Ln)))};e.addEventListener("wheel",v,{passive:!1}),e.addEventListener("pointerdown",S),e.addEventListener("pointermove",p),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",h);const k={viewport:e,zoomIn:g,zoomOut:y,fit:f,fitToViewport:u,cleanup:()=>{qn(k),e.removeEventListener("wheel",v),e.removeEventListener("pointerdown",S),e.removeEventListener("pointermove",p),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",h),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),Ae.delete(t)}};return k},At=t=>{for(const[e,n]of t.controllers){const r=bt(e);(!t.container.contains(e)||r!==t.signatures.get(e))&&(n.cleanup(),t.controllers.delete(e),t.signatures.delete(e))}},$n=t=>{if(t.disposed)return[];const e=[];for(const n of Array.from(t.container.querySelectorAll(ie))){if(t.controllers.has(n)||n.querySelector('[data-markdown="mermaid"] svg')===null)continue;const r=Bn(n);r&&(t.controllers.set(n,r),t.signatures.set(n,bt(n)),Ae.set(n,r),e.push(r))}return e},vt=()=>{const t=Array.from(se);se.clear();const e=[];for(const n of t)n.disposed||(At(n),e.push(...$n(n)));wt(e);for(const n of e)Wn(n)},zn=()=>{ne===null&&(ne=window.requestAnimationFrame(()=>{ne=null,ne=window.requestAnimationFrame(()=>{ne=null,vt()})}))},Hn=t=>{t.disposed||(At(t),se.add(t),zn())},Vn=t=>{if(!(t instanceof HTMLElement))return null;const e=Ae.get(t);if(e)return e;for(const n of se)if(n.container.contains(t))return vt(),Ae.get(t)??null;return null},Kn=t=>{const e={container:t,controllers:new Map,signatures:new Map,disposed:!1},n=()=>Hn(e),r=()=>{e.disposed=!0,se.delete(e);for(const i of e.controllers.values())i.cleanup();e.controllers.clear(),e.signatures.clear()};return n(),{refresh:n,cleanup:r}},Un={copy:"file-copy",check:"check",download:"download",zoomIn:"add",zoomOut:"subtract",fit:"refresh",textWrap:"text-wrap",image:"file-image",disclosure:"arrow-right-s"},kt="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",ee=(t,e)=>{const n=Un[e],r=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","remixicon size-3.5"),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("aria-hidden","true");const i=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");i.setAttribute("href",`#oc-${n}`),r.appendChild(i),t.replaceChildren(r)},jn=t=>{for(const e of Array.from(t.querySelectorAll('[data-openchamber-markdown-image-label="true"]'))){if(e.querySelector("[data-openchamber-markdown-image-label-icon]"))continue;const n=document.createElement("span");n.className="inline-flex shrink-0",n.setAttribute("aria-hidden","true"),n.setAttribute("data-openchamber-markdown-image-label-icon","true"),ee(n,"image"),e.prepend(n)}},Xn=t=>{for(const e of t.querySelectorAll("details[data-md-details] > summary")){if(e.querySelector("[data-md-disclosure-icon]"))continue;const n=document.createElement("span");n.append(...Array.from(e.childNodes));const r=document.createElement("span");r.setAttribute("data-md-disclosure-icon",""),r.setAttribute("aria-hidden","true"),ee(r,"disclosure"),e.append(r,n)}},B=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=kt,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),ee(r,t),r},Et=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),i=t.querySelector("pre"),o=t.querySelector("pre code"),s=t.querySelectorAll("[data-md-code-line-content]"),a=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),i?.classList.toggle("whitespace-pre-wrap",e),i?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),i&&(i.style.whiteSpace=e?"pre-wrap":"pre",i.style.overflowWrap=e?"anywhere":"normal"),o&&(o.style.whiteSpace=e?"pre-wrap":"pre",o.style.overflowWrap=e?"anywhere":"normal");for(const l of Array.from(s))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(a){const l=e?n.disableCodeWrap:n.enableCodeWrap;a.setAttribute("title",l),a.setAttribute("aria-label",l),a.classList.toggle("text-foreground",e),a.classList.toggle("opacity-100",e),a.classList.toggle("text-muted-foreground",!e),a.classList.toggle("opacity-65",!e),a.setAttribute("aria-pressed",e?"true":"false")}},Ct=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;t.removeAttribute("data-md-gutter-reserved");const n=e.textContent??"",r=n.endsWith(`
2
+ `),i=r?n.slice(0,-1).split(`
3
+ `):n.split(`
4
+ `),o=i.length>0?i:[""],s=Array.from(e.children).filter(c=>c.classList.contains("line"));r&&s.length===o.length+1&&s.at(-1)?.textContent===""&&s.pop();const a=s.length===o.length,l=document.createDocumentFragment();o.forEach((c,u)=>{const f=document.createElement("span");f.setAttribute("data-md-code-line","");const m=document.createElement("span");m.setAttribute("data-md-code-line-number",String(u+1)),m.setAttribute("aria-hidden","true");const g=document.createElement("span");if(g.setAttribute("data-md-code-line-content",""),a){const y=s[u];y&&g.append(...Array.from(y.childNodes))}else g.textContent=c;if(f.append(m,g),l.appendChild(f),u<o.length-1||r){const y=document.createElement("span");y.setAttribute("data-md-code-line-break",""),y.textContent=`
5
+ `,l.appendChild(y)}}),e.replaceChildren(l),e.setAttribute("data-md-code-lines",""),e.toggleAttribute("data-md-code-trailing-newline",r)},St=t=>{const e=Array.from(t.querySelectorAll("[data-md-code-line-content]"));if(e.length===0)return t.textContent??"";const n=e.map(r=>r.textContent??"").join(`
6
+ `);return t.hasAttribute("data-md-code-trailing-newline")?`${n}
7
+ `:n},Ke=(t,e,n)=>{const r=t.querySelectorAll('[data-component="markdown-code"]');for(const i of Array.from(r)){const o=i.querySelector("pre");o&&Ct(o),Et(i,e,n)}},Ue=(t,e,n,r)=>{ee(t,"check"),t.setAttribute("title",e),t.setAttribute("aria-label",e),window.setTimeout(()=>{ee(t,n),t.setAttribute("title",r),t.setAttribute("aria-label",r)},2e3)},Zn=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const n of Array.from(e))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},Gn=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const i=r.parentElement;if(!i||i.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],s=r.getAttribute("data-md-lang")??o??"text",a=document.createElement("div");a.setAttribute("data-component","markdown-code"),a.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const l=document.createElement("div");l.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const c=document.createElement("span");c.className="font-mono text-[13px] text-muted-foreground",c.textContent=s;const u=B("copy",e.labels.copy,"copy-code"),f=B("textWrap",e.codeBlockLineWrap?e.labels.disableCodeWrap:e.labels.enableCodeWrap,"toggle-code-wrap");l.appendChild(c);const m=document.createElement("div");m.className="flex items-center gap-1",m.setAttribute("data-md-code-actions",""),m.appendChild(f),m.appendChild(u),l.appendChild(m);const g=document.createElement("div");g.setAttribute("data-md-code-body",""),g.className="px-3 py-2.5 overflow-x-auto",i.replaceChild(a,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),e.deferCodeLineNumberSync?r.setAttribute("data-md-gutter-reserved",""):Ct(r),g.appendChild(r),a.appendChild(l),a.appendChild(g),Et(a,e.codeBlockLineWrap,e.labels)}},je=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const i=t.querySelectorAll("tbody tr");for(const o of Array.from(i)){const s=Array.from(o.querySelectorAll("td")).map(a=>(a.textContent??"").trim());s.length>0&&n.push(s)}return{headers:e,rows:n}},Yn=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Xe=({headers:t,rows:e})=>[t,...e].map(n=>n.map(Yn).join(",")).join(`
8
+ `),Jn=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
9
+ `),Ze=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,i=e.map(o=>`| ${o.join(" | ")} |`).join(`
10
+ `);return`${n}
11
+ ${r}
12
+ ${i}`},Ge=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${Gt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const i=document.createElement("button");i.type="button",i.className=`w-full text-left ${Yt}`,i.setAttribute("data-md-action",`${t}-${r.key}`),i.textContent=r.label,n.appendChild(i)}return n},Qn=120,er=320,Ie="data-md-table-layout",tr=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex w-fit max-w-full flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const s=document.createElement("div");s.className="flex items-center justify-end gap-1";const a=document.createElement("div");a.className="relative",a.appendChild(B("copy",e.copyTable,"table-copy-toggle")),a.appendChild(Ge("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(B("download",e.downloadTable,"table-download-toggle")),l.appendChild(Ge("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),s.appendChild(a),s.appendChild(l);const c=document.createElement("div");c.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const u=r.parentElement;if(!u)continue;u.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.setAttribute(Ie,"pending"),r.classList.add("w-max","border-collapse","text-sm");for(const m of Array.from(r.querySelectorAll("tr")))m.classList.add("border-b","border-border/60");const f=r.querySelector("tbody tr:last-child");f?.classList.remove("border-b"),f?.classList.add("border-0");for(const m of Array.from(r.querySelectorAll("th")))m.classList.add("min-w-[120px]","max-w-[320px]","whitespace-normal","[overflow-wrap:anywhere]","border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const m of Array.from(r.querySelectorAll("td")))m.classList.add("min-w-[120px]","max-w-[320px]","whitespace-normal","[overflow-wrap:anywhere]","border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");c.appendChild(r),o.appendChild(s),o.appendChild(c)}},nr=t=>{const e=Array.from(t.querySelectorAll(`table[data-markdown="table"]:not([${Ie}="fixed"])`));if(e.length===0||!t.isConnected)return;const n=t.ownerDocument.createElement("div");n.setAttribute("aria-hidden","true"),n.setAttribute("data-md-table-measure",""),n.style.position="fixed",n.style.left="-100000px",n.style.top="0",n.style.visibility="hidden",n.style.pointerEvents="none",n.style.width="max-content";const r=e.map(o=>{const s=f=>Array.from(f.children).filter(m=>m.tagName==="TH"||m.tagName==="TD"),a=Array.from(o.querySelectorAll("tbody tr")),l=a.some(f=>s(f).length>0)?a:Array.from(o.querySelectorAll("thead tr")),c=Math.max(0,...Array.from(o.querySelectorAll("tr")).map(f=>s(f).length)),u=[];for(let f=0;f<c;f+=1){const m=t.ownerDocument.createElement("table");m.className=o.className,m.style.tableLayout="auto",m.style.width="max-content";const g=t.ownerDocument.createElement("tbody");for(const y of l){const v=s(y)[f];if(!v)continue;const S=t.ownerDocument.createElement("tr"),p=v.cloneNode(!0);p instanceof HTMLElement&&(p.style.width="auto",p.style.minWidth="0",p.style.maxWidth="none",p.style.whiteSpace="nowrap",p.style.overflowWrap="normal",S.appendChild(p),g.appendChild(S))}m.appendChild(g),n.appendChild(m),u.push(m)}return{table:o,columnProbes:u}});t.appendChild(n);const i=r.map(({table:o,columnProbes:s})=>({table:o,widths:s.map(a=>Math.min(er,Math.max(Qn,Math.ceil(a.getBoundingClientRect().width))))}));n.remove();for(const{table:o,widths:s}of i){Array.from(o.children).find(u=>u.matches("colgroup[data-md-table-columns]"))?.remove();const l=t.ownerDocument.createElement("colgroup");l.setAttribute("data-md-table-columns","");for(const u of s){const f=t.ownerDocument.createElement("col");f.style.width=`${u}px`,l.appendChild(f)}const c=Array.from(o.children).find(u=>u.tagName==="THEAD"||u.tagName==="TBODY"||u.tagName==="TFOOT")??null;o.insertBefore(l,c),o.style.tableLayout="fixed",o.style.width=`${s.reduce((u,f)=>u+f,0)}px`,o.setAttribute(Ie,"fixed")}},rr=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const i=r.parentElement;if(!i)continue;const o=(r.textContent??"").replace(/\s+$/,""),s=e.renderMermaid(o),a=document.createElement("div");a.setAttribute("data-markdown","mermaid-block"),a.setAttribute("data-md-source",o),a.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const c=document.createElement("div");if(c.setAttribute("data-markdown","mermaid-toolbar"),c.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",s.svg){a.setAttribute("data-mermaid-render","svg");const f=document.createElement("div");f.setAttribute("data-markdown","mermaid-viewport");const m=document.createElement("div");if(m.setAttribute("data-markdown","mermaid"),m.setAttribute("data-md-original-svg",s.svg),m.innerHTML=s.svg,f.appendChild(m),l.appendChild(f),e.mermaidControls.showPanZoomControls&&(c.appendChild(B("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),c.appendChild(B("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),c.appendChild(B("fit",e.labels.resetDiagramView,"mermaid-fit"))),e.mermaidControls.copy){const g=B("copy",e.labels.copyDiagram,"mermaid-copy");g.setAttribute("data-md-source",o),c.appendChild(g)}if(e.mermaidControls.download){const g=B("download",e.labels.downloadDiagram,"mermaid-download");g.setAttribute("data-md-svg","1"),c.appendChild(g)}}else{a.setAttribute("data-mermaid-render","ascii");const f=document.createElement("pre");if(f.setAttribute("data-markdown","mermaid-ascii"),f.textContent=s.ascii||o,l.appendChild(f),e.mermaidControls.copy){const m=B("copy",e.labels.copyDiagram,"mermaid-copy");m.setAttribute("data-md-source",s.ascii||o),c.appendChild(m)}}a.appendChild(l),a.appendChild(c);const u=i.parentElement;u&&u.replaceChild(a,i)}},or=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-openchamber-file-link")==="true")continue;const i=r.getAttribute("href")??"";if(!at(i))continue;r.setAttribute("data-md-link-decorated","true");const o=jt(i);if(o){const s=document.createElement("span");s.setAttribute(Xt,"true"),s.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const a=document.createElement("img");a.src=o,a.alt="",a.setAttribute("aria-hidden","true"),a.loading="lazy",a.decoding="async",a.className="size-3.5 rounded-sm",a.addEventListener("error",()=>s.remove(),{once:!0}),s.appendChild(a),r.parentNode?.insertBefore(s,r)}if(e.onPreviewLoopback&&Zt(i)){const s=document.createElement("button");s.type="button",s.className=`ml-1 align-middle ${kt}`,s.setAttribute("data-md-action","preview-loopback"),s.setAttribute("data-md-url",i),s.setAttribute("title",e.labels.previewTitle),s.setAttribute("aria-label",e.labels.previewLabel),ee(s,"download"),r.parentNode?.insertBefore(s,r.nextSibling)}}},pe=(t,e)=>{Xn(t),jn(t),Zn(t),rr(t,e),Gn(t,e),tr(t,e.labels),or(t,e)},Ye=(t,e,n)=>{const r=new Blob([e],{type:n}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)},fe=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},Je=t=>(t.nodeType===1?t:t.parentElement)?.closest("pre code[data-md-code-lines]")??null,ir=t=>{const e=Je(t.startContainer);return!e||e!==Je(t.endContainer)?null:t.toString()},he=new WeakMap,sr=t=>{let e=he.get(t);if(!e){const n=()=>{const o=t.getSelection();return!o||o.rangeCount!==1||o.isCollapsed?null:ir(o.getRangeAt(0))},r=o=>{if(!o.clipboardData)return;const s=n();s!==null&&(o.preventDefault(),o.stopPropagation(),o.clipboardData.setData("text/plain",s))},i=o=>{const s=n();s!==null&&(o.preventDefault(),we(s))};e={registrations:0,handler:r,menuHandler:i},he.set(t,e),t.addEventListener("copy",r,!0),t.defaultView?.addEventListener("openchamber:copy",i)}return e.registrations+=1,()=>{const n=he.get(t);n&&(n.registrations-=1,!(n.registrations>0)&&(t.removeEventListener("copy",n.handler,!0),t.defaultView?.removeEventListener("openchamber:copy",n.menuHandler),he.delete(t)))}},ar=(t,e)=>{const n=sr(t.ownerDocument),r=i=>{const o=i.target;if(!(o instanceof Element))return;const s=o.closest("[data-md-action]");if(!s){fe(t);return}const a=s.getAttribute("data-md-action")??"";if(a==="copy-code"){const l=s.closest('[data-component="markdown-code"]')?.querySelector("code"),c=l?St(l):"";c&&(s.setAttribute("data-md-copy-pending",""),we(c).then(()=>Ue(s,e.labels.copied,"copy",e.labels.copy)).finally(()=>s.removeAttribute("data-md-copy-pending")));return}if(a==="toggle-code-wrap"){i.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(a==="table-copy-toggle"||a==="table-download-toggle"){i.preventDefault();const l=s.parentElement?.querySelector("[data-md-menu]")??null,c=l?.classList.contains("hidden")??!1;fe(t),l&&c&&l.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const l=a.replace("table-copy-",""),c=s.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const u=je(c),f=l==="csv"?Xe(u):l==="tsv"?Jn(u):Ze(u);we(f)}fe(t);return}if(a.startsWith("table-download-")){const l=a.replace("table-download-",""),c=s.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const u=je(c),f=l==="csv"?Xe(u):Ze(u);Ye(l==="csv"?"table.csv":"table.md",f,l==="csv"?"text/csv":"text/markdown")}fe(t);return}if(a==="mermaid-copy"){const l=s.getAttribute("data-md-source")??"";l&&we(l).then(()=>Ue(s,e.labels.copied,"copy",e.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){i.preventDefault();const l=s.closest('[data-markdown="mermaid-block"]'),c=Vn(l);a==="mermaid-zoom-in"?c?.zoomIn():a==="mermaid-zoom-out"?c?.zoomOut():c?.fit();return}if(a==="mermaid-download"){const l=s.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),c=l?.getAttribute("data-md-original-svg")??l?.innerHTML??"";c&&Ye("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){i.preventDefault();const l=s.getAttribute("data-md-url")??"";l&&e.onPreviewLoopback?.(l);return}};return t.addEventListener("click",r),()=>{n(),t.removeEventListener("click",r)}},Qe=(t,e,n)=>{let r=0;for(const o of t){const s=r+o.data.length;if(e<s||e===s&&n==="left")return{node:o,offset:Math.max(0,e-r)};r=s}const i=t.at(-1);return i?{node:i,offset:i.data.length}:null},lr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),et=Array.from(lr).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Lt=t=>Jt(t),cr=t=>Qt(t),dr=t=>{let e;try{e=new URL(t.trim())}catch{return null}if(e.protocol!=="file:"||e.hostname&&e.hostname!=="localhost")return null;try{const n=decodeURIComponent(e.pathname);return/^\/[A-Za-z]:\//.test(n)?n.slice(1):n.startsWith("/")?n:null}catch{return null}},ve=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},ge=t=>{let e=ve(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const i=et.length>0?e.match(new RegExp(`^(.*(?:/|^)(${et})):.*$`,"i")):null;return i&&(e=i[1]??e),ve(e)},Mt=t=>{const e=ve(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?ve(e.slice(0,n)):e;if(!r)return null;const i=r.match(/^(.*?):(\d+)-(\d+)$/);if(i){const l=ge(i[1]??""),c=Number.parseInt(i[2]??"",10),u=Number.parseInt(i[3]??"",10);return!l||!Number.isFinite(c)||!Number.isFinite(u)||u<c?null:{path:l,line:c,endLine:u}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=ge(o[1]??""),c=Number.parseInt(o[2]??"",10),u=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(u??Number.NaN)?u:void 0}}const s=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(s){const l=ge(s[1]??""),c=Number.parseInt(s[2]??"",10),u=s[3]?Number.parseInt(s[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(u??Number.NaN)?u:void 0}}const a=ge(r);return a?{path:a}:null},Re=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,ur=4,mr=1e3,pr=200,z=new Map;let be=0;const tt=[],fr=()=>pt()?pr:mr,hr=(t,e)=>`${t}\0${e}`,gr=(t,e)=>{const n=Lt(t);if(!n)return Promise.resolve(!1);const r=hr(e,n),i=z.get(r);if(i)return z.delete(r),z.set(r,i),i;const o=new Promise(a=>{const l=()=>{be+=1,cn(`/api/fs/stat?path=${encodeURIComponent(n)}&optional=true`,{method:"GET",cache:"no-store",headers:e?{"x-opencode-directory":e}:void 0}).then(async c=>{if(!c.ok){a(!1);return}const u=await c.json().catch(()=>null);a(u?.exists!==!1)}).catch(()=>a(!1)).finally(()=>{be=Math.max(0,be-1),tt.shift()?.()})};if(be<ur){l();return}tt.push(l)}),s=fr();for(;z.size>=s;){const a=z.keys().next().value;if(typeof a!="string")break;z.delete(a)}return z.set(r,o),o},br={maxSessions:8,maxEntriesPerSession:4};class wr{maxSessions;maxEntriesPerSession;sessions=new Map;constructor(e=br){this.maxSessions=Math.max(1,e.maxSessions),this.maxEntriesPerSession=Math.max(1,e.maxEntriesPerSession)}store(e){const n=e.scope,r=e.id;let i=this.sessions.get(n);for(i===void 0?(i=new Map,this.sessions.set(n,i)):this.refreshSession(n,i),i.delete(r),i.set(r,e);i.size>this.maxEntriesPerSession;)this.removeOldestEntry(i);for(;this.sessions.size>this.maxSessions;)this.removeOldestSession()}take(e){const n=e.scope,r=this.sessions.get(n);if(!r)return null;const i=e.id;this.refreshSession(n,r);const o=r.get(i);return o===void 0||o.locale!==e.locale||o.directory!==e.directory?null:(r.delete(i),r.size===0&&this.sessions.delete(n),o.fragment)}clear(){this.sessions.clear()}stats(){let e=0;for(const n of this.sessions.values())e+=n.size;return{sessions:this.sessions.size,entries:e}}refreshSession(e,n){this.sessions.delete(e),this.sessions.set(e,n)}removeOldestEntry(e){const n=e.keys().next().value;n!==void 0&&e.delete(n)}removeOldestSession(){const e=this.sessions.keys().next().value;e!==void 0&&this.sessions.delete(e)}}const nt=new wr,Nt=()=>{const t=ae.c(4),e=en();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=qe(!1),t[0]=n):n=t[0];const r=n;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=qe(!0),t[1]=i):i=t[1];const o=i;let s;return t[2]!==e?.currentTheme?(s=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=s):s=t[3],s},Tt=t=>{const e=ae.c(4),{containerRef:n,enabled:r}=t;let i,o;e[0]!==n||e[1]!==r?(i=()=>{const s=n.current;if(s)return wn(s,{allowExternalHttp:r!==!1,openAppLink:Wr,openExternalHttp:qr})},o=[n,r],e[0]=n,e[1]=r,e[2]=i,e[3]=o):(i=e[2],o=e[3]),E.useEffect(i,o)},te={download:!0,copy:!0,showPanZoomControls:!0},Rt=!0,yr=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},rt='[data-openchamber-file-link="true"]',_t="data-openchamber-block-path-token",xt=`[${_t}]`,J="data-openchamber-block-paths-scanned",Ar=2e5,vr=80,kr=40,ot=160,Er=()=>pt()?kr:vr,Cr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Pt=t=>Lt(t),Sr=t=>cr(t),Lr=(t,e)=>on(t,e),Mr=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},It=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=Pt(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return Cr.has(r)||r.startsWith(".")&&r.length>1?!0:Mr(e)},Ft=t=>{const e=Mt(t);return e?It(e.path):!1},Nr=t=>{const e=t.querySelectorAll(xt);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${J}]`);for(const r of Array.from(n))r.removeAttribute(J),r.normalize()},_e=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim(),n=e?dr(e):null;if(n)return n;if(e&&Ft(e))return e}return(t.textContent||"").trim()},Tr=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(J)==="true")continue;if((r.textContent??"").length>Ar){r.setAttribute(J,"true");continue}const i=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let s=i.nextNode();for(;s;){const u=s;u.parentElement?.closest("[data-md-code-line-number]")||o.push(u),s=i.nextNode()}const a=St(r);if(!a.includes(".")){r.setAttribute(J,"true");continue}Re.lastIndex=0;const l=[];let c=Re.exec(a);for(;c;){const u=c[0];u&&Ft(u)&&l.push({start:c.index,end:c.index+u.length,raw:u}),c=Re.exec(a)}for(const{start:u,end:f,raw:m}of l.reverse()){const g=Qe(o,u,"right"),y=Qe(o,f,"left");if(!g||!y)continue;const v=n.createRange();v.setStart(g.node,g.offset),v.setEnd(y.node,y.offset);const S=n.createElement("span");S.setAttribute(_t,"true"),S.textContent=m,v.deleteContents(),v.insertNode(S)}r.setAttribute(J,"true")}},xe=(t,e)=>{const n=Mt(t);if(!n||!It(n.path))return null;const r=Sr(n.path)?Pt(n.path):Lr(e,n.path);return r?{...n,resolvedPath:r}:null},Rr=(t,e)=>t||rn(t,e),Dt=({containerRef:t,effectiveDirectory:e,editor:n,preferRuntimeEditor:r,enabled:i})=>{const o=E.useRef(null);E.useEffect(()=>{const s=t.current;if(!s||i&&!e)return;let a=!1;const l=Er(),c=i&&!mn(),u=d=>{d.removeAttribute("data-openchamber-file-link"),d.removeAttribute("data-openchamber-file-ref"),d.removeAttribute("data-openchamber-file-path"),d.getAttribute("title")==="Open file"&&d.removeAttribute("title"),d.tagName.toLowerCase()!=="a"&&(d.removeAttribute("role"),d.removeAttribute("tabindex"))},f=()=>{const d=s.querySelectorAll(rt);for(const b of Array.from(d))u(b);Nr(s)};if(!c){f();return}const m=(d=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){g();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{a||g()})},d)},g=()=>{h+=1;try{y()}finally{queueMicrotask(()=>{h-=1})}},y=()=>{c&&Tr(s);const d=s.querySelectorAll(`[data-markdown="inline-code"], a, ${xt}`);let b=0;for(const w of Array.from(d)){const A=_e(w),M=xe(A,e);if(u(w),!M||b>=l)continue;b+=1,(!nn(M.resolvedPath,e)?Promise.resolve(!0):gr(M.resolvedPath,e)).then(x=>{if(a||!x||!s.contains(w))return;const L=_e(w),T=xe(L,e);!T||T.resolvedPath!==M.resolvedPath||(w.setAttribute("data-openchamber-file-link","true"),w.setAttribute("data-openchamber-file-ref",L),w.setAttribute("data-openchamber-file-path",T.resolvedPath),w.setAttribute("title","Open file"),w.tagName.toLowerCase()!=="a"&&(w.setAttribute("role","button"),w.setAttribute("tabindex","0")))})}},v=async d=>{const b=d.getAttribute("data-openchamber-file-ref")||_e(d),w=xe(b,e);if(!w)return;const A=Rr(e,w.resolvedPath);if(r&&n){n.openFile(w.resolvedPath,Number.isFinite(w.line??Number.NaN)?Math.max(1,Math.trunc(w.line)):void 0,Number.isFinite(w.column??Number.NaN)?Math.max(1,Math.trunc(w.column)):void 0);return}const M=Y.getState();Number.isFinite(w.line??Number.NaN)?M.openContextFileAtLine(A,w.resolvedPath,Math.max(1,Math.trunc(w.line)),Number.isFinite(w.column??Number.NaN)?Math.max(1,Math.trunc(w.column)):1):M.openContextFile(A,w.resolvedPath)},S=d=>{const b=d.target;if(!(b instanceof Element))return;const w=b.closest(rt);w instanceof HTMLElement&&(d.preventDefault(),d.stopPropagation(),v(w))},p=d=>{if(d.key!=="Enter"&&d.key!==" ")return;const b=d.target;!(b instanceof HTMLElement)||b.getAttribute("data-openchamber-file-link")!=="true"||(d.preventDefault(),d.stopPropagation(),v(b))};m(ot);let h=0;const k=new MutationObserver(()=>{h>0||m(ot)});return k.observe(s,{childList:!0,subtree:!0}),s.addEventListener("click",S),s.addEventListener("keydown",p),()=>{a=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,k.disconnect(),s.removeEventListener("click",S),s.removeEventListener("keydown",p)}},[t,n,e,r,i])},Ot=t=>{const e=ae.c(7),{containerRef:n,onShowPopup:r,enableFullscreen:i,enablePanZoom:o,allowMermaidWheelEvents:s}=t;let a,l;e[0]!==s||e[1]!==n||e[2]!==i||e[3]!==o||e[4]!==r?(a=()=>{const c=n.current;if(!c)return;const u=m=>{if(!i||!r)return;const g=m.target;if(!(g instanceof Element)||g.closest('button, a, [role="button"]'))return;const y=g.closest(ie);if(!y)return;if(y instanceof HTMLElement&&y.hasAttribute("data-mermaid-suppress-click")){y.removeAttribute("data-mermaid-suppress-click");return}const S=Array.from(c.querySelectorAll(ie)).indexOf(y);if(S<0)return;const p=y instanceof HTMLElement?y.getAttribute("data-md-source"):null;if(!p||p.trim().length===0)return;const h=`Diagram ${S+1}`;r({open:!0,title:h,content:"",metadata:{tool:"mermaid-preview",filename:h},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(p)}`,source:p,filename:h}})},f=m=>{if(s||(m.ctrlKey||m.metaKey)&&o)return;const g=m.target;!(g instanceof Element)||!g.closest(ie)||m.stopPropagation()};return c.addEventListener("click",u),c.addEventListener("wheel",f,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",u),c.removeEventListener("wheel",f,!0)}},l=[s,n,i,o,r],e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=r,e[5]=a,e[6]=l):(a=e[5],l=e[6]),E.useEffect(a,l)},H=new Map,_r=100,V="data-md-decoration-id",xr=(t,e,n)=>{const r=t.children;if(r.length!==e.length)return!1;for(let i=0;i<e.length;i+=1){const o=r[i];if(!o||o.getAttribute("data-md-id")!==e[i]?.id||o.getAttribute(V)!==n)return!1}return!0},it=new WeakMap;let st=0;const Pr=2e5,Pe=t=>{const e=it.get(t);if(e)return e;const n=`decoration-${st}`;return st+=1,it.set(t,n),n},Ir=(t,e)=>{const n=H.get(t);if(n)return H.delete(t),H.set(t,n),n;const r=e();if(H.set(t,r),H.size>_r){const i=H.keys().next().value;i&&H.delete(i)}return r},Fr=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),Wt=(t,e,n,r=te)=>{const{t:i}=ut(),o=E.useMemo(()=>({copy:i("markdownRenderer.code.actions.copyTitle"),copied:i("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:i("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:i("markdownRenderer.code.actions.disableWrapTitle"),copyTable:i("markdownRenderer.table.actions.copyTitle"),downloadTable:i("markdownRenderer.table.actions.downloadTitle"),copyDiagram:i("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:i("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:i("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:i("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:i("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:i("terminalView.preview.open"),previewTitle:i("terminalView.preview.openTitle")}),[i]),s=Y(c=>c.codeBlockLineWrap),a=Y(c=>c.setCodeBlockLineWrap),l=E.useCallback(()=>{a(!Y.getState().codeBlockLineWrap)},[a]);return E.useMemo(()=>{const c=Fr(t),u=Y.getState().mermaidRenderingMode,f=t.metadata?.id??"theme";return{labels:o,mermaidControls:r,codeBlockLineWrap:s,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:l,renderMermaid:g=>Ir(`${f}:${u}:${g}`,()=>{try{return u==="ascii"?{ascii:Ht(g)}:{svg:Vt(g,c)}}catch{return{}}}),onPreviewLoopback:n}},[t,o,r,s,e,l,n])},qt=({containerRef:t,text:e,streaming:n,imageMode:r="inline",syntaxVars:i,ctx:o,domCacheKey:s,tableLayoutSettled:a})=>{E.useEffect(()=>{vn()},[]);const l=E.useRef(null),c=E.useRef(0),u=E.useRef(null),f=E.useContext(tn),m=E.useRef(null),g=E.useCallback(()=>{m.current?.(),m.current=null},[]);E.useEffect(()=>g,[g]);const y=E.useRef(null),v=E.useCallback(()=>{const p=t.current;if(p){if(!l.current){if(!F(p))return;l.current=Kn(p);return}l.current.refresh()}},[t]),S=E.useCallback(()=>{if(!a)return;const p=u.current;p!==null&&window.cancelAnimationFrame(p);const h=c.current,k=window.requestAnimationFrame(()=>{if(u.current!==k||(u.current=null,c.current!==h))return;const d=t.current,b=d?.querySelector("[data-markdown-content]")??d;b&&nr(b)});u.current=k},[t,a]);E.useEffect(()=>()=>{const p=u.current;p!==null&&(window.cancelAnimationFrame(p),u.current=null)},[]),E.useLayoutEffect(()=>{c.current+=1,y.current=null},[o,r,n,e]),E.useLayoutEffect(()=>{if(!s)return;const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(!h||h.childNodes.length>0)return;const k=nt.take(s);if(k){h.appendChild(k);const d=Pe(o);for(const b of Array.from(h.children))b.setAttribute(V,d);for(const[b,w]of Object.entries(i))h.style.setProperty(b,w);Ke(h,o.codeBlockLineWrap,o.labels),y.current={key:s,copiedLabel:o.labels.copied},oe("ui.markdown_renderer.dom_cache.hit")}},[t,o,s,i,e.length]),E.useLayoutEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(h)return()=>{const k=y.current;if(!k||h.childNodes.length===0||F(h)||Array.from(h.children).some(M=>!M.hasAttribute("data-md-id"))||h.querySelector("[data-md-copy-pending]"))return;const d=window.getSelection();if(d?.rangeCount&&!d.isCollapsed&&d.getRangeAt(0).intersectsNode(h))return;const b=h.querySelector("[data-md-menu]:not(.hidden)"),w=Array.from(h.querySelectorAll("[data-md-action]")).some(M=>M.getAttribute("title")===k.copiedLabel);if(b||w)return;const A=document.createDocumentFragment();A.append(...Array.from(h.childNodes)),nt.store({...k.key,fragment:A}),oe("ui.markdown_renderer.dom_cache.capture")}},[t]),E.useLayoutEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(!h)return;const k=Pe(o);if(e&&h.childNodes.length===0){const d=n?null:Be(e,r);if(d){let b=!1;for(const w of d){const A=document.createElement("div");A.setAttribute("data-md-block",""),A.style.display="contents",A.innerHTML=w.html,pe(A,o),A.setAttribute("data-md-id",w.id),A.setAttribute(V,k),b||=F(A),h.appendChild(A)}b&&v()}else{!n&&!m.current&&(m.current=f?.hold()??null);const b=document.createElement("div");b.setAttribute("data-md-block",""),b.style.display="contents",b.innerHTML=pn(e,r),pe(b,o),b.setAttribute(V,k),h.appendChild(b),F(b)&&v()}}else!l.current&&F(h)&&v()},[t,e,n,r,o,v,f]),E.useEffect(()=>()=>{l.current?.cleanup(),l.current=null},[]),E.useEffect(()=>{const p=t.current;if(!p)return;const h=p.querySelector("[data-markdown-content]")??p;let k=!0;const d=c.current,b=Pe(o);if(!n){const w=Be(e,r);if(w&&xr(h,w,b)){y.current=s?{key:s,copiedLabel:o.labels.copied}:null,oe("ui.markdown_renderer.settled_paint.reused"),S(),g();return}}return fn(e,n,r).then(w=>{if(!k||c.current!==d)return;const A=Array.from(h.children),M=Array.from(h.querySelectorAll("details[data-md-details]")).map(L=>({summary:L.querySelector("summary")?.textContent,open:L.open}));let D=0;w.forEach((L,T)=>{let C=A[T],P=!1;if(C||(C=document.createElement("div"),C.setAttribute("data-md-block",""),C.style.display="contents",h.appendChild(C),P=!0),C.getAttribute("data-md-id")===L.id){if(C.getAttribute(V)!==b){const I=F(C);I&&(l.current?.cleanup(),l.current=null);const N=document.createElement("div");N.setAttribute("data-md-block",""),N.style.display="contents",N.innerHTML=L.html,pe(N,o),N.setAttribute("data-md-id",L.id),N.setAttribute(V,b),C.replaceWith(N),(I||F(N))&&v()}!l.current&&F(C)&&v();return}const _=document.createElement("div");if(_.innerHTML=L.html,pe(_,o),P&&n&&T>0){const I=Math.min(D,4)*55;D+=1;for(const N of Array.from(_.children))N.classList.add("oc-md-block-enter"),I>0&&N instanceof HTMLElement&&N.style.setProperty("--oc-md-enter-delay",`${I}ms`)}const O=F(C),W=F(_);zt(C,_,{childrenOnly:!0,onBeforeElUpdated:(I,N)=>(I.matches("details[data-md-details]")&&N.matches("details[data-md-details]")&&I.querySelector("summary")?.textContent===N.querySelector("summary")?.textContent&&N.toggleAttribute("open",I.hasAttribute("open")),!I.isEqualNode(N))}),C.setAttribute("data-md-id",L.id),C.setAttribute(V,b),(O||W||F(C))&&v()});const $=F(h);let x=!1;for(let L=A.length-1;L>=w.length;L-=1){const T=A[L];T&&F(T)&&(x=!0),T?.remove()}(x||A.length>w.length&&$)&&v(),M.length>0&&h.querySelectorAll("details[data-md-details]").forEach((L,T)=>{const C=M[T];C&&C.summary===L.querySelector("summary")?.textContent&&(L.open=C.open)}),y.current=s?{key:s,copiedLabel:o.labels.copied}:null,S(),g()}),()=>{k=!1}},[t,o,s,r,v,g,S,n,e]),E.useEffect(()=>{const p=t.current;if(p)return ar(p,o)},[t,o]),E.useEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(h)for(const[k,d]of Object.entries(i))h.style.setProperty(k,d)},[t,i]),E.useEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;h&&(o.deferCodeLineNumberSync||Ke(h,o.codeBlockLineWrap,o.labels))},[t,o.codeBlockLineWrap,o.deferCodeLineNumberSync,o.labels])},Bt=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Dr=t=>{const e=ae.c(40),{content:n,part:r,messageId:i,isAnimated:o,skipFadeIn:s,className:a,isStreaming:l,disableStreamAnimation:c,variant:u,onShowPopup:f,enableFileReferences:m}=t,g=o===void 0?!0:o,y=s===void 0?!1:s,v=l===void 0?!1:l,S=c===void 0?!1:c,p=u===void 0?"assistant":u,h=m===void 0?!0:m;oe("ui.markdown_renderer.render"),v&&oe("ui.markdown_renderer.render.streaming"),dn("ui.markdown_renderer.content_len",n.length);const k=Nt(),{editor:d,runtime:b}=lt(),w=E.useRef(null),A=ct()??"",M=Y(Br);let D;e[0]!==A||e[1]!==M?(D=q=>{A&&M(A,q)},e[0]=A,e[1]=M,e[2]=D):D=e[2];const $=D,x=v&&!S;let L;e[3]!==f?(L={containerRef:w,onShowPopup:f,enableFullscreen:Rt,enablePanZoom:te.showPanZoomControls},e[3]=f,e[4]=L):L=e[4],Ot(L);const T=h&&!v;let C;e[5]!==d||e[6]!==A||e[7]!==b.isVSCode||e[8]!==T?(C={containerRef:w,effectiveDirectory:A,editor:d,preferRuntimeEditor:b.isVSCode,enabled:T},e[5]=d,e[6]=A,e[7]=b.isVSCode,e[8]=T,e[9]=C):C=e[9],Dt(C);let P;e[10]===Symbol.for("react.memo_cache_sentinel")?(P={containerRef:w},e[10]=P):P=e[10],Tt(P);let _;e[11]!==k?(_=dt(k),e[11]=k,e[12]=_):_=e[12];const O=_,W=Wt(k,x,A?$:void 0,te),{locale:I}=ut(),N=p==="assistant"?"label":"inline",ke=r&&(r.type==="text"||r.type==="reasoning")&&r.time?.end!==void 0?r:null;let le;e[13]===Symbol.for("react.memo_cache_sentinel")?(le=un(),e[13]=le):le=e[13];const $t=le,De=ke?.sessionID,Oe=ke?.messageID,We=ke?.id;let Ee;e:{if(v||!De||!Oe||!We||n.length===0||n.length>Pr){Ee=null;break e}const q=`${$t}\0${De}`,Me=`${Oe}\0${We}\0${N}\0${n.length}`;let me;e[14]!==A||e[15]!==I||e[16]!==q||e[17]!==Me?(me={scope:q,id:Me,locale:I,directory:A},e[14]=A,e[15]=I,e[16]=q,e[17]=Me,e[18]=me):me=e[18],Ee=me}const Ce=Ee,Se=`markdown-${r?.id?`part-${r.id}`:`message-${i}`}`,Le=!v;let ce;e[19]!==n||e[20]!==W||e[21]!==Ce||e[22]!==N||e[23]!==x||e[24]!==O||e[25]!==Le?(ce={containerRef:w,text:n,streaming:x,imageMode:N,syntaxVars:O,ctx:W,domCacheKey:Ce,tableLayoutSettled:Le},e[19]=n,e[20]=W,e[21]=Ce,e[22]=N,e[23]=x,e[24]=O,e[25]=Le,e[26]=ce):ce=e[26],qt(ce);let j;e[27]!==a?(j=mt("break-words w-full min-w-0",a),e[27]=a,e[28]=j):j=e[28];let X;e[29]!==p?(X=Bt(p),e[29]=p,e[30]=X):X=e[30];let Z;e[31]!==X?(Z=re.jsx("div",{className:X,"data-markdown-content":!0}),e[31]=X,e[32]=Z):Z=e[32];let de;e[33]!==j||e[34]!==Z?(de=re.jsx("div",{className:j,ref:w,children:Z}),e[33]=j,e[34]=Z,e[35]=de):de=e[35];const ue=de;if(g){let q;return e[36]!==Se||e[37]!==ue||e[38]!==y?(q=re.jsx(sn,{skipAnimation:y,children:ue},Se),e[36]=Se,e[37]=ue,e[38]=y,e[39]=q):q=e[39],q}return ue},Vi=E.memo(Dr,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Or=t=>{const e=ae.c(29),{content:n,className:r,variant:i,disableLinkSafety:o,stripFrontmatter:s,onShowPopup:a,mermaidControls:l,allowMermaidWheelEvents:c,enableFileReferences:u}=t,f=i===void 0?"assistant":i,m=s===void 0?!1:s,g=l===void 0?te:l,y=c===void 0?!1:c,v=u===void 0?!0:u,{editor:S,runtime:p}=lt(),h=Nt(),k=E.useRef(null),d=ct()??"";let b;e[0]!==n||e[1]!==m?(b=m?yr(n):n,e[0]=n,e[1]=m,e[2]=b):b=e[2];const w=b;let A;e[3]!==y||e[4]!==g.showPanZoomControls||e[5]!==a?(A={containerRef:k,onShowPopup:a,enableFullscreen:Rt,enablePanZoom:g.showPanZoomControls,allowMermaidWheelEvents:y},e[3]=y,e[4]=g.showPanZoomControls,e[5]=a,e[6]=A):A=e[6],Ot(A);let M;e[7]!==S||e[8]!==d||e[9]!==v||e[10]!==p.isVSCode?(M={containerRef:k,effectiveDirectory:d,editor:S,preferRuntimeEditor:p.isVSCode,enabled:v},e[7]=S,e[8]=d,e[9]=v,e[10]=p.isVSCode,e[11]=M):M=e[11],Dt(M);const D=!o;let $;e[12]!==D?($={containerRef:k,enabled:D},e[12]=D,e[13]=$):$=e[13],Tt($);let x;e[14]!==h?(x=dt(h),e[14]=h,e[15]=x):x=e[15];const L=x,T=Wt(h,!1,void 0,g);let C;e[16]!==T||e[17]!==w||e[18]!==L?(C={containerRef:k,text:w,streaming:!1,syntaxVars:L,ctx:T,tableLayoutSettled:!0},e[16]=T,e[17]=w,e[18]=L,e[19]=C):C=e[19],qt(C);let P;e[20]!==r?(P=mt("break-words w-full min-w-0",r),e[20]=r,e[21]=P):P=e[21];let _;e[22]!==f?(_=Bt(f),e[22]=f,e[23]=_):_=e[23];let O;e[24]!==_?(O=re.jsx("div",{className:_,"data-markdown-content":!0}),e[24]=_,e[25]=O):O=e[25];let W;return e[26]!==P||e[27]!==O?(W=re.jsx("div",{className:P,ref:k,children:O}),e[26]=P,e[27]=O,e[28]=W):W=e[28],W},Ki=E.memo(Or,(t,e)=>{const n=t.mermaidControls??te,r=e.mermaidControls??te;return t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&t.allowMermaidWheelEvents===e.allowMermaidWheelEvents&&t.enableFileReferences===e.enableFileReferences});function Wr(t){an(t)}function qr(t){ln(t)}function Br(t){return t.openContextPreview}export{Vi as MarkdownRenderer,Ki as SimpleMarkdownRenderer};
@@ -0,0 +1 @@
1
+ import{r as D,j as e,R as c,f as G}from"./vendor-react-BUCujlKS.js";import{f as J,B as U,X as z,g as me,O as Ce,h as ne,I as O}from"./useAppFontEffects-Ci3FEaPf.js";import{P as W,cR as Ne,cO as le,cK as V,E as B,aw as H,e2 as Se,aD as ue,X as pe,h as X,aM as he,t as xe,U as re}from"./index-CvLgnuNI.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CQa7_1cr.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-client-_BAHQo4R.js";function Re(a){switch(a){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function oe(a){return a==="wrong-service"||a==="unreachable"||a==="incompatible"}function fe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:i="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:u,showInstancePicker:r=!1}){const{t:o}=J(),[w,R]=D.useState(s),[j,T]=D.useState(i),[I,x]=D.useState("idle"),[m,k]=D.useState(null),[C,b]=D.useState(""),[N,K]=D.useState([]),[y,f]=D.useState(()=>r?"instances":"add"),[g,L]=D.useState("");D.useEffect(()=>{r&&W().then(h=>K(h.hosts)).catch(h=>{b(h instanceof Error?h.message:String(h))})},[r]);const S=Ne(w),A=S?.persistedUrl??null,E=D.useCallback(h=>{R(h.target.value),x("idle"),k(null),b("")},[]),F=D.useCallback(h=>{T(h.target.value)},[]),d=D.useCallback(async()=>{if(A){x("testing"),k(null),b("");try{const h=await le(A);k(h),x(h.status==="ok"||h.status==="update-recommended"?"success":"error")}catch(h){b(h instanceof Error?h.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[A,o]),_=D.useCallback(async()=>{if(!S)return;const h=S.persistedUrl;x("testing"),k(null),b("");try{const M=await le(h);if(k(M),oe(M.status)){x("error");return}const Z=await W(),je=j.trim()||h,ee=Z.hosts.find(q=>q.url===h),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:je,url:h,apiUrl:h},ke=ee?Z.hosts.map(q=>q.id===te?ie:q):[...Z.hosts,ie];if(await V({hosts:ke,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),S.redeemUrl){window.location.assign(S.redeemUrl);return}B()&&await H()}catch(M){b(M instanceof Error?M.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[S,j,l,o]),$=D.useCallback(async h=>{const M=await W();await V({hosts:M.hosts,defaultHostId:h,initialHostChoiceCompleted:!0}),await H()},[]),p=D.useCallback(async()=>{x("testing"),b("");try{const h=await W(),M=await Se(g,h.hosts);await V({hosts:M.hosts,defaultHostId:M.hostId,initialHostChoiceCompleted:!0}),await H()}catch(h){b(h instanceof Error&&h.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[g,o]),v=I==="testing",P=A!==null&&!v,Q=A!==null&&!v&&!oe(m?.status??null),Y=Re(m?.status??null),ye=m?.status==="ok",ve=m?.status==="update-recommended",we=m?.status==="auth",ae=oe(m?.status??null);return r&&y==="instances"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("desktopHostSwitcher.actions.switchInstance")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.description")})]}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx("div",{className:"space-y-2",children:N.length===0?e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("settings.remoteInstances.direct.state.empty")}):N.map(h=>e.jsx(U,{variant:"outline",className:"w-full justify-start",onClick:()=>{$(h.id)},children:e.jsx("span",{className:"min-w-0 truncate",children:h.label})},h.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(U,{variant:"outline",className:"flex-1",onClick:()=>f("import"),children:o("settings.remoteInstances.direct.import.action")}),e.jsx(U,{className:"flex-1",onClick:()=>f("add"),children:o("settings.remoteInstances.direct.actions.add")})]})]})}):r&&y==="import"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsx(U,{variant:"ghost",onClick:()=>f("instances"),className:"p-0 text-muted-foreground",children:o("onboarding.common.actions.back")}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("settings.remoteInstances.direct.import.action")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.import.description")})]}),e.jsx(z,{value:g,onChange:h=>L(h.target.value),placeholder:o("settings.remoteInstances.direct.import.placeholder"),disabled:v,autoFocus:!0}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx(U,{onClick:()=>{p()},disabled:v||!g.trim(),children:o("settings.remoteInstances.direct.import.action")})]})}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(t||r)&&e.jsx("div",{className:"flex items-center",children:e.jsx(U,{variant:"ghost",onClick:r?()=>f("instances"):a,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o(n?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("onboarding.remoteConnection.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.serverAddress")}),e.jsx(z,{id:"remote-url",type:"url",value:w,onChange:E,placeholder:o("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:v})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.nameOptional")}),e.jsx(z,{id:"remote-label",type:"text",value:j,onChange:F,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),m&&ye&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:o("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&we&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:o("onboarding.remoteConnection.status.authWarning")}),m&&ve&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:Y?o(Y):null}),m&&ae&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:o("onboarding.remoteConnection.status.connectionFailed")}),e.jsx("div",{className:"opacity-90",children:Y?o(Y):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?o("onboarding.remoteConnection.status.suggestionsUnreachable"):o("onboarding.remoteConnection.status.suggestionsWrongService")})]}),C&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(U,{variant:"outline",onClick:d,disabled:!P,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(U,{onClick:_,disabled:!Q,children:o("onboarding.remoteConnection.actions.connectAndRestart")})]}),ae&&e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[e.jsx("div",{className:"text-xs text-muted-foreground text-center",children:o("onboarding.remoteConnection.actions.whatToDo")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(U,{variant:"outline",size:"sm",onClick:a,className:"flex-1",children:o("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&u&&e.jsx(U,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Le="curl -fsSL https://opencode.ai/v2/install | bash",ge="npm install -g @opencode/cli",Ue="https://opencode.ai/download",ce=2500;function Ie(a){const t=G.c(9),{windows:s,onCopy:i,copyTitle:n}=a;let l;t[0]!==s?(l=e.jsx("code",{className:"flex-1 min-w-0 text-left overflow-x-auto whitespace-nowrap",children:s?e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:ge}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),t[0]=s,t[1]=l):l=t[1];let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=e.jsx(O,{name:"file-copy",className:"h-4 w-4"}),t[2]=u):u=t[2];let r;t[3]!==n||t[4]!==i?(r=e.jsx("button",{onClick:i,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:u}),t[3]=n,t[4]=i,t[5]=r):r=t[5];let o;return t[6]!==l||t[7]!==r?(o=e.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[l,r]}),t[6]=l,t[7]=r,t[8]=o):o=t[8],o}function Te({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=J(),[i,n]=c.useState(!1),[l,u]=c.useState(!1),[r,o]=c.useState(!1),[w,R]=c.useState(!1),[j,T]=c.useState(""),[I,x]=c.useState("unknown"),[m,k]=c.useState(()=>t?"local":"remote"),[C,b]=c.useState(!1),[N,K]=c.useState(!1);c.useEffect(()=>{u(B())},[]),c.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const p=navigator.userAgent||"";/Windows/i.test(p)?x("windows"):/Macintosh|Mac OS X/i.test(p)?x("macos"):/Linux/i.test(p)?x("linux"):x("unknown")},[]),c.useEffect(()=>{let p=!1;return(async()=>{try{const v=await ue();if(!v||p)return;const P=v.opencodeBinary??"";P&&T(P)}catch{}})(),()=>{p=!0}},[]);const y=c.useCallback(async p=>{const v=p.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||p.button===0&&l&&await pe()},[l]),f=c.useCallback(async()=>{try{const p=await X("/health");if(!p.ok)return!1;const v=await p.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),g=c.useCallback(async p=>{if(!l)return;const v=await W();await V({...v,...p==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),L=c.useCallback(async()=>{l&&await g("local"),a?.()},[l,a,g]);c.useEffect(()=>{if(!t||m!=="local")return;let p=!1,v=null;const P=async()=>{if(!p){try{const Q=await f();if(p)return;if(Q){await L();return}}catch{}p||(v=setTimeout(P,ce))}};return v=setTimeout(P,ce),()=>{p=!0,v&&clearTimeout(v)}},[m,f,L,t]);const S=c.useCallback(async()=>{R(!0);try{await f()&&await L()}finally{R(!1)}},[f,L]),A=c.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const p=await he();p.success&&p.path&&p.path.trim().length>0&&T(p.path.trim())}catch{}},[l]),E=c.useCallback(async()=>{o(!0);try{if(await xe({opencodeBinary:j.trim()}),l){await g("local"),await H();return}await X("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,g]),F=c.useCallback(async()=>{const p=await me(I==="windows"?ge:Le);p.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",p.error)},[I]),d=Ue,_=I==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":I==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode",$=t&&(!l||m==="local");return e.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:y,children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("header",{className:"flex flex-col items-center text-center",children:[e.jsx(Ce,{width:48,height:48}),e.jsx("h1",{className:"mt-6 text-xl font-semibold tracking-tight text-foreground",children:s("onboarding.chooser.title")}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:s("onboarding.chooser.description")})]}),l&&t&&e.jsxs("div",{role:"tablist",className:"app-region-no-drag mt-7 flex gap-1 rounded-lg border border-border p-1",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":m==="local",className:ne("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",m==="local"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>k("local"),children:s("onboarding.chooser.tabs.localInstall")}),e.jsx("button",{type:"button",role:"tab","aria-selected":m==="remote",className:ne("flex-1 rounded-md px-3 py-1.5 text-sm transition-colors",m==="remote"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]":"text-muted-foreground hover:text-foreground"),onClick:()=>k("remote"),children:s("onboarding.chooser.tabs.connectRemote")})]}),l&&m==="remote"?e.jsx("div",{className:"app-region-no-drag mt-6",children:e.jsx(fe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,$&&e.jsxs("div",{className:"mt-6",children:[I==="windows"&&e.jsxs("div",{className:"mb-4 rounded-lg border border-border p-4",children:[e.jsx("div",{className:"text-sm text-foreground",children:s("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:s("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("p",{className:"text-center text-sm leading-relaxed text-muted-foreground text-balance",children:s("onboarding.localSetup.intro")}),e.jsx("div",{className:"app-region-no-drag mt-3 rounded-lg border border-border bg-background/60 px-4 py-3 font-mono text-sm",children:i?e.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(O,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Ie,{windows:I==="windows",onCopy:F,copyTitle:s("onboarding.common.copyToClipboard")})}),e.jsxs("div",{className:"app-region-no-drag mt-3 flex items-center gap-2.5 px-1",role:"status","aria-live":"polite",children:[e.jsx("span",{className:"relative inline-flex h-2 w-2 shrink-0","aria-hidden":!0,children:e.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}})}),e.jsxs("span",{className:"min-w-0 flex-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"text-foreground",children:s("onboarding.localSetup.status.watching")})," · ",s("onboarding.localSetup.status.autoContinue")]}),e.jsx("button",{type:"button",onClick:S,disabled:w,className:"shrink-0 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:s(w?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),e.jsxs("div",{className:"mt-6 divide-y divide-border/60 border-y border-border/60",children:[e.jsxs("details",{className:"app-region-no-drag group",open:C,onToggle:p=>b(p.currentTarget.open),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between py-3 text-sm text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.advanced.title")}),e.jsx(O,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"space-y-2 pb-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{value:j,onChange:p=>T(p.target.value),placeholder:_,disabled:r,className:"flex-1 font-mono text-xs"}),e.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:r||!l,children:s("onboarding.localSetup.actions.browse")}),e.jsx(U,{type:"button",size:"sm",onClick:E,disabled:r||!j.trim(),children:s("onboarding.localSetup.actions.apply")})]}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:s("onboarding.localSetup.helper.saveAndReload")})]})]}),e.jsxs("details",{className:"app-region-no-drag group",open:N,onToggle:p=>K(p.currentTarget.open),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between py-3 text-sm text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.troubleshoot.title")}),e.jsx(O,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsx("ul",{className:"list-disc space-y-1.5 pb-4 pl-4 text-xs text-muted-foreground",children:I==="windows"?e.jsx("li",{children:s("onboarding.localSetup.windows.hintDetectionFailed")}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:s("onboarding.localSetup.hint.ensurePath")}),e.jsx("li",{children:s("onboarding.localSetup.hint.setEnv")}),e.jsx("li",{children:s("onboarding.localSetup.hint.missingRuntime")})]})})]})]}),e.jsx("div",{className:"app-region-no-drag mt-5 text-center",children:e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[s(I==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(O,{name:"external-link",className:"h-3 w-3"})]})})]})]})})}const Ke="curl -fsSL https://opencode.ai/v2/install | bash",be="npm install -g @opencode/cli",De="https://opencode.ai/download";function _e(a){const t=G.c(9),{windows:s,onCopy:i,copyTitle:n}=a;let l;t[0]!==s?(l=e.jsx("code",{className:"flex-1 min-w-0 text-left overflow-x-auto whitespace-nowrap",children:s?e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:be}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/v2/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]})}),t[0]=s,t[1]=l):l=t[1];let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=e.jsx(O,{name:"file-copy",className:"h-4 w-4"}),t[2]=u):u=t[2];let r;t[3]!==n||t[4]!==i?(r=e.jsx("button",{onClick:i,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,"aria-label":n,children:u}),t[3]=n,t[4]=i,t[5]=r):r=t[5];let o;return t[6]!==l||t[7]!==r?(o=e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[l,r]}),t[6]=l,t[7]=r,t[8]=o):o=t[8],o}const Ae=3e4;function Oe({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:i}){const{t:n}=J(),[l,u]=c.useState(!1),[r,o]=c.useState(!1),[w,R]=c.useState(!1),[j,T]=c.useState(!1),[I,x]=c.useState(!1),[m,k]=c.useState(null),[C,b]=c.useState(""),[N,K]=c.useState("unknown");c.useEffect(()=>{const d=setTimeout(()=>o(!0),Ae);return()=>clearTimeout(d)},[]),c.useEffect(()=>{R(B())},[]),c.useEffect(()=>{if(typeof navigator>"u"){K("unknown");return}const d=navigator.userAgent||"";if(/Windows/i.test(d)){K("windows");return}if(/Macintosh|Mac OS X/i.test(d)){K("macos");return}if(/Linux/i.test(d)){K("linux");return}K("unknown")},[]),c.useEffect(()=>{let d=!1;return(async()=>{try{const _=await ue();if(!_||d)return;const $=_.opencodeBinary??"";$&&b($)}catch{}})(),()=>{d=!0}},[]);const y=c.useCallback(async d=>{d.target.closest("button, a, input, select, textarea, code")||d.button===0&&w&&await pe()},[w]),f=c.useCallback(async()=>{try{const d=await X("/health");if(!d.ok)return!1;const _=await d.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),g=c.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const d=await he();d.success&&d.path&&d.path.trim().length>0&&b(d.path.trim())}catch{}},[w]),L=c.useCallback(async()=>{T(!0);try{if(await xe({opencodeBinary:C.trim()}),w){await H();return}await X("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>T(!1),1e3)}},[w,C]),S=c.useCallback(async()=>{const d=await me(N==="windows"?be:Ke);d.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",d.error)},[N]),A=c.useCallback(async()=>{x(!0),k(null);try{await f()?t?.():k(n("onboarding.localSetup.errors.cliNotReady"))}catch(d){k(d instanceof Error?d.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{x(!1)}},[f,t,n]),E=De,F=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.opencode/bin/opencode":"/Users/you/.opencode/bin/opencode";return e.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:y,children:[e.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[e.jsx("div",{className:"flex items-center",children:e.jsx(U,{variant:"ghost",onClick:a,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:n("onboarding.localSetup.title")}),e.jsx("p",{className:"text-muted-foreground",children:n("onboarding.localSetup.description")})]}),N==="windows"&&e.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[e.jsx("div",{className:"text-sm text-foreground",children:n("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:n("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:n("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:l?e.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(O,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(_e,{windows:N==="windows",onCopy:S,copyTitle:n("onboarding.common.copyToClipboard")})})}),e.jsxs("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[n(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(O,{name:"external-link",className:"h-3 w-3"})]}),m&&e.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{type:"button",onClick:A,disabled:I,className:"w-full max-w-xs",size:"lg",children:n(I?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("onboarding.localSetup.helper.checkAndContinue")})]}),e.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:n("onboarding.localSetup.field.alreadyInstalled")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{value:C,onChange:d=>b(d.target.value),placeholder:F,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(U,{type:"button",variant:"secondary",onClick:g,disabled:j||!w,children:n("onboarding.localSetup.actions.browse")}),e.jsx(U,{type:"button",onClick:L,disabled:j,children:n("onboarding.localSetup.actions.apply")})]}),e.jsx("div",{className:"text-xs text-muted-foreground/70",children:n("onboarding.localSetup.helper.saveAndReload")})]})}),s&&i&&e.jsxs("div",{className:"text-center pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n("onboarding.localSetup.remotePreference")}),e.jsx(U,{variant:"link",onClick:i,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),r&&e.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:N==="windows"?e.jsx(e.Fragment,{children:e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.ensurePath")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.setEnv")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.missingRuntime")})]})})]})}function se(a,t){if(a?.trim())return re(a.trim());if(t)return re(t)}function Ee(a,t,s){switch(a){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const i=se(t,s);return{title:"Remote Server Unreachable",description:`Could not connect to "${i||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:i?{host:i}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const i=se(t,s);return{title:"Incompatible Server",description:`The server at "${i||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:i?{host:i}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const i=se(t,s);return{title:"Server Update Required",description:`The OpenChamber server at "${i||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:i?{host:i}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const i=a;throw new Error(`Unknown recovery variant: ${i}`)}}}function Me(a){switch(a){case"local":return e.jsx(O,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(O,{name:"server",className:"h-8 w-8"})}}function Fe({variant:a,hostLabel:t,hostUrl:s,onRetry:i,onUseLocal:n,onUseRemote:l,isRetrying:u=!1}){const{t:r}=J(),o=Ee(a,t,s),w=o.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",R=c.useMemo(()=>{if(o.descriptionParams?.host)return o.descriptionParams;if(a==="remote-unreachable")return{host:r("onboarding.desktopRecovery.placeholders.remoteServer")};if(a==="remote-wrong-service"||a==="remote-incompatible")return{host:r("onboarding.desktopRecovery.placeholders.unknownServer")}},[o.descriptionParams,r,a]);return e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[e.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:e.jsx("div",{style:{color:"var(--status-warning)"},children:Me(o.iconKey)})}),e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:r(o.titleKey)}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:r(o.descriptionKey,R)})]}),s&&(a==="remote-unreachable"||a==="remote-wrong-service"||a==="remote-incompatible")&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:r("onboarding.remoteConnection.field.serverAddress")}),e.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:re(s)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[o.showRetry&&i&&e.jsxs(U,{onClick:i,disabled:u,className:"w-full",children:[e.jsx(O,{name:"refresh",className:ne("h-4 w-4",u&&"animate-spin")}),r(u?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(U,{variant:"outline",onClick:n,disabled:u,className:"flex-1",children:[e.jsx(O,{name:"macbook",className:"h-4 w-4"}),r(o.useLocalLabelKey)]}),o.showUseRemote&&l&&e.jsxs(U,{variant:"outline",onClick:l,disabled:u,className:"flex-1",children:[e.jsx(O,{name:"server",className:"h-4 w-4"}),r(o.useRemoteLabelKey)]})]})]})]})})}function de(a,t){if(t==="use-remote")return{kind:"remote-form"};switch(a){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const s=a;throw new Error(`Unhandled RecoveryVariant: ${s}`)}}}function He(a){const t=G.c(29),{variant:s,hostUrl:i,hostLabel:n,onRetry:l,onChooseRemote:u,showRemoteForm:r,onCloseRemoteForm:o,onSwitchToLocalFromRemote:w,onEnterLocalSetup:R,isRetrying:j,localAvailable:T}=a,I=r===void 0?!1:r,x=j===void 0?!1:j,m=T===void 0?!0:T,k=Pe;let C;t[0]!==l?(C=async()=>{if(B()){await H();return}await X("/api/config/reload",{method:"POST"}),l?.()},t[0]=l,t[1]=C):C=t[1];const b=C;let N;t[2]!==R||t[3]!==s?(N=async()=>{if(de(s,"use-local").kind==="local-setup"){R?.();return}if(await k("local"),B()){await H();return}window.location.reload()},t[2]=R,t[3]=s,t[4]=N):N=t[4];const K=N;let y;t[5]!==u||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&u?.()},t[5]=u,t[6]=s,t[7]=y):y=t[7];const f=y;if(I){const S=s==="remote-wrong-service"?"":i||"",A=s==="remote-wrong-service"?"":n||"";let E;t[8]!==u||t[9]!==o?(E=o||(()=>u?.()),t[8]=u,t[9]=o,t[10]=E):E=t[10];const F=!m;let d;t[11]!==m||t[12]!==R||t[13]!==w?(d=m?w||(()=>{k("local").then(()=>{B()?H():R?.()})}):void 0,t[11]=m,t[12]=R,t[13]=w,t[14]=d):d=t[14];let _;return t[15]!==A||t[16]!==S||t[17]!==E||t[18]!==F||t[19]!==d?(_=e.jsx(fe,{onBack:E,initialUrl:S,initialLabel:A,isRecoveryMode:!0,showInstancePicker:F,onSwitchToLocal:d}),t[15]=A,t[16]=S,t[17]=E,t[18]=F,t[19]=d,t[20]=_):_=t[20],_}const g=m?K:void 0;let L;return t[21]!==b||t[22]!==f||t[23]!==n||t[24]!==i||t[25]!==x||t[26]!==g||t[27]!==s?(L=e.jsx(Fe,{variant:s,hostLabel:n,hostUrl:i,onRetry:b,onUseLocal:g,onUseRemote:f,isRetrying:x}),t[21]=b,t[22]=f,t[23]=n,t[24]=i,t[25]=x,t[26]=g,t[27]=s,t[28]=L):L=t[28],L}async function Pe(a){if(!B())return;const t=await W();await V({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function fo(a){const t=G.c(29),{onBack:s,onCliAvailable:i,mode:n,recoveryVariant:l,recoveryHostUrl:u,recoveryHostLabel:r,onEnterLocalSetup:o,localAvailable:w}=a,R=n===void 0?"first-launch":n,j=l===void 0?"missing-default-host":l,T=w===void 0?!0:w,[I,x]=c.useState(!1),[m,k]=c.useState(!1);let C;t[0]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{k(!1),x(!1)},t[0]=C):C=t[0];let b;t[1]!==R||t[2]!==r||t[3]!==u||t[4]!==j?(b=[R,j,u,r],t[1]=R,t[2]=r,t[3]=u,t[4]=j,t[5]=b):b=t[5],c.useEffect(C,b);const N=m?"local-setup":R;if(N==="recovery"){let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=()=>x(!0),t[6]=y):y=t[6];let f,g;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),g=()=>{x(!1),k(!0)},t[7]=f,t[8]=g):(f=t[7],g=t[8]);let L;t[9]!==o?(L=()=>{k(!0),o?.()},t[9]=o,t[10]=L):L=t[10];let S;return t[11]!==T||t[12]!==r||t[13]!==u||t[14]!==j||t[15]!==I||t[16]!==L?(S=e.jsx(He,{variant:j,hostUrl:u,hostLabel:r,onChooseRemote:y,showRemoteForm:I,onCloseRemoteForm:f,onSwitchToLocalFromRemote:g,onEnterLocalSetup:L,localAvailable:T}),t[11]=T,t[12]=r,t[13]=u,t[14]=j,t[15]=I,t[16]=L,t[17]=S):S=t[17],S}if(N==="local-setup"){let y;t[18]!==s||t[19]!==m?(y=()=>{m?k(!1):s?.()},t[18]=s,t[19]=m,t[20]=y):y=t[20];let f;t[21]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!0),t[21]=f):f=t[21];let g;return t[22]!==i||t[23]!==m||t[24]!==y?(g=e.jsx(Oe,{onBack:y,onCliAvailable:i,isFromRecovery:m,onSwitchToRemote:f}),t[22]=i,t[23]=m,t[24]=y,t[25]=g):g=t[25],g}let K;return t[26]!==T||t[27]!==i?(K=e.jsx(Te,{onCliAvailable:i,localAvailable:T}),t[26]=T,t[27]=i,t[28]=K):K=t[28],K}export{fo as OnboardingScreen};
@@ -1 +1 @@
1
- import{jC as S,jH as k,jP as y}from"./useAppFontEffects-ne84JBVL.js";import{k as D,a as C}from"./web-components-DxX8bZ1o.js";import{M as P,G as O,u as L,W as A,a as H,b as M,n as F,t as R}from"./Virtualizer-CZlLSacm.js";import{j as d,r as w}from"./vendor-react-BUCujlKS.js";import{V as _,F as N}from"./VirtualizedFileDiff-NU0FHFhT.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const o=e.hunkContent[l];n+=o.type==="context"?o.lines:o.deletions+o.additions}return n}function U(e){const t=S(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:o,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:s,lineAnnotations:a,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=o?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[g!=null?d.jsx("div",{slot:k,children:g}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:D(r),children:f(r)},h)),t!=null&&s!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:s(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const j=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:o,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:s,contentEditable:a}){const p=L(),m=l!==void 0,g=w.useContext(A),c=H(),i=w.useRef(null),v=M(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");p!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),p,x,s?void 0:g,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),s?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:o})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return j(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),j(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:o,hasGutterRenderUtility:x}){const f=n&&o,u=t||x||l;if(!u&&!f)return e;let s={...e};return u&&(s={...s,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(s={...s,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),s}function X({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:o,className:x,style:f,prerenderedHTML:u,renderAnnotation:s,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:o,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(y,{ref:h,className:x,style:f,children:R($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:s,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{X as P};
1
+ import{k4 as k,k9 as j,kh as y}from"./useAppFontEffects-Ci3FEaPf.js";import{k as D,a as C}from"./web-components-B6tKQyJN.js";import{M as P,G as O,u as L,W as A,a as M,b as R,n as F,t as H}from"./Virtualizer-CZlLSacm.js";import{j as d,r as w}from"./vendor-react-BUCujlKS.js";import{V as _,F as N}from"./VirtualizedFileDiff-C763hNCR.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const o=e.hunkContent[l];n+=o.type==="context"?o.lines:o.deletions+o.additions}return n}function U(e){const t=k(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:o,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:s,lineAnnotations:a,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=o?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[g!=null?d.jsx("div",{slot:j,children:g}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:D(r),children:f(r)},h)),t!=null&&s!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:s(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:o,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:s,contentEditable:a}){const p=L(),m=l!==void 0,g=w.useContext(A),c=M(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");p!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),p,x,s?void 0:g,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),s?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:o})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:o,hasGutterRenderUtility:x}){const f=n&&o,u=t||x||l;if(!u&&!f)return e;let s={...e};return u&&(s={...s,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(s={...s,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),s}function X({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:o,className:x,style:f,prerenderedHTML:u,renderAnnotation:s,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:o,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(y,{ref:h,className:x,style:f,children:H($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:s,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{X as P};
@@ -1,4 +1,4 @@
1
- import{R as $,j as F,c as we,r as l}from"./vendor-react-BUCujlKS.js";import{a as nt}from"./web-components-DxX8bZ1o.js";import{f as We}from"./computeVirtualFileMetrics-DlWlEM3x.js";import{V as rt,F as it}from"./VirtualizedFileDiff-NU0FHFhT.js";import{V as ot}from"./Virtualizer-D_a8gKmg.js";import{eE as st,eF as je,bg as at,c6 as lt,h as Be}from"./useAppFontEffects-ne84JBVL.js";import{I as _e,a as ct,u as dt}from"./useInlineCommentController-CgS0fnw_.js";import"./index-Dqc6USl3.js";import{an as ut}from"./runtimeEndpointReset-DdrazOVH.js";import{ensurePierreThemeRegistered as Ve,getResolvedShikiTheme as Ue}from"./appThemeRegistry-DLicw4dH.js";const xe=n=>{if(n.type==="new"){const r=Math.min(n.selection.start,n.selection.end),i=Math.max(n.selection.start,n.selection.end);return`new-comment-${n.selection.side??"additions"}-${r}-${i}`}return`draft-${n.draft.id}`},ft=n=>{const{drafts:r,editingDraftId:i,selection:s}=n,c=[];for(const m of r){if(!Number.isFinite(m.endLine))continue;const x=Math.max(1,Math.floor(m.endLine)),M=m.side==="original"?"deletions":"additions";c.push({lineNumber:x,side:M,metadata:{type:m.id===i?"edit":"saved",draft:m}})}return s&&!i&&c.push({lineNumber:Math.max(s.start,s.end),side:s.side??"additions",metadata:{type:"new",selection:s}}),c};function ht(n){const r=n.trim();if(!r)return null;if(/^-?\d+(\.\d+)?$/.test(r)){const i=Number.parseFloat(r);return Number.isFinite(i)?i:null}if(r.endsWith("px")){const i=Number.parseFloat(r.slice(0,-2));return Number.isFinite(i)?i:null}return null}function Ke(n){if(!(!n||n<=0))return Math.max(200,Math.floor(n))}function pt(n){const{diffRootRef:r,drafts:i,selection:s,editingDraftId:c,commentText:m,onTextChange:x,fileLabel:M,onSave:d,onCancel:R,onEdit:z,onDelete:N}=n,[ue,W]=$.useState(0),[O,U]=$.useState(null),D=$.useMemo(()=>!s||c?null:xe({type:"new",selection:s}),[c,s]),Z=$.useMemo(()=>{const h=i.map(E=>xe({type:E.id===c?"edit":"saved",draft:E}));return D&&h.push(D),h},[i,c,D]),A=$.useCallback(h=>{const E=r.current;if(!E)return null;const T=E.querySelector("diffs-container");if(!(T instanceof HTMLElement))return null;const w=T.querySelector(`[data-annotation-id="${h}"]`);if(w instanceof HTMLElement)return w;const C=T.shadowRoot;return C?C.querySelector(`[data-annotation-id="${h}"]`):null},[r]);$.useEffect(()=>{if(Z.length===0)return;let h=!1,E=0;const T=12,w=()=>{h||Z.every(q=>!!A(q))||E>=T||(E+=1,requestAnimationFrame(()=>{h||(W(q=>q+1),w())}))};return w(),()=>{h=!0}},[Z,A]),$.useEffect(()=>{const h=r.current;if(!h)return;const E=()=>{const w=getComputedStyle(h),C=ht(w.getPropertyValue("--oc-context-panel-width")),q=h.getBoundingClientRect(),I=C??q.width;U(I>0?I:null)};E();const T=new ResizeObserver(()=>{E()});return T.observe(h),window.addEventListener("resize",E),()=>{T.disconnect(),window.removeEventListener("resize",E)}},[r]);const ee=$.useCallback(h=>{const T=r.current?.getBoundingClientRect(),w=h.closest("[data-annotation-content]"),C=w instanceof HTMLElement?w.getBoundingClientRect():h.getBoundingClientRect(),q=[C.width];T&&q.push(T.right-C.left);const I=q.filter(K=>Number.isFinite(K)&&K>0);return I.length>0?Ke(Math.min(...I)):Ke(O)},[r,O]);return F.jsxs(F.Fragment,{children:[i.map(h=>{const E=xe({type:h.id===c?"edit":"saved",draft:h}),T=A(E);if(!T)return null;const w=ee(T);return h.id===c?we.createPortal(F.jsx(_e,{initialText:m,onTextChange:x,fileLabel:M,lineRange:{start:h.startLine,end:h.endLine,side:h.side==="original"?"deletions":"additions"},isEditing:!0,onSave:d,onCancel:R,maxWidth:w}),T,`draft-edit-${h.id}`):we.createPortal(F.jsx(ct,{draft:h,onEdit:()=>z(h),onDelete:()=>N(h),maxWidth:w}),T,`draft-card-${h.id}`)}),s&&!c&&D&&(()=>{const h=A(D);if(!h)return null;const E=ee(h);return we.createPortal(F.jsx(_e,{initialText:m,onTextChange:x,fileLabel:M,lineRange:s,isEditing:!1,onSave:d,onCancel:R,maxWidth:E}),h,D)})()]})}const Ge=[],mt=`
1
+ import{R as $,j as F,c as we,r as l}from"./vendor-react-BUCujlKS.js";import{a as nt}from"./web-components-B6tKQyJN.js";import{f as We}from"./computeVirtualFileMetrics-DW5jjX4n.js";import{V as rt,F as it}from"./VirtualizedFileDiff-C763hNCR.js";import{V as ot}from"./Virtualizer-D_a8gKmg.js";import{eE as st,eF as je,bj as at,c8 as lt,h as Be}from"./useAppFontEffects-Ci3FEaPf.js";import{I as _e,a as ct,u as dt}from"./useInlineCommentController-CuUuakrt.js";import"./index-CvLgnuNI.js";import{at as ut}from"./runtimeEndpointReset-CsIpUep1.js";import{ensurePierreThemeRegistered as Ve,getResolvedShikiTheme as Ue}from"./appThemeRegistry-u4zw1l0B.js";const xe=n=>{if(n.type==="new"){const r=Math.min(n.selection.start,n.selection.end),i=Math.max(n.selection.start,n.selection.end);return`new-comment-${n.selection.side??"additions"}-${r}-${i}`}return`draft-${n.draft.id}`},ft=n=>{const{drafts:r,editingDraftId:i,selection:s}=n,c=[];for(const m of r){if(!Number.isFinite(m.endLine))continue;const x=Math.max(1,Math.floor(m.endLine)),M=m.side==="original"?"deletions":"additions";c.push({lineNumber:x,side:M,metadata:{type:m.id===i?"edit":"saved",draft:m}})}return s&&!i&&c.push({lineNumber:Math.max(s.start,s.end),side:s.side??"additions",metadata:{type:"new",selection:s}}),c};function ht(n){const r=n.trim();if(!r)return null;if(/^-?\d+(\.\d+)?$/.test(r)){const i=Number.parseFloat(r);return Number.isFinite(i)?i:null}if(r.endsWith("px")){const i=Number.parseFloat(r.slice(0,-2));return Number.isFinite(i)?i:null}return null}function Ke(n){if(!(!n||n<=0))return Math.max(200,Math.floor(n))}function pt(n){const{diffRootRef:r,drafts:i,selection:s,editingDraftId:c,commentText:m,onTextChange:x,fileLabel:M,onSave:d,onCancel:R,onEdit:z,onDelete:N}=n,[ue,W]=$.useState(0),[O,U]=$.useState(null),D=$.useMemo(()=>!s||c?null:xe({type:"new",selection:s}),[c,s]),Z=$.useMemo(()=>{const h=i.map(E=>xe({type:E.id===c?"edit":"saved",draft:E}));return D&&h.push(D),h},[i,c,D]),A=$.useCallback(h=>{const E=r.current;if(!E)return null;const T=E.querySelector("diffs-container");if(!(T instanceof HTMLElement))return null;const w=T.querySelector(`[data-annotation-id="${h}"]`);if(w instanceof HTMLElement)return w;const C=T.shadowRoot;return C?C.querySelector(`[data-annotation-id="${h}"]`):null},[r]);$.useEffect(()=>{if(Z.length===0)return;let h=!1,E=0;const T=12,w=()=>{h||Z.every(q=>!!A(q))||E>=T||(E+=1,requestAnimationFrame(()=>{h||(W(q=>q+1),w())}))};return w(),()=>{h=!0}},[Z,A]),$.useEffect(()=>{const h=r.current;if(!h)return;const E=()=>{const w=getComputedStyle(h),C=ht(w.getPropertyValue("--oc-context-panel-width")),q=h.getBoundingClientRect(),I=C??q.width;U(I>0?I:null)};E();const T=new ResizeObserver(()=>{E()});return T.observe(h),window.addEventListener("resize",E),()=>{T.disconnect(),window.removeEventListener("resize",E)}},[r]);const ee=$.useCallback(h=>{const T=r.current?.getBoundingClientRect(),w=h.closest("[data-annotation-content]"),C=w instanceof HTMLElement?w.getBoundingClientRect():h.getBoundingClientRect(),q=[C.width];T&&q.push(T.right-C.left);const I=q.filter(K=>Number.isFinite(K)&&K>0);return I.length>0?Ke(Math.min(...I)):Ke(O)},[r,O]);return F.jsxs(F.Fragment,{children:[i.map(h=>{const E=xe({type:h.id===c?"edit":"saved",draft:h}),T=A(E);if(!T)return null;const w=ee(T);return h.id===c?we.createPortal(F.jsx(_e,{initialText:m,onTextChange:x,fileLabel:M,lineRange:{start:h.startLine,end:h.endLine,side:h.side==="original"?"deletions":"additions"},isEditing:!0,onSave:d,onCancel:R,maxWidth:w}),T,`draft-edit-${h.id}`):we.createPortal(F.jsx(ct,{draft:h,onEdit:()=>z(h),onDelete:()=>N(h),maxWidth:w}),T,`draft-card-${h.id}`)}),s&&!c&&D&&(()=>{const h=A(D);if(!h)return null;const E=ee(h);return we.createPortal(F.jsx(_e,{initialText:m,onTextChange:x,fileLabel:M,lineRange:s,isEditing:!1,onSave:d,onCancel:R,maxWidth:E}),h,D)})()]})}const Ge=[],mt=`
2
2
  [data-gutter-buffer="annotation"] { min-height: 0; }
3
3
  [data-code] { min-height: 2.5rem; align-content: start; }
4
4
  `,Ye=5e5,gt=`
@@ -0,0 +1,5 @@
1
+ import{R as t,j as n}from"./vendor-react-BUCujlKS.js";import{n as jt,u as Qe,a as he,x as Xe,h as qe,y as xt}from"./index-CvLgnuNI.js";import{c as bt,s as Ct,P as Rt,C as Mt}from"./shikiHighlight-DNm2Z_Jc.js";import{f as Tt,z as G,cC as Pt,aJ as kt,b as Ze,K as Nt,ai as Et,_ as It,bj as Dt,T as Vt,fY as Ft,a3 as Lt,ix as At,l as et,fX as Ot,ay as tt,hy as zt,fV as Kt,dy as nt,f_ as Wt,f$ as _t,m as Bt,iy as $t,as as rt,ae as ge,af as ve,at as st,B as ee,I as L,ag as we,av as it,bh as te,g as Gt,c8 as Jt,aB as Ut,cp as Ht,iz as Yt}from"./useAppFontEffects-Ci3FEaPf.js";import{u as Qt,n as Xt}from"./useInlineCommentController-CuUuakrt.js";import{b as qt}from"./CodeMirrorCommentWidgets-ntXIbhV2.js";import{getResolvedShikiTheme as Zt}from"./appThemeRegistry-u4zw1l0B.js";import{E as en}from"./vendor-codemirror-view-CiLROUVV.js";import{as as tn}from"./runtimeEndpointReset-CsIpUep1.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CQa7_1cr.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./textMateThemeFromAppTheme-DGF2kG7g.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./GuestAttachDialog-DdOuyZzp.js";import"./PluginPane-BPP1dbck.js";const nn=()=>{const l=new Map,d=new Map;return{schedule:(c,s,m)=>{if(s<=(d.get(c)??Number.NEGATIVE_INFINITY))return l.get(c)??Promise.resolve();d.set(c,s);const h=(l.get(c)??Promise.resolve()).then(m,m);return l.set(c,h.catch(()=>{d.get(c)===s&&d.delete(c)})),h},pendingFor:async c=>{await l.get(c)},reset:c=>{d.delete(c)}}},y=l=>{if(!l)return"";const d=l.replace(/\\/g,"/");return d==="/"?"/":d.replace(/\/+$/,"")},rn=(l,d)=>{const c=y(d.currentDirectory),s=y(d.homeDirectory),m=y(l);return c&&m.startsWith(c+"/")?m.slice(c.length+1):s&&m===s?"~":s&&m.startsWith(s+"/")?`~${m.slice(s.length)}`:m},sn=(l,d,c)=>{const s=y(l.trim());if(!s)return null;const m=c?d.find(h=>h.id===c)??null:null;if(m?.path){const h=y(m.path);if(s===h||s.startsWith(`${h}/`))return{id:m.id,path:m.path}}const R=d.filter(h=>{const M=y(h.path);return s===M||s.startsWith(`${M}/`)}).sort((h,M)=>y(M.path).length-y(h.path).length)[0];return R?{id:R.id,path:R.path}:null},on=l=>xt(()=>l()),as=({targetPath:l=null,savedProjectPlan:d=null,onNavigatedToChat:c})=>{const{t:s}=Tt(),m=G(e=>e.currentSessionId),R=G(e=>e.createSession),h=G(e=>e.initializeNewOpenChamberSession),M=G(e=>e.sendMessage),Se=G(e=>e.setCurrentSession),ye=Pt(),J=jt(e=>e.homeDirectory),je=kt(e=>e.planModeEnabled),xe=Ze(e=>e.projects),be=Ze(e=>e.activeProjectId),Ce=Nt(e=>e.directories),Re=Et()??"",Me=Qe(e=>e.setSessionSwitcherOpen),A=It(),O=t.useSyncExternalStore(on,he,he),{isMobile:Te}=Dt(),{currentTheme:U}=Vt(),ne=t.useMemo(()=>m?ye.find(e=>e.id===m)??null:null,[m,ye]),E=t.useMemo(()=>{const e=typeof ne?.directory=="string"?ne.directory:"";return y(e||"")},[ne?.directory]),Pe=t.useMemo(()=>y(Re||E),[Re,E]),z=t.useMemo(()=>sn(Pe,xe,be),[be,Pe,xe]),re=d?.projectRef.id??null,se=d?.projectRef.path??null,g=t.useMemo(()=>re&&se?{id:re,path:se}:null,[re,se]),x=d?.planId??null,K=g&&x?JSON.stringify(["saved-plan",O,Ft(g),x]):null,I=g?.id===Lt,H=t.useMemo(()=>{const e=g??z;return e?Ce.get(e.path)?.isGitRepo===!0:!1},[z,Ce,g]),[T,D]=t.useState(null),[ke,Ne]=t.useState(!1),[u,W]=t.useState(null),[ie,oe]=t.useState(null),ot=!!u||!!ie,ae=t.useMemo(()=>!u||!E||!J?u:rn(u,{currentDirectory:E,homeDirectory:J}),[u,E,J]),[f,P]=t.useState(""),{isPlaying:Y,play:at,stop:lt}=At(),ct=et(e=>e.showMessageTTSButtons),[Ee,le]=t.useState(null),[Ie,ce]=t.useState(null),ue=t.useMemo(()=>ae&&ae.split("/").pop()||s("planView.file.defaultName"),[ae,s]),de=t.useMemo(()=>f.trim()?Ot(f,s("planView.title.default")).title:s("planView.title.default"),[f,s]),Q=t.useMemo(()=>de.trim()||s("planView.title.default"),[de,s]),[ut,_]=t.useState(!1),[dt,De]=t.useState(!1),[X,Ve]=t.useState("edit"),B=t.useRef(null),[a,w]=t.useState(null),Fe=t.useRef(null),mt=t.useRef(null),Le="openchamber:plan:md-viewer-mode";t.useEffect(()=>{try{const e=localStorage.getItem(Le);if(!e)return;const i=JSON.parse(e);(i==="preview"||i==="edit")&&Ve(i)}catch{}},[]);const pt=t.useCallback(e=>{Ve(e);try{localStorage.setItem(Le,JSON.stringify(e))}catch{}},[]),V=t.useRef(!1),b=t.useRef(null),[Ae,F]=t.useState(!1);t.useEffect(()=>{const e=()=>{V.current=!1,b.current=null,F(!1)};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[]);const ft=t.useCallback((e,i)=>{const o=e.split(`
2
+ `),r=Math.max(1,i.start),p=Math.min(o.length,i.end);return r>p?"":o.slice(r-1,p).join(`
3
+ `)},[]),ht=Qt({source:"plan",fileLabel:ue,language:u&&tt(u)||"markdown",getCodeForRange:e=>ft(f,Xt(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})}),{drafts:Oe,commentText:q,setCommentText:ze,editingDraftId:me,setSelection:Ke,saveComment:We,cancel:$,reset:_e,startEdit:Be,deleteDraft:$e}=ht;t.useEffect(()=>{w(null),_e()},[f,_e]),t.useEffect(()=>{Ke(a)},[a,Ke]);const Ge=t.useCallback(()=>{w(null),$()},[$]),Je=t.useCallback((e,i)=>{i&&w(i),We(e,i??a??void 0),w(null)},[a,We]);t.useEffect(()=>{if(!a)return;const e=o=>{const r=o.target;r.closest('[data-comment-card="true"]')||r.closest('[data-comment-input="true"]')||r.closest(".oc-block-widget")||r.closest(".cm-gutterElement")||r.closest("[data-sonner-toast]")||r.closest("[data-sonner-toaster]")||q.trim()||(w(null),$())},i=window.setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{window.clearTimeout(i),document.removeEventListener("click",e)}},[$,q,me,Te,a]);const pe=Qe(e=>e.editorFontSize),gt=t.useMemo(()=>{const e=u?tt(u):null,i=!!e&&e!=="markdown",o=[bt(U,i?{syntaxColors:!1,fontSize:pe}:{fontSize:pe})],r=zt(u||"plan.md");return r&&o.push(r),i&&e&&o.push(Ct({language:e,themeName:U.metadata.id,theme:Zt(U)})),o.push(en.lineWrapping),o},[U,u,pe]),j=t.useRef({key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""}),k=t.useState(nn)[0],Ue=t.useCallback(async(e,i)=>{if("filePath"in e){const r=A.files??Xe()?.files;if(r?.writeFile){if(!(await r.writeFile(e.filePath,i))?.success)throw new Error("Plan file write failed");return}const p=await qe("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.filePath,content:i})});if(!p.ok)throw new Error(`Failed to write plan file (${p.status})`);return}if(!await Kt.getState().savePlan(e.projectRef,e.planId,i))throw new Error("Plan save rejected: the plan no longer exists")},[A.files]),He=t.useRef(Ue);He.current=Ue;const N=t.useCallback(()=>{const e=j.current;if(!e.key||!e.target||e.editRevision<=e.savedRevision)return;const i={key:e.key,target:e.target,content:e.content,revision:e.editRevision,runtimeKey:e.runtimeKey,write:He.current};k.schedule(i.key,i.revision,async()=>{if(he()!==i.runtimeKey)return;await i.write(i.target,i.content);const o=j.current;o.key===i.key&&(o.savedRevision=Math.max(o.savedRevision,i.revision),le(null))}).catch(o=>{j.current.key===i.key&&le(o instanceof Error?o.message:"Plan save failed")})},[k]);t.useEffect(()=>{if(!je&&!l&&!x){N(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},W(null),oe(null),P(""),_(!1);return}let e=!1;const i=async r=>{if(A.files?.readFile)return(await A.files.readFile(r))?.content??"";const p=Xe()?.files;if(p?.readFile)return(await p.readFile(r,{optional:!0}))?.content??"";const v=await qe(`/api/fs/read?path=${encodeURIComponent(r)}&optional=true`,{cache:"no-store"});if(!v.ok)throw new Error(`Failed to read plan file (${v.status})`);return v.text()};return(async()=>{if(N(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},W(null),oe(null),P(""),le(null),ce(null),x&&g&&K){if(await k.pendingFor(K),e)return;k.reset(K),_(!0);try{const r=await Yt(g,x);if(e)return;if(!r){ce("Plan not found");return}j.current={key:K,target:{projectRef:g,planId:x},content:r.raw,editRevision:0,savedRevision:0,runtimeKey:O},P(r.raw),oe(x)}catch(r){if(e)return;ce(r instanceof Error?r.message:"Plan load failed")}finally{e||_(!1)}return}if(l){const r=JSON.stringify(["plan-file",O,l]);if(await k.pendingFor(r),e)return;k.reset(r),_(!0);try{const p=await i(l);if(e)return;j.current={key:r,target:{filePath:l},content:p,editRevision:0,savedRevision:0,runtimeKey:O},W(l),P(p)}catch{if(e)return;W(null),P("")}finally{e||_(!1)}return}W(null),P("")})(),()=>{e=!0}},[O,J,je,A.files,x,K,g,k,N,E,l]);const vt=t.useCallback(e=>{j.current.content=e,j.current.editRevision+=1,P(e)},[]);t.useEffect(()=>{if(!u&&!ie)return;const e=window.setTimeout(()=>{N()},350);return()=>{window.clearTimeout(e)}},[f,ie,u,N]),t.useEffect(()=>()=>{N()},[N]),t.useEffect(()=>()=>{B.current!==null&&window.clearTimeout(B.current)},[]);const Ye=t.useCallback(()=>{Me(!1),c?.()},[c,Me]),wt=t.useCallback(async e=>{const i=g??z;if(!i||!T||I)return;const o=await nt(T.action==="improve"?"plan.improve.visible":"plan.implement.visible",{plan_title:Q}),r=await nt(T.action==="improve"?"plan.improve.instructions":"plan.implement.instructions",{plan_title:Q,plan_path:u??""}),v=[{synthetic:!0,text:u?r:[r,"","The plan is not stored as a file in the repository and has no file path. Its full current contents follow below this note and are the source of truth for the plan. Where the instructions above refer to the plan file, treat the plan as stored in OpenChamber project knowledge (it is edited through the OpenChamber UI): propose plan revisions as plan text in the chat rather than editing a file.","",f].join(`
4
+ `)}];Ne(!0);try{Ye();let S=null,fe=i.path;if(T.target==="worktree"){if(!H)return;const C=await Wt(i.path,_t());if(!C?.id)return;S=C.id,fe=C.path}else{const C=await R(void 0,i.path,void 0,{model:{providerID:e.providerID,id:e.modelID,variant:e.variant||void 0},agent:e.agent.trim()||void 0});if(!C?.id)return;S=C.id,fe=C.directory??i.path,h(C.id,et.getState().agents??[])}if(!S)return;const Z=Bt.getState();Z.saveSessionModelSelection(S,e.providerID,e.modelID),e.agent.trim()&&(Z.saveSessionAgentSelection(S,e.agent),Z.saveAgentModelForSession(S,e.agent,e.providerID,e.modelID),Z.saveAgentModelVariantForSession(S,e.agent,e.providerID,e.modelID,e.variant||void 0)),Se(S,fe);const yt=e.runAsGoal===!0?[`Implement the plan "${Q}" end-to-end${u?` (plan file: ${u})`:" (the full plan follows)"}.`,u?"Re-read that file for full details — it is the source of truth.":"The full plan follows in this message and is the source of truth.","",f].join(`
5
+ `):null;$t.getState().setArmed(e.runAsGoal===!0,yt),await M(o,e.providerID,e.modelID,e.agent.trim()||void 0,void 0,void 0,v,e.variant||void 0),D(null)}finally{Ne(!1)}},[H,f,R,z,h,I,T,u,Ye,g,M,Q,Se]),St=t.useMemo(()=>qt({drafts:Oe,editingDraftId:me,commentText:q,onTextChange:ze,selection:a,isDragging:Ae,fileLabel:ue,newWidgetId:"plan-new-comment-input",mapDraftToRange:e=>({start:e.startLine,end:e.endLine}),onSave:Je,onCancel:Ge,onEdit:e=>{Be(e),w({start:e.startLine,end:e.endLine})},onDelete:$e}),[q,$e,me,Ge,Je,Ae,a,Oe,ue,ze,Be]);return n.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 border-b border-border/40 px-3 py-1.5 flex-shrink-0",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"typography-ui-label font-medium truncate",children:de}),Ie?n.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:Ie,children:s("planView.error.loadFailed")}):null,Ee?n.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:Ee,children:s("planView.error.saveFailed")}):null]}),ot?n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsxs(rt,{children:[n.jsxs(ge,{children:[n.jsx(ve,{asChild:!0,children:n.jsx(st,{asChild:!0,children:n.jsx(ee,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s("planView.actions.improvePlanAria"),disabled:!f.trim()||I,children:n.jsx(L,{name:"loop-right-ai",className:"size-4"})})})}),n.jsx(we,{sideOffset:8,children:s("planView.actions.improve")})]}),n.jsxs(it,{align:"end",children:[n.jsx(te,{onClick:()=>D({action:"improve",target:"session"}),disabled:I,children:s("planView.actions.sendToNewSession")}),n.jsx(te,{onClick:()=>D({action:"improve",target:"worktree"}),disabled:!H,children:s("planView.actions.sendToNewWorktreeSession")})]})]}),n.jsxs(rt,{children:[n.jsxs(ge,{children:[n.jsx(ve,{asChild:!0,children:n.jsx(st,{asChild:!0,children:n.jsx(ee,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s("planView.actions.implementPlanAria"),disabled:!f.trim()||I,children:n.jsx(L,{name:"code-ai",className:"size-4"})})})}),n.jsx(we,{sideOffset:8,children:s("planView.actions.implement")})]}),n.jsxs(it,{align:"end",children:[n.jsx(te,{onClick:()=>D({action:"implement",target:"session"}),disabled:I,children:s("planView.actions.sendToNewSession")}),n.jsx(te,{onClick:()=>D({action:"implement",target:"worktree"}),disabled:!H,children:s("planView.actions.sendToNewWorktreeSession")})]})]}),n.jsx(Rt,{currentMode:X,onToggle:()=>pt(X==="preview"?"edit":"preview")}),X==="preview"&&ct&&n.jsxs(ge,{children:[n.jsx(ve,{asChild:!0,children:n.jsx(ee,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s(Y?"planView.tts.stopSpeaking":"planView.tts.readAloud"),onClick:()=>{Y?lt():f.trim()&&at(f)},children:Y?n.jsx(L,{name:"stop",className:"h-4 w-4 text-[color:var(--status-success)]"}):n.jsx(L,{name:"volume-up",className:"h-4 w-4"})})}),n.jsx(we,{sideOffset:8,children:s(Y?"planView.tts.stopSpeaking":"planView.tts.readAloud")})]}),n.jsx(ee,{variant:"ghost",size:"sm",onClick:async()=>{(await Gt(f)).ok&&(De(!0),B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{De(!1)},1200))},className:"h-5 w-5 p-0",title:s("planView.actions.copyPlanContents"),"aria-label":s("planView.actions.copyPlanContents"),children:dt?n.jsx(L,{name:"check",className:"h-4 w-4 text-[color:var(--status-success)]"}):n.jsx(L,{name:"clipboard",className:"h-4 w-4"})})]}):null]}),n.jsx(tn,{open:T!==null,onOpenChange:e=>{!e&&!ke&&D(null)},target:T?.target??"session",projectDirectory:g?.path??z?.path??null,submitting:ke,allowRunAsGoal:!0,onConfirm:wt}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:n.jsx(Jt,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:ut?n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:s("planView.state.loading")}):n.jsx("div",{className:"relative h-full",children:n.jsx("div",{className:"h-full",children:X==="preview"?n.jsx("div",{className:"h-full overflow-auto p-3",children:n.jsx(Ut,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:s("planView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:s("planView.error.switchToEditMode")})]}),children:n.jsx(Ht,{content:f,className:"typography-markdown-body",enableFileReferences:!1})})}):n.jsx("div",{className:"relative h-full",ref:mt,children:n.jsx(Mt,{value:f,onChange:vt,readOnly:!1,className:"h-full",extensions:gt,onViewReady:e=>{Fe.current=e},onViewDestroy:()=>{Fe.current=null},blockWidgets:St,highlightLines:a?{start:Math.min(a.start,a.end),end:Math.max(a.start,a.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(e,i,o)=>{if(!(o instanceof MouseEvent)||o.button!==0)return!1;o.preventDefault();const r=e.state.doc.lineAt(i.from).number;if(a&&!o.shiftKey&&Math.min(a.start,a.end)===r&&Math.max(a.start,a.end)===r)return w(null),$(),V.current=!1,b.current=null,F(!1),!0;if(Te&&a&&!o.shiftKey){const p=Math.min(a.start,a.end,r),v=Math.max(a.start,a.end,r);return w({start:p,end:v}),V.current=!1,b.current=null,F(!1),!0}if(V.current=!0,b.current=r,F(!0),a&&o.shiftKey){const p=Math.min(a.start,r),v=Math.max(a.end,r);w({start:p,end:v})}else w({start:r,end:r});return!0},mouseover:(e,i,o)=>{if(!(o instanceof MouseEvent)||o.buttons!==1||!V.current||b.current===null)return!1;const r=e.state.doc.lineAt(i.from).number,p=Math.min(b.current,r),v=Math.max(b.current,r);return w({start:p,end:v}),F(!0),!1},mouseup:()=>(V.current=!1,b.current=null,F(!1),!1)}}})})})})})})]})};export{as as PlanView};
@@ -0,0 +1,3 @@
1
+ import{f as Kn,R as y,j as ce}from"./vendor-react-BUCujlKS.js";import{iD as Me,iE as Pe,iF as Wn,iG as Vn,iH as Yn,iI as je,iJ as Zn,iK as Ht,iL as Qn,iM as es,iN as ts,iO as ns,iP as ss,iQ as rs,iR as os,iS as as,iT as is,iU as Bt,iV as cs,iW as ls,iX as us,iY as ds,iZ as ps,i_ as ms,i$ as fs,j0 as ys,j1 as Ft,j2 as hs,j3 as Ss,j4 as W,j5 as V,j6 as ln,j7 as un,j8 as gs,j9 as Es,ja as Ts,jb as ks,jc as dn,jd as ws,je as vt,jf as pn,jg as mn,jh as fn,ji as yn,jj as xs,jk as $t,jl as _s,jm as vs,jn as hn,jo as bs,jp as Rs,jq as As,jr as Sn,js as Is,jt as Os,ju as Cs,jv as Ps,jw as Xt,jx as qt,jy as Ms,jz as zt,jA as Jt,jB as Kt,jC as Wt,jD as js,jE as Gs,jF as Ns,jG as Us,jH as Ds,jI as bt,jJ as Ls,jK as Hs,jL as Bs,jM as Fs,jN as $s,jO as Xs,u as Rt,z as ne,b as At,er as gn,dp as En,l as ue,jP as Tn,jQ as qs,ft as kn,bD as zs,fs as Js,ei as Ks,fz as Ws,jR as Vs,jS as Ys,fu as Zs,m as Qs,fA as er,fB as tr,fC as nr,fj as sr,fe as rr,f as wn,B as Vt,g as xn,T as or,ai as ar,H as ir,jT as cr,b_ as He,hR as ft,jU as Yt,cX as Zt,jV as lr,jW as Qt,jX as ur,h as dr,jY as pr,o as en,bu as ie,jZ as mr,cI as yt}from"./useAppFontEffects-Ci3FEaPf.js";import{o as r,s,r as Ze,b as U,n as G,_ as g,c as X,a as I,l as c,e as _n,d as de,j as Qe,N as fr}from"./vendor-zod-Gea9uBlY.js";import{h as q,a as F,u as et,aV as yr,dW as hr,a1 as ht,dX as Sr,a3 as gr,y as tt,o as $,a8 as Er}from"./index-CvLgnuNI.js";import{c as Tr}from"./vendor-zustand-BAGL70zf.js";import{toast as J}from"./vendor-sonner-DFyL3AvE.js";const kr=128,wr=65536,xr=2e3,_r=/^(>=)?\d+\.\d+\.\d+$/;class K extends Error{code;constructor(t,n){super(n),this.name="HostRequestError",this.code=t}}const vr=/^[a-z][a-z0-9-]*$/,br=r({connected:U(),account:s(),hasClient:U(),settings:Ze(s().regex(vr),s()),redirectUri:s().optional()}),Rr=r({authorizationUrl:s().min(1)}),Ar=r({status:G().int().min(100).max(599),body:s()}),Ir=r({error:s().min(1),message:s().min(1).optional()}),ze=(e,t)=>({ok:!1,code:e,message:t}),Or=async e=>{const t=await e.json().catch(()=>null);if(!e.ok){const o=Ir.safeParse(t);return o.success?ze(Me(o.data.error),o.data.message??o.data.error):ze("HOST_REJECTED","Request failed.")}const n=Ar.safeParse(t);return n.success?{ok:!0,result:n.data}:ze("HOST_REJECTED","Request failed.")},Cr=e=>({connection:{connected:e.connected,account:e.account},settings:e.settings,hasClient:e.hasClient,redirectUri:e.redirectUri??""}),Ge=async e=>{if(!e.ok)return null;const t=br.safeParse(await e.json().catch(()=>null));return t.success?Cr(t.data):null},Pr=async e=>{try{return await Ge(await q(`/api/guests/${e}/oauth/status`))}catch{return null}},$a=async(e,t,n)=>{const o={clientId:t};n&&(o.clientSecret=n);try{return await Ge(await q(`/api/guests/${e}/oauth/client`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}))}catch{return null}},Xa=async(e,t,n)=>{try{return await Ge(await q(`/api/guests/${e}/token`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n?{token:t,username:n}:{token:t})}))}catch{return null}},qa=async(e,t)=>{try{return await Ge(await q(`/api/guests/${e}/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}))}catch{return null}},Mr=async e=>{try{const t=await q(`/api/guests/${e}/oauth/start`,{method:"POST"});if(!t.ok)return null;const n=Rr.safeParse(await t.json().catch(()=>null));return n.success?n.data.authorizationUrl:null}catch{return null}},jr=async e=>{try{return await Ge(await q(`/api/guests/${e}/oauth`,{method:"DELETE"}))}catch{return null}},Gr=3*6e4,Nr=1500,Ur=(e,t)=>t.connected?e.connected?t.account!==e.account:!0:!1,Dr=async(e,t)=>{try{const n=await q(`/api/guests/${e}/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return Or(n)}catch{return ze("HOST_REJECTED","Request failed.")}};let St=0;const Be=Tr(e=>({byId:{},setStatus:(t,n)=>{e(o=>({byId:{...o.byId,[t]:n}}))},refresh:async t=>{const n=St,o=F(),a=await Pr(t);return n!==St||F()!==o?null:(a&&e(d=>({byId:{...d.byId,[t]:a}})),a)},resetForRuntimeSwitch:()=>{St++,e({byId:{}})}})),Lr=r({status:G().int().min(100).max(599),body:s()}),Hr=r({error:s().min(1),message:s().min(1).optional()}),Br=r({status:g(["stopped","starting","ready","failed"])}),Je=(e,t)=>({ok:!1,code:e,message:t}),Fr=async e=>{const t=await e.json().catch(()=>null);if(!e.ok){const o=Hr.safeParse(t);return o.success?Je(Me(o.data.error),o.data.message??o.data.error):Je("HOST_REJECTED","Request failed.")}const n=Lr.safeParse(t);return n.success?{ok:!0,result:n.data}:Je("HOST_REJECTED","Request failed.")},$r=async(e,t)=>{try{const n=await q(`/api/guests/${e}/service/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return Fr(n)}catch{return Je("HOST_REJECTED","Request failed.")}},Xr=async e=>{try{const t=await q(`/api/guests/${e}/service/status`);if(!t.ok)return{ok:!1,code:"NO_SERVICE",message:"No service for this extension."};const n=Br.safeParse(await t.json().catch(()=>null));return n.success?{ok:!0,result:n.data}:{ok:!1,code:"HOST_REJECTED",message:"Service status was empty."}}catch{return{ok:!1,code:"HOST_REJECTED",message:"Could not read service status."}}},qr=r({guest:r({id:s().min(1)}).passthrough()}),za=async(e,t,n)=>{try{const o=await q(`/api/guests/${e}/service/sockets`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,path:n})});return o.ok?qr.safeParse(await o.json().catch(()=>null)).success:!1}catch{return!1}},vn=e=>{const t=et.getState();for(const[n,o]of Object.entries(t.contextPanelByDirectory)){const a=o.tabs.filter(d=>d.mode===e).map(d=>d.id);a.length>0&&t.closeContextPanelTabs(n,a)}},Ja=e=>vn(yr(e)),It=e=>je.test(e)||Ss(e),tn=e=>{try{const t=new URL(e);return t.protocol==="https:"&&t.username===""&&t.password===""}catch{return!1}},bn=e=>{try{const t=new URL(e);return t.protocol==="https:"&&t.username===""&&t.password===""&&t.pathname==="/"&&t.search===""&&t.hash===""&&e===t.origin}catch{return!1}},Rn=e=>!e.startsWith("/")||e.includes("\0")||e.includes("\\")||e.includes("://")?!1:!e.split("/").some(n=>n==="."||n===".."),An=/^[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)*$/,In=g(["panel","dialog"]),zr=r({mode:In,entry:s().trim().refine(Pe).optional()}).refine(e=>e.mode==="dialog"||e.entry===void 0,{path:["entry"]}),Jr=X([U(),In,zr]),Kr=r({id:s().trim().regex(je),name:s().trim().min(1),icon:s().trim().refine(It),entry:s().trim().refine(Pe).optional(),dock:g(Yn).optional(),size:G().int().min(Wn).max(Vn).optional()}),Wr=r({id:s().trim().regex(je),label:s().trim().min(1)}),Vr=r({authorizeUrl:s().trim().refine(tn),tokenUrl:s().trim().refine(tn),apiOrigin:s().trim().refine(bn),scopes:I(s().trim().min(1)).optional(),account:r({path:s().trim().refine(Rn),name:s().trim().regex(An)}).optional()}),Yr=r({apiOrigin:s().trim().refine(bn),account:r({path:s().trim().refine(Rn),name:s().trim().regex(An)}).optional(),scheme:g(["raw","bearer","basic"]).optional(),usernameLabel:s().trim().min(1).max(64).optional()}),Zr=r({provider:g(["linear"])}),Qr=r({name:s().trim().min(1),description:s().trim().min(1),oauth:Vr.optional(),token:Yr.optional(),host:Zr.optional(),settings:I(Wr).optional()}).refine(e=>Zn(e)!==null,{path:["oauth"]}),nn=["linux","darwin","win32"],Ce=s().trim().min(1).max(512),eo=r({linux:I(Ce).max(16).optional(),darwin:I(Ce).max(16).optional(),win32:I(Ce).max(16).optional()}).strict(),to=r({id:s().trim().regex(je).max(64),path:Ce.optional(),candidates:eo.optional()}).strict().refine(e=>!!e.path||!!e.candidates,{message:"socket binding needs path or candidates"}),no=e=>{const t={};if(e.candidates)for(const n of nn){const o=e.candidates[n];o&&o.length>0&&(t[n]=[...o])}else if(e.path)for(const n of nn)t[n]=[e.path];return{id:e.id,candidatesByPlatform:t}},so=X([Ce.transform(e=>({id:e,candidatesByPlatform:{linux:[e],darwin:[e],win32:[e]}})),to.transform(no)]),ro=r({sockets:I(so).max(32).optional(),exec:I(s().trim().min(1).max(128)).max(32).optional()}).strict().transform(e=>{const t={};return e.sockets&&e.sockets.length>0&&(t.sockets=e.sockets),e.exec&&e.exec.length>0&&(t.exec=[...e.exec]),t}),oo=r({entry:s().trim().refine(Pe),runtime:c("host"),permissions:ro.optional(),provides:I(g(Ht)).min(1).max(Ht.length).refine(e=>new Set(e).size===e.length,{message:"provides entries must be unique"}).optional(),surface:c(!0).optional()}),On=(e,t)=>new Set(e.map(t)).size===e.length,ao=r({id:s().trim().regex(je).max(64),label:s().trim().min(1).max(Qn),icon:s().trim().refine(It).optional(),where:g(["message","session"]),mode:g(["open","background"]).optional(),roles:I(g(["user","assistant"])).min(1).max(2).optional(),payload:I(g(["messages"])).max(1).optional()}).refine(e=>e.where==="message"||e.roles===void 0,{path:["roles"]}).refine(e=>e.where==="session"||e.payload===void 0,{path:["payload"]}),io=I(ao).min(1).max(es).refine(e=>On(e,t=>t.id),{message:"action ids must be unique"}),co=r({name:s().trim().regex(ns),description:s().trim().min(1).max(ts).optional()}),lo=I(co).min(1).max(ss).refine(e=>On(e,t=>t.name),{message:"command names must be unique"}),uo=r({match:s().trim().min(1).max(ls).regex(us),name:s().trim().min(1).max(cs).optional(),icon:s().trim().refine(It).optional(),title:s().trim().min(1).max(Bt).optional(),subtitle:s().trim().min(1).max(Bt).optional(),output:g(is).optional(),language:s().trim().min(1).max(as).optional(),columns:I(s().trim().min(1).max(rs)).min(1).max(os).optional()}).refine(e=>e.output==="code"||e.language===void 0,{path:["language"]}).refine(e=>e.output==="table"==(e.columns!==void 0),{path:["columns"]}),po=I(uo).min(1).max(ds),mo=r({panel:Kr,background:r({entry:s().trim().refine(e=>Pe(e)&&e.toLowerCase().endsWith(".html"))}).optional(),attach:Jr.optional(),page:X([c(!0),r({entry:s().trim().refine(Pe),title:s().trim().min(1).max(200).optional()})]).optional(),capabilities:I(g(ys)).max(8).optional(),integration:Qr.optional(),service:oo.optional(),filesystem:I(s().max(ps).refine(ms)).min(1).max(fs).optional(),actions:io.optional(),commands:lo.optional(),tools:po.optional()}),fo=e=>{const t=[];return e.page!==void 0&&t.push("page"),e.attach!==void 0&&e.attach!==!1&&t.push("attach"),e.capabilities&&e.capabilities.length>0&&t.push("capabilities"),e.integration!==void 0&&t.push("integration"),e.service!==void 0&&!e.service.provides?.length&&!e.service.surface&&t.push("service"),e.filesystem!==void 0&&t.push("filesystem"),e.actions!==void 0&&t.push("actions"),e.commands!==void 0&&t.push("commands"),t},yo=r({apiVersion:c(hs[0]),engines:r({openchamber:s().trim().regex(_r)}).strict().optional(),contributes:mo.superRefine((e,t)=>{if((e.panel.dock!==void 0||e.panel.size!==void 0)&&!(e.service?.surface&&Ft(e))){t.addIssue({code:"custom",path:["panel","dock"],message:"panel.dock and panel.size place panel.entry beside service.surface; they need both."});return}if(Ft(e))return;if(e.background){const a=[];e.page!==void 0&&a.push("page"),e.attach!==void 0&&e.attach!==!1&&a.push("attach"),e.actions?.some(d=>d.mode!=="background")&&a.push('actions with mode "open"'),a.length>0&&t.addIssue({code:"custom",path:["panel"],message:`${a.join(", ")} needs panel.entry; background-only actions must declare mode "background".`});return}const o=fo(e);o.length!==0&&t.addIssue({code:"custom",path:["panel"],message:`${o.map(a=>`contributes.${a}`).join(", ")} needs panel.entry or background.entry; an extension without either may only declare tools.`})})}),ho=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,So=s().trim().regex(ho).max(64);r({version:So.optional(),openchamber:yo});X([r({openchamber:_n()}),r({openchamber:r({}).passthrough()})]);const z=s().trim().min(1).max(1024),Fe=g(["loading","ready","error"]),sn=r({directory:z,name:s(),branch:s(),status:g(["ready","pending","invalid","missing"])}),rn=de("kind",[r({kind:c("projects")}).strict(),r({kind:c("worktrees"),projectId:z}).strict(),r({kind:c("sessions"),projectId:z}).strict()]),Cn=de("kind",[r({kind:c("projects"),state:Fe,projects:I(r({id:z,name:s(),directory:z}))}),r({kind:c("worktrees"),projectId:z,state:Fe,worktrees:I(sn)}),r({kind:c("sessions"),projectId:z,state:Fe,coverage:I(r({directory:z,state:Fe})),sessions:I(r({id:z,title:s(),projectId:z,directory:z,parentId:z.nullable(),createdAt:G(),updatedAt:G(),archivedAt:G().nullable(),worktree:sn.nullable(),activity:g(["unknown","idle","running","retrying","waiting-permission","waiting-question"]),outcome:g(["completed","failed"]).nullable(),items:I(r({id:z,data:Qe().optional()}))}))})]),go=X([U(),r({kind:c("existing"),directory:z}).strict(),r({kind:c("new"),name:s().trim().min(1).max(200).optional(),baseBranch:s().trim().min(1).max(200).optional()}).strict()]),Ke=s().min(1).max(kr),Eo=de("op",[r({op:c("get"),key:Ke}).strict(),r({op:c("delete"),key:Ke}).strict(),r({op:c("set"),key:Ke,value:Qe().refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=wr)}).strict(),r({op:c("keys")}).strict()]),Pn=X([r({storage:c(!0),op:c("get"),found:c(!1)}),r({storage:c(!0),op:c("get"),found:c(!0),value:Qe()}),r({storage:c(!0),op:g(["set","delete"])}),r({storage:c(!0),op:c("keys"),keys:I(Ke).max(xr)})]),T={channel:c(V),v:c(W)},To=r({background:s().min(1),elevated:s().min(1),foreground:s().min(1),muted:s().min(1),subtle:s().min(1),border:s().min(1),hover:s().min(1),selection:s().min(1),focus:s().min(1),primary:s().min(1),mutedSurface:s().min(1),elevatedForeground:s().min(1),active:s().min(1),selectionForeground:s().min(1),primaryForeground:s().min(1),primaryText:s().min(1),successText:s().min(1),warningText:s().min(1),errorText:s().min(1),infoText:s().min(1),success:s().min(1),warning:s().min(1),error:s().min(1),info:s().min(1),font:s().min(1),mono:s().min(1),radius:s().min(1)}),Mn=r({id:s().min(1),title:s().min(1),busy:U().optional().default(!1),model:s().min(1).max(un).optional(),agent:s().min(1).max(ln).optional()}).nullable(),jn=r({connected:U(),account:s().max(gs)}),Gn=Ze(s().regex(Ts),s().max(Es)),ko=r({status:G().int().min(100).max(599),body:s().max(ks)}),on=r({directory:s(),name:s(),branch:s(),status:g(["ready","pending","invalid","missing"])}),wo=X([r({sessionId:s().min(1),sent:g(dn),directory:s().optional(),worktree:on.optional(),linked:U().optional()}),r({sessionId:_n(),sent:c("skipped"),directory:s(),worktree:on,failure:g(["bootstrap-failed","session-create-failed"])})]),xo=r({sent:g(dn)}),_o=r({status:g(ws)}),vo=r({content:s().max(vt)}),bo=r({written:c(!0)}),Ro=r({entries:I(r({name:s().min(1),kind:g(pn)})).max(mn)}),Ao=r({kind:g(fn),size:G().int().min(0),mtime:G().int().min(0)}),Io=r({text:s().max(yn)}),Oo=X([Pn,Cn,wo,ko,xo,_o,vo,bo,Ro,Ao,Io]),Oe=r({providerId:s().trim().regex(As),id:s().trim().min(1).max(Rs),title:s().trim().min(1).max(bs),url:s().trim().min(1).max(hn),text:s().trim().min(1).max(vs).optional(),kind:g(["issue","pull"]).optional(),author:s().trim().min(1).max(_s).optional(),branches:r({head:s().trim().min(1).max($t),base:s().trim().min(1).max($t)}).optional(),data:Qe().refine(e=>JSON.stringify(e).length<=xs).optional()}),Nn=g(["user","assistant"]),Un=r({kind:c("message"),action:s().trim().min(1).max(64),sessionId:s().min(1),sessionTitle:s(),directory:s().nullable(),messageId:s().min(1),role:Nn,text:s().max(Sn)}),Dn=r({kind:c("session"),action:s().trim().min(1).max(64),sessionId:s().min(1),sessionTitle:s(),directory:s().nullable(),messages:I(r({id:s().min(1),role:Nn,text:s().max(Sn),createdAt:G().int().min(0)})).optional(),truncated:U().optional()}).refine(e=>JSON.stringify(e).length<=Is),Ln=X([Un,Dn,Oe]).nullable(),Co=r({theme:r({mode:g(["light","dark"]),tokens:To}),locale:s().min(1),directory:s().nullable(),session:Mn,surface:g(["panel","dialog","page","background"]),connection:jn,settings:Gn,item:Ln}),Po=r({...T,type:c("result"),id:s().min(1),ok:U(),error:s().min(1).optional(),code:s().min(1).optional(),payload:Oo.optional()}).transform((e,t)=>e.ok?e.payload?{channel:e.channel,v:e.v,type:"result",id:e.id,ok:!0,payload:e.payload}:{channel:e.channel,v:e.v,type:"result",id:e.id,ok:!0}:e.error?{channel:e.channel,v:e.v,type:"result",id:e.id,ok:!1,error:e.error,code:Me(e.code)}:(t.addIssue({code:"custom",message:"Failed result needs an error string."}),fr));X([r({...T,type:c("workspace"),payload:r({subscriptionId:s().min(1).max(128),snapshot:Cn})}),r({...T,type:c("ready"),payload:Co}),r({...T,type:c("directory"),payload:r({directory:s().nullable()})}),r({...T,type:c("session"),payload:r({session:Mn})}),r({...T,type:c("connection"),payload:r({connection:jn})}),r({...T,type:c("settings"),payload:r({settings:Gn})}),r({...T,type:c("session-lifecycle"),payload:r({sessionId:s().min(1),phase:g(Os)})}),r({...T,type:c("item"),payload:r({item:Ln})}),r({...T,type:c("resolve"),id:s().min(1),payload:r({command:s().min(1),args:s()})}),Po,r({...T,type:c("action"),id:s().min(1),payload:X([Un,Dn])})]);const $e=s().min(1).max(Cs).refine(Ps),Mo=de("type",[r({...T,type:c("action-result"),id:s().min(1),payload:de("ok",[r({ok:c(!0)}),r({ok:c(!1),error:s().trim().min(1).max(Xt)})])}),r({...T,type:c("workspace-read"),id:s().min(1),payload:rn}),r({...T,type:c("workspace-subscribe"),id:s().min(1),payload:r({subscriptionId:s().min(1).max(128),query:rn})}),r({...T,type:c("workspace-unsubscribe"),id:s().min(1),payload:r({subscriptionId:s().min(1).max(128)})}),r({...T,type:c("storage"),id:s().min(1),payload:Eo}),r({...T,type:c("open-session"),id:s().min(1),payload:r({sessionId:s().min(1).max(1024)})}),r({...T,type:c("hello")}),r({...T,type:c("toast"),id:s().min(1),payload:r({kind:g(["info","success","error"]),message:s().trim().min(1).max(Ms),copy:X([U(),r({text:s().min(1).max(qt)})]).optional(),dismiss:U().optional(),persistent:U().optional()})}),r({...T,type:c("open-url"),id:s().min(1),payload:r({url:s().trim().min(1).max(hn)})}),r({...T,type:c("open-surface"),id:s().min(1),payload:r({surfaceId:s().trim().min(1).max(64)})}),r({...T,type:c("clipboard-write"),id:s().min(1),payload:r({text:s().min(1).max(qt)})}),r({...T,type:c("compose"),id:s().min(1),payload:r({text:s().trim().min(1).max(zt),mode:g(["replace","append"]).optional()})}),r({...T,type:c("attach"),id:s().min(1),payload:Oe}),r({...T,type:c("start-session"),id:s().min(1),payload:Oe.extend({worktree:go.optional(),projectId:s().trim().min(1).max(1024).optional(),navigation:g(["preserve","open"]).optional()})}),r({...T,type:c("prompt"),id:s().min(1),payload:r({text:s().trim().min(1).max(zt),send:U().optional()})}),r({...T,type:c("session-link"),id:s().min(1),payload:Oe}),r({...T,type:c("close"),id:s().min(1)}),r({...T,type:c("oauth-start"),id:s().min(1)}),r({...T,type:c("oauth-disconnect"),id:s().min(1)}),r({...T,type:c("request"),id:s().min(1),payload:r({method:g(["GET","POST","PUT","PATCH","DELETE"]),path:s().trim().min(1).max(Kt).refine(Wt),query:Ze(s().min(1).max(128),s().max(2e3)).optional(),body:s().max(Jt).optional()})}),r({...T,type:c("service-request"),id:s().min(1),payload:r({method:g(["GET","POST","PUT","PATCH","DELETE"]),path:s().trim().min(1).max(Kt).refine(Wt),query:Ze(s().min(1).max(128),s().max(2e3)).optional(),body:s().max(Jt).optional()})}),r({...T,type:c("service-status"),id:s().min(1)}),r({...T,type:c("file-read"),id:s().min(1),payload:r({path:$e})}),r({...T,type:c("file-write"),id:s().min(1),payload:r({path:$e,content:s().max(vt)})}),r({...T,type:c("file-list"),id:s().min(1),payload:r({path:$e})}),r({...T,type:c("file-stat"),id:s().min(1),payload:r({path:$e})}),r({...T,type:c("generate"),id:s().min(1),payload:r({prompt:s().trim().min(1).max(Ns),system:s().trim().min(1).max(Gs).optional(),maxOutputTokens:G().int().min(1).max(js).optional()})}),r({...T,type:c("badge"),id:s().min(1),payload:r({count:G().int().min(0).max(Us).nullable()})}),r({...T,type:c("resolve-result"),id:s().min(1),payload:X([r({item:Oe.nullable()}),r({error:s().trim().min(1).max(Xt)})])})]);X([r({ok:c(!0),data:r({}).passthrough()}),r({ok:c(!1),error:s().min(1).max(2e3)})]);g(Ds);const gt=r({alt:U(),ctrl:U(),meta:U(),shift:U()}),xe=G().finite(),jo=de("type",[r({type:c("pointer"),action:g(["down","up","move"]),x:xe,y:xe,button:G().int().min(-1).max(4),buttons:G().int().min(0).max(31),modifiers:gt}),r({type:c("wheel"),x:xe,y:xe,deltaX:xe,deltaY:xe,modifiers:gt}),r({type:c("key"),action:g(["down","up"]),key:s().min(1).max(64),code:s().max(64),modifiers:gt}),r({type:c("text"),text:s().min(1).max(bt)})]),le=G().int().min(1).max(Ls);de("type",[r({type:c("ack"),seq:G().int().min(0)}),r({type:c("input"),events:I(jo).min(1).max(Hs)}),r({type:c("release")}),r({type:c("resize"),width:le,height:le}),r({type:c("clipboard-read"),id:s().min(1).max(64)})]);const Go=g(Bs),Ka=de("type",[r({type:c("hello"),viewerId:s().min(1)}),r({type:c("frame"),seq:G().int().min(0),width:le,height:le,mime:g($s),bytes:G().int().min(1),title:s().max(Fs).optional(),agentActive:U()}),r({type:c("control"),controller:Go,mine:U()}),r({type:c("resized"),width:le,height:le}),r({type:c("clipboard"),id:s().min(1).max(64),text:s().max(bt)}),r({type:c("error"),code:s().min(1).max(64),message:s().min(1).max(500)}),r({type:c("ended"),reason:g(["service-stopped","extension-unavailable","host-shutdown"])})]);r({width:le,height:le});r({text:s().max(bt)});const No=e=>({channel:V,v:W,type:"ready",payload:e}),Uo=e=>({channel:V,v:W,type:"directory",payload:{directory:e}}),Do=e=>({channel:V,v:W,type:"session",payload:{session:e}}),Lo=e=>({channel:V,v:W,type:"connection",payload:{connection:e}}),Ho=e=>({channel:V,v:W,type:"settings",payload:{settings:e}}),Bo=e=>({channel:V,v:W,type:"item",payload:{item:e}}),Fo=(e,t,n)=>({channel:V,v:W,type:"resolve",id:e,payload:{command:t,args:n}}),$o=e=>({channel:V,v:W,type:"session-lifecycle",payload:e}),Xo=e=>e?.type==="busy"||e?.type==="retry"?"started":e?.type==="idle"?"completed":e?.type?"failure":null,qo=e=>{const t=e?.providerID?.trim(),n=e?.id?.trim();if(!(!t||!n))return`${t}/${n}`},zo=e=>{if(!e?.id)return null;const t=e.title?.trim(),n={id:e.id,title:t||e.id,busy:!!e.busy},o=e.model?.trim().slice(0,un);o&&(n.model=o);const a=e.agent?.trim().slice(0,ln);return a&&(n.agent=a),n},M=(e,t)=>t?{channel:V,v:W,type:"result",id:e,ok:!0,payload:t}:{channel:V,v:W,type:"result",id:e,ok:!0},N=(e,t,n="HOST_REJECTED")=>({channel:V,v:W,type:"result",id:e,ok:!1,error:t,code:n}),Xe=(e,t)=>t.ok?M(e,t.result):N(e,t.message,t.code),qe=e=>{try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},Jo=async(e,t)=>{try{switch(e.type){case"workspace-read":return M(e.id,t.workspaceRead(e.payload));case"workspace-subscribe":return t.workspaceSubscribe(e.payload),M(e.id);case"workspace-unsubscribe":return t.workspaceUnsubscribe(e.payload.subscriptionId),M(e.id);case"storage":return M(e.id,await t.storage(e.payload));case"open-session":return t.openSession(e.payload.sessionId),M(e.id);case"hello":case"action-result":return null;case"toast":return t.toast(e.payload),M(e.id);case"open-url":return qe(e.payload.url)?await t.openUrl(e.payload.url)?M(e.id):N(e.id,"Could not open URL."):N(e.id,"URL must be http or https.");case"open-surface":return hr(e.payload.surfaceId)?(t.openSurface(e.payload.surfaceId),M(e.id)):N(e.id,"Unknown surface.");case"clipboard-write":return await t.writeClipboard(e.payload.text)?M(e.id):N(e.id,"Could not write clipboard.");case"compose":return t.compose(e.payload.text,e.payload.mode??"append"),M(e.id);case"attach":return qe(e.payload.url)?(t.attach(e.payload),M(e.id)):N(e.id,"URL must be http or https.");case"start-session":{if(!qe(e.payload.url))return N(e.id,"URL must be http or https.");const n=await t.startSession(e.payload);return n?"sessionId"in n?M(e.id,n):N(e.id,n.message,n.code):N(e.id,"Could not start that session.")}case"prompt":{const n=await t.prompt(e.payload);return n.ok?M(e.id,n.result):N(e.id,n.message,n.code)}case"session-link":{if(!qe(e.payload.url))return N(e.id,"URL must be http or https.");const n=await t.sessionLink(e.payload);return n.ok?M(e.id):N(e.id,n.message,n.code)}case"close":return t.close(),M(e.id);case"oauth-start":return await t.oauthStart()?M(e.id):N(e.id,"Could not start OAuth.");case"oauth-disconnect":return await t.oauthDisconnect()?M(e.id):N(e.id,"Could not disconnect.");case"request":{const n=await t.request(e.payload);return n.ok?M(e.id,n.result):N(e.id,n.message,n.code)}case"service-request":{const n=await t.serviceRequest(e.payload);return n.ok?M(e.id,n.result):N(e.id,n.message,n.code)}case"service-status":{const n=await t.serviceStatus();return n.ok?M(e.id,n.result):N(e.id,n.message,n.code)}case"file-read":return Xe(e.id,await t.file({op:"read",path:e.payload.path}));case"file-write":return Xe(e.id,await t.file({op:"write",path:e.payload.path,content:e.payload.content}));case"file-list":return Xe(e.id,await t.file({op:"list",path:e.payload.path}));case"file-stat":return Xe(e.id,await t.file({op:"stat",path:e.payload.path}));case"generate":{const n=await t.generate(e.payload);return n.ok?M(e.id,n.result):N(e.id,n.message,n.code)}case"badge":return t.setBadge(e.payload.count),M(e.id);case"resolve-result":return t.resolveResult(e.id,e.payload),null}}catch(n){return e.type==="hello"?null:N(e.id,n instanceof K?n.message:"Extension operation failed.",n instanceof K?n.code:"HOST_REJECTED")}},Ko=X([r({content:s().max(vt)}),r({written:c(!0)}),r({entries:I(r({name:s().min(1),kind:g(pn)})).max(mn)}),r({kind:g(fn),size:G().int().min(0),mtime:G().int().min(0)})]),Wo=r({ok:c(!0),result:Ko}),Vo=r({error:s().min(1),message:s().min(1).optional()}),We=(e,t)=>({ok:!1,code:e,message:t}),Yo=async e=>{const t=await e.json().catch(()=>null);if(!e.ok){const o=Vo.safeParse(t);return o.success?We(Me(o.data.error),o.data.message??o.data.error):We("HOST_REJECTED","File operation failed.")}const n=Wo.safeParse(t);return n.success?{ok:!0,result:n.data.result}:We("HOST_REJECTED","File operation failed.")},Zo=async(e,t,n)=>{const o=new Headers({"Content-Type":"application/json"});n&&o.set("x-opencode-directory",n);try{const a=await q(`/api/guests/${e}/files`,{method:"POST",headers:o,body:JSON.stringify(t)});return Yo(a)}catch{return We("HOST_REJECTED","File operation failed.")}},Qo=r({ok:c(!0),result:r({text:s().max(yn)})}),ea=r({error:s().min(1),message:s().min(1).optional()}),Ve=(e,t)=>({ok:!1,code:e,message:t}),xt="Text generation failed.",ta=async e=>{const t=await e.json().catch(()=>null);if(!e.ok){const o=ea.safeParse(t);return o.success?Ve(Me(o.data.error),o.data.message??o.data.error):Ve("HOST_REJECTED",xt)}const n=Qo.safeParse(t);return n.success?{ok:!0,result:n.data.result}:Ve("HOST_REJECTED",xt)},na=async(e,t,n)=>{const o=new Headers({"Content-Type":"application/json"});n&&o.set("x-opencode-directory",n);try{const a=await q(`/api/guests/${e}/generate`,{method:"POST",headers:o,body:JSON.stringify(t)});return ta(a)}catch{return Ve("HOST_REJECTED",xt)}},Et="https://extension.invalid",sa=500,ra=40*1024*1024,an=64*1024*1024,Tt=async e=>{const t=new Uint8Array(await e.arrayBuffer());let n="";for(let o=0;o<t.length;o+=8192)n+=String.fromCharCode(...t.subarray(o,o+8192));return`data:${e.type||"application/octet-stream"};base64,${btoa(n)}`},oa=e=>e.replace(/\\(?:([0-9a-f]{1,6})\s?|([\s\S]))/gi,(t,n,o)=>{if(n){const a=Number.parseInt(n,16);return a>0&&a<=1114111?String.fromCodePoint(a):"�"}return o===`
2
+ `||o==="\r"?"":o??""}),aa=/\/\*[\s\S]*?\*\/|"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\burl\(\s*(?:"((?:\\[\s\S]|[^"\\])*)"|'((?:\\[\s\S]|[^'\\])*)'|((?:\\[\s\S]|[^)\\])*?))\s*\)|@import\s+(?:"((?:\\[\s\S]|[^"\\])*)"|'((?:\\[\s\S]|[^'\\])*)')/gi,ia=async(e,t,n)=>{const o=`/api/guests/${e}/`,a=new URL(t,`${Et}${o}`),d=new Map;let b=0,x=0;const _=async i=>{if(i.origin!==Et||!i.pathname.startsWith(o))throw new Error("Extension resource is outside its package");const f=await n(`${i.pathname}${i.search}`);if(!f.ok)throw new Error(`Could not load extension resource (HTTP ${f.status})`);const v=f.body?.getReader();if(!v)throw new Error("Extension resource has no response body");const m=[];try{for(;;){const{done:l,value:u}=await v.read();if(l)break;if(b+=u.byteLength,b>ra)throw new Error("Extension document exceeds the resource size limit");m.push(new Uint8Array(u))}}catch(l){throw await v.cancel().catch(()=>{}),l}finally{v.releaseLock()}return new Blob(m,{type:f.headers.get("content-type")?.split(";")[0]||"application/octet-stream"})},j=async(i,f,v)=>{const m=i.trim();if(!m||m.startsWith("#"))return i;const l=new URL(m,f);if(l.origin!==Et)return l.href;const u=l.hash;l.hash="";const k=l.href;if(v.includes(k))throw new Error("Circular extension resource reference");let E=d.get(k);if(!E){if(d.size>=sa)throw new Error("Extension document has too many resources");const A=[...v,k];E=_(l).then(async D=>{const Z=D.type.split(";")[0];return Z==="text/css"||l.pathname.endsWith(".css")?Tt(new Blob([await h(await D.text(),l,A)],{type:"text/css"})):Tt(Z==="text/html"?new Blob([await C(await D.text(),l,A)],{type:"text/html"}):D)}),d.set(k,E)}const P=`${await E}${u}`;if(x+=P.length,x>an)throw new Error("Extension document exceeds the embedded size limit");return P},h=async(i,f,v)=>{let m="",l=0;for(const u of i.matchAll(aa)){const k=u[1]??u[2]??u[3]??u[4]??u[5];if(k===void 0)continue;m+=i.slice(l,u.index);const E=await j(oa(k.trim()),f,v),P=JSON.stringify(E);m+=u[4]!==void 0||u[5]!==void 0?`@import url(${P})`:`url(${P})`,l=u.index+u[0].length}return m+i.slice(l)},R=async(i,f,v)=>{const m=[];let l=i;for(;l.trim();){l=l.replace(/^[\s,]+/,"");const u=/^\S+/.exec(l);if(!u)break;const k=u[0];l=l.slice(k.length);let E="";if(!k.endsWith(",")){const A=l.indexOf(",");E=(A<0?l:l.slice(0,A)).trim(),l=A<0?"":l.slice(A+1)}const P=await j(k.replace(/,+$/,""),f,v);m.push(E?`${P} ${E}`:P)}return m.join(", ")},C=async(i,f,v)=>{const m=new DOMParser().parseFromString(i,"text/html"),l=m.querySelector("base[href]")?.getAttribute("href"),u=m.querySelector("base[target]")?.getAttribute("target"),k=l?new URL(l,f):f;for(const A of m.querySelectorAll("base"))A.remove();const E=m.createElement("base");E.href=k.href,u&&(E.target=u),m.head.prepend(E);for(const A of m.querySelectorAll("script[src], link[href], img[src], source[src], video[src], audio[src], iframe[src], embed[src], object[data], image[href], image[xlink\\:href], use[href], use[xlink\\:href]"))for(const D of["src","href","data","xlink:href"]){const Z=A.getAttribute(D);Z!==null&&A.setAttribute(D,await j(Z,k,v))}for(const A of m.querySelectorAll("[poster]"))A.setAttribute("poster",await j(A.getAttribute("poster")??"",k,v));for(const A of m.querySelectorAll("img[srcset], source[srcset]"))A.setAttribute("srcset",await R(A.getAttribute("srcset")??"",k,v));for(const A of m.querySelectorAll("style"))A.textContent=await h(A.textContent??"",k,v);for(const A of m.querySelectorAll("[style]"))A.setAttribute("style",await h(A.getAttribute("style")??"",k,v));const P=`<!doctype html>
3
+ ${m.documentElement.outerHTML}`;if(P.length>an)throw new Error("Extension document exceeds the size limit");return P},S=await _(a);if(S.type.split(";")[0]!=="text/html")throw new Error("Extension entry is not HTML");return C(await S.text(),a,[a.href])},ca=async(e,t,n)=>{const o=F(),a=ht();if(a){const x=await ia(e,t,_=>{if(F()!==o||ht()!==a||n?.aborted)throw new DOMException("Extension frame owner changed","AbortError");return q(_,{signal:n})});if(F()!==o||ht()!==a||n?.aborted)throw new DOMException("Extension frame owner changed","AbortError");return{kind:"document",html:x}}const{token:d,expiresAt:b}=await Sr(e);if(o!==F())throw new Error("Runtime changed while authorizing extension frame");return{kind:"url",url:gr().assetWithUrlToken(`/api/guests/${e}/${t}`,d,{oc_ui:"issue-page"}),expiresAt:b}},la=e=>{const t=Kn.c(31),{guestId:n,entry:o,instanceKey:a,enabled:d}=e,[b,x]=y.useState(null),[_,j]=y.useState(0),h=y.useRef(!1),[R,C]=y.useState(F);let S;t[0]!==d||t[1]!==o||t[2]!==n||t[3]!==a||t[4]!==R?(S=JSON.stringify([R,n,o,a,d]),t[0]=d,t[1]=o,t[2]=n,t[3]=a,t[4]=R,t[5]=S):S=t[5];const i=S;let f,v;t[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>tt(se=>{C(se.runtimeKey)}),v=[],t[6]=f,t[7]=v):(f=t[6],v=t[7]),y.useEffect(f,v);let m;t[8]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{h.current=!1},t[8]=m):m=t[8];let l;t[9]!==i?(l=[i],t[9]=i,t[10]=l):l=t[10],y.useEffect(m,l);let u;t[11]!==d||t[12]!==o||t[13]!==n||t[14]!==i?(u=()=>{if(x({key:i,status:"loading"}),!o||!d)return;let se=!1;const me=new AbortController;return ca(n,o,me.signal).then(Re=>{se||x({key:i,status:"ready",source:Re})}).catch(()=>{se||x({key:i,status:"error"})}),()=>{se=!0,me.abort()}},t[11]=d,t[12]=o,t[13]=n,t[14]=i,t[15]=u):u=t[15];let k;t[16]!==d||t[17]!==o||t[18]!==n||t[19]!==i||t[20]!==_?(k=[d,o,n,i,_],t[16]=d,t[17]=o,t[18]=n,t[19]=i,t[20]=_,t[21]=k):k=t[21],y.useEffect(u,k);const E=b?.key===i&&b.status==="ready"?b.source:null;let P;t[22]!==E||t[23]!==i?(P=()=>E?E.kind==="document"||Date.now()<E.expiresAt?!1:(h.current?x({key:i,status:"error"}):(x({key:i,status:"loading"}),h.current=!0,j(ua)),!0):!0,t[22]=E,t[23]=i,t[24]=P):P=t[24];const A=P;let D;t[25]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{h.current=!1},t[25]=D):D=t[25];const Z=D,ge=E?.kind==="url"?E.url:"",ve=E?.kind==="document"?E.html:void 0,be=b?.key===i?b.status:"loading";let pe;return t[26]!==A||t[27]!==ge||t[28]!==ve||t[29]!==be?(pe={src:ge,srcDoc:ve,status:be,recoverExpiredNavigation:A,acknowledgeHandshake:Z},t[26]=A,t[27]=ge,t[28]=ve,t[29]=be,t[30]=pe):pe=t[30],pe};function ua(e){return e+1}const Hn="/api/linear/issues/get",da=(e,t)=>e==="host"&&t.method==="GET"&&t.path===Hn,pa=async(e,t)=>{if(da(e,t))try{const n=await q(Hn,{query:t.query});return{status:n.status,body:await n.text()}}catch{return null}},ma=e=>{const t=At.getState();if(!t.hasServerSnapshot)throw new K("HOST_UNAVAILABLE","The project registry has not loaded.");const n=t.projects.find(o=>o.id===e);if(!n)throw new K("NOT_FOUND","Project is not registered.");return n},Ye=e=>ne.getState().availableWorktreesByProject.get($(e)??e)??[],Bn=e=>({directory:e.path,name:e.name??e.label,branch:e.branch,status:e.worktreeStatus==="not-a-repo"?"invalid":e.worktreeStatus??"ready"}),fa=e=>e.includes("error")?"error":e.includes("loading")?"loading":"ready",ya=(e,t,n,o)=>{const a=e.directory,d=Tn(a),b=En.getState(),x=b.statusById.get(e.id),_=(x&&$(x.directory)===$(a)?x.status:void 0)??d?.session_status[e.id],j=b.observedById.get(e.id),h=j&&$(j.directory)===$(a)?j:void 0,R=ne.getState().worktreeMetadata.get(e.id),C=o.get($(a)??a)??(R&&$(R.path)===$(a)?Bn(R):null),S=ue.getState().isConnected;let i="unknown";return S&&(_?.type==="busy"?i="running":_?.type==="retry"?i="retrying":(_?.type==="idle"||d?.sessionStatusReady||h)&&(i="idle"),d?.permission[e.id]?.length?i="waiting-permission":d?.form[e.id]?.length&&(i="waiting-question")),{id:e.id,title:e.title||e.id,projectId:t,directory:a,parentId:e.parentID??null,createdAt:e.time.created,updatedAt:e.time.updated,archivedAt:e.time.archived||null,worktree:C,activity:i,outcome:i==="idle"?h?.outcome??null:null,items:qs(e).flatMap(f=>{if(f.kind!=="guest"||f.providerId!==n)return[];const v={id:f.identifier};return f.data!==void 0&&(v.data=f.data),[v]})}},_t=(e,t)=>{const n=At.getState();if(e.kind==="projects")return{kind:"projects",state:n.serverSnapshotFailed?"error":n.hasServerSnapshot?"ready":"loading",projects:n.hasServerSnapshot?n.projects.map(i=>({id:i.id,name:i.label||i.path.split("/").pop()||i.path,directory:i.path})):[]};const o=n.projects.find(i=>i.id===e.projectId),a=ne.getState(),d=o?$(o.path)??o.path:"",b=o?a.worktreeDiscoveryByProject.get(d)??"loading":n.hasServerSnapshot?"error":"loading",x=o?Ye(o.path).map(Bn):[];if(e.kind==="worktrees")return{...e,state:b,worktrees:x};const _=new Set(o?[d,...x.map(i=>$(i.directory)??i.directory)]:[]),j=gn(),h=Rt.getState(),R=[..._].map(i=>{const v=j.getBootstrapState(i)==="failed"||h.status==="error"?"error":h.status==="ready"?"ready":"loading";return{directory:i,state:v}}),C=new Map;for(const i of _)for(const f of h.structure.activeIdsByDirectory.get(i)??[]){const v=h.entityById.get(f);v&&C.set(f,v)}for(const i of h.archivedSessions)_.has($(i.directory)??i.directory)&&C.set(i.id,i);for(const i of _)for(const f of Tn(i)?.session??[])_.has($(f.directory)??f.directory)&&(C.has(f.id)||C.set(f.id,f));const S=new Map(x.map(i=>[$(i.directory)??i.directory,i]));return{...e,state:fa([b,...R.map(i=>i.state)]),coverage:R,sessions:[...C.values()].map(i=>ya(i,e.projectId,t,S))}},kt=new Map,ha=(e,t,n)=>{const o=JSON.stringify([F(),t,e]);let a=kt.get(o);if(!a){const b=new Set,x={listeners:b,snapshot:_t(e,t),dispose:()=>{}};let _=!1,j=!1,h=JSON.stringify(x.snapshot);const R=()=>{_||j||(_=!0,queueMicrotask(()=>{if(_=!1,j)return;const S=_t(e,t),i=JSON.stringify(S);if(i!==h){h=i,x.snapshot=S;for(const f of b)f(S)}}))},C=[At.subscribe((S,i)=>{(S.projects!==i.projects||S.hasServerSnapshot!==i.hasServerSnapshot||S.serverSnapshotFailed!==i.serverSnapshotFailed)&&R()})];if(e.kind!=="projects"&&C.push(ne.subscribe((S,i)=>{(S.availableWorktreesByProject!==i.availableWorktreesByProject||S.worktreeDiscoveryByProject!==i.worktreeDiscoveryByProject||S.worktreeMetadata!==i.worktreeMetadata)&&R()})),e.kind==="sessions"){const S=gn();C.push(Rt.subscribe((i,f)=>{(i.activeSessions!==f.activeSessions||i.archivedSessions!==f.archivedSessions||i.status!==f.status)&&R()}),En.subscribe(R),ue.subscribe((i,f)=>{i.isConnected!==f.isConnected&&R()}),S.subscribeBootstrap(R),S.subscribeAllSelected(i=>i.session,R),S.subscribeAllSelected(i=>i.permission,R),S.subscribeAllSelected(i=>i.form,R),S.subscribeAllSelected(i=>i.sessionStatusReady,R))}x.dispose=()=>{j=!0;for(const S of C)S();kt.delete(o)},C.push(tt(x.dispose)),kt.set(o,x),a=x}a.listeners.add(n),n(a.snapshot);const d=a;return()=>{d.listeners.delete(n),d.listeners.size===0&&d.dispose()}},Sa=e=>{const t=Xs().get(e)??Rt.getState().entityById.get(e);if(!t?.directory)throw new K("NO_SESSION","Session is not available.");ne.getState().setCurrentSession(e,t.directory),et.getState().closeMainSurfaces()},ga=e=>`${e.id} ${e.title}`.trim(),Ea=(e,t)=>{const n=e.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase();return`${t==="pull"?"pr":"issue"}-${n||"guest"}`},Fn=(e,t,n)=>{const o=t?.trim()??"";if(!o)return{ok:!1,reason:"no-directory"};const a=Ys(e),d=a.kind==="pull"?"pull":"issue",b={ok:!0,directory:o,title:ga(a),worktree:!!a.worktree,branchName:Ea(a.id,d),kind:d==="pull"?"pr":"standard",linked:Zs({providerId:a.providerId,identifier:a.id,title:a.title,url:a.url,thread:d,author:a.author,head:a.branches?.head,base:a.branches?.base,data:a.data,linkedAt:n})};return a.text&&(b.text=a.text),b},Ta=async(e,t)=>{const n=e.worktree?await t.createWorktree(e.directory,e.branchName,e.kind):await t.createSession(e.title,e.directory);if(!n)return{ok:!1,reason:e.worktree?"worktree-failed":"create-failed"};if(t.initializeSession(n.id),t.closeSurfaces(),await t.setLinkedIssue(n.id,n.directory,e.linked),!e.text)return{ok:!0,sessionId:n.id,sent:"skipped"};const o=await t.sendFirstMessage(n.id,n.directory,e.text);return{ok:!0,sessionId:n.id,sent:o}},ka=()=>{const e=ue.getState();if(e.settingsDefaultAgent)return e.settingsDefaultAgent;const t=e.agents.filter(n=>!n.hidden);return e.currentAgentName||t.find(n=>n.mode==="primary"||!n.mode)?.name||t[0]?.name},wa=()=>{const e=sr(ue.getState().settingsDefaultModel);return!e||!ue.getState().getModelMetadata(e.providerId,e.modelId)?null:{providerID:e.providerId,modelID:e.modelId}},xa=(e,t)=>{const n=ue.getState(),o=n.settingsDefaultVariant,a=n.currentProviderId===e&&n.currentModelId===t?n.currentVariant:void 0,b=n.providers.find(_=>_.id===e)?.models.find(_=>_.id===t),x=rr(b);if(x.length===0)return o||a||void 0;if(o&&x.includes(o))return o;if(a&&x.includes(a))return a},$n=()=>{const e=ue.getState(),t=Qs.getState().lastUsedProvider,n=wa(),o=n?.providerID||e.currentProviderId||t?.providerID,a=n?.modelID||e.currentModelId||t?.modelID,d=ka()||e.currentAgentName||void 0;return!o||!a?null:{providerID:o,modelID:a,agentName:d,variant:xa(o,a)}},Xn=async(e,t,n,o=$n())=>{if(!o)return"no-model";try{return await ne.getState().sendMessage(n,o.providerID,o.modelID,o.agentName,void 0,void 0,void 0,o.variant,void 0,{sessionId:e,directory:t}),"sent"}catch{return"failed"}},_a=(e,t,n,o)=>{const a=n?.trim()??"";if(!a)return{ok:!1,code:"HOST_REJECTED",message:"Open a project first.",toastKey:"contextPanel.plugin.startSession.noProject"};const d=t?.trim()??"";if(!d)return{ok:!1,code:"NO_SESSION",message:"No open session.",toastKey:"contextPanel.plugin.sessionLink.noSession"};const b=Fn(e,a,o);return b.ok?{ok:!0,sessionId:d,directory:a,linked:b.linked}:{ok:!1,code:"HOST_REJECTED",message:"Open a project first.",toastKey:"contextPanel.plugin.startSession.noProject"}},va=async e=>{const t=_a(e.request,e.sessionId,e.directory,Date.now());if(!t.ok)return J.error(e.t(t.toastKey)),{ok:!1,code:t.code,message:t.message};try{return await kn(t.sessionId,t.directory,t.linked,!0),J.success(e.t("contextPanel.plugin.sessionLink.linked")),{ok:!0}}catch{return J.error(e.t("contextPanel.plugin.sessionLink.failed")),{ok:!1,code:"HOST_REJECTED",message:"Could not link that item."}}},ba=e=>{const t=Vs(e.request),n=e.sessionId?.trim()??"";if(!n)return{ok:!1,code:"NO_SESSION",message:"No open session.",toastKey:"contextPanel.plugin.prompt.noSession"};if(!t.send)return{ok:!0,action:"compose",text:t.text};if(e.busy)return{ok:!1,code:"SESSION_BUSY",message:"Session is busy.",toastKey:"contextPanel.plugin.prompt.busy"};const o=e.directory?.trim()??"";return o?{ok:!0,action:"send",text:t.text,sessionId:n,directory:o}:{ok:!1,code:"HOST_REJECTED",message:"Open a project first.",toastKey:"contextPanel.plugin.startSession.noProject"}},Ra=async e=>{const t=ba(e);if(!t.ok)return J.error(e.t(t.toastKey)),{ok:!1,code:t.code,message:t.message};if(t.action==="compose")return e.compose(t.text,"replace"),{ok:!0,result:{sent:"skipped"}};const n=await Xn(t.sessionId,t.directory,t.text);return n==="no-model"?J.error(e.t("contextPanel.plugin.prompt.noModel")):n==="failed"&&J.error(e.t("contextPanel.plugin.prompt.sendFailed")),{ok:!0,result:{sent:n}}},Aa=async e=>{e.assertAuthorized();const t=e.request.projectId?ma(e.request.projectId):e.directory?zs(e.directory):null,n=e.request.worktree;let o=e.request.projectId?t?.path??null:e.directory,a;if(n&&n!==!0&&n.kind==="existing"){if(!t)throw new K("NO_DIRECTORY","Project is not registered.");if(a=Ye(t.path).find(m=>$(m.path)===$(n.directory)),!a)throw new K("NOT_FOUND","Worktree does not belong to this project or has not loaded yet.");if(a.worktreeStatus==="missing"||a.worktreeStatus==="invalid"||a.worktreeStatus==="not-a-repo")throw new K("HOST_REJECTED","Worktree is unavailable.");o=a.path}const d=n===!0||!!(n&&n.kind==="new"),b=Fn({...e.request,worktree:d},o,Date.now());if(!b.ok)return J.error(e.t("contextPanel.plugin.startSession.noProject")),null;const x=e.request.navigation??"preserve",_=$n();let j=!1;const h=tt(()=>{j=!0}),R=()=>{if(j)throw new K("DISCONNECTED","The connected server changed.");e.assertAuthorized()};let C="session-create-failed",S=!0,i=o??"";const f=()=>{if(!a)return;const m=t?Ye(t.path).find(l=>l.path===a?.path)??a:a;return{directory:m.path,name:m.name??m.label,branch:m.branch,status:m.worktreeStatus==="not-a-repo"?"invalid":m.worktreeStatus??"ready"}},v=async(m,l)=>{if(a&&t){C="bootstrap-failed";const k=await er(t);R(),k&&await tr(a.path)}R(),C="session-create-failed";const u=await nr(m,l,void 0,void 0,_?{model:{providerID:_.providerID,id:_.modelID,variant:_.variant},agent:_.agentName}:void 0,x);if(R(),!u)return null;if(i=u.directory??l,a){const k=t?Ye(t.path).find(E=>E.path===a?.path):void 0;a={...a,worktreeStatus:k?.worktreeStatus??a.worktreeStatus},ne.getState().setWorktreeMetadata(u.id,a)}return{id:u.id,directory:i}};try{const m=await Ta(b,{createSession:v,createWorktree:async(l,u,k)=>{if(!t)throw new K("NO_DIRECTORY","Project is not registered.");const E=n&&n!==!0&&n.kind==="new"?n:void 0,P=E?.name??`${u}-${Js()}`,A=await Ks(t);return R(),a=await Ws(t,{preferredName:P,mode:"new",branchName:P,worktreeName:P,startRef:E?.baseBranch,setupCommands:A,returnAfterDirectoryCreated:!0}),R(),a={...a,kind:k,createdFromBranch:E?.baseBranch},v(b.title,a.path)},initializeSession:l=>{ne.getState().initializeNewOpenChamberSession(l,ue.getState().agents)},setLinkedIssue:async(l,u,k)=>{R(),await kn(l,u,k,!0).catch(()=>{S=!1}),R()},sendFirstMessage:(l,u,k)=>(R(),Xn(l,u,k,_)),closeSurfaces:()=>{x==="open"&&et.getState().closeMainSurfaces()}});if(R(),!m.ok){const l=f();return l?{sessionId:null,sent:"skipped",directory:l.directory,worktree:l,failure:C}:(J.error(e.t("contextPanel.plugin.startSession.failed")),null)}return m.sent==="no-model"?J.error(e.t("contextPanel.plugin.startSession.noModel")):m.sent==="failed"?J.error(e.t("contextPanel.plugin.startSession.sendFailed")):J.success(e.t("contextPanel.plugin.startSession.created")),{sessionId:m.sessionId,sent:m.sent,directory:i,worktree:f(),linked:S}}catch(m){R();const l=f();if(l)return{sessionId:null,sent:"skipped",directory:l.directory,worktree:l,failure:C};throw m}finally{h()}},Ia=async(e,t)=>{const n=await q(`/api/guests/${encodeURIComponent(e)}/storage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new K("HOST_REJECTED","Storage operation failed. Check extension approval and storage limits.");return Pn.parse(await n.json())},Oa=({copyText:e,dismiss:t,onDismiss:n})=>{const{t:o}=wn(),[a,d]=y.useState("idle"),b=async()=>{if(!(e===void 0||a==="copying")){d("copying");try{const x=await xn(e);d(x.ok?"copied":"failed")}catch{d("failed")}}};return ce.jsxs("div",{className:"ml-auto flex shrink-0 flex-col items-end gap-1",children:[ce.jsxs("div",{className:"flex items-center gap-2",children:[e!==void 0&&ce.jsx(Vt,{type:"button",variant:"secondary",size:"xs",disabled:a==="copying",onClick:()=>{b()},"aria-live":"polite",children:o(a==="copied"?"contextPanel.plugin.toast.copied":"contextPanel.plugin.toast.copy")}),t&&ce.jsx(Vt,{type:"button",size:"xs",onClick:n,children:o("contextPanel.plugin.toast.ok")})]}),a==="failed"&&ce.jsx("span",{role:"status",className:"typography-micro text-[var(--status-error-text)]",children:o("contextPanel.plugin.toast.copyFailed")})]})},Ca=e=>{const t=e.copy===!0?e.message:e.copy?e.copy.text:void 0,n=e.dismiss===!0||e.persistent===!0;if(t===void 0&&!n){J[e.kind](e.message);return}const o=crypto.randomUUID(),a={id:o,action:ce.jsx(Oa,{copyText:t,dismiss:n,onDismiss:()=>J.dismiss(o)})};e.persistent&&(a.duration=1/0),J[e.kind](e.message,a)},cn="*",Pa='"SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif',Ma='ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',ja="0.5625rem",_e="The user has not allowed this capability for the extension.",Ga=(e,t)=>e.type==="attach"||e.type==="start-session"||e.type==="session-link"?e.payload.providerId===t?e:{...e,payload:{...e.payload,providerId:t}}:e,wt=(e,t)=>getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t,Na=({mode:e,surface:t="panel",item:n,headless:o=!1,backgroundAction:a,onDismiss:d,onAttach:b,onSessionStarted:x})=>{const{t:_,locale:j}=wn(),{currentTheme:h}=or(),R=ar(),C=ne(w=>w.currentSessionId),S=a?a.item.directory??"":R,i=a?a.item.sessionId:C,f=ir(i,S||void 0),v=cr(i??"",S||void 0),m=y.useRef(null),l=Er(e),u=He(w=>w.guests.find(Y=>Y.id===l)??null),k=He(w=>w.status),E=u?ft(u):!0,P=Be(w=>w.byId[l]),A=Be(w=>w.setStatus),D=Be(w=>w.refresh),Z=Yt(w=>w.pendingItemByGuest[l]),ge=Yt(w=>w.takePendingItem),[ve,be]=y.useState(null);y.useEffect(()=>{o||n!==void 0||!Z||be(ge(l))},[l,o,n,Z,ge]);const pe=o?null:n!==void 0?n:ve,se=Zt(w=>w.clearBadge);y.useEffect(()=>{t==="panel"&&!o&&se(l)},[se,l,o,t]);const me=v?.type==="busy"||v?.type==="retry",Re=Xo(v),Ot=y.useMemo(()=>zo(i?{id:f?.id??i,title:f?.title??a?.item.sessionTitle,busy:me,model:qo(f?.model),agent:f?.agent}:null),[a,i,f,me]),fe=y.useMemo(()=>lr(h),[h]),nt=y.useMemo(()=>({theme:{mode:h.metadata.variant==="dark"?"dark":"light",tokens:{background:h.colors.surface.background,elevated:h.colors.surface.elevated,foreground:h.colors.surface.foreground,muted:h.colors.surface.mutedForeground,subtle:h.colors.surface.subtle,border:h.colors.interactive.border,hover:h.colors.interactive.hover,selection:h.colors.interactive.selection,focus:h.colors.interactive.focusRing,primary:h.colors.primary.base,mutedSurface:h.colors.surface.muted,elevatedForeground:h.colors.surface.elevatedForeground,active:h.colors.interactive.active,selectionForeground:fe.selectionForeground,primaryForeground:h.colors.primary.foreground??"#ffffff",primaryText:fe.tinted.primary,successText:fe.tinted.success,warningText:fe.tinted.warning,errorText:fe.tinted.error,infoText:fe.tinted.info,success:h.colors.status.success,warning:h.colors.status.warning,error:h.colors.status.error,info:h.colors.status.info,font:wt("--font-sans",Pa),mono:wt("--font-mono",Ma),radius:wt("--radius",ja)}},locale:j,directory:S||null,session:Ot,surface:o&&u?.backgroundEntry?"background":t,connection:P?.connection??Qt,settings:P?.settings??{},item:pe}),[h,fe,S,u?.backgroundEntry,o,pe,j,P,Ot,t]),Ae=`${l}:${u?.version??""}:${E}:service-${u?.service?.granted?"1":"0"}:${u?.entry??""}:${u?.backgroundEntry??""}`,qn=u?o?u.backgroundEntry??u.entry??null:t==="page"?u.pageEntry??null:t==="dialog"&&u.attachEntry?u.attachEntry:u.entry??null:null,{src:Ne,srcDoc:Ue,status:st,recoverExpiredNavigation:zn,acknowledgeHandshake:Ct}=la({guestId:l,entry:qn,instanceKey:Ae,enabled:E}),Ee=y.useRef(nt);Ee.current=nt;const re=y.useRef(S);re.current=S;const rt=y.useRef(i);rt.current=i;const Pt=y.useRef(me);Pt.current=me;const H=y.useRef(l);H.current=l;const oe=y.useRef(E);oe.current=E;const Q=y.useRef(u);Q.current=u;const Mt=y.useRef(u?.integration?.auth);Mt.current=u?.integration?.auth;const De=y.useRef(_);De.current=_;const ot=y.useRef(b);ot.current=b;const at=y.useRef(d);at.current=d;const jt=y.useRef(x);jt.current=x;const Le=y.useRef(null),Te=y.useRef(new Map),Gt=y.useRef(0),ye=y.useCallback(()=>{Le.current!=null&&(window.clearInterval(Le.current),Le.current=null)},[]),B=y.useCallback(w=>{m.current?.contentWindow?.postMessage(w,cn)},[]),it=y.useCallback(()=>{const w=a?.takeMessage();w&&B(w)},[a,B]),ct=y.useRef(!1),lt=y.useRef(null),ut=y.useCallback(()=>{if(ct.current||t!=="panel"||!o&&Q.current?.backgroundEntry)return;ct.current=!0;const w=Q.current,Y=F();lt.current=ur(H.current,he=>{const ee=He.getState().guests.find(ae=>ae.id===w?.id);return F()!==Y||!ee||!ft(ee)||ee.version!==w?.version||ee.entry!==w?.entry||ee.backgroundEntry!==w?.backgroundEntry?Promise.resolve({ok:!1,reason:"unavailable"}):new Promise(ae=>{Gt.current+=1;const te=`resolve-${Gt.current}`,pt=window.setTimeout(()=>{Te.current.delete(te),ae({ok:!1,reason:"timeout"})},pr);Te.current.set(te,ke=>{window.clearTimeout(pt),Te.current.delete(te),ae(ke)}),m.current?.contentWindow?.postMessage(Fo(te,he.command,he.args),cn)})})},[o,t]);y.useEffect(()=>()=>{lt.current?.(),lt.current=null,ct.current=!1;for(const w of Te.current.values())w({ok:!1,reason:"unavailable"});Te.current.clear()},[Ae,Ne,Ue]);const Ie=y.useCallback(()=>{B(No(Ee.current)),B(Uo(re.current||null)),B(Do(Ee.current.session)),B(Lo(Ee.current.connection)),B(Ho(Ee.current.settings)),B(Bo(Ee.current.item))},[B]);y.useEffect(()=>{u?.integration&&D(u.id)},[u?.id,u?.integration,D]),y.useEffect(()=>{u&&!E&&d?.()},[u,E,d]),y.useEffect(()=>{const w=new Map;let Y=!1;const he=F(),ee=H.current,ae=()=>He.getState().guests.find(we=>we.id===ee)??null,te=()=>{for(const we of w.values())we();w.clear()},pt=tt(()=>{Y=!0,te(),ye()}),ke=()=>{if(!ie(ae(),"sessions"))throw new K("NOT_GRANTED",_e)},Nt=we=>{const mt=m.current;if(!mt||we.source!==mt.contentWindow)return;const Ut=Mo.safeParse(we.data);if(!Ut.success||Y||F()!==he||a&&!a.isActive())return;const Se=Ga(Ut.data,H.current),Dt=ae();if(!Dt||!ft(Dt)){te(),"id"in Se&&B({channel:V,v:W,type:"result",id:Se.id,ok:!1,error:"Extension is unavailable.",code:"DISABLED"});return}if(Se.type==="hello"){Ct(),te(),Ie(),ut(),it();return}if(Se.type==="action-result"){Se.id===a?.id&&a.complete(Se.payload);return}Jo(Se,{workspaceRead:p=>(ke(),_t(p,H.current)),workspaceSubscribe:({subscriptionId:p,query:O})=>{if(ke(),w.get(p)?.(),w.delete(p),w.size>=32)throw new K("HOST_REJECTED","At most 32 workspace subscriptions per frame.");w.set(p,ha(O,H.current,L=>{!Y&&ie(Q.current,"sessions")&&B({channel:V,v:W,type:"workspace",payload:{subscriptionId:p,snapshot:L}})}))},workspaceUnsubscribe:p=>{w.get(p)?.(),w.delete(p)},storage:p=>Ia(H.current,p),openSession:p=>{ke(),Sa(p)},toast:p=>{oe.current&&Ca(p)},openUrl:en,openSurface:p=>{const O=re.current||"";O&&et.getState().openContextSurface(O,p)},writeClipboard:async p=>(await xn(p)).ok,compose:(p,O)=>{yt.getState().setPendingInputText(p,O)},attach:p=>{if(ot.current){ot.current(p);return}yt.getState().setPendingGuestIssue(p)},startSession:async p=>{if(!ie(Q.current,"sessions")||p.text&&!ie(Q.current,"prompt"))return{ok:!1,code:"NOT_GRANTED",message:_e};const O=await Aa({request:p,directory:re.current||null,t:De.current,assertAuthorized:()=>{if(ke(),p.text&&!ie(ae(),"prompt"))throw new K("NOT_GRANTED",_e)}});return O?.sessionId&&p.navigation==="open"&&(jt.current?.(),at.current?.()),O},prompt:p=>p.send&&!ie(Q.current,"prompt")?Promise.resolve({ok:!1,code:"NOT_GRANTED",message:_e}):Ra({request:p,sessionId:rt.current,directory:re.current||null,busy:Pt.current,compose:(O,L)=>{yt.getState().setPendingInputText(O,L)},t:De.current}),sessionLink:p=>va({request:p,sessionId:rt.current,directory:re.current||null,t:De.current}),close:()=>{at.current?.()},oauthStart:async()=>{if(!oe.current)return!1;const p=H.current,O=Be.getState().byId[p]?.connection??Qt,L=await Mr(p);if(!L||Y||F()!==he)return!1;en(L),ye();const Jn=Date.now()+Gr;return Le.current=window.setInterval(()=>{(async()=>{if(Date.now()>Jn){ye();return}const Lt=await D(p);Lt&&Ur(O,Lt.connection)&&ye()})()},Nr),!0},oauthDisconnect:async()=>{const p=await jr(ee);return!p||Y||F()!==he?!1:(A(ee,p),!0)},request:async p=>{if(!oe.current)return{ok:!1,code:"DISABLED",message:"This extension is disabled in Settings → Extensions."};const O=await pa(Mt.current,p);if(O!==void 0)return O?{ok:!0,result:O}:{ok:!1,code:"HOST_REJECTED",message:"Request failed."};const L=await Dr(H.current,p);return L.ok||D(H.current),L},serviceRequest:p=>oe.current?$r(H.current,p):Promise.resolve({ok:!1,code:"DISABLED",message:"This extension is disabled in Settings → Extensions."}),serviceStatus:()=>Xr(H.current),file:p=>{if(!oe.current)return Promise.resolve({ok:!1,code:"DISABLED",message:"This extension is disabled in Settings → Extensions."});const O=mr(p.path);if(!ie(Q.current,O==="project"?"files":"filesystem"))return Promise.resolve({ok:!1,code:"NOT_GRANTED",message:_e});const L=re.current||null;return O==="project"&&!L?Promise.resolve({ok:!1,code:"NO_DIRECTORY",message:"No project is open."}):Zo(H.current,p,L)},generate:p=>oe.current?ie(Q.current,"model")?na(H.current,p,re.current||null):Promise.resolve({ok:!1,code:"NOT_GRANTED",message:_e}):Promise.resolve({ok:!1,code:"DISABLED",message:"This extension is disabled in Settings → Extensions."}),setBadge:p=>{oe.current&&Zt.getState().setBadge(H.current,p)},resolveResult:(p,O)=>{const L=Te.current.get(p);if(L){if("error"in O){L({ok:!1,reason:"error",message:O.error});return}L({ok:!0,item:O.item})}}}).then(p=>{p&&!Y&&mt===m.current&&F()===he&&(!a||a.isActive())&&B(p)})};return window.addEventListener("message",Nt),()=>{Y=!0,te(),pt(),window.removeEventListener("message",Nt)}},[Ct,a,Ae,E,B,Ie,D,ut,it,A,Ne,Ue,ye]),y.useEffect(()=>{a&&(st==="error"||!E)&&a.complete({ok:!1,reason:"unavailable"})},[a,st,E]);const dt=y.useRef(!1);return y.useEffect(()=>(dt.current=!0,()=>{dt.current=!1,queueMicrotask(()=>{dt.current||a?.complete({ok:!1,reason:"unavailable"})})}),[a]),y.useEffect(()=>()=>ye(),[Ae,ye]),y.useEffect(()=>{Ie()},[Ie,nt,S]),y.useEffect(()=>{o||k!=="ready"||u?.entry||(vn(e),d?.())},[k,u?.entry,o,e,d]),y.useEffect(()=>{!i||!Re||B($o({sessionId:i,phase:Re}))},[i,Re,B]),!u&&k!=="ready"&&k!=="error"?null:!u||!Ne&&!Ue?ce.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:_(u&&st==="loading"?"common.loading":"contextPanel.plugin.loadFailed")}):E?ce.jsx("iframe",{ref:m,title:u.name,src:Ne||void 0,srcDoc:Ue,sandbox:"allow-scripts",className:dr("h-full w-full min-h-0 min-w-0 border-0 overflow-hidden",t==="dialog"?"bg-transparent":"bg-[var(--surface-background)]"),onLoad:()=>{zn()||(Ie(),ut(),it())}},Ae):null},Wa=Object.freeze(Object.defineProperty({__proto__:null,PluginPane:Na},Symbol.toStringTag,{value:"Module"}));export{Gr as A,Na as P,Ea as a,Mr as b,Ur as c,jr as d,Nr as e,Xa as f,ga as g,$a as h,Ja as i,za as j,Ka as k,Wa as l,qa as s,Be as u};