@openchamber/web 1.24.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.test.js +22 -0
- package/bin/lib/commands-connect-url.js +3 -8
- package/bin/lib/commands-status.js +5 -0
- package/bin/lib/commands-tunnel.js +3 -0
- package/dist/assets/{CodeMirrorCommentWidgets-DvUH815P.js → CodeMirrorCommentWidgets-hJbl3JX4.js} +1 -1
- package/dist/assets/DiffView-BucGEJYa.js +4 -0
- package/dist/assets/FilesView-CQcaaAVP.js +17 -0
- package/dist/assets/{GitView-Bxuv3dfP.js → GitView-DY4pelsO.js} +4 -4
- package/dist/assets/{GuestAttachDialog-B0u3Q5uO.js → GuestAttachDialog-D6mHDTB2.js} +1 -1
- package/dist/assets/GuestSurfacePane--DJ7rsmY.js +1 -0
- package/dist/assets/{JsonTreeView-BBVPFM5K.js → JsonTreeView-DEXI2NvJ.js} +1 -1
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/LinearIssuesView-BTNc-4dN.js +1 -0
- package/dist/assets/MarkdownImageGallery-wcUUcf8l.js +1 -0
- package/dist/assets/MarkdownRendererImpl-BPe2TVV2.js +12 -0
- package/dist/assets/OnboardingScreen-FJUreEgI.js +1 -0
- package/dist/assets/{PatchDiff-C4rE5k6z.js → PatchDiff-C0oOkKnO.js} +1 -1
- package/dist/assets/PierreDiffViewer-asuSQAsf.js +210 -0
- package/dist/assets/PlanView-DGbasNHP.js +5 -0
- package/dist/assets/PluginPane-DImv8hV2.js +3 -0
- package/dist/assets/SettingsView-DOjuOljf.js +29 -0
- package/dist/assets/SettingsWindow-By4cqnqy.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-C0P2tXLU.js +1 -0
- package/dist/assets/ToolOutputDialog-Cayc-yIM.js +15 -0
- package/dist/assets/ToolPartDiffPreview-B0jmpPQz.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-CZgXWHjU.js → VirtualizedFileDiff-DsOpvWZD.js} +4 -4
- package/dist/assets/{WalkthroughView-wSpED5L4.js → WalkthroughView-CCakjyn9.js} +2 -2
- package/dist/assets/appThemeRegistry-Bw5oTm41.js +1 -0
- package/dist/assets/{commitAndPush-DZnzlhvc.js → commitAndPush-sGEelpjh.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-VYnT_A2h.js → computeVirtualFileMetrics-B-4aLf4A.js} +1 -1
- package/dist/assets/de-CD9utsNj.js +10 -0
- package/dist/assets/es-NNum2rX8.js +16 -0
- package/dist/assets/fr-CJLGmduQ.js +14 -0
- package/dist/assets/index-B6r0Kv-B.js +1 -0
- package/dist/assets/index-DjGPR5vW.js +41 -0
- package/dist/assets/index-fCXJ-8Qt.css +1 -0
- package/dist/assets/{isDiffPlainText-ImDG3Uhg.js → isDiffPlainText-Ok-kgtJA.js} +1 -1
- package/dist/assets/{isFilePlainText-D_YDVYDb.js → isFilePlainText-0dLnkYm8.js} +1 -1
- package/dist/assets/ja-BuddHNi6.js +16 -0
- package/dist/assets/ko-BrwMbHmf.js +16 -0
- package/dist/assets/main-CjXBM_Xe.js +2 -0
- package/dist/assets/main-CxVyUDU_.js +896 -0
- package/dist/assets/markdownCore-B6PpX409.js +5 -0
- package/dist/assets/miniChat-DZ3OAeLN.js +2 -0
- package/dist/assets/mobile-CH0LOIF-.js +2 -0
- package/dist/assets/{patchFileDiff-DDQ6Rq5e.js → patchFileDiff-BFRGKaGH.js} +3 -3
- package/dist/assets/pl-BwN4TNlP.js +16 -0
- package/dist/assets/pt-BR-BhMtownO.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-CB1uLYvh.js +2 -0
- package/dist/assets/renderMobileApp-nQ4sjQtb.js +25 -0
- package/dist/assets/runtimeEndpointReset-9ZGlXU4J.js +27 -0
- package/dist/assets/scheduledTasksApi-6DsL_SwM.js +1 -0
- package/dist/assets/{shikiHighlight-1imXsir9.js → shikiHighlight-CocY80VR.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-Dgqc63LZ.js → textMateThemeFromAppTheme-CF77r8FA.js} +1 -1
- package/dist/assets/tr-DRzvqMdi.js +7 -0
- package/dist/assets/uk-b2aYOSNh.js +16 -0
- package/dist/assets/useAppFontEffects-Dc5nTHi8.js +7337 -0
- package/dist/assets/useInlineCommentController-Dbza5c8l.js +2 -0
- package/dist/assets/useRootScrollLock-CSCLv396.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-BDyxuqK4.js → vendor-codemirror-language-data-CkmYWcRI.js} +2 -2
- package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
- package/dist/assets/vendor-katex-Cp579UoJ.css +1 -0
- package/dist/assets/vendor-opencode-client-_BAHQo4R.js +12 -0
- package/dist/assets/{vendor-remixicon-react-BDmGmFCA.js → vendor-remixicon-react-D6dZ0UwF.js} +1 -1
- package/dist/assets/{vendor-zod-fZppILAM.js → vendor-zod-Gea9uBlY.js} +4 -4
- package/dist/assets/{web-components-D7FinaeH.js → web-components-nsStrYq9.js} +2 -2
- package/dist/assets/zh-CN-DZeUThm_.js +16 -0
- package/dist/assets/zh-TW-2fRE7uc6.js +16 -0
- package/dist/index.html +15 -7
- package/dist/mini-chat.html +7 -5
- package/dist/mobile.html +7 -5
- package/package.json +8 -7
- package/server/index.d.ts +1 -0
- package/server/index.js +248 -90
- package/server/lib/agent-tool/DOCUMENTATION.md +45 -15
- package/server/lib/agent-tool/runtime.js +189 -61
- package/server/lib/agent-tool/runtime.test.js +229 -75
- package/server/lib/browser-control/DOCUMENTATION.md +37 -2
- package/server/lib/browser-control/provider.js +217 -0
- package/server/lib/browser-control/provider.test.js +251 -0
- package/server/lib/context-obligatory/runtime.js +61 -50
- package/server/lib/context-obligatory/runtime.test.js +62 -162
- package/server/lib/event-stream/DOCUMENTATION.md +12 -1
- package/server/lib/event-stream/delta-coalescer.js +0 -0
- package/server/lib/event-stream/delta-coalescer.test.js +68 -57
- package/server/lib/event-stream/directory-ws-bridge.js +1 -1
- package/server/lib/event-stream/global-hub.js +10 -1
- package/server/lib/event-stream/global-hub.test.js +27 -26
- package/server/lib/event-stream/index.js +6 -0
- package/server/lib/event-stream/protocol.js +26 -19
- package/server/lib/event-stream/protocol.test.js +18 -7
- package/server/lib/event-stream/rebind.test.js +5 -5
- package/server/lib/event-stream/runtime.test.js +17 -15
- package/server/lib/event-stream/translate-v2.js +313 -0
- package/server/lib/event-stream/translate-v2.test.js +209 -0
- package/server/lib/event-stream/upstream-reader.test.js +16 -16
- package/server/lib/fs/DOCUMENTATION.md +6 -3
- package/server/lib/fs/byte-range.js +35 -0
- package/server/lib/fs/byte-range.test.js +31 -0
- package/server/lib/fs/routes.js +103 -46
- package/server/lib/fs/routes.test.js +239 -18
- package/server/lib/git/DOCUMENTATION.md +2 -2
- package/server/lib/git/service.js +106 -9
- package/server/lib/git/service.test.js +18 -0
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/github/pr-status.js +22 -2
- package/server/lib/github/pr-status.test.js +27 -14
- package/server/lib/guests/DOCUMENTATION.md +13 -0
- package/server/lib/guests/catalog.js +12 -0
- package/server/lib/guests/catalog.test.js +33 -0
- package/server/lib/guests/routes.js +10 -1
- package/server/lib/guests/service.js +192 -14
- package/server/lib/guests/service.test.js +201 -1
- package/server/lib/guests/surface.js +630 -0
- package/server/lib/guests/surface.test.js +486 -0
- package/server/lib/markdown-image-grants/routes.js +18 -5
- package/server/lib/markdown-image-grants/routes.test.js +9 -6
- package/server/lib/message-queue/DOCUMENTATION.md +36 -22
- package/server/lib/message-queue/runtime.js +170 -100
- package/server/lib/message-queue/runtime.test.js +184 -82
- package/server/lib/notifications/DOCUMENTATION.md +28 -0
- package/server/lib/notifications/control-stream.http.test.js +68 -0
- package/server/lib/notifications/emitter-runtime.js +15 -0
- package/server/lib/notifications/emitter-runtime.test.js +32 -0
- package/server/lib/notifications/push-runtime.js +5 -1
- package/server/lib/notifications/push-runtime.test.js +2 -2
- package/server/lib/notifications/routes.js +5 -0
- package/server/lib/notifications/runtime.js +115 -26
- package/server/lib/notifications/template-runtime.js +13 -15
- package/server/lib/notifications/template-runtime.test.js +16 -9
- package/server/lib/notifications/trigger-runtime.test.js +187 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +10 -0
- package/server/lib/openchamber-control/actions.js +3 -2
- package/server/lib/openchamber-control/error.js +1 -1
- package/server/lib/openchamber-control/file-open.js +59 -0
- package/server/lib/openchamber-control/file-open.test.js +57 -0
- package/server/lib/openchamber-control/routes.test.js +12 -0
- package/server/lib/openchamber-control/service.js +102 -49
- package/server/lib/openchamber-control/service.test.js +84 -44
- package/server/lib/openchamber-sessions/archive-store.js +224 -0
- package/server/lib/openchamber-sessions/archive-store.test.js +187 -0
- package/server/lib/openchamber-sessions/opencode-client.js +22 -0
- package/server/lib/openchamber-sessions/routes.js +398 -328
- package/server/lib/openchamber-sessions/routes.test.js +786 -700
- package/server/lib/openchamber-sessions/session-metadata-store.js +285 -0
- package/server/lib/openchamber-sessions/session-metadata-store.test.js +259 -0
- package/server/lib/opencode/DOCUMENTATION.md +450 -30
- package/server/lib/opencode/agents.js +233 -327
- package/server/lib/opencode/auth.js +41 -44
- package/server/lib/opencode/auth.test.js +92 -0
- package/server/lib/opencode/bootstrap-runtime.js +1 -0
- package/server/lib/opencode/cli-upgrade.d.ts +4 -0
- package/server/lib/opencode/cli-upgrade.js +18 -0
- package/server/lib/opencode/cli-upgrade.test.js +36 -0
- package/server/lib/opencode/commands.js +164 -145
- package/server/lib/opencode/compatibility.d.ts +16 -0
- package/server/lib/opencode/compatibility.js +88 -0
- package/server/lib/opencode/compatibility.test.js +62 -0
- package/server/lib/opencode/config-entity-routes.js +58 -29
- package/server/lib/opencode/config-entity-v2.test.js +290 -0
- package/server/lib/opencode/config-mutation-response.js +17 -7
- package/server/lib/opencode/config-mutation-response.test.js +4 -7
- package/server/lib/opencode/config-paths.test.js +2 -2
- package/server/lib/opencode/config-v2.d.ts +183 -0
- package/server/lib/opencode/config-v2.js +801 -0
- package/server/lib/opencode/config-v2.test.js +466 -0
- package/server/lib/opencode/credential-db.js +144 -0
- package/server/lib/opencode/credential-db.test.js +104 -0
- package/server/lib/opencode/env-runtime.js +48 -9
- package/server/lib/opencode/env-runtime.test.js +45 -0
- package/server/lib/opencode/feature-routes-runtime.js +15 -5
- package/server/lib/opencode/lifecycle-process.test.js +7 -4
- package/server/lib/opencode/lifecycle.js +85 -30
- package/server/lib/opencode/lifecycle.test.js +80 -8
- package/server/lib/opencode/login-shell-env.js +27 -0
- package/server/lib/opencode/managed-config-file.js +119 -0
- package/server/lib/opencode/managed-config-file.test.js +152 -0
- package/server/lib/opencode/managed-plugin-config.js +33 -13
- package/server/lib/opencode/mcp.js +43 -149
- package/server/lib/opencode/network-runtime.js +6 -7
- package/server/lib/opencode/openchamber-routes.test.js +0 -1
- package/server/lib/opencode/plugin-routes.js +3 -3
- package/server/lib/opencode/plugin-routes.test.js +6 -24
- package/server/lib/opencode/plugins.js +91 -40
- package/server/lib/opencode/plugins.test.js +28 -15
- package/server/lib/opencode/providers.js +63 -83
- package/server/lib/opencode/providers.test.js +128 -59
- package/server/lib/opencode/proxy-agent-wiring.test.js +4 -2
- package/server/lib/opencode/proxy.js +179 -129
- package/server/lib/opencode/pwa-manifest-routes.js +4 -2
- package/server/lib/opencode/pwa-manifest-routes.test.js +3 -2
- package/server/lib/opencode/response-envelope.js +14 -0
- package/server/lib/opencode/response-envelope.test.js +23 -0
- package/server/lib/opencode/routes-upgrade.test.js +73 -116
- package/server/lib/opencode/routes.js +121 -428
- package/server/lib/opencode/server-utils-runtime.js +10 -4
- package/server/lib/opencode/session-activity.js +78 -0
- package/server/lib/opencode/session-runtime.js +79 -0
- package/server/lib/opencode/session-runtime.test.js +43 -0
- package/server/lib/opencode/settings-helpers.js +9 -9
- package/server/lib/opencode/settings-helpers.test.js +7 -12
- package/server/lib/opencode/settings-registry.json +6 -8
- package/server/lib/opencode/settings-runtime.js +18 -1
- package/server/lib/opencode/settings-runtime.test.js +31 -2
- package/server/lib/opencode/shared.js +54 -22
- package/server/lib/opencode/shared.test.js +8 -4
- package/server/lib/opencode/shutdown-runtime.js +54 -7
- package/server/lib/opencode/shutdown-runtime.test.js +224 -30
- package/server/lib/opencode/skill-routes.js +23 -24
- package/server/lib/opencode/skills.js +7 -5
- package/server/lib/opencode/tunnel-wiring-runtime.js +2 -1
- package/server/lib/opencode/upgrade-capability.test.js +1 -1
- package/server/lib/opencode/v1-migration-topup.js +288 -0
- package/server/lib/opencode/v1-migration-topup.test.js +266 -0
- package/server/lib/opencode/v2-install.d.ts +8 -0
- package/server/lib/opencode/v2-install.js +158 -0
- package/server/lib/opencode/v2-install.test.js +124 -0
- package/server/lib/opencode/watcher.js +10 -3
- package/server/lib/opencode/watcher.test.js +17 -21
- package/server/lib/opencode/websearch-config.js +66 -0
- package/server/lib/permission-auto-accept/runtime.js +38 -22
- package/server/lib/permission-auto-accept/runtime.test.js +39 -17
- package/server/lib/projects/project-config.js +2 -2
- package/server/lib/quota/DOCUMENTATION.md +4 -0
- package/server/lib/quota/providers/xai.js +4 -4
- package/server/lib/realtime-proxy-terminal.test.js +150 -0
- package/server/lib/realtime-proxy.js +2 -0
- package/server/lib/relay/tunnel-host.js +4 -1
- package/server/lib/relay/tunnel-host.test.js +7 -0
- package/server/lib/routing/DOCUMENTATION.md +52 -19
- package/server/lib/routing/defaults.js +23 -6
- package/server/lib/routing/jev.js +17 -7
- package/server/lib/routing/routes.http.test.js +68 -33
- package/server/lib/routing/routes.js +65 -22
- package/server/lib/routing/runtime.js +145 -48
- package/server/lib/routing/runtime.test.js +79 -55
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -0
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +51 -46
- package/server/lib/scheduled-tasks/runtime.js +83 -76
- package/server/lib/scheduled-tasks/runtime.test.js +67 -1
- package/server/lib/session-assist/DOCUMENTATION.md +8 -3
- package/server/lib/session-assist/context.js +122 -46
- package/server/lib/session-assist/context.test.js +117 -49
- package/server/lib/session-assist/runtime.js +52 -22
- package/server/lib/session-assist/runtime.test.js +145 -173
- package/server/lib/session-goal/DOCUMENTATION.md +23 -15
- package/server/lib/session-goal/create.js +9 -12
- package/server/lib/session-goal/create.test.js +27 -28
- package/server/lib/session-goal/runtime.js +164 -77
- package/server/lib/session-goal/runtime.test.js +271 -519
- package/server/lib/session-knowledge/DOCUMENTATION.md +5 -0
- package/server/lib/session-knowledge/runtime.js +59 -41
- package/server/lib/session-knowledge/runtime.test.js +90 -20
- package/server/lib/small-model/DOCUMENTATION.md +154 -196
- package/server/lib/small-model/client.js +113 -0
- package/server/lib/small-model/index.js +296 -158
- package/server/lib/small-model/index.test.js +423 -256
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/spaces/DOCUMENTATION.md +807 -0
- package/server/lib/spaces/code-in-bait.js +185 -0
- package/server/lib/spaces/code-in.js +641 -0
- package/server/lib/spaces/code-in.test.js +1048 -0
- package/server/lib/spaces/errors.js +8 -0
- package/server/lib/spaces/exec-http.js +94 -0
- package/server/lib/spaces/gatekeeper-channel.js +202 -0
- package/server/lib/spaces/gatekeeper-channel.test.js +215 -0
- package/server/lib/spaces/gatekeeper-program.cjs +914 -0
- package/server/lib/spaces/gatekeeper-program.test.js +1391 -0
- package/server/lib/spaces/hardening.js +457 -0
- package/server/lib/spaces/hardening.test.js +368 -0
- package/server/lib/spaces/host-git.js +127 -0
- package/server/lib/spaces/host-git.test.js +137 -0
- package/server/lib/spaces/labels.js +234 -0
- package/server/lib/spaces/labels.test.js +219 -0
- package/server/lib/spaces/layout.js +184 -0
- package/server/lib/spaces/layout.test.js +30 -0
- package/server/lib/spaces/manager.js +82 -0
- package/server/lib/spaces/manager.test.js +114 -0
- package/server/lib/spaces/places/code-in.docker.live.test.js +216 -0
- package/server/lib/spaces/places/contract-suite.js +156 -0
- package/server/lib/spaces/places/contract.docker.live.test.js +7 -0
- package/server/lib/spaces/places/contract.test.js +6 -0
- package/server/lib/spaces/places/docker-engine.js +126 -0
- package/server/lib/spaces/places/docker-live-support.js +202 -0
- package/server/lib/spaces/places/docker-tools.js +186 -0
- package/server/lib/spaces/places/docker.js +587 -0
- package/server/lib/spaces/places/docker.test.js +1610 -0
- package/server/lib/spaces/places/escape-suite.js +1018 -0
- package/server/lib/spaces/places/escape.docker.live.test.js +7 -0
- package/server/lib/spaces/places/fake-docker.js +375 -0
- package/server/lib/spaces/places/memory-place.js +103 -0
- package/server/lib/spaces/places/packed.docker.live.test.js +77 -0
- package/server/lib/spaces/places/registry.js +43 -0
- package/server/lib/spaces/places/registry.test.js +50 -0
- package/server/lib/spaces/places/server.docker.live.test.js +225 -0
- package/server/lib/spaces/run-command.js +261 -0
- package/server/lib/spaces/run-command.test.js +396 -0
- package/server/lib/spaces/space-server.js +190 -0
- package/server/lib/spaces/space-server.test.js +335 -0
- package/server/lib/spaces/tools-filler.js +82 -0
- package/server/lib/spaces/tools-filler.test.js +148 -0
- package/server/lib/spaces/tools-pack.js +49 -0
- package/server/lib/spaces/tools-pack.test.js +57 -0
- package/server/lib/spaces/tools.js +137 -0
- package/server/lib/spaces/tools.test.js +153 -0
- package/server/lib/terminal/DOCUMENTATION.md +21 -2
- package/server/lib/terminal/runtime.js +10 -3
- package/server/lib/terminal/runtime.test.js +22 -0
- package/server/lib/terminal/shutdown.js +106 -0
- package/server/lib/terminal/shutdown.test.js +84 -0
- package/server/lib/tts/openai-sdk.js +11 -0
- package/server/lib/tts/service.js +7 -5
- package/server/lib/tts/service.test.js +78 -0
- package/server/lib/tts/stt.js +3 -2
- package/server/lib/tunnels/DOCUMENTATION.md +2 -0
- package/server/lib/tunnels/routes.js +7 -0
- package/server/lib/tunnels/routes.test.js +55 -0
- package/server/lib/ui-auth/ui-auth.js +38 -2
- package/server/lib/ui-auth/ui-auth.test.js +42 -0
- package/server/lib/ui-auth/ui-passkeys.js +12 -10
- package/server/lib/walkthrough/DOCUMENTATION.md +10 -1
- package/server/lib/walkthrough/pull-request.js +61 -8
- package/server/lib/walkthrough/pull-request.test.js +54 -1
- package/server/lib/walkthrough/routes.js +20 -0
- package/server/lib/walkthrough/routes.test.js +19 -0
- package/server/opencode-proxy.test.js +190 -166
- package/server/opencode-worktree-readiness.test.js +5 -4
- package/dist/assets/DiffView-DkC3xlRJ.js +0 -4
- package/dist/assets/FilesView-D0bM9FVB.js +0 -13
- package/dist/assets/LinearIssuesView-UI1FcSC8.js +0 -1
- package/dist/assets/MarkdownImageGallery-CUJxH8Le.js +0 -1
- package/dist/assets/MarkdownRendererImpl-D5BZOg8X.js +0 -12
- package/dist/assets/OnboardingScreen-5Gou9cGD.js +0 -1
- package/dist/assets/PierreDiffViewer-ByRVu6ss.js +0 -161
- package/dist/assets/PlanView-u2yi5XGJ.js +0 -5
- package/dist/assets/PluginPane-QxjsKYeO.js +0 -3
- package/dist/assets/SettingsView-Fo5ZqMaT.js +0 -29
- package/dist/assets/SettingsWindow-HVDVANjJ.js +0 -1
- package/dist/assets/SubmoduleDiffSummary-D3hzkybB.js +0 -1
- package/dist/assets/ToolOutputDialog-3J6IRayW.js +0 -15
- package/dist/assets/ToolPartDiffPreview-DarxPjSd.js +0 -8
- package/dist/assets/appThemeRegistry-Cf8KitzT.js +0 -1
- package/dist/assets/de-BM_8EDD3.js +0 -10
- package/dist/assets/es-CxZjlqpo.js +0 -16
- package/dist/assets/fr-VCixCnMW.js +0 -14
- package/dist/assets/index-3U4CtS9b.js +0 -1
- package/dist/assets/index-B9Hvzjwl.css +0 -1
- package/dist/assets/index-DLHQogv8.js +0 -40
- package/dist/assets/ja-CZ5k_GyD.js +0 -16
- package/dist/assets/ko-7YM3A1Xh.js +0 -16
- package/dist/assets/main-CycplCph.js +0 -2
- package/dist/assets/main-DFYTCx5o.js +0 -896
- package/dist/assets/markdownCore-DHvqMxPn.js +0 -5
- package/dist/assets/miniChat-DIQKfY2V.js +0 -2
- package/dist/assets/mobile-BMwz5q-m.js +0 -2
- package/dist/assets/pl-BcgDO_w5.js +0 -16
- package/dist/assets/pt-BR-CU2u_1q5.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-3_d6g6CU.js +0 -2
- package/dist/assets/renderMobileApp-D0Y8DtkA.js +0 -25
- package/dist/assets/runtimeEndpointReset-DhC3REb2.js +0 -25
- package/dist/assets/scheduledTasksApi-D8pq6gQz.js +0 -1
- package/dist/assets/tr-DuYhOzNe.js +0 -7
- package/dist/assets/uk-Cuk7-uvq.js +0 -16
- package/dist/assets/useAppFontEffects-BItUWdo4.js +0 -7333
- package/dist/assets/useInlineCommentController-CkbKsm7m.js +0 -2
- package/dist/assets/useRootScrollLock-vmzxZjWA.js +0 -2
- package/dist/assets/vendor-cron-parser-CUcP7OfX.js +0 -2
- package/dist/assets/vendor-opencode-sdk-BJ73u-bH.js +0 -7
- package/dist/assets/zh-CN-CUWoiRHd.js +0 -16
- package/dist/assets/zh-TW-CQ8EBSBN.js +0 -16
- package/server/lib/opencode/mcp-oauth-callback.test.js +0 -111
- package/server/lib/routing/feature-flag.js +0 -11
- package/server/lib/small-model/call.js +0 -820
- package/server/lib/small-model/call.test.js +0 -1110
- package/server/lib/small-model/catalog.js +0 -13
- package/server/lib/small-model/resolve.js +0 -131
- package/server/lib/small-model/resolve.test.js +0 -197
- package/server/lib/small-model/runtime-providers.js +0 -164
- package/server/lib/small-model/runtime-providers.test.js +0 -118
- package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
- package/server/lib/system-prompt/runtime.js +0 -49
- package/server/lib/system-prompt/runtime.test.js +0 -76
- package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
- /package/dist/assets/{vendor-katex-k3Ppq1Ha.js → vendor-katex-CHD9BdDO.js} +0 -0
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{R as C,f as ae,j as re}from"./vendor-react-BUCujlKS.js";import{m as Ht}from"./vendor-morphdom-B7dS_VPB.js";import{r as Vt,a as Kt}from"./vendor-beautiful-mermaid-DztCUpLZ.js";import{gq as lt,gr as jt,gs as Ut,gt as Zt,gu as Xt,g as we,bm as Gt,bp as Yt,gv as Jt,gw as Qt,Z as ct,af as dt,gx as ut,f as mt,h as pt,eL as en,eM as qe,gy as tn,gz as Be,gA as nn,gB as rn,gC as on,gD as sn,gE as an,o as ln}from"./useAppFontEffects-BItUWdo4.js";import{h as cn,O as ft,L as oe,cM as dn,u as Y,a as un,a$ as mn,E as pn,F as fn}from"./index-DLHQogv8.js";import{getCachedMarkdownBlocks as $e,renderMarkdownSync as hn,renderMarkdownBlocks as gn}from"./markdownCore-DHvqMxPn.js";import{b as bn,r as wn}from"./textMateThemeFromAppTheme-Dgqc63LZ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-elkjs-BRwcR927.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zod-fZppILAM.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-BDyxuqK4.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-sdk-BJ73u-bH.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-k3Ppq1Ha.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 ht=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=ht(t)?.getAttribute("href")??"";return jt(r)?(t.preventDefault(),t.stopPropagation(),e?.(r),!0):!1},yn=t=>t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey,An=(t,e)=>{const n=o=>{if(Ne(o,e.openAppLink)||!e.allowExternalHttp||o.defaultPrevented||!yn(o))return;const i=ht(o)?.getAttribute("href")??"";lt(i)&&(o.preventDefault(),o.stopPropagation(),e.openExternalHttp(i))},r=o=>{o.button===1&&Ne(o,e.openAppLink)},s=o=>{Ne(o)};return t.addEventListener("click",n),t.addEventListener("auxclick",r),t.addEventListener("dragstart",s),()=>{t.removeEventListener("click",n),t.removeEventListener("auxclick",r),t.removeEventListener("dragstart",s)}},gt="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)"},vn=Object.fromEntries(Object.keys(Ut({base:ye})).map(t=>[t,`var(--md-token-${t})`])),kn={name:gt,colors:{"editor.background":"transparent","editor.foreground":ye.foreground},tokenColors:[...bn({base:ye,tokens:vn}),{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 ze=!1;const Cn=()=>{ze||(ze=!0,wn(gt,()=>Promise.resolve(kn)))},T=t=>Number.isFinite(t)&&t>0,He=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 T(n)?n:null},Re=(t,e,n)=>Math.min(n,Math.max(e,t)),En=6,Ve=1.25,Sn=1.0015,Ln=.5,Mn=12,Ke=3,Nn=400,se='[data-markdown="mermaid-block"]',F=t=>t.querySelector(se)!==null,Rn=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(En));return Object.is(n,-0)?"0":String(n)}).join(" "),Tn=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(e?.length===4){const[s,o,i,a]=e;if(Number.isFinite(s)&&Number.isFinite(o)&&T(i)&&T(a))return{x:s,y:o,width:i,height:a}}const n=He(t.width),r=He(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},_n=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)},xn=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(s=>s!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,_n(n)].join(":")},bt=(t,e)=>{if(!T(e.width)||!T(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 s=t.height*r;return{x:t.x-(s-t.width)/2,y:t.y,width:s,height:t.height}},Pn=({currentBox:t,viewport:e,delta:n})=>!T(e.width)||!T(e.height)||!T(t.width)||!T(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},In=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>Ke*Ke},Fn=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:s,minScale:o,maxScale:i})=>{if(!T(n.width)||!T(n.height)||!T(s)||!T(t.width)||!T(t.height)||!T(e.width)||!T(e.height)||!T(o)||!T(i))return t;const a=Math.min(o,i),l=Math.max(o,i),c=bt(e,n),u=c.width/t.width,f=Re(u*s,a,l),m=c.width/f,g=m/(t.width/t.height),y=Re(r.x/n.width,0,1),v=Re(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,j=new Set,ie=new Set;let K=null,ne=null,Q=null;const Dn=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),wt=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return xn({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}},On=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},Wn=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),yt=t=>{const e=t.map(n=>G(n.viewport));t.forEach((n,r)=>{const s=e[r];s&&n.fitToViewport(s)})},At=()=>{Q!==null||j.size===0||(Q=window.requestAnimationFrame(()=>{Q=null,yt(Array.from(j))}))},qn=()=>{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},Bn=t=>{if(j.has(t))return;const e=j.size===0;j.add(t),Fe.set(t.viewport,t),qn()?.observe(t.viewport),e&&window.addEventListener("resize",At)},$n=t=>{j.delete(t)&&(K?.unobserve(t.viewport),Fe.delete(t.viewport),!(j.size>0)&&(K?.disconnect(),K=null,window.removeEventListener("resize",At),Q!==null&&(window.cancelAnimationFrame(Q),Q=null)))},zn=t=>{const e=Dn(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=Tn({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let s=r,o=null,i=null,a=null,l=null;const c=d=>{s=d,n.setAttribute("viewBox",Rn(d)),n.removeAttribute("width"),n.removeAttribute("height")},u=d=>{c(bt(r,d))},f=()=>{u(G(e))},m=(d,b)=>{c(Fn({currentBox:s,contentBox:r,viewport:G(e),pointer:d,zoomFactor:b,minScale:Ln,maxScale:Mn}))},g=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},Ve)},y=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},1/Ve)},v=d=>{!d.ctrlKey&&!d.metaKey||(d.preventDefault(),d.stopPropagation(),m(On(d,e),Math.pow(Sn,-d.deltaY)))},S=d=>{d.button!==0||Wn(d.target)||(o=d.pointerId,i={x:d.clientX,y:d.clientY},a=i,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(Pn({currentBox:s,viewport:G(e),delta:{x:b.x-a.x,y:b.y-a.y}})),a=b,i&&In(i,b)&&t.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault()},h=d=>{o===d.pointerId&&(e.releasePointerCapture?.(d.pointerId),o=null,i=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},Nn)))};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:()=>{$n(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},vt=t=>{for(const[e,n]of t.controllers){const r=wt(e);(!t.container.contains(e)||r!==t.signatures.get(e))&&(n.cleanup(),t.controllers.delete(e),t.signatures.delete(e))}},Hn=t=>{if(t.disposed)return[];const e=[];for(const n of Array.from(t.container.querySelectorAll(se))){if(t.controllers.has(n)||n.querySelector('[data-markdown="mermaid"] svg')===null)continue;const r=zn(n);r&&(t.controllers.set(n,r),t.signatures.set(n,wt(n)),Ae.set(n,r),e.push(r))}return e},kt=()=>{const t=Array.from(ie);ie.clear();const e=[];for(const n of t)n.disposed||(vt(n),e.push(...Hn(n)));yt(e);for(const n of e)Bn(n)},Vn=()=>{ne===null&&(ne=window.requestAnimationFrame(()=>{ne=null,ne=window.requestAnimationFrame(()=>{ne=null,kt()})}))},Kn=t=>{t.disposed||(vt(t),ie.add(t),Vn())},jn=t=>{if(!(t instanceof HTMLElement))return null;const e=Ae.get(t);if(e)return e;for(const n of ie)if(n.container.contains(t))return kt(),Ae.get(t)??null;return null},Un=t=>{const e={container:t,controllers:new Map,signatures:new Map,disposed:!1},n=()=>Kn(e),r=()=>{e.disposed=!0,ie.delete(e);for(const s of e.controllers.values())s.cleanup();e.controllers.clear(),e.signatures.clear()};return n(),{refresh:n,cleanup:r}},Zn={copy:"file-copy",check:"check",download:"download",zoomIn:"add",zoomOut:"subtract",fit:"refresh",textWrap:"text-wrap",image:"file-image",disclosure:"arrow-right-s"},Ct="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=Zn[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 s=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");s.setAttribute("href",`#oc-${n}`),r.appendChild(s),t.replaceChildren(r)},Xn=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)}},Gn=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=Ct,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]"),s=t.querySelector("pre"),o=t.querySelector("pre code"),i=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),s?.classList.toggle("whitespace-pre-wrap",e),s?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),s&&(s.style.whiteSpace=e?"pre-wrap":"pre",s.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(i))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")}},St=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
|
-
`),s=r?n.slice(0,-1).split(`
|
|
3
|
-
`):n.split(`
|
|
4
|
-
`),o=s.length>0?s:[""],i=Array.from(e.children).filter(c=>c.classList.contains("line"));r&&i.length===o.length+1&&i.at(-1)?.textContent===""&&i.pop();const a=i.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=i[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)},Lt=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},je=(t,e,n)=>{const r=t.querySelectorAll('[data-component="markdown-code"]');for(const s of Array.from(r)){const o=s.querySelector("pre");o&&St(o),Et(s,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)},Yn=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")},Jn=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const s=r.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],i=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=i;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",s.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",""):St(r),g.appendChild(r),a.appendChild(l),a.appendChild(g),Et(a,e.codeBlockLineWrap,e.labels)}},Ze=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const s=t.querySelectorAll("tbody tr");for(const o of Array.from(s)){const i=Array.from(o.querySelectorAll("td")).map(a=>(a.textContent??"").trim());i.length>0&&n.push(i)}return{headers:e,rows:n}},Qn=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Xe=({headers:t,rows:e})=>[t,...e].map(n=>n.map(Qn).join(",")).join(`
|
|
8
|
-
`),er=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
|
|
9
|
-
`),Ge=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,s=e.map(o=>`| ${o.join(" | ")} |`).join(`
|
|
10
|
-
`);return`${n}
|
|
11
|
-
${r}
|
|
12
|
-
${s}`},Ye=(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 s=document.createElement("button");s.type="button",s.className=`w-full text-left ${Yt}`,s.setAttribute("data-md-action",`${t}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},tr=120,nr=320,Ie="data-md-table-layout",rr=(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 i=document.createElement("div");i.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(Ye("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(Ye("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),i.appendChild(a),i.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(i),o.appendChild(c)}},or=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 i=f=>Array.from(f.children).filter(m=>m.tagName==="TH"||m.tagName==="TD"),a=Array.from(o.querySelectorAll("tbody tr")),l=a.some(f=>i(f).length>0)?a:Array.from(o.querySelectorAll("thead tr")),c=Math.max(0,...Array.from(o.querySelectorAll("tr")).map(f=>i(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=i(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 s=r.map(({table:o,columnProbes:i})=>({table:o,widths:i.map(a=>Math.min(nr,Math.max(tr,Math.ceil(a.getBoundingClientRect().width))))}));n.remove();for(const{table:o,widths:i}of s){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 i){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=`${i.reduce((u,f)=>u+f,0)}px`,o.setAttribute(Ie,"fixed")}},sr=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),i=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",i.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",i.svg),m.innerHTML=i.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=i.ascii||o,l.appendChild(f),e.mermaidControls.copy){const m=B("copy",e.labels.copyDiagram,"mermaid-copy");m.setAttribute("data-md-source",i.ascii||o),c.appendChild(m)}}a.appendChild(l),a.appendChild(c);const u=s.parentElement;u&&u.replaceChild(a,s)}},ir=(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 s=r.getAttribute("href")??"";if(!lt(s))continue;r.setAttribute("data-md-link-decorated","true");const o=Zt(s);if(o){const i=document.createElement("span");i.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",()=>i.remove(),{once:!0}),i.appendChild(a),r.parentNode?.insertBefore(i,r)}if(e.onPreviewLoopback&&Xt(s)){const i=document.createElement("button");i.type="button",i.className=`ml-1 align-middle ${Ct}`,i.setAttribute("data-md-action","preview-loopback"),i.setAttribute("data-md-url",s),i.setAttribute("title",e.labels.previewTitle),i.setAttribute("aria-label",e.labels.previewLabel),ee(i,"download"),r.parentNode?.insertBefore(i,r.nextSibling)}}},pe=(t,e)=>{Gn(t),Xn(t),Yn(t),sr(t,e),Jn(t,e),rr(t,e.labels),ir(t,e)},Je=(t,e,n)=>{const r=new Blob([e],{type:n}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)},fe=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},Qe=t=>(t.nodeType===1?t:t.parentElement)?.closest("pre code[data-md-code-lines]")??null,ar=t=>{const e=Qe(t.startContainer);return!e||e!==Qe(t.endContainer)?null:t.toString()},he=new WeakMap,lr=t=>{let e=he.get(t);if(!e){const n=()=>{const o=t.getSelection();return!o||o.rangeCount!==1||o.isCollapsed?null:ar(o.getRangeAt(0))},r=o=>{if(!o.clipboardData)return;const i=n();i!==null&&(o.preventDefault(),o.stopPropagation(),o.clipboardData.setData("text/plain",i))},s=o=>{const i=n();i!==null&&(o.preventDefault(),we(i))};e={registrations:0,handler:r,menuHandler:s},he.set(t,e),t.addEventListener("copy",r,!0),t.defaultView?.addEventListener("openchamber:copy",s)}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)))}},cr=(t,e)=>{const n=lr(t.ownerDocument),r=s=>{const o=s.target;if(!(o instanceof Element))return;const i=o.closest("[data-md-action]");if(!i){fe(t);return}const a=i.getAttribute("data-md-action")??"";if(a==="copy-code"){const l=i.closest('[data-component="markdown-code"]')?.querySelector("code"),c=l?Lt(l):"";c&&(i.setAttribute("data-md-copy-pending",""),we(c).then(()=>Ue(i,e.labels.copied,"copy",e.labels.copy)).finally(()=>i.removeAttribute("data-md-copy-pending")));return}if(a==="toggle-code-wrap"){s.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(a==="table-copy-toggle"||a==="table-download-toggle"){s.preventDefault();const l=i.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=i.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const u=Ze(c),f=l==="csv"?Xe(u):l==="tsv"?er(u):Ge(u);we(f)}fe(t);return}if(a.startsWith("table-download-")){const l=a.replace("table-download-",""),c=i.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const u=Ze(c),f=l==="csv"?Xe(u):Ge(u);Je(l==="csv"?"table.csv":"table.md",f,l==="csv"?"text/csv":"text/markdown")}fe(t);return}if(a==="mermaid-copy"){const l=i.getAttribute("data-md-source")??"";l&&we(l).then(()=>Ue(i,e.labels.copied,"copy",e.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){s.preventDefault();const l=i.closest('[data-markdown="mermaid-block"]'),c=jn(l);a==="mermaid-zoom-in"?c?.zoomIn():a==="mermaid-zoom-out"?c?.zoomOut():c?.fit();return}if(a==="mermaid-download"){const l=i.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),c=l?.getAttribute("data-md-original-svg")??l?.innerHTML??"";c&&Je("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){s.preventDefault();const l=i.getAttribute("data-md-url")??"";l&&e.onPreviewLoopback?.(l);return}};return t.addEventListener("click",r),()=>{n(),t.removeEventListener("click",r)}},et=(t,e,n)=>{let r=0;for(const o of t){const i=r+o.data.length;if(e<i||e===i&&n==="left")return{node:o,offset:Math.max(0,e-r)};r=i}const s=t.at(-1);return s?{node:s,offset:s.data.length}:null},dr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),tt=Array.from(dr).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Mt=t=>Jt(t),ur=t=>Qt(t),mr=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 s=tt.length>0?e.match(new RegExp(`^(.*(?:/|^)(${tt})):.*$`,"i")):null;return s&&(e=s[1]??e),ve(e)},Nt=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 s=r.match(/^(.*?):(\d+)-(\d+)$/);if(s){const l=ge(s[1]??""),c=Number.parseInt(s[2]??"",10),u=Number.parseInt(s[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 i=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(i){const l=ge(i[1]??""),c=Number.parseInt(i[2]??"",10),u=i[3]?Number.parseInt(i[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},Te=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,pr=4,fr=1e3,hr=200,z=new Map;let be=0;const nt=[],gr=()=>ft()?hr:fr,br=(t,e)=>`${t}\0${e}`,wr=(t,e)=>{const n=Mt(t);if(!n)return Promise.resolve(!1);const r=br(e,n),s=z.get(r);if(s)return z.delete(r),z.set(r,s),s;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),nt.shift()?.()})};if(be<pr){l();return}nt.push(l)}),i=gr();for(;z.size>=i;){const a=z.keys().next().value;if(typeof a!="string")break;z.delete(a)}return z.set(r,o),o},yr={maxSessions:8,maxEntriesPerSession:4};class Ar{maxSessions;maxEntriesPerSession;sessions=new Map;constructor(e=yr){this.maxSessions=Math.max(1,e.maxSessions),this.maxEntriesPerSession=Math.max(1,e.maxEntriesPerSession)}store(e){const n=e.scope,r=e.id;let s=this.sessions.get(n);for(s===void 0?(s=new Map,this.sessions.set(n,s)):this.refreshSession(n,s),s.delete(r),s.set(r,e);s.size>this.maxEntriesPerSession;)this.removeOldestEntry(s);for(;this.sessions.size>this.maxSessions;)this.removeOldestSession()}take(e){const n=e.scope,r=this.sessions.get(n);if(!r)return null;const s=e.id;this.refreshSession(n,r);const o=r.get(s);return o===void 0||o.locale!==e.locale||o.directory!==e.directory?null:(r.delete(s),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 rt=new Ar,Rt=()=>{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 s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=qe(!0),t[1]=s):s=t[1];const o=s;let i;return t[2]!==e?.currentTheme?(i=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=i):i=t[3],i},Tt=t=>{const e=ae.c(4),{containerRef:n,enabled:r}=t;let s,o;e[0]!==n||e[1]!==r?(s=()=>{const i=n.current;if(i)return An(i,{allowExternalHttp:r!==!1,openAppLink:Br,openExternalHttp:$r})},o=[n,r],e[0]=n,e[1]=r,e[2]=s,e[3]=o):(s=e[2],o=e[3]),C.useEffect(s,o)},te={download:!0,copy:!0,showPanZoomControls:!0},_t=!0,vr=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},ot='[data-openchamber-file-link="true"]',xt="data-openchamber-block-path-token",Pt=`[${xt}]`,J="data-openchamber-block-paths-scanned",kr=2e5,Cr=80,Er=40,st=160,Sr=()=>ft()?Er:Cr,Lr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),It=t=>Mt(t),Mr=t=>ur(t),Nr=(t,e)=>on(t,e),Rr=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},Ft=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=It(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return Lr.has(r)||r.startsWith(".")&&r.length>1?!0:Rr(e)},Dt=t=>{const e=Nt(t);return e?Ft(e.path):!1},Tr=t=>{const e=t.querySelectorAll(Pt);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?mr(e):null;if(n)return n;if(e&&Dt(e))return e}return(t.textContent||"").trim()},_r=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>kr){r.setAttribute(J,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let i=s.nextNode();for(;i;){const u=i;u.parentElement?.closest("[data-md-code-line-number]")||o.push(u),i=s.nextNode()}const a=Lt(r);if(!a.includes(".")){r.setAttribute(J,"true");continue}Te.lastIndex=0;const l=[];let c=Te.exec(a);for(;c;){const u=c[0];u&&Dt(u)&&l.push({start:c.index,end:c.index+u.length,raw:u}),c=Te.exec(a)}for(const{start:u,end:f,raw:m}of l.reverse()){const g=et(o,u,"right"),y=et(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(xt,"true"),S.textContent=m,v.deleteContents(),v.insertNode(S)}r.setAttribute(J,"true")}},xe=(t,e)=>{const n=Nt(t);if(!n||!Ft(n.path))return null;const r=Mr(n.path)?It(n.path):Nr(e,n.path);return r?{...n,resolvedPath:r}:null},xr=(t,e)=>t||rn(t,e),Ot=({containerRef:t,effectiveDirectory:e,editor:n,preferRuntimeEditor:r,enabled:s})=>{const o=C.useRef(null);C.useEffect(()=>{const i=t.current;if(!i||s&&!e)return;let a=!1;const l=Sr(),c=s&&!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=i.querySelectorAll(ot);for(const b of Array.from(d))u(b);Tr(i)};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&&_r(i);const d=i.querySelectorAll(`[data-markdown="inline-code"], a, ${Pt}`);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,(pn()&&fn()&&!Be(M.resolvedPath,e)?Promise.resolve(!0):wr(M.resolvedPath,e)).then(x=>{if(a||!x||!i.contains(w))return;const L=_e(w),R=xe(L,e);!R||R.resolvedPath!==M.resolvedPath||(w.setAttribute("data-openchamber-file-link","true"),w.setAttribute("data-openchamber-file-ref",L),w.setAttribute("data-openchamber-file-path",R.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=xr(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}Be(w.resolvedPath,e)||await nn(w.resolvedPath,e);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(ot);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(st);let h=0;const k=new MutationObserver(()=>{h>0||m(st)});return k.observe(i,{childList:!0,subtree:!0}),i.addEventListener("click",S),i.addEventListener("keydown",p),()=>{a=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,k.disconnect(),i.removeEventListener("click",S),i.removeEventListener("keydown",p)}},[t,n,e,r,s])},Wt=t=>{const e=ae.c(7),{containerRef:n,onShowPopup:r,enableFullscreen:s,enablePanZoom:o,allowMermaidWheelEvents:i}=t;let a,l;e[0]!==i||e[1]!==n||e[2]!==s||e[3]!==o||e[4]!==r?(a=()=>{const c=n.current;if(!c)return;const u=m=>{if(!s||!r)return;const g=m.target;if(!(g instanceof Element)||g.closest('button, a, [role="button"]'))return;const y=g.closest(se);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(se)).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(i||(m.ctrlKey||m.metaKey)&&o)return;const g=m.target;!(g instanceof Element)||!g.closest(se)||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=[i,n,s,o,r],e[0]=i,e[1]=n,e[2]=s,e[3]=o,e[4]=r,e[5]=a,e[6]=l):(a=e[5],l=e[6]),C.useEffect(a,l)},H=new Map,Pr=100,V="data-md-decoration-id",Ir=(t,e,n)=>{const r=t.children;if(r.length!==e.length)return!1;for(let s=0;s<e.length;s+=1){const o=r[s];if(!o||o.getAttribute("data-md-id")!==e[s]?.id||o.getAttribute(V)!==n)return!1}return!0},it=new WeakMap;let at=0;const Fr=2e5,Pe=t=>{const e=it.get(t);if(e)return e;const n=`decoration-${at}`;return at+=1,it.set(t,n),n},Dr=(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>Pr){const s=H.keys().next().value;s&&H.delete(s)}return r},Or=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"}),qt=(t,e,n,r=te)=>{const{t:s}=mt(),o=C.useMemo(()=>({copy:s("markdownRenderer.code.actions.copyTitle"),copied:s("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:s("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:s("markdownRenderer.code.actions.disableWrapTitle"),copyTable:s("markdownRenderer.table.actions.copyTitle"),downloadTable:s("markdownRenderer.table.actions.downloadTitle"),copyDiagram:s("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:s("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:s("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:s("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:s("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:s("terminalView.preview.open"),previewTitle:s("terminalView.preview.openTitle")}),[s]),i=Y(c=>c.codeBlockLineWrap),a=Y(c=>c.setCodeBlockLineWrap),l=C.useCallback(()=>{a(!Y.getState().codeBlockLineWrap)},[a]);return C.useMemo(()=>{const c=Or(t),u=Y.getState().mermaidRenderingMode,f=t.metadata?.id??"theme";return{labels:o,mermaidControls:r,codeBlockLineWrap:i,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:l,renderMermaid:g=>Dr(`${f}:${u}:${g}`,()=>{try{return u==="ascii"?{ascii:Vt(g)}:{svg:Kt(g,c)}}catch{return{}}}),onPreviewLoopback:n}},[t,o,r,i,e,l,n])},Bt=({containerRef:t,text:e,streaming:n,imageMode:r="inline",syntaxVars:s,ctx:o,domCacheKey:i,tableLayoutSettled:a})=>{C.useEffect(()=>{Cn()},[]);const l=C.useRef(null),c=C.useRef(0),u=C.useRef(null),f=C.useContext(tn),m=C.useRef(null),g=C.useCallback(()=>{m.current?.(),m.current=null},[]);C.useEffect(()=>g,[g]);const y=C.useRef(null),v=C.useCallback(()=>{const p=t.current;if(p){if(!l.current){if(!F(p))return;l.current=Un(p);return}l.current.refresh()}},[t]),S=C.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&&or(b)});u.current=k},[t,a]);C.useEffect(()=>()=>{const p=u.current;p!==null&&(window.cancelAnimationFrame(p),u.current=null)},[]),C.useLayoutEffect(()=>{c.current+=1,y.current=null},[o,r,n,e]),C.useLayoutEffect(()=>{if(!i)return;const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(!h||h.childNodes.length>0)return;const k=rt.take(i);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(s))h.style.setProperty(b,w);je(h,o.codeBlockLineWrap,o.labels),y.current={key:i,copiedLabel:o.labels.copied},oe("ui.markdown_renderer.dom_cache.hit")}},[t,o,i,s,e.length]),C.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)),rt.store({...k.key,fragment:A}),oe("ui.markdown_renderer.dom_cache.capture")}},[t]),C.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:$e(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=hn(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]),C.useEffect(()=>()=>{l.current?.cleanup(),l.current=null},[]),C.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=$e(e,r);if(w&&Ir(h,w,b)){y.current=i?{key:i,copiedLabel:o.labels.copied}:null,oe("ui.markdown_renderer.settled_paint.reused"),S(),g();return}}return gn(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,R)=>{let E=A[R],P=!1;if(E||(E=document.createElement("div"),E.setAttribute("data-md-block",""),E.style.display="contents",h.appendChild(E),P=!0),E.getAttribute("data-md-id")===L.id){if(E.getAttribute(V)!==b){const I=F(E);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),E.replaceWith(N),(I||F(N))&&v()}!l.current&&F(E)&&v();return}const _=document.createElement("div");if(_.innerHTML=L.html,pe(_,o),P&&n&&R>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(E),W=F(_);Ht(E,_,{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))}),E.setAttribute("data-md-id",L.id),E.setAttribute(V,b),(O||W||F(E))&&v()});const $=F(h);let x=!1;for(let L=A.length-1;L>=w.length;L-=1){const R=A[L];R&&F(R)&&(x=!0),R?.remove()}(x||A.length>w.length&&$)&&v(),M.length>0&&h.querySelectorAll("details[data-md-details]").forEach((L,R)=>{const E=M[R];E&&E.summary===L.querySelector("summary")?.textContent&&(L.open=E.open)}),y.current=i?{key:i,copiedLabel:o.labels.copied}:null,S(),g()}),()=>{k=!1}},[t,o,i,r,v,g,S,n,e]),C.useEffect(()=>{const p=t.current;if(p)return cr(p,o)},[t,o]),C.useEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;if(h)for(const[k,d]of Object.entries(s))h.style.setProperty(k,d)},[t,s]),C.useEffect(()=>{const p=t.current,h=p?.querySelector("[data-markdown-content]")??p;h&&(o.deferCodeLineNumberSync||je(h,o.codeBlockLineWrap,o.labels))},[t,o.codeBlockLineWrap,o.deferCodeLineNumberSync,o.labels])},$t=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Wr=t=>{const e=ae.c(40),{content:n,part:r,messageId:s,isAnimated:o,skipFadeIn:i,className:a,isStreaming:l,disableStreamAnimation:c,variant:u,onShowPopup:f,enableFileReferences:m}=t,g=o===void 0?!0:o,y=i===void 0?!1:i,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=Rt(),{editor:d,runtime:b}=ct(),w=C.useRef(null),A=dt()??"",M=Y(zr);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:_t,enablePanZoom:te.showPanZoomControls},e[3]=f,e[4]=L):L=e[4],Wt(L);const R=h&&!v;let E;e[5]!==d||e[6]!==A||e[7]!==b.isVSCode||e[8]!==R?(E={containerRef:w,effectiveDirectory:A,editor:d,preferRuntimeEditor:b.isVSCode,enabled:R},e[5]=d,e[6]=A,e[7]=b.isVSCode,e[8]=R,e[9]=E):E=e[9],Ot(E);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?(_=ut(k),e[11]=k,e[12]=_):_=e[12];const O=_,W=qt(k,x,A?$:void 0,te),{locale:I}=mt(),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 zt=le,De=ke?.sessionID,Oe=ke?.messageID,We=ke?.id;let Ce;e:{if(v||!De||!Oe||!We||n.length===0||n.length>Fr){Ce=null;break e}const q=`${zt}\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],Ce=me}const Ee=Ce,Se=`markdown-${r?.id?`part-${r.id}`:`message-${s}`}`,Le=!v;let ce;e[19]!==n||e[20]!==W||e[21]!==Ee||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:Ee,tableLayoutSettled:Le},e[19]=n,e[20]=W,e[21]=Ee,e[22]=N,e[23]=x,e[24]=O,e[25]=Le,e[26]=ce):ce=e[26],Bt(ce);let U;e[27]!==a?(U=pt("break-words w-full min-w-0",a),e[27]=a,e[28]=U):U=e[28];let Z;e[29]!==p?(Z=$t(p),e[29]=p,e[30]=Z):Z=e[30];let X;e[31]!==Z?(X=re.jsx("div",{className:Z,"data-markdown-content":!0}),e[31]=Z,e[32]=X):X=e[32];let de;e[33]!==U||e[34]!==X?(de=re.jsx("div",{className:U,ref:w,children:X}),e[33]=U,e[34]=X,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},js=C.memo(Wr,(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),qr=t=>{const e=ae.c(29),{content:n,className:r,variant:s,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:a,mermaidControls:l,allowMermaidWheelEvents:c,enableFileReferences:u}=t,f=s===void 0?"assistant":s,m=i===void 0?!1:i,g=l===void 0?te:l,y=c===void 0?!1:c,v=u===void 0?!0:u,{editor:S,runtime:p}=ct(),h=Rt(),k=C.useRef(null),d=dt()??"";let b;e[0]!==n||e[1]!==m?(b=m?vr(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:_t,enablePanZoom:g.showPanZoomControls,allowMermaidWheelEvents:y},e[3]=y,e[4]=g.showPanZoomControls,e[5]=a,e[6]=A):A=e[6],Wt(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],Ot(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=ut(h),e[14]=h,e[15]=x):x=e[15];const L=x,R=qt(h,!1,void 0,g);let E;e[16]!==R||e[17]!==w||e[18]!==L?(E={containerRef:k,text:w,streaming:!1,syntaxVars:L,ctx:R,tableLayoutSettled:!0},e[16]=R,e[17]=w,e[18]=L,e[19]=E):E=e[19],Bt(E);let P;e[20]!==r?(P=pt("break-words w-full min-w-0",r),e[20]=r,e[21]=P):P=e[21];let _;e[22]!==f?(_=$t(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},Us=C.memo(qr,(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 Br(t){an(t)}function $r(t){ln(t)}function zr(t){return t.openContextPreview}export{js as MarkdownRenderer,Us as SimpleMarkdownRenderer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as D,j as e,R as i,f as G}from"./vendor-react-BUCujlKS.js";import{P as W,cD as je,cA as le,cw as z,E as B,ay as O,dP as ke,aE as ue,X as me,h as X,aJ as pe,t as he,U as ne}from"./index-DLHQogv8.js";import{f as J,B as L,W as V,g as xe,h as re,I as A}from"./useAppFontEffects-BItUWdo4.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.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-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-BDyxuqK4.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";function Ce(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:r="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:d,showInstancePicker:h=!1}){const{t:o}=J(),[w,S]=D.useState(s),[j,U]=D.useState(r),[K,x]=D.useState("idle"),[u,k]=D.useState(null),[C,g]=D.useState(""),[T,I]=D.useState([]),[y,f]=D.useState(()=>h?"instances":"add"),[b,R]=D.useState("");D.useEffect(()=>{h&&W().then(p=>I(p.hosts)).catch(p=>{g(p instanceof Error?p.message:String(p))})},[h]);const N=je(w),E=N?.persistedUrl??null,F=D.useCallback(p=>{S(p.target.value),x("idle"),k(null),g("")},[]),H=D.useCallback(p=>{U(p.target.value)},[]),c=D.useCallback(async()=>{if(E){x("testing"),k(null),g("");try{const p=await le(E);k(p),x(p.status==="ok"||p.status==="update-recommended"?"success":"error")}catch(p){g(p instanceof Error?p.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[E,o]),_=D.useCallback(async()=>{if(!N)return;const p=N.persistedUrl;x("testing"),k(null),g("");try{const P=await le(p);if(k(P),oe(P.status)){x("error");return}const Z=await W(),ve=j.trim()||p,ee=Z.hosts.find(q=>q.url===p),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:ve,url:p,apiUrl:p},we=ee?Z.hosts.map(q=>q.id===te?ie:q):[...Z.hosts,ie];if(await z({hosts:we,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),N.redeemUrl){window.location.assign(N.redeemUrl);return}B()&&await O()}catch(P){g(P instanceof Error?P.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[N,j,l,o]),$=D.useCallback(async p=>{const P=await W();await z({hosts:P.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await O()},[]),m=D.useCallback(async()=>{x("testing"),g("");try{const p=await W(),P=await ke(b,p.hosts);await z({hosts:P.hosts,defaultHostId:P.hostId,initialHostChoiceCompleted:!0}),await O()}catch(p){g(p instanceof Error&&p.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[b,o]),v=K==="testing",M=E!==null&&!v,Q=E!==null&&!v&&!oe(u?.status??null),Y=Ce(u?.status??null),be=u?.status==="ok",ge=u?.status==="update-recommended",ye=u?.status==="auth",ae=oe(u?.status??null);return h&&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:T.length===0?e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("settings.remoteInstances.direct.state.empty")}):T.map(p=>e.jsx(L,{variant:"outline",className:"w-full justify-start",onClick:()=>{$(p.id)},children:e.jsx("span",{className:"min-w-0 truncate",children:p.label})},p.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",className:"flex-1",onClick:()=>f("import"),children:o("settings.remoteInstances.direct.import.action")}),e.jsx(L,{className:"flex-1",onClick:()=>f("add"),children:o("settings.remoteInstances.direct.actions.add")})]})]})}):h&&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(L,{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(V,{value:b,onChange:p=>R(p.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(L,{onClick:()=>{m()},disabled:v||!b.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||h)&&e.jsx("div",{className:"flex items-center",children:e.jsx(L,{variant:"ghost",onClick:h?()=>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(V,{id:"remote-url",type:"url",value:w,onChange:F,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(V,{id:"remote-label",type:"text",value:j,onChange:H,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),u&&be&&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:u.latencyMs})}),u&&ye&&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")}),u&&ge&&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}),u&&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:u.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(L,{variant:"outline",onClick:c,disabled:!M,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(L,{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(L,{variant:"outline",size:"sm",onClick:a,className:"flex-1",children:o("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&d&&e.jsx(L,{variant:"outline",size:"sm",onClick:d,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Ne="curl -fsSL https://opencode.ai/install | bash",Se="https://opencode.ai/docs",ce=2500;function Re(a){const t=G.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",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/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let d;return t[2]!==r||t[3]!==s?(d=e.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:r,"aria-label":r,children:l})]}),t[2]=r,t[3]=s,t[4]=d):d=t[4],d}function Le({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=J(),[r,n]=i.useState(!1),[l,d]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(""),[K,x]=i.useState("unknown"),[u,k]=i.useState(()=>t?"local":"remote"),[C,g]=i.useState(!1),[T,I]=i.useState(!1);i.useEffect(()=>{d(B())},[]),i.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const m=navigator.userAgent||"";/Windows/i.test(m)?x("windows"):/Macintosh|Mac OS X/i.test(m)?x("macos"):/Linux/i.test(m)?x("linux"):x("unknown")},[]),i.useEffect(()=>{let m=!1;return(async()=>{try{const v=await ue();if(!v||m)return;const M=v.opencodeBinary??"";M&&U(M)}catch{}})(),()=>{m=!0}},[]);const y=i.useCallback(async m=>{const v=m.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||m.button===0&&l&&await me()},[l]),f=i.useCallback(async()=>{try{const m=await X("/health");if(!m.ok)return!1;const v=await m.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async m=>{if(!l)return;const v=await W();await z({...v,...m==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),R=i.useCallback(async()=>{l&&await b("local"),a?.()},[l,a,b]);i.useEffect(()=>{if(!t||u!=="local")return;let m=!1,v=null;const M=async()=>{if(!m){try{const Q=await f();if(m)return;if(Q){await R();return}}catch{}m||(v=setTimeout(M,ce))}};return v=setTimeout(M,ce),()=>{m=!0,v&&clearTimeout(v)}},[u,f,R,t]);const N=i.useCallback(async()=>{S(!0);try{await f()&&await R()}finally{S(!1)}},[f,R]),E=i.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const m=await pe();m.success&&m.path&&m.path.trim().length>0&&U(m.path.trim())}catch{}},[l]),F=i.useCallback(async()=>{o(!0);try{if(await he({opencodeBinary:j.trim()}),l){await b("local"),await O();return}await X("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,b]),H=i.useCallback(async()=>{const m=await xe(Ne);m.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",m.error)},[]),c=Se,_=K==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":K==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",$=t&&(!l||u==="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 space-y-7",children:[e.jsxs("header",{className:"text-center space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s("onboarding.chooser.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("onboarding.chooser.description")})]}),l&&t&&e.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",u==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("local"),children:s("onboarding.chooser.tabs.localInstall")}),e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",u==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("remote"),children:s("onboarding.chooser.tabs.connectRemote")})]}),l&&u==="remote"?e.jsx("div",{className:"app-region-no-drag",children:e.jsx(fe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,$&&e.jsxs("div",{className:"space-y-4",children:[K==="windows"&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 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-sm text-muted-foreground text-center leading-relaxed",children:s("onboarding.localSetup.intro")}),e.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:r?e.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(A,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Re,{onCopy:H,copyTitle:s("onboarding.common.copyToClipboard")})}),e.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[s(K==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),e.jsx("button",{type:"button",onClick:N,disabled:w,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:s(w?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),e.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 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.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-foreground leading-tight",children:s("onboarding.localSetup.status.watching")}),e.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:s("onboarding.localSetup.status.autoContinue")})]})]}),e.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:C,onToggle:m=>g(m.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.advanced.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"pb-4 space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{value:j,onChange:m=>U(m.target.value),placeholder:_,disabled:h,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",size:"sm",onClick:E,disabled:h||!l,children:s("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",size:"sm",onClick:F,disabled:h||!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 rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:T,onToggle:m=>I(m.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.troubleshoot.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:K==="windows"?e.jsx(e.Fragment,{children: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")})]})})]})]})]})})}const Ue="curl -fsSL https://opencode.ai/install | bash",Te="https://opencode.ai/docs";function Ke(a){const t=G.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{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/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let d;return t[2]!==r||t[3]!==s?(d=e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:r,children:l})]}),t[2]=r,t[3]=s,t[4]=d):d=t[4],d}const Ie=3e4;function De({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:r}){const{t:n}=J(),[l,d]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(!1),[K,x]=i.useState(!1),[u,k]=i.useState(null),[C,g]=i.useState(""),[T,I]=i.useState("unknown");i.useEffect(()=>{const c=setTimeout(()=>o(!0),Ie);return()=>clearTimeout(c)},[]),i.useEffect(()=>{S(B())},[]),i.useEffect(()=>{if(typeof navigator>"u"){I("unknown");return}const c=navigator.userAgent||"";if(/Windows/i.test(c)){I("windows");return}if(/Macintosh|Mac OS X/i.test(c)){I("macos");return}if(/Linux/i.test(c)){I("linux");return}I("unknown")},[]),i.useEffect(()=>{let c=!1;return(async()=>{try{const _=await ue();if(!_||c)return;const $=_.opencodeBinary??"";$&&g($)}catch{}})(),()=>{c=!0}},[]);const y=i.useCallback(async c=>{c.target.closest("button, a, input, select, textarea, code")||c.button===0&&w&&await me()},[w]),f=i.useCallback(async()=>{try{const c=await X("/health");if(!c.ok)return!1;const _=await c.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const c=await pe();c.success&&c.path&&c.path.trim().length>0&&g(c.path.trim())}catch{}},[w]),R=i.useCallback(async()=>{U(!0);try{if(await he({opencodeBinary:C.trim()}),w){await O();return}await X("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[w,C]),N=i.useCallback(async()=>{const c=await xe(Ue);c.ok?(d(!0),setTimeout(()=>d(!1),2e3)):console.error("Failed to copy:",c.error)},[]),E=i.useCallback(async()=>{x(!0),k(null);try{await f()?t?.():k(n("onboarding.localSetup.errors.cliNotReady"))}catch(c){k(c instanceof Error?c.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{x(!1)}},[f,t,n]),F=Te,H=T==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":T==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/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(L,{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")})]}),T==="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(A,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(Ke,{onCopy:N,copyTitle:n("onboarding.common.copyToClipboard")})})}),e.jsxs("a",{href:F,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(T==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),u&&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:u}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(L,{type:"button",onClick:E,disabled:K,className:"w-full max-w-xs",size:"lg",children:n(K?"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(V,{value:C,onChange:c=>g(c.target.value),placeholder:H,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",onClick:b,disabled:j||!w,children:n("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",onClick:R,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&&r&&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(L,{variant:"link",onClick:r,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),h&&e.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:T==="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 ne(a.trim());if(t)return ne(t)}function _e(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 r=se(t,s);return{title:"Remote Server Unreachable",description:`Could not connect to "${r||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:r?{host:r}: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 r=se(t,s);return{title:"Incompatible Server",description:`The server at "${r||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:r?{host:r}: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 r=se(t,s);return{title:"Server Update Required",description:`The OpenChamber server at "${r||"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:r?{host:r}: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 r=a;throw new Error(`Unknown recovery variant: ${r}`)}}}function Ee(a){switch(a){case"local":return e.jsx(A,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(A,{name:"server",className:"h-8 w-8"})}}function Ae({variant:a,hostLabel:t,hostUrl:s,onRetry:r,onUseLocal:n,onUseRemote:l,isRetrying:d=!1}){const{t:h}=J(),o=_e(a,t,s),w=o.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",S=i.useMemo(()=>{if(o.descriptionParams?.host)return o.descriptionParams;if(a==="remote-unreachable")return{host:h("onboarding.desktopRecovery.placeholders.remoteServer")};if(a==="remote-wrong-service"||a==="remote-incompatible")return{host:h("onboarding.desktopRecovery.placeholders.unknownServer")}},[o.descriptionParams,h,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:Ee(o.iconKey)})}),e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:h(o.titleKey)}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:h(o.descriptionKey,S)})]}),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:h("onboarding.remoteConnection.field.serverAddress")}),e.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:ne(s)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[o.showRetry&&r&&e.jsxs(L,{onClick:r,disabled:d,className:"w-full",children:[e.jsx(A,{name:"refresh",className:re("h-4 w-4",d&&"animate-spin")}),h(d?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(L,{variant:"outline",onClick:n,disabled:d,className:"flex-1",children:[e.jsx(A,{name:"macbook",className:"h-4 w-4"}),h(o.useLocalLabelKey)]}),o.showUseRemote&&l&&e.jsxs(L,{variant:"outline",onClick:l,disabled:d,className:"flex-1",children:[e.jsx(A,{name:"server",className:"h-4 w-4"}),h(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 Fe(a){const t=G.c(29),{variant:s,hostUrl:r,hostLabel:n,onRetry:l,onChooseRemote:d,showRemoteForm:h,onCloseRemoteForm:o,onSwitchToLocalFromRemote:w,onEnterLocalSetup:S,isRetrying:j,localAvailable:U}=a,K=h===void 0?!1:h,x=j===void 0?!1:j,u=U===void 0?!0:U,k=Pe;let C;t[0]!==l?(C=async()=>{if(B()){await O();return}await X("/api/config/reload",{method:"POST"}),l?.()},t[0]=l,t[1]=C):C=t[1];const g=C;let T;t[2]!==S||t[3]!==s?(T=async()=>{if(de(s,"use-local").kind==="local-setup"){S?.();return}if(await k("local"),B()){await O();return}window.location.reload()},t[2]=S,t[3]=s,t[4]=T):T=t[4];const I=T;let y;t[5]!==d||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&d?.()},t[5]=d,t[6]=s,t[7]=y):y=t[7];const f=y;if(K){const N=s==="remote-wrong-service"?"":r||"",E=s==="remote-wrong-service"?"":n||"";let F;t[8]!==d||t[9]!==o?(F=o||(()=>d?.()),t[8]=d,t[9]=o,t[10]=F):F=t[10];const H=!u;let c;t[11]!==u||t[12]!==S||t[13]!==w?(c=u?w||(()=>{k("local").then(()=>{B()?O():S?.()})}):void 0,t[11]=u,t[12]=S,t[13]=w,t[14]=c):c=t[14];let _;return t[15]!==E||t[16]!==N||t[17]!==F||t[18]!==H||t[19]!==c?(_=e.jsx(fe,{onBack:F,initialUrl:N,initialLabel:E,isRecoveryMode:!0,showInstancePicker:H,onSwitchToLocal:c}),t[15]=E,t[16]=N,t[17]=F,t[18]=H,t[19]=c,t[20]=_):_=t[20],_}const b=u?I:void 0;let R;return t[21]!==g||t[22]!==f||t[23]!==n||t[24]!==r||t[25]!==x||t[26]!==b||t[27]!==s?(R=e.jsx(Ae,{variant:s,hostLabel:n,hostUrl:r,onRetry:g,onUseLocal:b,onUseRemote:f,isRetrying:x}),t[21]=g,t[22]=f,t[23]=n,t[24]=r,t[25]=x,t[26]=b,t[27]=s,t[28]=R):R=t[28],R}async function Pe(a){if(!B())return;const t=await W();await z({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function po(a){const t=G.c(29),{onBack:s,onCliAvailable:r,mode:n,recoveryVariant:l,recoveryHostUrl:d,recoveryHostLabel:h,onEnterLocalSetup:o,localAvailable:w}=a,S=n===void 0?"first-launch":n,j=l===void 0?"missing-default-host":l,U=w===void 0?!0:w,[K,x]=i.useState(!1),[u,k]=i.useState(!1);let C;t[0]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{k(!1),x(!1)},t[0]=C):C=t[0];let g;t[1]!==S||t[2]!==h||t[3]!==d||t[4]!==j?(g=[S,j,d,h],t[1]=S,t[2]=h,t[3]=d,t[4]=j,t[5]=g):g=t[5],i.useEffect(C,g);const T=u?"local-setup":S;if(T==="recovery"){let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=()=>x(!0),t[6]=y):y=t[6];let f,b;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),b=()=>{x(!1),k(!0)},t[7]=f,t[8]=b):(f=t[7],b=t[8]);let R;t[9]!==o?(R=()=>{k(!0),o?.()},t[9]=o,t[10]=R):R=t[10];let N;return t[11]!==U||t[12]!==h||t[13]!==d||t[14]!==j||t[15]!==K||t[16]!==R?(N=e.jsx(Fe,{variant:j,hostUrl:d,hostLabel:h,onChooseRemote:y,showRemoteForm:K,onCloseRemoteForm:f,onSwitchToLocalFromRemote:b,onEnterLocalSetup:R,localAvailable:U}),t[11]=U,t[12]=h,t[13]=d,t[14]=j,t[15]=K,t[16]=R,t[17]=N):N=t[17],N}if(T==="local-setup"){let y;t[18]!==s||t[19]!==u?(y=()=>{u?k(!1):s?.()},t[18]=s,t[19]=u,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 b;return t[22]!==r||t[23]!==u||t[24]!==y?(b=e.jsx(De,{onBack:y,onCliAvailable:r,isFromRecovery:u,onSwitchToRemote:f}),t[22]=r,t[23]=u,t[24]=y,t[25]=b):b=t[25],b}let I;return t[26]!==U||t[27]!==r?(I=e.jsx(Le,{onCliAvailable:r,localAvailable:U}),t[26]=U,t[27]=r,t[28]=I):I=t[28],I}export{po as OnboardingScreen};
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import{R as I,j as M,c as ye,r as l}from"./vendor-react-BUCujlKS.js";import{a as Ke}from"./web-components-D7FinaeH.js";import{f as Ie}from"./computeVirtualFileMetrics-VYnT_A2h.js";import{V as Ye,F as Xe}from"./VirtualizedFileDiff-CZgXWHjU.js";import{V as Je}from"./Virtualizer-D_a8gKmg.js";import{eL as Qe,eM as ze,bg as Ze,c5 as et,h as Ne}from"./useAppFontEffects-BItUWdo4.js";import{I as He,a as tt,u as nt}from"./useInlineCommentController-CkbKsm7m.js";import"./index-DLHQogv8.js";import{ag as rt}from"./runtimeEndpointReset-DhC3REb2.js";import{ensurePierreThemeRegistered as $e,getResolvedShikiTheme as qe}from"./appThemeRegistry-Cf8KitzT.js";const ve=i=>{if(i.type==="new"){const n=Math.min(i.selection.start,i.selection.end),r=Math.max(i.selection.start,i.selection.end);return`new-comment-${i.selection.side??"additions"}-${n}-${r}`}return`draft-${i.draft.id}`},it=i=>{const{drafts:n,editingDraftId:r,selection:a}=i,d=[];for(const w of n){if(!Number.isFinite(w.endLine))continue;const E=Math.max(1,Math.floor(w.endLine)),C=w.side==="original"?"deletions":"additions";d.push({lineNumber:E,side:C,metadata:{type:w.id===r?"edit":"saved",draft:w}})}return a&&!r&&d.push({lineNumber:Math.max(a.start,a.end),side:a.side??"additions",metadata:{type:"new",selection:a}}),d};function ot(i){const n=i.trim();if(!n)return null;if(/^-?\d+(\.\d+)?$/.test(n)){const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}if(n.endsWith("px")){const r=Number.parseFloat(n.slice(0,-2));return Number.isFinite(r)?r:null}return null}function Be(i){if(!(!i||i<=0))return Math.max(200,Math.floor(i))}function st(i){const{diffRootRef:n,drafts:r,selection:a,editingDraftId:d,commentText:w,onTextChange:E,fileLabel:C,onSave:u,onCancel:$,onEdit:z,onDelete:N}=i,[V,O]=I.useState(0),[ee,P]=I.useState(null),H=I.useMemo(()=>!a||d?null:ve({type:"new",selection:a}),[d,a]),te=I.useMemo(()=>{const o=r.map(b=>ve({type:b.id===d?"edit":"saved",draft:b}));return H&&o.push(H),o},[r,d,H]),K=I.useCallback(o=>{const b=n.current;if(!b)return null;const S=b.querySelector("diffs-container");if(!(S instanceof HTMLElement))return null;const k=S.querySelector(`[data-annotation-id="${o}"]`);if(k instanceof HTMLElement)return k;const T=S.shadowRoot;return T?T.querySelector(`[data-annotation-id="${o}"]`):null},[n]);I.useEffect(()=>{if(te.length===0)return;let o=!1,b=0;const S=12,k=()=>{o||te.every(F=>!!K(F))||b>=S||(b+=1,requestAnimationFrame(()=>{o||(O(F=>F+1),k())}))};return k(),()=>{o=!0}},[te,K]),I.useEffect(()=>{const o=n.current;if(!o)return;const b=()=>{const k=getComputedStyle(o),T=ot(k.getPropertyValue("--oc-context-panel-width")),F=o.getBoundingClientRect(),W=T??F.width;P(W>0?W:null)};b();const S=new ResizeObserver(()=>{b()});return S.observe(o),window.addEventListener("resize",b),()=>{S.disconnect(),window.removeEventListener("resize",b)}},[n]);const Y=I.useCallback(o=>{const S=n.current?.getBoundingClientRect(),k=o.closest("[data-annotation-content]"),T=k instanceof HTMLElement?k.getBoundingClientRect():o.getBoundingClientRect(),F=[T.width];S&&F.push(S.right-T.left);const W=F.filter(ce=>Number.isFinite(ce)&&ce>0);return W.length>0?Be(Math.min(...W)):Be(ee)},[n,ee]);return M.jsxs(M.Fragment,{children:[r.map(o=>{const b=ve({type:o.id===d?"edit":"saved",draft:o}),S=K(b);if(!S)return null;const k=Y(S);return o.id===d?ye.createPortal(M.jsx(He,{initialText:w,onTextChange:E,fileLabel:C,lineRange:{start:o.startLine,end:o.endLine,side:o.side==="original"?"deletions":"additions"},isEditing:!0,onSave:u,onCancel:$,maxWidth:k}),S,`draft-edit-${o.id}`):ye.createPortal(M.jsx(tt,{draft:o,onEdit:()=>z(o),onDelete:()=>N(o),maxWidth:k}),S,`draft-card-${o.id}`)}),a&&!d&&H&&(()=>{const o=K(H);if(!o)return null;const b=Y(o);return ye.createPortal(M.jsx(He,{initialText:w,onTextChange:E,fileLabel:C,lineRange:a,isEditing:!1,onSave:u,onCancel:$,maxWidth:b}),o,H)})()]})}const De=[],at=`
|
|
2
|
-
[data-gutter-buffer="annotation"] { min-height: 0; }
|
|
3
|
-
[data-code] { min-height: 2.5rem; align-content: start; }
|
|
4
|
-
`,Oe=5e5,lt=`
|
|
5
|
-
:host {
|
|
6
|
-
font-family: var(--font-mono);
|
|
7
|
-
font-size: var(--text-code);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
pre, [data-code] {
|
|
11
|
-
font-family: var(--font-mono);
|
|
12
|
-
font-size: var(--text-code);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* Mobile touch selection support */
|
|
16
|
-
[data-line-number] {
|
|
17
|
-
touch-action: manipulation;
|
|
18
|
-
-webkit-tap-highlight-color: transparent;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/* Ensure interactive line numbers work on touch */
|
|
23
|
-
pre[data-interactive-line-numbers] [data-line-number] {
|
|
24
|
-
touch-action: manipulation;
|
|
25
|
-
}
|
|
26
|
-
`,We=`
|
|
27
|
-
${lt}
|
|
28
|
-
|
|
29
|
-
/* While a multi-line content drag is being mapped to a line selection the
|
|
30
|
-
row highlight is the feedback; the native blue text selection on top of
|
|
31
|
-
it reads as double-selection, so it is painted transparent for the drag's
|
|
32
|
-
duration only (single-line selections keep the normal look for copying). */
|
|
33
|
-
:host([data-oc-comment-drag]) {
|
|
34
|
-
user-select: none;
|
|
35
|
-
-webkit-user-select: none;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* Gutter "+" comment utility: theme primary, and smaller than Pierre's
|
|
39
|
-
1lh default, which reads oversized next to our 13px line numbers. */
|
|
40
|
-
[data-utility-button] {
|
|
41
|
-
width: 16px;
|
|
42
|
-
height: 16px;
|
|
43
|
-
align-self: center;
|
|
44
|
-
margin-right: calc(-16px + 1ch);
|
|
45
|
-
border-radius: 5px;
|
|
46
|
-
background-color: var(--primary-base);
|
|
47
|
-
color: var(--primary-foreground);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
:host {
|
|
51
|
-
--diffs-bg-separator-override: var(--surface-elevated);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
[data-diff-header],
|
|
55
|
-
[data-diff] {
|
|
56
|
-
[data-separator] {
|
|
57
|
-
height: 24px !important;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
[data-separator="line-info-basic"] {
|
|
62
|
-
height: 24px !important;
|
|
63
|
-
background: var(--diffs-bg) !important;
|
|
64
|
-
position: relative;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
[data-diff-type="single"] [data-gutter],
|
|
68
|
-
[data-diff-type="split"] [data-deletions] [data-gutter] {
|
|
69
|
-
[data-separator-wrapper] {
|
|
70
|
-
position: absolute;
|
|
71
|
-
left: 100%;
|
|
72
|
-
display: flex;
|
|
73
|
-
align-items: center;
|
|
74
|
-
gap: unset;
|
|
75
|
-
width: max-content;
|
|
76
|
-
background: transparent;
|
|
77
|
-
color: var(--diffs-fg-number);
|
|
78
|
-
font-family: var(--diffs-header-font-family, var(--font-sans));
|
|
79
|
-
font-size: 0.75rem;
|
|
80
|
-
line-height: 1;
|
|
81
|
-
margin-left: calc(-2ch - 2px);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
[data-separator-wrapper][data-separator-multi-button] {
|
|
85
|
-
margin-left: calc(-3ch - 2px);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
[data-expand-button],
|
|
89
|
-
[data-separator-content] {
|
|
90
|
-
display: block;
|
|
91
|
-
align-self: unset;
|
|
92
|
-
min-width: unset;
|
|
93
|
-
min-height: unset;
|
|
94
|
-
padding: 0;
|
|
95
|
-
flex-shrink: 0;
|
|
96
|
-
grid-column: unset;
|
|
97
|
-
border: none;
|
|
98
|
-
width: auto;
|
|
99
|
-
height: auto;
|
|
100
|
-
background-color: transparent;
|
|
101
|
-
color: inherit;
|
|
102
|
-
font: inherit;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
[data-expand-button]:not([data-expand-all-button]) {
|
|
106
|
-
&[data-expand-down]::before {
|
|
107
|
-
content: '\\2191';
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
&[data-expand-up]::before {
|
|
111
|
-
content: '\\2193';
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
&[data-expand-both]::before {
|
|
115
|
-
content: '\\2195';
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
svg {
|
|
119
|
-
display: none;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
[data-separator-content] {
|
|
124
|
-
background: transparent;
|
|
125
|
-
margin-left: calc(2px + 1ch);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
[data-expand-all-button] {
|
|
129
|
-
position: relative;
|
|
130
|
-
margin-left: 14px;
|
|
131
|
-
text-transform: lowercase;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
[data-expand-all-button]::before {
|
|
135
|
-
content: '';
|
|
136
|
-
display: block;
|
|
137
|
-
position: absolute;
|
|
138
|
-
top: 50%;
|
|
139
|
-
left: -8px;
|
|
140
|
-
margin-top: -1px;
|
|
141
|
-
width: 3px;
|
|
142
|
-
height: 3px;
|
|
143
|
-
border-radius: 2px;
|
|
144
|
-
background-color: var(--diffs-fg-number);
|
|
145
|
-
pointer-events: none;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
[data-separator-content]:hover,
|
|
149
|
-
[data-expand-button]:hover,
|
|
150
|
-
[data-expand-all-button]:hover {
|
|
151
|
-
color: var(--diffs-fg);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
[data-expand-all-button]:hover {
|
|
155
|
-
text-decoration: underline;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
`;function ct(i){let n=2166136261;for(let r=0;r<i.length;r+=1)n^=i.charCodeAt(r),n=n+((n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24))>>>0;return n.toString(16)}function je(i){const n=i.length>400?`${i.slice(0,200)}${i.slice(-200)}`:i;return`${i.length}:${ct(n)}`}const dt=(i,n,r,a)=>{const d=a.side==="deletions",E=(r?(d?r.deletionLines:r.additionLines).join(""):d?i:n).split(`
|
|
159
|
-
`),C=Math.min(a.start,a.end),u=Math.max(a.start,a.end),$=Math.max(1,C),z=Math.min(E.length,u);return $>z?"":E.slice($-1,z).join(`
|
|
160
|
-
`)},ut=(i,n)=>i===n?!0:!i||!n?!1:i.start===n.start&&i.end===n.end&&i.side===n.side,ft=i=>i==="auto"||i==="scroll"||i==="overlay",ht=i=>{let n=i?.parentElement??null;for(;n;){const r=window.getComputedStyle(n);if(ft(r.overflowY))return n;n=n.parentElement}return null},mt=(i,n)=>{if(!i||!n||typeof window>"u")return()=>{};const r=ht(i);if(!r)return()=>{};const a=n.getBoundingClientRect().height;if(!a)return()=>{};const d=i.getBoundingClientRect().top-r.getBoundingClientRect().top,w=n.style.minHeight;n.style.minHeight=`${Math.ceil(a)}px`;let E=!1;return()=>{if(E)return;E=!0,n.style.minHeight=w;const u=i.getBoundingClientRect().top-r.getBoundingClientRect().top-d;u&&(r.scrollTop+=u)}},pt=(i,n)=>{if(typeof window>"u")return()=>{};let r=null,a=null,d=!1;const w=()=>{d||(a?.disconnect(),a=null,r=window.requestAnimationFrame(()=>{r=window.requestAnimationFrame(()=>{d||n()})}))},E=()=>i.querySelector("diffs-container")?.shadowRoot??void 0,C=(u=E())=>!!u?.querySelector("[data-line]");return C()?w():typeof MutationObserver<"u"?(a=new MutationObserver(()=>{const u=E();if(u){if(C(u)){w();return}a?.disconnect(),a=new MutationObserver(()=>{C(u)&&w()}),a.observe(u,{childList:!0,subtree:!0})}}),a.observe(i,{childList:!0,subtree:!0})):r=window.requestAnimationFrame(w),()=>{d=!0,a?.disconnect(),r!==null&&window.cancelAnimationFrame(r)}},ge=new WeakMap,gt={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function yt(i){const n=i.closest("[data-diff-virtual-root]");if(n instanceof HTMLElement){const r=n.querySelector("[data-diff-virtual-content]");return{key:n,root:n,content:r instanceof HTMLElement?r:void 0}}return{key:document,root:document,content:void 0}}function vt(i){if(typeof document>"u")return null;const n=yt(i);let r=ge.get(n.key);if(!r){const d=new Je;d.setup(n.root,n.content),r={virtualizer:d,refs:0},ge.set(n.key,r)}r.refs+=1;let a=!1;return{virtualizer:r.virtualizer,root:n.root,release:()=>{if(a)return;a=!0;const d=ge.get(n.key);d&&(d.refs-=1,!(d.refs>0)&&(d.virtualizer.cleanUp(),ge.delete(n.key)))}}}const bt=(i,n,r)=>{if(typeof window>"u")return()=>{};const a=[],d=()=>{try{i.rerender()}catch{}const w=n?.root;w instanceof HTMLElement?w.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),r()};return a.push(window.requestAnimationFrame(d)),a.push(window.requestAnimationFrame(()=>{a.push(window.requestAnimationFrame(d))})),()=>{for(const w of a)window.cancelAnimationFrame(w)}},Pt=({original:i,modified:n,fileDiff:r,language:a,fileName:d,renderSideBySide:w,wrapLines:E,layout:C="fill",enableComments:u=!0,hunkActions:$})=>{const z=Qe(),N=z?.currentTheme.metadata.variant==="dark",V=z?.availableThemes.find(e=>e.metadata.id===z.lightThemeId)??ze(!1),O=z?.availableThemes.find(e=>e.metadata.id===z.darkThemeId)??ze(!0),{isMobile:ee}=Ze(),P=$?.anchors??De,[H,te]=I.useState(()=>({fileDiff:void 0,anchors:De,targets:new Map})),K=nt({source:"diff",fileLabel:d||"unknown",language:a,getCodeForRange:e=>dt(i,n,r,e),toStoreRange:e=>({startLine:e.start,endLine:e.end,side:e.side==="deletions"?"original":"modified"}),fromDraftRange:e=>({start:e.startLine,end:e.endLine,side:e.side==="original"?"deletions":"additions"})}),{drafts:Y,selection:o,setSelection:b,commentText:S,setCommentText:k,editingDraftId:T,saveComment:F,cancel:W,startEdit:ce,deleteDraft:Ve}=K,de=l.useRef(null),U=l.useRef(null),ne=l.useRef(""),q=l.useRef(!1),ue=l.useRef(null);l.useEffect(()=>{de.current=o},[o]),l.useEffect(()=>{U.current=T},[T]),l.useEffect(()=>{ne.current=S},[S]);const fe=l.useCallback(e=>{if(!u||q.current)return;const t=de.current;if(!(!e&&t&&ne.current.trim())){if(ee&&t&&e&&e.side===t.side){const s=Math.min(t.start,e.start),c=Math.max(t.end,e.end);b({...e,start:s,end:c})}else b(e);e&&(U.current||k(""))}},[u,ee,k,b]),Ue=l.useCallback(()=>{W()},[W]),Ee=l.useCallback(e=>{const t=document.createElement("div");if(t.style.position="relative",e.metadata.type==="hunk-action")return t.dataset.hunkActionTarget=String(e.metadata.index),t.style.height="0px",t;const s=ve(e.metadata);return t.dataset.annotationId=s,t.dataset.annotationSide=e.side,t.dataset.annotationLine=String(e.lineNumber),t},[]),Te=l.useCallback((e,t,s)=>{const c=new Map;if(s!=="unmount"){const f=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)*2,y=new Map,x=[];for(const R of e.shadowRoot?.querySelectorAll("slot")??[])for(const L of R.assignedElements()){const v=L.querySelector("[data-hunk-action-target]"),h=Number(v?.dataset.hunkActionTarget);if(!v||!Number.isInteger(h)||h<0)continue;c.set(h,v);const m=R.closest("[data-code]");if(!m)continue;let g=y.get(m);g||(g=m.getBoundingClientRect(),y.set(m,g));const j=v.getBoundingClientRect().top,ae=Math.max(g.top+4,Math.min(j+4,g.bottom-f-4));x.push({target:v,offset:ae-j})}for(const{target:R,offset:L}of x){const v=`${L}px`;R.style.getPropertyValue("--oc-hunk-action-offset")!==v&&R.style.setProperty("--oc-hunk-action-offset",v)}}const p=t.fileDiff;te(f=>f.fileDiff===p&&f.anchors===P&&f.targets.size===c.size&&[...c].every(([y,x])=>f.targets.get(y)===x)?f:{fileDiff:p,anchors:P,targets:c})},[P]),_e=l.useCallback((e,t)=>{F(e,t??o??void 0)},[F,o]),_=l.useCallback(e=>{b(e);const t=A.current;if(t)try{q.current=!0,t.setSelectedLines(e),ue.current=e}catch{}finally{q.current=!1}},[b]),re=l.useRef(null),be=l.useRef(null);l.useEffect(()=>{if(!u)return;const e=J.current;if(!e)return;const t=()=>{const h=e.querySelector("diffs-container");return h instanceof HTMLElement?h.shadowRoot:null},s=h=>{const m=e.querySelector("diffs-container");m instanceof HTMLElement&&(h?m.setAttribute("data-oc-comment-drag",""):m.removeAttribute("data-oc-comment-drag"))},c=(h,m)=>{const j=t()?.elementFromPoint(h,m)??document.elementFromPoint(h,m);if(!(j instanceof Element))return null;const ae=!!j.closest("[data-column-number]"),le=j.closest("[data-line]");if(!(le instanceof HTMLElement))return null;const Le=Number.parseInt(le.getAttribute("data-line")??"",10);if(!Number.isFinite(Le)||Le<=0)return null;const Ge=le.getAttribute("data-line-type")==="change-deletion"||le.closest("[data-code][data-deletions]")!=null?"deletions":"additions";return{line:Le,side:Ge,numberColumn:ae}};let p=null,f=!1,y=null;const x=h=>{re.current=h;const m=A.current;if(m)try{q.current=!0,m.setSelectedLines(h)}catch{}finally{q.current=!1}},R=h=>{if(h.button!==0||h.pointerType!=="mouse")return;const m=c(h.clientX,h.clientY);if(!m||m.numberColumn){p=null;return}p={line:m.line,side:m.side},f=!1,y=h.pointerId},L=h=>{if(p==null||h.pointerId!==y)return;const m=c(h.clientX,h.clientY);if(m){if(!f){if(m.line===p.line)return;f=!0,s(!0),window.getSelection()?.removeAllRanges();const g=t();g&&"getSelection"in g&&g.getSelection()?.removeAllRanges()}x({start:Math.min(p.line,m.line),end:Math.max(p.line,m.line),side:p.side})}},v=h=>{if(p==null||h.pointerId!==y)return;const m=f;if(p=null,f=!1,y=null,s(!1),!m)return;const g=re.current;re.current=null,g&&(de.current&&ne.current.trim()&&!U.current||(_(g),U.current||k("")))};return e.addEventListener("pointerdown",R),document.addEventListener("pointermove",L,{passive:!0}),document.addEventListener("pointerup",v),()=>{e.removeEventListener("pointerdown",R),document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",v),s(!1)}},[_,u,k]);const Me=l.useCallback(e=>{if(!u)return;const t=re.current,s=t&&e.start>=t.start&&e.end<=t.end&&(e.side==null||e.side===t.side);be.current!==null&&(window.clearTimeout(be.current),be.current=null),re.current=null,_(s&&t?t:e),U.current||k("")},[_,u,k]),Ce=l.useCallback(e=>{if(!u||e.numberColumn||window.getSelection()?.toString().trim())return;const t=e.annotationSide,s={start:e.lineNumber,end:e.lineNumber,side:t},c=de.current;if(c&&c.start===s.start&&c.end===s.end&&c.side===s.side){if(!ne.current.trim()){b(null);const p=A.current;try{q.current=!0,p?.setSelectedLines(null)}finally{q.current=!1}}return}c&&ne.current.trim()&&!U.current||(_(s),U.current||k(""))},[_,u,k,b]),Pe=l.useCallback(e=>{const t=e.closest("[data-line-type]")?.getAttribute("data-line-type")??e.getAttribute("data-line-type");if(t==="change-deletion")return"deletions";if(t==="change-addition")return"additions";const s=e.getAttribute("data-column-side")??e.getAttribute("data-side")??e.closest("[data-column-side]")?.getAttribute("data-column-side");if(s==="deletions"||s==="left"||s==="original")return"deletions";if(s==="additions"||s==="right"||s==="modified")return"additions";const c=e.closest("[data-line-type]");if(c instanceof HTMLElement){const p=c.getBoundingClientRect(),f=e.getBoundingClientRect(),y=p.left+p.width/2;return f.left+f.width/2<y?"deletions":"additions"}return"additions"},[]);$e(V),$e(O);const X=`${V.metadata.id}:${O.metadata.id}:${N?"dark":"light"}`,ie=l.useMemo(()=>{if(r){const e=r.deletionLines.reduce((s,c)=>s+c.length,0),t=r.additionLines.reduce((s,c)=>s+c.length,0);return Math.max(e,t)>Oe}return Math.max(i.length,n.length)>Oe},[r,n.length,i.length]),J=l.useRef(null),Q=l.useRef(null),A=l.useRef(null),oe=l.useRef(null),we=l.useRef(null),ke=l.useRef(null),Re=l.useRef(void 0),he=l.useRef(void 0),me=l.useRef(void 0),pe=l.useRef(void 0),[,xe]=I.useReducer(e=>e+1,0),Z=rt(ie?"unified":w?"split":"unified"),B=l.useMemo(()=>qe(V),[V]),D=l.useMemo(()=>qe(O),[O]);I.useLayoutEffect(()=>{const e=J.current;if(!e)return;const t=e.querySelector("diffs-container");if(!t)return;const s=N?D:B,c=(j,ae)=>j.colors?.[ae],p=c(B,"terminal.ansiGreen"),f=c(B,"terminal.ansiRed"),y=c(B,"terminal.ansiBlue"),x=c(D,"terminal.ansiGreen"),R=c(D,"terminal.ansiRed"),L=c(D,"terminal.ansiBlue");t.style.setProperty("--shiki-light",B.fg),t.style.setProperty("--shiki-light-bg",B.bg),p&&t.style.setProperty("--shiki-light-addition-color",p),f&&t.style.setProperty("--shiki-light-deletion-color",f),y&&t.style.setProperty("--shiki-light-modified-color",y),t.style.setProperty("--shiki-dark",D.fg),t.style.setProperty("--shiki-dark-bg",D.bg),x&&t.style.setProperty("--shiki-dark-addition-color",x),R&&t.style.setProperty("--shiki-dark-deletion-color",R),L&&t.style.setProperty("--shiki-dark-modified-color",L),t.style.setProperty("--diffs-bg",s.bg),t.style.setProperty("--diffs-fg",s.fg);const v=N?x:p,h=N?R:f,m=N?L:y;v&&t.style.setProperty("--diffs-addition-color-override",v),h&&t.style.setProperty("--diffs-deletion-color-override",h),m&&t.style.setProperty("--diffs-modified-color-override",m);const g=t.shadowRoot?.querySelector("pre");g&&(g.style.setProperty("--shiki-light",B.fg),g.style.setProperty("--shiki-light-bg",B.bg),p&&g.style.setProperty("--shiki-light-addition-color",p),f&&g.style.setProperty("--shiki-light-deletion-color",f),y&&g.style.setProperty("--shiki-light-modified-color",y),g.style.setProperty("--shiki-dark",D.fg),g.style.setProperty("--shiki-dark-bg",D.bg),x&&g.style.setProperty("--shiki-dark-addition-color",x),R&&g.style.setProperty("--shiki-dark-deletion-color",R),L&&g.style.setProperty("--shiki-dark-modified-color",L),g.style.setProperty("--diffs-bg",s.bg),g.style.setProperty("--diffs-fg",s.fg),v&&g.style.setProperty("--diffs-addition-color-override",v),h&&g.style.setProperty("--diffs-deletion-color-override",h),m&&g.style.setProperty("--diffs-modified-color-override",m))},[D,X,N,B]);const G=l.useMemo(()=>({theme:{dark:O.metadata.id,light:V.metadata.id},themeType:N?"dark":"light",diffStyle:w?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:ie?0:1e3,maxLineLengthForHighlighting:ie?1:1e3,tokenizeMaxLineLength:ie?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:E?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:u,enableGutterUtility:u,onGutterUtilityClick:u?Me:void 0,onLineClick:u?Ce:void 0,onLineSelected:u?fe:void 0,unsafeCSS:P.length>0?`${We}
|
|
161
|
-
${at}`:We,renderAnnotation:u||P.length>0?Ee:void 0,onPostRender:P.length>0?Te:void 0}),[Te,P.length,O.metadata.id,u,N,ie,V.metadata.id,w,E,fe,Me,Ce,Ee]),se=l.useMemo(()=>{const e=u?it({drafts:Y,editingDraftId:T,selection:o}):[];for(const t of P)e.push({side:t.side,lineNumber:t.lineNumber,metadata:{type:"hunk-action",index:t.index}});return e},[T,u,Y,P,o]),Se=l.useRef(se);if(l.useEffect(()=>{Se.current=se},[se]),l.useEffect(()=>{const e=Q.current;return()=>{A.current?.cleanUp(),A.current=null,oe.current?.release(),oe.current=null,we.current=null,ke.current=null,Re.current=void 0,he.current=void 0,me.current=void 0,pe.current=void 0,e&&(e.innerHTML="")}},[]),l.useEffect(()=>{if(typeof window>"u")return;const e=Q.current,t=J.current;if(!e||!Z)return;const s=mt(t,e);let c=oe.current;c||(c=vt(e),oe.current=c),oe.current=c;const p=c?.virtualizer??null,f=r?void 0:{name:d||"",contents:i,lang:a,cacheKey:`old:${X}:${d}:${je(i)}`},y=r?void 0:{name:d||"",contents:n,lang:a,cacheKey:`new:${X}:${d}:${je(n)}`},x=r?he.current!==r:he.current!==void 0||!f||!y||!me.current||!pe.current||!Ie(me.current,f)||!Ie(pe.current,y),R=A.current,L=!!(R&&(we.current!==p||ke.current!==Z||p&&(Re.current!==G.hunkSeparators||x)));L&&(R?.cleanUp(),A.current=null,e.innerHTML="");let v=A.current;const h=!L&&R?!Ke(R.options,G):!1;if(v?v.setOptions(G):(v=c?new Ye(G,c.virtualizer,gt,Z):new Xe(G,Z),A.current=v,ue.current=null),we.current=p,ke.current=Z,Re.current=p?G.hunkSeparators:void 0,he.current=r,me.current=f,pe.current=y,r)v.render({fileDiff:r,forceRender:h,lineAnnotations:Se.current,containerWrapper:e});else{if(!f||!y)return;v.render({oldFile:f,newFile:y,forceRender:h,lineAnnotations:Se.current,containerWrapper:e})}const m=pt(e,()=>{s(),bt(v,c,xe)});return()=>{m(),s()}},[X,r,d,a,n,G,i,Z]),l.useEffect(()=>{const e=A.current;if(e){try{e.setLineAnnotations(se)}catch(t){console.error("Failed to apply diff line annotations",t);try{e.setLineAnnotations([])}catch{}}requestAnimationFrame(()=>{if(A.current===e){try{e.rerender()}catch{}xe()}})}},[se]),l.useEffect(()=>{const e=A.current;if(!e||o!==null)return;const t=ue.current;if(!ut(o,t))try{q.current=!0,e.setSelectedLines(o),ue.current=o}catch{}finally{q.current=!1}},[o]),l.useEffect(()=>{if(!u)return;const e=Q.current;if(!e)return;let t=null,s=()=>{};const c=()=>{const f=e.querySelector("diffs-container")?.shadowRoot;if(!f){t=requestAnimationFrame(c);return}const y=x=>{if(!(x instanceof MouseEvent)||x.button!==0||!(x.target instanceof Element))return;const R=x.target.closest("[data-column-number]");if(!(R instanceof HTMLElement))return;const L=R.getAttribute("data-column-number"),v=L?parseInt(L,10):NaN;if(Number.isNaN(v))return;const h=Pe(R);fe({start:v,end:v,side:h}),x.preventDefault(),x.stopPropagation()};f.addEventListener("click",y,!0),s=()=>{f.removeEventListener("click",y,!0)}};return c(),()=>{t!==null&&cancelAnimationFrame(t),s()}},[X,u,d,fe,Pe]),l.useEffect(()=>{const e=Q.current;if(!e)return;let t=null,s=null;const p=setTimeout(()=>{const f=e.querySelector("diffs-container");if(!(f instanceof HTMLElement))return;const y=f.shadowRoot;t=new MutationObserver(()=>{s&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{xe(),s=null})}),t.observe(f,{childList:!0,subtree:!0}),y&&t.observe(y,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(p),s&&cancelAnimationFrame(s),t?.disconnect()}},[X,d]),typeof window>"u")return null;const Ae=u?M.jsx(st,{diffRootRef:J,drafts:Y,selection:o,editingDraftId:T,commentText:S,onTextChange:k,fileLabel:d?.split("/").pop()??"",onSave:_e,onCancel:Ue,onEdit:e=>{_({start:e.startLine,end:e.endLine,side:e.side==="original"?"deletions":"additions"}),ce(e)},onDelete:Ve}):null,Fe=$&&r&&H.fileDiff===r&&H.anchors===P?[...H.targets].map(([e,t])=>ye.createPortal($.render(e),t,`hunk-${e}`)):null;return C==="fill"?M.jsx("div",{className:Ne("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:M.jsxs("div",{className:"flex-1 relative min-h-0",children:[M.jsx(et,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:M.jsx("div",{ref:J,className:"size-full relative",children:M.jsx("div",{ref:Q,className:"size-full"})})}),Ae,Fe]})}):M.jsxs("div",{className:Ne("relative","w-full"),children:[M.jsx("div",{ref:J,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative",children:M.jsx("div",{ref:Q,className:"w-full"})}),Ae,Fe]})};export{Pt as P};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{R as t,j as n}from"./vendor-react-BUCujlKS.js";import{n as bt,u as qe,a as he,x as Ze,h as Xe,A as jt}from"./index-DLHQogv8.js";import{c as Ct,s as Rt,P as Pt,C as Mt}from"./shikiHighlight-1imXsir9.js";import{f as Tt,z as H,cz as kt,aF as Nt,b as et,K as Et,af as It,Z as Dt,bg as Vt,S as Ft,fT as Lt,a0 as At,i7 as Ot,l as tt,fS as Kt,av as nt,h8 as $t,fQ as zt,ds as rt,fV as Wt,fW as _t,m as Bt,i8 as Gt,ap as st,aa as ge,ab as we,aq as it,B as ne,I as z,ac as ve,as as ot,be as re,g as Jt,c5 as Ut,ay as Ht,cm as Qt,i9 as Yt}from"./useAppFontEffects-BItUWdo4.js";import{u as qt,n as Zt}from"./useInlineCommentController-CkbKsm7m.js";import{b as Xt}from"./CodeMirrorCommentWidgets-DvUH815P.js";import{getResolvedShikiTheme as en}from"./appThemeRegistry-Cf8KitzT.js";import{E as tn}from"./vendor-codemirror-view-CiLROUVV.js";import{af as nn}from"./runtimeEndpointReset-DhC3REb2.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.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-BDyxuqK4.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-Dgqc63LZ.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-B0u3Q5uO.js";import"./PluginPane-QxjsKYeO.js";const rn=()=>{const l=new Map,c=new Map;return{schedule:(o,s,f)=>{if(s<=(c.get(o)??Number.NEGATIVE_INFINITY))return l.get(o)??Promise.resolve();c.set(o,s);const g=(l.get(o)??Promise.resolve()).then(f,f);return l.set(o,g.catch(()=>{c.get(o)===s&&c.delete(o)})),g},pendingFor:async o=>{await l.get(o)},reset:o=>{c.delete(o)}}},x=l=>{if(!l)return"";const c=l.replace(/\\/g,"/");return c==="/"?"/":c.replace(/\/+$/,"")},Se=(l,c)=>{const o=x(l),s=c.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"");return!o||o==="/"?`/${s}`:`${o}/${s}`},sn=(l,c,o)=>Se(Se(Se(l,".opencode"),"plans"),`${c}-${o}.md`),on=(l,c)=>`~/.opencode/plans/${l}-${c}.md`,an=(l,c)=>{const o=l.trim();return o.startsWith("~")?o==="~"?c||o:(o.startsWith("~/")||o.startsWith("~\\"))&&c?`${c}${o.slice(1)}`:o:o},ln=(l,c)=>{const o=x(c.currentDirectory),s=x(c.homeDirectory),f=x(l);return o&&f.startsWith(o+"/")?f.slice(o.length+1):s&&f===s?"~":s&&f.startsWith(s+"/")?`~${f.slice(s.length)}`:f},cn=(l,c,o)=>{const s=x(l.trim());if(!s)return null;const f=o?c.find(g=>g.id===o)??null:null;if(f?.path){const g=x(f.path);if(s===g||s.startsWith(`${g}/`))return{id:f.id,path:f.path}}const N=c.filter(g=>{const E=x(g.path);return s===E||s.startsWith(`${E}/`)}).sort((g,E)=>x(E.path).length-x(g.path).length)[0];return N?{id:N.id,path:N.path}:null},un=l=>jt(()=>l()),ds=({targetPath:l=null,savedProjectPlan:c=null,onNavigatedToChat:o})=>{const{t:s}=Tt(),f=H(e=>e.currentSessionId),N=H(e=>e.createSession),g=H(e=>e.initializeNewOpenChamberSession),E=H(e=>e.sendMessage),ye=H(e=>e.setCurrentSession),xe=kt(),W=bt(e=>e.homeDirectory),be=Nt(e=>e.planModeEnabled),je=et(e=>e.projects),Ce=et(e=>e.activeProjectId),Re=Et(e=>e.directories),Pe=It()??"",Me=qe(e=>e.setSessionSwitcherOpen),_=Dt(),I=t.useSyncExternalStore(un,he,he),{isMobile:Te}=Vt(),{currentTheme:Q}=Ft(),S=t.useMemo(()=>f?xe.find(e=>e.id===f)??null:null,[f,xe]),R=t.useMemo(()=>{const e=typeof S?.directory=="string"?S.directory:"";return x(e||"")},[S?.directory]),ke=t.useMemo(()=>x(Pe||R),[Pe,R]),B=t.useMemo(()=>cn(ke,je,Ce),[Ce,ke,je]),se=c?.projectRef.id??null,ie=c?.projectRef.path??null,v=t.useMemo(()=>se&&ie?{id:se,path:ie}:null,[se,ie]),P=c?.planId??null,G=v&&P?JSON.stringify(["saved-plan",I,Lt(v),P]):null,L=v?.id===At,Y=t.useMemo(()=>{const e=v??B;return e?Re.get(e.path)?.isGitRepo===!0:!1},[B,Re,v]),[D,A]=t.useState(null),[Ne,Ee]=t.useState(!1),[p,M]=t.useState(null),[oe,ae]=t.useState(null),at=!!p||!!oe,le=t.useMemo(()=>!p||!R||!W?p:ln(p,{currentDirectory:R,homeDirectory:W}),[p,R,W]),[h,b]=t.useState(""),{isPlaying:q,play:lt,stop:ct}=Ot(),ut=tt(e=>e.showMessageTTSButtons),[Ie,ce]=t.useState(null),[De,ue]=t.useState(null),de=t.useMemo(()=>le&&le.split("/").pop()||s("planView.file.defaultName"),[le,s]),me=t.useMemo(()=>h.trim()?Kt(h,s("planView.title.default")).title:s("planView.title.default"),[h,s]),Z=t.useMemo(()=>me.trim()||s("planView.title.default"),[me,s]),[dt,V]=t.useState(!1),[mt,Ve]=t.useState(!1),[X,Fe]=t.useState("edit"),J=t.useRef(null),[u,y]=t.useState(null),Le=t.useRef(null),pt=t.useRef(null),Ae="openchamber:plan:md-viewer-mode";t.useEffect(()=>{try{const e=localStorage.getItem(Ae);if(!e)return;const i=JSON.parse(e);(i==="preview"||i==="edit")&&Fe(i)}catch{}},[]);const ft=t.useCallback(e=>{Fe(e);try{localStorage.setItem(Ae,JSON.stringify(e))}catch{}},[]),O=t.useRef(!1),T=t.useRef(null),[Oe,K]=t.useState(!1);t.useEffect(()=>{const e=()=>{O.current=!1,T.current=null,K(!1)};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[]);const ht=t.useCallback((e,i)=>{const a=e.split(`
|
|
2
|
-
`),r=Math.max(1,i.start),d=Math.min(a.length,i.end);return r>d?"":a.slice(r-1,d).join(`
|
|
3
|
-
`)},[]),gt=qt({source:"plan",fileLabel:de,language:p&&nt(p)||"markdown",getCodeForRange:e=>ht(h,Zt(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})}),{drafts:Ke,commentText:ee,setCommentText:$e,editingDraftId:pe,setSelection:ze,saveComment:We,cancel:U,reset:_e,startEdit:Be,deleteDraft:Ge}=gt;t.useEffect(()=>{y(null),_e()},[h,_e]),t.useEffect(()=>{ze(u)},[u,ze]);const Je=t.useCallback(()=>{y(null),U()},[U]),Ue=t.useCallback((e,i)=>{i&&y(i),We(e,i??u??void 0),y(null)},[u,We]);t.useEffect(()=>{if(!u)return;const e=a=>{const r=a.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]")||ee.trim()||(y(null),U())},i=window.setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{window.clearTimeout(i),document.removeEventListener("click",e)}},[U,ee,pe,Te,u]);const fe=qe(e=>e.editorFontSize),wt=t.useMemo(()=>{const e=p?nt(p):null,i=!!e&&e!=="markdown",a=[Ct(Q,i?{syntaxColors:!1,fontSize:fe}:{fontSize:fe})],r=$t(p||"plan.md");return r&&a.push(r),i&&e&&a.push(Rt({language:e,themeName:Q.metadata.id,theme:en(Q)})),a.push(tn.lineWrapping),a},[Q,p,fe]),j=t.useRef({key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""}),C=t.useState(rn)[0],He=t.useCallback(async(e,i)=>{if("filePath"in e){const r=_.files??Ze()?.files;if(r?.writeFile){if(!(await r.writeFile(e.filePath,i))?.success)throw new Error("Plan file write failed");return}const d=await Xe("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.filePath,content:i})});if(!d.ok)throw new Error(`Failed to write plan file (${d.status})`);return}if(!await zt.getState().savePlan(e.projectRef,e.planId,i))throw new Error("Plan save rejected: the plan no longer exists")},[_.files]),Qe=t.useRef(He);Qe.current=He;const F=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:Qe.current};C.schedule(i.key,i.revision,async()=>{if(he()!==i.runtimeKey)return;await i.write(i.target,i.content);const a=j.current;a.key===i.key&&(a.savedRevision=Math.max(a.savedRevision,i.revision),ce(null))}).catch(a=>{j.current.key===i.key&&ce(a instanceof Error?a.message:"Plan save failed")})},[C]);t.useEffect(()=>{if(!be&&!l&&!P){F(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},M(null),ae(null),b(""),V(!1);return}let e=!1;const i=async r=>{if(_.files?.readFile)return(await _.files.readFile(r))?.content??"";const d=Ze()?.files;if(d?.readFile)return(await d.readFile(r,{optional:!0}))?.content??"";const m=await Xe(`/api/fs/read?path=${encodeURIComponent(r)}&optional=true`,{cache:"no-store"});if(!m.ok)throw new Error(`Failed to read plan file (${m.status})`);return m.text()};return(async()=>{if(F(),j.current={key:null,target:null,content:"",editRevision:0,savedRevision:0,runtimeKey:""},M(null),ae(null),b(""),ce(null),ue(null),P&&v&&G){if(await C.pendingFor(G),e)return;C.reset(G),V(!0);try{const r=await Yt(v,P);if(e)return;if(!r){ue("Plan not found");return}j.current={key:G,target:{projectRef:v,planId:P},content:r.raw,editRevision:0,savedRevision:0,runtimeKey:I},b(r.raw),ae(P)}catch(r){if(e)return;ue(r instanceof Error?r.message:"Plan load failed")}finally{e||V(!1)}return}if(l){const r=JSON.stringify(["plan-file",I,l]);if(await C.pendingFor(r),e)return;C.reset(r),V(!0);try{const d=await i(l);if(e)return;j.current={key:r,target:{filePath:l},content:d,editRevision:0,savedRevision:0,runtimeKey:I},M(l),b(d)}catch{if(e)return;M(null),b("")}finally{e||V(!1)}return}if(!S?.slug||!S?.time?.created||!R){M(null),b("");return}V(!0);try{const r=sn(R,S.time.created,S.slug),d=an(on(S.time.created,S.slug),W||null);let m=null;try{await i(r),m=r}catch{}if(!m)try{await i(d),m=d}catch{}if(e)return;if(!m){M(null),b("");return}const w=JSON.stringify(["plan-file",I,m]);if(await C.pendingFor(w),e)return;const $=await i(m);if(e)return;C.reset(w),j.current={key:w,target:{filePath:m},content:$,editRevision:0,savedRevision:0,runtimeKey:I},M(m),b($)}catch{if(e)return;M(null),b("")}finally{e||V(!1)}})(),()=>{e=!0}},[I,W,be,_.files,P,G,v,C,F,S?.slug,S?.time?.created,R,l]);const vt=t.useCallback(e=>{j.current.content=e,j.current.editRevision+=1,b(e)},[]);t.useEffect(()=>{if(!p&&!oe)return;const e=window.setTimeout(()=>{F()},350);return()=>{window.clearTimeout(e)}},[h,oe,p,F]),t.useEffect(()=>()=>{F()},[F]),t.useEffect(()=>()=>{J.current!==null&&window.clearTimeout(J.current)},[]);const Ye=t.useCallback(()=>{Me(!1),o?.()},[o,Me]),St=t.useCallback(async e=>{const i=v??B;if(!i||!D||L)return;const a=await rt(D.action==="improve"?"plan.improve.visible":"plan.implement.visible",{plan_title:Z}),r=await rt(D.action==="improve"?"plan.improve.instructions":"plan.implement.instructions",{plan_title:Z,plan_path:p??""}),m=[{synthetic:!0,text:p?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.","",h].join(`
|
|
4
|
-
`)}];Ee(!0);try{Ye();let w=null,$=i.path;if(D.target==="worktree"){if(!Y)return;const k=await Wt(i.path,_t());if(!k?.id)return;w=k.id,$=k.path}else{const k=await N(void 0,i.path,null);if(!k?.id)return;w=k.id,$=k.directory??i.path,g(k.id,tt.getState().agents??[])}if(!w)return;const te=Bt.getState();te.saveSessionModelSelection(w,e.providerID,e.modelID),e.agent.trim()&&(te.saveSessionAgentSelection(w,e.agent),te.saveAgentModelForSession(w,e.agent,e.providerID,e.modelID),te.saveAgentModelVariantForSession(w,e.agent,e.providerID,e.modelID,e.variant||void 0)),ye(w,$);const xt=e.runAsGoal===!0?[`Implement the plan "${Z}" end-to-end${p?` (plan file: ${p})`:" (the full plan follows)"}.`,p?"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.","",h].join(`
|
|
5
|
-
`):null;Gt.getState().setArmed(e.runAsGoal===!0,xt),await E(a,e.providerID,e.modelID,e.agent.trim()||void 0,void 0,void 0,m,e.variant||void 0),A(null)}finally{Ee(!1)}},[Y,h,N,B,g,L,D,p,Ye,v,E,Z,ye]),yt=t.useMemo(()=>Xt({drafts:Ke,editingDraftId:pe,commentText:ee,onTextChange:$e,selection:u,isDragging:Oe,fileLabel:de,newWidgetId:"plan-new-comment-input",mapDraftToRange:e=>({start:e.startLine,end:e.endLine}),onSave:Ue,onCancel:Je,onEdit:e=>{Be(e),y({start:e.startLine,end:e.endLine})},onDelete:Ge}),[ee,Ge,pe,Je,Ue,Oe,u,Ke,de,$e,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:me}),De?n.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:De,children:s("planView.error.loadFailed")}):null,Ie?n.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:Ie,children:s("planView.error.saveFailed")}):null]}),at?n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsxs(st,{children:[n.jsxs(ge,{children:[n.jsx(we,{asChild:!0,children:n.jsx(it,{asChild:!0,children:n.jsx(ne,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s("planView.actions.improvePlanAria"),disabled:!h.trim()||L,children:n.jsx(z,{name:"loop-right-ai",className:"size-4"})})})}),n.jsx(ve,{sideOffset:8,children:s("planView.actions.improve")})]}),n.jsxs(ot,{align:"end",children:[n.jsx(re,{onClick:()=>A({action:"improve",target:"session"}),disabled:L,children:s("planView.actions.sendToNewSession")}),n.jsx(re,{onClick:()=>A({action:"improve",target:"worktree"}),disabled:!Y,children:s("planView.actions.sendToNewWorktreeSession")})]})]}),n.jsxs(st,{children:[n.jsxs(ge,{children:[n.jsx(we,{asChild:!0,children:n.jsx(it,{asChild:!0,children:n.jsx(ne,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s("planView.actions.implementPlanAria"),disabled:!h.trim()||L,children:n.jsx(z,{name:"code-ai",className:"size-4"})})})}),n.jsx(ve,{sideOffset:8,children:s("planView.actions.implement")})]}),n.jsxs(ot,{align:"end",children:[n.jsx(re,{onClick:()=>A({action:"implement",target:"session"}),disabled:L,children:s("planView.actions.sendToNewSession")}),n.jsx(re,{onClick:()=>A({action:"implement",target:"worktree"}),disabled:!Y,children:s("planView.actions.sendToNewWorktreeSession")})]})]}),n.jsx(Pt,{currentMode:X,onToggle:()=>ft(X==="preview"?"edit":"preview")}),X==="preview"&&ut&&n.jsxs(ge,{children:[n.jsx(we,{asChild:!0,children:n.jsx(ne,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":s(q?"planView.tts.stopSpeaking":"planView.tts.readAloud"),onClick:()=>{q?ct():h.trim()&<(h)},children:q?n.jsx(z,{name:"stop",className:"h-4 w-4 text-[color:var(--status-success)]"}):n.jsx(z,{name:"volume-up",className:"h-4 w-4"})})}),n.jsx(ve,{sideOffset:8,children:s(q?"planView.tts.stopSpeaking":"planView.tts.readAloud")})]}),n.jsx(ne,{variant:"ghost",size:"sm",onClick:async()=>{(await Jt(h)).ok&&(Ve(!0),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{Ve(!1)},1200))},className:"h-5 w-5 p-0",title:s("planView.actions.copyPlanContents"),"aria-label":s("planView.actions.copyPlanContents"),children:mt?n.jsx(z,{name:"check",className:"h-4 w-4 text-[color:var(--status-success)]"}):n.jsx(z,{name:"clipboard",className:"h-4 w-4"})})]}):null]}),n.jsx(nn,{open:D!==null,onOpenChange:e=>{!e&&!Ne&&A(null)},target:D?.target??"session",projectDirectory:v?.path??B?.path??null,submitting:Ne,allowRunAsGoal:!0,onConfirm:St}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:n.jsx(Ut,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:dt?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(Ht,{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(Qt,{content:h,className:"typography-markdown-body",enableFileReferences:!1})})}):n.jsx("div",{className:"relative h-full",ref:pt,children:n.jsx(Mt,{value:h,onChange:vt,readOnly:!1,className:"h-full",extensions:wt,onViewReady:e=>{Le.current=e},onViewDestroy:()=>{Le.current=null},blockWidgets:yt,highlightLines:u?{start:Math.min(u.start,u.end),end:Math.max(u.start,u.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(e,i,a)=>{if(!(a instanceof MouseEvent)||a.button!==0)return!1;a.preventDefault();const r=e.state.doc.lineAt(i.from).number;if(u&&!a.shiftKey&&Math.min(u.start,u.end)===r&&Math.max(u.start,u.end)===r)return y(null),U(),O.current=!1,T.current=null,K(!1),!0;if(Te&&u&&!a.shiftKey){const d=Math.min(u.start,u.end,r),m=Math.max(u.start,u.end,r);return y({start:d,end:m}),O.current=!1,T.current=null,K(!1),!0}if(O.current=!0,T.current=r,K(!0),u&&a.shiftKey){const d=Math.min(u.start,r),m=Math.max(u.end,r);y({start:d,end:m})}else y({start:r,end:r});return!0},mouseover:(e,i,a)=>{if(!(a instanceof MouseEvent)||a.buttons!==1||!O.current||T.current===null)return!1;const r=e.state.doc.lineAt(i.from).number,d=Math.min(T.current,r),m=Math.max(T.current,r);return y({start:d,end:m}),K(!0),!1},mouseup:()=>(O.current=!1,T.current=null,K(!1),!1)}}})})})})})})]})};export{ds as PlanView};
|