@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,17 +0,0 @@
|
|
|
1
|
-
import{f as gt,R as n,c as Sn,j as s,r as ir}from"./vendor-react-BUCujlKS.js";import{R as la,S as ca,T as ua,U as da,al as kn,n as He,u as ht,d5 as fa,C as Rn,w as ma,r as Tn,W as Vn,e as pa,d3 as ha,aO as ga,d4 as xa,a as va}from"./index-DW_E3rnL.js";import{f as Bt,y as En,ab as Yn,bS as wa,h as q,ht as ba,fj as ya,S as ss,B as z,I as b,V as ja,L as Fa,b5 as Na,ad as Ca,c8 as Sa,hu as Dn,hv as ka,g_ as Ra,fk as Ta,t as Q,l as Pn,am as ar,c3 as Cs,cC as Va,b as Ea,hw as or,bF as Da,an as Mn,hx as zn,c4 as An,c5 as Pa,gd as Ma,hy as za,hz as Aa,hA as La,bG as Zn,bH as ei,bI as ti,bJ as si,bK as ri,bL as ni,b4 as mr,b1 as pr,ap as ks,b3 as hr,b0 as Rs,c2 as lr,ao as cr,b_ as Ln,a6 as zt,a7 as At,a8 as Lt,bD as Ia,bE as Oa,g as Vs,b2 as Ba,bc as $a}from"./useAppFontEffects-CjrntdL0.js";import{$ as Wa,y as _a,z as Ua,A as Ka,B as Ha,E as Ga}from"./runtimeEndpointReset-CjhvxLH0.js";import{c as In,s as qa,C as On,P as ur}from"./shikiHighlight-DYOWuY65.js";import{a as Xa}from"./vendor-codemirror-state-C9awkmn-.js";import{E as jt}from"./vendor-codemirror-view-CiLROUVV.js";import{J as Ja,F as Qa}from"./JsonTreeView-B0BdZEHG.js";import{ensurePierreThemeRegistered as Bn,getResolvedShikiTheme as Ya}from"./appThemeRegistry-BK0dHKa6.js";import{V as Za,W as eo}from"./Virtualizer-CZlLSacm.js";import{V as to}from"./Virtualizer-D_a8gKmg.js";import{u as Ss,c as so,e as ro}from"./scheduledTasksApi-DLW0mkQK.js";import{D as no}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as io,u as ao,n as oo}from"./useInlineCommentController-CDEuSlPH.js";import{b as lo}from"./CodeMirrorCommentWidgets-B3u7UIcE.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-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.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-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.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";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-Bhg83tjf.js";import"./computeVirtualFileMetrics-BMIRgMHv.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-QfoiKJNY.js";import"./registerCustomTheme-BBXUCRnG.js";function $n(a){const e=gt.c(41),{containerRef:r,filePath:d,fileContent:v}=a,{t:g}=Bt(),x=En(xo),w=En(go),f=Yn(),C=wa(ho),[h,F]=n.useState(null),[N,k]=n.useState(""),[j,T]=n.useState(!1),o=n.useRef(!1),L=n.useRef(null),I=n.useRef(null),[W,A]=n.useState(null);let E;e[0]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{F(null),k(""),T(!1),o.current=!1,I.current=null,A(null)},e[0]=E):E=e[0];const V=E;let S,M;e[1]!==r?(S=()=>{const B=r.current;if(!B)return;const G=()=>{if(o.current)return;const re=window.getSelection(),Se=re?.toString().trim()??"";if(!re||!Se||re.rangeCount===0){V();return}const ie=re.getRangeAt(0);if(!B.contains(ie.commonAncestorContainer)){V();return}const ae=ie.getBoundingClientRect();I.current=ie.cloneRange(),k(Se),F({x:ae.left+ae.width/2,y:ae.top-10})},se=re=>{L.current?.contains(re.target)||o.current&&V()};return document.addEventListener("selectionchange",G),document.addEventListener("pointerdown",se),()=>{document.removeEventListener("selectionchange",G),document.removeEventListener("pointerdown",se)}},M=[r,V],e[1]=r,e[2]=S,e[3]=M):(S=e[2],M=e[3]),n.useEffect(S,M);let $;e[4]!==v?($=B=>{const G=de=>v.slice(0,de).split(`
|
|
2
|
-
`).length,se=mo,re=(de,Ve)=>{for(const Ee of se(de)){const ke=v.indexOf(Ee,Ve);if(ke>=0)return ke}return-1},Se=B.length>=8?v.indexOf(B):-1;if(Se>=0){const de=G(Se);return{start:de,end:de+B.split(`
|
|
3
|
-
`).length-1}}const ie=B.split(`
|
|
4
|
-
`).map(fo).filter(Boolean);if(ie.length===0)return null;const ae=re(ie[0],0);if(ae<0)return null;const ye=G(ae);if(ie.length===1)return{start:ye,end:ye};const Te=re(ie[ie.length-1],ae);return Te<0?null:{start:ye,end:Math.max(ye,G(Te))}},e[4]=v,e[5]=$):$=e[5];const P=$;let J;e[6]===Symbol.for("react.memo_cache_sentinel")?(J=()=>{const B=I.current;if(!B){A(null);return}A(ba(B))},e[6]=J):J=e[6];const Ne=J;let _,Y;e[7]!==j?(_=()=>{if(!j)return;let B=null;const G=()=>{B===null&&(B=window.requestAnimationFrame(()=>{B=null,Ne()}))};return document.addEventListener("scroll",G,{capture:!0,passive:!0}),window.addEventListener("resize",G),()=>{B!==null&&window.cancelAnimationFrame(B),document.removeEventListener("scroll",G,{capture:!0}),window.removeEventListener("resize",G)}},Y=[j,Ne],e[7]=j,e[8]=_,e[9]=Y):(_=e[8],Y=e[9]),n.useEffect(_,Y);let ee;e[10]!==N?(ee=()=>{N&&(T(!0),o.current=!0,Ne(),window.getSelection()?.removeAllRanges())},e[10]=N,e[11]=ee):ee=e[11];const le=ee;let te;e[12]!==C||e[13]!==x||e[14]!==f||e[15]!==d||e[16]!==w||e[17]!==P||e[18]!==N?(te=B=>{const G=x??(w?"draft":null);if(!N||!G||!f){V();return}const se=P(N);C({directory:f,sessionKey:G},{source:"file-quote",fileLabel:d,startLine:se?.start??0,endLine:se?.end??0,code:N,language:"",text:B.trim()}),V(),queueMicrotask(uo)},e[12]=C,e[13]=x,e[14]=f,e[15]=d,e[16]=w,e[17]=P,e[18]=N,e[19]=te):te=e[19];const Ce=te;if(!h)return null;let O;e[20]!==j||e[21]!==P||e[22]!==N?(O=j?P(N):null,e[20]=j,e[21]=P,e[22]=N,e[23]=O):O=e[23];const ve=O;let we;e[24]!==h.x||e[25]!==h.y?(we={left:h.x,top:h.y,transform:"translate(-50%, -100%)"},e[24]=h.x,e[25]=h.y,e[26]=we):we=e[26];let ce;e[27]!==j||e[28]!==W?(ce=j&&W&&W.length>0?Sn.createPortal(s.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:W.map(co)}),document.body):null,e[27]=j,e[28]=W,e[29]=ce):ce=e[29];let ue;e[30]!==j||e[31]!==d||e[32]!==ve||e[33]!==le||e[34]!==Ce||e[35]!==g?(ue=j?s.jsx("div",{className:"w-[min(420px,80vw)]",children:s.jsx(io,{fileLabel:d,lineRange:ve?{start:ve.start,end:ve.end}:void 0,onSave:Ce,onCancel:V})}):s.jsx("div",{className:q("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:s.jsx("button",{type:"button",onClick:le,className:q("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-[var(--surface-foreground)]","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:g("chat.textSelection.title.commentOnSelection"),children:g("chat.textSelection.actions.comment")})}),e[30]=j,e[31]=d,e[32]=ve,e[33]=le,e[34]=Ce,e[35]=g,e[36]=ue):ue=e[36];let be;return e[37]!==we||e[38]!==ce||e[39]!==ue?(be=Sn.createPortal(s.jsxs("div",{ref:L,className:"fixed z-50",style:we,children:[ce,ue]}),document.body),e[37]=we,e[38]=ce,e[39]=ue,e[40]=be):be=e[40],be}function co(a,e){return s.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:a.left,top:a.top,width:a.width,height:a.height}},e)}function uo(){ya()}function fo(a){return a.trim()}function mo(a){const e=a.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(po)}function po(a){return a.length>=8}function ho(a){return a.addDraft}function go(a){return a.newSessionDraft?.open}function xo(a){return a.currentSessionId}const vo=(a,e)=>{if(!e)return null;const r=Number.parseInt(a.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},Wn=(a,e)=>{const r=a.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},_n=(a,e,r)=>{const d=a.state.doc.line(e),v=Math.max(1,Math.min(r,d.length+1)),g=d.from+v-1;a.dispatch({selection:Xa.cursor(g),effects:jt.scrollIntoView(g,{y:"center"})})};function wo({open:a,onOpenChange:e,view:r,variant:d="overlay"}){const{t:v}=Bt(),[g,x]=n.useState(""),w=n.useRef(null),f=n.useRef(!1),C=n.useRef(null),h=n.useRef(null),F=n.useMemo(()=>vo(g,r),[g,r]);n.useEffect(()=>{!a||!r||(f.current=!1,w.current=Wn(r,r.state.selection),x(""))},[a,r]),n.useEffect(()=>{a&&window.requestAnimationFrame(()=>{h.current?.focus(),h.current?.select()})},[a]),n.useEffect(()=>{if(!(!a||!r||!w.current)){if(F===null){const{selection:o}=w.current;r.dispatch({selection:o,effects:jt.scrollIntoView(o.main.from,{y:"center"})});return}_n(r,F,w.current.character)}},[F,a,r]);const N=n.useCallback(()=>{if(!r||f.current||!w.current)return;const{selection:o}=w.current;r.dispatch({selection:o,effects:jt.scrollIntoView(o.main.from,{y:"center"})})},[r]),k=n.useCallback(o=>{o||N(),e(o)},[e,N]),j=n.useCallback(()=>{!r||F===null||!w.current||(f.current=!0,_n(r,F,w.current.character),e(!1),r.focus())},[F,e,r]);n.useEffect(()=>{if(!a)return;const o=I=>{const W=C.current,A=I.target;!W||!(A instanceof Node)||W.contains(A)||k(!1)},L=I=>{I.key==="Escape"&&(I.preventDefault(),k(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",L,!0)}},[k,a,d]);const T=n.useMemo(()=>{if(!r)return v("goToLineDialog.helper.editorUnavailable");if(F===null){const o=w.current??Wn(r,r.state.selection);return v("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:r.state.doc.lines})}return v("goToLineDialog.helper.goToLine",{line:F})},[F,v,r]);return d==="inline"?a?s.jsxs("div",{ref:C,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(ss,{ref:h,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:o=>x(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),j())},placeholder:v("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx(z,{variant:"outline",size:"xs",onClick:j,disabled:!r||F===null,className:"h-6 px-2",children:v("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:C,className:q("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",a?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(ss,{ref:h,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:o=>x(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),j())},placeholder:v("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:T})]})})}const bo=(a,e)=>{const r=e.trim().toLowerCase(),d=[];if(!r)return d;const v=a.toLowerCase();let g=0;for(;;){const x=v.indexOf(r,g);if(x===-1)break;d.push({start:x,end:x+r.length}),g=x+r.length}return d},Ds="data-md-find",dr="data-md-find-current",ii="rounded-[2px] bg-status-warning/30 text-foreground",yo="rounded-[2px] bg-status-warning/60 text-foreground",jo=120,Fo=a=>a instanceof Element&&a.hasAttribute(Ds),No=a=>a.target instanceof Element&&a.target.hasAttribute(Ds)?!0:[...a.addedNodes].some(e=>Fo(e)),ai=a=>{const e=new Set;a.querySelectorAll(`mark[${Ds}]`).forEach(r=>{const d=r.parentNode;d&&(d.replaceChild(document.createTextNode(r.textContent??""),r),e.add(d))}),e.forEach(r=>r.normalize())},Co=(a,e)=>{ai(a);const r=e.trim().toLowerCase();if(!r)return[];const d=[],v=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,{acceptNode(x){const w=x.parentElement;return!w||w.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),g=[];for(;v.nextNode();){const x=v.currentNode;x instanceof Text&&g.push(x)}for(const x of g){const w=x.nodeValue??"";if(!w)continue;const f=bo(w,r);if(f.length===0)continue;const C=x.parentNode;if(!C)continue;const h=document.createDocumentFragment();let F=0;for(const N of f){N.start>F&&h.appendChild(document.createTextNode(w.slice(F,N.start)));const k=document.createElement("mark");k.setAttribute(Ds,""),k.className=ii,k.textContent=w.slice(N.start,N.end),h.appendChild(k),d.push(k),F=N.end}F<w.length&&h.appendChild(document.createTextNode(w.slice(F))),C.replaceChild(h,x)}return d},Un=({containerRef:a,open:e,onOpenChange:r,focusNonce:d,className:v})=>{const{t:g}=Bt(),[x,w]=n.useState(""),[f,C]=n.useState(0),[h,F]=n.useState(0),N=n.useRef(null),k=n.useRef([]),j=n.useRef(x);j.current=x;const T=n.useRef(null),o=n.useRef(null),L=n.useCallback((S,M=!1)=>{const $=a.current;if(!$){k.current=[],C(0),F(0);return}k.current=Co($,S);const P=k.current.length;C(P),F(J=>!M||P===0?0:Math.min(J,P-1))},[a]),I=n.useCallback((S,M=!1)=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{T.current=null,L(S,M)},jo)},[L]);n.useEffect(()=>()=>{T.current&&clearTimeout(T.current)},[]);const W=n.useCallback(()=>{r(!1);const S=o.current;o.current=null,S?.isConnected&&S.focus()},[r]);n.useEffect(()=>{const S=a.current;if(!e||!S)return;const M=new MutationObserver($=>{!j.current.trim()||!$.some(J=>!No(J))||I(j.current,!0)});return M.observe(S,{childList:!0,subtree:!0,characterData:!0}),()=>{M.disconnect(),ai(S)}},[a,e,I]),n.useEffect(()=>{if(!e)return;const S=document.activeElement;S instanceof HTMLElement&&!o.current&&(o.current=S),N.current?.focus()},[e]),n.useEffect(()=>{e&&d>0&&(N.current?.focus(),N.current?.select())},[e,d]),n.useEffect(()=>{const S=a.current;if(!S||(S.querySelectorAll(`mark[${dr}]`).forEach($=>{$.removeAttribute(dr),$.className=ii}),f===0))return;const M=k.current[Math.min(Math.max(h,0),f-1)];M&&(M.setAttribute(dr,""),M.className=yo,M.scrollIntoView({block:"nearest"}))},[a,h,f]);const A=n.useCallback(()=>{F(S=>f===0?0:(S+1)%f)},[f]),E=n.useCallback(()=>{F(S=>f===0?0:(S-1+f)%f)},[f]),V=n.useCallback(S=>{S.key==="Enter"?(S.preventDefault(),S.shiftKey?E():A()):S.key==="Escape"&&(S.preventDefault(),W())},[W,A,E]);return e?s.jsxs("div",{className:q("absolute right-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",v),children:[s.jsx(b,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),s.jsx(ss,{ref:N,value:x,onChange:S=>{w(S.target.value),I(S.target.value)},onKeyDown:V,placeholder:g("filesView.preview.find.placeholder"),"aria-label":g("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),s.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":f>0?g("filesView.preview.find.countAria",{current:h+1,total:f}):g("filesView.preview.find.noMatches"),children:x.trim()&&f===0?g("filesView.preview.find.noMatches"):f>0?`${h+1}/${f}`:""}),s.jsx(z,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:E,title:g("filesView.preview.find.previousAria"),"aria-label":g("filesView.preview.find.previousAria"),disabled:f===0,children:s.jsx(b,{name:"arrow-up",className:"size-3.5"})}),s.jsx(z,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:A,title:g("filesView.preview.find.nextAria"),"aria-label":g("filesView.preview.find.nextAria"),disabled:f===0,children:s.jsx(b,{name:"arrow-down",className:"size-3.5"})}),s.jsx(z,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:W,title:g("filesView.preview.find.closeAria"),"aria-label":g("filesView.preview.find.closeAria"),children:s.jsx(b,{name:"close",className:"size-3.5"})})]}):null};function Kn(){const a=gt.c(8),[e]=ir.useState(So),r=ir.useRef(!1);let d;a[0]!==e?(d=f=>{if(f==null){e.cleanUp(),r.current=!1;return}r.current||(r.current=!0,e.setup(f,f.firstElementChild??void 0))},a[0]=e,a[1]=d):d=a[1];const v=d;let g,x;a[2]!==e?(g=()=>()=>{r.current=!1,e.cleanUp()},x=[e],a[2]=e,a[3]=g,a[4]=x):(g=a[3],x=a[4]),ir.useLayoutEffect(g,x);let w;return a[5]!==v||a[6]!==e?(w={virtualizer:e,setScroller:v},a[5]=v,a[6]=e,a[7]=w):w=a[7],w}function So(){return new to}function ko(a){return!(!a.autoSaveEnabled||!a.isDirty||!a.canWrite||a.isSaving||a.fileLoading||a.isNonEditableBinary||!a.selectedFilePath||a.loadedFilePath!==a.selectedFilePath)}function Ro(a){return a.selectedFilePath?a.isDirty?!(a.fileLoading||a.loadedFilePath!==a.selectedFilePath||a.isNonEditableBinary||a.draftContent===""&&a.fileContent!==""&&a.loadedFilePath!==a.selectedFilePath):!0:!1}const To='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function Hn(){if(typeof document>"u")return!1;const a=document.documentElement.getAttribute("data-theme");return a==="dark"||!a&&window.matchMedia("(prefers-color-scheme: dark)").matches}const Vo=n.forwardRef(function({xml:e,readOnly:r,className:d,onChange:v},g){const x=n.useRef(e),w=n.useRef(null),f=n.useRef(!1),[C,h]=n.useState(Hn),F=n.useRef(e),N=n.useRef(e);N.current!==e&&(N.current=e,F.current=e,x.current=e);const k=n.useRef(C);k.current!==C&&(k.current=C,F.current=x.current);const j=n.useRef(null);n.useEffect(()=>{const L=()=>h(Hn());L();const I=new MutationObserver(L);return I.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>I.disconnect()},[]),n.useEffect(()=>{const L=setTimeout(()=>{j.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(L)},[]),n.useImperativeHandle(g,()=>({getXml:()=>x.current}));const T=n.useCallback(()=>{!e&&!f.current&&(f.current=!0,setTimeout(()=>{w.current?.template({})},500))},[e]),o=n.useCallback(L=>{x.current=L.xml,v?.(L.xml)},[v]);return s.jsx("div",{ref:j,className:q("h-full w-full",d),children:s.jsx(no,{ref:w,xml:F.current||To,autosave:!0,urlParameters:{ui:r?"simple":C?"dark":"kennedy",spin:!0,libraries:!r,chrome:r,nav:r,layers:r,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:T,onAutoSave:o},C?"dark":"light")})}),Eo=a=>{const e=H(a);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const r=e.lastIndexOf("/");if(r<0)return e;if(r===0)return"/";const d=e.slice(0,r);return/^[A-Za-z]:$/.test(d)?`${d}/`:d},Do=a=>{const e=gt.c(8),{label:r,iconDataUrl:d}=a,[v,g]=n.useState(!1);let x;e[0]!==r?(x=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=x):x=e[1];const w=x;if(d&&!v){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>g(!0),e[2]=h):h=e[2];let F;return e[3]!==d?(F=s.jsx("img",{src:d,alt:"",className:"size-4 rounded-sm",onError:h}),e[3]=d,e[4]=F):F=e[4],F}let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=q("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=f):f=e[5];let C;return e[6]!==w?(C=s.jsx("span",{className:f,children:w}),e[6]=w,e[7]=C):C=e[7],C},Po=a=>a.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),H=a=>{if(!a)return"";const e=a.replace(/\\/g,"/"),r=e.startsWith("//");let d=e.replace(/\/+/g,"/");r&&!d.startsWith("//")&&(d=`/${d}`);const v=d==="/",g=/^[A-Za-z]:\/$/.test(d);return!v&&!g&&(d=d.replace(/\/+$/,"")),d},Mo=a=>a.startsWith("/")||a.startsWith("//")||/^[A-Za-z]:\//.test(a),Ot=a=>/^[A-Za-z]:\//.test(a)?a.toLowerCase():a,Es=(a,e)=>{const r=H(e),d=H(a);if(!r||!d)return!1;const v=Ot(r),g=Ot(d);return g===v||g.startsWith(`${v}/`)},Gn=(a,e)=>{const r=H(e),d=H(a);if(!Es(d,r))return[];const g=d.slice(r.length).replace(/^\//,"").split("/"),x=[];let w=r;for(let f=0;f<g.length-1;f++)w=w?`${w}/${g[f]}`:g[f],x.push(w);return x},Ts=(a,e)=>{if(!e)return"";const r=H(e);if(!a||!Es(r,a))return r;const d=r.slice(a.length);return d.startsWith("/")?d.slice(1):d},zo=new Set(["node_modules"]),Ao=a=>{const e=gt.c(3),{status:r}=a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=d):d=e[0];const v=d[r];let g;return e[1]!==v?(g=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:v}}),e[1]=v,e[2]=g):g=e[2],g},qn=a=>{const e=gt.c(11),{name:r}=a,d=n.useRef(null),v=n.useRef(null),[g,x]=n.useState(!1);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{const N=d.current,k=v.current;if(!N||!k)return;const j=()=>{x(k.scrollWidth>N.clientWidth+1)};j();const T=new ResizeObserver(j);return T.observe(N),T.observe(k),()=>{T.disconnect()}},e[0]=w):w=e[0];let f;e[1]!==r?(f=[r],e[1]=r,e[2]=f):f=e[2],n.useLayoutEffect(w,f);let C;e[3]!==r?(C=s.jsx("span",{ref:v,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=C):C=e[4];let h;e[5]!==r||e[6]!==g?(h=g?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:r}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):s.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=g,e[7]=h):h=e[7];let F;return e[8]!==C||e[9]!==h?(F=s.jsxs("span",{ref:d,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[C,h]}),e[8]=C,e[9]=h,e[10]=F):F=e[10],F},Lo=a=>zo.has(a),Io=a=>{const e=H(a);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Oo=a=>{const r=(a instanceof Error?a.message:String(a??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},Xn=a=>{const r=(a instanceof Error?a.message:String(a??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},It=2e5;function Bo(a){const e=a.length>400?`${a.slice(0,200)}${a.slice(-200)}`:a;let r=2166136261;for(let d=0;d<e.length;d+=1)r^=e.charCodeAt(d),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return`${a.length}:${r.toString(16)}`}const $o=a=>{let e=0,r=0;for(let d=0;d<a.length;d+=1)a.charCodeAt(d)===10&&(d>0&&a.charCodeAt(d-1)===13?e+=1:r+=1);return e>r?`\r
|
|
5
|
-
`:`
|
|
6
|
-
`},oi=a=>a.replace(/\r\n/g,`
|
|
7
|
-
`).replace(/\r/g,`
|
|
8
|
-
`),Wo=(a,e)=>{const r=oi(a);return e===`\r
|
|
9
|
-
`?r.replace(/\n/g,`\r
|
|
10
|
-
`):r},li=(a,e)=>s.jsx(ks,{filePath:a,extension:e}),Jn=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},_o=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},fr=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Uo=a=>{const e=gt.c(76),{node:r,root:d,isExpanded:v,isActive:g,isMobile:x,isBrowserClient:w,alwaysShowActions:f,status:C,badge:h,permissions:F,downloadFile:N,contextMenuPath:k,setContextMenuPath:j,rightClickMenuPath:T,setRightClickMenuPath:o,onSelect:L,onToggle:I,onRevealPath:W,onOpenDialog:A}=a,{t:E}=Bt(),V=r.type==="directory",{canRename:S,canCreateFile:M,canCreateFolder:$,canDelete:P,canReveal:J}=F,Ne=!V&&!!N,_=J&&!w,Y=S||M||$||P||Ne||_;let ee;e[0]!==Y||e[1]!==r.path||e[2]!==o?(ee=fe=>{Y&&(fe?.preventDefault(),o(r.path))},e[0]=Y,e[1]=r.path,e[2]=o,e[3]=ee):ee=e[3];const le=ee;let te;e[4]!==V||e[5]!==r||e[6]!==L||e[7]!==I?(te=()=>{V?I(r.path):L(r)},e[4]=V,e[5]=r,e[6]=L,e[7]=I,e[8]=te):te=e[8];const Ce=te;let O;e[9]!==r.path||e[10]!==j||e[11]!==o?(O=fe=>{fe.stopPropagation(),o(null),j(r.path)},e[9]=r.path,e[10]=j,e[11]=o,e[12]=O):O=e[12];const ve=O;let we;e[13]!==M||e[14]!==$||e[15]!==P||e[16]!==S||e[17]!==_||e[18]!==N||e[19]!==w||e[20]!==V||e[21]!==r||e[22]!==A||e[23]!==W||e[24]!==d||e[25]!==E?(we=fe=>{const{Item:he,Separator:et}=fe;return s.jsxs(s.Fragment,{children:[S&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),A("rename",r)},children:[s.jsx(b,{name:"edit",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.rename")]}),s.jsxs(he,{onClick:X=>{X.stopPropagation(),Vs(r.path).then(at=>{if(at.ok){Q.success(E("sidebarFilesTree.toast.pathCopied"));return}Q.error(E("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(b,{name:"file-copy",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.copyPath")]}),s.jsxs(he,{onClick:X=>{X.stopPropagation();const at=Ts(d,r.path)||r.path;Vs(at).then(me=>{if(me.ok){Q.success(E("filesView.toast.relativePathCopied"));return}Q.error(E("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(b,{name:"file-copy-2",className:"mr-2 size-4"})," ",E("filesView.tree.menu.copyRelativePath")]}),!V&&N&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),N(r.path).catch(at=>{console.error("Download failed:",at),Q.error(E("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(b,{name:"download",className:"mr-2 size-4"})," ",E(w?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),_&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),W(r.path)},children:[s.jsx(b,{name:"folder-received",className:"mr-2 size-4"})," ",E($a())]}),V&&(M||$)&&s.jsxs(s.Fragment,{children:[s.jsx(et,{}),M&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),A("createFile",r)},children:[s.jsx(b,{name:"file-add",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.newFile")]}),$&&s.jsxs(he,{onClick:X=>{X.stopPropagation(),A("createFolder",r)},children:[s.jsx(b,{name:"folder-add",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.newFolder")]})]}),P&&s.jsxs(s.Fragment,{children:[s.jsx(et,{}),s.jsxs(he,{onClick:X=>{X.stopPropagation(),A("delete",r)},className:"text-destructive focus:text-destructive",children:[s.jsx(b,{name:"delete-bin",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.delete")]})]})]})},e[13]=M,e[14]=$,e[15]=P,e[16]=S,e[17]=_,e[18]=N,e[19]=w,e[20]=V,e[21]=r,e[22]=A,e[23]=W,e[24]=d,e[25]=E,e[26]=we):we=e[26];const ce=we,ue=T===r.path;let be;e[27]!==r.path||e[28]!==o?(be=fe=>o(fe?r.path:null),e[27]=r.path,e[28]=o,e[29]=be):be=e[29];const B=x?void 0:le;let G;e[30]!==B?(G=s.jsx("div",{className:"group relative flex items-center",onContextMenu:B}),e[30]=B,e[31]=G):G=e[31];const se=x?void 0:le,re=g?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let Se;e[32]!==re?(Se=q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",re),e[32]=re,e[33]=Se):Se=e[33];let ie;e[34]!==V||e[35]!==v||e[36]!==r.extension||e[37]!==r.path?(ie=V?v?s.jsx(b,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(b,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):li(r.path,r.extension),e[34]=V,e[35]=v,e[36]=r.extension,e[37]=r.path,e[38]=ie):ie=e[38];let ae;e[39]!==r.name||e[40]!==r.path?(ae=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:r.path,children:r.name}),e[39]=r.name,e[40]=r.path,e[41]=ae):ae=e[41];let ye;e[42]!==V||e[43]!==C?(ye=!V&&C&&s.jsx(Ao,{status:C}),e[42]=V,e[43]=C,e[44]=ye):ye=e[44];let Te;e[45]!==h||e[46]!==V?(Te=V&&h&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[h.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",h.modified]}),h.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",h.added]})]}),e[45]=h,e[46]=V,e[47]=Te):Te=e[47];let de;e[48]!==Ce||e[49]!==Se||e[50]!==ie||e[51]!==ae||e[52]!==ye||e[53]!==Te||e[54]!==se?(de=s.jsxs("button",{type:"button",onClick:Ce,onContextMenu:se,className:Se,children:[ie,ae,ye,Te]}),e[48]=Ce,e[49]=Se,e[50]=ie,e[51]=ae,e[52]=ye,e[53]=Te,e[54]=se,e[55]=de):de=e[55];let Ve;e[56]!==f||e[57]!==k||e[58]!==ve||e[59]!==Y||e[60]!==x||e[61]!==r.path||e[62]!==ce||e[63]!==j?(Ve=Y&&s.jsx("div",{className:q("absolute right-1 top-1/2 -translate-y-1/2",f?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(mr,{open:k===r.path,onOpenChange:fe=>j(fe?r.path:null),children:[s.jsx(pr,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"icon",className:"size-6",onClick:ve,children:s.jsx(b,{name:"more-2-fill",className:"size-4"})})}),s.jsx(hr,{align:"end",side:"bottom",onCloseAutoFocus:()=>j(null),children:ce({Item:Rs,Separator:Ba})})]})}),e[56]=f,e[57]=k,e[58]=ve,e[59]=Y,e[60]=x,e[61]=r.path,e[62]=ce,e[63]=j,e[64]=Ve):Ve=e[64];let Ee;e[65]!==de||e[66]!==Ve||e[67]!==G?(Ee=s.jsxs(Ha,{render:G,children:[de,Ve]}),e[65]=de,e[66]=Ve,e[67]=G,e[68]=Ee):Ee=e[68];let ke;e[69]!==ce?(ke=s.jsx(_a,{className:"min-w-[180px]",children:ce({Item:Ka,Separator:Ua})}),e[69]=ce,e[70]=ke):ke=e[70];let Z;return e[71]!==Ee||e[72]!==ke||e[73]!==ue||e[74]!==be?(Z=s.jsxs(Ga,{open:ue,onOpenChange:be,children:[Ee,ke]}),e[71]=Ee,e[72]=ke,e[73]=ue,e[74]=be,e[75]=Z):Z=e[75],Z},Ko=a=>{const e=gt.c(83),{activeDialog:r,dialogData:d,dialogInputValue:v,onDialogInputChange:g,isDialogSubmitting:x,onDialogSubmit:w,onClose:f,inputRef:C}=a,{t:h}=Bt(),F=!!r;let N;e[0]!==f?(N=O=>!O&&f(),e[0]=f,e[1]=N):N=e[1];let k;e[2]!==r||e[3]!==h?(k=r==="createFile"&&h("filesView.dialog.createFile.title"),e[2]=r,e[3]=h,e[4]=k):k=e[4];let j;e[5]!==r||e[6]!==h?(j=r==="createFolder"&&h("filesView.dialog.createFolder.title"),e[5]=r,e[6]=h,e[7]=j):j=e[7];let T;e[8]!==r||e[9]!==h?(T=r==="rename"&&h("filesView.dialog.rename.title"),e[8]=r,e[9]=h,e[10]=T):T=e[10];let o;e[11]!==r||e[12]!==h?(o=r==="delete"&&h("filesView.dialog.delete.title"),e[11]=r,e[12]=h,e[13]=o):o=e[13];let L;e[14]!==k||e[15]!==j||e[16]!==T||e[17]!==o?(L=s.jsxs(si,{children:[k,j,T,o]}),e[14]=k,e[15]=j,e[16]=T,e[17]=o,e[18]=L):L=e[18];let I;e[19]!==r||e[20]!==d?.path||e[21]!==h?(I=r==="createFile"&&h("filesView.dialog.createFile.description",{path:d?.path??h("filesView.dialog.rootFallback")}),e[19]=r,e[20]=d?.path,e[21]=h,e[22]=I):I=e[22];let W;e[23]!==r||e[24]!==d?.path||e[25]!==h?(W=r==="createFolder"&&h("filesView.dialog.createFolder.description",{path:d?.path??h("filesView.dialog.rootFallback")}),e[23]=r,e[24]=d?.path,e[25]=h,e[26]=W):W=e[26];let A;e[27]!==r||e[28]!==d?.name||e[29]!==h?(A=r==="rename"&&h("filesView.dialog.rename.description",{name:d?.name??""}),e[27]=r,e[28]=d?.name,e[29]=h,e[30]=A):A=e[30];let E;e[31]!==r||e[32]!==d?.name||e[33]!==h?(E=r==="delete"&&h("filesView.dialog.delete.description",{name:d?.name??""}),e[31]=r,e[32]=d?.name,e[33]=h,e[34]=E):E=e[34];let V;e[35]!==A||e[36]!==E||e[37]!==I||e[38]!==W?(V=s.jsxs(ri,{children:[I,W,A,E]}),e[35]=A,e[36]=E,e[37]=I,e[38]=W,e[39]=V):V=e[39];let S;e[40]!==V||e[41]!==L?(S=s.jsxs(ti,{children:[L,V]}),e[40]=V,e[41]=L,e[42]=S):S=e[42];let M;e[43]!==r||e[44]!==v||e[45]!==C||e[46]!==g||e[47]!==w||e[48]!==h?(M=r!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(ss,{value:v,onChange:O=>g(O.target.value),placeholder:h(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:O=>{O.key==="Enter"&&w()},ref:C})}),e[43]=r,e[44]=v,e[45]=C,e[46]=g,e[47]=w,e[48]=h,e[49]=M):M=e[49];let $;e[50]!==h?($=h("filesView.dialog.cancel"),e[50]=h,e[51]=$):$=e[51];let P;e[52]!==x||e[53]!==f||e[54]!==$?(P=s.jsx(z,{variant:"outline",onClick:f,disabled:x,children:$}),e[52]=x,e[53]=f,e[54]=$,e[55]=P):P=e[55];const J=r==="delete"?"destructive":"default";let Ne;e[56]!==w?(Ne=()=>{w()},e[56]=w,e[57]=Ne):Ne=e[57];let _;e[58]!==r||e[59]!==v||e[60]!==x?(_=x||r!=="delete"&&!v.trim(),e[58]=r,e[59]=v,e[60]=x,e[61]=_):_=e[61];let Y;e[62]!==r||e[63]!==x||e[64]!==h?(Y=x?s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}):h(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=x,e[64]=h,e[65]=Y):Y=e[65];let ee;e[66]!==J||e[67]!==Ne||e[68]!==_||e[69]!==Y?(ee=s.jsx(z,{variant:J,onClick:Ne,disabled:_,children:Y}),e[66]=J,e[67]=Ne,e[68]=_,e[69]=Y,e[70]=ee):ee=e[70];let le;e[71]!==P||e[72]!==ee?(le=s.jsxs(ni,{children:[P,ee]}),e[71]=P,e[72]=ee,e[73]=le):le=e[73];let te;e[74]!==C||e[75]!==S||e[76]!==M||e[77]!==le?(te=s.jsxs(ei,{initialFocus:C,children:[S,M,le]}),e[74]=C,e[75]=S,e[76]=M,e[77]=le,e[78]=te):te=e[78];let Ce;return e[79]!==F||e[80]!==N||e[81]!==te?(Ce=s.jsx(Zn,{open:F,onOpenChange:N,children:te}),e[79]=F,e[80]=N,e[81]=te,e[82]=Ce):Ce=e[82],Ce},Qn=(a,e,r)=>{const d=gt.c(8),[v,g]=n.useState(""),[x,w]=n.useState(0);let f,C;d[0]!==a||d[1]!==r||d[2]!==e?(f=()=>{if(!a){g("");return}let F=!1;g("");const N=pa(),k=ha(N);ga(N).then(T=>{F||!T||(g(a),e(null))}).catch(T=>{F||(e(T instanceof Error?T.message:r),g(a))});const j=xa(()=>{F||(g(a),w(Ho),e(null))});return()=>{F=!0,k(),j()}},C=[a,e,r],d[0]=a,d[1]=r,d[2]=e,d[3]=f,d[4]=C):(f=d[3],C=d[4]),n.useEffect(f,C);let h;return d[5]!==x||d[6]!==v?(h={readyKey:v,nonce:x},d[5]=x,d[6]=v,d[7]=h):h=d[7],h},mu=({mode:a="full"})=>{const{t:e}=Bt(),{files:r,runtime:d}=ja(),{currentTheme:v,availableThemes:g,lightThemeId:x,darkThemeId:w}=Fa(),{isMobile:f,isTablet:C,screenWidth:h}=Na(),F=la(d.platform),N=f||C,k=ca(),j=ua(),T=Yn()??"",o=H(T.trim()),L=a!=="editor-only",I=a==="editor-only"&&!f,W=da(t=>t.searchFiles),A=Ca(T),[E,V]=n.useState(""),S=Sa(E,200),M=n.useRef(null),[$,P]=n.useState(!1),[J,Ne]=n.useState(!0),[_,Y]=n.useState(!1),[ee,le]=n.useState(!1),te=n.useRef(0),Ce=n.useCallback(t=>{te.current=Math.max(0,te.current+(t?1:-1))},[]),[O,ve]=n.useState("edit"),[we,ce]=n.useState("edit"),[ue,be]=n.useState("tree"),[B,G]=n.useState("edit"),[se,re]=n.useState("preview"),[Se,ie]=n.useState(0),ae=n.useRef({}),ye=n.useRef({}),Te=n.useRef({}),de=n.useRef({}),Ve=n.useMemo(()=>g.find(t=>t.metadata.id===x)??kn(!1),[g,x]),Ee=n.useMemo(()=>g.find(t=>t.metadata.id===w)??kn(!0),[g,w]);n.useEffect(()=>{Bn(Ve),Bn(Ee)},[Ve,Ee]);const ke=n.useMemo(()=>[],[]),Z=He(t=>o?t.byRoot[o]?.openPaths??ke:ke),fe=He(t=>o?t.byRoot[o]?.selectedPath??null:null),he=He(t=>o?t.byRoot[o]?.expandedPaths??ke:ke),et=He(t=>t.removeOpenPath),X=He(t=>t.removeOpenPathsByPrefix),at=He(t=>t.removeExpandedPathsByPrefix),me=He(t=>t.setSelectedPath),gr=He(t=>t.toggleExpandedPath),rs=He(t=>t.expandPaths),Ft=n.useCallback(t=>{const i=H(t),l=i.split("/"),u=l[l.length-1]||i,p=u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;return{name:u,path:i,type:"file",extension:p}},[]),Nt=n.useMemo(()=>Z.map(Ft),[Z,Ft]),Ps=n.useMemo(()=>{if(fe){const t=Ot(fe);if(Z.some(i=>Ot(i)===t))return fe}return Z[0]??null},[Z,fe]),c=n.useMemo(()=>Ps?Ft(Ps):null,[Ps,Ft]),Ge=c?.path??"",[,ci]=n.useState(0);n.useEffect(()=>{if(!o||!fe)return;const t=Ot(fe);Z.some(l=>Ot(l)===t)||me(o,Z[0]??null)},[Z,o,fe,me]);const ns=!!(o&&Ge&&!Es(Ge,o)),xr=ns?Dn(Ge):void 0,xt=n.useMemo(()=>({allowOutsideWorkspace:a==="editor-only"&&ns,outsideFileGrant:xr,directory:o||void 0}),[a,ns,xr,o]),qe=n.useCallback(async t=>{const i=Dn(t),l=await ka(t,o,a==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==i&&ci(u=>u+1),l},[a,o]),Ms=n.useRef(null),[vr,ui]=n.useState({left:!1,right:!1}),wr=n.useCallback(()=>{const t=Ms.current;t&&ui({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),br=n.useRef(wr);br.current=wr,n.useEffect(()=>{const t=Ms.current;if(!t)return;const i=()=>br.current();i(),t.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(t),()=>{t.removeEventListener("scroll",i),l.disconnect()}},[Nt.length]);const[yr,zs]=n.useState({}),[is,$t]=n.useState({}),ze=n.useRef(new Set),Ae=n.useRef(new Set),tt=n.useRef(new Map),jr=n.useRef(0),[Fr,as]=n.useState([]),[di,os]=n.useState(!1),[D,pe]=n.useState(""),{isPlaying:ls,play:fi,stop:mi}=Ra(),[Le,ot]=n.useState(!1),[st,ge]=n.useState(null),[pi,Ie]=n.useState(""),[De,oe]=n.useState(null),[ne,xe]=n.useState(""),[Wt,As]=n.useState(!1),[Nr,hi]=n.useState(`
|
|
11
|
-
`),gi=n.useRef(null),Xe=n.useRef(null),Pe=n.useRef(null),lt=n.useRef(""),_t=n.useRef(""),rt=n.useRef(null),Cr=n.useRef(null),Je=n.useRef(null),Ut=n.useRef(0),Ct=n.useRef(null),[cs,xi]=n.useState(0),[vi,St]=n.useState("idle"),[wi,us]=n.useState(!1),[Kt,Sr]=n.useState(!1),je=ht(t=>t.autoSaveEnabled),bi=ht(t=>t.setAutoSaveEnabled),[Ls,Ht]=n.useState(!1),kt=n.useRef(null),Gt=n.useRef(null),qt=n.useRef(!1),Xt=n.useRef(null),Jt=n.useRef(null),We=n.useRef(null),ds=n.useRef(null),[yi,Is]=n.useState(0),Rt=n.useRef(null),vt=n.useRef({key:"",attempts:0});n.useEffect(()=>()=>{Rt.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Rt.current),Rt.current=null)},[]);const[wt,Os]=n.useState(null),[bt,ji]=n.useState(null),[ct,kr]=n.useState(""),[Fi,Bs]=n.useState(!1),[Ni,Ci]=n.useState(null),[Si,ki]=n.useState(null),[Ri,Rr]=n.useState(!1),[Ti,Tr]=n.useState(!1),[Vi,$s]=n.useState(!1),[Vr,fs]=n.useState(!1),[Er,Dr]=n.useState(0),ms=n.useRef(null),ps=n.useCallback(t=>{const i=t?.currentTarget??ms.current;if(!i)return;const l=document.activeElement;l&&l!==document.body&&l!==i&&(Ta(l)||i.contains(l))||i.focus({preventScroll:!0})},[]),Ws=n.useRef(null),Pr=!!r.writeFile,Mr=!!r.createDirectory,zr=!!r.rename,Ar=!!r.delete,Lr=!!r.revealPath,Ei=Ss(t=>t.availableApps),Di=Ss(t=>t.isCacheStale),Ir=Ss(t=>t.initialize),Pi=Ss(t=>t.loadInstalledApps);n.useEffect(()=>{Ir()},[Ir]);const Mi=n.useCallback(t=>{r.revealPath&&r.revealPath(t).catch(()=>{Q.error(e("sidebarFilesTree.toast.revealFailed"))})},[r,e]),zi=n.useCallback(async t=>{if(!c?.path||await fa(c.path,t.id,t.appName)||await Rn(c.path,t.appName))return;const u=Eo(c.path)||o;u&&await Rn(u,t.appName)||Q.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,c?.path,e]),_s=n.useCallback((t,i)=>{Os(t),ji(i),kr(t==="rename"&&i.name||""),Bs(!1)},[]),[U,_e]=n.useState(null),Tt=n.useRef(!1),ut=n.useRef(null),[Or,Vt]=n.useState(!1),Qe=ht(t=>t.pendingFileNavigation),hs=ht(t=>t.setPendingFileNavigation),Us=ht(t=>t.pendingFileFocusPath),Ks=ht(t=>t.setPendingFileFocusPath),Br=ht(t=>t.fileEditorKeymap),Qt=Pn(t=>t.settingsDefaultFileViewerPreview),Ai=Pn(t=>t.showMessageTTSButtons);n.useEffect(()=>{const t=()=>{Tt.current=!1,ut.current=null,Vt(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),n.useEffect(()=>()=>{Xt.current!==null&&window.clearTimeout(Xt.current),Jt.current!==null&&window.clearTimeout(Jt.current)},[]);const Li=n.useCallback((t,i)=>{const l=t.split(`
|
|
12
|
-
`),u=Math.max(1,i.start),p=Math.min(l.length,i.end);return u>p?"":l.slice(u-1,p).join(`
|
|
13
|
-
`)},[]),gs=n.useRef(null),Ii=ao({source:"file",fileLabel:c?.path??null,language:c?.path&&ar(c.path)||"text",getCodeForRange:t=>Li(D,oo(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:$r,commentText:xs,setCommentText:Wr,editingDraftId:vs,setSelection:_r,saveComment:Ur,cancel:Yt,reset:Kr,startEdit:Hr,deleteDraft:Gr}=Ii;n.useEffect(()=>{_e(null),Kr(),xe(""),As(!1)},[c?.path,Kr]),n.useEffect(()=>{_r(U)},[U,_r]),n.useEffect(()=>{if(!U&&!vs)return;const t=l=>{const u=l.target;u.closest('[data-comment-input="true"]')||u.closest('[data-comment-card="true"]')||u.closest(".cm-gutterElement")||u.closest("[data-sonner-toast]")||u.closest("[data-sonner-toaster]")||xs.trim()||(_e(null),Yt())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[Yt,xs,vs,U]);const qr=n.useCallback((t,i)=>{const l=i??U??void 0;i&&_e(i),Ur(t,l),_e(null)},[U,Ur]),Xr=n.useCallback((t,i)=>{const l=[];for(const u of i){if(!(u&&typeof u.name=="string"&&u.name.length>0)||!k&&u.name.startsWith(".")||!j&&Lo(u.name))continue;const p=u.name,m=H(u.path||""),y=m?Mo(m)?m:H(`${t}/${m}`):H(`${t}/${p}`),R=u.isDirectory?"directory":"file",K=R==="file"&&p.includes(".")?p.split(".").pop()?.toLowerCase():void 0;l.push({name:p,path:y,type:R,extension:K})}return Po(l)},[j,k]),Oe=n.useCallback(async t=>{const i=H(t.trim());if(!i||ze.current.has(i)||Ae.current.has(i))return;Ae.current=new Set(Ae.current),Ae.current.add(i);const l=jr.current+1;jr.current=l,tt.current=new Map(tt.current),tt.current.set(i,l);const u=()=>tt.current.get(i)===l;await(r.listDirectory?r.listDirectory(i).then(m=>m.entries.map(y=>({name:y.name,path:y.path,isDirectory:y.isDirectory}))):ma.listLocalDirectory(i).then(m=>m.map(y=>({name:y.name,path:y.path,isDirectory:y.isDirectory})))).then(m=>{if(!u())return;const y=Xr(i,m);ze.current=new Set(ze.current),ze.current.add(i),$t(R=>{if(!R[i])return R;const K={...R};return delete K[i],K}),zs(R=>({...R,[i]:y}))}).catch(m=>{if(!u())return;const y=m instanceof Error?m.message:String(m??"");if(y==="Directory not found"&&o&&i!==o){at(o,i),$t(R=>{if(!R[i])return R;const K={...R};return delete K[i],K});return}console.error("Failed to load files directory:",m),$t(R=>({...R,[i]:y}))}).finally(()=>{u()&&(tt.current=new Map(tt.current),tt.current.delete(i),Ae.current=new Set(Ae.current),Ae.current.delete(i))})},[r,Xr,at,o]),ws=n.useCallback(async()=>{o&&(ze.current=new Set,Ae.current=new Set,tt.current=new Map,$t({}),zs(t=>Object.keys(t).length===0?t:{}),await Oe(o))},[Oe,o]),Ye=n.useCallback(async t=>{if(!t){await ws();return}const i=H(t);ze.current=new Set(ze.current),ze.current.delete(i),Ae.current=new Set(Ae.current),Ae.current.delete(i),await Oe(i)},[Oe,ws]),Jr=n.useRef(""),Qr=n.useRef("");n.useEffect(()=>{if(!o)return;const t=`${o}|h${k?"1":"0"}|g${j?"1":"0"}`,i=Jr.current!==o,l=Qr.current!==t;!i&&!l||(i&&(Jr.current=o,pe(""),ge(null),Ie(""),oe(null),P(!1)),l&&(Qr.current=t,ze.current=new Set,Ae.current=new Set,tt.current=new Map,$t({}),zs(u=>Object.keys(u).length===0?u:{}),Oe(o)))},[Oe,o,j,k]),n.useEffect(()=>{if(!r.listDirectory)return;const t=()=>{if(!document.hidden&&he.length>0)for(const i of he)Ye(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[he,r.listDirectory,Ye]),n.useEffect(()=>{if(!r.listDirectory||he.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of he)Ye(i)},8e3);return()=>clearInterval(t)},[he,r.listDirectory,Ye]);const Oi=n.useCallback(async t=>{if(t?.preventDefault(),!bt||!wt)return;Bs(!0);const i=()=>{Os(null)},l=p=>{Q.error(p)},u=()=>{Bs(!1)};if(wt==="createFile"){if(!ct.trim()){l(e("sidebarFilesTree.toast.filenameRequired")),u();return}if(!r.writeFile){l(e("sidebarFilesTree.toast.writeNotSupported")),u();return}const p=bt.path,m=p?`${p}/`:"",y=H(`${m}${ct.trim()}`);await r.writeFile(y,"").then(async R=>{R.success&&(Q.success(e("sidebarFilesTree.toast.fileCreated")),await Ye(p)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(wt==="createFolder"){if(!ct.trim()){l(e("sidebarFilesTree.toast.folderNameRequired")),u();return}const p=bt.path,m=p?`${p}/`:"",y=H(`${m}${ct.trim()}`);await r.createDirectory(y).then(async R=>{R.success&&(Q.success(e("sidebarFilesTree.toast.folderCreated")),await Ye(p)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(wt==="rename"){if(!ct.trim()){l(e("sidebarFilesTree.toast.nameRequired")),u();return}if(!r.rename){l(e("sidebarFilesTree.toast.renameNotSupported")),u();return}const p=bt.path,m=p.split("/").slice(0,-1).join("/"),y=m?`${m}/`:"",R=H(`${y}${ct.trim()}`);await r.rename(p,R).then(async K=>{K.success&&(Q.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await Ye(m),o&&X(o,p),(c?.path===p||c?.path.startsWith(`${p}/`))&&(o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(wt==="delete"){if(!r.delete){l(e("sidebarFilesTree.toast.deleteNotSupported")),u();return}const p=bt.path,m=p.split("/").slice(0,-1).join("/");await r.delete(p).then(async y=>{y.success&&(Q.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await Ye(m),o&&X(o,p),(c?.path===p||c?.path.startsWith(`${p}/`))&&(o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}u()},[wt,bt,ct,r,Ye,f,X,o,c?.path,me,e]);n.useEffect(()=>{if(!T){as([]),os(!1);return}const t=S.trim();if(!t){as([]),os(!1);return}let i=!1;return os(!0),W(T,t,150,{includeHidden:k,respectGitignore:!j,type:"file"}).then(l=>{if(i)return;const p=l.filter(m=>j||!Io(m.path)).map(m=>({name:m.name,path:H(m.path),type:"file",extension:m.extension,relativePath:m.relativePath}));as(p)}).catch(()=>{i||as([])}).finally(()=>{i||os(!1)}),()=>{i=!0}},[T,S,W,k,j]);const Yr=n.useCallback(async t=>{const i=await qe(t);if(r.readFile)return(await r.readFile(t,{...i,directory:o||void 0})).content??"";const l=new URLSearchParams({path:t});i.allowOutsideWorkspace&&l.set("allowOutsideWorkspace","true"),i.outsideFileGrant&&l.set("outsideFileGrant",i.outsideFileGrant),o&&l.set("directory",o);const u=await Tn(`/api/fs/read?${l.toString()}`);if(!u.ok){const p=await u.json().catch(()=>({error:u.statusText}));throw new Error(p.error||e("filesView.error.readFileFailed"))}return u.text()},[r,qe,o,e]),dt=n.useCallback(async t=>{if(r.statFile){const i=await qe(t),l=await r.statFile(t,{...i,directory:o||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[r,qe,o]);n.useEffect(()=>{if(!o||!r.statFile||Z.length===0)return;let t=!1;const i=[...Z];return Promise.all(i.map(async l=>{try{const u=await qe(l),p=await r.statFile?.(l,{...u,directory:o||void 0});!t&&p&&!p.isFile&&X(o,l)}catch(u){!t&&Xn(u)&&X(o,l)}})),()=>{t=!0}},[r,Z,X,qe,o]);const Hs=n.useMemo(()=>D.length>It?`${D.slice(0,It)}
|
|
14
|
-
|
|
15
|
-
… truncated …`:D,[D]),Me=ne!==Hs,Et=n.useCallback(async()=>{if(!c||!r.writeFile)return Q.error(e("filesView.toast.savingNotSupported")),!1;const t=Cs(c.path)||Kt;if(!Ro({selectedFilePath:c.path,loadedFilePath:De,fileLoading:Le,isDirty:Me,draftContent:ne,fileContent:D,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${c.path}".`):ne===""&&D!==""&&De!==c.path&&console.warn(`[saveDraft] refusing to save empty draft for "${c.path}" (${D.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!Me)return!0;As(!0);try{const i=Wo(ne,Nr);if(!(await r.writeFile(c.path,i))?.success)return Q.error(e("filesView.toast.writeFileFailed")),!1;if(pe(ne),o&&Es(c.path,o)){const u=Ts(o,c.path);u&&Va.requestGitRefresh({directory:o,paths:[u]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(H(c.path))){const u=Ea.getState().projects.find(p=>H(p.path)===H(o));if(u)try{await so(u.id)}catch{Q.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return c?.path&&or(c.path)&&(lt.current=ne,_t.current=ne),dt(c.path).then(u=>{u&&(Je.current=u)}).catch(()=>{}),!0}catch(i){return Q.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{As(!1)}},[Kt,ne,D,Le,r,Me,Nr,De,dt,o,c,e]);n.useEffect(()=>{je||(St("idle"),Xe.current&&(clearTimeout(Xe.current),Xe.current=null))},[je]);const Zr=1500;n.useEffect(()=>{const t=!!(c&&r.writeFile),i=!!(c?.path&&(Cs(c.path)||Kt));if(ko({autoSaveEnabled:je,isDirty:Me,canWrite:t,isSaving:Wt,fileLoading:Le,selectedFilePath:c?.path,loadedFilePath:De,isNonEditableBinary:i}))return Xe.current=setTimeout(()=>{Et().then(l=>{l&&(St("saved"),setTimeout(()=>St("idle"),2e3))})},Zr),()=>{Xe.current&&(clearTimeout(Xe.current),Xe.current=null)}},[je,Kt,ne,Le,Me,De,c,r.writeFile,Wt,Et]),n.useEffect(()=>{St("idle")},[c?.path]),Da({save_file:t=>{if(!(t.target instanceof Node)||!ds.current?.contains(t.target))return!1;Xe.current&&(clearTimeout(Xe.current),Xe.current=null),Wt||Et().then(i=>{i&&(St("saved"),setTimeout(()=>St("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node))return!1;if(Ze&&$e()==="preview"){if(f||!(_?Ws.current:ms.current)?.contains(t.target))return!1;fs(!0),Dr(l=>l+1);return}if(!ds.current?.contains(t.target))return!1;le(!0)}});const en=n.useCallback(async t=>{const i=Ut.current+1;Ut.current=i;const l=()=>{if(!o)return!1;const R=He.getState().byRoot[o],K=R?.selectedPath??R?.openPaths[0]??null;return Ut.current===i&&K===t.path};if(ge(null),Ie(""),oe(null),Sr(!1),ot(!0),await qe(t.path),!l())return;const u=Mn(t.path),p=zn(t.path),m=An(t.path),y=Cs(t.path);if(f&&P(!0),d.isDesktop&&u&&!p){pe(""),xe("");return}if(!d.isDesktop&&u&&!p){pe(""),xe(""),oe(t.path),ot(!1);return}if(m){pe(""),xe(""),oe(t.path),ot(!1);return}if(y){pe(""),xe(""),oe(t.path),ot(!1);return}await Yr(t.path).then(R=>{if(!l())return;if(Pa(R)){Sr(!0),pe(""),xe(""),oe(t.path);return}const K=oi(R);hi($o(R)),pe(K),lt.current=K,_t.current=K,xe(K.length>It?`${K.slice(0,It)}
|
|
16
|
-
|
|
17
|
-
… truncated …`:K),oe(t.path),dt(t.path).then(mt=>{mt&&l()&&(Je.current=mt)}).catch(()=>{})}).catch(R=>{if(l()){if(Oo(R)){if(ot(!1),o&&me(o,null),ge(null),pe(""),xe(""),oe(null),Je.current=null,E.trim().length>0&&V(""),f&&P(!1),o){const mt=[...Gn(t.path,o),t.path];mt.length>0&&rs(o,mt);for(const pt of mt)ze.current.has(pt)||Oe(pt)}return}if(Xn(R)){o&&X(o,t.path),pe(""),xe(""),ge(null),Je.current=null,f&&P(!1);return}pe(""),xe(""),ge(R instanceof Error?R.message:e("filesView.error.readFileFailed")),Je.current=null}}).finally(()=>{l()&&ot(!1)})},[rs,f,Oe,Yr,dt,X,qe,o,d.isDesktop,E,me,e]),bs=n.useCallback(async(t,i)=>{if(!o)return;const l=Gn(t,o),u=i?[...l,t]:l;u.length>0&&rs(o,u);const p=u.map(m=>{if(!ze.current.has(m))return Oe(m)}).filter(Boolean);await Promise.all(p)},[rs,Oe,o]),tn=n.useCallback((t,i)=>{const l=i.findIndex(u=>u.path===t);return l===-1||i.length<=1?null:i[l+1]??i[l-1]??null},[]),Re=n.useCallback(async t=>{if(qt.current)qt.current=!1;else if(Me){Ht(!0),kt.current=t;return}o&&(me(o,t.path),bs(t.path,!1)),ge(null),Ie(""),pe(""),lt.current="",_t.current="",xe(""),oe(null),f&&P(!0)},[bs,Me,f,o,me]);n.useEffect(()=>{c?.path&&bs(c.path,!1)},[bs,c?.path]),n.useEffect(()=>{if(!c){Ut.current+=1,Ct.current=null,ot(!1);return}if(De===c.path||Ct.current===c.path)return;const t=c.path;Ct.current=t,en(c).finally(()=>{Ct.current===t&&(Ct.current=null)})},[cs,en,De,c]);const Gs=n.useRef(Me);Gs.current=Me,n.useEffect(()=>ro(({runtimeKey:t,paths:i})=>{const l=c?.path;t!==va()||!l||Gs.current||!i.includes(H(l))||(Ut.current+=1,Ct.current=null,Je.current=null,Ie(""),ge(null),oe(null),xi(u=>u+1))}),[c?.path]),n.useEffect(()=>{if(!c?.path||De!==c.path)return;let t=!1;const i=window.setInterval(()=>{document.hidden||dt(c.path).then(l=>{if(t||!l)return;const u=Je.current;if(!u||u.path!==c.path){Je.current=l;return}const p=l.mtimeMs!==void 0&&u.mtimeMs!==void 0&&l.mtimeMs!==u.mtimeMs,m=l.size!==u.size;!p&&!m||Gs.current||(Je.current=l,oe(null))}).catch(()=>{})},2e3);return()=>{t=!0,window.clearInterval(i)}},[De,dt,c?.path]);const Bi=n.useCallback(()=>{const t=kt.current,i=Gt.current;if(kt.current=null,Gt.current=null,qt.current=!0,Ht(!1),xe(Hs),i){o&&et(o,i),c?.path===i&&(t?Re(t):(o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1)));return}if(t){Re(t);return}},[Hs,Re,f,et,o,c?.path,me]),$i=n.useCallback(async()=>{const t=kt.current,i=Gt.current;if(!await Et()){qt.current=!1;return}if(kt.current=null,Gt.current=null,qt.current=!0,Ht(!1),i){o&&et(o,i),c?.path===i&&(t?await Re(t):(o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1)));return}if(t){await Re(t);return}},[Re,f,et,o,Et,c?.path,me]),sn=n.useCallback(t=>{const i=c?.path===t,l=tn(t,Nt);if(i&&Me){Ht(!0),kt.current=l,Gt.current=t;return}if(o&&et(o,t),!!i){if(l){Re(l);return}o&&me(o,null),pe(""),ge(null),Ie(""),oe(null),f&&P(!1)}},[tn,Re,Me,f,Nt,et,o,c?.path,me]),Wi=n.useCallback(t=>{if(Z.includes(t))return"open";if(A?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=A.files.find(u=>u.path===i);if(l){if(l.index==="A"||l.working_dir==="?")return"git-added";if(l.index==="D")return"git-deleted";if(l.index==="M"||l.working_dir==="M")return"git-modified"}}return null},[Z,A,o]),_i=n.useCallback(t=>{if(!A?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=i?`${i}/`:"";let u=0,p=0;for(const m of A.files)m.path.startsWith(l)&&((m.index==="M"||m.working_dir==="M")&&u++,(m.index==="A"||m.working_dir==="?")&&p++);return u+p>0?{modified:u,added:p}:null},[A,o]),Ui=n.useCallback(async t=>{const i=H(t);o&&(gr(o,i),ze.current.has(i)||await Oe(i))},[Oe,o,gr]),Ki=n.useMemo(()=>({canRename:zr,canCreateFile:Pr,canCreateFolder:Mr,canDelete:Ar,canReveal:Lr}),[zr,Pr,Mr,Ar,Lr]);function rn(t,i){const l=yr[t]??[];return l.map((u,p)=>{const m=u.type==="directory",y=m&&he.includes(u.path),R=c?.path===u.path,K=p===l.length-1;return s.jsxs("li",{className:"relative",children:[i>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),K&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(Uo,{node:u,root:o,isExpanded:y,isActive:R,isMobile:f,isBrowserClient:F,alwaysShowActions:N,status:m?void 0:Wi(u.path),badge:m?_i(u.path):void 0,permissions:Ki,downloadFile:r.downloadFile,contextMenuPath:Ni,setContextMenuPath:Ci,rightClickMenuPath:Si,setRightClickMenuPath:ki,onSelect:Re,onToggle:Ui,onRevealPath:Mi,onOpenDialog:_s}),m&&y&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[is[u.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:is[u.path],children:is[u.path]}),s.jsxs(z,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ye(u.path)},children:[s.jsx(b,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,rn(u.path,i+1)]})]},u.path)})}const Fe=!!(c?.path&&Mn(c.path)),ys=!!(c?.path&&zn(c.path)),Be=!!(c?.path&&An(c.path)),qs=!!(c?.path&&(Cs(c.path)||Kt)),nt=qs&&!Fe&&!Be,nn=n.useMemo(()=>H(Qe?.path??""),[Qe?.path]),Dt=!!(Qe&&nn&&Ge&&Ge===nn&&!Le&&!st&&!Fe&&!Be&&!nt),ft=n.useMemo(()=>Ts(o,Ge),[Ge,o]),Hi=!!(c&&(!Fe||ys)&&!Be&&!nt&&D.length>0),Gi=!!(c&&ft.length>0),Ue=!!(c&&!ns&&!qs&&!Fe&&r.writeFile&&D.length<=It),Ze=!!(c?.path&&Jn(c.path)),Zt=!!(c?.path&&_o(c.path)),Pt=!!(c?.path&&fr(c.path)),es=!!(c?.path&&or(c.path)),Xs=!!(c&&!qs&&!Fe)&&!Ze&&!es&&!(Pt&&B==="preview"),qi=Ze&&we==="edit"||Pt&&B==="edit"||Zt&&ue==="text"||!Ze&&!Pt&&!Zt&&O==="edit",js=n.useMemo(()=>Ge?Ma(Ge):null,[Ge]),[an,Js]=n.useState(null);n.useEffect(()=>{let t=!1;const i=c?.path;if(!i||js){Js(null);return}return Js(null),za(i).then(l=>{t||Js(l)}),()=>{t=!0}},[c?.path,js]),n.useEffect(()=>{!Ue&&O==="edit"&&ve("view")},[Ue,O]);const Qs="aiworker:files:md-viewer-mode",Ys="aiworker:files:html-viewer-mode",Zs="aiworker:files:json-viewer-mode";n.useEffect(()=>{const t=c?.path;if(!t)return;ve(ae.current[t]??"edit");let i=Qt?"preview":"edit";try{const p=localStorage.getItem(Qs);(p==="preview"||p==="edit")&&(i=p)}catch{}ce(ye.current[t]??i);let l=Qt?"preview":"edit";try{const p=localStorage.getItem(Ys);(p==="preview"||p==="edit")&&(l=p)}catch{}G(Te.current[t]??l),re(de.current[t]??(Qt?"preview":"edit"));let u=Qt?"tree":"text";try{const p=localStorage.getItem(Zs);(p==="tree"||p==="text")&&(u=p)}catch{}be(u)},[c?.path,Qt]);const Xi=n.useCallback(t=>{const i=c?.path;i&&(ae.current[i]=t),ve(t)},[c?.path]),Ji=n.useCallback(t=>{const i=c?.path;i&&(ye.current[i]=t),ce(t);try{localStorage.setItem(Qs,t)}catch{}},[c?.path]),$e=n.useCallback(()=>we,[we]),on=c&&Ze&&$e()==="preview"&&!Le?c.path:null;n.useEffect(()=>{!on||f||ps()},[ps,_,f,on]);const Qi=n.useCallback(t=>{be(t);try{localStorage.setItem(Zs,t)}catch{}},[]),Yi=n.useCallback(t=>{const i=c?.path;i&&(Te.current[i]=t),G(t);try{localStorage.setItem(Ys,t)}catch{}},[c?.path]),Zi=n.useCallback(t=>{const i=c?.path;if(i&&(de.current[i]=t),Pe.current&&(clearTimeout(Pe.current),Pe.current=null),rt.current!==null&&(cancelAnimationFrame(rt.current),rt.current=null),t==="edit")xe(lt.current||D),re(t);else{lt.current=ne;const l=i;re("edit"),rt.current=requestAnimationFrame(()=>{rt.current=requestAnimationFrame(()=>{rt.current=null,!(o&&l&&He.getState().byRoot[o]?.selectedPath!==l)&&(ie(u=>u+1),re("preview"))})});return}},[ne,D,o,c?.path]),er=n.useCallback(async(t,i)=>{if(!r.writeFile||i===_t.current)return!1;if(!(await r.writeFile(t,i))?.success)return Q.error(e("filesView.toast.writeFileFailed")),!1;lt.current=i,_t.current=i,xe(i);const u=await dt(t).catch(()=>null);return u&&(Je.current=u),!0},[r,dt,e]);n.useEffect(()=>()=>{Pe.current&&(clearTimeout(Pe.current),Pe.current=null),rt.current!==null&&(cancelAnimationFrame(rt.current),rt.current=null)},[se,c?.path]);const ea=n.useCallback(t=>{if(lt.current=t,!je||!c?.path||se!=="preview"||!r.writeFile)return;Pe.current&&clearTimeout(Pe.current);const i=c.path;Pe.current=setTimeout(()=>{Pe.current=null,er(i,t).then(l=>{l&&(us(!0),setTimeout(()=>us(!1),1500))}).catch(l=>{Q.error(l instanceof Error?l.message:e("filesView.toast.saveFailed"))})},Zr)},[je,se,r.writeFile,er,c?.path,e]),ta=n.useMemo(()=>es&&(lt.current||ne)||D,[ne,D,es]),ln=n.useCallback(()=>B,[B]);n.useEffect(()=>{const t=l=>{const u=l?"preview":"edit",p=l?"tree":"text";for(const m of Z)ae.current[m]="edit",Jn(m)&&(ye.current[m]=u),fr(m)&&(Te.current[m]=u),or(m)&&(de.current[m]=u);ve("edit"),ce(u),G(u),re(u),be(p);try{localStorage.setItem(Qs,u),localStorage.setItem(Ys,u),localStorage.setItem(Zs,p)}catch{}},i=l=>{const u=!!l.detail?.enabled;t(u)};return window.addEventListener("aiworker:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("aiworker:file-viewer-preview-mode-changed",i)}},[Z]),n.useEffect(()=>{if(!Qe||!o)return;const t=()=>{typeof window>"u"||Rt.current===null&&(Rt.current=window.requestAnimationFrame(()=>{Rt.current=null,Is(it=>it+1)}))},i=(it,yt)=>{if(it.state.doc.length!==yt.length)return!1;if(yt.length===0)return!0;const nr=Math.min(128,yt.length);if(it.state.sliceDoc(0,nr)!==yt.slice(0,nr))return!1;const Cn=Math.max(0,yt.length-nr);return it.state.sliceDoc(Cn,yt.length)===yt.slice(Cn)},l=H(Qe.path);if(!l){hs(null),vt.current={key:"",attempts:0};return}const u=`${l}:${Qe.line}:${Qe.column??1}`;if(vt.current.key!==u&&(vt.current={key:u,attempts:0}),c?.path!==l){if(Ls)return;Re(Ft(l));return}if(Le||De!==l)return;if(st||Fe||Be||nt){hs(null),vt.current={key:"",attempts:0};return}if(!Ue)return;if(O!=="edit"){ve("edit");return}const p=We.current;if(!p){t();return}if(!i(p,ne)){t();return}const m=Math.max(1,Math.min(Qe.line,p.state.doc.lines)),y=p.state.doc.line(m),R=Math.max(1,Qe.column||1),K=Math.max(0,y.to-y.from),mt=Math.min(K,R-1),pt=y.from+mt;if(!(p.state.selection.main.head===pt)||vt.current.attempts===0){vt.current.attempts+=1,p.dispatch({selection:{anchor:pt},effects:jt.scrollIntoView(pt,{y:"center"})}),p.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const it=We.current;it&&(it.dispatch({selection:{anchor:pt},effects:jt.scrollIntoView(pt,{y:"center"})}),it.focus())}),hs(null),vt.current={key:"",attempts:0}},[Ue,Ls,ne,yi,st,Le,Fe,Be,nt,De,Re,Qe,o,c?.path,hs,O,Ft]),n.useEffect(()=>{if(!Us||!o)return;const t=H(Us);if(!t){Ks(null);return}c?.path===t&&(Le||De!==t||(!st&&!Fe&&!Be&&!nt&&Ue&&O==="edit"&&We.current?.focus(),Ks(null)))},[Ue,st,Le,Fe,Be,nt,De,Us,o,c?.path,Ks,O]);const Mt=n.useCallback(t=>{if(!f||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(i.offsetTop+i.height))<=0)return;const p=t.state.selection.main.head,m=t.coordsAtPos(p);if(!m)return;const y=Math.round(i.offsetTop+i.height),K=m.bottom+20-y;K<=0||(t.scrollDOM.scrollTop+=K)},[f]);n.useEffect(()=>{if(!f||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Mt(We.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[f,Mt]),Aa("open_go_to_line",t=>{if(!Ue||O!=="edit"||f)return!1;const i=t.target;if(i?.closest('[role="dialog"]')||!(i instanceof Node)||!ds.current?.contains(i))return!1;const l=!!i?.closest(".cm-editor");if(!!i?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;$s(!0)});const Fs=ht(t=>t.editorFontSize),cn=n.useMemo(()=>{if(!c?.path)return[In(v,{fontSize:Fs})];const t=ar(c.path),i=[In(v,t?{syntaxColors:!1,fontSize:Fs}:{fontSize:Fs})],l=js??an;return l&&i.push(l),t&&i.push(qa({language:t,themeName:v.metadata.id,theme:Ya(v)})),J&&i.push(jt.lineWrapping),f&&i.push(jt.updateListener.of(u=>{u.view.hasFocus&&(u.selectionSet||u.focusChanged||u.viewportChanged||u.geometryChanged)&&window.requestAnimationFrame(()=>{Mt(u.view)})})),i},[v,c?.path,js,an,J,f,Mt,Fs]),un=n.useMemo(()=>({light:Ve.metadata.id,dark:Ee.metadata.id}),[Ve.metadata.id,Ee.metadata.id]),ts=c?.path&&Be&&(!xt.allowOutsideWorkspace||xt.outsideFileGrant)?`${c.path}|${xt.allowOutsideWorkspace?"outside":"workspace"}|${xt.outsideFileGrant??""}|${cs}`:"",Ns=c?.path&&Pt&&B==="preview"&&!d.isVSCode?`${c.path}|${cs}`:"",dn=e("filesView.error.readFileFailed"),{readyKey:fn,nonce:sa}=Qn(Ns,ge,dn),{readyKey:mn,nonce:pn}=Qn(ts,ge,dn),ra=!!(Ns&&fn!==Ns),hn=!!(ts&&mn!==ts),gn=c?.path&&Fe?ys?`data:${La(c.path)};utf8,${encodeURIComponent(D)}`:pi:"",xn=c?.path&&Be&&ts&&mn===ts?Vn().authenticatedAsset("/api/fs/raw",{path:c.path,allowOutsideWorkspace:xt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:xt.outsideFileGrant,directory:o||void 0}):"",vn=n.useCallback(t=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:xn,className:"h-full w-full border-0",title:t.name},pn)}),[xn,pn]);n.useEffect(()=>{let t=!1,i="";return(async()=>{if(!c?.path||!Fe||ys){Ie("");return}ge(null);const u=await qe(c.path);if(t)return;await(r.readFileBinary?r.readFileBinary(c.path,u).then(m=>m.dataUrl):(async()=>{const m=await Tn("/api/fs/raw",{query:{path:c.path,allowOutsideWorkspace:u.allowOutsideWorkspace?"true":void 0,outsideFileGrant:u.outsideFileGrant,directory:o||void 0}});if(!m.ok)throw new Error(e("filesView.error.readFileFailed"));const y=await m.blob();return i=URL.createObjectURL(y),t?(URL.revokeObjectURL(i),i="",""):i})()).then(m=>{t||(Ie(m),oe(c.path))}).catch(m=>{t||(Ie(""),ge(m instanceof Error?m.message:e("filesView.error.readFileFailed")),oe(null))}).finally(()=>{t||ot(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[cs,r,Fe,ys,qe,o,c?.path,xt,e]);const na=n.useCallback(()=>Os(null),[]),ia=n.useMemo(()=>lo({drafts:$r,editingDraftId:vs,commentText:xs,onTextChange:Wr,selection:U,isDragging:Or,fileLabel:c?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:qr,onCancel:()=>{_e(null),Yt()},onEdit:t=>{Hr(t),_e({start:t.startLine,end:t.endLine})},onDelete:Gr}),[Yt,xs,Gr,vs,$r,qr,Or,U,c?.path,Wr,Hr]),wn=Kn(),bn=Kn(),tr=Wa("unified"),Ke=D.length>It,sr=n.useMemo(()=>Ke?Bo(D):void 0,[D,Ke]),yn=n.useCallback((t,i,l)=>{const u={name:t.name,contents:i,lang:ar(t.path)||void 0},p=m=>s.jsx(Qa,{file:Ke&&sr?{...u,cacheKey:`${t.path}:${sr}`}:u,options:{disableFileHeader:!0,overflow:J?"wrap":"scroll",theme:un,themeType:v.metadata.variant==="dark"?"dark":"light"},className:Ke?"block w-full":"block h-full w-full",style:Ke?void 0:{height:"100%"}},m);return Ke?s.jsx("div",{className:"h-full",children:s.jsx(Za.Provider,{value:l.virtualizer,children:s.jsx(eo.Provider,{value:tr,children:p(`${t.path}:${tr?"pool":"pending"}`)})})}):s.jsx("div",{className:"h-full",children:p(t.path)})},[v.metadata.variant,Ke,sr,un,tr,J]),jn=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!c)return null;const l=i==="docked",u=Ia(Oa("save_file")),p=l?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",m=(y,R)=>s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:R})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:y})]});return s.jsxs("div",{className:p,children:[Ue&&qi&&s.jsxs(s.Fragment,{children:[Wt?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(b,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):je&&vi==="saved"&&!Me?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(b,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):Me?m(e(je?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{Et()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(je?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),"aria-label":e("filesView.editor.saveAria",{shortcut:u}),children:s.jsx(b,{name:"save-3",className:"size-4"})})):null,m(e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>bi(!je),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",je?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:je?s.jsx(b,{name:"file-check-fill",className:"size-4"}):s.jsx(b,{name:"file-check",className:"size-4"})}))]}),s.jsxs(mr,{onOpenChange:Ce,children:[s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(pr,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:s.jsx(b,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),s.jsxs(hr,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Ei.map(y=>s.jsxs(Rs,{className:"flex items-center gap-2",onClick:()=>{zi(y)},children:[s.jsx(Do,{label:y.label,iconDataUrl:y.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:y.label})]},y.id)),Di?s.jsxs(Rs,{className:"flex items-center gap-2",onClick:()=>{Pi(!0)},children:[s.jsx(b,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!Fe&&!Be&&!nt&&s.jsxs(s.Fragment,{children:[m(e(J?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ne(!J),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",J?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(J?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(b,{name:"text-wrap",className:"size-4"})})),O==="edit"&&s.jsxs(s.Fragment,{children:[m(e("filesView.editor.findInFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:y=>{le(!ee),y.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(b,{name:"search",className:"size-4"})})),m(e("filesView.editor.goToLine"),s.jsx(z,{variant:"ghost",size:"sm",onClick:y=>{$s(R=>!R),y.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:s.jsx(b,{name:"menu-fold-2",className:"size-4"})})),s.jsx(wo,{open:Vi,onOpenChange:$s,view:We.current,variant:"inline"})]})]}),Xs&&Ue&&!Zt&&!Pt&&s.jsx(ur,{currentMode:O==="view"?"preview":"edit",onToggle:()=>{Xi(O==="view"?"edit":"view")}}),Ze&&m(e($e()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ji($e()==="preview"?"edit":"preview"),className:q("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",$e()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:e($e()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e($e()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(b,{name:$e()==="preview"?"eye":"eye-off",className:"size-4"})})),fr(c?.path??"")&&s.jsx(ur,{currentMode:ln(),onToggle:()=>{Yi(ln()==="preview"?"edit":"preview")}}),Ze&&$e()==="preview"&&m(e("filesView.editor.findInFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{fs(!0),Dr(y=>y+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(b,{name:"search",className:"size-4"})})),Ze&&$e()==="preview"&&Ai&&s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":e(ls?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{ls?mi():D.trim()&&fi(D)},children:ls?s.jsx(b,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(b,{name:"volume-up",className:"size-4"})})}),s.jsx(Lt,{sideOffset:8,children:e(ls?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),es&&s.jsxs(s.Fragment,{children:[s.jsx(ur,{currentMode:se,onToggle:()=>Zi(se==="preview"?"edit":"preview")}),se==="preview"&&s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{const y=Cr.current?.getXml();if(Pe.current&&(clearTimeout(Pe.current),Pe.current=null),c?.path&&y){if(!await er(c.path,y))return;us(!0),setTimeout(()=>us(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:wi?s.jsx(b,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(b,{name:"save-3",className:"size-4"})})]}),Zt&&m(e(ue==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Qi(ue==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(ue==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:ue==="tree"?s.jsx(b,{name:"code-sslash",className:"size-4"}):s.jsx(b,{name:"node-tree",className:"size-4"})})),Hi&&m(e("filesView.editor.copyFileContents"),s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(D)).ok?(Rr(!0),Xt.current!==null&&window.clearTimeout(Xt.current),Xt.current=window.setTimeout(()=>{Rr(!1)},1200)):Q.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:Ri?s.jsx(b,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(b,{name:"clipboard",className:"size-4"})})),Gi&&m(e("filesView.editor.copyFilePathTitle",{path:ft}),s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(ft)).ok?(Tr(!0),Jt.current!==null&&window.clearTimeout(Jt.current),Jt.current=window.setTimeout(()=>{Tr(!1)},1200)):Q.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:ft}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:ft}),children:Ti?s.jsx(b,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(b,{name:"file-copy-2",className:"size-4"})})),r.downloadFile&&m(e("filesView.editor.saveFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{const y=r.downloadFile;y&&y(c.path).catch(R=>{console.error("Download failed:",R),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:s.jsx(b,{name:"download",className:"size-4"})})),t?m(e("filesView.editor.exitFullscreen"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Y(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:s.jsx(b,{name:"fullscreen-exit",className:"size-4"})})):!f&&a==="full"&&m(e(_?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Y(!_),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(_?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(_?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:_?s.jsx(b,{name:"fullscreen-exit",className:"size-4"}):s.jsx(b,{name:"fullscreen",className:"size-4"})}))]})},rr=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(Zn,{open:Ls,onOpenChange:t=>{t||Ht(!0)},children:s.jsxs(ei,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(ti,{children:[s.jsx(si,{children:e("filesView.unsaved.title")}),s.jsx(ri,{children:e("filesView.unsaved.description")})]}),s.jsxs(ni,{children:[s.jsx(z,{variant:"outline",onClick:()=>{$i()},disabled:Wt,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),s.jsx(z,{variant:"destructive",onClick:Bi,children:e("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:q("flex flex-col flex-shrink-0",L&&"border-b border-border/40"),children:[L?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[f&&$&&s.jsx("button",{type:"button",onClick:()=>P(!1),"aria-label":e("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(b,{name:"arrow-left-s",className:"size-5"})}),f?c?s.jsxs(mr,{children:[s.jsx(pr,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":e("filesView.editor.openFilesAria"),children:[s.jsx(ks,{filePath:c.path,extension:c.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(qn,{name:c.name}),s.jsx(b,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(hr,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Nt.map(t=>{const i=c?.path===t.path;return s.jsxs(Rs,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}i||Re(t)},className:q("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(ks,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(qn,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),sn(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(b,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):Nt.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[vr.left&&s.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),vr.right&&s.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),s.jsx("div",{ref:Ms,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Nt.map(t=>{const i=c?.path===t.path;return s.jsxs("div",{title:Ts(o,t.path),className:q("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[s.jsx(ks,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{i||Re(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),s.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),sn(t.path)},className:q("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!N&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(b,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,c?s.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[ft&&!f?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:ft,children:ft}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:jn({layout:"docked"})})]}):null]}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:s.jsx(lr,{ref:wn.setScroller,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",Ke&&"[overflow-anchor:none]"),children:c?Le||hn?I?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):st?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:st}):Fe?s.jsx("div",{className:"flex h-full items-center justify-center p-3",children:s.jsx("img",{src:gn,alt:c?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):Be?vn(c):nt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(z,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(b,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):c&&es&&se==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(Vo,{ref:Cr,xml:ta,onChange:ea},`${c.path}:${Se}`)}):c&&Zt&&ue==="tree"?s.jsx(cr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(Ja,{jsonString:D,maxHeight:"100%",initiallyExpandedDepth:2})})}):c&&Ze&&$e()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:ps,ref:t=>{gs.current=t,ms.current=t},children:[s.jsx($n,{containerRef:gs,filePath:c.path,fileContent:D}),D.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(D.length/1024)})}),s.jsx(cr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(Ln,{content:D,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),!_&&s.jsx(Un,{containerRef:ms,open:Vr,onOpenChange:fs,focusNonce:Er})]}):c&&Pt&&B==="preview"?ra?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:!d.isVSCode&&fn===Ns?(()=>{const t=c.path.split("/").map(i=>encodeURIComponent(i)).join("/");return Vn().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:d.isVSCode?(()=>{const t=c.path.substring(0,c.path.lastIndexOf("/")+1);return t?D.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):D})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},sa)}):c&&Xs&&O==="view"?yn(c,Ke?D:ne,wn):s.jsxs("div",{className:q("relative h-full",Dt&&"overflow-hidden"),ref:ds,children:[s.jsx("div",{className:q("h-full",Dt&&"invisible"),children:s.jsx(On,{value:ne,onChange:xe,readOnly:!Ue,vimMode:Br==="vim",extensions:cn,className:"h-full",blockWidgets:ia,onViewReady:t=>{We.current=t,Is(i=>i+1),window.requestAnimationFrame(()=>{Mt(t)})},onViewDestroy:()=>{We.current&&(We.current=null),Is(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:le,highlightLines:U?{start:Math.min(U.start,U.end),end:Math.max(U.start,U.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const u=t.state.doc.lineAt(i.from).number;if(U&&!l.shiftKey&&Math.min(U.start,U.end)===u&&Math.max(U.start,U.end)===u)return _e(null),Yt(),Tt.current=!1,ut.current=null,Vt(!1),!0;if(f&&U&&!l.shiftKey){const p=Math.min(U.start,U.end,u),m=Math.max(U.start,U.end,u);return _e({start:p,end:m}),Tt.current=!1,ut.current=null,Vt(!1),!0}if(Tt.current=!0,ut.current=u,Vt(!0),U&&l.shiftKey){const p=Math.min(U.start,u),m=Math.max(U.end,u);_e({start:p,end:m})}else _e({start:u,end:u});return!0},mouseover:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Tt.current||ut.current===null)return!1;const u=t.state.doc.lineAt(i.from).number,p=Math.min(ut.current,u),m=Math.max(ut.current,u);return _e({start:p,end:m}),Vt(!0),!1},mouseup:()=>(Tt.current=!1,ut.current=null,Vt(!1),!1)}}})}),Dt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})})]}),aa=!!(o&&yr[o]),Fn=o?is[o]:null,Nn=s.jsxs("section",{className:q("flex min-h-0 flex-col overflow-hidden",f?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:q("flex flex-col gap-2 py-2",f?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(b,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(ss,{ref:M,value:E,onChange:t=>V(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),E.trim().length>0&&s.jsx("button",{type:"button","aria-label":e("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{V(""),M.current?.focus()},children:s.jsx(b,{name:"close",className:"size-4"})})]}),s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>_s("createFile",{path:T,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:s.jsx(b,{name:"file-add",className:"size-4"})})})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>_s("createFolder",{path:T,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:s.jsx(b,{name:"folder-add",className:"size-4"})})})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),s.jsxs(zt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{ws()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:s.jsx(b,{name:"refresh",className:"size-4"})})})}),s.jsx(Lt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(lr,{outerClassName:"flex-1 min-h-0",className:q("py-2",f?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:di?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):Fr.length>0?Fr.map(t=>{const i=c?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{Re(t)},className:q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[li(t.path,t.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):Fn?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:Fn}),s.jsxs(z,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ws()},children:[s.jsx(b,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):aa?rn(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),oa=a==="full"&&_&&c&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute right-4 top-4 z-30",children:jn({exitFullscreenOnly:!0})}),s.jsx(lr,{ref:bn.setScroller,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",Ke&&"[overflow-anchor:none]"),children:Le||hn?I?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):st?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:st}):Fe?s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsx("img",{src:gn,alt:c.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):Be?vn(c):nt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(z,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(b,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):Ze&&$e()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:ps,ref:t=>{gs.current=t,Ws.current=t},children:[c?s.jsx($n,{containerRef:gs,filePath:c.path,fileContent:D}):null,D.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(D.length/1024)})}),s.jsx(cr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(Ln,{content:D,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),s.jsx(Un,{containerRef:Ws,open:Vr,onOpenChange:fs,focusNonce:Er,className:"right-4 top-16"})]}):Xs&&O==="view"?yn(c,Ke?D:ne,bn):s.jsxs("div",{className:q("relative h-full",Dt&&"overflow-hidden"),children:[s.jsx("div",{className:q("h-full",Dt&&"invisible"),children:s.jsx(On,{value:ne,onChange:xe,readOnly:!Ue,vimMode:Br==="vim",extensions:cn,className:"h-full",onViewReady:t=>{We.current=t,window.requestAnimationFrame(()=>{Mt(t)})},onViewDestroy:()=>{We.current&&(We.current=null)}})}),Dt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(b,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Ko,{activeDialog:wt,dialogData:bt,dialogInputValue:ct,onDialogInputChange:kr,isDialogSubmitting:Fi,onDialogSubmit:Oi,onClose:na,inputRef:gi}),oa,f?$?rr:Nn:a==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:rr})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[h>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Nn}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:rr})]})]})};function Ho(a){return a+1}export{mu as FilesView};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{R as l,r as be,j as t,f as Ct}from"./vendor-react-BUCujlKS.js";import{f as et,y as Ze,a0 as Rt,hV as Mn,cU as Jt,cf as qt,t as v,I as A,b4 as Bs,b1 as Ds,cS as Nr,b3 as Ms,cx as Es,cy as Ts,cz as As,cA as Ls,cs as Yt,ct as Qt,B as W,hW as En,hX as Tn,bG as ht,bH as gt,bI as ft,bJ as pt,bK as bt,S as dr,a6 as Xt,a7 as Zt,a8 as es,hY as An,h as Ce,hZ as Ln,h_ as On,h$ as zn,i0 as Gn,b0 as _n,am as Hn,bR as $n,i1 as Wn,i2 as Un,i3 as Kn,i4 as Jn,i5 as qn,i6 as Yn,i7 as Qn,c2 as Sr,bU as Xn,bV as Zn,bW as ea,bX as ta,bY as sa,i8 as ra,b$ as na,bL as Rs,eN as aa,V as ia,ab as oa,ac as la,ae as ca,ad as da,bw as ua,i9 as ma,c0 as ha,ia as ga,ib as fa,af as pa,ic as xa,ag as wa,bP as ya,hO as ba,l as va,c1 as ja,g as Ca,cC as Na,al as Sa,a1 as ka,id as Va,ie as Is}from"./useAppFontEffects-CjrntdL0.js";import{a as Ia,b as Pa,d as Fa}from"./main-Bv5Pkngh.js";import{x as Ra,w as Ba,v as Da,X as Ma,c as Ea,a0 as Ta}from"./runtimeEndpointReset-CjhvxLH0.js";import{u as ur}from"./vendor-zustand-BAGL70zf.js";import{r as Aa,u as Pt}from"./index-DW_E3rnL.js";import{C as La,a as Oa}from"./CommitSection-SGBCAW0w.js";import{P as za}from"./PierreDiffViewer-B7m3f0d7.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.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";import"./vendor-zod-BLfBSgBh.js";import"./useRootScrollLock-BHYPkrLv.js";import"./scheduledTasksApi-DLW0mkQK.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./web-components-Bhg83tjf.js";import"./computeVirtualFileMetrics-BMIRgMHv.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-DD8lDVej.js";import"./isDiffPlainText-BqayB8d3.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-CDEuSlPH.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";const kr="gitmojiCache",Ga=1e3*60*60*24*7,Vr="1",_a="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",Ir=i=>{if(!i||typeof i!="object")return!1;const e=i;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},Ps=()=>{if(typeof window>"u")return null;try{const i=window.localStorage.getItem(kr);if(!i)return null;const e=JSON.parse(i);return!e||e.version!==Vr||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(Ir),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Ha=i=>{if(!(typeof window>"u"))try{const e={gitmojis:i,fetchedAt:Date.now(),version:Vr};window.localStorage.setItem(kr,JSON.stringify(e))}catch{return}},mr=i=>Date.now()-i.fetchedAt<Ga;let Ut=null;const Ft=new Set,hr=async()=>{if(Ut)return Ut;const i=(async()=>{try{const e=await fetch(_a);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const n=await e.json(),u=Array.isArray(n.gitmojis)?n.gitmojis.filter(Ir):[];return Ha(u),Ft.forEach(j=>j(u)),u}catch(e){console.warn("Failed to load gitmoji list:",e);const n=[];return Ft.forEach(u=>u(n)),n}finally{Ut=null}})();return Ut=i,i},$a=i=>{const[e,n]=l.useState(()=>i?Ps()?.gitmojis??[]:[]),[u,j]=l.useState(!1),f=l.useRef(i);f.current=i,l.useEffect(()=>{if(!i){Ft.delete(n),n([]),j(!1);return}const p=Ps();if(p&&(n(p.gitmojis),mr(p)))return;Ft.add(n),j(!0);let h=!1;return hr().finally(()=>{!h&&f.current&&j(!1)}),()=>{h=!0,Ft.delete(n)}},[i]);const x=l.useCallback(async()=>{if(!f.current)return[];if(e.length>0)return e;const p=Ps();return p&&mr(p)?p.gitmojis:hr()},[e]);return{gitmojis:e,isLoading:u,ensureLoaded:x}},Nt=async(i,e)=>{const n=await Aa(`/api/git/integrate/${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const u=await n.json().catch(()=>null);throw new Error(u?.error||`Git integrate request failed: ${n.statusText}`)}return n.json()};async function It(i){return Nt("plan",i)}async function Wa(i){return Nt("conflict-details",{tempWorktreePath:i})}async function Ua(i){return(await Nt("cherry-pick-status",{tempWorktreePath:i})).inProgress}async function Ka(i){return Nt("run",{plan:i})}async function Ja(i){await Nt("abort",{state:i})}async function qa(i){return Nt("continue",{state:i})}const Ya=({repoRoot:i,sourceBranch:e,worktreeMetadata:n,localBranches:u,defaultTargetBranch:j,refreshKey:f,onRefresh:x,showHeader:p=!0})=>{const{t:h}=et(),w=Ze(g=>g.currentSessionId),[E,b]=be.useState(!1),[V,L]=be.useState(""),S=be.useRef(null),O=be.useMemo(()=>Rt(u,V,g=>[g]),[u,V]),[C,y]=be.useState(j);be.useEffect(()=>{y(j)},[j]),be.useEffect(()=>{if(E){const g=setTimeout(()=>{S.current?.focus()},0);return()=>clearTimeout(g)}},[E]);const D=!!(i&&e&&C&&C!=="HEAD"&&e!==C),[k,R]=be.useState({kind:"idle"}),[I,F]=be.useState(!1),[r,Y]=be.useState([]),B=be.useMemo(()=>w?`aiworker.integrate.conflict:${w}`:null,[w]);be.useEffect(()=>{if(!B||typeof window>"u")return;const g=window.localStorage.getItem(B);if(!g)return;let d=!1;try{const P=JSON.parse(g);if(!P?.tempWorktreePath||P.repoRoot!==i){window.localStorage.removeItem(B);return}(async()=>{const M=await Ua(P.tempWorktreePath).catch(()=>!1);if(d)return;if(!M){window.localStorage.removeItem(B);return}const J=await Wa(P.tempWorktreePath).catch(()=>null);d||J&&R({kind:"conflict",state:P,details:J})})()}catch{window.localStorage.removeItem(B)}return()=>{d=!0}},[B,i]),be.useEffect(()=>{if(!D){R({kind:"idle"});return}let g=!1;return R({kind:"loading"}),(async()=>{try{const d=await It({repoRoot:i,sourceBranch:e,targetBranch:C});if(g)return;if(R({kind:"ready",plan:d}),d.commits.length>0){const M=d.commits.slice(-50).reverse(),J=await Mn(i,M);g||(Y(J),F(!1))}else g||(Y([]),F(!1))}catch{g||R({kind:"idle"})}})(),()=>{g=!0}},[D,i,e,C,f]);const m=be.useCallback(g=>{w&&Ze.getState().setWorktreeMetadata(w,{...n,createdFromBranch:g})},[w,n]),T=Ze(g=>g.openNewSessionDraft),ee=be.useCallback(async g=>{const d=await Jt("git.integrate.cherrypick.resolve.visible",{current_commit:g.state.currentCommit,target_branch:g.state.targetBranch}),P=await Jt("git.integrate.cherrypick.resolve.instructions",{repo_root:g.state.repoRoot,temp_worktree_path:g.state.tempWorktreePath,source_branch:g.state.sourceBranch,target_branch:g.state.targetBranch,current_commit:g.state.currentCommit}),M=`Cherry-pick conflict context (JSON)
|
|
2
|
-
${JSON.stringify({repoRoot:g.state.repoRoot,tempWorktreePath:g.state.tempWorktreePath,sourceBranch:g.state.sourceBranch,targetBranch:g.state.targetBranch,currentCommit:g.state.currentCommit,remainingCommits:g.state.remainingCommits,statusPorcelain:g.details.statusPorcelain,unmergedFiles:g.details.unmergedFiles,currentPatchMeta:g.details.currentPatchMeta,currentPatch:g.details.currentPatch,diff:g.details.diff},null,2)}`;return{visibleText:d,instructionsText:P,payloadText:M}},[]),$=qt(g=>g.setPendingInputText),G=qt(g=>g.setPendingSyntheticParts),_=be.useCallback(async(g,d)=>{const P=await ee(g);if(d){T({directoryOverride:g.state.tempWorktreePath,initialPrompt:P.visibleText,syntheticParts:[{text:P.instructionsText,synthetic:!0},{text:P.payloadText,synthetic:!0}]});return}if(!w){v.error(h("gitView.integrate.noActiveSession"),{description:h("gitView.integrate.noActiveSessionDescription")});return}$(P.visibleText,"replace"),G([{text:P.instructionsText,synthetic:!0},{text:P.payloadText,synthetic:!0}])},[w,ee,T,$,G,h]),Z=be.useCallback(async()=>{if(k.kind==="ready"){if(k.plan.commits.length===0){v.message(h("gitView.integrate.noCommitsToMoveToast"));return}R({kind:"running",plan:k.plan});try{const g=await Ka(k.plan);if(g.kind==="success"){v.success(h("gitView.integrate.commitsMovedToast"),{description:g.moved===1?h("gitView.integrate.commitsMovedDescriptionSingle",{count:g.moved,branch:k.plan.targetBranch}):h("gitView.integrate.commitsMovedDescriptionPlural",{count:g.moved,branch:k.plan.targetBranch})});const d=await It(k.plan);R({kind:"ready",plan:d}),x?.();return}g.kind==="conflict"&&(v.error(h("gitView.integrate.cherryPickConflictToast"),{description:h("gitView.integrate.cherryPickConflictDescription")}),R({kind:"conflict",state:g.state,details:g.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(g.state)))}catch(g){const d=g instanceof Error?g.message:String(g);v.error(h("gitView.integrate.failedToMoveToast"),{description:d});const P=await It({repoRoot:i,sourceBranch:e,targetBranch:C}).catch(()=>null);R(P?{kind:"ready",plan:P}:{kind:"idle"})}}},[k,x,i,e,C,B,h]),H=be.useCallback(async()=>{if(k.kind==="conflict")try{await Ja(k.state),v.message(h("gitView.integrate.cherryPickAbortedToast")),B&&typeof window<"u"&&window.localStorage.removeItem(B)}finally{const g=await It({repoRoot:i,sourceBranch:e,targetBranch:C}).catch(()=>null);R(g?{kind:"ready",plan:g}:{kind:"idle"})}},[k,i,e,C,B,h]),ce=be.useCallback(async()=>{if(k.kind==="conflict")try{const g=await qa(k.state);if(g.kind==="success"){v.success(h("gitView.integrate.cherryPickFinishedToast"));const d=await It({repoRoot:i,sourceBranch:e,targetBranch:C}).catch(()=>null);R(d?{kind:"ready",plan:d}:{kind:"idle"}),B&&typeof window<"u"&&window.localStorage.removeItem(B),x?.();return}g.kind==="conflict"&&(R({kind:"conflict",state:g.state,details:g.details}),B&&typeof window<"u"&&window.localStorage.setItem(B,JSON.stringify(g.state)))}catch(g){const d=g instanceof Error?g.message:String(g);v.error(h("gitView.integrate.cherryPickContinueFailedToast"),{description:d})}},[k,i,e,C,x,B,h]);return!i||!e?null:t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[p?t.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(A,{name:"split-cells-horizontal",className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:h("gitView.integrate.title")}),k.kind==="ready"&&k.plan.commits.length>0?t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:h("gitView.integrate.toMoveCount",{count:k.plan.commits.length})}):null]}),t.jsx("div",{className:"flex items-center gap-2",children:k.kind==="loading"||k.kind==="running"?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):null})]}):null,t.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"typography-ui-label text-foreground",children:h("gitView.integrate.moveCommits")}),t.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," → ",C]})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Bs,{open:E,onOpenChange:b,children:[t.jsx(Ds,{asChild:!0,children:t.jsxs("button",{type:"button",className:Nr({size:"default"}),children:[h("gitView.integrate.target"),t.jsx("span",{className:"max-w-[160px] truncate font-mono text-xs text-muted-foreground",children:C}),t.jsx(A,{name:"arrow-down-s",className:"size-4 opacity-60"})]})}),t.jsx(Ms,{align:"end",className:"w-72 p-0 max-h-[var(--available-height)] flex flex-col overflow-hidden",children:t.jsxs(Es,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(Ts,{ref:S,placeholder:h("gitView.branch.searchPlaceholder"),value:V,onValueChange:L,onKeyDown:g=>g.stopPropagation()}),t.jsxs(As,{className:"h-full min-h-0",scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(Ls,{children:h("gitView.branch.empty")}),t.jsx(Yt,{heading:h("gitView.branch.localBranches"),children:O.map(g=>t.jsx(Qt,{value:g,onSelect:()=>{y(g),m(g),b(!1),L("")},children:g},g))})]})]})})]}),k.kind==="ready"?t.jsx(W,{size:"sm",onClick:()=>{Z()},disabled:!D||k.plan.commits.length===0,children:h("gitView.integrate.move")}):k.kind==="loading"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:h("gitView.integrate.checking")}):k.kind==="running"?t.jsx(W,{size:"sm",variant:"outline",disabled:!0,children:h("gitView.integrate.moving")}):null]}),k.kind==="ready"&&k.plan.commits.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:h("gitView.integrate.noCommitsToMove")}),k.kind==="ready"&&k.plan.commits.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"typography-meta text-foreground",children:[h("gitView.integrate.commitsToMove"),t.jsxs("span",{className:"text-muted-foreground",children:[" (",k.plan.commits.length,")"]})]}),r.length>0&&k.plan.commits.length>5&&t.jsx("button",{type:"button",onClick:()=>F(g=>!g),className:"typography-micro text-muted-foreground hover:text-foreground",children:h(I?"gitView.integrate.showLess":"gitView.integrate.showAll")})]}),t.jsxs("div",{className:"space-y-1",children:[(I?r:r.slice(0,5)).map(g=>t.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[t.jsx("span",{className:"font-mono text-xs text-muted-foreground flex-shrink-0",children:g.short}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:g.subject||g.sha})]},g.sha)),r.length===0&&t.jsx("div",{className:"typography-meta text-muted-foreground",children:h("gitView.integrate.previewUnavailable")}),k.plan.commits.length>r.length&&t.jsx("div",{className:"typography-micro text-muted-foreground/70",children:h("gitView.integrate.showingFirstCommits",{count:r.length})})]})]}),k.kind==="conflict"&&t.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 p-3 space-y-2",children:[t.jsx("div",{className:"typography-meta text-foreground",children:h("gitView.integrate.conflictsInFiles",{count:k.details.unmergedFiles.length})}),t.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[h("gitView.integrate.currentCommit"),": ",t.jsx("span",{className:"font-mono",children:k.state.currentCommit.slice(0,7)})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[k.details.unmergedFiles.slice(0,6).map(g=>t.jsx("span",{className:"font-mono text-xs px-2 py-0.5 rounded bg-muted/40 text-muted-foreground",children:g},g)),k.details.unmergedFiles.length>6&&t.jsx("span",{className:"text-xs text-muted-foreground",children:h("gitView.integrate.moreFiles",{count:k.details.unmergedFiles.length-6})})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{size:"sm",variant:"ghost",className:"typography-meta",onClick:()=>{H()},children:h("gitView.operation.abort")}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",disabled:!w,onClick:()=>{_({state:k.state,details:k.details},!1)},children:[t.jsx(A,{name:"sparkling",className:"size-3.5"}),h("gitView.integrate.currentSession")]}),t.jsxs(W,{size:"sm",variant:"secondary",className:"typography-meta gap-1",onClick:()=>{_({state:k.state,details:k.details},!0)},children:[t.jsx(A,{name:"sparkling",className:"size-3.5"}),h("gitView.integrate.newSession")]}),t.jsx(W,{size:"sm",className:"typography-meta",onClick:()=>{ce()},children:h("gitView.operation.continue")})]})]})]})]})},Qa=({open:i,onOpenChange:e,directory:n,hasUncommittedChanges:u,hasStagedChanges:j=!1,uncommittedFileCount:f,onChanged:x})=>{const{t:p}=et(),[h,w]=l.useState([]),[E,b]=l.useState(!1),[V,L]=l.useState(""),[S,O]=l.useState(""),[C,y]=l.useState(null),[D,k]=l.useState({}),R=l.useCallback(async()=>{if(n){b(!0);try{const m=await En(n);w(m.stashes),k({})}catch(m){v.error(m instanceof Error?m.message:p("gitView.stashes.toast.loadFailed"))}finally{b(!1)}}},[n,p]);l.useEffect(()=>{i&&R()},[R,i]),l.useEffect(()=>{if(!i||!n||h.length===0)return;let m=!1;const T=h.map(ee=>ee.ref);return Tn(n,T).then(ee=>{m||k(ee.counts)}).catch(()=>{}),()=>{m=!0}},[n,i,h]);const I=l.useMemo(()=>Rt(h,V,m=>[m.message,m.ref,m.relativeTime]),[V,h]),F=l.useCallback(async m=>{await R(),await x?.(m)},[R,x]),r=async()=>{if(!(!n||C)){y("create");try{const m=await An(n,{message:S.trim()||void 0});m.created?(v.success(p("gitView.stashes.toast.created")),O("")):v.info(p("gitView.stashes.toast.noChanges")),await F({affectsIndex:!!(m.created&&j)})}catch(m){v.error(m instanceof Error?m.message:p("gitView.stashes.toast.createFailed"))}finally{y(null)}}},Y=async(m,T)=>{if(!(!n||C)&&!(T==="drop"&&!window.confirm(p("gitView.stashes.confirm.drop",{ref:m.ref})))){y(`${T}:${m.ref}`);try{T==="apply"&&await Ln(n,{ref:m.ref}),T==="pop"&&await On(n,{ref:m.ref}),T==="drop"&&await zn(n,{ref:m.ref});const ee=T==="apply"?"gitView.stashes.toast.applySuccess":T==="pop"?"gitView.stashes.toast.popSuccess":"gitView.stashes.toast.dropSuccess";v.success(p(ee)),await F({affectsIndex:T!=="drop"})}catch(ee){const $=T==="apply"?"gitView.stashes.toast.applyFailed":T==="pop"?"gitView.stashes.toast.popFailed":"gitView.stashes.toast.dropFailed";v.error(ee instanceof Error?ee.message:p($)),await F({affectsIndex:T!=="drop"})}finally{y(null)}}},B=C!==null;return t.jsx(ht,{open:i,onOpenChange:e,children:t.jsxs(gt,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsxs(ft,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(A,{name:"archive-stack",className:"h-5 w-5"}),p("gitView.stashes.title")]}),t.jsx(bt,{children:p("gitView.stashes.description")})]}),t.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(dr,{value:S,onChange:m=>O(m.target.value),placeholder:p("gitView.stashes.messagePlaceholder"),disabled:B||!u,className:"flex-1"}),t.jsxs(W,{onClick:r,disabled:!u||B||!n,children:[C==="create"?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"inbox-archive",className:"size-4"}),p("gitView.stashes.actions.stashCurrentWithCount",{count:f})]})]}),t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:p("gitView.stashes.includeUntrackedHint")})]}),t.jsxs("div",{className:"relative mt-2",children:[t.jsx(A,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(dr,{value:V,onChange:m=>L(m.target.value),placeholder:p("gitView.stashes.searchPlaceholder"),className:"pl-9"})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:E?t.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:t.jsx(A,{name:"loader-4",className:"size-5 animate-spin"})}):I.length===0?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:p(V?"gitView.stashes.empty.search":"gitView.stashes.empty.list")}):I.map((m,T)=>t.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[t.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[t.jsx("p",{className:"typography-small truncate text-foreground",children:m.message||p("gitView.stashes.untitled")}),t.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[t.jsxs(Xt,{children:[t.jsx(Zt,{asChild:!0,children:t.jsx("span",{children:T===0&&!V.trim()?p("gitView.stashes.latestLabel"):p("gitView.stashes.itemNumber",{number:T+1})})}),t.jsx(es,{sideOffset:6,children:m.ref})]})," · ",m.relativeTime," · ",typeof D[m.ref]=="number"?p("gitView.stashes.fileCount",{count:D[m.ref]}):p("gitView.stashes.fileCountLoading")]})]}),t.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[t.jsx(Fs,{label:p("gitView.stashes.actions.apply"),loading:C===`apply:${m.ref}`,onClick:()=>Y(m,"apply"),disabled:B,children:t.jsx(A,{name:"inbox-unarchive",className:"size-4"})}),t.jsx(Fs,{label:p("gitView.stashes.actions.pop"),loading:C===`pop:${m.ref}`,onClick:()=>Y(m,"pop"),disabled:B,children:t.jsx(A,{name:"inbox-unarchive-fill",className:"size-4"})}),t.jsx(Fs,{label:p("gitView.stashes.actions.drop"),loading:C===`drop:${m.ref}`,onClick:()=>Y(m,"drop"),disabled:B,destructive:!0,children:t.jsx(A,{name:"delete-bin",className:"size-4"})})]})]},m.ref))})]})})},Fs=i=>{const e=Ct.c(17),{label:n,loading:u,disabled:j,destructive:f,onClick:x,children:p}=i,h=u||void 0,w=f?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground";let E;e[0]!==w?(E=Ce("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",w),e[0]=w,e[1]=E):E=e[1];let b;e[2]!==p||e[3]!==u?(b=u?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):p,e[2]=p,e[3]=u,e[4]=b):b=e[4];let V;e[5]!==j||e[6]!==n||e[7]!==x||e[8]!==h||e[9]!==E||e[10]!==b?(V=t.jsx(Zt,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":n,"aria-busy":h,className:E,onClick:x,disabled:j,children:b})}),e[5]=j,e[6]=n,e[7]=x,e[8]=h,e[9]=E,e[10]=b,e[11]=V):V=e[11];let L;e[12]!==n?(L=t.jsx(es,{sideOffset:6,children:n}),e[12]=n,e[13]=L):L=e[13];let S;return e[14]!==V||e[15]!==L?(S=t.jsxs(Xt,{children:[V,L]}),e[14]=V,e[15]=L,e[16]=S):S=e[16],S},Xa=i=>{const e=Ct.c(16),{onOpenStashes:n}=i,{t:u}=et();let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(A,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e[0]=j):j=e[0];let f;e[1]!==u?(f=u("gitView.empty.cleanTitle"),e[1]=u,e[2]=f):f=e[2];let x;e[3]!==f?(x=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:f}),e[3]=f,e[4]=x):x=e[4];let p;e[5]!==u?(p=u("gitView.empty.cleanDescription"),e[5]=u,e[6]=p):p=e[6];let h;e[7]!==p?(h=t.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:p}),e[7]=p,e[8]=h):h=e[8];let w;e[9]!==n||e[10]!==u?(w=n?t.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[t.jsx(A,{name:"archive-stack",className:"size-4"}),u("gitView.stashes.title")]}):null,e[9]=n,e[10]=u,e[11]=w):w=e[11];let E;return e[12]!==x||e[13]!==h||e[14]!==w?(E=t.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[j,x,h,w]}),e[12]=x,e[13]=h,e[14]=w,e[15]=E):E=e[15],E},mt=8,Za=i=>{const e=Ct.c(18),{laned:n,totalLanes:u,isExpanded:j}=i,{lane:f,color:x,connectors:p}=n,w=Math.max(u,f+1)*mt+mt/2,E=l.useRef(null),b=l.useRef(null);let V;e[0]!==x||e[1]!==p||e[2]!==f||e[3]!==w?(V=()=>{const y=E.current,D=b.current;if(!y||!D)return;const k=y.offsetHeight;if(k===0)return;const R=window.devicePixelRatio||1;D.width=w*R,D.height=k*R;const I=D.getContext("2d");if(!I)return;I.scale(R,R),I.clearRect(0,0,w,k);const F=k/2,r=f*mt+mt/2,Y=getComputedStyle(D),B=Y.getPropertyValue("--surface-muted-foreground").trim()||Y.color,m=$=>{if(!$.startsWith("var("))return $;const G=$.slice(4,-1).trim();return Y.getPropertyValue(G).trim()||B},T=[...p].sort(ti);for(const $ of T){const G=$.fromLane*mt+mt/2,_=$.toLane*mt+mt/2,Z=$.type==="passing"?.72:$.type==="branch-out"||$.type==="merge-in"?.95:1;I.beginPath(),I.strokeStyle=m($.color),I.globalAlpha=Z,I.lineWidth=1.25,I.lineCap="round";e:switch($.type){case"passing":case"commit-lane":{I.moveTo(G,0),I.lineTo(G,k);break e}case"top-stub":{I.moveTo(G,0),I.lineTo(G,F);break e}case"bottom-stub":{I.moveTo(G,F),I.lineTo(G,k);break e}case"branch-out":{const H=(F+k)/2;I.moveTo(r,F),I.bezierCurveTo(r,H,_,H,_,k);break e}case"merge-in":{const H=F/2;I.moveTo(G,0),I.bezierCurveTo(G,H,r,H,r,F);break e}default:continue}I.stroke(),I.globalAlpha=1}const ee=Y.getPropertyValue("--background").trim()||Y.getPropertyValue("--surface-background").trim();I.beginPath(),I.arc(r,F,4,0,Math.PI*2),I.fillStyle=m(x),I.fill(),I.beginPath(),I.arc(r,F,5,0,Math.PI*2),I.strokeStyle=ee||B,I.lineWidth=2,I.stroke()},e[0]=x,e[1]=p,e[2]=f,e[3]=w,e[4]=V):V=e[4];let L;e[5]!==x||e[6]!==p||e[7]!==j||e[8]!==f||e[9]!==n||e[10]!==u||e[11]!==w?(L=[n,f,x,p,u,j,w],e[5]=x,e[6]=p,e[7]=j,e[8]=f,e[9]=n,e[10]=u,e[11]=w,e[12]=L):L=e[12],l.useLayoutEffect(V,L);let S;e[13]!==w?(S={width:w,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},e[13]=w,e[14]=S):S=e[14];let O;e[15]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx("canvas",{ref:b,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),e[15]=O):O=e[15];let C;return e[16]!==S?(C=t.jsx("div",{ref:E,style:S,children:O}),e[16]=S,e[17]=C):C=e[17],C};function ei(i){return i==="branch-out"||i==="merge-in"}function ti(i,e){const n=ei;return(n(i.type)?1:0)-(n(e.type)?1:0)}const gr=15e3,fr=500,pr=12,xr=8*1024*1024,wr=i=>typeof i=="string"?0:(i.original?.length??0)+(i.modified?.length??0),yr=i=>{if(i.size<=pr){let j=0;for(const f of i.values())j+=wr(f);if(j<=xr)return i}const e=Array.from(i.entries()).reverse(),n=new Map;let u=0;for(const[j,f]of e){if(n.size>=pr)continue;const x=wr(f);u+x>xr&&n.size>0||(n.set(j,f),u+=x)}return new Map(Array.from(n.entries()).reverse())};function br(i,e){const n=new Date(i);return Number.isNaN(n.getTime())?i:$n(n,e,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function si(i){switch(i){case"A":return"text-[var(--status-success)]";case"D":return"text-[var(--status-error)]";case"M":return"text-[var(--status-warning)]";case"R":return"text-[var(--status-info)]";default:return"text-muted-foreground"}}function ri(i){return i?i.split(",").map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.startsWith("HEAD ->");return{label:n?e.replace("HEAD -> ",""):e.replace("tag: ",""),isHead:n,isTag:e.startsWith("tag: ")}}):[]}const ni=l.memo(({entry:i,mode:e="history",laned:n,totalLanes:u,isExpanded:j,onToggle:f,files:x,isLoadingFiles:p,onCopyHash:h,directory:w,onConflict:E,onActionSuccess:b})=>{const{t:V}=et(),L=Pt(d=>d.timeFormatPreference),S=e==="graph",[O,C]=l.useState(null),[y,D]=l.useState(!1),[k,R]=l.useState(""),[I,F]=l.useState(null),[r,Y]=l.useState(new Set),[B,m]=l.useState(new Map),[T,ee]=l.useState(new Set),$=async()=>{if(w){C("checkout");try{await Qn(w,i.hash),v.success(V("gitView.history.actions.detachedHead")),b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},G=async()=>{if(!(!w||!k.trim())){C("createBranch");try{await Wn(w,k.trim(),i.hash),D(!1),R(""),b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},_=async()=>{if(w){C("cherryPick");try{const d=await Yn(w,i.hash);d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"cherry-pick"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},Z=async()=>{if(w){C("revert");try{const d=await qn(w,i.hash);d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"revert"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},H=async(d,P=!1)=>{if(!(!w||O!==null)){C("reset");try{await Un(w,i.hash,d,P),b?.()}catch(M){v.error(String(M.message))}finally{C(null)}}},ce=async()=>{if(!I)return;const d=I;switch(F(null),d){case"checkout":return $();case"cherryPick":return _();case"revert":return Z();case"merge":return ie();case"rebase":return de();case"resetSoft":return H("soft");case"resetMixed":return H("mixed");case"resetHard":return H("hard",!0)}},ie=async()=>{if(w){C("merge");try{const d=await Jn(w,{branch:i.hash});d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"merge"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},de=async()=>{if(w){C("rebase");try{const d=await Kn(w,{onto:i.hash});d.conflict?E?.({conflict:!0,conflictFiles:d.conflictFiles,operation:"rebase"}):b?.()}catch(d){v.error(String(d.message))}finally{C(null)}}},oe=l.useCallback(async d=>{const P=d.path;if(!w){m(M=>new Map(M).set(P,"error"));return}m(M=>yr(new Map(M).set(P,"loading")));try{const M=Gn(w,i.hash,d.path,!1),J=new Promise((te,K)=>{setTimeout(()=>K(new Error(`Timed out after ${gr}ms`)),gr)}),ae=await Promise.race([M,J]);m(te=>yr(new Map(te).set(P,ae)))}catch{m(M=>new Map(M).set(P,"error"))}},[w,i.hash]),g=l.useCallback(async d=>{const P=d.path;if(d.changeType==="R"||d.isBinary){Y(te=>{const K=new Set(te);return K.has(P)?K.delete(P):K.add(P),K});return}const M=B.get(P);if(r.has(P)&&M&&M!=="error"){Y(te=>{const K=new Set(te);return K.delete(P),K});return}Y(te=>{const K=new Set(te);return K.add(P),K}),!(M&&M!=="error"||d.insertions+d.deletions>fr&&!T.has(P))&&await oe(d)},[B,T,oe,r]);return t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:f,className:Ce("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",S?"hover:bg-[var(--interactive-hover)]/40":j?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[S&&n&&u!==void 0?t.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:t.jsx(Za,{laned:n,totalLanes:u,isExpanded:j})}):t.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[S?(()=>{const d=ri(i.refs);return d.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:d.map(P=>t.jsx("span",{className:Ce("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",P.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":P.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:P.label},P.label))}):null})():null,t.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:i.message}),t.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[t.jsx("span",{className:"truncate min-w-[3ch]",title:i.author_name,children:i.author_name}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("span",{className:"truncate min-w-0",title:br(i.date,L),children:br(i.date,L)})]}),t.jsx("span",{className:"shrink-0",children:"·"}),t.jsx("code",{className:"shrink-0 font-mono",children:i.hash.slice(0,8)}),t.jsxs(Xt,{children:[t.jsx(Zt,{asChild:!0,children:t.jsx(W,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:d=>{d.stopPropagation(),h(i.hash)},children:t.jsx(A,{name:"file-copy",className:"size-3"})})}),t.jsx(es,{sideOffset:8,children:V("gitView.history.copySha")})]})]})]})]}),j&&t.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[S&&I?t.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/30 mb-2",children:[t.jsx("span",{className:"typography-micro text-muted-foreground flex-1 min-w-0",children:V(`gitView.history.actions.${I}Confirm`)}),t.jsxs(W,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:O!==null,onClick:d=>{d.stopPropagation(),ce()},children:[O!==null?t.jsx(A,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.confirmButton")]}),t.jsx(W,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:O!==null,onClick:d=>{d.stopPropagation(),F(null)},children:V("gitView.history.actions.cancelButton")})]}):S?t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:O!==null,onClick:d=>{d.stopPropagation(),F("checkout")},children:V("gitView.history.actions.checkout")}),y?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{autoFocus:!0,value:k,onChange:d=>R(d.target.value),onKeyDown:d=>{d.key==="Enter"&&G(),d.key==="Escape"&&(D(!1),R(""))},placeholder:V("gitView.history.actions.createBranchPlaceholder"),className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:!k.trim()||O!==null,onClick:d=>{d.stopPropagation(),G()},children:[O==="createBranch"?t.jsx(A,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.createBranchConfirm")]})]}):t.jsx(W,{variant:"outline",size:"xs",className:"h-6",onClick:d=>{d.stopPropagation(),D(!0)},children:V("gitView.history.actions.createBranch")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:O!==null,onClick:d=>{d.stopPropagation(),F("cherryPick")},children:V("gitView.history.actions.cherryPick")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:O!==null,onClick:d=>{d.stopPropagation(),F("revert")},children:V("gitView.history.actions.revert")}),t.jsxs(Bs,{children:[t.jsx(Ds,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"xs",className:"h-6",disabled:O!==null,onClick:d=>d.stopPropagation(),children:[O==="reset"?t.jsx(A,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,V("gitView.history.actions.reset")]})}),t.jsx(Ms,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(d=>t.jsx(_n,{disabled:O!==null,onSelect:P=>{P.stopPropagation(),F(`reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},children:V(`gitView.history.actions.reset${d.charAt(0).toUpperCase()+d.slice(1)}`)},d))})]}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:O!==null,onClick:d=>{d.stopPropagation(),F("merge")},children:V("gitView.history.actions.merge")}),t.jsx(W,{variant:"outline",size:"xs",className:"h-6",disabled:O!==null,onClick:d=>{d.stopPropagation(),F("rebase")},children:V("gitView.history.actions.rebase")})]}):null,p?t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(A,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:V("gitView.history.loadingFiles")})]}):x.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:V("gitView.history.noFiles")}):t.jsx("ul",{className:"space-y-0.5 py-2",children:x.map(d=>t.jsxs("li",{children:[t.jsxs("button",{type:"button",onClick:()=>g(d),className:Ce("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",r.has(d.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[t.jsx("span",{className:Ce("font-semibold w-3 text-center shrink-0",si(d.changeType)),children:d.changeType}),t.jsx("span",{className:"truncate text-foreground min-w-0",title:d.path,children:d.path}),!d.isBinary&&t.jsxs("span",{className:"shrink-0",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",d.insertions]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d.deletions]})]}),d.isBinary&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:V("gitView.history.binary")}),t.jsx(A,{name:r.has(d.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),r.has(d.path)&&t.jsx("div",{className:"max-h-[400px] overflow-y-auto rounded border border-border/40 mx-2 mb-1","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:d.changeType==="R"?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.renamedNoDiff")}):d.isBinary?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.binaryNoDiff")}):(()=>{const P=d.insertions+d.deletions;if(!T.has(d.path)&&P>fr)return t.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:V("gitView.history.largeDiffTitle",{count:P})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:V("gitView.history.largeDiffDescription")}),t.jsx(W,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{ee(J=>new Set(J).add(d.path)),oe(d)},children:V("gitView.history.renderDiffAnyway")})]});const M=B.get(d.path);return M==="loading"||M===void 0?t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:V("gitView.history.loadingDiff")}):M==="error"?t.jsx("button",{type:"button",onClick:()=>g(d),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:V("gitView.history.diffError")}):t.jsx(za,{original:M.original,modified:M.modified,language:Hn(d.path)||"",fileName:d.path,renderSideBySide:!1,layout:"inline",enableComments:!1})})()})]},d.path))})]})]})}),vr=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)","var(--syntax-keyword)","var(--syntax-string)","var(--status-info)"];function Kt(i){return vr[i%vr.length]}function ai(i){if(i.length===0)return[];const e=[],n=[];for(let u=0;u<i.length;u++){const j=i[u],f=[];for(let S=0;S<e.length;S++)e[S]===j.hash&&f.push(S);let x=f.length>0?f[0]:-1;if(x===-1){const S=e.indexOf(null);S!==-1?x=S:(x=e.length,e.push(null))}const p=f.slice(1),h=Kt(x),w=e[x]===j.hash,E=j.parents.length>0;E?e[x]=j.parents[0]:e[x]=null;const b=[],V=new Set;for(let S=1;S<j.parents.length;S++){const O=j.parents[S],C=e.indexOf(O);if(C!==-1)b.push(C);else{const y=e.indexOf(null);if(y!==-1)e[y]=O,b.push(y),V.add(y);else{const D=e.length;e.push(O),b.push(D),V.add(D)}}}const L=[];w&&E?L.push({fromLane:x,toLane:x,color:h,type:"commit-lane"}):w&&!E?L.push({fromLane:x,toLane:x,color:h,type:"top-stub"}):!w&&E&&L.push({fromLane:x,toLane:x,color:h,type:"bottom-stub"});for(const S of p)L.push({fromLane:S,toLane:x,color:Kt(S),type:"merge-in"}),e[S]=null;for(const S of b)L.push({fromLane:x,toLane:S,color:Kt(S),type:"branch-out"});for(let S=0;S<e.length;S++)e[S]!==null&&S!==x&&(V.has(S)||L.push({fromLane:S,toLane:S,color:Kt(S),type:"passing"}));n.push({commit:j,lane:x,color:h,connectors:L})}return n}const ii=[{labelKey:"gitView.history.logSize25",value:25},{labelKey:"gitView.history.logSize50",value:50},{labelKey:"gitView.history.logSize100",value:100}],oi=i=>{const e=Ct.c(84),{mode:n,log:u,isLogLoading:j,logMaxCount:f,onLogMaxCountChange:x,expandedCommitHashes:p,onToggleCommit:h,commitFilesMap:w,loadingCommitHashes:E,onCopyHash:b,directory:V,showHeader:L,contentMaxHeightClassName:S,branchDivider:O,onConflict:C,onActionSuccess:y}=i,D=n===void 0?"history":n,k=L===void 0?!0:L,R=S===void 0?"max-h-[50vh]":S,I=O===void 0?null:O,{t:F}=et(),[r,Y]=l.useState(!0),B=D==="graph";let m;e[0]!==B||e[1]!==u?(m=B&&u?ai(u.all):[],e[0]=B,e[1]=u,e[2]=m):m=e[2];const T=m;let ee;e[3]!==T?(ee=Math.max(1,...T.map(li)),e[3]=T,e[4]=ee):ee=e[4];const $=ee;let G;e[5]!==T?(G=new Map(T.map(ci)),e[5]=T,e[6]=G):G=e[6];const _=G;if(!u)return null;const Z=I!==null&&I.insertBeforeIndex>0&&I.insertBeforeIndex<u.all.length,H=I!==null&&I.insertBeforeIndex===u.all.length,ce=Z||H;let ie;e[7]!==I||e[8]!==Z||e[9]!==H||e[10]!==u.all?(ie=Z?u.all.slice(0,I.insertBeforeIndex):H?u.all:[],e[7]=I,e[8]=Z,e[9]=H,e[10]=u.all,e[11]=ie):ie=e[11];const de=ie;let oe;if(e[12]!==I||e[13]!==w||e[14]!==R||e[15]!==V||e[16]!==p||e[17]!==Z||e[18]!==ce||e[19]!==B||e[20]!==j||e[21]!==_||e[22]!==E||e[23]!==u.all||e[24]!==f||e[25]!==$||e[26]!==D||e[27]!==y||e[28]!==C||e[29]!==b||e[30]!==x||e[31]!==h||e[32]!==F||e[33]!==de){const se=Z?u.all.slice(I.insertBeforeIndex):[];let Q;e[35]!==I?.direction?(Q=I?.direction==="down"?t.jsx(A,{name:"arrow-down-s",className:"size-3.5"}):t.jsx(A,{name:"arrow-up",className:"size-3.5"}),e[35]=I?.direction,e[36]=Q):Q=e[36];const Ne=Q;let ve;e[37]!==w||e[38]!==V||e[39]!==p||e[40]!==B||e[41]!==_||e[42]!==E||e[43]!==$||e[44]!==D||e[45]!==y||e[46]!==C||e[47]!==b||e[48]!==h?(ve=Fe=>t.jsx("ul",{className:"divide-y divide-border/60",children:Fe.map(ue=>t.jsx(ni,{entry:ue,mode:D,laned:B?_.get(ue.hash):void 0,totalLanes:B?$:void 0,isExpanded:p.has(ue.hash),onToggle:()=>h(ue.hash),files:w.get(ue.hash)??[],isLoadingFiles:E.has(ue.hash),onCopyHash:b,directory:V,onConflict:C,onActionSuccess:y},ue.hash))}),e[37]=w,e[38]=V,e[39]=p,e[40]=B,e[41]=_,e[42]=E,e[43]=$,e[44]=D,e[45]=y,e[46]=C,e[47]=b,e[48]=h,e[49]=ve):ve=e[49];const me=ve;let he;e[50]!==j||e[51]!==u.all.length||e[52]!==f||e[53]!==x||e[54]!==F?(he=u.all.length>=f?t.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:t.jsx(W,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(f+25),disabled:j,className:"px-3 text-muted-foreground hover:text-foreground",children:j?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(A,{name:"loader-4",className:"size-3 animate-spin"}),F("gitView.history.loadingMore")]}):F("gitView.history.loadMore")})}):null,e[50]=j,e[51]=u.all.length,e[52]=f,e[53]=x,e[54]=F,e[55]=he):he=e[55];const Pe=he;oe=t.jsx(Sr,{outerClassName:`min-h-0 ${R}`,className:"h-full w-full",children:u.all.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:F("gitView.history.noCommits")})}):ce&&I?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0",children:[de.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(de)}):null,t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"h-px flex-1 bg-border/60"}),t.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[t.jsx("span",{className:"truncate",title:I.branchName,children:I.branchName}),Ne]}),t.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),se.length>0?t.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:me(se)}):null]}),Pe]}):t.jsxs(t.Fragment,{children:[me(u.all),Pe]})}),e[12]=I,e[13]=w,e[14]=R,e[15]=V,e[16]=p,e[17]=Z,e[18]=ce,e[19]=B,e[20]=j,e[21]=_,e[22]=E,e[23]=u.all,e[24]=f,e[25]=$,e[26]=D,e[27]=y,e[28]=C,e[29]=b,e[30]=x,e[31]=h,e[32]=F,e[33]=de,e[34]=oe}else oe=e[34];const g=oe;if(!k){if(ce){let Q;return e[56]!==g?(Q=t.jsx("section",{className:"h-full min-h-0",children:g}),e[56]=g,e[57]=Q):Q=e[57],Q}let se;return e[58]!==g?(se=t.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:g}),e[58]=g,e[59]=se):se=e[59],se}let d;e[60]!==F?(d=F("gitView.history.title"),e[60]=F,e[61]=d):d=e[61];let P;e[62]!==d?(P=t.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:d}),e[62]=d,e[63]=P):P=e[63];let M;e[64]!==j||e[65]!==r||e[66]!==f||e[67]!==x||e[68]!==F?(M=r&&t.jsx("div",{onClick:di,onPointerDown:ui,children:t.jsxs(Xn,{value:String(f),onValueChange:se=>x(Number(se)),disabled:j,children:[t.jsx(Zn,{size:"sm",className:"w-auto",disabled:j,children:t.jsx(ea,{placeholder:F("gitView.history.commitsPlaceholder")})}),t.jsx(ta,{children:ii.map(se=>t.jsx(sa,{value:String(se.value),children:F(se.labelKey)},se.value))})]})}),e[64]=j,e[65]=r,e[66]=f,e[67]=x,e[68]=F,e[69]=M):M=e[69];let J;e[70]!==r?(J=r?t.jsx(A,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):t.jsx(A,{name:"arrow-down-s",className:"size-4 text-muted-foreground"}),e[70]=r,e[71]=J):J=e[71];let ae;e[72]!==M||e[73]!==J?(ae=t.jsxs("div",{className:"flex items-center gap-2",children:[M,J]}),e[72]=M,e[73]=J,e[74]=ae):ae=e[74];let te;e[75]!==P||e[76]!==ae?(te=t.jsxs(Ra,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[P,ae]}),e[75]=P,e[76]=ae,e[77]=te):te=e[77];let K;e[78]!==g?(K=t.jsx(Ba,{children:g}),e[78]=g,e[79]=K):K=e[79];let we;return e[80]!==r||e[81]!==te||e[82]!==K?(we=t.jsxs(Da,{open:r,onOpenChange:Y,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[te,K]}),e[80]=r,e[81]=te,e[82]=K,e[83]=we):we=e[83],we};function li(i){return i.lane+1}function ci(i){return[i.commit.hash,i]}function di(i){return i.stopPropagation()}function ui(i){return i.stopPropagation()}const mi=i=>{const e=Ct.c(148),{open:n,onOpenChange:u,conflictFiles:j,directory:f,operation:x,onAbort:p,onClearState:h}=i;let w;e[0]!==j?(w=j===void 0?[]:j,e[0]=j,e[1]=w):w=e[1];const E=w,{t:b}=et(),V=Ze(hi),L=Ze(gi),S=qt(fi),O=qt(pi),[C,y]=l.useState(!1),[D,k]=l.useState(null),[R,I]=l.useState(null);let F,r;e[2]!==f||e[3]!==n||e[4]!==b?(F=()=>{!n||!f||(y(!0),I(null),k(null),ra(f).then(X=>{k(X)}).catch(X=>{const pe=X instanceof Error?X.message:b("gitView.conflict.loadFailed");I(pe)}).finally(()=>{y(!1)}))},r=[n,f,b],e[2]=f,e[3]=n,e[4]=b,e[5]=F,e[6]=r):(F=e[5],r=e[6]),l.useEffect(F,r);let Y;e[7]!==D||e[8]!==f||e[9]!==x?(Y=async()=>{if(!D)return null;const X=x==="merge"?"merge":"rebase",pe=D.headInfo||(x==="merge"?"MERGE_HEAD":"REBASE_HEAD"),Re=x==="merge"?"git commit --no-edit":"git rebase --continue",Ve=await Jt("git.conflict.resolve.visible",{operation_label:X,head_ref:pe}),je=await Jt("git.conflict.resolve.instructions",{operation_label:X,directory:f,operation:x,head_info:D.headInfo||"N/A",continue_cmd:Re}),le=`${X} conflict context (JSON)
|
|
3
|
-
${JSON.stringify({directory:f,operation:D.operation,headInfo:D.headInfo,statusPorcelain:D.statusPorcelain,unmergedFiles:D.unmergedFiles,diff:D.diff},null,2)}`;return{visibleText:Ve,instructionsText:je,payloadText:le}},e[7]=D,e[8]=f,e[9]=x,e[10]=Y):Y=e[10];const B=Y;let m;e[11]!==p||e[12]!==u?(m=()=>{p(),u(!1)},e[11]=p,e[12]=u,e[13]=m):m=e[13];const T=m;let ee;e[14]!==h||e[15]!==u?(ee=()=>{h?.(),u(!1)},e[14]=h,e[15]=u,e[16]=ee):ee=e[16];const $=ee;let G;e[17]!==B||e[18]!==L||e[19]!==h||e[20]!==u||e[21]!==S||e[22]!==O||e[23]!==b?(G=async()=>{const X=await B();if(!X){v.error(b("gitView.conflict.noDetailsAvailable"));return}if(!L){v.error(b("gitView.conflict.noActiveSession"),{description:b("gitView.conflict.noActiveSessionDescription")});return}S(X.visibleText,"replace"),O([{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]),h?.(),u(!1)},e[17]=B,e[18]=L,e[19]=h,e[20]=u,e[21]=S,e[22]=O,e[23]=b,e[24]=G):G=e[24];const _=G;let Z;e[25]!==B||e[26]!==f||e[27]!==h||e[28]!==u||e[29]!==V||e[30]!==b?(Z=async()=>{const X=await B();if(!X){v.error(b("gitView.conflict.noDetailsAvailable"));return}V({directoryOverride:f,initialPrompt:X.visibleText,syntheticParts:[{text:X.instructionsText,synthetic:!0},{text:X.payloadText,synthetic:!0}]}),h?.(),u(!1)},e[25]=B,e[26]=f,e[27]=h,e[28]=u,e[29]=V,e[30]=b,e[31]=Z):Z=e[31];const H=Z;let ce,ie,de,oe,g,d,P,M,J,ae,te,K,we,se,Q,Ne,ve,me,he,Pe,Fe,ue;if(e[32]!==D||e[33]!==E||e[34]!==L||e[35]!==T||e[36]!==$||e[37]!==_||e[38]!==H||e[39]!==C||e[40]!==R||e[41]!==u||e[42]!==n||e[43]!==x||e[44]!==b){const X=b(x==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),pe=D?.unmergedFiles||E;de=ht,Fe=n,ue=u,ie=gt,Pe="max-w-md w-[calc(100vw-2rem)]",se="flex flex-col gap-4 overflow-hidden";let Re;e[67]===Symbol.for("react.memo_cache_sentinel")?(Re=t.jsx(A,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e[67]=Re):Re=e[67];const Ve=t.jsxs("div",{className:"flex items-center gap-2",children:[Re,t.jsx(pt,{children:b("gitView.conflict.detectedTitle",{operation:X})})]});let je;e[68]!==x||e[69]!==b?(je=b("gitView.conflict.detectedDescription",{operation:x}),e[68]=x,e[69]=b,e[70]=je):je=e[70];let le;e[71]!==je?(le=t.jsx(bt,{children:je}),e[71]=je,e[72]=le):le=e[72],e[73]!==Ve||e[74]!==le?(Q=t.jsxs(ft,{children:[Ve,le]}),e[73]=Ve,e[74]=le,e[75]=Q):Q=e[75],e[76]!==C||e[77]!==b?(Ne=C&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-meta",children:b("gitView.conflict.loading")})]}),e[76]=C,e[77]=b,e[78]=Ne):Ne=e[78],e[79]!==R||e[80]!==b?(ve=R&&t.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:b("gitView.conflict.errorLoadingDetails",{message:R})}),e[79]=R,e[80]=b,e[81]=ve):ve=e[81],e[82]!==pe||e[83]!==b?(me=pe.length>0&&t.jsxs("div",{className:"space-y-2 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:b("gitView.conflict.conflictedFiles")}),t.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:pe.length})]}),t.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:t.jsx("ul",{className:"space-y-1",children:pe.map(xi)})})]}),e[82]=pe,e[83]=b,e[84]=me):me=e[84],e[85]!==D||e[86]!==b?(he=D?.headInfo&&t.jsxs("div",{className:"space-y-1 overflow-hidden",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:b("gitView.conflict.headInfo")}),t.jsx("div",{className:"typography-micro text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap",children:D.headInfo})]}),e[85]=D,e[86]=b,e[87]=he):he=e[87],te="flex flex-col gap-2 pt-2";let Be;e[88]!==H?(Be=()=>{H()},e[88]=H,e[89]=Be):Be=e[89];const _e=C||!D;let Le;e[90]!==C?(Le=C?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"add",className:"size-4"}),e[90]=C,e[91]=Le):Le=e[91];let Ee;e[92]!==b?(Ee=b("gitView.conflict.resolveNewSession"),e[92]=b,e[93]=Ee):Ee=e[93],e[94]!==Be||e[95]!==_e||e[96]!==Le||e[97]!==Ee?(K=t.jsxs(W,{variant:"default",onClick:Be,disabled:_e,className:"w-full gap-2",children:[Le,Ee]}),e[94]=Be,e[95]=_e,e[96]=Le,e[97]=Ee,e[98]=K):K=e[98];let De;e[99]!==_?(De=()=>{_()},e[99]=_,e[100]=De):De=e[100];const Te=C||!D||!L;let Ie;e[101]!==C?(Ie=C?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"chat-1",className:"size-4"}),e[101]=C,e[102]=Ie):Ie=e[102];let q;e[103]!==b?(q=b("gitView.conflict.resolveCurrentSession"),e[103]=b,e[104]=q):q=e[104],e[105]!==De||e[106]!==Te||e[107]!==Ie||e[108]!==q?(we=t.jsxs(W,{variant:"outline",onClick:De,disabled:Te,className:"w-full gap-2",children:[Ie,q]}),e[105]=De,e[106]=Te,e[107]=Ie,e[108]=q,e[109]=we):we=e[109],J="flex gap-2 pt-1";let xe;e[110]!==b?(xe=b("gitView.conflict.continueLater"),e[110]=b,e[111]=xe):xe=e[111],e[112]!==$||e[113]!==xe?(ae=t.jsx(W,{variant:"ghost",size:"sm",onClick:$,className:"flex-1",children:xe}),e[112]=$,e[113]=xe,e[114]=ae):ae=e[114],ce=W,oe="destructive",g="sm",d=T,P="flex-1",M=b("gitView.conflict.abortOperation",{operation:X}),e[32]=D,e[33]=E,e[34]=L,e[35]=T,e[36]=$,e[37]=_,e[38]=H,e[39]=C,e[40]=R,e[41]=u,e[42]=n,e[43]=x,e[44]=b,e[45]=ce,e[46]=ie,e[47]=de,e[48]=oe,e[49]=g,e[50]=d,e[51]=P,e[52]=M,e[53]=J,e[54]=ae,e[55]=te,e[56]=K,e[57]=we,e[58]=se,e[59]=Q,e[60]=Ne,e[61]=ve,e[62]=me,e[63]=he,e[64]=Pe,e[65]=Fe,e[66]=ue}else ce=e[45],ie=e[46],de=e[47],oe=e[48],g=e[49],d=e[50],P=e[51],M=e[52],J=e[53],ae=e[54],te=e[55],K=e[56],we=e[57],se=e[58],Q=e[59],Ne=e[60],ve=e[61],me=e[62],he=e[63],Pe=e[64],Fe=e[65],ue=e[66];let qe;e[115]!==ce||e[116]!==oe||e[117]!==g||e[118]!==d||e[119]!==P||e[120]!==M?(qe=t.jsx(ce,{variant:oe,size:g,onClick:d,className:P,children:M}),e[115]=ce,e[116]=oe,e[117]=g,e[118]=d,e[119]=P,e[120]=M,e[121]=qe):qe=e[121];let Ye;e[122]!==J||e[123]!==ae||e[124]!==qe?(Ye=t.jsxs("div",{className:J,children:[ae,qe]}),e[122]=J,e[123]=ae,e[124]=qe,e[125]=Ye):Ye=e[125];let ge;e[126]!==te||e[127]!==K||e[128]!==we||e[129]!==Ye?(ge=t.jsxs("div",{className:te,children:[K,we,Ye]}),e[126]=te,e[127]=K,e[128]=we,e[129]=Ye,e[130]=ge):ge=e[130];let fe;e[131]!==se||e[132]!==Q||e[133]!==Ne||e[134]!==ve||e[135]!==me||e[136]!==he||e[137]!==ge?(fe=t.jsxs("div",{className:se,children:[Q,Ne,ve,me,he,ge]}),e[131]=se,e[132]=Q,e[133]=Ne,e[134]=ve,e[135]=me,e[136]=he,e[137]=ge,e[138]=fe):fe=e[138];let Se;e[139]!==ie||e[140]!==Pe||e[141]!==fe?(Se=t.jsx(ie,{className:Pe,children:fe}),e[139]=ie,e[140]=Pe,e[141]=fe,e[142]=Se):Se=e[142];let ke;return e[143]!==de||e[144]!==Fe||e[145]!==ue||e[146]!==Se?(ke=t.jsx(de,{open:Fe,onOpenChange:ue,children:Se}),e[143]=de,e[144]=Fe,e[145]=ue,e[146]=Se,e[147]=ke):ke=e[147],ke};function hi(i){return i.openNewSessionDraft}function gi(i){return i.currentSessionId}function fi(i){return i.setPendingInputText}function pi(i){return i.setPendingSyntheticParts}function xi(i){return t.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:i,children:i},i)}const wi=({open:i,onOpenChange:e,operation:n,targetBranch:u,onConfirm:j})=>{const{t:f}=et(),[x,p]=l.useState(!0),[h,w]=l.useState(!1),E=f(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase"),b=async()=>{w(!0);try{await j(x),e(!1)}catch(L){const S=L instanceof Error?L.message:`Failed to ${n}`;v.error(S)}finally{w(!1)}},V=()=>{h||e(!1)};return t.jsx(ht,{open:i,onOpenChange:h?void 0:e,children:t.jsxs(gt,{className:"max-w-md",children:[t.jsxs(ft,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),t.jsx(pt,{children:f("gitView.stash.title")})]}),t.jsx(bt,{children:f("gitView.stash.description",{operation:n})})]}),t.jsxs("div",{className:"py-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:f("gitView.stash.thisWill")}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[t.jsx("li",{children:f("gitView.stash.stepStash")}),t.jsxs("li",{children:[f(n==="merge"?"gitView.operation.merge":"gitView.operation.rebase")," ",f(n==="merge"?"gitView.stash.mergeWith":"gitView.stash.rebaseOnto")," ",t.jsx("span",{className:"font-mono text-primary",children:u})]}),x&&t.jsx("li",{children:f("gitView.stash.stepRestore")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 py-2",children:[t.jsx(na,{checked:x,onChange:p,disabled:h,ariaLabel:f("gitView.stash.restoreAria")}),t.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!h&&p(!x),children:f("gitView.stash.restoreAfterOperation",{operation:n})})]}),t.jsxs(Rs,{className:"gap-2",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:V,disabled:h,children:f("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:b,disabled:h,className:"gap-1.5",children:h?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),f("gitView.common.processing")]}):f("gitView.stash.confirmButton",{operation:E})})]})]})})},yi=({mergeInProgress:i,rebaseInProgress:e,onContinue:n,onAbort:u,onResolveWithAI:j,conflictCount:f=0,isLoading:x=!1})=>{const{t:p}=et(),[h,w]=l.useState(null),E=i&&i.head,b=e&&(e.headName||e.onto),V=E?"merge":b?"rebase":null;if(!V)return null;const L=async()=>{w("continue");try{await n()}finally{w(null)}},S=async()=>{w("abort");try{await u()}finally{w(null)}},O=h!==null,C=f>0,y=p(V==="merge"?"gitView.operation.merge":"gitView.operation.rebase");let D="";i?D=i.message?p("gitView.operation.mergingMessage",{message:i.message}):p("gitView.operation.mergeInProgressWithHead",{head:i.head}):e&&(D=e.headName?p("gitView.operation.rebasingOnto",{headName:e.headName,onto:e.onto||""}):p("gitView.operation.rebaseInProgress"));const k=C?f===1?p("gitView.operation.inProgressTitleOneConflict",{operation:y,count:f}):p("gitView.operation.inProgressTitleManyConflicts",{operation:y,count:f}):p("gitView.operation.inProgressTitle",{operation:y}),R=p(C?"gitView.operation.resolveConflictsHint":"gitView.operation.readyToContinueHint");return t.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:t.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:k}),D&&t.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:D})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:R}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs(W,{variant:"ghost",size:"sm",onClick:S,disabled:O||x,className:"gap-1.5",children:[h==="abort"?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"close",className:"size-4"}),p("gitView.operation.abort")]}),C?j&&t.jsx(W,{variant:"default",size:"sm",onClick:j,disabled:O||x,children:p("gitView.operation.resolveWithAi")}):t.jsxs(W,{variant:"default",size:"sm",onClick:L,disabled:O||x,className:"gap-1.5",children:[h==="continue"?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"check",className:"size-4"}),p("gitView.operation.continue")]})]})]})]})})},bi=i=>{const e=Ct.c(104),{currentBranch:n,localBranches:u,remoteBranches:j,onMerge:f,onRebase:x,disabled:p,isOperating:h,operationLogs:w,onOperationComplete:E,mode:b,defaultTargetBranch:V}=i,L=p===void 0?!1:p,S=h===void 0?!1:h,O=w===void 0?[]:w,C=b===void 0?"dialog":b,{t:y}=et(),[D,k]=l.useState(!1),[R,I]=l.useState("merge"),[F,r]=l.useState(null),[Y,B]=l.useState(!1),[m,T]=l.useState(""),ee=l.useRef(null),$=l.useRef(null),G=L||S,_=n||y("gitView.branch.currentBranchFallback"),Z=O.length>0&&O.every(vi),H=O.some(ji);let ce;e[0]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{$.current&&($.current.scrollTop=$.current.scrollHeight)},e[0]=ce):ce=e[0],l.useEffect(ce,[O]);let ie;e[1]!==j?(ie=new Set(j.map(Ci).filter(Boolean)),e[1]=j,e[2]=ie):ie=e[2];const de=ie;let oe;if(e[3]!==m||e[4]!==n||e[5]!==u||e[6]!==de){let q;e[8]!==n||e[9]!==de?(q=Ae=>Ae!==n&&!de.has(Ae),e[8]=n,e[9]=de,e[10]=q):q=e[10];const xe=u.filter(q);oe=Rt(xe,m,Ni),e[3]=m,e[4]=n,e[5]=u,e[6]=de,e[7]=oe}else oe=e[7];const g=oe;let d;e[11]!==m||e[12]!==j?(d=Rt(j,m,Si),e[11]=m,e[12]=j,e[13]=d):d=e[13];const P=d;let M;e[14]!==V||e[15]!==u||e[16]!==j?(M=()=>V&&(j.includes(V)||u.includes(V))?V:null,e[14]=V,e[15]=u,e[16]=j,e[17]=M):M=e[17];const J=M;let ae;e[18]!==J||e[19]!==k?(ae=()=>{k(!0),r(J()),I("merge"),T("")},e[18]=J,e[19]=k,e[20]=ae):ae=e[20];const te=ae;let K;e[21]===Symbol.for("react.memo_cache_sentinel")?(K=q=>{r(q),B(!1),T("")},e[21]=K):K=e[21];const we=K;let se;e[22]!==f||e[23]!==x||e[24]!==R||e[25]!==F?(se=()=>{F&&(R==="merge"?f(F):x(F))},e[22]=f,e[23]=x,e[24]=R,e[25]=F,e[26]=se):se=e[26];const Q=se;let Ne;e[27]!==S||e[28]!==k?(Ne=()=>{S||(r(null),I("merge"),T(""),k(!1))},e[27]=S,e[28]=k,e[29]=Ne):Ne=e[29];const ve=Ne,me=()=>{S&&!Z||(Z&&E?.(),r(null),I("merge"),T(""),k(!1))};let he,Pe;e[30]!==Y?(he=()=>{Y||T("")},Pe=[Y],e[30]=Y,e[31]=he,e[32]=Pe):(he=e[31],Pe=e[32]),l.useEffect(he,Pe);let Fe,ue;e[33]!==C||e[34]!==J||e[35]!==F?(Fe=()=>{C==="dialog"||F||r(J())},ue=[C,J,F],e[33]=C,e[34]=J,e[35]=F,e[36]=Fe,e[37]=ue):(Fe=e[36],ue=e[37]),l.useEffect(Fe,ue);const ge=S?t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{ref:$,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:t.jsx("div",{className:"space-y-2",children:O.map(ki)})}),Z?C==="dialog"?t.jsx(Rs,{children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y(H?"gitView.common.close":"gitView.common.done")})}):t.jsx("div",{className:"flex justify-end",children:t.jsx(W,{variant:"default",size:"sm",onClick:me,children:y(H?"gitView.common.close":"gitView.common.done")})}):null]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:y("gitView.branch.operation")}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>I("merge"),className:Ce("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"git-merge",className:Ce("size-4",R==="merge"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Ce("typography-ui-label",R==="merge"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.merge")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.mergeDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>I("rebase"),className:Ce("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",R==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{name:"git-branch",className:Ce("size-4",R==="rebase"?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Ce("typography-ui-label",R==="rebase"?"text-foreground":"text-muted-foreground"),children:y("gitView.operation.rebase")})]}),t.jsx("p",{className:"typography-micro text-muted-foreground",children:y("gitView.branch.rebaseDescription")})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?y("gitView.branch.branchToMergeInto",{branch:_}):y("gitView.branch.branchToRebaseOnto")}),t.jsxs(Bs,{open:Y,onOpenChange:B,modal:!1,children:[t.jsx(Ds,{asChild:!0,children:t.jsxs("button",{type:"button",className:Ce(Nr({size:"default"}),"w-full"),children:[t.jsx("span",{className:Ce("truncate",!F&&"text-muted-foreground"),children:F||y("gitView.branch.selectBranch")}),t.jsx(A,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),t.jsx(Ms,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:t.jsxs(Es,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(Ts,{ref:ee,placeholder:y("gitView.branch.searchPlaceholder"),value:m,onValueChange:T,onKeyDown:Vi}),t.jsxs(As,{className:"h-full min-h-0",disableHorizontal:!0,children:[t.jsx(Ls,{children:y("gitView.branch.empty")}),g.length>0&&t.jsx(Yt,{heading:y("gitView.branch.localBranches"),children:g.map(q=>t.jsx(Qt,{onSelect:()=>we(q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:q})},`local-${q}`))}),g.length>0&&P.length>0?t.jsx(aa,{}):null,P.length>0&&t.jsx(Yt,{heading:y("gitView.branch.remoteBranches"),children:P.map(q=>t.jsx(Qt,{onSelect:()=>we(q),children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:q})},`remote-${q}`))})]})]})})]})]}),F?t.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:R==="merge"?t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryMergePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})," ",y("gitView.branch.summaryMergeInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_})]}):t.jsxs(t.Fragment,{children:[y("gitView.branch.summaryRebasePrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_})," ",y("gitView.branch.summaryRebaseInfix")," ",t.jsx("span",{className:"font-mono text-foreground",children:F})]})})}):null,C==="dialog"?t.jsxs(Rs,{className:"gap-2 pt-1",children:[t.jsx(W,{variant:"ghost",size:"sm",onClick:ve,children:y("gitView.common.cancel")}),t.jsx(W,{variant:"default",size:"sm",onClick:Q,disabled:!F,className:"gap-1.5",children:R==="merge"?t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"git-merge",className:"size-4"}),y("gitView.operation.merge")]}):t.jsxs(t.Fragment,{children:[t.jsx(A,{name:"git-branch",className:"size-4"}),y("gitView.operation.rebase")]})})]}):t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(W,{variant:"destructive",size:"sm",onClick:ve,disabled:G,children:y("gitView.common.reset")}),t.jsx("div",{className:"flex-1"}),t.jsx(W,{variant:"default",size:"sm",onClick:Q,disabled:G||!F,children:y(R==="merge"?"gitView.operation.merge":"gitView.operation.rebase")})]})]});if(C==="bare")return ge;if(C==="inline"){let q;e[38]!==y?(q=y("gitView.branch.updateTitle"),e[38]=y,e[39]=q):q=e[39];let xe;e[40]!==q?(xe=t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:q}),e[40]=q,e[41]=xe):xe=e[41];let Ae;e[42]!==y?(Ae=y("gitView.branch.updateDescriptionPrefix"),e[42]=y,e[43]=Ae):Ae=e[43];let Ge;e[44]!==_?(Ge=t.jsx("span",{className:"font-mono text-foreground",children:_}),e[44]=_,e[45]=Ge):Ge=e[45];let tt;e[46]!==Ae||e[47]!==Ge?(tt=t.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Ae," ",Ge,"."]}),e[46]=Ae,e[47]=Ge,e[48]=tt):tt=e[48];let nt;e[49]!==xe||e[50]!==tt?(nt=t.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:t.jsxs("div",{className:"space-y-1",children:[xe,tt]})}),e[49]=xe,e[50]=tt,e[51]=nt):nt=e[51];let at;e[52]!==ge?(at=t.jsx("div",{className:"pt-3",children:ge}),e[52]=ge,e[53]=at):at=e[53];let it;return e[54]!==nt||e[55]!==at?(it=t.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[nt,at]}),e[54]=nt,e[55]=at,e[56]=it):it=e[56],it}let fe;e[57]!==S?(fe=S?t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(A,{name:"git-merge",className:"size-4"}),e[57]=S,e[58]=fe):fe=e[58];let Se;e[59]!==y?(Se=y("gitView.branch.mergeRebase"),e[59]=y,e[60]=Se):Se=e[60];let ke;e[61]!==Se?(ke=t.jsx("span",{children:Se}),e[61]=Se,e[62]=ke):ke=e[62];let X;e[63]!==te||e[64]!==G||e[65]!==fe||e[66]!==ke?(X=t.jsx(Zt,{asChild:!0,children:t.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",onClick:te,disabled:G,children:[fe,ke]})}),e[63]=te,e[64]=G,e[65]=fe,e[66]=ke,e[67]=X):X=e[67];let pe;e[68]!==y?(pe=y("gitView.branch.mergeRebaseTooltip"),e[68]=y,e[69]=pe):pe=e[69];let Re;e[70]!==pe?(Re=t.jsx(es,{sideOffset:8,children:pe}),e[70]=pe,e[71]=Re):Re=e[71];let Ve;e[72]!==X||e[73]!==Re?(Ve=t.jsxs(Xt,{children:[X,Re]}),e[72]=X,e[73]=Re,e[74]=Ve):Ve=e[74];let je;e[75]!==me||e[76]!==k?(je=q=>{q?k(!0):me()},e[75]=me,e[76]=k,e[77]=je):je=e[77];let le;e[78]!==y?(le=y("gitView.branch.updateTitle"),e[78]=y,e[79]=le):le=e[79];let Be;e[80]!==le?(Be=t.jsx(pt,{children:le}),e[80]=le,e[81]=Be):Be=e[81];let _e;e[82]!==H||e[83]!==S||e[84]!==R||e[85]!==Z||e[86]!==y||e[87]!==_?(_e=S?y(Z?H?"gitView.branch.operationFailed":"gitView.branch.operationCompleted":R==="merge"?"gitView.branch.mergingInProgress":"gitView.branch.rebasingInProgress"):t.jsxs(t.Fragment,{children:[y("gitView.branch.dialogDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:_}),"."]}),e[82]=H,e[83]=S,e[84]=R,e[85]=Z,e[86]=y,e[87]=_,e[88]=_e):_e=e[88];let Le;e[89]!==_e?(Le=t.jsx(bt,{children:_e}),e[89]=_e,e[90]=Le):Le=e[90];let Ee;e[91]!==Be||e[92]!==Le?(Ee=t.jsxs(ft,{children:[Be,Le]}),e[91]=Be,e[92]=Le,e[93]=Ee):Ee=e[93];let De;e[94]!==ge||e[95]!==Ee?(De=t.jsxs(gt,{className:"max-w-md",children:[Ee,ge]}),e[94]=ge,e[95]=Ee,e[96]=De):De=e[96];let Te;e[97]!==D||e[98]!==je||e[99]!==De?(Te=t.jsx(ht,{open:D,onOpenChange:je,children:De}),e[97]=D,e[98]=je,e[99]=De,e[100]=Te):Te=e[100];let Ie;return e[101]!==Ve||e[102]!==Te?(Ie=t.jsxs(t.Fragment,{children:[Ve,Te]}),e[101]=Ve,e[102]=Te,e[103]=Ie):Ie=e[103],Ie};function vi(i){return i.status==="done"||i.status==="error"}function ji(i){return i.status==="error"}function Ci(i){return i.slice(i.indexOf("/")+1)}function Ni(i){return[i]}function Si(i){return[i]}function ki(i,e){return t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"mt-0.5 shrink-0",children:[i.status==="running"&&t.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),i.status==="done"&&t.jsx(A,{name:"check",className:"size-3.5 text-success"}),i.status==="error"&&t.jsx(A,{name:"close",className:"size-3.5 text-destructive"}),i.status==="pending"&&t.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),t.jsx("span",{className:Ce("typography-micro",i.status==="error"&&"text-destructive",i.status==="done"&&"text-muted-foreground",i.status==="running"&&"text-foreground",i.status==="pending"&&"text-muted-foreground/60"),children:i.message})]},e)}function Vi(i){return i.stopPropagation()}const Ii=({runMutation:i,onMutationComplete:e,onMutationError:n,onPathsComplete:u,scheduleFlush:j})=>{const f=[];let x=!1;return{enqueue:h=>{const w=f[f.length-1];if(w?.directory===h.directory&&w.direction===h.direction){h.paths.forEach(E=>w.paths.add(E));return}f.push(h)},flush:()=>{if(x)return;const h=f.shift();if(!h)return;x=!0;const w={directory:h.directory,direction:h.direction,paths:Array.from(h.paths),rollback:h.rollback};(async()=>{try{await i(w),e(w)}catch(E){n(w,E)}finally{u(w.paths),x=!1,f.length>0&&j()}})()},clear:()=>{f.length=0},size:()=>f.length,isRunning:()=>x}},Pi=15e3,Fi=40,Ri=20,jr={feat:":sparkles:",feature:":sparkles:",fix:":bug:",bug:":bug:",hotfix:":ambulance:",docs:":memo:",documentation:":memo:",style:":lipstick:",refactor:":recycle:",perf:":zap:",performance:":zap:",test:":white_check_mark:",tests:":white_check_mark:",build:":construction_worker:",ci:":green_heart:",chore:":wrench:",revert:":rewind:",wip:":construction:",security:":lock:",release:":bookmark:",merge:":twisted_rightwards_arrows:",mv:":truck:",move:":truck:",rename:":truck:",remove:":fire:",delete:":fire:",add:":sparkles:",create:":sparkles:",implement:":sparkles:",update:":recycle:",improve:":zap:",optimize:":zap:",upgrade:":arrow_up:",downgrade:":arrow_down:",deploy:":rocket:",init:":tada:",initial:":tada:"},Bi=(i,e)=>{const n=i.toLowerCase(),u=/^([a-z]+)(?:\(.*\))?!?:/,j=n.match(u);if(j){const p=j[1],h=jr[p];if(h)return e.find(w=>w.code===h)||null}const f=n.split(" ")[0],x=jr[f];return x&&e.find(p=>p.code===x)||null},Di=20,yt=new Map,Mi=(i,e)=>{if(yt.delete(i),yt.set(i,e),yt.size>Di){const n=yt.keys().next().value;n!==void 0&&yt.delete(n)}},rt=i=>(i||"").replace(/\\/g,"/").replace(/\/+$/,""),Cr=i=>{const e=i.index?.trim();return!!(e&&e!=="?")},Ei=i=>{const e=i.working_dir?.trim(),n=i.index?.trim();return!!(e||n==="?")},Xl=({isActive:i})=>{const{t:e}=et(),{git:n}=ia(),u=oa(),[j,f]=l.useState(null),[x,p]=l.useState(!1),h=Ze(s=>s.currentSessionId),w=Ze(s=>s.newSessionDraft),E=Ze(s=>s.setDraftBootstrapPendingDirectory),b=Ze(s=>s.worktreeMetadata),V=Ze(s=>s.availableWorktrees),L=rt(u),S=l.useMemo(()=>{if(!L)return;const s=V.find(a=>rt(a.path)===L);if(s)return s;for(const a of b.values())if(rt(a.path)===L)return a},[V,L,b]),O=l.useMemo(()=>{if(h)return b.get(h)??S;if(w?.open)return S},[h,S,w?.open,b]),{profiles:C,globalIdentity:y,defaultGitIdentityId:D,loadProfiles:k,loadGlobalIdentity:R,loadDefaultGitIdentityId:I}=Ma(ur(s=>({profiles:s.profiles,globalIdentity:s.globalIdentity,defaultGitIdentityId:s.defaultGitIdentityId,loadProfiles:s.loadProfiles,loadGlobalIdentity:s.loadGlobalIdentity,loadDefaultGitIdentityId:s.loadDefaultGitIdentityId}))),{rootIsGitRepo:F,gitDirectory:r,nestedRepos:Y}=la(u??null,{enabled:i}),B=ca(r??null),m=da(r??null),T=ua(s=>h?s.getAttachment(h):void 0),ee=T?ma(T):[],$=T&&!T.degraded&&!T.legacy?T.worktreeRoot??void 0:void 0,G=Ia(u,O,m?.current??void 0),_=ha(r??null),Z=ga(r??null),H=fa(r??null),ce=pa(r??null),ie=xa(r??null),{setActiveDirectory:de,fetchAll:oe,ensureAll:g,fetchStatus:d,fetchBranches:P,fetchLog:M,setLogMaxCount:J,fetchIdentity:ae,prefetchDiffs:te,clearDiffCache:K,moveStatusPathsOptimistically:we,restoreStatus:se,bumpIndexRevision:Q,ensureNestedRepos:Ne,selectNestedRepo:ve}=wa(ur(s=>({setActiveDirectory:s.setActiveDirectory,fetchAll:s.fetchAll,ensureAll:s.ensureAll,fetchStatus:s.fetchStatus,fetchBranches:s.fetchBranches,fetchLog:s.fetchLog,setLogMaxCount:s.setLogMaxCount,fetchIdentity:s.fetchIdentity,prefetchDiffs:s.prefetchDiffs,clearDiffCache:s.clearDiffCache,moveStatusPathsOptimistically:s.moveStatusPathsOptimistically,restoreStatus:s.restoreStatus,bumpIndexRevision:s.bumpIndexRevision,ensureNestedRepos:s.ensureNestedRepos,selectNestedRepo:s.selectNestedRepo}))),me=Pt(s=>s.isMobile),he=Pt(s=>s.openContextDiff),Pe=Pt(s=>s.openContextSurface),Fe=m?.current??null,ue=ya(s=>!r||!Fe?null:ba(s.entries,r,Fe)),qe=Pt(s=>s.navigateToDiff),Ye=l.useRef(null),ge=l.useRef(null),fe=l.useRef(null),Se=l.useRef(null),ke=l.useRef(!0);l.useEffect(()=>()=>{ke.current=!1},[]);const X=l.useCallback(()=>{ge.current!==null&&(window.clearTimeout(ge.current),ge.current=null)},[]),pe=l.useCallback(s=>{X(),ge.current=window.setTimeout(()=>{ge.current=null,rt(s)===rt(r)&&d(s,n,{silent:!0})},Pi)},[X,r,d,n]);l.useEffect(()=>X,[X]);const Re=l.useCallback(()=>{fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null)},[]),Ve=l.useCallback(()=>{fe.current===null&&(fe.current=window.setTimeout(()=>{fe.current=null,Se.current?.()},0))},[]),je=l.useCallback(async(s,a,o)=>{if(a==="stage"){if(n.stageGitFiles){await n.stageGitFiles(s,o);return}await Promise.all(o.map(c=>n.stageGitFile(s,c)));return}if(n.unstageGitFiles){await n.unstageGitFiles(s,o);return}await Promise.all(o.map(c=>n.unstageGitFile(s,c)))},[n]),le=l.useMemo(()=>Ii({runMutation:({directory:s,direction:a,paths:o})=>je(s,a,o),onMutationComplete:({directory:s})=>{Q(s),pe(s)},onMutationError:({directory:s,direction:a,rollback:o},c)=>{o?.(),Q(s),pe(s);const N=e(a==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed");v.error(c instanceof Error?c.message:N)},onPathsComplete:s=>{Ws(a=>{const o=new Set(a);return s.forEach(c=>o.delete(c)),o})},scheduleFlush:Ve}),[Q,je,Ve,pe,e]);l.useEffect(()=>(Se.current=le.flush,()=>{Se.current=null}),[le]),l.useEffect(()=>()=>le.clear(),[le]),l.useEffect(()=>Re,[Re]),l.useEffect(()=>{if(!i)return;if(!u){f(null),p(!1);return}let s=!1,a=null;const o=async()=>{try{const c=await Va(u);if(s)return;f(c.status),c.status==="pending"&&(a=window.setTimeout(()=>{o()},500))}catch{s||f(null)}};return o(),()=>{s=!0,a!==null&&window.clearTimeout(a)}},[i,u]),l.useEffect(()=>{const s=Ye.current;Ye.current=j,!(!u||!n)&&(s==="pending"&&j==="ready"&&(p(!0),oe(u,n).finally(()=>{window.setTimeout(()=>{p(!1)},1200)})),j==="failed"&&(E(null),p(!1)))},[u,oe,n,E,j]);const Be=rt(w?.bootstrapPendingDirectory??null),_e=!!(u&&Be&&Be===rt(u)),Ee=!!(u&&(j==="pending"||_e))||x,De=l.useMemo(()=>r?yt.get(r)??null:null,[r]),Te=va(s=>s.settingsGitmojiEnabled),[Ie,q]=l.useState(null),{gitmojis:xe}=$a(Te);l.useEffect(()=>{const s=$||G?.projectDirectory;if(!s){q(null);return}let a=!1;return ja(s).then(o=>{if(a)return;const c=o.trim();q(c&&c!=="HEAD"?c:null)}).catch(()=>{a||q(null)}),()=>{a=!0}},[$,G?.projectDirectory]);const[Ae,Ge]=l.useState(De?.commitMessage??""),[tt,nt]=l.useState([]),[at,it]=l.useState(!1),Os=l.useRef(null),[zs,Bt]=l.useState(null),[Pr,ts]=l.useState(!1),[Gs,_s]=l.useState(null),[Ue,Fr]=l.useState(25),[Rr,Hs]=l.useState(!1),{triggerFireworks:Br}=Pa(),$s=l.useRef(new Map),Dt=l.useRef(0),ss=l.useCallback(()=>{Dt.current+=1,ke.current&&Hs(!0)},[]),rs=l.useCallback(()=>{Dt.current=Math.max(0,Dt.current-1),ke.current&&Dt.current===0&&Hs(!1)},[]),[ns,Mt]=l.useState(new Set),[Dr,Ws]=l.useState(new Set),[as,Us]=l.useState(!1),[Mr,Er]=l.useState(0),[Tr,Ks]=l.useState(!1),[is,os]=l.useState(De?.generatedHighlights??[]),Ar=Dr.size>0||le.size()>0||le.isRunning(),Js=l.useCallback(()=>{const s=Os.current;s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})})})},[]),ls=$||G?.projectDirectory||null,cs=m?.current||null,Lr=l.useMemo(()=>{const s=m?.tracking;return s?s.startsWith("origin/"):!0},[m?.tracking]),qs=l.useMemo(()=>{const s=G?.createdFromBranch,a=typeof s=="string"?s.trim():"",o=typeof m?.current=="string"?m.current.trim():"",c=typeof Ie=="string"?Ie.trim():"";return a?a===o&&a.startsWith("opencode/")&&c.length>0&&c!==a?c:a:c||o||"HEAD"},[G?.createdFromBranch,m,Ie]),Et=l.useCallback(()=>{os([])},[]),[ds,Or]=l.useState(new Set),[Tt,zr]=l.useState(new Map),[At,us]=l.useState(new Set),ms=l.useRef(Tt),St=l.useRef(At),[Gr,vt]=l.useState(null),[xt,hs]=l.useState(null),[Ys,Qs]=l.useState(""),[Me,Lt]=l.useState(null),[_r,Xs]=l.useState(!1),[Hr,Zs]=l.useState(!1),[gs,fs]=l.useState([]),[$r,er]=l.useState(null),[tr,ps]=l.useState(null),[Wr,Ot]=l.useState([]),[Ur,Ke]=l.useState(!1),[Kr,Qe]=l.useState([]),[zt,Xe]=l.useState("merge"),[Jr,xs]=l.useState(null),[ws,sr]=l.useState(!1),[ys,qr]=l.useState(100),[Yr,Qr]=l.useState(0),Je=l.useMemo(()=>h?`aiworker.conflict:${h}`:null,[h]),st=l.useCallback((s,a,o)=>{if(!Je||typeof window>"u")return;const c={directory:s,conflictFiles:a,operation:o};window.localStorage.setItem(Je,JSON.stringify(c))},[Je]),He=l.useCallback(()=>{!Je||typeof window>"u"||window.localStorage.removeItem(Je)},[Je]);l.useEffect(()=>{if(!Je||typeof window>"u"||!r)return;const s=window.localStorage.getItem(Je);if(s)try{const a=JSON.parse(s);if(a.directory!==r){window.localStorage.removeItem(Je);return}Qe(a.conflictFiles??[]),Xe(a.operation??"merge"),Ke(!0)}catch{window.localStorage.removeItem(Je)}},[Je,r]);const[Xr,bs]=l.useState(!1),[vs,rr]=l.useState("merge"),[js,nr]=l.useState(""),Zr=l.useCallback(s=>{Ca(s).then(a=>{if(a.ok){v.success(e("gitView.toast.commitHashCopied"));return}v.error(e("gitView.toast.copyFailed"))})},[e]),en=l.useCallback(s=>{Or(a=>{const o=new Set(a);return o.has(s)?o.delete(s):o.add(s),o})},[]);l.useEffect(()=>{ms.current=Tt},[Tt]),l.useEffect(()=>{St.current=At},[At]),l.useEffect(()=>{if(!r||!n)return;const s=Array.from(ds).filter(o=>!ms.current.has(o)&&!St.current.has(o));if(s.length===0)return;let a=!1;return us(o=>{const c=new Set(o);for(const N of s)c.add(N);return St.current=c,c}),Promise.all(s.map(o=>n.getCommitFiles(r,o).then(c=>({hash:o,files:c.files})).catch(c=>(console.error("Failed to fetch commit files:",c),{hash:o,files:[]})))).then(o=>{a||(zr(c=>{const N=new Map(c);for(const{hash:z,files:ne}of o)N.set(z,ne);return ms.current=N,N}),us(c=>{const N=new Set(c);for(const{hash:z}of o)N.delete(z);return St.current=N,N}))}),()=>{a=!0,us(o=>{let c=!1;const N=new Set(o);for(const z of s)N.delete(z)&&(c=!0);return c?(St.current=N,N):o})}},[ds,r,n]),l.useEffect(()=>{if(!r)return;const s=yt.get(r)??null;Ge(s?.commitMessage??""),os(s?.generatedHighlights??[])},[r]),l.useEffect(()=>{r&&Mi(r,{directory:r,commitMessage:Ae,generatedHighlights:is})},[Ae,r,is]),l.useEffect(()=>{i&&(k(),R(),I())},[i,k,R,I]),l.useEffect(()=>{if(!i)return;if(!r||!n?.getRemoteUrl||B!==!0){hs(null);return}let s=!1;return n.getRemoteUrl(r).then(a=>{s||hs(a)}).catch(()=>{s||hs(null)}),()=>{s=!0}},[i,r,n,B]);const Gt=l.useCallback(async()=>{if(!r||!n?.getRemotes||B!==!0){fs([]);return}try{const s=await n.getRemotes(r);ke.current&&fs(s)}catch{ke.current&&fs([])}},[r,n,B]);l.useEffect(()=>{i&&Gt()},[i,Gt]),l.useEffect(()=>{i&&u&&r&&(de(u),g(r,n))},[i,u,r,de,g,n]),l.useEffect(()=>{if(i&&r)return Na.onGitRefreshHint(s=>{rt(s.directory)===rt(r)&&(s.paths?.length&&K(r,s.paths),d(r,n,{silent:!0}))})},[i,K,r,d,n]);const re=l.useCallback(async(s=!0)=>{if(r)try{await Promise.all([d(r,n),P(r,n)])}catch(a){if(s){const o=a instanceof Error?a.message:e("gitView.toast.refreshRepositoryFailed");v.error(o)}}},[r,n,d,P,e]),ye=l.useCallback(async()=>{r&&await M(r,n,Ue)},[r,n,M,Ue]),Cs=l.useCallback(async()=>{r&&await ae(r,n)},[r,n,ae]);l.useEffect(()=>{if(!i||!r||!n?.hasLocalIdentity||B!==!0)return;const s=typeof D=="string"?D.trim():"";if(!s||s==="global"||$s.current.get(r)===s)return;let o=!1;return(async()=>{try{const N=await n.hasLocalIdentity?.(r);if(o||N===!0)return;ss(),await n.setGitIdentity(r,s),$s.current.set(r,s),await Cs()}catch(N){console.warn("Failed to auto-apply default git identity:",N)}finally{o||rs()}})(),()=>{o=!0}},[i,ss,r,D,rs,n,B,Cs]);const ot=l.useMemo(()=>m?[...m.files??[]].sort((a,o)=>a.path.localeCompare(o.path)):[],[m]),$e=l.useMemo(()=>ot.filter(Cr),[ot]),Ns=l.useMemo(()=>ot.filter(Ei),[ot]);l.useEffect(()=>{if(!r||ot.length===0)return;const s=[],a=new Set,o=N=>{!N||a.has(N)||(a.add(N),s.push(N))};if($e.forEach(N=>o(N.path)),tt.forEach(o),ot.slice(0,Ri).forEach(N=>o(N.path)),s.length===0)return;const c=window.setTimeout(()=>{te(r,n,s,{maxFiles:Fi})},120);return()=>{window.clearTimeout(c)}},[ot,r,n,te,$e,tt]);const ar=s=>s?.pushed[0]?.remote||m?.tracking?.split("/")[0]||We.find(a=>a.name==="origin")?.name||We[0]?.name||"origin",ir=async(s,a)=>{if(r){Bt(s);try{const o=c=>{const N=`${c.name}/`,z=m?.tracking?.startsWith(N)?m.tracking.slice(N.length):void 0;return{remote:c.name,branch:z,rebase:!0}};if(s==="fetch"){if(!a)throw new Error("No remote available for fetch");await n.gitFetch(r,{remote:a.name}),v.success(e("gitView.toast.fetchedFromRemote",{name:a.name}))}else if(s==="pull"){if(!a)throw new Error("No remote available for pull");const c=await n.gitPull(r,o(a));v.success(c.files.length===1?e("gitView.toast.pulledFilesSingle",{count:c.files.length,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c.files.length,name:a.name}))}else if(s==="push"){const c=await n.gitPush(r);v.success(e("gitView.toast.pushedToUpstream",{name:ar(c)}))}else if(s==="sync"){if(!a)throw new Error("No remote available for sync");let c=0,N=!1;await n.gitFetch(r,{remote:a.name});const z=await n.getGitStatus(r);if((z.behind??0)>0){if((z.files?.length??0)>0){v.error(e("gitView.toast.commitOrStashBeforeSync"));return}c=(await n.gitPull(r,o(a))).files.length}((await n.getGitStatus(r)).ahead??0)>0&&(await n.gitPush(r),N=!0),c>0&&N?v.success(c===1?e("gitView.toast.syncedPulledSingleAndPushed",{count:c,name:a.name}):e("gitView.toast.syncedPulledPluralAndPushed",{count:c,name:a.name})):c>0?v.success(c===1?e("gitView.toast.pulledFilesSingle",{count:c,name:a.name}):e("gitView.toast.pulledFilesPlural",{count:c,name:a.name})):N?v.success(e("gitView.toast.pushedToUpstream",{name:a.name})):v.success(e("gitView.toast.alreadyUpToDate"))}await re(!1),await ye()}catch(o){const c=o instanceof Error?o.message:e("gitView.toast.syncActionFailed",{action:s==="sync"?e("gitView.sync.syncChanges"):s==="pull"?e("gitView.sync.pull"):s});v.error(c)}finally{Bt(null)}}},tn=l.useCallback(async s=>{if(!r)return;const a=s.name.trim();if(!a){v.error(e("gitView.toast.remoteNameRequired"));return}if(a==="origin"){v.error(e("gitView.toast.cannotRemoveOriginRemote"));return}er(a);try{await n.removeRemote(r,{remote:a}),v.success(e("gitView.toast.removedRemote",{name:a})),await Promise.all([re(!1),Gt()])}catch(o){const c=o instanceof Error?o.message:`Failed to remove ${a}`;v.error(c)}finally{er(null)}},[r,n,Gt,re,e]),or=async(s={})=>{if(!r)return;if(!Ae.trim()){v.error(e("gitView.toast.enterCommitMessage"));return}const a=$e.map(c=>c.path).sort();if(a.length===0){v.error(e("gitView.toast.stageFileToCommit"));return}const o=s.pushAfter?"commitAndPush":"commit";_s(o);try{if(await n.createGitCommit(r,Ae.trim(),{files:a,stageFiles:[]}),Q(r),v.success(e("gitView.toast.commitCreated")),Ge(""),Et(),await re(),s.pushAfter){const c=m?.tracking?.split("/")[0],N=We.find(Dn=>Dn.name===c)??We[0];if(!N)throw new Error(e("mobile.changes.noRemote"));Bt("sync");const z=`${N.name}/`,ne=m?.tracking?.startsWith(z)?m.tracking.slice(z.length):void 0;await n.gitFetch(r,{remote:N.name});const U=await n.getGitStatus(r);if((U.behind??0)>0){if((U.files?.length??0)>0){v.error(e("gitView.toast.commitOrStashBeforeSync")),await re(!1);return}await n.gitPull(r,{remote:N.name,branch:ne,rebase:!0})}const ze=await n.getGitStatus(r);let jt;(ze.ahead??0)>0&&(jt=await n.gitPush(r)),v.success(e("gitView.toast.pushedToUpstream",{name:ar(jt)})),Br(),await re(!1)}else await re(!1);await ye(),Er(c=>c+1)}catch(c){const N=c instanceof Error?c.message:e("gitView.toast.createCommitFailed");v.error(N)}finally{_s(null),s.pushAfter&&Bt(null)}},sn=l.useCallback(async()=>{if(!r)return;const s=$e.map(a=>a.path).sort();if(s.length===0){v.error(e("gitView.toast.stageFileToDescribe"));return}console.error("[git-generation][browser] generate button clicked",{directory:r,selectedFiles:s.length}),Ks(!0);try{const{message:a}=await Sa(r,s),o=a.subject?.trim()??"",c=Array.isArray(a.highlights)?a.highlights:[];if(o){let N=o;if(Te&&xe.length>0){const z=Bi(o,xe);if(z){const{code:ne,emoji:U}=z;!o.startsWith(ne)&&!o.startsWith(U)&&(N=`${ne} ${o}`)}}Ge(N)}os(c),Js()}catch(a){console.error("[git-generation][browser] GitView generate handler failed",{message:a instanceof Error?a.message:String(a),error:a});const o=a instanceof Error?a.message:e("gitView.toast.generateCommitMessageFailed");v.error(o)}finally{Ks(!1)}},[r,$e,Te,xe,Js,e]),Ss=s=>s.reason==="attention"?`${s.attentionReason} in progress`:s.reason==="missing"?"worktree is missing":"worktree is invalid",rn=async(s,a)=>{if(!r||!m)return;const o=Is(T);if(o.length>0){v.error(e("gitView.toast.cannotCreateBranch",{reason:Ss(o[0])}));return}const c=m.current??null,N=a?.name??"origin";try{await n.createBranch(r,s,c??"HEAD"),v.success(e("gitView.toast.createdBranch",{name:s})),await n.checkoutBranch(r,s);let z=!1;try{await n.gitPush(r,{remote:N,branch:s,options:["--set-upstream"]}),z=!0}catch(ne){const U=ne instanceof Error?ne.message:`Unable to push new branch to ${N}.`;v.warning(e("gitView.toast.branchCreatedLocally"),{description:t.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",U]})})}await re(),await ye(),z&&v.success(e("gitView.toast.upstreamSet",{branch:s,remote:N}))}catch(z){const ne=z instanceof Error?z.message:e("gitView.toast.createBranchFailed");throw v.error(ne),z}},nn=async(s,a)=>{if(!r)return;const o=Is(T);if(o.length>0){v.error(e("gitView.toast.cannotRenameBranch",{reason:Ss(o[0])}));return}try{await n.renameBranch(r,s,a),v.success(e("gitView.toast.renamedBranch",{oldName:s,newName:a})),await re(),await ye()}catch(c){const N=c instanceof Error?c.message:e("gitView.toast.renameBranchFailed",{oldName:s,newName:a});v.error(N)}},an=async s=>{if(!r)return;const a=Is(T);if(a.length>0){v.error(e("gitView.toast.cannotCheckout",{reason:Ss(a[0])}));return}const o=s.replace(/^remotes\//,"");if(m?.current!==o)try{const c=await n.checkoutBranch(r,o);v.success(e("gitView.toast.checkedOut",{name:c?.branch||o})),await re(),await ye()}catch(c){const N=c instanceof Error?c.message:e("gitView.toast.checkoutFailed",{name:o});v.error(N)}},on=async s=>{if(r){ss();try{await n.setGitIdentity(r,s.id),v.success(e("gitView.toast.appliedIdentity",{name:s.name})),await Cs()}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.applyIdentityFailed");v.error(o)}finally{rs()}}},kt=l.useMemo(()=>_?.all?_.all.filter(s=>!s.startsWith("remotes/")).sort():[],[_]),lt=l.useMemo(()=>_?.all?_.all.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],[_]),We=l.useMemo(()=>{if(gs.length>0)return gs;const s=new Set,a=m?.tracking?.trim();a&&a.includes("/")&&s.add(a.split("/")[0]);for(const o of lt){const c=o.indexOf("/");c>0&&s.add(o.slice(0,c))}return s.size===0&&xt&&s.add("origin"),Array.from(s).map(o=>({name:o,fetchUrl:xt??"",pushUrl:xt??""}))},[gs,lt,xt,m?.tracking]),ct=m?.current??null,lr=l.useMemo(()=>{const s=m?.tracking?.trim().split("/")[0];return(s&&_?.defaultBranches?.[s])??_?.defaultBranches?.origin},[_,m?.tracking]),wt=l.useMemo(()=>Fa({remoteNames:new Set(We.map(s=>s.name)),localBranches:kt,worktreeCreatedFromBranch:G?.createdFromBranch,rootBranchHint:Ie,defaultBranch:lr,headBranch:ct}),[ct,lr,We,kt,Ie,G?.createdFromBranch]),ln=l.useMemo(()=>We.map(o=>o.name).map(o=>`${o}/${wt}`).find(o=>lt.includes(o))??wt,[wt,We,lt]),cn=l.useMemo(()=>{const s=new Map;y&&s.set(y.id,y);let a=null;if(xt)try{let o=xt.trim();o.startsWith("git@")&&(o=`https://${o.slice(4).replace(":","/")}`),o.endsWith(".git")&&(o=o.slice(0,-4));const c=new URL(o);a=c.hostname+c.pathname}catch{}for(const o of C){if(o.authType!=="token"){s.set(o.id,o);continue}const c=o.host;if(!c){s.set(o.id,o);continue}if(!c.includes("/")){s.set(o.id,o);continue}a&&a===c&&s.set(o.id,o)}return Array.from(s.values())},[C,y,xt]),dn=l.useMemo(()=>{if(H?.userName&&H?.userEmail){const s=C.find(a=>a.userName===H.userName&&a.userEmail===H.userEmail);return s||(y&&y.userName===H.userName&&y.userEmail===H.userEmail?y:{id:"local-config",name:H.userName,userName:H.userName,userEmail:H.userEmail,sshKey:H.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return y??null},[H,C,y]),un=$e.length,mn=ce||zs!==null||Gs!==null,hn=!!(G&&ls&&cs&&Lr),cr=!!ct,dt=hn&&ls&&cs&&G?{repoRoot:ls,sourceBranch:cs,worktreeMetadata:G}:null;l.useEffect(()=>{if(!r||!n||!Z?.all?.length||!ct||!wt||ct===wt){vt(null);return}let s=!1;return(async()=>{try{const o=await n.getGitLog(r,{from:wt,to:"HEAD",maxCount:Ue});if(s)return;const c=new Set((o?.all??[]).map(z=>z.hash).filter(z=>typeof z=="string"&&z.length>0));if(c.size===0){vt(null);return}const N=Z.all.findIndex(z=>!c.has(z.hash));if(N===0){vt(null);return}if(N===-1){vt({insertBeforeIndex:Z.all.length,branchName:ct,direction:"up"});return}vt({insertBeforeIndex:N,branchName:ct,direction:"up"})}catch{s||vt(null)}})(),()=>{s=!0}},[wt,ct,r,n,Z,Ue]),l.useEffect(()=>{xs(null)},[r]),l.useEffect(()=>{if(Me!=="graph"||!r){Me!=="graph"&&xs(null);return}let s=!1;return sr(!0),n.getGitLog(r,{maxCount:ys,all:!0}).then(a=>{s||xs(a)}).catch(a=>{console.error("Failed to fetch graph log:",a)}).finally(()=>{s||sr(!1)}),()=>{s=!0}},[Me,r,ys,Yr,n]);const Vt=l.useCallback((s,a)=>{if(!r||s.length===0)return;const o=Array.from(new Set(s));Ws(N=>{const z=new Set(N);return o.forEach(ne=>z.add(ne)),z});const c=we(r,o,a);le.enqueue({directory:r,direction:a,paths:new Set(o),rollback:()=>se(r,c)}),Ve()},[r,le,we,se,Ve]),ks=l.useCallback(async s=>{if(r){Mt(a=>{const o=new Set(a);return o.add(s),o});try{await n.revertGitFile(r,s,{scope:"working"}),v.success(e("gitView.toast.revertedFile",{path:s})),await re(!1)}catch(a){const o=a instanceof Error?a.message:e("gitView.toast.revertFailed");v.error(o)}finally{Mt(a=>{const o=new Set(a);return o.delete(s),o})}}},[r,re,n,e]),_t=l.useCallback(async(s,a,o="all")=>{if(!r||s.length===0)return;const c=Array.from(new Set(s));if(as||c.some(U=>ns.has(U)))return;const N=new Set($e.map(U=>U.path)),z=o==="all"&&c.some(U=>N.has(U));a&&Us(!0),Mt(U=>{const ze=new Set(U);return c.forEach(jt=>ze.add(jt)),ze});const ne=[];try{if(await Promise.all(c.map(async U=>{try{await n.revertGitFile(r,U,{scope:o})}catch(ze){ne.push({path:U,message:ze instanceof Error?ze.message:e("gitView.toast.revertFailed")})}})),z&&ne.length<c.length&&Q(r),await re(!1),ne.length===0)v.success(c.length===1?e("gitView.toast.revertedFilesSingle",{count:c.length}):e("gitView.toast.revertedFilesPlural",{count:c.length}));else if(ne.length===c.length)v.error(ne[0]?.message||e("gitView.toast.revertFailed"));else{const U=c.length-ne.length;v.warning(U===1?e("gitView.toast.revertedSomeSingle",{success:U,failed:ne.length}):e("gitView.toast.revertedSomePlural",{success:U,failed:ne.length}))}}finally{Mt(U=>{const ze=new Set(U);return c.forEach(jt=>ze.delete(jt)),ze}),a&&Us(!1)}},[Q,r,n,as,re,ns,$e,e]),gn=l.useCallback(async s=>{await _t(s,!0)},[_t]),fn=l.useCallback(async s=>{await _t(s,!1,"working")},[_t]),Vs=l.useCallback((s,a)=>{if(u&&!me){he(u,s,a);return}qe(s,a)},[u,me,qe,he]),pn=l.useCallback(()=>ts(!0),[]),xn=l.useMemo(()=>{const s=[];return $e.length>0&&s.push({id:"staged",title:e("gitView.changes.stagedTitle"),entries:$e,actionSymbol:"-",actionAllLabel:e("gitView.changes.unstageAllAria"),getActionLabel:a=>e("gitView.changes.unstageFileAria",{path:a}),onActionFile:a=>{Vt([a],"unstage")},onActionAll:a=>{Vt(a,"unstage")},onViewDiff:a=>Vs(a,!0),onRevertFile:ks,showRevertActions:!1,accent:!0}),Ns.length>0&&s.push({id:"unstaged",title:e("gitView.changes.title"),entries:Ns,actionSymbol:"+",actionAllLabel:e("gitView.changes.stageAllAria"),getActionLabel:a=>e("gitView.changes.stageFileAria",{path:a}),onActionFile:a=>{Vt([a],"stage")},onActionAll:a=>{Vt(a,"stage")},onViewDiff:a=>Vs(a,!1),onRevertFile:ks}),s},[ks,Vs,Vt,$e,e,Ns]),wn=l.useCallback(s=>{if(s.length===0)return;const a=s.map(o=>o.trim()).filter(Boolean);if(a.length===0){Et();return}Ge(o=>{const c=o.trim(),N=c.length>0?`
|
|
4
|
-
|
|
5
|
-
`:"";return`${c}${N}${a.join(`
|
|
6
|
-
`)}`.trim()}),Et()},[Et]),yn=l.useCallback((s,a)=>{const o=a||s;Ge(c=>{const N=c.trimStart();return N.startsWith(s)||a&&N.startsWith(a)?c:`${o.endsWith(" ")?o:`${o} `}${c}`.trimStart()}),Qs(""),it(!1)},[]),Ht=l.useCallback(s=>{const a=s instanceof Error?s.message.toLowerCase():"";return a.includes("uncommitted changes")||a.includes("local changes")||a.includes("your local changes would be overwritten")||a.includes("please commit your changes or stash them")||a.includes("cannot rebase: you have unstaged changes")||a.includes("error: cannot pull with rebase")},[]),ut=l.useCallback((s,a)=>{Ot(o=>[...o,{message:s,status:a,timestamp:Date.now()}])},[]),Oe=l.useCallback((s,a)=>{Ot(o=>{if(o.length===0)return o;const c=[...o];return c[c.length-1]={...c[c.length-1],status:s,...a?{message:a}:{}},c})},[]),$t=l.useCallback(()=>{Ot([])},[]),bn=l.useCallback(()=>{Ot([]),ps(null)},[]),Wt=l.useCallback(s=>{const a=s.trim(),o=new Set(We.map(N=>N.name)),c=a.indexOf("/");if(c>0){const N=a.slice(0,c),z=a.slice(c+1);if(o.has(N)&&z)return{branch:a,remote:N,remoteBranch:z}}for(const N of We){const z=`${N.name}/${a}`;if(lt.includes(z))return{branch:z,remote:N.name,remoteBranch:a}}return{branch:a,remote:null,remoteBranch:null}},[We,lt]),vn=l.useCallback(async s=>{if(!r)return;ps("merge"),$t();const a=m?.current,o=Wt(s);try{o.remote&&o.remoteBranch&&(ut(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),Oe("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ut(`Merging ${o.branch} into ${a}...`,"running");const c=await n.merge(r,{branch:o.branch});c.conflict?(Oe("error","Merge conflicts detected"),Qe(c.conflictFiles??[]),Xe("merge"),Ke(!0),st(r,c.conflictFiles??[],"merge")):(Oe("done",`Merged ${o.branch} into ${a}`),He(),ut("Refreshing repository status...","running"),await re(),await ye(),Oe("done","Repository status updated"))}catch(c){if(Ht(c))Oe("error","Uncommitted changes detected"),rr("merge"),nr(o.branch),bs(!0);else{const N=c instanceof Error?c.message:`Failed to merge ${o.branch}`;Oe("error",N)}}},[r,n,m,Wt,re,ye,Ht,st,He,ut,Oe,$t]),jn=l.useCallback(async s=>{if(!r)return;ps("rebase"),$t();const a=m?.current,o=Wt(s);try{o.remote&&o.remoteBranch&&(ut(`Fetching ${o.remote}/${o.remoteBranch}...`,"running"),await n.gitFetch(r,{remote:o.remote,branch:o.remoteBranch}),Oe("done",`Fetched ${o.remote}/${o.remoteBranch}`)),ut(`Rebasing ${a} onto ${o.branch}...`,"running");const c=await n.rebase(r,{onto:o.branch});c.conflict?(Oe("error","Rebase conflicts detected"),Qe(c.conflictFiles??[]),Xe("rebase"),Ke(!0),st(r,c.conflictFiles??[],"rebase")):(Oe("done",`Rebased ${a} onto ${o.branch}`),He(),ut("Refreshing repository status...","running"),await re(),await ye(),Oe("done","Repository status updated"))}catch(c){if(Ht(c))Oe("error","Uncommitted changes detected"),rr("rebase"),nr(o.branch),bs(!0);else{const N=c instanceof Error?c.message:`Failed to rebase onto ${o.branch}`;Oe("error",N)}}},[r,n,m,Wt,re,ye,Ht,st,He,ut,Oe,$t]),Cn=l.useCallback(async()=>{if(r)try{zt==="merge"?(await n.abortMerge(r),v.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),v.success(e("gitView.toast.rebaseAborted"))),He(),await re(),await ye()}catch(s){const a=s instanceof Error?s.message:`Failed to abort ${zt}`;v.error(a)}},[r,n,zt,re,ye,He,e]),Nn=l.useMemo(()=>m?.files?m.files.filter(s=>s.index==="U"||s.working_dir==="U"||s.index==="A"&&s.working_dir==="A"||s.index==="D"&&s.working_dir==="D").length:0,[m?.files]),Sn=l.useCallback(async()=>{if(r)try{const s=!!m?.mergeInProgress?.head,a=!!(m?.rebaseInProgress?.headName||m?.rebaseInProgress?.onto);if(s){const o=await n.continueMerge(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("merge"),Ke(!0),st(r,o.conflictFiles??[],"merge"),v.error(e("gitView.toast.mergeConflictsDetected"))):(He(),v.success(e("gitView.toast.mergeCompleted")),await re(),await ye())}else if(a){const o=await n.continueRebase(r);o.conflict?(Qe(o.conflictFiles??[]),Xe("rebase"),Ke(!0),st(r,o.conflictFiles??[],"rebase"),v.error(e("gitView.toast.rebaseConflictsDetected"))):(He(),v.success(e("gitView.toast.rebaseStepCompleted")),await re(),await ye())}}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.continueOperationFailed");v.error(a)}},[r,n,m,re,ye,st,He,e]),kn=l.useCallback(async()=>{if(r)try{!!m?.mergeInProgress?.head?(await n.abortMerge(r),v.success(e("gitView.toast.mergeAborted"))):(await n.abortRebase(r),v.success(e("gitView.toast.rebaseAborted"))),He(),await re(),await ye()}catch(s){const a=s instanceof Error?s.message:e("gitView.toast.abortOperationFailed");v.error(a)}},[r,n,m,re,ye,He,e]),Vn=l.useCallback(()=>{if(!r)return;const a=!!m?.mergeInProgress?.head?"merge":"rebase",o=m?.files?.filter(c=>c.index==="U"||c.working_dir==="U").map(c=>c.path)??[];o.length>0&&Qe(o),Xe(a),Ke(!0)},[r,m]),In=l.useCallback(async s=>{if(!r)return;const a=m?.current,o=vs,c=js,N=(m?.files??[]).some(Cr);try{await n.stash(r,{message:`Auto-stash before ${o} with ${c}`,includeUntracked:!0}),N&&Q(r)}catch(U){const ze=U instanceof Error?U.message:"Failed to stash changes";v.error(ze);return}let z=!1,ne=!1;try{if(o==="merge"){const U=await n.merge(r,{branch:c});U.conflict?(ne=!0,Qe(U.conflictFiles??[]),Xe("merge"),Ke(!0)):(z=!0,v.success(e("gitView.toast.mergedIntoBranch",{branch:c,currentBranch:a||""})))}else{const U=await n.rebase(r,{onto:c});U.conflict?(ne=!0,Qe(U.conflictFiles??[]),Xe("rebase"),Ke(!0)):(z=!0,v.success(e("gitView.toast.rebasedOntoBranch",{currentBranch:a||"",branch:c})))}if(s&&z)try{await n.stashPop(r),Q(r),v.success(e("gitView.toast.stashedRestored"))}catch(U){const ze=U instanceof Error?U.message:e("gitView.toast.restoreStashFailed");v.error(ze)}else s&&ne&&v.info(e("gitView.toast.restoreStashManually"));await re(),await ye()}catch(U){if(s)try{await n.stashPop(r),Q(r)}catch{}throw U}},[Q,r,n,m,vs,js,re,ye,e]),Pn=l.useCallback(s=>{Fr(s),r&&(J(r,s),M(r,n,s))},[r,M,n,J]),Fn=l.useCallback(s=>{qr(s)},[]),Rn=l.useCallback(()=>{Lt(null),r&&(d(r,n),P(r,n),M(r,n,Ue))},[r,d,P,M,Ue,n]),Bn=l.useCallback(s=>{if(s.conflict){if(s.operation==="cherry-pick"||s.operation==="revert"){v.error(e("gitView.history.actions.conflictToastTitle"),{description:e("gitView.history.actions.conflictToastDescription",{files:s.conflictFiles?.join(", ")??"unknown files"})}),r&&(d(r,n),P(r,n),M(r,n,Ue));return}Qe(s.conflictFiles??[]),Xe(s.operation),Ke(!0),r&&st(r,s.conflictFiles??[],s.operation)}},[e,Qe,Xe,Ke,st,r,d,P,M,Ue,n]);return u?B===null||B===!0&&!m?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),t.jsx("span",{className:"typography-ui-label",children:e("gitView.loading.checkingRepository")})]})}):B===!1?Ee?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[t.jsx(A,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e("gitView.empty.worktreeSetupInProgress")}),t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:e("gitView.empty.worktreeSetupDescription")})]}):t.jsx(Ea,{rootIsGitRepo:F,resolvedIsGitRepo:B,nestedRepos:Y,onRetryDiscovery:()=>{u&&Ne(u,{force:!0})},emptyStateFooter:ee.includes("open-without-worktree-features")?t.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:e("gitView.empty.worktreeFeaturesUnavailable")}):void 0}):t.jsxs("div",{className:Ce("flex h-full flex-col overflow-hidden"),children:[t.jsx(Ta,{status:m,localBranches:kt,remoteBranches:lt,branchInfo:_?.branches,syncAction:zs,remotes:We,onFetch:s=>ir("fetch",s),onSync:s=>ir("sync",s),onRemoveRemote:tn,removingRemoteName:$r,onCheckoutBranch:an,onCreateBranch:rn,onRenameBranch:nn,activeIdentityProfile:dn,availableIdentities:cn,onSelectIdentity:on,isApplyingIdentity:Rr,isWorktreeMode:!!G,onOpenHistory:()=>Lt("history"),onOpenGraph:()=>Lt("graph"),onOpenStashes:pn,onOpenUpdateBranch:cr?()=>Xs(!0):void 0,onOpenReintegrateCommits:dt?()=>Zs(!0):void 0,pullRequest:ue?.pr??null,prChecks:ue?.checks??null,onOpenPullRequest:r?()=>Pe(r,"pr"):void 0,repositoryOptions:r!==u&&Array.isArray(Y)?Y:void 0,selectedRepository:r!==u?r:null,onSelectRepository:r!==u&&u?s=>ve(u,s):void 0,repositoryRoot:r!==u?u:void 0}),u&&(m?.mergeInProgress?.head||m?.rebaseInProgress?.headName||m?.rebaseInProgress?.onto)&&t.jsx(yi,{mergeInProgress:m?.mergeInProgress,rebaseInProgress:m?.rebaseInProgress,onContinue:Sn,onAbort:kn,onResolveWithAI:Vn,conflictCount:Nn,isLoading:ce}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx("div",{className:"h-full min-h-0 flex flex-col",children:t.jsx("div",{className:Ce("min-w-0 min-h-0 h-full flex flex-col"),children:t.jsx(Sr,{as:ka,ref:Os,outerClassName:"flex-1 min-h-0",className:Ce("px-4","pt-1 pb-4"),disableHorizontal:!0,preventOverscroll:!0,children:t.jsx("div",{className:"flex h-full min-h-0 flex-col gap-3",children:(ot?.length??0)>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(La,{groups:xn,diffStats:m?.diffStats,revertingPaths:ns,isRevertingAll:as,onVisiblePathsChange:nt,onRevertAll:gn,onRevertDirectory:fn,headerBackgroundClassName:"bg-background"})}),t.jsx(Oa,{stagedCount:un,commitMessage:Ae,onCommitMessageChange:Ge,generatedHighlights:is,onInsertHighlights:wn,onGenerateMessage:sn,isGeneratingMessage:Tr,onCommit:()=>or({pushAfter:!1}),onCommitAndPush:()=>or({pushAfter:!0}),commitAction:Gs,hasPendingIndexMutation:Ar,gitmojiEnabled:Te,onOpenGitmojiPicker:()=>it(!0)})]}):t.jsx(Xa,{onOpenStashes:()=>ts(!0)})})})})})}),t.jsx(ht,{open:_r,onOpenChange:s=>{!s&&tr!==null||Xs(s)},children:t.jsxs(gt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ft,{children:[t.jsx(pt,{children:e("gitView.branch.updateTitle")}),t.jsxs(bt,{children:[e("gitView.branch.updateDescriptionPrefix")," ",t.jsx("span",{className:"font-mono text-foreground",children:m?.current??""}),"."]})]}),cr?t.jsx(bi,{mode:"bare",currentBranch:m?.current,localBranches:kt,remoteBranches:lt,defaultTargetBranch:ln,onMerge:vn,onRebase:jn,disabled:mn,isOperating:tr!==null,operationLogs:Wr,onOperationComplete:bn}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("gitView.branch.actionsUnavailable")})]})}),t.jsx(ht,{open:Hr,onOpenChange:Zs,children:t.jsxs(gt,{className:"max-w-2xl min-h-[26rem]",children:[t.jsxs(ft,{children:[t.jsx(pt,{children:e("gitView.integrate.title")}),t.jsx(bt,{children:dt?t.jsxs("span",{className:"font-mono text-foreground",children:[dt.sourceBranch," → ",qs]}):null})]}),dt?t.jsx(Ya,{repoRoot:dt.repoRoot,sourceBranch:dt.sourceBranch,worktreeMetadata:dt.worktreeMetadata,localBranches:kt,defaultTargetBranch:qs,refreshKey:Mr,showHeader:!1,onRefresh:()=>{r&&(d(r,n),P(r,n),M(r,n,Ue))}},dt.worktreeMetadata.path):null]})}),t.jsx(ht,{open:Me!==null,onOpenChange:s=>{s||Lt(null)},children:t.jsxs(gt,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs(ft,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(pt,{children:e(Me==="graph"?"gitView.graph.title":"gitView.history.title")}),t.jsxs(W,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:()=>{if(Me==="graph"){Qr(s=>s+1);return}r&&M(r,n,Ue)},disabled:Me==="graph"?ws:ie,title:e("gitView.history.refresh"),"aria-label":e("gitView.history.refresh"),children:[t.jsx(A,{name:"refresh",className:Ce("size-4",(Me==="graph"?ws:ie)&&"animate-spin")}),e("gitView.history.refresh")]})]}),t.jsx(bt,{children:e("gitView.history.dialogDescription")})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(oi,{mode:Me==="graph"?"graph":"history",log:Me==="graph"?Jr??Z:Z,isLogLoading:Me==="graph"&&ws||ie,logMaxCount:Me==="graph"?ys:Ue,onLogMaxCountChange:Me==="graph"?Fn:Pn,expandedCommitHashes:ds,onToggleCommit:en,commitFilesMap:Tt,loadingCommitHashes:At,onCopyHash:Zr,directory:r??void 0,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:Me==="graph"?null:Gr,onConflict:Me==="graph"?Bn:void 0,onActionSuccess:Me==="graph"?Rn:void 0})})]})}),t.jsx(Qa,{open:Pr,onOpenChange:ts,directory:r,hasUncommittedChanges:(m?.files?.length??0)>0,hasStagedChanges:$e.length>0,uncommittedFileCount:m?.files?.length??0,onChanged:async s=>{r&&s?.affectsIndex&&Q(r),await re(!1),await ye()}}),t.jsx(ht,{open:at,onOpenChange:it,children:t.jsxs(gt,{className:"max-w-md p-0 overflow-hidden",children:[t.jsx(ft,{className:"px-4 pt-4",children:t.jsx(pt,{children:e("gitView.gitmoji.title")})}),t.jsxs(Es,{className:"h-[420px]",shouldFilter:!1,children:[t.jsx(Ts,{placeholder:e("gitView.gitmoji.searchPlaceholder"),value:Ys,onValueChange:Qs}),t.jsxs(As,{children:[t.jsx(Ls,{children:e("gitView.gitmoji.empty")}),t.jsx(Yt,{children:Rt(xe,Ys,s=>[s.code,s.description,s.emoji]).map(s=>t.jsxs(Qt,{onSelect:()=>yn(s.emoji,s.code),children:[t.jsx("span",{className:"text-lg",children:s.emoji}),t.jsx("span",{className:"typography-ui-label text-foreground",children:s.code}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:s.description})]},s.code))})]})]})]})}),r&&t.jsx(mi,{open:Ur,onOpenChange:Ke,conflictFiles:Kr,directory:r,operation:zt,onAbort:Cn,onClearState:He}),t.jsx(wi,{open:Xr,onOpenChange:bs,operation:vs,targetBranch:js,onConfirm:In})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:e("gitView.empty.selectSessionOrDirectory")})})};export{Xl as GitView};
|