@aiworker/web 1.22.0 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/bin/cli.js +14 -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-B1Gizi3a.js} +1 -1
- package/dist/assets/DiffView-DXjVsEOw.js +4 -0
- package/dist/assets/DirtyBranchSwitchDialog-aig6zJjg.js +1 -0
- package/dist/assets/FilesView-CJdG0-wk.js +17 -0
- package/dist/assets/GitView-BXsS3jG6.js +6 -0
- package/dist/assets/{JsonTreeView-B0BdZEHG.js → JsonTreeView-D_hpXBnF.js} +1 -1
- package/dist/assets/LinearIssuesView-BoUiLQG1.js +1 -0
- package/dist/assets/MarkdownImageGallery-B_B_a9KS.js +1 -0
- package/dist/assets/MarkdownRendererImpl-xgyyLiBM.js +12 -0
- package/dist/assets/OnboardingScreen-DIp84OWt.js +1 -0
- package/dist/assets/{PatchDiff-DvfqDql7.js → PatchDiff-8p6nLJaU.js} +1 -1
- package/dist/assets/PierreDiffViewer-DjC8nTk9.js +161 -0
- package/dist/assets/PlanView-CJTmOF6I.js +5 -0
- package/dist/assets/SettingsView-DD-JqIJx.js +28 -0
- package/dist/assets/{SettingsWindow-i45U1Cy1.js → SettingsWindow-Cpb4hM6q.js} +1 -1
- package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
- package/dist/assets/{ToolOutputDialog-BTwyh5OF.js → ToolOutputDialog-DfaKZXNU.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-DtZLzrSK.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-DD8lDVej.js → VirtualizedFileDiff-C8i9HpTB.js} +1 -1
- package/dist/assets/WalkthroughView-DeKMvZlL.js +4 -0
- package/dist/assets/{computeVirtualFileMetrics-BMIRgMHv.js → computeVirtualFileMetrics-BBI7ZwrC.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-BdA6bdky.js +1 -0
- package/dist/assets/de-DCrsQ5zS.js +10 -0
- package/dist/assets/es-Dwv4YfH6.js +16 -0
- package/dist/assets/fr-BCWg4Cnx.js +14 -0
- package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
- package/dist/assets/index-B68h5S5B.css +1 -0
- package/dist/assets/index-DVwMarHI.js +39 -0
- package/dist/assets/{index-CODwDsU_.js → index-jXSK5RrB.js} +1 -1
- package/dist/assets/{isDiffPlainText-BqayB8d3.js → isDiffPlainText-B_x_rVon.js} +1 -1
- package/dist/assets/{isFilePlainText-QfoiKJNY.js → isFilePlainText-DW_xMer1.js} +1 -1
- package/dist/assets/ja-Bruw3RYC.js +16 -0
- package/dist/assets/ko-idhXGF8j.js +16 -0
- package/dist/assets/main-BkyaQhJX.js +930 -0
- package/dist/assets/{main-C5DVOxc6.js → main-CzdPuL0s.js} +2 -2
- package/dist/assets/markdownCore-Cn4Tyejo.js +5 -0
- package/dist/assets/{miniChat-DUJ4irZc.js → miniChat-CCkqKOLp.js} +2 -2
- package/dist/assets/{mobile-CcaxB0n4.js → mobile-mvxTo055.js} +2 -2
- package/dist/assets/patchFileDiff-Csk4iNUi.js +13 -0
- package/dist/assets/pl-CGZWUqZJ.js +16 -0
- package/dist/assets/pt-BR-B8V7u7tA.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-BxoyujA5.js +2 -0
- package/dist/assets/renderMobileApp-B48CsP4r.js +25 -0
- package/dist/assets/runtimeEndpointReset-Bg5gx18H.js +17 -0
- package/dist/assets/scheduledTasksApi-BW0Etzwz.js +1 -0
- package/dist/assets/{shikiHighlight-DYOWuY65.js → shikiHighlight-CRl0SUC9.js} +1 -1
- package/dist/assets/surface-oMvhsog3.js +1 -0
- package/dist/assets/tr-BK_KiO2V.js +7 -0
- package/dist/assets/uk-CG74xV8N.js +16 -0
- package/dist/assets/useAppFontEffects-CPKeOpUo.js +7284 -0
- package/dist/assets/useGitComparison-DH220WmO.js +1 -0
- package/dist/assets/useInlineCommentController-BiWz4AVb.js +2 -0
- package/dist/assets/useRootScrollLock-BS4-kr7P.js +1 -0
- package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-DdV8vhHn.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DFZik9R2.js → vendor-codemirror-language-data-Bg4AEeCr.js} +2 -2
- package/dist/assets/vendor-zod-BPAANqvH.js +39 -0
- package/dist/assets/{web-components-Bhg83tjf.js → web-components-z7hfnS8n.js} +1 -1
- package/dist/assets/zh-CN-T4AXofZI.js +16 -0
- package/dist/assets/zh-TW-Dte40sxp.js +16 -0
- package/dist/index.html +21 -59
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +5 -5
- package/package.json +3 -4
- package/server/index.d.ts +15 -0
- package/server/index.js +158 -89
- 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/data-dir-migration.js +40 -0
- package/server/lib/data-dir-migration.test.js +59 -0
- 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 +18 -18
- package/server/lib/fs/DOCUMENTATION.md +5 -0
- package/server/lib/fs/routes.js +68 -26
- package/server/lib/fs/routes.test.js +208 -22
- package/server/lib/git/DOCUMENTATION.md +32 -6
- 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 +41 -5
- package/server/lib/git/service.js +300 -224
- package/server/lib/git/service.test.js +596 -28
- 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 +17 -10
- package/server/lib/inherited-env.test.js +10 -11
- 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 +161 -0
- package/server/lib/message-queue/runtime.js +870 -0
- package/server/lib/message-queue/runtime.test.js +482 -0
- package/server/lib/network-defaults.js +23 -0
- package/server/lib/network-defaults.test.js +52 -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 +30 -6
- package/server/lib/opencode/auth.js +1 -1
- package/server/lib/opencode/bootstrap-runtime.js +8 -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 +19 -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 +79 -19
- package/server/lib/opencode/openchamber-routes.test.js +139 -12
- 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 +19 -17
- 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-files.js +214 -0
- package/server/lib/opencode/settings-helpers.js +116 -44
- package/server/lib/opencode/settings-helpers.test.js +354 -12
- package/server/lib/opencode/settings-registry.json +747 -0
- package/server/lib/opencode/settings-runtime.js +141 -20
- package/server/lib/opencode/settings-runtime.test.js +191 -4
- 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/DOCUMENTATION.md +25 -1
- package/server/lib/project-context/routes.http.test.js +18 -0
- package/server/lib/project-context/routes.js +16 -1
- package/server/lib/project-context/runtime.js +248 -23
- package/server/lib/project-context/runtime.test.js +106 -3
- package/server/lib/projects/DOCUMENTATION.md +76 -0
- package/server/lib/projects/project-config.js +144 -11
- package/server/lib/projects/project-id.js +17 -0
- package/server/lib/projects/project-setup.js +409 -0
- package/server/lib/projects/project-setup.test.js +557 -0
- package/server/lib/projects/routes.js +59 -0
- package/server/lib/quota/DOCUMENTATION.md +40 -2
- 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/cline-pass.js +125 -0
- package/server/lib/quota/providers/cline-pass.test.js +103 -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 +22 -0
- package/server/lib/quota/providers/neuralwatt.js +3 -6
- package/server/lib/quota/providers/neuralwatt.test.js +7 -7
- package/server/lib/quota/providers/ollama-cloud.js +32 -1
- package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
- package/server/lib/quota/providers/opencode-go.js +3 -2
- package/server/lib/quota/providers/opencode-go.test.js +35 -6
- package/server/lib/quota/providers/openrouter.js +119 -24
- package/server/lib/quota/providers/openrouter.test.js +330 -0
- 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 +56 -1
- package/server/lib/relay/cross-compat.test.js +26 -0
- package/server/lib/relay/downstream-scheduler.js +154 -0
- package/server/lib/relay/downstream-scheduler.test.js +162 -0
- package/server/lib/relay/e2ee.js +10 -8
- package/server/lib/relay/flow-control.test.js +177 -0
- package/server/lib/relay/host-client.js +38 -9
- 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-codec.js +9 -0
- package/server/lib/relay/tunnel-host.js +69 -18
- 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 +15 -18
- 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 +91 -30
- 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 +7 -2
- package/server/lib/small-model/call.js +18 -7
- package/server/lib/small-model/call.test.js +58 -6
- package/server/lib/small-model/index.js +12 -16
- 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/small-model/runtime-providers.js +15 -7
- package/server/lib/small-model/runtime-providers.test.js +7 -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 +14 -10
- package/server/lib/terminal/runtime.js +190 -31
- package/server/lib/terminal/runtime.test.js +572 -38
- 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/DOCUMENTATION.md +33 -14
- 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 +11 -15
- package/server/lib/walkthrough/model-settings.test.js +1 -1
- package/server/lib/walkthrough/prompt.js +3 -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/sources.js +23 -2
- 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/DiffView-DluiRSla.js +0 -4
- 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/MarkdownImageGallery-ClOvuZxC.js +0 -1
- package/dist/assets/MarkdownRendererImpl-Dt9mjTRN.js +0 -12
- package/dist/assets/OnboardingScreen-D2DG7K6b.js +0 -1
- package/dist/assets/PierreDiffViewer-B7m3f0d7.js +0 -157
- 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/WalkthroughView-egQgxel3.js +0 -4
- package/dist/assets/contextPanelEmbeddedChat-C3fjDbdg.js +0 -1
- package/dist/assets/de-C1P6X5Rs.js +0 -9
- package/dist/assets/es-CDgaF1_t.js +0 -15
- package/dist/assets/fr-Bgxqvvz_.js +0 -13
- package/dist/assets/index-C57jT0Sa.css +0 -1
- package/dist/assets/index-DW_E3rnL.js +0 -7
- package/dist/assets/ja-BDRrEcNP.js +0 -15
- package/dist/assets/ko-Ba8sQV79.js +0 -15
- package/dist/assets/main-Bv5Pkngh.js +0 -928
- package/dist/assets/markdownCore-CZwzz5gw.js +0 -3
- package/dist/assets/patchFileDiff-yNfWXN4E.js +0 -10
- package/dist/assets/pl-Dioz29BI.js +0 -15
- package/dist/assets/pt-BR-DIs6ElwV.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-BcKLHXKe.js +0 -2
- package/dist/assets/renderMobileApp-D9yQJy0L.js +0 -25
- package/dist/assets/runtimeEndpointReset-CjhvxLH0.js +0 -16
- package/dist/assets/scheduledTasksApi-DLW0mkQK.js +0 -1
- package/dist/assets/tr-DFnMlPxY.js +0 -6
- package/dist/assets/uk-ZrCNjM7Y.js +0 -15
- package/dist/assets/useAppFontEffects-CjrntdL0.js +0 -7310
- package/dist/assets/useInlineCommentController-CDEuSlPH.js +0 -2
- package/dist/assets/useRootScrollLock-BHYPkrLv.js +0 -1
- package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
- package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
- package/dist/assets/zh-CN-iv_AV4EC.js +0 -15
- package/dist/assets/zh-TW-CzEUk38j.js +0 -15
- 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
|
@@ -0,0 +1,930 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-DeKMvZlL.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-CPKeOpUo.js","assets/index-DVwMarHI.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-BPAANqvH.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-B68h5S5B.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-DdV8vhHn.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/contextPanelEmbeddedChat-BdA6bdky.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Bg4AEeCr.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-Csk4iNUi.js","assets/runtimeEndpointReset-Bg5gx18H.js","assets/VirtualizedFileDiff-C8i9HpTB.js","assets/web-components-z7hfnS8n.js","assets/computeVirtualFileMetrics-BBI7ZwrC.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isDiffPlainText-B_x_rVon.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-DjC8nTk9.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-BiWz4AVb.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/useRootScrollLock-BS4-kr7P.js","assets/scheduledTasksApi-BW0Etzwz.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-DXjVsEOw.js","assets/useGitComparison-DH220WmO.js","assets/FilesView-CJdG0-wk.js","assets/shikiHighlight-CRl0SUC9.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-D_hpXBnF.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-DW_xMer1.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-B1Gizi3a.js","assets/GitView-BXsS3jG6.js","assets/DirtyBranchSwitchDialog-aig6zJjg.js","assets/LinearIssuesView-BoUiLQG1.js","assets/PlanView-CJTmOF6I.js","assets/SettingsWindow-Cpb4hM6q.js","assets/SettingsView-DD-JqIJx.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/OnboardingScreen-DIp84OWt.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as tt,R as c,j as s,r as ht,h as Lf}from"./vendor-react-BUCujlKS.js";import{D as xn,E as $o,F as $f,G as rd,h as ds,v as Wo,u as De,H as Mt,I as Ua,J as Wf,K as Dn,L as zf,N as yt,O as Gs,P as zo,Q as od,R as Vf,S as Uf,T as Kf,U as Hf,V as id,z as fa,n as ts,W as En,X as Lr,e as Nn,Y as Gf,a as ps,Z as qf,_ as Qf,$ as Yf,a0 as ad,t as mn,A as qs,a1 as Xf,a2 as Jf,a3 as Ka,a4 as Zf,a5 as ld,a6 as em,a7 as cd,f as tm,a8 as sm,a9 as rr,aa as ma,d as No,q as Tr,o as ls,ab as dd,ac as nm,ad as wi,ae as rm,af as om,i as im,ag as fo,ah as mo,ai as am,aj as Ha,ak as lm,al as cm,am as dm,an as um,ao as Ga,ap as qa,aq as Qa,ar as Ya,as as fm,y as Xa,at as mm,au as hm,av as pm,B as gm,C as xm}from"./index-DVwMarHI.js";import{_ as _n}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as At,h as Pe,b9 as Ut,I as E,g as pn,t as Me,ap as Qs,ba as Os,ar as Ys,ao as Xs,N as Zn,W as wn,ac as br,bb as Bn,o as Vo,bc as Ja,bd as bm,be as ym,a7 as Dt,a8 as Pt,a9 as It,b as Kt,y as Je,G as wm,bf as ud,bg as Jr,u as Ps,A as ha,C as fd,bh as Si,bi as Sm,bj as md,bk as hd,r as $s,bl as pd,bm as pa,bn as Uo,bo as gd,bp as xd,bq as vm,br as Za,bs as jm,bt as km,bu as ga,bv as vi,bw as Cm,bx as Nm,L as bd,by as Am,l as Gt,bz as Dm,n as ir,bA as yd,p as Pm,bB as wd,bC as Im,bD as Tm,bE as Rm,bF as Sd,bG as vd,bH as Em,aD as xa,bI as qn,bJ as qr,bK as Mm,bL as ws,bM as Ss,bN as Ws,bO as Is,bP as Ts,bQ as bn,B as pt,bR as ln,ax as Hs,bS as Om,bT as Fm,aB as An,bU as ho,bV as Ks,bW as Ko,bX as jd,bY as ji,bZ as _m,b_ as Fs,b$ as _s,c0 as Cs,c1 as Bs,c2 as ss,T as Cn,c3 as ar,c4 as el,c5 as dr,M as Ho,ad as Bm,ae as ba,af as kd,ag as Cd,ai as On,c6 as Go,a2 as ya,c7 as Lm,c8 as $m,av as Wm,c9 as zm,ca as Vm,cb as Um,aw as wa,cc as Sa,cd as ur,ce as Nd,cf as Km,cg as Hm,ch as Qr,ci as Gm,cj as Yr,ck as qm,cl as or,O as Ad,cm as Qm,cn as Ym,co as Ln,cp as Xm,cq as Jm,cr as ei,cs as Dd,ct as Pd,cu as Zm,aC as ki,cv as Ci,cw as eh,cx as tl,cy as Rr,c as $r,d as va,_ as th,cz as Id,cA as vr,cB as Er,cC as sh,cD as nh,cE as rh,X as Td,ay as oh,cF as ih,cG as ah,cH as lh,cI as ch,cJ as Rd,cK as gn,cL as dh,cM as Ed,cN as uh,cO as Ni,cP as fh,cQ as mh,cR as Md,cS as hh,cT as Od,a0 as Ao,cU as Ai,R as ja,Q as ka,S as Ca,cV as Na,a as Aa,$ as ph,cW as sl,cX as Di,cY as Fd,cZ as gh,aq as _d,c_ as xh,P as Pi,H as bh,c$ as nl,d0 as yh,d1 as rl,d2 as wh,d3 as cs,d4 as Sh,d5 as Fn,d6 as Da,d7 as Bd,d8 as vh,d9 as Ld,da as $d,db as jh,D as kh,dc as Ch,dd as Nh,de as Ah,df as ol,dg as Dh,dh as Ph,di as Wd,E as Ih,dj as po,dk as zd,dl as Th,dm as Rh,dn as Eh,dp as Mh,e as Vd,dq as Pa,dr as Oh,ds as Wr,dt as Fh,du as il,dv as _h,dw as Bh,Z as Lh,dx as $h,aP as Ii,a3 as al,aU as ll,a4 as cl,dy as Wh,J as zh,K as ti,dz as Vh,dA as Uh,dB as Ud,dC as Kd,dD as Hd,dE as Kh,F as Ia,dF as Hh,a1 as Gh,dG as qh,dH as Qh,dI as Yh,dJ as Xh,dK as Jh,dL as Zh,dM as ep,dN as tp,dO as Do,ah as sp,dP as np,dQ as dl,dR as rp,dS as op,dT as ip,dU as ap,dV as Po,dW as lp,dX as ul,dY as cp,dZ as dp,d_ as up,d$ as fp,e0 as mp,e1 as hp,e2 as go,e3 as pp,i as gp,e4 as xp,e5 as bp,e6 as yp,e7 as wp,a5 as Sp,e8 as vp,e9 as jp,ea as kp,eb as Cp,ec as fl,ed as Np,aJ as Ap,aK as Dp,aL as Pp,aN as ml,aO as hl,aR as pl,aS as gl,aQ as Gd,aT as qd,ee as Ip,b4 as Tp,b5 as Rp,b6 as Ep,b7 as Mp,b8 as Op,a_ as Fp,b0 as _p,b1 as Bp,b2 as Lp,b3 as $p}from"./useAppFontEffects-CPKeOpUo.js";import{u as Qd,S as xl,C as Wp,W as Yd,f as zp,a as Vp}from"./useRootScrollLock-BS4-kr7P.js";import{l as bl,n as si,t as dn,o as Ti,m as yl,q as Up,v as Kp,w as Hp,x as Gp,y as qp,z as Qp,A as Yp,E as Xp,U as Xd,F as Ri,G as Ei,e as Jd,H as Zd,I as Jp,d as Zp,c as eg,J as eu,K as Mi,L as Un,M as tu,Q as su,P as tg,T as sg,R as ng,V as rg,W as og,X as ig,S as wl,Y as ag,Z as lg,_ as cg,u as Or,s as dg,N as ug,D as fg,$ as mg,a0 as Sl,a1 as hg,i as pg,g as gg,j as nu,k as xg,a2 as bg,a3 as yg,a4 as wg,f as Sg,h as vg,O as ru,C as jg}from"./runtimeEndpointReset-Bg5gx18H.js";import{u as Wn,O as vl,D as kg,n as Cg,f as Ng,a as jl,s as Ag,d as Dg,b as Pg,r as Ig}from"./scheduledTasksApi-BW0Etzwz.js";import{f as zr,h as Mn,T as ou,M as iu,D as Vr,j as Ur,d as Tg,P as Oi,b as Rg,k as Fi,i as Eg}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as qo,S as Io,h as Mg,a as au,v as _i,s as Og}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Qo}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as lu,M as cu,C as du,a as Bi,b as Li,c as $i,d as uu,e as Fg,f as _g}from"./vendor-base-ui-DdV8vhHn.js";import{c as er,u as Jn,d as fu,p as Bg}from"./vendor-zustand-BAGL70zf.js";import{g as Lg,a as $g,E as mu,b as Wg,c as zg,d as Vg,e as Ug,i as Kg}from"./contextPanelEmbeddedChat-BdA6bdky.js";import{c as Ta,s as xr,r as hu}from"./vendor-zod-BPAANqvH.js";import{u as Hg}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{d as pu}from"./vendor-cron-parser-CUcP7OfX.js";const Gg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",qg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",ni=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__AIWORKER_PLATFORM__==="darwin"?Gg:t.id==="terminal"?qg:void 0}),kl=t=>{const e=tt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const u=a,d=r||i;if(d&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let g;return e[3]!==d?(g=s.jsx("img",{src:d,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=d,e[4]=g):g=e[4],g}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Pe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let m;return e[6]!==u?(m=s.jsx("span",{className:h,children:u}),e[6]=u,e[7]=m):m=e[7],m},Qg=t=>{const e=tt.c(75),{directory:n,className:r}=t,{t:i}=At(),o=Wn(Yg),l=Wn(Xg),a=Wn(Jg),u=Wn(Zg),d=Wn(ex),h=Wn(tx),m=Wn(sx);let p,g;e[0]!==d?(p=()=>{d()},g=[d],e[0]=d,e[1]=p,e[2]=g):(p=e[1],g=e[2]),c.useEffect(p,g);const w=xn()&&$o();let v;e:{let B;e[3]!==l||e[4]!==o?(B=l.find(ce=>ce.id===o)??l.find(nx)??l[0]??vl[0],e[3]=l,e[4]=o,e[5]=B):B=e[5];const ne=B;if(ne){let ce;e[6]!==ne?(ce=ni(ne),e[6]=ne,e[7]=ce):ce=e[7],v=ce;break e}let ye;e[8]===Symbol.for("react.memo_cache_sentinel")?(ye=ni(vl[0]),e[8]=ye):ye=e[8],v=ye}const x=v;if(!w||!n||l.length===0)return null;let f;e[9]!==n?(f=async B=>{await $f(n,B.id,B.appName)||await rd(n,B.appName)},e[9]=n,e[10]=f):f=e[10];const b=f;let y;e[11]!==b||e[12]!==m?(y=async B=>{await m(B.id),await b(B)},e[11]=b,e[12]=m,e[13]=y):y=e[13];const S=y;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await pn(n)).ok&&Me.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const C=N;let j;e[17]!==r?(j=Pe("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=j):j=e[18];let A;e[19]!==b||e[20]!==x?(A=()=>{b(x)},e[19]=b,e[20]=x,e[21]=A):A=e[21];const P=u&&"animate-pulse";let I;e[22]!==P?(I=Pe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",P),e[22]=P,e[23]=I):I=e[23];let M;e[24]!==x.label||e[25]!==i?(M=i("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=i,e[26]=M):M=e[26];let z;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?(z=s.jsx(kl,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=z):z=e[30];let R;e[31]!==I||e[32]!==M||e[33]!==z||e[34]!==A?(R=s.jsx("button",{type:"button",onClick:A,className:I,"aria-label":M,children:z}),e[31]=I,e[32]=M,e[33]=z,e[34]=A,e[35]=R):R=e[35];let H;e[36]===Symbol.for("react.memo_cache_sentinel")?(H=Pe("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=H):H=e[36];let F;e[37]!==i?(F=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=F):F=e[38];let O;e[39]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=O):O=e[39];let T;e[40]!==F?(T=s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:H,"aria-label":F,children:O})}),e[40]=F,e[41]=T):T=e[41];let k;e[42]!==C?(k=()=>{C()},e[42]=C,e[43]=k):k=e[43];let D;e[44]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(E,{name:"file-copy",className:"h-4 w-4"}),e[44]=D):D=e[44];let L;e[45]!==i?(L=i("openInApp.actions.copyPath"),e[45]=i,e[46]=L):L=e[46];let Q;e[47]!==L?(Q=s.jsx("span",{className:"typography-ui-label text-foreground",children:L}),e[47]=L,e[48]=Q):Q=e[48];let q;e[49]!==k||e[50]!==Q?(q=s.jsxs(Ut,{className:"flex items-center gap-2",onClick:k,children:[D,Q]}),e[49]=k,e[50]=Q,e[51]=q):q=e[51];let te;e[52]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(Os,{}),e[52]=te):te=e[52];let ae;if(e[53]!==l||e[54]!==S||e[55]!==x.id){let B;e[57]!==S||e[58]!==x.id?(B=ne=>{const ye=ni(ne);return s.jsxs(Ut,{className:"flex items-center gap-2",onClick:()=>{S(ne)},children:[s.jsx(kl,{label:ne.label,iconDataUrl:ne.iconDataUrl,fallbackIconDataUrl:ye.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:ne.label}),x.id===ne.id?s.jsx(E,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},ne.id)},e[57]=S,e[58]=x.id,e[59]=B):B=e[59],ae=l.map(B),e[53]=l,e[54]=S,e[55]=x.id,e[56]=ae}else ae=e[56];let X;e[60]!==a||e[61]!==h||e[62]!==i?(X=a?s.jsxs(Ut,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(E,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=i,e[63]=X):X=e[63];let Z;e[64]!==q||e[65]!==ae||e[66]!==X?(Z=s.jsxs(Ys,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[q,te,ae,X]}),e[64]=q,e[65]=ae,e[66]=X,e[67]=Z):Z=e[67];let se;e[68]!==T||e[69]!==Z?(se=s.jsxs(Xs,{children:[T,Z]}),e[68]=T,e[69]=Z,e[70]=se):se=e[70];let fe;return e[71]!==R||e[72]!==se||e[73]!==j?(fe=s.jsxs("div",{className:j,children:[R,se]}),e[71]=R,e[72]=se,e[73]=j,e[74]=fe):fe=e[74],fe};function Yg(t){return t.selectedAppId}function Xg(t){return t.availableApps}function Jg(t){return t.isCacheStale}function Zg(t){return t.isScanning}function ex(t){return t.initialize}function tx(t){return t.loadInstalledApps}function sx(t){return t.selectApp}function nx(t){return t.id===kg}const To=new Map,Wi=new Set,gu=()=>{for(const t of Wi)t()},ri=(t,e)=>{const n=t.trim();n&&(e.length===0?To.delete(n):To.set(n,[...e]),gu())},rx=t=>{To.delete(t.trim())&&gu()},xu=[],ox=t=>To.get(t.trim())??xu,ix=t=>(Wi.add(t),()=>{Wi.delete(t)}),ax=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=()=>ox(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(ix,n,lx)};function lx(){return xu}const cx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],dx=["dev","start","preview","serve"];async function ux(t,e,n){if(!t)return null;const r=hx(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=px(n);if(i){const o=await gx(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await fx(t)){const i=await mx(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function fx(t){const e=`${t}/index.html`,n=await Ro(e,t);return typeof n=="string"&&n.trim().length>0}async function mx(){try{const t=await ds("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function hx(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(dx.some(i=>n.includes(i)))return e}return null}function px(t){for(const{pattern:e}of cx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function gx(t){const e=await Ro(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await Ro(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ro(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ds(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Wo()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ds(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function xx(t){try{const e=await Ro(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const fn="__aiworker_auto_discover_preview__",bx=15e3,yx=3e3,oi=t=>t.id===fn?"scan-2":Xp.find(n=>n.key===t.icon)?.Icon??"play",wx=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Sx=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=At(),{currentTheme:l}=Zn(),{terminal:a,runtime:u}=wn(),d=br(),{isMobile:h}=Bn(),m=c.useMemo(()=>xn(),[]),p=bl(ie=>ie.instances),g=bl(ie=>ie.load),w=De(ie=>ie.terminalShell),v=De(ie=>ie.terminalLoginShells.includes(ie.terminalShell)),x=De(ie=>ie.setSettingsPage),f=De(ie=>ie.setSettingsDialogOpen),b=De(ie=>ie.setSettingsProjectsSelectedId),y=De(ie=>ie.openContextPreview),S=Mt(ie=>ie.ensureDirectory),N=Mt(ie=>ie.reconcileServerSessions),C=Mt(ie=>ie.setTabLabel),j=Mt(ie=>ie.setTabIconKey),A=Mt(ie=>ie.setActiveTab),P=Mt(ie=>ie.setConnecting),I=Mt(ie=>ie.setTabSessionId),M=Mt(ie=>ie.setTabPurpose),z=Mt(ie=>ie.allocateActionExecution),R=Mt(ie=>ie.setTabLifecycle),H=Mt(ie=>ie.setTabPreviewUrl),F=Mt(ie=>ie.matchesActionExecution),O=Mt(ie=>ie.captureStartedActionMutationRevisions),[T,k]=c.useState([]),D=c.useRef(null),[L,Q]=c.useState(null),[q,te]=c.useState(!1),ae=c.useRef({}),X=c.useRef({}),Z=c.useRef({}),se=c.useRef(new Set),fe=c.useRef(0),[B,ne]=c.useState({}),ye=t?.id??null,ce=t?.path??"",_=c.useMemo(()=>ye?{id:ye,path:ce}:null,[ye,ce]);c.useEffect(()=>{m&&g().catch(()=>{})},[m,g]);const re=c.useCallback(async ie=>{await Vo(ie)},[]),me=c.useCallback(async()=>{if(!_)return;const ie=fe.current+1;fe.current=ie,te(!0);try{const pe=await Ja(_);if(fe.current!==ie)return;D.current=pe;const Ve=pe.projectActions;k(Ve),Q(ze=>ze===fn||ze&&Ve.some(He=>He.id===ze)?ze:null)}catch{if(fe.current!==ie)return}finally{fe.current===ie&&te(!1)}},[_]),de=c.useMemo(()=>si(e||_?.path||""),[e,_?.path]),ge=c.useMemo(()=>si(_?.path||""),[_?.path]),Te=c.useMemo(()=>si(d||"")||de,[d,de]),be=c.useRef(Te);c.useEffect(()=>{be.current=Te},[Te]);const Re=Mt(ie=>de?ie.getDirectoryState(de):void 0),we=Mt(ie=>ge&&ge!==de?ie.getDirectoryState(ge):void 0),Y=c.useMemo(()=>{const ie=de?[{directory:de,state:Re}]:[];return ge&&ge!==de&&ie.push({directory:ge,state:we}),ie},[Re,de,ge,we]),ve=c.useMemo(()=>{const ie=de?[de]:[];return ge&&ge!==de&&ie.push(ge),ie},[de,ge]),xe=c.useCallback(ie=>ie.id!==fn&&ie.runIn==="parent"&&ge||de,[de,ge]),je=c.useCallback((ie,pe,Ve)=>`${ie}::${pe}::${Ve}`,[]),oe=c.useCallback((ie,pe,Ve=Mt.getState())=>ie?Ve.getDirectoryState(ie)?.tabs.find(ze=>ze.purpose.type==="project-action"&&ze.purpose.actionId===pe)??null:null,[]),J=c.useMemo(()=>{const ie={};for(const{directory:pe,state:Ve}of Y)for(const ze of Ve?.tabs??[]){if(ze.purpose.type!=="project-action"||!ze.purpose.executionId||!ze.terminalSessionId||ze.lifecycle==="idle"||ze.lifecycle==="exited")continue;const He=dn(pe,ze.purpose.actionId),ot=je(pe,ze.purpose.actionId,ze.purpose.executionId);ie[He]={directory:pe,actionId:ze.purpose.actionId,tabId:ze.id,sessionId:ze.terminalSessionId,executionId:ze.purpose.executionId,status:ze.lifecycle==="stopping"?"stopping":B[ot]?"waiting-for-preview":"running"}}return ie},[je,B,Y]),K=c.useCallback((ie,pe,Ve)=>{const ze=dn(ie,pe),He=je(ie,pe,Ve),at=ae.current[ze]?.executionId===Ve,et=globalThis.window,Xe=dt=>{et?.clearTimeout(Z.current[dt]),delete Z.current[dt]};at&&(delete ae.current[ze],Xe(ze)),X.current[He]?.(),delete X.current[He],Xe(He),ne(dt=>{if(!dt[He])return dt;const Fe={...dt};return delete Fe[He],Fe})},[je]),$=c.useCallback(ie=>{X.current[ie]?.(),delete X.current[ie]},[]),le=c.useCallback(ie=>{window.clearTimeout(Z.current[ie]),delete Z.current[ie]},[]);c.useEffect(()=>{const ie=X.current,pe=Z.current;return()=>{for(const Ve of Object.keys(ie))$(Ve);for(const Ve of Object.keys(pe))le(Ve)}},[le,$]),c.useEffect(()=>{const ie=new Set(ve);for(const pe of Object.values(ae.current))ie.has(pe.directory)||K(pe.directory,pe.actionId,pe.executionId);for(const pe of Object.keys(X.current)){const Ve=pe.split("::",1)[0]??"";ie.has(Ve)||$(pe)}},[K,$,ve]);const V=c.useCallback((ie,pe)=>{De.getState().openContextPanelTab(ie,{mode:"terminal",targetDirectory:pe===ie?null:pe})},[]),Ce=c.useMemo(()=>L?T.find(ie=>ie.id===L)??null:null,[T,L]),Be=c.useMemo(()=>({id:fn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),ke=!h,Ne=c.useMemo(()=>ke?[Be,...T]:T,[T,Be,ke]);c.useEffect(()=>{me()},[me]),c.useEffect(()=>{const ie=ve.map(pe=>Ti(a,pe,O,Ve=>N(pe,Ve.sessions,{startedActionMutationRevisions:Ve.startedActionMutationRevisions})));return()=>{for(const pe of ie)pe()}},[O,N,a,ve]),c.useEffect(()=>{for(const{directory:ie,state:pe}of Y)if(ie)for(const Ve of pe?.tabs??[]){if(Ve.purpose.type!=="project-action")continue;const ze=Ve.purpose.actionId,He=Ne.find(et=>et.id===ze),ot=He?.name??ze,at=He?.icon||"play";Ve.label!==ot&&C(ie,Ve.id,ot),Ve.iconKey!==at&&j(ie,Ve.id,at)}},[Ne,j,C,Y]),c.useEffect(()=>{const ie=globalThis.window;if(!ie)return;const pe=Ve=>{const ze=Ve.detail;ye&&(ze?.projectId&&ze.projectId!==ye||me())};return ie.addEventListener(yl,pe),()=>{ie.removeEventListener(yl,pe)}},[me,ye]),c.useEffect(()=>{L&&(L===fn&&ke||T.some(ie=>ie.id===L)||Q(null))},[T,ke,L]),c.useEffect(()=>{const ie=Ve=>{delete Z.current[Ve];const ze=ae.current[Ve];if(!ze||ze.openedUrl)return;const He=je(ze.directory,ze.actionId,ze.executionId),ot=ze.announced;if(ot.length!==0){if(window.clearTimeout(Z.current[He]),delete Z.current[He],ze.openedUrl=!0,ne(at=>{if(!at[He])return at;const et={...at};return delete et[He],et}),ot.length===1){ri(ze.directory,[]),H(ze.directory,ze.tabId,ot[0],{locked:!1,autoOpened:!0}),y(ze.directory,ot[0]);return}ze.offering=!0,ri(ze.directory,ot),De.getState().openContextSurface(ze.directory,"browser"),Me.info(o("projectActions.toast.multipleServers"))}},pe=()=>{const Ve=Mt.getState(),ze=Ve.sessions,He=J;for(const[ot,at]of Object.entries(He)){const Xe=ze.get(at.directory)?.tabs.find(xt=>xt.id===at.tabId);if(!Xe||Xe.terminalSessionId!==at.sessionId){K(at.directory,at.actionId,at.executionId);continue}const dt=ae.current[ot],Fe=dt?.executionId===at.executionId?dt:{hostDirectory:be.current||at.directory,directory:at.directory,tabId:at.tabId,actionId:at.actionId,executionId:at.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ae.current[ot]=Fe;const Se=Ne.find(xt=>xt.id===at.actionId),St=Ve.getBuffer(at.directory,at.tabId).chunks;if(!Se||St.length===0)continue;const vt=St.filter(xt=>Fe.lastSeenChunkId===null||xt.id>Fe.lastSeenChunkId);if(vt.length===0)continue;const Rt=vt.map(xt=>xt.data).join(""),Ze=`${Fe.tail}${Rt}`;if(Fe.openInPreview&&(!Fe.openedUrl||Fe.offering)){const xt=Qp(Ze),Et=Fe.announced.length;for(const Tt of xt)Fe.announced.includes(Tt)||Fe.announced.push(Tt);const kt=Fe.announced.length-Et;Fe.offering&&kt>0?ri(at.directory,Fe.announced):!Fe.openedUrl&&Et===0&&Fe.announced.length>0&&(window.clearTimeout(Z.current[ot]),Z.current[ot]=window.setTimeout(()=>ie(ot),yx))}const it=!Fe.openedUrl&&Se.autoOpenUrl===!0&&!Fe.openInPreview?Yp(Ze):null,gt=vt[vt.length-1]?.id??Fe.lastSeenChunkId;if(Fe.lastSeenChunkId=gt,Fe.tail=Ze.slice(-512),it)if(Fe.openedUrl=!0,Fe.openInPreview){const xt=He[ot];xt&&(H(xt.directory,xt.tabId,it,{locked:!1,autoOpened:!1,expectedExecutionId:xt.executionId}),xt.status==="waiting-for-preview"&&ne(Et=>{const kt=je(xt.directory,xt.actionId,xt.executionId);if(!Et[kt])return Et;const Tt={...Et};return delete Tt[kt],Tt}),window.clearTimeout(Z.current[ot]),delete Z.current[ot],y(xt.directory,it))}else re(it),Me.success(o("projectActions.toast.openedUrlFromOutput"));ae.current[ot]=Fe}for(const ot of Object.keys(ae.current))if(!He[ot]){const at=ae.current[ot],et=at?ze.get(at.directory)?.tabs.find(dt=>dt.id===at.tabId):void 0;if(et?.purpose.type==="project-action"&&et.purpose.executionId===at?.executionId&&!!et.terminalSessionId&&et.lifecycle!=="idle"&&et.lifecycle!=="exited")continue;delete ae.current[ot],window.clearTimeout(Z.current[ot]),delete Z.current[ot]}};return pe(),Mt.subscribe((Ve,ze)=>{(Ve.sessions!==ze.sessions||Ve.buffers!==ze.buffers)&&pe()})},[K,be,Ne,je,y,re,J,H,o]),c.useEffect(()=>{for(const{directory:ie,state:pe}of Y)for(const Ve of pe?.tabs??[]){if(Ve.purpose.type!=="project-action"||!Ve.purpose.executionId||!Ve.terminalSessionId||Ve.lifecycle!=="running")continue;const ze=Ve.purpose.actionId,He=Ve.purpose.executionId,ot=je(ie,ze,He);if(X.current[ot])continue;const at=a.connect(Ve.terminalSessionId,{onEvent:et=>{if(!F(ie,Ve.id,He))return;et.type==="snapshot"&&(Mt.getState().replaceBuffer(ie,Ve.id,et.data??"",et.sequence??0,Ua(et)),et.status==="running"&&Mt.getState().setTabLifecycle(ie,Ve.id,"running",{expectedExecutionId:He}),et.status==="exited"&&(Mt.getState().setTabLifecycle(ie,Ve.id,"exited",{expectedExecutionId:He}),Mt.getState().setTabPurpose(ie,Ve.id,{type:"project-action",actionId:ze,executionId:null}),K(ie,ze,He)));const Xe=et.type==="data"?et.data??"":"";Xe&&Mt.getState().appendToBuffer(ie,Ve.id,Xe,et.sequence,et.replayData),et.type==="exit"&&(Mt.getState().setTabLifecycle(ie,Ve.id,"exited",{expectedExecutionId:He}),Mt.getState().setTabPurpose(ie,Ve.id,{type:"project-action",actionId:ze,executionId:null}),K(ie,ze,He))},onError:(et,Xe)=>{!Xe||!F(ie,Ve.id,He)||(Mt.getState().setTabLifecycle(ie,Ve.id,"exited",{expectedExecutionId:He}),Mt.getState().setTabSessionId(ie,Ve.id,null,{expectedExecutionId:He}),Mt.getState().setTabPurpose(ie,Ve.id,{type:"project-action",actionId:ze,executionId:null}),K(ie,ze,He))}});X.current[ot]=at.close}},[K,je,F,a,Y]);const Qe=c.useCallback(async ie=>{const pe=xe(ie);if(!pe)throw new Error(o("projectActions.error.noActiveDirectory"));const Ve=dn(pe,ie.id);S(pe);const ze=Mt.getState(),He=oe(pe,ie.id,ze),ot=He?.id??ze.createTab(pe);C(pe,ot,ie.name),j(pe,ot,ie.icon||"play"),He||M(pe,ot,{type:"project-action",actionId:ie.id,executionId:null}),A(pe,ot);const et=Mt.getState().getDirectoryState(pe)?.tabs.find(Xe=>Xe.id===ot);return{executionDirectory:pe,key:Ve,tabId:ot,sessionId:et?.terminalSessionId??null,executionId:et?.purpose.type==="project-action"?et.purpose.executionId:null}},[S,xe,oe,A,j,C,M,o]),We=c.useCallback(async ie=>{if(u.isVSCode||!i&&h)return;if(!de){Me.error(o("projectActions.error.noActiveDirectoryForAction"));return}const pe=dn(xe(ie),ie.id),Ve=J[pe];if(Ve&&Ve.status==="running"||se.current.has(pe))return;se.current.add(pe);let ze=null;try{const He=ie.id===fn?await(async()=>{const[kt,Tt]=await Promise.all([bm({id:_?.id??"",path:de}),xx(de)]),Ot=await ux(de,kt.actions,Tt);if(!Ot)throw new Error(o("contextPanel.preview.noDevServer"));return{id:fn,name:o("projectActions.actions.autoDiscover"),command:Ot.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Ot.previewUrlHint||""}})():ie,ot=He.autoOpenUrl===!0&&(He.openUrl||"").trim().length>0,at=!ot&&ie.id!==fn,et=be.current||de,{executionDirectory:Xe,key:dt,tabId:Fe}=await Qe(He),Se=Up(He.command);if(!Se)throw new Error(o("projectActions.error.failedToRunAction"));const St=He.autoOpenUrl===!0&&m&&(He.desktopOpenSshForward||"").trim().length>0,vt=He.autoOpenUrl?wx(He.openUrl):null,Rt=He.autoOpenUrl&&m?Kp(He.desktopOpenSshForward,p):null;if(a.listSessions){const kt=oe(Xe,He.id);if(kt?.purpose.type==="project-action"&&kt.purpose.executionId===null){const Tt=await Hp(a,Xe,{captureStartedActionMutationRevisions:O});Tt&&N(Xe,Tt.sessions,{startedActionMutationRevisions:Tt.startedActionMutationRevisions})}}const Ze=oe(Xe,He.id);let it,gt;if(Ze?.lifecycle==="running"&&Ze.terminalSessionId&&Ze.purpose.type==="project-action"&&Ze.purpose.executionId)it=Ze.terminalSessionId,gt=Ze.purpose.executionId;else{const kt=Ze?.purpose.type==="project-action"?Ze.purpose.executionId:null;kt&&K(Xe,He.id,kt);const Tt=z(Xe,Fe,He.id);if(!Tt)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));ze={directory:Xe,tabId:Fe,id:Tt},P(Xe,Fe,!0,{expectedExecutionId:Tt});const Ot=await Gp({terminal:a,createOptions:{cwd:Xe,shell:w,loginShell:v,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Se,isRunStillExpected:()=>F(Xe,Fe,Tt),purpose:{type:"project-action",actionId:He.id,executionId:Tt}});if(!F(Xe,Fe,Tt)){Ot.sessionId===Tt&&await a.close(Ot.sessionId).catch(()=>{});return}gt=Ot.purpose?.type==="project-action"?Ot.purpose.executionId:Tt,it=Ot.sessionId,M(Xe,Fe,{type:"project-action",actionId:He.id,executionId:gt}),I(Xe,Fe,it,{expectedExecutionId:gt}),P(Xe,Fe,!1,{expectedExecutionId:gt})}at&&et&&V(et,Xe),ae.current[dt]={hostDirectory:et,directory:Xe,tabId:Fe,actionId:He.id,executionId:gt,lastSeenChunkId:null,openedUrl:!!Rt||!!vt||ot,tail:"",openInPreview:He.id===fn,announced:[],offering:!1};const xt=je(Xe,He.id,gt);P(Xe,Fe,!0,{expectedExecutionId:gt});const Et=a.connect(it,{onEvent:kt=>{if(!F(Xe,Fe,gt)||kt.purpose?.type==="project-action"&&kt.purpose.executionId!==gt)return;kt.type==="snapshot"&&(Mt.getState().replaceBuffer(Xe,Fe,kt.data??"",kt.sequence??0,Ua(kt)),Mt.getState().setConnecting(Xe,Fe,!1,{expectedExecutionId:gt}),kt.purpose?.type==="project-action"&&Mt.getState().setTabPurpose(Xe,Fe,{type:"project-action",actionId:kt.purpose.actionId,executionId:kt.purpose.executionId}),kt.status==="running"&&Mt.getState().setTabLifecycle(Xe,Fe,"running",{expectedExecutionId:gt}),kt.status==="exited"&&(Mt.getState().setTabLifecycle(Xe,Fe,"exited",{expectedExecutionId:gt}),Mt.getState().setTabPurpose(Xe,Fe,{type:"project-action",actionId:He.id,executionId:null}),K(Xe,He.id,gt)));const Tt=kt.type==="data"?kt.data??"":"";Tt&&Mt.getState().appendToBuffer(Xe,Fe,Tt,kt.sequence,kt.replayData),kt.type==="exit"&&(Mt.getState().setTabLifecycle(Xe,Fe,"exited",{expectedExecutionId:gt}),Mt.getState().setConnecting(Xe,Fe,!1,{expectedExecutionId:gt}),Mt.getState().setTabPurpose(Xe,Fe,{type:"project-action",actionId:He.id,executionId:null}),K(Xe,He.id,gt))},onError:(kt,Tt)=>{F(Xe,Fe,gt)&&(Mt.getState().setConnecting(Xe,Fe,!1,{expectedExecutionId:gt}),Tt&&(Mt.getState().setTabLifecycle(Xe,Fe,"exited",{expectedExecutionId:gt}),Mt.getState().setTabSessionId(Xe,Fe,null,{expectedExecutionId:gt}),Mt.getState().setTabPurpose(Xe,Fe,{type:"project-action",actionId:He.id,executionId:null}),K(Xe,He.id,gt)))}});if(!F(Xe,Fe,gt)){Et.close();return}X.current[xt]?.(),X.current[xt]=Et.close,window.clearTimeout(Z.current[xt]),delete Z.current[xt],He.id===fn&&!vt&&(ne(kt=>({...kt,[xt]:!0})),Z.current[xt]=window.setTimeout(()=>{delete Z.current[xt];const kt=ae.current[dt];!kt||kt.executionId!==gt||kt.openedUrl||kt.offering||F(Xe,Fe,gt)&&(ne(Tt=>{if(!Tt[xt])return Tt;const Ot={...Tt};return delete Ot[xt],Ot}),Mt.getState().setActiveTab(Xe,Fe),V(kt.hostDirectory,Xe))},bx)),Rt?(H(Xe,Fe,null,{locked:!0,expectedExecutionId:gt}),re(Rt),Me.success(o("projectActions.toast.openedForwardedUrl"))):vt?(H(Xe,Fe,vt,{locked:!0,autoOpened:!0,expectedExecutionId:gt}),y(et,vt),Me.success(o("projectActions.toast.openedActionUrl"))):ot?(H(Xe,Fe,null,{locked:!0,expectedExecutionId:gt}),Me.error(o("projectActions.error.invalidCustomUrlFormat"))):St?(H(Xe,Fe,null,{locked:!0,expectedExecutionId:gt}),Me.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):H(Xe,Fe,null,{locked:!1,autoOpened:!1,expectedExecutionId:gt})}catch(He){if(ze&&F(ze.directory,ze.tabId,ze.id)){const{directory:ot,tabId:at,id:et}=ze;K(ot,ie.id,et),R(ot,at,"exited",{expectedExecutionId:et}),M(ot,at,{type:"project-action",actionId:ie.id,executionId:null})}if(He instanceof Error&&He.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(He instanceof Error&&(He.message==="COMMAND_MODE_UNSUPPORTED"||He.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Me.error(o("projectActions.error.failedToCreateTerminalSession"));return}Me.error(He instanceof Error?He.message:o("projectActions.error.failedToRunAction"))}finally{se.current.delete(pe)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,be,p,Qe,i,h,m,de,v,w,re,y,J,V,u.isVSCode,xe,F,K,je,oe,N,z,O,P,R,M,H,I,_?.id,o,a]),U=c.useCallback(async ie=>{const pe=dn(xe(ie),ie.id),Ve=J[pe];Ve&&await qp({terminal:a,sessionId:Ve.sessionId,isExecutionStillCurrent:()=>F(Ve.directory,Ve.tabId,Ve.executionId),markStopping:()=>{R(Ve.directory,Ve.tabId,"stopping",{expectedExecutionId:Ve.executionId})},restoreRunning:()=>{R(Ve.directory,Ve.tabId,"running",{expectedExecutionId:Ve.executionId})},clearSession:()=>{I(Ve.directory,Ve.tabId,null,{expectedExecutionId:Ve.executionId})},finalizeExit:()=>{R(Ve.directory,Ve.tabId,"exited",{expectedExecutionId:Ve.executionId}),M(Ve.directory,Ve.tabId,{type:"project-action",actionId:Ve.actionId,executionId:null}),K(Ve.directory,Ve.actionId,Ve.executionId)}})},[K,xe,F,J,R,M,I,a]),he=c.useCallback(()=>{const ie=Ce??Ne[0];if(!ie)return;const pe=dn(xe(ie),ie.id),Ve=J[pe];if(Ve?.status!=="stopping"){if(Ve){U(ie);return}We(ie)}},[Ne,xe,We,J,Ce,U]),Ee=c.useCallback(async ie=>{if(ie.source==="shared"&&_){const pe=D.current?.trust.trusted?D.current:await Ja(_);if(D.current=pe,!await ym(_,pe))return;D.current={...pe,trust:{...pe.trust,trusted:!0}}}await We(ie)},[We,_]),Ie=c.useCallback((ie,pe=!1)=>{if(Q(ie.id),!pe){Ee(ie);return}const Ve=dn(xe(ie),ie.id),ze=J[Ve];if(ze?.status!=="stopping"){if(ze){U(ie);return}Ee(ie)}},[xe,Ee,J,U]),rt=c.useCallback(()=>{_?.id&&(b(_.id),x("projects"),f(!0))},[f,x,b,_?.id]),Ge=Ce??Ne[0]??null,ut=Ge?J[dn(xe(Ge),Ge.id)]:null,ct=Mt(ie=>ut?ie.getDirectoryState(ut.directory)?.tabs.find(pe=>pe.id===ut.tabId)?.previewUrl??null:null);if(u.isVSCode||!i&&h||!_||!de)return null;const ue=Ce??Ne[0]??null;if(!ue)return null;const G=oi(ue),Le=dn(xe(ue),ue.id),Oe=J[Le],qe=Oe?.status==="stopping",Ue=Oe?.status==="waiting-for-preview",st=!!(Oe&&ct),wt=()=>{!Oe||!ct||y(Oe.directory,ct)},Nt=ue.id===fn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:q||qe,className:Pe("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","disabled:cursor-not-allowed",n),onClick:he,"aria-label":Oe?o("projectActions.actions.stopNamedAria",{name:ue.name}):o("projectActions.actions.runNamedAria",{name:ue.name}),children:qe||Ue?s.jsx(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):Oe?s.jsx(E,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(E,{name:G,className:"h-5 w-5"})})}),Nt?s.jsx(It,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),st?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("projectActions.actions.openPreview"),onClick:wt,children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(It,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ys,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ut,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ne.map(ie=>{const pe=oi(ie),Ve=dn(xe(ie),ie.id),ze=J[Ve],He=!!ze,ot=ze?.status==="stopping";return s.jsxs(Ut,{className:"flex items-center gap-2",onClick:()=>{Ie(ie,!0)},children:[s.jsx(E,{name:pe,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ie.name}),ie.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,ot||ze?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):He?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},ie.id)})]})]})]}):s.jsxs("div",{className:Pe("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:he,disabled:q||qe,className:Pe("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed"),"aria-label":Oe?o("projectActions.actions.stopNamedAria",{name:ue.name}):o("projectActions.actions.runNamedAria",{name:ue.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:qe||Ue?s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):Oe?s.jsx(E,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(E,{name:G,className:"h-4 w-4"})})})}),Nt?s.jsx(It,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),st?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:wt,className:Pe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(It,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ys,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ut,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ne.map(ie=>{const pe=oi(ie),Ve=dn(xe(ie),ie.id),ze=J[Ve],He=!!ze,ot=ze?.status==="stopping";return s.jsxs(Ut,{className:"flex items-center gap-2",onClick:()=>{Ie(ie,!0)},children:[s.jsx(E,{name:pe,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ie.name}),ie.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,ot||ze?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):He?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},ie.id)})]})]})]})},Mr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},vx=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Mr(n??"");if(i){const o=ud(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function jx(){const t=Kt(w=>w.projects),e=Kt(w=>w.activeProjectId),n=Je(w=>w.availableWorktreesByProject),r=Je(w=>w.currentSessionId),i=wm(r??null),o=Je(w=>r?w.worktreeMetadata.get(r)?.path??"":""),l=Je(w=>w.newSessionDraft?.open?Mr(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Mr(o||""),[o]),u=c.useMemo(()=>{const w=typeof i?.directory=="string"?i.directory:"";return Mr(w||"")},[i?.directory]),d=a||u||l,h=c.useMemo(()=>vx({projects:t,worktreesByProject:n,directory:d,activeProjectId:e}),[e,d,t,n]),m=c.useMemo(()=>Mr(d||h?.path||""),[d,h?.path]),p=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),g=c.useRef(null);return c.useEffect(()=>{p&&m&&(g.current={projectRef:p,directory:m})},[m,p]),c.useMemo(()=>p&&m?{projectRef:p,directory:m}:g.current,[p,m])}const kx=({transform:t})=>({...t,y:0}),Cx={Item:Ut,Separator:Os},Nx={Item:({className:t,...e})=>s.jsx(cu,{className:Pe(hd,t),...e}),Separator:({className:t,...e})=>s.jsx(lu,{className:Pe(md,t),...e})},Ax=t=>{const e=tt.c(62),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:u,onMenuOpenChangeComplete:d,children:h}=t,{t:m}=At(),[p,g]=c.useState(!1),[w,v]=c.useState(!1),[x,f]=c.useState(!1);let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:y,listeners:S,setNodeRef:N,transform:C,transition:j,isDragging:A}=qo(b);let P;e[2]!==m||e[3]!==n.session.title?(P=n.session.title?.trim()||m("sessions.sidebar.session.untitled"),e[2]=m,e[3]=n.session.title,e[4]=P):P=e[4];const I=P,M=!i&&(p||w),z=ha(n.id),R=z?.type==="busy"||z?.type==="retry",F=fd(n.id)>0&&!r&&!R,O=R||F;let T;e[5]!==R||e[6]!==m?(T=m(R?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[5]=R,e[6]=m,e[7]=T):T=e[7];const k=T;let D;e[8]!==u||e[9]!==r||e[10]!==o||e[11]!==n?(D=me=>({session:n.session,isActive:r,select:()=>o(n),closeOtherTabs:()=>u(n.id),components:me}),e[8]=u,e[9]=r,e[10]=o,e[11]=n,e[12]=D):D=e[12];const L=D;let Q;e[13]!==C?(Q=Qo.Translate.toString(C),e[13]=C,e[14]=Q):Q=e[14];let q;e[15]!==Q||e[16]!==j?(q={transform:Q,transition:j},e[15]=Q,e[16]=j,e[17]=q):q=e[17];const te=A&&"z-10 opacity-60";let ae;e[18]!==te?(ae=Pe("session-tab-slot flex h-7 w-44 shrink-0 touch-none",te),e[18]=te,e[19]=ae):ae=e[19];const X=r?"true":"false";let Z;e[20]!==r?(Z=r?{"data-active-session-tab":!0}:{},e[20]=r,e[21]=Z):Z=e[21];let se;e[22]!==d?(se=me=>d?.(me),e[22]=d,e[23]=se):se=e[23];let fe;e[24]!==h||e[25]!==k||e[26]!==r||e[27]!==R||e[28]!==L||e[29]!==p||e[30]!==l||e[31]!==d||e[32]!==o||e[33]!==M||e[34]!==a||e[35]!==O||e[36]!==i||e[37]!==m||e[38]!==n||e[39]!==I?(fe=s.jsx(du,{render:me=>s.jsxs("div",{...me,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:de=>{(de.key==="Enter"||de.key===" ")&&(de.preventDefault(),o(n))},onAuxClick:de=>{de.button===1&&(de.preventDefault(),l(n.id))},"data-controls-open":M?"true":"false",className:Pe("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection":Pe("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",M&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Pe("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",M&&"pr-10"),children:[s.jsx("div",{className:Pe("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:I})})}),O?s.jsx("span",{className:Pe("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",R?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",M&&"opacity-0"),"aria-label":k}):null]}),i?null:s.jsxs("div",{onClick:Px,onPointerDown:Ix,className:Pe("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",M&&"flex opacity-100"),children:[s.jsxs(Xs,{open:p,onOpenChange:de=>{g(de),de&&v(!0)},onOpenChangeComplete:de=>{de||v(!1),d?.(de)},children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":m("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"more",className:"size-4"})})}),s.jsx(Ys,{align:"start",className:"min-w-[190px]",children:a(L(Cx))})]}),s.jsx("button",{type:"button","aria-label":m("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"size-4"})})]})]})}),e[24]=h,e[25]=k,e[26]=r,e[27]=R,e[28]=L,e[29]=p,e[30]=l,e[31]=d,e[32]=o,e[33]=M,e[34]=a,e[35]=O,e[36]=i,e[37]=m,e[38]=n,e[39]=I,e[40]=fe):fe=e[40];let B,ne;e[41]===Symbol.for("react.memo_cache_sentinel")?(B={color:"var(--surface-elevated-foreground)"},ne=Pe(Si,"min-w-[190px]"),e[41]=B,e[42]=ne):(B=e[41],ne=e[42]);let ye;e[43]!==L||e[44]!==a?(ye=a(L(Nx)),e[43]=L,e[44]=a,e[45]=ye):ye=e[45];let ce;e[46]!==ye?(ce=s.jsx(Bi,{children:s.jsx(Li,{className:"app-region-no-drag z-50",children:s.jsx($i,{"data-slot":"dropdown-menu-content",style:B,className:ne,children:ye})})}),e[46]=ye,e[47]=ce):ce=e[47];let _;e[48]!==x||e[49]!==se||e[50]!==fe||e[51]!==ce?(_=s.jsxs(uu,{open:x,onOpenChange:f,onOpenChangeComplete:se,children:[fe,ce]}),e[48]=x,e[49]=se,e[50]=fe,e[51]=ce,e[52]=_):_=e[52];let re;return e[53]!==y||e[54]!==S||e[55]!==N||e[56]!==Z||e[57]!==_||e[58]!==q||e[59]!==ae||e[60]!==X?(re=s.jsx("div",{ref:N,style:q,className:ae,"data-active":X,...Z,...y,...S,children:_}),e[53]=y,e[54]=S,e[55]=N,e[56]=Z,e[57]=_,e[58]=q,e[59]=ae,e[60]=X,e[61]=re):re=e[61],re},Dx=t=>{const e=tt.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=At(),u=Jr(Tx),d=Jr(Rx),h=Jr(Ex),m=Jr(Mx),p=Je(Ox),g=Je(Fx),w=Ps(_x);let v,x;e[0]!==p||e[1]!==d?(v=()=>{p&&d(p)},x=[p,d],e[0]=p,e[1]=d,e[2]=v,e[3]=x):(v=e[2],x=e[3]),c.useEffect(v,x);let f;if(e[4]!==w){f=new Map;for(const be of w)f.set(be.id,be);e[4]=w,e[5]=f}else f=e[5];const b=f;let y;if(e[6]!==b||e[7]!==u){y=[];for(const be of u){const Re=b.get(be);Re&&y.push({id:be,session:Re})}e[6]=b,e[7]=u,e[8]=y}else y=e[8];const S=y;let N;e[9]!==g?(N=be=>{g(be.id,$s(be.session))},e[9]=g,e[10]=N):N=e[10];const C=N,j=Bx;let A;e[11]!==h||e[12]!==p||e[13]!==C||e[14]!==S?(A=be=>{if(h(be),p&&p!==be){const Re=S.find(we=>we.id===be);Re&&C(Re)}},e[11]=h,e[12]=p,e[13]=C,e[14]=S,e[15]=A):A=e[15];const P=A;let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I={activationConstraint:{distance:8}},e[16]=I):I=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{delay:200,tolerance:6}},e[17]=M):M=e[17];const z=zr(Mn(iu,I),Mn(ou,M));let R;e[18]!==m?(R=be=>{const{active:Re,over:we}=be;we&&Re.id!==we.id&&m(String(Re.id),String(we.id))},e[18]=m,e[19]=R):R=e[19];const H=R,F=c.useRef(null);let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O={left:!1,right:!1},e[20]=O):O=e[20];const[T,k]=c.useState(O);let D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{const be=F.current;if(!be)return;const Re=be.scrollLeft>2,we=be.scrollLeft+be.clientWidth<be.scrollWidth-2;k(Y=>Y.left===Re&&Y.right===we?Y:{left:Re,right:we})},e[21]=D):D=e[21];const L=D;let Q;e[22]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>{L();const be=F.current;if(!be||!globalThis.ResizeObserver)return;const Re=new ResizeObserver(L);return Re.observe(be),()=>Re.disconnect()},e[22]=Q):Q=e[22];let q;e[23]!==S.length?(q=[L,S.length],e[23]=S.length,e[24]=q):q=e[24],c.useEffect(Q,q);let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{F.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=te):te=e[25];let ae;e[26]!==p?(ae=[p],e[26]=p,e[27]=ae):ae=e[27],c.useEffect(te,ae);const X=T.left&&T.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":T.left?"linear-gradient(to right, transparent, black 24px)":T.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let Z;e[28]!==S?(Z=S.map(Lx),e[28]=S,e[29]=Z):Z=e[29];const se=Z;let fe;e[30]!==p||e[31]!==S?(fe=!p||!S.some(be=>be.id===p),e[30]=p,e[31]=S,e[32]=fe):fe=e[32];const B=fe;let ne;e[33]!==a?(ne=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=ne):ne=e[34];let ye;e[35]!==X?(ye=X?{maskImage:X,WebkitMaskImage:X}:void 0,e[35]=X,e[36]=ye):ye=e[36];let ce;e[37]===Symbol.for("react.memo_cache_sentinel")?(ce=[kx],e[37]=ce):ce=e[37];let _;e[38]!==o||e[39]!==p||e[40]!==P||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==S?(_=S.map(be=>s.jsx(Ax,{tab:be,isActive:be.id===p,suppressControls:be.id===p&&l,onSelect:C,onClose:j,renderMenu:n,closeOtherTabs:P,onMenuOpenChangeComplete:r,children:be.id===p?o:null},be.id)),e[38]=o,e[39]=p,e[40]=P,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=S,e[46]=_):_=e[46];let re;e[47]!==_||e[48]!==se?(re=s.jsx(Io,{items:se,strategy:Mg,children:_}),e[47]=_,e[48]=se,e[49]=re):re=e[49];let me;e[50]!==H||e[51]!==z||e[52]!==re?(me=s.jsx(Vr,{sensors:z,collisionDetection:Ur,modifiers:ce,onDragEnd:H,children:re}),e[50]=H,e[51]=z,e[52]=re,e[53]=me):me=e[53];let de;e[54]!==o||e[55]!==B?(de=B?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=B,e[56]=de):de=e[56];let ge;e[57]!==ye||e[58]!==me||e[59]!==de?(ge=s.jsxs("div",{ref:F,onScroll:L,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:ye,children:[me,de]}),e[57]=ye,e[58]=me,e[59]=de,e[60]=ge):ge=e[60];let Te;return e[61]!==ne||e[62]!==ge?(Te=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ne,children:ge}),e[61]=ne,e[62]=ge,e[63]=Te):Te=e[63],Te};function Px(t){return t.stopPropagation()}function Ix(t){return t.stopPropagation()}function Tx(t){return t.tabIds}function Rx(t){return t.ensureTab}function Ex(t){return t.closeOtherTabs}function Mx(t){return t.reorderTabs}function Ox(t){return t.currentSessionId}function Fx(t){return t.setCurrentSession}function _x(t){return t.activeSessions}function Bx(t){Sm(t)}function Lx(t){return t.id}function $x(t){if(typeof t!="number"||!Number.isFinite(t))return"";const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=e.toLocaleString(pa(),{month:"short"}),r=e.getDate(),i=e.getFullYear(),o=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0");return`${n} ${r}, ${i}, ${o}:${l}`}function Wx(t){if(t.info.role==="user")return"";const e=typeof t.info.providerID=="string"?t.info.providerID.trim():"",n=typeof t.info.modelID=="string"?t.info.modelID.trim():"";return e&&n?`${e}/${n}`:n||e}function zx(t){const e=t.info.role==="user"?"User":"Assistant",n=$x(t.info.time?.created),r=Wx(t),i=n&&r?`${n} (${r})`:n||r;return i?`**${e}**
|
|
3
|
+
|
|
4
|
+
*${i}*`:`**${e}**`}function Vx(t){return t.filter(e=>e.type==="text"&&typeof e.text=="string").map(e=>e.text).join("")}function bu(t){const e=zx(t),n=Vx(t.parts).trim();return n?`${e}
|
|
5
|
+
|
|
6
|
+
${n}`:""}function yu(t,e){const n="#".repeat(Math.min(e+1,6)),r=t.agent?` — ${t.agent}`:"",i=`${n} Sub-agent: ${t.title}${r}
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
`,o=t.records.map(bu).filter(Boolean).join(`
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
`),l=[i+o];for(const a of t.children)l.push(yu(a,e+1));return l.join(`
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
`)}function wu(t,e,n){const r=e?.trim()||"Session",i=new Date().toISOString().split("T")[0],o=`# ${r}
|
|
19
|
+
|
|
20
|
+
*Exported on ${i}*
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
`,l=t.map(bu).filter(Boolean).join(`
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
`);let a=o+l;if(n&&n.length>0){const u=n.map(d=>yu(d,1)).join(`
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
`);a+=`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
`+u}return a}function Su(t,e){const n=new Blob([t],{type:"text/markdown;charset=utf-8"}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function vu(t,e){const n=await Wf(e,t);if(n)return n;if(!Dn())return null;try{const r=await Wo()?.vscode?.saveMarkdown?.({fileName:e,content:t});if(!r||r.saved!==!0)return null;const i=typeof r.path=="string"?r.path.trim():"";return i.length>0?i:null}catch{return null}}async function Ux(t){const e=Wo()?.files;if(e?.revealPath)try{return!!(await e.revealPath(t))?.success}catch{return!1}return await zf(t)?!0:rd(t)}function Kx(){return pd()}function ju(t){const r=(t?.trim()||"session").normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,60)||"session",i=new Date().toISOString().split("T")[0];return`${r}-${i}.md`}const zi=(t,e)=>({success:t(e.success),failure:t(e.failure),sourceVerificationFailed:t("sessions.sidebar.session.moveToWorktree.sourceVerificationFailed"),applyChangesFailed:t("sessions.sidebar.session.moveToWorktree.applyChangesFailed"),changesMayBeInDestination:t("sessions.sidebar.session.moveToWorktree.changesMayBeInDestination")}),$n=er(()=>({pendingSessionIds:new Set,requestingSessionIds:new Set,confirmation:null})),ku=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t)||r.requestingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],$n(n)},Hx=()=>$n(sb),Cu=()=>$n.getState().confirmation,Ra=t=>{$n.setState(e=>e.confirmation===t?e:{...e,confirmation:t})},Cl=(t,e)=>{$n.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},lr=(t,e)=>{$n.setState(n=>{if(n.requestingSessionIds.has(t)===e)return n;const r=new Set(n.requestingSessionIds);return e?r.add(t):r.delete(t),{...n,requestingSessionIds:r}})},Gx="Unable to apply your changes in the destination directory",qx=t=>t.status===400&&t.message.includes(Gx),Qx=async(t,e)=>{try{const u=(await gd(t,{mode:"light"})).current?.trim();if(u)return u}catch{}const n=yt(t),r=yt(e)??e,i=Je.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>yt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},Nl=t=>{for(const e of t){const n=jm(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class Nu extends Error{changesMayBeInDestination;constructor(e,n,r){super(e,{cause:n}),this.name="IncompleteRollbackError",this.changesMayBeInDestination=r}}const Yx=(t,e,n)=>{const r=e.map(({sessionId:i,error:o})=>`${i}: ${o.message}`).join(", ");return new Nu(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${r}`,{moveError:t,rollbackFailures:e},n)},Xx=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(km(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await xd(o,n,e,!1),Je.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i};class Au extends Error{constructor(e){super(e.message,{cause:e}),this.name="ChangesMayBeInDestinationError"}}const Al=async(t,e,n)=>{try{await bd(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Dl=async(t,e)=>{const n=e?[t,e]:[t];try{await ga(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},Du=async(t,e)=>{if($n.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Cl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,Je.getState().getWorktreeMetadata(a.id)]));Nl(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,u]of n.entries()){Nl(n.slice(a));const d=u.id===t.root.id&&t.moveChanges;try{await xd(u,t.sourceDirectory,i.directory,d)}catch(h){throw d&&vm(h)&&(l=!0),h}o.push(u),u.id!==t.root.id&&Je.getState().setWorktreeMetadata(u.id,Za(i.metadata))}}catch(a){const u=a instanceof Error?a:new Error(String(a)),d=await Xx(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await Dl(t.sourceDirectory,i?.directory),d.length>0)throw Yx(u,d,l);if(l)throw new Au(u);if(i?.onMoveFailure)return i.onMoveFailure(u);throw u}return Je.getState().setWorktreeMetadata(t.root.id,Za(i.metadata)),await Dl(t.sourceDirectory,i.directory),i.directory}finally{Cl(t.root.id,!1)}},Jx=async t=>{const e=yt(t.sourceDirectory)??t.sourceDirectory,n=yt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return Du(t,async()=>({directory:t.destination.path,metadata:t.destination}))},Zx=async t=>Du(t,async()=>{const e=vi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await Uo(t.sourceDirectory)?await Qx(t.sourceDirectory,e.path):null,r=await Cm(e,n?{startRef:n}:{});try{await Nm(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Al(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Al(e,r,i)}}),eb=(t,e,n)=>e instanceof Au?t.changesMayBeInDestination:e instanceof Nu&&e.changesMayBeInDestination?`${e.message} ${t.changesMayBeInDestination}`:n&&qx(e)?t.applyChangesFailed:e.message,Vi=(t,e)=>{(t.kind==="existing"?Jx({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination,moveChanges:e}):Zx({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,moveChanges:e})).then(()=>Me.success(t.messages.success)).catch(r=>{const i=r instanceof Error?r:new Error(String(r));Me.error(t.messages.failure,{description:eb(t.messages,i,e)})})},tb=()=>{const t=Cu();t&&(lr(t.intent.root.id,!1),Ra(null))},Pu=t=>{const e=Cu();if(!e)return;const{intent:n}=e;Ra(null),lr(n.root.id,!1),Vi(n,t)},Ui=t=>{const e=$n.getState();e.confirmation||e.pendingSessionIds.has(t.root.id)||e.requestingSessionIds.has(t.root.id)||(lr(t.root.id,!0),(async()=>{try{if(!await Uo(t.sourceDirectory)){lr(t.root.id,!1),Vi(t,!1);return}const r=await gd(t.sourceDirectory);if(r.isClean){lr(t.root.id,!1),Vi(t,!1);return}const i=r.files.filter(o=>{const l=o.index.trim();return l!==""&&l!=="?"}).length;Ra({intent:t,dirtyFileCount:r.files.length,stagedFileCount:i})}catch{Me.error(t.messages.failure,{description:t.messages.sourceVerificationFailed}),lr(t.root.id,!1)}})())};function sb(t){return t.confirmation}const Eo="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",nb=c.memo(function(e){const n=tt.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:u,iconClassName:d,pressed:h}=e,m=r===void 0?!0:r,p=h===void 0?!1:h;if(!m)return null;const g=a??Eo,w=p&&"bg-interactive-selection text-interactive-selection-foreground";let v;n[0]!==g||n[1]!==w?(v=Pe(g,w),n[0]=g,n[1]=w,n[2]=v):v=n[2];const x=d??"h-[18px] w-[18px]";let f;n[3]!==u||n[4]!==x?(f=s.jsx(E,{name:u,className:x}),n[3]=u,n[4]=x,n[5]=f):f=n[5];let b;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==v||n[10]!==f?(b=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:v,children:f})}),n[6]=o,n[7]=l,n[8]=p,n[9]=v,n[10]=f,n[11]=b):b=n[11];let y;n[12]!==i?(y=s.jsx(It,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=y):y=n[13];let S;return n[14]!==b||n[15]!==y?(S=s.jsxs(Dt,{children:[b,y]}),n[14]=b,n[15]=y,n[16]=S):S=n[16],S}),rb=c.memo(function(e){const n=tt.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:u,shortcutLabel:d,remoteUpdateInfo:h,remoteUpdateChecking:m,remoteUpdateError:p,onOpenRemoteUpdate:g}=e,{t:w}=At();let v;n[0]!==u||n[1]!==a?(v=z=>{a(z),z&&u()},n[0]=u,n[1]=a,n[2]=v):v=n[2];let x;n[3]!==i||n[4]!==r||n[5]!==w?(x=r?w("header.services.openWithCurrent",{current:i}):w("header.services.open"),n[3]=i,n[4]=r,n[5]=w,n[6]=x):x=n[6];const f=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let b;n[7]!==f?(b=Pe(Eo,f),n[7]=f,n[8]=b):b=n[8];let y;n[9]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(E,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=y):y=n[9];let S;n[10]!==i||n[11]!==r?(S=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=S):S=n[12];let N;n[13]!==x||n[14]!==b||n[15]!==S?(N=s.jsx(Pt,{asChild:!0,children:s.jsx(Qs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":x,className:b,children:[y,S]})})}),n[13]=x,n[14]=b,n[15]=S,n[16]=N):N=n[16];let C;n[17]!==i||n[18]!==d||n[19]!==w?(C=w("header.services.tooltip.currentInstance",{current:i,toggle:d("toggle_services_menu")}),n[17]=i,n[18]=d,n[19]=w,n[20]=C):C=n[20];let j;n[21]!==C?(j=s.jsx(It,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=j):j=n[22];let A;n[23]!==N||n[24]!==j?(A=s.jsxs(Dt,{children:[N,j]}),n[23]=N,n[24]=j,n[25]=A):A=n[25];let P;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==g||n[30]!==m||n[31]!==p||n[32]!==h||n[33]!==a||n[34]!==w?(P=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:w("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?w("header.services.remoteUpdate.available",{version:h.version||""}):m?w("header.services.remoteUpdate.checking"):p||w("header.services.remoteUpdate.upToDate")})]}),h?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:g,children:w("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Am,{embedded:!0,open:l,onOpenChange:ab,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=g,n[30]=m,n[31]=p,n[32]=h,n[33]=a,n[34]=w,n[35]=P):P=n[35];let I;n[36]!==P?(I=s.jsx(Ys,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:P}),n[36]=P,n[37]=I):I=n[37];let M;return n[38]!==l||n[39]!==v||n[40]!==A||n[41]!==I?(M=s.jsxs(Xs,{open:l,onOpenChange:v,children:[A,I]}),n[38]=l,n[39]=v,n[40]=A,n[41]=I,n[42]=M):M=n[42],M}),ob=(t,e)=>t===e?!0:!t||!e?!1:t.totalTokens===e.totalTokens&&t.percentage===e.percentage&&t.contextLimit===e.contextLimit&&(t.outputLimit??0)===(e.outputLimit??0)&&(t.normalizedOutput??0)===(e.normalizedOutput??0)&&t.thresholdLimit===e.thresholdLimit&&(t.lastMessageId??"")===(e.lastMessageId??""),vn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Pl=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,ib=()=>{Gs("ui.header.render");const{t}=At(),e=De(W=>W.isSidebarOpen),n=De(W=>W.openContextOverview),r=De(W=>W.closeContextPanel),i=De(W=>W.shortcutOverrides),o=De(W=>W.sessionTabsEnabled),l=Gt(W=>W.getCurrentModel),a=Je(W=>W.getContextUsage),u=Je(W=>!!W.newSessionDraft?.open),d=Je(W=>W.currentSessionId),h=Dm(d??""),m=ha(d??""),p=ku(d??""),g=Ps(Jn(c.useCallback(W=>{if(!d)return null;const $e=[...W.activeSessions,...W.archivedSessions].find(jt=>jt.id===d);if(!$e)return null;const nt=$e;return{title:$e.title??null,directory:nt.directory??null,created:$e.time?.created??null,slug:nt.slug??null,shareUrl:$e.share?.url??null,parentId:$e.parentID??null}},[d]))),w=Kt(Jn(W=>{if(!W.activeProjectId)return null;const $e=W.projects.find(nt=>nt.id===W.activeProjectId);return $e?{id:$e.id,path:$e.path,label:$e.label}:null})),v=c.useMemo(()=>{if(!w)return null;const W=w.label?.trim();if(W)return W;const $e=w.path.split(/[\\/]/).filter(Boolean);return $e[$e.length-1]??null},[w]),x=ir(W=>W.loadSettings),{isMobile:f}=Bn(),b=c.useRef(null),[y,S]=c.useState(()=>typeof window>"u"?!1:xn()),N=c.useMemo(()=>zo(),[]),C=yd(),[j,A]=c.useState(!1),P=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:I,side:M}=Qd(),z=c.useMemo(()=>{if(typeof window>"u")return null;const W=window.__AIWORKER_MACOS_MAJOR__;if(typeof W=="number"&&Number.isFinite(W)&&W>0)return W;if(typeof navigator>"u")return null;const $e=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!$e)return null;const nt=Number.parseInt($e[1],10),jt=Number.parseInt($e[2],10);return Number.isNaN(nt)?null:nt===10?jt:nt},[]);ht.useEffect(()=>{typeof window>"u"||S(xn())},[]);const R=l(),H=R&&typeof R.limit=="object"&&R.limit!==null?R.limit:null,F=H&&typeof H.context=="number"?H.context:0,O=H&&typeof H.output=="number"?H.output:0,T=a(F,O),[k,D]=c.useState(null),L=!d||h;ht.useEffect(()=>{if(!d){D(W=>W===null?W:null);return}if(T&&T.totalTokens>0){D(W=>ob(W,T)?W:T);return}L&&D(W=>W===null?W:null)},[T,d,L]);const[Q,q]=c.useState(!1),[te,ae]=c.useState("Local"),[X,Z]=c.useState(!0),[se,fe]=c.useState(!1),[B,ne]=c.useState(null),[ye,ce]=c.useState(!1),[_,re]=c.useState(null),me=c.useMemo(()=>Dn(),[]),de=De(W=>W.workStatusPanelVisible),ge=De(W=>W.workStatusPanelEnabled),Te=De(W=>W.setWorkStatusPanelEnabled),be=De(W=>W.workStatusPanelFits),Re=De(W=>W.workStatusOverlayOpen),we=De(W=>W.setWorkStatusOverlayOpen),ve=ge&&be||Re,xe=c.useCallback(()=>{if(ge&&!be){we(!Re);return}Te(!ge)},[we,Te,Re,ge,be]),je=!me&&!de&&!!k&&k.totalTokens>0,oe=k&&k.contextLimit>0?Math.min(999,k.totalTokens/k.contextLimit*100):0,J=c.useCallback(async()=>{if(!(typeof window>"u"||!y))try{if($o()){ae("Local"),Z(!0);return}Z(!1);const W=await od(),$e=Vf(),nt=Uf([Kf($e),...W.hosts]);if(nt.id===Hf){ae("Local"),Z(!0);return}ae(id(nt.label.trim()||"Instance"))}catch{ae("Local"),Z(!0)}},[y]);ht.useEffect(()=>(J(),fa(()=>{J()})),[J]);const K=c.useCallback(async()=>{if(X){ne(null),re(null);return}ce(!0),re(null);try{const W=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),$e=await ds(`/api/openchamber/update-check?${W.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!$e.ok)throw new Error(`Server responded with ${$e.status}`);const nt=await $e.json();ne({available:nt.available??!1,version:nt.version,currentVersion:nt.currentVersion??"unknown",body:nt.body,nextSuggestedCheckInSec:typeof nt.nextSuggestedCheckInSec=="number"?nt.nextSuggestedCheckInSec:void 0,packageManager:nt.packageManager,updateCommand:nt.updateCommand})}catch(W){ne(null),re(W instanceof Error?W.message:t("header.services.remoteUpdate.error"))}finally{ce(!1)}},[X,t]);c.useEffect(()=>{ne(null),re(null),fe(!1)},[X,te]),c.useEffect(()=>{if(!y||X)return;const W=3e3,$e=3600*1e3;let nt=!1,jt=null;const Ct=Bt=>{jt=window.setTimeout(()=>{if(nt||typeof document<"u"&&document.visibilityState!=="visible"){Ct($e);return}K().finally(()=>{nt||Ct($e)})},Bt)};return Ct(W),()=>{nt=!0,jt!==null&&window.clearTimeout(jt)}},[K,X,te,y]);const $=c.useCallback(()=>{if(B?.available){fe(!0);return}K()},[K,B?.available]);Pm(),c.useEffect(()=>{x()},[x]);const le=d?g??null:null,V=c.useRef(null),[Ce,Be]=c.useState(0);c.useEffect(()=>{if(!d){V.current&&(V.current=null,Be(jt=>jt+1));return}if(le){V.current={sessionId:d,session:le,expiresAt:Date.now()+2e3};return}const W=V.current;if(!W||W.sessionId!==d)return;const $e=W.expiresAt-Date.now();if($e<=0){V.current=null,Be(jt=>jt+1);return}const nt=window.setTimeout(()=>{V.current?.sessionId===d&&(V.current=null),Be(jt=>jt+1)},$e);return()=>{window.clearTimeout(nt)}},[d,le]);const ke=(()=>{if(le)return le;if(!d)return null;const W=V.current;return W&&W.sessionId===d&&W.expiresAt>Date.now()?W.session:null})(),Ne=Je(W=>d?W.worktreeMetadata.get(d)?.path??"":""),Qe=Je(W=>d?W.worktreeMetadata.get(d)?.branch?.trim()??null:null),We=wd(W=>d?W.getAttachment(d):void 0),U=c.useMemo(()=>We?Im(We,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,We]),he=c.useMemo(()=>We?We.legacy?"legacy":We.degraded?"degraded":We.worktreeStatus==="pending"?"pending":We.worktreeStatus==="missing"?"missing":We.worktreeStatus==="invalid"?"invalid":We.attentionReason?"attention":null:null,[We]),Ee=c.useMemo(()=>vn(Ne||""),[Ne]),Ie=c.useMemo(()=>{const W=typeof ke?.directory=="string"?ke.directory:"";return vn(W||"")},[ke?.directory]),rt=Je(W=>W.newSessionDraft?.open?vn(W.newSessionDraft.bootstrapPendingDirectory??W.newSessionDraft.directoryOverride??""):""),Ge=Je(W=>W.newSessionDraft.target),ut=Je(W=>W.newSessionDraft.selectedProjectId),ct=Je(W=>W.currentSessionDirectory),ue=ts(W=>W.homeDirectory),G=c.useMemo(()=>Ee||Ie||rt,[rt,Ie,Ee]),Le=De(c.useCallback(W=>{const $e=vn(G||"");return $e?Pl(W.contextPanelByDirectory[$e]):null},[G])),Oe=Je(W=>{const $e=vn(Ee||Ie||"");if(!$e)return null;for(const nt of W.availableWorktreesByProject.values()){const Ct=nt.find(Bt=>vn(Bt.path)===$e)?.branch?.trim();if(Ct)return Ct}return null}),Ue=Tm(G||null)||Qe||Oe,st=u?Ge==="chat":Rm(Ie||ct,ue),wt=!st&&!de&&!!(v||Ue||!u&&he),Nt=c.useMemo(()=>{if(!d)return v??"AiWorker";const W=ke?.title?.trim();return W&&W.length>0?W:"Untitled Session"},[v,ke?.title,d]),ie=Sd(G||void 0,{bootstrap:!1}),pe=vd(),Ve=Je(W=>W.updateSessionTitle),ze=Je(W=>W.shareSession),He=Je(W=>W.unshareSession),ot=Je(W=>W.archiveSessions),at=Je(W=>W.deleteSessions),[et,Xe]=c.useState(!1),[dt,Fe]=c.useState(!1),Se=c.useRef(null),[St,vt]=c.useState(""),[Rt,Ze]=c.useState(null),it=c.useRef(null),gt=c.useCallback(()=>{d&&(vt(ke?.title?.trim()||Nt),Xe(!0))},[ke?.title,d,Nt]),xt=c.useRef(gt);xt.current=gt;const Et=c.useCallback(W=>{W&&(W.focus(),W.select())},[]);c.useEffect(()=>{if(Fe(!1),Ze(null),d&&Se.current===d){Se.current=null,xt.current();return}Xe(!1),vt("")},[d]);const kt=c.useCallback(async()=>{if(!d)return;const W=St.trim();W&&W!==ke?.title?.trim()&&await Ve(d,W),Xe(!1)},[ke?.title,d,St,Ve]);c.useEffect(()=>{if(!et)return;const W=$e=>{const nt=$e.target;(!nt||!it.current?.contains(nt))&&kt()};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[et,kt]);const Tt=c.useCallback(W=>{W&&pn(W).then($e=>{Me[$e.ok?"success":"error"](t($e.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Me.error(t("sessions.sidebar.session.copyId.error")))},[t]),Ot=c.useCallback(async W=>{if(!W)return;const $e=await ze(W);if($e?.share?.url){const nt=await pn($e.share.url);Me[nt.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(nt.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}Me.error(t("sessions.sidebar.session.share.error"))},[ze,t]),Vt=c.useCallback(W=>{W&&pn(W).then($e=>{Me[$e.ok?"success":"error"](t($e.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>Me.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),Yt=c.useCallback(async W=>{if(!W)return;const $e=await He(W);Me[$e?"success":"error"](t($e?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,He]),Ht=c.useCallback(async()=>{if(!d||!G){Me.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await pe.loadCompleteHistory(d,G)}catch{Me.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const W=Em(ie.getState(),d).list;if(W.length===0){Me.error(t("sessions.sidebar.session.export.nothingToExport"));return}const $e=wu(W,ke?.title??null),nt=ju(ke?.title??null);await vu($e,nt)||Su($e,nt),Me.success(t("sessions.sidebar.session.export.success"))},[ke?.title,d,ie,G,pe,t]),Lt=m?.type==="busy"||m?.type==="retry",zt=c.useCallback(()=>{if(!d||!Ie||Lt||p)return;const W=Ps.getState().activeSessions,$e=W.find(Ct=>Ct.id===d);if(!$e)return;const nt=[],jt=[d];for(let Ct=0;Ct<jt.length;Ct+=1){const Bt=jt[Ct];for(const os of W)os.parentID===Bt&&(nt.push(os),jt.push(os.id))}Ui({kind:"quick",root:$e,descendants:nt,sourceDirectory:Ie,messages:zi(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Lt,p,Ie,t]),_e=c.useCallback(async()=>{if(!Rt)return;const W=Ps.getState().activeSessions,$e=[Rt.sessionId];for(let Bt=0;Bt<$e.length;Bt+=1){const os=$e[Bt];for(const qt of W)qt.parentID===os&&!$e.includes(qt.id)&&$e.push(qt.id)}const nt=Rt.action;if(Ze(null),(nt==="archive"?await ot($e):await at($e)).failedIds.length>0){Me.error(t(nt==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Me.success(t(nt==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[ot,at,Rt,t]),Ye=De(W=>W.isScheduledTasksDialogOpen),ft=De(W=>W.isArchivePageOpen),bt=De(W=>W.worktreesPageProjectId),mt=De(W=>W.isMultiRunLauncherOpen),lt=Kt(W=>{if(!bt)return null;const $e=W.projects.find(nt=>nt.id===bt);return $e?.label?.trim()||$e?.path?.split("/").pop()||null}),$t=c.useMemo(()=>Ye?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:ft?{title:t("sessions.archivePage.title"),subtitle:null}:bt?{title:t("sessions.worktreesPage.title",{project:lt??""}),subtitle:null}:mt?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[ft,mt,Ye,t,bt,lt]),Zt=c.useMemo(()=>vn(G||w?.path||""),[w?.path,G]),Xt=jx(),Ns=xa(W=>W.planModeEnabled),Jt=Je(W=>W.isSessionPlanAvailable),zs=Ns&&d?Jt(d):!1,Js=c.useRef("");c.useEffect(()=>{if(!Ns||!d)return;const W=`${d||"none"}:${Ie||"none"}:${ke?.created||0}:${ke?.slug||"none"}`;Js.current!==W&&(Js.current=W)},[Ns,zs,ke?.slug,ke?.created,d,Ie]);const rs=c.useCallback(()=>{En("desktop_open_draft_mini_chat_window",{directory:st?"":rt,projectId:st?null:ut,apiBaseUrl:Nn(),clientToken:Lr()}).catch(W=>{console.warn("[header] failed to open draft mini chat window",W)})},[rt,ut,st]),Vs=c.useCallback(()=>{if(u){rs();return}d&&En("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ie||vn(ct||"")||Ee,apiBaseUrl:Nn(),clientToken:Lr()}).catch(W=>{console.warn("[header] failed to open session mini chat window",W)})},[d,rs,u,ct,Ie,Ee]),Rs=c.useCallback(()=>{const W=vn(G||"");if(!W)return;const $e=De.getState().contextPanelByDirectory[W];if(Pl($e)==="context"){r(W);return}n(W)},[r,n,G]),cn=Le==="context",gs=Eo,vs=c.useMemo(()=>y&&P&&!j?"88px":C?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!y||I)&&!me?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[y,j,P,C,me,I]);ht.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",vs)},[vs]);const Zs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Es=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ht.useEffect(()=>{if(!y||!P){A(!1);return}let W=!1;const $e=async()=>{try{const jt=await En("desktop_is_window_fullscreen");W||A(jt===!0)}catch{W||A(!1)}},nt=()=>{$e()};return $e(),window.addEventListener("aiworker:window-resized",nt),()=>{W=!0,window.removeEventListener("aiworker:window-resized",nt)}},[y,P]);const As=c.useMemo(()=>!y||!P||z===null?"":z>=26?"h-12":z<=15?"h-14":"",[y,P,z]),Ds=c.useMemo(()=>{if(!(y&&!I||me)&&!(I&&M==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[y,me,I,M]),js=c.useCallback(()=>{if(typeof document>"u")return;const W=b.current?.getBoundingClientRect().height;W&&document.documentElement.style.setProperty("--oc-header-height",`${W}px`)},[]);ht.useEffect(()=>{if(typeof window>"u")return;js();const W=b.current;if(!W||typeof ResizeObserver>"u")return()=>{};let $e=0;const nt=()=>{$e||($e=requestAnimationFrame(()=>{$e=0,js()}))},jt=new ResizeObserver(nt);return jt.observe(W),window.addEventListener("resize",nt),window.addEventListener("orientationchange",nt),()=>{$e&&cancelAnimationFrame($e),jt.disconnect(),window.removeEventListener("resize",nt),window.removeEventListener("orientationchange",nt)}},[js]),ht.useEffect(()=>{js()},[js,f,As]);const Ft=c.useCallback(async W=>{const $e=W.target;$e.closest(".app-region-no-drag")||$e.closest("button, a, input, select, textarea")||W.button===0&&y&&await Gf()},[y]),Wt=c.useCallback(W=>qn(qr(W,i)),[i]);Mm({rename_current_session:()=>{if(!d||f)return!1;gt()},toggle_services_menu:()=>{if(Q){q(!1);return}q(!0),J()}});const ns=s.jsxs(s.Fragment,{children:[Xt?s.jsx(Sx,{projectRef:Xt.projectRef,directory:Xt.directory,className:"mr-2"}):null,s.jsx(Qg,{directory:Zt,className:"mr-1"}),y?s.jsx(rb,{isDesktopApp:y,currentInstanceLabel:te,currentInstanceIsLocal:X,isDesktopServicesOpen:Q,setIsDesktopServicesOpen:q,refreshCurrentInstanceLabel:J,shortcutLabel:Wt,remoteUpdateInfo:B,remoteUpdateChecking:ye,remoteUpdateError:_,onOpenRemoteUpdate:$}):null]}),us=N&&(u||!!d),xs=c.useCallback(({session:W,isActive:$e,select:nt,closeOtherTabs:jt,components:Ct})=>{const{Item:Bt,Separator:os}=Ct,qt=W.share?.url??null,en=$e&&!me&&!st&&ke&&!ke.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Bt,{onClick:()=>{$e||nt(),Se.current=W.id},children:[s.jsx(E,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsxs(Bt,{onClick:()=>Tt(W.id),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(os,{}),qt?s.jsxs(s.Fragment,{children:[s.jsxs(Bt,{onClick:()=>Vt(qt),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Bt,{onClick:()=>{Yt(W.id)},children:[s.jsx(E,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Bt,{onClick:()=>{Ot(W.id)},children:[s.jsx(E,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),$e?s.jsxs(Bt,{onClick:()=>{Ht()},children:[s.jsx(E,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,en?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Bt,{disabled:!Ie||Lt||p,onClick:zt,className:"w-full",children:[s.jsx(E,{name:"folder-shared",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(It,{side:"right",className:"max-w-72",children:t(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Lt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(os,{}),s.jsxs(Bt,{onClick:jt,children:[s.jsx(E,{name:"close-circle",className:"mr-2 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(os,{}),s.jsxs(Bt,{onClick:()=>Ze({action:"archive",sessionId:W.id}),children:[s.jsx(E,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Bt,{className:"text-destructive focus:text-destructive",onClick:()=>Ze({action:"delete",sessionId:W.id}),children:[s.jsx(E,{name:"delete-bin",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Tt,Vt,ke,Ht,st,Lt,p,me,zt,Ie,Ot,t,Yt]),ee=()=>s.jsxs("div",{onMouseDown:Ft,className:Pe("app-region-drag relative flex h-12 select-none items-center",I&&M==="right"?"pr-0":"pr-3",As),style:Ds,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Zs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Es}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[$t?s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:$t.title}),$t.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:$t.subtitle}):null]}):me||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[e?null:s.jsx(xl,{align:"start",children:s.jsx("button",{type:"button",className:gs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(E,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[et?s.jsxs("form",{ref:it,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:W=>W.stopPropagation(),onSubmit:W=>{W.preventDefault(),kt()},children:[s.jsx("input",{ref:Et,value:St,onChange:W=>vt(W.target.value),onKeyDown:W=>{W.stopPropagation(),W.key==="Escape"&&Xe(!1)},placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Xe(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:u?t("sessions.switcher.draftTitle"):Nt}),wt?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[v?s.jsx("span",{className:"truncate",children:v}):null,Ue?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:Ue})]}):null,!u&&he?s.jsxs("span",{className:Pe("inline-flex min-w-0 items-center gap-0.5",he==="attention"||he==="invalid"||he==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(E,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:U})]}):null]}):null]}),s.jsx("div",{className:Pe("flex h-[18px] shrink-0 items-center justify-center",wt?"self-start":"self-center"),children:d&&!u&&!et?s.jsxs(Xs,{open:dt,onOpenChange:Fe,onOpenChangeComplete:W=>{!W&&Se.current&&Se.current===d&&(Se.current=null,gt())},children:[s.jsx(Qs,{asChild:!0,children:s.jsx(pt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(E,{name:"more",className:"size-4"})})}),s.jsxs(Ys,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Ut,{onClick:()=>{Se.current=d},children:[s.jsx(E,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsxs(Ut,{onClick:()=>d&&Tt(d),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Os,{}),ke?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Ut,{onClick:()=>Vt(ke?.shareUrl),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Ut,{onClick:()=>{d&&Yt(d)},children:[s.jsx(E,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Ut,{onClick:()=>{d&&Ot(d)},children:[s.jsx(E,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Ut,{onClick:()=>{Ht()},children:[s.jsx(E,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),!me&&!st&&ke&&!ke.parentId?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ut,{disabled:!Ie||Lt||p,onClick:zt,className:"w-full",children:[s.jsx(E,{name:"folder-shared",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(It,{side:"right",className:"max-w-72",children:t(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Lt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Os,{}),s.jsxs(Ut,{onClick:()=>{d&&Ze({action:"archive",sessionId:d})},children:[s.jsx(E,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Ut,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&Ze({action:"delete",sessionId:d})},children:[s.jsx(E,{name:"delete-bin",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(xl,{align:"start",children:s.jsx("button",{type:"button",className:gs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(E,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Dx,{renderMenu:xs,suppressActiveTabControls:et,onMenuOpenChangeComplete:W=>{!W&&Se.current&&Se.current===d&&(Se.current=null,gt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:et?s.jsxs("form",{ref:it,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:W=>W.stopPropagation(),onSubmit:W=>{W.preventDefault(),kt()},children:[s.jsx("input",{ref:Et,value:St,onChange:W=>vt(W.target.value),onKeyDown:W=>{W.stopPropagation(),W.key==="Escape"&&Xe(!1)},placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Xe(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:u?t("sessions.switcher.draftTitle"):Nt})})})]}),$t||me||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[je&&k?s.jsx(Wp,{totalTokens:k.totalTokens,percentage:oe,colorPercentage:k.percentage,contextLimit:k.contextLimit,outputLimit:k.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Rs,pressed:cn,className:us?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(nb,{visible:us,title:t(u?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(u?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Vs,className:Pe(gs,"mr-1"),Icon:"picture-in-picture-2"}),me?null:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":ve,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:xe,className:Pe(Eo,"mr-1",ve?"text-foreground":"text-muted-foreground/50"),children:s.jsx(E,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(It,{side:"bottom",children:t(ge&&!be?Re?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ge?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ns,s.jsx(Yd,{visible:I&&M==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:b,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:ee()}),s.jsx(ws,{open:Rt!==null,onOpenChange:W=>{W||Ze(null)},children:s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:Rt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Ts,{children:Rt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Nt}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Nt})})]}),s.jsxs(bn,{children:[s.jsx(pt,{variant:"outline",size:"sm",onClick:()=>Ze(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(pt,{variant:"destructive",size:"sm",onClick:()=>{_e()},children:Rt?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Xd,{open:se,onOpenChange:fe,info:B,downloading:!1,downloaded:!1,progress:null,error:_,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function ab(){}const Il=280,Tl=168,Rl=500,lb=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=At(),l=De(j=>j.sidebarWidth),a=De(j=>j.setSidebarWidth),[u,d]=c.useState(!1),h=c.useRef(0),m=c.useRef(l||Il),p=c.useRef(null),g=c.useRef(null),w=c.useRef(null),v=c.useCallback(j=>Math.min(Rl,Math.max(Tl,j)),[]),x=c.useCallback(j=>{const A=w.current;A&&(A.style.width=`${j}px`,A.style.minWidth=`${j}px`,A.style.maxWidth=`${j}px`,A.style.setProperty("--oc-left-sidebar-width",`${j}px`))},[]);if(c.useEffect(()=>{e&&u&&d(!1)},[e,u]),c.useEffect(()=>{u||(p.current=null,g.current=null)},[u]),e)return null;const f=Math.min(Rl,Math.max(Tl,l||Il)),b=t?f:0,y=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}g.current=j.pointerId,d(!0),h.current=j.clientX,m.current=b,p.current=b,x(b),j.preventDefault()}},S=j=>{if(e||!u||g.current!==j.pointerId)return;const A=j.clientX-h.current,P=v(m.current+A);p.current!==P&&(p.current=P,x(P))},N=j=>{if(g.current!==j.pointerId||e)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const A=v(p.current??b);g.current=null,p.current=null,d(!1),a(A)},C=u?p.current??b:b;return s.jsxs("aside",{ref:w,className:Pe("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${u?C:f}px`,overflowX:"clip",transitionProperty:u?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||b===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Pe("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",u&&"bg-[var(--interactive-border)]"),onPointerDown:y,onPointerMove:S,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Pe("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",u&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(ln,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Hs,{children:n})})]})]})},cb=()=>{const t=tt.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},El="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors",db=()=>{const t=tt.c(32),{t:e}=At(),n=De(ub),r=De(fb),i=c.useRef(null),o=qn(qr("toggle_sidebar",r)),{usesFramelessChrome:l,side:a}=Qd(),u=hb;let d,h;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{if(typeof document>"u")return;const z=i.current;if(!z)return;const R=()=>{const F=Math.max(z.getBoundingClientRect().width,z.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(F)}px`)};if(R(),typeof ResizeObserver>"u")return;const H=new ResizeObserver(R);return H.observe(z),()=>{H.disconnect()}},h=[],t[0]=d,t[1]=h):(d=t[0],h=t[1]),c.useEffect(d,h);const m="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let p;t[2]===Symbol.for("react.memo_cache_sentinel")?(p={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=p):p=t[2];const g="flex items-center gap-2";let w;t[3]!==l||t[4]!==a?(w=l&&a==="left"?s.jsx(Yd,{visible:!0,position:"left"}):null,t[3]=l,t[4]=a,t[5]=w):w=t[5];let v;t[6]!==e||t[7]!==l?(v=l?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,"aria-label":e("header.actions.openAppMenuAria"),className:Pe(El,"shrink-0"),children:s.jsx(E,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(It,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=l,t[8]=v):v=t[8];const x=Dt;let f;t[9]!==e?(f=e("header.actions.openSessionsAria"),t[9]=e,t[10]=f):f=t[10];let b,y;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=Pe(El,"shrink-0"),y=s.jsx(E,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=b,t[12]=y):(b=t[11],y=t[12]);let S;t[13]!==f||t[14]!==n?(S=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":f,className:b,children:y})}),t[13]=f,t[14]=n,t[15]=S):S=t[15];const N=It,C=e("header.actions.openSessionsWithShortcut",{shortcut:o});let j;t[16]!==C?(j=s.jsx("p",{children:C}),t[16]=C,t[17]=j):j=t[17];let A;t[18]!==N||t[19]!==j?(A=s.jsx(N,{children:j}),t[18]=N,t[19]=j,t[20]=A):A=t[20];let P;t[21]!==x||t[22]!==S||t[23]!==A?(P=s.jsxs(x,{children:[S,A]}),t[21]=x,t[22]=S,t[23]=A,t[24]=P):P=t[24];let I;t[25]!==P||t[26]!==w||t[27]!==v?(I=s.jsxs("div",{ref:i,className:g,children:[w,v,P]}),t[25]=P,t[26]=w,t[27]=v,t[28]=I):I=t[28];let M;return t[29]!==I||t[30]!==p?(M=s.jsx("div",{className:m,style:p,children:I}),t[29]=I,t[30]=p,t[31]=M):M=t[31],M};function ub(t){return t.toggleSidebar}function fb(t){return t.shortcutOverrides}function mb(t){console.warn("[titlebar] failed to open app menu",t)}function hb(t){const e=t.currentTarget.getBoundingClientRect();En("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(mb)}function Iu(t){const e=tt.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(E,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let u;return e[3]!==i?(u=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=u):u=e[4],u}const Ml=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function pb(t,e,n){const r=tt.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let u=!1;return(async()=>{const[d,h]=await Promise.all([Om(t),Fm(t)]).catch(gb);if(u)return;const m=Ml(d),p=Ml(h);if(!m||!p||p===m)return;const g=n||"",w=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:m,branch:g,label:g||w,name:w,worktreeRoot:p,worktreeStatus:"ready",headState:g?"branch":"unborn",worktreeSource:"existing"})})(),()=>{u=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function gb(){return["",""]}const Ol="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",xb=async(t,e)=>{if(t)return t.authActivate(e);const n=await ds("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},Fl=({className:t})=>{const{t:e}=At(),{github:n}=wn(),r=An(g=>g.status),i=An(g=>g.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async g=>{if(!(!g||o)){l(!0);try{i(await xb(n,g))}catch(w){console.error("Failed to switch GitHub account:",w)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const u=r.user?.login??null,d=r.user?.avatarUrl??null,h=r.accounts??[],m=u?e("header.github.connectedWithLogin",{login:u}):e("header.github.connected"),p=d?s.jsx("img",{src:d,alt:u?e("header.github.avatarWithLogin",{login:u}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(E,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Pe(Ol,t),title:m,children:p}):s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe(Ol,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:m,disabled:o,children:p})}),s.jsxs(Ys,{align:"end",className:"w-64",children:[s.jsx(ho,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Os,{}),h.map(g=>{const w=g.user,v=!!g.current,x=g.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Ut,{className:"gap-2",disabled:o,onSelect:()=>{v||a(g.id)},children:[w?.avatarUrl?s.jsx("img",{src:w.avatarUrl,alt:w.login?e("header.github.avatarWithLogin",{login:w.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(E,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:w?.name?.trim()||w?.login||"GitHub"}),w?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:w.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:x})]}):null]}),v?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},g.id)})]})]})};class Yo extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const Xo="/api/walkthrough",Tu=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),Ru=()=>new Yo("This AiWorker server has no walkthrough API",{code:"server-unsupported"}),bb=t=>!Tu(t)&&(t.ok||t.status===404),Ea=async(t,e)=>{if(bb(t))throw Ru();const n=await t.json().catch(()=>null);throw new Yo(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},Eu=async t=>{if(!Tu(t))throw Ru();try{return await t.json()}catch{throw new Yo("The server returned a malformed walkthrough response")}};async function yb(t,e,n={}){const r=await ds(Xo,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?Eu(r):Ea(r,"Failed to load walkthrough")}async function wb(t,e,n={}){const r=await ds(`${Xo}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?Eu(r):Ea(r,"Failed to generate walkthrough")}async function Sb(t,e){const n=await ds(`${Xo}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Ea(n,"Failed to cancel walkthrough generation")}async function vb(t,e,n){const r=await ds(`${Xo}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const jr={status:"idle",stage:null,result:null,readiness:null,error:null},jb=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:`pr:${t.number}`,Pn=(t,e)=>`${ps()}\0${t}\0${jb(e)}`,_l=t=>t instanceof Yo?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},nn=new Map,kr=new Map,kb=1e3,Cb=er()(fu((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Pn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Pn(n,r)],selectModel:(n,r,i)=>{const o=Pn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Pn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[Pn(n,r)]??jr,load:async(n,r,i={})=>{if(!n)return;const o=Pn(n,r);if(e().entries[o]?.status==="generating")return;nn.get(o)?.abort();const a=new AbortController;nn.set(o,a),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??jr,status:"loading",error:null}}}));try{const u=await yb(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:u.readiness??null,error:null}}})),u.generating&&e().generate(n,r,{language:i.language})}catch(u){if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??jr,status:"error",stage:null,error:_l(u)}}}))}finally{nn.get(o)===a&&nn.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Pn(n,r);nn.get(o)?.abort();const l=new AbortController;nn.set(o,l),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??jr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const u=kr.get(o);u!==void 0&&(clearInterval(u),kr.delete(o))};a(),kr.set(o,setInterval(()=>{vb(n,r).then(u=>{!u||l.signal.aborted||t(d=>{const h=d.entries[o];return!h||h.status!=="generating"||h.stage===u?d:{entries:{...d.entries,[o]:{...h,stage:u}}}})}).catch(()=>{})},kb));try{const u=await wb(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:d.entries[o]?.readiness??null,error:null}}}))}catch(u){if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??jr,status:"error",stage:null,error:_l(u)}}}))}finally{a(),nn.get(o)===l&&nn.delete(o)}},cancel:(n,r)=>{const i=Pn(n,r);Sb(n,r).catch(()=>{}),nn.get(i)?.abort(),nn.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of nn.values())n.abort();nn.clear();for(const n of kr.values())clearInterval(n);kr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Nb="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",Ab=3e4,Bl=20,Mu=(t,e)=>JSON.stringify([ps(),t,e]),Db=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},Ll=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),Zr=new Map,Pb=t=>{const e=Object.entries(t);return e.length<=Bl?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,Bl))},$l=er()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=Mu(r,i),a=o?.includeCheckDetails??!1,u=e().entries[l],d=u&&u.result&&Date.now()-u.fetchedAt<Ab&&(u.hasCheckDetails||!a);if(!o?.force&&d)return u.result;const h=`${l}::${a?"details":"plain"}`,p=Zr.get(`${l}::details`)??(a?null:Zr.get(h));if(p&&!o?.force)return p;const g=(async()=>{t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??Ll(),isLoading:!0,error:null}}}));try{const w=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(v=>({entries:Pb({...v.entries,[l]:{result:w,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),w}catch(w){const v=w instanceof Error?w.message:"Failed to load pull request context";return t(x=>({entries:{...x.entries,[l]:{...x.entries[l]??Ll(),isLoading:!1,error:v}}})),null}finally{Zr.delete(h)}})();return Zr.set(h,g),g},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const u=Db(l);u&&u.directory===n&&(r==null||u.number===r)||(o[l]=a)}return{entries:o}})}})),Ib=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},Tb=35e3,ii=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},ai=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},Wl=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},Rb=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},Eb=[2e3,5e3],Mb=600,zl=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Tn=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},Ob=(t,e)=>{const n=Tn(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},Fb=(t,e)=>`${t}::${e}`,Ma=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},li=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=Ma(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},_b=t=>t.startsWith("pr-"),Bb=(t,e)=>{const n=Ma(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!_b(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Cr=new Map,eo=Vo;function Lb(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const u=await e.repoUpstream(t);if(a||!u?.isFork||!u.upstream||(r(u.upstream),!e.repoBranches))return;try{const d=await e.repoBranches(u.upstream.owner,u.upstream.repo);a||o(d)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const $b=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=At(),u=De(ee=>ee.timeFormatPreference),{github:d}=wn(),h=An(ee=>ee.status),m=An(ee=>ee.hasChecked),p=De(ee=>ee.setSettingsDialogOpen),g=De(ee=>ee.setSettingsPage),w=Je(ee=>ee.currentSessionId),v=Je(ee=>!!ee.newSessionDraft?.open),{isMobile:x,hasTouchInput:f,screenWidth:b}=Bn(),y=De(ee=>ee.openContextSurface),S=Cb(ee=>ee.requestSource),N=!x&&b>=768&&!Dn(),C=c.useCallback(()=>{g("integrations"),p(!0)},[p,g]),j=c.useMemo(()=>Fb(t,e),[t,e]),A=c.useMemo(()=>Cr.get(j)??null,[j]),P=Ks(ee=>ee.ensureEntry),I=Ks(ee=>ee.setParams),M=Ks(ee=>ee.startWatching),z=Ks(ee=>ee.stopWatching),R=Ks(ee=>ee.refresh),H=Ks(ee=>ee.updateStatus),[F,O]=c.useState(()=>A?.title??zl(e)),[T,k]=c.useState(()=>A?.body??""),[D,L]=c.useState(()=>A?.draft??!1),[Q,q]=c.useState(()=>A?.additionalContext??""),[te,ae]=c.useState(()=>{const ee=typeof A?.targetBaseBranch=="string"?Tn(A.targetBaseBranch):"";return ee||Tn(n)}),[X,Z]=c.useState("squash"),[se,fe]=c.useState(!1),[B,ne]=c.useState(!1),[ye,ce]=c.useState(!1),[_,re]=c.useState(!1),[me,de]=c.useState(!1),[ge,Te]=c.useState(!1),[be,Re]=c.useState(null),[we,Y]=c.useState(""),[ve,xe]=c.useState(""),[je,oe]=c.useState(!1),[J,K]=c.useState(!1),[$,le]=c.useState(()=>li(i,{selectedRemoteName:A?.selectedRemoteName,trackingBranch:r})),[V,Ce]=c.useState(!1),{detectedUpstream:Be,upstreamBranches:ke}=Lb(t,d);c.useEffect(()=>{Ce(!1)},[t]);const Ne=i.some(ee=>ee.name==="upstream"),We=!!(t&&e&&n&&(e!==n||(Ne||Be!==null))),U=c.useMemo(()=>Ko(t,e,$?.name??null),[t,e,$?.name]),he=Ks(ee=>ee.entries[U]),Ee=he?.isLoading??!1,Ie=he?.status??null,rt=he?.error??null,Ge=he?.isInitialStatusResolved??!1,ut=c.useMemo(()=>{const ee=V?null:$?.name?.trim()||null,Ke=new Set;for(const nt of o){const jt=Ob(nt,ee);!jt||jt==="HEAD"||Ke.add(jt)}if(V)for(const nt of ke)nt&&nt!=="HEAD"&&Ke.add(nt);const W=Tn(n);W&&W!=="HEAD"&&Ke.add(W);const $e=Tn(te);return $e&&$e!=="HEAD"&&Ke.add($e),Array.from(Ke).sort((nt,jt)=>nt.localeCompare(jt))},[n,o,$?.name,te,ke,V]);c.useEffect(()=>{if(i.length===0){$&&le(null);return}(!$||!i.some(ee=>ee.name===$.name))&&le(li(i,{selectedRemoteName:A?.selectedRemoteName,trackingBranch:r}))},[A?.selectedRemoteName,i,$,r]),c.useEffect(()=>{const ee=Tn(n);if(!te&&ee){ae(ee);return}if(ut.length!==0&&!ut.includes(te)){const Ke=ut.includes(ee)?ee:ut[0];Ke&&ae(Ke)}},[ut,n,te]);const[ct,ue]=c.useState(()=>A?.activeSegment??"overview"),[G,Le]=c.useState(new Set),[Oe,qe]=c.useState(new Set),Ue=c.useRef(new Set),st=c.useRef(null),wt=c.useRef(!1),Nt=c.useRef(new Set),ie=c.useRef([]);c.useEffect(()=>{Be&&!Ne&&Ce(!0)},[Be,Ne]),c.useEffect(()=>{V&&Be?.defaultBranch&&ae(Be.defaultBranch)},[V,Be?.defaultBranch]);const pe=Ie?.pr??null,Ve=pe?.state==="merged"||pe?.state==="closed",ze=Ve?null:pe,He=ze?Mu(t,ze.number):null,ot=$l(ee=>He?ee.entries[He]:void 0),at=$l(ee=>ee.ensure),et=ot?.result??null,Xe=ot?.isLoading??!1,dt=c.useCallback(ee=>{ue(ee);const Ke=Cr.get(j);Ke&&Cr.set(j,{...Ke,activeSegment:ee})},[j]);c.useEffect(()=>{!ze||!d?.prContext||ct==="overview"||at(d,t,ze.number,{includeCheckDetails:ct==="checks",sourceRepo:Ie?.repo??null})},[ct,t,at,d,ze,Ie?.repo]);const Fe=Ie?.checks??null,Se=(Fe?.pending??0)>0,St=et?.checkRuns??null,vt=et?.fetchedAt;c.useEffect(()=>{if(!St||St.length===0)return;const ee=Ib(St);H(U,Ke=>{if(!Ke?.pr||typeof vt=="number"&&typeof Ke.fetchedAt=="number"&&vt<Ke.fetchedAt)return Ke;const W=Ke.checks;return W&&W.state===ee.state&&W.total===ee.total&&W.success===ee.success&&W.failure===ee.failure&&W.pending===ee.pending&&W.inProgress===ee.inProgress&&W.queued===ee.queued&&W.startedAt===ee.startedAt?Ke:{...Ke,checks:ee,...typeof vt=="number"?{fetchedAt:vt}:{}}})},[St,vt,U,H]),c.useEffect(()=>{if(ct!=="checks"||!Se||!pe||!d?.prContext)return;const ee=window.setInterval(()=>{at(d,t,pe.number,{includeCheckDetails:!0,sourceRepo:Ie?.repo??null,force:!0})},Tb);return()=>window.clearInterval(ee)},[ct,Se,t,at,d,pe,Ie?.repo]);const[Rt,Ze]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Se)return;Ze(Date.now());const ee=window.setInterval(()=>Ze(Date.now()),3e4);return()=>window.clearInterval(ee)},[Se]);const it=pe?`${t}#${pe.number}`:null,gt=!!(it&&be===it);c.useEffect(()=>{if(!d?.prContext||!pe||typeof pe.body=="string"&&pe.body.length>0)return;const ee=`${t}#${pe.number}`;if(Ue.current.has(ee))return;Ue.current.add(ee),Re(ee);let Ke=!1;return at(d,t,pe.number,{sourceRepo:Ie?.repo??null}).then(W=>{if(Ke)return;const $e=W?.pr;$e&&H(U,nt=>!nt?.pr||nt.pr.number!==pe.number?nt:{...nt,pr:{...nt.pr,body:$e.body||""}})}).catch(()=>{}).finally(()=>{Ke||Re(W=>W===ee?null:W)}),()=>{Ke=!0}},[t,at,d,pe,U,Ie?.repo,H]),c.useEffect(()=>{if(!pe){Te(!1),Y(""),xe(""),st.current=null;return}const ee=st.current!==null&&st.current!==pe.number;ee&&Te(!1),(!ge||ee)&&(Y(pe.title||""),xe(pe.body||"")),st.current=pe.number},[ge,pe]);const xt=c.useCallback(ee=>{if(!ee)return"";const Ke=Date.parse(ee);return Number.isFinite(Ke)?jd(Ke,u,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):ee},[u]),Et=c.useMemo(()=>{const ee=h?.user?.login;return typeof ee=="string"?ee.trim():""},[h]),kt=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),Tt=c.useCallback(ee=>{const Ke=Et.toLowerCase(),W=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return ee.replace(W,($e,nt,jt)=>{const Ct=`@${jt}`,Bt=jt.toLowerCase();return`${nt}[${Ct}](https://github.com/${Bt}${Ke&&Bt===Ke?"?oc-self-mention=1":""})`})},[Et]),Ot=c.useMemo(()=>{const ee=(et?.issueComments??[]).map($e=>({id:`issue-${$e.id}`,body:$e.body||"",authorName:$e.author?.name||$e.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:$e.author?.login||null,avatarUrl:$e.author?.avatarUrl||null,createdAt:$e.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),Ke=(et?.reviewComments??[]).map($e=>({id:`review-${$e.id}`,body:$e.body||"",authorName:$e.author?.name||$e.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:$e.author?.login||null,avatarUrl:$e.author?.avatarUrl||null,createdAt:$e.createdAt,context:a("gitView.pr.comments.reviewContext"),path:$e.path||null,line:$e.line??null})),W=[...ee,...Ke];return W.sort(($e,nt)=>{const jt=$e.createdAt?Date.parse($e.createdAt):0,Ct=nt.createdAt?Date.parse(nt.createdAt):0,Bt=Number.isFinite(jt)?jt:0,os=Number.isFinite(Ct)?Ct:0;return Bt-os}),W},[et,a]),Vt=c.useCallback(()=>{const ee=w??(v?"draft":null);return ee?{directory:t,sessionKey:ee}:(Me.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[w,t,v,a]),Yt=c.useCallback((ee,Ke)=>{const W=Ke.authorLogin?`@${Ke.authorLogin}`:Ke.authorName,$e=Ke.path?` · ${Ke.path}${Ke.line?`:${Ke.line}`:""}`:"";ji.getState().addDraft(ee,{source:"pr-comment",fileLabel:`PR #${pe?.number??""} ${W}${$e}`,startLine:Ke.line??0,endLine:Ke.line??0,code:Ke.body,language:"markdown",text:""})},[pe?.number]),Ht=c.useCallback((ee,Ke)=>{const W=ee.status||"unknown",$e=ee.conclusion??void 0,nt=$e?`${W} / ${$e}`:W,jt=ee.app?.name||ee.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:Ke?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[Ke?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:ee.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:jt?`${jt} · ${nt}`:nt})]}),ee.detailsUrl?s.jsx(pt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:ee.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),ee.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:ee.output.title}):null,ee.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:ee.output.summary}):null,ee.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:ee.output.text}):null,Array.isArray(ee.annotations)&&ee.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",ee.annotations.length>20?` (showing 20/${ee.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:ee.annotations.slice(0,20).map((Ct,Bt)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[Ct.title||Ct.level||"Issue",Ct.path?` · ${Ct.path}`:"",typeof Ct.startLine=="number"?`:${Ct.startLine}`:"",typeof Ct.endLine=="number"&&Ct.endLine!==Ct.startLine?`-${Ct.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:Ct.message}),Ct.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:Ct.rawDetails}):null]},`${Ct.path||"file"}:${Ct.startLine||Bt}:${Bt}`))})]}):null,ee.job?.steps&&ee.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:ee.job.steps.map((Ct,Bt)=>{const os=(Ct.conclusion||"").toLowerCase(),qt=os&&!["success","neutral","skipped"].includes(os),en=`${ee.id??"run"}:${ee.job?.jobId??"job"}:${Ct.number??Bt}:${Ct.name}`,Sn=G.has(en);return qt?s.jsxs(Ri,{open:Sn,children:[s.jsxs("button",{type:"button",onClick:()=>{Le(Zo=>{const tr=new Set(Zo);return tr.has(en)?tr.delete(en):tr.add(en),tr})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(qt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Sn?s.jsx(E,{name:"arrow-down-s",className:"size-4"}):s.jsx(E,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:Ct.name}),Ct.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Ct.conclusion}):null]}),s.jsx(Ei,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof Ct.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",Ct.number]}):null,Ct.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",Ct.status]}):null,Ct.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",Ct.conclusion]}):null,Ct.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",xt(Ct.startedAt)]}):null,Ct.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",xt(Ct.completedAt)]}):null]})})]},en):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:Ct.name}),Ct.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Ct.conclusion}):null]},en)})})]}):null]})},[G,xt,a]),[Lt,zt]=c.useState(!1),[_e,Ye]=c.useState(!1),ft=c.useCallback(async()=>{if(!d?.prContext){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!pe)return;const ee=Vt();if(ee){zt(!0);try{const Ke=await at(d,t,pe.number,{includeCheckDetails:!0,sourceRepo:Ie?.repo??null});if(!Ke){Me.error(a("gitView.pr.toast.loadChecksFailed"));return}const $e=(Ke.checkRuns??[]).filter(jt=>ai(jt.conclusion));if($e.length===0){Me.message(a("gitView.pr.toast.noFailedChecks"));return}const nt=ji.getState();for(const jt of $e){const Ct=(jt.annotations??[]).map(qt=>[[qt.level,qt.title].filter(Boolean).join(" "),qt.path?`${qt.path}${typeof qt.startLine=="number"?`:${qt.startLine}`:""}`:null,qt.message,qt.rawDetails].filter(Boolean).join(`
|
|
37
|
+
`)),Bt=(jt.job?.steps??[]).filter(qt=>ai(qt.conclusion)).map(qt=>`step ${qt.number??"?"}: ${qt.name} → ${qt.conclusion}`),os=[`check: ${jt.job?.workflowName?`${jt.job.workflowName} / ${jt.name}`:jt.name}`,`status: ${jt.status??"unknown"} / ${jt.conclusion??"unknown"}`,jt.detailsUrl?`url: ${jt.detailsUrl}`:null,jt.output?.title?`title: ${jt.output.title}`:null,jt.output?.summary?`summary:
|
|
38
|
+
${jt.output.summary}`:null,Bt.length>0?`failed steps:
|
|
39
|
+
${Bt.join(`
|
|
40
|
+
`)}`:null,Ct.length>0?`annotations:
|
|
41
|
+
${Ct.join(`
|
|
42
|
+
---
|
|
43
|
+
`)}`:null].filter(Boolean).join(`
|
|
44
|
+
|
|
45
|
+
`);nt.addDraft(ee,{source:"pr-check",fileLabel:`PR #${pe.number} · ${jt.name}`,startLine:0,endLine:0,code:os,language:"text",text:""})}}catch(Ke){const W=Ke instanceof Error?Ke.message:String(Ke);Me.error(a("gitView.pr.toast.loadChecksFailed"),{description:W})}finally{zt(!1)}}},[t,at,d,pe,Vt,Ie?.repo,a]),bt=c.useCallback(async()=>{if(!d?.prContext){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!pe)return;const ee=Vt();if(ee){Ye(!0);try{if(!await at(d,t,pe.number,{sourceRepo:Ie?.repo??null})){Me.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(Ot.length===0){Me.message(a("gitView.pr.toast.noPrComments"));return}for(const W of Ot)Yt(ee,W)}catch(Ke){const W=Ke instanceof Error?Ke.message:String(Ke);Me.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:W})}finally{Ye(!1)}}},[Yt,t,at,d,pe,Vt,Ie?.repo,a,Ot]),mt=c.useCallback(async ee=>{const Ke=Vt();Ke&&Yt(Ke,ee)},[Yt,Vt]),lt=c.useCallback(async ee=>{await R(U,ee)},[U,R]),[$t,Zt]=c.useState(!1),Xt=c.useRef(!0);c.useEffect(()=>(Xt.current=!0,()=>{Xt.current=!1}),[]);const Ns=c.useCallback(async()=>{if($t)return;Zt(!0);const ee=Date.now();try{await lt({force:!0})}finally{const Ke=Mb-(Date.now()-ee);Ke>0&&await new Promise(W=>window.setTimeout(W,Ke)),Xt.current&&Zt(!1)}},[$t,lt]),Jt=c.useCallback(()=>{ie.current.forEach(ee=>{window.clearTimeout(ee)}),ie.current=Eb.map(ee=>window.setTimeout(()=>{lt({force:!0,silent:!0,markInitialResolved:!0})},ee))},[lt]);c.useEffect(()=>{if(!d?.prStatus||!We||i.length<=1||wt.current||Ie?.pr)return;const ee=`${j}::${$?.name??""}`;if(Nt.current.has(ee))return;Nt.current.add(ee);const Ke=Bb(i,r).filter(nt=>nt.name!==$?.name);if(Ke.length===0)return;let W=!1;return(async()=>{for(const nt of Ke){if(W)return;try{if(!(await d.prStatus(t,e,nt.name))?.pr)continue;if(W)return;le(Ct=>Ct?.name===nt.name?Ct:nt);return}catch{}}})(),()=>{W=!0}},[e,We,t,d,i,$?.name,j,Ie?.pr,r]),c.useEffect(()=>{P(U),I(U,{directory:t,branch:e,remoteName:$?.name??null,canShow:We,github:d,githubAuthChecked:m,githubConnected:h?.connected??null})},[e,We,t,P,d,m,h?.connected,U,$?.name,I]),c.useEffect(()=>(M(U),()=>{z(U)}),[U,M,z]),c.useEffect(()=>{const ee=Cr.get(j)??null;O(ee?.title??zl(e)),k(ee?.body??""),L(ee?.draft??!1),ae(ee?.targetBaseBranch?Tn(ee.targetBaseBranch):Tn(n));const Ke=li(i,{selectedRemoteName:ee?.selectedRemoteName,trackingBranch:r});le(W=>W?.name===Ke?.name?W:Ke)},[n,e,i,j,r]),c.useEffect(()=>{lt({markInitialResolved:!0})},[U,lt]),c.useEffect(()=>{!We||!$?.name||lt({force:!0,silent:!0,markInitialResolved:!0})},[We,lt,$?.name]),c.useEffect(()=>{const ee=Ie?.resolvedRemoteName?.trim();if(!ee||wt.current)return;const Ke=i.find(W=>W.name===ee);Ke&&le(W=>W?.name===Ke.name?W:Ke)},[i,Ie?.resolvedRemoteName]),c.useEffect(()=>{const ee=()=>{const W=Ks.getState().entries[U]?.lastRefreshAt??0;Date.now()-W>6e4&<({force:!0,silent:!0})},Ke=()=>{document.visibilityState==="visible"&&ee()};return window.addEventListener("focus",ee),document.addEventListener("visibilitychange",Ke),()=>{window.removeEventListener("focus",ee),document.removeEventListener("visibilitychange",Ke)}},[U,lt]),c.useEffect(()=>{m&&h?.connected===!1&<({force:!0,silent:!0,markInitialResolved:!0})},[m,h,lt]),c.useEffect(()=>{!t||!e||Cr.set(j,{title:F,body:T,draft:D,additionalContext:Q,targetBaseBranch:te,selectedRemoteName:$?.name,activeSegment:ct})},[j,F,T,D,Q,te,$?.name,t,e,ct]),c.useEffect(()=>{const ee=ie.current;return()=>{ee.forEach(Ke=>{window.clearTimeout(Ke)}),ie.current=[]}},[]);const zs=c.useCallback(async()=>{if(!se&&t){fe(!0);try{const Ke={base:V&&Be?.defaultBranchSha?Be.defaultBranchSha:te,head:e};Q&&(Ke.context=Q);const W=await _m(t,Ke);W.title?.trim()&&O(W.title.trim()),W.body?.trim()&&k(W.body.trim()),l?.()}catch(ee){const Ke=ee instanceof Error?ee.message:String(ee);Me.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:Ke})}finally{fe(!1)}}},[Q,e,Be?.defaultBranchSha,t,se,l,te,a,V]),Js=c.useCallback(async()=>{if(!d?.prCreate){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}const ee=F.trim();if(!ee){Me.error(a("gitView.pr.toast.titleRequired"));return}const Ke=te.trim();if(!Ke){Me.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!V&&Ke===e){Me.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}ne(!0);try{const W=Ma(r),$e=V&&Be,nt=await d.prCreate({directory:t,title:ee,head:e,base:Ke,...T.trim()?{body:T}:{},draft:D,...$e?{targetRepo:{owner:Be.owner,repo:Be.repo},headRemote:"origin"}:{...$?{remote:$.name}:{},...W&&W!==$?.name?{headRemote:W}:{}}});Me.success(a("gitView.pr.toast.prCreated")),H(U,jt=>jt&&{...jt,pr:nt}),await lt({force:!0}),Jt()}catch(W){const $e=W instanceof Error?W.message:String(W);Me.error(a("gitView.pr.toast.createPrFailed"),{description:$e})}finally{ne(!1)}},[T,e,Be,t,D,d,U,lt,Jt,$,te,F,r,H,V,a]),rs=c.useCallback(async ee=>{if(!d?.prMerge){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}re(!0);try{const Ke=await d.prMerge({directory:t,number:ee.number,method:X});Ke.merged?Me.success(a("gitView.pr.toast.prMerged")):Me.message(a("gitView.pr.toast.prNotMerged"),{description:Ke.message||a("gitView.pr.notMergeable")}),await lt({force:!0}),Jt()}catch(Ke){const W=Ke instanceof Error?Ke.message:String(Ke);Me.error(a("gitView.pr.toast.mergeFailed"),{description:W}),ee.url&&eo(ee.url)}finally{re(!1)}},[t,d,X,lt,Jt,a]),Vs=c.useCallback(async ee=>{if(!d?.prReady){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}de(!0);try{await d.prReady({directory:t,number:ee.number}),Me.success(a("gitView.pr.toast.markedReady")),await lt({force:!0}),Jt()}catch(Ke){const W=Ke instanceof Error?Ke.message:String(Ke);Me.error(a("gitView.pr.toast.markReadyFailed"),{description:W}),ee.url&&eo(ee.url)}finally{de(!1)}},[t,d,lt,Jt,a]),Rs=c.useCallback(async ee=>{if(!d?.prUpdate){Me.error(a("gitView.pr.toast.githubApiUnavailable"));return}const Ke=we.trim();if(!Ke){Me.error(a("gitView.pr.toast.titleRequired"));return}ce(!0);try{const W=await d.prUpdate({directory:t,number:ee.number,title:Ke,body:ve});H(U,$e=>$e&&{...$e,pr:{...$e.pr??ee,...W}}),Te(!1),Me.success(a("gitView.pr.toast.prUpdated")),await lt({force:!0}),Jt()}catch(W){const $e=W instanceof Error?W.message:String(W);Me.error(a("gitView.pr.toast.updatePrFailed"),{description:$e})}finally{ce(!1)}},[t,ve,we,d,U,lt,Jt,H,a]);if(!We)return s.jsx("section",{className:"border-0 bg-transparent rounded-none",children:s.jsxs("div",{className:"space-y-1 pt-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),s.jsx(Fl,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const cn=Ie?.repo?.url||null,gs=V&&Be?.url?Be.url:cn,vs=!!Ie?.canMerge,Zs=!!Ie?.connected,Es=m&&Ie?.connected===!1,As=Rb(Ie),Ds=As?`var(--pr-${As})`:"var(--status-info)",js=As==="draft"?"git-pr-draft":As==="merged"?"git-merge":As==="closed"?"git-close-pull-request":"git-pull-request",Ft=pe?[`${pe.state}${pe.draft?" (draft)":""}`,pe.mergeable===!1?a("gitView.pr.notMergeable"):null,pe.state==="open"&&typeof pe.mergeableState=="string"&&pe.mergeableState&&pe.mergeableState!=="unknown"?pe.mergeableState:null].filter(Boolean).join(" · "):"",Wt=Fe?Fe.total>0?`${Fe.success}/${Fe.total} ${a("gitView.pr.checks.label")}`:`${Fe.state} ${a("gitView.pr.checks.label")}`:"";return s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[s.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex flex-col gap-1",children:[s.jsxs("div",{className:"@container/pr-actions flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[pe?s.jsxs(pt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{eo(pe.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(E,{name:js,className:"size-4 shrink-0",style:{color:Ds}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(E,{name:js,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.pullRequest.title")}),pe?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",pe.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[pe&&N?s.jsxs(pt,{variant:"outline",size:"sm",className:Pe("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Nb),onClick:()=>{S(t,{kind:"pr",number:pe.number}),y(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(E,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(pt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Ee||$t,onClick:()=>{Ns()},"aria-label":a("gitView.pr.actions.refreshAria"),children:Ee||$t?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(E,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx(Fl,{className:"h-7 w-7"})]})]}),pe?s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:Ds},children:Ft}),Fe?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${Wl(Fe.state)}`}),Wt]}):null,r&&$&&r.split("/")[0]!==$.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",$.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[vs&&pe.draft&&pe.state==="open"?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(pt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Vs(pe),disabled:me||_||ye||ge,"aria-label":a("gitView.pr.actions.markReadyAria"),children:me?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,vs?s.jsxs(s.Fragment,{children:[s.jsxs(Fs,{value:X,onValueChange:ee=>Z(ee),disabled:_||pe.state!=="open",children:[s.jsx(_s,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(Cs,{})}),s.jsxs(Bs,{children:[s.jsx(ss,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(ss,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(ss,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(pt,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>rs(pe),disabled:_||me||pe.state!=="open"||pe.draft||ye||ge,"aria-label":a("gitView.pr.actions.mergePrAria"),children:_?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"git-merge",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[Es?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(pt,{variant:"outline",size:"sm",onClick:C,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,rt?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:rt}),gs?s.jsx(pt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:gs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!pe&&!Ge&&!rt&&!Es?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):pe&&!Ve?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(Jd,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Fe&&Fe.total>0?`${a("gitView.pr.segment.checks")} ${Fe.success}/${Fe.total}`:a("gitView.pr.segment.checks"),icon:Fe?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Wl(Fe.state)}`}):void 0},{id:"comments",label:et?`${a("gitView.pr.segment.comments")} ${(et.issueComments?.length??0)+(et.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:ct,onSelect:ee=>dt(ee),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),ct==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[vs&&pe.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,vs?null:s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.noMergePermission")}),s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:ge?s.jsx(Cn,{value:we,onChange:ee=>Y(ee.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:pe.title})}),pe.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:ge?s.jsxs(s.Fragment,{children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(pt,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Te(!1),Y(pe.title||""),xe(pe.body||"")},disabled:ye,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(E,{name:"close",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(pt,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>Rs(pe),disabled:ye||!we.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:ye?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"check",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(pt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Te(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(E,{name:"edit",className:"size-4"})})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),ge?s.jsx(ar,{value:ve,onChange:ee=>xe(ee.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f}):null,ge?null:pe.body?.trim()?s.jsx(el,{content:pe.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words",enableFileReferences:!1}):s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:a(gt?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,ct==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Fe&&Fe.total>0?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted/40",children:[Fe.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Fe.success/Fe.total*100}%`}}):null,Fe.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Fe.failure/Fe.total*100}%`}}):null,Fe.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Fe.pending/Fe.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Fe.success,"/",Fe.total," ",a("gitView.pr.checks.label")]}),(Fe.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}),ii(Fe.startedAt,void 0,Rt)]}):null]}):null,Fe?.failure?s.jsxs(pt,{variant:"outline",size:"sm",className:"w-fit gap-1.5 border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",onClick:ft,disabled:Lt,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[Lt?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(et?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(et?.checkRuns??[]).map((ee,Ke)=>{const W=`${ee.id??"run"}:${ee.name}:${Ke}`,$e=ee.status==="in_progress",nt=ee.status==="queued",jt=ai(ee.conclusion),Ct=Oe.has(W),Bt=!!(ee.output?.title||ee.output?.summary||ee.output?.text||(ee.annotations?.length??0)>0||(ee.job?.steps?.length??0)>0||ee.detailsUrl),os=ee.job?.workflowName,qt=$e?ii(ee.startedAt,void 0,Rt):ii(ee.startedAt,ee.completedAt);return s.jsxs("div",{className:Pe("rounded-md border border-border/40",jt&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!Bt,onClick:()=>{qe(en=>{const Sn=new Set(en);return Sn.has(W)?Sn.delete(W):Sn.add(W),Sn})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[$e?s.jsx(E,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):nt?s.jsx(E,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):jt?s.jsx(E,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(E,{name:"checkbox-circle",className:"size-4 shrink-0 text-[var(--status-success)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:os&&os!==ee.name?`${os} / ${ee.name}`:ee.name}),qt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:qt}):null,Bt?s.jsx(E,{name:"arrow-down-s",className:Pe("size-4 shrink-0 text-muted-foreground transition-transform",Ct&&"rotate-180")}):null]}),Ct&&Bt?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Ht(ee,{hideHeader:!0})}):null]},W)})}):Xe?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.checkDetails.empty")})]}):null,ct==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Ot.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(pt,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)]",onClick:bt,disabled:_e,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[_e?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,Ot.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:Ot.map((ee,Ke)=>{const W=(ee.authorName||"?").charAt(0).toUpperCase(),$e=Ke===Ot.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[$e?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:ee.avatarUrl?s.jsx("img",{src:ee.avatarUrl,alt:ee.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:W})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1 typography-micro text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-1 sm:gap-y-1",children:[s.jsxs("span",{className:"text-foreground whitespace-nowrap",children:[ee.authorName,ee.authorLogin&&ee.authorLogin!==ee.authorName?` · @${ee.authorLogin}`:""]}),ee.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:xt(ee.createdAt)}):null,s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs(pt,{variant:"ghost",size:"sm",className:"h-6 px-0 has-[>svg]:px-0 sm:px-2 sm:has-[>svg]:px-2.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)] justify-start",onClick:()=>{mt(ee)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(E,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(It,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[ee.context,ee.path?` · ${ee.path}`:"",ee.line?`:${ee.line}`:""]}),s.jsx(el,{content:Tt(ee.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",kt].filter(Boolean).join(" "),enableFileReferences:!1})]})]},ee.id)})})}):Xe&&!et?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.comments.empty")})]}):null]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[pe&&Ve?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border/60 bg-surface-muted/40 px-2.5 py-2",children:[s.jsx(E,{name:pe.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Ds}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:pe.state==="merged"?a("gitView.pr.history.merged",{number:pe.number,base:pe.base||te}):a("gitView.pr.history.closed",{number:pe.number})}),s.jsx(pt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{eo(pe.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(E,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",te," ",s.jsxs("span",{className:"opacity-60",children:["(",V&&Be?"upstream":"remote",")"]})]})]}),gs?s.jsx(pt,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:gs,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{name:"external-link",className:"size-4"}),a("gitView.pr.actions.repo")]})}):null]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.title")}),s.jsx(Cn,{value:F,onChange:ee=>O(ee.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),ut.length>0?s.jsxs(Fs,{value:te,onValueChange:ae,children:[s.jsx(_s,{size:"lg",children:s.jsx(Cs,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(Bs,{children:ut.map(ee=>s.jsx(ss,{value:ee,children:ee},ee))})]}):s.jsx(Cn,{value:te,onChange:ee=>ae(ee.target.value),placeholder:a("gitView.pr.placeholder.main")})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.description")}),s.jsx(ar,{value:T,onChange:ee=>k(ee.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":D,onClick:()=>L(ee=>!ee),onKeyDown:ee=>{(ee.key===" "||ee.key==="Enter")&&(ee.preventDefault(),L(Ke=>!Ke))},children:[s.jsx(dr,{size:"sm",checked:D,onChange:ee=>L(ee),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),x?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx(pt,{variant:"outline",size:"sm",onClick:()=>K(!0),children:Q.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),Q.trim()&&s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--interactive-selection)] px-2 py-0.5 text-xs text-[var(--interactive-selection-foreground)]",children:a("gitView.pr.additionalContext.added")})})]}):s.jsxs(Ri,{open:je,onOpenChange:oe,children:[s.jsxs(Zd,{className:"flex w-full items-center justify-between rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-2 hover:bg-[var(--interactive-hover)]",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:je?a("gitView.pr.actions.hide"):Q.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(Ei,{children:s.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[s.jsx(ar,{value:Q,onChange:ee=>q(ee.target.value),className:"min-h-[100px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext")}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})})]}),s.jsx(Ho,{open:J,onClose:()=>K(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(pt,{size:"sm",onClick:()=>K(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(ar,{value:Q,onChange:ee=>q(ee.target.value),className:"min-h-[200px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(pt,{variant:"outline",size:"sm",onClick:zs,disabled:se||B,children:[se?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(pt,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:Js,disabled:B||!Zs||!te.trim()||!V&&te.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:B?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},ci=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),to=new Map,so=new Map,In=t=>`${ps()}::${t}`,Wb=()=>{const t=tt.c(115),{t:e}=At(),{git:n}=wn(),r=br(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=Bm(r??null),a=ba(o??null),u=kd(o??null),d=Cd(o??null),{ensureAll:h,ensureNestedRepos:m,selectNestedRepo:p}=On(Jn(zb)),g=Je(Vb),w=Je(Ub),v=Je(Kb),x=Je(Hb);let f;t[0]!==r?(f=ci(r),t[0]=r,t[1]=f):f=t[1];const b=f;let y;if(t[2]!==x||t[3]!==b||t[4]!==v){e:{if(!b){y=void 0;break e}let $;if(t[6]!==x||t[7]!==b){let V;t[9]!==b?(V=Ce=>ci(Ce.path)===b,t[9]=b,t[10]=V):V=t[10],$=x.find(V),t[6]=x,t[7]=b,t[8]=$}else $=t[8];const le=$;if(le){y=le;break e}for(const V of v.values())if(ci(V.path)===b){y=V;break e}y=void 0}t[2]=x,t[3]=b,t[4]=v,t[5]=y}else y=t[5];const S=y;let N;t[11]!==g||t[12]!==S||t[13]!==w?.open||t[14]!==v?(N=()=>{if(g)return v.get(g)??S;if(w?.open)return S},t[11]=g,t[12]=S,t[13]=w?.open,t[14]=v,t[15]=N):N=t[15],w?.open;let C;t[16]!==N?(C=N(),t[16]=N,t[17]=C):C=t[17];const j=C;let A;t[18]!==g?(A=$=>g?$.getAttachment(g):void 0,t[18]=g,t[19]=A):A=t[19];const P=wd(A),I=P&&!P.degraded&&!P.legacy?P.worktreeRoot??void 0:void 0,M=pb(r,j,a?.current??void 0);let z,R;t[20]!==h||t[21]!==n||t[22]!==o?(z=()=>{!o||!n||h(o,n)},R=[o,h,n],t[20]=h,t[21]=n,t[22]=o,t[23]=z,t[24]=R):(z=t[23],R=t[24]),c.useEffect(z,R);const[H,F]=c.useState(null);let O;t[25]!==I||t[26]!==M?.projectDirectory?(O=()=>{const $=I||M?.projectDirectory;if(!$){F(null);return}let le=!1;return Go($).then(V=>{if(le)return;const Ce=V.trim();F(Ce&&Ce!=="HEAD"?Ce:null)}).catch(()=>{le||F(null)}),()=>{le=!0}},t[25]=I,t[26]=M?.projectDirectory,t[27]=O):O=t[27];const T=M?.projectDirectory;let k;t[28]!==I||t[29]!==T?(k=[I,T],t[28]=I,t[29]=T,t[30]=k):k=t[30],c.useEffect(O,k);let D;t[31]!==o?(D=()=>(o?to.get(In(o)):void 0)??[],t[31]=o,t[32]=D):D=t[32];const[L,Q]=c.useState(D);let q;t[33]!==o?(q=()=>(o?so.get(In(o)):void 0)??null,t[33]=o,t[34]=q):q=t[34];const[te,ae]=c.useState(q);let X,Z;t[35]!==n||t[36]!==o?(X=()=>{if(!o||!n?.getRemotes){Q([]);return}Q(to.get(In(o))??[]);let $=!1;return n.getRemotes(o).then(le=>{$||(to.set(In(o),le??[]),Q(le??[]))}).catch(()=>{$||Q(to.get(In(o))??[])}),()=>{$=!0}},Z=[o,n],t[35]=n,t[36]=o,t[37]=X,t[38]=Z):(X=t[37],Z=t[38]),c.useEffect(X,Z);let se,fe;t[39]!==n||t[40]!==o?(se=()=>{if(!o||!n?.getRemoteUrl){ae(null);return}ae(so.get(In(o))??null);let $=!1;return n.getRemoteUrl(o).then(le=>{$||(so.set(In(o),le),ae(le))}).catch(()=>{$||ae(so.get(In(o))??null)}),()=>{$=!0}},fe=[o,n],t[39]=n,t[40]=o,t[41]=se,t[42]=fe):(se=t[41],fe=t[42]),c.useEffect(se,fe);let B;e:{if(!u?.all){let le;t[43]===Symbol.for("react.memo_cache_sentinel")?(le=[],t[43]=le):le=t[43],B=le;break e}let $;t[44]!==u.all?($=u.all.filter(Gb).sort(),t[44]=u.all,t[45]=$):$=t[45],B=$}const ne=B;let ye;e:{if(!u?.all){let le;t[46]===Symbol.for("react.memo_cache_sentinel")?(le=[],t[46]=le):le=t[46],ye=le;break e}let $;t[47]!==u.all?($=u.all.filter(qb).map(Qb).sort(),t[47]=u.all,t[48]=$):$=t[48],ye=$}const ce=ye;let _;t[49]!==ce||t[50]!==te||t[51]!==L||t[52]!==a?.tracking?(_=()=>{if(L.length>0)return L;const $=new Set,le=a?.tracking?.trim();le&&le.includes("/")&&$.add(le.split("/")[0]);for(const V of ce){const Ce=V.indexOf("/");Ce>0&&$.add(V.slice(0,Ce))}return $.size===0&&te&&$.add("origin"),Array.from($).map(V=>({name:V,fetchUrl:te??"",pushUrl:te??""}))},t[49]=ce,t[50]=te,t[51]=L,t[52]=a?.tracking,t[53]=_):_=t[53],a?.tracking;let re;t[54]!==_?(re=_(),t[54]=_,t[55]=re):re=t[55];const me=re,de=a?.current??null;a?.tracking;let ge;t[56]!==a?.tracking?(ge=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=ge):ge=t[57];const Te=ge,be=(Te&&u?.defaultBranches?.[Te])??u?.defaultBranches?.origin;let Re;t[58]!==de||t[59]!==be||t[60]!==me||t[61]!==ne||t[62]!==H||t[63]!==M?.createdFromBranch?(Re=()=>Jp({remoteNames:new Set(me.map(Yb)),localBranches:ne,worktreeCreatedFromBranch:M?.createdFromBranch,rootBranchHint:H,defaultBranch:be,headBranch:de}),t[58]=de,t[59]=be,t[60]=me,t[61]=ne,t[62]=H,t[63]=M?.createdFromBranch,t[64]=Re):Re=t[64],M?.createdFromBranch;let we;t[65]!==Re?(we=Re(),t[65]=Re,t[66]=we):we=t[66];const Y=we;if(!r){let $;t[67]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(E,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=$):$=t[67];let le;t[68]!==e?(le=e("gitView.pullRequest.title"),t[68]=e,t[69]=le):le=t[69];let V;t[70]!==le?(V=s.jsx("div",{className:"typography-ui-header text-foreground",children:le}),t[70]=le,t[71]=V):V=t[71];let Ce;t[72]!==e?(Ce=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=Ce):Ce=t[73];let Be;t[74]!==Ce?(Be=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ce}),t[74]=Ce,t[75]=Be):Be=t[75];let ke;return t[76]!==V||t[77]!==Be?(ke=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[$,V,Be]}),t[76]=V,t[77]=Be,t[78]=ke):ke=t[78],ke}if(i===!1&&d!==!0){let $;t[79]!==r||t[80]!==m?($=()=>{m(r,{force:!0})},t[79]=r,t[80]=m,t[81]=$):$=t[81];let le;return t[82]!==d||t[83]!==l||t[84]!==i||t[85]!==$?(le=s.jsx(Zp,{rootIsGitRepo:i,resolvedIsGitRepo:d,nestedRepos:l,onRetryDiscovery:$}),t[82]=d,t[83]=l,t[84]=i,t[85]=$,t[86]=le):le=t[86],le}if(!de){let $;t[87]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(E,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=$):$=t[87];let le;t[88]!==e?(le=e("gitView.pullRequest.title"),t[88]=e,t[89]=le):le=t[89];let V;t[90]!==le?(V=s.jsx("div",{className:"typography-ui-header text-foreground",children:le}),t[90]=le,t[91]=V):V=t[91];let Ce;t[92]!==e?(Ce=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=Ce):Ce=t[93];let Be;t[94]!==Ce?(Be=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ce}),t[94]=Ce,t[95]=Be):Be=t[95];let ke;return t[96]!==V||t[97]!==Be?(ke=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[$,V,Be]}),t[96]=V,t[97]=Be,t[98]=ke):ke=t[98],ke}const ve=i===!1&&Array.isArray(l)&&l.length>0;let xe;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==p||t[103]!==ve?(xe=ve?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(eg,{repositories:l,selectedRepository:o??null,onSelectRepository:$=>{r&&p(r,$)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=p,t[103]=ve,t[104]=xe):xe=t[104];const je=o??r,oe=a?.tracking??void 0;let J;t[105]!==Y||t[106]!==de||t[107]!==ce||t[108]!==L||t[109]!==je||t[110]!==oe?(J=s.jsx(ln,{as:ya,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx($b,{directory:je,branch:de,baseBranch:Y,trackingBranch:oe,remotes:L,remoteBranches:ce})}),t[105]=Y,t[106]=de,t[107]=ce,t[108]=L,t[109]=je,t[110]=oe,t[111]=J):J=t[111];let K;return t[112]!==xe||t[113]!==J?(K=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[xe,J]}),t[112]=xe,t[113]=J,t[114]=K):K=t[114],K};function zb(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function Vb(t){return t.currentSessionId}function Ub(t){return t.newSessionDraft}function Kb(t){return t.worktreeMetadata}function Hb(t){return t.availableWorktrees}function Gb(t){return!t.startsWith("remotes/")}function qb(t){return t.startsWith("remotes/")}function Qb(t){return t.replace(/^remotes\//,"")}function Yb(t){return t.name}const Ki=2e4,Xb=(t,e)=>{if(!t)return 1;let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(n+=1,n>e))return n;return n},no=(t,e)=>Vm(Um.getState().dictionary,t,e),Jb=t=>{const n=(t instanceof Error?t.message:String(t??"")).toLowerCase();return n.includes("file not found")||n.includes("not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")?"missing":"unreadable"},Zb=async(t,e,n)=>{if(t.readFile)return(await t.readFile(e,{optional:!0,directory:n?.directory})).content??"";const r=new URLSearchParams({path:e,optional:"true"});n?.directory&&r.set("directory",n.directory);const i=await ds(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!i.ok){const o=await i.json().catch(()=>({error:i.statusText}));throw new Error(o.error||"Failed to read file")}return i.text()},Ou=async(t,e,n)=>{if(Lm(e)||$m(e)||Wm(e))return{ok:!0};try{const r=await Zb(t,e,n);return zm(r)?{ok:!1,reason:"binary"}:Xb(r,Ki)>Ki?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:Jb(r)}}},Fu=t=>{if(t==="too-large"){const e=Ki.toLocaleString(pa());return no("contextFileOpen.failure.tooLarge",{count:e})}return no(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},Vl=8;let Hi=null;const _u=t=>{Hi={x:t.clientX,y:t.clientY}},Bu=t=>{const e=Hi;return Hi=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=Vl&&Math.abs(t.clientY-e.y)<=Vl},Ul=3,fr=t=>Array.from(t.types).includes("Files"),ey=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},Kl=t=>{const e=t.name;return!e||e==="."||e===".."||e.includes("/")||e.includes("\\")?null:e},ty=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),as=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Oa=(t,e)=>{const n=as(e),r=as(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},sy=(t,e)=>{const n=Oa(t,e);if(n!==".")return n;const r=as(t);return r.split("/").filter(Boolean).pop()??r},ny=t=>{const e=as(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},ry=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),oy=new Set(["node_modules"]),iy=t=>oy.has(t),ay=t=>{const e=as(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},ly=8,hn=new Map,Fa=t=>JSON.stringify([ps(),t]),cy=t=>{const e=Fa(t),n=hn.get(e);return n?(n.touchedAt=Date.now(),hn.delete(e),hn.set(e,n),n):null},di=t=>{const e=Fa(t),n=hn.get(e);if(n)return n.touchedAt=Date.now(),n;if(hn.size>=ly){const i=hn.keys().next().value;i!==void 0&&hn.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return hn.set(e,r),r},dy=t=>{hn.delete(Fa(t))},Lu=(t,e)=>s.jsx(wa,{filePath:t,extension:e}),uy=t=>{const e=tt.c(3),{status:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={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]=r):r=e[0];const i=r[n];let o;return e[1]!==i?(o=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i}}),e[1]=i,e[2]=o):o=e[2],o},fy=t=>{const e=tt.c(87),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:u,isDropTarget:d,canUpload:h,permissions:m,downloadFile:p,onSelect:g,onToggle:w,onRevealPath:v,onOpenDialog:x,onSetDropTarget:f,onDropFiles:b}=t,{t:y}=At(),S=n.type==="directory";let N;e[0]!==S||e[1]!==n.path?(N=S?n.path:ny(n.path),e[0]=S,e[1]=n.path,e[2]=N):N=e[2];const C=N,{canRename:j,canCreateFile:A,canCreateFolder:P,canDelete:I,canReveal:M}=m,z=!S&&!!p,R=M&&!l,H=j||A||P||I||z||R,[F,O]=c.useState(!1),[T,k]=c.useState(!1);let D;e[3]!==H?(D=$=>{H&&($?.preventDefault(),k(!0))},e[3]=H,e[4]=D):D=e[4];const L=D;let Q;e[5]!==S||e[6]!==n||e[7]!==g||e[8]!==w?(Q=()=>{S?w(n.path):g(n)},e[5]=S,e[6]=n,e[7]=g,e[8]=w,e[9]=Q):Q=e[9];const q=Q;let te;e[10]===Symbol.for("react.memo_cache_sentinel")?(te=$=>{$.stopPropagation(),k(!1),O(!0)},e[10]=te):te=e[10];const ae=te;let X;e[11]!==A||e[12]!==P||e[13]!==I||e[14]!==j||e[15]!==R||e[16]!==p||e[17]!==l||e[18]!==S||e[19]!==n||e[20]!==x||e[21]!==v||e[22]!==y?(X=$=>{const{Item:le,Separator:V}=$;return s.jsxs(s.Fragment,{children:[j&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),x("rename",n)},children:[s.jsx(E,{name:"edit",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.rename")]}),s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),pn(n.path).then(Be=>{if(Be.ok){Me.success(y("sidebarFilesTree.toast.pathCopied"));return}Me.error(y("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(E,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.copyPath")]}),!S&&p&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),p(n.path).catch(Be=>{console.error("Download failed:",Be),Me.error(y("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(E,{name:"download",className:"mr-2 h-4 w-4"})," ",y(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),R&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),v(n.path)},children:[s.jsx(E,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",y(pd())]}),S&&(A||P)&&s.jsxs(s.Fragment,{children:[s.jsx(V,{}),A&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),x("createFile",n)},children:[s.jsx(E,{name:"file-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFile")]}),P&&s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),x("createFolder",n)},children:[s.jsx(E,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFolder")]})]}),I&&s.jsxs(s.Fragment,{children:[s.jsx(V,{}),s.jsxs(le,{onClick:Ce=>{Ce.stopPropagation(),x("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.delete")]})]})]})},e[11]=A,e[12]=P,e[13]=I,e[14]=j,e[15]=R,e[16]=p,e[17]=l,e[18]=S,e[19]=n,e[20]=x,e[21]=v,e[22]=y,e[23]=X):X=e[23];const Z=X;let se;e[24]!==n.path||e[25]!==r?(se=$=>{_u($);const le=Oa(r,n.path);!le||le==="."||($.dataTransfer.setData("application/x-openchamber-file-path",le),$.dataTransfer.effectAllowed="copy")},e[24]=n.path,e[25]=r,e[26]=se):se=e[26];const fe=se;let B;e[27]!==q?(B=$=>{Bu($)&&q()},e[27]=q,e[28]=B):B=e[28];const ne=B;let ye;e[29]!==h||e[30]!==f||e[31]!==C?(ye=$=>{!h||!C||!fr($.dataTransfer)||($.preventDefault(),$.stopPropagation(),$.dataTransfer.dropEffect="copy",f(C))},e[29]=h,e[30]=f,e[31]=C,e[32]=ye):ye=e[32];const ce=ye;let _;e[33]!==h||e[34]!==f||e[35]!==C?(_=$=>{!h||!C||!fr($.dataTransfer)||$.relatedTarget instanceof Node&&$.currentTarget.contains($.relatedTarget)||($.stopPropagation(),f(null))},e[33]=h,e[34]=f,e[35]=C,e[36]=_):_=e[36];const re=_;let me;e[37]!==h||e[38]!==b||e[39]!==C?(me=$=>{!h||!C||!fr($.dataTransfer)||($.preventDefault(),$.stopPropagation(),b(C,$.dataTransfer))},e[37]=h,e[38]=b,e[39]=C,e[40]=me):me=e[40];const de=me;let ge;e[41]!==L||e[42]!==re||e[43]!==ce||e[44]!==de?(ge=s.jsx("div",{className:"group relative flex items-center",onContextMenu:L,onDragEnter:ce,onDragOver:ce,onDragLeave:re,onDrop:de}),e[41]=L,e[42]=re,e[43]=ce,e[44]=de,e[45]=ge):ge=e[45];const Te=d?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let be;e[46]!==Te?(be=Pe("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",Te),e[46]=Te,e[47]=be):be=e[47];let Re;e[48]!==S||e[49]!==i||e[50]!==n.extension||e[51]!==n.path?(Re=S?i?s.jsx(E,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):Lu(n.path,n.extension),e[48]=S,e[49]=i,e[50]=n.extension,e[51]=n.path,e[52]=Re):Re=e[52];let we;e[53]!==n.name||e[54]!==n.path?(we=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[53]=n.name,e[54]=n.path,e[55]=we):we=e[55];let Y;e[56]!==S||e[57]!==a?(Y=!S&&a&&s.jsx(uy,{status:a}),e[56]=S,e[57]=a,e[58]=Y):Y=e[58];let ve;e[59]!==u||e[60]!==S?(ve=S&&u&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[u.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",u.modified]}),u.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",u.added]})]}),e[59]=u,e[60]=S,e[61]=ve):ve=e[61];let xe;e[62]!==L||e[63]!==ne||e[64]!==fe||e[65]!==q||e[66]!==be||e[67]!==Re||e[68]!==we||e[69]!==Y||e[70]!==ve?(xe=s.jsxs("button",{type:"button",onClick:q,onContextMenu:L,draggable:!0,onDragStart:fe,onDragEnd:ne,className:be,children:[Re,we,Y,ve]}),e[62]=L,e[63]=ne,e[64]=fe,e[65]=q,e[66]=be,e[67]=Re,e[68]=we,e[69]=Y,e[70]=ve,e[71]=xe):xe=e[71];let je;e[72]!==F||e[73]!==H||e[74]!==Z||e[75]!==y?(je=H&&s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:s.jsxs(Xs,{open:F,onOpenChange:O,children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Qs,{asChild:!0,children:s.jsx(pt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ae,title:y("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":y("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(E,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:y("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(Ys,{align:"end",side:"bottom",onCloseAutoFocus:()=>O(!1),children:Z({Item:Ut,Separator:Os})})]})}),e[72]=F,e[73]=H,e[74]=Z,e[75]=y,e[76]=je):je=e[76];let oe;e[77]!==ge||e[78]!==xe||e[79]!==je?(oe=s.jsxs(tu,{render:ge,children:[xe,je]}),e[77]=ge,e[78]=xe,e[79]=je,e[80]=oe):oe=e[80];let J;e[81]!==Z?(J=s.jsx(eu,{className:"min-w-[180px]",children:Z({Item:Un,Separator:Mi})}),e[81]=Z,e[82]=J):J=e[82];let K;return e[83]!==T||e[84]!==oe||e[85]!==J?(K=s.jsxs(su,{open:T,onOpenChange:k,children:[oe,J]}),e[83]=T,e[84]=oe,e[85]=J,e[86]=K):K=e[86],K},my=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.canUpload===e.canUpload&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles,hy=c.memo(fy,my),py=()=>{const{t}=At(),{files:e,runtime:n}=wn(),r=qf(n.platform),i=br()??"",o=as(i.trim()),l=Qf(),a=Yf(),u=ad(ue=>ue.searchFiles),d=De(ue=>ue.openContextFile),h=ba(i),[m,p]=c.useState(""),g=Sa(m,200),w=c.useRef(null),[v,x]=c.useState([]),[f,b]=c.useState(!1),[y,S]=c.useState(null),[N,C]=c.useState(!1),[j,A]=c.useState(null),P=c.useRef(!1),I=c.useRef(o);I.current=o;const[M,z]=c.useState({}),[R,H]=c.useState({}),F=c.useRef(new Set),O=c.useRef(new Set),T=c.useRef(null);c.useEffect(()=>{if(S(null),A(null),!o){z({}),H({}),F.current=new Set;return}const ue=cy(o);ue?(z({...ue.childrenByDir}),H({...ue.loadErrorsByDir}),F.current=new Set(ue.loadedDirs)):(z({}),H({}),F.current=new Set)},[o]),c.useEffect(()=>{if(!o)return;const ue=di(o);ue.childrenByDir=M},[o,M]),c.useEffect(()=>{if(!o)return;const ue=di(o);ue.loadErrorsByDir=R},[o,R]),c.useEffect(()=>{if(!o)return;const ue=di(o);ue.loadedDirs=new Set(F.current)},[o,M,R]),c.useEffect(()=>()=>{if(!o)return;const ue=hn.get(o);ue&&ue.loadedDirs.size===0&&Object.keys(ue.childrenByDir).length===0&&dy(o)},[o]);const k=c.useMemo(()=>[],[]),D=c.useMemo(()=>[],[]),L=mn(ue=>o?ue.byRoot[o]?.expandedPaths??k:k),Q=mn(ue=>o?ue.byRoot[o]?.selectedPath??null:null),q=mn(ue=>ue.setSelectedPath),te=mn(ue=>ue.addOpenPath),ae=mn(ue=>ue.removeOpenPathsByPrefix),X=mn(ue=>ue.toggleExpandedPath),Z=mn(ue=>ue.collapseAllExpandedPaths),se=De(ue=>o?ue.contextPanelByDirectory[o]?.tabs??D:D),fe=c.useMemo(()=>new Set(se.map(ue=>ue.mode==="file"?ue.targetPath:null).filter(ue=>typeof ue=="string"&&ue.length>0).map(ue=>as(ue))),[se]),[B,ne]=c.useState(null),[ye,ce]=c.useState(null),[_,re]=c.useState(""),[me,de]=c.useState(!1),ge=!!e.writeFile,Te=!!e.createDirectory,be=!!e.rename,Re=!!e.delete,we=!!e.revealPath,Y=!!e.uploadFile,ve=c.useMemo(()=>({canRename:be,canCreateFile:ge,canCreateFolder:Te,canDelete:Re,canReveal:we}),[be,ge,Te,Re,we]),xe=c.useCallback(ue=>{e.revealPath&&e.revealPath(ue).catch(()=>{Me.error(t("sidebarFilesTree.toast.revealFailed"))})},[e,t]),je=c.useCallback((ue,G)=>{ne(ue),ce(G),re(ue==="rename"&&G.name||""),de(!1)},[]),oe=c.useCallback((ue,G)=>{const Le=G.filter(Oe=>Oe&&typeof Oe.name=="string"&&Oe.name.length>0).filter(Oe=>l||!Oe.name.startsWith(".")).filter(Oe=>a||!iy(Oe.name)).map(Oe=>{const qe=Oe.name,Ue=as(Oe.path||""),st=Ue?ry(Ue)?Ue:as(`${ue}/${Ue}`):as(`${ue}/${qe}`),wt=Oe.isDirectory?"directory":"file",Nt=wt==="file"&&qe.includes(".")?qe.split(".").pop()?.toLowerCase():void 0;return{name:qe,path:st,type:wt,extension:Nt}});return ty(Le)},[a,l]),J=c.useCallback(async(ue,G)=>{const Le=as(ue.trim());if(!Le||F.current.has(Le)||O.current.has(Le))return;O.current=new Set(O.current),O.current.add(Le);const Oe=e.listDirectory?e.listDirectory(Le).then(qe=>qe.entries.map(Ue=>({name:Ue.name,path:Ue.path,isDirectory:Ue.isDirectory}))):qs.listLocalDirectory(Le).then(qe=>qe.map(Ue=>({name:Ue.name,path:Ue.path,isDirectory:Ue.isDirectory})));try{const qe=await Oe;if(G?.())return;const Ue=oe(Le,qe);F.current=new Set(F.current),F.current.add(Le),H(st=>{if(!st[Le])return st;const wt={...st};return delete wt[Le],wt}),z(st=>({...st,[Le]:Ue}))}catch(qe){if(G?.())return;const Ue=qe instanceof Error?qe.message:String(qe??"");console.error("Failed to load sidebar directory:",qe),H(st=>({...st,[Le]:Ue}))}finally{O.current=new Set(O.current),O.current.delete(Le)}},[e,oe]),K=c.useCallback(async()=>{if(!o)return;T.current?.abort();const ue=new AbortController;T.current=ue;try{const Le=(mn.getState().byRoot[o]?.expandedPaths??[]).map(Ue=>as(Ue)).filter(Ue=>!!Ue&&Ue!==o&&Ue.startsWith(`${o}/`)),Oe=[o,...Le];F.current=new Set(F.current);for(const Ue of Oe)F.current.delete(Ue);H(Ue=>{if(Object.keys(Ue).length===0)return Ue;const st={...Ue};let wt=!1;for(const Nt of Oe)Nt in st&&(delete st[Nt],wt=!0);return wt?st:Ue});const qe=()=>ue.signal.aborted;await J(o,qe);for(let Ue=0;Ue<Le.length&&!ue.signal.aborted;Ue+=3){const st=Le.slice(Ue,Ue+3);await Promise.all(st.map(wt=>J(wt,qe)))}}catch(G){if(ue.signal.aborted)return;console.error("Failed to refresh sidebar tree:",G)}finally{T.current===ue&&(T.current=null)}},[J,o]),$=c.useCallback(async ue=>{if(!ue){await K();return}const G=as(ue);F.current=new Set(F.current),F.current.delete(G),O.current=new Set(O.current),O.current.delete(G),await J(G)},[J,K]);c.useEffect(()=>{o&&(T.current?.abort(),F.current=new Set,O.current=new Set,H({}),z(ue=>Object.keys(ue).length===0?ue:{}),J(o))},[J,o,l,a]),c.useEffect(()=>{if(!o||L.length===0)return;const ue=L.map(Oe=>as(Oe)).filter(Oe=>!!Oe&&Oe!==o&&Oe.startsWith(`${o}/`)&&!F.current.has(Oe)&&!O.current.has(Oe)).sort((Oe,qe)=>Oe.split("/").length-qe.split("/").length);if(ue.length===0)return;let G=!1;const Le=()=>G;return(async()=>{for(let Oe=0;Oe<ue.length&&!G;Oe+=3){const qe=ue.slice(Oe,Oe+3);await Promise.all(qe.map(Ue=>J(Ue,Le)))}})(),()=>{G=!0}},[L,J,o]),c.useEffect(()=>{if(!i){x([]),b(!1);return}const ue=g.trim();if(!ue){x([]),b(!1);return}let G=!1;return b(!0),u(i,ue,150,{includeHidden:l,respectGitignore:!a,type:"file"}).then(Le=>{if(G)return;const qe=Le.filter(Ue=>a||!ay(Ue.path)).map(Ue=>({name:Ue.name,path:as(Ue.path),type:"file",extension:Ue.extension,relativePath:Ue.relativePath}));x(qe)}).catch(()=>{G||x([])}).finally(()=>{G||b(!1)}),()=>{G=!0}},[i,g,u,l,a]);const le=c.useMemo(()=>{const ue=new Map;if(!h?.files)return ue;for(const G of h.files)G.index==="A"||G.working_dir==="?"?ue.set(G.path,"git-added"):G.index==="D"?ue.set(G.path,"git-deleted"):(G.index==="M"||G.working_dir==="M")&&ue.set(G.path,"git-modified");return ue},[h]),V=c.useMemo(()=>{const ue=new Map;if(!h?.files||!o)return ue;for(const G of h.files){const Le=G.index==="M"||G.working_dir==="M",Oe=G.index==="A"||G.working_dir==="?";if(!Le&&!Oe)continue;const qe=G.path.split("/");if(qe.length<=1)continue;let Ue=o;for(let st=0;st<qe.length-1;st++){Ue=`${Ue}/${qe[st]}`;let wt=ue.get(Ue);wt||(wt={modified:0,added:0},ue.set(Ue,wt)),Le&&wt.modified++,Oe&&wt.added++}}return ue},[h,o]),Ce=c.useCallback(ue=>{if(fe.has(ue))return"open";if(le.size===0)return null;const G=ue.startsWith(o+"/")?ue.slice(o.length+1):ue;return le.get(G)??null},[fe,le,o]),Be=c.useCallback(ue=>{if(V.size===0)return null;const G=V.get(ue);return G&&G.modified+G.added>0?G:null},[V]),ke=c.useCallback(async ue=>{if(!o)return;const G=await Ou(e,ue.path,{directory:o});if(!G.ok){Me.error(Fu(G.reason));return}q(o,ue.path),te(o,ue.path),d(o,ue.path)},[te,e,d,o,q]),Ne=c.useCallback(async ue=>{const G=as(ue);o&&(X(o,G),F.current.has(G)||await J(G))},[J,o,X]),Qe=c.useCallback(async(ue,G,Le=!1)=>{const Oe=e.uploadFile;if(!Oe||G.length===0||P.current||!o)return;const qe=o,Ue=ps();P.current=!0,C(!0),S(ue),Le&&A(null);const st=[];for(let ze=0;ze<G.length;ze+=Ul){const He=G.slice(ze,ze+Ul),ot=await Promise.all(He.map(async at=>{const et=Kl(at);if(!et||ps()!==Ue)return"failed";try{return(await Oe(as(`${ue}/${et}`),at,{directory:qe,overwrite:Le})).success?"uploaded":"failed"}catch(Xe){return!Le&&Xf(Xe)&&Xe.reason==="already-exists"?"conflict":"failed"}}));st.push(...ot)}const wt=st.filter(ze=>ze==="uploaded").length,Nt=st.filter(ze=>ze==="failed").length,ie=G.filter((ze,He)=>st[He]==="conflict"),pe=G.flatMap((ze,He)=>{const ot=Kl(ze);return st[He]==="uploaded"&&ot?[as(`${ue}/${ot}`)]:[]}),Ve=I.current===qe&&ps()===Ue;try{pe.length>0&&Cg({runtimeKey:Ue,paths:pe}),wt>0&&Ve&&await $(ue),wt>0&&Me.success(t(ie.length>0?"sidebarFilesTree.toast.uploadedWithoutConflicts":"sidebarFilesTree.toast.uploaded")),Nt>0&&Me.error(t("sidebarFilesTree.toast.uploadFailed")),ie.length>0&&Ve&&A({directory:ue,files:ie,runtimeKey:Ue,workspaceRoot:qe})}finally{P.current=!1,C(!1),S(null)}},[e.uploadFile,$,o,t]),We=c.useCallback((ue,G)=>{const Le=ey(G);Le.length!==0&&Qe(ue,Le)},[Qe]),U=c.useCallback(ue=>{!Y||P.current||!o||!fr(ue.dataTransfer)||(ue.preventDefault(),ue.dataTransfer.dropEffect="copy",S(o))},[Y,o]),he=c.useCallback(ue=>{fr(ue.dataTransfer)&&(ue.relatedTarget instanceof Node&&ue.currentTarget.contains(ue.relatedTarget)||S(null))},[]),Ee=c.useCallback(ue=>{!Y||P.current||!o||!fr(ue.dataTransfer)||(ue.preventDefault(),We(o,ue.dataTransfer))},[Y,We,o]),Ie=c.useCallback(async ue=>{if(ue?.preventDefault(),!ye||!B)return;de(!0);const G=()=>de(!1),Le=()=>ne(null);if(B==="createFile"){if(!_.trim()){Me.error(t("sidebarFilesTree.toast.filenameRequired")),G();return}if(!e.writeFile){Me.error(t("sidebarFilesTree.toast.writeNotSupported")),G();return}const Oe=ye.path,qe=Oe?`${Oe}/`:"",Ue=as(`${qe}${_.trim()}`);await e.writeFile(Ue,"").then(async st=>{st.success&&(Me.success(t("sidebarFilesTree.toast.fileCreated")),await $(Oe)),Le()}).catch(()=>Me.error(t("sidebarFilesTree.toast.operationFailed"))).finally(G);return}if(B==="createFolder"){if(!_.trim()){Me.error(t("sidebarFilesTree.toast.folderNameRequired")),G();return}const Oe=ye.path,qe=Oe?`${Oe}/`:"",Ue=as(`${qe}${_.trim()}`);await e.createDirectory(Ue).then(async st=>{st.success&&(Me.success(t("sidebarFilesTree.toast.folderCreated")),await $(Oe)),Le()}).catch(()=>Me.error(t("sidebarFilesTree.toast.operationFailed"))).finally(G);return}if(B==="rename"){if(!_.trim()){Me.error(t("sidebarFilesTree.toast.nameRequired")),G();return}if(!e.rename){Me.error(t("sidebarFilesTree.toast.renameNotSupported")),G();return}const Oe=ye.path,qe=Oe.split("/").slice(0,-1).join("/"),Ue=qe?`${qe}/`:"",st=as(`${Ue}${_.trim()}`);await e.rename(Oe,st).then(async wt=>{wt.success&&(Me.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await $(qe),o&&ae(o,Oe),(Q===Oe||Q&&Q.startsWith(`${Oe}/`))&&q(o,null)),Le()}).catch(()=>Me.error(t("sidebarFilesTree.toast.operationFailed"))).finally(G);return}if(B==="delete"){if(!e.delete){Me.error(t("sidebarFilesTree.toast.deleteNotSupported")),G();return}const Oe=ye.path,qe=Oe.split("/").slice(0,-1).join("/");await e.delete(Oe).then(async Ue=>{Ue.success&&(Me.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await $(qe),o&&ae(o,Oe),(Q===Oe||Q&&Q.startsWith(Oe+"/"))&&q(o,null)),Le()}).catch(()=>Me.error(t("sidebarFilesTree.toast.operationFailed"))).finally(G);return}G()},[B,ye,_,e,$,ae,o,Q,q,t]);function rt(ue,G){const Le=M[ue]??[];return Le.map((Oe,qe)=>{const Ue=Oe.type==="directory",st=Ue&&L.includes(Oe.path),wt=Q===Oe.path,Nt=qe===Le.length-1;return s.jsxs("li",{className:"relative",children:[G>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Nt&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(hy,{node:Oe,root:o,isExpanded:st,isActive:wt,isBrowserClient:r,status:Ue?void 0:Ce(Oe.path),badge:Ue?Be(Oe.path):void 0,isDropTarget:Ue&&y===Oe.path,canUpload:Y&&!N,permissions:ve,downloadFile:e.downloadFile,onSelect:ke,onToggle:Ne,onRevealPath:xe,onOpenDialog:je,onSetDropTarget:S,onDropFiles:We}),Ue&&st&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[R[Oe.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:R[Oe.path],children:R[Oe.path]}),s.jsxs(pt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{$(Oe.path)},children:[s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):null,rt(Oe.path,G+1)]})]},Oe.path)})}const Ge=!!(o&&M[o]),ut=o?R[o]:null,ct=y?sy(o,y):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[ge&&s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(pt,{variant:"ghost",size:"sm",onClick:()=>je("createFile",{path:i,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.newFileTitle"),"aria-label":t("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(E,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFileTitle")})]}),Te&&s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(pt,{variant:"ghost",size:"sm",onClick:()=>je("createFolder",{path:i,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.newFolderTitle"),"aria-label":t("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(E,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFolderTitle")})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(pt,{variant:"ghost",size:"sm",onClick:()=>{K()},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.refreshTitle"),"aria-label":t("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(E,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(pt,{variant:"ghost",size:"sm",onClick:()=>{o&&Z(o)},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":t("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(E,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(Cn,{ref:w,value:m,onChange:ue=>p(ue.target.value),placeholder:t("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),m.trim().length>0?s.jsx("button",{type:"button","aria-label":t("sidebarFilesTree.search.clearAria"),className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{p(""),w.current?.focus()},children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(ln,{outerClassName:"h-full min-h-0",className:Pe("p-2",y===o&&"bg-interactive-selection/10"),onDragEnter:U,onDragOver:U,onDragLeave:he,onDrop:Ee,children:s.jsx("ul",{className:"flex flex-col",children:f?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("sidebarFilesTree.state.searching")]}):v.length>0?v.map(ue=>{const G=Q===ue.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>ke(ue),draggable:!0,onDragStart:Le=>{_u(Le);const Oe=ue.relativePath||Oa(o??"",ue.path);!Oe||Oe==="."||(Le.dataTransfer.setData("application/x-openchamber-file-path",Oe),Le.dataTransfer.effectAllowed="copy")},onDragEnd:Le=>{Bu(Le)&&ke(ue)},className:Pe("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",G?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:ue.path,children:[Lu(ue.path,ue.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:ue.relativePath??ue.path})]})},ue.path)}):ut?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:ut}),s.jsxs(pt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{K()},children:[s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):Ge&&o?rt(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("sidebarFilesTree.state.loading")})})}),y?s.jsxs("div",{className:"pointer-events-none absolute left-2 right-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(E,{name:N?"loader-4":"folder-received",className:Pe("size-4 flex-shrink-0",N&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:ct,children:t(N?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:ct})})]}):null]}),s.jsx(ws,{open:!!j,onOpenChange:ue=>!ue&&A(null),children:s.jsxs(Ss,{children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:t("sidebarFilesTree.dialog.uploadConflicts.title")}),s.jsx(Ts,{children:t("sidebarFilesTree.dialog.uploadConflicts.description",{path:j?.directory??""})})]}),s.jsx(ln,{outerClassName:"max-h-52",className:"flex flex-col gap-1 pr-2",children:j?.files.map((ue,G)=>s.jsx("div",{className:"truncate rounded-md bg-muted px-2 py-1 typography-meta",title:ue.name,children:ue.name},`${ue.name}-${ue.size}-${G}`))}),s.jsxs(bn,{children:[s.jsx(pt,{variant:"outline",onClick:()=>A(null),disabled:N,children:t("sidebarFilesTree.dialog.cancel")}),s.jsx(pt,{onClick:()=>{if(j){if(j.runtimeKey!==ps()||j.workspaceRoot!==o){A(null);return}Qe(j.directory,j.files,!0)}},disabled:N,children:t("sidebarFilesTree.dialog.uploadConflicts.replace")})]})]})}),s.jsx(ws,{open:!!B,onOpenChange:ue=>!ue&&ne(null),children:s.jsxs(Ss,{children:[s.jsxs(Ws,{children:[s.jsxs(Is,{children:[B==="createFile"&&t("sidebarFilesTree.dialog.createFile.title"),B==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.title"),B==="rename"&&t("sidebarFilesTree.dialog.rename.title"),B==="delete"&&t("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Ts,{children:[B==="createFile"&&t("sidebarFilesTree.dialog.createFile.description",{path:ye?.path??t("sidebarFilesTree.dialog.rootFallback")}),B==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.description",{path:ye?.path??t("sidebarFilesTree.dialog.rootFallback")}),B==="rename"&&t("sidebarFilesTree.dialog.rename.description",{name:ye?.name??""}),B==="delete"&&t("sidebarFilesTree.dialog.delete.description",{name:ye?.name??""})]})]}),B!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Cn,{value:_,onChange:ue=>re(ue.target.value),placeholder:t(B==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:ue=>{ue.key==="Enter"&&Ie()},autoFocus:!0})}),s.jsxs(bn,{children:[s.jsx(pt,{variant:"outline",onClick:()=>ne(null),disabled:me,children:t("sidebarFilesTree.dialog.cancel")}),s.jsx(pt,{variant:B==="delete"?"destructive":"default",onClick:()=>{Ie()},disabled:me||B!=="delete"&&!_.trim(),children:me?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t(B==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})},Hl=60,gy=t=>{try{return new URL(t).origin}catch{return""}},ui=new Set,$u=er()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=gy(n);!i||!r||e().byOrigin[i]||ui.has(i)||(ui.add(i),ur("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const u={...a.byOrigin,[i]:l},d=Object.keys(u);if(d.length<=Hl)return{byOrigin:u};for(const h of d.slice(0,d.length-Hl))delete u[h];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{ui.delete(i)}))}})),_a=t=>t,Gi=t=>{const e=_a(t).type;return typeof e=="string"?e:""},xy=t=>{const e=_a(t).tool;return typeof e=="string"?e:""},by=t=>{const e=_a(t).text;return typeof e=="string"?e:""},yy=t=>{const e=Gi(t);return e==="tool"?xy(t).trim().toLowerCase()||"tool":e||"unknown"},wy=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=yy(n);e.includes(r)||e.push(r)}return e.join(" + ")},Sy=t=>t.replace(/\s+/g," ").trim(),vy=t=>{for(const n of t)if(Gi(n)==="text"){const r=Sy(by(n));if(r.length===0)continue;return r}const e=t.filter(n=>Gi(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},jy=(t,e,n)=>`${n(t)} / ${n(e)}`,ky=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Cy=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=ky(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},qi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},xo={user:0,assistant:0,tool:0,other:0},Rn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,fi=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(h=>h.tokens!==void 0)?.tokens;if(typeof n=="number")return{...qi,total:Rn(n)};if(!n||typeof n!="object")return qi;const r=n,i=Rn(r.input),o=Rn(r.output),l=Rn(r.reasoning),a=Rn(r.cache?.read),u=Rn(r.cache?.write),d=Rn(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:u,total:d>0?d:i+o+l+a+u}},Ny=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Us=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Us(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Us(n),0):0,Ay=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...xo,assistant:Us(n.text)+Us(n.content)};const i=Ny(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Us(n.input)+Us(n.output)+Us(n.error)+Us(n.call?.input)+Us(n.call?.output)+Us(n.call?.error)+Us(n.raw)+Math.round(Us(n.metadata)*.25)+Math.round(Us(n.state)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},Gl=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Dy=t=>{const e=Qr(t.info);return e.isUser?"user":e.role==="assistant"?"assistant":e.role==="tool"?"tool":"other"},Py=(t,e)=>{if(t.length===0)return{...xo};const n=t.reduce((r,i)=>{const o=Dy(i);let l={...xo};for(const a of i.parts)l=Gl(l,Ay(a,o));return Gl(r,l)},{...xo});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},Vn=t=>t.toLocaleString(pa()),Iy=(t,e)=>!t||!Number.isFinite(t)?"-":jd(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Ty=(t,e,n)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===n);return{providerName:r?.name||e||"-",modelName:i?.name||n||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},Ry=()=>{const t=tt.c(203),{t:e}=At(),n=De(Ey);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[i,o]=c.useState(r),[l,a]=c.useState(null),u=c.useRef(null),d=Je(My),h=Je(Oy),m=Nd(h??void 0),p=Km(d??"",h??void 0),g=Gt(Fy);let w;t[1]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),o(_y),a(null)},t[1]=w):w=t[1];let v;t[2]!==h||t[3]!==d?(v=[h,d],t[2]=h,t[3]=d,t[4]=v):v=t[4],c.useEffect(w,v);let x,f;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},f=[],t[5]=x,t[6]=f):(x=t[5],f=t[6]),c.useEffect(x,f);let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=async(dt,Fe)=>{(await pn(Fe)).ok?(a(dt),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{a(St=>St===dt?null:St),u.current=null},2e3)):a(null)},t[7]=b):b=t[7];const y=b;let S;t[8]!==d||t[9]!==m?(S=d?m.find(dt=>dt.id===d)??null:null,t[8]=d,t[9]=m,t[10]=S):S=t[10];const N=S;let C,j,A,P,I,M;if(t[11]!==g||t[12]!==p){C=p.filter(By);let dt;t[19]!==p?(dt=p.filter(Ly),t[19]=p,t[20]=dt):dt=t[20],M=dt;let Fe=null;for(let St=C.length-1;St>=0;St=St-1,St){const vt=C[St];if(fi(vt).total>0){Fe=vt;break}}P=Fe?fi(Fe):qi,j=Hm({input:P.input,cache:{read:P.cacheRead,write:P.cacheWrite}}),I=C.reduce($y,0);const Se=Fe?.info??null;A=Ty(g,Se?.providerID||"",Se?.modelID||""),t[11]=g,t[12]=p,t[13]=C,t[14]=j,t[15]=A,t[16]=P,t[17]=I,t[18]=M}else C=t[13],j=t[14],A=t[15],P=t[16],I=t[17],M=t[18];const z=A,R=z.contextLimit,H=R&&R>0?Math.min(999,P.total/R*100):0;let F;if(t[21]!==p){const dt=[...p].reverse().find(Wy)?.info?.system||"";F=Py(p,dt),t[21]=p,t[22]=F}else F=t[22];const O=F,T=O.user,k=O.assistant,D=O.tool,L=Math.max(0,P.input-T-k-D),Q=T+k+D+L,q=p[0]?.info?.time?.created,te=p.length>0?p[p.length-1]?.info?.time?.created:null;let ae;t[23]!==N?.title||t[24]!==e?(ae=N?.title||e("contextSidebar.session.untitled"),t[23]=N?.title,t[24]=e,t[25]=ae):ae=t[25];const X=N?.time?.created??q??null,Z=te??N?.time?.created??null;let se;t[26]!==k||t[27]!==L||t[28]!==D||t[29]!==T?(se={user:T,assistant:k,tool:D,other:L},t[26]=k,t[27]=L,t[28]=D,t[29]=T,t[30]=se):se=t[30];let fe;t[31]!==C.length||t[32]!==Q||t[33]!==j||t[34]!==R||t[35]!==z||t[36]!==p.length||t[37]!==X||t[38]!==Z||t[39]!==se||t[40]!==ae||t[41]!==P||t[42]!==I||t[43]!==H||t[44]!==M.length?(fe={sessionTitle:ae,messagesCount:p.length,userMessagesCount:M.length,assistantMessagesCount:C.length,createdAt:X,lastActivityAt:Z,providerModel:z,tokenBreakdown:P,usagePercent:H,cacheHitRate:j,totalAssistantCost:I,contextLimit:R,breakdown:se,breakdownTotal:Q},t[31]=C.length,t[32]=Q,t[33]=j,t[34]=R,t[35]=z,t[36]=p.length,t[37]=X,t[38]=Z,t[39]=se,t[40]=ae,t[41]=P,t[42]=I,t[43]=H,t[44]=M.length,t[45]=fe):fe=t[45];const B=fe;if(!d){let dt;t[46]!==e?(dt=e("contextSidebar.empty.openSession"),t[46]=e,t[47]=dt):dt=t[47];let Fe;return t[48]!==dt?(Fe=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:dt}),t[48]=dt,t[49]=Fe):Fe=t[49],Fe}let ne;t[50]!==e?(ne=e("contextSidebar.breakdown.user"),t[50]=e,t[51]=ne):ne=t[51];let ye;t[52]!==ne||t[53]!==B.breakdown.user?(ye={key:"user",label:ne,value:B.breakdown.user,color:"var(--status-success)"},t[52]=ne,t[53]=B.breakdown.user,t[54]=ye):ye=t[54];let ce;t[55]!==e?(ce=e("contextSidebar.breakdown.assistant"),t[55]=e,t[56]=ce):ce=t[56];let _;t[57]!==ce||t[58]!==B.breakdown.assistant?(_={key:"assistant",label:ce,value:B.breakdown.assistant,color:"var(--primary-base)"},t[57]=ce,t[58]=B.breakdown.assistant,t[59]=_):_=t[59];let re;t[60]!==e?(re=e("contextSidebar.breakdown.toolCalls"),t[60]=e,t[61]=re):re=t[61];let me;t[62]!==re||t[63]!==B.breakdown.tool?(me={key:"tool",label:re,value:B.breakdown.tool,color:"var(--status-warning)"},t[62]=re,t[63]=B.breakdown.tool,t[64]=me):me=t[64];let de;t[65]!==e?(de=e("contextSidebar.breakdown.other"),t[65]=e,t[66]=de):de=t[66];let ge;t[67]!==de||t[68]!==B.breakdown.other?(ge={key:"other",label:de,value:B.breakdown.other,color:"var(--surface-muted-foreground)"},t[67]=de,t[68]=B.breakdown.other,t[69]=ge):ge=t[69];let Te;t[70]!==ye||t[71]!==_||t[72]!==me||t[73]!==ge?(Te=[ye,_,me,ge],t[70]=ye,t[71]=_,t[72]=me,t[73]=ge,t[74]=Te):Te=t[74];const be=Te;let Re;t[75]!==B.sessionTitle?(Re=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:B.sessionTitle}),t[75]=B.sessionTitle,t[76]=Re):Re=t[76];let we;t[77]!==B.providerModel.modelName||t[78]!==B.providerModel.providerName?(we=s.jsxs("span",{children:[B.providerModel.providerName," / ",B.providerModel.modelName]}),t[77]=B.providerModel.modelName,t[78]=B.providerModel.providerName,t[79]=we):we=t[79];let Y;t[80]!==n||t[81]!==B.createdAt?(Y=B.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:Iy(B.createdAt,n)})]}),t[80]=n,t[81]=B.createdAt,t[82]=Y):Y=t[82];let ve;t[83]!==we||t[84]!==Y?(ve=s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[we,Y]}),t[83]=we,t[84]=Y,t[85]=ve):ve=t[85];let xe;t[86]!==Re||t[87]!==ve?(xe=s.jsxs("div",{className:"mb-6",children:[Re,ve]}),t[86]=Re,t[87]=ve,t[88]=xe):xe=t[88];let je;t[89]!==e?(je=e("contextSidebar.section.context"),t[89]=e,t[90]=je):je=t[90];let oe;t[91]!==je?(oe=s.jsx("span",{className:"typography-micro text-muted-foreground",children:je}),t[91]=je,t[92]=oe):oe=t[92];let J;t[93]!==B.tokenBreakdown.total?(J=Vn(B.tokenBreakdown.total),t[93]=B.tokenBreakdown.total,t[94]=J):J=t[94];let K;t[95]!==B.contextLimit?(K=B.contextLimit?` / ${Vn(B.contextLimit)}`:"",t[95]=B.contextLimit,t[96]=K):K=t[96];let $;t[97]!==J||t[98]!==K?($=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[J,K]}),t[97]=J,t[98]=K,t[99]=$):$=t[99];let le;t[100]!==oe||t[101]!==$?(le=s.jsxs("div",{className:"flex items-baseline justify-between",children:[oe,$]}),t[100]=oe,t[101]=$,t[102]=le):le=t[102];let V;t[103]!==B.usagePercent?(V=B.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,B.usagePercent)}%`,backgroundColor:B.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[103]=B.usagePercent,t[104]=V):V=t[104];let Ce;t[105]!==V?(Ce=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:V}),t[105]=V,t[106]=Ce):Ce=t[106];let Be;t[107]!==e||t[108]!==B.usagePercent?(Be=e("contextSidebar.context.percentUsed",{percent:B.usagePercent.toFixed(1)}),t[107]=e,t[108]=B.usagePercent,t[109]=Be):Be=t[109];let ke;t[110]!==Be?(ke=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Be}),t[110]=Be,t[111]=ke):ke=t[111];let Ne;t[112]!==le||t[113]!==Ce||t[114]!==ke?(Ne=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[le,Ce,ke]}),t[112]=le,t[113]=Ce,t[114]=ke,t[115]=Ne):Ne=t[115];let Qe;t[116]!==e?(Qe=e("contextSidebar.stats.messages"),t[116]=e,t[117]=Qe):Qe=t[117];let We;t[118]!==B.messagesCount?(We=Vn(B.messagesCount),t[118]=B.messagesCount,t[119]=We):We=t[119];let U;t[120]!==Qe||t[121]!==We?(U={label:Qe,value:We},t[120]=Qe,t[121]=We,t[122]=U):U=t[122];let he;t[123]!==e?(he=e("contextSidebar.stats.user"),t[123]=e,t[124]=he):he=t[124];let Ee;t[125]!==B.userMessagesCount?(Ee=Vn(B.userMessagesCount),t[125]=B.userMessagesCount,t[126]=Ee):Ee=t[126];let Ie;t[127]!==he||t[128]!==Ee?(Ie={label:he,value:Ee},t[127]=he,t[128]=Ee,t[129]=Ie):Ie=t[129];let rt;t[130]!==e?(rt=e("contextSidebar.stats.assistant"),t[130]=e,t[131]=rt):rt=t[131];let Ge;t[132]!==B.assistantMessagesCount?(Ge=Vn(B.assistantMessagesCount),t[132]=B.assistantMessagesCount,t[133]=Ge):Ge=t[133];let ut;t[134]!==rt||t[135]!==Ge?(ut={label:rt,value:Ge},t[134]=rt,t[135]=Ge,t[136]=ut):ut=t[136];let ct;t[137]!==e?(ct=e("contextSidebar.stats.cost"),t[137]=e,t[138]=ct):ct=t[138];let ue;t[139]!==B.totalAssistantCost?(ue=zp(B.totalAssistantCost),t[139]=B.totalAssistantCost,t[140]=ue):ue=t[140];let G;t[141]!==ct||t[142]!==ue?(G={label:ct,value:ue},t[141]=ct,t[142]=ue,t[143]=G):G=t[143];let Le;t[144]!==U||t[145]!==Ie||t[146]!==ut||t[147]!==G?(Le=[U,Ie,ut,G],t[144]=U,t[145]=Ie,t[146]=ut,t[147]=G,t[148]=Le):Le=t[148];const Oe=Le;let qe;t[149]!==Oe?(qe=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:Oe.map(zy)}),t[149]=Oe,t[150]=qe):qe=t[150];let Ue;t[151]!==e?(Ue=e("contextSidebar.section.lastAssistantMessage"),t[151]=e,t[152]=Ue):Ue=t[152];let st;t[153]!==Ue?(st=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:Ue}),t[153]=Ue,t[154]=st):st=t[154];let wt;t[155]!==e||t[156]!==B.cacheHitRate.hasInput||t[157]!==B.cacheHitRate.percent||t[158]!==B.tokenBreakdown.cacheRead||t[159]!==B.tokenBreakdown.cacheWrite||t[160]!==B.tokenBreakdown.input||t[161]!==B.tokenBreakdown.output||t[162]!==B.tokenBreakdown.reasoning?(wt=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:B.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:B.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:B.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:B.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:B.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:B.cacheHitRate.hasInput?B.cacheHitRate.percent:null,format:"percent"}].map(Vy)}),t[155]=e,t[156]=B.cacheHitRate.hasInput,t[157]=B.cacheHitRate.percent,t[158]=B.tokenBreakdown.cacheRead,t[159]=B.tokenBreakdown.cacheWrite,t[160]=B.tokenBreakdown.input,t[161]=B.tokenBreakdown.output,t[162]=B.tokenBreakdown.reasoning,t[163]=wt):wt=t[163];let Nt;t[164]!==st||t[165]!==wt?(Nt=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[st,wt]}),t[164]=st,t[165]=wt,t[166]=Nt):Nt=t[166];let ie;t[167]!==be||t[168]!==B.breakdownTotal?(ie=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:be.map(dt=>dt.value<=0||B.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${dt.value/B.breakdownTotal*100}%`,backgroundColor:dt.color}},dt.key))}),t[167]=be,t[168]=B.breakdownTotal,t[169]=ie):ie=t[169];let pe;t[170]!==be||t[171]!==B.breakdownTotal?(pe=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:be.map(dt=>{const Fe=B.breakdownTotal>0?dt.value/B.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:dt.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[dt.label," ",s.jsxs("span",{className:"tabular-nums",children:[Fe.toFixed(0),"%"]})]})]},dt.key)})}),t[170]=be,t[171]=B.breakdownTotal,t[172]=pe):pe=t[172];let Ve;t[173]!==ie||t[174]!==pe?(Ve=s.jsxs("div",{className:"mb-6",children:[ie,pe]}),t[173]=ie,t[174]=pe,t[175]=Ve):Ve=t[175];let ze;t[176]!==e?(ze=e("contextSidebar.section.rawMessages"),t[176]=e,t[177]=ze):ze=t[177];let He;t[178]!==ze?(He=s.jsx("div",{className:"typography-micro text-muted-foreground",children:ze}),t[178]=ze,t[179]=He):He=t[179];let ot;if(t[180]!==l||t[181]!==i||t[182]!==p||t[183]!==e||t[184]!==n){let dt;t[186]!==l||t[187]!==i||t[188]!==e||t[189]!==n?(dt=Fe=>{const St=Qr(Fe.info).role,vt=St==="assistant",Rt=St==="user",Ze=i[Fe.info.id]===!0,it=l===Fe.info.id,gt=Fe.info.time?.created??null,xt=wy(Fe.parts),Et=vt?fi({info:Fe.info,parts:Fe.parts}):null,kt=Rt?vy(Fe.parts):"",Tt=Cy(gt,n),Ot=xt||"—",Vt=Et?jy(Et.input,Et.output,Vn):"",Yt=St||"unknown",Ht=xt?`${Yt}: ${xt}`:Yt,Lt=Ze?JSON.stringify({info:Fe.info,parts:Fe.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":Ze,onClick:()=>{o(zt=>({...zt,[Fe.info.id]:zt[Fe.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:vt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Rt?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",kt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:vt?Ot:Ht}),vt&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Vt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Tt})]})}),Ze&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[s.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:zt=>{zt.stopPropagation(),y(Fe.info.id,Lt)},"aria-label":e(it?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(it?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:it?s.jsx(E,{name:"check",className:"size-3.5"}):s.jsx(E,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Gm,{language:"json",code:Lt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Fe.info.id)},t[186]=l,t[187]=i,t[188]=e,t[189]=n,t[190]=dt):dt=t[190],ot=[...p].reverse().map(dt),t[180]=l,t[181]=i,t[182]=p,t[183]=e,t[184]=n,t[185]=ot}else ot=t[185];let at;t[191]!==ot?(at=s.jsx("div",{className:"mt-2.5 space-y-1",children:ot}),t[191]=ot,t[192]=at):at=t[192];let et;t[193]!==He||t[194]!==at?(et=s.jsxs("div",{children:[He,at]}),t[193]=He,t[194]=at,t[195]=et):et=t[195];let Xe;return t[196]!==xe||t[197]!==Ne||t[198]!==qe||t[199]!==Nt||t[200]!==Ve||t[201]!==et?(Xe=s.jsx(ln,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[xe,Ne,qe,Nt,Ve,et]})}),t[196]=xe,t[197]=Ne,t[198]=qe,t[199]=Nt,t[200]=Ve,t[201]=et,t[202]=Xe):Xe=t[202],Xe};function Ey(t){return t.timeFormatPreference}function My(t){return t.currentSessionId}function Oy(t){return t.currentSessionDirectory}function Fy(t){return t.providers}function _y(t){return Object.keys(t).length>0?{}:t}function By(t){return Qr(t.info).role==="assistant"}function Ly(t){return Qr(t.info).isUser}function $y(t,e){const n=Rn(e.info.cost);return t+n}function Wy(t){return Qr(t.info).isUser&&typeof t.info.system=="string"}function zy(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function Vy(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:Vn(t.value):"—"})]},t.label)}const Wu=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),Uy=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Wu.has(n.toLowerCase())},an="about:blank",mr=t=>{const e=t.trim();if(!e)return an;const n=e.includes("://")?e:`${Uy(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?an:r.toString()}catch{return an}},yr=t=>{try{return Wu.has(new URL(t).hostname.toLowerCase())}catch{return!1}},Ba=t=>{if(!t||t===an)return"";try{return new URL(t).host||t}catch{return t}},Ky=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),Hy=(t,e)=>Ky.has(t)&&yr(e),Gy=t=>{if(!t||typeof t!="object")return!1;const e=t;return typeof e.port=="number"&&Number.isFinite(e.port)&&typeof e.url=="string"&&e.url.length>0&&typeof e.command=="string"},qy=async t=>{try{const e=await ds("/api/dev-servers",{signal:t});if(!e.ok)return{kind:"unavailable"};const n=await e.json();if(!n||typeof n!="object")return{kind:"unavailable"};const r=n.servers;return Array.isArray(r)?{kind:"ready",servers:r.filter(Gy)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Qy=async t=>{try{const e=await ds("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},Yy=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},Xy=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=Yy(r);i!==null&&!n.has(i)&&n.set(i,r)}return e?e.map(r=>{const i=n.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...n.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},Qi="__aiworkerBrowserAnnotationActive",Jy=`(() => {
|
|
46
|
+
try {
|
|
47
|
+
var host = document.querySelector('[data-openchamber-annotation]');
|
|
48
|
+
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
49
|
+
} catch (error) { /* page navigated away */ }
|
|
50
|
+
try {
|
|
51
|
+
var cursor = document.getElementById('openchamber-annotation-cursor');
|
|
52
|
+
if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
|
|
53
|
+
} catch (error) { /* page navigated away */ }
|
|
54
|
+
try { delete window['${Qi}']; } catch (error) { /* non-configurable */ }
|
|
55
|
+
})();`,Zy=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
56
|
+
var CONFIG = ${n};
|
|
57
|
+
var THEME = CONFIG.theme;
|
|
58
|
+
var LABELS = CONFIG.labels;
|
|
59
|
+
var OVERLAY_ATTR = 'data-openchamber-annotation';
|
|
60
|
+
var Z_OVERLAY = 2147483646;
|
|
61
|
+
var MAX_TEXT = 400;
|
|
62
|
+
var MIN_RECT = 3;
|
|
63
|
+
var EDITOR_GAP = 10;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
|
|
67
|
+
if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
|
|
68
|
+
} catch (error) { /* nothing to clean */ }
|
|
69
|
+
|
|
70
|
+
window['${Qi}'] = true;
|
|
71
|
+
|
|
72
|
+
var counter = 0;
|
|
73
|
+
var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
|
|
74
|
+
|
|
75
|
+
var selected = null;
|
|
76
|
+
var regions = [];
|
|
77
|
+
var strokes = [];
|
|
78
|
+
var tool = 'select';
|
|
79
|
+
var settled = false;
|
|
80
|
+
|
|
81
|
+
// ---------------------------------------------------------------- geometry
|
|
82
|
+
|
|
83
|
+
var rectFrom = function (domRect) {
|
|
84
|
+
return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
|
|
85
|
+
};
|
|
86
|
+
var normalizeRect = function (ax, ay, bx, by) {
|
|
87
|
+
return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
|
|
88
|
+
};
|
|
89
|
+
var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
|
|
90
|
+
|
|
91
|
+
// ------------------------------------------------------------- description
|
|
92
|
+
|
|
93
|
+
var isOverlayNode = function (element) {
|
|
94
|
+
var node = element;
|
|
95
|
+
while (node) {
|
|
96
|
+
if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
|
|
97
|
+
node = node.parentNode || (node.host || null);
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
var elementFromPoint = function (x, y) {
|
|
103
|
+
var found = document.elementFromPoint(x, y);
|
|
104
|
+
if (!found || isOverlayNode(found)) return null;
|
|
105
|
+
return found;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
var selectorPart = function (element) {
|
|
109
|
+
var part = element.tagName.toLowerCase();
|
|
110
|
+
if (element.id) return part + '#' + element.id;
|
|
111
|
+
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
112
|
+
if (className) {
|
|
113
|
+
var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
|
|
114
|
+
if (first) part += '.' + first;
|
|
115
|
+
}
|
|
116
|
+
return part;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
var buildSelector = function (element) {
|
|
120
|
+
if (element.id) return '#' + element.id;
|
|
121
|
+
var parts = [];
|
|
122
|
+
var node = element;
|
|
123
|
+
var depth = 0;
|
|
124
|
+
while (node && node.nodeType === 1 && depth < 5) {
|
|
125
|
+
var part = selectorPart(node);
|
|
126
|
+
var parent = node.parentElement;
|
|
127
|
+
if (parent) {
|
|
128
|
+
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
129
|
+
return child.tagName === node.tagName;
|
|
130
|
+
});
|
|
131
|
+
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
132
|
+
}
|
|
133
|
+
parts.unshift(part);
|
|
134
|
+
if (node.id) break;
|
|
135
|
+
node = parent;
|
|
136
|
+
depth += 1;
|
|
137
|
+
}
|
|
138
|
+
return parts.join(' > ');
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
|
|
142
|
+
var STYLE_PROPS = [
|
|
143
|
+
'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
|
|
144
|
+
'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
|
|
145
|
+
'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
var describe = function (element) {
|
|
149
|
+
var computed = window.getComputedStyle(element);
|
|
150
|
+
var attributes = {};
|
|
151
|
+
for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
|
|
152
|
+
var name = INTERESTING_ATTRS[i];
|
|
153
|
+
var value = element.getAttribute(name);
|
|
154
|
+
if (value) attributes[name] = String(value).slice(0, 200);
|
|
155
|
+
}
|
|
156
|
+
var computedStyle = {};
|
|
157
|
+
for (var j = 0; j < STYLE_PROPS.length; j += 1) {
|
|
158
|
+
var prop = STYLE_PROPS[j];
|
|
159
|
+
computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
|
|
160
|
+
}
|
|
161
|
+
var ancestry = [];
|
|
162
|
+
var node = element.parentElement;
|
|
163
|
+
var depth = 0;
|
|
164
|
+
while (node && node.nodeType === 1 && depth < 4) {
|
|
165
|
+
var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
|
|
166
|
+
if (node.id) entry.id = node.id;
|
|
167
|
+
var cls = typeof node.className === 'string' ? node.className.trim() : '';
|
|
168
|
+
if (cls) entry.className = cls.slice(0, 200);
|
|
169
|
+
ancestry.unshift(entry);
|
|
170
|
+
node = node.parentElement;
|
|
171
|
+
depth += 1;
|
|
172
|
+
}
|
|
173
|
+
var box = element.getBoundingClientRect();
|
|
174
|
+
var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
|
|
175
|
+
return {
|
|
176
|
+
tag: element.tagName.toLowerCase(),
|
|
177
|
+
text: text.slice(0, MAX_TEXT),
|
|
178
|
+
selector: buildSelector(element),
|
|
179
|
+
path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
|
|
180
|
+
bounds: rectFrom(box),
|
|
181
|
+
center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
|
|
182
|
+
attributes: attributes,
|
|
183
|
+
computedStyle: computedStyle,
|
|
184
|
+
ancestry: ancestry
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// ------------------------------------------------------------------ chrome
|
|
189
|
+
|
|
190
|
+
var host = document.createElement('div');
|
|
191
|
+
host.setAttribute(OVERLAY_ATTR, '');
|
|
192
|
+
host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
|
|
193
|
+
var shadow = host.attachShadow({ mode: 'closed' });
|
|
194
|
+
|
|
195
|
+
var style = document.createElement('style');
|
|
196
|
+
style.textContent = [
|
|
197
|
+
':host{all:initial}',
|
|
198
|
+
'*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
|
|
199
|
+
'.layer{position:fixed;inset:0;pointer-events:none}',
|
|
200
|
+
'.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
|
|
201
|
+
'.label{position:fixed;left:0;top:0;display:none;pointer-events:none;padding:1px 6px;border-radius:4px;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';font-size:11px;line-height:17px;white-space:nowrap;font-weight:600}',
|
|
202
|
+
'.tools{position:fixed;top:14px;left:50%;transform:translateX(-50%);display:flex;gap:2px;padding:4px;border-radius:999px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 6px 20px rgba(0,0,0,.24);pointer-events:auto}',
|
|
203
|
+
'.tools button{appearance:none;border:none;background:transparent;color:' + THEME.mutedText + ';border-radius:999px;padding:5px 14px;font-size:12px;line-height:18px;font-weight:500;cursor:pointer;white-space:nowrap}',
|
|
204
|
+
'.tools button:hover{background:' + THEME.primaryFaint + '}',
|
|
205
|
+
'.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
|
|
206
|
+
'.editor{position:fixed;left:0;top:0;display:none;align-items:center;gap:8px;width:min(420px,calc(100vw - 24px));padding:6px;padding-left:16px;border-radius:22px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 8px 28px rgba(0,0,0,.3);pointer-events:auto}',
|
|
207
|
+
'.editor textarea{flex:1;min-width:0;resize:none;border:none;background:transparent;color:' + THEME.text + ';font-size:13px;line-height:20px;outline:none;padding:6px 0;min-height:32px;max-height:104px;display:block}',
|
|
208
|
+
'.editor textarea::placeholder{color:' + THEME.mutedText + '}',
|
|
209
|
+
'.editor button{appearance:none;border:none;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';border-radius:999px;width:32px;height:32px;padding:0;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer}',
|
|
210
|
+
'.editor button svg{width:16px;height:16px;display:block}',
|
|
211
|
+
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
212
|
+
].join('');
|
|
213
|
+
shadow.appendChild(style);
|
|
214
|
+
|
|
215
|
+
var cursorStyle = document.createElement('style');
|
|
216
|
+
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
217
|
+
document.head.appendChild(cursorStyle);
|
|
218
|
+
var setCursor = function (value) {
|
|
219
|
+
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
var svgNS = 'http://www.w3.org/2000/svg';
|
|
223
|
+
var svg = document.createElementNS(svgNS, 'svg');
|
|
224
|
+
svg.setAttribute('class', 'layer');
|
|
225
|
+
svg.style.overflow = 'visible';
|
|
226
|
+
shadow.appendChild(svg);
|
|
227
|
+
|
|
228
|
+
var hoverBox = document.createElement('div');
|
|
229
|
+
hoverBox.className = 'box';
|
|
230
|
+
var hoverLabel = document.createElement('div');
|
|
231
|
+
hoverLabel.className = 'label';
|
|
232
|
+
var marqueeBox = document.createElement('div');
|
|
233
|
+
marqueeBox.className = 'box';
|
|
234
|
+
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
235
|
+
|
|
236
|
+
var positionBox = function (node, rect) {
|
|
237
|
+
node.style.display = 'block';
|
|
238
|
+
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
239
|
+
node.style.width = rect.width + 'px';
|
|
240
|
+
node.style.height = rect.height + 'px';
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
var tools = document.createElement('div');
|
|
244
|
+
tools.className = 'tools';
|
|
245
|
+
shadow.appendChild(tools);
|
|
246
|
+
|
|
247
|
+
var toolButtons = {};
|
|
248
|
+
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
249
|
+
var button = document.createElement('button');
|
|
250
|
+
button.type = 'button';
|
|
251
|
+
button.textContent = entry[1];
|
|
252
|
+
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
253
|
+
toolButtons[entry[0]] = button;
|
|
254
|
+
tools.appendChild(button);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
var editor = document.createElement('div');
|
|
258
|
+
editor.className = 'editor';
|
|
259
|
+
shadow.appendChild(editor);
|
|
260
|
+
|
|
261
|
+
var comment = document.createElement('textarea');
|
|
262
|
+
comment.rows = 1;
|
|
263
|
+
comment.placeholder = LABELS.commentPlaceholder;
|
|
264
|
+
var submit = document.createElement('button');
|
|
265
|
+
submit.type = 'button';
|
|
266
|
+
// Icon-only attach button (Remix attachment-2), matching the chat comment
|
|
267
|
+
// input; the localized label stays available to assistive tech.
|
|
268
|
+
submit.setAttribute('aria-label', LABELS.submit);
|
|
269
|
+
submit.title = LABELS.submit;
|
|
270
|
+
submit.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/></svg>';
|
|
271
|
+
editor.append(comment, submit);
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Grows the box with its content.
|
|
275
|
+
*
|
|
276
|
+
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
277
|
+
* field to nothing — which is what left a sliver of a click target and an
|
|
278
|
+
* invisible caret. Measuring only while visible, and never below the CSS
|
|
279
|
+
* min-height, keeps it usable.
|
|
280
|
+
*/
|
|
281
|
+
var resizeComment = function () {
|
|
282
|
+
if (editor.style.display === 'none') return;
|
|
283
|
+
comment.style.height = 'auto';
|
|
284
|
+
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
285
|
+
};
|
|
286
|
+
comment.addEventListener('input', resizeComment);
|
|
287
|
+
|
|
288
|
+
// -------------------------------------------------------------- selection
|
|
289
|
+
|
|
290
|
+
var lastTargetRect = null;
|
|
291
|
+
|
|
292
|
+
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
293
|
+
var positionEditor = function () {
|
|
294
|
+
if (!lastTargetRect) {
|
|
295
|
+
editor.style.display = 'none';
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
var wasHidden = editor.style.display === 'none';
|
|
299
|
+
editor.style.display = 'flex';
|
|
300
|
+
// Measured now that it is laid out, not while it was still hidden.
|
|
301
|
+
if (wasHidden) resizeComment();
|
|
302
|
+
var box = editor.getBoundingClientRect();
|
|
303
|
+
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
304
|
+
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
305
|
+
// Above the target when there is no room below, so the box is never left
|
|
306
|
+
// half off the bottom of the page.
|
|
307
|
+
if (top + box.height > window.innerHeight - 8) {
|
|
308
|
+
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
309
|
+
}
|
|
310
|
+
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
311
|
+
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
315
|
+
var focusComment = function () {
|
|
316
|
+
requestAnimationFrame(function () {
|
|
317
|
+
try {
|
|
318
|
+
comment.focus({ preventScroll: true });
|
|
319
|
+
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
320
|
+
} catch (error) { /* field went away */ }
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
var hasTargets = function () {
|
|
325
|
+
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
var syncChrome = function () {
|
|
329
|
+
submit.disabled = !hasTargets();
|
|
330
|
+
if (!hasTargets()) {
|
|
331
|
+
lastTargetRect = null;
|
|
332
|
+
editor.style.display = 'none';
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
positionEditor();
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
var syncSelectionVisuals = function () {
|
|
339
|
+
if (!selected) return;
|
|
340
|
+
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
341
|
+
if (!usableRect(rect)) {
|
|
342
|
+
selected.outline.style.display = 'none';
|
|
343
|
+
selected.badge.style.display = 'none';
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
positionBox(selected.outline, rect);
|
|
347
|
+
selected.badge.style.display = 'block';
|
|
348
|
+
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
349
|
+
lastTargetRect = rect;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
var dropSelection = function () {
|
|
353
|
+
if (!selected) return;
|
|
354
|
+
selected.outline.remove();
|
|
355
|
+
selected.badge.remove();
|
|
356
|
+
selected = null;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
var selectElement = function (element) {
|
|
360
|
+
var wasSelected = selected && selected.element === element;
|
|
361
|
+
dropSelection();
|
|
362
|
+
if (wasSelected) {
|
|
363
|
+
// Clicking the chosen element again clears it, so a misclick costs one
|
|
364
|
+
// click rather than starting over.
|
|
365
|
+
lastTargetRect = null;
|
|
366
|
+
syncChrome();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
var outline = document.createElement('div');
|
|
370
|
+
outline.className = 'box';
|
|
371
|
+
var badge = document.createElement('div');
|
|
372
|
+
badge.className = 'label';
|
|
373
|
+
badge.textContent = selectorPart(element);
|
|
374
|
+
shadow.append(outline, badge);
|
|
375
|
+
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
376
|
+
syncSelectionVisuals();
|
|
377
|
+
syncChrome();
|
|
378
|
+
focusComment();
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
var setTool = function (next) {
|
|
382
|
+
tool = next;
|
|
383
|
+
hoverBox.style.display = 'none';
|
|
384
|
+
hoverLabel.style.display = 'none';
|
|
385
|
+
marqueeBox.style.display = 'none';
|
|
386
|
+
setCursor(next === 'select' ? '' : 'crosshair');
|
|
387
|
+
for (var key in toolButtons) {
|
|
388
|
+
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
389
|
+
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
// ------------------------------------------------------------- interaction
|
|
395
|
+
|
|
396
|
+
var drag = null;
|
|
397
|
+
|
|
398
|
+
var onPointerMove = function (event) {
|
|
399
|
+
if (drag) {
|
|
400
|
+
if (drag.kind === 'marquee') {
|
|
401
|
+
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
402
|
+
positionBox(marqueeBox, drag.rect);
|
|
403
|
+
} else if (drag.kind === 'draw') {
|
|
404
|
+
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
405
|
+
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
406
|
+
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
407
|
+
}).join(' '));
|
|
408
|
+
}
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (tool !== 'select') return;
|
|
413
|
+
var element = elementFromPoint(event.clientX, event.clientY);
|
|
414
|
+
if (!element) {
|
|
415
|
+
hoverBox.style.display = 'none';
|
|
416
|
+
hoverLabel.style.display = 'none';
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
var rect = rectFrom(element.getBoundingClientRect());
|
|
420
|
+
positionBox(hoverBox, rect);
|
|
421
|
+
hoverLabel.textContent = selectorPart(element);
|
|
422
|
+
hoverLabel.style.display = 'block';
|
|
423
|
+
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
var onPointerDown = function (event) {
|
|
427
|
+
if (event.button !== 0) return;
|
|
428
|
+
if (isOverlayNode(event.target)) return;
|
|
429
|
+
event.preventDefault();
|
|
430
|
+
event.stopPropagation();
|
|
431
|
+
|
|
432
|
+
if (tool === 'select') {
|
|
433
|
+
var element = elementFromPoint(event.clientX, event.clientY);
|
|
434
|
+
if (element) selectElement(element);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (tool === 'marquee') {
|
|
439
|
+
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
var path = document.createElementNS(svgNS, 'path');
|
|
444
|
+
path.setAttribute('fill', 'none');
|
|
445
|
+
path.setAttribute('stroke', THEME.primary);
|
|
446
|
+
path.setAttribute('stroke-width', '2.5');
|
|
447
|
+
path.setAttribute('stroke-linecap', 'round');
|
|
448
|
+
path.setAttribute('stroke-linejoin', 'round');
|
|
449
|
+
svg.appendChild(path);
|
|
450
|
+
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
var onPointerUp = function () {
|
|
454
|
+
if (!drag) return;
|
|
455
|
+
var finished = drag;
|
|
456
|
+
drag = null;
|
|
457
|
+
|
|
458
|
+
if (finished.kind === 'marquee') {
|
|
459
|
+
marqueeBox.style.display = 'none';
|
|
460
|
+
var rect = finished.rect;
|
|
461
|
+
if (!rect || !usableRect(rect)) return;
|
|
462
|
+
// A region marks an area, not the elements inside it: expanding it into a
|
|
463
|
+
// selection made the result depend on the page's markup rather than on
|
|
464
|
+
// what was drawn.
|
|
465
|
+
regions.push({ id: nextId('region'), rect: rect });
|
|
466
|
+
var outline = document.createElementNS(svgNS, 'rect');
|
|
467
|
+
outline.setAttribute('x', String(rect.x));
|
|
468
|
+
outline.setAttribute('y', String(rect.y));
|
|
469
|
+
outline.setAttribute('width', String(rect.width));
|
|
470
|
+
outline.setAttribute('height', String(rect.height));
|
|
471
|
+
outline.style.fill = THEME.primarySoft;
|
|
472
|
+
outline.setAttribute('stroke', THEME.primary);
|
|
473
|
+
outline.setAttribute('stroke-width', '1.5');
|
|
474
|
+
outline.setAttribute('rx', '2');
|
|
475
|
+
svg.appendChild(outline);
|
|
476
|
+
lastTargetRect = rect;
|
|
477
|
+
syncChrome();
|
|
478
|
+
focusComment();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
var points = finished.points;
|
|
483
|
+
if (points.length < 2) {
|
|
484
|
+
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
488
|
+
for (var p = 1; p < points.length; p += 1) {
|
|
489
|
+
minX = Math.min(minX, points[p].x);
|
|
490
|
+
minY = Math.min(minY, points[p].y);
|
|
491
|
+
maxX = Math.max(maxX, points[p].x);
|
|
492
|
+
maxY = Math.max(maxY, points[p].y);
|
|
493
|
+
}
|
|
494
|
+
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
495
|
+
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
496
|
+
lastTargetRect = bounds;
|
|
497
|
+
syncChrome();
|
|
498
|
+
focusComment();
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Swallows the page's own mouse handling while annotating.
|
|
503
|
+
*
|
|
504
|
+
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
505
|
+
* button pressed that button and marking a link navigated away from the page
|
|
506
|
+
* being annotated. These are the events that reach page code, so these are
|
|
507
|
+
* the ones that have to stop.
|
|
508
|
+
*/
|
|
509
|
+
var blockPageInteraction = function (event) {
|
|
510
|
+
if (isOverlayNode(event.target)) return;
|
|
511
|
+
event.preventDefault();
|
|
512
|
+
event.stopPropagation();
|
|
513
|
+
};
|
|
514
|
+
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
515
|
+
|
|
516
|
+
var onScrollOrResize = function () {
|
|
517
|
+
syncSelectionVisuals();
|
|
518
|
+
positionEditor();
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
var onKeyDown = function (event) {
|
|
522
|
+
if (event.isComposing || event.keyCode === 229) return;
|
|
523
|
+
if (event.key === 'Escape') {
|
|
524
|
+
event.preventDefault();
|
|
525
|
+
event.stopImmediatePropagation();
|
|
526
|
+
finish(null);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
var onCommentKeyDown = function (event) {
|
|
531
|
+
// Do not let the annotated page treat typed letters as its own shortcuts.
|
|
532
|
+
event.stopPropagation();
|
|
533
|
+
// WebKit can report the composition-confirming Enter as keyCode 229.
|
|
534
|
+
if (event.isComposing || event.keyCode === 229) return;
|
|
535
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
536
|
+
event.preventDefault();
|
|
537
|
+
attach();
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
document.addEventListener('pointermove', onPointerMove, true);
|
|
542
|
+
document.addEventListener('pointerdown', onPointerDown, true);
|
|
543
|
+
document.addEventListener('pointerup', onPointerUp, true);
|
|
544
|
+
BLOCKED_EVENTS.forEach(function (name) {
|
|
545
|
+
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
546
|
+
});
|
|
547
|
+
window.addEventListener('scroll', onScrollOrResize, true);
|
|
548
|
+
window.addEventListener('resize', onScrollOrResize, true);
|
|
549
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
550
|
+
comment.addEventListener('keydown', onCommentKeyDown);
|
|
551
|
+
|
|
552
|
+
// ------------------------------------------------------------------ finish
|
|
553
|
+
|
|
554
|
+
var teardown = function () {
|
|
555
|
+
document.removeEventListener('pointermove', onPointerMove, true);
|
|
556
|
+
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
557
|
+
document.removeEventListener('pointerup', onPointerUp, true);
|
|
558
|
+
BLOCKED_EVENTS.forEach(function (name) {
|
|
559
|
+
window.removeEventListener(name, blockPageInteraction, true);
|
|
560
|
+
});
|
|
561
|
+
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
562
|
+
window.removeEventListener('resize', onScrollOrResize, true);
|
|
563
|
+
window.removeEventListener('keydown', onKeyDown, true);
|
|
564
|
+
comment.removeEventListener('keydown', onCommentKeyDown);
|
|
565
|
+
setCursor('');
|
|
566
|
+
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
567
|
+
if (host.parentNode) host.parentNode.removeChild(host);
|
|
568
|
+
try { delete window['${Qi}']; } catch (error) { /* non-configurable */ }
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
var finish = function (payload) {
|
|
572
|
+
if (settled) return;
|
|
573
|
+
settled = true;
|
|
574
|
+
teardown();
|
|
575
|
+
// Removing the chrome is not enough: the host screenshots this page right
|
|
576
|
+
// after we resolve, and the compositor can still hold a frame containing
|
|
577
|
+
// our outlines. Yield two frames so the page has actually repainted.
|
|
578
|
+
requestAnimationFrame(function () {
|
|
579
|
+
requestAnimationFrame(function () { resolve(payload); });
|
|
580
|
+
});
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
var attach = function () {
|
|
584
|
+
if (!hasTargets()) return;
|
|
585
|
+
finish({
|
|
586
|
+
id: 'annotation-' + Date.now(),
|
|
587
|
+
pageUrl: String(location.href),
|
|
588
|
+
pageTitle: String(document.title || ''),
|
|
589
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
590
|
+
devicePixelRatio: window.devicePixelRatio || 1,
|
|
591
|
+
comment: comment.value,
|
|
592
|
+
// Zero or one element, never more. Kept as a list so elements, regions
|
|
593
|
+
// and strokes stay one uniform shape for everything downstream.
|
|
594
|
+
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
595
|
+
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
596
|
+
strokes: strokes.map(function (entry) {
|
|
597
|
+
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
598
|
+
})
|
|
599
|
+
});
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
submit.addEventListener('click', attach);
|
|
603
|
+
|
|
604
|
+
(document.body || document.documentElement).appendChild(host);
|
|
605
|
+
setTool('select');
|
|
606
|
+
syncChrome();
|
|
607
|
+
});`},e1={kind:"idle"},yn=t=>typeof t=="object"&&t!==null,kn=t=>typeof t=="number"&&Number.isFinite(t),ql=t=>yn(t)&&Object.values(t).every(e=>typeof e=="string"),La=t=>yn(t)&&kn(t.x)&&kn(t.y)&&kn(t.width)&&kn(t.height),zu=t=>yn(t)&&kn(t.x)&&kn(t.y),t1=t=>yn(t)&&typeof t.tag=="string"&&typeof t.selectorPart=="string"&&(t.id===void 0||typeof t.id=="string")&&(t.className===void 0||typeof t.className=="string"),s1=t=>yn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&La(t.bounds)&&zu(t.center)&&ql(t.attributes)&&ql(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(t1),n1=t=>yn(t)&&typeof t.id=="string"&&s1(t.element),r1=t=>yn(t)&&typeof t.id=="string"&&La(t.rect),o1=t=>yn(t)&&typeof t.id=="string"&&La(t.bounds)&&Array.isArray(t.points)&&t.points.every(zu),i1=t=>yn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&yn(t.viewport)&&kn(t.viewport.width)&&kn(t.viewport.height)&&kn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(n1)&&Array.isArray(t.regions)&&t.regions.every(r1)&&Array.isArray(t.strokes)&&t.strokes.every(o1),a1=1600,l1=t=>new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>n(new Error("Failed to decode browser page capture")),r.src=t}),c1=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:u})=>{if(!t)return null;try{const d=await l1(`data:${e};base64,${t}`),h=Math.max(1,d.naturalWidth||n),m=Math.max(1,d.naturalHeight||r),p=h/Math.max(1,i||h),g=m/Math.max(1,o||m),w=Math.min(1,a1/h),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(h*w)),v.height=Math.max(1,Math.floor(m*w));const x=v.getContext("2d");if(!x)return null;x.scale(w,w),x.drawImage(d,0,0,h,m);const f=N=>({x:N.x*p,y:N.y*g,width:N.width*p,height:N.height*g}),b=Math.max(2,2.5*p/Math.max(w,.2));x.strokeStyle=a,x.fillStyle=u;const y=N=>{const C=f(N);x.lineWidth=b,x.fillRect(C.x,C.y,C.width,C.height),x.strokeRect(C.x,C.y,C.width,C.height)};for(const N of l.elements)y(N.element.bounds);for(const N of l.regions)y(N.rect);for(const N of l.strokes)N.points.length<2||(x.beginPath(),N.points.forEach((C,j)=>{const A=C.x*p,P=C.y*g;j===0?x.moveTo(A,P):x.lineTo(A,P)}),x.lineCap="round",x.lineJoin="round",x.lineWidth=b*1.4,x.stroke());const S=await new Promise(N=>v.toBlob(N,"image/jpeg",.85));return S?new File([S],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},d1="({ width: window.innerWidth, height: window.innerHeight })",u1=async t=>{try{const e=await t.executeJavaScript(d1,!0);if(!e||typeof e!="object")return null;const n=e;return typeof n.width!="number"||typeof n.height!="number"||!Number.isFinite(n.width)||!Number.isFinite(n.height)?null:{width:n.width,height:n.height}}catch{return null}},bo=async t=>{try{await t.executeJavaScript(Jy,!1)}catch{}},f1=async({host:t,theme:e,labels:n})=>{const r=Zy(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!i1(i))return await bo(t),null;const o=i;try{const l=await u1(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const u=await c1({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:u}}catch{return{payload:o,screenshot:null}}},rn={colorScheme:"dark",primary:"rgb(59, 130, 246)",primarySoft:"rgba(59, 130, 246, 0.16)",primaryFaint:"rgba(59, 130, 246, 0.10)",primaryContrast:"rgb(255, 255, 255)",surface:"rgb(24, 24, 27)",surfaceElevated:"rgb(32, 32, 36)",glassSurface:"rgba(32, 32, 36, 0.64)",glassFilter:"blur(26px) saturate(1.16)",border:"rgba(255, 255, 255, 0.14)",text:"rgb(244, 244, 245)",mutedText:"rgba(244, 244, 245, 0.62)"},m1=()=>{if(typeof document>"u"||!document.body)return null;const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none",document.body.appendChild(t),{read:e=>{t.style.backgroundColor="",t.style.backgroundColor=e;const n=window.getComputedStyle(t).backgroundColor;return n&&n!=="rgba(0, 0, 0, 0)"?n:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},h1=t=>{const e=m1();if(!e)return{...rn,colorScheme:t};try{const n=(a,u)=>e.read(`var(${a})`)||u,r=(a,u,d)=>e.read(`color-mix(in srgb, var(${a}) ${u}%, transparent)`)||d,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||rn.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",rn.primary),primarySoft:r("--primary",16,rn.primarySoft),primaryFaint:r("--primary",10,rn.primaryFaint),primaryContrast:n("--primary-foreground",rn.primaryContrast),surface:n("--surface-background",rn.surface),surfaceElevated:n("--surface-elevated",rn.surfaceElevated),border:n("--border",rn.border),text:n("--foreground",rn.text),mutedText:n("--muted-foreground",rn.mutedText)}}catch{return{...rn,colorScheme:t}}finally{e.dispose()}},p1=2e3,g1=50;let Qn=null,hr=null,Fr=null;const x1=async t=>{try{const e=await ds("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===!0:!1}catch{return!1}},nr=async(t,e)=>{try{const n=await ds("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},b1=async(t=p1)=>{const e=Date.now()+t;for(;!Qn&&Date.now()<e;)await new Promise(n=>setTimeout(n,g1));return Qn},y1=async t=>{const e=t.action==="browser.open",n=Qn;if(!(!n&&!(e&&hr))&&await x1(t.requestId))try{if(e&&!n){const i=typeof t.parameters.url=="string"?t.parameters.url:"";if(!i){await nr(t.requestId,{ok:!1,error:"url is required"});return}hr?.(i);const o=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!o||o==="fill"){await nr(t.requestId,{ok:!0,data:{url:i,opened:!0}});return}const l=await b1();if(!l){await nr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const a=await l.run("browser.resize",{viewport:o}),u=a&&typeof a=="object"?a.viewport??null:null;await nr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!0,viewport:u}});return}const r=await n.run(t.action,t.parameters);await nr(t.requestId,{ok:!0,data:r})}catch(r){await nr(t.requestId,{ok:!1,error:r instanceof Error?r.message:String(r)})}},Vu=()=>{Fr||(Fr=Yr(t=>{t.type==="browser-control-request"&&y1({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Uu=()=>{Qn||hr||!Fr||(Fr(),Fr=null)},w1=t=>(Qn=t,Vu(),()=>{Qn===t&&(Qn=null),Uu()}),S1=t=>(hr=t,Vu(),()=>{hr===t&&(hr=null),Uu()}),v1=50,j1=6,k1=2048,C1=200,Ku=t=>{const e=mr(String(t??"").trim());if(!e||e.length>k1)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},N1=(t,e)=>{const n=Ku(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,C1)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,v1)},A1=(t,e)=>{const n=Ku(e);return t.filter(r=>r.url!==n)},D1=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Hu=(t,e,n=j1)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return i.slice(0,n);const o=r.replace(/^https?:\/\//,"");return i.filter(l=>{const a=D1(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},Ql=20,yo=t=>{const e=yt((t||"").trim());return e?JSON.stringify([ps(),e]):""},P1=t=>{const e=Object.keys(t);if(e.length<=Ql)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,Ql);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},pr=er()(Bg(t=>({byProject:{},recordVisit:(e,n)=>{const r=yo(e);r&&t(i=>{const o=i.byProject[r]??[],l=N1(o,{...n,at:Date.now()});return l===o?i:{byProject:P1({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=yo(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:A1(o,n)}}:i})},clear:e=>{const n=yo(e);n&&t(r=>{if(!(n in r.byProject))return r;const i={...r.byProject};return delete i[n],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:Jf(),partialize:t=>({byProject:t.byProject})})),I1=[],Gu=t=>e=>{const n=yo(t);return(n?e.byProject[n]:void 0)??I1},Yi=new Map,Jo=new Map,Yn=new Map,Xn=new Set,T1=async(t,e)=>{if(!Ka()){Xn.delete(t),or(t,{type:"close"});return}if(await Zf(Nn()),!Xn.has(t)||!Ka())return;const n=ld().websocket(`/api/dev-tunnel?port=${e}`),r=em(n);Yn.set(t,r),r.binaryType="arraybuffer",r.onopen=()=>or(t,{type:"ready"}),r.onmessage=i=>or(t,{type:"data",data:i.data instanceof ArrayBuffer?i.data:new TextEncoder().encode(i.data)}),r.onerror=()=>or(t,{type:"close"}),r.onclose=()=>{Xn.delete(t),Yn.delete(t),or(t,{type:"close"})}};qm(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=Yn.get(t);r&&n.data&&r.send(n.data);return}case"close":Xn.delete(t),Yn.get(t)?.close(),Yn.delete(t);return;case"connect":Xn.add(t),T1(t,e).catch(()=>{Xn.delete(t),or(t,{type:"close"})})}});const qu=()=>typeof window<"u"&&!!window.__AIWORKER_ELECTRON__,Qu=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),n=typeof window<"u"?window.__AIWORKER_LOCAL_ORIGIN__:"";return n&&e.origin===n?!1:!yr(e.toString())}catch{return!1}},Yu=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:0}catch{return 0}},Yl=(t,e)=>{try{const n=new URL(t);return n.protocol="http:",n.hostname="127.0.0.1",n.port=String(e),n.toString()}catch{return t}},Xl=(t,e)=>{try{Jo.set(e,new URL(t).origin)}catch{}};class _r extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const Jl=async t=>{if(!t||!qu()||!yr(t))return t;const e=Nn();if(!Qu(e))return t;const n=Yu(t);if(!n)return t;const r=`${e}|${n}`,i=Yi.get(r);if(i)return Xl(t,i),Yl(t,i);try{const o=await ur("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:tm(),targetKey:ps(),clientToken:Lr(),requestHeaders:cd()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new _r(t);return Yi.set(r,o.localPort),Xl(t,o.localPort),Yl(t,o.localPort)}catch(o){throw o instanceof _r?o:new _r(t)}},Zl=t=>{if(!t||!qu()||!yr(t)||!Qu(Nn()))return!1;const e=Yu(t);return e>0&&!Jo.has(e)},Nr=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=Jo.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},R1=()=>{Yi.clear(),Jo.clear(),Xn.clear();for(const t of Yn.values())t.close();Yn.clear(),ur("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&fa(R1);const ec=6e3,E1=120,M1=80,O1=`
|
|
608
|
+
var MAX_ELEMENTS = ${E1};
|
|
609
|
+
var MAX_LABEL_CHARS = ${M1};
|
|
610
|
+
var visible = function (element) {
|
|
611
|
+
var rect = element.getBoundingClientRect();
|
|
612
|
+
if (rect.width < 1 || rect.height < 1) return false;
|
|
613
|
+
var style = window.getComputedStyle(element);
|
|
614
|
+
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
615
|
+
};
|
|
616
|
+
var label = function (element) {
|
|
617
|
+
var aria = element.getAttribute('aria-label');
|
|
618
|
+
if (aria) return aria.trim();
|
|
619
|
+
var value = element.getAttribute('value');
|
|
620
|
+
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
621
|
+
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
622
|
+
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
623
|
+
var placeholder = element.getAttribute('placeholder');
|
|
624
|
+
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
625
|
+
};
|
|
626
|
+
var isUnique = function (selector) {
|
|
627
|
+
try {
|
|
628
|
+
return document.querySelectorAll(selector).length === 1;
|
|
629
|
+
} catch (error) {
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Names an element by what it is, falling back to where it sits.
|
|
636
|
+
*
|
|
637
|
+
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
638
|
+
* only until the markup shifts, and says nothing about what it points at.
|
|
639
|
+
* Anything the page states about identity — an id, a test id, an accessible
|
|
640
|
+
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
641
|
+
* as the last resort, because something always has to work.
|
|
642
|
+
*/
|
|
643
|
+
var cssPath = function (element) {
|
|
644
|
+
var tag = element.tagName.toLowerCase();
|
|
645
|
+
|
|
646
|
+
if (element.id) {
|
|
647
|
+
var byId = '#' + CSS.escape(element.id);
|
|
648
|
+
if (isUnique(byId)) return byId;
|
|
649
|
+
}
|
|
650
|
+
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
651
|
+
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
652
|
+
var value = element.getAttribute(stableAttrs[a]);
|
|
653
|
+
if (!value) continue;
|
|
654
|
+
var raw = String(value);
|
|
655
|
+
// A value containing a quote would need escaping for no real gain: such
|
|
656
|
+
// attributes are rare, and the positional chain still covers them.
|
|
657
|
+
if (raw.indexOf('"') !== -1) continue;
|
|
658
|
+
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
659
|
+
if (isUnique(byAttr)) return byAttr;
|
|
660
|
+
}
|
|
661
|
+
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
662
|
+
if (className) {
|
|
663
|
+
var classes = className.split(/\\s+/).filter(Boolean);
|
|
664
|
+
for (var c = 0; c < classes.length; c += 1) {
|
|
665
|
+
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
666
|
+
if (isUnique(byClass)) return byClass;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
var parts = [];
|
|
671
|
+
var node = element;
|
|
672
|
+
var depth = 0;
|
|
673
|
+
while (node && node.nodeType === 1 && depth < 6) {
|
|
674
|
+
var part = node.tagName.toLowerCase();
|
|
675
|
+
var parent = node.parentElement;
|
|
676
|
+
if (!parent) { parts.unshift(part); break; }
|
|
677
|
+
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
678
|
+
return child.tagName === node.tagName;
|
|
679
|
+
});
|
|
680
|
+
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
681
|
+
parts.unshift(part);
|
|
682
|
+
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
683
|
+
node = parent;
|
|
684
|
+
depth += 1;
|
|
685
|
+
}
|
|
686
|
+
return parts.join(' > ');
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
690
|
+
var accessibleName = function (element) {
|
|
691
|
+
var aria = element.getAttribute('aria-label');
|
|
692
|
+
if (aria && aria.trim()) return aria.trim();
|
|
693
|
+
var labelled = element.getAttribute('aria-labelledby');
|
|
694
|
+
if (labelled) {
|
|
695
|
+
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
696
|
+
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
697
|
+
}
|
|
698
|
+
var title = element.getAttribute('title');
|
|
699
|
+
if (title && title.trim()) return title.trim();
|
|
700
|
+
var alt = element.getAttribute('alt');
|
|
701
|
+
if (alt && alt.trim()) return alt.trim();
|
|
702
|
+
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
703
|
+
if (text) return text;
|
|
704
|
+
var value = element.getAttribute('value');
|
|
705
|
+
return value && String(value).trim() ? String(value).trim() : '';
|
|
706
|
+
};
|
|
707
|
+
var findByText = function (needle) {
|
|
708
|
+
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
709
|
+
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
710
|
+
var exact = null;
|
|
711
|
+
var partial = null;
|
|
712
|
+
for (var i = 0; i < candidates.length; i += 1) {
|
|
713
|
+
var element = candidates[i];
|
|
714
|
+
if (!visible(element)) continue;
|
|
715
|
+
var text = label(element).toLowerCase();
|
|
716
|
+
if (!text) continue;
|
|
717
|
+
if (text === wanted) { exact = element; break; }
|
|
718
|
+
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
719
|
+
}
|
|
720
|
+
return exact || partial;
|
|
721
|
+
};
|
|
722
|
+
`,Xr=t=>`(() => {
|
|
723
|
+
${O1}
|
|
724
|
+
${t}
|
|
725
|
+
})()`,F1=({selector:t}={})=>Xr(`
|
|
726
|
+
var scopeSelector = ${JSON.stringify(t??"")};
|
|
727
|
+
var root = document;
|
|
728
|
+
if (scopeSelector) {
|
|
729
|
+
try { root = document.querySelector(scopeSelector); }
|
|
730
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
731
|
+
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
732
|
+
}
|
|
733
|
+
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
734
|
+
var elements = [];
|
|
735
|
+
var visibleTotal = 0;
|
|
736
|
+
for (var i = 0; i < interactive.length; i += 1) {
|
|
737
|
+
var element = interactive[i];
|
|
738
|
+
if (!visible(element)) continue;
|
|
739
|
+
visibleTotal += 1;
|
|
740
|
+
if (elements.length >= MAX_ELEMENTS) continue;
|
|
741
|
+
|
|
742
|
+
var rect = element.getBoundingClientRect();
|
|
743
|
+
// Empty and default-valued fields are left out rather than serialized as
|
|
744
|
+
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
745
|
+
// the information it carried.
|
|
746
|
+
var entry = {
|
|
747
|
+
selector: cssPath(element),
|
|
748
|
+
tag: element.tagName.toLowerCase(),
|
|
749
|
+
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
750
|
+
};
|
|
751
|
+
// The list covers the whole document so anything can be clicked without
|
|
752
|
+
// scrolling to it first, which means bounds alone do not say what is on
|
|
753
|
+
// screen — a negative y reads as a bug otherwise.
|
|
754
|
+
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
755
|
+
var type = element.getAttribute('type');
|
|
756
|
+
if (type) entry.type = type;
|
|
757
|
+
var role = element.getAttribute('role');
|
|
758
|
+
if (role) entry.role = role;
|
|
759
|
+
var labelText = label(element);
|
|
760
|
+
if (labelText) entry.label = labelText;
|
|
761
|
+
if (element.disabled === true) entry.disabled = true;
|
|
762
|
+
// Flagged rather than described: reporting the accessible name of every
|
|
763
|
+
// element would cost more than it tells, while its absence on something
|
|
764
|
+
// clickable is a defect worth naming.
|
|
765
|
+
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
766
|
+
elements.push(entry);
|
|
767
|
+
}
|
|
768
|
+
var body = document.body ? (document.body.innerText || '') : '';
|
|
769
|
+
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
770
|
+
var docEl = document.documentElement;
|
|
771
|
+
var result = {
|
|
772
|
+
ok: true,
|
|
773
|
+
url: String(location.href),
|
|
774
|
+
title: String(document.title || ''),
|
|
775
|
+
scope: scopeSelector || 'document',
|
|
776
|
+
scrollY: Math.round(window.scrollY),
|
|
777
|
+
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
778
|
+
text: text.slice(0, ${ec}),
|
|
779
|
+
elements: elements
|
|
780
|
+
};
|
|
781
|
+
// State what was dropped. A capped list that reports only its own length
|
|
782
|
+
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
783
|
+
if (text.length > ${ec}) {
|
|
784
|
+
result.textTruncated = true;
|
|
785
|
+
result.textTotalChars = text.length;
|
|
786
|
+
}
|
|
787
|
+
if (visibleTotal > elements.length) {
|
|
788
|
+
result.elementsTruncated = true;
|
|
789
|
+
result.interactiveElementsOnPage = visibleTotal;
|
|
790
|
+
}
|
|
791
|
+
return result;
|
|
792
|
+
`),_1=({selector:t,text:e})=>Xr(`
|
|
793
|
+
var selector = ${JSON.stringify(t??"")};
|
|
794
|
+
var text = ${JSON.stringify(e??"")};
|
|
795
|
+
var target = null;
|
|
796
|
+
if (selector) {
|
|
797
|
+
try { target = document.querySelector(selector); }
|
|
798
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
799
|
+
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
800
|
+
} else {
|
|
801
|
+
target = findByText(text);
|
|
802
|
+
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
803
|
+
}
|
|
804
|
+
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
805
|
+
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
806
|
+
target.click();
|
|
807
|
+
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
808
|
+
`),B1=({selector:t,value:e,submit:n})=>Xr(`
|
|
809
|
+
var selector = ${JSON.stringify(t)};
|
|
810
|
+
var value = ${JSON.stringify(e)};
|
|
811
|
+
var target = null;
|
|
812
|
+
try { target = document.querySelector(selector); }
|
|
813
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
814
|
+
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
815
|
+
|
|
816
|
+
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
817
|
+
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
818
|
+
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
819
|
+
|
|
820
|
+
target.scrollIntoView({ block: 'center' });
|
|
821
|
+
target.focus();
|
|
822
|
+
if (target.isContentEditable) {
|
|
823
|
+
target.textContent = value;
|
|
824
|
+
} else {
|
|
825
|
+
// Frameworks track the value through the native setter; assigning the
|
|
826
|
+
// property directly leaves React and friends unaware of the change.
|
|
827
|
+
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
828
|
+
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
829
|
+
if (setter && setter.set) setter.set.call(target, value);
|
|
830
|
+
else target.value = value;
|
|
831
|
+
}
|
|
832
|
+
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
833
|
+
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
834
|
+
|
|
835
|
+
if (${n?"true":"false"}) {
|
|
836
|
+
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
837
|
+
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
838
|
+
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
839
|
+
var form = target.form;
|
|
840
|
+
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
841
|
+
}
|
|
842
|
+
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
843
|
+
`),L1=({selector:t,direction:e})=>Xr(`
|
|
844
|
+
var selector = ${JSON.stringify(t??"")};
|
|
845
|
+
var direction = ${JSON.stringify(e??"")};
|
|
846
|
+
|
|
847
|
+
var settle = function (extra) {
|
|
848
|
+
return new Promise(function (resolve) {
|
|
849
|
+
requestAnimationFrame(function () {
|
|
850
|
+
requestAnimationFrame(function () {
|
|
851
|
+
var doc = document.documentElement;
|
|
852
|
+
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
853
|
+
var scrollY = Math.round(window.scrollY);
|
|
854
|
+
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
855
|
+
result.atTop = scrollY <= 1;
|
|
856
|
+
result.atBottom = scrollY >= maxScrollY - 1;
|
|
857
|
+
for (var key in extra) {
|
|
858
|
+
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
859
|
+
}
|
|
860
|
+
resolve(result);
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
});
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
if (selector) {
|
|
867
|
+
var target = null;
|
|
868
|
+
try { target = document.querySelector(selector); }
|
|
869
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
870
|
+
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
871
|
+
// Instant on purpose: the page's own smooth scrolling would still be
|
|
872
|
+
// animating when the next action runs against it.
|
|
873
|
+
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
874
|
+
return settle({ scrolledTo: cssPath(target) });
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
var doc = document.documentElement;
|
|
878
|
+
var page = Math.round(window.innerHeight * 0.85);
|
|
879
|
+
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
880
|
+
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
881
|
+
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
882
|
+
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
883
|
+
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
884
|
+
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
885
|
+
return settle({ direction: direction });
|
|
886
|
+
`),$1=["color","background-color","background-image","opacity","font-family","font-size","font-weight","line-height","letter-spacing","text-align","border-radius","border-width","border-style","border-color","box-shadow","display","position","width","height","padding","margin","gap","flex-direction","justify-content","align-items","z-index","overflow","visibility"],W1=({selector:t})=>Xr(`
|
|
887
|
+
var selector = ${JSON.stringify(t)};
|
|
888
|
+
var target = null;
|
|
889
|
+
try { target = document.querySelector(selector); }
|
|
890
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
891
|
+
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
892
|
+
|
|
893
|
+
var computed = window.getComputedStyle(target);
|
|
894
|
+
var styles = {};
|
|
895
|
+
var props = ${JSON.stringify($1)};
|
|
896
|
+
for (var i = 0; i < props.length; i += 1) {
|
|
897
|
+
var value = computed.getPropertyValue(props[i]);
|
|
898
|
+
if (value) styles[props[i]] = String(value).trim();
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
var rect = target.getBoundingClientRect();
|
|
902
|
+
return {
|
|
903
|
+
ok: true,
|
|
904
|
+
selector: cssPath(target),
|
|
905
|
+
tag: target.tagName.toLowerCase(),
|
|
906
|
+
label: label(target),
|
|
907
|
+
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
908
|
+
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
909
|
+
styles: styles
|
|
910
|
+
};
|
|
911
|
+
`),z1=t=>{const e=tt.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=At();if(n.length===0)return null;let u;e[0]!==a?(u=a("contextPanel.browser.history.label"),e[0]=a,e[1]=u):u=e[1];let d;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let m;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(m=(p,g)=>s.jsxs("div",{role:"option","aria-selected":g===r,className:Pe("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",g===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:w=>{w.preventDefault(),i(p.url)},onPointerEnter:()=>l(g),children:[s.jsx(E,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||Ba(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsx("button",{type:"button",className:Pe("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:w=>{w.preventDefault(),w.stopPropagation(),o(p.url)},children:s.jsx(E,{name:"close",className:"size-3","aria-hidden":"true"})})]},p.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=m):m=e[14],d=n.map(m),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=d}else d=e[8];let h;return e[15]!==u||e[16]!==d?(h=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":u,children:d}),e[15]=u,e[16]=d,e[17]=h):h=e[17],h},on=t=>{const e=tt.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",u=l&&"text-foreground";let d;e[0]!==u?(d=Pe("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",u),e[0]=u,e[1]=d):d=e[1];let h;e[2]!==n?(h=s.jsx(E,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let m;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==d||e[10]!==h?(m=s.jsx(Pt,{asChild:!0,children:s.jsx(pt,{type:"button",variant:a,size:"xs",className:d,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:h})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=d,e[10]=h,e[11]=m):m=e[11];let p;e[12]!==r?(p=s.jsx(It,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let g;return e[14]!==m||e[15]!==p?(g=s.jsxs(Dt,{children:[m,p]}),e[14]=m,e[15]=p,e[16]=g):g=e[16],g},Xu=t=>{const e=tt.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:u,onReload:d,onOpenExternal:h,canGoBack:m,canGoForward:p,isLoading:g,onAnnotate:w,onOpenDevTools:v,isAnnotating:x,onHardReload:f,onZoomIn:b,onZoomOut:y,onZoomReset:S,zoomPercent:N,onClearCookies:C,onClearCache:j,onToggleDeviceBar:A,isDeviceBarOpen:P}=t;let I;e[0]!==r?(I=r===void 0?[]:r,e[0]=r,e[1]=I):I=e[1];const M=I,z=N===void 0?100:N,{t:R}=At(),[H,F]=c.useState(!1),[O,T]=c.useState(-1);let k;e[2]!==H||e[3]!==M?(k=H?M:[],e[2]=H,e[3]=M,e[4]=k):k=e[4];const D=k;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{T(-1)},e[5]=L):L=e[5];let Q;e[6]!==n||e[7]!==H?(Q=[n,H],e[6]=n,e[7]=H,e[8]=Q):Q=e[8],c.useEffect(L,Q);let q;e[9]!==l?(q=Ne=>{F(!1),T(-1),l(Ne)},e[9]=l,e[10]=q):q=e[10];const te=q;let ae;e[11]!==O||e[12]!==te||e[13]!==D?(ae=Ne=>{if(D.length!==0){if(Ne.key==="ArrowDown"||Ne.key==="ArrowUp"){Ne.preventDefault();const Qe=Ne.key==="ArrowDown"?1:-1,We=D.length;T(U=>{const he=U+Qe;return he<-1?We-1:he>=We?-1:he});return}if(Ne.key==="Escape"&&O>=0){Ne.preventDefault(),T(-1);return}if(Ne.key==="Enter"&&O>=0){Ne.preventDefault();const Qe=D[O];Qe&&te(Qe.url)}}},e[11]=O,e[12]=te,e[13]=D,e[14]=ae):ae=e[14];const X=ae;let Z;e[15]!==R?(Z=R("contextPanel.browser.back"),e[15]=R,e[16]=Z):Z=e[16];const se=!m;let fe;e[17]!==a||e[18]!==se||e[19]!==Z?(fe=s.jsx(on,{icon:"arrow-left",label:Z,onClick:a,disabled:se}),e[17]=a,e[18]=se,e[19]=Z,e[20]=fe):fe=e[20];let B;e[21]!==R?(B=R("contextPanel.browser.forward"),e[21]=R,e[22]=B):B=e[22];const ne=!p;let ye;e[23]!==u||e[24]!==B||e[25]!==ne?(ye=s.jsx(on,{icon:"arrow-right",label:B,onClick:u,disabled:ne}),e[23]=u,e[24]=B,e[25]=ne,e[26]=ye):ye=e[26];let ce;e[27]!==g||e[28]!==R?(ce=R(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=R,e[29]=ce):ce=e[29];let _;e[30]!==d||e[31]!==ce?(_=s.jsx(on,{icon:"refresh",label:ce,onClick:d}),e[30]=d,e[31]=ce,e[32]=_):_=e[32];let re;e[33]!==f||e[34]!==R?(re=f?s.jsx(on,{icon:"restart",label:R("contextPanel.browser.hardReload"),onClick:f}):null,e[33]=f,e[34]=R,e[35]=re):re=e[35];let me;e[36]!==n||e[37]!==te?(me=Ne=>{Ne.preventDefault(),te(n)},e[36]=n,e[37]=te,e[38]=me):me=e[38];let de;e[39]!==o?(de=Ne=>o(Ne.target.value),e[39]=o,e[40]=de):de=e[40];let ge,Te;e[41]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>F(!0),Te=()=>F(!1),e[41]=ge,e[42]=Te):(ge=e[41],Te=e[42]);const be=D.length>0;let Re;e[43]===Symbol.for("react.memo_cache_sentinel")?(Re=Pe("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=Re):Re=e[43];let we;e[44]!==R?(we=R("contextPanel.browser.addressAria"),e[44]=R,e[45]=we):we=e[45];let Y;e[46]!==n||e[47]!==X||e[48]!==de||e[49]!==be||e[50]!==we?(Y=s.jsx("input",{value:n,onChange:de,onFocus:ge,onBlur:Te,onKeyDown:X,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":be,"aria-controls":"openchamber-browser-address-suggestions",className:Re,"aria-label":we}),e[46]=n,e[47]=X,e[48]=de,e[49]=be,e[50]=we,e[51]=Y):Y=e[51];let ve;e[52]!==i?(ve=Ne=>i?.(Ne),e[52]=i,e[53]=ve):ve=e[53];let xe;e[54]!==O||e[55]!==te||e[56]!==ve||e[57]!==D?(xe=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(z1,{entries:D,activeIndex:O,onSelect:te,onForget:ve,onHighlight:T})}),e[54]=O,e[55]=te,e[56]=ve,e[57]=D,e[58]=xe):xe=e[58];let je;e[59]!==me||e[60]!==Y||e[61]!==xe?(je=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:me,children:[Y,xe]}),e[59]=me,e[60]=Y,e[61]=xe,e[62]=je):je=e[62];let oe;e[63]!==b||e[64]!==y||e[65]!==S||e[66]!==R||e[67]!==z?(oe=y&&b?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(on,{icon:"subtract",label:R("contextPanel.browser.zoomOut"),onClick:y}),z!==100&&S?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs(pt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:S,"aria-label":R("contextPanel.browser.zoomReset"),children:[z,"%"]})}),s.jsx(It,{sideOffset:6,children:R("contextPanel.browser.zoomReset")})]}):null,s.jsx(on,{icon:"add",label:R("contextPanel.browser.zoomIn"),onClick:b})]}):null,e[63]=b,e[64]=y,e[65]=S,e[66]=R,e[67]=z,e[68]=oe):oe=e[68];let J;e[69]!==C||e[70]!==R?(J=C?s.jsx(on,{icon:"delete-bin",label:R("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=R,e[71]=J):J=e[71];let K;e[72]!==j||e[73]!==R?(K=j?s.jsx(on,{icon:"database-2",label:R("contextPanel.browser.clearCache"),onClick:j}):null,e[72]=j,e[73]=R,e[74]=K):K=e[74];let $;e[75]!==P||e[76]!==A||e[77]!==R?($=A?s.jsx(on,{icon:"smartphone",label:R("contextPanel.browser.deviceToolbar"),onClick:A,pressed:P}):null,e[75]=P,e[76]=A,e[77]=R,e[78]=$):$=e[78];let le;e[79]!==x||e[80]!==w||e[81]!==R?(le=w?s.jsx(on,{icon:"markup",label:R("contextPanel.browser.annotate.toggle"),onClick:w,pressed:x}):null,e[79]=x,e[80]=w,e[81]=R,e[82]=le):le=e[82];let V;e[83]!==v||e[84]!==R?(V=v?s.jsx(on,{icon:"terminal-box",label:R("contextPanel.browser.devTools"),onClick:v}):null,e[83]=v,e[84]=R,e[85]=V):V=e[85];let Ce;e[86]!==R?(Ce=R("contextPanel.browser.openExternal"),e[86]=R,e[87]=Ce):Ce=e[87];let Be;e[88]!==h||e[89]!==Ce?(Be=s.jsx(on,{icon:"external-link",label:Ce,onClick:h}),e[88]=h,e[89]=Ce,e[90]=Be):Be=e[90];let ke;return e[91]!==fe||e[92]!==ye||e[93]!==_||e[94]!==re||e[95]!==je||e[96]!==oe||e[97]!==J||e[98]!==K||e[99]!==$||e[100]!==le||e[101]!==V||e[102]!==Be?(ke=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[fe,ye,_,re,je,oe,J,K,$,le,V,Be]}),e[91]=fe,e[92]=ye,e[93]=_,e[94]=re,e[95]=je,e[96]=oe,e[97]=J,e[98]=K,e[99]=$,e[100]=le,e[101]=V,e[102]=Be,e[103]=ke):ke=e[103],ke},Mo={kind:"fill"},tc=240,V1=3840,Ju=[{id:"iphone-se",label:"iPhone SE",width:375,height:667},{id:"iphone-14",label:"iPhone 14",width:390,height:844},{id:"iphone-14-pro-max",label:"iPhone 14 Pro Max",width:430,height:932},{id:"pixel-7",label:"Pixel 7",width:412,height:915},{id:"ipad-mini",label:"iPad mini",width:768,height:1024},{id:"ipad-pro",label:"iPad Pro",width:1024,height:1366},{id:"laptop",label:"Laptop",width:1280,height:800},{id:"desktop",label:"Desktop",width:1440,height:900}],sc=t=>Number.isFinite(t)?Math.round(Math.min(V1,Math.max(tc,t))):tc,Oo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Zu=t=>{const e=Ju.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},U1=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},K1=(t,e)=>{const n=Oo(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},H1=["mobile","tablet","desktop","fill"],G1={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},nc=t=>typeof t=="string"&&H1.includes(t),Xi=t=>t==="fill"?Mo:Zu(G1[t])??Mo,ro=t=>{const e=Oo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Xi(n),i=Oo(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},q1=t=>{const e=tt.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=At();let u;e[0]!==n?(u=Oo(n),e[0]=n,e[1]=u):u=e[1];const d=u,h=n.kind==="preset"?n.id:"";let m;e[2]!==r||e[3]!==d?(m=(se,fe)=>{const B=Number.parseInt(fe,10);if(!Number.isFinite(B))return;const ne=d??{width:1280,height:800};r({kind:"custom",width:sc(se==="width"?B:ne.width),height:sc(se==="height"?B:ne.height)})},e[2]=r,e[3]=d,e[4]=m):m=e[4];const p=m;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=Pe("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=g):g=e[5];const w=g;let v;e[6]!==r?(v=se=>{const fe=Zu(se.target.value);r(fe??Mo)},e[6]=r,e[7]=v):v=e[7];let x;e[8]!==a?(x=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=x):x=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=Pe("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=f):f=e[10];let b;e[11]!==a?(b=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=b):b=e[12];let y;e[13]!==b?(y=s.jsx("option",{value:"",children:b}),e[13]=b,e[14]=y):y=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=Ju.map(Q1),e[15]=S):S=e[15];let N;e[16]!==h||e[17]!==v||e[18]!==x||e[19]!==y?(N=s.jsxs("select",{value:h,onChange:v,"aria-label":x,className:f,children:[y,S]}),e[16]=h,e[17]=v,e[18]=x,e[19]=y,e[20]=N):N=e[20];const C=d?String(d.width):"";let j;e[21]!==p?(j=se=>p("width",se.target.value),e[21]=p,e[22]=j):j=e[22];let A;e[23]!==a?(A=a("contextPanel.browser.device.width"),e[23]=a,e[24]=A):A=e[24];let P;e[25]!==C||e[26]!==j||e[27]!==A?(P=s.jsx("input",{value:C,onChange:j,placeholder:"—",inputMode:"numeric","aria-label":A,className:w}),e[25]=C,e[26]=j,e[27]=A,e[28]=P):P=e[28];let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=I):I=e[29];const M=d?String(d.height):"";let z;e[30]!==p?(z=se=>p("height",se.target.value),e[30]=p,e[31]=z):z=e[31];let R;e[32]!==a?(R=a("contextPanel.browser.device.height"),e[32]=a,e[33]=R):R=e[33];let H;e[34]!==M||e[35]!==z||e[36]!==R?(H=s.jsx("input",{value:M,onChange:z,placeholder:"—",inputMode:"numeric","aria-label":R,className:w}),e[34]=M,e[35]=z,e[36]=R,e[37]=H):H=e[37];let F;e[38]!==r||e[39]!==n?(F=()=>r(U1(n)),e[38]=r,e[39]=n,e[40]=F):F=e[40];const O=!d;let T;e[41]!==a?(T=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=T):T=e[42];let k;e[43]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(E,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=k):k=e[43];let D;e[44]!==F||e[45]!==O||e[46]!==T?(D=s.jsx(Pt,{asChild:!0,children:s.jsx(pt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:F,disabled:O,"aria-label":T,children:k})}),e[44]=F,e[45]=O,e[46]=T,e[47]=D):D=e[47];let L;e[48]!==a?(L=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=L):L=e[49];let Q;e[50]!==L?(Q=s.jsx(It,{sideOffset:6,children:L}),e[50]=L,e[51]=Q):Q=e[51];let q;e[52]!==D||e[53]!==Q?(q=s.jsxs(Dt,{children:[D,Q]}),e[52]=D,e[53]=Q,e[54]=q):q=e[54];let te;e[55]!==l||e[56]!==d?(te=d&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=d,e[57]=te):te=e[57];let ae;e[58]===Symbol.for("react.memo_cache_sentinel")?(ae=["system","light","dark"],e[58]=ae):ae=e[58];let X;e[59]!==i||e[60]!==o||e[61]!==a?(X=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ae.map(se=>s.jsx(pt,{type:"button",variant:i===se?"secondary":"ghost",size:"xs",className:Pe("shrink-0 rounded-full px-2.5 typography-micro",i===se?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(se),"aria-pressed":i===se,children:a(se==="system"?"contextPanel.browser.device.schemeSystem":se==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},se))}),e[59]=i,e[60]=o,e[61]=a,e[62]=X):X=e[62];let Z;return e[63]!==N||e[64]!==P||e[65]!==H||e[66]!==q||e[67]!==te||e[68]!==X?(Z=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,P,I,H,q,te,X]}),e[63]=N,e[64]=P,e[65]=H,e[66]=q,e[67]=te,e[68]=X,e[69]=Z):Z=e[69],Z};function Q1(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Y1=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},X1=2e3,J1=()=>{if(typeof window>"u"||window.__AIWORKER_ELECTRON__)return!1;const t=Nn();if(!t)return!1;try{return!yr(new URL(t,window.location.href).toString())}catch{return!1}},ef=t=>{const e=tt.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=At();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,u]=c.useState(l),d=ax(i),[h]=c.useState(J1);let m,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{let P=!0,I=null;const M=new AbortController,z=()=>{qy(M.signal).then(R=>{P&&(u(R),I=setTimeout(z,X1))})};return z(),()=>{P=!1,I&&clearTimeout(I),M.abort()}},p=[],e[1]=m,e[2]=p):(m=e[1],p=e[2]),c.useEffect(m,p);const g=a.kind==="ready"?a.servers:null;let w;e[3]!==d||e[4]!==g?(w=Xy({announced:d,discovered:g}),e[3]=d,e[4]=g,e[5]=w):w=e[5];const v=w;let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Ad,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=x):x=e[6];let f;e[7]!==o?(f=o("contextPanel.browser.empty"),e[7]=o,e[8]=f):f=e[8];let b;e[9]!==f?(b=s.jsx("span",{className:"typography-ui-header text-foreground",children:f}),e[9]=f,e[10]=b):b=e[10];let y;e[11]!==o?(y=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=y):y=e[12];let S;e[13]!==y?(S=s.jsx("span",{className:"typography-micro text-muted-foreground",children:y}),e[13]=y,e[14]=S):S=e[14];let N;e[15]!==S||e[16]!==b?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[b,S]}),e[15]=S,e[16]=b,e[17]=N):N=e[17];let C;e[18]!==d||e[19]!==v||e[20]!==i||e[21]!==n||e[22]!==h||e[23]!==o?(C=v.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:d.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),h?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:v.map(P=>s.jsxs(pt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{rx(i),n(P.url)},children:[s.jsx(E,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:Ba(P.url)||P.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:Y1(P.url)})]},P.port))})]}):null,e[18]=d,e[19]=v,e[20]=i,e[21]=n,e[22]=h,e[23]=o,e[24]=C):C=e[24];let j;e[25]!==v.length||e[26]!==a.kind||e[27]!==o?(j=v.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=v.length,e[26]=a.kind,e[27]=o,e[28]=j):j=e[28];let A;return e[29]!==N||e[30]!==C||e[31]!==j?(A=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[x,N,C,j]}),e[29]=N,e[30]=C,e[31]=j,e[32]=A):A=e[32],A},Ls=t=>Math.round(t),Z1=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,u])=>`${a}="${u}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Ls(l.x)}, y=${Ls(l.y)}, width=${Ls(l.width)}, height=${Ls(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},ew=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},tw=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},sw=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Ls(t.viewport.width)}x${Ls(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...Z1(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(ew(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(tw(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
912
|
+
`)},nw=t=>{const e=tt.c(7),{t:n}=At(),r=Je(ow),i=Je(iw),o=ji(aw),l=Qm(lw);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async u=>{const d=r??(i?"draft":null);if(!d){Me.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(u.screenshot)try{await l(u.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:d},{source:"preview-annotation",fileLabel:u.payload.pageUrl||"browser",startLine:1,endLine:1,code:sw({payload:u.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Me.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},rw=()=>{const t=tt.c(16),{t:e}=At();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function ow(t){return t.currentSessionId}function iw(t){return t.newSessionDraft?.open}function aw(t){return t.addDraft}function lw(t){return t.addAttachedFile}const cw=3e4,dw=3,uw=250,fw={attempts:0,windowStartedAt:null},mw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=cw,r=n?0:t.attempts;return r>=dw?null:{delayMs:uw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},hw=-3,oo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",cr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},pw=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:e1),[o,l]=c.useState(e),[a,u]=c.useState(""),[d,h]=c.useState(!1),[m,p]=c.useState(!1),g=c.useRef(n);g.current=n;const w=c.useRef(fw);return c.useEffect(()=>{if(!t)return;const v=()=>{try{const I=t.getURL();return oo(I)?I:""}catch{return""}},x=()=>{try{h(t.canGoBack()),p(t.canGoForward())}catch{}},f=I=>{oo(I)&&(l(I),g.current(I))},b=()=>{const I=v();i({kind:"loading",url:I})},y=()=>{const I=v();let M="";try{M=t.getTitle()||""}catch{M=""}u(M),f(I),x(),i(z=>z.kind==="failed"&&z.url===I?z:{kind:"ready",url:I,title:M})},S=I=>{const M=cr(I);oo(M.url)&&(f(M.url),x())},N=I=>{const M=cr(I),z=Array.isArray(M.favicons)?M.favicons.find(Boolean):"",R=v();z&&R&&$u.getState().resolve(R,z)},C=I=>{const M=cr(I);typeof M.title=="string"&&u(M.title)},j=I=>{const M=cr(I);if(M.isMainFrame===!1)return;const z=typeof M.errorCode=="number"?M.errorCode:0;z!==hw&&i({kind:"failed",url:oo(M.validatedURL)?M.validatedURL:v(),code:z,description:typeof M.errorDescription=="string"?M.errorDescription:""})};let A=null;const P=()=>{const I=v(),M=mw(w.current,Date.now());if(!M){i({kind:"failed",url:I,code:0,description:"",crashed:!0});return}w.current=M.state,i({kind:"loading",url:I}),A=setTimeout(()=>{A=null;try{t.reload()}catch{i({kind:"failed",url:I,code:0,description:"",crashed:!0})}},M.delayMs)};t.addEventListener("did-start-loading",b),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",j),t.addEventListener("render-process-gone",P),t.addEventListener("crashed",P);try{!t.isLoading()&&v()&&y()}catch{}return()=>{A!==null&&clearTimeout(A),t.removeEventListener("render-process-gone",P),t.removeEventListener("crashed",P),t.removeEventListener("did-start-loading",b),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",j)}},[t]),{status:r,url:o,title:a,canGoBack:d,canGoForward:m}},gw=()=>typeof window<"u"&&!!window.__AIWORKER_ELECTRON__,xw=4e4,io=.5,bw=-3,yw=4,ww="persist:openchamber-browser",rc=20,Sw=600,vw=2e4,jw=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=At(),{currentTheme:i}=Zn(),o=c.useRef(null),[l,a]=c.useState(null),u=c.useCallback(oe=>{o.current=oe,a(oe)},[]),d=De(oe=>oe.setContextPanelTabTargetPath),h=c.useRef(mr(t)),m=h.current!==an?h.current:"",[p,g]=c.useState(m?null:an),[w,v]=c.useState(m),[x,f]=c.useState(!1),[b,y]=c.useState(!1),[S,N]=c.useState(0),C=c.useRef(0),[j,A]=c.useState(!1),[P,I]=c.useState(Mo),M=c.useRef(P);M.current=P;const z=c.useRef([]),[R,H]=c.useState("system"),[F,O]=c.useState({width:0,height:0}),T=c.useRef(null),k=c.useRef(null),D=c.useRef(!1),L=c.useRef(Date.now()),Q=c.useCallback(oe=>{!oe||oe===an||!e||!n||d(e,n,oe)},[e,n,d]),q=pw(l,{initialUrl:m,onUrlChange:c.useCallback(oe=>{const J=Nr(oe);v(J),Q(J)},[Q])}),[te,ae]=c.useState(null),X=nw(e),Z=rw(),se=q.status.kind==="loading",fe=pr(Gu(e)),B=pr(oe=>oe.recordVisit),ne=pr(oe=>oe.forget);c.useEffect(()=>{q.status.kind==="ready"&&B(e,{url:Nr(q.status.url),title:q.status.title})},[e,q.status,B]);const ye=c.useMemo(()=>Hu(fe,w),[fe,w]),ce=c.useCallback(oe=>{const J=mr(oe);J!==an&&(v(J),ae(null),Jl(J).then(K=>{const $=o.current;if(!$){g(K);return}try{$.loadURL(K)}catch{g(K)}}).catch(K=>{K instanceof _r&&ae(J)}))},[]);c.useEffect(()=>{if(!m)return;let oe=!0;return Jl(m).then(J=>{oe&&g(J)}).catch(J=>{if(oe){if(J instanceof _r){ae(m),g(an);return}g(m)}}),()=>{oe=!1}},[]);const _=c.useMemo(()=>({executeJavaScript:async(oe,J)=>{const K=o.current;if(!K)throw new Error("Browser view is not available");return K.executeJavaScript(oe,J)},capturePage:async()=>{const oe=o.current;if(!oe)return null;const J=oe.getWebContentsId();return Number.isFinite(J)?await ur("desktop_browser_capture_page",{webContentsId:J}):null}}),[]),re=c.useCallback(()=>{if(x){f(!1),bo(_);return}if(!q.url){Me.error(r("contextPanel.browser.annotate.noPage"));return}const oe=h1(i.metadata.variant==="light"?"light":"dark");f(!0),f1({host:_,theme:oe,labels:Z}).then(async J=>{f(!1),J&&await X(J)}).catch(()=>{f(!1),Me.error(r("contextPanel.browser.annotate.failed"))})},[_,X,i,x,q.url,Z,r]);c.useEffect(()=>{if(!x)return;const oe=J=>{Ym(J)||J.key!=="Escape"||(J.preventDefault(),J.stopImmediatePropagation(),f(!1),bo(_))};return window.addEventListener("keydown",oe,!0),()=>window.removeEventListener("keydown",oe,!0)},[_,x]);const me=c.useCallback(async(oe=8e3)=>{const J=Date.now();for(;;){const K=o.current;if(!K)return!1;let $=!1;try{$=K.isLoading()}catch{return!1}if(!$)return!0;if(Date.now()-J>oe)return!1;await new Promise(le=>setTimeout(le,120))}},[]),de=c.useCallback(async(oe,J)=>{const K=o.current;if(!K)throw new Error("The browser panel is not ready");const $=()=>{nc(J.viewport)&&(I(Xi(J.viewport)),A(!0))};if(oe==="browser.back"||oe==="browser.forward"){const Ne=oe==="browser.back";if(!(Ne?K.canGoBack():K.canGoForward()))throw new Error(Ne?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Ne?K.goBack():K.goForward(),await new Promise(U=>setTimeout(U,150)),await me();let We="";try{We=K.getTitle()||""}catch{We=""}return{url:Nr(K.getURL()),title:We}}if(oe==="browser.capture"){De.getState().openContextBrowser(e,K.getURL());const Ne=Date.now()+1200;let Qe=0,We=0;for(;We<2&&Date.now()<Ne;){const Ee=K.getBoundingClientRect().width;We=Ee>=2&&Math.abs(Ee-Qe)<.5?We+1:0,Qe=Ee,await new Promise(Ie=>setTimeout(Ie,50))}await new Promise(Ee=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Ee()))}),await me();const U=await _.capturePage();if(!U)throw new Error("The page could not be captured");let he="";try{he=K.getTitle()||""}catch{he=""}return{...U,url:Nr(K.getURL()),title:he,viewport:ro(M.current)}}if(oe==="browser.resize"){if(!nc(J.viewport))throw new Error("viewport is required");return $(),await new Promise(Ne=>setTimeout(Ne,200)),await me(),{viewport:ro(Xi(J.viewport))}}if(oe==="browser.open"){const Ne=typeof J.url=="string"?J.url:"";if(!Ne)throw new Error("url is required");$(),ce(Ne),await new Promise(U=>setTimeout(U,150));const Qe=await me(25e3);let We="";try{We=K.getTitle()||""}catch{We=""}return{url:mr(Ne),title:We,opened:!0,settled:Qe,viewport:ro(M.current)}}await me();const le=Ne=>typeof Ne=="string"&&Ne?Ne:void 0,Ce=(()=>{switch(oe){case"browser.snapshot":return F1({selector:le(J.selector)});case"browser.click":return _1({selector:le(J.selector),text:le(J.text)});case"browser.type":return B1({selector:String(J.selector??""),value:String(J.value??""),submit:J.submit===!0});case"browser.inspect":return W1({selector:String(J.selector??"")});case"browser.scroll":return L1({selector:le(J.selector),direction:le(J.direction)});default:return null}})();if(!Ce)throw new Error(`Unsupported browser action: ${oe}`);const Be=await K.executeJavaScript(Ce,!0);if(!Be||typeof Be!="object")throw new Error("The page returned no result");const ke=Be;if(ke.ok!==!0)throw new Error(typeof ke.error=="string"&&ke.error?ke.error:"Browser action failed");if(oe==="browser.snapshot"){const Ne=z.current;return{...ke,viewport:ro(M.current),...Ne.length>0?{consoleProblems:[...Ne]}:{}}}return(oe==="browser.click"||oe==="browser.type"&&J.submit===!0)&&(await new Promise(Ne=>setTimeout(Ne,150)),await me()),Be},[_,e,ce,me]);c.useEffect(()=>w1({run:de}),[de]),c.useEffect(()=>{const oe=_;return()=>{bo(oe)}},[_]),c.useEffect(()=>{if(!l)return;const oe=K=>{const $=K;if(typeof $.level!="number"||$.level<2)return;const le=$.sourceId?`${$.sourceId}${$.line?`:${$.line}`:""}`:"";z.current.push({level:$.level>=3?"error":"warning",message:String($.message??"").slice(0,400),source:le}),z.current.length>rc&&z.current.splice(0,z.current.length-rc)},J=()=>{z.current=[]};return l.addEventListener("console-message",oe),l.addEventListener("did-start-loading",J),()=>{l.removeEventListener("console-message",oe),l.removeEventListener("did-start-loading",J)}},[l]);const ge=c.useRef(new Set),Te=c.useCallback(oe=>{ge.current.clear(),ce(oe)},[ce]);c.useEffect(()=>{if(!l)return;const oe=K=>{const $=cr(K),le=typeof $.url=="string"?$.url:"";!le||!Zl(le)||(K.preventDefault(),ce(le))},J=K=>{const $=cr(K);if($.isMainFrame===!1||$.errorCode===-3)return;const le=typeof $.validatedURL=="string"?$.validatedURL:"";!le||!Zl(le)||ge.current.has(le)||(ge.current.add(le),ce(le))};return l.addEventListener("will-navigate",oe),l.addEventListener("did-fail-load",J),()=>{l.removeEventListener("will-navigate",oe),l.removeEventListener("did-fail-load",J)}},[ce,l]),c.useEffect(()=>{if(!l)return;const oe=J=>{const K=J.detail;J.preventDefault(),K?.url&&ce(K.url)};return l.addEventListener("new-window",oe),()=>l.removeEventListener("new-window",oe)},[ce,l]);const be=c.useCallback(oe=>{const J=Math.min(yw,Math.max(bw,oe));C.current=J,N(J);try{o.current?.setZoomLevel(J)}catch{}},[]);c.useEffect(()=>{const oe=J=>{if(!(J instanceof CustomEvent))return;const K=J.detail,$=o.current;!$||document.activeElement!==$||(K==="zoom-in"?be(C.current+io):K==="zoom-out"?be(C.current-io):K==="zoom-reset"&&be(0))};return window.addEventListener("aiworker:zoom",oe),()=>window.removeEventListener("aiworker:zoom",oe)},[be]);const Re=c.useCallback(oe=>{ur("desktop_browser_clear_data",{partition:ww,cookies:oe==="cookies",cache:oe==="cache"}).then(()=>{Me.success(r(oe==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Me.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const oe=T.current;if(!oe||typeof ResizeObserver>"u")return;const J=new ResizeObserver(K=>{const $=K[0]?.contentRect;$&&O({width:$.width,height:$.height})});return J.observe(oe),()=>J.disconnect()},[]);const we=c.useCallback(oe=>{H(oe);const J=o.current;if(!J)return;let K=-1;try{K=J.getWebContentsId()}catch{return}ur("desktop_browser_set_color_scheme",{webContentsId:K,scheme:oe}).catch($=>{H("system"),Me.error($ instanceof Error?$.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),Y=c.useCallback(()=>{try{se?o.current?.stop():o.current?.reload()}catch{}},[se]),ve=q.status;c.useEffect(()=>{const oe=()=>{y(!0);const $=setTimeout(()=>{try{o.current?.reload()}catch{}},Sw);return()=>clearTimeout($)};if(ve.kind==="failed"){if(!Hy(ve.code,ve.url)){y(!1);return}const $=Date.now(),le=k.current?.url===ve.url?k.current:{url:ve.url,startedAt:$};if(k.current=le,$-le.startedAt>xw){y(!1);return}return oe()}if(ve.kind==="loading")return;if(k.current=null,ve.kind!=="ready"||!ve.url||!yr(ve.url)){D.current=!0,y(!1);return}if(D.current||Date.now()-L.current>vw){D.current=!0,y(!1);return}let J=!1,K=null;return Qy(Nr(ve.url)).then($=>{if(!J){if($===null||$<500){D.current=!0,y(!1);return}K=oe()}}),()=>{J=!0,K?.()}},[ve]);const xe=q.status.kind==="failed"&&!b?q.status:null,je=K1(P,F);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Xu,{address:w,onAddressChange:v,onSubmit:Te,suggestions:ye,onForgetSuggestion:oe=>ne(e,oe),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:Y,onOpenExternal:()=>{Vo(q.url||w)},canGoBack:q.canGoBack,canGoForward:q.canGoForward,isLoading:se,onAnnotate:re,isAnnotating:x,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>be(S+io),onZoomOut:()=>be(S-io),onZoomReset:()=>be(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>Re("cookies"),onClearCache:()=>Re("cache"),onToggleDeviceBar:()=>A(oe=>!oe),isDeviceBarOpen:j}),j?s.jsx(q1,{viewport:P,onViewportChange:I,colorScheme:R,onColorSchemeChange:we,scale:je?.scale??1}):null,s.jsxs("div",{ref:T,className:Pe("relative min-h-0 flex-1 bg-background",je&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:u,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:je?{width:`${je.width}px`,height:`${je.height}px`,transform:`scale(${je.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!m&&!q.url&&!se?s.jsx(ef,{onOpen:Te,directory:e}):null,b?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:te})})]}):null,xe&&!te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:xe.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:xe.crashed?r("contextPanel.browser.crashedHint"):xe.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,se?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},kw=t=>{const e=tt.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=At(),l=De(Nw);let a;e[0]!==n?(a=mr(n),e[0]=n,e[1]=a):a=e[1];const u=a,d=u!==an?u:"",[h,m]=c.useState(d),[p,g]=c.useState(d);let w;e[2]!==d?(w=d?[d]:[],e[2]=d,e[3]=w):w=e[3];const[v,x]=c.useState(w),[f,b]=c.useState(d?0:-1),[y,S]=c.useReducer(Aw,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=Z=>{!Z||Z===an||!r||!i||l(r,i,Z)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const C=N;let j;e[8]!==r?(j=Gu(r),e[8]=r,e[9]=j):j=e[9];const A=pr(j),P=pr(Dw),I=pr(Pw);let M;e[10]!==h||e[11]!==A?(M=Hu(A,h),e[10]=h,e[11]=A,e[12]=M):M=e[12];const z=M;let R;e[13]!==r||e[14]!==f||e[15]!==C||e[16]!==P?(R=Z=>{const se=mr(Z);se!==an&&(m(se),g(se),C(se),P(r,{url:se}),x(fe=>{const B=f>=0?fe.slice(0,f+1):[];return B[B.length-1]===se?(b(B.length-1),B):(b(B.length),[...B,se])}))},e[13]=r,e[14]=f,e[15]=C,e[16]=P,e[17]=R):R=e[17];const H=R;let F;e[18]!==v||e[19]!==C?(F=Z=>{const se=v[Z];se&&(b(Z),m(se),g(se),C(se))},e[18]=v,e[19]=C,e[20]=F):F=e[20];const O=F;let T;e[21]!==r||e[22]!==I?(T=Z=>I(r,Z),e[21]=r,e[22]=I,e[23]=T):T=e[23];let k,D;e[24]!==O||e[25]!==f?(D=()=>O(f-1),k=()=>O(f+1),e[24]=O,e[25]=f,e[26]=k,e[27]=D):(k=e[26],D=e[27]);let L;e[28]!==h||e[29]!==p?(L=()=>{Vo(p||h)},e[28]=h,e[29]=p,e[30]=L):L=e[30];const Q=f>0,q=f>=0&&f<v.length-1;let te;e[31]!==h||e[32]!==H||e[33]!==z||e[34]!==k||e[35]!==L||e[36]!==Q||e[37]!==q||e[38]!==T||e[39]!==D?(te=s.jsx(Xu,{address:h,onAddressChange:m,onSubmit:H,suggestions:z,onForgetSuggestion:T,onBack:D,onForward:k,onReload:S,onOpenExternal:L,canGoBack:Q,canGoForward:q,isLoading:!1}),e[31]=h,e[32]=H,e[33]=z,e[34]=k,e[35]=L,e[36]=Q,e[37]=q,e[38]=T,e[39]=D,e[40]=te):te=e[40];let ae;e[41]!==p||e[42]!==H||e[43]!==y||e[44]!==o?(ae=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:p?s.jsx("iframe",{src:p,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${p}|${y}`):s.jsx(ef,{onOpen:H})}),e[41]=p,e[42]=H,e[43]=y,e[44]=o,e[45]=ae):ae=e[45];let X;return e[46]!==te||e[47]!==ae?(X=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[te,ae]}),e[46]=te,e[47]=ae,e[48]=X):X=e[48],X},Cw=t=>{const e=tt.c(3),[n]=c.useState(gw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(jw,{...t}):s.jsx(kw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Nw(t){return t.setContextPanelTabTargetPath}function Aw(t){return t+1}function Dw(t){return t.recordVisit}function Pw(t){return t.forget}const Iw=Ln(()=>_n(()=>import("./WalkthroughView-DeKMvZlL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.WalkthroughView}))),Tw=Ln(()=>_n(()=>import("./DiffView-DXjVsEOw.js"),__vite__mapDeps([124,1,2,4,5,6,7,8,9,83,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,125,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.DiffView}))),Rw=Ln(()=>_n(()=>import("./FilesView-CJdG0-wk.js"),__vite__mapDeps([126,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,127,128,129,130,131,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,132,133,118,119,116,121,134,117,135])).then(t=>({default:t.FilesView}))),Ew=Ln(()=>_n(()=>import("./GitView-BXsS3jG6.js"),__vite__mapDeps([136,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,137,115,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,85,113,114,116,117,118,119,120,121,122,123])).then(t=>({default:t.GitView}))),Mw=Ln(()=>_n(()=>import("./LinearIssuesView-BoUiLQG1.js"),__vite__mapDeps([138,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.LinearIssuesView}))),Ow=Ln(()=>_n(()=>import("./PlanView-CJTmOF6I.js"),__vite__mapDeps([139,1,2,4,5,6,7,8,9,127,57,58,59,60,61,62,79,55,56,63,128,129,130,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,117,84,135,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102])).then(t=>({default:t.PlanView}))),Fw=320,_w=1400,tf=600,Bw=100,Lw=24,Fo=new Map,$w=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},oc=t=>Number.isFinite(t)?Math.min(_w,Math.max(Fw,Math.round(t))):tf,Ww=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},zw=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},sf=(t,e)=>e(t==="chat"?"contextPanel.mode.chat":t==="file"?"contextPanel.mode.files":t==="diff"?"contextPanel.mode.diff":t==="walkthrough"?"contextPanel.mode.walkthrough":t==="plan"?"contextPanel.mode.plan":t==="browser"?"contextPanel.mode.browser":t==="git"?"layout.rightSidebar.git":t==="pr"?"contextPanel.mode.pr":t==="linear"?"contextPanel.mode.linear":t==="notes"?"contextRail.surface.notes":t==="terminal"?"layout.mainTab.terminal":"contextPanel.mode.context"),Vw=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},Uw=(t,e,n)=>{if(t.mode==="chat"){const r=Ji(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?Ba(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Vw(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):sf(t.mode,n)},ic=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(wa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(Iu,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(E,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(E,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(E,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(E,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(E,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(E,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(E,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(E,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=Kw(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(E,{name:"global",className:"h-3.5 w-3.5"})}},Kw=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Hw=200,Gw=480,qw=({visible:t})=>{const{t:e}=At(),n=De(f=>f.contextEditorTreeWidth),r=De(f=>f.setContextEditorTreeWidth),[i,o]=c.useState(!1),l=c.useRef(0),a=c.useRef(n),u=c.useRef(null),d=c.useRef(null),h=c.useRef(null),m=c.useCallback(f=>Math.min(Gw,Math.max(Hw,Math.round(f))),[]),p=c.useCallback(f=>{const b=h.current;b&&(b.style.width=`${f}px`,b.style.setProperty("--oc-editor-tree-width",`${f}px`))},[]),g=f=>{if(t){try{f.currentTarget.setPointerCapture(f.pointerId)}catch{}d.current=f.pointerId,o(!0),l.current=f.clientX,a.current=n,u.current=n,f.preventDefault()}},w=f=>{if(!i||d.current!==f.pointerId)return;const b=l.current-f.clientX,y=m(a.current+b);u.current!==y&&(u.current=y,p(y))},v=f=>{if(d.current!==f.pointerId)return;try{f.currentTarget.releasePointerCapture(f.pointerId)}catch{}const b=m(u.current??n);d.current=null,u.current=null,o(!1),r(b)},x=t?n:0;return s.jsxs("div",{ref:h,className:Pe("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${i?u.current??x:x}px`,"--oc-editor-tree-width":`${i?u.current??n:n}px`,overflowX:"clip",transitionProperty:i?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:Pe("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",i&&"bg-[var(--interactive-border)]"),onPointerDown:g,onPointerMove:w,onPointerUp:v,onPointerCancel:v,role:"separator","aria-orientation":"vertical","aria-label":e("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Pe("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",i&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(py,{})})]})},Ji=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Qw=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},Yw=(t,e)=>{if(e.length===0)return Fo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Fo:r},Xw=(t,e)=>{const n=Sd(t),r=c.useRef(Fo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=Yw(n.getState().session,i.current);return Qw(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Fo)},Jw=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Zw=()=>{const{t}=At(),e=br()??"",n=c.useMemo(()=>$w(e),[e]),r=De(G=>n?G.contextPanelByDirectory[n]:void 0),i=De(G=>G.closeContextPanel),o=De(G=>G.closeContextPanelTab),l=De(G=>G.openContextPanelTab),a=De(G=>G.toggleContextPanelExpanded),u=De(G=>G.setContextPanelWidth),d=De(G=>G.setActiveContextPanelTab),h=De(G=>G.openContextBrowser);c.useEffect(()=>{if(e)return S1(G=>h(e,G))},[e,h]);const m=De(G=>G.reorderContextPanelTabs),p=mn(G=>G.setSelectedPath),g=De(G=>G.contextEditorTreeVisible),w=De(G=>G.toggleContextEditorTree),v=De(G=>G.openNewContextBrowserTab),x=$u(G=>G.byOrigin),f=De(G=>G.allowPromptingSubagentSessions),{themeMode:b,setThemeMode:y,lightThemeId:S,darkThemeId:N,currentTheme:C}=Zn(),j=c.useMemo(()=>r?.tabs??[],[r?.tabs]),A=j.find(G=>G.id===r?.activeTabId)??j[j.length-1]??null,P=!!(r?.isOpen&&A),I=!!(P&&r?.expanded),[M,z]=c.useState(null),R=A?.mode??null,H=R?r?.widthByMode?.[R]:void 0,F=R?r?.widthFractionByMode?.[R]:void 0,O=R?Xm(R):.5,T=M??(typeof window<"u"?window.innerWidth:tf*2),k=F!=null&&M!=null?Math.round(F*M):H,D=oc(k??Math.round(O*T));c.useEffect(()=>{!n||!R||F!=null||H==null||M==null||u(n,R,H,M)},[R,M,n,H,F,u]);const L=c.useMemo(()=>{const G=[];for(const Le of j){if(Le.mode!=="chat")continue;const Oe=Ji(Le.dedupeKey);Oe&&!G.includes(Oe)&&G.push(Oe)}return G},[j]),Q=Xw(n||void 0,L),[q,te]=c.useState(!1),ae=c.useRef(0),X=c.useRef(D),Z=c.useRef(null),se=c.useRef(null),fe=c.useRef(null),B=c.useRef(new Map),ne=c.useRef(new Map),ye=c.useRef(!1);c.useLayoutEffect(()=>{const G=fe.current?.parentElement;if(!G||typeof ResizeObserver>"u")return;const Le=new ResizeObserver(()=>{z(G.clientWidth||null)});return Le.observe(G),z(G.clientWidth||null),()=>Le.disconnect()},[]),c.useEffect(()=>{if(!P||ye.current){ye.current=P;return}const G=window.requestAnimationFrame(()=>{fe.current?.focus({preventScroll:!0})});return ye.current=!0,()=>window.cancelAnimationFrame(G)},[P]);const ce=c.useRef(null),_=c.useRef(null),re=c.useCallback(()=>{_.current=null;const G=fe.current,Le=Z.current;!G||Le===null||G.style.setProperty("--oc-context-panel-width",`${Le}px`)},[]);c.useEffect(()=>()=>{_.current!==null&&clearTimeout(_.current)},[]);const me=c.useCallback(G=>{const Le=oc(G),Oe=ce.current;return Oe===null?Le:Math.min(Le,Math.max(1,Oe))},[]),de=c.useCallback(G=>{!P||I||!n||(se.current=G.pointerId,te(!0),ae.current=G.clientX,X.current=D,Z.current=D,ce.current=Ww(fe.current),document.documentElement.style.cursor="col-resize",G.preventDefault())},[n,I,P,D]),ge=c.useCallback(()=>{const G=me(Z.current??D),Le=ce.current;Z.current=null,ce.current=null,_.current!==null&&(clearTimeout(_.current),_.current=null),document.documentElement.style.cursor="",n&&R&&u(n,R,G,Le??void 0),te(!1),se.current=null},[R,me,n,u,D]);c.useEffect(()=>{if(!q)return;const G=qe=>{if(se.current!==qe.pointerId)return;const Ue=ae.current-qe.clientX,st=me(X.current+Ue);Z.current!==st&&(Z.current=st,_.current===null&&(_.current=setTimeout(re,Bw)))},Le=qe=>{se.current===qe.pointerId&&ge()},Oe=()=>{ge()};return window.addEventListener("pointermove",G),window.addEventListener("pointerup",Le),window.addEventListener("pointercancel",Le),window.addEventListener("blur",Oe),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("pointerup",Le),window.removeEventListener("pointercancel",Le),window.removeEventListener("blur",Oe)}},[re,me,ge,q]),c.useEffect(()=>{q||(Z.current=null,document.documentElement.style.cursor="")},[q]);const Te=c.useCallback(()=>{n&&i(n)},[i,n]),be=c.useCallback(()=>{n&&a(n)},[n,a]),Re=c.useCallback(G=>{G.key==="Escape"&&(Jm(G.target)||(G.preventDefault(),G.stopPropagation(),Te()))},[Te]);c.useEffect(()=>{if(!(!n||!A)&&A.mode==="file"&&A.targetPath){p(n,A.targetPath,{allowOutsideRoot:!0});return}},[A,n,p]);const we=c.useMemo(()=>j.filter(G=>G.mode==="chat"),[j]),Y=P&&A?.mode==="chat"?A.id:null,ve=P&&A?.mode==="chat"?Ji(A.dedupeKey):null,xe=Lg(we,Y);c.useEffect(()=>{if(!P||!n||!ve||typeof window>"u")return;const G=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ei(n,ve,!1);return}Dd(ve),ei(n,ve,!0)};G();const Le=window.setInterval(G,1e4);return window.addEventListener("focus",G),window.addEventListener("blur",G),document.addEventListener("visibilitychange",G),()=>{window.clearInterval(Le),window.removeEventListener("focus",G),window.removeEventListener("blur",G),document.removeEventListener("visibilitychange",G),ei(n,ve,!1)}},[ve,n,P]);const je=c.useCallback((G,Le,Oe)=>$g(ne.current,G,Le,n||null,Oe,{mode:b,lightThemeId:S,darkThemeId:N,currentTheme:C},{allowPromptingSubagentSessions:f}),[f,C,N,n,S,b]),oe=xe&&ve?je(xe.id,ve,xe.readOnly):null;c.useEffect(()=>{const G=new Set(j.map(Le=>Le.id));for(const Le of ne.current.keys())G.has(Le)||ne.current.delete(Le)},[j]);const J=c.useCallback(G=>{!n||A?.mode!=="diff"||l(n,{mode:"diff",targetPath:A.targetPath,stagedDiff:G==="staged",diffScope:G})},[A,n,l]),K=c.useCallback(()=>{if(typeof window>"u")return;const G={themeMode:b,lightThemeId:S,darkThemeId:N,currentTheme:C};for(const Le of B.current.values()){const Oe=Le.contentWindow;Oe&&Oe.postMessage({type:"aiworker:theme-sync",payload:G},window.location.origin)}},[C,N,S,b]),$=c.useCallback(()=>{if(typeof window>"u")return;const G={allowPromptingSubagentSessions:f};for(const Le of B.current.values()){const Oe=Le.contentWindow;Oe&&Oe.postMessage({type:"aiworker:chat-settings-sync",payload:G},window.location.origin)}},[f]),le=c.useCallback((G,Le,Oe)=>{const qe=Le.contentWindow;qe&&qe.postMessage({type:mu,payload:{visible:Y===G}},Oe)},[Y]),V=c.useCallback(()=>{if(!(typeof window>"u"))for(const[G,Le]of B.current.entries())le(G,Le,window.location.origin)},[le]);c.useEffect(()=>{if(typeof window>"u")return;const G=Le=>{if(Le.origin!==window.location.origin)return;const Oe=Array.from(B.current.entries()).find(([,Nt])=>Nt.contentWindow===Le.source);if(!Oe)return;const qe=Le.data;if(qe?.type===Wg){const[Nt,ie]=Oe;le(Nt,ie,Le.origin);return}if(qe?.type===zg){if(typeof qe.requestId!="string"||!qe.requestId)return;const Nt=ps(),ie={apiBaseUrl:Nn(),clientToken:Lr(),localOrigin:typeof window.__AIWORKER_LOCAL_ORIGIN__=="string"?window.__AIWORKER_LOCAL_ORIGIN__:"",runtimeHeaders:cd(),relayHostId:Nt.startsWith("host:")?Nt.slice(5):"",relay:sm()??void 0};Le.source?.postMessage({type:Vg,requestId:qe.requestId,payload:ie},Le.origin);return}if(qe?.type==="aiworker:theme-sync-request"){K();return}if(qe?.type==="aiworker:chat-settings-request"){$();return}if(qe?.type!=="aiworker:cycle-theme-request")return;const Ue=["light","dark","system"],wt=(Ue.indexOf(b)+1)%Ue.length;y(Ue[wt])};return window.addEventListener("message",G),()=>window.removeEventListener("message",G)},[$,le,K,y,b]),c.useLayoutEffect(()=>{j.some(Le=>Le.mode==="chat")&&(K(),$(),V())},[N,S,$,V,K,j,b]);const Ce=A?.mode==="file"||A?.mode==="chat"||A?.mode==="browser",Be=c.useMemo(()=>A?j.filter(G=>G.mode===A.mode):[],[A,j]),ke=c.useMemo(()=>Be.map(G=>{const Le=Uw(G,Q,t),Oe=Jw(Le,Lw),qe=zw(G.targetPath,e);return{id:G.id,label:Oe,icon:ic(G,x),title:qe?`${Le}: ${qe}`:Le,closeLabel:t("contextPanel.tab.closeTabAria",{label:Oe})}}),[Be,e,x,Q,t]),Ne=A?.mode==="context"?s.jsx(Ry,{}):A?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Ew,{isActive:P})}):A?.mode==="pr"?s.jsx(Wb,{}):A?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Mw,{})}):A?.mode==="notes"?s.jsx(tg,{}):A?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Ow,{targetPath:A.targetPath,savedProjectPlan:A.projectPlanId&&A.projectPlanRef?{projectRef:A.projectPlanRef,planId:A.projectPlanId}:null})}):null,Qe=c.useMemo(()=>j.filter(G=>G.mode==="browser"),[j]),We=c.useMemo(()=>j.filter(G=>G.mode==="diff"),[j]),U=c.useMemo(()=>j.find(G=>G.mode==="terminal")??null,[j]),he=c.useMemo(()=>j.some(G=>G.mode==="walkthrough"),[j]),Ee=c.useMemo(()=>j.some(G=>G.mode==="file"),[j]),Ie=c.useMemo(()=>j.some(G=>G.mode==="file"&&G.targetPath),[j]),rt=A?.mode==="file",Ge=De(G=>G.closeContextPanelTabs),ut=c.useCallback(G=>{if(!n)return null;const{id:Le,index:Oe,allIds:qe,close:Ue}=G,st=()=>Ge(n,qe.filter(He=>He!==Le)),wt=()=>Ge(n,qe.slice(0,Oe)),Nt=()=>Ge(n,qe.slice(Oe+1)),ie=()=>Ge(n,qe),pe=qe.length>1,Ve=Oe===0,ze=Oe===qe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Un,{onClick:Ue,children:[s.jsx(E,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Mi,{}),s.jsxs(Un,{onClick:st,disabled:!pe,children:[s.jsx(E,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Un,{onClick:wt,disabled:Ve,children:[s.jsx(E,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Un,{onClick:Nt,disabled:ze,children:[s.jsx(E,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Mi,{}),s.jsxs(Un,{onClick:ie,disabled:!pe,children:[s.jsx(E,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Ge,n,t]),ct=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Ce?s.jsx(Jd,{items:ke,activeId:A?.id??null,onSelect:G=>{n&&d(n,G)},onClose:G=>{n&&o(n,G)},onReorder:(G,Le)=>{n&&m(n,G,Le)},layoutMode:"scrollable",variant:"default",tabContextMenu:ut}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[A?ic(A,x):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:A?sf(A.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[A?.mode==="browser"?s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&v(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(E,{name:"add",className:"h-3.5 w-3.5"})}):null,rt?s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":g,children:s.jsx(E,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:be,className:"h-7 w-7 p-0",title:t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:I?s.jsx(E,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:Te,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]})]}),ue=P?I?{"--oc-context-panel-width":M!==null?`${M}px`:"100%",width:M!==null?`${M}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${D}px`}:{"--oc-context-panel-width":`${D}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:fe,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:Pe("flex min-h-0 flex-col overflow-hidden bg-background",I?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Re,style:ue,children:[P&&!I&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!I&&s.jsx("div",{className:Pe("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",q&&"bg-[var(--interactive-border)]"),onPointerDown:de,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Pe("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!P&&"pointer-events-none select-none opacity-0"),style:{width:I?M!==null?`${M}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[ct,s.jsxs("div",{className:Pe("relative min-h-0 flex-1 overflow-hidden",q&&"pointer-events-none"),children:[Ee?s.jsxs("div",{className:Pe("absolute inset-0 flex",rt?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:Ie?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Rw,{mode:"editor-only"})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(E,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}),s.jsx(qw,{visible:g})]}):null,xe&&ve&&oe?s.jsx("iframe",{ref:G=>{if(!G){B.current.delete(xe.id);return}B.current.set(xe.id,G)},src:oe,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ve}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{K(),$(),V()}},xe.id):null,Qe.map(G=>s.jsx("div",{className:Pe("absolute inset-0",A?.id!==G.id&&"hidden"),children:s.jsx(Cw,{initialUrl:G.targetPath??"",directory:n,tabID:G.id})},G.id)),We.map(G=>s.jsx("div",{className:Pe("absolute inset-0",A?.id!==G.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Tw,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:G.diffScope??(G.stagedDiff?"staged":"working"),onDiffScopeChange:J,targetFilePath:G.targetPath,flushContent:!0})})},G.id)),U?s.jsx("div",{className:Pe("absolute inset-0",A?.mode==="terminal"?"block":"hidden"),children:s.jsx(sg,{visible:P&&A?.mode==="terminal",directory:U.targetDirectory})}):null,he?s.jsx("div",{className:Pe("absolute inset-0",A?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Iw,{directory:e,visible:A?.mode==="walkthrough"})})}):null,A?.mode!=="chat"&&!rt&&A?.mode!=="browser"&&A?.mode!=="diff"&&A?.mode!=="terminal"&&A?.mode!=="walkthrough"?Ne:null]})]})]})},eS=t=>{const e=tt.c(42),{open:n,onOpenChange:r}=t,{t:i}=At(),o=De(tS),l=De(sS),a=De(nS),u=De(rS);let d;e[0]!==o?(d=Pd(o),e[0]=o,e[1]=d):d=e[1];const h=d,m=l.length===0;let p;if(e[2]!==l||e[3]!==h){let A;e[5]!==l?(A=P=>l.includes(P.id),e[5]=l,e[6]=A):A=e[6],p=h.every(A),e[2]=l,e[3]=h,e[4]=p}else p=e[4];const g=p;let w;e[7]!==i?(w=i("contextRail.configure.dialogTitle"),e[7]=i,e[8]=w):w=e[8];let v;e[9]!==w?(v=s.jsx(Is,{children:w}),e[9]=w,e[10]=v):v=e[10];let x;e[11]!==i?(x=i("contextRail.configure.dialogDescription"),e[11]=i,e[12]=x):x=e[12];let f;e[13]!==x?(f=s.jsx(Ts,{children:x}),e[13]=x,e[14]=f):f=e[14];let b;e[15]!==v||e[16]!==f?(b=s.jsxs(Ws,{children:[v,f]}),e[15]=v,e[16]=f,e[17]=b):b=e[17];let y;if(e[18]!==l||e[19]!==a||e[20]!==h||e[21]!==i){let A;e[23]!==l||e[24]!==a||e[25]!==i?(A=P=>s.jsx(Zm,{settingsItem:`layout.context-rail.surface.${P.id}`,checked:!l.includes(P.id),onChange:I=>a(P.id,I),label:i(P.labelKey),ariaLabel:i(P.labelKey)},P.id),e[23]=l,e[24]=a,e[25]=i,e[26]=A):A=e[26],y=h.map(A),e[18]=l,e[19]=a,e[20]=h,e[21]=i,e[22]=y}else y=e[22];let S;e[27]!==y?(S=s.jsx("div",{className:"flex flex-col",children:y}),e[27]=y,e[28]=S):S=e[28];let N;e[29]!==m||e[30]!==g||e[31]!==u||e[32]!==i?(N=m?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[g?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(pt,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[29]=m,e[30]=g,e[31]=u,e[32]=i,e[33]=N):N=e[33];let C;e[34]!==N||e[35]!==b||e[36]!==S?(C=s.jsxs(Ss,{className:"max-w-md",children:[b,S,N]}),e[34]=N,e[35]=b,e[36]=S,e[37]=C):C=e[37];let j;return e[38]!==r||e[39]!==n||e[40]!==C?(j=s.jsx(ws,{open:n,onOpenChange:r,children:C}),e[38]=r,e[39]=n,e[40]=C,e[41]=j):j=e[41],j};function tS(t){return t.contextRailOrder}function sS(t){return t.contextRailHiddenSurfaces}function nS(t){return t.setContextRailSurfaceVisible}function rS(t){return t.setContextRailHiddenSurfaces}const nf=150,oS=500,iS=[],aS=t=>t>99?"99+":String(t),lS=t=>{const e=tt.c(51),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:u,badgeDescription:d,orderNumber:h,showOrderNumber:m,onSelect:p}=t;let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:w,listeners:v,setNodeRef:x,transform:f,transition:b,isDragging:y}=qo(g);let S;e[2]!==a?(S=a!=null&&a>0?aS(a):null,e[2]=a,e[3]=S):S=e[3];const N=S;let C;e[4]!==f?(C=Qo.Translate.toString(f),e[4]=f,e[5]=C):C=e[5];let j;e[6]!==C||e[7]!==b?(j={transform:C,transition:b},e[6]=C,e[7]=b,e[8]=j):j=e[8];const A=y&&"z-10 opacity-70";let P;e[9]!==A?(P=Pe("relative",A),e[9]=A,e[10]=P):P=e[10];let I;e[11]!==p||e[12]!==n?(I=()=>p(n),e[11]=p,e[12]=n,e[13]=I):I=e[13];const M=u??o,z=r?"text-primary":"text-muted-foreground hover:text-foreground";let R;e[14]!==z?(R=Pe("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",z),e[14]=z,e[15]=R):R=e[15];let H;e[16]!==n.icon||e[17]!==n.id?(H=n.id==="diff"?s.jsx(Iu,{}):s.jsx(E,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=H):H=e[18];let F;e[19]!==N||e[20]!==h||e[21]!==i||e[22]!==m?(F=m&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):N?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:N}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[19]=N,e[20]=h,e[21]=i,e[22]=m,e[23]=F):F=e[23];let O;e[24]!==w||e[25]!==r||e[26]!==v||e[27]!==R||e[28]!==H||e[29]!==F||e[30]!==I||e[31]!==M?(O=s.jsx(Pt,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...v,onClick:I,"aria-label":M,"aria-pressed":r,className:R,children:[H,F]})}),e[24]=w,e[25]=r,e[26]=v,e[27]=R,e[28]=H,e[29]=F,e[30]=I,e[31]=M,e[32]=O):O=e[32];let T;e[33]!==o?(T=s.jsx("span",{children:o}),e[33]=o,e[34]=T):T=e[34];let k;e[35]!==l?(k=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[35]=l,e[36]=k):k=e[36];let D;e[37]!==d?(D=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[37]=d,e[38]=D):D=e[38];let L;e[39]!==T||e[40]!==k||e[41]!==D?(L=s.jsx(It,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[T,k,D]})}),e[39]=T,e[40]=k,e[41]=D,e[42]=L):L=e[42];let Q;e[43]!==O||e[44]!==L?(Q=s.jsxs(Dt,{delayDuration:nf,children:[O,L]}),e[43]=O,e[44]=L,e[45]=Q):Q=e[45];let q;return e[46]!==x||e[47]!==Q||e[48]!==j||e[49]!==P?(q=s.jsx("div",{ref:x,style:j,className:P,children:Q}),e[46]=x,e[47]=Q,e[48]=j,e[49]=P,e[50]=q):q=e[50],q},cS=()=>{const t=tt.c(86),{t:e}=At(),n=br();let r;t[0]!==n?(r=n?rr(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=ve=>i?ve.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=De(o),a=De(dS),u=De(uS),d=De(fS),h=De(mS),m=De(hS),p=De(pS),g=De(gS),w=xa(xS),v=ki(bS),x=ki(yS),f=An(wS),b=An(SS),{screenWidth:y}=Bn(),S=ba(i||null);let N;t[4]!==g?(N=Ci("switch_context_surface",g),t[4]=g,t[5]=N):N=t[5];const C=N,[j,A]=c.useState(!1);let P,I;t[6]!==C?(P=()=>{const ve=new Set;let xe=null,je=!1;const oe=vS,J=()=>{tl(C,ve)?!je&&xe===null&&(xe=setTimeout(()=>A(!0),oS)):(je=!1,xe!==null&&(clearTimeout(xe),xe=null),A(!1))},K=V=>{if(ve.add(V.key.toLowerCase()),oe(V.key)&&tl(C,ve)){je=!0,xe!==null&&(clearTimeout(xe),xe=null),A(!1);return}J()},$=V=>{ve.delete(V.key.toLowerCase()),J()},le=()=>{ve.clear(),je=!1,xe!==null&&(clearTimeout(xe),xe=null),A(!1)};return window.addEventListener("keydown",K,!0),window.addEventListener("keyup",$,!0),window.addEventListener("blur",le),()=>{window.removeEventListener("keydown",K,!0),window.removeEventListener("keyup",$,!0),window.removeEventListener("blur",le),xe!==null&&clearTimeout(xe)}},I=[C],t[6]=C,t[7]=P,t[8]=I):(P=t[7],I=t[8]),c.useEffect(P,I);let M;t[9]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{distance:8}},t[9]=M):M=t[9];let z;t[10]===Symbol.for("react.memo_cache_sentinel")?(z={activationConstraint:{delay:200,tolerance:6}},t[10]=z):z=t[10];const R=zr(Mn(iu,M),Mn(ou,z)),H=l?.tabs??iS;let F;t[11]!==l?.activeTabId||t[12]!==H?(F=H.find(ve=>ve.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=H,t[13]=F):F=t[13];const O=F,T=l?.isOpen?O?.mode??null:null,k=S?.files.length??0;let D;t[14]!==d||t[15]!==u||t[16]!==b||t[17]!==x||t[18]!==w||t[19]!==y||t[20]!==H?(D=eh({railOrder:u,hiddenSurfaces:d,planModeEnabled:w,isVSCode:Dn(),screenWidth:y,tabs:H,linearConnected:x,githubConnected:b}),t[14]=d,t[15]=u,t[16]=b,t[17]=x,t[18]=w,t[19]=y,t[20]=H,t[21]=D):D=t[21];const L=D;let Q,q;t[22]!==T||t[23]!==p||t[24]!==i||t[25]!==v||t[26]!==x?(q=()=>{!i||!v||x||T!=="linear"||p(i)},Q=[T,p,i,v,x],t[22]=T,t[23]=p,t[24]=i,t[25]=v,t[26]=x,t[27]=Q,t[28]=q):(Q=t[27],q=t[28]),c.useEffect(q,Q);let te,ae;t[29]!==T||t[30]!==p||t[31]!==i||t[32]!==f||t[33]!==b?(te=()=>{!i||!f||b||T!=="pr"||p(i)},ae=[T,p,i,f,b],t[29]=T,t[30]=p,t[31]=i,t[32]=f,t[33]=b,t[34]=te,t[35]=ae):(te=t[34],ae=t[35]),c.useEffect(te,ae);const[X,Z]=c.useState(!1);let se;t[36]!==h?(se=ve=>{const{active:xe,over:je}=ve;if(!je||xe.id===je.id)return;const oe=Pd(De.getState().contextRailOrder).map(jS),J=oe.indexOf(xe.id),K=oe.indexOf(je.id);J===-1||K===-1||h(au(oe,J,K))},t[36]=h,t[37]=se):se=t[37];const fe=se;if(!i)return null;let B;t[38]!==e?(B=e("contextRail.aria.rail"),t[38]=e,t[39]=B):B=t[39];let ne;t[40]!==L?(ne=L.map(kS),t[40]=L,t[41]=ne):ne=t[41];let ye;if(t[42]!==T||t[43]!==k||t[44]!==i||t[45]!==m||t[46]!==j||t[47]!==L||t[48]!==e||t[49]!==a){let ve;t[51]!==T||t[52]!==k||t[53]!==i||t[54]!==m||t[55]!==j||t[56]!==e||t[57]!==a?(ve=(xe,je)=>{const oe=e(xe.labelKey),J=xe.id==="git"&&!a?k:0,K=J>0?J:null;return s.jsx(lS,{surface:xe,isActive:T===xe.mode,showActivityDot:!1,label:oe,description:e(xe.descriptionKey),badgeCount:K,badgeAriaLabel:K!==null?e(K===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:oe,count:K}):null,badgeDescription:K!==null?e(K===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:K}):null,orderNumber:je+1,showOrderNumber:j,onSelect:$=>m(i,$.mode)},xe.id)},t[51]=T,t[52]=k,t[53]=i,t[54]=m,t[55]=j,t[56]=e,t[57]=a,t[58]=ve):ve=t[58],ye=L.map(ve),t[42]=T,t[43]=k,t[44]=i,t[45]=m,t[46]=j,t[47]=L,t[48]=e,t[49]=a,t[50]=ye}else ye=t[50];let ce;t[59]!==ne||t[60]!==ye?(ce=s.jsx(Io,{items:ne,strategy:_i,children:ye}),t[59]=ne,t[60]=ye,t[61]=ce):ce=t[61];let _;t[62]!==fe||t[63]!==R||t[64]!==ce?(_=s.jsx(Vr,{sensors:R,collisionDetection:Ur,onDragEnd:fe,children:ce}),t[62]=fe,t[63]=R,t[64]=ce,t[65]=_):_=t[65];let re;t[66]!==e?(re=e("contextRail.configure.open"),t[66]=e,t[67]=re):re=t[67];let me;t[68]===Symbol.for("react.memo_cache_sentinel")?(me=()=>Z(!0),t[68]=me):me=t[68];let de;t[69]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(E,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[69]=de):de=t[69];let ge;t[70]!==re?(ge=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":re,onClick:me,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:de})}),t[70]=re,t[71]=ge):ge=t[71];let Te;t[72]!==e?(Te=e("contextRail.configure.open"),t[72]=e,t[73]=Te):Te=t[73];let be;t[74]!==Te?(be=s.jsx(It,{side:"left",sideOffset:8,children:Te}),t[74]=Te,t[75]=be):be=t[75];let Re;t[76]!==ge||t[77]!==be?(Re=s.jsxs(Dt,{delayDuration:nf,children:[ge,be]}),t[76]=ge,t[77]=be,t[78]=Re):Re=t[78];let we;t[79]!==X?(we=s.jsx(eS,{open:X,onOpenChange:Z}),t[79]=X,t[80]=we):we=t[80];let Y;return t[81]!==B||t[82]!==_||t[83]!==Re||t[84]!==we?(Y=s.jsxs("nav",{"aria-label":B,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[_,Re,we]}),t[81]=B,t[82]=_,t[83]=Re,t[84]=we,t[85]=Y):Y=t[85],Y};function dS(t){return t.workStatusPanelVisible}function uS(t){return t.contextRailOrder}function fS(t){return t.contextRailHiddenSurfaces}function mS(t){return t.setContextRailOrder}function hS(t){return t.openContextSurface}function pS(t){return t.closeContextPanel}function gS(t){return t.shortcutOverrides}function xS(t){return t.planModeEnabled}function bS(t){return t.hasChecked}function yS(t){return t.status?.connected===!0}function wS(t){return t.hasChecked}function SS(t){return t.status?.connected===!0}function vS(t){return t.length===1&&t>="0"&&t<="9"}function jS(t){return t.id}function kS(t){return t.id}const CS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),NS=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Rr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),AS=new Set,DS=[],Zi=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},PS=()=>{const t=tt.c(182),{t:e}=At(),n=De(IS),r=De(TS),i=De(RS),o=De(ES),l=De(MS),a=De(OS),u=De(FS),d=De(_S),h=De(BS),m=De(LS),p=De($S),g=De(WS),w=De(zS),v=Je(VS),x=Je(US),f=Je(KS),b=$r(HS);let y;t[0]!==n?(y=Ze=>n?Ze.activeSessions:DS,t[0]=n,t[1]=y):y=t[1];const S=Ps(y);let N;t[2]!==n?(N=Ze=>n?Ze.ids:AS,t[2]=n,t[3]=N):N=t[3];const C=$r(N);let j;t[4]!==n?(j=Ze=>n?Ze.rankById:Td,t[4]=n,t[5]=j):j=t[5];const A=va(j),P=ts(GS),I=Kt(qS),M=Kt(QS),z=br(),R=ad(YS),{files:H,git:F}=wn(),O=On(XS),{isMobile:T}=Bn();let k;t[6]!==z?(k=z?Zi(z):null,t[6]=z,t[7]=k):k=t[7];const D=k,[L,Q]=c.useState(""),te=Sa(L,200).trim();let ae;t[8]!==L?(ae=L.trim(),t[8]=L,t[9]=ae):ae=t[9];const X=ae;let Z,se;t[10]!==n?(Z=()=>{n&&Q("")},se=[n],t[10]=n,t[11]=Z,t[12]=se):(Z=t[11],se=t[12]),c.useEffect(Z,se);let fe,B;t[13]!==S||t[14]!==O||t[15]!==F||t[16]!==n?(fe=()=>{if(!n||!F)return;const Ze=setTimeout(()=>{const it=new Set;for(const gt of S){const xt=$s(gt);!xt||it.has(xt)||(it.add(xt),O(xt,F))}},0);return()=>clearTimeout(Ze)},B=[n,S,F,O],t[13]=S,t[14]=O,t[15]=F,t[16]=n,t[17]=fe,t[18]=B):(fe=t[17],B=t[18]),c.useEffect(fe,B);let ne;t[19]!==r?(ne=()=>r(!1),t[19]=r,t[20]=ne):ne=t[20];const ye=ne;let ce;t[21]!==ye?(ce=Ze=>()=>{ye(),Ze()},t[21]=ye,t[22]=ce):ce=t[22];const _=ce;let re;t[23]!==I?.id||t[24]!==I?.path||t[25]!==P||t[26]!==f||t[27]!==T||t[28]!==u||t[29]!==d||t[30]!==p||t[31]!==v||t[32]!==_||t[33]!==g||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==b||t[39]!==a?(re=()=>{const Ze=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(E,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:_(()=>{l(!1),v()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(E,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:_(JS)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(E,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:_(ZS)},{id:"toggle-sidebar",title:e(T?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(E,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(T?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:_(()=>{if(T){const{isSessionSwitcherOpen:it}=De.getState();l(!it)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(E,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:_(()=>{P&&d(P,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(E,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:_(()=>{P&&u(P)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(E,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:_(ev)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(E,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:_(tv)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(E,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:_(()=>i(!0))}];return Ze.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(E,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:_(()=>{f&&P&&b({directory:P,sessionId:f})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(E,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:_(()=>{f&&pn(f).then(it=>{if(it.ok){Me.success(e("sessions.sidebar.session.copyId.success"));return}Me.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Me.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(E,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:_(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(E,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:_(()=>{l(!1),g(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(E,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:_(()=>{P&&(w("notes"),d(P,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(E,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:_(()=>{P&&(w("todos"),d(P,"notes"))})}),Ze.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(E,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:_(sv)}),zo()&&Ze.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(E,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:_(()=>{En("desktop_open_draft_mini_chat_window",{directory:Zi(P||I?.path||""),projectId:I?.id??null}).catch(nv)})}),Ze},t[23]=I?.id,t[24]=I?.path,t[25]=P,t[26]=f,t[27]=T,t[28]=u,t[29]=d,t[30]=p,t[31]=v,t[32]=_,t[33]=g,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=b,t[39]=a,t[40]=re):re=t[40],I?.id,I?.path;let me;t[41]!==re?(me=re(),t[41]=re,t[42]=me):me=t[42];const de=me;let ge;t[43]===Symbol.for("react.memo_cache_sentinel")?(ge=xn(),t[43]=ge):ge=t[43];const Te=ge;let be,Re;t[44]===Symbol.for("react.memo_cache_sentinel")?(be=Dn(),Re=!Te&&ma(),t[44]=be,t[45]=Re):(be=t[44],Re=t[45]);let we;t[46]!==T?(we={isVSCode:be,isWeb:Re,isDesktop:Te,isMobile:T},t[46]=T,t[47]=we):we=t[47];const Y=we;let ve;if(t[48]!==_||t[49]!==i||t[50]!==o||t[51]!==Y){let Ze;t[53]!==Y?(Ze=gt=>gt.isAvailable?gt.isAvailable(Y):!0,t[53]=Y,t[54]=Ze):Ze=t[54];let it;t[55]!==_||t[56]!==i||t[57]!==o?(it=gt=>{const xt=rg(gt.slug)??"settings-3",Et=(gt.keywords??[]).join(" ");return{id:`settings:${gt.slug}`,title:gt.title,icon:gt.slug==="mcp"?s.jsx(oh,{className:"mr-2 h-4 w-4"}):s.jsx(E,{name:xt,className:"mr-2 h-4 w-4"}),searchText:`${gt.title} ${gt.group} ${Et}`,onSelect:_(()=>{o(gt.slug),i(!0)})}},t[55]=_,t[56]=i,t[57]=o,t[58]=it):it=t[58],ve=ng.filter(rv).filter(Ze).map(it),t[48]=_,t[49]=i,t[50]=o,t[51]=Y,t[52]=ve}else ve=t[52];const xe=ve;let je;if(t[59]!==S||t[60]!==C||t[61]!==A){const Ze=S.filter(ov);je=th(Ze,C,A),t[59]=S,t[60]=C,t[61]=A,t[62]=je}else je=t[62];const oe=je,J=Id(),K=Je(iv);let $;t[63]!==J||t[64]!==K?($=(Ze,it)=>{const gt=K.get(Ze);return gt?.branch?gt.branch.trim()||null:it&&J.get(it)?.trim()||null},t[63]=J,t[64]=K,t[65]=$):$=t[65];const le=$;let V;t[66]===Symbol.for("react.memo_cache_sentinel")?(V=[],t[66]=V):V=t[66];const[Ce,Be]=c.useState(V),[ke,Ne]=c.useState(""),Qe=CS(D,te);let We;t[67]!==D||t[68]!==Qe||t[69]!==n||t[70]!==R||t[71]!==Be||t[72]!==Ne||t[73]!==te?(We=()=>{if(!n){Be([]),Ne("");return}if(!Qe){Be([]),Ne("");return}if(!D){Be([]),Ne("");return}let Ze=!1;return R(D,te,40,{type:"file"}).then(it=>{Ze||(Be(it.map(av)),Ne(Qe))}).catch(()=>{Ze||(Be([]),Ne(Qe))}),()=>{Ze=!0}},t[67]=D,t[68]=Qe,t[69]=n,t[70]=R,t[71]=Be,t[72]=Ne,t[73]=te,t[74]=We):We=t[74];let U;t[75]!==D||t[76]!==Qe||t[77]!==n||t[78]!==R||t[79]!==te?(U=[n,D,te,Qe,R],t[75]=D,t[76]=Qe,t[77]=n,t[78]=R,t[79]=te,t[80]=U):U=t[80],c.useEffect(We,U);const he=X.length>0;let Ee;e:{if(!he){let it;t[81]!==de?(it=de.filter(lv).map(cv),t[81]=de,t[82]=it):it=t[82],Ee=it;break e}let Ze;t[83]!==de||t[84]!==X?(Ze=Rr(de,X,dv,{limit:7,noFuzzy:!0}),t[83]=de,t[84]=X,t[85]=Ze):Ze=t[85],Ee=Ze}const Ie=Ee;let rt;e:{if(!he){let it;t[86]===Symbol.for("react.memo_cache_sentinel")?(it=[],t[86]=it):it=t[86],rt=it;break e}let Ze;t[87]!==X||t[88]!==xe?(Ze=Rr(xe,X,uv,{limit:7,noFuzzy:!0}),t[87]=X,t[88]=xe,t[89]=Ze):Ze=t[89],rt=Ze}const Ge=rt;let ut;e:{if(!he){let it;t[90]!==oe?(it=oe.slice(0,5).map(fv),t[90]=oe,t[91]=it):it=t[91],ut=it;break e}let Ze;t[92]!==X||t[93]!==oe?(Ze=Rr(oe,X,mv,{limit:7,threshold:.2}),t[92]=X,t[93]=oe,t[94]=Ze):Ze=t[94],ut=Ze}const ct=ut;let ue;e:{if(!n){let it;t[95]===Symbol.for("react.memo_cache_sentinel")?(it=[],t[95]=it):it=t[95],ue=it;break e}let Ze;t[96]!==Ce||t[97]!==ke||t[98]!==Qe||t[99]!==te?(Ze=NS(Ce,te,Qe,ke),t[96]=Ce,t[97]=ke,t[98]=Qe,t[99]=te,t[100]=Ze):Ze=t[100],ue=Ze}const G=ue,Le=n&&Qe.length>0&&ke!==Qe;let Oe;e:{if(!he){let it;t[101]===Symbol.for("react.memo_cache_sentinel")?(it=[],t[101]=it):it=t[101],Oe=it;break e}let Ze;if(t[102]!==X||t[103]!==M){const it=M.map(hv);Ze=Rr(it,X,pv,{limit:7,threshold:.4}),t[102]=X,t[103]=M,t[104]=Ze}else Ze=t[104];Oe=Ze}const qe=Oe;let Ue,st,wt,Nt,ie,pe,Ve,ze,He,ot,at,et,Xe,dt;if(t[105]!==le||t[106]!==ye||t[107]!==D||t[108]!==H||t[109]!==he||t[110]!==n||t[111]!==h||t[112]!==v||t[113]!==L||t[114]!==Ie||t[115]!==G||t[116]!==qe||t[117]!==ct||t[118]!==Ge||t[119]!==r||t[120]!==x||t[121]!==m||t[122]!==e){const Ze=Ie.map(gv),it=Ge.map(xv),gt=ct.map(bv),xt=he?G.map(yv):[],Et=he?qe.map(wv):[];let kt;e:{if(!he){kt=["commands","sessions"];break e}const mt=Sv,lt=[{key:"commands",score:mt(Ie)},{key:"settings",score:mt(Ge)},{key:"sessions",score:mt(ct)},{key:"files",score:mt(G)},{key:"projects",score:mt(qe)}];lt.sort(vv),kt=lt.map(jv)}const Tt=kt,Ot=mt=>{ye(),x(mt.id,$s(mt))},Vt=async mt=>{if(!D)return;const lt=await Ou(H,mt,{directory:D});if(!lt.ok){Me.error(Fu(lt.reason));return}h(D,mt),ye()},Yt=(mt,lt)=>{ye(),v({selectedProjectId:mt,directoryOverride:lt})},Ht=mt=>qn(qr(mt,m));Nt=ws,et=n,Xe=r;let Lt;t[137]!==e?(Lt=e("commandPalette.title"),t[137]=e,t[138]=Lt):Lt=t[138];let zt;t[139]!==Lt?(zt=s.jsx(Is,{children:Lt}),t[139]=Lt,t[140]=zt):zt=t[140];let _e;t[141]!==e?(_e=e("commandPalette.description"),t[141]=e,t[142]=_e):_e=t[142];let Ye;t[143]!==_e?(Ye=s.jsx(Ts,{children:_e}),t[143]=_e,t[144]=Ye):Ye=t[144],t[145]!==zt||t[146]!==Ye?(dt=s.jsxs(Ws,{className:"sr-only",children:[zt,Ye]}),t[145]=zt,t[146]=Ye,t[147]=dt):dt=t[147],wt=Ss,ot="overflow-hidden p-0",at=!0,st=ih,Ve=!1,ze="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let ft;t[148]!==e?(ft=e("commandPalette.input.placeholder"),t[148]=e,t[149]=ft):ft=t[149],t[150]!==L||t[151]!==ft?(He=s.jsx(ah,{value:L,onValueChange:Q,placeholder:ft}),t[150]=L,t[151]=ft,t[152]=He):He=t[152],Ue=lh;let bt;t[153]!==e?(bt=e("commandPalette.empty.noResults"),t[153]=e,t[154]=bt):bt=t[154],t[155]!==bt?(ie=s.jsx(ch,{children:bt}),t[155]=bt,t[156]=ie):ie=t[156],pe=Tt.map(mt=>mt==="commands"&&Ze.length>0?s.jsx(vr,{children:Ze.map(lt=>s.jsxs(Er,{value:lt.id,onSelect:lt.onSelect,children:[lt.icon,s.jsx("span",{children:lt.title}),lt.shortcutId?s.jsx(sh,{children:Ht(lt.shortcutId)}):null]},lt.id))},"commands"):mt==="settings"&&it.length>0?s.jsx(vr,{children:it.map(kv)},"settings"):mt==="sessions"&>.length>0?s.jsx(vr,{children:gt.map(lt=>{const $t=lt.title||e("commandPalette.session.untitled"),Zt=$s(lt),Xt=le(lt.id,Zt);return s.jsxs(Er,{value:`session:${lt.id}`,onSelect:()=>Ot(lt),children:[s.jsx(E,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:$t}),Xt?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:Xt})]}):null]},lt.id)})},"sessions"):mt==="files"&&xt.length>0?s.jsx(vr,{children:xt.map(lt=>{const $t=nh(lt.relativePath||lt.name,{maxLength:80});return s.jsxs(Er,{value:`file:${lt.path}`,onSelect:()=>{Vt(lt.path)},children:[s.jsx(wa,{filePath:lt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":lt.relativePath,children:$t})]},`file:${lt.path}`)})},"files"):mt==="projects"&&Et.length>0?s.jsx(vr,{children:Et.map(lt=>{const $t=lt.displayName;return s.jsxs(Er,{value:`project:${lt.id}`,onSelect:()=>Yt(lt.id,lt.path),children:[s.jsx(E,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:$t}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:lt.path})]},`project:${lt.id}`)})},"projects"):null),t[105]=le,t[106]=ye,t[107]=D,t[108]=H,t[109]=he,t[110]=n,t[111]=h,t[112]=v,t[113]=L,t[114]=Ie,t[115]=G,t[116]=qe,t[117]=ct,t[118]=Ge,t[119]=r,t[120]=x,t[121]=m,t[122]=e,t[123]=Ue,t[124]=st,t[125]=wt,t[126]=Nt,t[127]=ie,t[128]=pe,t[129]=Ve,t[130]=ze,t[131]=He,t[132]=ot,t[133]=at,t[134]=et,t[135]=Xe,t[136]=dt}else Ue=t[123],st=t[124],wt=t[125],Nt=t[126],ie=t[127],pe=t[128],Ve=t[129],ze=t[130],He=t[131],ot=t[132],at=t[133],et=t[134],Xe=t[135],dt=t[136];let Fe;t[157]!==Le||t[158]!==e?(Fe=Le?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[157]=Le,t[158]=e,t[159]=Fe):Fe=t[159];let Se;t[160]!==Ue||t[161]!==ie||t[162]!==pe||t[163]!==Fe?(Se=s.jsxs(Ue,{children:[ie,pe,Fe]}),t[160]=Ue,t[161]=ie,t[162]=pe,t[163]=Fe,t[164]=Se):Se=t[164];let St;t[165]!==st||t[166]!==Ve||t[167]!==ze||t[168]!==He||t[169]!==Se?(St=s.jsxs(st,{shouldFilter:Ve,className:ze,children:[He,Se]}),t[165]=st,t[166]=Ve,t[167]=ze,t[168]=He,t[169]=Se,t[170]=St):St=t[170];let vt;t[171]!==wt||t[172]!==ot||t[173]!==at||t[174]!==St?(vt=s.jsx(wt,{className:ot,showCloseButton:at,children:St}),t[171]=wt,t[172]=ot,t[173]=at,t[174]=St,t[175]=vt):vt=t[175];let Rt;return t[176]!==Nt||t[177]!==et||t[178]!==Xe||t[179]!==dt||t[180]!==vt?(Rt=s.jsxs(Nt,{open:et,onOpenChange:Xe,children:[dt,vt]}),t[176]=Nt,t[177]=et,t[178]=Xe,t[179]=dt,t[180]=vt,t[181]=Rt):Rt=t[181],Rt};function IS(t){return t.isCommandPaletteOpen}function TS(t){return t.setCommandPaletteOpen}function RS(t){return t.setSettingsDialogOpen}function ES(t){return t.setSettingsPage}function MS(t){return t.setSessionSwitcherOpen}function OS(t){return t.toggleSidebar}function FS(t){return t.openContextOverview}function _S(t){return t.openContextSurface}function BS(t){return t.openContextFile}function LS(t){return t.shortcutOverrides}function $S(t){return t.openMultiRunLauncher}function WS(t){return t.setArchivePageOpen}function zS(t){return t.setProjectContextTab}function VS(t){return t.openNewSessionDraft}function US(t){return t.setCurrentSession}function KS(t){return t.currentSessionId}function HS(t){return t.toggle}function GS(t){return t.currentDirectory}function qS(t){return t.getActiveProject()}function QS(t){return t.projects}function YS(t){return t.searchFiles}function XS(t){return t.ensureStatus}function JS(){Rd()}function ZS(){gn.requestDirectoryDialog()}function ev(){dh.invoke("cycle_theme")}function tv(){Ed()}function sv(){window.dispatchEvent(new CustomEvent("aiworker:memory-debug-toggle"))}function nv(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function rv(t){return t.slug!=="home"}function ov(t){return!rh(t)}function iv(t){return t.worktreeMetadata}function av(t){return{path:Zi(t.path),name:t.name,relativePath:t.relativePath}}function lv(t){return!t.secondary}function cv(t){return{item:t,score:0}}function dv(t){return t.searchText}function uv(t){return t.searchText}function fv(t){return{item:t,score:0}}function mv(t){return t.title||""}function hv(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function pv(t){return t.searchText}function gv(t){return t.item}function xv(t){return t.item}function bv(t){return t.item}function yv(t){return t.item}function wv(t){return t.item}function Sv(t){return t.length?t[0].score:1/0}function vv(t,e){return t.score-e.score}function jv(t){return t.key}function kv(t){return s.jsxs(Er,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const ac=(t,e,n)=>qn(qr(t,e),n),Cv=()=>{const t=tt.c(74),{t:e}=At(),n=De(Nv),r=De(Av),i=De(Dv);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=Dn(),t[0]=o):o=t[0];const l=o;let a,u,d,h,m,p,g,w,v,x,f,b;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const k=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[qn("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${qn(Ci("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${qn(Ci("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];d=ws,f=n,b=r,u=Ss,v="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let D;t[17]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(E,{name:"command",className:"h-5 w-5"}),t[17]=D):D=t[17];let L;t[18]!==e?(L=e("helpDialog.title"),t[18]=e,t[19]=L):L=t[19];let Q;t[20]!==L?(Q=s.jsxs(Is,{className:"flex items-center gap-2",children:[D,L]}),t[20]=L,t[21]=Q):Q=t[21];let q;t[22]!==e?(q=e("helpDialog.description"),t[22]=e,t[23]=q):q=t[23];let te;t[24]!==q?(te=s.jsx(Ts,{children:q}),t[24]=q,t[25]=te):te=t[25],t[26]!==Q||t[27]!==te?(x=s.jsxs(Ws,{children:[Q,te]}),t[26]=Q,t[27]=te,t[28]=x):x=t[28],a=ln,p="flex-1 min-h-0 mt-3",g="pr-1",w=!0,h="space-y-4",m=k.map(ae=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(ae.categoryKey)}),s.jsx("div",{className:"space-y-1",children:ae.items.filter(X=>!(l&&X.id==="toggle_prompt_navigator")).map(X=>{const Z=X.id?uh(X.id):void 0,se=X.descriptionKey??(Z?.customizable?Z.settingsLabelKey:void 0);if(!se||X.id&&!qr(X.id,i))return null;const fe=X.id?ac(X.id,i,e("settings.aiworker.keyboardShortcuts.unassigned")):Array.isArray(X.keys)?X.keys:X.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[X.icon&&s.jsx(E,{name:X.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(se)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(fe)?fe:[fe]).map((B,ne)=>s.jsxs(c.Fragment,{children:[ne>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:B})]},`${B}-${ne}`))})]},X.id||se)})})]},ae.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=u,t[7]=d,t[8]=h,t[9]=m,t[10]=p,t[11]=g,t[12]=w,t[13]=v,t[14]=x,t[15]=f,t[16]=b}else a=t[5],u=t[6],d=t[7],h=t[8],m=t[9],p=t[10],g=t[11],w=t[12],v=t[13],x=t[14],f=t[15],b=t[16];let y;t[29]!==h||t[30]!==m?(y=s.jsx("div",{className:h,children:m}),t[29]=h,t[30]=m,t[31]=y):y=t[31];let S;t[32]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=S):S=t[32];let N;t[33]!==e?(N=e("helpDialog.proTips.title"),t[33]=e,t[34]=N):N=t[34];let C;t[35]!==N?(C=s.jsx("p",{className:"font-medium mb-1",children:N}),t[35]=N,t[36]=C):C=t[36];let j;t[37]!==i||t[38]!==e?(j=e("helpDialog.proTips.commandPalette",{shortcut:ac("open_command_palette",i,e("settings.aiworker.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=j):j=t[39];let A;t[40]!==j?(A=s.jsxs("li",{children:["• ",j]}),t[40]=j,t[41]=A):A=t[41];let P;t[42]!==e?(P=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=P):P=t[43];let I;t[44]!==P?(I=s.jsxs("li",{children:["• ",P]}),t[44]=P,t[45]=I):I=t[45];let M;t[46]!==e?(M=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=M):M=t[47];let z;t[48]!==M?(z=s.jsxs("li",{children:["• ",M]}),t[48]=M,t[49]=z):z=t[49];let R;t[50]!==A||t[51]!==I||t[52]!==z?(R=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[A,I,z]}),t[50]=A,t[51]=I,t[52]=z,t[53]=R):R=t[53];let H;t[54]!==C||t[55]!==R?(H=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[S,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[C,R]})]})}),t[54]=C,t[55]=R,t[56]=H):H=t[56];let F;t[57]!==a||t[58]!==y||t[59]!==H||t[60]!==p||t[61]!==g||t[62]!==w?(F=s.jsxs(a,{outerClassName:p,className:g,disableHorizontal:w,children:[y,H]}),t[57]=a,t[58]=y,t[59]=H,t[60]=p,t[61]=g,t[62]=w,t[63]=F):F=t[63];let O;t[64]!==u||t[65]!==F||t[66]!==v||t[67]!==x?(O=s.jsxs(u,{className:v,children:[x,F]}),t[64]=u,t[65]=F,t[66]=v,t[67]=x,t[68]=O):O=t[68];let T;return t[69]!==d||t[70]!==O||t[71]!==f||t[72]!==b?(T=s.jsx(d,{open:f,onOpenChange:b,children:O}),t[69]=d,t[70]=O,t[71]=f,t[72]=b,t[73]=T):T=t[73],T};function Nv(t){return t.isHelpDialogOpen}function Av(t){return t.setHelpDialogOpen}function Dv(t){return t.shortcutOverrides}const Pv=()=>{const t=tt.c(32),{t:e}=At(),n=De(Iv),r=De(Tv),i=De(Rv);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await pn(i)).ok){Me.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Me.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let u;t[5]!==a?(u=s.jsx(Is,{children:a}),t[5]=a,t[6]=u):u=t[6];let d;t[7]!==e?(d=e("openCodeStatusDialog.description"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==d?(h=s.jsx(Ts,{children:d}),t[9]=d,t[10]=h):h=t[10];let m;t[11]!==u||t[12]!==h?(m=s.jsxs(Ws,{children:[u,h]}),t[11]=u,t[12]=h,t[13]=m):m=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let g;t[16]!==l||t[17]!==p?(g=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:p})}),t[16]=l,t[17]=p,t[18]=g):g=t[18];let w;t[19]!==i||t[20]!==e?(w=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:w}),t[22]=w,t[23]=v):v=t[23];let x;t[24]!==m||t[25]!==g||t[26]!==v?(x=s.jsxs(Ss,{className:"max-w-2xl",children:[m,g,v]}),t[24]=m,t[25]=g,t[26]=v,t[27]=x):x=t[27];let f;return t[28]!==n||t[29]!==r||t[30]!==x?(f=s.jsx(ws,{open:n,onOpenChange:r,children:x}),t[28]=n,t[29]=r,t[30]=x,t[31]=f):f=t[31],f};function Iv(t){return t.isOpenCodeStatusDialogOpen}function Tv(t){return t.setOpenCodeStatusDialogOpen}function Rv(t){return t.openCodeStatusText}const Ev=t=>{const e=tt.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let u,d;e[0]!==a||e[1]!==r||e[2]!==o?(u=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},d=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=u,e[4]=d):(u=e[3],d=e[4]),c.useEffect(u,d);let h,m;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const w=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("aiworker:sidebar-session-search",w),()=>window.removeEventListener("aiworker:sidebar-session-search",w)},m=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=m):(h=e[8],m=e[9]),c.useEffect(h,m);let p,g;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const w=v=>{l.current&&(l.current.contains(v.target)||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},g=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=g):(p=e[14],g=e[15]),c.useEffect(p,g)},Mv=t=>{const e=tt.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const u=new Map(l.map(Ov)),d=[];a.forEach(p=>{const g=u.get(p);g&&(d.push(g),u.delete(p))});const h=[],m=[];return l.forEach(p=>{u.has(p.id)&&(p.isArchivedBucket?m.push(p):h.push(p))}),[...h,...d,...m]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function Ov(t){return[t.id,t]}const ao="oc.sessions.projectCollapse",lc="oc.sessions.groupOrder",cc="oc.sessions.groupCollapse",dc=t=>{if(!t)return new Set;try{const e=Ta(xr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},Fv=t=>{if(!t)return new Map;try{const e=hu(xr(),Ta(xr())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},_v=t=>{const e=tt.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=No(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>dc(o.getItem(ao)),e[1]=l):l=e[1];const[a,u]=c.useState(l);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>dc(o.getItem(cc)),e[2]=d):d=e[2];const[h,m]=c.useState(d);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>Fv(o.getItem(lc)),e[3]=p):p=e[3];const[g,w]=c.useState(p),v=c.useRef(0),x=c.useRef(!1),f=c.useRef(!1),b=c.useRef(null),y=c.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const ne=y.current;if(y.current=null,b.current=null,!ne)return;const{projects:ye}=Kt.getState(),ce=ye.map(_=>({..._,sidebarCollapsed:ne.has(_.id)}));Tr({projects:ce}).catch(Bv)},e[4]=n,e[5]=S):S=e[5];const N=S;let C;e[6]!==N||e[7]!==n?(C=ne=>{!globalThis.window||n||(y.current=ne,b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=C):C=e[8];const j=C;let A,P;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=()=>()=>{globalThis.window&&b.current!==null&&window.clearTimeout(b.current),b.current=null,y.current=null},P=[],e[9]=A,e[10]=P):(A=e[9],P=e[10]),c.useEffect(A,P);let I,M;e[11]!==g?(M=()=>{if(f.current)try{o.setItem(lc,JSON.stringify(Object.fromEntries(g.entries())))}catch{}},I=[g,o],e[11]=g,e[12]=I,e[13]=M):(I=e[12],M=e[13]),c.useEffect(M,I);let z,R;e[14]!==h?(z=()=>{if(x.current)try{o.setItem(cc,JSON.stringify(Array.from(h)))}catch{}},R=[h,o],e[14]=h,e[15]=z,e[16]=R):(z=e[15],R=e[16]),c.useEffect(z,R);let H;e[17]!==r||e[18]!==j?(H=()=>{v.current=Date.now()+150,x.current=!0,m(new Set),u(()=>{const ne=new Set(r.map(Lv));try{o.setItem(ao,JSON.stringify(Array.from(ne)))}catch{}return j(ne),ne})},e[17]=r,e[18]=j,e[19]=H):H=e[19];const F=H;let O;e[20]!==j?(O=()=>{v.current=Date.now()+150,x.current=!0,m(new Set),u(()=>{const ne=new Set;try{o.setItem(ao,JSON.stringify([]))}catch{}return j(ne),ne})},e[20]=j,e[21]=O):O=e[21];const T=O;let k;e[22]!==j?(k=ne=>{v.current=Date.now()+150,u(ye=>{const ce=new Set(ye);ce.has(ne)?ce.delete(ne):ce.add(ne);try{o.setItem(ao,JSON.stringify(Array.from(ce)))}catch{}return j(ce),ce})},e[22]=j,e[23]=k):k=e[23];const D=k;let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=ne=>{x.current=!0,m(ye=>{const ce=new Set(ye);return ce.has(ne)?ce.delete(ne):ce.add(ne),ce})},e[24]=L):L=e[24];const Q=L;let q;e[25]===Symbol.for("react.memo_cache_sentinel")?(q=ne=>{f.current=!0,w(ne)},e[25]=q):q=e[25];const te=q,{getOrderedGroups:ae}=Mv(g);let X;e[26]!==h||e[27]!==a||e[28]!==g?(X={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:g},e[26]=h,e[27]=a,e[28]=g,e[29]=X):X=e[29];const Z=X;let se;e[30]!==F||e[31]!==T||e[32]!==ae||e[33]!==j||e[34]!==D?(se={setCollapsedProjects:u,toggleProject:D,collapseAllProjects:F,expandAllProjects:T,scheduleCollapsedProjectsPersist:j,setCollapsedGroups:m,toggleGroup:Q,setGroupOrderByProject:te,getOrderedGroups:ae},e[30]=F,e[31]=T,e[32]=ae,e[33]=j,e[34]=D,e[35]=se):se=e[35];const fe=se;let B;return e[36]!==fe||e[37]!==Z?(B={state:Z,actions:fe},e[36]=fe,e[37]=Z,e[38]=B):B=e[38],B};function Bv(){}function Lv(t){return t.id}const $v=5*6e4,Wv=t=>{const e=tt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:u}=wn(),d=On(zv);let h,m;e[0]!==a||e[1]!==d||e[2]!==u||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!u||n.length===0){o(new Map);return}n.forEach(C=>{Ni(()=>d(C.normalizedPath,u))})},m=[a,n,u,d,o],e[0]=a,e[1]=d,e[2]=u,e[3]=n,e[4]=o,e[5]=h,e[6]=m):(h=e[5],m=e[6]),c.useEffect(h,m);let p,g;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(j=>{C.set(j.id,i.get(j.normalizedPath)?.isGitRepo??null)}),o(C)},g=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=g):(p=e[11],g=e[12]),c.useEffect(p,g);let w;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=j=>{const A=i.get(j.normalizedPath)?.branch??"";return`${j.id}:${A}`},e[16]=i,e[17]=C):C=e[17],w=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=w}else w=e[15];const v=w;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[18]=x):x=e[18];const f=c.useRef(x);let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=new Map,e[19]=b):b=e[19];const y=c.useRef(b);let S;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(S=()=>{if(!a)return;let C=!1;const j=setTimeout(()=>{(async()=>{const P=new Set(n.map(Vv));for(const F of f.current.keys())P.has(F)||(f.current.delete(F),y.current.delete(F));const I=Date.now(),M=n.filter(F=>{const O=i.get(F.normalizedPath);if(O?.isGitRepo===!1)return f.current.delete(F.id),y.current.delete(F.id),!1;if(O?.isGitRepo!==!0||O.branch===null)return!1;const T=O.branch.trim(),k=`${F.normalizedPath}\0${T}`,D=f.current.get(F.id);if(D===k){const L=y.current.get(F.id);return L&&(L.at=I),!1}return!(D!==void 0&&I-(y.current.get(F.id)?.at??0)<$v)});if(M.length===0)return;const z=await fh(M,2,async F=>{const O=i.get(F.normalizedPath)?.branch?.trim()??"",T=`${F.normalizedPath}\0${O}`,k=await Ni(()=>Go(F.normalizedPath,O?{knownBranch:O}:void 0)).catch(Uv);return{id:F.id,inputKey:T,branch:k}});if(C)return;const R=z.filter(Kv);if(R.length===0)return;const H=Date.now();l(F=>{const O=new Map(F);return R.forEach(T=>{const{id:k,branch:D}=T;D&&O.set(k,D)}),O}),R.forEach(F=>{const{id:O,inputKey:T,branch:k}=F;f.current.set(O,T),k&&y.current.set(O,{branch:k,at:H})})})()},150);return()=>{C=!0,clearTimeout(j)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=S):S=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==v||e[29]!==l?(N=[a,n,v,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=v,e[29]=l,e[30]=N):N=e[30],c.useEffect(S,N)};function zv(t){return t.ensureStatus}function Vv(t){return t.id}function Uv(){return null}function Kv(t){return t.branch}const Hv=t=>{const e=tt.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(og,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(Ss,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(ln,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-background",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==a?(u=s.jsx(ws,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=u):u=e[9],u},Gv=(t,e)=>{if(!e)return Array.from(t);const n=[],r=new Set;for(const i of t){r.has(i)||(r.add(i),n.push(i));const o=e.get(i);if(o)for(const l of o)r.has(l)||(r.add(l),n.push(l))}return n},hs=er()((t,e)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{e().enabled||t({enabled:!0})},disable:()=>{t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{e().enabled?t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):t({enabled:!0})},toggleSelected:(n,r,i)=>{const o=e(),l=new Set(o.selectedIds);let a=o.scopeKey,u=o.anchorId;r!==null&&o.scopeKey!==null&&r!==o.scopeKey?(l.clear(),a=r,u=null):a===null&&r!==null&&(a=r);const h=i&&i.length>0?[n,...i]:[n];if(l.has(n)){for(const p of h)l.delete(p);u===n&&(u=null)}else{for(const p of h)l.add(p);u=n}l.size===0?t({selectedIds:l,scopeKey:null,anchorId:null}):t({selectedIds:l,scopeKey:a,anchorId:u})},setRange:(n,r,i,o,l)=>{const a=e();if(i.length===0)return;const u=n&&i.includes(n)?n:i[0],d=i.indexOf(u),h=i.indexOf(r);if(d<0||h<0)return;const[m,p]=d<=h?[d,h]:[h,d],g=i.slice(m,p+1),w=Gv(g,l),x=o!==null&&a.scopeKey!==null&&o!==a.scopeKey?new Set:new Set(a.selectedIds);for(const f of w)x.add(f);t({selectedIds:x,scopeKey:o??a.scopeKey,anchorId:u})},replaceAll:(n,r)=>{if(n.length===0){t({selectedIds:new Set,scopeKey:null,anchorId:null});return}t({selectedIds:new Set(n),scopeKey:r,anchorId:n[0]??null})},clear:()=>{t({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{const r=e();if(r.selectedIds.size===0||n.length===0)return;const i=new Set(r.selectedIds);for(const o of n)i.delete(o);i.size!==r.selectedIds.size&&(i.size===0?t({selectedIds:i,scopeKey:null,anchorId:null}):t({selectedIds:i}))}}));function qv(t){const e=tt.c(213),{t:n}=At(),{hideDirectoryControls:r,showProjectDisplayControls:i,showRecentControls:o,handleOpenDirectoryDialog:l,onOpenScheduled:a,onOpenMultiRun:u,canOpenMultiRun:d,onOpenArchive:h,headerActionIconClass:m,headerActionButtonClass:p,isSessionSearchOpen:g,setIsSessionSearchOpen:w,sessionSearchInputRef:v,sessionSearchQuery:x,setSessionSearchQuery:f,hasSessionSearchQuery:b,searchMatchCount:y,collapseAllProjects:S,expandAllProjects:N}=t,C=hs(a0),j=hs(i0),A=ls(o0),P=ls(r0),I=ls(n0),M=ls(s0),z=ls(t0),R=ls(e0),H=ls(Zv),F=ls(Jv),O=ls(Xv),T=ls(Yv),k=i&&O==="single";if(r)return null;let D;e[0]!==p?(D=Pe(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=p,e[1]=D):D=e[1];let L;e[2]!==n?(L=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=L):L=e[3];let Q;e[4]!==m?(Q=s.jsx(E,{name:"folder-add",className:m}),e[4]=m,e[5]=Q):Q=e[5];let q;e[6]!==l||e[7]!==D||e[8]!==L||e[9]!==Q?(q=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,className:D,"aria-label":L,children:Q})}),e[6]=l,e[7]=D,e[8]=L,e[9]=Q,e[10]=q):q=e[10];let te;e[11]!==n?(te=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=te):te=e[12];let ae;e[13]!==te?(ae=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:te})}),e[13]=te,e[14]=ae):ae=e[14];let X;e[15]!==q||e[16]!==ae?(X=s.jsxs(Dt,{children:[q,ae]}),e[15]=q,e[16]=ae,e[17]=X):X=e[17];let Z;e[18]!==p?(Z=Pe(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=p,e[19]=Z):Z=e[19];let se;e[20]!==n?(se=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=se):se=e[21];let fe;e[22]!==m?(fe=s.jsx(E,{name:"calendar-schedule",className:m}),e[22]=m,e[23]=fe):fe=e[23];let B;e[24]!==a||e[25]!==Z||e[26]!==se||e[27]!==fe?(B=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:Z,"aria-label":se,children:fe})}),e[24]=a,e[25]=Z,e[26]=se,e[27]=fe,e[28]=B):B=e[28];let ne;e[29]!==n?(ne=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=ne):ne=e[30];let ye;e[31]!==ne?(ye=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ne})}),e[31]=ne,e[32]=ye):ye=e[32];let ce;e[33]!==B||e[34]!==ye?(ce=s.jsxs(Dt,{children:[B,ye]}),e[33]=B,e[34]=ye,e[35]=ce):ce=e[35];let _;e[36]!==p?(_=Pe(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=p,e[37]=_):_=e[37];let re;e[38]!==n?(re=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=re):re=e[39];const me=!d;let de;e[40]!==m?(de=s.jsx(mh,{className:m}),e[40]=m,e[41]=de):de=e[41];let ge;e[42]!==u||e[43]!==_||e[44]!==re||e[45]!==me||e[46]!==de?(ge=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:_,"aria-label":re,disabled:me,children:de})}),e[42]=u,e[43]=_,e[44]=re,e[45]=me,e[46]=de,e[47]=ge):ge=e[47];let Te;e[48]!==n?(Te=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Te):Te=e[49];let be;e[50]!==Te?(be=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Te})}),e[50]=Te,e[51]=be):be=e[51];let Re;e[52]!==ge||e[53]!==be?(Re=s.jsxs(Dt,{children:[ge,be]}),e[52]=ge,e[53]=be,e[54]=Re):Re=e[54];let we;e[55]!==p?(we=Pe(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=p,e[56]=we):we=e[56];let Y;e[57]!==n?(Y=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=Y):Y=e[58];let ve;e[59]!==m?(ve=s.jsx(E,{name:"archive",className:m}),e[59]=m,e[60]=ve):ve=e[60];let xe;e[61]!==h||e[62]!==we||e[63]!==Y||e[64]!==ve?(xe=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:we,"aria-label":Y,children:ve})}),e[61]=h,e[62]=we,e[63]=Y,e[64]=ve,e[65]=xe):xe=e[65];let je;e[66]!==n?(je=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=je):je=e[67];let oe;e[68]!==je?(oe=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:je})}),e[68]=je,e[69]=oe):oe=e[69];let J;e[70]!==xe||e[71]!==oe?(J=s.jsxs(Dt,{children:[xe,oe]}),e[70]=xe,e[71]=oe,e[72]=J):J=e[72];let K;e[73]!==ce||e[74]!==Re||e[75]!==J||e[76]!==X?(K=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[X,ce,Re,J]}),e[73]=ce,e[74]=Re,e[75]=J,e[76]=X,e[77]=K):K=e[77];let $;e[78]!==w?($=()=>w(Qv),e[78]=w,e[79]=$):$=e[79];let le;e[80]!==p?(le=Pe(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[80]=p,e[81]=le):le=e[81];let V;e[82]!==n?(V=n("sessions.sidebar.header.actions.searchSessions"),e[82]=n,e[83]=V):V=e[83];let Ce;e[84]!==m?(Ce=s.jsx(E,{name:"search",className:m}),e[84]=m,e[85]=Ce):Ce=e[85];let Be;e[86]!==g||e[87]!==$||e[88]!==le||e[89]!==V||e[90]!==Ce?(Be=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:$,className:le,"aria-label":V,"aria-expanded":g,children:Ce})}),e[86]=g,e[87]=$,e[88]=le,e[89]=V,e[90]=Ce,e[91]=Be):Be=e[91];let ke;e[92]!==n?(ke=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=ke):ke=e[93];let Ne;e[94]!==ke?(Ne=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ke})}),e[94]=ke,e[95]=Ne):Ne=e[95];let Qe;e[96]!==Be||e[97]!==Ne?(Qe=s.jsxs(Dt,{children:[Be,Ne]}),e[96]=Be,e[97]=Ne,e[98]=Qe):Qe=e[98];const We=C&&"bg-interactive-hover text-primary";let U;e[99]!==p||e[100]!==We?(U=Pe(p,"text-muted-foreground hover:text-foreground hover:bg-transparent",We),e[99]=p,e[100]=We,e[101]=U):U=e[101];let he;e[102]!==C||e[103]!==n?(he=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=C,e[103]=n,e[104]=he):he=e[104];let Ee;e[105]!==m?(Ee=s.jsx(E,{name:"checkbox-multiple",className:m}),e[105]=m,e[106]=Ee):Ee=e[106];let Ie;e[107]!==C||e[108]!==U||e[109]!==he||e[110]!==Ee||e[111]!==j?(Ie=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:j,className:U,"aria-label":he,"aria-pressed":C,children:Ee})}),e[107]=C,e[108]=U,e[109]=he,e[110]=Ee,e[111]=j,e[112]=Ie):Ie=e[112];let rt;e[113]!==C||e[114]!==n?(rt=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=C,e[114]=n,e[115]=rt):rt=e[115];let Ge;e[116]!==rt?(Ge=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:rt})}),e[116]=rt,e[117]=Ge):Ge=e[117];let ut;e[118]!==Ie||e[119]!==Ge?(ut=s.jsxs(Dt,{children:[Ie,Ge]}),e[118]=Ie,e[119]=Ge,e[120]=ut):ut=e[120];let ct;e[121]!==p?(ct=Pe(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=p,e[122]=ct):ct=e[122];let ue;e[123]!==n?(ue=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=ue):ue=e[124];let G;e[125]!==m?(G=s.jsx(E,{name:"equalizer-2",className:m}),e[125]=m,e[126]=G):G=e[126];let Le;e[127]!==ct||e[128]!==ue||e[129]!==G?(Le=s.jsx(Pt,{asChild:!0,children:s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:ct,"aria-label":ue,children:G})})}),e[127]=ct,e[128]=ue,e[129]=G,e[130]=Le):Le=e[130];let Oe;e[131]!==n?(Oe=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=Oe):Oe=e[132];let qe;e[133]!==Oe?(qe=s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[133]=Oe,e[134]=qe):qe=e[134];let Ue;e[135]!==Le||e[136]!==qe?(Ue=s.jsxs(Dt,{children:[Le,qe]}),e[135]=Le,e[136]=qe,e[137]=Ue):Ue=e[137];let st;e[138]!==n?(st=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=st):st=e[139];let wt;e[140]!==st?(wt=s.jsx(ho,{children:st}),e[140]=st,e[141]=wt):wt=e[141];let Nt;e[142]!==I||e[143]!==M||e[144]!==n?(Nt=[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(xt=>{const[Et,kt]=xt;return s.jsxs(Ut,{onClick:()=>{M(Et),Tr({sidebarProjectSortOrder:Et})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),I===Et?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},Et)}),e[142]=I,e[143]=M,e[144]=n,e[145]=Nt):Nt=e[145];let ie;e[146]===Symbol.for("react.memo_cache_sentinel")?(ie=s.jsx(Os,{}),e[146]=ie):ie=e[146];let pe;e[147]!==O||e[148]!==T||e[149]!==i||e[150]!==n?(pe=i?s.jsxs(s.Fragment,{children:[s.jsx(ho,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(xt=>{const[Et,kt]=xt;return s.jsxs(Ut,{onClick:()=>{T(Et),Tr({sidebarProjectDisplayMode:Et})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),O===Et?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},Et)}),s.jsx(Os,{})]}):null,e[147]=O,e[148]=T,e[149]=i,e[150]=n,e[151]=pe):pe=e[151];let Ve;e[152]!==n?(Ve=n("sessions.sidebar.header.grouping.label"),e[152]=n,e[153]=Ve):Ve=e[153];let ze;e[154]!==Ve?(ze=s.jsx(ho,{children:Ve}),e[154]=Ve,e[155]=ze):ze=e[155];let He;e[156]!==z||e[157]!==R||e[158]!==n?(He=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(xt=>{const[Et,kt]=xt;return s.jsxs(Ut,{onClick:()=>{R(Et),Tr({sidebarSessionGroupingMode:Et})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),z===Et?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},Et)}),e[156]=z,e[157]=R,e[158]=n,e[159]=He):He=e[159];let ot;e[160]===Symbol.for("react.memo_cache_sentinel")?(ot=s.jsx(Os,{}),e[160]=ot):ot=e[160];let at;e[161]!==k||e[162]!==o||e[163]!==A||e[164]!==n||e[165]!==P?(at=o&&!k?s.jsxs(Ut,{onClick:()=>{P(),Tr({sidebarShowRecentSection:!A})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),A?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[161]=k,e[162]=o,e[163]=A,e[164]=n,e[165]=P,e[166]=at):at=e[166];let et;e[167]!==n?(et=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[167]=n,e[168]=et):et=e[168];let Xe;e[169]!==et?(Xe=s.jsx("span",{children:et}),e[169]=et,e[170]=Xe):Xe=e[170];let dt;e[171]!==H?(dt=H?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null,e[171]=H,e[172]=dt):dt=e[172];let Fe;e[173]!==Xe||e[174]!==dt||e[175]!==F?(Fe=s.jsxs(Ut,{onClick:F,className:"flex items-center justify-between",children:[Xe,dt]}),e[173]=Xe,e[174]=dt,e[175]=F,e[176]=Fe):Fe=e[176];let Se;e[177]!==S||e[178]!==N||e[179]!==k||e[180]!==n?(Se=k?null:s.jsxs(s.Fragment,{children:[s.jsx(Os,{}),s.jsxs(Ut,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(E,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Ut,{onClick:N,className:"flex items-center gap-2",children:[s.jsx(E,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[177]=S,e[178]=N,e[179]=k,e[180]=n,e[181]=Se):Se=e[181];let St;e[182]!==wt||e[183]!==Nt||e[184]!==pe||e[185]!==ze||e[186]!==He||e[187]!==at||e[188]!==Fe||e[189]!==Se?(St=s.jsxs(Ys,{align:"end",className:"min-w-[180px]",children:[wt,Nt,ie,pe,ze,He,ot,at,Fe,Se]}),e[182]=wt,e[183]=Nt,e[184]=pe,e[185]=ze,e[186]=He,e[187]=at,e[188]=Fe,e[189]=Se,e[190]=St):St=e[190];let vt;e[191]!==Ue||e[192]!==St?(vt=s.jsxs(Xs,{children:[Ue,St]}),e[191]=Ue,e[192]=St,e[193]=vt):vt=e[193];let Rt;e[194]!==Qe||e[195]!==ut||e[196]!==vt?(Rt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Qe,ut,vt]}),e[194]=Qe,e[195]=ut,e[196]=vt,e[197]=Rt):Rt=e[197];let Ze;e[198]!==K||e[199]!==Rt?(Ze=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[K,Rt]}),e[198]=K,e[199]=Rt,e[200]=Ze):Ze=e[200];let it;e[201]!==b||e[202]!==g||e[203]!==y||e[204]!==v||e[205]!==x||e[206]!==w||e[207]!==f||e[208]!==n?(it=g?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[b?s.jsx("span",{children:y===1?n("sessions.sidebar.header.search.matchCountSingle",{count:y}):n("sessions.sidebar.header.search.matchCountPlural",{count:y})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsxs("div",{className:"relative",children:[s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:v,value:x,onChange:xt=>f(xt.target.value),placeholder:n("sessions.sidebar.header.search.placeholder"),className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50",onKeyDown:xt=>{xt.key==="Escape"&&(xt.stopPropagation(),b?f(""):w(!1))}}),x.length>0?s.jsx("button",{type:"button",onClick:()=>f(""),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":n("sessions.sidebar.header.search.clear"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]})]}):null,e[201]=b,e[202]=g,e[203]=y,e[204]=v,e[205]=x,e[206]=w,e[207]=f,e[208]=n,e[209]=it):it=e[209];let gt;return e[210]!==Ze||e[211]!==it?(gt=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Ze,it]})}),e[210]=Ze,e[211]=it,e[212]=gt):gt=e[212],gt}function Qv(t){return!t}function Yv(t){return t.setProjectDisplayMode}function Xv(t){return t.projectDisplayMode}function Jv(t){return t.toggleStickyZoneHeaders}function Zv(t){return t.stickyZoneHeaders}function e0(t){return t.setSessionGroupingMode}function t0(t){return t.sessionGroupingMode}function s0(t){return t.setProjectSortOrder}function n0(t){return t.projectSortOrder}function r0(t){return t.toggleRecentSection}function o0(t){return t.showRecentSection}function i0(t){return t.toggleMode}function a0(t){return t.enabled}function l0(t){const e=tt.c(8),{t:n}=At(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(E,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==o?(l=s.jsx("span",{className:"truncate",children:o}),e[3]=o,e[4]=l):l=e[4];let a;return e[5]!==t.onNewSession||e[6]!==l?(a=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 pt-1.5",children:s.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left typography-ui-label font-normal text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const mi="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50";function c0(t){const e=tt.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,u=l===void 0?!0:l,d=a===void 0?!0:a,{t:h}=At();if(!u&&!d)return null;let m;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==u||e[4]!==h?(m=u?s.jsxs(s.Fragment,{children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:mi,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(E,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:mi,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(E,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:mi,"aria-label":h("sessions.sidebar.footer.actions.aboutAiWorker"),children:s.jsx(E,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutAiWorker")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=h,e[5]=m):m=e[5];let p;e[6]!==o||e[7]!==d||e[8]!==h?(p=d?s.jsx(pt,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:o,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=d,e[8]=h,e[9]=p):p=e[9];let g;return e[10]!==m||e[11]!==p?(g=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[m,p]}),e[10]=m,e[11]=p,e[12]=g):g=e[12],g}const d0=t=>{for(const e of t.sessions.values())if(e.tabs.some(dd))return!0;return!1},u0=()=>{const t=tt.c(4),{terminal:e}=wn(),n=Mt(d0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=f0,l=m0;if(n)return Ti(e,"",l,o);let a=h0;return a=Ti(e,"",l,u=>{o(u),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function f0(t){const e=Mt.getState(),n=ig(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function m0(){return new Map(Mt.getState().actionMutationRevisions)}function h0(){}const p0=t=>{const e=tt.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:u,foldersMap:d,createFolder:h,addSessionToFolder:m}=t,p=r===void 0?!0:r;let g,w;e[0]!==m||e[1]!==h||e[2]!==p||e[3]!==d||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==u?(g=()=>{!p||o||!l||a||n.forEach(v=>{if(u.has(v.normalizedPath))return;const x=Md(v.normalizedPath),f=i.archivedSessionsByProject.get(v.id)??[],b=d[x]??[],y=new Map(b.map(g0));f.forEach(S=>{const N=hh(S,v.normalizedPath),C=N.toLowerCase();let j=y.get(C);j||(j=h(x,N),y.set(C,j)),j.sessionIds.includes(S.id)||m(x,j.id,S.id)})})},w=[n,p,i,o,l,a,u,d,h,m],e[0]=m,e[1]=h,e[2]=p,e[3]=d,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=u,e[10]=g,e[11]=w):(g=e[10],w=e[11]),c.useEffect(g,w)};function g0(t){return[t.name.toLowerCase(),t]}function x0({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const d=!!(e&&Array.from(i.entries()).some(([h,m])=>h!==t&&m.has(e)));if(e&&r&&!d)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const u=(o&&r.has(o)?o:null)??l;return!u||u===e?{kind:"none"}:{kind:"select-session",sessionId:u}}const b0=t=>{const e=tt.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:u,newSessionDraftOpen:d,mobileVariant:h,openNewSessionDraft:m,setSessionSwitcherOpen:p}=t;let g,w;if(e[0]!==n){w=new Map,g=new Map;const C=(j,A,P,I)=>{w.has(j)||w.set(j,new Map);const M=w.get(j);I.forEach(z=>{const R=yt(z.worktree?.path??z.session.directory??P??A);M.set(z.session.id,{directory:R}),g.has(j)||g.set(j,{id:z.session.id,directory:R}),z.children.length>0&&C(j,A,R,z.children)})};n.forEach(j=>{j.groups.forEach(A=>{C(j.project.id,j.project.normalizedPath,A.directory,A.sessions)})}),e[0]=n,e[1]=g,e[2]=w}else g=e[1],w=e[2];let v;e[3]!==g||e[4]!==w?(v={metaByProject:w,firstSessionByProject:g},e[3]=g,e[4]=w,e[5]=v):v=e[5];const x=v,f=c.useRef(null);let b,y;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==u||e[11]!==h||e[12]!==d||e[13]!==m||e[14]!==n||e[15]!==x||e[16]!==o||e[17]!==p?(b=()=>{if(!r||d||De.getState().isNewWorktreeDialogOpen||f.current===r)return;const C=n.find(I=>I.project.id===r);if(!C)return;const j=x.metaByProject.get(r);if(l&&j&&j.has(l)){f.current=r,o(I=>{if(I.get(r)===l)return I;const M=new Map(I);return M.set(r,l),M});return}const A=x0({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:j,metaByProject:x.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(A.kind==="preserve-current"){a===r&&(f.current=r);return}if(f.current=r,A.kind==="open-draft"){h&&p(!1),m({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(A.kind!=="select-session")return;const P=j?.get(A.sessionId)?.directory??null;u(A.sessionId,P)},y=[r,i,l,a,u,d,h,m,n,x,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=u,e[11]=h,e[12]=d,e[13]=m,e[14]=n,e[15]=x,e[16]=o,e[17]=p,e[18]=b,e[19]=y):(b=e[18],y=e[19]),c.useLayoutEffect(b,y);let S,N;e[20]!==r||e[21]!==l||e[22]!==x||e[23]!==o?(S=()=>{if(!r||!l)return;const C=x.metaByProject.get(r);!C||!C.has(l)||o(j=>{if(j.get(r)===l)return j;const A=new Map(j);return A.set(r,l),A})},N=[r,l,x,o],e[20]=r,e[21]=l,e[22]=x,e[23]=o,e[24]=S,e[25]=N):(S=e[24],N=e[25]),c.useEffect(S,N)},y0=t=>{const e=tt.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=Je(w0),a=Je(S0);let u;e[5]!==l||e[6]!==o?(u=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=u):u=e[7];const d=u;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[m,p]=c.useState(h);let g;e[10]!==m||e[11]!==n||e[12]!==l||e[13]!==d||e[14]!==a?(g={...n,activeSessionByProject:m,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:d,newSessionDraftOpen:a},e[10]=m,e[11]=n,e[12]=l,e[13]=d,e[14]=a,e[15]=g):g=e[15],b0(g);let w,v;return e[16]!==m||e[17]!==i?(w=()=>{i(m)},v=[m,i],e[16]=m,e[17]=i,e[18]=w,e[19]=v):(w=e[18],v=e[19]),c.useEffect(w,v),null};function w0(t){return t.currentSessionId}function S0(t){return!!t.newSessionDraft?.open}const uc={selected:0,"active-project":1,expanded:2,visible:3,background:4};function rf(t){const e=new Map,n=(r,i,o)=>{const l=yt(r??null);if(!l)return;const a=e.get(l);a&&uc[a.priority]<=uc[i]||e.set(l,{directory:l,priority:i,reason:o})};for(const r of t.knownDirectories??[])n(r,"background","known-project");n(t.activeProjectDirectory,"active-project","project-expanded");for(const r of t.projectSections??[]){const i=!t.collapsedProjects.has(r.project.id);let o="background";r.project.id===t.activeProjectId?o="active-project":i&&(o="expanded"),n(r.project.normalizedPath,o,i?"project-expanded":"known-project");for(const l of r.groups){if(!l.directory||l.isArchivedBucket||l.isMain)continue;const a=i&&!t.collapsedGroups.has(`${r.project.id}:${l.id}`);let u="background";a?u="expanded":i&&(u="visible"),n(l.directory,u,a?"worktree-expanded":"known-worktree")}}return n(t.currentDirectory,"selected","current-directory"),n(t.currentSessionDirectory,"selected","selected-session"),[...e.values()]}const v0=(t,e)=>t?e.kind!==t.kind?e.kind==="project":e.projectRoot.length!==t.projectRoot.length?e.projectRoot.length>t.projectRoot.length:e.projectId.localeCompare(t.projectId)<0:!0,fc=(t,e,n)=>{v0(t.get(e),n)&&t.set(e,n)},j0=t=>{const e=t;return yt(e.directory)??yt(e.project?.worktree)},k0=t=>{if(t==="/"||/^[A-Z]:$/.test(t))return null;const e=t.lastIndexOf("/");return e<0?null:e===0?"/":e===2&&/^[A-Z]:\//.test(t)?t.slice(0,2):t.slice(0,e)},C0=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const v=yt(w.normalizedPath);if(!v)continue;const x=l.get(v);(!x||w.id.localeCompare(x.id)<0)&&l.set(v,w),fc(o,v,{projectId:w.id,projectRoot:v,scopeDirectory:v,kind:"project"})}if(!r)for(const[w,v]of n){const x=yt(w),f=x?l.get(x):void 0;if(!(!f||!x))for(const b of v){const y=yt(b.path);y&&fc(o,y,{projectId:f.id,projectRoot:x,scopeDirectory:y,kind:"worktree"})}}const a=new Map,u=new Map,d=new Map,h=new Map,m=new Map,p=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const b=o.get(w)??null;return a.set(w,b),b}const v=[];let x=w,f=null;for(;x;){if(a.has(x)){f=a.get(x)??null;break}if(v.push(x),f=o.get(x)??null,f)break;x=k0(x)}for(const b of v)a.set(b,f);return f},g=(w,v,x)=>{for(const f of w){const b=p(j0(f));if(!b)continue;u.set(f.id,b);const y=v.get(b.projectId);if(y?y.push(f):v.set(b.projectId,[f]),!x)continue;const S=x.get(b.scopeDirectory);S?S.add(f.id):x.set(b.scopeDirectory,new Set([f.id]))}};return g(t,d,m),g(i,h),{bySessionId:u,sessionsByProject:d,archivedSessionsByProject:h,sessionsByScope:m,directoryResolutions:a.size}},N0=t=>{const e=tt.c(7),{ownership:n}=t;let r;e[0]!==n?(r=u=>n.sessionsByProject.get(u)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=u=>n.archivedSessionsByProject.get(u)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},A0=(t,e)=>t.map(n=>{const r=yt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
913
|
+
`),D0=[],P0=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:u,buildGroupedSessions:d,hasSessionSearchQuery:h,normalizedSessionSearchQuery:m,filterSessionNodesForSearch:p,buildGroupSearchText:g,foldersMap:w,standaloneGroups:v}=t,x=c.useRef(new Map),f=c.useMemo(()=>{const P=x.current,I=new Map;let M=0,z=0;const R=(F,O)=>F.length===O.length&&F.every((T,k)=>T===O[k]),H=e.map(F=>{const O=n(F.id),T=r(F.id),k=i.get(F.normalizedPath)??D0,D=o.has(F.id)?!!o.get(F.id):u,L=l.get(F.id)??null,Q=A0(k,a),q=P.get(F.id);if(q&&q.project===F&&R(q.activeSessions,O)&&R(q.archivedSessions,T)&&q.availableWorktrees===k&&q.rootBranch===L&&q.worktreeBranchesKey===Q&&q.isRepo===D&&q.buildGroupedSessions===d)return M+=1,I.set(F.id,q),q.section;if(z+=1,q){const Z=q.project!==F?"project":R(q.activeSessions,O)?R(q.archivedSessions,T)?q.availableWorktrees!==k?"worktrees":q.rootBranch!==L?"branch":q.worktreeBranchesKey!==Q?"worktreeBranches":q.isRepo!==D?"repo":"builder":"archived":"sessions";Gs(`ui.sidebar.project_section.rebuilt_reason.${Z}`)}const te=Od([...O,...T]),ae=d(te,F.normalizedPath,k,L,D),X={project:F,groups:ae};return I.set(F.id,{project:F,activeSessions:O,archivedSessions:T,availableWorktrees:k,rootBranch:L,worktreeBranchesKey:Q,isRepo:D,buildGroupedSessions:d,section:X}),X});return x.current=I,M>0&&Gs("ui.sidebar.project_section.reused",M),z>0&&Gs("ui.sidebar.project_section.rebuilt",z),H},[e,n,r,i,o,u,d,l,a]),b=c.useMemo(()=>f,[f]),y=c.useMemo(()=>{const P=new WeakMap;if(!h)return P;const I=m.trim().toLowerCase(),M=I.startsWith("ses_"),z=H=>H.reduce((F,O)=>F+(!M||O.session.id.toLowerCase()===I?1:0)+z(O.children),0),R=H=>{const F=p(H.sessions,m),O=z(F),T=!M&&Ao([g(H)],m),k=yt(H.directory??null),D=k?w[k]??[]:[],L=M?0:D.filter(Q=>Ao([Q.name],m)).length;P.set(H,{filteredNodes:F,matchedSessionCount:O,folderNameMatchCount:L,groupMatches:T,hasMatch:T||O>0||L>0})};return b.forEach(H=>{H.groups.forEach(R)}),v.forEach(R),P},[h,b,v,p,m,g,w]),S=c.useMemo(()=>h?b.map(P=>({...P,groups:P.groups.filter(I=>y.get(I)?.hasMatch===!0)})).filter(P=>P.groups.length>0):b,[h,b,y]),N=h?S:b,C=c.useRef(new WeakMap),j=c.useMemo(()=>{const P=C.current;return N.map(I=>{const M=P.get(I);if(M&&M.query===m)return M.section;const z=I.groups.filter(D=>!D.isArchivedBucket),R=I.groups.filter(D=>D.isArchivedBucket),H=z.flatMap(D=>h?y.get(D)?.filteredNodes??[]:D.sessions),F=z.map(D=>({scopeKey:D.folderScopeKey??yt(D.directory??null),directory:D.directory??null})).filter(D=>!!D.scopeKey),O=z.find(D=>D.isMain)??null,T={id:"flat",label:O?.label??"",branch:O?.branch??null,description:O?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:O?.directory??I.project.normalizedPath,folderScopeKey:O?.folderScopeKey??I.project.normalizedPath,folderScopes:F,sessions:H};if(h){const D=z.map(L=>y.get(L)).filter(L=>!!L);y.set(T,{filteredNodes:H,matchedSessionCount:D.reduce((L,Q)=>L+Q.matchedSessionCount,0),folderNameMatchCount:D.reduce((L,Q)=>L+Q.folderNameMatchCount,0),groupMatches:D.some(L=>L.groupMatches),hasMatch:D.some(L=>L.hasMatch)})}const k={project:I.project,groups:[T,...R]};return P.set(I,{query:m,section:k}),k})},[y,h,m,N]),A=c.useMemo(()=>{if(!h)return 0;const P=(M,z)=>{const R=y.get(z);if(!R)return M;const H=R.folderNameMatchCount+(R.groupMatches?1:0);return M+R.matchedSessionCount+H},I=N.reduce((M,z)=>z.groups.reduce(P,M),0);return v.reduce(P,I)},[h,N,v,y]);return{projectSections:f,visibleProjectSections:b,groupSearchDataByGroup:y,searchableProjectSections:S,sectionsForRender:N,flatSectionsForRender:j,searchMatchCount:A}},I0=180,mc=150,T0=2,R0=8,hc=[-1,1,-2,2],hi=t=>`${t.directory}
|
|
914
|
+
${t.sessionId}`,E0=t=>t?.directory?.trim()||null,M0=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),u=c.useRef(0),d=c.useMemo(()=>Dn(),[]),h=c.useCallback(()=>{u.current+=1,l.current=[],o.current.forEach(g=>window.clearTimeout(g)),o.current.clear()},[]),m=c.useCallback(()=>{if(!(!t||d))for(;a.current.size<T0&&l.current.length>0;){const g=l.current.shift();if(!g)break;if(g.generation!==u.current||Je.getState().currentSessionId===g.sessionId||Ai(g.sessionId,g.directory).renderable)continue;const v=hi(g);a.current.add(v),i({directory:g.directory,sessionID:g.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(v),m()})}},[t,d,i]),p=c.useCallback(g=>{const w=g?.id,v=E0(g);if(!t||d||!w||!v||w===e)return;const x={sessionId:w,directory:v,generation:u.current},f=hi(x);if(Ai(w,v).renderable||a.current.has(f)||l.current.some(S=>hi(S)===f))return;const b=o.current.get(f);b!==void 0&&window.clearTimeout(b);const y=window.setTimeout(()=>{if(o.current.delete(f),x.generation!==u.current)return;const S=l.current;S.length>=R0&&S.shift(),S.push(x),m()},I0);o.current.set(f,y)},[e,t,d,m]);c.useEffect(()=>{h()},[h,e,t,d]),c.useEffect(()=>{if(!t||d||!e||n.length===0)return;const g=window.setTimeout(()=>{const w=n.findIndex(v=>v.id===e);if(!(w<0))for(const v of hc)p(n[w+v])},mc);return()=>window.clearTimeout(g)},[e,t,d,p,n]),c.useEffect(()=>{if(!t||d||!e||r.length===0)return;const g=window.setTimeout(()=>{const w=r.findIndex(v=>v.id===e);if(!(w<0))for(const v of hc)p(r[w+v])},mc);return()=>window.clearTimeout(g)},[e,t,d,r,p]),c.useEffect(()=>h,[h])},O0=t=>{const e=tt.c(3),n=Je(F0);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],M0(r),null};function F0(t){return t.currentSessionId}const Kr=t=>{const e=tt.c(13),{directory:n,className:r}=t,{t:i}=At();let o;e[0]!==n?(o=nm(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=v=>v.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Mt(a)?.tabs.some(dd))return null;let h;e[4]!==i?(h=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=h):h=e[5];const m=h;let p;e[6]!==r?(p=Pe("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=p):p=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(E,{name:"pulse",className:"size-3.5"}),e[8]=g):g=e[8];let w;return e[9]!==l||e[10]!==m||e[11]!==p?(w=s.jsx("span",{className:p,role:"img","aria-label":m,title:m,"data-action-directory":l,children:g}),e[9]=l,e[10]=m,e[11]=p,e[12]=w):w=e[12],w},wo=t=>{const e=tt.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:u,alwaysShowActions:d}=t,h=d===void 0?!1:d,{currentTheme:m}=Zn(),p=i?ja[i]:null,g=o?ka[o]??null:null,w=u!==void 0,v=w?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let x;e[0]!==h||e[1]!==w||e[2]!==u?(x=w?s.jsx("span",{className:Pe("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(E,{name:u?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=w,e[2]=u,e[3]=x):x=e[3];let f;e[4]!==h||e[5]!==m||e[6]!==w||e[7]!==g||e[8]!==v||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==p?(f=l?s.jsx("span",{className:Pe("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",w&&h?"hidden":"inline-flex",v),style:a?{backgroundColor:a}:void 0,children:s.jsx(Ca,{project:{id:n,iconImage:l},options:{themeVariant:m.metadata.variant,iconColor:m.colors.surface.foreground},className:"h-full w-full object-contain",fallback:p?s.jsx(E,{name:p,className:"h-3.5 w-3.5",style:g?{color:g}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:g?{color:g}:void 0})})}):p?s.jsx(E,{name:p,className:Pe("h-3.5 w-3.5",v),style:g?{color:g}:void 0}):s.jsx(E,{name:"folder",className:Pe("h-3.5 w-3.5 text-muted-foreground/80",v),style:g?{color:g}:void 0}),e[4]=h,e[5]=m,e[6]=w,e[7]=g,e[8]=v,e[9]=n,e[10]=a,e[11]=l,e[12]=p,e[13]=f):f=e[13];let b;e[14]!==x||e[15]!==f?(b=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[x,f]}),e[14]=x,e[15]=f,e[16]=b):b=e[16];let y;e[17]!==r?(y=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=y):y=e[18];let S;return e[19]!==b||e[20]!==y?(S=s.jsxs(s.Fragment,{children:[b,y]}),e[19]=b,e[20]=y,e[21]=S):S=e[21],S},_0=t=>{const e=tt.c(63),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:m,isRepo:p,isDesktopShell:g,hideDirectoryControls:w,alwaysShowActions:v,onToggle:x,onNewSession:f,onNewWorktreeSession:b,onManageWorktrees:y,onRenameStart:S,onClose:N,sentinelRef:C,children:j,showCreateButtons:A,hideHeader:P,statusIndicator:I,openSidebarMenuKey:M,setOpenSidebarMenuKey:z,projectPickerOptions:R,onProjectSelect:H}=t,F=r===void 0?!1:r,O=A===void 0?!0:A,T=P===void 0?!1:P,k=I===void 0?null:I,{t:D}=At(),L=ls($0);let Q;e[0]!==F||e[1]!==n?(Q={id:n,disabled:F},e[0]=F,e[1]=n,e[2]=Q):Q=e[2];const{attributes:q,listeners:te,setNodeRef:ae,transform:X,transition:Z,isDragging:se}=qo(Q),fe=c.useRef(!1),B=`project:${n}`,ne=M===B,[ye,ce]=c.useState(!1),_=!!(R&&H);let re;e[3]!==B||e[4]!==z?(re=V=>{V&&ce(!1),z(V?B:null)},e[3]=B,e[4]=z,e[5]=re):re=e[5];const me=re;let de;e[6]!==w||e[7]!==p||e[8]!==N||e[9]!==y||e[10]!==f||e[11]!==S||e[12]!==O||e[13]!==D?(de=V=>s.jsxs(s.Fragment,{children:[O&&!p&&!w&&f&&s.jsxs(V,{onClick:f,children:[s.jsx(E,{name:"add",className:"mr-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.newSession")]}),p&&!w&&y&&s.jsxs(V,{onClick:y,children:[s.jsx(E,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(V,{onClick:S,children:[s.jsx(E,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.edit")]}),s.jsxs(V,{onClick:N,className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=w,e[7]=p,e[8]=N,e[9]=y,e[10]=f,e[11]=S,e[12]=O,e[13]=D,e[14]=de):de=e[14];const ge=de,Te=W0,be=z0,Re=V0;let we;e[15]===Symbol.for("react.memo_cache_sentinel")?(we=V=>{(V.button===2||V.button===0&&V.ctrlKey)&&(fe.current=!0)},e[15]=we):we=e[15];const Y=we;let ve;e[16]!==x?(ve=V=>{if(V.currentTarget.blur(),fe.current){fe.current=!1;return}x()},e[16]=x,e[17]=ve):ve=e[17];const xe=ve;let je;e[18]!==X?(je=Qo.Transform.toString(X),e[18]=X,e[19]=je):je=e[19];let oe;e[20]!==je||e[21]!==Z?(oe={transform:je,transition:Z},e[20]=je,e[21]=Z,e[22]=oe):oe=e[22];const J=se&&"opacity-30";let K;e[23]!==J?(K=Pe("relative",J),e[23]=J,e[24]=K):K=e[24];let $;e[25]!==v||e[26]!==q||e[27]!==me||e[28]!==xe||e[29]!==w||e[30]!==T||e[31]!==n||e[32]!==m||e[33]!==ye||e[34]!==g||e[35]!==ne||e[36]!==_||e[37]!==p||e[38]!==te||e[39]!==f||e[40]!==b||e[41]!==H||e[42]!==u||e[43]!==o||e[44]!==l||e[45]!==a||e[46]!==h||e[47]!==d||e[48]!==i||e[49]!==R||e[50]!==ge||e[51]!==C||e[52]!==O||e[53]!==k||e[54]!==L||e[55]!==D?($=T?null:s.jsxs(s.Fragment,{children:[g&&s.jsx("div",{ref:C,"data-project-id":n,className:"absolute top-0 h-px w-full pointer-events-none","aria-hidden":"true"}),s.jsxs(su,{open:ye,onOpenChange:ce,children:[s.jsx(tu,{render:s.jsx("div",{className:Pe("-ml-2.5 -mr-2 text-left group/project select-none",L&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":L?"true":void 0,onContextMenu:V=>{w||(V.preventDefault(),ce(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...q,children:[_?s.jsxs(Xs,{children:[s.jsx(Qs,{asChild:!0,children:s.jsxs("button",{type:"button",className:Pe("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-[padding]",p&&!w?v||ne?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":v||ne?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":D("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(wo,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h}),s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(Kr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Ys,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:R?.map(V=>s.jsxs(Ut,{onClick:()=>H?.(V.id),className:"flex items-center justify-between gap-3",title:V.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(wo,{...V})}),V.id===n?s.jsx(E,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},V.id))})]}):s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:Y,onClick:xe,...te,className:Pe("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 rounded-md cursor-grab active:cursor-grabbing transition-[padding]",p&&!w?v||ne?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":v||ne?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(wo,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:m,alwaysShowActions:v}),k?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:k}):null,l?s.jsx(Kr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(It,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Pe("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",O?"right-7":"right-0.5"),children:[O&&p&&!w&&b?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:V=>{V.stopPropagation(),b()},className:Pe("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground transition-opacity",v?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":D("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(E,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:D("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,w?null:s.jsxs(Xs,{open:ne,onOpenChange:me,children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground",ne?"opacity-100 pointer-events-auto":v?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":D("sessions.sidebar.project.actions.projectMenu"),onPointerDown:be,onMouseDown:Re,onClick:Te,children:s.jsx(E,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Ys,{align:"end",className:"min-w-[180px]",children:ge(Ut)})]})]}),O&&f?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:V=>{V.stopPropagation(),f()},className:Pe("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",v?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":D(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(E,{name:"add",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:D(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(eu,{className:"min-w-[180px]",children:ge(Un)})]})]}),e[25]=v,e[26]=q,e[27]=me,e[28]=xe,e[29]=w,e[30]=T,e[31]=n,e[32]=m,e[33]=ye,e[34]=g,e[35]=ne,e[36]=_,e[37]=p,e[38]=te,e[39]=f,e[40]=b,e[41]=H,e[42]=u,e[43]=o,e[44]=l,e[45]=a,e[46]=h,e[47]=d,e[48]=i,e[49]=R,e[50]=ge,e[51]=C,e[52]=O,e[53]=k,e[54]=L,e[55]=D,e[56]=$):$=e[56];let le;return e[57]!==j||e[58]!==ae||e[59]!==oe||e[60]!==K||e[61]!==$?(le=s.jsxs("div",{ref:ae,style:oe,className:K,children:[$,j]}),e[57]=j,e[58]=ae,e[59]=oe,e[60]=K,e[61]=$,e[62]=le):le=e[62],le},B0=t=>{const e=tt.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:u,setActivatorNodeRef:d,transform:h,transition:m,isDragging:p}=qo(l);let g;e[3]!==a||e[4]!==d?(g={listeners:a,setActivatorNodeRef:d},e[3]=a,e[4]=d,e[5]=g):g=e[5];const w=g;let v;e[6]!==h?(v=Qo.Transform.toString(h),e[6]=h,e[7]=v):v=e[7];let x;e[8]!==v||e[9]!==m?(x={transform:v,transition:m},e[8]=v,e[9]=m,e[10]=x):x=e[10];const f=p&&"opacity-50";let b;e[11]!==f?(b=Pe("space-y-0.5 rounded-md",f),e[11]=f,e[12]=b):b=e[12];let y;e[13]!==i||e[14]!==w?(y=i(w),e[13]=i,e[14]=w,e[15]=y):y=e[15];let S;return e[16]!==u||e[17]!==x||e[18]!==b||e[19]!==y?(S=s.jsx("div",{ref:u,style:x,className:b,children:y}),e[16]=u,e[17]=x,e[18]=b,e[19]=y,e[20]=S):S=e[20],S},L0=c.memo(B0);function $0(t){return t.stickyZoneHeaders}function W0(t){t.stopPropagation()}function z0(t){t.stopPropagation()}function V0(t){t.stopPropagation()}const U0=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},of=t=>{const e=tt.c(9),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==r||e[1]!==n?(l=U0(n,r),e[0]=r,e[1]=n,e[2]=l):l=e[2];const a=l;let u;e[3]!==o||e[4]!==a.active?(u=p=>{if(!o)return null;for(const g of a.active){const w=p.statusById.get(g)?.status.type;if(w==="busy"||w==="retry")return"active"}return null},e[3]=o,e[4]=a.active,e[5]=u):u=e[5];const d=Na(u);let h;e[6]!==o||e[7]!==a.unread?(h=p=>{if(!o)return null;for(const g of a.unread)if((p.index.session.unseenCount[g]??0)>0)return"unread";return null},e[6]=o,e[7]=a.unread,e[8]=h):h=e[8];const m=Aa(h);return d??m};function af(t){const e=tt.c(6),{state:n,activeLabel:r,unreadLabel:i,className:o}=t,l=n==="active"?r:i,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let u;e[0]!==o||e[1]!==a?(u=Pe("h-1.5 w-1.5 shrink-0 rounded-full",a,o),e[0]=o,e[1]=a,e[2]=u):u=e[2];let d;return e[3]!==l||e[4]!==u?(d=s.jsx("span",{className:u,"aria-label":l,title:l}),e[3]=l,e[4]=u,e[5]=d):d=e[5],d}const K0=t=>{const e=tt.c(11),{nodes:n,includeUnreadSubtasks:r}=t,{t:i}=At();let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=of(o);if(!l)return null;let a;e[3]!==i?(a=i("sessions.sidebar.session.status.active"),e[3]=i,e[4]=a):a=e[4];let u;e[5]!==i?(u=i("sessions.sidebar.session.status.unread"),e[5]=i,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==u?(d=s.jsx(af,{state:l,activeLabel:a,unreadLabel:u}),e[7]=l,e[8]=a,e[9]=u,e[10]=d):d=e[10],d},H0=t=>{const e=tt.c(82),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:u,onRename:d,onDelete:h,children:m,mobileVariant:p,alwaysShowActions:g,isRenaming:w,renameDraft:v,onRenameDraftChange:x,onRenameSave:f,onRenameCancel:b,droppableRef:y,isDropTarget:S,onNewSession:N,depth:C,hideActions:j,archivedBucket:A}=t,P=a===void 0?null:a,M=g===void 0?p===void 0?!1:p:g,z=w===void 0?!1:w,R=v===void 0?"":v,H=S===void 0?!1:S,F=j===void 0?!1:j,O=A===void 0?!1:A,{t:T}=At(),[k,D]=c.useState(!1),[L,Q]=c.useState(""),q=c.useRef(null),te=z||k,ae=z?R:L;let X;e[0]!==n.name?(X=()=>{Q(n.name),D(!0)},e[0]=n.name,e[1]=X):X=e[1];const Z=X;let se;e[2]!==ae||e[3]!==n.name||e[4]!==z||e[5]!==d||e[6]!==f?(se=()=>{const ke=ae.trim();ke&&ke!==n.name&&d(ke),z&&f&&f(),D(!1),Q("")},e[2]=ae,e[3]=n.name,e[4]=z,e[5]=d,e[6]=f,e[7]=se):se=e[7];const fe=se;let B;e[8]!==z||e[9]!==b?(B=()=>{z&&b&&b(),D(!1),Q("")},e[8]=z,e[9]=b,e[10]=B):B=e[10];const ne=B;let ye;e[11]!==z||e[12]!==x?(ye=ke=>{z&&x?x(ke):Q(ke)},e[11]=z,e[12]=x,e[13]=ye):ye=e[13];const ce=ye;let _,re;e[14]!==z?(_=()=>{if(!z)return;const ke=()=>{const We=q.current;We&&(We.focus(),We.select())},Ne=requestAnimationFrame(ke),Qe=window.setTimeout(ke,0);return()=>{cancelAnimationFrame(Ne),window.clearTimeout(Qe)}},re=[z],e[14]=z,e[15]=_,e[16]=re):(_=e[15],re=e[16]),c.useEffect(_,re);const me=l?"folder":"folder-open",de=H&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let ge;e[17]!==de?(ge=Pe("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",de),e[17]=de,e[18]=ge):ge=e[18];let Te;e[19]!==u||e[20]!==te?(Te=te?void 0:ke=>{ke.currentTarget.blur(),u()},e[19]=u,e[20]=te,e[21]=Te):Te=e[21];const be=te?void 0:"button",Re=te?void 0:0;let we;e[22]!==u||e[23]!==te?(we=te?void 0:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),u())},e[22]=u,e[23]=te,e[24]=we):we=e[24];let Y;e[25]!==n.name||e[26]!==l||e[27]!==T?(Y=l?T("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):T("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=T,e[28]=Y):Y=e[28];const ve=O?M?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":M?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let xe;e[29]!==ve?(xe=Pe("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",ve),e[29]=ve,e[30]=xe):xe=e[30];const je=H?"text-primary":"text-muted-foreground";let oe;e[31]!==je?(oe=Pe("h-3.5 w-3.5 flex-shrink-0",je),e[31]=je,e[32]=oe):oe=e[32];let J;e[33]!==me||e[34]!==oe?(J=s.jsx(E,{name:me,className:oe}),e[33]=me,e[34]=oe,e[35]=J):J=e[35];let K;e[36]!==P||e[37]!==r||e[38]!==ae||e[39]!==n.name||e[40]!==ne||e[41]!==ce||e[42]!==fe||e[43]!==l||e[44]!==H||e[45]!==te||e[46]!==i||e[47]!==T?(K=te?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:q0,onMouseDown:Q0,onSubmit:ke=>{ke.preventDefault(),fe()},children:[s.jsx("input",{ref:q,value:ae,onChange:ke=>ce(ke.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:T("sessions.sidebar.folderItem.namePlaceholder"),onClick:Y0,onPointerDown:X0,onMouseDown:J0,onKeyDown:ke=>{if(ke.key==="Escape"){ke.stopPropagation(),ne();return}(ke.key===" "||ke.key==="Enter")&&ke.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:Z0,onPointerDown:ej,onMouseDown:tj,children:s.jsx(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),ne()},onPointerDown:sj,onMouseDown:nj,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("span",{className:Pe("typography-ui-label font-semibold truncate",H?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(It,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),P?s.jsx(af,{state:P,activeLabel:T("sessions.sidebar.session.status.active"),unreadLabel:T("sessions.sidebar.session.status.unread")}):null,l?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=P,e[37]=r,e[38]=ae,e[39]=n.name,e[40]=ne,e[41]=ce,e[42]=fe,e[43]=l,e[44]=H,e[45]=te,e[46]=i,e[47]=T,e[48]=K):K=e[48];let $;e[49]!==xe||e[50]!==J||e[51]!==K?($=s.jsxs("div",{className:xe,children:[J,K]}),e[49]=xe,e[50]=J,e[51]=K,e[52]=$):$=e[52];let le;e[53]!==M||e[54]!==O||e[55]!==n.name||e[56]!==Z||e[57]!==F||e[58]!==h||e[59]!==N||e[60]!==te||e[61]!==T?(le=!te&&(!F||O)?s.jsx("div",{className:Pe("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",M?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!O&&N?s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),N()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":T("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:T("sessions.sidebar.project.actions.newSession"),children:s.jsx(E,{name:"add",className:"h-3.5 w-3.5"})}):null,O?null:s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),Z()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":T("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(E,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),h()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":O?T("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):T("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=M,e[54]=O,e[55]=n.name,e[56]=Z,e[57]=F,e[58]=h,e[59]=N,e[60]=te,e[61]=T,e[62]=le):le=e[62];let V;e[63]!==y||e[64]!==ge||e[65]!==Te||e[66]!==be||e[67]!==Re||e[68]!==we||e[69]!==Y||e[70]!==$||e[71]!==le?(V=s.jsxs("div",{ref:y,className:ge,onClick:Te,role:be,tabIndex:Re,onKeyDown:we,"aria-label":Y,children:[$,le]}),e[63]=y,e[64]=ge,e[65]=Te,e[66]=be,e[67]=Re,e[68]=we,e[69]=Y,e[70]=$,e[71]=le,e[72]=V):V=e[72];let Ce;e[73]!==m||e[74]!==l||e[75]!==i||e[76]!==o||e[77]!==T?(Ce=l?null:s.jsxs("div",{className:"pb-1",children:[o,i.length>0?m:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:T("sessions.sidebar.folderItem.emptyFolder")})]}),e[73]=m,e[74]=l,e[75]=i,e[76]=o,e[77]=T,e[78]=Ce):Ce=e[78];let Be;return e[79]!==V||e[80]!==Ce?(Be=s.jsxs("div",{className:"oc-folder",children:[V,Ce]}),e[79]=V,e[80]=Ce,e[81]=Be):Be=e[81],Be},G0=c.memo(H0);function q0(t){return t.stopPropagation()}function Q0(t){return t.stopPropagation()}function Y0(t){return t.stopPropagation()}function X0(t){return t.stopPropagation()}function J0(t){return t.stopPropagation()}function Z0(t){return t.stopPropagation()}function ej(t){return t.stopPropagation()}function tj(t){return t.stopPropagation()}function sj(t){return t.stopPropagation()}function nj(t){return t.stopPropagation()}const rj=t=>{const e=tt.c(15),{sessionId:n,sessionDirectory:r,sessionTitle:i,children:o}=t,l=`session-drag:${n}`;let a;e[0]!==r||e[1]!==n||e[2]!==i?(a={type:"session",sessionId:n,sessionDirectory:r,sessionTitle:i},e[0]=r,e[1]=n,e[2]=i,e[3]=a):a=e[3];let u;e[4]!==l||e[5]!==a?(u={id:l,data:a},e[4]=l,e[5]=a,e[6]=u):u=e[6];const{attributes:d,listeners:h,setNodeRef:m,isDragging:p}=Tg(u);let g;e[7]!==h?(g=f=>{f.stopPropagation(),h?.onPointerDown&&h.onPointerDown(f)},e[7]=h,e[8]=g):g=e[8];const w=g,v=p?"opacity-30":void 0;let x;return e[9]!==d||e[10]!==o||e[11]!==w||e[12]!==m||e[13]!==v?(x=s.jsx("div",{ref:m,...d,onPointerDown:w,className:v,children:o}),e[9]=d,e[10]=o,e[11]=w,e[12]=m,e[13]=v,e[14]=x):x=e[14],x},oj=t=>{const e=tt.c(11),{folderId:n,children:r}=t,i=`folder-drop:${n}`;let o;e[0]!==n?(o={type:"folder",folderId:n},e[0]=n,e[1]=o):o=e[1];let l;e[2]!==i||e[3]!==o?(l={id:i,data:o},e[2]=i,e[3]=o,e[4]=l):l=e[4];const{setNodeRef:a,isOver:u}=Rg(l);let d;e[5]!==r||e[6]!==u||e[7]!==a?(d=r(a,u),e[5]=r,e[6]=u,e[7]=a,e[8]=d):d=e[8];let h;return e[9]!==d?(h=s.jsx(s.Fragment,{children:d}),e[9]=d,e[10]=h):h=e[10],h},ij=t=>{const e=tt.c(20),{scopeKey:n,hasFolders:r,onSessionDroppedOnFolder:i,children:o}=t;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={activationConstraint:{distance:8}},e[0]=l):l=e[0];const a=zr(Mn(Oi,l)),[u,d]=c.useState(null),[h,m]=c.useState("Session"),[p,g]=c.useState(null),[w,v]=c.useState(null);if(!n){let j;return e[1]!==o?(j=s.jsx(s.Fragment,{children:o}),e[1]=o,e[2]=j):j=e[2],j}let x;e[3]!==i?(x=j=>{d(null),g(null),v(null);const{active:A,over:P}=j;if(!P)return;const I=A.data.current,M=P.data.current;I?.type==="session"&&I.sessionId&&M?.type==="folder"&&M.folderId&&i(I.sessionId,M.folderId)},e[3]=i,e[4]=x):x=e[4];const f=x;let b,y;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=j=>{const A=j.active.data.current;if(A?.type==="session"&&A.sessionId){d(A.sessionId),m(A.sessionTitle??"Session");const P=j.active.rect.current.initial?.width,I=j.active.rect.current.initial?.height;g(typeof P=="number"?P:null),v(typeof I=="number"?I:null)}},y=()=>{d(null),g(null),v(null)},e[5]=b,e[6]=y):(b=e[5],y=e[6]);let S;e[7]!==w||e[8]!==u||e[9]!==h||e[10]!==p||e[11]!==r?(S=u&&r?s.jsxs("div",{style:{width:p?`${p}px`:"auto",height:w?`${w}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(E,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:h})]}):null,e[7]=w,e[8]=u,e[9]=h,e[10]=p,e[11]=r,e[12]=S):S=e[12];let N;e[13]!==S?(N=s.jsx(Fi,{children:S}),e[13]=S,e[14]=N):N=e[14];let C;return e[15]!==o||e[16]!==f||e[17]!==a||e[18]!==N?(C=s.jsxs(Vr,{sensors:a,collisionDetection:Ur,onDragStart:b,onDragCancel:y,onDragEnd:f,children:[o,N]}),e[15]=o,e[16]=f,e[17]=a,e[18]=N,e[19]=C):C=e[19],C},ea=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},Hn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Hn(n,e))return!0;return!1},aj=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!ph(r),lj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,cj=(t,e,n)=>{const r=new Map,i=o=>{const l=$s(o.session)??yt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},dj=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},uj=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const u=a.pop();if(!(!u||r.has(u))){r.add(u);for(const d of n.get(u)??[])a.push(d.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},fj=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(d=>[d.id,d])),i=new Map,o=new Set;for(const d of t){if(d.parentId&&!r.has(d.parentId)){o.add(d.id);continue}if(d.parentId){const p=i.get(d.parentId)??[];p.push(d.id),i.set(d.parentId,p)}const h=new Set;let m=d.id;for(;m;){if(h.has(m)){o.add(d.id);break}h.add(m),m=r.get(m)?.parentId}}const l=new Set,a=new Set,u=d=>{if(l.has(d))return!0;if(a.has(d))return!1;const h=r.get(d);if(!h)return!1;a.add(d);let m=o.has(d);return!m&&e.archivedBucket&&h.nodeCount===0?m=(i.get(d)??[]).some(u):(!m&&!e.searchQuery&&(m=!0),!m&&(h.nodeCount>0||!n&&Ao([h.name],e.searchQuery))&&(m=!0),m||(m=(i.get(d)??[]).some(u))),a.delete(d),m&&l.add(d),m};return t.forEach(d=>u(d.id)),new Set(t.filter(d=>l.has(d.id)).map(d=>d.id))},pc=new WeakMap;let gc=1;const mj=t=>{const e=pc.get(t);if(e!==void 0)return e;const n=gc;return gc+=1,pc.set(t,n),n},_o=t=>t.children.length===0?"":t.children.map(n=>{const r=mj(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${_o(n)}`}).join("|"),lf=(t,e,n,r,i,o)=>{const l=ps(),a=(u,d)=>{if(u.session.id!==d.session.id||u.children.length!==d.children.length)return!0;const h=u.session.directory??i,m=d.session.directory??o,p=sl(l,h??"",u.session.id),g=sl(l,m??"",d.session.id);return(p?n.has(p):!1)!==(g?r.has(g):!1)?!0:u.children.some((w,v)=>a(w,d.children[v]))};return a(t,e)},hj=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,Hr=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const d of a.children)if(l(d))return!0;return!1};return t.forEach(a=>l(a)),o};let ta=!1;const sa=new Set;let xc=!1;function pj(){for(const t of sa)t()}function $a(t){ta!==t&&(ta=t,pj())}function gj(t){t.key==="Shift"&&$a(!0)}function xj(t){t.key==="Shift"&&$a(!1)}function bj(){$a(!1)}function yj(){xc||typeof window>"u"||(xc=!0,window.addEventListener("keydown",gj),window.addEventListener("keyup",xj),window.addEventListener("blur",bj))}function wj(t){return yj(),sa.add(t),()=>{sa.delete(t)}}function Sj(){return ta}function vj(){return!1}function jj(){return ht.useSyncExternalStore(wj,Sj,vj)}const kj=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,cf=/^g[1-9]\d*$/,Ar=(t,e,n,r,i)=>{if(!kj.test(t)||e!==void 0&&!cf.test(e)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(i===void 0)return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!1};if(i==="fusion")return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(i))return null;const o=Number.parseInt(i,10);return!Number.isSafeInteger(o)||o<=0?null:{groupSlug:t,runGroup:e,providerID:n,modelID:r,index:o,fusion:!1}},So=t=>{if(!t)return null;const e=t.split("/");if(e.length<3||e.length>5)return null;const[n]=e;if(e.length===3)return Ar(n,void 0,e[1],e[2],void 0);if(e.length===4){const[,a,u,d]=e;return cf.test(a)?Ar(n,a,u,d,void 0):Ar(n,void 0,a,u,d)}const[,r,i,o,l]=e;return r===""?Ar(n,void 0,i,o,l):Ar(n,r,i,o,l)},Cj=t=>{const e=[t.groupSlug];return t.runGroup&&e.push(t.runGroup),e.push(t.providerID,t.modelID),t.index!==void 0&&e.push(String(t.index)),e.join("/")},Nj=(t,e,n,r)=>{const i=[t];return r&&i.push(r),i.push(e,n,"fusion"),i.join("/")},df=t=>{const e=tt.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:u}=At(),d=Gt(Aj),h=Gt(Dj),m=Gt(Pj);let p;e[0]!==d?(p=d(),e[0]=d,e[1]=p):p=e[1];const g=p;let w;e[2]!==g?(w=g.filter(Ij),e[2]=g,e[3]=w):w=e[3];const v=w;let x,f;e[4]!==g.length||e[5]!==h?(x=()=>{g.length===0&&h()},f=[g.length,h],e[4]=g.length,e[5]=h,e[6]=x,e[7]=f):(x=e[6],f=e[7]),c.useEffect(x,f);let b,y;e[8]!==m||e[9]!==o||e[10]!==r||e[11]!==v||e[12]!==n?(b=()=>{if(o)return;const z=n.trim();if(z.length>0&&v.some(F=>F.name===z))return;const R=typeof m=="string"&&m.trim().length>0?m.trim():null;if(R&&v.some(F=>F.name===R)){r(R);return}const H=v[0]?.name;H&&r(H)},y=[m,o,r,v,n],e[8]=m,e[9]=o,e[10]=r,e[11]=v,e[12]=n,e[13]=b,e[14]=y):(b=e[13],y=e[14]),c.useEffect(b,y);const S=n.trim().length>0?n:void 0;let N;e[15]!==i?(N=Pe("max-w-full",i),e[15]=i,e[16]=N):N=e[16];let C;e[17]!==u?(C=u("multirun.agentSelector.placeholder"),e[17]=u,e[18]=C):C=e[18];let j;e[19]!==C?(j=s.jsx(Cs,{placeholder:C}),e[19]=C,e[20]=j):j=e[20];let A;e[21]!==l||e[22]!==N||e[23]!==j?(A=s.jsx(_s,{id:l,size:"lg",className:N,children:j}),e[21]=l,e[22]=N,e[23]=j,e[24]=A):A=e[24];let P;e[25]!==v?(P=v.length>0&&s.jsx(Di,{children:v.map(Tj)}),e[25]=v,e[26]=P):P=e[26];let I;e[27]!==a||e[28]!==P?(I=s.jsx(Bs,{fitContent:!0,portalToBody:a,children:P}),e[27]=a,e[28]=P,e[29]=I):I=e[29];let M;return e[30]!==o||e[31]!==r||e[32]!==S||e[33]!==A||e[34]!==I?(M=s.jsxs(Fs,{value:S,onValueChange:r,disabled:o,children:[A,I]}),e[30]=o,e[31]=r,e[32]=S,e[33]=A,e[34]=I,e[35]=M):M=e[35],M};function Aj(t){return t.getVisibleAgents}function Dj(t){return t.loadAgents}function Pj(t){return t.currentAgentName}function Ij(t){return Fd(t.mode)}function Tj(t){return s.jsx(ss,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Rj="h-7",Br=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Ej=t=>{const e=tt.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Pe("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Rj),e[0]=u):u=e[0];let d;e[1]!==n.providerID?(d=s.jsx(Pi,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=d):d=e[2];let h;e[3]!==a?(h=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=h):h=e[4];let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(E,{name:"close",className:"h-3.5 w-3.5"}),e[5]=m):m=e[5];let p;e[6]!==o?(p=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:m}),e[6]=o,e[7]=p):p=e[7];let g;return e[8]!==d||e[9]!==h||e[10]!==p?(g=s.jsxs("div",{className:u,children:[d,h,p]}),e[8]=d,e[9]=h,e[10]=p,e[11]=g):g=e[11],g},uf=t=>{const e=tt.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:u,maxModels:d,addButtonClassName:h,dropdownSide:m,dropdownClassName:p,containerClassName:g,triggerIcon:w}=t,v=u===void 0?!0:u,x=m===void 0?"top":m,{t:f}=At(),b=Gt(Mj),y=Gt(Oj),S=De(Fj),N=De(_j),{favoriteModelsList:C,recentModelsList:j}=gh(),A=De(Bj),P=De(Lj),[I,M]=c.useState(!1),[z,R]=c.useState(""),[H,F]=c.useState(null),O=c.useRef(null),T=c.useRef(null),k=d===1,D=d===void 0||n.length<d||k;let L;if(e[0]!==n){L=new Map;for(const Ie of n){const rt=`${Ie.providerID}:${Ie.modelID}`;L.set(rt,(L.get(rt)||0)+1)}e[0]=n,e[1]=L}else L=e[1];const Q=L;let q;e[2]!==n?(q=Ie=>n.filter(Ge=>Ge.providerID===Ie.providerID&&Ge.modelID===Ie.modelID).findIndex(Ge=>Ge.instanceId===Ie.instanceId)+1,e[2]=n,e[3]=q):q=e[3];const te=q;let ae,X;e[4]!==x||e[5]!==I?(ae=()=>{if(!I||!T.current)return;const Ie=T.current.getBoundingClientRect();if(x==="bottom"){const G=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Ie.bottom-16-112;F(Math.max(160,Math.min(320,G)));return}let rt=T.current.parentElement;for(;rt&&!rt.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const ct=getComputedStyle(rt);if(ct.overflow==="auto"||ct.overflow==="hidden"||ct.overflowY==="auto"||ct.overflowY==="hidden")break;rt=rt.parentElement}const Ge=rt?rt.getBoundingClientRect().top:0,ut=Ie.top-Ge-16;F(Math.max(150,Math.min(300,ut)))},X=[x,I],e[4]=x,e[5]=I,e[6]=ae,e[7]=X):(ae=e[6],X=e[7]),c.useEffect(ae,X);let Z,se;e[8]!==D||e[9]!==I?(Z=()=>{!D&&I&&(M(!1),R(""))},se=[D,I],e[8]=D,e[9]=I,e[10]=Z,e[11]=se):(Z=e[10],se=e[11]),c.useEffect(Z,se);let fe,B;e[12]!==I?(fe=()=>{if(!I)return;const Ie=rt=>{O.current&&!O.current.contains(rt.target)&&(M(!1),R(""))};return document.addEventListener("mousedown",Ie),()=>document.removeEventListener("mousedown",Ie)},B=[I],e[12]=I,e[13]=fe,e[14]=B):(fe=e[13],B=e[14]),c.useEffect(fe,B);let ne;e[15]!==k||e[16]!==r||e[17]!==o||e[18]!==n.length?(ne=Ie=>{const rt={providerID:Ie.providerID,modelID:Ie.modelID,displayName:Ie.model.name||Ie.modelID,instanceId:Br()};k&&n.length>0&&o?o(0,rt):r(rt),k&&(M(!1),R(""))},e[15]=k,e[16]=r,e[17]=o,e[18]=n.length,e[19]=ne):ne=e[19];const ye=ne;let ce;e[20]!==f?(ce=f("multirun.modelMultiSelect.search.placeholder"),e[20]=f,e[21]=ce):ce=e[21];let _;e[22]!==f?(_=f("multirun.modelMultiSelect.search.noResults"),e[22]=f,e[23]=_):_=e[23];let re;e[24]!==f?(re=f("multirun.modelMultiSelect.sections.favorites"),e[24]=f,e[25]=re):re=e[25];let me;e[26]!==f?(me=f("multirun.modelMultiSelect.sections.recent"),e[26]=f,e[27]=me):me=e[27];let de;e[28]!==f?(de=f("multirun.modelMultiSelect.keyboard.hint"),e[28]=f,e[29]=de):de=e[29];let ge;e[30]!==f?(ge=f("settings.agents.modelSelector.actions.favorite"),e[30]=f,e[31]=ge):ge=e[31];let Te;e[32]!==f?(Te=f("settings.agents.modelSelector.actions.unfavorite"),e[32]=f,e[33]=Te):Te=e[33];let be;e[34]!==f?(be=f("chat.modelControls.capabilities"),e[34]=f,e[35]=be):be=e[35];let Re;e[36]!==f?(Re=f("chat.modelControls.capability.toolCalling"),e[36]=f,e[37]=Re):Re=e[37];let we;e[38]!==f?(we=f("chat.modelControls.capability.reasoning"),e[38]=f,e[39]=we):we=e[39];let Y;e[40]!==f?(Y=f("chat.modelControls.input"),e[40]=f,e[41]=Y):Y=e[41];let ve;e[42]!==f?(ve=f("chat.modelControls.output"),e[42]=f,e[43]=ve):ve=e[43];let xe;e[44]!==f?(xe=f("chat.modelControls.costPerMillion"),e[44]=f,e[45]=xe):xe=e[45];let je;e[46]!==ce||e[47]!==_||e[48]!==re||e[49]!==me||e[50]!==de||e[51]!==ge||e[52]!==Te||e[53]!==be||e[54]!==Re||e[55]!==we||e[56]!==Y||e[57]!==ve||e[58]!==xe?(je={searchPlaceholder:ce,noResults:_,favorites:re,recent:me,keyboardHint:de,favorite:ge,unfavorite:Te,capabilities:be,capabilityToolCalling:Re,capabilityReasoning:we,input:Y,output:ve,costPerMillion:xe},e[46]=ce,e[47]=_,e[48]=re,e[49]=me,e[50]=de,e[51]=ge,e[52]=Te,e[53]=be,e[54]=Re,e[55]=we,e[56]=Y,e[57]=ve,e[58]=xe,e[59]=je):je=e[59];const oe=je;let J;e[60]!==g?(J=Pe("relative",g),e[60]=g,e[61]=J):J=e[61];const K=I?"":void 0;let $;e[62]!==h?($=Pe(_d({size:"default"}),"w-fit",h),e[62]=h,e[63]=$):$=e[63];const le=!D;let V;e[64]!==I?(V=()=>{M(!I)},e[64]=I,e[65]=V):V=e[65];let Ce;e[66]!==w?(Ce=w??s.jsx(E,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=w,e[67]=Ce):Ce=e[67];let Be;e[68]!==a||e[69]!==f?(Be=a??f("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=f,e[70]=Be):Be=e[70];let ke;e[71]!==K||e[72]!==$||e[73]!==le||e[74]!==V||e[75]!==Ce||e[76]!==Be?(ke=s.jsxs("button",{ref:T,type:"button","data-popup-open":K,className:$,disabled:le,onClick:V,children:[Ce,Be]}),e[71]=K,e[72]=$,e[73]=le,e[74]=V,e[75]=Ce,e[76]=Be,e[77]=ke):ke=e[77];let Ne;e[78]!==H||e[79]!==D||e[80]!==p||e[81]!==x||e[82]!==C||e[83]!==ye||e[84]!==A||e[85]!==N||e[86]!==I||e[87]!==oe||e[88]!==Q||e[89]!==y||e[90]!==P||e[91]!==b||e[92]!==j||e[93]!==z||e[94]!==S?(Ne=I?s.jsx("div",{className:Pe("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",x==="top"?"bottom-full mb-1":"top-full mt-1",p),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(xh,{providers:b,providerOrder:P,favoriteModels:C,recentModels:j,modelsMetadata:y,hiddenModels:A,searchQuery:z,onSearchQueryChange:R,onSelect:ye,labels:oe,selectionCount:Ie=>Q.get(`${Ie.providerID}:${Ie.modelID}`)||0,disabled:!D,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:H?`${H}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:I,isFavorite:Ie=>N(Ie.providerID,Ie.modelID),onToggleFavorite:Ie=>S(Ie.providerID,Ie.modelID),onEscape:()=>{M(!1),R("")}})}):null,e[78]=H,e[79]=D,e[80]=p,e[81]=x,e[82]=C,e[83]=ye,e[84]=A,e[85]=N,e[86]=I,e[87]=oe,e[88]=Q,e[89]=y,e[90]=P,e[91]=b,e[92]=j,e[93]=z,e[94]=S,e[95]=Ne):Ne=e[95];let Qe;e[96]!==J||e[97]!==ke||e[98]!==Ne?(Qe=s.jsxs("div",{className:J,ref:O,children:[ke,Ne]}),e[96]=J,e[97]=ke,e[98]=Ne,e[99]=Qe):Qe=e[99];let We;e[100]!==te||e[101]!==Q||e[102]!==i||e[103]!==o||e[104]!==b||e[105]!==n||e[106]!==v||e[107]!==f?(We=v&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Ie,rt)=>{const Ge=`${Ie.providerID}:${Ie.modelID}`,ut=Q.get(Ge)||1,ct=te(Ie),G=b.find(Ue=>Ue.id===Ie.providerID)?.models?.find(Ue=>Ue.id===Ie.modelID),Le=G?.variants?Object.keys(G.variants):[],Oe=Le.length>0,qe=Ie.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Ej,{model:Ie,instanceIndex:ct,totalSameModel:ut,onRemove:()=>i(rt)}),Oe&&s.jsxs(Fs,{value:qe,onValueChange:Ue=>{if(!o)return;o(rt,{...Ie,variant:Ue==="__default__"?void 0:Ue})},children:[s.jsxs(_s,{size:"sm",className:"gap-1.5",children:[s.jsx(E,{name:"brain-ai-3",className:Pe("h-3.5 w-3.5 flex-shrink-0",qe==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(Cs,{placeholder:f("multirun.modelMultiSelect.variant.placeholder"),children:Ue=>Ue==="__default__"?f("multirun.modelMultiSelect.variant.default"):Ue})]}),s.jsxs(Bs,{fitContent:!0,children:[s.jsx(ss,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:f("multirun.modelMultiSelect.variant.default")}),Le.map($j)]})]})]},Ie.instanceId)})}),e[100]=te,e[101]=Q,e[102]=i,e[103]=o,e[104]=b,e[105]=n,e[106]=v,e[107]=f,e[108]=We):We=e[108];let U;e[109]!==Qe||e[110]!==We?(U=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[Qe,We]}),e[109]=Qe,e[110]=We,e[111]=U):U=e[111];let he;e[112]!==d||e[113]!==l||e[114]!==n.length||e[115]!==f?(he=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:d!==void 0?f("multirun.modelMultiSelect.validation.minToMax",{min:l,max:d}):f("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=d,e[113]=l,e[114]=n.length,e[115]=f,e[116]=he):he=e[116];let Ee;return e[117]!==U||e[118]!==he?(Ee=s.jsxs("div",{className:"space-y-2",children:[U,he]}),e[117]=U,e[118]=he,e[119]=Ee):Ee=e[119],Ee};function Mj(t){return t.providers}function Oj(t){return t.modelsMetadata}function Fj(t){return t.toggleFavoriteModel}function _j(t){return t.isFavoriteModel}function Bj(t){return t.hiddenModels}function Lj(t){return t.providerOrder}function $j(t){return s.jsx(ss,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const Wj=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
915
|
+
|
|
916
|
+
--- RESULT ${n+1}: ${r} ---
|
|
917
|
+
${e.trim()}
|
|
918
|
+
--- END RESULT ${n+1} ---`},bc=(t,e)=>Je.getState().getWorktreeMetadata(t)?.projectDirectory??e,zj=async t=>{const e=t.directory??void 0,n=yh(t.session.id,e);if(n.length===0&&t.directory){const i=(await qs.withDirectory(t.directory,()=>qs.getSdkClient().session.messages({sessionID:t.session.id,directory:t.directory??void 0,limit:50}))).data??[];for(let o=i.length-1;o>=0;o-=1){const l=i[o];if(l.info?.role==="assistant")return rl(l.parts??[]).trim()}return""}for(let r=n.length-1;r>=0;r-=1){const i=n[r];if(i.role==="assistant")return rl(wh(i.id,e)).trim()}return""};function Vj({session:t,open:e,onOpenChange:n}){const{t:r}=At(),i=bh(),o=Ps(k=>k.activeSessions),l=Ps(k=>k.archivedSessions),a=Gt(k=>k.providers),u=Gt(k=>k.currentProviderId),d=Gt(k=>k.currentModelId),h=Gt(k=>k.currentAgentName),[m,p]=c.useState(u??""),[g,w]=c.useState(d??""),[v,x]=c.useState(()=>u&&d?[{providerID:u,modelID:d,instanceId:Br()}]:[]),[f,b]=c.useState(""),[y,S]=c.useState(h??""),[N,C]=c.useState([]),[j,A]=c.useState(!1),P=c.useMemo(()=>So(t.title),[t.title]),I=c.useMemo(()=>{const k=new Map;for(const D of i)k.set(D.id,D);for(const D of o)k.set(D.id,D);for(const D of l)k.set(D.id,D);return t.id&&k.set(t.id,t),Array.from(k.values())},[o,l,i,t]);c.useEffect(()=>{if(!e||!P)return;const k=Je.getState().getDirectoryForSession(t.id),D=bc(t.id,k),L=I.map(Q=>{const q=So(Q.title);if(!q||q.groupSlug!==P.groupSlug||q.fusion||(q.runGroup??null)!==(P.runGroup??null))return null;const te=Je.getState().getDirectoryForSession(Q.id)??$s(Q),ae=bc(Q.id,te);return D&&ae&&D!==ae?null:{session:Q,directory:te,projectDirectory:ae}}).filter(Q=>Q!==null).sort((Q,q)=>(Q.session.time?.created??0)-(q.session.time?.created??0));C(L)},[I,e,P,t.id]);const z=a.find(k=>k.id===m)?.models.find(k=>k.id===g),R=z?.variants?Object.keys(z.variants):[],H=!!(P&&m&&g&&N.length>0&&!j),F=c.useCallback(k=>{x([k]),p(k.providerID),w(k.modelID),b("")},[]),O=v[0]?.displayName||v[0]?.modelID||r("multirun.fusion.model.placeholder"),T=async()=>{if(!(!P||!m||!g)){A(!0);try{const k=await Promise.all(N.map(X=>zj(X))),D=N.map((X,Z)=>({source:X,text:k[Z]??""})).filter(X=>X.text.trim().length>0);if(D.length===0){Me.error(r("multirun.fusion.toast.noOutputs"));return}const L=N[0]?.projectDirectory??N[0]?.directory??null,Q=Nj(P.groupSlug,m,g,P.runGroup),[q,te]=await Promise.all([nl("session.fusion.visible"),nl("session.fusion.instructions")]),ae=await Je.getState().createSession(Q,L,null);if(!ae)throw new Error("Failed to create fusion session");Je.getState().setCurrentSession(ae.id,L),n(!1),await qs.sendMessage({id:ae.id,providerID:m,modelID:g,variant:f||void 0,agent:y||void 0,text:q,additionalParts:[{text:te,synthetic:!0},...D.map((X,Z)=>({text:Wj(X.source,X.text,Z),synthetic:!0})),{text:`
|
|
919
|
+
|
|
920
|
+
--- FUSION INPUTS END ---
|
|
921
|
+
Now write the final fused answer.`,synthetic:!0}],directory:L??qs.getDirectory()})}catch(k){console.error("[MultiRunFusion] Failed to start fusion",k),Me.error(r("multirun.fusion.toast.failed"))}finally{A(!1)}}};return s.jsx(ws,{open:e,onOpenChange:n,children:s.jsxs(Ss,{className:"max-w-xl overflow-visible",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:r("multirun.fusion.title")}),s.jsx(Ts,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(uf,{selectedModels:v,onAdd:F,onUpdate:(k,D)=>F(D),onRemove:()=>{x([]),p(""),w(""),b("")},maxModels:1,addButtonLabel:O,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:m?s.jsx(Pi,{providerId:m,className:"h-3.5 w-3.5 mr-1"}):void 0})}),R.length>0?s.jsxs(Fs,{value:f||"__default__",onValueChange:k=>b(k==="__default__"?"":k),children:[s.jsxs(_s,{size:"lg",className:"w-fit",children:[s.jsx(E,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Cs,{children:k=>k==="__default__"?r("multirun.modelMultiSelect.variant.default"):k})]}),s.jsxs(Bs,{fitContent:!0,portalToBody:!0,children:[s.jsx(ss,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),R.map(k=>s.jsx(ss,{value:k,children:k},k))]})]}):null,s.jsx(df,{value:y,onChange:S,portalToBody:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:N.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:N.map(k=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(Pi,{providerId:So(k.session.title)?.providerID??"",className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:k.session.title||k.session.id}),s.jsx("button",{type:"button",onClick:()=>C(D=>D.filter(L=>L.session.id!==k.session.id)),className:"text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"h-4 w-4"})})]},k.session.id))})]}),s.jsxs(bn,{children:[s.jsx(pt,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(pt,{onClick:T,disabled:!H,children:r(j?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function Uj(t){const e=tt.c(7);let n,r,i,o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),i=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),o=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),l=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=i,e[3]=o,e[4]=l):(n=e[0],r=e[1],i=e[2],o=e[3],l=e[4]);let a;return e[5]!==t?(a=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,i,o,l]}),e[5]=t,e[6]=a):a=e[6],a}const Kj=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),ff=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>Gr(r))])),na=t=>((t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey||t.rawWorktreesByProjectRef.current.worktreesByProject.size===0&&t.publishedWorktreesByProject.size>0)&&(t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.rawWorktreesByProjectRef.current.runtimeKey===t.runtimeKey?t.rawWorktreesByProjectRef.current.revision:0,worktreesByProject:ff(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),mf=(t,e)=>{const n=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=n.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},yc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Gr=t=>({...t,path:yt(t.path)??t.path,projectDirectory:yt(t.projectDirectory)??t.projectDirectory,worktreeRoot:yt(t.worktreeRoot??t.path)??t.worktreeRoot}),wc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=yt(e?.path??null)===n,a=l?e?.branch??"":i??"",u={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||yc(n):i||yc(n),name:l?e?.name:void 0,worktreeRoot:l?yt(e?.worktreeRoot??n)??n:n,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...u}:u},Sc=t=>{const e=yt(t.projectPath??null),n=yt(t.sourceDirectory??null)??yt(t.currentWorktree?.path??null),r=yt(t.discoveredWorktrees.find(h=>yt(h.projectDirectory??null))?.projectDirectory??null),i=yt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=h=>{const m=yt(h.metadata.path??null);!m||l.has(m)||l.set(m,{...h,metadata:Gr({...h.metadata,path:m})})};for(const h of t.discoveredWorktrees){const m=yt(h.path??null);m&&a({metadata:Gr({...h,path:m,projectDirectory:yt(h.projectDirectory??null)??o??e??m}),isPrimary:o===m,isCurrent:n===m})}o&&!l.has(o)&&a({metadata:wc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:wc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const u=[],d=[];for(const h of l.values()){if(h.isPrimary){u.push(h);continue}d.push(h)}return u.sort((h,m)=>h.metadata.path.localeCompare(m.metadata.path,void 0,{sensitivity:"base"})),d.sort(mf),[...u,...d]},Hj=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=na({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),l=(t.projectId?e.projects.find(d=>d.id===t.projectId)??null:null)??(t.sourceDirectory?e.resolveProject(t.sourceDirectory):null),a=yt(l?.path??null);return{cachedTargets:Sc({projectPath:a,discoveredWorktrees:a?i.worktreesByProject.get(a)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!l||!a)throw new Error("Unable to resolve worktree project");const d=await e.listProjectWorktrees(l,{force:!0});if(e.getRuntimeKey()!==n)throw new Error("Runtime changed during worktree refresh");const h=e.getCurrentProjects(),m=h.find(S=>S.id===l.id)??null;if(!m||yt(m.path??null)!==a)throw new Error("Project removed during worktree refresh");const p=na({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:e.getPublishedWorktreesByProject(),runtimeKey:n}),g=ff(p.worktreesByProject),w=[...d].map(S=>Gr(S)).sort((S,N)=>mf({metadata:S},{metadata:N})),v=yt(w.find(S=>yt(S.projectDirectory??null))?.projectDirectory??t.currentWorktree?.projectDirectory??l.path),x=new Set([a]);for(const[S,N]of g.entries()){const C=yt(N.find(j=>yt(j.projectDirectory??null))?.projectDirectory??S);C&&C===v&&x.add(S)}for(const S of x){if(w.length===0){g.delete(S);continue}g.set(S,w.map(N=>Gr(N)))}Kj(e.rawWorktreesByProjectRef,n),e.rawWorktreesByProjectRef.current={runtimeKey:n,revision:e.rawWorktreesByProjectRef.current.revision,worktreesByProject:g};const f=e.partitionWorktreesByRegisteredProject(h,g),b=[...f.values()].flat();e.recordWorktreesSeen(b.map(S=>S.path),e.now());const y=e.getPublishedWorktreesByProject();return e.worktreeMapsEqual(f,y)||e.publishTopology({availableWorktrees:b,availableWorktreesByProject:f}),Sc({projectPath:a,discoveredWorktrees:w,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},Gj=t=>{if(t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey)return!1;if(t.rawWorktreesByProjectRef.current.revision!==t.capturedRevision)return t.requestRediscovery(),!1;const e=t.partitionWorktreesByRegisteredProject(t.projects,t.nextRawWorktreesByProject),n=[...e.values()].flat();return t.recordWorktreesSeen(n.map(r=>r.path),t.now()),t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.capturedRevision,worktreesByProject:new Map(t.nextRawWorktreesByProject)},t.worktreeMapsEqual(e,t.publishedWorktreesByProject)||t.publishTopology({availableWorktrees:n,availableWorktreesByProject:e}),!0},qj=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),Qj=(t,e)=>yt(t.worktree?.path??null)===yt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,ra=6,lo=14,vc=ra+14+6,pi=new WeakMap,Yj=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;pi.get(n)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,pi.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},u=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const d=e.getBoundingClientRect().top-r;if(Math.abs(d)>.5&&(n.scrollTop+=d,Gs("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(u)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),pi.set(n,a),l=window.requestAnimationFrame(u)},Xj=c.memo(function(e){const n=tt.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:u,onArchive:d,onDelete:h}=e,m=jj(),p=m?i:r;let g;n[0]!==d||n[1]!==h||n[2]!==m?(g=C=>{if(m||C.shiftKey){h(C);return}d(C)},n[0]=d,n[1]=h,n[2]=m,n[3]=g):g=n[3];const w=g,v=m?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let x;n[4]!==o||n[5]!==v?(x=Pe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",v,o),n[4]=o,n[5]=v,n[6]=x):x=n[6];const f=m?"delete-bin":"archive";let b;n[7]!==l||n[8]!==f?(b=s.jsx(E,{name:f,className:l}),n[7]=l,n[8]=f,n[9]=b):b=n[9];let y;n[10]!==w||n[11]!==p||n[12]!==u||n[13]!==a||n[14]!==x||n[15]!==b?(y=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:x,"aria-label":p,onPointerDown:a,onMouseDown:u,onClick:w,onKeyDown:i2,children:b})}),n[10]=w,n[11]=p,n[12]=u,n[13]=a,n[14]=x,n[15]=b,n[16]=y):y=n[16];let S;n[17]!==p?(S=s.jsx(It,{side:"left",sideOffset:8,children:p}),n[17]=p,n[18]=S):S=n[18];let N;return n[19]!==y||n[20]!==S?(N=s.jsxs(Dt,{children:[y,S]}),n[19]=y,n[20]=S,n[21]=N):N=n[21],N});function Jj(t){Gs("ui.sidebar_session_node.render");const{t:e}=At(),{node:n,depth:r=0,groupDirectory:i,projectId:o,archivedBucket:l=!1,pinnedSessionIds:a,expandedParents:u,hasSessionSearchQuery:d,normalizedSessionSearchQuery:h,notifyOnSubtasks:m,editingId:p,setEditingId:g,editTitle:w,setEditTitle:v,handleSaveEdit:x,handleCancelEdit:f,toggleParent:b,handleSessionSelect:y,handleSessionDoubleClick:S,handleShareSession:N,copiedSessionId:C,handleCopyShareUrl:j,handleCopySessionId:A,handleUnshareSession:P,openSidebarMenuKey:I,setOpenSidebarMenuKey:M,createFolderAndStartRename:z,handleDeleteSession:R,handleRestoreSession:H,startSessionWorktreeMenuLoad:F,mobileVariant:O,alwaysShowActions:T,secondaryMeta:k,renderContext:D="project",children:L}=t,Q=$r(Ae=>Ae.toggle),q=cs(Ae=>Ae.getFoldersForScope),te=cs(Ae=>Ae.getSessionFolderId),ae=cs(Ae=>Ae.removeSessionFromFolder),X=cs(Ae=>Ae.addSessionToFolder),Z=De(Ae=>Ae.openContextPanelTab),se=c.useMemo(()=>Dn(),[]),fe=c.useMemo(()=>zo(),[]),B=c.useContext(Sh),ne=se?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto",ye=se?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",ce=se,_=!l&&!O,re=se?_&&ce?"group-hover:pr-18":_||ce?"group-hover:pr-14":"group-hover:pr-8":_?"group-hover:pr-7 group-focus-within:pr-7":"group-hover:pr-3 group-focus-within:pr-3",me=_?"pr-13":"pr-7",de=se?_?"pr-18":"pr-14":_?"pr-7":"pr-3",ge=c.useRef(!1),[Te,be]=c.useState(!1),Re=c.useRef(p);Re.current=p;const we=c.useRef(null),Y=c.useRef(!1),ve=c.useRef(x);ve.current=x;const[xe,je]=c.useState(w),oe=c.useRef(xe);oe.current=xe;const J=c.useRef(null),K=c.useRef(!1),$=c.useRef(null),le=c.useRef(null),V=n.session,Ce=V,Be=Kt(c.useCallback(Ae=>{if(k?.projectLabel||!o)return null;const _t=Ae.projects.find(Qt=>Qt.id===o);return _t?_t.label?.trim()||Fn(yt(_t.path)??_t.path,null)||_t.path:null},[o,k?.projectLabel])),ke=k?.projectLabel??(Be?Da(Be):null),Ne=k?.branchLabel??n.worktree?.branch??null,Qe=c.useMemo(()=>{if(se)return null;const Ae=n.worktree?.branch?.trim(),_t=yt(n.worktree?.path??null);return Ae&&_t?Ko(_t,Ae):null},[se,n.worktree]),We=Bd(Qe),U=We?`var(--pr-${We.visualState})`:void 0,he=ls(Ae=>Ae.sessionGroupingMode),Ee=!!Ne&&(D==="recent"||he==="flat"),Ie=c.useMemo(()=>{if(!We)return null;switch(We.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return We.canMerge===!0||We.mergeableState==="clean"||We.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return We.mergeableState==="dirty"?e("sessions.sidebar.group.pr.status.mergeConflicts"):e("sessions.sidebar.group.pr.status.mergeBlocked");case"draft":return e("sessions.sidebar.group.pr.status.draft");case"closed":return e("sessions.sidebar.group.pr.status.closed");default:return null}},[We,e]),rt=Je(Ae=>Ae.currentSessionId===V.id),Ge=yt(V.directory??null)??yt(i??null),ut=o??Ge??null,ct=vh(),ue=Ld(),G=se,Le=hs(Ae=>Ae.enabled),Oe=hs(c.useCallback(Ae=>Ae.selectedIds.has(V.id),[V.id])),qe=hs(Ae=>Ae.toggleSelected),Ue=hs(Ae=>Ae.setRange),st=c.useCallback(Ae=>{const _t=[],Qt=is=>{is.children.forEach(bs=>{_t.push(bs.session.id),Qt(bs)})};return Qt(Ae),_t},[]),wt=c.useCallback(Ae=>{const _t=[],Qt=is=>{is.children.forEach(bs=>{_t.push(bs.session),Qt(bs)})};return Qt(Ae),_t},[]),[Nt,ie]=c.useState(!1),[pe,Ve]=c.useState(!0),ze=`${D}:${l?"archived":"active"}:${V.id}`,He=$d(c.useCallback(Ae=>!!Ae.sessionMemoryState.get(jh(V.id))?.isZombie,[V.id])),at=ha(V.id)?.type??"idle",et=at==="busy"||at==="retry",Xe=kh(V.id,et),dt=ku(V.id),Fe=n.worktree??Je.getState().getWorktreeMetadata(V.id)??null,[Se,St]=c.useState([]),[vt,Rt]=c.useState(!1),[Ze,it]=c.useState(!1),gt=c.useRef(!1),xt=c.useRef(0),Et=Ch(V.id,Ge??void 0,{bootstrap:!1}),kt=Nh(Ce),Tt=kt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(ol[kt.status]),"aria-label":e(ol[kt.status]),children:s.jsx(E,{name:"target",className:"h-3 w-3",style:{color:Ah[kt.status]}})}):null,Ot=Ce.title||e("sessions.sidebar.session.untitled"),Vt=n.children.length>0,Yt=Dh(a,Ge,V.id),Ht=ze,Lt=d?!0:u.has(Ht),zt=c.useMemo(()=>cj(n,Lt,Ge),[Lt,n,Ge]),_e=Ph(zt),Ye=!!Ce.parentID,bt=fd(V.id)>0&&(!Ye||m),mt=Ce.time?.updated||Ce.time?.created||Date.now(),lt=Wd(mt),$t=Ih(mt),Zt=I===ze,[Xt,Ns]=c.useState(!1),Jt=Zt||Xt,zs=c.useMemo(()=>So(Ce.title)!==null,[Ce.title]),[Js,rs]=c.useState(!1),Vs=c.useMemo(()=>st(n).length,[st,n]),Rs=c.useCallback(async Ae=>{const _t=[];let Qt=0;for(const is of Ae)try{if(!Ge)throw new Error("Session directory is required for export");const bs=await ct({directory:Ge,sessionID:is.session.id});if(!bs)throw new Error("Session runtime changed during export");const fs=is.session.title||e("sessions.sidebar.session.export.untitledSubagent"),tn=is.session.agent,es=await Rs(is.children);Qt+=es.skipped,_t.push({title:fs,agent:tn,records:bs,children:es.children})}catch{Qt+=st(is).length+1}return{children:_t,skipped:Qt}},[st,ct,Ge,e]),cn=c.useCallback(Ae=>{Ae<=0||Me.warning(Ae===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Ae}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Ae}))},[e]),gs=c.useCallback(async Ae=>{if(!Ge){Me.error(e("sessions.sidebar.session.export.nothingToExport"));return}const _t=await ct({directory:Ge,sessionID:V.id}).catch(()=>null);if(!_t){Me.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(_t.length===0){Me.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Qt,is=0;if(Ae&&n.children.length>0){const es=await Rs(n.children);Qt=es.children,is=es.skipped}const bs=wu(_t,Ce.title??null,Qt),fs=ju(Ce.title??null),tn=await vu(bs,fs);if(tn){Me.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Kx()),onClick:()=>{Ux(tn).then(es=>{es||Me.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),cn(is);return}Su(bs,fs),Me.success(e("sessions.sidebar.session.export.success")),cn(is)},[Rs,ct,n.children,Ce.title,V.id,Ge,cn,e]),vs=c.useCallback(async()=>{if(n.children.length>0){Ve(!0),ie(!0);return}await gs(!1)},[gs,n.children.length]),Zs=c.useCallback(()=>{Ge&&En("desktop_open_session_mini_chat_window",{sessionId:V.id,directory:Ge,apiBaseUrl:Nn(),clientToken:Lr()}).catch(Ae=>{console.warn("[session-sidebar] failed to open mini chat window",Ae)})},[V.id,Ge]);if(c.useEffect(()=>{if(p!==V.id)return;const Ae=_t=>{const is=(_t.target instanceof HTMLElement?_t.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(V.id)}"]`);le.current&&!is&&ve.current(oe.current)};return document.addEventListener("mousedown",Ae),()=>document.removeEventListener("mousedown",Ae)},[p,V.id]),c.useLayoutEffect(()=>{if(p!==V.id){J.current===V.id&&(J.current=null);return}J.current!==V.id&&(J.current=V.id,K.current=!0,je(w))},[p,w,V.id]),c.useLayoutEffect(()=>{if(p!==V.id||!K.current)return;const Ae=$.current;!Ae||Ae.value!==w||(K.current=!1,Ae.focus(),Ae.select())},[p,w,xe,V.id]),p===V.id)return s.jsx("div",{style:{paddingLeft:vc+r*lo},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:s.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:s.jsxs("form",{ref:le,"data-session-rename-form":V.id,className:"flex w-full items-center gap-2",onSubmit:Ae=>{Ae.preventDefault(),x(xe)},children:[s.jsx("input",{ref:$,value:xe,onChange:Ae=>je(Ae.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:e("sessions.sidebar.session.menu.rename"),onKeyDown:Ae=>{if(Ae.stopPropagation(),Ae.key==="Escape"){f();return}}}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:f,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"size-4"})})]})})},V.id);const Es=Et.length,As=_e===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:_e}),Ds=hj({actionsAlwaysVisible:T&&!se,menuOpen:Jt,hideOnHoverClass:ye}),js=!dt&&!et&&bt&&!rt,Ft=et||js,Wt=e(et?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),ns=s.jsx("span",{className:Pe("h-1.5 w-1.5 rounded-full",et?"bg-primary":"bg-[var(--status-info)]"),"aria-label":Wt,title:Wt}),us=(et||js)&&Xe,xs=!T&&Vt&&(dt||Ft||Yt),ee=Yt&&!dt&&!Ft,Ke=s.jsx(E,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),W=dt||Ft||ee?s.jsx("span",{style:{left:ra+r*lo},className:Pe("pointer-events-none absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center transition-opacity",xs?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:dt?s.jsx(E,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e("sessions.sidebar.session.status.movingToWorktree")}):Ft?ns:ee?Ke:null}):null,$e=Vt&&!T&&(dt||Ft||Yt),nt=Vt?s.jsx("span",{role:"button",tabIndex:0,onClick:Ae=>{Ae.stopPropagation(),Ae.currentTarget.blur(),b(Ht)},onKeyDown:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),Ae.stopPropagation(),b(Ht))},style:{minWidth:14,minHeight:14,left:ra+r*lo},className:Pe("absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",$e?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto":""),"aria-label":e(Lt?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:Lt?s.jsx(E,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(E,{name:"arrow-right-s",className:"h-3 w-3"})}):null,jt=He?s.jsx(E,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Ct=Ae=>{Ae&&Ns(!1),M(Ae?ze:null)},Bt=Ae=>{if(!Ae&&we.current){const{id:_t,title:Qt}=we.current;we.current=null,g(_t),v(Qt)}},os=Ae=>{Ns(Ae)},qt=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),M(Zt?null:ze)},en=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Sn=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Zo=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},tr=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Df=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),M(null),R(V,{archivedBucket:l})},Pf=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),M(null),R(V,{archivedBucket:l,hardDelete:!0,skipConfirm:!0})},If=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Tf=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Rf=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),B?.vscode?.executeCommand("aiworker.openSessionInEditor",V.id,Ot)},Wa=Ae=>{if(ge.current){ge.current=!1;return}if(Le){if(Ae?.preventDefault(),Ae?.stopPropagation(),Ae?.shiftKey){const Qt=Array.from(document.querySelectorAll("[data-session-row]")).map(fs=>fs.getAttribute("data-session-row")).filter(fs=>fs!==null&&fs.length>0),is=hs.getState().anchorId,bs=new Map;bs.set(V.id,st(n)),Ue(is,V.id,Qt,ut,bs);return}qe(V.id,ut,st(n));return}Ae?.currentTarget&&Yj(Ae.currentTarget),y(V.id,Ge)},Ef=Ae=>{Ae.defaultPrevented||(Ae.target instanceof HTMLElement?Ae.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||Wa(Ae)},Mf=Ae=>{(Ae.button===2||Ae.button===0&&Ae.ctrlKey&&!Le)&&(ge.current=!0)},Of=Ae=>{O&&Ae.pointerType==="touch"&&be(!0),Ae.button===0&&!rt&&!Le&&!G&&Ge&&!Ai(V.id,Ge).renderable&&ue({directory:Ge,sessionID:V.id}).catch(()=>{})},za=Ae=>{O&&Ae.pointerType==="touch"&&be(!1)},Ff=Ae=>{gt.current=Ae,xt.current+=1;const _t=xt.current;if(!Ae){Rt(!1),it(!1);return}const Qt=F({projectId:o??null,sourceDirectory:Ge,currentWorktree:Fe});St(Qt.cachedTargets),Rt(!0),it(!1),Qt.refreshTargets.then(is=>{!gt.current||xt.current!==_t||(St(is),Rt(!1),it(!1))}).catch(()=>{!gt.current||xt.current!==_t||(Rt(!1),it(!0))})},Va=({Item:Ae,Separator:_t,Sub:Qt,SubTrigger:is,SubContent:bs})=>s.jsxs(s.Fragment,{children:[s.jsxs(Ae,{onClick:()=>{we.current={id:V.id,title:Ot}},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsxs(Ae,{onClick:()=>A(V.id),className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Ae,{onClick:()=>Ge&&Q({directory:Ge,sessionId:V.id}),className:"[&>svg]:mr-1",children:[Yt?s.jsx(E,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(E,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(Yt?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),Ce.share?s.jsxs(s.Fragment,{children:[s.jsx(Ae,{onClick:()=>{Ce.share?.url&&j(Ce.share.url,V.id)},className:"[&>svg]:mr-1",children:C===V.id?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"check",className:"mr-1 h-4 w-4",style:{color:"var(--status-success)"}}),e("sessions.sidebar.session.menu.copied")]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(Ae,{onClick:()=>P(V.id),className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Ae,{onClick:()=>N(Ce),className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(Ae,{onClick:()=>{vs()},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),aj({isSubtaskSession:Ye,archivedBucket:!!l,isVSCode:se,sessionDirectory:Ge})?(()=>{const fs=lj({sessionDirectory:Ge,isStreaming:et,isMovingToWorktree:dt}),tn=qj({targets:Se,isRefreshing:vt,loadFailed:Ze});return s.jsxs(Qt,{onOpenChange:Ff,children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs(is,{disabled:fs,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":V.id,children:[s.jsx(E,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(It,{side:"right",className:"max-w-72",children:e(dt?"sessions.sidebar.session.moveToWorktree.tooltipMoving":et?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(bs,{className:"min-w-[220px]","data-session-worktree-submenu":V.id,children:[Se.map(es=>{const sn=yt(es.metadata.path??null)??es.metadata.path,Sr=es.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):es.metadata.label||es.metadata.branch||es.metadata.name||es.metadata.path,ms=es.isCurrent||es.metadata.worktreeStatus!=="ready";return s.jsxs(Ae,{disabled:ms,title:es.metadata.path,"data-session-worktree-target":sn,onClick:()=>{ms||!Ge||Ui({kind:"existing",root:Ce,descendants:wt(n),sourceDirectory:Ge,destination:es.metadata,messages:zi(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[s.jsx("span",{className:"truncate",children:Sr}),es.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),es.isCurrent?s.jsx(E,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},sn)}),tn.refreshState==="loading"?s.jsx(Ae,{disabled:!0,"data-session-worktree-refresh-state":"loading",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.refreshing")}):null,tn.refreshState==="error"?s.jsx(Ae,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(_t,{}),s.jsxs(Ae,{disabled:fs,"data-session-worktree-new-action":"true",onClick:()=>{fs||!Ge||Ui({kind:"quick",root:Ce,descendants:wt(n),sourceDirectory:Ge,messages:zi(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,zs?s.jsxs(Ae,{onClick:()=>rs(!0),className:"[&>svg]:mr-1",children:[s.jsx(Uj,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,Ge&&!l?(()=>{const fs=[],tn=ms=>{const ks=yt(ms??null);ks&&!fs.includes(ks)&&fs.push(ks)};if(o&&!se){const ms=Kt.getState().projects.find(sr=>sr.id===o),ks=yt(ms?.path??null);tn(ks),ks&&(Je.getState().availableWorktreesByProject.get(ks)??[]).forEach(sr=>tn(sr.path))}tn(zd(Ge)),tn(Ge);const es=fs.flatMap(ms=>q(ms).map(ks=>({scope:ms,folder:ks}))),sn=es.find(({scope:ms,folder:ks})=>te(ms,V.id)===ks.id)??null,Sr=fs[0]??Ge;return s.jsxs(s.Fragment,{children:[s.jsx(_t,{}),s.jsxs(Qt,{children:[s.jsxs(is,{className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(bs,{className:"min-w-[180px]",children:[es.length===0?s.jsx(Ae,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):es.map(({scope:ms,folder:ks})=>{const sr=sn?.folder.id===ks.id;return s.jsxs(Ae,{onClick:()=>{if(sr){ae(ms,V.id);return}sn&&sn.scope!==ms&&ae(sn.scope,V.id),X(ms,ks.id,V.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:ks.name}),sr?s.jsx(E,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ks.id)}),s.jsx(_t,{}),s.jsxs(Ae,{onClick:()=>{const ms=z(Sr);ms&&(Y.current=!0,sn&&sn.scope!==Sr&&ae(sn.scope,V.id),X(Sr,ms.id,V.id))},children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),sn?s.jsxs(Ae,{onClick:()=>{ae(sn.scope,V.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,se?null:s.jsxs(Ae,{disabled:!Ge,onClick:()=>{Ge&&Z(Ge,{mode:"chat",dedupeKey:`session:${V.id}`,label:Ot,sessionTitleFallback:Ot})},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),fe?s.jsxs(Ae,{disabled:!Ge,onClick:Zs,className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(_t,{}),l?null:s.jsxs(Ae,{className:"[&>svg]:mr-1",onClick:()=>R(V,{archivedBucket:l}),children:[s.jsx(E,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),l?s.jsxs(Ae,{className:"[&>svg]:mr-1",onClick:()=>H(V),children:[s.jsx(E,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Ae,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>R(V,{archivedBucket:l,hardDelete:!0}),children:[s.jsx(E,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),_f=s.jsx(Ys,{align:"end",className:"min-w-[180px]",finalFocus:()=>Y.current?(Y.current=!1,!1):!Re.current,children:Va({Item:Ut,Separator:Os,Sub:Rh,SubTrigger:Eh,SubContent:Mh})}),Bf=s.jsx(Bi,{children:s.jsx(Li,{className:"app-region-no-drag z-50",children:s.jsx($i,{"data-slot":"dropdown-menu-content",finalFocus:()=>Y.current?(Y.current=!1,!1):!Re.current,style:{color:"var(--surface-elevated-foreground)"},className:Pe(Si,"min-w-[180px]"),children:Va({Item:({className:Ae,..._t})=>s.jsx(cu,{className:Pe(hd,Ae),..._t}),Separator:({className:Ae,..._t})=>s.jsx(lu,{className:Pe(md,Ae),..._t}),Sub:Fg,SubTrigger:({className:Ae,children:_t,...Qt})=>s.jsxs(_g,{className:Pe(Th,Ae),...Qt,children:[_t,s.jsx(E,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Ae,children:_t,...Qt})=>s.jsx(Bi,{children:s.jsx(Li,{className:"app-region-no-drag z-50",children:s.jsx($i,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Pe(Si,Ae),...Qt,children:_t})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(rj,{sessionId:V.id,sessionDirectory:Ge??null,sessionTitle:Ot,children:s.jsxs(uu,{open:Xt,onOpenChange:os,onOpenChangeComplete:Bt,children:[s.jsxs(du,{render:s.jsx("div",{"data-session-row":V.id,"data-session-scope":ut??"","data-session-archived":l?"1":"0","aria-current":rt?"page":void 0,onClick:Ef,style:{paddingLeft:vc+r*lo},className:Pe("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-1.5",rt&&!Oe&&"bg-primary/10",Oe&&"bg-interactive-selection")}),children:[W,nt,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onPointerDown:Of,onPointerUp:za,onPointerCancel:za,onMouseDown:Mf,onClick:Ae=>Wa(Ae),onDoubleClick:Ae=>{Ae.stopPropagation(),S(V.id,Ot)},className:Pe("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 text-foreground select-none transition-[padding]",Te&&"bg-interactive-hover/70",T?se?re:me:Jt?de:re),children:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Pe("block min-w-0 flex-1 truncate typography-ui-label font-normal",rt?"text-primary":bt?"text-foreground":"text-foreground/80"),children:po(Ot,h)}),!l&&Ge&&(D==="recent"||he==="flat"&&n.worktree&&yt(n.worktree.path)!==yt(n.worktree.projectDirectory))?s.jsx(Kr,{directory:Ge,className:T?void 0:Jt?"mr-1":se?"group-hover:mr-1":"group-hover:mr-1 group-focus-within:mr-1"}):null,T?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",children:us?s.jsx(wl,{sessionId:V.id,running:et}):s.jsxs(s.Fragment,{children:[Tt,Ee?s.jsx(E,{name:"git-branch",className:Pe("h-3 w-3",!U&&"text-muted-foreground/60"),style:U?{color:U}:void 0}):null,$t]})}):us||Tt||Ee||D==="recent"?s.jsx("div",{className:Pe("relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",Jt?"hidden":se?"group-hover:hidden":"group-hover:hidden group-focus-within:hidden"),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:us?s.jsx(wl,{sessionId:V.id,running:et,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[Tt,Ee?s.jsx(E,{name:"git-branch",className:Pe("h-3 w-3",!U&&"text-muted-foreground/60"),style:U?{color:U}:void 0}):null,D==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:$t}):null]})})}):null,Es>0?s.jsxs("span",{className:Pe("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",Ds),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(E,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Es})]}):null,_e>0?s.jsxs("span",{className:Pe("inline-flex items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info flex-shrink-0",Ds),title:As,"aria-label":As,children:[s.jsx(E,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:_e})]}):null]})})}),se?null:s.jsx(It,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:Ot}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:lt,children:$t})]}),ke?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(E,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:ke})]}):null,Ne?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:U?{color:U}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:Ne})]}):null,We&&Ie?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(E,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:U?{color:U}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:U?{color:U}:void 0,children:["#",We.number," · ",Ie]})]}):null]})})]})}),jt&&!O?s.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 z-10",children:jt}):null,s.jsxs("div",{className:Pe("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",Jt||T&&!se?"opacity-100":Pe("opacity-0",ne)),children:[_?s.jsx(Xj,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:T?"h-6 w-6":"h-4 w-4",iconSizeClass:T?"h-3.5 w-3.5":"h-2.5 w-2.5",onPointerDown:Zo,onMouseDown:tr,onArchive:Df,onDelete:Pf}):null,ce?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",T?"h-6 w-6":"h-4 w-4"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:If,onMouseDown:Tf,onClick:Rf,onKeyDown:Ae=>Ae.stopPropagation(),children:s.jsx(E,{name:"external-link",className:Pe(T?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),s.jsx(It,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(Xs,{open:Zt,onOpenChange:Ct,onOpenChangeComplete:Bt,children:[s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",T?"h-6 w-6 opacity-100":Jt?"h-4 w-4 opacity-100":Pe("h-4 w-4 opacity-0",ne)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:en,onMouseDown:Sn,onClick:qt,onKeyDown:Ae=>Ae.stopPropagation(),children:s.jsx(E,{name:"more-2",className:Pe(T?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),_f]})]})]}),Bf]})}),Vt&&Lt?L:null,s.jsx(ws,{open:Nt,onOpenChange:ie,children:s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Ts,{children:Vs===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:Vs}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:Vs})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:pe,onChange:Ae=>Ve(Ae.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(bn,{children:[s.jsx(pt,{type:"button",onClick:()=>ie(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(pt,{type:"button",onClick:()=>{ie(!1),gs(pe)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),zs?s.jsx(Vj,{session:Ce,open:Js,onOpenChange:rs}):null]},V.id)}const jc=t=>yt(t.session.directory??null),Zj=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),e2=t=>{if(!t.openSidebarMenuKey)return null;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},kc=t=>t.menuOpenSessionId??e2(t),co=(t,e,n)=>e?n.has(t.node.session.id)?!0:Hn(t.node,e):!1,oa=(t,e,n,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(n.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(oa(t.children[l],e.children[l],n,r,i))return!0;return!1},t2=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return oa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||oa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},s2=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.share?.url===e.share?.url&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived,n2=(t,e)=>{if(t.node.session.id!==e.node.session.id||!s2(t.node.session,e.node.session)||!Qj(t.node,e.node))return"node";if(t.depth!==e.depth)return"depth";if(t.groupDirectory!==e.groupDirectory)return"groupDirectory";if(t.projectId!==e.projectId)return"projectId";if(t.archivedBucket!==e.archivedBucket)return"archivedBucket";if((t.renderContext??"project")!==(e.renderContext??"project"))return"renderContext";if(t.mobileVariant!==e.mobileVariant)return"mobileVariant";if(t.alwaysShowActions!==e.alwaysShowActions)return"alwaysShowActions";if(t.hasSessionSearchQuery!==e.hasSessionSearchQuery)return"hasSessionSearchQuery";if(t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery)return"normalizedSessionSearchQuery";if(t.notifyOnSubtasks!==e.notifyOnSubtasks)return"notifyOnSubtasks";if(t.nodeStructureKey!==e.nodeStructureKey)return"nodeStructureKey";if(t.relativeTimeTick!==e.relativeTimeTick)return"relativeTimeTick";if(jc(t.node)!==jc(e.node))return"nodeDirectory";if(!Zj(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&lf(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&t2(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(co(t,t.editingId,t.subtreeContainsEditing)||co(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editTitle!==e.editTitle&&(co(t,t.editingId,t.subtreeContainsEditing)||co(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.copiedSessionId!==e.copiedSessionId&&(Hn(t.node,t.copiedSessionId)||Hn(e.node,e.copiedSessionId)))return"copiedSessionId";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=kc(t),i=kc(e);if(Hn(t.node,r)||Hn(e.node,i))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.handleShareSession===e.handleShareSession&&t.handleCopyShareUrl===e.handleCopyShareUrl&&t.handleCopySessionId===e.handleCopySessionId&&t.handleUnshareSession===e.handleUnshareSession&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.children===e.children?null:"callbacks"},r2=(t,e)=>{const n=n2(t,e);return n===null?!0:(Gs(`ui.sidebar_session_node.props_changed.${n}`),!1)},o2=c.memo(Jj,r2);function i2(t){return t.stopPropagation()}const a2=t=>{const{t:e}=At(),n=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=De(Z=>Z.setSessionSwitcherOpen),a=Je(Z=>Z.setCurrentSession),u=Je(Z=>Z.updateSessionTitle),d=Je(Z=>Z.shareSession),h=Je(Z=>Z.unshareSession),m=Je(Z=>Z.deleteSession),p=Je(Z=>Z.deleteSessions),g=Je(Z=>Z.archiveSession),w=Je(Z=>Z.archiveSessions),v=Je(Z=>Z.unarchiveSession),{mobileVariant:x,allowReselect:f,onSessionSelected:b,isSessionSearchOpen:y,sessionSearchQuery:S,setSessionSearchQuery:N,setIsSessionSearchOpen:C,descendantIds:j,showDeletionDialog:A,setDeleteSessionConfirm:P,setEditingId:I,setEditTitle:M,setCopiedSessionId:z}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const R=c.useCallback((Z,se)=>{wi("navigation.session_select"),De.getState().closeMainSurfaces();const fe=()=>{!y&&S.length===0||(N(""),C(!1))};if(x&&l(!1),Z===Je.getState().currentSessionId){f&&b?.(Z),fe();return}wi("navigation.session_state_set"),a(Z,se??null),b?.(Z),fe()},[f,y,x,b,S,a,C,N,l]),H=c.useCallback((Z,se)=>{I(Z),M(se)},[M,I]),F=c.useCallback(async Z=>{const se=r.current;if(!se)return;const fe=(Z??i.current).trim();fe&&await u(se,fe),I(null),M("")},[M,I,u]),O=c.useCallback(()=>{I(null),M("")},[M,I]),T=c.useCallback(async(Z,se)=>{try{return(await pn(Z)).ok?(z(se),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{z(null),n.current=null},2e3),!0):!1}catch{return!1}},[z]),k=c.useCallback(async Z=>{const se=await d(Z.id);if(!se?.share?.url){Me.error(e("sessions.sidebar.session.share.error"));return}const fe=await T(se.share.url,Z.id);Me[fe?"success":"warning"](e("sessions.sidebar.session.share.successTitle"),{description:e(fe?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},[T,d,e]),D=c.useCallback((Z,se)=>{T(Z,se).then(fe=>{fe||Me.error(e("sessions.sidebar.session.share.copyUrlError"))})},[T,e]),L=c.useCallback(Z=>{pn(Z).then(se=>{if(se.ok){Me.success(e("sessions.sidebar.session.copyId.success"));return}Me.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Me.error(e("sessions.sidebar.session.copyId.error")))},[e]),Q=c.useCallback(async Z=>{await h(Z)?Me.success(e("sessions.sidebar.session.unshare.success")):Me.error(e("sessions.sidebar.session.unshare.error"))},[e,h]),q=c.useCallback(async(Z,se,fe)=>{const B=se?.archivedBucket===!0||se?.hardDelete===!0,ne=fe?.descendantIds??j;if(ne.length===0){(B?await m(Z.id):await g(Z.id))?Me.success(e(B?"sessions.sidebar.session.delete.success":"sessions.sidebar.session.archive.success")):Me.error(e(B?"sessions.sidebar.session.delete.error":"sessions.sidebar.session.archive.error"));return}const ye=[Z.id,...ne];if(B){const{deletedIds:re,failedIds:me}=await p(ye);if(me.length===0){const de=re.length;Me.success(de===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:de}):e("sessions.sidebar.bulkActions.deletedPlural",{count:de}))}else Me.error(e("sessions.sidebar.session.delete.error"));return}const{archivedIds:ce,failedIds:_}=await w(ye);ce.length>0&&Me.success(ce.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:ce.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:ce.length})),_.length>0&&Me.error(_.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:_.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:_.length}))},[g,w,m,p,j,e]),te=c.useCallback((Z,se)=>{const fe=se?.archivedBucket===!0||se?.hardDelete===!0,B=[...j];if(!A||se?.skipConfirm===!0){q(Z,se,{descendantIds:B});return}P({session:Z,descendantCount:B.length,descendantIds:B,archivedBucket:fe})},[j,q,P,A]),ae=c.useCallback(async()=>{const Z=o.current;if(!Z)return;const{session:se,archivedBucket:fe,descendantIds:B}=Z;P(null),await q(se,{archivedBucket:fe},{descendantIds:B})},[q,P]),X=c.useCallback(async Z=>{await v(Z.id)?Me.success(e("sessions.sidebar.session.restore.success")):Me.error(e("sessions.sidebar.session.restore.error"))},[e,v]);return c.useMemo(()=>({handleSessionSelect:R,handleSessionDoubleClick:H,handleSaveEdit:F,handleCancelEdit:O,handleShareSession:k,handleCopyShareUrl:D,handleCopySessionId:L,handleUnshareSession:Q,handleDeleteSession:te,handleRestoreSession:X,confirmDeleteSession:ae}),[O,L,D,te,X,F,H,R,k,Q,ae])};function l2(t){const e=tt.c(71),{t:n}=At(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let u,d,h,m,p,g,w,v,x,f;if(e[0]!==i||e[1]!==n||e[2]!==r){const D=n("sessions.sidebar.session.untitled");m=ws,x=!!r,e[13]!==i?(f=Q=>{Q||i(null)},e[13]=i,e[14]=f):f=e[14],h=Ss,w=!1,v="max-w-sm gap-5",d=Ws;let L;e[15]!==n||e[16]!==r?.archivedBucket?(L=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=L):L=e[17],e[18]!==L?(g=s.jsx(Is,{children:L}),e[18]=L,e[19]=g):g=e[19],u=Ts,p=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||D,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||D,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||D,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||D,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||D}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||D}),e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=d,e[5]=h,e[6]=m,e[7]=p,e[8]=g,e[9]=w,e[10]=v,e[11]=x,e[12]=f}else u=e[3],d=e[4],h=e[5],m=e[6],p=e[7],g=e[8],w=e[9],v=e[10],x=e[11],f=e[12];let b;e[20]!==u||e[21]!==p?(b=s.jsx(u,{children:p}),e[20]=u,e[21]=p,e[22]=b):b=e[22];let y;e[23]!==d||e[24]!==g||e[25]!==b?(y=s.jsxs(d,{children:[g,b]}),e[23]=d,e[24]=g,e[25]=b,e[26]=y):y=e[26];let S;e[27]!==l||e[28]!==o?(S=()=>l(!o),e[27]=l,e[28]=o,e[29]=S):S=e[29];const N=!o;let C;e[30]!==o?(C=o?s.jsx(E,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(E,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=C):C=e[31];let j;e[32]!==n?(j=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=j):j=e[33];let A;e[34]!==C||e[35]!==j||e[36]!==S||e[37]!==N?(A=s.jsxs("button",{type:"button",onClick:S,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":N,children:[C,j]}),e[34]=C,e[35]=j,e[36]=S,e[37]=N,e[38]=A):A=e[38];let P;e[39]!==i?(P=()=>i(null),e[39]=i,e[40]=P):P=e[40];let I;e[41]!==n?(I=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=I):I=e[42];let M;e[43]!==P||e[44]!==I?(M=s.jsx("button",{type:"button",onClick:P,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:I}),e[43]=P,e[44]=I,e[45]=M):M=e[45];let z;e[46]!==a?(z=()=>{a()},e[46]=a,e[47]=z):z=e[47];let R;e[48]!==n||e[49]!==r?.archivedBucket?(R=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=R):R=e[50];let H;e[51]!==z||e[52]!==R?(H=s.jsx("button",{type:"button",onClick:z,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:R}),e[51]=z,e[52]=R,e[53]=H):H=e[53];let F;e[54]!==M||e[55]!==H?(F=s.jsxs("div",{className:"flex items-center gap-2",children:[M,H]}),e[54]=M,e[55]=H,e[56]=F):F=e[56];let O;e[57]!==A||e[58]!==F?(O=s.jsxs(bn,{className:"w-full sm:items-center sm:justify-between",children:[A,F]}),e[57]=A,e[58]=F,e[59]=O):O=e[59];let T;e[60]!==h||e[61]!==w||e[62]!==O||e[63]!==v||e[64]!==y?(T=s.jsxs(h,{showCloseButton:w,className:v,children:[y,O]}),e[60]=h,e[61]=w,e[62]=O,e[63]=v,e[64]=y,e[65]=T):T=e[65];let k;return e[66]!==m||e[67]!==T||e[68]!==x||e[69]!==f?(k=s.jsx(m,{open:x,onOpenChange:f,children:T}),e[66]=m,e[67]=T,e[68]=x,e[69]=f,e[70]=k):k=e[70],k}function c2(t){const e=tt.c(57),{t:n}=At(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,u=r?.archivedBucket===!0,d=r?.sessionCount??0;let h;e[0]!==u||e[1]!==d||e[2]!==n?(h=n(u?d===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":d===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=u,e[1]=d,e[2]=n,e[3]=h):h=e[3];const m=h;let p;e[4]!==u||e[5]!==d||e[6]!==n?(p=u?d===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:d}):d===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:d}),e[4]=u,e[5]=d,e[6]=n,e[7]=p):p=e[7];const g=p,w=!!r;let v;e[8]!==i?(v=k=>{k||i(null)},e[8]=i,e[9]=v):v=e[9];let x;e[10]!==m?(x=s.jsx(Is,{children:m}),e[10]=m,e[11]=x):x=e[11];let f;e[12]!==g?(f=s.jsx(Ts,{children:g}),e[12]=g,e[13]=f):f=e[13];let b;e[14]!==x||e[15]!==f?(b=s.jsxs(Ws,{children:[x,f]}),e[14]=x,e[15]=f,e[16]=b):b=e[16];let y;e[17]!==l||e[18]!==o?(y=()=>l(!o),e[17]=l,e[18]=o,e[19]=y):y=e[19];const S=!o;let N;e[20]!==o?(N=o?s.jsx(E,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(E,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=N):N=e[21];let C;e[22]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=C):C=e[23];let j;e[24]!==C||e[25]!==y||e[26]!==S||e[27]!==N?(j=s.jsxs("button",{type:"button",onClick:y,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":S,children:[N,C]}),e[24]=C,e[25]=y,e[26]=S,e[27]=N,e[28]=j):j=e[28];let A;e[29]!==i?(A=()=>i(null),e[29]=i,e[30]=A):A=e[30];let P;e[31]!==n?(P=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=P):P=e[32];let I;e[33]!==A||e[34]!==P?(I=s.jsx("button",{type:"button",onClick:A,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:P}),e[33]=A,e[34]=P,e[35]=I):I=e[35];let M;e[36]!==a?(M=()=>{a()},e[36]=a,e[37]=M):M=e[37];let z;e[38]!==u||e[39]!==n?(z=n(u?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=u,e[39]=n,e[40]=z):z=e[40];let R;e[41]!==M||e[42]!==z?(R=s.jsx("button",{type:"button",onClick:M,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:z}),e[41]=M,e[42]=z,e[43]=R):R=e[43];let H;e[44]!==I||e[45]!==R?(H=s.jsxs("div",{className:"flex items-center gap-2",children:[I,R]}),e[44]=I,e[45]=R,e[46]=H):H=e[46];let F;e[47]!==j||e[48]!==H?(F=s.jsxs(bn,{className:"w-full sm:items-center sm:justify-between",children:[j,H]}),e[47]=j,e[48]=H,e[49]=F):F=e[49];let O;e[50]!==F||e[51]!==b?(O=s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[b,F]}),e[50]=F,e[51]=b,e[52]=O):O=e[52];let T;return e[53]!==w||e[54]!==O||e[55]!==v?(T=s.jsx(ws,{open:w,onOpenChange:v,children:O}),e[53]=w,e[54]=O,e[55]=v,e[56]=T):T=e[56],T}function d2(t){const e=tt.c(36),{t:n}=At(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=N=>{N||i(null)},e[0]=i,e[1]=a):a=e[1];let u;e[2]!==n?(u=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=u):u=e[3];let d;e[4]!==u?(d=s.jsx(Is,{children:u}),e[4]=u,e[5]=d):d=e[5];let h;e[6]!==n||e[7]!==r?(h=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=h):h=e[8];let m;e[9]!==h?(m=s.jsx(Ts,{children:h}),e[9]=h,e[10]=m):m=e[10];let p;e[11]!==d||e[12]!==m?(p=s.jsxs(Ws,{children:[d,m]}),e[11]=d,e[12]=m,e[13]=p):p=e[13];let g;e[14]!==i?(g=()=>i(null),e[14]=i,e[15]=g):g=e[15];let w;e[16]!==n?(w=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=w):w=e[17];let v;e[18]!==g||e[19]!==w?(v=s.jsx("button",{type:"button",onClick:g,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:w}),e[18]=g,e[19]=w,e[20]=v):v=e[20];let x;e[21]!==n?(x=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=x):x=e[22];let f;e[23]!==o||e[24]!==x?(f=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:x}),e[23]=o,e[24]=x,e[25]=f):f=e[25];let b;e[26]!==f||e[27]!==v?(b=s.jsxs(bn,{children:[v,f]}),e[26]=f,e[27]=v,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==p?(y=s.jsxs(Ss,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,b]}),e[29]=b,e[30]=p,e[31]=y):y=e[31];let S;return e[32]!==l||e[33]!==a||e[34]!==y?(S=s.jsx(ws,{open:l,onOpenChange:a,children:y}),e[32]=l,e[33]=a,e[34]=y,e[35]=S):S=e[35],S}const u2=new Set;function Bo(t){const e=tt.c(142),{node:n,depth:r,groupDirectory:i,projectId:o,archivedBucket:l,secondaryMeta:a,renderContext:u,renderExtras:d,pinnedSessionIds:h,expandedParents:m,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:v,setEditingId:x,editTitle:f,setEditTitle:b,toggleParent:y,openSidebarMenuKey:S,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:j,isSessionSearchOpen:A,sessionSearchQuery:P,setSessionSearchQuery:I,setIsSessionSearchOpen:M,deleteSessionConfirm:z,setDeleteSessionConfirm:R,startFolderRename:H,copiedSessionId:F,setCopiedSessionId:O,startSessionWorktreeMenuLoad:T,mobileVariant:k,alwaysShowActions:D}=t,L=r===void 0?0:r,Q=l===void 0?!1:l,q=u===void 0?"project":u,te=cs(p2),ae=cs(h2),X=De(m2),Z=De(f2);let se;if(e[0]!==n){se=[];const We=U=>U.children.forEach(he=>{se.push(he.session.id),We(he)});We(n),e[0]=n,e[1]=se}else se=e[1];const fe=se.join(`
|
|
922
|
+
`);let B;e[2]!==fe?(B=fe?fe.split(`
|
|
923
|
+
`):[],e[2]=fe,e[3]=B):B=e[3];const ne=B;let ye;e[4]!==te||e[5]!==H||e[6]!==ae?(ye=(We,U)=>{if(!We)return null;U&&cs.getState().collapsedFolderIds.has(U)&&ae(U);const he=te(We,"New folder",U);return H(We,he),he},e[4]=te,e[5]=H,e[6]=ae,e[7]=ye):ye=e[7];const ce=ye;let _;e[8]!==C||e[9]!==F||e[10]!==z||e[11]!==ne||e[12]!==f||e[13]!==v||e[14]!==A||e[15]!==k||e[16]!==j||e[17]!==P||e[18]!==O||e[19]!==R||e[20]!==b||e[21]!==x||e[22]!==M||e[23]!==I||e[24]!==X?(_={mobileVariant:k,allowReselect:C,onSessionSelected:j,isSessionSearchOpen:A,sessionSearchQuery:P,setSessionSearchQuery:I,setIsSessionSearchOpen:M,descendantIds:ne,showDeletionDialog:X,setDeleteSessionConfirm:R,deleteSessionConfirm:z,editingId:v,setEditingId:x,editTitle:f,setEditTitle:b,copiedSessionId:F,setCopiedSessionId:O},e[8]=C,e[9]=F,e[10]=z,e[11]=ne,e[12]=f,e[13]=v,e[14]=A,e[15]=k,e[16]=j,e[17]=P,e[18]=O,e[19]=R,e[20]=b,e[21]=x,e[22]=M,e[23]=I,e[24]=X,e[25]=_):_=e[25];const re=a2(_),me=d?.childRenderExtrasFor,de=n.session.directory??i;let ge;e[26]!==Q||e[27]!==o||e[28]!==q||e[29]!==de?(ge={groupDirectory:de,projectId:o,archivedBucket:Q,renderContext:q},e[26]=Q,e[27]=o,e[28]=q,e[29]=de,e[30]=ge):ge=e[30];const Te=ge,be=re.handleSaveEdit,Re=re.handleCancelEdit,we=re.handleSessionSelect,Y=re.handleSessionDoubleClick,ve=re.handleShareSession,xe=re.handleCopyShareUrl,je=re.handleCopySessionId,oe=re.handleUnshareSession,J=re.handleDeleteSession,K=re.handleRestoreSession,$=d?.subtreeContainsEditing??u2,le=d?.menuOpenSessionId??null,V=d?.nodeStructureKey??"",Ce=d?.relativeTimeTick;let Be;if(e[31]!==C||e[32]!==D||e[33]!==Te||e[34]!==me||e[35]!==F||e[36]!==z||e[37]!==L||e[38]!==f||e[39]!==v||e[40]!==m||e[41]!==p||e[42]!==A||e[43]!==k||e[44]!==n.children||e[45]!==g||e[46]!==w||e[47]!==j||e[48]!==S||e[49]!==h||e[50]!==P||e[51]!==O||e[52]!==R||e[53]!==b||e[54]!==x||e[55]!==M||e[56]!==N||e[57]!==I||e[58]!==H||e[59]!==T||e[60]!==y){let We;e[62]!==C||e[63]!==D||e[64]!==Te||e[65]!==me||e[66]!==F||e[67]!==z||e[68]!==L||e[69]!==f||e[70]!==v||e[71]!==m||e[72]!==p||e[73]!==A||e[74]!==k||e[75]!==g||e[76]!==w||e[77]!==j||e[78]!==S||e[79]!==h||e[80]!==P||e[81]!==O||e[82]!==R||e[83]!==b||e[84]!==x||e[85]!==M||e[86]!==N||e[87]!==I||e[88]!==H||e[89]!==T||e[90]!==y?(We=U=>s.jsx(Bo,{node:U,pinnedSessionIds:h,expandedParents:m,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:v,setEditingId:x,editTitle:f,copiedSessionId:F,setEditTitle:b,toggleParent:y,openSidebarMenuKey:S,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:j,isSessionSearchOpen:A,sessionSearchQuery:P,setSessionSearchQuery:I,setIsSessionSearchOpen:M,deleteSessionConfirm:z,setDeleteSessionConfirm:R,startFolderRename:H,setCopiedSessionId:O,startSessionWorktreeMenuLoad:T,mobileVariant:k,alwaysShowActions:D,depth:L+1,...Te,renderExtras:me?.(U)},U.session.id),e[62]=C,e[63]=D,e[64]=Te,e[65]=me,e[66]=F,e[67]=z,e[68]=L,e[69]=f,e[70]=v,e[71]=m,e[72]=p,e[73]=A,e[74]=k,e[75]=g,e[76]=w,e[77]=j,e[78]=S,e[79]=h,e[80]=P,e[81]=O,e[82]=R,e[83]=b,e[84]=x,e[85]=M,e[86]=N,e[87]=I,e[88]=H,e[89]=T,e[90]=y,e[91]=We):We=e[91],Be=n.children.map(We),e[31]=C,e[32]=D,e[33]=Te,e[34]=me,e[35]=F,e[36]=z,e[37]=L,e[38]=f,e[39]=v,e[40]=m,e[41]=p,e[42]=A,e[43]=k,e[44]=n.children,e[45]=g,e[46]=w,e[47]=j,e[48]=S,e[49]=h,e[50]=P,e[51]=O,e[52]=R,e[53]=b,e[54]=x,e[55]=M,e[56]=N,e[57]=I,e[58]=H,e[59]=T,e[60]=y,e[61]=Be}else Be=e[61];let ke;e[92]!==D||e[93]!==Q||e[94]!==F||e[95]!==ce||e[96]!==L||e[97]!==f||e[98]!==v||e[99]!==m||e[100]!==i||e[101]!==p||e[102]!==k||e[103]!==n||e[104]!==g||e[105]!==w||e[106]!==S||e[107]!==h||e[108]!==o||e[109]!==q||e[110]!==a||e[111]!==re.handleCancelEdit||e[112]!==re.handleCopySessionId||e[113]!==re.handleCopyShareUrl||e[114]!==re.handleDeleteSession||e[115]!==re.handleRestoreSession||e[116]!==re.handleSaveEdit||e[117]!==re.handleSessionDoubleClick||e[118]!==re.handleSessionSelect||e[119]!==re.handleShareSession||e[120]!==re.handleUnshareSession||e[121]!==b||e[122]!==x||e[123]!==N||e[124]!==T||e[125]!==$||e[126]!==le||e[127]!==V||e[128]!==Ce||e[129]!==Be||e[130]!==y?(ke=s.jsx(o2,{expandedParents:m,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:v,setEditingId:x,editTitle:f,setEditTitle:b,handleSaveEdit:be,handleCancelEdit:Re,toggleParent:y,handleSessionSelect:we,handleSessionDoubleClick:Y,handleShareSession:ve,copiedSessionId:F,handleCopyShareUrl:xe,handleCopySessionId:je,handleUnshareSession:oe,openSidebarMenuKey:S,setOpenSidebarMenuKey:N,createFolderAndStartRename:ce,handleDeleteSession:J,handleRestoreSession:K,startSessionWorktreeMenuLoad:T,mobileVariant:k,alwaysShowActions:D,pinnedSessionIds:h,node:n,depth:L,groupDirectory:i,projectId:o,archivedBucket:Q,secondaryMeta:a,renderContext:q,subtreeContainsEditing:$,menuOpenSessionId:le,nodeStructureKey:V,relativeTimeTick:Ce,children:Be}),e[92]=D,e[93]=Q,e[94]=F,e[95]=ce,e[96]=L,e[97]=f,e[98]=v,e[99]=m,e[100]=i,e[101]=p,e[102]=k,e[103]=n,e[104]=g,e[105]=w,e[106]=S,e[107]=h,e[108]=o,e[109]=q,e[110]=a,e[111]=re.handleCancelEdit,e[112]=re.handleCopySessionId,e[113]=re.handleCopyShareUrl,e[114]=re.handleDeleteSession,e[115]=re.handleRestoreSession,e[116]=re.handleSaveEdit,e[117]=re.handleSessionDoubleClick,e[118]=re.handleSessionSelect,e[119]=re.handleShareSession,e[120]=re.handleUnshareSession,e[121]=b,e[122]=x,e[123]=N,e[124]=T,e[125]=$,e[126]=le,e[127]=V,e[128]=Ce,e[129]=Be,e[130]=y,e[131]=ke):ke=e[131];let Ne;e[132]!==z||e[133]!==n.session.id||e[134]!==re.confirmDeleteSession||e[135]!==R||e[136]!==Z||e[137]!==X?(Ne=z?.session.id===n.session.id?s.jsx(l2,{value:z,setValue:R,showDeletionDialog:X,setShowDeletionDialog:Z,onConfirm:re.confirmDeleteSession}):null,e[132]=z,e[133]=n.session.id,e[134]=re.confirmDeleteSession,e[135]=R,e[136]=Z,e[137]=X,e[138]=Ne):Ne=e[138];let Qe;return e[139]!==ke||e[140]!==Ne?(Qe=s.jsxs(s.Fragment,{children:[ke,Ne]}),e[139]=ke,e[140]=Ne,e[141]=Qe):Qe=e[141],Qe}function f2(t){return t.setShowDeletionDialog}function m2(t){return t.showDeletionDialog}function h2(t){return t.toggleFolderCollapse}function p2(t){return t.createFolder}const g2=50,x2=28,Cc=[],b2=t=>{const e=tt.c(6),{nodes:n,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=of(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},Dr=(t,e)=>e?t.sessions.some(n=>Hn(n,e)):!1,y2=(t,e,n)=>t.sessions.some(r=>lf(r,r,e,n,t.directory,t.directory)),w2=(t,e,n)=>{const r=i=>{const o=i.session.id;return e.get(o)!==n.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},S2=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==n.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},v2=(t,e)=>{if(t.group!==e.group||t.groupKey!==e.groupKey||t.projectId!==e.projectId||t.hideGroupLabel!==e.hideGroupLabel||t.compactBodyPadding!==e.compactBodyPadding||t.groupSearchDataByGroup!==e.groupSearchDataByGroup||t.visibleSessionCount!==e.visibleSessionCount||t.sessionBatchSize!==e.sessionBatchSize||t.collapsedGroups!==e.collapsedGroups&&t.collapsedGroups.has(t.groupKey)!==e.collapsedGroups.has(e.groupKey)||t.pinnedSessionIds!==e.pinnedSessionIds&&y2(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&w2(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&S2(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Dr(e.group,t.editingId)||Dr(e.group,e.editingId))||t.editTitle!==e.editTitle&&Dr(e.group,e.editingId)||t.copiedSessionId!==e.copiedSessionId&&(Dr(e.group,t.copiedSessionId)||Dr(e.group,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Hr(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Hr(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||i)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??yt(e.group.directory??null)];if(n.includes(t.folderRename?.scopeKey??null)||n.includes(e.folderRename?.scopeKey??null))return!1}return t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.scrollContainerRef===e.scrollContainerRef&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.isSessionSearchOpen===e.isSessionSearchOpen&&t.sessionSearchQuery===e.sessionSearchQuery&&t.setSessionSearchQuery===e.setSessionSearchQuery&&t.setIsSessionSearchOpen===e.setIsSessionSearchOpen&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.setCopiedSessionId===e.setCopiedSessionId&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename};function j2(t){const{t:e}=At(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,groupSearchDataByGroup:u,visibleSessionCount:d,sessionBatchSize:h,collapsedGroups:m,hideDirectoryControls:p,showMoreGroupSessions:g,resetGroupSessionLimit:w,mobileVariant:v,alwaysShowActions:x,activeProjectId:f,setActiveProjectIdOnly:b,setSessionSwitcherOpen:y,openNewSessionDraft:S,pinnedSessionIds:N,sessionOrderIndex:C,notifyOnSubtasks:j,onToggleCollapsedGroup:A,dragHandleProps:P,compactBodyPadding:I=!1,scrollContainerRef:M,expandedParents:z,editingId:R,openSidebarMenuKey:H,editTitle:F,copiedSessionId:O,folderRename:T,setFolderRenameDraft:k,clearFolderRename:D}=t,L=cs(_e=>_e.toggleFolderCollapse),Q=cs(_e=>_e.renameFolder),q=cs(_e=>_e.deleteFolder),te=cs(_e=>_e.addSessionToFolder),ae=De(_e=>_e.showDeletionDialog),[X,Z]=c.useState(null),se=c.useCallback((_e,Ye)=>{const ft=C.get(_e.session.id),bt=C.get(Ye.session.id);if(ft!==void 0||bt!==void 0){if(ft===void 0)return 1;if(bt===void 0)return-1;if(ft!==bt)return ft-bt}return Vd(_e.session,Ye.session,N,Td)},[N,C]),fe=l?u.get(n):null,B=l?!1:m.has(r),ne=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const _e=yt(n.directory??null),Ye=n.branch?.trim();return _e&&Ye?Ko(_e,Ye):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),ye=Bd(ne),ce=ye?`var(--pr-${ye.visualState})`:void 0,_=Pa(),re=c.useMemo(()=>{const _e=n.folderScopes?.map(Ye=>yt(Ye.directory))??[yt(n.directory??null)];return[...new Set(_e.filter(Ye=>!!Ye))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(_e=>re.length>0?_.subscribeBootstrap(_e):()=>{},[re.length,_]),c.useCallback(()=>re.map(_e=>`${_e}\0${_.getBootstrapState(_e)??""}\0${_.getBootstrapFailure(_e)??""}`).join(""),[re,_]),c.useCallback(()=>"",[]));const me=re.some(_e=>{const Ye=_.getBootstrapState(_e);return Ye==="queued"||Ye==="running"}),de=re.find(_e=>_.getBootstrapState(_e)==="failed")??null,ge=de?_.getBootstrapFailure(de):void 0,Te=ge==="os-permission"&&rm(),[be,Re]=c.useState(!1),we=c.useCallback(()=>{de&&_.requestBootstrap({directory:de,priority:B?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[_,de,n.isMain,B]),Y=c.useCallback(async()=>{if(!(!de||!Te||be)){Re(!0);try{(await om(de)).success&&we()}finally{Re(!1)}}},[Te,de,be,we]),ve=h??(p?10:5),xe=Math.max(ve,d??ve),je=l?fe?.groupMatches===!0:!1,oe=l,J=c.useMemo(()=>[...oe?fe?.filteredNodes??[]:n.sessions].sort(se),[se,n.sessions,fe?.filteredNodes,oe]),K=n.folderScopeKey??yt(n.directory??null),$=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:K?[{scopeKey:K,directory:n.directory??null}]:[],[K,n.directory,n.folderScopes]),le=cs(Jn(c.useCallback(_e=>$.map(({scopeKey:Ye})=>_e.foldersMap[Ye]??Cc),[$]))),V=c.useMemo(()=>$.flatMap(({scopeKey:_e,directory:Ye},ft)=>(le[ft]??Cc).map(mt=>({folder:mt,scopeKey:_e,scopeDirectory:Ye}))),[le,$]),Ce=cs(Jn(c.useCallback(_e=>new Set(le.flatMap(Ye=>Ye.filter(ft=>_e.collapsedFolderIds.has(ft.id)).map(ft=>ft.id))),[le]))),Be=c.useMemo(()=>{const _e=new Map,Ye=ft=>{ft.forEach(bt=>{_e.set(bt.session.id,bt),bt.children.length>0&&Ye(bt.children)})};return Ye(J),_e},[J]),ke=c.useMemo(()=>V.map(({folder:_e,scopeKey:Ye,scopeDirectory:ft})=>{const bt=dj(_e.sessionIds,Be).sort(se);return{folder:_e,scopeKey:Ye,scopeDirectory:ft,nodes:bt}}),[V,Be,se]),Ne=c.useMemo(()=>{const _e=fj(ke.map(({folder:Ye,nodes:ft})=>({id:Ye.id,name:Ye.name,parentId:Ye.parentId,nodeCount:ft.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:l?a:""});return ke.filter(({folder:Ye})=>_e.has(Ye.id))},[ke,n.isArchivedBucket,l,a]),Qe=R,We=H,U=z,he=c.useMemo(()=>new Set(Ne.flatMap(_e=>_e.folder.sessionIds)),[Ne]),Ee=c.useMemo(()=>J.filter(_e=>!he.has(_e.session.id)),[J,he]),Ie=c.useMemo(()=>{const _e=new Map(Ne.map(Ye=>[Ye.folder.id,Ye]));return uj(Ne.map(Ye=>Ye.folder)).map(Ye=>_e.get(Ye.id)).filter(Ye=>!!Ye)},[Ne]),rt=c.useMemo(()=>{const _e=new Map;return Ne.forEach(Ye=>{if(!Ye.folder.parentId)return;const ft=_e.get(Ye.folder.parentId)??[];ft.push(Ye),_e.set(Ye.folder.parentId,ft)}),_e},[Ne]),Ge=c.useMemo(()=>{const _e=new Map(Ne.map(bt=>[bt.folder.id,bt])),Ye=new Map,ft=(bt,mt)=>{const lt=Ye.get(bt);if(lt!==void 0)return lt;if(mt.has(bt))return[];mt.add(bt);const $t=_e.get(bt),Zt=$t?[...$t.nodes]:[];for(const Xt of rt.get(bt)??[])Zt.push(...ft(Xt.folder.id,mt));return Ye.set(bt,Zt),Zt};return Ne.forEach(({folder:bt})=>ft(bt.id,new Set)),Ye},[Ne,rt]),ut="project",ct=c.useMemo(()=>{const _e=new Set;return ea(J,Qe,_e),Ne.forEach(({nodes:Ye})=>{ea(Ye,Qe,_e)}),_e},[J,Ne,Qe]),ue=c.useMemo(()=>{if(!We)return null;const _e=Hr(J,We,ut,!!n.isArchivedBucket);if(_e)return _e;for(const{nodes:Ye}of Ne){const ft=Hr(Ye,We,ut,!!n.isArchivedBucket);if(ft)return ft}return null},[We,J,Ne,n.isArchivedBucket]),G=c.useCallback(_e=>{const Ye=new WeakMap,ft=bt=>{Ye.set(bt,_o(bt));for(const mt of bt.children)ft(mt)};return _e.forEach(ft),Ye},[]),Le=c.useMemo(()=>G(J),[G,J]),Oe=c.useMemo(()=>{const _e=new WeakMap;return Ne.forEach(({nodes:Ye})=>{Ye.forEach(ft=>_e.set(ft,_o(ft)))}),_e},[Ne]),qe=c.useCallback(_e=>Le.get(_e)??Oe.get(_e)??"",[Le,Oe]),Ue=c.useCallback(_e=>({subtreeContainsEditing:ct,menuOpenSessionId:ue,nodeStructureKey:qe(_e)}),[ct,ue,qe]),st=Ee.length,wt=n.isArchivedBucket||l?Ee:Ee.slice(0,xe),Nt=st-wt.length,ie=!n.isArchivedBucket&&!l&&st>ve&&Nt===0,pe=n.isArchivedBucket===!0&&!l&&wt.length>=g2,Ve=n.isArchivedBucket?"archived":"active",ze=pe&&wt.some(_e=>{if(_e.children.length===0)return!1;const Ye=`project:${Ve}:${_e.session.id}`;return U.has(Ye)}),He=c.useRef(null),[ot,at]=c.useState(null),[et,Xe]=c.useState(0),[,dt]=c.useState(0);c.useEffect(()=>{if(!pe)return;const _e=He.current;if(!_e||!globalThis.ResizeObserver)return;const Ye=new ResizeObserver(()=>dt(ft=>ft+1));return Ye.observe(_e),()=>Ye.disconnect()},[pe]),c.useLayoutEffect(()=>{if(!pe){ot!==null&&at(null),et!==0&&Xe(0);return}const _e=He.current;if(!_e)return;let Ye=ot;const ft=M?.current??null;if(ft&&ft.contains(_e)){if(Ye=ft,Ye!==ot){at(Ye);return}}else if(!Ye||!Ye.contains(_e)){let mt=_e.parentElement;for(;mt;){const lt=window.getComputedStyle(mt);if(lt.overflowY==="auto"||lt.overflowY==="scroll"){Ye=mt;break}mt=mt.parentElement}if(Ye!==ot){at(Ye);return}}if(!Ye)return;const bt=_e.getBoundingClientRect().top-Ye.getBoundingClientRect().top+Ye.scrollTop;Xe(mt=>Math.abs(mt-bt)<1?mt:bt)});const Fe=pe&&ot!==null,Se=Hg({count:wt.length,enabled:Fe,getScrollElement:()=>ot,initialOffset:()=>ot?.scrollTop??0,estimateSize:()=>x2,overscan:ze?20:8,scrollMargin:et,getItemKey:_e=>wt[_e]?.session.id??_e}),St=c.useCallback(_e=>{const Ye=[],ft=bt=>{bt.forEach(mt=>{Ye.push(mt.session),mt.children.length>0&&ft(mt.children)})};return ft(_e),Ye},[]),vt=c.useMemo(()=>St(J),[St,J]),Rt=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const _e=new Map,Ye=new Map;for(const{folder:bt}of Ne){if(!bt.parentId)continue;const mt=Ye.get(bt.parentId)??[];mt.push(bt.id),Ye.set(bt.parentId,mt)}const ft=(bt,mt)=>{if(mt.has(bt))return[];mt.add(bt);const lt=Ne.find(({folder:Xt})=>Xt.id===bt),$t=lt?St(lt.nodes):[],Zt=Ye.get(bt)??[];for(const Xt of Zt)$t.push(...ft(Xt,mt));return $t};for(const{folder:bt}of Ne)_e.set(bt.id,ft(bt.id,new Set));return _e},[Ne,St,n.isArchivedBucket]);if(l&&!je&&Ie.length===0&&Ee.length===0)return null;const Ze=!n.isMain&&!!n.branch,it=n.branch&&Oh(n.branch,n.label)?{label:n.branch}:null,gt=B?s.jsx(K0,{nodes:J,includeUnreadSubtasks:j}):null,xt=(_e,Ye)=>{const{folder:ft,scopeKey:bt,scopeDirectory:mt,nodes:lt}=_e,$t=Rt.get(ft.id)??[],Zt=T?.folderId===ft.id&&T?.scopeKey===bt,Xt=l?!1:Ce.has(ft.id),Ns=Jt=>s.jsx(oj,{folderId:ft.id,children:(zs,Js)=>s.jsx(G0,{folder:ft,displayName:Ye,sessions:lt,isCollapsed:Xt,collapsedActivityState:Jt,onToggle:()=>L(ft.id),onRename:rs=>{Q(bt,ft.id,rs)},onDelete:()=>{if(n.isArchivedBucket){gn.requestDelete({sessions:$t,mode:"session"});return}if(!ae){q(bt,ft.id);return}const rs=Ne.filter(({folder:Rs})=>Rs.parentId===ft.id).length,Vs=lt.length;Z({scopeKey:bt,folderId:ft.id,folderName:ft.name,subFolderCount:rs,sessionCount:Vs})},groupDirectory:mt??n.directory,projectId:i,mobileVariant:v,alwaysShowActions:x,isRenaming:Zt,renameDraft:Zt?T?.draft:void 0,onRenameDraftChange:k,onRenameSave:()=>{const rs=T?.draft.trim()??"";rs&&Q(bt,ft.id,rs),D()},onRenameCancel:D,droppableRef:zs,isDropTarget:Js,depth:0,onNewSession:()=>{i&&i!==f&&b(i),v&&y(!1),S({selectedProjectId:i,directoryOverride:mt??n.directory,targetFolderId:ft.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:lt.map(rs=>s.jsx(Bo,{node:rs,pinnedSessionIds:N,expandedParents:z,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:j,editingId:R,editTitle:F,copiedSessionId:O,openSidebarMenuKey:H,mobileVariant:v,alwaysShowActions:x,groupDirectory:mt??n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ct,menuOpenSessionId:ue,nodeStructureKey:qe(rs),childRenderExtrasFor:Ue},setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},rs.session.id))})},ft.id);return Xt?s.jsx(b2,{nodes:Ge.get(ft.id)??lt,includeUnreadSubtasks:j,children:Ns},ft.id):Ns(null)},Et=()=>{const _e=new Map;for(const mt of Ne){const lt=mt.folder.parentId;if(!lt)continue;const $t=_e.get(lt);$t?$t.push(mt):_e.set(lt,[mt])}const Ye=[],ft=new Set,bt=(mt,lt)=>{if(ft.has(mt.folder.id))return;ft.add(mt.folder.id);const $t=lt?`${lt} / ${mt.folder.name}`:mt.folder.name;Ye.push(xt(mt,$t)),!(!l&&Ce.has(mt.folder.id))&&(_e.get(mt.folder.id)??[]).forEach(Xt=>bt(Xt,$t))};return Ie.forEach(mt=>bt(mt,"")),Ye},kt=!!(!n.isMain&&n.worktree),Tt=n.worktree?.worktreeStatus==="missing"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.worktreeMissing"),"aria-label":e("sessions.sidebar.group.worktreeMissing"),children:s.jsx(E,{name:"alert",className:"h-3 w-3"})}):null,Ot=x?kt?"pr-14":"pr-7":kt?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",Vt=de?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(ge==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":"sessions.sidebar.group.empty.loadFailed"),Te?s.jsx(pt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:be,onClick:()=>{Y()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(pt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:we,children:e("sessions.sidebar.group.empty.retry")})]}):null,Yt=_e=>s.jsx(Bo,{node:_e,pinnedSessionIds:N,expandedParents:z,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:j,editingId:R,editTitle:F,copiedSessionId:O,openSidebarMenuKey:H,mobileVariant:v,alwaysShowActions:x,groupDirectory:n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ct,menuOpenSessionId:ue,nodeStructureKey:qe(_e),childRenderExtrasFor:Ue},setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},_e.session.id),Ht=s.jsxs(ij,{scopeKey:$[0]?.scopeKey??K,hasFolders:Ne.length>0,onSessionDroppedOnFolder:(_e,Ye)=>{const ft=Ne.find(({folder:mt})=>mt.id===Ye);if(!ft)return;const bt=cs.getState();for(const{scopeKey:mt}of $)mt!==ft.scopeKey&&bt.getSessionFolderId(mt,_e)&&bt.removeSessionFromFolder(mt,_e);te(ft.scopeKey,Ye,_e)},children:[Et(),pe?s.jsx("div",{ref:He,children:Fe?s.jsx("div",{style:{height:Se.getTotalSize(),position:"relative"},children:Se.getVirtualItems().map(_e=>{const Ye=wt[_e.index];return Ye?s.jsx("div",{"data-index":_e.index,ref:Se.measureElement,className:"[&_[data-session-row]]:my-px",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${_e.start-et}px)`},children:Yt(Ye)},Ye.session.id):null})}):wt.map(Yt)}):wt.map(Yt),st===0&&Ne.length===0?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):me?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Vt||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,st>0&&Vt?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:Vt}):null,Nt>0?s.jsx("button",{type:"button",onClick:()=>g(r,wt.length,h??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,ie?s.jsx("button",{type:"button",onClick:()=>w(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),Lt="pb-2",zt=s.jsx(d2,{value:X,setValue:Z,onConfirm:()=>{const _e=X;_e&&(q(_e.scopeKey,_e.folderId),Z(null))}});return o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Pe("oc-group-body",Lt),children:Ht})}),zt]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Pe("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>A(r),role:"button",tabIndex:0,onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),A(r))},"aria-label":B?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!B,children:[s.jsxs("div",{ref:P?.setActivatorNodeRef,className:Pe("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",Ot),...P?.listeners??{},children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(E,{name:"archive",className:Pe("h-3.5 w-3.5 shrink-0 text-muted-foreground",x?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Pe("text-muted-foreground h-3.5 w-3.5 items-center justify-center",x?"inline-flex":"hidden group-hover/gh:inline-flex"),children:B?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:po(n.label,a)}),Tt,gt]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(E,{name:"git-branch",className:Pe("h-3.5 w-3.5 shrink-0",!ce&&"text-muted-foreground",x?"hidden":"group-hover/gh:hidden"),style:ce?{color:ce}:void 0}),s.jsx("span",{className:Pe("text-muted-foreground h-3.5 w-3.5 items-center justify-center",x?"inline-flex":"hidden group-hover/gh:inline-flex"),children:B?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:po(n.label,a)}),Tt,gt,ye?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:ce?{color:ce}:void 0,children:["#",ye.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:po(n.label,a)}),gt]})}),Ze&&it?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(E,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:it.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(Kr,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&vt.length>0?s.jsx("div",{className:Pe("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:_e=>{_e.stopPropagation(),gn.requestDelete({sessions:vt,mode:"session"})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:Pe("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:_e=>{_e.stopPropagation(),gn.requestDelete({sessions:vt,mode:"worktree",worktree:n.worktree})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:Pe("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:_e=>{_e.stopPropagation(),i&&i!==f&&b(i),v&&y(!1),S({selectedProjectId:i,directoryOverride:n.directory})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(E,{name:"add",className:"h-4 w-4"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),B?null:s.jsx("div",{className:Pe("oc-group-body",Lt),children:Ht})]}),zt]})}const vo=c.memo(j2,v2),k2=(t,e,n)=>e?t.filter(r=>r.project.id===n):t,C2=t=>t?"top-content":"empty-state",N2=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return[n,...r?[r]:[]].map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:o.id===n.id}))},A2=48,D2=32,P2=24,gi=(t,e)=>Da(t.label?.trim()||Fn(t.normalizedPath,e)||t.normalizedPath);function I2(t){const e=tt.c(42);Gs("ui.sidebar_projects_list.render");const{t:n}=At(),{model:r,view:i,actions:o}=t,l=r.state.editingId!==null,a=i.isDesktopShellRuntime&&i.stickyZoneHeaders&&!r.singleProjectMode;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{distance:8}},e[0]=u):u=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={coordinateGetter:Og},e[1]=d):d=e[1];const h=zr(Mn(Oi,u),Mn(Eg,d));let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m={activationConstraint:{distance:8}},e[2]=m):m=e[2];const p=zr(Mn(Oi,m)),g=c.useRef(null),w=c.useRef(0);let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=fe=>{const ne=fe.scrollTop>1?Math.min(D2+fe.scrollTop,A2):0;w.current=ne;const ye=fe.closest(".oc-sticky-fade-root");ye?.style.setProperty("--scroll-shadow-top-size",`${ne}px`),ye?.style.setProperty("--scroll-shadow-top-clear-size",`${Math.min(Math.max(ne-8,0),P2)}px`)},e[3]=v):v=e[3];const x=v;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=fe=>{fe.target.closest("[data-overlay-scrollbar-thumb], [data-sidebar-sticky-header]")||fe.clientY-fe.currentTarget.getBoundingClientRect().top>=w.current||(fe.preventDefault(),fe.stopPropagation())},e[4]=f):f=e[4];const b=f,y=k2(r.sectionsForRender,r.singleProjectMode,r.singleProjectId),S=r.projectSections.length>0&&y.length>0;let N,C;e[5]!==a||e[6]!==S?(N=()=>{a&&S&&g.current&&x(g.current)},C=[a,S,x],e[5]=a,e[6]=S,e[7]=N,e[8]=C):(N=e[7],C=e[8]),c.useLayoutEffect(N,C);let j=null;for(const fe of r.projectSections)r.stuckProjectHeaders.has(fe.project.id)&&(j=fe.project);const A=j??(r.hasSharedSessions?null:y[0]?.project??null),P=A?gi(A,i.homeDirectory):null;let I;if(e[9]!==r.projectSections||e[10]!==i.homeDirectory){let fe;e[12]!==i.homeDirectory?(fe=B=>({id:B.project.id,projectLabel:gi(B.project,i.homeDirectory),projectDescription:Wr(B.project.normalizedPath,i.homeDirectory),projectIcon:B.project.icon,projectColor:B.project.color,projectIconImage:B.project.iconImage,projectIconBackground:B.project.iconBackground}),e[12]=i.homeDirectory,e[13]=fe):fe=e[13],I=r.projectSections.map(fe),e[9]=r.projectSections,e[10]=i.homeDirectory,e[11]=I}else I=e[11];const M=I;if(r.projectSections.length===0){let fe;return e[14]!==r.emptyState||e[15]!==r.topContent?(fe=s.jsxs(ln,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"space-y-1 pb-1 pl-2.5 pr-2",children:[r.topContent,r.emptyState]}),e[14]=r.emptyState,e[15]=r.topContent,e[16]=fe):fe=e[16],fe}if(r.sectionsForRender.length===0){const B=C2(r.topContentHasSearchMatches===!0)==="top-content"?r.topContent:r.searchEmptyState;let ne;return e[17]!==B?(ne=s.jsx(ln,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"space-y-1 pb-1 pl-2.5 pr-2",children:B}),e[17]=B,e[18]=ne):ne=e[18],ne}const z="oc-sticky-fade-root relative flex min-h-0 flex-1";let R;e[19]!==a?(R=a?{"--scroll-shadow-top-size":"0px"}:void 0,e[19]=a,e[20]=R):R=e[20];const H=a?b:void 0,F=a?b:void 0,O=a?b:void 0,T=ln,k=!0,D=!a,L=96,Q="flex-1 min-h-0",q="oc-sidebar-scroller oc-sticky-fade-scroller space-y-1.5 pb-1 pl-2.5 pr-2 [overflow-anchor:none]";let te;e[21]!==a?(te=a?fe=>x(fe.currentTarget):void 0,e[21]=a,e[22]=te):te=e[22];const ae=i.showOnlyMainWorkspace?s.jsx("div",{className:"space-y-[0.6rem] py-1",children:(()=>{const fe=y.find(ne=>ne.project.id===r.activeProjectId)??y[0];if(!fe)return i.hasSessionSearchQuery?r.searchEmptyState:r.emptyState;const B=N2(fe);return B.length?B.map(ne=>{const{group:ye,groupKey:ce,projectId:_,hideGroupLabel:re}=ne;return s.jsx(c.Fragment,{children:s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:ye,groupKey:ce,projectId:_,hideGroupLabel:re,visibleSessionCount:r.state.visibleSessionCountByGroup.get(ce),compactBodyPadding:!0,scrollContainerRef:g})},ce)}):s.jsx("div",{className:"py-1 text-left typography-micro text-muted-foreground",children:n("sessions.sidebar.empty.noSessions.title")})})()}):s.jsxs(Vr,{sensors:h,collisionDetection:Ur,onDragEnd:fe=>{if(l||i.projectSortOrder!=="manual")return;const{active:B,over:ne}=fe;if(!ne||B.id===ne.id)return;const ye=r.sectionsForRender.findIndex(_=>_.project.id===B.id),ce=r.sectionsForRender.findIndex(_=>_.project.id===ne.id);ye===-1||ce===-1||ye===ce||o.reorderProjects(ye,ce)},children:[s.jsx(Io,{items:y.map(M2),strategy:_i,children:y.map(fe=>{const B=fe.project,ne=B.id,ye=gi(B,i.homeDirectory),ce=Wr(B.normalizedPath,i.homeDirectory),_=r.singleProjectMode?!1:i.collapsedProjects.has(ne),re=r.projectRepoStatus.get(ne);return s.jsx(_0,{id:ne,disabled:r.singleProjectMode||i.projectSortOrder!=="manual",projectLabel:ye,projectDescription:ce,projectDirectory:B.normalizedPath,projectIcon:B.icon,projectColor:B.color,projectIconImage:B.iconImage,projectIconBackground:B.iconBackground,isCollapsed:_,isRepo:!!re,isDesktopShell:i.isDesktopShellRuntime,hideDirectoryControls:i.hideDirectoryControls,mobileVariant:i.mobileVariant,alwaysShowActions:i.alwaysShowActions,statusIndicator:_?o.renderProjectStatusIndicator?.(ne,fe.groups):null,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,projectPickerOptions:r.singleProjectMode?M:void 0,onProjectSelect:r.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{r.singleProjectMode||o.toggleProject(ne)},onNewSession:()=>{ne!==r.activeProjectId&&o.setActiveProjectIdOnly(ne),i.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:ne,directoryOverride:B.normalizedPath})},onNewWorktreeSession:()=>{ne!==r.activeProjectId&&o.setActiveProjectIdOnly(ne),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(ne),onRenameStart:()=>o.openProjectEditDialog(ne),onClose:()=>o.removeProject(ne),sentinelRef:me=>{r.projectHeaderSentinelRefs.current.set(ne,me)},showCreateButtons:!0,children:_?null:s.jsx("div",{className:"space-y-0 pt-0.5 pb-0.5",children:(()=>{const me=fe.groups,de=me.find(E2)??null,ge=de?me.filter(Te=>Te.id!==de.id):me;return s.jsxs(Vr,{sensors:p,collisionDetection:Ur,onDragEnd:Te=>{if(l)return;const{active:be,over:Re}=Te;if(!Re||be.id===Re.id)return;const we=ge.findIndex(je=>je.id===be.id),Y=ge.findIndex(je=>je.id===Re.id);if(we===-1||Y===-1||we===Y)return;const ve=au(ge,we,Y).map(R2),xe=de?[de.id,...ve]:ve;o.setGroupOrderByProject(je=>{const oe=new Map(je);return oe.set(ne,xe),oe})},children:[de?s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:de,groupKey:`${ne}:${de.id}`,projectId:ne,hideGroupLabel:!0,visibleSessionCount:r.state.visibleSessionCountByGroup.get(`${ne}:${de.id}`),scrollContainerRef:g}):null,s.jsx(Io,{items:ge.map(T2),strategy:_i,children:ge.map(Te=>{const be=`${ne}:${Te.id}`;return s.jsx(L0,{id:Te.id,disabled:l,children:Re=>s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:Te,groupKey:be,projectId:ne,visibleSessionCount:r.state.visibleSessionCountByGroup.get(be),dragHandleProps:Re,scrollContainerRef:g})},Te.id)})}),s.jsx(Fi,{dropAnimation:null})]})})()})},ne)})}),s.jsx(Fi,{dropAnimation:null})]});let X;e[23]!==T||e[24]!==r.topContent||e[25]!==D||e[26]!==te||e[27]!==ae?(X=s.jsxs(T,{ref:g,useScrollShadow:k,hideTopScrollShadow:D,scrollShadowSize:L,outerClassName:Q,className:q,onScroll:te,children:[r.topContent,ae]}),e[23]=T,e[24]=r.topContent,e[25]=D,e[26]=te,e[27]=ae,e[28]=X):X=e[28];let Z;e[29]!==a||e[30]!==A||e[31]!==P||e[32]!==r.hasSharedSessions||e[33]!==n?(Z=a&&(A||r.hasSharedSessions)?s.jsx("div",{className:"oc-sticky-fade-overlay pointer-events-none absolute inset-x-0 top-0 z-30 flex items-center gap-1.5 py-1 pl-4 pr-5","aria-hidden":"true",children:A&&P?s.jsxs(s.Fragment,{children:[s.jsx(wo,{id:A.id,projectLabel:P,projectIcon:A.icon,projectColor:A.color,projectIconImage:A.iconImage,projectIconBackground:A.iconBackground}),s.jsx(Kr,{directory:A.normalizedPath,className:"ml-auto"})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"history",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:n("sessions.sidebar.activity.recentTitle")})]})}):null,e[29]=a,e[30]=A,e[31]=P,e[32]=r.hasSharedSessions,e[33]=n,e[34]=Z):Z=e[34];let se;return e[35]!==H||e[36]!==F||e[37]!==O||e[38]!==X||e[39]!==Z||e[40]!==R?(se=s.jsxs("div",{className:z,style:R,onPointerDownCapture:H,onClickCapture:F,onContextMenuCapture:O,children:[X,Z]}),e[35]=H,e[36]=F,e[37]=O,e[38]=X,e[39]=Z,e[40]=R,e[41]=se):se=e[41],se}function T2(t){return t.id}function R2(t){return t.id}function E2(t){return t.isMain}function M2(t){return t.project.id}const O2=c.memo(I2),ia=new Map,Nc=(t,e)=>{for(const n of t){const r=yt(n??null);r&&!ia.has(r)&&ia.set(r,e)}},Ac=t=>{const e=yt(t??null);return e?ia.get(e)??0:0},Pr=t=>!!t.time?.archived,F2=t=>{const{t:e}=At(),n=c.useRef(t.gitBranches);n.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const u=yt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${u}`.toLowerCase()},[e]),o=c.useCallback((a,u)=>{if(!u)return a;const d=u.trim().toLowerCase(),h=d.startsWith("ses_");return a.flatMap(m=>{if(h&&Pr(m.session))return[];if(h?m.session.id.toLowerCase()===d:Ao([i(m.session)],u))return[m];const g=o(m.children,u);return g.length===0?[]:[{...m,children:g}]})},[i]),l=c.useCallback((a,u,d,h,m)=>{const p=yt(u??null),g=Od(a),w=new Map(g.map(O=>[O.id,O])),v=new Map;g.forEach(O=>{const T=O.parentID;if(!T)return;const k=w.get(T);if(!k||Pr(k)!==Pr(O))return;const D=v.get(T)??[];D.push(O),v.set(T,D)});const x=new Map;d.forEach(O=>{if(O.path){const T=yt(O.path)??O.path;x.set(T,O)}});const f=O=>{const T=yt(O.directory??null),k=t.worktreeMetadata.get(O.id)??null;if(k)return k;if(T){const D=x.get(T)??null;if(D&&T!==p)return D}return null},b=new Set,y=O=>{b.add(O.id);const T=v.get(O.id)??[],k=[];for(const D of T)b.has(D.id)||k.push(y(D));return{session:O,children:k,worktree:f(O)}},S=g.filter(O=>{const T=O.parentID;if(!T)return!0;const k=w.get(T);return k?Pr(k)!==Pr(O):!0}),N=[],C=O=>{b.has(O.id)||N.push(y(O))};S.forEach(C),g.forEach(C);const j=new Map,A="__archived__",P=O=>{if(O.time?.archived)return A;if(t.isVSCode)return p??"__project_root__";const k=yt(t.worktreeMetadata.get(O.id)?.path??null)??$s(O);return k?k!==p&&x.has(k)?k:k===p?p??"__project_root__":A:A};N.forEach(O=>{const T=P(O.session);j.has(T)||j.set(T,[]),j.get(T)?.push(O)});const I=p??"__project_root__",M=[{id:"root",label:m&&h&&h!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:h}):e("sessions.sidebar.grouping.projectRoot"),branch:h??null,description:p?Wr(p,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:p,folderScopeKey:p,sessions:j.get(I)??[]}],z=new Map;d.forEach(O=>{const T=yt(O.path)??O.path,k=j.get(T)??[],D=k.length>0,L=k.reduce((Q,q)=>{const te=Fh(q.session,t.sessionOrderRanks);return Number.isFinite(te)?Math.max(Q,te):Q},0);z.set(T,{hasActiveSession:D,lastUpdatedAt:L})});const R=[...d].sort((O,T)=>{const k=yt(O.path)??O.path,D=yt(T.path)??T.path,L=z.get(k)??{hasActiveSession:!1,lastUpdatedAt:0},Q=z.get(D)??{hasActiveSession:!1,lastUpdatedAt:0};if(L.hasActiveSession!==Q.hasActiveSession)return L.hasActiveSession?-1:1;if(L.hasActiveSession&&Q.hasActiveSession)return Q.lastUpdatedAt-L.lastUpdatedAt;const q=Ac(O.path),te=Ac(T.path);if(q!==te)return te-q;const ae=(O.label||O.branch||O.name||O.path||"").toLowerCase(),X=(T.label||T.branch||T.name||T.path||"").toLowerCase();return ae.localeCompare(X)});(t.isVSCode?[]:R).forEach(O=>{const T=yt(O.path)??O.path,k=n.current.get(T)?.trim()||null,D=O.branch?.trim()||null,Q=!!(k&&D&&O.label&&il(O.label)===il(D))?k:O.label||O.name||Fn(T,t.homeDirectory)||T;M.push({id:`worktree:${T}`,label:Q,branch:k||D,description:Wr(T,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:O,directory:T,folderScopeKey:T,sessions:j.get(T)??[]})});const F=j.get(A)??[];return F.length>0&&M.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&p?Md(p):null,sessions:F}),M},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},_2=t=>{const e=tt.c(10),{enabled:n,isDesktopShellRuntime:r,projectSections:i,projectHeaderSentinelRefs:o}=t,l=n===void 0?!0:n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,e[0]=a):a=e[0];const[u,d]=c.useState(a);let h;e[1]!==l||e[2]!==r||e[3]!==o?(h=()=>{if(!l||!r){d(B2);return}const g=Array.from(o.current.values()).find(L2)?.closest(".oc-sidebar-scroller")??null;if(!g)return;const w=new IntersectionObserver(v=>{d(x=>{const f=new Set(x);let b=!1;for(const y of v){const S=y.target.dataset.projectId;if(!S)continue;const N=y.rootBounds?.top??g.getBoundingClientRect().top,C=!y.isIntersecting&&y.boundingClientRect.top<N;f.has(S)!==C&&(b=!0,C?f.add(S):f.delete(S))}return b?f:x})},{root:g,threshold:0});return o.current.forEach(v=>{v&&w.observe(v)}),()=>w.disconnect()},e[1]=l,e[2]=r,e[3]=o,e[4]=h):h=e[4];let m;return e[5]!==l||e[6]!==r||e[7]!==o||e[8]!==i?(m=[l,r,o,i],e[5]=l,e[6]=r,e[7]=o,e[8]=i,e[9]=m):m=e[9],c.useEffect(h,m),u};function B2(t){return t.size===0?t:new Set}function L2(t){return t!==null}const $2=t=>{const e=tt.c(51),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:u,canRemoveFromFolder:d,onRestore:h,onDelete:m,onDone:p}=t,{t:g}=At(),w=!!r&&!o;let v;e[0]!==o||e[1]!==g?(v=g(o?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=o,e[1]=g,e[2]=v):v=e[2];const x=v;let f;e[3]!==n||e[4]!==g?(f=g("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=g,e[5]=f):f=e[5];let b;e[6]!==f?(b=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:f}),e[6]=f,e[7]=b):b=e[7];let y;e[8]!==w||e[9]!==d||e[10]!==a||e[11]!==l||e[12]!==u||e[13]!==i||e[14]!==g?(y=w?s.jsxs(Xs,{children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(Qs,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":g("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(E,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:g("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Ys,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Ut,{disabled:!0,className:"text-muted-foreground",children:g("sessions.sidebar.folders.none")}):i.map(k=>s.jsx(Ut,{onClick:()=>l(k.id),children:s.jsx("span",{className:"flex-1 truncate",children:k.name})},k.id)),s.jsx(Os,{}),s.jsxs(Ut,{onClick:a,children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.newFolderEllipsis")]}),d?s.jsxs(Ut,{onClick:u,className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=w,e[9]=d,e[10]=a,e[11]=l,e[12]=u,e[13]=i,e[14]=g,e[15]=y):y=e[15];let S;e[16]!==o||e[17]!==h||e[18]!==g?(S=o?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":g("sessions.sidebar.bulkActions.restore"),children:s.jsx(E,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:g("sessions.sidebar.bulkActions.restore")})})]}):null,e[16]=o,e[17]=h,e[18]=g,e[19]=S):S=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=Pe("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50"),e[20]=N):N=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(E,{name:"delete-bin",className:"h-4 w-4"}),e[21]=C):C=e[21];let j;e[22]!==x||e[23]!==m?(j=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,className:N,"aria-label":x,children:C})}),e[22]=x,e[23]=m,e[24]=j):j=e[24];let A;e[25]!==x?(A=s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:x})}),e[25]=x,e[26]=A):A=e[26];let P;e[27]!==j||e[28]!==A?(P=s.jsxs(Dt,{children:[j,A]}),e[27]=j,e[28]=A,e[29]=P):P=e[29];let I;e[30]!==g?(I=g("sessions.sidebar.header.actions.exitSelection"),e[30]=g,e[31]=I):I=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(E,{name:"close",className:"h-4 w-4"}),e[32]=M):M=e[32];let z;e[33]!==p||e[34]!==I?(z=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:p,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":I,children:M})}),e[33]=p,e[34]=I,e[35]=z):z=e[35];let R;e[36]!==g?(R=g("sessions.sidebar.header.actions.exitSelection"),e[36]=g,e[37]=R):R=e[37];let H;e[38]!==R?(H=s.jsx(It,{side:"top",sideOffset:4,children:s.jsx("p",{children:R})}),e[38]=R,e[39]=H):H=e[39];let F;e[40]!==z||e[41]!==H?(F=s.jsxs(Dt,{children:[z,H]}),e[40]=z,e[41]=H,e[42]=F):F=e[42];let O;e[43]!==P||e[44]!==F||e[45]!==y||e[46]!==S?(O=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[y,S,P,F]}),e[43]=P,e[44]=F,e[45]=y,e[46]=S,e[47]=O):O=e[47];let T;return e[48]!==O||e[49]!==b?(T=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[b,O]}),e[48]=O,e[49]=b,e[50]=T):T=e[50],T},W2=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},z2=t=>{const{t:e}=At(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,getFolderScopesForProject:o,addSessionsToFolder:l,removeSessionsFromFolders:a,createFolderAndStartRename:u,archiveSessions:d,unarchiveSessions:h,deleteSessions:m,setBulkDeleteConfirm:p}=t,g=hs(k=>k.enabled),w=hs(k=>k.selectedIds.size),v=w>0,x=hs(k=>k.selectedIds),f=hs(k=>k.scopeKey),b=c.useCallback(()=>{hs.getState().toggleMode()},[]),y=c.useCallback(()=>{hs.getState().disable()},[]),S=c.useMemo(()=>{if(!v||typeof document>"u")return!1;let k=!1,D=!1;for(const L of x){const Q=document.querySelectorAll(`[data-session-row="${CSS.escape(L)}"]`);for(const q of Q)q.getAttribute("data-session-archived")==="1"?D=!0:k=!0}return D&&!k},[v,x]),N=c.useMemo(()=>{if(f)return f;if(!v||typeof document>"u")return null;for(const k of x){const L=document.querySelector(`[data-session-row="${CSS.escape(k)}"]`)?.getAttribute("data-session-scope");if(L&&L.length>0)return L}return null},[v,x,f]),C=c.useMemo(()=>W2(N,o),[N,o]),j=c.useMemo(()=>C.flatMap(k=>i[k]??[]),[i,C]),A=c.useCallback(k=>{for(const D of C)if((i[D]??[]).some(L=>L.id===k))return D;return null},[i,C]),P=c.useMemo(()=>{if(!v)return!1;for(const k of C)for(const D of i[k]??[])for(const L of D.sessionIds)if(x.has(L))return!0;return!1},[i,C,v,x]),I=c.useCallback((k,D)=>{const L=Array.from(x);for(const Q of C)Q!==k&&a(Q,L);l(k,D,L)},[l,a,x,C]),M=c.useCallback(k=>{if(!v)return;const D=A(k);D&&I(D,k)},[v,I,A]),z=c.useCallback(()=>{const k=C[0];if(!k||!v)return;const D=u(k);D&&I(k,D.id)},[u,v,I,C]),R=c.useCallback(()=>{if(!v)return;const k=Array.from(x);for(const D of C)a(D,k)},[a,x,C,v]),H=c.useCallback(async()=>{const k=Array.from(x);if(k.length!==0){if(S){const{deletedIds:D,failedIds:L}=await m(k);D.length>0&&Me.success(D.length===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:D.length}):e("sessions.sidebar.bulkActions.deletedPlural",{count:D.length})),L.length>0&&Me.error(L.length===1?e("sessions.sidebar.bulkActions.failedDeleteSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedDeletePlural",{count:L.length}))}else{const{archivedIds:D,failedIds:L}=await d(k);D.length>0&&Me.success(D.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:D.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:D.length})),L.length>0&&Me.error(L.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:L.length}))}hs.getState().clear()}},[d,S,m,x,e]),F=c.useCallback(()=>{if(!v)return;const k=x.size;if(!r){H();return}p({sessionCount:k,archivedBucket:S})},[S,H,x,r,p,v]),O=c.useCallback(async()=>{if(!v||!S)return;const k=Array.from(x),{restoredIds:D,failedIds:L}=await h(k);D.length>0&&Me.success(D.length===1?e("sessions.sidebar.bulkActions.restoredSingle",{count:D.length}):e("sessions.sidebar.bulkActions.restoredPlural",{count:D.length})),L.length>0&&Me.error(L.length===1?e("sessions.sidebar.bulkActions.failedRestoreSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedRestorePlural",{count:L.length})),hs.getState().clear()},[S,v,x,e,h]),T=c.useCallback(async()=>{p(null),await H()},[H]);return c.useEffect(()=>{if(!g)return;const k=typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""),D=L=>{if(n)return;const Q=L.target;if(Q&&(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.isContentEditable))return;const q=k?L.metaKey:L.ctrlKey;if(L.key==="Escape"){L.preventDefault(),hs.getState().disable();return}if(q&&L.key==="Backspace"){L.preventDefault(),F();return}if(q&&(L.key==="a"||L.key==="A")){const te=typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[];if(te.length===0)return;L.preventDefault();const X=hs.getState().scopeKey??te[0]?.getAttribute("data-session-scope")??null,Z=fe=>X?fe.getAttribute("data-session-scope")===X:!0,se=te.filter(Z).map(fe=>fe.getAttribute("data-session-row")).filter(fe=>typeof fe=="string"&&fe.length>0);if(se.length===0)return;hs.getState().replaceAll(se,X||null)}};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[F,n,g]),{selectionModeEnabled:g,hasSelection:v,selectedIdsSize:w,bulkScopeIsArchived:S,derivedSelectionScope:N,bulkScopeFolders:j,bulkCanRemoveFromFolder:P,handleToggleSelectionMode:b,handleExitSelectionMode:y,handleBulkMoveToFolder:M,handleBulkCreateFolderAndMove:z,handleBulkRemoveFromFolder:R,handleBulkDelete:F,handleBulkRestore:O,confirmBulkDelete:T}};function V2(t){const e=tt.c(36),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=De(J2),u=De(X2),d=cs(Y2),h=cs(Q2),m=cs(q2),p=cs(G2),g=Je(H2),w=Je(K2),v=Je(U2);let x;e[0]!==h||e[1]!==i?(x=C=>{const j=h(C,"New folder");return i(C,j),j},e[0]=h,e[1]=i,e[2]=x):x=e[2];let f;e[3]!==m||e[4]!==g||e[5]!==v||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p||e[10]!==a||e[11]!==x||e[12]!==w?(f={isInlineEditing:r,showDeletionDialog:a,foldersMap:d,getFolderScopesForProject:n,addSessionsToFolder:m,removeSessionsFromFolders:p,createFolderAndStartRename:x,archiveSessions:g,unarchiveSessions:w,deleteSessions:v,setBulkDeleteConfirm:l},e[3]=m,e[4]=g,e[5]=v,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=a,e[11]=x,e[12]=w,e[13]=f):f=e[13];const b=z2(f);let y;e[14]!==b.bulkCanRemoveFromFolder||e[15]!==b.bulkScopeFolders||e[16]!==b.bulkScopeIsArchived||e[17]!==b.derivedSelectionScope||e[18]!==b.handleBulkCreateFolderAndMove||e[19]!==b.handleBulkDelete||e[20]!==b.handleBulkMoveToFolder||e[21]!==b.handleBulkRemoveFromFolder||e[22]!==b.handleBulkRestore||e[23]!==b.handleExitSelectionMode||e[24]!==b.hasSelection||e[25]!==b.selectedIdsSize||e[26]!==b.selectionModeEnabled?(y=b.selectionModeEnabled&&b.hasSelection?s.jsx($2,{selectedCount:b.selectedIdsSize,scopeKey:b.derivedSelectionScope,scopeFolders:b.bulkScopeFolders,archivedBucket:b.bulkScopeIsArchived,onMoveToFolder:b.handleBulkMoveToFolder,onCreateFolderAndMove:b.handleBulkCreateFolderAndMove,onRemoveFromFolder:b.handleBulkRemoveFromFolder,canRemoveFromFolder:b.bulkCanRemoveFromFolder,onRestore:b.handleBulkRestore,onDelete:b.handleBulkDelete,onDone:b.handleExitSelectionMode}):null,e[14]=b.bulkCanRemoveFromFolder,e[15]=b.bulkScopeFolders,e[16]=b.bulkScopeIsArchived,e[17]=b.derivedSelectionScope,e[18]=b.handleBulkCreateFolderAndMove,e[19]=b.handleBulkDelete,e[20]=b.handleBulkMoveToFolder,e[21]=b.handleBulkRemoveFromFolder,e[22]=b.handleBulkRestore,e[23]=b.handleExitSelectionMode,e[24]=b.hasSelection,e[25]=b.selectedIdsSize,e[26]=b.selectionModeEnabled,e[27]=y):y=e[27];let S;e[28]!==b.confirmBulkDelete||e[29]!==o||e[30]!==u||e[31]!==a?(S=s.jsx(c2,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:u,onConfirm:b.confirmBulkDelete}),e[28]=b.confirmBulkDelete,e[29]=o,e[30]=u,e[31]=a,e[32]=S):S=e[32];let N;return e[33]!==y||e[34]!==S?(N=s.jsxs(s.Fragment,{children:[y,S]}),e[33]=y,e[34]=S,e[35]=N):N=e[35],N}function U2(t){return t.deleteSessions}function K2(t){return t.unarchiveSessions}function H2(t){return t.archiveSessions}function G2(t){return t.removeSessionsFromFolders}function q2(t){return t.addSessionsToFolder}function Q2(t){return t.createFolder}function Y2(t){return t.foldersMap}function X2(t){return t.setShowDeletionDialog}function J2(t){return t.showDeletionDialog}const Dc=7,Z2=6e4,ek=()=>{const t=tt.c(2),[e,n]=c.useState(0);let r,i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const o=setInterval(()=>{n(sk)},Z2);return()=>clearInterval(o)},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),c.useEffect(r,i),e};function tk(t){const{sections:e,variant:n="section",initialVisibleCount:r=Dc,batchSize:i=Dc}=t,{t:o}=At(),{pinnedSessionIds:l}=t,a=ls(y=>y.stickyZoneHeaders),[u,d]=c.useState(new Set),[h,m]=c.useState(new Map),p=n==="flat",g=c.useCallback(y=>{m(S=>{if(!S.has(y))return S;const N=new Map(S);return N.delete(y),N})},[]),w=c.useCallback(y=>{g(y),d(S=>{const N=new Set(S);return N.has(y)?N.delete(y):N.add(y),N})},[g]),v=c.useCallback((y,S,N)=>{m(C=>{const j=Math.min(N,S+i),A=new Map(C);return A.set(y,j),A})},[i]),x=ek(),f=c.useCallback(y=>{const S=new Set;ea(y,t.editingId,S);const N=Hr(y,t.openSidebarMenuKey,"recent",!1),C=new WeakMap,j=P=>{C.set(P,_o(P)),P.children.forEach(j)};y.forEach(j);const A=P=>({subtreeContainsEditing:S,menuOpenSessionId:N,nodeStructureKey:C.get(P)??"",relativeTimeTick:x,childRenderExtrasFor:A});return P=>({subtreeContainsEditing:S,menuOpenSessionId:N,nodeStructureKey:C.get(P)??"",relativeTimeTick:x,childRenderExtrasFor:A})},[t.editingId,t.openSidebarMenuKey,x]),b=e.filter(y=>y.items.length>0||y.key==="chats");return b.length===0?null:s.jsx("div",{className:Pe(p?"space-y-0.5 pb-2":"space-y-2 pb-2"),children:b.map(y=>{const S=u.has(y.key),N=Math.max(r,h.get(y.key)??r),C=y.items.slice(0,N),j=y.items.length-C.length,A=y.key==="chats"&&!!t.renderChatsSection,P=!A&&!p&&y.items.length>r&&j===0,I=f(C.map(z=>z.node)),M=z=>s.jsx(Bo,{node:z.node,pinnedSessionIds:l,expandedParents:t.expandedParents,hasSessionSearchQuery:t.hasSessionSearchQuery,normalizedSessionSearchQuery:t.normalizedSessionSearchQuery,notifyOnSubtasks:t.notifyOnSubtasks,editingId:t.editingId,editTitle:t.editTitle,copiedSessionId:t.copiedSessionId,openSidebarMenuKey:t.openSidebarMenuKey,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,groupDirectory:z.groupDirectory,projectId:z.projectId,secondaryMeta:z.secondaryMeta,renderContext:"recent",renderExtras:I(z.node),setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},z.node.session.id);return p?s.jsxs("div",{className:"space-y-0.5",children:[C.map(M),j>0?s.jsx("button",{type:"button",onClick:()=>v(y.key,C.length,y.items.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:o("sessions.sidebar.group.showMore")}):null]},y.key):s.jsxs("div",{className:"relative space-y-1",children:[s.jsxs("div",{className:Pe("relative group/chats","-ml-2.5 -mr-2",a&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":a?"true":void 0,children:[s.jsxs("button",{type:"button",onClick:()=>w(y.key),className:Pe("group flex w-full items-center gap-1.5 py-1 pl-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",y.key==="chats"?"pr-10":"pr-3.5"),"aria-expanded":!S,children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[s.jsx(E,{name:y.key==="chats"?"chat-4":"history",className:Pe("h-3.5 w-3.5 text-muted-foreground/80","group-hover:hidden")}),s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:S?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:y.title})]}),y.key==="chats"&&t.onNewChat?s.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),t.onNewChat?.()},className:Pe("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",t.alwaysShowActions?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":o("sessions.sidebar.header.actions.newSession"),children:s.jsx(E,{name:"add",className:"h-4 w-4"})}):null]}),S?null:s.jsxs("div",{className:Pe("space-y-0.5"),children:[A?t.renderChatsSection?.(y.items):C.map(M),!A&&j>0?s.jsx("button",{type:"button",onClick:()=>v(y.key,C.length,y.items.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:o("sessions.sidebar.group.showMore")}):null,P?s.jsx("button",{type:"button",onClick:()=>g(y.key),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:o("sessions.sidebar.group.showFewer")}):null]})]},y.key)})})}function sk(t){return t+1}const nk=t=>{const e=tt.c(61),{projects:n,availableWorktreesByProject:r,gitBranches:i,homeDirectory:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,isDesktopShellRuntime:u,sessions:d,childrenMap:h,pinnedSessionIds:m,recentSessions:p,chatSessions:g,showRecentSection:w}=t,{t:v}=At();let x;if(e[0]!==r||e[1]!==i||e[2]!==o||e[3]!==n||e[4]!==d){x=new Map;for(const F of d){const O=yt(F.directory??null);if(!O)continue;let T=null,k=-1;for(const q of n){const te=yt(q.normalizedPath);te&&(O===te||O.startsWith(`${te}/`))&&te.length>k&&(T=q,k=te.length)}if(!T)continue;const D=r.get(T.normalizedPath)?.find(q=>yt(q.path)===O),L=Da(T.label?.trim()||Fn(T.normalizedPath,o)||T.normalizedPath),Q=D?.branch?.trim()||i.get(O)?.trim()||null;x.set(F.id,{projectId:T.id,groupDirectory:O,projectLabel:L,branchLabel:Q&&Q!=="HEAD"&&Q!==L?Q:null})}e[0]=r,e[1]=i,e[2]=o,e[3]=n,e[4]=d,e[5]=x}else x=e[5];const f=x;let b;e[6]!==f?(b=F=>f.get(F)??null,e[6]=f,e[7]=b):b=e[7];const y=b;let S;e[8]!==h?(S=F=>({session:F,children:(h.get(F.id)??[]).filter(rk).map(ok),worktree:null}),e[8]=h,e[9]=S):S=e[9];const N=S,C=l?a:"";let j;e[10]!==y||e[11]!==N||e[12]!==p||e[13]!==C?(j=ag({sessions:p,getSessionLocation:y,getSessionNode:N,query:C}),e[10]=y,e[11]=N,e[12]=p,e[13]=C,e[14]=j):j=e[14];const A=j;let P;e[15]!==v?(P=v("sessions.sidebar.activity.chatsTitle"),e[15]=v,e[16]=P):P=e[16];let I;if(e[17]!==g||e[18]!==N){let F;e[20]!==N?(F=O=>({node:N(O),projectId:null,groupDirectory:O.directory??null,secondaryMeta:null}),e[20]=N,e[21]=F):F=e[21],I=g.map(F),e[17]=g,e[18]=N,e[19]=I}else I=e[19];let M;e[22]!==P||e[23]!==I?(M={key:"chats",title:P,items:I},e[22]=P,e[23]=I,e[24]=M):M=e[24];let z;e[25]!==A||e[26]!==w||e[27]!==v||e[28]!==M?(z=[M,...w?A.map(F=>({...F,title:v("sessions.sidebar.activity.recentTitle")})):[]],e[25]=A,e[26]=w,e[27]=v,e[28]=M,e[29]=z):z=e[29];const R=z;let H;return e[30]!==u||e[31]!==m||e[32]!==t.allowReselect||e[33]!==t.alwaysShowActions||e[34]!==t.copiedSessionId||e[35]!==t.deleteSessionConfirm||e[36]!==t.editTitle||e[37]!==t.editingId||e[38]!==t.expandedParents||e[39]!==t.hasSessionSearchQuery||e[40]!==t.isSessionSearchOpen||e[41]!==t.mobileVariant||e[42]!==t.normalizedSessionSearchQuery||e[43]!==t.notifyOnSubtasks||e[44]!==t.onNewChat||e[45]!==t.onSessionSelected||e[46]!==t.openSidebarMenuKey||e[47]!==t.renderChatsSection||e[48]!==t.sessionSearchQuery||e[49]!==t.setCopiedSessionId||e[50]!==t.setDeleteSessionConfirm||e[51]!==t.setEditTitle||e[52]!==t.setEditingId||e[53]!==t.setIsSessionSearchOpen||e[54]!==t.setOpenSidebarMenuKey||e[55]!==t.setSessionSearchQuery||e[56]!==t.startFolderRename||e[57]!==t.startSessionWorktreeMenuLoad||e[58]!==t.toggleParent||e[59]!==R?(H=s.jsx(tk,{sections:R,variant:"section",isDesktopShellRuntime:u,pinnedSessionIds:m,expandedParents:t.expandedParents,hasSessionSearchQuery:t.hasSessionSearchQuery,normalizedSessionSearchQuery:t.normalizedSessionSearchQuery,notifyOnSubtasks:t.notifyOnSubtasks,editingId:t.editingId,editTitle:t.editTitle,copiedSessionId:t.copiedSessionId,openSidebarMenuKey:t.openSidebarMenuKey,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,onNewChat:t.onNewChat,renderChatsSection:t.renderChatsSection,setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad}),e[30]=u,e[31]=m,e[32]=t.allowReselect,e[33]=t.alwaysShowActions,e[34]=t.copiedSessionId,e[35]=t.deleteSessionConfirm,e[36]=t.editTitle,e[37]=t.editingId,e[38]=t.expandedParents,e[39]=t.hasSessionSearchQuery,e[40]=t.isSessionSearchOpen,e[41]=t.mobileVariant,e[42]=t.normalizedSessionSearchQuery,e[43]=t.notifyOnSubtasks,e[44]=t.onNewChat,e[45]=t.onSessionSelected,e[46]=t.openSidebarMenuKey,e[47]=t.renderChatsSection,e[48]=t.sessionSearchQuery,e[49]=t.setCopiedSessionId,e[50]=t.setDeleteSessionConfirm,e[51]=t.setEditTitle,e[52]=t.setEditingId,e[53]=t.setIsSessionSearchOpen,e[54]=t.setOpenSidebarMenuKey,e[55]=t.setSessionSearchQuery,e[56]=t.startFolderRename,e[57]=t.startSessionWorktreeMenuLoad,e[58]=t.toggleParent,e[59]=R,e[60]=H):H=e[60],H};function rk(t){return!t.time?.archived}function ok(t){return{session:t,children:[],worktree:null}}const hf="oc.sessions.expandedParents.v3",ik=Ta(xr()),ak=()=>{try{const t=globalThis.localStorage.getItem(hf);if(t===null)return new Set;const e=ik.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},lk=()=>{const[t,e]=c.useState(ak),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=_h(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(hf,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},ck=5*6e4,dk=[],uk=t=>!t.parentID,fk=t=>{const e=tt.c(293),{topology:n,view:r,actions:i}=t;let o,l,a,u,d;e[0]!==i?({alwaysShowActions:o,notifyOnSubtasks:l,projectViewActions:a,rowActions:u,...d}=i,e[0]=i,e[1]=o,e[2]=l,e[3]=a,e[4]=u,e[5]=d):(o=e[1],l=e[2],a=e[3],u=e[4],d=e[5]);const h=cs(hk),m=cs(pk),p=cs(gk),g=r.projectView,{getOrderedGroups:w,setGroupOrderByProject:v,toggleGroup:x,toggleProject:f}=a;let b;e[6]!==n.isVSCode||e[7]!==n.knownDirectories?(b={knownDirectories:n.knownDirectories,isVSCode:n.isVSCode,isVisible:!0},e[6]=n.isVSCode,e[7]=n.knownDirectories,e[8]=b):b=e[8];const y=lg(b);let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=new Map,e[9]=S):S=e[9];const[N,C]=c.useState(S);let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=(Ft,Wt)=>{C(ns=>new Map(ns).set(Ft,Wt+7))},e[10]=j):j=e[10];const A=j;let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=Ft=>{C(Wt=>{if(!Wt.has(Ft))return Wt;const ns=new Map(Wt);return ns.delete(Ft),ns})},e[11]=P):P=e[11];const I=P,M=ls(xk),z=ls(bk),R=ls(yk),H=ls(wk);let F;e[12]!==n.isVSCode?(F=!n.isVSCode&&!im(),e[12]=n.isVSCode,e[13]=F):F=e[13];const T=F&&z==="single",k=M&&!T;let D;e[14]!==y.pinnedSessionIds||e[15]!==y.rootSessions||e[16]!==y.sessionOrderRanks||e[17]!==k||e[18]!==n.isVSCode?(D={enabled:k,isVSCode:n.isVSCode,pinnedSessionIds:y.pinnedSessionIds,sessionOrderRanks:y.sessionOrderRanks,sessions:y.rootSessions},e[14]=y.pinnedSessionIds,e[15]=y.rootSessions,e[16]=y.sessionOrderRanks,e[17]=k,e[18]=n.isVSCode,e[19]=D):D=e[19];const L=cg(D),[Q,q]=c.useState(null),[te,ae]=c.useState(""),[X,Z]=c.useState(null),[se,fe]=c.useState(null),[B,ne]=c.useState(null),[ye,ce]=c.useState(null);let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=(Ft,Wt)=>{ce({scopeKey:Ft,folderId:Wt.id,draft:Wt.name})},e[20]=_):_=e[20];const re=_;let me;e[21]===Symbol.for("react.memo_cache_sentinel")?(me=Ft=>{ce(Wt=>Wt?{...Wt,draft:Ft}:null)},e[21]=me):me=e[21];const de=me;let ge;e[22]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>ce(null),e[22]=ge):ge=e[22];const Te=ge,{expandedParents:be,toggleParent:Re}=lk(),we=Je(Sk);let Y;e[23]!==we?(Y=(Ft,Wt)=>{Ft!==Je.getState().currentSessionId&&we(Ft,Wt)},e[23]=we,e[24]=Y):Y=e[24];const ve=Y,xe=Ld();let je;e[25]!==y.pinnedSessionIds||e[26]!==y.sessionOrderRanks||e[27]!==n.gitBranches||e[28]!==n.isVSCode||e[29]!==n.worktreeMetadata||e[30]!==r.homeDirectory?(je={homeDirectory:r.homeDirectory,worktreeMetadata:n.worktreeMetadata,pinnedSessionIds:y.pinnedSessionIds,sessionOrderRanks:y.sessionOrderRanks,gitBranches:n.gitBranches,isVSCode:n.isVSCode},e[25]=y.pinnedSessionIds,e[26]=y.sessionOrderRanks,e[27]=n.gitBranches,e[28]=n.isVSCode,e[29]=n.worktreeMetadata,e[30]=r.homeDirectory,e[31]=je):je=e[31];const{buildGroupedSessions:oe,filterSessionNodesForSearch:J,buildGroupSearchText:K}=F2(je);let $;e[32]!==y.archivedSessions||e[33]!==y.sessions||e[34]!==n.availableWorktreesByProject||e[35]!==n.isVSCode||e[36]!==n.projects?($=C0(y.sessions,n.projects,n.availableWorktreesByProject,n.isVSCode,y.archivedSessions),e[32]=y.archivedSessions,e[33]=y.sessions,e[34]=n.availableWorktreesByProject,e[35]=n.isVSCode,e[36]=n.projects,e[37]=$):$=e[37];const le=$;let V;e[38]!==le?(V={ownership:le},e[38]=le,e[39]=V):V=e[39];const{getSessionsForProject:Ce,getArchivedSessionsForProject:Be}=N0(V);let ke;e:{if(n.isVSCode){ke=null;break e}let Ft;e[40]!==y.chatSessions||e[41]!==r.homeDirectory?(Ft=Bh(r.homeDirectory)??y.chatSessions.map(vk).find(Boolean)??null,e[40]=y.chatSessions,e[41]=r.homeDirectory,e[42]=Ft):Ft=e[42];const Wt=Ft;if(!Wt){ke=null;break e}let ns;if(e[43]!==Wt||e[44]!==y.chatSessions){const Ke=[Wt,...y.chatSessions.map(jk).filter(Boolean)];let W;e[46]!==Ke?(W=new Set(Ke),e[46]=Ke,e[47]=W):W=e[47],ns=Array.from(W).filter(kk).map(Ck),e[43]=Wt,e[44]=y.chatSessions,e[45]=ns}else ns=e[45];const us=ns;let xs;if(e[48]!==y.chatSessions||e[49]!==y.childrenMap){let Ke;e[51]!==y.childrenMap?(Ke=W=>({session:W,children:(y.childrenMap.get(W.id)??[]).filter(Ak).map(Dk),worktree:null}),e[51]=y.childrenMap,e[52]=Ke):Ke=e[52],xs=y.chatSessions.filter(Nk).map(Ke),e[48]=y.chatSessions,e[49]=y.childrenMap,e[50]=xs}else xs=e[50];let ee;e[53]!==Wt||e[54]!==us||e[55]!==xs?(ee={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Wt,folderScopeKey:Wt,folderScopes:us,draftTarget:"chat",sessions:xs},e[53]=Wt,e[54]=us,e[55]=xs,e[56]=ee):ee=e[56],ke=ee}const Ne=ke;let Qe;e[57]!==Ne?(Qe=Ne?[Ne]:dk,e[57]=Ne,e[58]=Qe):Qe=e[58];const We=Qe;let U;e[59]!==K||e[60]!==oe||e[61]!==J||e[62]!==h||e[63]!==Be||e[64]!==Ce||e[65]!==We||e[66]!==n.availableWorktreesByProject||e[67]!==n.gitBranches||e[68]!==n.lastRepoStatus||e[69]!==n.projectRepoStatus||e[70]!==n.projectRootBranches||e[71]!==n.projects||e[72]!==r.hasSessionSearchQuery||e[73]!==r.normalizedSessionSearchQuery?(U={normalizedProjects:n.projects,getSessionsForProject:Ce,getArchivedSessionsForProject:Be,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,gitBranches:n.gitBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:oe,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:J,buildGroupSearchText:K,foldersMap:h,standaloneGroups:We},e[59]=K,e[60]=oe,e[61]=J,e[62]=h,e[63]=Be,e[64]=Ce,e[65]=We,e[66]=n.availableWorktreesByProject,e[67]=n.gitBranches,e[68]=n.lastRepoStatus,e[69]=n.projectRepoStatus,e[70]=n.projectRootBranches,e[71]=n.projects,e[72]=r.hasSessionSearchQuery,e[73]=r.normalizedSessionSearchQuery,e[74]=U):U=e[74];const{projectSections:he,groupSearchDataByGroup:Ee,sectionsForRender:Ie,flatSectionsForRender:rt,searchMatchCount:Ge}=P0(U),ut=r.onSearchMatchCountChange;let ct,ue;e[75]!==ut||e[76]!==Ge?(ct=()=>{ut(Ge)},ue=[ut,Ge],e[75]=ut,e[76]=Ge,e[77]=ct,e[78]=ue):(ct=e[77],ue=e[78]),c.useEffect(ct,ue);let G,Le;e[79]!==ut?(G=()=>()=>ut(0),Le=[ut],e[79]=ut,e[80]=G,e[81]=Le):(G=e[80],Le=e[81]),c.useEffect(G,Le);const Oe=Pa(),qe=`session-collection-expansion:${c.useId()}`;let Ue,st;e[82]!==Oe||e[83]!==qe||e[84]!==he||e[85]!==g.collapsedGroups||e[86]!==g.collapsedProjects||e[87]!==r.activeProjectId?(Ue=()=>(Oe.setBootstrapDemand(qe,rf({projectSections:he,activeProjectId:r.activeProjectId,collapsedProjects:g.collapsedProjects,collapsedGroups:g.collapsedGroups,currentDirectory:null,currentSessionDirectory:null})),()=>Oe.clearBootstrapDemand(qe)),st=[Oe,qe,he,g.collapsedProjects,g.collapsedGroups,r.activeProjectId],e[82]=Oe,e[83]=qe,e[84]=he,e[85]=g.collapsedGroups,e[86]=g.collapsedProjects,e[87]=r.activeProjectId,e[88]=Ue,e[89]=st):(Ue=e[88],st=e[89]),c.useEffect(Ue,st);const wt=r.useGroupedSections?Ie:rt;let Nt;e[90]!==wt||e[91]!==r.showInlineArchived?(Nt=r.showInlineArchived?wt:wt.map(Tk),e[90]=wt,e[91]=r.showInlineArchived,e[92]=Nt):Nt=e[92];const ie=Nt;let pe;e[93]!==rt?(pe=Ft=>rt.find(ns=>ns.project.id===Ft)?.groups.find(Rk)?.folderScopes??[],e[93]=rt,e[94]=pe):pe=e[94];const Ve=pe;let ze;e[95]===Symbol.for("react.memo_cache_sentinel")?(ze=new Map,e[95]=ze):ze=e[95];const He=c.useRef(ze);let ot;e[96]!==he||e[97]!==r.isDesktopShellRuntime||e[98]!==r.stickyZoneHeaders?(ot={enabled:r.stickyZoneHeaders,isDesktopShellRuntime:r.isDesktopShellRuntime,projectSections:he,projectHeaderSentinelRefs:He},e[96]=he,e[97]=r.isDesktopShellRuntime,e[98]=r.stickyZoneHeaders,e[99]=ot):ot=e[99];const at=_2(ot);let et;e[100]!==p||e[101]!==y.hasAuthoritativeGlobalSessions||e[102]!==m||e[103]!==h||e[104]!==le||e[105]!==n.projects||e[106]!==r.isSessionsLoading||e[107]!==r.isWorktreeTopologyLoading||e[108]!==r.unresolvedWorktreeProjectPaths?(et={enabled:!0,normalizedProjects:n.projects,ownership:le,isSessionsLoading:r.isSessionsLoading,hasAuthoritativeGlobalSessions:y.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:r.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:r.unresolvedWorktreeProjectPaths,foldersMap:h,createFolder:m,addSessionToFolder:p},e[100]=p,e[101]=y.hasAuthoritativeGlobalSessions,e[102]=m,e[103]=h,e[104]=le,e[105]=n.projects,e[106]=r.isSessionsLoading,e[107]=r.isWorktreeTopologyLoading,e[108]=r.unresolvedWorktreeProjectPaths,e[109]=et):et=e[109],p0(et);const{github:Xe}=wn(),dt=An(Ek),Fe=An(Mk),Se=Ks(Ok),St=Ks(Fk),vt=Ks(_k);let Rt;e[110]===Symbol.for("react.memo_cache_sentinel")?(Rt=new Set,e[110]=Rt):Rt=e[110];const Ze=c.useRef(Rt);let it;e[111]!==Se||e[112]!==Xe||e[113]!==Fe||e[114]!==dt||e[115]!==he||e[116]!==g.collapsedProjects||e[117]!==vt||e[118]!==St||e[119]!==n.gitBranches?(it=()=>{if(!Xe||!Fe||!dt?.connected)return;const Ft=new Map,Wt=Date.now();he.forEach(ns=>{g.collapsedProjects.has(ns.project.id)||ns.groups.forEach(us=>{if(us.isArchivedBucket||us.isMain)return;const xs=yt(us.directory??null),ee=us.branch?.trim()||n.gitBranches.get(xs||"")?.trim();if(!xs||!ee)return;const Ke=Ko(xs,ee),W=Ks.getState().entries[Ke],$e=W?.status?.pr?.state==="closed"||W?.status?.pr?.state==="merged",nt=`${xs}::${ee}`,jt=Math.max(W?.lastRefreshAt??0,W?.lastDiscoveryPollAt??0),Ct=!!(W?.isInitialStatusResolved&&(!W.status?.pr||$e)&&(!Ze.current.has(nt)||Wt-jt>=ck));(!W||!W.isInitialStatusResolved||Ct)&&(Ct&&Ze.current.add(nt),Ft.set(Ke,{directory:xs,branch:ee}))})}),Ft.forEach((ns,us)=>{Se(us),St(us,{...ns,remoteName:null,canShow:!0,github:Xe,githubAuthChecked:Fe,githubConnected:dt.connected})}),Ft.size&&vt([...Ft.values()],{silent:!0,markInitialResolved:!0})},e[111]=Se,e[112]=Xe,e[113]=Fe,e[114]=dt,e[115]=he,e[116]=g.collapsedProjects,e[117]=vt,e[118]=St,e[119]=n.gitBranches,e[120]=it):it=e[120];const gt=dt?.connected;let xt;e[121]!==Se||e[122]!==Xe||e[123]!==Fe||e[124]!==he||e[125]!==g.collapsedProjects||e[126]!==vt||e[127]!==St||e[128]!==gt||e[129]!==n.gitBranches?(xt=[Se,Xe,Fe,gt,he,g.collapsedProjects,vt,St,n.gitBranches],e[121]=Se,e[122]=Xe,e[123]=Fe,e[124]=he,e[125]=g.collapsedProjects,e[126]=vt,e[127]=St,e[128]=gt,e[129]=n.gitBranches,e[130]=xt):xt=e[130],c.useEffect(it,xt);let Et;e[131]!==y.orderedSessions?(Et=new Map(y.orderedSessions.map(Bk)),e[131]=y.orderedSessions,e[132]=Et):Et=e[132];const kt=Et;let Tt;if(e[133]!==w||e[134]!==ie){let Ft;e[136]!==w?(Ft=Wt=>{const ns=w(Wt.project.id,Wt.groups);return ns===Wt.groups?Wt:{...Wt,groups:ns}},e[136]=w,e[137]=Ft):Ft=e[137],Tt=ie.map(Ft),e[133]=w,e[134]=ie,e[135]=Tt}else Tt=e[135];const Ot=Tt;let Vt;e[138]!==he||e[139]!==R||e[140]!==T||e[141]!==r.activeProjectId?(Vt=null,T&&(he.some(Ft=>Ft.project.id===R)?Vt=R:he.some(Ft=>Ft.project.id===r.activeProjectId)?Vt=r.activeProjectId:Vt=he[0]?.project.id??null),e[138]=he,e[139]=R,e[140]=T,e[141]=r.activeProjectId,e[142]=Vt):Vt=e[142];const Yt=T&&!r.useGroupedSections?20:void 0;let Ht;e[143]!==i.startSessionWorktreeMenuLoad||e[144]!==o||e[145]!==y.pinnedSessionIds||e[146]!==B||e[147]!==se||e[148]!==te||e[149]!==Q||e[150]!==be||e[151]!==ye||e[152]!==Ee||e[153]!==l||e[154]!==g.collapsedGroups||e[155]!==u.allowReselect||e[156]!==u.isSessionSearchOpen||e[157]!==u.onSessionSelected||e[158]!==u.sessionSearchQuery||e[159]!==u.setIsSessionSearchOpen||e[160]!==u.setSessionSearchQuery||e[161]!==kt||e[162]!==Yt||e[163]!==Re||e[164]!==r.activeProjectId||e[165]!==r.hasSessionSearchQuery||e[166]!==r.hideDirectoryControls||e[167]!==r.mobileVariant||e[168]!==r.normalizedSessionSearchQuery?(Ht={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:Ee,collapsedGroups:g.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:y.pinnedSessionIds,sessionOrderIndex:kt,expandedParents:be,editingId:Q,editTitle:te,copiedSessionId:B,sessionBatchSize:Yt,setEditingId:q,setEditTitle:ae,toggleParent:Re,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,isSessionSearchOpen:u.isSessionSearchOpen,sessionSearchQuery:u.sessionSearchQuery,setSessionSearchQuery:u.setSessionSearchQuery,setIsSessionSearchOpen:u.setIsSessionSearchOpen,deleteSessionConfirm:se,setDeleteSessionConfirm:fe,startFolderRename:re,setCopiedSessionId:ne,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,folderRename:ye,setFolderRenameDraft:de,clearFolderRename:Te},e[143]=i.startSessionWorktreeMenuLoad,e[144]=o,e[145]=y.pinnedSessionIds,e[146]=B,e[147]=se,e[148]=te,e[149]=Q,e[150]=be,e[151]=ye,e[152]=Ee,e[153]=l,e[154]=g.collapsedGroups,e[155]=u.allowReselect,e[156]=u.isSessionSearchOpen,e[157]=u.onSessionSelected,e[158]=u.sessionSearchQuery,e[159]=u.setIsSessionSearchOpen,e[160]=u.setSessionSearchQuery,e[161]=kt,e[162]=Yt,e[163]=Re,e[164]=r.activeProjectId,e[165]=r.hasSessionSearchQuery,e[166]=r.hideDirectoryControls,e[167]=r.mobileVariant,e[168]=r.normalizedSessionSearchQuery,e[169]=Ht):Ht=e[169];const Lt=Ht;let zt;e[170]!==d.openNewSessionDraft||e[171]!==d.setActiveProjectIdOnly||e[172]!==d.setSessionSwitcherOpen||e[173]!==x?(zt={showMoreGroupSessions:A,resetGroupSessionLimit:I,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,onToggleCollapsedGroup:x},e[170]=d.openNewSessionDraft,e[171]=d.setActiveProjectIdOnly,e[172]=d.setSessionSwitcherOpen,e[173]=x,e[174]=zt):zt=e[174];const _e=zt;let Ye;e[175]!==Ne||e[176]!==_e||e[177]!==Lt||e[178]!==X?(Ye=()=>Ne?s.jsx(vo,{...Lt,..._e,group:Ne,groupKey:"managed-chats",projectId:null,hideGroupLabel:!0,sessionBatchSize:20,scrollContainerRef:void 0,openSidebarMenuKey:X,setOpenSidebarMenuKey:Z}):null,e[175]=Ne,e[176]=_e,e[177]=Lt,e[178]=X,e[179]=Ye):Ye=e[179];const ft=Ye;let bt;e[180]!==d||e[181]!==r.mobileVariant?(bt=()=>{De.getState().closeMainSurfaces(),r.mobileVariant&&d.setSessionSwitcherOpen(!1),d.openNewSessionDraft({selectedProjectId:Lh,directoryOverride:null})},e[180]=d,e[181]=r.mobileVariant,e[182]=bt):bt=e[182];const mt=bt;let lt;e[183]!==i.startSessionWorktreeMenuLoad||e[184]!==o||e[185]!==y.chatSessions||e[186]!==y.childrenMap||e[187]!==y.pinnedSessionIds||e[188]!==B||e[189]!==se||e[190]!==te||e[191]!==Q||e[192]!==be||e[193]!==mt||e[194]!==l||e[195]!==X||e[196]!==L||e[197]!==ft||e[198]!==u.allowReselect||e[199]!==u.isSessionSearchOpen||e[200]!==u.onSessionSelected||e[201]!==u.sessionSearchQuery||e[202]!==u.setIsSessionSearchOpen||e[203]!==u.setSessionSearchQuery||e[204]!==M||e[205]!==T||e[206]!==Re||e[207]!==n.availableWorktreesByProject||e[208]!==n.gitBranches||e[209]!==n.isVSCode||e[210]!==n.projects||e[211]!==r.hasSessionSearchQuery||e[212]!==r.homeDirectory||e[213]!==r.isDesktopShellRuntime||e[214]!==r.mobileVariant||e[215]!==r.normalizedSessionSearchQuery?(lt=n.isVSCode?null:s.jsx(nk,{projects:n.projects,availableWorktreesByProject:n.availableWorktreesByProject,gitBranches:n.gitBranches,homeDirectory:r.homeDirectory,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,isDesktopShellRuntime:r.isDesktopShellRuntime,sessions:L,childrenMap:y.childrenMap,pinnedSessionIds:y.pinnedSessionIds,recentSessions:L,expandedParents:be,notifyOnSubtasks:l,editingId:Q,editTitle:te,copiedSessionId:B,openSidebarMenuKey:X,mobileVariant:r.mobileVariant,alwaysShowActions:o,setEditingId:q,setEditTitle:ae,toggleParent:Re,setOpenSidebarMenuKey:Z,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,isSessionSearchOpen:u.isSessionSearchOpen,sessionSearchQuery:u.sessionSearchQuery,setSessionSearchQuery:u.setSessionSearchQuery,setIsSessionSearchOpen:u.setIsSessionSearchOpen,deleteSessionConfirm:se,setDeleteSessionConfirm:fe,startFolderRename:re,setCopiedSessionId:ne,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,chatSessions:y.chatSessions,renderChatsSection:ft,onNewChat:mt,showRecentSection:M&&!T}),e[183]=i.startSessionWorktreeMenuLoad,e[184]=o,e[185]=y.chatSessions,e[186]=y.childrenMap,e[187]=y.pinnedSessionIds,e[188]=B,e[189]=se,e[190]=te,e[191]=Q,e[192]=be,e[193]=mt,e[194]=l,e[195]=X,e[196]=L,e[197]=ft,e[198]=u.allowReselect,e[199]=u.isSessionSearchOpen,e[200]=u.onSessionSelected,e[201]=u.sessionSearchQuery,e[202]=u.setIsSessionSearchOpen,e[203]=u.setSessionSearchQuery,e[204]=M,e[205]=T,e[206]=Re,e[207]=n.availableWorktreesByProject,e[208]=n.gitBranches,e[209]=n.isVSCode,e[210]=n.projects,e[211]=r.hasSessionSearchQuery,e[212]=r.homeDirectory,e[213]=r.isDesktopShellRuntime,e[214]=r.mobileVariant,e[215]=r.normalizedSessionSearchQuery,e[216]=lt):lt=e[216];const $t=lt;let Zt;e[217]!==Ee||e[218]!==We||e[219]!==r.hasSessionSearchQuery?(Zt=r.hasSessionSearchQuery&&We.some(Ft=>Ee.get(Ft)?.hasMatch===!0),e[217]=Ee,e[218]=We,e[219]=r.hasSessionSearchQuery,e[220]=Zt):Zt=e[220];const Xt=Zt,Ns=!!$t;let Jt;e[221]!==Q||e[222]!==X||e[223]!==N?(Jt={editingId:Q,openSidebarMenuKey:X,setOpenSidebarMenuKey:Z,visibleSessionCountByGroup:N},e[221]=Q,e[222]=X,e[223]=N,e[224]=Jt):Jt=e[224];let zs;e[225]!==Lt||e[226]!==Ot||e[227]!==he||e[228]!==$t||e[229]!==Vt||e[230]!==T||e[231]!==at||e[232]!==Ns||e[233]!==Jt||e[234]!==Xt||e[235]!==n.projectRepoStatus||e[236]!==r.activeProjectId||e[237]!==r.emptyState||e[238]!==r.searchEmptyState?(zs={topContent:$t,topContentHasSearchMatches:Xt,hasSharedSessions:Ns,sectionsForRender:Ot,projectSections:he,activeProjectId:r.activeProjectId,singleProjectMode:T,singleProjectId:Vt,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,stuckProjectHeaders:at,projectHeaderSentinelRefs:He,state:Jt,groupProps:Lt},e[225]=Lt,e[226]=Ot,e[227]=he,e[228]=$t,e[229]=Vt,e[230]=T,e[231]=at,e[232]=Ns,e[233]=Jt,e[234]=Xt,e[235]=n.projectRepoStatus,e[236]=r.activeProjectId,e[237]=r.emptyState,e[238]=r.searchEmptyState,e[239]=zs):zs=e[239];const Js=zs;let rs;e[240]!==o||e[241]!==g.collapsedProjects||e[242]!==r.hasSessionSearchQuery||e[243]!==r.hideDirectoryControls||e[244]!==r.homeDirectory||e[245]!==r.isDesktopShellRuntime||e[246]!==r.mobileVariant||e[247]!==r.normalizedSessionSearchQuery||e[248]!==r.projectSortOrder||e[249]!==r.showOnlyMainWorkspace||e[250]!==r.stickyZoneHeaders?(rs={homeDirectory:r.homeDirectory,collapsedProjects:g.collapsedProjects,showOnlyMainWorkspace:r.showOnlyMainWorkspace,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,hideDirectoryControls:r.hideDirectoryControls,isDesktopShellRuntime:r.isDesktopShellRuntime,stickyZoneHeaders:r.stickyZoneHeaders,mobileVariant:r.mobileVariant,alwaysShowActions:o,projectSortOrder:r.projectSortOrder},e[240]=o,e[241]=g.collapsedProjects,e[242]=r.hasSessionSearchQuery,e[243]=r.hideDirectoryControls,e[244]=r.homeDirectory,e[245]=r.isDesktopShellRuntime,e[246]=r.mobileVariant,e[247]=r.normalizedSessionSearchQuery,e[248]=r.projectSortOrder,e[249]=r.showOnlyMainWorkspace,e[250]=r.stickyZoneHeaders,e[251]=rs):rs=e[251];const Vs=rs;let Rs;e[252]!==_e||e[253]!==d.openNewSessionDraft||e[254]!==d.openNewWorktreeDialog||e[255]!==d.openProjectEditDialog||e[256]!==d.openWorktreesPage||e[257]!==d.removeProject||e[258]!==d.renderProjectStatusIndicator||e[259]!==d.reorderProjects||e[260]!==d.setActiveProjectIdOnly||e[261]!==d.setSessionSwitcherOpen||e[262]!==v||e[263]!==H||e[264]!==f?(Rs={group:_e,toggleProject:f,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,openNewWorktreeDialog:d.openNewWorktreeDialog,openWorktreesPage:d.openWorktreesPage,openProjectEditDialog:d.openProjectEditDialog,removeProject:d.removeProject,reorderProjects:d.reorderProjects,setGroupOrderByProject:v,renderProjectStatusIndicator:d.renderProjectStatusIndicator,setSingleProjectId:H},e[252]=_e,e[253]=d.openNewSessionDraft,e[254]=d.openNewWorktreeDialog,e[255]=d.openProjectEditDialog,e[256]=d.openWorktreesPage,e[257]=d.removeProject,e[258]=d.renderProjectStatusIndicator,e[259]=d.reorderProjects,e[260]=d.setActiveProjectIdOnly,e[261]=d.setSessionSwitcherOpen,e[262]=v,e[263]=H,e[264]=f,e[265]=Rs):Rs=e[265];const cn=Rs;let gs;e[266]===Symbol.for("react.memo_cache_sentinel")?(gs=s.jsx(u0,{}),e[266]=gs):gs=e[266];let vs;e[267]!==i.initialActiveSessionByProject||e[268]!==i.openNewSessionDraft||e[269]!==i.persistActiveSessionByProject||e[270]!==i.setSessionSwitcherOpen||e[271]!==le.bySessionId||e[272]!==he||e[273]!==ve||e[274]!==r.activeProjectId||e[275]!==r.mobileVariant?(vs=s.jsx(y0,{projectSections:he,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:le.bySessionId,handleSessionSelect:ve}),e[267]=i.initialActiveSessionByProject,e[268]=i.openNewSessionDraft,e[269]=i.persistActiveSessionByProject,e[270]=i.setSessionSwitcherOpen,e[271]=le.bySessionId,e[272]=he,e[273]=ve,e[274]=r.activeProjectId,e[275]=r.mobileVariant,e[276]=vs):vs=e[276];let Zs;e[277]!==y.orderedSessions||e[278]!==xe||e[279]!==L?(Zs=s.jsx(O0,{sortedSessions:y.orderedSessions,recentSessions:L,prefetchSession:xe}),e[277]=y.orderedSessions,e[278]=xe,e[279]=L,e[280]=Zs):Zs=e[280];let Es;e[281]!==cn||e[282]!==Js||e[283]!==Vs?(Es=s.jsx(O2,{model:Js,view:Vs,actions:cn}),e[281]=cn,e[282]=Js,e[283]=Vs,e[284]=Es):Es=e[284];const As=Q!==null;let Ds;e[285]!==Ve||e[286]!==As?(Ds=s.jsx(V2,{getFolderScopesForProject:Ve,isInlineEditing:As,startFolderRename:re}),e[285]=Ve,e[286]=As,e[287]=Ds):Ds=e[287];let js;return e[288]!==vs||e[289]!==Zs||e[290]!==Es||e[291]!==Ds?(js=s.jsxs(s.Fragment,{children:[gs,vs,Zs,Es,Ds]}),e[288]=vs,e[289]=Zs,e[290]=Es,e[291]=Ds,e[292]=js):js=e[292],js},mk=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(fk,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function hk(t){return t.foldersMap}function pk(t){return t.createFolder}function gk(t){return t.addSessionToFolder}function xk(t){return t.showRecentSection}function bk(t){return t.projectDisplayMode}function yk(t){return t.singleProjectId}function wk(t){return t.setSingleProjectId}function Sk(t){return t.setCurrentSession}function vk(t){return zd(t.directory)}function jk(t){return yt(t.directory??null)}function kk(t){return!!t}function Ck(t){return{scopeKey:t,directory:t}}function Nk(t){return!t.time?.archived&&uk(t)}function Ak(t){return!t.time?.archived}function Dk(t){return{session:t,children:[],worktree:null}}function Pk(t){return t.isArchivedBucket}function Ik(t){return!t.isArchivedBucket}function Tk(t){return t.groups.some(Pk)?{...t,groups:t.groups.filter(Ik)}:t}function Rk(t){return!t.isArchivedBucket}function Ek(t){return t.status}function Mk(t){return t.hasChecked}function Ok(t){return t.ensureEntry}function Fk(t){return t.setParams}function _k(t){return t.refreshTargets}function Bk(t,e){return[t.id,e]}const pf=(t,e,n)=>{const r=new Set;for(const i of t){const o=yt(i.path)?.toLowerCase();o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=yt(o.path)?.toLowerCase();l&&r.add(l)}return r},Pc="oc.sessions.activeSessionByProject",Lk=[],$k=hu(xr(),xr().min(1).catch("")),Wk=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{wi("react.session_sidebar_render"),Gs("ui.session_sidebar.render"),Gs(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Gs(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=At(),[a,u]=c.useState(!1),[d,h]=c.useState(""),[m,p]=c.useState(0),g=c.useRef(null),w=c.useRef(null),[v,x]=c.useState(null),f=c.useMemo(()=>No(),[]),[b,y]=c.useState(new Map),S=De(Se=>Se.isNewWorktreeDialogOpen),N=De(Se=>Se.setNewWorktreeDialogOpen),[C,j]=c.useState(!1),A=c.useMemo(()=>{try{const Se=f.getItem(Pc);if(!Se)return new Map;const St=$k.safeParse(JSON.parse(Se));if(!St.success)return new Map;const vt=new Map;return Object.entries(St.data).forEach(([Rt,Ze])=>{Ze&&vt.set(Rt,Ze)}),vt}catch{return new Map}},[f]),P=c.useCallback(Se=>{try{f.setItem(Pc,JSON.stringify(Object.fromEntries(Se.entries())))}catch{}},[f]),[I,M]=c.useState(new Map),z=ts(Se=>Se.homeDirectory),R=Kt(Se=>Se.projects),H=Kt(Se=>Se.activeProjectId),F=Kt(Se=>Se.removeProject),O=Kt(Se=>Se.setActiveProjectIdOnly),T=Kt(Se=>Se.updateProjectMeta),k=Kt(Se=>Se.reorderProjects),D=De(Se=>Se.setSettingsDialogOpen),L=De(Se=>Se.toggleHelpDialog),Q=De(Se=>Se.setAboutDialogOpen),q=De(Se=>Se.setSessionSwitcherOpen),te=De(Se=>Se.setScheduledTasksDialogOpen),ae=De(Se=>Se.setArchivePageOpen),X=De(Se=>Se.setWorktreesPageProjectId),Z=De(Se=>Se.openMultiRunLauncher),se=De(Se=>Se.notifyOnSubtasks),fe=Sa(d,120),B=c.useMemo(()=>fe.trim().toLowerCase(),[fe]),ne=B.length>0;Ev({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchContainerRef:g});const ye=Id(t),ce=c.useMemo(()=>Dn(),[]),_=Je(Se=>Se.setCurrentSession),re=Je(Se=>Se.worktreeMetadata),me=Je(Se=>Se.availableWorktreesByProject),de=Je(Se=>Se.openNewSessionDraft),ge=c.useMemo(()=>pf(R,me,{includeWorktrees:!ce}),[me,ce,R]),Te=c.useCallback(Se=>{De.getState().closeMainSurfaces(),de(Se),ce&&window.dispatchEvent(new CustomEvent("aiworker:navigate",{detail:{view:"chat"}}))},[ce,de]),be=Or(Jn(Se=>({checkForUpdates:Se.checkForUpdates,available:Se.available,runtimeType:Se.runtimeType,info:Se.info,downloading:Se.downloading,downloaded:Se.downloaded,progress:Se.progress,error:Se.error,downloadUpdate:Se.downloadUpdate,restartToUpdate:Se.restartToUpdate}))),Re=ps(),we=c.useMemo(()=>`${Re}|${R.map(Se=>`${Se.id}:${yt(Se.path)??""}`).join("|")}`,[R,Re]),[Y,ve]=c.useState(ce?we:null),[xe,je]=c.useReducer(Se=>Se+1,0),oe=!ce&&Y!==we,[J,K]=c.useState(new Set),$=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let Se=!1;return(async()=>{const vt=Re,Rt=Kt.getState().projects;if(Rt.length===0||ce){Se||($.current={runtimeKey:null,revision:0,worktreesByProject:new Map},K(new Set),ve(we));return}const Ze=Je.getState().availableWorktreesByProject,it=na({rawWorktreesByProjectRef:$,publishedWorktreesByProject:Ze,runtimeKey:vt}),gt=it.revision,xt=new Map(it.worktreesByProject),Et=new Set,kt=3;let Tt=0;const Ot=Array.from({length:kt},async()=>{for(;;){const Ht=Tt;if(Tt+=1,Ht>=Rt.length)return;const Lt=Rt[Ht],zt=yt(Lt.path);if(zt)try{const _e=await Ni(async()=>On.getState().directories.get(zt)?.isGitRepo??await Uo(zt)?al({id:Lt.id,path:zt}):null);if(_e===null){xt.delete(zt);continue}if(Se)return;_e.length===0?xt.delete(zt):xt.set(zt,_e)}catch{Et.add(zt)}}});if(await Promise.all(Ot),Se||ps()!==vt)return;const Vt=new Set(Rt.map(Ht=>yt(Ht.path)).filter(Boolean));for(const Ht of xt.keys())Vt.has(Ht)||xt.delete(Ht);Gj({rawWorktreesByProjectRef:$,runtimeKey:vt,capturedRevision:gt,nextRawWorktreesByProject:xt,publishedWorktreesByProject:Ze,partitionWorktreesByRegisteredProject:cl,projects:Rt,worktreeMapsEqual:ll,recordWorktreesSeen:Nc,publishTopology:Ht=>{Je.setState(Ht)},requestRediscovery:()=>{je()},now:()=>Date.now()})&&(K(Et),ve(we))})(),()=>{Se=!0}},[ce,we,Re,xe]),c.useEffect(()=>{if(!ce)return Yr(Se=>{Se.type==="session-created"&&je()})},[ce]);const le=c.useMemo(()=>xn(),[]),{isTablet:V}=Bn(),Ce=e||V,Be=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),ke=c.useMemo(()=>R.find(Se=>Se.id===v)??null,[R,v]),Ne=c.useCallback(Se=>{v&&T(v,{label:Se.label,icon:Se.icon,color:Se.color,iconBackground:Se.iconBackground,defaultModel:Se.defaultModel??null})},[v,T]),Qe=c.useCallback(()=>{N(!0)},[N]),We=c.useCallback(()=>{const Se=Or.getState();if(Se.available&&Se.info){j(!0);return}be.checkForUpdates().then(()=>{const{available:St,error:vt}=Or.getState();if(vt){Me.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:vt});return}if(!St){Me.success(l("sessions.sidebar.updateCheck.latestVersion"));return}j(!0)})},[l,be]),U=c.useCallback(()=>{e&&q(!1),D(!0)},[e,q,D]),he=be.available&&(be.runtimeType==="desktop"||be.runtimeType==="web"),Ee=c.useCallback(()=>{gn.requestDirectoryDialog()},[]),Ie=c.useMemo(()=>R.flatMap(Se=>{const St=yt(Se.path);return St?[{id:Se.id,path:Se.path,label:Se.label,normalizedPath:St,icon:Se.icon??void 0,color:Se.color??void 0,iconImage:Se.iconImage??void 0,iconBackground:Se.iconBackground??void 0,addedAt:Se.addedAt,lastOpenedAt:Se.lastOpenedAt,sidebarCollapsed:Se.sidebarCollapsed}]:[]}),[R]),rt=c.useMemo(()=>Ie.map(Se=>Se.normalizedPath),[Ie]),Ge=$h(t?rt:Lk);Wv({enabled:t,normalizedProjects:Ie,gitRepoStatus:Ge,setProjectRepoStatus:y,setProjectRootBranches:M});const ut=Je(Se=>Se.isLoading),ct=c.useRef(!1);H&&b.has(H)&&(ct.current=!!b.get(H));const ue=ls(Se=>Se.showArchivedSessions),G=ls(Se=>Se.projectSortOrder),Le=ls(Se=>Se.stickyZoneHeaders),Oe=Kt(Se=>Se.manualProjectOrder),qe={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:V,projects:R,activeProjectId:H,manualProjectOrder:Oe,worktreeMetadata:re,availableWorktreesByProject:me,gitBranches:ye,gitRepoStatus:Ge,updateStore:be,showArchivedSessions:ue,projectSortOrder:G,projectRepoStatus:b,projectRootBranches:I,resolvedWorktreeTopologyKey:Y,unresolvedWorktreeProjectPaths:J,isSessionSearchOpen:a,sessionSearchQuery:d,editingProjectDialogId:v,updateDialogOpen:C},Ue=c.useRef(null),st=Ue.current;if(st){let Se=!1;for(const St of Object.keys(qe))Object.is(st[St],qe[St])||(Gs(`ui.session_sidebar.source.${St}`),Se=!0);Se||Gs("ui.session_sidebar.source.parent_or_context")}Ue.current=qe;const wt=c.useMemo(()=>dg(Ie,G,Oe),[Ie,G,Oe]),Nt=_v({isVSCode:ce,projects:wt}),ie=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),pe=ce&&ue,ze=ls(Se=>Se.sessionGroupingMode)==="by-worktree"&&!ce,at=e?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed",et="h-4.5 w-4.5",Xe=c.useCallback(()=>{e&&q(!1),Z()},[e,Z,q]),dt=c.useCallback(Se=>{const St=Se.projectId?R.find(vt=>vt.id===Se.projectId)??null:Se.sourceDirectory?vi(Se.sourceDirectory):null;return Hj(Se,{projects:R,getCurrentProjects:()=>Kt.getState().projects,rawWorktreesByProjectRef:$,getPublishedWorktreesByProject:()=>Je.getState().availableWorktreesByProject,resolveProject:vt=>vi(vt),listProjectWorktrees:al,partitionWorktreesByRegisteredProject:cl,worktreeMapsEqual:ll,recordWorktreesSeen:Nc,publishTopology:vt=>{Je.setState(vt)},getRuntimeKey:ps,now:()=>Date.now(),projectRootBranch:St?I.get(St.id)??null:null})},[I,R]),Fe=c.useCallback(()=>{De.getState().closeMainSurfaces(),e&&q(!1),de()},[e,de,q]);return s.jsx(Ii,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:g,className:Pe("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[!i&&!ce?s.jsx(l0,{onNewSession:Fe}):null,s.jsx(qv,{hideDirectoryControls:i,showProjectDisplayControls:!ce,showRecentControls:!ce,handleOpenDirectoryDialog:Ee,onOpenScheduled:()=>{e&&q(!1),te(!0)},onOpenMultiRun:Xe,canOpenMultiRun:R.length>0,onOpenArchive:()=>{e&&q(!1),ae(!0)},headerActionIconClass:et,headerActionButtonClass:at,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchQuery:d,setSessionSearchQuery:h,hasSessionSearchQuery:ne,searchMatchCount:m,collapseAllProjects:Nt.actions.collapseAllProjects,expandAllProjects:Nt.actions.expandAllProjects}),s.jsx(mk,{topology:{projects:wt,availableWorktreesByProject:me,knownDirectories:ge,isVSCode:ce,worktreeMetadata:re,gitBranches:ye,projectRepoStatus:b,projectRootBranches:I,lastRepoStatus:ct.current},view:{isVisible:t,hasSessionSearchQuery:ne,normalizedSessionSearchQuery:B,activeProjectId:H,showInlineArchived:pe,useGroupedSections:ze,homeDirectory:z,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:le,stickyZoneHeaders:Le,projectSortOrder:G,emptyState:Be,searchEmptyState:ie,isSessionsLoading:ut,isWorktreeTopologyLoading:oe,unresolvedWorktreeProjectPaths:J,projectView:Nt.state,onSearchMatchCountChange:p},actions:{rowActions:{allowReselect:r,onSessionSelected:n,isSessionSearchOpen:a,sessionSearchQuery:d,setSessionSearchQuery:h,setIsSessionSearchOpen:u},alwaysShowActions:Ce,notifyOnSubtasks:se,setActiveProjectIdOnly:O,setSessionSwitcherOpen:q,openNewSessionDraft:Te,openNewWorktreeDialog:Qe,openWorktreesPage:Se=>{e&&q(!1),X(Se)},openProjectEditDialog:x,removeProject:F,reorderProjects:k,startSessionWorktreeMenuLoad:dt,initialActiveSessionByProject:A,persistActiveSessionByProject:P,projectViewActions:Nt.actions}}),s.jsx(c0,{onOpenSettings:U,onOpenShortcuts:L,onOpenAbout:()=>Q(!0),onOpenUpdate:We,showRuntimeButtons:!ce,showUpdateButton:he}),s.jsx(Xd,{open:C,onOpenChange:j,info:be.info,downloading:be.downloading,downloaded:be.downloaded,progress:be.progress,error:be.error,onDownload:be.downloadUpdate,onRestart:be.restartToUpdate,runtimeType:be.runtimeType}),s.jsx(Hv,{open:!!ke,onOpenChange:Se=>{Se||x(null)},project:ke,onSave:Ne}),s.jsx(ug,{open:S,onOpenChange:N,onWorktreeCreated:(Se,St)=>{if(De.getState().closeMainSurfaces(),e&&q(!1),St?.sessionId){_(St.sessionId,Se);return}de({directoryOverride:Se,preserveDirectoryOverride:!0})}})]})})},zk=c.memo(Wk),jn=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,un=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Vk=()=>{const{t}=At(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,u]=c.useState([]),[d,h]=c.useState(!1),[m,p]=c.useState(!1),[g,w]=c.useState(!1),[v,x]=c.useState(!1),[f,b]=c.useState(new Set),y=Je(Y=>Y.getWorktreeMetadata),S=Je(Y=>Y.newSessionDraft),N=Je(Y=>Y.setNewSessionDraftTarget),C=Je(Y=>Y.setDraftBootstrapPendingDirectory),j=Wh,A=Je(Y=>Y.deleteSessions),P=Je(Y=>Y.archiveSessions),I=De(Y=>Y.showDeletionDialog),M=De(Y=>Y.setShowDeletionDialog),z=ts(Y=>Y.currentDirectory),R=ts(Y=>Y.homeDirectory),H=ts(Y=>Y.isHomeReady),F=Kt(Y=>Y.projects),O=Kt(Y=>Y.activeProjectId),{isMobile:T,isTablet:k,hasTouchInput:D}=Bn(),L=T||k||D,Q=c.useMemo(()=>{const ve=(O?F.find(xe=>xe.id===O)??null:null)?.path??z;return un(ve)},[O,z,F]),q=c.useCallback(Y=>{const xe=un(Y.projectDirectory)||Q;return{id:(F.find(oe=>un(oe.path)===xe)??null)?.id??`path:${xe}`,path:xe}},[Q,F]),te=v&&f.size>0,ae=c.useMemo(()=>{const Y=o?.worktree;return Y&&typeof Y.branch=="string"&&Y.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:ve})=>typeof ve.branch=="string"&&ve.branch.trim().length>0)},[o?.worktree,a]),X=o?.mode==="worktree",Z=X,se=g||!X||!ae,fe=g||!X;c.useEffect(()=>{r||!H||F.length>0||(i(!0),n(!0))},[r,H,F.length]);const B=c.useCallback(Y=>{l({sessions:Y.sessions,dateLabel:Y.dateLabel,mode:Y.mode??"session",worktree:Y.worktree??null})},[]),ne=c.useCallback(()=>{l(null),u([]),h(!1),p(!1),w(!1),x(!1),b(new Set)},[]),ye=c.useCallback(async Y=>{if(Y.sessions.length===0)return;if(Y.sessions.length===1){const oe=Y.sessions[0];await j(oe.id)?Me.success(t("sessions.sidebar.session.delete.success")):Me.error(t("sessions.sidebar.session.delete.error"));return}const ve=Y.sessions.map(oe=>oe.id),{deletedIds:xe,failedIds:je}=await A(ve);if(xe.length>0){const oe=je.length>0?je.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:je.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:je.length}):Y.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:Y.dateLabel}):void 0;Me.success(xe.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:xe.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:xe.length}),{description:jn(oe)})}je.length>0&&Me.error(je.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:je.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:je.length}),{description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[j,A,t]);c.useEffect(()=>gn.onDeleteRequest(Y=>{if(!I&&(Y.mode??"session")==="session"){ye(Y);return}B(Y)}),[B,I,ye]),c.useEffect(()=>gn.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){u([]),h(!1),p(!1),x(!1),b(new Set);return}const Y=o.sessions.map(je=>{const oe=y(je.id);return oe?{session:je,metadata:oe}:null}).filter(je=>!!je);u(Y),h(!1),x(!1),b(new Set);const ve=new Map;if(o.worktree?.path&&ve.set(un(o.worktree.path),o.worktree),Y.forEach(({metadata:je})=>{je.path&&ve.set(un(je.path),je)}),ve.size===0){x(!0);return}let xe=!1;return(async()=>{const je=new Map,oe=new Set;await Promise.all(Array.from(ve.entries()).map(async([J,K])=>{try{const $=await zh(K.path);je.set(J,$),$?.isDirty&&oe.add(J)}catch{K.status&&(je.set(J,K.status),K.status.isDirty&&oe.add(J))}})).catch(J=>{console.warn("Failed to inspect worktree status before deletion:",J)}),!xe&&(b(oe),x(!0),l(J=>{if(!J?.worktree?.path)return J;const K=un(J.worktree.path),$=je.get(K);if(!$)return J;const le=J.worktree.status;return le?.isDirty===$.isDirty&&le?.ahead===$.ahead&&le?.behind===$.behind&&le?.upstream===$.upstream?J:{...J,worktree:{...J.worktree,status:$}}}),u(J=>J.map(K=>{const $=un(K.metadata.path),le=je.get($);return le?{session:K.session,metadata:{...K.metadata,status:le}}:K})))})(),()=>{xe=!0}},[o,y]),c.useEffect(()=>{ae||h(!1)},[ae]);const ce=c.useCallback(async(Y,ve,xe)=>{const je=d&&ae,oe=q(Y),J=un(Y.path),K=un(oe.path);try{await bd(oe,Y,{deleteRemoteBranch:je,deleteLocalBranch:ve});const $=un(S?.directoryOverride);return S?.open&&J&&$===J&&K&&(C(null),N({projectId:oe.id,directoryOverride:K},{force:!0})),un(z)===J&&K&&ts.getState().setDirectory(K,{showOverlay:!1}),!0}catch($){return Me.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:ti(Y)}),{id:xe,description:jn($ instanceof Error?$.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ae,z,d,q,S?.directoryOverride,S?.open,C,N,t]),_=c.useCallback((Y,ve,xe)=>{const je=d&&ae,oe=Me.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:ti(Y)}));(async()=>{try{if(ve.length>0){const{failedIds:$}=await P(ve);if($.length>0){Me.error($.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:$.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:$.length}),{id:oe,description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await ce(Y,xe,oe))return;const K=t(je?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Me.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:ti(Y)}),{id:oe,description:jn(K)})}catch(J){Me.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:oe,description:jn(J instanceof Error?J.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[P,ae,d,ce,t]),re=c.useCallback(async()=>{if(o){w(!0);try{const Y=Z,ve=Y&&d,xe=Y&&m;if(X&&o.worktree){_(o.worktree,o.sessions.map(je=>je.id),xe),ne();return}if(o.sessions.length===1){const je=o.sessions[0];if(!await j(je.id)){Me.error(t("sessions.sidebar.session.delete.error")),w(!1);return}const J=!X&&Y?t(ve?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;Me.success(t("sessions.sidebar.session.delete.success"),{description:jn(J),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const je=o.sessions.map($=>$.id);let oe=[],J=[];const K=await A(je);if(oe=K.deletedIds,J=K.failedIds,oe.length>0){const $=!X&&Y?t(ve?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,V=[J.length>0?J.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:J.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:J.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,$].filter(Boolean).join(" ");Me.success(oe.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:oe.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:oe.length}),{description:jn(V||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(J.length>0&&(Me.error(J.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:J.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:J.length}),{description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),oe.length===0)){w(!1);return}}ne()}finally{w(!1)}}},[o,d,m,j,A,ne,Z,X,_,t]),me=o?.worktree??a[0]?.metadata??null,de=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",ge=o?s.jsxs("div",{className:Pe(X?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Pe(X?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[X&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),s.jsxs("ul",{className:Pe(X?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(Y=>s.jsxs("li",{className:Pe(X?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Pe(!X&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:Y.title||t("sessions.sidebar.session.untitled")})]},Y.id)),o.sessions.length>5&&s.jsx("li",{className:Pe(X?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),X?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),me?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:me.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:me?Wr(me.path,R):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),te&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Te=X?ae?s.jsxs("button",{type:"button",onClick:()=>{se||h(Y=>!Y)},disabled:se,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",se?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[d?s.jsx(E,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(E,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,be=X?s.jsxs("button",{type:"button",onClick:()=>{fe||p(Y=>!Y)},disabled:fe,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",fe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[m?s.jsx(E,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(E,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Re=X?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[be,Te]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pt,{variant:"ghost",onClick:ne,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(pt,{variant:"destructive",onClick:re,disabled:g,children:t(g?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>M(!I),className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":!I,children:[I?s.jsx(E,{name:"checkbox-blank",className:"size-4"}):s.jsx(E,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pt,{variant:"ghost",onClick:ne,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(pt,{variant:"destructive",onClick:re,disabled:g,children:g?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),we=X?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[L?s.jsx(Ho,{open:!!o,onClose:()=>{g||ne()},title:we,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Re}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[de&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:de}),ge]})}):s.jsx(ws,{open:!!o,onOpenChange:Y=>{if(!Y){if(g)return;ne()}},children:s.jsxs(Ss,{className:Pe(X?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Ws,{children:[s.jsxs(Is,{className:Pe(X&&"flex items-center gap-2"),children:[X&&s.jsx(E,{name:"delete-bin",className:"h-5 w-5"}),we]}),de&&s.jsx(Ts,{children:de})]}),s.jsx("div",{className:Pe(X&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:ge}),s.jsx(bn,{className:"mt-2 gap-2 pt-1 pb-1",children:Re})]})}),s.jsx(fg,{open:e,onOpenChange:n})]})};function Uk(t){const e=tt.c(64),{t:n}=At(),{value:r,onMoveSessionOnly:i,onMoveAllChanges:o,onCancel:l}=t,a=!!r;let u;e[0]!==l?(u=T=>{T||l()},e[0]=l,e[1]=u):u=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.session.moveToWorktree.confirm.title"),e[2]=n,e[3]=d):d=e[3];let h;e[4]!==d?(h=s.jsx(Is,{children:d}),e[4]=d,e[5]=h):h=e[5];const m=r?.dirtyFileCount??0;let p;e[6]!==n||e[7]!==m?(p=n("sessions.sidebar.session.moveToWorktree.confirm.changedFiles",{count:m}),e[6]=n,e[7]=m,e[8]=p):p=e[8];let g;e[9]!==n?(g=n("sessions.sidebar.session.moveToWorktree.confirm.ownership"),e[9]=n,e[10]=g):g=e[10];let w;e[11]!==p||e[12]!==g?(w=s.jsxs(Ts,{children:[p," ",g]}),e[11]=p,e[12]=g,e[13]=w):w=e[13];let v;e[14]!==h||e[15]!==w?(v=s.jsxs(Ws,{children:[h,w]}),e[14]=h,e[15]=w,e[16]=v):v=e[16];let x;e[17]!==n?(x=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnlyHelp"),e[17]=n,e[18]=x):x=e[18];let f;e[19]!==x?(f=s.jsx("p",{children:x}),e[19]=x,e[20]=f):f=e[20];let b;e[21]!==n?(b=n("sessions.sidebar.session.moveToWorktree.confirm.allChangesHelp"),e[21]=n,e[22]=b):b=e[22];let y;e[23]!==b?(y=s.jsx("p",{children:b}),e[23]=b,e[24]=y):y=e[24];let S;e[25]!==n||e[26]!==r?(S=r&&r.stagedFileCount>0?s.jsx("p",{"data-session-worktree-move-staged-warning":"true",children:n("sessions.sidebar.session.moveToWorktree.confirm.stagedWarning")}):null,e[25]=n,e[26]=r,e[27]=S):S=e[27];let N;e[28]!==n?(N=n("sessions.sidebar.session.moveToWorktree.confirm.baseWarning"),e[28]=n,e[29]=N):N=e[29];let C;e[30]!==N?(C=s.jsx("p",{children:N}),e[30]=N,e[31]=C):C=e[31];let j;e[32]!==f||e[33]!==y||e[34]!==S||e[35]!==C?(j=s.jsxs("div",{className:"space-y-2 typography-ui-label text-muted-foreground",children:[f,y,S,C]}),e[32]=f,e[33]=y,e[34]=S,e[35]=C,e[36]=j):j=e[36];let A;e[37]!==n?(A=n("sessions.sidebar.session.moveToWorktree.confirm.cancel"),e[37]=n,e[38]=A):A=e[38];let P;e[39]!==l||e[40]!==A?(P=s.jsx(pt,{type:"button",variant:"neutral","data-session-worktree-move-action":"cancel",onClick:l,children:A}),e[39]=l,e[40]=A,e[41]=P):P=e[41];let I;e[42]!==n?(I=n("sessions.sidebar.session.moveToWorktree.confirm.allChanges"),e[42]=n,e[43]=I):I=e[43];let M;e[44]!==o||e[45]!==I?(M=s.jsx(pt,{type:"button",variant:"outline","data-session-worktree-move-action":"all-changes",onClick:o,children:I}),e[44]=o,e[45]=I,e[46]=M):M=e[46];let z;e[47]!==n?(z=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnly"),e[47]=n,e[48]=z):z=e[48];let R;e[49]!==i||e[50]!==z?(R=s.jsx(pt,{type:"button",autoFocus:!0,"data-session-worktree-move-action":"session-only",onClick:i,children:z}),e[49]=i,e[50]=z,e[51]=R):R=e[51];let H;e[52]!==P||e[53]!==M||e[54]!==R?(H=s.jsxs(bn,{className:"gap-2 sm:justify-end",children:[P,M,R]}),e[52]=P,e[53]=M,e[54]=R,e[55]=H):H=e[55];let F;e[56]!==j||e[57]!==H||e[58]!==v?(F=s.jsxs(Ss,{id:"session-worktree-move-confirm-dialog",showCloseButton:!1,className:"max-w-md gap-5",children:[v,j,H]}),e[56]=j,e[57]=H,e[58]=v,e[59]=F):F=e[59];let O;return e[60]!==a||e[61]!==u||e[62]!==F?(O=s.jsx(ws,{open:a,onOpenChange:u,children:F}),e[60]=a,e[61]=u,e[62]=F,e[63]=O):O=e[63],O}function gf(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return pu.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function Kk(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=pu.CronExpressionParser.parse(t,r),o=[];for(let l=0;l<n;l+=1){const a=i.next();a&&o.push(a.toDate())}return o}catch{return[]}}const Hk=[{expression:"*/5 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.every5min"},{expression:"0 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.everyHour"},{expression:"0 9 * * 1",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.monday9am"},{expression:"0 9,17 * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.9am5pm"},{expression:"0 0 1 * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth"}],Gk={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Rangoon":"Asia/Yangon","Asia/Katmandu":"Asia/Kathmandu","America/Godthab":"America/Nuuk","Atlantic/Faeroe":"Atlantic/Faroe","Pacific/Enderbury":"Pacific/Kanton"},Gn=t=>Gk[t]??t,xf=[0,1,2,3,4,5,6],Ic="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",aa=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(Gn))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],Tc=()=>{const t=new Date,e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},jo=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),o=new Date(n,r-1,i);return Number.isNaN(o.getTime())||o.getFullYear()!==n||o.getMonth()!==r-1||o.getDate()!==i?null:o},Rc=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},qk=(t,e,n)=>{const r=jo(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},Ec=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),Qk=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),u=new Date(n,r,0).getDate(),d=[];for(let h=0;h<42;h+=1){const m=h-l+1;if(m<=0){const p=u+m;d.push({date:new Date(n,r-1,p),inCurrentMonth:!1});continue}if(m>a){d.push({date:new Date(n,r+1,m-a),inCurrentMonth:!1});continue}d.push({date:new Date(n,r,m),inCurrentMonth:!0})}return d},Yk=t=>{const e=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(t);if(!e)return{hour24:"00",hour12:"12",minute:"00",meridiem:"AM"};const n=Number(e[1]),r=e[2],i=n>=12?"PM":"AM",o=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(o).padStart(2,"0"),minute:r,meridiem:i}},zn=(t,e,n)=>{const r=Number(t),i=Number(e),o=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,l=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0;let a=o%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(l).padStart(2,"0")}`},wr=(t,e)=>{const{max:n,min:r=0,loop:i=!1}=e;let o=Number.parseInt(t,10);return Number.isFinite(o)?(i?(o>n&&(o=r),o<r&&(o=n)):(o>n&&(o=n),o<r&&(o=r)),String(o).padStart(2,"0")):"00"},Mc=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:wr(t,{min:1,max:12}),uo=t=>/^[0-5][0-9]$/.test(t)?t:wr(t,{max:59}),Xk=(t,e)=>wr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),Oc=(t,e)=>wr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),Jk=t=>{try{const e=Intl.Locale;if(typeof e!="function")return 1;const r=new e(t).weekInfo?.firstDay;return typeof r!="number"?1:r%7}catch{return 1}},Zk=t=>{try{const e=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions();return typeof e.hour12=="boolean"?!e.hour12:e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!0}},e3=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return xf.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},t3=(t,e)=>[...t.slice(e),...t.slice(0,e)],Ms=t=>{const e=tt.c(6),{htmlFor:n,required:r,children:i}=t;let o;e[0]!==r?(o=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=o):o=e[1];let l;return e[2]!==i||e[3]!==n||e[4]!==o?(l=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,o]})}),e[2]=i,e[3]=n,e[4]=o,e[5]=l):l=e[5],l},Fc=t=>{const e=tt.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:u,pmLabel:d}=t;let h;e[0]!==n?(h=Yk(n),e[0]=n,e[1]=h):h=e[1];const m=h,p=ht.useRef(null),g=ht.useRef(null),[w,v]=ht.useState(null),[x,f]=ht.useState(null),b=ht.useRef(null),y=ht.useRef(null);let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=Y=>{b.current=Y,v(Y)},e[2]=S):S=e[2];const N=S;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=Y=>{y.current=Y,f(Y)},e[3]=C):C=e[3];const j=C,A=l3,P=c3,I=d3;let M;e[4]!==r||e[5]!==m.meridiem||e[6]!==m.minute||e[7]!==i?(M=Y=>{const ve=Y.replace(/\D/g,"").slice(0,2);N(ve),ve.length===2&&(r(i?I(A(ve),m.minute):zn(Mc(ve),m.minute,m.meridiem)),N(null),g.current?.focus())},e[4]=r,e[5]=m.meridiem,e[6]=m.minute,e[7]=i,e[8]=M):M=e[8];const z=M;let R;e[9]!==r||e[10]!==m.meridiem||e[11]!==m.minute||e[12]!==i?(R=()=>{const Y=b.current;if(Y!==null&&(N(null),Y.length!==0)){if(i){r(I(A(Y.padStart(2,"0")),m.minute));return}r(zn(Mc(Y.padStart(2,"0")),m.minute,m.meridiem))}},e[9]=r,e[10]=m.meridiem,e[11]=m.minute,e[12]=i,e[13]=R):R=e[13];const H=R;let F;e[14]!==r||e[15]!==m.hour12||e[16]!==m.hour24||e[17]!==m.meridiem||e[18]!==i?(F=Y=>{const ve=Y.replace(/\D/g,"").slice(0,2);j(ve),ve.length===2&&(r(i?I(m.hour24,uo(ve)):zn(m.hour12,uo(ve),m.meridiem)),j(null))},e[14]=r,e[15]=m.hour12,e[16]=m.hour24,e[17]=m.meridiem,e[18]=i,e[19]=F):F=e[19];const O=F;let T;e[20]!==r||e[21]!==m.hour12||e[22]!==m.hour24||e[23]!==m.meridiem||e[24]!==i?(T=()=>{const Y=y.current;Y!==null&&(j(null),Y.length!==0&&r(i?I(m.hour24,uo(Y.padStart(2,"0"))):zn(m.hour12,uo(Y.padStart(2,"0")),m.meridiem)))},e[20]=r,e[21]=m.hour12,e[22]=m.hour24,e[23]=m.meridiem,e[24]=i,e[25]=T):T=e[25];const k=T;let D;e[26]!==r||e[27]!==m.hour12||e[28]!==m.hour24||e[29]!==m.meridiem||e[30]!==m.minute||e[31]!==i?(D=Y=>r(i?I(P(m.hour24,Y),m.minute):zn(Xk(m.hour12,Y),m.minute,m.meridiem)),e[26]=r,e[27]=m.hour12,e[28]=m.hour24,e[29]=m.meridiem,e[30]=m.minute,e[31]=i,e[32]=D):D=e[32];const L=D;let Q;e[33]!==r||e[34]!==m.hour12||e[35]!==m.hour24||e[36]!==m.meridiem||e[37]!==m.minute||e[38]!==i?(Q=Y=>r(i?I(m.hour24,Oc(m.minute,Y)):zn(m.hour12,Oc(m.minute,Y),m.meridiem)),e[33]=r,e[34]=m.hour12,e[35]=m.hour24,e[36]=m.meridiem,e[37]=m.minute,e[38]=i,e[39]=Q):Q=e[39];const q=Q;let te;e[40]!==r||e[41]!==m.hour12||e[42]!==m.meridiem||e[43]!==m.minute?(te=Y=>{Y!==m.meridiem&&r(zn(m.hour12,m.minute,Y))},e[40]=r,e[41]=m.hour12,e[42]=m.meridiem,e[43]=m.minute,e[44]=te):te=e[44];const ae=te;let X;e[45]!==H||e[46]!==L?(X=Y=>{if(Y.key==="ArrowRight"){Y.preventDefault(),H(),g.current?.focus();return}(Y.key==="ArrowUp"||Y.key==="ArrowDown")&&(Y.preventDefault(),N(null),L(Y.key==="ArrowUp"?1:-1))},e[45]=H,e[46]=L,e[47]=X):X=e[47];const Z=X;let se;e[48]!==k||e[49]!==q?(se=Y=>{if(Y.key==="ArrowLeft"&&(Y.currentTarget.selectionStart??0)===0){Y.preventDefault(),k(),p.current?.focus();return}(Y.key==="ArrowUp"||Y.key==="ArrowDown")&&(Y.preventDefault(),j(null),q(Y.key==="ArrowUp"?1:-1))},e[48]=k,e[49]=q,e[50]=se):se=e[50];const fe=se,B=i?"px-2":"pl-2 pr-1";let ne;e[51]!==B?(ne=Pe("inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-background focus-within:ring-1 focus-within:ring-interactive-focusRing focus-within:border-interactive-focusRing",B),e[51]=B,e[52]=ne):ne=e[52];const ye=w??(i?m.hour24:m.hour12);let ce;e[53]!==z?(ce=Y=>z(Y.target.value),e[53]=z,e[54]=ce):ce=e[54];let _;e[55]===Symbol.for("react.memo_cache_sentinel")?(_=()=>N(""),e[55]=_):_=e[55];let re;e[56]!==H||e[57]!==o||e[58]!==Z||e[59]!==ye||e[60]!==ce?(re=s.jsx("input",{ref:p,inputMode:"numeric",value:ye,onChange:ce,onKeyDown:Z,onFocus:_,onBlur:H,maxLength:2,"aria-label":o,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[56]=H,e[57]=o,e[58]=Z,e[59]=ye,e[60]=ce,e[61]=re):re=e[61];let me;e[62]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=me):me=e[62];const de=x??m.minute;let ge;e[63]!==O?(ge=Y=>O(Y.target.value),e[63]=O,e[64]=ge):ge=e[64];let Te;e[65]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>j(""),e[65]=Te):Te=e[65];let be;e[66]!==k||e[67]!==l||e[68]!==fe||e[69]!==de||e[70]!==ge?(be=s.jsx("input",{ref:g,inputMode:"numeric",value:de,onChange:ge,onKeyDown:fe,onFocus:Te,onBlur:k,maxLength:2,"aria-label":l,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[66]=k,e[67]=l,e[68]=fe,e[69]=de,e[70]=ge,e[71]=be):be=e[71];let Re;e[72]!==u||e[73]!==m.meridiem||e[74]!==a||e[75]!==d||e[76]!==ae||e[77]!==i?(Re=i?null:s.jsxs(Fs,{value:m.meridiem,onValueChange:Y=>ae(Y),children:[s.jsx(_s,{"aria-label":a,className:"ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0",children:s.jsx(Cs,{})}),s.jsxs(Bs,{children:[s.jsx(ss,{value:"AM",children:u}),s.jsx(ss,{value:"PM",children:d})]})]}),e[72]=u,e[73]=m.meridiem,e[74]=a,e[75]=d,e[76]=ae,e[77]=i,e[78]=Re):Re=e[78];let we;return e[79]!==ne||e[80]!==re||e[81]!==be||e[82]!==Re?(we=s.jsxs("div",{className:ne,children:[re,me,be,Re]}),e[79]=ne,e[80]=re,e[81]=be,e[82]=Re,e[83]=we):we=e[83],we},_c=t=>new Date(t.getFullYear(),t.getMonth(),1),s3=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},Bc=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),n3=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(i=>typeof i=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(i)).map(i=>i.trim()),r=Array.from(new Set(n)).sort((i,o)=>i.localeCompare(o));return r.length>0?r:["09:00"]},Lc=(t,e)=>{const n=Gn(Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC");return t?{id:t.id,name:t.name,enabled:t.enabled,schedule:{kind:t.schedule.kind==="cron"?"cron":t.schedule.kind==="once"?"once":t.schedule.kind==="weekly"?"weekly":"daily",times:n3(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:Tc(),onceTime:typeof t.schedule.time=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.time)?t.schedule.time:"09:00",weekdays:Array.isArray(t.schedule.weekdays)?t.schedule.weekdays:[1],timezone:Gn(t.schedule.timezone||n),cronExpression:t.schedule.kind==="cron"&&typeof t.schedule.cron=="string"?t.schedule.cron:""},execution:{prompt:t.execution.prompt,providerID:t.execution.providerID,modelID:t.execution.modelID,variant:t.execution.variant||"",agent:t.execution.agent||"",goalEnabled:t.execution.goalEnabled===!0,goalTokenBudget:typeof t.execution.goalTokenBudget=="number"&&t.execution.goalTokenBudget>0?t.execution.goalTokenBudget:null,permissionAutoAccept:t.execution.permissionAutoAccept===!0},state:t.state}:{name:"",enabled:!0,schedule:{kind:"daily",times:["09:00"],onceDate:Tc(),onceTime:"09:00",weekdays:[1],timezone:n,cronExpression:""},execution:{prompt:"",providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:e.agent,goalEnabled:!1,goalTokenBudget:null,permissionAutoAccept:!1}}},r3=(t,e)=>{if(!t.name.trim())return e("sessions.scheduledTasks.editor.validation.taskNameRequired");if(!t.execution.prompt.trim())return e("sessions.scheduledTasks.editor.validation.promptRequired");if(!t.execution.providerID.trim()||!t.execution.modelID.trim())return e("sessions.scheduledTasks.editor.validation.modelRequired");if(t.schedule.kind==="once"){if(!/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.onceDate))return e("sessions.scheduledTasks.editor.validation.dateFormat");if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.onceTime))return e("sessions.scheduledTasks.editor.validation.timeFormat")}else if(t.schedule.kind==="cron"){if(!t.schedule.cronExpression.trim())return e("sessions.scheduledTasks.editor.validation.cronRequired");if(!gf(t.schedule.cronExpression).valid)return e("sessions.scheduledTasks.editor.validation.cronInvalid")}else if(t.schedule.times.filter(r=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)).length===0)return e("sessions.scheduledTasks.editor.validation.atLeastOneTime");return t.schedule.kind==="weekly"&&t.schedule.weekdays.length===0?e("sessions.scheduledTasks.editor.validation.atLeastOneWeekday"):t.schedule.timezone.trim()?null:e("sessions.scheduledTasks.editor.validation.timezoneRequired")},o3=t=>{const e=t.filter(n=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(n));return Array.from(new Set(e)).sort((n,r)=>n.localeCompare(r))},i3=t=>{const e=tt.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?gf(l):null,e[0]=l,e[1]=a):a=e[1];const u=a;let d;e:{if(!u?.valid||!l.trim()){let D;e[2]===Symbol.for("react.memo_cache_sentinel")?(D=[],e[2]=D):D=e[2],d=D;break e}let k;e[3]!==l||e[4]!==n.schedule.timezone?(k=Kk(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=k):k=e[5],d=k}const h=d;let m;e[6]!==n.schedule.timezone||e[7]!==i?(m=k=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(k),e[6]=n.schedule.timezone,e[7]=i,e[8]=m):m=e[8];const p=m;let g;e[9]!==o?(g=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=g):g=e[10];let w;e[11]!==g?(w=s.jsx(Ms,{htmlFor:"sched-cron",required:!0,children:g}),e[11]=g,e[12]=w):w=e[12];let v;e[13]!==r?(v=k=>r(D=>({...D,schedule:{...D.schedule,cronExpression:k.target.value}})),e[13]=r,e[14]=v):v=e[14];let x;e[15]!==o?(x=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=x):x=e[16];let f;e[17]!==l||e[18]!==v||e[19]!==x?(f=s.jsx(Cn,{id:"sched-cron",value:l,onChange:v,placeholder:x,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=v,e[19]=x,e[20]=f):f=e[20];let b;e[21]!==l||e[22]!==u||e[23]!==o?(b=u&&!u.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=u,e[23]=o,e[24]=b):b=e[24];let y;e[25]!==w||e[26]!==f||e[27]!==b?(y=s.jsxs("div",{className:"flex flex-col gap-1",children:[w,f,b]}),e[25]=w,e[26]=f,e[27]=b,e[28]=y):y=e[28];let S;e[29]!==p||e[30]!==h||e[31]!==o?(S=h.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:h.map(p).join(", ")})]}):null,e[29]=p,e[30]=h,e[31]=o,e[32]=S):S=e[32];let N;e[33]!==o?(N=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=N):N=e[34];let C;e[35]!==N?(C=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[35]=N,e[36]=C):C=e[36];let j;e[37]!==r||e[38]!==o?(j=Hk.map(k=>s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover",onClick:()=>r(D=>({...D,schedule:{...D.schedule,cronExpression:k.expression}})),children:[s.jsx("span",{className:"font-mono",children:k.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(k.labelKey)})]},k.expression)),e[37]=r,e[38]=o,e[39]=j):j=e[39];let A;e[40]!==j?(A=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:j}),e[40]=j,e[41]=A):A=e[41];let P;e[42]!==C||e[43]!==A?(P=s.jsxs("div",{className:"flex flex-col gap-1",children:[C,A]}),e[42]=C,e[43]=A,e[44]=P):P=e[44];let I;e[45]!==o?(I=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=I):I=e[46];let M;e[47]!==I?(M=s.jsx(Ms,{children:I}),e[47]=I,e[48]=M):M=e[48];let z;e[49]!==r?(z=k=>{r(D=>({...D,schedule:{...D.schedule,timezone:k}}))},e[49]=r,e[50]=z):z=e[50];let R;e[51]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),e[51]=R):R=e[51];let H;e[52]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Bs,{children:aa.map(u3)}),e[52]=H):H=e[52];let F;e[53]!==n.schedule.timezone||e[54]!==z?(F=s.jsxs(Fs,{value:n.schedule.timezone,onValueChange:z,children:[R,H]}),e[53]=n.schedule.timezone,e[54]=z,e[55]=F):F=e[55];let O;e[56]!==M||e[57]!==F?(O=s.jsxs("div",{className:"flex flex-col gap-1",children:[M,F]}),e[56]=M,e[57]=F,e[58]=O):O=e[58];let T;return e[59]!==y||e[60]!==S||e[61]!==P||e[62]!==O?(T=s.jsxs("div",{className:"flex flex-col gap-3",children:[y,S,P,O]}),e[59]=y,e[60]=S,e[61]=P,e[62]=O,e[63]=T):T=e[63],T};function a3(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=At(),a=Gt(U=>U.loadProviders),u=Gt(U=>U.loadAgents),d=Gt(U=>U.providers),h=Gt(U=>U.currentProviderId),m=Gt(U=>U.currentModelId),p=Gt(U=>U.currentVariant||""),g=Gt(U=>U.currentAgentName||""),w=De(U=>U.timeFormatPreference),v=De(U=>U.weekStartPreference),x=De(U=>U.isMobile),[f,b]=ht.useState(()=>Lc(n,{providerID:h,modelID:m,variant:p,agent:g})),[y,S]=ht.useState(!1),[N,C]=ht.useState(!1),[j,A]=ht.useState(!1),[P,I]=ht.useState(""),[M,z]=ht.useState(!1),[R,H]=ht.useState(""),[F,O]=ht.useState(!1),[T,k]=ht.useState(""),[D,L]=ht.useState(()=>{const U=jo(n?.schedule?.date||"")||new Date;return new Date(U.getFullYear(),U.getMonth(),1)}),Q=ht.useRef(null),q=ht.useRef(null),te=ht.useRef(null),ae=ht.useRef(null),X=ht.useRef(null),Z=ht.useMemo(()=>Zk(l),[l]),se=ht.useMemo(()=>Jk(l),[l]),fe=ht.useMemo(()=>w==="24h"?!0:w==="12h"?!1:Z,[w,Z]),B=ht.useMemo(()=>v==="sunday"?0:v==="monday"?1:se,[v,se]),ne=ht.useMemo(()=>{const U=e3(l);return t3(xf.map(he=>({value:he,label:U[he]||""})),B)},[l,B]);ht.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),u({source:"scheduledTaskEditor"}))},[e,a,u]),ht.useEffect(()=>{if(!e)return;b(Lc(n,{providerID:h,modelID:m,variant:p,agent:g}));const U=jo(n?.schedule?.date||"")||new Date;L(new Date(U.getFullYear(),U.getMonth(),1)),C(!1),z(!1),A(!1),H(""),I("")},[e,n,h,m,p,g]),ht.useEffect(()=>{if(!N)return;const U=he=>{Q.current&&!Q.current.contains(he.target)&&C(!1)};return document.addEventListener("mousedown",U),()=>{document.removeEventListener("mousedown",U)}},[N]);const ye=ht.useMemo(()=>{const he=d.find(Ee=>Ee.id===f.execution.providerID)?.models?.find(Ee=>Ee.id===f.execution.modelID);return he?.variants?Object.keys(he.variants):[]},[d,f.execution.providerID,f.execution.modelID]),ce=ye.length>0,_=ht.useMemo(()=>!ce||!f.execution.variant?"__default":ye.includes(f.execution.variant)?f.execution.variant:"__default",[f.execution.variant,ce,ye]);ht.useEffect(()=>{ce||!f.execution.variant||b(U=>({...U,execution:{...U.execution,variant:""}}))},[ce,f.execution.variant]);const re=ht.useCallback((U,he)=>{b(Ee=>{const Ie=new Set(Ee.schedule.weekdays);return he?Ie.add(U):Ie.delete(U),{...Ee,schedule:{...Ee.schedule,weekdays:Array.from(Ie).sort((rt,Ge)=>rt-Ge)}}})},[]),me=ht.useCallback((U,he)=>{b(Ee=>{const Ie=Ee.schedule.times.slice();return Ie[U]=he,{...Ee,schedule:{...Ee.schedule,times:Ie}}})},[]),de=ht.useCallback(U=>{b(he=>{const Ee=he.schedule.times.filter((Ie,rt)=>rt!==U);return{...he,schedule:{...he.schedule,times:Ee.length>0?Ee:["09:00"]}}})},[]),ge=ht.useCallback(()=>{b(U=>({...U,schedule:{...U.schedule,times:[...U.schedule.times,"12:00"]}}))},[]),Te=ht.useMemo(()=>s3(),[]),be=ht.useMemo(()=>_c(Te),[Te]),Re=ht.useMemo(()=>{const U=jo(f.schedule.onceDate);return U?Bc(U,Te)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(U):null},[f.schedule.onceDate,l,o,Te]),we=ht.useMemo(()=>_c(D).getTime()<=be.getTime(),[D,be]),Y=ht.useMemo(()=>ne.map(U=>U.label),[ne]),ve=ht.useCallback(U=>{b(he=>({...he,schedule:{...he.schedule,onceDate:U}}))},[]),xe=ht.useCallback((U,he)=>{if(U.startsWith("/")){const Ge=U.indexOf(" "),ut=U.indexOf(`
|
|
924
|
+
`),ct=Math.min(Ge===-1?U.length:Ge,ut===-1?U.length:ut);if(he<=ct&&Ge===-1){H(U.substring(1,ct)),z(!0),A(!1),O(!1);return}}z(!1);const Ee=U.substring(0,he),Ie=Ee.lastIndexOf("#");if(Ie!==-1){const Ge=Ie>0?Ee[Ie-1]:null,ut=Ee.substring(Ie+1);if((!Ge||/\s/.test(Ge))&&!ut.includes(" ")&&!ut.includes(`
|
|
925
|
+
`)){k(ut),O(!0),A(!1);return}}O(!1);const rt=Ee.lastIndexOf("@");if(rt!==-1){const Ge=rt>0?Ee[rt-1]:null,ut=Ee.substring(rt+1);(!Ge||/\s/.test(Ge))&&!ut.includes(" ")&&!ut.includes(`
|
|
926
|
+
`)?(I(ut),A(!0)):A(!1);return}A(!1)},[]),je=ht.useCallback(U=>{b(he=>({...he,execution:{...he.execution,prompt:U}}))},[]),oe=ht.useCallback(U=>{const he=f.execution.prompt,Ie=q.current?.selectionStart??he.length,Ge=he.substring(0,Ie).lastIndexOf("@"),ut=U.relativePath&&U.relativePath.trim().length>0?U.relativePath.trim():U.path||U.name,ct=Ge!==-1?Ge:Ie,ue=`${he.substring(0,ct)}@${ut} ${he.substring(Ie)}`,G=ct+ut.length+2;je(ue),A(!1),I(""),requestAnimationFrame(()=>{const Le=q.current;Le&&(Le.selectionStart=G,Le.selectionEnd=G,Le.focus()),xe(ue,G)})},[f.execution.prompt,je,xe]),J=ht.useCallback(U=>{const he=f.execution.prompt,Ie=q.current?.selectionStart??he.length,Ge=he.substring(0,Ie).lastIndexOf("@"),ut=Ge!==-1?Ge:Ie,ct=`${he.substring(0,ut)}@${U} ${he.substring(Ie)}`,ue=ut+U.length+2;je(ct),A(!1),I(""),requestAnimationFrame(()=>{const G=q.current;G&&(G.selectionStart=ue,G.selectionEnd=ue,G.focus()),xe(ct,ue)})},[f.execution.prompt,je,xe]),K=ht.useCallback(U=>{const he=`/${U.name} `;je(he),z(!1),H(""),O(!1),requestAnimationFrame(()=>{const Ee=q.current;Ee&&(Ee.focus(),Ee.selectionStart=Ee.value.length,Ee.selectionEnd=Ee.value.length),xe(he,he.length)})},[je,xe]),$=ht.useCallback((U,he)=>{const Ee=f.execution.prompt,rt=q.current?.selectionStart??Ee.length,ut=Ee.substring(0,rt).lastIndexOf("#"),ct=ut!==-1?ut:rt,ue=`${Ee.substring(0,ct)}#${he} ${Ee.substring(rt)}`,G=ct+he.length+2;je(ue),O(!1),k(""),requestAnimationFrame(()=>{const Le=q.current;Le&&(Le.selectionStart=G,Le.selectionEnd=G,Le.focus()),xe(ue,G)})},[f.execution.prompt,je,xe]),le=ht.useCallback(U=>{if(M&&ae.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")){U.preventDefault(),ae.current.handleKeyDown(U.key);return}j&&te.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")&&(U.preventDefault(),te.current.handleKeyDown(U.key)),F&&X.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")&&(U.preventDefault(),X.current.handleKeyDown(U.key))},[M,j,F]),V=ht.useCallback(async()=>{const U=r3(f,o);if(U){Me.error(U);return}const he={...f.id?{id:f.id}:{},name:f.name.trim(),enabled:f.enabled,schedule:{kind:f.schedule.kind,timezone:f.schedule.timezone.trim(),...f.schedule.kind==="cron"?{cron:f.schedule.cronExpression.trim()}:f.schedule.kind==="once"?{date:f.schedule.onceDate,time:f.schedule.onceTime}:{times:o3(f.schedule.times),...f.schedule.kind==="weekly"?{weekdays:f.schedule.weekdays}:{}}},execution:{prompt:f.execution.prompt,providerID:f.execution.providerID,modelID:f.execution.modelID,...f.execution.variant.trim()?{variant:f.execution.variant.trim()}:{},...f.execution.agent.trim()?{agent:f.execution.agent.trim()}:{},...f.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...f.execution.goalEnabled?{goalEnabled:!0}:{},...f.execution.goalEnabled&&f.execution.goalTokenBudget?{goalTokenBudget:f.execution.goalTokenBudget}:{}},...f.state?{state:f.state}:{}};S(!0);try{await i(he),r(!1)}catch(Ee){Me.error(Ee instanceof Error?Ee.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{S(!1)}},[f,r,i,o]),Ce=ht.useId(),Be=ht.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),ke=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),Ne=o("sessions.scheduledTasks.editor.description"),Qe=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(Cn,{id:"sched-name",value:f.name,onChange:U=>b(he=>({...he,name:U.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Fs,{value:f.schedule.kind,onValueChange:U=>{b(he=>({...he,schedule:{...he.schedule,kind:U,...U==="cron"&&!he.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{children:U=>o(U==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":U==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":U==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(Bs,{children:[s.jsx(ss,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ss,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ss,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ss,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),f.schedule.kind==="cron"?s.jsx(i3,{draft:f,setDraft:b,locale:l,t:o}):f.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:Q,children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Pe(_d({size:"default"}),"w-fit max-w-full"),onClick:()=>C(U=>!U),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(E,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:qk(f.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-background p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>L(U=>Ec(U,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:we,children:s.jsx(E,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(D)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>L(U=>Ec(U,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(E,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:Y.map((U,he)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:U},`${U}-${he}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:Qk(D,B).map(({date:U,inCurrentMonth:he})=>{const Ee=Rc(U),Ie=Ee===f.schedule.onceDate,rt=Bc(U,Te),Ge=U.getTime()<Te.getTime(),ut=Ie?"bg-interactive-selection text-interactive-selection-foreground":Ge?"text-muted-foreground/40":he?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{Ge||(ve(Ee),C(!1))},disabled:Ge,className:["h-8 rounded-md typography-ui-label",ut,rt&&!Ie?"ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50":"",Ge?"cursor-not-allowed opacity-45":""].join(" "),children:U.getDate()},Ee)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:Re||""}),s.jsx(pt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{ve(Rc(Te)),L(new Date(Te.getFullYear(),Te.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(Fc,{value:f.schedule.onceTime,use24Hour:fe,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:U=>b(he=>({...he,schedule:{...he.schedule,onceTime:U}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Fs,{value:f.schedule.timezone,onValueChange:U=>{b(he=>({...he,schedule:{...he.schedule,timezone:U}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),s.jsx(Bs,{children:aa.map(U=>s.jsx(ss,{value:U,children:U},U))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[f.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:ne.map(U=>{const he=f.schedule.weekdays.includes(U.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",he?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(dr,{checked:he,onChange:Ee=>re(U.value,Ee),ariaLabel:U.label}),s.jsx("button",{type:"button",onClick:()=>re(U.value,!he),className:"group-hover:text-foreground",children:U.label})]},U.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:f.schedule.times.map((U,he)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Fc,{value:U,use24Hour:fe,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Ee=>me(he,Ee)}),f.schedule.times.length>1?s.jsx(pt,{type:"button",size:"icon",variant:"ghost",onClick:()=>de(he),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null]},he))}),s.jsx("div",{children:s.jsxs(pt,{type:"button",size:"sm",variant:"outline",onClick:ge,children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Fs,{value:f.schedule.timezone,onValueChange:U=>{b(he=>({...he,schedule:{...he.schedule,timezone:U}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),s.jsx(Bs,{children:aa.map(U=>s.jsx(ss,{value:U,children:U},U))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Vh,{providerId:f.execution.providerID,modelId:f.execution.modelID,onChange:(U,he)=>{b(Ee=>({...Ee,execution:{...Ee.execution,providerID:U,modelID:he,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Fs,{value:_,disabled:!ce,onValueChange:U=>{b(he=>({...he,execution:{...he.execution,variant:U==="__default"?"":U}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{children:U=>U==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):U})}),s.jsxs(Bs,{children:[s.jsx(ss,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),ye.map(U=>s.jsx(ss,{value:U,children:U},U))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Uh,{agentName:f.execution.agent,filter:U=>Fd(U.mode),onChange:U=>b(he=>({...he,execution:{...he.execution,agent:U}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(ar,{id:"sched-prompt",ref:q,value:f.execution.prompt,onChange:U=>{const he=U.target.value;je(he);const Ee=U.target.selectionStart??he.length;xe(he,Ee)},onKeyDown:le,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),M?s.jsx(Ud,{ref:ae,searchQuery:R,onCommandSelect:K,onClose:()=>z(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,j?s.jsx(Kd,{ref:te,searchQuery:P,onFileSelect:oe,onAgentSelect:J,onClose:()=>A(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,F?s.jsx(Hd,{ref:X,searchQuery:T,onSnippetSelect:$,onClose:()=>O(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),f.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(dr,{checked:f.execution.goalTokenBudget!==null,onChange:U=>b(he=>({...he,execution:{...he.execution,goalTokenBudget:U?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),f.execution.goalTokenBudget!==null?s.jsx(Kh,{value:f.execution.goalTokenBudget,onValueChange:U=>{typeof U=="number"&&Number.isFinite(U)&&U>0&&b(he=>({...he,execution:{...he.execution,goalTokenBudget:Math.floor(U)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),We=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(dr,{checked:f.enabled,onChange:U=>b(he=>({...he,enabled:U})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe(Ic),onClick:()=>b(U=>({...U,execution:{...U.execution,permissionAutoAccept:!U.execution.permissionAutoAccept}})),"aria-pressed":f.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:f.execution.permissionAutoAccept?s.jsx(E,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(E,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(It,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe(Ic,f.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>b(U=>({...U,execution:{...U.execution,goalEnabled:!U.execution.goalEnabled}})),"aria-pressed":f.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:f.execution.goalEnabled?s.jsx(E,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(E,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(It,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(pt,{type:"button",size:"sm",onClick:V,disabled:y,children:o(y?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return x?s.jsx(Ho,{open:e,title:ke,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:U=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:ke}),U]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:Ne})]}),footer:We,children:Qe}):s.jsx(ws,{open:e,onOpenChange:U=>{!U&&Be()||r(U)},children:s.jsxs(Ss,{"aria-describedby":Ce,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Ts,{id:Ce,className:"sr-only",children:Ne}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Is,{className:"typography-ui-label font-medium text-foreground",children:ke}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:Ne})]})}),s.jsx(ya,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:Qe})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:We})})]})})}function l3(t){return wr(t,{min:0,max:23})}function c3(t,e){return wr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function d3(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function u3(t){return s.jsx(ss,{value:t,children:t},t)}const f3=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},m3=(t,e)=>{const n=f3(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},h3=(t,e)=>!t||!Number.isFinite(t)?"":Hh(t,e),$c=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const m=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:m}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:m})}if(r<l){const m=Math.floor(r/o),p=Math.round(r%o/i),g=p>0?`${m}h ${p}m`:`${m}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:g}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:g})}const u=Math.floor(r/l),d=Math.round(r%l/o),h=d>0?`${u}d ${d}h`:`${u}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},p3={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},g3=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function x3(){const{t}=At(),e=De(k=>k.isScheduledTasksDialogOpen),n=De(k=>k.setScheduledTasksDialogOpen),r=De(k=>k.isMobile),i=De(k=>k.timeFormatPreference),o=Kt(k=>k.projects),l=Kt(k=>k.getActiveProject()),a=ts(k=>k.homeDirectory),{currentTheme:u}=Zn(),[d,h]=ht.useState(""),[m,p]=ht.useState([]),[g,w]=ht.useState(!0),[v,x]=ht.useState(!1),[f,b]=ht.useState(null),[y,S]=ht.useState(null),N=ht.useMemo(()=>o.find(k=>k.id===d)||null,[o,d]),C=ht.useCallback(k=>{const D=k.label?.trim()||Fn(k.path,a||void 0),L=k.icon?ja[k.icon]:null,Q=k.color?ka[k.color]:void 0,q=L?s.jsx(E,{name:L,className:"h-3.5 w-3.5 shrink-0",style:Q?{color:Q}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:Q?{color:Q}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[k.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:k.iconBackground?{backgroundColor:k.iconBackground}:void 0,children:s.jsx(Ca,{project:{id:k.id,iconImage:k.iconImage??null},options:{themeVariant:u.metadata.variant,iconColor:u.colors.surface.foreground},className:"h-full w-full object-contain",fallback:q})}):q,s.jsx("span",{className:"truncate",children:D})]})},[a,u.metadata.variant,u.colors.surface.foreground]),j=ht.useCallback(async(k,D)=>{if(!k){p([]);return}D?.silent||w(!0);try{const L=await Ng(k);L.sort((Q,q)=>{if(Q.enabled!==q.enabled)return Q.enabled?-1:1;const te=Q.name.localeCompare(q.name);return te!==0?te:(Q.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(q.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),p(L)}catch(L){Me.error(L instanceof Error?L.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),D?.silent||p([])}finally{D?.silent||w(!1)}},[t]);ht.useEffect(()=>{if(!e)return;const k=l?.id||o[0]?.id||"";h(k),k?j(k):(p([]),w(!1))},[e,l,o,j]),ht.useEffect(()=>{if(!e)return;let k=null;const D=Yr(L=>{L.type==="scheduled-task-ran"&&L.projectId===d&&(k&&clearTimeout(k),k=setTimeout(()=>{j(d,{silent:!0})},400))});return()=>{k&&clearTimeout(k),D()}},[e,d,j]);const A=ht.useCallback(async k=>{if(!d)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await jl(d,k),await j(d),Me.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[d,j,t]),P=ht.useCallback(async(k,D)=>{if(d){S(k.id),p(L=>L.map(Q=>Q.id===k.id?{...Q,enabled:D}:Q));try{k.loopFile?await Ag(d,k.id,D):await jl(d,{...k,enabled:D}),await j(d,{silent:!0})}catch(L){Me.error(L instanceof Error?L.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await j(d,{silent:!0})}finally{S(null)}}},[d,j,t]),I=ht.useCallback(async k=>{if(!(!d||!window.confirm(k.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:k.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:k.name})))){S(k.id);try{k.loopFile?await Dg(d,k.id):await Pg(d,k.id),await j(d,{silent:!0}),Me.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(L){Me.error(L instanceof Error?L.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{S(null)}}},[d,j,t]),M=ht.useCallback(k=>{if(!k.loopFile){b(k),x(!0);return}N?.path&&(n(!1),mn.getState().setSelectedPath(N.path,k.loopFile,{allowOutsideRoot:!0}),De.getState().openContextFile(N.path,k.loopFile))},[N?.path,n]),z=ht.useCallback(async k=>{if(d){S(k.id);try{const{sessionId:D,persistError:L}=await Ig(d,k.id);if(await Promise.all([j(d,{silent:!0}),Ia()]),L?Me.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Me.success(t("sessions.scheduledTasks.dialog.toast.started")),D){const Q=o.find(q=>q.id===d);Je.getState().setCurrentSession(D,Q?.path??null)}}catch(D){Me.error(D instanceof Error?D.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{S(null)}}},[d,o,j,t]),R=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(Fs,{value:d||"__none",onValueChange:k=>{const D=k==="__none"?"":k;h(D),D?j(D):p([])},children:[s.jsx(_s,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Cs,{children:C(N)}):s.jsx(Cs,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(Bs,{children:[o.length===0?s.jsx(ss,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(k=>s.jsx(ss,{value:k.id,children:C(k)},k.id))]})]})]}),H=()=>{b(null),x(!0)},F=k=>{h(k),k?j(k):p([])},O=s.jsx("div",{className:"min-h-[280px]",children:g?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):m.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(d?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:m.map(k=>{const D=y===k.id,L=k.state?.lastStatus||"idle",Q=p3[L],q=t(L==="success"?"sessions.scheduledTasks.dialog.status.success":L==="error"?"sessions.scheduledTasks.dialog.status.error":L==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),te=k.state?.nextRunAt,ae=k.state?.lastRunAt;return s.jsxs("div",{className:Pe("rounded-lg border border-border p-4 transition-opacity",!k.enabled&&"opacity-60"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:k.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:m3(k,t)}),k.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:k.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:k.loopFile})}):null]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),te?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:$c(te,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:h3(te,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),L==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ae?s.jsxs(s.Fragment,{children:[Q.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${Q.tone})`},children:[s.jsx(E,{name:Q.Icon,className:"h-3.5 w-3.5"}),q]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:$c(ae,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),k.state?.lastError?s.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",style:g3("error"),children:[s.jsx(E,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:k.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Pe("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",k.enabled?"text-foreground":"text-muted-foreground",D&&"cursor-not-allowed opacity-50"),children:[s.jsx(dr,{checked:k.enabled,onChange:X=>{P(k,X)},ariaLabel:k.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:k.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:k.name}),disabled:D}),k.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(pt,{variant:"outline",size:"sm",onClick:()=>{z(k)},disabled:D,children:[s.jsx(E,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(pt,{variant:"outline",size:"sm",onClick:()=>M(k),disabled:D,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:k.name}),children:[s.jsx(E,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(pt,{variant:"destructive",size:"sm",onClick:()=>{I(k)},disabled:D,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:k.name}),children:s.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},k.id)})})}),T=s.jsxs("div",{className:"space-y-4",children:[R,O]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Ho,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:k=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),k]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(pt,{className:"w-full",onClick:H,disabled:!d,children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:T}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(k=>s.jsx("button",{type:"button",onClick:()=>F(k.id),className:Pe("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",d===k.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(k)},k.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(pt,{size:"sm",onClick:H,disabled:!d,children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:O})})]})]})}):null,s.jsx(a3,{open:v,task:f,onOpenChange:x,onSave:A})]})}const ko=100;function b3(){const t=tt.c(106),{t:e}=At(),n=De(A3),r=De(N3),i=Je(C3),o=Je(k3),l=ts(j3);let a;t[0]!==n?(a=te=>n?te.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const u=Ps(Jn(a)),[d,h]=c.useState(""),[m,p]=c.useState(null),[g,w]=c.useState(ko);let v;t[2]!==d?(v=d.trim().toLowerCase(),t[2]=d,t[3]=v):v=t[3];const x=v;let f;e:{if(!n){let ae;t[4]===Symbol.for("react.memo_cache_sentinel")?(ae=[],t[4]=ae):ae=t[4],f=ae;break e}let te;t[5]!==u?(te=[...u].sort(v3),t[5]=u,t[6]=te):te=t[6],f=te}const b=f;let y;if(t[7]!==l||t[8]!==b||t[9]!==e){const te=new Map;for(const ae of b){const X=yt($s(ae))??"",Z=te.get(X);if(Z){Z.sessions.push(ae);continue}te.set(X,{directory:X,label:X?Fn(X,l)||X:e("sessions.archivePage.otherProjects"),sessions:[ae]})}y=[...te.values()].sort(S3),t[7]=l,t[8]=b,t[9]=e,t[10]=y}else y=t[10];const S=y;let N;e:{if(x){if(x.startsWith("ses_")){let X;if(t[11]!==x||t[12]!==b){let Z;t[14]!==x?(Z=se=>se.id.toLowerCase()===x,t[14]=x,t[15]=Z):Z=t[15],X=b.filter(Z),t[11]=x,t[12]=b,t[13]=X}else X=t[13];N=X;break e}let ae;t[16]!==x||t[17]!==b?(ae=Gh(b,x,w3),t[16]=x,t[17]=b,t[18]=ae):ae=t[18],N=ae;break e}if(m===null){N=b;break e}let te;t[19]!==S||t[20]!==m?(te=S.find(ae=>ae.directory===m)?.sessions??[],t[19]=S,t[20]=m,t[21]=te):te=t[21],N=te}const C=N;let j,A,P,I,M,z,R,H,F,O;if(t[22]!==u.length||t[23]!==S||t[24]!==C||t[25]!==l||t[26]!==x||t[27]!==n||t[28]!==d||t[29]!==m||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==g){M=Symbol.for("react.early_return_sentinel");e:{const te=C.slice(0,g);j=C.length-te.length;const ae=u.length;let X;t[45]===Symbol.for("react.memo_cache_sentinel")?(X=we=>{p(we),w(ko)},t[45]=X):X=t[45];const Z=X;let se;t[46]!==i||t[47]!==r?(se=we=>{const Y=yt($s(we));i(we.id,Y??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=se):se=t[48];const fe=se;let B;t[49]!==e||t[50]!==o?(B=we=>{o(we.id).then(Y=>{Y?Me.success(e("sessions.sidebar.session.restore.success")):Me.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=B):B=t[51];const ne=B;if(!n){M=null;break e}let ye;t[52]!==e?(ye=(we,Y,ve,xe,je,oe,J)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:je,title:oe,className:Pe("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",J?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",xe?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Y}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:ve})]}),J?s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>gn.requestDelete({sessions:J,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.archivePage.deleteProjectAria",{label:Y}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(It,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},we),t[52]=e,t[53]=ye):ye=t[53];const ce=ye;I="absolute inset-0 z-10 flex flex-col bg-background",A="flex min-h-0 flex-1";let _;if(t[54]!==ce||t[55]!==m||t[56]!==e||t[57]!==ae){let we;t[59]===Symbol.for("react.memo_cache_sentinel")?(we=()=>Z(null),t[59]=we):we=t[59],_=ce("__all__",e("sessions.archivePage.allDirectories"),ae,m===null,we),t[54]=ce,t[55]=m,t[56]=e,t[57]=ae,t[58]=_}else _=t[58];let re;if(t[60]!==S||t[61]!==ce||t[62]!==m){let we;t[64]!==ce||t[65]!==m?(we=Y=>ce(Y.directory||"__none__",Y.label,Y.sessions.length,m===Y.directory,()=>Z(Y.directory),Y.directory||void 0,Y.sessions),t[64]=ce,t[65]=m,t[66]=we):we=t[66],re=S.map(we),t[60]=S,t[61]=ce,t[62]=m,t[63]=re}else re=t[63];t[67]!==_||t[68]!==re?(P=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[_,re]})}),t[67]=_,t[68]=re,t[69]=P):P=t[69],F="flex min-w-0 flex-1 flex-col";let me;t[70]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t[70]=me):me=t[70];let de;t[71]===Symbol.for("react.memo_cache_sentinel")?(de=we=>{h(we.target.value),w(ko)},t[71]=de):de=t[71];let ge;t[72]!==e?(ge=e("sessions.archivePage.searchPlaceholder"),t[72]=e,t[73]=ge):ge=t[73];let Te;t[74]!==d||t[75]!==ge?(Te=s.jsxs("div",{className:"relative min-w-0 flex-1",children:[me,s.jsx("input",{value:d,onChange:de,placeholder:ge,className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-3 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50"})]}),t[74]=d,t[75]=ge,t[76]=Te):Te=t[76];let be;t[77]!==C.length||t[78]!==e?(be=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[77]=C.length,t[78]=e,t[79]=be):be=t[79];let Re;t[80]!==be?(Re=s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:be}),t[80]=be,t[81]=Re):Re=t[81],t[82]!==Te||t[83]!==Re?(O=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Te,Re]}),t[82]=Te,t[83]=Re,t[84]=O):O=t[84],H="min-h-0 flex-1 overflow-y-auto px-6 py-3",z="mx-auto w-full max-w-3xl space-y-0.5",R=te.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(x?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):te.map(we=>{const Y=yt($s(we))??"",ve=Y?Fn(Y,l)||Y:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>fe(we),role:"button",tabIndex:0,onKeyDown:xe=>{(xe.key==="Enter"||xe.key===" ")&&(xe.preventDefault(),fe(we))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:we.title||e("sessions.sidebar.session.untitled")}),x&&ve?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:Y,children:ve}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Wd(we.time?.archived??we.time?.updated??we.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),ne(we)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.archivePage.restoreSessionAria",{title:we.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(E,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),gn.requestDelete({sessions:[we],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.archivePage.deleteSessionAria",{title:we.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},we.id)})}t[22]=u.length,t[23]=S,t[24]=C,t[25]=l,t[26]=x,t[27]=n,t[28]=d,t[29]=m,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=g,t[35]=j,t[36]=A,t[37]=P,t[38]=I,t[39]=M,t[40]=z,t[41]=R,t[42]=H,t[43]=F,t[44]=O}else j=t[35],A=t[36],P=t[37],I=t[38],M=t[39],z=t[40],R=t[41],H=t[42],F=t[43],O=t[44];if(M!==Symbol.for("react.early_return_sentinel"))return M;let T;t[85]!==j||t[86]!==e?(T=j>0?s.jsx("button",{type:"button",onClick:()=>w(y3),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[85]=j,t[86]=e,t[87]=T):T=t[87];let k;t[88]!==T||t[89]!==z||t[90]!==R?(k=s.jsxs("div",{className:z,children:[R,T]}),t[88]=T,t[89]=z,t[90]=R,t[91]=k):k=t[91];let D;t[92]!==k||t[93]!==H?(D=s.jsx("div",{className:H,children:k}),t[92]=k,t[93]=H,t[94]=D):D=t[94];let L;t[95]!==D||t[96]!==F||t[97]!==O?(L=s.jsxs("div",{className:F,children:[O,D]}),t[95]=D,t[96]=F,t[97]=O,t[98]=L):L=t[98];let Q;t[99]!==A||t[100]!==P||t[101]!==L?(Q=s.jsxs("div",{className:A,children:[P,L]}),t[99]=A,t[100]=P,t[101]=L,t[102]=Q):Q=t[102];let q;return t[103]!==I||t[104]!==Q?(q=s.jsx("div",{className:I,children:Q}),t[103]=I,t[104]=Q,t[105]=q):q=t[105],q}function y3(t){return t+ko}function w3(t){return[t.title]}function S3(t,e){return e.sessions.length-t.sessions.length}function v3(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function j3(t){return t.homeDirectory}function k3(t){return t.unarchiveSession}function C3(t){return t.setCurrentSession}function N3(t){return t.setArchivePageOpen}function A3(t){return t.isArchivePageOpen}function D3(){const t=tt.c(18),{t:e}=At(),n=De(T3),r=De(I3),i=Kt(P3);let o;t[0]!==n?(o=g=>g.projects.find(w=>w.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Kt(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(E,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=u):u=t[6];let d;t[7]!==e?(d=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==a||t[10]!==d?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(pt,{size:"sm",onClick:a,children:[u,d]})}),t[9]=a,t[10]=d,t[11]=h):h=t[11];let m;t[12]!==l.id||t[13]!==l.path?(m=s.jsx(mg,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=m):m=t[14];let p;return t[15]!==h||t[16]!==m?(p=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[h,m]})})}),t[15]=h,t[16]=m,t[17]=p):p=t[17],p}function P3(t){return t.setActiveProjectIdOnly}function I3(t){return t.setNewWorktreeDialogOpen}function T3(t){return t.worktreesPageProjectId}const la=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),R3=(t,e)=>{const n=la(t),r=la(e);return`${n}-${r}`.substring(0,60)},Wc=(t,e)=>`${t}/${e}`,E3=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},zc=(t,e)=>{const n=E3(e),r=t.directory,i=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};tp(t.id,n),Je.getState().markSessionAsAiWorkerCreated(t.id),Ps.getState().upsertSession(i);try{Do().ensureChild(n,{bootstrap:!1}).setState(l=>{const a=l.session.findIndex(d=>d.id===t.id);if(a>=0&&l.session[a]===i)return l;const u=a>=0?l.session.map((d,h)=>h===a?i:d):[...l.session,i].sort((d,h)=>d.id.localeCompare(h.id));return{session:u,sessionTotal:Math.max(l.sessionTotal,u.length),limit:Math.max(l.limit,u.length)}})}catch{}return i},M3=()=>{const t=Kt.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(i=>i.id===e);if(n?.path)return{id:n.id,path:n.path};const r=ts.getState().currentDirectory??null;if(r&&r.trim().length>0){const i=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${i}`,path:i}}return null},xi=er()(fu(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:i,files:o,setupCommands:l}=e;if(!n)return t({error:"Group name is required"}),null;if(!r||r.length===0)return t({error:"At least one run group is required"}),null;for(let a=0;a<r.length;a++){if(!r[a].prompt.trim())return t({error:`Group ${a+1}: prompt is required`}),null;if(r[a].models.length<1)return t({error:`Group ${a+1}: select at least 1 model`}),null}t({isLoading:!0,error:null});try{const a=M3();if(!a)return t({error:"Select a project",isLoading:!1}),null;const u=a.path,h=await Uo(u)&&e.isolateRuns!==!1,m=la(n),p=h?await Go(u):void 0,g=h?await qh(u):null,w=[],v=l?.filter(S=>S.trim().length>0)??[];for(let S=0;S<r.length;S++){const N=r[S],C=N.prompt,j=new Map;for(const P of N.models){const I=`${P.providerID}:${P.modelID}`;j.set(I,(j.get(I)||0)+1)}const A=new Map;for(const P of N.models){const I=`${P.providerID}:${P.modelID}`,M=j.get(I)||1,z=(A.get(I)||0)+1;A.set(I,z);const R=R3(P.providerID,P.modelID),H=r.length>1?`g${S+1}`:void 0,F=M>1?Wc(m,`${R}/${z}`):Wc(m,R),O=H?`${H}/${F}`:F,T=Cj({groupSlug:m,runGroup:H,providerID:P.providerID,modelID:P.modelID,index:M>1?z:void 0});try{if(!h){const Q=await qs.withDirectory(u,()=>qs.createSession({title:T}));zc(Q,u),w.push({sessionId:Q.id,worktreePath:u,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:C});continue}const k=await Qh(a,{preferredName:O,mode:"new",branchName:O,worktreeName:O,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:v,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:g}),D={...k,createdFromBranch:p,kind:"standard"};await Yh(a)&&await Xh(k.path);const L=await qs.withDirectory(k.path,()=>qs.createSession({title:T}));zc(L,k.path),Je.getState().setWorktreeMetadata(L.id,D),w.push({sessionId:L.id,worktreePath:k.path,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:C})}catch(k){console.warn("[MultiRun] Failed to create session:",k)}}}const x=l?.filter(S=>S.trim().length>0)??[];x.length>0&&Jh(a,x).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const f=w.map(S=>S.sessionId),b=w[0]?.sessionId??null;if(f.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const y=o?.map(S=>({type:"file",mime:S.mime,filename:S.filename,url:S.url}));return(async()=>{try{const S=Zh.getState().expandText;await Promise.allSettled(w.map(async N=>{try{const C=await S(N.prompt).catch(()=>N.prompt);await ep({sessionId:N.sessionId,directory:N.worktreePath,content:C,providerID:N.providerID,modelID:N.modelID,variant:N.variant,agent:i,files:y})}catch(C){console.warn("[MultiRun] Failed to start run:",C)}}))}catch(S){console.warn("[MultiRun] Failed to start runs:",S)}})(),t({isLoading:!1}),{groupSlug:m,sessionIds:f,firstSessionId:b}}catch(a){return t({error:a instanceof Error?a.message:"Failed to create Multi-Run",isLoading:!1}),null}},clearError:()=>{t({error:null})}}),{name:"multirun-store"}));function bf(t){const e=tt.c(30),{git:n}=wn(),r=kd(t),i=Cd(t),o=sp(t),l=np(t),a=On(L3),u=On(B3);let d,h;e[0]!==t||e[1]!==u||e[2]!==n||e[3]!==i||e[4]!==o?(d=()=>{!t||!n||i!==null||o||u(t,n,{silent:!0})},h=[t,n,u,i,o],e[0]=t,e[1]=u,e[2]=n,e[3]=i,e[4]=o,e[5]=d,e[6]=h):(d=e[5],h=e[6]),c.useEffect(d,h);let m;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(m=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=m):m=e[12];const p=r?.all;let g;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==p?(g=[t,n,i,p,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=p,e[18]=g):g=e[18],c.useEffect(m,g);const w=o||i===!0&&l;let v;e:{if(!r?.all){let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[19]=j):j=e[19],v=j;break e}let C;e[20]!==r.all?(C=r.all.filter(_3).sort(),e[20]=r.all,e[21]=C):C=e[21],v=C}const x=v;let f;e:{if(!r?.all){let j;e[22]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[22]=j):j=e[22],f=j;break e}let C;e[23]!==r.all?(C=r.all.filter(F3).map(O3).sort(),e[23]=r.all,e[24]=C):C=e[24],f=C}const b=f;let y;e:{if(!t){y=null;break e}if(i!==null){y=i;break e}if(w){y=null;break e}y=r?.all?!0:null}const S=y;let N;return e[25]!==S||e[26]!==w||e[27]!==x||e[28]!==b?(N={localBranches:x,remoteBranches:b,isLoading:w,isGitRepository:S},e[25]=S,e[26]=w,e[27]=x,e[28]=b,e[29]=N):N=e[29],N}function O3(t){return t.replace(/^remotes\//,"")}function F3(t){return t.startsWith("remotes/")}function _3(t){return!t.startsWith("remotes/")}function B3(t){return t.fetchStatus}function L3(t){return t.fetchBranches}const $3=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=At(),{localBranches:a,remoteBranches:u,isLoading:d,isGitRepository:h}=bf(t),m=c.useMemo(()=>[...a,...u.map(g=>`remotes/${g}`)],[a,u]);c.useEffect(()=>{if(i||d||m.length===0||e&&m.includes(e))return;const g=e;let w=!1;return(async()=>{try{const x=t?await Go(t).catch(()=>null):null;if(w)return;const f=localStorage.getItem(Sl),{sourceBranch:b,shouldClearSavedSourceBranch:y}=hg({branches:m,savedSourceBranch:f,rootBranch:x});if(y&&localStorage.removeItem(Sl),w||g&&m.includes(g))return;b&&n(b)}catch{}})(),()=>{w=!0}},[m,t,i,d,n,e]);const p=i||!h||d;return s.jsxs("div",{children:[s.jsxs(Fs,{value:e,onValueChange:n,disabled:p,children:[s.jsx(_s,{id:o,size:"lg",className:Pe("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(Cs,{placeholder:l(d?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Bs,{className:"max-h-[280px] max-w-[320px]",children:d?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&u.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(Di,{children:[s.jsx(dl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(g=>s.jsx(ss,{value:g,className:"whitespace-normal break-all",children:g},g))]}),a.length>0&&u.length>0&&s.jsx(rp,{}),u.length>0&&s.jsxs(Di,{children:[s.jsx(dl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),u.map(g=>s.jsx(ss,{value:`remotes/${g}`,className:"whitespace-normal break-all",children:g},`remotes/${g}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},W3=10*1024*1024,Co=t=>{const e=tt.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(E,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(Dt,{children:[r,s.jsx(It,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Kn=t=>{const e=tt.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const u=o&&o;let d;return e[6]!==a||e[7]!==u?(d=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,u]}),e[6]=a,e[7]=u,e[8]=d):d=e[8],d},z3=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=At(),[o,l]=c.useState(""),[a,u]=c.useState(()=>[{id:Br(),prompt:"",models:[]}]),[d,h]=c.useState(""),[m,p]=c.useState([]),[g,w]=c.useState(!1),[v,x]=c.useState([]),[f,b]=c.useState(!1),[y,S]=c.useState(!1),[N,C]=c.useState(!0),j=c.useRef(null),A=ts(K=>K.currentDirectory??null),P=ts(K=>K.homeDirectory??null),I=c.useMemo(()=>{if(typeof window>"u")return null;const K=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof K=="string"&&K.trim().length>0?K.trim():null},[]),M=Kt(K=>K.activeProjectId),z=Kt(K=>K.setActiveProjectIdOnly),R=Kt(K=>K.projects),[H,F]=c.useState(()=>M??null);c.useEffect(()=>{if(M){F(M);return}!H&&R.length>0&&F(R[0].id)},[M,R,H]);const O=c.useMemo(()=>H?R.find(K=>K.id===H)??null:null,[R,H]),T=O?.path??A,k=c.useCallback(K=>{F(K),K!==M&&z(K)},[M,z]),{currentTheme:D}=Zn(),L=c.useCallback(K=>{const $=K.label?.trim()||Fn(K.path,P),le=K.icon?ja[K.icon]:null,V=K.color?ka[K.color]:void 0,Ce=le?s.jsx(E,{name:le,className:"h-3.5 w-3.5 shrink-0",style:V?{color:V}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:V?{color:V}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[K.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:K.iconBackground?{backgroundColor:K.iconBackground}:void 0,children:s.jsx(Ca,{project:{id:K.id,iconImage:K.iconImage??null},options:{themeVariant:D.metadata.variant,iconColor:D.colors.surface.foreground},className:"h-full w-full object-contain",fallback:Ce})}):Ce,s.jsx("span",{className:"truncate",children:$})]})},[P,D.metadata.variant,D.colors.surface.foreground]),Q=c.useMemo(()=>{if(O?.path)return{id:O.id,path:O.path};const K=A??I;return K?{id:`path:${K}`,path:K}:null},[O,A,I]),[q]=c.useState(()=>typeof window<"u"?xn():!1),te=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ae=yd(),X=c.useMemo(()=>{if(typeof window>"u")return null;const K=window.__AIWORKER_MACOS_MAJOR__;if(typeof K=="number"&&Number.isFinite(K)&&K>0)return K;if(typeof navigator>"u")return null;const $=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!$)return null;const le=Number.parseInt($[1],10),V=Number.parseInt($[2],10);return Number.isNaN(le)?null:le===10?V:le},[]),Z=c.useMemo(()=>q&&te||ae?"pl-[88px]":"pl-3",[q,te,ae]),se=c.useMemo(()=>!q||!te||X===null?"":X>=26?"h-12":X<=15?"h-14":"",[q,te,X]),fe=c.useCallback(async K=>{K.target.closest("button, a, input, select, textarea")||K.button===0&&q&&await op()},[q]);c.useEffect(()=>{if(!n)return;const K=$=>{$.key==="Escape"&&($.preventDefault(),$.stopPropagation(),n())};return window.addEventListener("keydown",K,!0),()=>window.removeEventListener("keydown",K,!0)},[n]);const[B,ne]=c.useState(""),{isLoading:ye,isGitRepository:ce}=bf(T),_=c.useRef(!1),re=ce===!0,me=re&&N;c.useEffect(()=>{if(ce===!1){_.current=!0,C(!1);return}ce===!0&&_.current&&(_.current=!1,C(!0))},[ce]);const de=xi(K=>K.createMultiRun),ge=xi(K=>K.error),Te=xi(K=>K.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&u(K=>{const $=[...K];return $.length>0&&!$[0].prompt.trim()&&($[0]={...$[0],prompt:t}),$})},[t]),c.useEffect(()=>{if(!Q)return;let K=!1;return S(!0),(async()=>{try{const $=await ip(Q);K||x($)}catch{}finally{K||S(!1)}})(),()=>{K=!0}},[Q]);const be=c.useCallback((K,$)=>{u(le=>le.map(V=>V.id===K?{...V,...$}:V))},[]),Re=c.useCallback(K=>{u($=>$.filter(le=>le.id!==K))},[]),we=c.useCallback(()=>{u(K=>[...K,{id:Br(),prompt:"",models:[]}])},[]),Y=async K=>{const $=K.target.files;if(!$)return;let le=0;for(let V=0;V<$.length;V++){const Ce=$[V];if(Ce.size>W3){Me.error(i("multirun.launcher.toast.fileTooLarge",{fileName:Ce.name}));continue}try{const Be=await new Promise((ke,Ne)=>{const Qe=new FileReader;Qe.onload=()=>ke(Qe.result),Qe.onerror=Ne,Qe.readAsDataURL(Ce)});p(ke=>[...ke,{id:Br(),filename:Ce.name,mimeType:Ce.type||"application/octet-stream",size:Ce.size,dataUrl:Be}]),le++}catch(Be){console.error("File attach failed",Be),Me.error(i("multirun.launcher.toast.attachFailed",{fileName:Ce.name}))}}le>0&&Me.success(le===1?i("multirun.launcher.toast.attachedSingle",{count:le}):i("multirun.launcher.toast.attachedPlural",{count:le})),j.current&&(j.current.value="")},ve=K=>{p($=>$.filter(le=>le.id!==K))},xe=c.useMemo(()=>a.reduce((K,$)=>K+$.models.length,0),[a]),je=async K=>{K.preventDefault();const $=a.filter(le=>le.prompt.trim()&&le.models.length>=1);if($.length!==0&&!(xe<1)){w(!0),Te();try{H&&H!==M&&z(H);const le=m.map(Ne=>({mime:Ne.mimeType,filename:Ne.filename,url:Ne.dataUrl})),V=v.filter(Ne=>Ne.trim().length>0),Ce=$.map(Ne=>({prompt:Ne.prompt.trim(),models:Ne.models.map(Qe=>({providerID:Qe.providerID,modelID:Qe.modelID,displayName:Qe.displayName,variant:Qe.variant}))})),Be={name:o.trim(),groups:Ce,agent:d||void 0,worktreeBaseBranch:me?B:void 0,isolateRuns:me,files:le.length>0?le:void 0,setupCommands:V.length>0?V:void 0},ke=await de(Be);ke&&(ke.firstSessionId&&Je.getState().setCurrentSession(ke.firstSessionId),e?.())}finally{w(!1)}}},oe=!!(o.trim()&&a.some(K=>K.prompt.trim()&&K.models.length>=1)&&xe>=1&&T&&!ye&&(ce===!1||!me||B)),J=v.filter(K=>K.trim()).length;return s.jsxs("form",{onSubmit:je,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:fe,className:Pe("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",Z,se),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary app-region-no-drag",children:s.jsx(E,{name:"close",className:"h-5 w-5"})})}),s.jsx(It,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(ya,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Kn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),R.length>0?s.jsxs(Fs,{value:H??void 0,onValueChange:k,children:[s.jsx(_s,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:O?s.jsx(Cs,{children:L(O)}):s.jsx(Cs,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(Bs,{fitContent:!0,children:R.map(K=>s.jsx(ss,{value:K.id,className:"max-w-[24rem]",children:L(K)},K.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Kn,{htmlFor:"group-name",required:!0,info:s.jsx(Co,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(Cn,{id:"group-name",value:o,onChange:K=>l(K.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Kn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Co,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx($3,{directory:T,value:B,onChange:ne,disabled:!me,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(dr,{checked:N,onChange:C,disabled:!re,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Kn,{htmlFor:"multirun-agent",info:s.jsx(Co,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(df,{value:d,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(Ri,{open:f,onOpenChange:b,children:[s.jsxs(Zd,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(E,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:i("multirun.launcher.setupCommands.label")}),J>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:J}),s.jsx(E,{name:"arrow-down-s",className:Pe("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",f&&"rotate-180")})]}),s.jsx(Ei,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:y?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[v.map((K,$)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(Cn,{value:K,onChange:le=>{const V=[...v];V[$]=le.target.value,x(V)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>x(v.filter((le,V)=>V!==$)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]},`${K}-${$}`)),s.jsxs("button",{type:"button",onClick:()=>x([...v,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(E,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Kn,{htmlFor:"prompt",required:!0,children:i("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:j,type:"file",multiple:!0,className:"hidden",onChange:Y,accept:"*/*"}),s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>j.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(E,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(It,{children:i("multirun.launcher.attachments.tooltip")})]}),m.map(K=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[K.mimeType.startsWith("image/")?s.jsx(E,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(E,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:K.filename,children:K.filename}),s.jsx("button",{type:"button",onClick:()=>ve(K.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(E,{name:"close",className:"h-3 w-3"})})]},K.id))]})]}),a.map((K,$)=>s.jsx(V3,{group:K,groupIndex:$,canRemove:a.length>1,onUpdate:be,onRemove:Re},K.id)),s.jsxs("button",{type:"button",onClick:we,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(E,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),ge&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:ge})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!me&&ce!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(E,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(pt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(pt,{type:"submit",size:"sm",disabled:!oe||g,children:g?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:xe})})})]})})]})},V3=t=>{const e=tt.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=At(),[u,d]=c.useState(!1),[h,m]=c.useState(""),[p,g]=c.useState(!1),[w,v]=c.useState(""),[x,f]=c.useState(!1),[b,y]=c.useState(""),S=c.useRef(null),N=c.useRef(null),C=c.useRef(null),j=c.useRef(null);let A;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(A=V=>{o(n.id,{models:[...n.models,V]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=A):A=e[3];const P=A;let I;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(I=V=>{o(n.id,{models:n.models.filter((Ce,Be)=>Be!==V)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=I):I=e[7];const M=I;let z;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(z=(V,Ce)=>{o(n.id,{models:n.models.map((Be,ke)=>ke===V?Ce:Be)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=z):z=e[11];const R=z;let H;e[12]===Symbol.for("react.memo_cache_sentinel")?(H=(V,Ce)=>{if(V.startsWith("/")){const Qe=V.indexOf(" "),We=V.indexOf(`
|
|
927
|
+
`),U=Math.min(Qe===-1?V.length:Qe,We===-1?V.length:We);if(Ce<=U&&Qe===-1){v(V.substring(1,U)),g(!0),d(!1),f(!1);return}}g(!1);const Be=V.substring(0,Ce),ke=Be.lastIndexOf("#");if(ke!==-1){const Qe=ke>0?Be[ke-1]:null,We=Be.substring(ke+1);if((!Qe||/\s/.test(Qe))&&!We.includes(" ")&&!We.includes(`
|
|
928
|
+
`)){y(We),f(!0),d(!1);return}}f(!1);const Ne=Be.lastIndexOf("@");if(Ne!==-1){const Qe=Ne>0?Be[Ne-1]:null,We=Be.substring(Ne+1);(!Qe||/\s/.test(Qe))&&!We.includes(" ")&&!We.includes(`
|
|
929
|
+
`)?(m(We),d(!0)):d(!1);return}d(!1)},e[12]=H):H=e[12];const F=H;let O;e[13]!==n.id||e[14]!==o?(O=V=>{o(n.id,{prompt:V})},e[13]=n.id,e[14]=o,e[15]=O):O=e[15];const T=O;let k;e[16]!==n.prompt||e[17]!==T?(k=V=>{const Ce=n.prompt,ke=S.current?.selectionStart??Ce.length,Qe=Ce.substring(0,ke).lastIndexOf("@"),We=V.relativePath&&V.relativePath.trim().length>0?V.relativePath.trim():V.path||V.name,U=Qe!==-1?Qe:ke,he=`${Ce.substring(0,U)}@${We} ${Ce.substring(ke)}`,Ee=U+We.length+2;T(he),d(!1),m(""),requestAnimationFrame(()=>{const Ie=S.current;Ie&&(Ie.selectionStart=Ee,Ie.selectionEnd=Ee,Ie.focus()),F(he,Ee)})},e[16]=n.prompt,e[17]=T,e[18]=k):k=e[18];const D=k;let L;e[19]!==n.prompt||e[20]!==T?(L=V=>{const Ce=n.prompt,ke=S.current?.selectionStart??Ce.length,Qe=Ce.substring(0,ke).lastIndexOf("@"),We=Qe!==-1?Qe:ke,U=`${Ce.substring(0,We)}@${V} ${Ce.substring(ke)}`,he=We+V.length+2;T(U),d(!1),m(""),requestAnimationFrame(()=>{const Ee=S.current;Ee&&(Ee.selectionStart=he,Ee.selectionEnd=he,Ee.focus()),F(U,he)})},e[19]=n.prompt,e[20]=T,e[21]=L):L=e[21];const Q=L;let q;e[22]!==T?(q=V=>{const Ce=`/${V.name} `;T(Ce),g(!1),v(""),f(!1),requestAnimationFrame(()=>{const Be=S.current;Be&&(Be.focus(),Be.selectionStart=Be.value.length,Be.selectionEnd=Be.value.length),F(Ce,Ce.length)})},e[22]=T,e[23]=q):q=e[23];const te=q;let ae;e[24]!==n.prompt||e[25]!==T?(ae=(V,Ce)=>{const Be=n.prompt,Ne=S.current?.selectionStart??Be.length,We=Be.substring(0,Ne).lastIndexOf("#"),U=We!==-1?We:Ne,he=`${Be.substring(0,U)}#${Ce} ${Be.substring(Ne)}`,Ee=U+Ce.length+2;T(he),f(!1),y(""),requestAnimationFrame(()=>{const Ie=S.current;Ie&&(Ie.selectionStart=Ee,Ie.selectionEnd=Ee,Ie.focus()),F(he,Ee)})},e[24]=n.prompt,e[25]=T,e[26]=ae):ae=e[26];const X=ae;let Z;e[27]!==p||e[28]!==u||e[29]!==x?(Z=V=>{if(p&&C.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")){V.preventDefault(),C.current.handleKeyDown(V.key);return}u&&N.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),N.current.handleKeyDown(V.key)),x&&j.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),j.current.handleKeyDown(V.key))},e[27]=p,e[28]=u,e[29]=x,e[30]=Z):Z=e[30];const se=Z,fe=r+1;let B;e[31]!==a||e[32]!==fe?(B=a("multirun.launcher.groups.groupLabel",{index:fe}),e[31]=a,e[32]=fe,e[33]=B):B=e[33];let ne;e[34]!==B?(ne=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:B}),e[34]=B,e[35]=ne):ne=e[35];let ye;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(ye=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=ye):ye=e[40];let ce;e[41]!==ne||e[42]!==ye?(ce=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ne,ye]}),e[41]=ne,e[42]=ye,e[43]=ce):ce=e[43];let _;e[44]!==a?(_=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=_):_=e[45];let re;e[46]!==_?(re=s.jsx(Kn,{required:!0,children:_}),e[46]=_,e[47]=re):re=e[47];const me=n.prompt;let de;e[48]!==T?(de=V=>{const Ce=V.target.value;T(Ce);const Be=V.target.selectionStart??Ce.length;F(Ce,Be)},e[48]=T,e[49]=de):de=e[49];let ge;e[50]!==a?(ge=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=ge):ge=e[51];let Te;e[52]!==n.prompt||e[53]!==se||e[54]!==de||e[55]!==ge?(Te=s.jsx(ar,{ref:S,value:me,onChange:de,onKeyDown:se,placeholder:ge,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=se,e[54]=de,e[55]=ge,e[56]=Te):Te=e[56];let be;e[57]!==w||e[58]!==te||e[59]!==p?(be=p?s.jsx(Ud,{ref:C,searchQuery:w,onCommandSelect:te,onClose:()=>g(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=te,e[59]=p,e[60]=be):be=e[60];let Re;e[61]!==Q||e[62]!==D||e[63]!==h||e[64]!==u?(Re=u?s.jsx(Kd,{ref:N,searchQuery:h,onFileSelect:D,onAgentSelect:Q,onClose:()=>d(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=Q,e[62]=D,e[63]=h,e[64]=u,e[65]=Re):Re=e[65];let we;e[66]!==X||e[67]!==x||e[68]!==b?(we=x?s.jsx(Hd,{ref:j,searchQuery:b,onSnippetSelect:X,onClose:()=>f(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=X,e[67]=x,e[68]=b,e[69]=we):we=e[69];let Y;e[70]!==Te||e[71]!==be||e[72]!==Re||e[73]!==we?(Y=s.jsxs("div",{className:"relative",children:[Te,be,Re,we]}),e[70]=Te,e[71]=be,e[72]=Re,e[73]=we,e[74]=Y):Y=e[74];let ve;e[75]!==re||e[76]!==Y?(ve=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[re,Y]}),e[75]=re,e[76]=Y,e[77]=ve):ve=e[77];let xe;e[78]!==a?(xe=a("multirun.launcher.models.info"),e[78]=a,e[79]=xe):xe=e[79];let je;e[80]!==xe?(je=s.jsx(Co,{children:xe}),e[80]=xe,e[81]=je):je=e[81];let oe;e[82]!==a?(oe=a("multirun.launcher.models.label"),e[82]=a,e[83]=oe):oe=e[83];let J;e[84]!==je||e[85]!==oe?(J=s.jsx(Kn,{required:!0,info:je,children:oe}),e[84]=je,e[85]=oe,e[86]=J):J=e[86];let K;e[87]!==n.models||e[88]!==P||e[89]!==M||e[90]!==R?(K=s.jsx(uf,{selectedModels:n.models,onAdd:P,onRemove:M,onUpdate:R,minModels:1}),e[87]=n.models,e[88]=P,e[89]=M,e[90]=R,e[91]=K):K=e[91];let $;e[92]!==J||e[93]!==K?($=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[J,K]}),e[92]=J,e[93]=K,e[94]=$):$=e[94];let le;return e[95]!==ce||e[96]!==ve||e[97]!==$?(le=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[ce,ve,$]}),e[95]=ce,e[96]=ve,e[97]=$,e[98]=le):le=e[98],le},U3=t=>{const e=new Map;for(const n of t){const r=$s(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},K3=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},H3=t=>{const e=tt.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,u;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const d=ps(),h=U3(i),m=l.current?.runtimeKey===d?l.current.identities:null;for(const p of K3(m,h))ap({runtimeKey:d,...p});l.current={runtimeKey:d,identities:h}},u=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=u):(a=e[3],u=e[4]),c.useEffect(a,u)},G3=new Map,q3=t=>{const e=tt.c(26),{isVSCode:n}=t,r=Pa(),i=Kt(Q3),o=Kt(Y3),l=ts(X3),a=Je(J3);let u;e[0]!==n?(u=I=>n?G3:I.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const d=Je(u),h=!n;let m;e[2]!==d||e[3]!==i||e[4]!==h?(m=pf(i,d,{includeWorktrees:h}),e[2]=d,e[3]=i,e[4]=h,e[5]=m):m=e[5];const p=m,g=Ps(Z3),w=Ps(e4),v=Ps(t4),x=`session-list-sync:${c.useId()}`;let f,b;e[6]!==o||e[7]!==x||e[8]!==r||e[9]!==l||e[10]!==a||e[11]!==p||e[12]!==i?(f=()=>(r.setBootstrapDemand(x,rf({knownDirectories:p,activeProjectDirectory:yt(i.find(I=>I.id===o)?.path??null),activeProjectId:o,collapsedProjects:new Set,collapsedGroups:new Set,currentDirectory:l,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(x)),b=[o,x,r,l,a,p,i],e[6]=o,e[7]=x,e[8]=r,e[9]=l,e[10]=a,e[11]=p,e[12]=i,e[13]=f,e[14]=b):(f=e[13],b=e[14]),c.useEffect(f,b);const y=c.useRef(null);let S,N;e[15]!==n||e[16]!==p?(S=()=>{const I=new Set(p),M=y.current;y.current=I;const z=M?[...I].filter(R=>!M.has(R)):n?[...I]:[];z.length&&ga(z,Po())},N=[n,p],e[15]=n,e[16]=p,e[17]=S,e[18]=N):(S=e[17],N=e[18]),c.useEffect(S,N);let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[19]=C):C=e[19],c.useEffect(s4,C);let j;e[20]!==w||e[21]!==g?(j=[...g,...w],e[20]=w,e[21]=g,e[22]=j):j=e[22];const A=j;let P;e[23]!==A||e[24]!==v?(P={enabled:!0,hasAuthoritativeGlobalSessions:v,sessions:A},e[23]=A,e[24]=v,e[25]=P):P=e[25],H3(P)};function Q3(t){return t.projects}function Y3(t){return t.activeProjectId}function X3(t){return t.currentDirectory}function J3(t){return t.currentSessionDirectory}function Z3(t){return t.activeSessions}function e4(t){return t.archivedSessions}function t4(t){return t.status==="ready"}function s4(){let t=null,e=!1;const n=new Set,r=Yr(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),Ia(Po());return}const o=[...n];n.clear(),o.length&&ga(o,Po())},500)});return()=>{t&&clearTimeout(t),r()}}const n4=Ln(()=>_n(()=>import("./SettingsWindow-Cpb4hM6q.js"),__vite__mapDeps([140,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,141,84,142,127,128,129,130,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102,143,144])).then(t=>({default:t.SettingsWindow}))),r4=()=>{const t=tt.c(58);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],q3(e),pg();const n=De(o4),r=De(i4),i=De(a4),o=De(l4),[l,a]=c.useState(!1);let u,d;t[1]!==i?(u=()=>{i&&a(!0)},d=[i],t[1]=i,t[2]=u,t[3]=d):(u=t[2],d=t[3]),c.useEffect(u,d);const h=De(c4),m=De(d4),p=De(u4),g=De(f4),w=De(m4),v=De(h4),x=g||w||!!v||h;let f;t[4]===Symbol.for("react.memo_cache_sentinel")?(f=[],t[4]=f):f=t[4],c.useEffect(g4,f);const{isMobile:b}=Bn();gg();const y=Hx();let S,N;t[5]!==b||t[6]!==r?(S=()=>{De.getState().isMobile!==b&&r(b)},N=[b,r],t[5]=b,t[6]=r,t[7]=S,t[8]=N):(S=t[7],N=t[8]),c.useEffect(S,N);let C,j,A,P;t[9]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(PS,{}),j=s.jsx(Cv,{}),A=s.jsx(Pv,{}),P=s.jsx(Vk,{}),t[9]=C,t[10]=j,t[11]=A,t[12]=P):(C=t[9],j=t[10],A=t[11],P=t[12]);let I;t[13]!==y?(I=s.jsx(Uk,{value:y,onMoveSessionOnly:x4,onMoveAllChanges:b4,onCancel:tb}),t[13]=y,t[14]=I):I=t[14];let M;t[15]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(db,{}),t[15]=M):M=t[15];let z;t[16]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(cb,{}),t[16]=z):z=t[16];let R;t[17]!==n?(R=s.jsx(zk,{isVisible:n}),t[17]=n,t[18]=R):R=t[18];let H;t[19]!==b||t[20]!==n||t[21]!==R?(H=s.jsx(lb,{isOpen:n,isMobile:b,className:"border-border",topBar:z,children:R}),t[19]=b,t[20]=n,t[21]=R,t[22]=H):H=t[22];let F;t[23]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(ib,{}),t[23]=F):F=t[23];const O=x&&"invisible";let T;t[24]!==O?(T=Pe("absolute inset-0",O),t[24]=O,t[25]=T):T=t[25];const k=!i&&!x;let D;t[26]!==k?(D=s.jsx(Hs,{children:s.jsx(nu,{active:k})}),t[26]=k,t[27]=D):D=t[27];let L;t[28]!==T||t[29]!==D?(L=s.jsx("div",{className:T,children:D}),t[28]=T,t[29]=D,t[30]=L):L=t[30];let Q;t[31]!==h||t[32]!==p||t[33]!==m?(Q=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Hs,{children:s.jsx(z3,{isWindowed:!0,initialPrompt:p,onCreated:()=>m(!1),onCancel:()=>m(!1)})})}),t[31]=h,t[32]=p,t[33]=m,t[34]=Q):Q=t[34];let q;t[35]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(Hs,{children:s.jsx(x3,{})}),t[35]=q):q=t[35];let te;t[36]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(Hs,{children:s.jsx(b3,{})}),t[36]=te):te=t[36];let ae;t[37]===Symbol.for("react.memo_cache_sentinel")?(ae=s.jsx(Hs,{children:s.jsx(D3,{})}),t[37]=ae):ae=t[37];let X;t[38]!==L||t[39]!==Q?(X=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[L,Q,q,te,ae]}),t[38]=L,t[39]=Q,t[40]=X):X=t[40];let Z;t[41]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Zw,{}),t[41]=Z):Z=t[41];let se;t[42]!==X?(se=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[X,Z]})})}),t[42]=X,t[43]=se):se=t[43];let fe;t[44]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Hs,{children:s.jsx(cS,{})})}),t[44]=fe):fe=t[44];let B;t[45]!==se?(B=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[F,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[se,fe]})]}),t[45]=se,t[46]=B):B=t[46];let ne;t[47]!==H||t[48]!==B?(ne=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[H,B]}),t[47]=H,t[48]=B,t[49]=ne):ne=t[49];let ye;t[50]!==i||t[51]!==o||t[52]!==l?(ye=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(n4,{open:i,onOpenChange:o})}):null,t[50]=i,t[51]=o,t[52]=l,t[53]=ye):ye=t[53];let ce;return t[54]!==I||t[55]!==ne||t[56]!==ye?(ce=s.jsx(xg,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[C,j,A,P,I,M,ne,ye]})}),t[54]=I,t[55]=ne,t[56]=ye,t[57]=ce):ce=t[57],ce};function o4(t){return t.isSidebarOpen}function i4(t){return t.setIsMobile}function a4(t){return t.isSettingsDialogOpen}function l4(t){return t.setSettingsDialogOpen}function c4(t){return t.isMultiRunLauncherOpen}function d4(t){return t.setMultiRunLauncherOpen}function u4(t){return t.multiRunLauncherPrefillPrompt}function f4(t){return t.isScheduledTasksDialogOpen}function m4(t){return t.isArchivePageOpen}function h4(t){return t.worktreesPageProjectId}function p4(){return De.getState().closeMainSurfaces()}function g4(){const t=p4,e=Je.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function x4(){return Pu(!1)}function b4(){return Pu(!0)}const yf=12,y4=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],w4=t=>{const e=tt.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,u=r===void 0?0:r,d=o===void 0?900:o,h=l===void 0?y4:l,m=ht.useRef(!1);let p,g;e[0]!==n||e[1]!==a?(p=()=>{!n&&m.current&&a?.(),n&&(m.current=!0)},g=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=g):(p=e[2],g=e[3]),ht.useEffect(p,g);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:yf},S4),e[4]=w):w=e[4];const v=w;if(!n)return null;let x;e[5]!==i?(x=Pe("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=x):x=e[6];let f;if(e[7]!==u||e[8]!==h||e[9]!==d){let y;e[11]!==u||e[12]!==d?(y=S=>{const N={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${d}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:v.map((C,j)=>{const A=C.x*S.radius,P=C.y*S.radius,I={"--translate-x":`${A}px`,"--translate-y":`${P}px`,"--particle-delay":`${C.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:I},`${S.id}-${j}-${u}`)})},`${S.id}-${u}`)},e[11]=u,e[12]=d,e[13]=y):y=e[13],f=h.map(y),e[7]=u,e[8]=h,e[9]=d,e[10]=f}else f=e[10];let b;return e[14]!==u||e[15]!==x||e[16]!==f?(b=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":u,children:f}),e[14]=u,e[15]=x,e[16]=f,e[17]=b):b=e[17],b};function S4(t,e){const n=Math.PI*2*e/yf;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const v4=t=>{const e=tt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=ht.useState(o),u=ht.useRef(null);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},e[3]=d):d=e[3];const h=d;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{h(),a(j4)},e[4]=m):m=e[4];const p=m;let g;e[5]!==i?(g=()=>{h(),a(k4),u.current=window.setTimeout(()=>{a(C4),u.current=null},i)},e[5]=i,e[6]=g):g=e[6];const w=g;let v,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>h(),x=[h],e[7]=v,e[8]=x):(v=e[7],x=e[8]),ht.useEffect(v,x);let f;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(f={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=f):f=e[12],f};function j4(t){return t.isActive?{...t,isActive:!1}:t}function k4(t){return{isActive:!0,cycle:t.cycle+1}}function C4(t){return t.isActive?{...t,isActive:!1}:t}const wf=c.createContext(void 0),N4=t=>{const e=tt.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=v4();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const u=a;let d;e[3]!==i||e[4]!==r?(d=s.jsx(w4,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let h;return e[6]!==n||e[7]!==d||e[8]!==u?(h=s.jsxs(wf.Provider,{value:u,children:[n,d]}),e[6]=n,e[7]=d,e[8]=u,e[9]=h):h=e[9],h},c5=()=>{const t=c.useContext(wf);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ca="aiworker_requests_in_flight",Sf=1e3,A4=300*1e3,Lo=Math.ceil(A4/Sf),D4=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ca)==="1"}catch{return!1}},vf=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let P4=1;const I4=(t,e)=>{const n=window.__aiworkerRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},T4=t=>{const e=window.__aiworkerRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},jf=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},gr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},R4=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=P4++;I4(o,Date.now());try{return await e(r,i)}finally{T4(o)}};window.fetch=n},Vc=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Ir=t=>{t.length>Lo&&t.splice(0,t.length-Lo)},E4=()=>{const t=window.__aiworkerRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=jf(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(gr(e,50)),t.p90Samples.push(gr(e,90)),t.p99Samples.push(gr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Ir(t.samples),Ir(t.p50Samples),Ir(t.p90Samples),Ir(t.p99Samples),Ir(t.maxSamples),t.lastSampleAt=Date.now()},M4=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(E4,Sf))},Uc=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Kc=t=>{if(!(typeof window>"u"))try{if(t){Uc(),Vc(),window.localStorage.setItem(ca,"1"),window.__aiworkerRequestsInFlight__=vf(),R4(),M4();return}window.localStorage.removeItem(ca),Uc(),Vc(),delete window.__aiworkerRequestsInFlight__}catch{}},O4=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;if(!t)return;const e=vf();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},da=()=>{if(typeof window>"u")return Hc();const t=window.__aiworkerRequestsInFlight__;if(!D4()||!t)return Hc();const e=jf(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:gr(e,50),ageP90:gr(e,90),ageP99:gr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Lo}},Hc=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Lo});function F4(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const kf=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},ua=t=>`${(t/1e3).toFixed(2)} s`,ys=t=>{const e=tt.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Gc=t=>{const e=tt.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=At();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let u;e[8]!==r.entries?(u=r.entries.reduce(L4,0),e[8]=r.entries,e[9]=u):u=e[9];const d=u;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let m;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(m=r.startedAt?kf(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=m):m=e[15];let p;e[16]!==m?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:m}),e[16]=m,e[17]=p):p=e[17];let g;e[18]!==h||e[19]!==p?(g=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,p]}),e[18]=h,e[19]=p,e[20]=g):g=e[20];let w;e[21]!==o?(w=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=w):w=e[22];let v;e[23]!==r.entries.length||e[24]!==w?(v=s.jsx(ys,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=v):v=e[25];let x;e[26]!==o?(x=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=x):x=e[27];let f;e[28]!==x||e[29]!==d?(f=s.jsx(ys,{label:x,value:d}),e[28]=x,e[29]=d,e[30]=f):f=e[30];let b;e[31]!==o?(b=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=b):b=e[32];let y;e[33]!==r.lastUpdatedAt||e[34]!==o?(y=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=y):y=e[35];let S;e[36]!==b||e[37]!==y?(S=s.jsx(ys,{label:b,value:y}),e[36]=b,e[37]=y,e[38]=S):S=e[38];let N;e[39]!==f||e[40]!==S||e[41]!==v?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,f,S]}),e[39]=f,e[40]=S,e[41]=v,e[42]=N):N=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[g,N,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(ln,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:C.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},qc=t=>{const e=tt.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,u=n.reduce($4,0),d=r>0?52/r:0;let h;e[0]!==u||e[1]!==a?(h=S=>a-u+S,e[0]=u,e[1]=a,e[2]=h):h=e[2];const m=h;let p;e[3]!==d?(p=S=>56-S*d,e[3]=d,e[4]=p):p=e[4];const g=p;let w;e[5]!==l?(w=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=w):w=e[6];const v=`0 0 ${a} 56`;let x;e[7]!==a?(x=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=x):x=e[8];let f;if(e[9]!==n||e[10]!==m||e[11]!==g){let S;e[13]!==m||e[14]!==g?(S=(N,C)=>{const j=N.samples.length;if(j===0)return null;const A=N.samples.map((I,M)=>`${m(M)},${g(I).toFixed(2)}`),P=`M ${A.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${m(0)},56 L ${A.join(" L ")} L ${m(j-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:P,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=m,e[14]=g,e[15]=S):S=e[15],f=n.map(S),e[9]=n,e[10]=m,e[11]=g,e[12]=f}else f=e[12];let b;e[16]!==o||e[17]!==v||e[18]!==x||e[19]!==f?(b=s.jsxs("svg",{viewBox:v,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[x,f]}),e[16]=o,e[17]=v,e[18]=x,e[19]=f,e[20]=b):b=e[20];let y;return e[21]!==w||e[22]!==b?(y=s.jsxs("div",{className:"relative w-full",children:[w,b]}),e[21]=w,e[22]=b,e[23]=y):y=e[23],y},_4=t=>{const e=tt.c(100),{onClose:n}=t,{t:r}=At(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),u=Je(W4),d=$d(z4),h=Nd(),m=lp(V4),p=Ks(U4),[g,w]=c.useState(K4),[v,x]=c.useState(H4),[f,b]=c.useState(G4),y=[{label:"p50",current:f.ageP50,samples:f.p50Samples,color:"var(--status-success)"},{label:"p90",current:f.ageP90,samples:f.p90Samples,color:"var(--status-info)"},{label:"p99",current:f.ageP99,samples:f.p99Samples,color:"var(--status-warning)"},{label:"max",current:f.ageMax,samples:f.maxSamples,color:"var(--status-error)"}];let S;e[0]!==f.samples?(S=f.samples.reduce(q4,0),e[0]=f.samples,e[1]=S):S=e[1];const N=S,C=y.reduce(Y4,0);let j;e[2]!==g.entries?(j=new Map,g.entries.forEach(Ee=>{j.set(Ee.metric,Ee.count)}),e[2]=g.entries,e[3]=j):j=e[3];let A;e[4]!==j?(A=j.get("ui.message_list.render")??0,e[4]=j,e[5]=A):A=e[5];let P;e[6]!==j?(P=j.get("ui.message_list.render.streaming")??0,e[6]=j,e[7]=P):P=e[7];let I;e[8]!==j?(I=j.get("ui.chat_message.render")??0,e[8]=j,e[9]=I):I=e[9];let M;e[10]!==j?(M=j.get("ui.chat_message.render.streaming")??0,e[10]=j,e[11]=M):M=e[11];let z;e[12]!==j?(z=j.get("ui.chat_message.render.static_during_stream")??0,e[12]=j,e[13]=z):z=e[13];let R;e[14]!==j?(R=j.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=j,e[15]=R):R=e[15];let H;e[16]!==A||e[17]!==P||e[18]!==I||e[19]!==M||e[20]!==z||e[21]!==R?(H={messageListRender:A,messageListRenderStreaming:P,chatMessageRender:I,chatMessageRenderStreaming:M,chatMessageRenderStaticDuringStream:z,chatMessageRenderStaticOutsideActiveTurnDuringStream:R},e[16]=A,e[17]=P,e[18]=I,e[19]=M,e[20]=z,e[21]=R,e[22]=H):H=e[22];const F=H;let O,T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const Ee=()=>{w(fo()),x(mo()),b(da())};Ee();const Ie=window.setInterval(Ee,500);return()=>window.clearInterval(Ie)},O=[],e[23]=O,e[24]=T):(O=e[23],T=e[24]),c.useEffect(T,O);let k,D;e[25]!==l?(k=()=>{if(l==="idle")return;const Ee=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Ee)},D=[l],e[25]=l,e[26]=k,e[27]=D):(k=e[26],D=e[27]),c.useEffect(k,D);let L=0,Q=0,q=0;for(const Ee of Object.keys(m)){const Ie=m[Ee]??[];Q=Q+Ie.length;for(const rt of Ie)rt.role==="user"?q=q+1:rt.role==="assistant"&&(L=L+1)}let te;e[28]!==L||e[29]!==Q||e[30]!==q?(te={assistant:L,total:Q,user:q},e[28]=L,e[29]=Q,e[30]=q,e[31]=te):te=e[31];const ae=te;let X;if(e[32]!==u||e[33]!==m||e[34]!==d||e[35]!==h||e[36]!==r){let Ee;e[38]!==u||e[39]!==m||e[40]!==d||e[41]!==r?(Ee=Ie=>{const rt=m[Ie.id]??[];let Ge=0,ut=0;for(const ue of rt)ue.role==="user"?ut=ut+1:ue.role==="assistant"&&(Ge=Ge+1);const ct=d.get(Ie.id);return{id:Ie.id,title:Ie.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:Ge,messageCount:rt.length,userMessageCount:ut,isStreaming:ct?.isStreaming||!1,isZombie:ct?.isZombie||!1,backgroundCount:ct?.backgroundMessageCount||0,lastAccessed:ct?.lastAccessedAt||0,isCurrent:Ie.id===u}},e[38]=u,e[39]=m,e[40]=d,e[41]=r,e[42]=Ee):Ee=e[42],X=h.map(Ee).sort(X4),e[32]=u,e[33]=m,e[34]=d,e[35]=h,e[36]=r,e[37]=X}else X=e[37];const Z=X;let se;e[43]!==m?(se=Object.keys(m),e[43]=m,e[44]=se):se=e[44];const fe=se.length;let B;e[45]===Symbol.for("react.memo_cache_sentinel")?(B=async()=>{try{const Ee={generatedAt:new Date().toISOString(),ui:fo(),vscode:mo()};await navigator.clipboard.writeText(JSON.stringify(Ee,null,2)),a("copied")}catch{a("error")}},e[45]=B):B=e[45];const ne=B,ye=dp,ce="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let _;e[46]===Symbol.for("react.memo_cache_sentinel")?(_={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=_):_=e[46];let re;e[47]!==i?(re=F4(i),e[47]=i,e[48]=re):re=e[48];let me;e[49]!==re?(me=s.jsx(E,{name:re,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=re,e[50]=me):me=e[50];let de;e[51]!==r?(de=r("memoryDebugPanel.title"),e[51]=r,e[52]=de):de=e[52];let ge;e[53]!==de?(ge=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:de}),e[53]=de,e[54]=ge):ge=e[54];let Te;e[55]!==me||e[56]!==ge?(Te=s.jsxs("div",{className:"flex items-center gap-2",children:[me,ge]}),e[55]=me,e[56]=ge,e[57]=Te):Te=e[57];let be;e[58]!==i?(be=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(pt,{size:"xs",variant:"ghost",onClick:ne,children:s.jsx(E,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(pt,{size:"xs",variant:"ghost",onClick:()=>{am(),w(fo()),x(mo())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=be):be=e[59];let Re;e[60]!==i?(Re=i==="requests"?s.jsx(pt,{size:"xs",variant:"ghost",onClick:()=>{O4(),b(da())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=Re):Re=e[61];let we;e[62]!==n?(we=n?s.jsx(pt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=we):we=e[63];let Y;e[64]!==be||e[65]!==Re||e[66]!==we?(Y=s.jsxs("div",{className:"flex items-center gap-1",children:[be,Re,we]}),e[64]=be,e[65]=Re,e[66]=we,e[67]=Y):Y=e[67];let ve;e[68]!==Te||e[69]!==Y?(ve=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Te,Y]}),e[68]=Te,e[69]=Y,e[70]=ve):ve=e[70];let xe;e[71]===Symbol.for("react.memo_cache_sentinel")?(xe={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=xe):xe=e[71];const je=i==="memory"?"secondary":"ghost";let oe;e[72]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>o("memory"),e[72]=oe):oe=e[72];let J;e[73]!==r?(J=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=J):J=e[74];let K;e[75]!==je||e[76]!==J?(K=s.jsx(pt,{size:"sm",variant:je,className:"flex-1",onClick:oe,children:J}),e[75]=je,e[76]=J,e[77]=K):K=e[77];const $=i==="streaming"?"secondary":"ghost";let le;e[78]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("streaming"),e[78]=le):le=e[78];let V;e[79]!==r?(V=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=V):V=e[80];let Ce;e[81]!==$||e[82]!==V?(Ce=s.jsx(pt,{size:"sm",variant:$,className:"flex-1",onClick:le,children:V}),e[81]=$,e[82]=V,e[83]=Ce):Ce=e[83];const Be=i==="requests"?"secondary":"ghost";let ke;e[84]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>o("requests"),e[84]=ke):ke=e[84];let Ne;e[85]!==r?(Ne=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Ne):Ne=e[86];let Qe;e[87]!==Be||e[88]!==Ne?(Qe=s.jsx(pt,{size:"sm",variant:Be,className:"flex-1",onClick:ke,children:Ne}),e[87]=Be,e[88]=Ne,e[89]=Qe):Qe=e[89];let We;e[90]!==K||e[91]!==Ce||e[92]!==Qe?(We=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:xe,children:[K,Ce,Qe]}),e[90]=K,e[91]=Ce,e[92]=Qe,e[93]=We):We=e[93];const U=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ys,{label:r("memoryDebugPanel.metric.totalMessages"),value:ae.total}),s.jsx(ys,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${fe} / ${ul.MAX_SESSIONS}`}),s.jsx(ys,{label:r("memoryDebugPanel.metric.userMessages"),value:ae.user}),s.jsx(ys,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ae.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:cp()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:ul.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:p})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(ln,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:Z.map(Ee=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Ee.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Ee.title}),Ee.isStreaming?s.jsx(E,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Ee.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Ee.assistantMessageCount,user:Ee.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Ee.messageCount})}),Ee.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Ee.backgroundCount]}):null]})]},Ee.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Dt,{children:[s.jsx(Pt,{asChild:!0,children:s.jsx(pt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(J4),currentSessionId:u,cachedSessions:Object.keys(m),messageRoleCounts:ae,sessionMessageRoleCounts:Z.map(Z4),memoryStates:Object.fromEntries(d)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(It,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(pt,{size:"xs",variant:"outline",onClick:ne,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ys,{label:r("memoryDebugPanel.metric.uiMetrics"),value:g.entries.length}),s.jsx(ys,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),s.jsx(ys,{label:r("memoryDebugPanel.metric.messageListRenders"),value:F.messageListRender}),s.jsx(ys,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:F.messageListRenderStreaming}),s.jsx(ys,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:F.chatMessageRender}),s.jsx(ys,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:F.chatMessageRenderStreaming}),s.jsx(ys,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:F.chatMessageRenderStaticDuringStream}),s.jsx(ys,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:F.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Gc,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:g,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?s.jsx(Gc,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:v,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ys,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${f.totalSettled} / ${f.totalStarted}`}),s.jsx(ys,{label:r("memoryDebugPanel.requests.tracking"),value:f.startedAt?kf(f.durationMs):r("memoryDebugPanel.common.idle")})]}),f.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:f.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:f.peak})]})]}),s.jsx(qc,{series:[{samples:f.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:f.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:f.peak}),maxLabel:`${N}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ua(f.peakAgeMs)})]}),s.jsx(qc,{series:y.map(eC),peak:C,windowSeconds:f.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:ua(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:y.map(tC)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:f.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let he;return e[94]!==ye||e[95]!==_||e[96]!==ve||e[97]!==We||e[98]!==U?(he=s.jsxs(ye,{className:ce,style:_,children:[ve,We,U]}),e[94]=ye,e[95]=_,e[96]=ve,e[97]=We,e[98]=U,e[99]=he):he=e[99],he},B4=_4;function L4(t,e){return t+e.count}function $4(t,e){return Math.max(t,e.samples.length)}function W4(t){return t.currentSessionId}function z4(t){return t.sessionMemoryState}function V4(t){return t.message}function U4(t){return t.totalRequestCount}function K4(){return fo()}function H4(){return mo()}function G4(){return da()}function q4(t,e){return Math.max(t,e)}function Q4(t,e){return Math.max(t,e)}function Y4(t,e){return e.samples.reduce(Q4,t)}function X4(t,e){return e.lastAccessed-t.lastAccessed}function J4(t){return{id:t.id,title:t.title}}function Z4(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function eC(t){return{samples:t.samples,color:t.color}}function tC(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ua(t.current)})]},t.label)}const sC=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},nC=async()=>{const t=sC()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Qc="aiworker:menu-action",bi="aiworker:check-for-updates",rC=t=>{const e=Je(f=>f.openNewSessionDraft),n=De(f=>f.toggleCommandPalette),r=De(f=>f.setCommandPaletteOpen),i=De(f=>f.toggleHelpDialog),o=De(f=>f.toggleSidebar),l=De(f=>f.setSessionSwitcherOpen),a=De(f=>f.setSettingsDialogOpen),u=De(f=>f.setAboutDialogOpen),d=Or(f=>f.checkForUpdates),{setThemeMode:h}=Zn(),m=c.useRef(!1),p=c.useCallback(()=>{m.current||(m.current=!0,d().then(()=>{const{available:f,error:b}=Or.getState();if(b){Me.error("Failed to check for updates",{description:b});return}f||Me.success("You are on the latest version")}).finally(()=>{m.current=!1}))},[d]),g=c.useCallback(()=>{gn.requestDirectoryDialog()},[]),w=c.useCallback(f=>{const b=up();if(b.length===0)return;const y=Je.getState().currentSessionId,S=b.findIndex(j=>j.id===y);let N=f>0?0:b.length-1;S>=0&&(N=(S+f+b.length)%b.length);const C=b[N];C&&(l(!1),Je.getState().setCurrentSession(C.id))},[l]),v=c.useCallback(f=>{const{activeProjectId:b,projects:y,setActiveProject:S}=Kt.getState();if(y.length===0)return;const N=y.findIndex(A=>A.id===b);let C=f>0?0:y.length-1;N>=0&&(C=(N+f+y.length)%y.length);const j=y[C];j&&S(j.id)},[]),x=c.useCallback(f=>{switch(f){case"about":u(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const b=Je.getState(),y=ts.getState().currentDirectory;e(b.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":l(!1),Rd();break;case"change-workspace":g();break;case"toggle-right-sidebar":{const b=ts.getState().currentDirectory;if(!b)break;const y=De.getState(),S=rr(b),N=y.contextPanelByDirectory[S];N?.isOpen?y.closeContextPanel(S):N?.activeTabId?y.setActiveContextPanelTab(S,N.activeTabId):y.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const b=ts.getState().currentDirectory;if(!b)break;De.getState().openContextSurface(rr(b),"git");break}case"open-right-sidebar-files":{const b=ts.getState().currentDirectory;if(!b)break;De.getState().openContextSurface(rr(b),"file");break}case"toggle-terminal":{const b=ts.getState().currentDirectory;if(!b)break;De.getState().openContextSurface(rr(b),"terminal");break}case"toggle-terminal-expanded":{const b=ts.getState().currentDirectory;if(!b)break;const y=rr(b),S=De.getState(),N=S.contextPanelByDirectory[y];(N?.isOpen?N.tabs.find(j=>j.id===N.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(y,"terminal"),S.toggleContextPanelExpanded(y);break}case"copy":{const b=new Event("aiworker:copy",{cancelable:!0});!window.dispatchEvent(b)||nC();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":fp();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ts.getState().goBack();break;case"go-forward":ts.getState().goForward();break;case"previous-session":w(-1);break;case"next-session":w(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":i();break;case"download-logs":{Ed().catch(()=>{Me.error("Failed to collect OpenCode status")});break}}},[g,v,w,t,e,u,l,r,a,h,n,i,o]);c.useEffect(()=>{const f=y=>{const S=y.detail;S&&x(S)},b=()=>{p()};return window.addEventListener(Qc,f),window.addEventListener(bi,b),()=>{window.removeEventListener(Qc,f),window.removeEventListener(bi,b)}},[x,p]),c.useEffect(()=>{if(typeof window>"u")return;const b=window.__AIWORKER_DESKTOP__?.listen;if(typeof b!="function")return;let y=null,S=null;return b("aiworker:menu-action",N=>{const C=N?.payload;typeof C=="string"&&x(C)}).then(N=>{y=N}).catch(()=>{}),b("aiworker:check-for-updates",()=>{window.dispatchEvent(new Event(bi))}).then(N=>{S=N}).catch(()=>{}),()=>{(async()=>{try{const C=y?.();C instanceof Promise&&await C}catch{}try{const C=S?.();C instanceof Promise&&await C}catch{}})()}},[x])},oC="aiworker:tray-action",Yc=5e3,iC=500,Cf=20,Xc=()=>{if(typeof window>"u")return!1;const t=window.__AIWORKER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Jc=()=>typeof window<"u"&&window.__AIWORKER_ELECTRON__?.trayEnabled!==!1,aC=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},lC=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Nf=(t,e)=>Vd(t,e,$r.getState().ids,va.getState().rankById),cC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},dC=(t,e,n,r,i)=>{if(!t)return"";const o=ud(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||cC(t),u=go(t);let d=u&&i.get(u)||"";if(!d){for(const[h,m]of On.getState().directories)if(go(h)===u){d=m.status?.current??"";break}}if(!d)for(const h of r.values()){const m=h.find(p=>go(p.path)===u);if(m?.branch){d=m.branch;break}}return d?`${a} · ${d}`:a},uC=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ir.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of pp){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const u=[];for(const[h,m]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?m.remainingPercent:m.usedPercent;u.push({label:xp(h),value:gp(m.valueLabel,p)})}const d=!a.ok&&a.error?a.error:u.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:u,status:d})}return{mode:r,groups:o}},fC=async()=>{try{if($o())return"Local AiWorker";const t=window.__AIWORKER_LOCAL_ORIGIN__||window.location.origin,e=Nn();if(e&&Ha(e,t))return"Local AiWorker";const r=(await od()).hosts.find(i=>e?Ha(e,lm(i)):!1);return r?.label?.trim()?id(r.label.trim()):"Instance"}catch{return""}},mC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Do()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(go(o)??o,a.vcs.branch);for(const u of a.session)u?.id&&r.set(u.id,u.title);for(const[u,d]of Object.entries(a.session_status??{})){const h=d?.type,m=h==="busy"?"busy":h==="retry"?"retry":"idle",p=t.get(u);(!p||p==="idle")&&t.set(u,m)}for(const[u,d]of Object.entries(a.permission??{}))for(const h of d??[]){if(!h?.id)continue;const m=h.sessionID||u;n.push({kind:"permission",id:h.id,sessionId:m,sessionTitle:"",label:aC(h),directory:o})}for(const[u,d]of Object.entries(a.question??{}))for(const h of d??[]){if(!h?.id)continue;const m=h.sessionID||u;n.push({kind:"question",id:h.id,sessionId:m,sessionTitle:"",label:lC(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},hC=()=>{const t=Ps.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Nf).slice(0,Cf).forEach(r=>{const i=$s(r);i&&e.add(i)});const n=new Map;for(const r of t){if(!r?.id)continue;const i=$s(r);if(!i||!e.has(i))continue;const o=n.get(i)??[];o.push(r.id),n.set(i,o)}return n},pC=t=>{const e=mC(),n=Aa.getState().index.session,r=Ps.getState().activeSessions,i=new Map(e.titleById),o=new Map;for(const x of r)if(x?.id&&(x.title&&i.set(x.id,x.title),x.parentID)){const f=o.get(x.parentID)??[];f.push(x.id),o.set(x.parentID,f)}const l=x=>{const f=[],b=[...o.get(x)??[]],y=new Set;for(;b.length;){const S=b.pop();y.has(S)||(y.add(S),f.push(S),b.push(...o.get(S)??[]))}return f},a=Na.getState().statusById,u=x=>{const f=e.statusById.get(x);return f&&f!=="idle"?f:a.get(x)?.status.type??f??"idle"},d=x=>{const f=x.map(b=>u(b));return f.includes("busy")?"busy":f.includes("retry")?"retry":"idle"},h=Kt.getState().projects,m=Je.getState().availableWorktreesByProject,p=r.filter(x=>x?.id&&!x.parentID).slice().sort(Nf).slice(0,Cf).map(x=>{const f=[x.id,...l(x.id)],b=$s(x)??"";return{id:x.id,title:x.title||"Untitled session",status:d(f),branch:b?e.branchByDirectory.get(b)??"":"",unseen:f.reduce((y,S)=>y+(n.unseenCount[S]??0),0),hasError:f.some(y=>n.unseenHasError[y]??!1),directory:b,subtitle:dC(b,x,h,m,e.branchByDirectory)}}),g=e.approvals.map(x=>({...x,sessionTitle:i.get(x.sessionId)||""})),w=De.getState();let v=0;if(w.dockBadgeEnabled)for(const x of r){if(!x?.id||x.parentID)continue;let f=n.unseenCount[x.id]??0;f===0&&w.notifyOnSubtasks&&(f=l(x.id).reduce((b,y)=>b+(n.unseenCount[y]??0),0)),f>0&&(v+=1)}return{sessions:p,approvals:g,instanceName:t,usage:uC(),dockBadgeCount:v}},gC=()=>{c.useEffect(()=>{if(!Xc()||!Jc()||!zo())return;let t=!1,e="",n=null,r="";const i=()=>{if(t)return;const C=pC(r),j=JSON.stringify(C);j!==e&&(e=j,En("desktop_tray_update",C))};fC().then(C=>{t||(r=C,i())});const o=async()=>{const C=hC();await Promise.all([...C.entries()].map(async([j,A])=>{const P=await qs.getSessionStatusForDirectory(j).catch(()=>null);t||P===null||mp(j,P,A)}))},l=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,i()},iC))},a=new Map,u=()=>{if(t)return;let C;try{C=Do()}catch{return}const j=new Set;for(const[A,P]of C.children.entries())j.add(A),a.has(A)||a.set(A,P.subscribe(()=>l()));for(const[A,P]of a)j.has(A)||(P(),a.delete(A))};let d=null;try{d=Do().subscribeRegistry(()=>{u(),l()})}catch{}u();const h=Aa.subscribe(()=>l()),m=Ps.subscribe(()=>l()),p=Kt.subscribe(()=>l()),g=Je.subscribe(()=>l()),w=On.subscribe(()=>l()),v=De.subscribe(()=>l()),x=Na.subscribe(()=>l()),f=va.subscribe(()=>l()),b=$r.subscribe(()=>l());o();const y=window.setInterval(()=>{o()},Yc),S=ir.subscribe(()=>l());ir.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:C,results:j}=ir.getState();C.length>0&&C.some(P=>!j.some(I=>I.providerId===P))&&ir.getState().fetchQuotas(C)});const N=window.setInterval(()=>{u(),i()},Yc);return i(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(N),window.clearInterval(y),h(),m(),p(),g(),w(),v(),x(),f(),b(),S(),d?.();for(const C of a.values())C();a.clear()}},[]),c.useEffect(()=>{if(!Xc()||!Jc()||typeof window>"u")return;const e=window.__AIWORKER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&hp(i.sessionId,i.id,i.response).catch(()=>{Me.error("Failed to respond to permission request")})};let r=null;return e(oC,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},xC=45e3,bC=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,xC);return()=>r(i)},yC=t=>{const e=tt.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return bC(wC,SC)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function wC(){bp(Po())}function SC(){Ia()}const vC="/api/notifications/stream",jC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),kC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="aiworker:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},CC=t=>{const e=tt.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||xn()||!ma()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(ld().sse(vC));return o.onmessage=NC,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function NC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=De.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&jC())return;const r=kC(e);if(!r)return;Wo()?.notifications?.notifyAgentCompletion(r)}const AC=6e4,DC=t=>{const e=tt.c(10),n=De(PC),r=yp(IC),o=bg(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:AC})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let u,d;e[5]!==n||e[6]!==r||e[7]!==o?(u=()=>{if(n)return Yr(h=>{h.type==="agent-memory-changed"&&r(o)})},d=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=u,e[9]=d):(u=e[8],d=e[9]),c.useEffect(u,d)};function PC(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function IC(t){return t.load}const Zc="pwa-install-toast-shown",ed="pwa-install-toast-dismissed",TC=()=>{const t=tt.c(6),{browserTab:e}=yg(),{t:n}=At(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!ma()||!e)return;let u=null,d=null;const h=()=>{d!==null&&(Me.dismiss(d),d=null)},m=async()=>{if(!u)return;const w=u;u=null,h(),await w.prompt();const{outcome:v}=await w.userChoice;v==="accepted"&&Me.success(r.current("pwa.installPrompt.started"))},p=w=>{const v=w;if(typeof v.prompt!="function")return;v.preventDefault(),u=v;const x=No(),f=cm();wg({dismissed:x.getItem(ed),sessionShown:f.getItem(Zc),hasActiveToast:d!==null})&&(f.setItem(Zc,"true"),d=Me.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{m()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{No().setItem(ed,"true"),h()}}}))},g=()=>{u=null,h(),Me.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",g),()=>{h(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",g)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},RC=({open:t,onOpenChange:e})=>{const{t:n}=At(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[u,d]=c.useState(!1),[h,m]=c.useState(!1),[p,g]=c.useState(null),[w,v]=c.useState(!1);c.useCallback(async()=>{},[p,u,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const b=await ds("/api/system/info");if(b.ok){const y=await b.json();if(typeof y.aiworkerVersion=="string"&&y.aiworkerVersion.trim()){o(y.aiworkerVersion);return}}}catch{}o(await wp())})()},[t]),c.useEffect(()=>{if(!t)return;let f=!1;return(async()=>{try{const y=await ds("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!y.ok)return;const S=await y.json().catch(()=>null),N=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!f&&N&&a(N)}catch{}})(),()=>{f=!0}},[t]),c.useEffect(()=>{{g(null),v(!1);return}},[t,r]);const x=i;return s.jsx(ws,{open:t,onOpenChange:e,children:s.jsx(Ss,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Ad,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"AiWorker"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://roweb.cn/roweb/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(E,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(E,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(E,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@aiworker_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},td=t=>{if(!(typeof window>"u")){if(t){window.location.href="aiworker://focus/mcp-auth";return}window.location.replace("/")}},yi=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},EC=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to AiWorker and click Authorize again.":n},MC=()=>{const t=Sp(a=>a.completeAuth),[e,n]=c.useState("working"),[r,i]=c.useState(!1),[o,l]=c.useState("Completing MCP authorization...");return c.useEffect(()=>{if(typeof window>"u"){n("error"),l("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),u=yi(a,"code"),d=vp(a),h=jp(a),m=yi(a,"error"),p=yi(a,"error_description");if(m){h&&ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(p??m);return}(async()=>{try{if(!u)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into AiWorker manually.");let g=d,w=!1;if(h){const v=await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(v.ok){const x=await v.json().catch(()=>null);w=x?.origin===kp,i(w),!g&&x?.name?.trim()&&(g={name:x.name.trim(),directory:typeof x.directory=="string"&&x.directory.trim()?x.directory.trim():null})}}if(!g?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into AiWorker manually.");await t(g.name,u,g.directory),h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&td(!0),l("Authorization completed. You can close this tab and return to AiWorker.")}catch(g){h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(EC(g,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("h1",{className:Cp,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Pe("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:o})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(pt,{type:"button",onClick:()=>td(r),children:"Return to AiWorker"})})]})})},sd=Ln(()=>_n(()=>import("./OnboardingScreen-DIp84OWt.js"),__vite__mapDeps([145,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),OC=()=>{const t=tt.c(3),e=De(WC),n=De(zC);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(RC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},FC=t=>{const e=tt.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=At();let o;e[0]!==i?(o=i("startup.initRecovery.title"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=s.jsx("h1",{className:"typography-title text-foreground",children:o}),e[2]=o,e[3]=l):l=e[3];let a;e[4]!==i?(a=i("startup.initRecovery.description"),e[4]=i,e[5]=a):a=e[5];let u;e[6]!==a?(u=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==u?(d=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,u]}),e[8]=l,e[9]=u,e[10]=d):d=e[10];let h;e[11]!==r||e[12]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=h):h=e[13];let m;e[14]!==r||e[15]!==n||e[16]!==h?(m=s.jsx(pt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=m):m=e[17];let p;return e[18]!==d||e[19]!==m?(p=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[d,m]})}),e[18]=d,e[19]=m,e[20]=p):p=e[20],p},nd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",_C=()=>{if(typeof window>"u"||!Kg())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},BC=()=>typeof window>"u"?!1:window.location.pathname===Ip,LC=t=>{const e=tt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ts(VC),l=Je(UC),a=Je(KC),u=vd(),d=c.useRef(null);let h;e[0]!==n.directory?(h=nd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const m=h;let p;e[2]!==o?(p=nd(o),e[2]=o,e[3]=p):p=e[3];const g=p;let w,v;if(e[4]!==g||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==m||e[9]!==r||e[10]!==a||e[11]!==u?(w=()=>{if(r||m&&g!==m)return;const N=`${m}
|
|
930
|
+
${n.sessionId}`;d.current===N&&l||(d.current=N,a(n.sessionId,n.directory),u.ensureSessionRenderable(n.sessionId,!0))},v=[g,l,n.directory,n.sessionId,m,r,a,u],e[4]=g,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=m,e[9]=r,e[10]=a,e[11]=u,e[12]=w,e[13]=v):(w=e[12],v=e[13]),c.useEffect(w,v),m&&g!==m)return null;let x;e[14]!==i?(x=s.jsx(Gd,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=x):x=e[15];let f;e[16]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(ru,{}),e[16]=f):f=e[16];let b;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(b=s.jsx(nu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=b):b=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(qd,{}),e[21]=y):y=e[21];let S;return e[22]!==x||e[23]!==b?(S=s.jsxs(s.Fragment,{children:[x,f,b,y]}),e[22]=x,e[23]=b,e[24]=S):S=e[24],S};function $C({apis:t}){c.useEffect(()=>{dm("App:mounted"),um()&&console.info("[startup-trace] enabled. Run console.table(window.__AIWORKER_STARTUP_TRACE__) after startup.")},[]);const e=Gt(_=>_.initializeApp),n=Gt(_=>_.isInitialized),r=Gt(_=>_.isConnected),i=Gt(_=>_.providers.length),o=Gt(_=>_.agents.length),l=Gt(_=>_.loadProviders),a=Gt(_=>_.loadAgents),u=Je(_=>_.error),d=Je(_=>_.clearError),h=ts(_=>_.currentDirectory),m=ts(_=>_.setDirectory),p=ts(_=>_.isSwitchingDirectory),[g,w]=c.useState(!1),v=An(_=>_.refreshStatus),x=ki(_=>_.refreshStatus),[f,b]=c.useState(()=>t.runtime.isVSCode),[y,S]=c.useState(!1),[N,C]=c.useState(!1),[j,A]=c.useState(0),[P,I]=c.useState(0),[M,z]=c.useState(!1),R=De(_=>_.wideChatLayoutEnabled),H=De(_=>_.mobileKeyboardMode),F=c.useMemo(()=>xn(),[]),O=xa(_=>_.setPlanModeEnabled),[T,k]=c.useState(()=>Ga()),[D,L]=c.useState(()=>{const _=qa();return _!==null?Qa({isDesktopShell:!0,bootOutcome:_}):null}),Q=c.useRef(!1),q=c.useMemo(()=>_C(),[]),te=!q||y,ae=c.useMemo(()=>BC(),[]);c.useEffect(()=>(Ya(g),()=>{Ya(!1)}),[g]),c.useEffect(()=>(Kc(g),()=>{Kc(!1)}),[g]),c.useEffect(()=>{fm(H)},[H]),c.useEffect(()=>{b(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>fa(_=>{Sg(_),I(re=>re+1),C(!1),A(re=>re+1)}),[]);const X=fl(_=>{const re=ps();return Object.values(_.runsByOriginalSessionID).filter(me=>me.status==="running"&&me.runtimeKey===re).map(me=>`${me.originalSessionID}:${me.phase}:${me.lastForwardedMessageID??""}:${me.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(q)return;const _=ps(),re=Object.values(fl.getState().runsByOriginalSessionID).filter(me=>me.status==="running"&&me.runtimeKey===_);for(const me of re)Np(me.originalSessionID)},[X,q,P]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",R),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[R]),c.useEffect(()=>(Xa(t),()=>Xa(null)),[t]),c.useEffect(()=>{q||(v(t.github,{force:!0}),x(t.linear,{force:!0}))},[t.github,t.linear,q,r,v,x,P]),Ap();const Z=T==="valid",se=D?.screen==="main";c.useEffect(()=>{if(!mm({isDesktopShell:F,isInitialized:n,bootOutcomeKnown:Z,bootViewIsMain:se}))return;const _=setTimeout(()=>{const re=document.getElementById("initial-loading");re&&(re.classList.add("fade-out"),setTimeout(()=>{re.remove()},300))},150);return()=>clearTimeout(_)},[F,n,Z,se]),c.useEffect(()=>{if(!F||T!=="malformed")return;const _=document.getElementById("initial-loading");_&&(_.textContent="Desktop startup failed — please restart the app.")},[F,T]),c.useEffect(()=>{if(F)return;const _=setTimeout(()=>{const re=document.getElementById("initial-loading");re&&!n&&(re.classList.add("fade-out"),setTimeout(()=>{re.remove()},300))},5e3);return()=>clearTimeout(_)},[F,n]),c.useEffect(()=>{let _=!1;return(async()=>{const me=await ds("/health",{method:"GET"}).catch(()=>null);if(!me||!me.ok||_)return;const de=await me.json().catch(()=>null);if(!de||_)return;const ge=de.planModeExperimentalEnabled;O(ge===!0||ge===1||ge==="1"||ge==="true")})(),()=>{_=!0}},[O]),c.useEffect(()=>{f||e()},[e,f]),c.useEffect(()=>{if(f||n)return;let _=!0,re,me=0;const de=10,ge=1e3,Te=async()=>{if(!_)return;if(me>=de){C(!0);return}const be=Gt.getState();if(be.isInitialized){C(!1);return}me+=1,await be.initializeApp();const Re=Gt.getState();if(!_)return;if(Re.isInitialized){C(!1);return}if(me>=de){C(!0);return}const we=Math.min(ge*Math.pow(2,me-1),16e3);re=setTimeout(Te,we)};return re=setTimeout(Te,ge),()=>{_=!1,re&&clearTimeout(re)}},[j,n,f]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!N)return;const _=document.getElementById("initial-loading");_&&(_.classList.add("fade-out"),setTimeout(()=>{_.remove()},300))},[N]),c.useEffect(()=>{if(f||!r||i>0&&o>0)return;let _=!0,re=0;const me=15,de=async()=>{const Te=Gt.getState();if(!(Te.providers.length>0&&Te.agents.length>0))try{Te.providers.length===0&&await l({source:"startupRecovery"}),Gt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};de();const ge=setInterval(()=>{if(_){if(++re>=me){clearInterval(ge);return}de()}},2e3);return()=>{_=!1,clearInterval(ge)}},[r,f,a,l,i,o]),c.useEffect(()=>{p||f||r&&qs.setDirectory(h)},[h,p,r,f]),c.useEffect(()=>{if(!q||typeof window>"u")return;const _=de=>{S(de?.visible===!0)},re=de=>{if(de.origin!==window.location.origin||de.source!==window.parent)return;const ge=de.data;ge?.type===mu&&_(ge.payload)},me=window;return me.__aiworkerSetEmbeddedVisibility=_,window.addEventListener("message",re),Ug(),()=>{window.removeEventListener("message",re),me.__aiworkerSetEmbeddedVisibility===_&&delete me.__aiworkerSetEmbeddedVisibility}},[q]),c.useEffect(()=>{!q?.directory||f||h!==q.directory&&m(q.directory,{showOverlay:!1})},[h,q,f,m]),c.useEffect(()=>{if(!q||typeof window>"u")return;const _=re=>{re.storageArea===window.localStorage&&re.key==="ui-store"&&De.persist.rehydrate()};return window.addEventListener("storage",_),()=>{window.removeEventListener("storage",_)}},[q]),c.useEffect(()=>{if(typeof window>"u")return;const _=re=>{const me=re.detail,de=typeof me?.sessionId=="string"?me.sessionId.trim():"";if(!de)return;const ge=typeof me?.directory=="string"&&me.directory.trim().length>0?me.directory.trim():null;Je.getState().setCurrentSession(de,ge)};return window.addEventListener("aiworker:open-session",_),()=>window.removeEventListener("aiworker:open-session",_)},[]),c.useEffect(()=>{if(typeof window>"u")return;const _=()=>{En("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("aiworker:open-mini-chat",_),()=>window.removeEventListener("aiworker:open-mini-chat",_)},[]),c.useEffect(()=>{if(typeof window>"u")return;const _=()=>{const re=Je.getState().currentSessionId;re&&Dd(re)};return window.addEventListener("focus",_),()=>window.removeEventListener("focus",_)},[]),c.useEffect(()=>{if(typeof window>"u")return;const _=re=>{const me=re.detail,de=typeof me?.directory=="string"&&me.directory.trim().length>0?me.directory.trim():null,ge=typeof me?.projectId=="string"&&me.projectId.trim().length>0?me.projectId.trim():null,Te=!!(de||ge);De.getState().setSessionSwitcherOpen(!1),Je.getState().openNewSessionDraft({target:Te?"project":"chat",selectedProjectId:Te?ge:null,directoryOverride:Te?de:null,preserveDirectoryOverride:!!de})};return window.addEventListener("aiworker:open-draft-session",_),()=>window.removeEventListener("aiworker:open-draft-session",_)},[]),c.useEffect(()=>{typeof window>"u"||!n||p||Q.current||(Q.current=!0,window.__aiworkerAppReady=!0,window.dispatchEvent(new Event("aiworker:app-ready")))},[n,p]),Dp({enabled:te}),CC({enabled:te}),DC(h||null),TC(),Pp(),Vp(),vg();const fe=c.useCallback(()=>{w(_=>!_)},[]);rC(fe),gC(),yC(!q),c.useEffect(()=>{if(q)return;const _=()=>w(re=>!re);return window.addEventListener("aiworker:memory-debug-toggle",_),()=>window.removeEventListener("aiworker:memory-debug-toggle",_)},[q]),c.useEffect(()=>{q||u&&setTimeout(()=>d(),5e3)},[d,q,u]),c.useEffect(()=>{if(!F||T!=="not-injected")return;let _=!1,re=0;const me=200,de=2e3,ge=50,Te=()=>{if(_)return;re++;const be=Ga();if(be!=="not-injected"){if(_=!0,k(be),be==="valid"){const we=qa();we&&L(Qa({isDesktopShell:!0,bootOutcome:we}))}return}const Re=Math.min(me*Math.pow(1.1,re),de);if(re>=ge){const we=document.getElementById("initial-loading");we&&!we.textContent?.includes("taking longer")&&(we.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Te,Re)};return window.setTimeout(Te,me),()=>{_=!0}},[F,T]);const B=c.useCallback(async()=>{if(hm({isDesktopShell:xn(),isDesktopLocalOriginActive:$o()})){await pm();return}window.location.reload()},[]),ne=c.useCallback(async()=>{if(!M){C(!1),z(!0);try{await Gt.getState().initializeApp()}finally{z(!1)}Gt.getState().isInitialized||A(_=>_+1)}},[M]),ye=_=>{if(_.screen==="recovery")return _.variant};if(F&&D&&D.screen!=="main"){if(D.screen==="chooser")return s.jsx(Hs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(sd,{mode:"first-launch",localAvailable:D.localAvailable!==!1,onCliAvailable:B,onChooseRemote:()=>{}})})})});const _=ye(D),re=D.screen==="recovery"&&"url"in D?D.url:void 0;return s.jsx(Hs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(sd,{mode:"recovery",recoveryVariant:_,recoveryHostUrl:re,recoveryHostLabel:void 0,localAvailable:D.localAvailable!==!1,onCliAvailable:B})})})})}if(q)return s.jsx(Hs,{children:s.jsx(ml,{sdk:qs.getSdkClient(),directory:h||"",children:s.jsx(hl,{apis:t,children:s.jsx(Ii,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(LC,{embeddedSessionChat:q,isVSCodeRuntime:f,embeddedBackgroundWorkEnabled:te}),s.jsx(pl,{}),s.jsx(gl,{})]})})})},P)});if(ae)return s.jsx(Hs,{children:s.jsx(MC,{})});if(N&&!n&&!f&&!q)return s.jsx(Hs,{children:s.jsx(FC,{onRetry:()=>{ne()},isRetrying:M})});const ce=!n&&!F;return s.jsx(Hs,{children:s.jsx(ml,{sdk:qs.getSdkClient(),directory:h||"",children:s.jsx(hl,{apis:t,children:s.jsx(N4,{children:s.jsx(Ii,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:F?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Gd,{embeddedBackgroundWorkEnabled:te}),s.jsx(ru,{}),s.jsx(r4,{}),s.jsx(qd,{}),s.jsx(pl,{}),s.jsx(gl,{}),!ce&&s.jsxs(s.Fragment,{children:[s.jsx(jg,{}),s.jsx(OC,{}),g&&s.jsx(B4,{onClose:()=>w(!1)})]})]})})})})},P)})}function WC(t){return t.isAboutDialogOpen}function zC(t){return t.setAboutDialogOpen}function VC(t){return t.currentDirectory}function UC(t){return t.currentSessionId}function KC(t){return t.setCurrentSession}const HC=typeof window<"u"&&window.__AIWORKER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Tp();gm().then(()=>{Promise.all([xm(),Rp()]).catch(t=>{console.error("[main] settings init failed:",t)}),Ep(),Mp(),Op()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Af=document.getElementById("root");if(!Af)throw new Error("Root element not found");Fp();Lf.createRoot(Af).render(s.jsx(ht.StrictMode,{children:s.jsx(_p,{children:s.jsx(Bp,{children:s.jsx(Lp,{children:s.jsx($p,{children:s.jsx($C,{apis:HC})})})})})}));const d5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Nb as W,pb as a,c5 as b,Fu as g,d5 as m,Cb as u,Ou as v};
|