@aiworker/web 1.22.0 → 1.22.2
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/README.md +4 -4
- package/bin/cli.js +7 -4
- package/bin/cli.test.js +165 -73
- package/bin/lib/cli-api-target.js +2 -2
- package/bin/lib/cli-args.js +119 -119
- package/bin/lib/cli-lifecycle.js +9 -9
- package/bin/lib/cli-network.js +3 -3
- package/bin/lib/cli-paths.js +3 -3
- package/bin/lib/cli-ports.js +2 -2
- package/bin/lib/cli-process.js +4 -4
- package/bin/lib/cli-startup.js +64 -15
- package/bin/lib/cli-tunnel-profiles.js +1 -1
- package/bin/lib/cli-tunnel-utils.js +2 -2
- package/bin/lib/commands-connect-url.js +19 -19
- package/bin/lib/commands-lifecycle.js +27 -27
- package/bin/lib/commands-logs.js +5 -5
- package/bin/lib/commands-models.js +1 -1
- package/bin/lib/commands-projects.js +1 -1
- package/bin/lib/commands-schedule.js +1 -1
- package/bin/lib/commands-serve.js +29 -29
- package/bin/lib/commands-session.js +1 -1
- package/bin/lib/commands-startup.js +45 -10
- package/bin/lib/commands-status.js +1 -1
- package/bin/lib/commands-tunnel.js +40 -40
- package/bin/lib/commands-update.js +1 -1
- package/bin/lib/commands-update.test.js +6 -6
- package/dist/assets/{CodeMirrorCommentWidgets-B3u7UIcE.js → CodeMirrorCommentWidgets-CSICpWQD.js} +1 -1
- package/dist/assets/{DiffView-DluiRSla.js → DiffView-hDBKesA_.js} +3 -3
- package/dist/assets/DirtyBranchSwitchDialog-C22HdWj4.js +1 -0
- package/dist/assets/FilesView-CdWzeOp9.js +17 -0
- package/dist/assets/GitView-VQQkYuUw.js +6 -0
- package/dist/assets/{JsonTreeView-B0BdZEHG.js → JsonTreeView-6lrhwD3q.js} +1 -1
- package/dist/assets/LinearIssuesView-Ba6Q9569.js +1 -0
- package/dist/assets/{MarkdownImageGallery-ClOvuZxC.js → MarkdownImageGallery-Czv_mhvS.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-BrMcswiy.js +12 -0
- package/dist/assets/{OnboardingScreen-D2DG7K6b.js → OnboardingScreen-ChxQoAkx.js} +1 -1
- package/dist/assets/{PatchDiff-DvfqDql7.js → PatchDiff-BzcZPlOq.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B7m3f0d7.js → PierreDiffViewer-BchBtZlp.js} +2 -2
- package/dist/assets/PlanView-DyDt_nZ_.js +5 -0
- package/dist/assets/SettingsView-BKf5xBsP.js +28 -0
- package/dist/assets/{SettingsWindow-i45U1Cy1.js → SettingsWindow-DDQYaKWQ.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BTwyh5OF.js → ToolOutputDialog-iYF8Y2bz.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-CdjbOVMM.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-DD8lDVej.js → VirtualizedFileDiff-fFFm2QgH.js} +1 -1
- package/dist/assets/{WalkthroughView-egQgxel3.js → WalkthroughView-DOeCsMju.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-BMIRgMHv.js → computeVirtualFileMetrics-CzgLum_K.js} +2 -2
- package/dist/assets/{contextPanelEmbeddedChat-C3fjDbdg.js → contextPanelEmbeddedChat-C0ZLAepL.js} +1 -1
- package/dist/assets/{de-C1P6X5Rs.js → de-B5JaA3SA.js} +6 -5
- package/dist/assets/{es-CDgaF1_t.js → es-EPIH88ii.js} +6 -5
- package/dist/assets/{fr-Bgxqvvz_.js → fr-CAMfxUdZ.js} +6 -5
- package/dist/assets/{index-CODwDsU_.js → index-Bl3LSbjn.js} +1 -1
- package/dist/assets/index-DF5kMP-i.js +39 -0
- package/dist/assets/index-Dl3xbAB_.css +1 -0
- package/dist/assets/{isDiffPlainText-BqayB8d3.js → isDiffPlainText-Dx-dB_8l.js} +1 -1
- package/dist/assets/{isFilePlainText-QfoiKJNY.js → isFilePlainText-CWFPwmnU.js} +1 -1
- package/dist/assets/{ja-BDRrEcNP.js → ja-CifOE1VN.js} +7 -6
- package/dist/assets/{ko-Ba8sQV79.js → ko-BBDyAyYQ.js} +7 -6
- package/dist/assets/{main-C5DVOxc6.js → main-DnBAoktx.js} +2 -2
- package/dist/assets/main-MhSaOZoB.js +930 -0
- package/dist/assets/{markdownCore-CZwzz5gw.js → markdownCore-BrBwOOMn.js} +2 -2
- package/dist/assets/{miniChat-DUJ4irZc.js → miniChat-BKyvLseN.js} +2 -2
- package/dist/assets/{mobile-CcaxB0n4.js → mobile-DKjeFgMN.js} +2 -2
- package/dist/assets/{patchFileDiff-yNfWXN4E.js → patchFileDiff-o8ms1me8.js} +1 -1
- package/dist/assets/pl-DgEHYfFM.js +16 -0
- package/dist/assets/{pt-BR-DIs6ElwV.js → pt-BR-DuWHojUw.js} +6 -5
- package/dist/assets/{renderElectronMiniChatApp-BcKLHXKe.js → renderElectronMiniChatApp-CDgBwwCS.js} +2 -2
- package/dist/assets/renderMobileApp-DJIKIK1r.js +25 -0
- package/dist/assets/runtimeEndpointReset-CYJ9O_xX.js +17 -0
- package/dist/assets/{scheduledTasksApi-DLW0mkQK.js → scheduledTasksApi-D8yamh1b.js} +1 -1
- package/dist/assets/{shikiHighlight-DYOWuY65.js → shikiHighlight-TEQCmzW8.js} +1 -1
- package/dist/assets/tr-D5m2yIWL.js +7 -0
- package/dist/assets/{uk-ZrCNjM7Y.js → uk-D_q60oog.js} +6 -5
- package/dist/assets/{useAppFontEffects-CjrntdL0.js → useAppFontEffects-D7sNpuL2.js} +161 -190
- package/dist/assets/useInlineCommentController-Brz_cLcQ.js +2 -0
- package/dist/assets/{useRootScrollLock-BHYPkrLv.js → useRootScrollLock-lXEnWlaU.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DFZik9R2.js → vendor-codemirror-language-data-Dp3KMRQG.js} +2 -2
- package/dist/assets/vendor-zod-CK21ihK-.js +39 -0
- package/dist/assets/{web-components-Bhg83tjf.js → web-components-_mNEMjFY.js} +1 -1
- package/dist/assets/{zh-CN-iv_AV4EC.js → zh-CN-D8QvsVeg.js} +6 -5
- package/dist/assets/{zh-TW-CzEUk38j.js → zh-TW-B9t7rQQO.js} +6 -5
- package/dist/index.html +22 -22
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +5 -5
- package/package.json +3 -3
- package/server/index.js +118 -85
- package/server/lib/agent-memory/actions.js +2 -2
- package/server/lib/agent-memory/feature-flag.js +1 -1
- package/server/lib/agent-memory/feature-flag.test.js +8 -8
- package/server/lib/agent-memory/routes.js +2 -2
- package/server/lib/agent-tool/runtime.js +37 -54
- package/server/lib/agent-tool/runtime.test.js +59 -59
- package/server/lib/browser-control/broker.js +3 -3
- package/server/lib/browser-control/broker.test.js +1 -1
- package/server/lib/changelog/update-notes.js +82 -0
- package/server/lib/changelog/update-notes.test.js +59 -0
- package/server/lib/client-auth/remote-clients.test.js +5 -5
- package/server/lib/context-obligatory/runtime.js +7 -7
- package/server/lib/context-obligatory/runtime.test.js +5 -5
- package/server/lib/dev-servers/parse.js +2 -2
- package/server/lib/dev-servers/parse.test.js +2 -2
- package/server/lib/dev-servers/routes.js +1 -1
- package/server/lib/dev-tunnel/DOCUMENTATION.md +13 -4
- package/server/lib/dev-tunnel/client.js +1 -1
- package/server/lib/dev-tunnel/runtime.js +5 -5
- package/server/lib/dev-tunnel/tunnel.test.js +21 -1
- package/server/lib/dictation/local/model-catalog.js +1 -1
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/event-stream/directory-ws-bridge.js +1 -1
- package/server/lib/event-stream/global-ws-bridge.js +1 -1
- package/server/lib/event-stream/protocol.test.js +4 -4
- package/server/lib/event-stream/runtime.test.js +6 -6
- package/server/lib/fs/DOCUMENTATION.md +2 -0
- package/server/lib/fs/routes.js +37 -26
- package/server/lib/fs/routes.test.js +98 -21
- package/server/lib/git/DOCUMENTATION.md +3 -1
- package/server/lib/git/identity-storage.js +1 -1
- package/server/lib/git/issue-2746-longpaths.test.js +4 -4
- package/server/lib/git/routes.js +17 -1
- package/server/lib/git/service.js +116 -26
- package/server/lib/git/service.test.js +174 -3
- package/server/lib/github/auth.js +8 -8
- package/server/lib/github/pr-status.js +1 -1
- package/server/lib/github/routes.js +2 -2
- package/server/lib/inherited-env.js +1 -1
- package/server/lib/inherited-env.test.js +2 -2
- package/server/lib/linear/auth.js +8 -8
- package/server/lib/linear/auth.test.js +24 -24
- package/server/lib/linear/issues.test.js +6 -6
- package/server/lib/linear/mapping.test.js +4 -4
- package/server/lib/linear/oauth.js +2 -2
- package/server/lib/linear/oauth.test.js +14 -14
- package/server/lib/linear/routes.js +5 -5
- package/server/lib/linear/routes.test.js +16 -16
- package/server/lib/linear/status-runtime.test.js +9 -9
- package/server/lib/linear/status.js +1 -1
- package/server/lib/linear/status.test.js +15 -15
- package/server/lib/linear/teams.test.js +4 -4
- package/server/lib/magic-prompts/routes.js +2 -2
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +55 -0
- package/server/lib/mcp-reconnect/runtime.js +122 -0
- package/server/lib/mcp-reconnect/runtime.test.js +140 -0
- package/server/lib/message-queue/DOCUMENTATION.md +158 -0
- package/server/lib/message-queue/runtime.js +870 -0
- package/server/lib/message-queue/runtime.test.js +482 -0
- package/server/lib/notifications/apns-runtime.js +17 -17
- package/server/lib/notifications/apns-runtime.test.js +11 -11
- package/server/lib/notifications/emitter-runtime.js +1 -1
- package/server/lib/notifications/emitter-runtime.test.js +1 -1
- package/server/lib/notifications/push-runtime.js +7 -7
- package/server/lib/notifications/routes.js +1 -1
- package/server/lib/notifications/runtime.js +1 -1
- package/server/lib/openchamber-control/action-resolution.test.js +10 -10
- package/server/lib/openchamber-control/actions.js +24 -24
- package/server/lib/openchamber-control/error.js +4 -4
- package/server/lib/openchamber-control/routes.js +2 -2
- package/server/lib/openchamber-control/routes.test.js +5 -5
- package/server/lib/openchamber-control/screenshots.js +1 -1
- package/server/lib/openchamber-control/screenshots.test.js +1 -1
- package/server/lib/openchamber-control/service.js +50 -50
- package/server/lib/openchamber-control/service.test.js +5 -5
- package/server/lib/openchamber-sessions/routes.js +124 -22
- package/server/lib/openchamber-sessions/routes.test.js +99 -11
- package/server/lib/opencode/DOCUMENTATION.md +13 -5
- package/server/lib/opencode/auth.js +1 -1
- package/server/lib/opencode/bootstrap-runtime.js +6 -6
- package/server/lib/opencode/cli-options.js +8 -8
- package/server/lib/opencode/config-paths.test.js +116 -0
- package/server/lib/opencode/core-routes.js +8 -7
- package/server/lib/opencode/core-routes.test.js +11 -11
- package/server/lib/opencode/env-config.js +5 -5
- package/server/lib/opencode/env-config.test.js +7 -7
- package/server/lib/opencode/env-runtime.js +10 -10
- package/server/lib/opencode/env-runtime.test.js +18 -18
- package/server/lib/opencode/feature-routes-runtime.js +17 -12
- package/server/lib/opencode/hmr-state-runtime.js +2 -2
- package/server/lib/opencode/hmr-state-runtime.test.js +1 -1
- package/server/lib/opencode/input-history-scope.js +14 -0
- package/server/lib/opencode/lifecycle.js +8 -8
- package/server/lib/opencode/lifecycle.test.js +4 -4
- package/server/lib/opencode/managed-plugin-config.js +35 -0
- package/server/lib/opencode/managed-process-registry.js +3 -3
- package/server/lib/opencode/mcp-oauth-callback.test.js +2 -2
- package/server/lib/opencode/openchamber-routes.js +15 -15
- package/server/lib/opencode/openchamber-routes.test.js +11 -11
- package/server/lib/opencode/plugins.js +2 -2
- package/server/lib/opencode/plugins.test.js +1 -1
- package/server/lib/opencode/project-icon-routes.js +2 -2
- package/server/lib/opencode/project-icon-routes.test.js +1 -1
- package/server/lib/opencode/providers.js +44 -2
- package/server/lib/opencode/providers.test.js +131 -4
- package/server/lib/opencode/proxy.js +2 -2
- package/server/lib/opencode/pwa-manifest-routes.js +1 -1
- package/server/lib/opencode/restart-session-recovery.test.js +1 -1
- package/server/lib/opencode/routes-upgrade.test.js +4 -4
- package/server/lib/opencode/routes.js +14 -14
- package/server/lib/opencode/server-startup-runtime.js +6 -6
- package/server/lib/opencode/session-runtime.js +3 -3
- package/server/lib/opencode/session-runtime.test.js +6 -6
- package/server/lib/opencode/settings-helpers.js +31 -3
- package/server/lib/opencode/settings-helpers.test.js +189 -12
- package/server/lib/opencode/settings-runtime.js +2 -2
- package/server/lib/opencode/settings-runtime.test.js +29 -0
- package/server/lib/opencode/shared.js +5 -2
- package/server/lib/opencode/shared.test.js +7 -7
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/skill-routes.js +2 -1
- package/server/lib/opencode/snippets.js +1 -2
- package/server/lib/opencode/startup-performance.js +1 -1
- package/server/lib/opencode/startup-performance.test.js +6 -6
- package/server/lib/opencode/static-routes-runtime.js +8 -8
- package/server/lib/opencode/static-routes-runtime.test.js +7 -7
- package/server/lib/opencode/upgrade-capability.js +2 -2
- package/server/lib/opencode/upgrade-capability.test.js +3 -3
- package/server/lib/package-manager.js +17 -42
- package/server/lib/package-manager.test.js +19 -19
- package/server/lib/permission-auto-accept/runtime.js +1 -1
- package/server/lib/project-context/routes.js +1 -1
- package/server/lib/projects/project-config.js +2 -2
- package/server/lib/quota/DOCUMENTATION.md +9 -1
- package/server/lib/quota/credentials/providers.js +4 -0
- package/server/lib/quota/credentials/store.js +4 -4
- package/server/lib/quota/credentials/store.test.js +8 -8
- package/server/lib/quota/index.js +1 -0
- package/server/lib/quota/providers/exe-dev.js +75 -0
- package/server/lib/quota/providers/exe-dev.test.js +47 -0
- package/server/lib/quota/providers/hyper.js +118 -0
- package/server/lib/quota/providers/hyper.test.js +126 -0
- package/server/lib/quota/providers/index.js +15 -0
- package/server/lib/quota/providers/ollama-cloud.js +1 -1
- package/server/lib/quota/providers/opencode-go.js +2 -1
- package/server/lib/quota/providers/opencode-go.test.js +9 -5
- package/server/lib/quota/providers/xai.js +1 -1
- package/server/lib/quota/routes.js +2 -0
- package/server/lib/quota/utils/auth.js +1 -1
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/host-client.js +1 -1
- package/server/lib/relay/host-client.test.js +9 -1
- package/server/lib/relay/host-lock.js +1 -1
- package/server/lib/relay/service.js +5 -5
- package/server/lib/relay/tunnel-host.js +3 -1
- package/server/lib/relay/tunnel-host.test.js +9 -1
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +2 -2
- package/server/lib/scheduled-tasks/routes.js +5 -5
- package/server/lib/scheduled-tasks/service.js +25 -25
- package/server/lib/scheduled-tasks/service.test.js +1 -1
- package/server/lib/security/bind-host.js +4 -4
- package/server/lib/security/bind-host.test.js +1 -1
- package/server/lib/security/request-security.js +11 -5
- package/server/lib/security/request-security.test.js +14 -14
- package/server/lib/session-assist/runtime.js +10 -9
- package/server/lib/session-folders/routes.js +2 -2
- package/server/lib/session-folders/routes.test.js +8 -8
- package/server/lib/session-goal/DOCUMENTATION.md +20 -7
- package/server/lib/session-goal/create.js +4 -2
- package/server/lib/session-goal/create.test.js +1 -1
- package/server/lib/session-goal/objectives.js +4 -4
- package/server/lib/session-goal/routes.js +1 -1
- package/server/lib/session-goal/runtime.js +88 -22
- package/server/lib/session-goal/runtime.test.js +428 -2
- package/server/lib/session-knowledge/runtime.js +11 -11
- package/server/lib/session-knowledge/runtime.test.js +5 -5
- package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
- package/server/lib/skills-catalog/cache.test.js +2 -2
- package/server/lib/skills-catalog/disk-cache.js +5 -5
- package/server/lib/skills-catalog/github-meta.test.js +2 -2
- package/server/lib/skills-catalog/install.js +3 -2
- package/server/lib/small-model/DOCUMENTATION.md +4 -0
- package/server/lib/small-model/call.js +9 -3
- package/server/lib/small-model/call.test.js +29 -6
- package/server/lib/small-model/index.js +8 -7
- package/server/lib/small-model/index.test.js +1 -1
- package/server/lib/small-model/resolve.js +1 -1
- package/server/lib/small-model/resolve.test.js +1 -1
- package/server/lib/small-model/routes.js +2 -1
- package/server/lib/system-prompt/runtime.js +3 -22
- package/server/lib/system-prompt/runtime.test.js +3 -3
- package/server/lib/terminal/DOCUMENTATION.md +11 -7
- package/server/lib/terminal/runtime.js +180 -26
- package/server/lib/terminal/runtime.test.js +554 -27
- package/server/lib/terminal/shells.js +20 -3
- package/server/lib/terminal/shells.test.js +33 -2
- package/server/lib/tts/base-url.js +3 -3
- package/server/lib/tts/routes.test.js +20 -20
- package/server/lib/ui-auth/ui-auth.js +12 -9
- package/server/lib/ui-auth/ui-auth.test.js +19 -3
- package/server/lib/ui-auth/ui-passkeys.js +7 -7
- package/server/lib/walkthrough/index.js +1 -0
- package/server/lib/walkthrough/jobs.test.js +1 -1
- package/server/lib/walkthrough/language.test.js +1 -1
- package/server/lib/walkthrough/model-settings.js +3 -3
- package/server/lib/walkthrough/model-settings.test.js +1 -1
- package/server/lib/walkthrough/pull-request.test.js +5 -5
- package/server/lib/walkthrough/reproduce-2607.test.js +2 -2
- package/server/lib/walkthrough/routes.test.js +26 -5
- package/server/lib/walkthrough/store.js +3 -3
- package/server/lib/walkthrough/store.test.js +1 -1
- package/server/opencode-proxy.test.js +2 -2
- package/server/proxy-headers.js +1 -1
- package/server/sse-routes.test.js +4 -4
- package/README.md.bak +0 -250
- package/bin/lib/DOCUMENTATION.md.bak +0 -163
- package/dist/assets/CommitSection-SGBCAW0w.js +0 -1
- package/dist/assets/FilesView-Bdq8ppva.js +0 -17
- package/dist/assets/GitView-Znn7VJcP.js +0 -6
- package/dist/assets/LinearIssuesView-jP-hXyac.js +0 -1
- package/dist/assets/MarkdownRendererImpl-Dt9mjTRN.js +0 -12
- package/dist/assets/PlanView-B0F3BtPZ.js +0 -5
- package/dist/assets/SettingsView-BBW-S-gh.js +0 -28
- package/dist/assets/ToolPartDiffPreview-CUNe28U1.js +0 -8
- package/dist/assets/index-C57jT0Sa.css +0 -1
- package/dist/assets/index-DW_E3rnL.js +0 -7
- package/dist/assets/main-Bv5Pkngh.js +0 -928
- package/dist/assets/pl-Dioz29BI.js +0 -15
- package/dist/assets/renderMobileApp-D9yQJy0L.js +0 -25
- package/dist/assets/runtimeEndpointReset-CjhvxLH0.js +0 -16
- package/dist/assets/tr-DFnMlPxY.js +0 -6
- package/dist/assets/useInlineCommentController-CDEuSlPH.js +0 -2
- package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
- package/server/index.d.ts.bak +0 -39
- package/server/lib/agent-tool/DOCUMENTATION.md.bak +0 -119
- package/server/lib/browser-control/DOCUMENTATION.md.bak +0 -50
- package/server/lib/context-obligatory/DOCUMENTATION.md.bak +0 -19
- package/server/lib/dev-tunnel/DOCUMENTATION.md.bak +0 -57
- package/server/lib/dictation/DOCUMENTATION.md.bak +0 -100
- package/server/lib/event-stream/DOCUMENTATION.md.bak +0 -62
- package/server/lib/fs/DOCUMENTATION.md.bak +0 -47
- package/server/lib/git/DOCUMENTATION.md.bak +0 -193
- package/server/lib/github/DOCUMENTATION.md.bak +0 -183
- package/server/lib/linear/DOCUMENTATION.md.bak +0 -97
- package/server/lib/linear/OAUTH-BROKER-HANDOFF.md.bak +0 -91
- package/server/lib/markdown-image-grants/DOCUMENTATION.md.bak +0 -40
- package/server/lib/notifications/APNS.md.bak +0 -135
- package/server/lib/notifications/DOCUMENTATION.md.bak +0 -138
- package/server/lib/openchamber-control/DOCUMENTATION.md.bak +0 -64
- package/server/lib/opencode/DOCUMENTATION.md.bak +0 -431
- package/server/lib/opencode/managed-process-registry.d.ts.bak +0 -13
- package/server/lib/opencode/provider-env-aliases.d.ts.bak +0 -3
- package/server/lib/permission-auto-accept/DOCUMENTATION.md.bak +0 -34
- package/server/lib/project-context/DOCUMENTATION.md.bak +0 -160
- package/server/lib/quota/DOCUMENTATION.md.bak +0 -123
- package/server/lib/relay/DOCUMENTATION.md.bak +0 -100
- package/server/lib/scheduled-tasks/DOCUMENTATION.md.bak +0 -182
- package/server/lib/session-assist/DOCUMENTATION.md.bak +0 -66
- package/server/lib/session-goal/DOCUMENTATION.md.bak +0 -213
- package/server/lib/session-knowledge/DOCUMENTATION.md.bak +0 -89
- package/server/lib/skills-catalog/DOCUMENTATION.md.bak +0 -151
- package/server/lib/small-model/DOCUMENTATION.md.bak +0 -212
- package/server/lib/system-prompt/DOCUMENTATION.md.bak +0 -36
- package/server/lib/terminal/DOCUMENTATION.md.bak +0 -50
- package/server/lib/text/DOCUMENTATION.md.bak +0 -35
- package/server/lib/tts/DOCUMENTATION.md.bak +0 -147
- package/server/lib/tunnels/DOCUMENTATION.md.bak +0 -21
- package/server/lib/ui-auth/DOCUMENTATION.md.bak +0 -44
- package/server/lib/walkthrough/DOCUMENTATION.md.bak +0 -411
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as _,j as e,R as i,f as Q}from"./vendor-react-BUCujlKS.js";import{K as V,ca as we,c9 as le,c7 as G,z as $,ak as B,d6 as je,r as W,Q as ue,at as me,a0 as pe,L as ne}from"./index-DW_E3rnL.js";import{f as J,B as L,S as Y,g as he,h as re,I as E}from"./useAppFontEffects-CjrntdL0.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BeMD8X_w.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"./contextPanelEmbeddedChat-C3fjDbdg.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-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.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-DFZik9R2.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-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function ke(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 xe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:r="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:u,showInstancePicker:h=!1}){const{t:o}=J(),[w,S]=_.useState(s),[j,U]=_.useState(r),[K,x]=_.useState("idle"),[m,k]=_.useState(null),[C,b]=_.useState(""),[T,I]=_.useState([]),[y,f]=_.useState(()=>h?"instances":"add"),[g,R]=_.useState("");_.useEffect(()=>{h&&V().then(p=>I(p.hosts)).catch(p=>{b(p instanceof Error?p.message:String(p))})},[h]);const N=we(w),D=N?.persistedUrl??null,F=_.useCallback(p=>{S(p.target.value),x("idle"),k(null),b("")},[]),M=_.useCallback(p=>{U(p.target.value)},[]),c=_.useCallback(async()=>{if(D){x("testing"),k(null),b("");try{const p=await le(D);k(p),x(p.status==="ok"||p.status==="update-recommended"?"success":"error")}catch(p){b(p instanceof Error?p.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[D,o]),A=_.useCallback(async()=>{if(!N)return;const p=N.persistedUrl;x("testing"),k(null),b("");try{const H=await le(p);if(k(H),oe(H.status)){x("error");return}const Z=await V(),ye=j.trim()||p,ee=Z.hosts.find(X=>X.url===p),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:ye,url:p,apiUrl:p},ve=ee?Z.hosts.map(X=>X.id===te?ie:X):[...Z.hosts,ie];if(await G({hosts:ve,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),N.redeemUrl){window.location.assign(N.redeemUrl);return}$()&&await B()}catch(H){b(H instanceof Error?H.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[N,j,l,o]),O=_.useCallback(async p=>{const H=await V();await G({hosts:H.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await B()},[]),d=_.useCallback(async()=>{x("testing"),b("");try{const p=await V(),H=await je(g,p.hosts);await G({hosts:H.hosts,defaultHostId:H.hostId,initialHostChoiceCompleted:!0}),await B()}catch(p){b(p instanceof Error&&p.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[g,o]),v=K==="testing",P=D!==null&&!v,z=D!==null&&!v&&!oe(m?.status??null),q=ke(m?.status??null),fe=m?.status==="ok",ge=m?.status==="update-recommended",be=m?.status==="auth",ae=oe(m?.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:()=>{O(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(Y,{value:g,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:()=>{d()},disabled:v||!g.trim(),children:o("settings.remoteInstances.direct.import.action")})]})}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(t||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(Y,{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(Y,{id:"remote-label",type:"text",value:j,onChange:M,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),m&&fe&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:o("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&be&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:o("onboarding.remoteConnection.status.authWarning")}),m&&ge&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:q?o(q):null}),m&&ae&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:o("onboarding.remoteConnection.status.connectionFailed")}),e.jsx("div",{className:"opacity-90",children:q?o(q):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?o("onboarding.remoteConnection.status.suggestionsUnreachable"):o("onboarding.remoteConnection.status.suggestionsWrongService")})]}),C&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(L,{variant:"outline",onClick:c,disabled:!P,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(L,{onClick:A,disabled:!z,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&&u&&e.jsx(L,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Ce="curl -fsSL https://opencode.ai/install | bash",Ne="https://opencode.ai/docs",ce=2500;function Se(a){const t=Q.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(E,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let u;return t[2]!==r||t[3]!==s?(u=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]=u):u=t[4],u}function Re({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=J(),[r,n]=i.useState(!1),[l,u]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(""),[K,x]=i.useState("unknown"),[m,k]=i.useState(()=>t?"local":"remote"),[C,b]=i.useState(!1),[T,I]=i.useState(!1);i.useEffect(()=>{u($())},[]),i.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const d=navigator.userAgent||"";/Windows/i.test(d)?x("windows"):/Macintosh|Mac OS X/i.test(d)?x("macos"):/Linux/i.test(d)?x("linux"):x("unknown")},[]),i.useEffect(()=>{let d=!1;return(async()=>{try{const v=await W("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!v.ok)return;const P=await v.json().catch(()=>null);if(!P||d)return;const z=typeof P.opencodeBinary=="string"?P.opencodeBinary.trim():"";z&&U(z)}catch{}})(),()=>{d=!0}},[]);const y=i.useCallback(async d=>{const v=d.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||d.button===0&&l&&await ue()},[l]),f=i.useCallback(async()=>{try{const d=await W("/health");if(!d.ok)return!1;const v=await d.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),g=i.useCallback(async d=>{if(!l)return;const v=await V();await G({...v,...d==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),R=i.useCallback(async()=>{l&&await g("local"),a?.()},[l,a,g]);i.useEffect(()=>{if(!t||m!=="local")return;let d=!1,v=null;const P=async()=>{if(!d){try{const z=await f();if(d)return;if(z){await R();return}}catch{}d||(v=setTimeout(P,ce))}};return v=setTimeout(P,ce),()=>{d=!0,v&&clearTimeout(v)}},[m,f,R,t]);const N=i.useCallback(async()=>{S(!0);try{await f()&&await R()}finally{S(!1)}},[f,R]),D=i.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const d=await me();d.success&&d.path&&d.path.trim().length>0&&U(d.path.trim())}catch{}},[l]),F=i.useCallback(async()=>{o(!0);try{if(await pe({opencodeBinary:j.trim()}),l){await g("local"),await B();return}await W("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,g]),M=i.useCallback(async()=>{const d=await he(Ce);d.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",d.error)},[]),c=Ne,A=K==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":K==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",O=t&&(!l||m==="local");return e.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:y,children:e.jsxs("div",{className:"w-full max-w-md 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",m==="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",m==="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&&m==="remote"?e.jsx("div",{className:"app-region-no-drag",children:e.jsx(xe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,O&&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(E,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Se,{onCopy:M,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(E,{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:d=>b(d.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(E,{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(Y,{value:j,onChange:d=>U(d.target.value),placeholder:A,disabled:h,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",size:"sm",onClick:D,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:d=>I(d.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(E,{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 Le="curl -fsSL https://opencode.ai/install | bash",Ue="https://opencode.ai/docs";function Te(a){const t=Q.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(E,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let u;return t[2]!==r||t[3]!==s?(u=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]=u):u=t[4],u}const Ke=3e4;function Ie({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:r}){const{t:n}=J(),[l,u]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(!1),[K,x]=i.useState(!1),[m,k]=i.useState(null),[C,b]=i.useState(""),[T,I]=i.useState("unknown");i.useEffect(()=>{const c=setTimeout(()=>o(!0),Ke);return()=>clearTimeout(c)},[]),i.useEffect(()=>{S($())},[]),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 A=await W("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!A.ok)return;const O=await A.json().catch(()=>null);if(!O||c)return;const d=typeof O.opencodeBinary=="string"?O.opencodeBinary.trim():"";d&&b(d)}catch{}})(),()=>{c=!0}},[]);const y=i.useCallback(async c=>{c.target.closest("button, a, input, select, textarea, code")||c.button===0&&w&&await ue()},[w]),f=i.useCallback(async()=>{try{const c=await W("/health");if(!c.ok)return!1;const A=await c.json();return A.openCodeRunning===!0||A.isOpenCodeReady===!0}catch{return!1}},[]),g=i.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const c=await me();c.success&&c.path&&c.path.trim().length>0&&b(c.path.trim())}catch{}},[w]),R=i.useCallback(async()=>{U(!0);try{if(await pe({opencodeBinary:C.trim()}),w){await B();return}await W("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[w,C]),N=i.useCallback(async()=>{const c=await he(Le);c.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",c.error)},[]),D=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=Ue,M=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(E,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(Te,{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(E,{name:"external-link",className:"h-3 w-3"})]}),m&&e.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(L,{type:"button",onClick:D,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(Y,{value:C,onChange:c=>b(c.target.value),placeholder:M,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",onClick:g,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 AiWorker. Verify the address points to an AiWorker 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 AiWorker server at "${r||"unknown"}" is not compatible with this app version. Update AiWorker 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 Ae(a){switch(a){case"local":return e.jsx(E,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(E,{name:"server",className:"h-8 w-8"})}}function De({variant:a,hostLabel:t,hostUrl:s,onRetry:r,onUseLocal:n,onUseRemote:l,isRetrying:u=!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:Ae(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:u,className:"w-full",children:[e.jsx(E,{name:"refresh",className:re("h-4 w-4",u&&"animate-spin")}),h(u?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(L,{variant:"outline",onClick:n,disabled:u,className:"flex-1",children:[e.jsx(E,{name:"macbook",className:"h-4 w-4"}),h(o.useLocalLabelKey)]}),o.showUseRemote&&l&&e.jsxs(L,{variant:"outline",onClick:l,disabled:u,className:"flex-1",children:[e.jsx(E,{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 Ee(a){const t=Q.c(29),{variant:s,hostUrl:r,hostLabel:n,onRetry:l,onChooseRemote:u,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,m=U===void 0?!0:U,k=Fe;let C;t[0]!==l?(C=async()=>{if($()){await B();return}await W("/api/config/reload",{method:"POST"}),l?.()},t[0]=l,t[1]=C):C=t[1];const b=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"),$()){await B();return}window.location.reload()},t[2]=S,t[3]=s,t[4]=T):T=t[4];const I=T;let y;t[5]!==u||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&u?.()},t[5]=u,t[6]=s,t[7]=y):y=t[7];const f=y;if(K){const N=s==="remote-wrong-service"?"":r||"",D=s==="remote-wrong-service"?"":n||"";let F;t[8]!==u||t[9]!==o?(F=o||(()=>u?.()),t[8]=u,t[9]=o,t[10]=F):F=t[10];const M=!m;let c;t[11]!==m||t[12]!==S||t[13]!==w?(c=m?w||(()=>{k("local").then(()=>{$()?B():S?.()})}):void 0,t[11]=m,t[12]=S,t[13]=w,t[14]=c):c=t[14];let A;return t[15]!==D||t[16]!==N||t[17]!==F||t[18]!==M||t[19]!==c?(A=e.jsx(xe,{onBack:F,initialUrl:N,initialLabel:D,isRecoveryMode:!0,showInstancePicker:M,onSwitchToLocal:c}),t[15]=D,t[16]=N,t[17]=F,t[18]=M,t[19]=c,t[20]=A):A=t[20],A}const g=m?I:void 0;let R;return t[21]!==b||t[22]!==f||t[23]!==n||t[24]!==r||t[25]!==x||t[26]!==g||t[27]!==s?(R=e.jsx(De,{variant:s,hostLabel:n,hostUrl:r,onRetry:b,onUseLocal:g,onUseRemote:f,isRetrying:x}),t[21]=b,t[22]=f,t[23]=n,t[24]=r,t[25]=x,t[26]=g,t[27]=s,t[28]=R):R=t[28],R}async function Fe(a){if(!$())return;const t=await V();await G({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function mo(a){const t=Q.c(29),{onBack:s,onCliAvailable:r,mode:n,recoveryVariant:l,recoveryHostUrl:u,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),[m,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 b;t[1]!==S||t[2]!==h||t[3]!==u||t[4]!==j?(b=[S,j,u,h],t[1]=S,t[2]=h,t[3]=u,t[4]=j,t[5]=b):b=t[5],i.useEffect(C,b);const T=m?"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,g;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),g=()=>{x(!1),k(!0)},t[7]=f,t[8]=g):(f=t[7],g=t[8]);let 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]!==u||t[14]!==j||t[15]!==K||t[16]!==R?(N=e.jsx(Ee,{variant:j,hostUrl:u,hostLabel:h,onChooseRemote:y,showRemoteForm:K,onCloseRemoteForm:f,onSwitchToLocalFromRemote:g,onEnterLocalSetup:R,localAvailable:U}),t[11]=U,t[12]=h,t[13]=u,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]!==m?(y=()=>{m?k(!1):s?.()},t[18]=s,t[19]=m,t[20]=y):y=t[20];let f;t[21]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!0),t[21]=f):f=t[21];let g;return t[22]!==r||t[23]!==m||t[24]!==y?(g=e.jsx(Ie,{onBack:y,onCliAvailable:r,isFromRecovery:m,onSwitchToRemote:f}),t[22]=r,t[23]=m,t[24]=y,t[25]=g):g=t[25],g}let I;return t[26]!==U||t[27]!==r?(I=e.jsx(Re,{onCliAvailable:r,localAvailable:U}),t[26]=U,t[27]=r,t[28]=I):I=t[28],I}export{mo as OnboardingScreen};
|
|
1
|
+
import{r as _,j as e,R as i,f as J}from"./vendor-react-BUCujlKS.js";import{L as V,cs as we,cp as le,cl as G,z as $,au as B,dz as je,r as W,V as ue,aC as me,a8 as pe,S as ne}from"./index-DF5kMP-i.js";import{f as Q,B as L,T as Y,g as he,h as re,I as E}from"./useAppFontEffects-D7sNpuL2.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-CK21ihK-.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BeMD8X_w.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"./contextPanelEmbeddedChat-C0ZLAepL.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-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.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-Dp3KMRQG.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-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function ke(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 xe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:r="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:u,showInstancePicker:h=!1}){const{t:o}=Q(),[w,S]=_.useState(s),[j,U]=_.useState(r),[K,x]=_.useState("idle"),[m,k]=_.useState(null),[C,b]=_.useState(""),[T,I]=_.useState([]),[y,f]=_.useState(()=>h?"instances":"add"),[g,R]=_.useState("");_.useEffect(()=>{h&&V().then(p=>I(p.hosts)).catch(p=>{b(p instanceof Error?p.message:String(p))})},[h]);const N=we(w),D=N?.persistedUrl??null,F=_.useCallback(p=>{S(p.target.value),x("idle"),k(null),b("")},[]),M=_.useCallback(p=>{U(p.target.value)},[]),c=_.useCallback(async()=>{if(D){x("testing"),k(null),b("");try{const p=await le(D);k(p),x(p.status==="ok"||p.status==="update-recommended"?"success":"error")}catch(p){b(p instanceof Error?p.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[D,o]),A=_.useCallback(async()=>{if(!N)return;const p=N.persistedUrl;x("testing"),k(null),b("");try{const H=await le(p);if(k(H),oe(H.status)){x("error");return}const Z=await V(),ye=j.trim()||p,ee=Z.hosts.find(X=>X.url===p),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:ye,url:p,apiUrl:p},ve=ee?Z.hosts.map(X=>X.id===te?ie:X):[...Z.hosts,ie];if(await G({hosts:ve,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),N.redeemUrl){window.location.assign(N.redeemUrl);return}$()&&await B()}catch(H){b(H instanceof Error?H.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[N,j,l,o]),O=_.useCallback(async p=>{const H=await V();await G({hosts:H.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await B()},[]),d=_.useCallback(async()=>{x("testing"),b("");try{const p=await V(),H=await je(g,p.hosts);await G({hosts:H.hosts,defaultHostId:H.hostId,initialHostChoiceCompleted:!0}),await B()}catch(p){b(p instanceof Error&&p.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[g,o]),v=K==="testing",P=D!==null&&!v,z=D!==null&&!v&&!oe(m?.status??null),q=ke(m?.status??null),fe=m?.status==="ok",ge=m?.status==="update-recommended",be=m?.status==="auth",ae=oe(m?.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:()=>{O(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(Y,{value:g,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:()=>{d()},disabled:v||!g.trim(),children:o("settings.remoteInstances.direct.import.action")})]})}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(t||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(Y,{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(Y,{id:"remote-label",type:"text",value:j,onChange:M,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),m&&fe&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:o("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&be&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:o("onboarding.remoteConnection.status.authWarning")}),m&&ge&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:q?o(q):null}),m&&ae&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:o("onboarding.remoteConnection.status.connectionFailed")}),e.jsx("div",{className:"opacity-90",children:q?o(q):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?o("onboarding.remoteConnection.status.suggestionsUnreachable"):o("onboarding.remoteConnection.status.suggestionsWrongService")})]}),C&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(L,{variant:"outline",onClick:c,disabled:!P,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(L,{onClick:A,disabled:!z,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&&u&&e.jsx(L,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Ce="curl -fsSL https://opencode.ai/install | bash",Ne="https://opencode.ai/docs",ce=2500;function Se(a){const t=J.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(E,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let u;return t[2]!==r||t[3]!==s?(u=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]=u):u=t[4],u}function Re({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=Q(),[r,n]=i.useState(!1),[l,u]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(""),[K,x]=i.useState("unknown"),[m,k]=i.useState(()=>t?"local":"remote"),[C,b]=i.useState(!1),[T,I]=i.useState(!1);i.useEffect(()=>{u($())},[]),i.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const d=navigator.userAgent||"";/Windows/i.test(d)?x("windows"):/Macintosh|Mac OS X/i.test(d)?x("macos"):/Linux/i.test(d)?x("linux"):x("unknown")},[]),i.useEffect(()=>{let d=!1;return(async()=>{try{const v=await W("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!v.ok)return;const P=await v.json().catch(()=>null);if(!P||d)return;const z=typeof P.opencodeBinary=="string"?P.opencodeBinary.trim():"";z&&U(z)}catch{}})(),()=>{d=!0}},[]);const y=i.useCallback(async d=>{const v=d.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||d.button===0&&l&&await ue()},[l]),f=i.useCallback(async()=>{try{const d=await W("/health");if(!d.ok)return!1;const v=await d.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),g=i.useCallback(async d=>{if(!l)return;const v=await V();await G({...v,...d==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),R=i.useCallback(async()=>{l&&await g("local"),a?.()},[l,a,g]);i.useEffect(()=>{if(!t||m!=="local")return;let d=!1,v=null;const P=async()=>{if(!d){try{const z=await f();if(d)return;if(z){await R();return}}catch{}d||(v=setTimeout(P,ce))}};return v=setTimeout(P,ce),()=>{d=!0,v&&clearTimeout(v)}},[m,f,R,t]);const N=i.useCallback(async()=>{S(!0);try{await f()&&await R()}finally{S(!1)}},[f,R]),D=i.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const d=await me();d.success&&d.path&&d.path.trim().length>0&&U(d.path.trim())}catch{}},[l]),F=i.useCallback(async()=>{o(!0);try{if(await pe({opencodeBinary:j.trim()}),l){await g("local"),await B();return}await W("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,g]),M=i.useCallback(async()=>{const d=await he(Ce);d.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",d.error)},[]),c=Ne,A=K==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":K==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",O=t&&(!l||m==="local");return e.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:y,children:e.jsxs("div",{className:"w-full max-w-md 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",m==="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",m==="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&&m==="remote"?e.jsx("div",{className:"app-region-no-drag",children:e.jsx(xe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,O&&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(E,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Se,{onCopy:M,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(E,{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:d=>b(d.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(E,{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(Y,{value:j,onChange:d=>U(d.target.value),placeholder:A,disabled:h,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",size:"sm",onClick:D,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:d=>I(d.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(E,{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 Le="curl -fsSL https://opencode.ai/install | bash",Ue="https://opencode.ai/docs";function Te(a){const t=J.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(E,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let u;return t[2]!==r||t[3]!==s?(u=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]=u):u=t[4],u}const Ke=3e4;function Ie({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:r}){const{t:n}=Q(),[l,u]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(!1),[K,x]=i.useState(!1),[m,k]=i.useState(null),[C,b]=i.useState(""),[T,I]=i.useState("unknown");i.useEffect(()=>{const c=setTimeout(()=>o(!0),Ke);return()=>clearTimeout(c)},[]),i.useEffect(()=>{S($())},[]),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 A=await W("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!A.ok)return;const O=await A.json().catch(()=>null);if(!O||c)return;const d=typeof O.opencodeBinary=="string"?O.opencodeBinary.trim():"";d&&b(d)}catch{}})(),()=>{c=!0}},[]);const y=i.useCallback(async c=>{c.target.closest("button, a, input, select, textarea, code")||c.button===0&&w&&await ue()},[w]),f=i.useCallback(async()=>{try{const c=await W("/health");if(!c.ok)return!1;const A=await c.json();return A.openCodeRunning===!0||A.isOpenCodeReady===!0}catch{return!1}},[]),g=i.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const c=await me();c.success&&c.path&&c.path.trim().length>0&&b(c.path.trim())}catch{}},[w]),R=i.useCallback(async()=>{U(!0);try{if(await pe({opencodeBinary:C.trim()}),w){await B();return}await W("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[w,C]),N=i.useCallback(async()=>{const c=await he(Le);c.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",c.error)},[]),D=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=Ue,M=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(E,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(Te,{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(E,{name:"external-link",className:"h-3 w-3"})]}),m&&e.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(L,{type:"button",onClick:D,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(Y,{value:C,onChange:c=>b(c.target.value),placeholder:M,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",onClick:g,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 AiWorker. Verify the address points to an AiWorker 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 AiWorker server at "${r||"unknown"}" is not compatible with this app version. Update AiWorker 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 Ae(a){switch(a){case"local":return e.jsx(E,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(E,{name:"server",className:"h-8 w-8"})}}function De({variant:a,hostLabel:t,hostUrl:s,onRetry:r,onUseLocal:n,onUseRemote:l,isRetrying:u=!1}){const{t:h}=Q(),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:Ae(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:u,className:"w-full",children:[e.jsx(E,{name:"refresh",className:re("h-4 w-4",u&&"animate-spin")}),h(u?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(L,{variant:"outline",onClick:n,disabled:u,className:"flex-1",children:[e.jsx(E,{name:"macbook",className:"h-4 w-4"}),h(o.useLocalLabelKey)]}),o.showUseRemote&&l&&e.jsxs(L,{variant:"outline",onClick:l,disabled:u,className:"flex-1",children:[e.jsx(E,{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 Ee(a){const t=J.c(29),{variant:s,hostUrl:r,hostLabel:n,onRetry:l,onChooseRemote:u,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,m=U===void 0?!0:U,k=Fe;let C;t[0]!==l?(C=async()=>{if($()){await B();return}await W("/api/config/reload",{method:"POST"}),l?.()},t[0]=l,t[1]=C):C=t[1];const b=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"),$()){await B();return}window.location.reload()},t[2]=S,t[3]=s,t[4]=T):T=t[4];const I=T;let y;t[5]!==u||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&u?.()},t[5]=u,t[6]=s,t[7]=y):y=t[7];const f=y;if(K){const N=s==="remote-wrong-service"?"":r||"",D=s==="remote-wrong-service"?"":n||"";let F;t[8]!==u||t[9]!==o?(F=o||(()=>u?.()),t[8]=u,t[9]=o,t[10]=F):F=t[10];const M=!m;let c;t[11]!==m||t[12]!==S||t[13]!==w?(c=m?w||(()=>{k("local").then(()=>{$()?B():S?.()})}):void 0,t[11]=m,t[12]=S,t[13]=w,t[14]=c):c=t[14];let A;return t[15]!==D||t[16]!==N||t[17]!==F||t[18]!==M||t[19]!==c?(A=e.jsx(xe,{onBack:F,initialUrl:N,initialLabel:D,isRecoveryMode:!0,showInstancePicker:M,onSwitchToLocal:c}),t[15]=D,t[16]=N,t[17]=F,t[18]=M,t[19]=c,t[20]=A):A=t[20],A}const g=m?I:void 0;let R;return t[21]!==b||t[22]!==f||t[23]!==n||t[24]!==r||t[25]!==x||t[26]!==g||t[27]!==s?(R=e.jsx(De,{variant:s,hostLabel:n,hostUrl:r,onRetry:b,onUseLocal:g,onUseRemote:f,isRetrying:x}),t[21]=b,t[22]=f,t[23]=n,t[24]=r,t[25]=x,t[26]=g,t[27]=s,t[28]=R):R=t[28],R}async function Fe(a){if(!$())return;const t=await V();await G({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function mo(a){const t=J.c(29),{onBack:s,onCliAvailable:r,mode:n,recoveryVariant:l,recoveryHostUrl:u,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),[m,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 b;t[1]!==S||t[2]!==h||t[3]!==u||t[4]!==j?(b=[S,j,u,h],t[1]=S,t[2]=h,t[3]=u,t[4]=j,t[5]=b):b=t[5],i.useEffect(C,b);const T=m?"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,g;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),g=()=>{x(!1),k(!0)},t[7]=f,t[8]=g):(f=t[7],g=t[8]);let 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]!==u||t[14]!==j||t[15]!==K||t[16]!==R?(N=e.jsx(Ee,{variant:j,hostUrl:u,hostLabel:h,onChooseRemote:y,showRemoteForm:K,onCloseRemoteForm:f,onSwitchToLocalFromRemote:g,onEnterLocalSetup:R,localAvailable:U}),t[11]=U,t[12]=h,t[13]=u,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]!==m?(y=()=>{m?k(!1):s?.()},t[18]=s,t[19]=m,t[20]=y):y=t[20];let f;t[21]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!0),t[21]=f):f=t[21];let g;return t[22]!==r||t[23]!==m||t[24]!==y?(g=e.jsx(Ie,{onBack:y,onCliAvailable:r,isFromRecovery:m,onSwitchToRemote:f}),t[22]=r,t[23]=m,t[24]=y,t[25]=g):g=t[25],g}let I;return t[26]!==U||t[27]!==r?(I=e.jsx(Re,{onCliAvailable:r,localAvailable:U}),t[26]=U,t[27]=r,t[28]=I):I=t[28],I}export{mo as OnboardingScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hM as j,h5 as k,hd as y}from"./useAppFontEffects-
|
|
1
|
+
import{hM as j,h5 as k,hd as y}from"./useAppFontEffects-D7sNpuL2.js";import{k as D,a as C}from"./web-components-_mNEMjFY.js";import{M as P,G as O,u as L,W as M,a as A,b as R,n as F,t as H}from"./Virtualizer-CZlLSacm.js";import{j as d,r as w}from"./vendor-react-BUCujlKS.js";import{V as _,F as N}from"./VirtualizedFileDiff-fFFm2QgH.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const o=e.hunkContent[l];n+=o.type==="context"?o.lines:o.deletions+o.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:o,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:s,lineAnnotations:a,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=o?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[g!=null?d.jsx("div",{slot:k,children:g}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:D(r),children:f(r)},h)),t!=null&&s!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:s(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:o,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:s,contentEditable:a}){const p=L(),m=l!==void 0,g=w.useContext(M),c=A(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");p!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),p,x,s?void 0:g,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),s?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:o})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:o,hasGutterRenderUtility:x}){const f=n&&o,u=t||x||l;if(!u&&!f)return e;let s={...e};return u&&(s={...s,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(s={...s,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),s}function X({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:o,className:x,style:f,prerenderedHTML:u,renderAnnotation:s,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:o,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(y,{ref:h,className:x,style:f,children:H($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:s,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{X as P};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as N,j as T,c as xe,r as a}from"./vendor-react-BUCujlKS.js";import{a as Be}from"./web-components-
|
|
1
|
+
import{R as N,j as T,c as xe,r as a}from"./vendor-react-BUCujlKS.js";import{a as Be}from"./web-components-_mNEMjFY.js";import{f as Te}from"./computeVirtualFileMetrics-CzgLum_K.js";import{V as je,F as Oe}from"./VirtualizedFileDiff-fFFm2QgH.js";import{V as De}from"./Virtualizer-D_a8gKmg.js";import{ea as Ve,eb as Ce,b7 as Ue,c0 as Ge,h as Pe}from"./useAppFontEffects-D7sNpuL2.js";import{I as Ae,a as Ke,u as _e}from"./useInlineCommentController-Brz_cLcQ.js";import"./index-DF5kMP-i.js";import{a6 as Ye}from"./runtimeEndpointReset-CYJ9O_xX.js";import{ensurePierreThemeRegistered as Fe,getResolvedShikiTheme as Ie}from"./appThemeRegistry-BK0dHKa6.js";const he=r=>{if(r.type==="new"){const t=Math.min(r.selection.start,r.selection.end),i=Math.max(r.selection.start,r.selection.end);return`new-comment-${r.selection.side??"additions"}-${t}-${i}`}return`draft-${r.draft.id}`},Xe=r=>{const{drafts:t,editingDraftId:i,selection:o}=r,l=[];for(const g of t){if(!Number.isFinite(g.endLine))continue;const E=Math.max(1,Math.floor(g.endLine)),C=g.side==="original"?"deletions":"additions";l.push({lineNumber:E,side:C,metadata:{type:g.id===i?"edit":"saved",draft:g}})}return o&&!i&&l.push({lineNumber:Math.max(o.start,o.end),side:o.side??"additions",metadata:{type:"new",selection:o}}),l};function Je(r){const t=r.trim();if(!t)return null;if(/^-?\d+(\.\d+)?$/.test(t)){const i=Number.parseFloat(t);return Number.isFinite(i)?i:null}if(t.endsWith("px")){const i=Number.parseFloat(t.slice(0,-2));return Number.isFinite(i)?i:null}return null}function ze(r){if(!(!r||r<=0))return Math.max(200,Math.floor(r))}function Qe(r){const{diffRootRef:t,drafts:i,selection:o,editingDraftId:l,commentText:g,onTextChange:E,fileLabel:C,onSave:u,onCancel:q,onEdit:P,onDelete:O}=r,[U,oe]=N.useState(0),[se,Q]=N.useState(null),w=N.useMemo(()=>!o||l?null:he({type:"new",selection:o}),[l,o]),H=N.useMemo(()=>{const c=i.map(b=>he({type:b.id===l?"edit":"saved",draft:b}));return w&&c.push(w),c},[i,l,w]),D=N.useCallback(c=>{const b=t.current;if(!b)return null;const R=b.querySelector("diffs-container");if(!(R instanceof HTMLElement))return null;const S=R.querySelector(`[data-annotation-id="${c}"]`);if(S instanceof HTMLElement)return S;const $=R.shadowRoot;return $?$.querySelector(`[data-annotation-id="${c}"]`):null},[t]);N.useEffect(()=>{if(H.length===0)return;let c=!1,b=0;const R=12,S=()=>{c||H.every(A=>!!D(A))||b>=R||(b+=1,requestAnimationFrame(()=>{c||(oe(A=>A+1),S())}))};return S(),()=>{c=!0}},[H,D]),N.useEffect(()=>{const c=t.current;if(!c)return;const b=()=>{const S=getComputedStyle(c),$=Je(S.getPropertyValue("--oc-context-panel-width")),A=c.getBoundingClientRect(),F=$??A.width;Q(F>0?F:null)};b();const R=new ResizeObserver(()=>{b()});return R.observe(c),window.addEventListener("resize",b),()=>{R.disconnect(),window.removeEventListener("resize",b)}},[t]);const I=N.useCallback(c=>{const R=t.current?.getBoundingClientRect(),S=c.closest("[data-annotation-content]"),$=S instanceof HTMLElement?S.getBoundingClientRect():c.getBoundingClientRect(),A=[$.width];R&&A.push(R.right-$.left);const F=A.filter(V=>Number.isFinite(V)&&V>0);return F.length>0?ze(Math.min(...F)):ze(se)},[t,se]);return T.jsxs(T.Fragment,{children:[i.map(c=>{const b=he({type:c.id===l?"edit":"saved",draft:c}),R=D(b);if(!R)return null;const S=I(R);return c.id===l?xe.createPortal(T.jsx(Ae,{initialText:g,onTextChange:E,fileLabel:C,lineRange:{start:c.startLine,end:c.endLine,side:c.side==="original"?"deletions":"additions"},isEditing:!0,onSave:u,onCancel:q,maxWidth:S}),R,`draft-edit-${c.id}`):xe.createPortal(T.jsx(Ke,{draft:c,onEdit:()=>P(c),onDelete:()=>O(c),maxWidth:S}),R,`draft-card-${c.id}`)}),o&&!l&&w&&(()=>{const c=D(w);if(!c)return null;const b=I(c);return xe.createPortal(T.jsx(Ae,{initialText:g,onTextChange:E,fileLabel:C,lineRange:o,isEditing:!1,onSave:u,onCancel:q,maxWidth:b}),c,w)})()]})}const qe=5e5,Ze=`
|
|
2
2
|
:host {
|
|
3
3
|
font-family: var(--font-mono);
|
|
4
4
|
font-size: var(--text-code);
|
|
@@ -154,4 +154,4 @@ import{R as N,j as T,c as xe,r as a}from"./vendor-react-BUCujlKS.js";import{a as
|
|
|
154
154
|
}
|
|
155
155
|
`;function tt(r){let t=2166136261;for(let i=0;i<r.length;i+=1)t^=r.charCodeAt(i),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t.toString(16)}function He(r){const t=r.length>400?`${r.slice(0,200)}${r.slice(-200)}`:r;return`${r.length}:${tt(t)}`}const nt=(r,t,i,o)=>{const l=o.side==="deletions",E=(i?(l?i.deletionLines:i.additionLines).join(""):l?r:t).split(`
|
|
156
156
|
`),C=Math.min(o.start,o.end),u=Math.max(o.start,o.end),q=Math.max(1,C),P=Math.min(E.length,u);return q>P?"":E.slice(q-1,P).join(`
|
|
157
|
-
`)},rt=(r,t)=>r===t?!0:!r||!t?!1:r.start===t.start&&r.end===t.end&&r.side===t.side,it=r=>r==="auto"||r==="scroll"||r==="overlay",ot=r=>{let t=r?.parentElement??null;for(;t;){const i=window.getComputedStyle(t);if(it(i.overflowY))return t;t=t.parentElement}return null},st=(r,t)=>{if(!r||!t||typeof window>"u")return()=>{};const i=ot(r);if(!i)return()=>{};const o=t.getBoundingClientRect().height;if(!o)return()=>{};const l=r.getBoundingClientRect().top-i.getBoundingClientRect().top,g=t.style.minHeight;t.style.minHeight=`${Math.ceil(o)}px`;let E=!1;return()=>{if(E)return;E=!0,t.style.minHeight=g;const u=r.getBoundingClientRect().top-i.getBoundingClientRect().top-l;u&&(i.scrollTop+=u)}},at=(r,t)=>{if(typeof window>"u")return()=>{};let i=null,o=null,l=!1;const g=()=>{l||(o?.disconnect(),o=null,i=window.requestAnimationFrame(()=>{i=window.requestAnimationFrame(()=>{l||t()})}))},E=()=>r.querySelector("diffs-container")?.shadowRoot??void 0,C=(u=E())=>!!u?.querySelector("[data-line]");return C()?g():typeof MutationObserver<"u"?(o=new MutationObserver(()=>{const u=E();if(u){if(C(u)){g();return}o?.disconnect(),o=new MutationObserver(()=>{C(u)&&g()}),o.observe(u,{childList:!0,subtree:!0})}}),o.observe(r,{childList:!0,subtree:!0})):i=window.requestAnimationFrame(g),()=>{l=!0,o?.disconnect(),i!==null&&window.cancelAnimationFrame(i)}},fe=new WeakMap,lt={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function ct(r){const t=r.closest("[data-diff-virtual-root]");if(t instanceof HTMLElement){const i=t.querySelector("[data-diff-virtual-content]");return{key:t,root:t,content:i instanceof HTMLElement?i:void 0}}return{key:document,root:document,content:void 0}}function dt(r){if(typeof document>"u")return null;const t=ct(r);let i=fe.get(t.key);if(!i){const l=new De;l.setup(t.root,t.content),i={virtualizer:l,refs:0},fe.set(t.key,i)}i.refs+=1;let o=!1;return{virtualizer:i.virtualizer,root:t.root,release:()=>{if(o)return;o=!0;const l=fe.get(t.key);l&&(l.refs-=1,!(l.refs>0)&&(l.virtualizer.cleanUp(),fe.delete(t.key)))}}}const ut=(r,t,i)=>{if(typeof window>"u")return()=>{};const o=[],l=()=>{try{r.rerender()}catch{}const g=t?.root;g instanceof HTMLElement?g.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),i()};return o.push(window.requestAnimationFrame(l)),o.push(window.requestAnimationFrame(()=>{o.push(window.requestAnimationFrame(l))})),()=>{for(const g of o)window.cancelAnimationFrame(g)}},xt=({original:r,modified:t,fileDiff:i,language:o,fileName:l,renderSideBySide:g,wrapLines:E,layout:C="fill",enableComments:u=!0})=>{const q=Ve(),P=q?.currentTheme.metadata.variant==="dark",O=q?.availableThemes.find(e=>e.metadata.id===q.lightThemeId)??Ae(!1),U=q?.availableThemes.find(e=>e.metadata.id===q.darkThemeId)??Ae(!0),{isMobile:oe}=Ue(),se=_e({source:"diff",fileLabel:l||"unknown",language:o,getCodeForRange:e=>nt(r,t,i,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:Q,selection:w,setSelection:H,commentText:D,setCommentText:I,editingDraftId:c,saveComment:b,cancel:R,startEdit:S,deleteDraft:$}=se,A=a.useRef(null),F=a.useRef(null),V=a.useRef(""),W=a.useRef(!1),ae=a.useRef(null);a.useEffect(()=>{A.current=w},[w]),a.useEffect(()=>{F.current=c},[c]),a.useEffect(()=>{V.current=D},[D]);const le=a.useCallback(e=>{if(!u||W.current)return;const n=A.current;if(!(!e&&n&&V.current.trim())){if(oe&&n&&e&&e.side===n.side){const s=Math.min(n.start,e.start),d=Math.max(n.end,e.end);H({...e,start:s,end:d})}else H(e);e&&(F.current||I(""))}},[u,oe,I,H]),$e=a.useCallback(()=>{R()},[R]),ke=a.useCallback(e=>{const n=document.createElement("div");n.style.position="relative";const s=he(e.metadata);return n.dataset.annotationId=s,n.dataset.annotationSide=e.side,n.dataset.annotationLine=String(e.lineNumber),n},[]),Ne=a.useCallback((e,n)=>{b(e,n??w??void 0)},[b,w]),G=a.useCallback(e=>{H(e);const n=z.current;if(n)try{W.current=!0,n.setSelectedLines(e),ae.current=e}catch{}finally{W.current=!1}},[H]),Z=a.useRef(null),me=a.useRef(null);a.useEffect(()=>{if(!u)return;const e=Y.current;if(!e)return;const n=()=>{const f=e.querySelector("diffs-container");return f instanceof HTMLElement?f.shadowRoot:null},s=f=>{const p=e.querySelector("diffs-container");p instanceof HTMLElement&&(f?p.setAttribute("data-oc-comment-drag",""):p.removeAttribute("data-oc-comment-drag"))},d=(f,p)=>{const re=n()?.elementFromPoint(f,p)??document.elementFromPoint(f,p);if(!(re instanceof Element))return null;const we=!!re.closest("[data-column-number]"),ie=re.closest("[data-line]");if(!(ie instanceof HTMLElement))return null;const Re=Number.parseInt(ie.getAttribute("data-line")??"",10);if(!Number.isFinite(Re)||Re<=0)return null;const We=ie.getAttribute("data-line-type")==="change-deletion"||ie.closest("[data-code][data-deletions]")!=null?"deletions":"additions";return{line:Re,side:We,numberColumn:we}};let h=null,m=!1,y=null;const k=f=>{Z.current=f;const p=z.current;if(p)try{W.current=!0,p.setSelectedLines(f)}catch{}finally{W.current=!1}},L=f=>{if(f.button!==0||f.pointerType!=="mouse")return;const p=d(f.clientX,f.clientY);if(!p||p.numberColumn){h=null;return}h={line:p.line,side:p.side},m=!1,y=f.pointerId},M=f=>{if(h==null||f.pointerId!==y)return;const p=d(f.clientX,f.clientY);if(p){if(!m){if(p.line===h.line)return;m=!0,s(!0),window.getSelection()?.removeAllRanges();const v=n();v&&"getSelection"in v&&v.getSelection()?.removeAllRanges()}k({start:Math.min(h.line,p.line),end:Math.max(h.line,p.line),side:h.side})}},x=f=>{if(h==null||f.pointerId!==y)return;const p=m;if(h=null,m=!1,y=null,s(!1),!p)return;const v=Z.current;Z.current=null,v&&(A.current&&V.current.trim()&&!F.current||(G(v),F.current||I("")))};return e.addEventListener("pointerdown",L),document.addEventListener("pointermove",M,{passive:!0}),document.addEventListener("pointerup",x),()=>{e.removeEventListener("pointerdown",L),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",x),s(!1)}},[G,u,I]);const Le=a.useCallback(e=>{if(!u)return;const n=Z.current,s=n&&e.start>=n.start&&e.end<=n.end&&(e.side==null||e.side===n.side);me.current!==null&&(window.clearTimeout(me.current),me.current=null),Z.current=null,G(s&&n?n:e),F.current||I("")},[G,u,I]),Ee=a.useCallback(e=>{if(!u||e.numberColumn||window.getSelection()?.toString().trim())return;const n=e.annotationSide,s={start:e.lineNumber,end:e.lineNumber,side:n},d=A.current;if(d&&d.start===s.start&&d.end===s.end&&d.side===s.side){if(!V.current.trim()){H(null);const h=z.current;try{W.current=!0,h?.setSelectedLines(null)}finally{W.current=!1}}return}d&&V.current.trim()&&!F.current||(G(s),F.current||I(""))},[G,u,I,H]),Se=a.useCallback(e=>{const n=e.closest("[data-line-type]")?.getAttribute("data-line-type")??e.getAttribute("data-line-type");if(n==="change-deletion")return"deletions";if(n==="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 d=e.closest("[data-line-type]");if(d instanceof HTMLElement){const h=d.getBoundingClientRect(),m=e.getBoundingClientRect(),y=h.left+h.width/2;return m.left+m.width/2<y?"deletions":"additions"}return"additions"},[]);Fe(O),Fe(U);const _=`${O.metadata.id}:${U.metadata.id}:${P?"dark":"light"}`,ee=a.useMemo(()=>{if(i){const e=i.deletionLines.reduce((s,d)=>s+d.length,0),n=i.additionLines.reduce((s,d)=>s+d.length,0);return Math.max(e,n)>qe}return Math.max(r.length,t.length)>qe},[i,t.length,r.length]),Y=a.useRef(null),X=a.useRef(null),z=a.useRef(null),te=a.useRef(null),pe=a.useRef(null),ge=a.useRef(null),ye=a.useRef(void 0),ce=a.useRef(void 0),de=a.useRef(void 0),ue=a.useRef(void 0),[,ve]=N.useReducer(e=>e+1,0),J=Ye(ee?"unified":g?"split":"unified"),B=a.useMemo(()=>Ie(O),[O]),j=a.useMemo(()=>Ie(U),[U]);N.useLayoutEffect(()=>{const e=Y.current;if(!e)return;const n=e.querySelector("diffs-container");if(!n)return;const s=P?j:B,d=(re,we)=>re.colors?.[we],h=d(B,"terminal.ansiGreen"),m=d(B,"terminal.ansiRed"),y=d(B,"terminal.ansiBlue"),k=d(j,"terminal.ansiGreen"),L=d(j,"terminal.ansiRed"),M=d(j,"terminal.ansiBlue");n.style.setProperty("--shiki-light",B.fg),n.style.setProperty("--shiki-light-bg",B.bg),h&&n.style.setProperty("--shiki-light-addition-color",h),m&&n.style.setProperty("--shiki-light-deletion-color",m),y&&n.style.setProperty("--shiki-light-modified-color",y),n.style.setProperty("--shiki-dark",j.fg),n.style.setProperty("--shiki-dark-bg",j.bg),k&&n.style.setProperty("--shiki-dark-addition-color",k),L&&n.style.setProperty("--shiki-dark-deletion-color",L),M&&n.style.setProperty("--shiki-dark-modified-color",M),n.style.setProperty("--diffs-bg",s.bg),n.style.setProperty("--diffs-fg",s.fg);const x=P?k:h,f=P?L:m,p=P?M:y;x&&n.style.setProperty("--diffs-addition-color-override",x),f&&n.style.setProperty("--diffs-deletion-color-override",f),p&&n.style.setProperty("--diffs-modified-color-override",p);const v=n.shadowRoot?.querySelector("pre");v&&(v.style.setProperty("--shiki-light",B.fg),v.style.setProperty("--shiki-light-bg",B.bg),h&&v.style.setProperty("--shiki-light-addition-color",h),m&&v.style.setProperty("--shiki-light-deletion-color",m),y&&v.style.setProperty("--shiki-light-modified-color",y),v.style.setProperty("--shiki-dark",j.fg),v.style.setProperty("--shiki-dark-bg",j.bg),k&&v.style.setProperty("--shiki-dark-addition-color",k),L&&v.style.setProperty("--shiki-dark-deletion-color",L),M&&v.style.setProperty("--shiki-dark-modified-color",M),v.style.setProperty("--diffs-bg",s.bg),v.style.setProperty("--diffs-fg",s.fg),x&&v.style.setProperty("--diffs-addition-color-override",x),f&&v.style.setProperty("--diffs-deletion-color-override",f),p&&v.style.setProperty("--diffs-modified-color-override",p))},[j,_,P,B]);const K=a.useMemo(()=>({theme:{dark:U.metadata.id,light:O.metadata.id},themeType:P?"dark":"light",diffStyle:g?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:ee?0:1e3,maxLineLengthForHighlighting:ee?1:1e3,tokenizeMaxLineLength:ee?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:E?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:u,enableGutterUtility:u,onGutterUtilityClick:u?Le:void 0,onLineClick:u?Ee:void 0,onLineSelected:u?le:void 0,unsafeCSS:et,renderAnnotation:u?ke:void 0}),[U.metadata.id,u,P,ee,O.metadata.id,g,E,le,Le,Ee,ke]),ne=a.useMemo(()=>u?Xe({drafts:Q,editingDraftId:c,selection:w}):[],[c,u,Q,w]),be=a.useRef(ne);if(a.useEffect(()=>{be.current=ne},[ne]),a.useEffect(()=>{const e=X.current;return()=>{z.current?.cleanUp(),z.current=null,te.current?.release(),te.current=null,pe.current=null,ge.current=null,ye.current=void 0,ce.current=void 0,de.current=void 0,ue.current=void 0,e&&(e.innerHTML="")}},[]),a.useEffect(()=>{if(typeof window>"u")return;const e=X.current,n=Y.current;if(!e||!J)return;const s=st(n,e);let d=te.current;d||(d=dt(e),te.current=d),te.current=d;const h=d?.virtualizer??null,m=i?void 0:{name:l||"",contents:r,lang:o,cacheKey:`old:${_}:${l}:${He(r)}`},y=i?void 0:{name:l||"",contents:t,lang:o,cacheKey:`new:${_}:${l}:${He(t)}`},k=i?ce.current!==i:ce.current!==void 0||!m||!y||!de.current||!ue.current||!Te(de.current,m)||!Te(ue.current,y),L=z.current,M=!!(L&&(pe.current!==h||ge.current!==J||h&&(ye.current!==K.hunkSeparators||k)));M&&(L?.cleanUp(),z.current=null,e.innerHTML="");let x=z.current;const f=!M&&L?!Be(L.options,K):!1;if(x?x.setOptions(K):(x=d?new je(K,d.virtualizer,lt,J):new Oe(K,J),z.current=x,ae.current=null),pe.current=h,ge.current=J,ye.current=h?K.hunkSeparators:void 0,ce.current=i,de.current=m,ue.current=y,i)x.render({fileDiff:i,forceRender:f,lineAnnotations:be.current,containerWrapper:e});else{if(!m||!y)return;x.render({oldFile:m,newFile:y,forceRender:f,lineAnnotations:be.current,containerWrapper:e})}const p=at(e,()=>{s(),ut(x,d,ve)});return()=>{p(),s()}},[_,i,l,o,t,K,r,J]),a.useEffect(()=>{const e=z.current;if(e){try{e.setLineAnnotations(ne)}catch(n){console.error("Failed to apply diff line annotations",n);try{e.setLineAnnotations([])}catch{}}requestAnimationFrame(()=>{if(z.current===e){try{e.rerender()}catch{}ve()}})}},[ne]),a.useEffect(()=>{const e=z.current;if(!e||w!==null)return;const n=ae.current;if(!rt(w,n))try{W.current=!0,e.setSelectedLines(w),ae.current=w}catch{}finally{W.current=!1}},[w]),a.useEffect(()=>{if(!u)return;const e=X.current;if(!e)return;let n=null,s=()=>{};const d=()=>{const m=e.querySelector("diffs-container")?.shadowRoot;if(!m){n=requestAnimationFrame(d);return}const y=k=>{if(!(k instanceof MouseEvent)||k.button!==0||!(k.target instanceof Element))return;const L=k.target.closest("[data-column-number]");if(!(L instanceof HTMLElement))return;const M=L.getAttribute("data-column-number"),x=M?parseInt(M,10):NaN;if(Number.isNaN(x))return;const f=Se(L);le({start:x,end:x,side:f}),k.preventDefault(),k.stopPropagation()};m.addEventListener("click",y,!0),s=()=>{m.removeEventListener("click",y,!0)}};return d(),()=>{n!==null&&cancelAnimationFrame(n),s()}},[_,u,l,le,Se]),a.useEffect(()=>{const e=X.current;if(!e)return;let n=null,s=null;const h=setTimeout(()=>{const m=e.querySelector("diffs-container");if(!(m instanceof HTMLElement))return;const y=m.shadowRoot;n=new MutationObserver(()=>{s&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{ve(),s=null})}),n.observe(m,{childList:!0,subtree:!0}),y&&n.observe(y,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(h),s&&cancelAnimationFrame(s),n?.disconnect()}},[_,l]),typeof window>"u")return null;const Me=u?T.jsx(Qe,{diffRootRef:Y,drafts:Q,selection:w,editingDraftId:c,commentText:D,onTextChange:I,fileLabel:l?.split("/").pop()??"",onSave:Ne,onCancel:$e,onEdit:e=>{G({start:e.startLine,end:e.endLine,side:e.side==="original"?"deletions":"additions"}),S(e)},onDelete:$}):null;return C==="fill"?T.jsx("div",{className:Ce("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:T.jsxs("div",{className:"flex-1 relative min-h-0",children:[T.jsx(Ge,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:T.jsx("div",{ref:Y,className:"size-full relative",children:T.jsx("div",{ref:X,className:"size-full"})})}),Me]})}):T.jsxs("div",{className:Ce("relative","w-full"),children:[T.jsx("div",{ref:Y,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative",children:T.jsx("div",{ref:X,className:"w-full"})}),Me]})};export{xt as P};
|
|
157
|
+
`)},rt=(r,t)=>r===t?!0:!r||!t?!1:r.start===t.start&&r.end===t.end&&r.side===t.side,it=r=>r==="auto"||r==="scroll"||r==="overlay",ot=r=>{let t=r?.parentElement??null;for(;t;){const i=window.getComputedStyle(t);if(it(i.overflowY))return t;t=t.parentElement}return null},st=(r,t)=>{if(!r||!t||typeof window>"u")return()=>{};const i=ot(r);if(!i)return()=>{};const o=t.getBoundingClientRect().height;if(!o)return()=>{};const l=r.getBoundingClientRect().top-i.getBoundingClientRect().top,g=t.style.minHeight;t.style.minHeight=`${Math.ceil(o)}px`;let E=!1;return()=>{if(E)return;E=!0,t.style.minHeight=g;const u=r.getBoundingClientRect().top-i.getBoundingClientRect().top-l;u&&(i.scrollTop+=u)}},at=(r,t)=>{if(typeof window>"u")return()=>{};let i=null,o=null,l=!1;const g=()=>{l||(o?.disconnect(),o=null,i=window.requestAnimationFrame(()=>{i=window.requestAnimationFrame(()=>{l||t()})}))},E=()=>r.querySelector("diffs-container")?.shadowRoot??void 0,C=(u=E())=>!!u?.querySelector("[data-line]");return C()?g():typeof MutationObserver<"u"?(o=new MutationObserver(()=>{const u=E();if(u){if(C(u)){g();return}o?.disconnect(),o=new MutationObserver(()=>{C(u)&&g()}),o.observe(u,{childList:!0,subtree:!0})}}),o.observe(r,{childList:!0,subtree:!0})):i=window.requestAnimationFrame(g),()=>{l=!0,o?.disconnect(),i!==null&&window.cancelAnimationFrame(i)}},fe=new WeakMap,lt={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function ct(r){const t=r.closest("[data-diff-virtual-root]");if(t instanceof HTMLElement){const i=t.querySelector("[data-diff-virtual-content]");return{key:t,root:t,content:i instanceof HTMLElement?i:void 0}}return{key:document,root:document,content:void 0}}function dt(r){if(typeof document>"u")return null;const t=ct(r);let i=fe.get(t.key);if(!i){const l=new De;l.setup(t.root,t.content),i={virtualizer:l,refs:0},fe.set(t.key,i)}i.refs+=1;let o=!1;return{virtualizer:i.virtualizer,root:t.root,release:()=>{if(o)return;o=!0;const l=fe.get(t.key);l&&(l.refs-=1,!(l.refs>0)&&(l.virtualizer.cleanUp(),fe.delete(t.key)))}}}const ut=(r,t,i)=>{if(typeof window>"u")return()=>{};const o=[],l=()=>{try{r.rerender()}catch{}const g=t?.root;g instanceof HTMLElement?g.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),i()};return o.push(window.requestAnimationFrame(l)),o.push(window.requestAnimationFrame(()=>{o.push(window.requestAnimationFrame(l))})),()=>{for(const g of o)window.cancelAnimationFrame(g)}},xt=({original:r,modified:t,fileDiff:i,language:o,fileName:l,renderSideBySide:g,wrapLines:E,layout:C="fill",enableComments:u=!0})=>{const q=Ve(),P=q?.currentTheme.metadata.variant==="dark",O=q?.availableThemes.find(e=>e.metadata.id===q.lightThemeId)??Ce(!1),U=q?.availableThemes.find(e=>e.metadata.id===q.darkThemeId)??Ce(!0),{isMobile:oe}=Ue(),se=_e({source:"diff",fileLabel:l||"unknown",language:o,getCodeForRange:e=>nt(r,t,i,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:Q,selection:w,setSelection:H,commentText:D,setCommentText:I,editingDraftId:c,saveComment:b,cancel:R,startEdit:S,deleteDraft:$}=se,A=a.useRef(null),F=a.useRef(null),V=a.useRef(""),W=a.useRef(!1),ae=a.useRef(null);a.useEffect(()=>{A.current=w},[w]),a.useEffect(()=>{F.current=c},[c]),a.useEffect(()=>{V.current=D},[D]);const le=a.useCallback(e=>{if(!u||W.current)return;const n=A.current;if(!(!e&&n&&V.current.trim())){if(oe&&n&&e&&e.side===n.side){const s=Math.min(n.start,e.start),d=Math.max(n.end,e.end);H({...e,start:s,end:d})}else H(e);e&&(F.current||I(""))}},[u,oe,I,H]),$e=a.useCallback(()=>{R()},[R]),ke=a.useCallback(e=>{const n=document.createElement("div");n.style.position="relative";const s=he(e.metadata);return n.dataset.annotationId=s,n.dataset.annotationSide=e.side,n.dataset.annotationLine=String(e.lineNumber),n},[]),Ne=a.useCallback((e,n)=>{b(e,n??w??void 0)},[b,w]),G=a.useCallback(e=>{H(e);const n=z.current;if(n)try{W.current=!0,n.setSelectedLines(e),ae.current=e}catch{}finally{W.current=!1}},[H]),Z=a.useRef(null),me=a.useRef(null);a.useEffect(()=>{if(!u)return;const e=Y.current;if(!e)return;const n=()=>{const f=e.querySelector("diffs-container");return f instanceof HTMLElement?f.shadowRoot:null},s=f=>{const p=e.querySelector("diffs-container");p instanceof HTMLElement&&(f?p.setAttribute("data-oc-comment-drag",""):p.removeAttribute("data-oc-comment-drag"))},d=(f,p)=>{const re=n()?.elementFromPoint(f,p)??document.elementFromPoint(f,p);if(!(re instanceof Element))return null;const we=!!re.closest("[data-column-number]"),ie=re.closest("[data-line]");if(!(ie instanceof HTMLElement))return null;const Re=Number.parseInt(ie.getAttribute("data-line")??"",10);if(!Number.isFinite(Re)||Re<=0)return null;const We=ie.getAttribute("data-line-type")==="change-deletion"||ie.closest("[data-code][data-deletions]")!=null?"deletions":"additions";return{line:Re,side:We,numberColumn:we}};let h=null,m=!1,y=null;const k=f=>{Z.current=f;const p=z.current;if(p)try{W.current=!0,p.setSelectedLines(f)}catch{}finally{W.current=!1}},L=f=>{if(f.button!==0||f.pointerType!=="mouse")return;const p=d(f.clientX,f.clientY);if(!p||p.numberColumn){h=null;return}h={line:p.line,side:p.side},m=!1,y=f.pointerId},M=f=>{if(h==null||f.pointerId!==y)return;const p=d(f.clientX,f.clientY);if(p){if(!m){if(p.line===h.line)return;m=!0,s(!0),window.getSelection()?.removeAllRanges();const v=n();v&&"getSelection"in v&&v.getSelection()?.removeAllRanges()}k({start:Math.min(h.line,p.line),end:Math.max(h.line,p.line),side:h.side})}},x=f=>{if(h==null||f.pointerId!==y)return;const p=m;if(h=null,m=!1,y=null,s(!1),!p)return;const v=Z.current;Z.current=null,v&&(A.current&&V.current.trim()&&!F.current||(G(v),F.current||I("")))};return e.addEventListener("pointerdown",L),document.addEventListener("pointermove",M,{passive:!0}),document.addEventListener("pointerup",x),()=>{e.removeEventListener("pointerdown",L),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",x),s(!1)}},[G,u,I]);const Le=a.useCallback(e=>{if(!u)return;const n=Z.current,s=n&&e.start>=n.start&&e.end<=n.end&&(e.side==null||e.side===n.side);me.current!==null&&(window.clearTimeout(me.current),me.current=null),Z.current=null,G(s&&n?n:e),F.current||I("")},[G,u,I]),Ee=a.useCallback(e=>{if(!u||e.numberColumn||window.getSelection()?.toString().trim())return;const n=e.annotationSide,s={start:e.lineNumber,end:e.lineNumber,side:n},d=A.current;if(d&&d.start===s.start&&d.end===s.end&&d.side===s.side){if(!V.current.trim()){H(null);const h=z.current;try{W.current=!0,h?.setSelectedLines(null)}finally{W.current=!1}}return}d&&V.current.trim()&&!F.current||(G(s),F.current||I(""))},[G,u,I,H]),Se=a.useCallback(e=>{const n=e.closest("[data-line-type]")?.getAttribute("data-line-type")??e.getAttribute("data-line-type");if(n==="change-deletion")return"deletions";if(n==="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 d=e.closest("[data-line-type]");if(d instanceof HTMLElement){const h=d.getBoundingClientRect(),m=e.getBoundingClientRect(),y=h.left+h.width/2;return m.left+m.width/2<y?"deletions":"additions"}return"additions"},[]);Fe(O),Fe(U);const _=`${O.metadata.id}:${U.metadata.id}:${P?"dark":"light"}`,ee=a.useMemo(()=>{if(i){const e=i.deletionLines.reduce((s,d)=>s+d.length,0),n=i.additionLines.reduce((s,d)=>s+d.length,0);return Math.max(e,n)>qe}return Math.max(r.length,t.length)>qe},[i,t.length,r.length]),Y=a.useRef(null),X=a.useRef(null),z=a.useRef(null),te=a.useRef(null),pe=a.useRef(null),ge=a.useRef(null),ye=a.useRef(void 0),ce=a.useRef(void 0),de=a.useRef(void 0),ue=a.useRef(void 0),[,ve]=N.useReducer(e=>e+1,0),J=Ye(ee?"unified":g?"split":"unified"),B=a.useMemo(()=>Ie(O),[O]),j=a.useMemo(()=>Ie(U),[U]);N.useLayoutEffect(()=>{const e=Y.current;if(!e)return;const n=e.querySelector("diffs-container");if(!n)return;const s=P?j:B,d=(re,we)=>re.colors?.[we],h=d(B,"terminal.ansiGreen"),m=d(B,"terminal.ansiRed"),y=d(B,"terminal.ansiBlue"),k=d(j,"terminal.ansiGreen"),L=d(j,"terminal.ansiRed"),M=d(j,"terminal.ansiBlue");n.style.setProperty("--shiki-light",B.fg),n.style.setProperty("--shiki-light-bg",B.bg),h&&n.style.setProperty("--shiki-light-addition-color",h),m&&n.style.setProperty("--shiki-light-deletion-color",m),y&&n.style.setProperty("--shiki-light-modified-color",y),n.style.setProperty("--shiki-dark",j.fg),n.style.setProperty("--shiki-dark-bg",j.bg),k&&n.style.setProperty("--shiki-dark-addition-color",k),L&&n.style.setProperty("--shiki-dark-deletion-color",L),M&&n.style.setProperty("--shiki-dark-modified-color",M),n.style.setProperty("--diffs-bg",s.bg),n.style.setProperty("--diffs-fg",s.fg);const x=P?k:h,f=P?L:m,p=P?M:y;x&&n.style.setProperty("--diffs-addition-color-override",x),f&&n.style.setProperty("--diffs-deletion-color-override",f),p&&n.style.setProperty("--diffs-modified-color-override",p);const v=n.shadowRoot?.querySelector("pre");v&&(v.style.setProperty("--shiki-light",B.fg),v.style.setProperty("--shiki-light-bg",B.bg),h&&v.style.setProperty("--shiki-light-addition-color",h),m&&v.style.setProperty("--shiki-light-deletion-color",m),y&&v.style.setProperty("--shiki-light-modified-color",y),v.style.setProperty("--shiki-dark",j.fg),v.style.setProperty("--shiki-dark-bg",j.bg),k&&v.style.setProperty("--shiki-dark-addition-color",k),L&&v.style.setProperty("--shiki-dark-deletion-color",L),M&&v.style.setProperty("--shiki-dark-modified-color",M),v.style.setProperty("--diffs-bg",s.bg),v.style.setProperty("--diffs-fg",s.fg),x&&v.style.setProperty("--diffs-addition-color-override",x),f&&v.style.setProperty("--diffs-deletion-color-override",f),p&&v.style.setProperty("--diffs-modified-color-override",p))},[j,_,P,B]);const K=a.useMemo(()=>({theme:{dark:U.metadata.id,light:O.metadata.id},themeType:P?"dark":"light",diffStyle:g?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:ee?0:1e3,maxLineLengthForHighlighting:ee?1:1e3,tokenizeMaxLineLength:ee?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:E?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:u,enableGutterUtility:u,onGutterUtilityClick:u?Le:void 0,onLineClick:u?Ee:void 0,onLineSelected:u?le:void 0,unsafeCSS:et,renderAnnotation:u?ke:void 0}),[U.metadata.id,u,P,ee,O.metadata.id,g,E,le,Le,Ee,ke]),ne=a.useMemo(()=>u?Xe({drafts:Q,editingDraftId:c,selection:w}):[],[c,u,Q,w]),be=a.useRef(ne);if(a.useEffect(()=>{be.current=ne},[ne]),a.useEffect(()=>{const e=X.current;return()=>{z.current?.cleanUp(),z.current=null,te.current?.release(),te.current=null,pe.current=null,ge.current=null,ye.current=void 0,ce.current=void 0,de.current=void 0,ue.current=void 0,e&&(e.innerHTML="")}},[]),a.useEffect(()=>{if(typeof window>"u")return;const e=X.current,n=Y.current;if(!e||!J)return;const s=st(n,e);let d=te.current;d||(d=dt(e),te.current=d),te.current=d;const h=d?.virtualizer??null,m=i?void 0:{name:l||"",contents:r,lang:o,cacheKey:`old:${_}:${l}:${He(r)}`},y=i?void 0:{name:l||"",contents:t,lang:o,cacheKey:`new:${_}:${l}:${He(t)}`},k=i?ce.current!==i:ce.current!==void 0||!m||!y||!de.current||!ue.current||!Te(de.current,m)||!Te(ue.current,y),L=z.current,M=!!(L&&(pe.current!==h||ge.current!==J||h&&(ye.current!==K.hunkSeparators||k)));M&&(L?.cleanUp(),z.current=null,e.innerHTML="");let x=z.current;const f=!M&&L?!Be(L.options,K):!1;if(x?x.setOptions(K):(x=d?new je(K,d.virtualizer,lt,J):new Oe(K,J),z.current=x,ae.current=null),pe.current=h,ge.current=J,ye.current=h?K.hunkSeparators:void 0,ce.current=i,de.current=m,ue.current=y,i)x.render({fileDiff:i,forceRender:f,lineAnnotations:be.current,containerWrapper:e});else{if(!m||!y)return;x.render({oldFile:m,newFile:y,forceRender:f,lineAnnotations:be.current,containerWrapper:e})}const p=at(e,()=>{s(),ut(x,d,ve)});return()=>{p(),s()}},[_,i,l,o,t,K,r,J]),a.useEffect(()=>{const e=z.current;if(e){try{e.setLineAnnotations(ne)}catch(n){console.error("Failed to apply diff line annotations",n);try{e.setLineAnnotations([])}catch{}}requestAnimationFrame(()=>{if(z.current===e){try{e.rerender()}catch{}ve()}})}},[ne]),a.useEffect(()=>{const e=z.current;if(!e||w!==null)return;const n=ae.current;if(!rt(w,n))try{W.current=!0,e.setSelectedLines(w),ae.current=w}catch{}finally{W.current=!1}},[w]),a.useEffect(()=>{if(!u)return;const e=X.current;if(!e)return;let n=null,s=()=>{};const d=()=>{const m=e.querySelector("diffs-container")?.shadowRoot;if(!m){n=requestAnimationFrame(d);return}const y=k=>{if(!(k instanceof MouseEvent)||k.button!==0||!(k.target instanceof Element))return;const L=k.target.closest("[data-column-number]");if(!(L instanceof HTMLElement))return;const M=L.getAttribute("data-column-number"),x=M?parseInt(M,10):NaN;if(Number.isNaN(x))return;const f=Se(L);le({start:x,end:x,side:f}),k.preventDefault(),k.stopPropagation()};m.addEventListener("click",y,!0),s=()=>{m.removeEventListener("click",y,!0)}};return d(),()=>{n!==null&&cancelAnimationFrame(n),s()}},[_,u,l,le,Se]),a.useEffect(()=>{const e=X.current;if(!e)return;let n=null,s=null;const h=setTimeout(()=>{const m=e.querySelector("diffs-container");if(!(m instanceof HTMLElement))return;const y=m.shadowRoot;n=new MutationObserver(()=>{s&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{ve(),s=null})}),n.observe(m,{childList:!0,subtree:!0}),y&&n.observe(y,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(h),s&&cancelAnimationFrame(s),n?.disconnect()}},[_,l]),typeof window>"u")return null;const Me=u?T.jsx(Qe,{diffRootRef:Y,drafts:Q,selection:w,editingDraftId:c,commentText:D,onTextChange:I,fileLabel:l?.split("/").pop()??"",onSave:Ne,onCancel:$e,onEdit:e=>{G({start:e.startLine,end:e.endLine,side:e.side==="original"?"deletions":"additions"}),S(e)},onDelete:$}):null;return C==="fill"?T.jsx("div",{className:Pe("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:T.jsxs("div",{className:"flex-1 relative min-h-0",children:[T.jsx(Ge,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:T.jsx("div",{ref:Y,className:"size-full relative",children:T.jsx("div",{ref:X,className:"size-full"})})}),Me]})}):T.jsxs("div",{className:Pe("relative","w-full"),children:[T.jsx("div",{ref:Y,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative",children:T.jsx("div",{ref:X,className:"w-full"})}),Me]})};export{xt as P};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{R as t,j as n}from"./vendor-react-BUCujlKS.js";import{m as bt,u as Ze,a as he,o as qe,r as Xe,v as jt}from"./index-DF5kMP-i.js";import{c as Ct,s as Rt,P as Pt,C as kt}from"./shikiHighlight-TEQCmzW8.js";import{f as Mt,y as H,c8 as Tt,ax as Nt,b as et,ai as Et,ac as It,W as Dt,b7 as Vt,N as Ft,f5 as At,Z as Lt,g_ as Wt,l as tt,f4 as $t,ao as nt,ge as Kt,f2 as zt,cV as rt,f7 as Ot,f8 as _t,m as Bt,g$ as Gt,b6 as st,a7 as ge,a8 as we,b3 as it,B as ne,I as z,a9 as ve,b5 as ot,b2 as re,g as Jt,c0 as Ut,aq as Ht,bZ as Qt,h0 as Yt}from"./useAppFontEffects-D7sNpuL2.js";import{u as Zt,n as qt}from"./useInlineCommentController-Brz_cLcQ.js";import{b as Xt}from"./CodeMirrorCommentWidgets-CSICpWQD.js";import{getResolvedShikiTheme as en}from"./appThemeRegistry-BK0dHKa6.js";import{E as tn}from"./vendor-codemirror-view-CiLROUVV.js";import{a5 as nn}from"./runtimeEndpointReset-CYJ9O_xX.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-CK21ihK-.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-BeMD8X_w.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"./contextPanelEmbeddedChat-C0ZLAepL.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-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.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-Dp3KMRQG.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./registerCustomTheme-BBXUCRnG.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 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()),cs=({targetPath:l=null,savedProjectPlan:c=null,onNavigatedToChat:o})=>{const{t:s}=Mt(),f=H(e=>e.currentSessionId),N=H(e=>e.createSession),g=H(e=>e.initializeNewAiWorkerSession),E=H(e=>e.sendMessage),ye=H(e=>e.setCurrentSession),xe=Tt(),O=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()??"",ke=Ze(e=>e.setSessionSwitcherOpen),_=Dt(),I=t.useSyncExternalStore(un,he,he),{isMobile:Me}=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]),Te=t.useMemo(()=>x(Pe||R),[Pe,R]),B=t.useMemo(()=>cn(Te,je,Ce),[Ce,Te,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,At(v),P]):null,A=v?.id===Lt,Y=t.useMemo(()=>{const e=v??B;return e?Re.get(e.path)?.isGitRepo===!0:!1},[B,Re,v]),[D,L]=t.useState(null),[Ne,Ee]=t.useState(!1),[p,k]=t.useState(null),[oe,ae]=t.useState(null),at=!!p||!!oe,le=t.useMemo(()=>!p||!R||!O?p:ln(p,{currentDirectory:R,homeDirectory:O}),[p,R,O]),[h,b]=t.useState(""),{isPlaying:Z,play:lt,stop:ct}=Wt(),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()?$t(h,s("planView.title.default")).title:s("planView.title.default"),[h,s]),q=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),Ae=t.useRef(null),pt=t.useRef(null),Le="aiworker:plan:md-viewer-mode";t.useEffect(()=>{try{const e=localStorage.getItem(Le);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(Le,JSON.stringify(e))}catch{}},[]),W=t.useRef(!1),M=t.useRef(null),[We,$]=t.useState(!1);t.useEffect(()=>{const e=()=>{W.current=!1,M.current=null,$(!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=Zt({source:"plan",fileLabel:de,language:p&&nt(p)||"markdown",getCodeForRange:e=>ht(h,qt(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})}),{drafts:$e,commentText:ee,setCommentText:Ke,editingDraftId:pe,setSelection:ze,saveComment:Oe,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),Oe(e,i??u??void 0),y(null)},[u,Oe]);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,Me,u]);const fe=Ze(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=Kt(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??qe()?.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:""},k(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=qe()?.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:""},k(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},k(l),b(d)}catch{if(e)return;k(null),b("")}finally{e||V(!1)}return}if(!S?.slug||!S?.time?.created||!R){k(null),b("");return}V(!0);try{const r=sn(R,S.time.created,S.slug),d=an(on(S.time.created,S.slug),O||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){k(null),b("");return}const w=JSON.stringify(["plan-file",I,m]);if(await C.pendingFor(w),e)return;const K=await i(m);if(e)return;C.reset(w),j.current={key:w,target:{filePath:m},content:K,editRevision:0,savedRevision:0,runtimeKey:I},k(m),b(K)}catch{if(e)return;k(null),b("")}finally{e||V(!1)}})(),()=>{e=!0}},[I,O,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(()=>{ke(!1),o?.()},[o,ke]),St=t.useCallback(async e=>{const i=v??B;if(!i||!D||A)return;const a=await rt(D.action==="improve"?"plan.improve.visible":"plan.implement.visible",{plan_title:q}),r=await rt(D.action==="improve"?"plan.improve.instructions":"plan.implement.instructions",{plan_title:q,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 AiWorker project knowledge (it is edited through the AiWorker 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,K=i.path;if(D.target==="worktree"){if(!Y)return;const T=await Ot(i.path,_t());if(!T?.id)return;w=T.id,K=T.path}else{const T=await N(void 0,i.path,null);if(!T?.id)return;w=T.id,K=T.directory??i.path,g(T.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,K);const xt=e.runAsGoal===!0?[`Implement the plan "${q}" 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),L(null)}finally{Ee(!1)}},[Y,h,N,B,g,A,D,p,Ye,v,E,q,ye]),yt=t.useMemo(()=>Xt({drafts:$e,editingDraftId:pe,commentText:ee,onTextChange:Ke,selection:u,isDragging:We,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,We,u,$e,de,Ke,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()||A,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:()=>L({action:"improve",target:"session"}),disabled:A,children:s("planView.actions.sendToNewSession")}),n.jsx(re,{onClick:()=>L({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()||A,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:()=>L({action:"implement",target:"session"}),disabled:A,children:s("planView.actions.sendToNewSession")}),n.jsx(re,{onClick:()=>L({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(Z?"planView.tts.stopSpeaking":"planView.tts.readAloud"),onClick:()=>{Z?ct():h.trim()&<(h)},children:Z?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(Z?"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&&L(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(kt,{value:h,onChange:vt,readOnly:!1,className:"h-full",extensions:wt,onViewReady:e=>{Ae.current=e},onViewDestroy:()=>{Ae.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(),W.current=!1,M.current=null,$(!1),!0;if(Me&&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}),W.current=!1,M.current=null,$(!1),!0}if(W.current=!0,M.current=r,$(!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||!W.current||M.current===null)return!1;const r=e.state.doc.lineAt(i.from).number,d=Math.min(M.current,r),m=Math.max(M.current,r);return y({start:d,end:m}),$(!0),!1},mouseup:()=>(W.current=!1,M.current=null,$(!1),!1)}}})})})})})})]})};export{cs as PlanView};
|